package org.ts.ddcs.DataSaveProcesser;

import com.alibaba.fastjson.JSONObject;
import org.ts.ddcs.DataTemplate.DataTemplateInterface;
import org.ts.ddcs.Entity.CommandEntity;
import org.ts.ddcs.log.LogHelper;
import org.ts.ddcs.Tool.BytesHelp;
import org.ts.ddcs.Worker.DataProcess;
import org.ts.ddcs.Worker.DataProcessHolder;
import org.springframework.web.client.RestTemplate;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.Date;
import java.util.concurrent.LinkedBlockingQueue;

@SuppressWarnings("all")
public class DataSaveProcesserCF4 extends DataSaveProcesser {
    @Override
    public void Save(DataTemplateInterface dataTemplateInterface) {
        super.Save(dataTemplateInterface);
        String rtucode = BytesHelp.byte2HexStr(dataTemplateInterface.RtuCode());
        LogHelper.info("SAVE:"+dataTemplateInterface.GetFeture()+" "+rtucode);

        byte[] content = dataTemplateInterface.GetContent();
        byte[] packageIndexBuff = BytesHelp.subBytes(content, 8, 2);
        int packageIndex = BytesHelp.bytes2Int(packageIndexBuff, 0, 2);
        LogHelper.info("F4 " + packageIndex);
//        LinkedBlockingQueue<CommandEntity> datagramlist = DataProcessHolder.newInstance().dataProcess.relpayCommandToRtu.get(rtucode);
//        CommandEntity datagram = datagramlist.peek();
//        if (null != datagram) {
//            if (datagram.getKey().equals(Integer.toString(packageIndex))) {
//                datagramlist.poll();
//            }
//        }
      //  DataProcess.DownloadNotify(rtucode);

       // DataProcessHolder.newInstance().dataProcess.SubmitRelayManageTask(dataTemplateInterface);
    }
}
