//package com.base.biz.service;
//
//import com.alibaba.fastjson.JSONObject;
//import com.base.biz.model.dto.request.FzTaskBodyMqDTO;
//import com.base.biz.model.dto.request.FzTaskBodyMsgMqDTO;
//import com.base.biz.model.dto.request.FzTaskMqDTO;
//import com.base.biz.model.entity.FzTaskInfo;
//import com.base.biz.model.entity.PointInfo;
//import com.base.biz.mq.MqProducer;
//import com.base.orbit.mq.model.BaseHeadMqDTO;
//import com.base.orbit.mq.topics.TopicConst;
//import com.base.orbit.utils.DateUtils;
//import com.base.orbit.utils.IdGenerator;
//import org.apache.kafka.clients.consumer.ConsumerRecord;
//import org.apache.kafka.clients.consumer.ConsumerRecords;
//import org.apache.kafka.clients.consumer.KafkaConsumer;
//import org.apache.kafka.common.serialization.StringDeserializer;
//import org.junit.Test;
//import org.junit.runner.RunWith;
//import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.test.context.junit4.SpringRunner;
//
//import javax.annotation.Resource;
//import java.time.Duration;
//import java.util.*;
//
//
//@RunWith(SpringRunner.class)
//@SpringBootTest
//public class MqTest {
//
//    @Resource
//    MqProducer mqProducer;
//
//    @Resource
//    PointService pointService;
//
//    @Test
//    public void test() {
//        Properties properties = new Properties();
//        properties.setProperty("bootstrap.servers", "127.0.0.1:9092");
//        properties.setProperty("group.id", "xxx");
//        properties.setProperty("key.deserializer", StringDeserializer.class.getName()); //  消息格式均为byte[]数组，key和value需要进行反序列化
//        properties.setProperty("value.deserializer", StringDeserializer.class.getName());
//        properties.setProperty("enable.auto.commit", "true");
//        properties.setProperty("auto.commit.interval.ms", "1000");
//        properties.setProperty("auto.offset.reset", "earliest");
//
//        KafkaConsumer<String, String> consumer = new KafkaConsumer<>(properties);
//
//        consumer.subscribe(Arrays.asList(TopicConst.BASE_TOPIC));
//
//        while (true) {
//            ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(500));
//
//            for (ConsumerRecord<String, String> record : records) {
//                System.out.println("~~~~~~~~~" + record);
//            }
//        }
//    }
//
//    /**
//     * 测试发送仿真调度指令
//     */
//    @Test
//    public void sendFzTask() {
////        FzTaskMqDTO fzTaskMqDTO = new FzTaskMqDTO();
////
////        //  消息头
////        BaseHeadMqDTO messageHeader = new BaseHeadMqDTO();
////        String createTime = DateUtils.dateTimeNow();
////        messageHeader.setCreationTime(createTime);
////        messageHeader.setOriginator("JCPT");
////        messageHeader.setRecipient("YKSC");
////        messageHeader.setMessageType("FZDD");
////        messageHeader.setMessageId(messageHeader.getMessageType() + "_" + messageHeader.getOriginator() + "_" + messageHeader.getCreationTime());
////
////        //  消息体
////        FzTaskBodyMqDTO messageBody = new FzTaskBodyMqDTO();
////        List<FzTaskBodyMsgMqDTO> requireList = new ArrayList<>();
////        FzTaskBodyMsgMqDTO fzTaskBodyMsgMqDTO = new FzTaskBodyMsgMqDTO();
////        fzTaskBodyMsgMqDTO.setReqID("9088");
////        fzTaskBodyMsgMqDTO.setReqName("测试kafka");
////        fzTaskBodyMsgMqDTO.setReqSrc("自测");
////        fzTaskBodyMsgMqDTO.setReqTime("2023-05-23 13:51:51");
////        fzTaskBodyMsgMqDTO.setScoutType("111");
////        fzTaskBodyMsgMqDTO.setIsEmergency("TRUE");
////        fzTaskBodyMsgMqDTO.setIsStarcalibration("TRUE");
////        fzTaskBodyMsgMqDTO.setIsOnboar("TRUE");
////        fzTaskBodyMsgMqDTO.setIsPrecise("TRUE");
////        fzTaskBodyMsgMqDTO.setIsEmcon("TRUE");
////        fzTaskBodyMsgMqDTO.setCountryName("China");
////        fzTaskBodyMsgMqDTO.setTargetID("1992");
////        fzTaskBodyMsgMqDTO.setTargetName("target-1992");
////        fzTaskBodyMsgMqDTO.setReqStartTime("2023-02-05 00:00:00");
////        fzTaskBodyMsgMqDTO.setReqEndTime("2023-02-06 00:00:00");
////        fzTaskBodyMsgMqDTO.setPriority("999");
////
////        requireList.add(fzTaskBodyMsgMqDTO);
////        messageBody.setReqCount(1);
////        messageBody.setRequireList(requireList);
////        messageBody.setTaskId("2c918086886740fb0188679bc246000c");
////
////        //  赋值对象
////        fzTaskMqDTO.setMessageHeader(messageHeader);
////        fzTaskMqDTO.setBody(messageBody);
//
////          发送报文
////        String str = JSONObject.toJSONString(fzTaskMqDTO);
//
//        String str = "{\"messageType\":\"SCOUTREQ\",\"creationTime\":\"20230529210401\",\"recipient\":\"YKSC\",\"messageId\":\"SCOUTREQ_JCPT_20230529210401\",\"originator\":\"JCPT\",\"body\":\"{\\\"reqCount\\\":\\\"1\\\",\\\"requireList\\\":\\\"[{\\\\\\\"centerLocation\\\\\\\":\\\\\\\"33,23;55,55;66,66;44,55\\\\\\\",\\\\\\\"countryName\\\\\\\":\\\\\\\"China\\\\\\\",\\\\\\\"isEmcon\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"isEmergency\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"isOnboard\\\\\\\":\\\\\\\"0\\\\\\\",\\\\\\\"isPrecise\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"isStarcalibration\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"pitchAngle\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"priority\\\\\\\":\\\\\\\"999\\\\\\\",\\\\\\\"productDest\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"productLevel\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"receivingEndTime\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"receivingStartTime\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"receivingStation\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"reqEndTime\\\\\\\":1675612800000,\\\\\\\"reqGroup\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"reqID\\\\\\\":\\\\\\\"9066\\\\\\\",\\\\\\\"reqInterval\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"reqName\\\\\\\":\\\\\\\"0529测试\\\\\\\",\\\\\\\"reqSrc\\\\\\\":\\\\\\\"11\\\\\\\",\\\\\\\"reqStartTime\\\\\\\":1675526400000,\\\\\\\"reqTime\\\\\\\":1685365409000,\\\\\\\"reqTimes\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"reqUnit\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"resolution\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"satellite\\\\\\\":\\\\\\\"YH3A-01\\\\\\\",\\\\\\\"scoutType\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"sensorID\\\\\\\":\\\\\\\"SAR\\\\\\\",\\\\\\\"sensorMode\\\\\\\":\\\\\\\"1\\\\\\\",\\\\\\\"targetID\\\\\\\":\\\\\\\"ee\\\\\\\",\\\\\\\"targetName\\\\\\\":\\\\\\\"安安\\\\\\\",\\\\\\\"targetPreprocess\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"workMode\\\\\\\":\\\\\\\"\\\\\\\"}]\\\",\\\"taskId\\\":\\\"2c918086886740fb0188679bc246000c\\\"}\"}";
//        try {
//            mqProducer.push(TopicConst.FZ_TASK_TOPIC, "xj", str);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
//
//    @Test
//    public void buildBaseInfo() {
//        String str = "{\"messageHeader\": \"{\\\"messageType\\\":\\\"JCFW\\\",\\\"creationTime\\\":\\\"20230524194848\\\",\\\"recipient\\\":\\\"YKSC\\\",\\\"messageId\\\":\\\"JCFW_JCPT_20230524194848\\\",\\\"originator\\\":\\\"JCPT\\\"}\",\"messageBody\": \"{\\\"txBaseMsg\\\":\\\"[{\\\\\\\"creatTime\\\\\\\":\\\\\\\"20230524194848\\\\\\\",\\\\\\\"dmzGT\\\\\\\":\\\\\\\"dmzGT\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"jsjhfs\\\\\\\":\\\\\\\"sss\\\\\\\",\\\\\\\"jspd\\\\\\\":\\\\\\\"dddd\\\\\\\",\\\\\\\"msl\\\\\\\":\\\\\\\"tt\\\\\\\",\\\\\\\"operationNum\\\\\\\":\\\\\\\"3\\\\\\\",\\\\\\\"rwzdqhsj\\\\\\\":\\\\\\\"abbc\\\\\\\",\\\\\\\"sczdh\\\\\\\":\\\\\\\"sdsds\\\\\\\",\\\\\\\"txkj\\\\\\\":\\\\\\\"txkj\\\\\\\",\\\\\\\"updateTime\\\\\\\":\\\\\\\"20230524194848\\\\\\\",\\\\\\\"zbpl\\\\\\\":\\\\\\\"test\\\\\\\",\\\\\\\"zxgzyj\\\\\\\":\\\\\\\"sddsdsd\\\\\\\",\\\\\\\"zxjsyj\\\\\\\":\\\\\\\"sdd\\\\\\\"}]\\\",\\\"dmzBaseMsg\\\":\\\"[]\\\",\\\"wxInstanceBaseMsg\\\":\\\"[]\\\",\\\"wxBaseMsg\\\":\\\"[]\\\"}\"}";
//        try {
//            mqProducer.push(TopicConst.BASE_TOPIC, "xj", str);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
//
//    @Test
//    public void build(){
//          String str = "{\"messageHeader\": \"{\\\"messageType\\\":\\\"JCFW\\\",\\\"creationTime\\\":\\\"20230524194848\\\",\\\"recipient\\\":\\\"YKSC\\\",\\\"messageId\\\":\\\"JCFW_JCPT_20230524194848\\\",\\\"originator\\\":\\\"JCPT\\\"}\",\"messageBody\": \"{\\\"txBaseMsg\\\":\\\"[{\\\\\\\"creatTime\\\\\\\":\\\\\\\"20230524194848\\\\\\\",\\\\\\\"dmzGT\\\\\\\":\\\\\\\"dmzGT\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"jsjhfs\\\\\\\":\\\\\\\"sss\\\\\\\",\\\\\\\"jspd\\\\\\\":\\\\\\\"dddd\\\\\\\",\\\\\\\"msl\\\\\\\":\\\\\\\"tt\\\\\\\",\\\\\\\"operationNum\\\\\\\":\\\\\\\"3\\\\\\\",\\\\\\\"rwzdqhsj\\\\\\\":\\\\\\\"abbc\\\\\\\",\\\\\\\"sczdh\\\\\\\":\\\\\\\"sdsds\\\\\\\",\\\\\\\"txkj\\\\\\\":\\\\\\\"txkj\\\\\\\",\\\\\\\"updateTime\\\\\\\":\\\\\\\"20230524194848\\\\\\\",\\\\\\\"zbpl\\\\\\\":\\\\\\\"test\\\\\\\",\\\\\\\"zxgzyj\\\\\\\":\\\\\\\"sddsdsd\\\\\\\",\\\\\\\"zxjsyj\\\\\\\":\\\\\\\"sdd\\\\\\\"}]\\\",\\\"dmzBaseMsg\\\":\\\"[]\\\",\\\"wxInstanceBaseMsg\\\":\\\"[]\\\",\\\"wxBaseMsg\\\":\\\"[]\\\"}\"}";
////        String str = "{\"messageHeader\": \"{\\\"messageType\\\":\\\"JCFW\\\",\\\"creationTime\\\":\\\"20230524194848\\\",\\\"recipient\\\":\\\"YKSC\\\",\\\"messageId\\\":\\\"JCFW_JCPT_20230524194848\\\",\\\"originator\\\":\\\"JCPT\\\"}\",\"messageBody\": \"{\\\"txBaseMsg\\\":\\\"[{\\\\\\\"creatTime\\\\\\\":\\\\\\\"20230524194848\\\\\\\",\\\\\\\"dmzGT\\\\\\\":\\\\\\\"dmzGT\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"jsjhfs\\\\\\\":\\\\\\\"sss\\\\\\\",\\\\\\\"jspd\\\\\\\":\\\\\\\"dddd\\\\\\\",\\\\\\\"msl\\\\\\\":\\\\\\\"tt\\\\\\\",\\\\\\\"operationNum\\\\\\\":\\\\\\\"3\\\\\\\",\\\\\\\"rwzdqhsj\\\\\\\":\\\\\\\"abbc\\\\\\\",\\\\\\\"sczdh\\\\\\\":\\\\\\\"sdsds\\\\\\\",\\\\\\\"txkj\\\\\\\":\\\\\\\"txkj\\\\\\\",\\\\\\\"updateTime\\\\\\\":\\\\\\\"20230524194848\\\\\\\",\\\\\\\"zbpl\\\\\\\":\\\\\\\"test\\\\\\\",\\\\\\\"zxgzyj\\\\\\\":\\\\\\\"sddsdsd\\\\\\\",\\\\\\\"zxjsyj\\\\\\\":\\\\\\\"sdd\\\\\\\"}]\\\",\\\"dmzBaseMsg\\\":\\\"[]\\\",\\\"wxInstanceBaseMsg\\\":\\\"[]\\\",\\\"wxBaseMsg\\\":\\\"[]\\\"}\"}";
//        JSONObject obj = JSONObject.parseObject(str);
//        System.out.println(obj.getJSONObject("messageHeader"));
//    }
//
//    @Test
//    public void buildPoint() {
//
//        FzTaskInfo fzTaskInfo = new FzTaskInfo();
//        fzTaskInfo.setCenterLocation("11,23;34,32;34,45;32,43");
//        fzTaskInfo.setId("111111");
//        //  区域对应的范围
//        String centerLocation = fzTaskInfo.getCenterLocation();
//        String[] strArray = centerLocation.split(";");
//        List<String> arrayList = new ArrayList<>(strArray.length);
//        Collections.addAll(arrayList, strArray);
//        List<PointInfo> pointInfos = new ArrayList<>();
//
//        for (int i = 0; i < arrayList.size(); i++) {
//            String[] str = arrayList.get(i).split(",");
//            PointInfo pointInfo = new PointInfo();
//            pointInfo.setId(IdGenerator.getStrId());
//            pointInfo.setLongitude(str[0]);
//            pointInfo.setLatitude(str[1]);
//            pointInfo.setSort("1");
//            pointInfo.setPointType("TARGET");
//            pointInfo.setParentId(fzTaskInfo.getId());
//            pointInfo.setCreateTime(DateUtils.getNowDate());
//            pointInfo.setSerial(i + "");
//            pointInfos.add(pointInfo);
//        }
//        pointService.saveBatch(pointInfos);
//    }
//
//
//    /**
//     * 测试发送
//     */
//    @Test
//    public void send(){
//
//    }
//}
