From 076112ac1d106e64e625c54f2fbb32dc0eafea42 Mon Sep 17 00:00:00 2001
From: cl <418351270@qq.com>
Date: 星期五, 28 六月 2024 08:20:01 +0800
Subject: [PATCH] 修改采集内容

---
 jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java |  518 ++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 326 insertions(+), 192 deletions(-)

diff --git a/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java b/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java
index 503c6ea..455e592 100644
--- a/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java
+++ b/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java
@@ -52,7 +52,7 @@
     public static MiloService miloService;
 
 
-    public IDaPassingStationCollectionService daPassingStationCollectionService;
+    public static IDaPassingStationCollectionService daPassingStationCollectionService;
 
     public static IDaCollectionParamConfService collectionParamConfService;
 
@@ -80,7 +80,7 @@
                              QingYanTestInfoService qingYanTestInfoService,
                              List<SendFactoryMes> sendFactoryMesList) {
         OPCUaSubscription.miloService = miloService;
-        this.daPassingStationCollectionService = daPassingStationCollectionService;
+        OPCUaSubscription.daPassingStationCollectionService = daPassingStationCollectionService;
         OPCUaSubscription.collectionParamConfService = collectionParamConfService;
         OPCUaSubscription.daParamCollectionService = daParamCollectionService;
         OPCUaSubscription.omProductionOrdeInfoService = omProductionOrdeInfoService;
@@ -103,7 +103,7 @@
                 String device = nodes[1];//璁惧
                 String tab = nodes[2];//鏍囪
                 String valueString = value.toString();//鍦板潃鍊�
-                if (Constants.RECORD_CHECK_CODE.equals(tab)){
+                if (Constants.RECORD_CHECK_CODE.equals(tab)){//鐢佃姱鏍¢獙
                     if (Constants.ONE.equals(valueString)){
                         Integer scanResult = 11;
                         if (Constants.OP010.equals(device) || Constants.OP030.equals(device)){
@@ -122,8 +122,24 @@
                         miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ScanerResult1").value(scanResult).build());
                         log.info("鍐欏叆鍒板伐浣峽}鐨凷canerResult1鏁版嵁锛歿}",device,scanResult);
                     }
-                }else if (Constants.RECORD_DATA.equals(tab)){
+                }else if (Constants.RECORD_SN.equals(tab)){//璇锋眰涓嬪彂妯$粍鐮�9
                     if (Constants.ONE.equals(valueString)){
+                        if (Constants.OP070.equals(device)){
+                            List<WorkOrder> orderList = workOrderService.list().stream()
+                                    .sorted(Comparator.comparing(WorkOrder::getCreateTime).reversed())
+                                    .collect(Collectors.toList());
+                            if (CollUtil.isNotEmpty(orderList)){
+                                String productNum = orderList.get(0).getProductNum();//妯$粍鐮�
+                                //OP070涓嬪彂浜у搧妯$粍鐮�
+                                miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ModuleCode").value(productNum).build());
+                                miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(1).build());
+                            }else{
+                                miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(2).build());//娌℃湁瑕佺敓浜х殑宸ュ崟
+                            }
+                        }
+                    }
+                }else if (Constants.RECORD_DATA.equals(tab)){//鍑哄叆绔�
+                    if (Constants.ONE.equals(valueString)){//鍏ョ珯
                         //1:鍛婄煡MES鎵樼洏宸插埌绔欙紝璇锋眰涓嬪彂杩涚珯鐘舵��
                         if (Constants.OP030.equals(device)){
                             //鍙嶉鐢佃姱ocv妫�娴嬬粨鏋�
@@ -139,18 +155,11 @@
                             miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build());
                             log.info("鍐欏叆鍒板伐浣峽}鐨凴ecordDataDone鏁版嵁锛歿}",device,11);
                         }
-                    }else if (Constants.TWO.equals(valueString)){
+                    }else if (Constants.TWO.equals(valueString)){//鍑虹珯
                         //鍒嗘010-065娈�
-                        List<String> PART1 = new ArrayList<>();
-                        PART1.add(Constants.OP020);
-                        PART1.add(Constants.OP030);
-                        PART1.add(Constants.OP040);
-                        PART1.add(Constants.OP050);
-                        PART1.add(Constants.OP060);
-                        PART1.add(Constants.OP065);
                         if (Constants.OP010.equals(device)){
                             //010宸ヤ綅鏃犺繃绔欒褰曪紝鍙粰鏀捐淇″彿
-                            List<SendFactoryMes> collect = sendFactoryMesList.stream().filter(x -> device.equals(x.getLocationCode())).collect(Collectors.toList());
+                            /*List<SendFactoryMes> collect = sendFactoryMesList.stream().filter(x -> device.equals(x.getLocationCode())).collect(Collectors.toList());
                             if (CollUtil.isNotEmpty(collect)){
                                 for (SendFactoryMes sendFactoryMes : collect) {
                                     ChildVO childVO = new ChildVO();
@@ -158,28 +167,35 @@
                                     childVO.setItemText(sendFactoryMes.getItemText());
                                     childVO.setItemType(sendFactoryMes.getItemType());
                                 }
-                            }
+                            }*/
                             miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(21).build());
                             log.info("鍐欏叆鍒板伐浣峽}鐨凴ecordDataDone鏁版嵁锛歿}",device,21);
-                        }else if (PART1.contains(device)){
-                            //020宸ヤ綅淇濆瓨杩囩珯璁板綍+鍙傛暟鏁版嵁
-                            List<DaPassingStationCollection> passingList = getDaPassingStationCollections(thoroughfare, device);
-                            if (CollUtil.isNotEmpty(passingList)){
-                                daPassingStationCollectionService.insertBatch(passingList);
+                        }else if (Constants.OP020_OP065.contains(device)){
+                            Integer result = 21;
+                            //璇诲彇鐢佃姱鐮�
+                            List<String> cellCodeList = readCellCodeList(thoroughfare, device);
+                            if(ObjectUtil.isNull(cellCodeList) && cellCodeList.size() != 4){
+                                result = 23;
+                                miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(23).build());
+                            }else{
+                                result = savePassingStation(thoroughfare, device,cellCodeList);//淇濆瓨杩囩珯
+                                if(result==21) {
+                                    result = saveParamCollection(thoroughfare, device,cellCodeList);//淇濆瓨鍙傛暟锛屽彂閫佸伐鍘侻ES
+                                }
                             }
-                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(21).build());
-                            log.info("鍐欏叆鍒板伐浣峽}鐨凴ecordDataDone鏁版嵁锛歿}",device,21);
+                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(result).build());
+                            log.info("鍐欏叆鍒板伐浣峽}鐨凴ecordDataDone鏁版嵁锛歿}",device,result);
                         } else if (Constants.OP100_1.equals(device) || Constants.OP100_2.equals(device)){
                             //涓嬪彂鍒荤爜淇℃伅-涓烘ā缁勭爜
-                            ProductOrderQuery query = new ProductOrderQuery();
+                            /*ProductOrderQuery query = new ProductOrderQuery();
                             query.setSiteCode("3983");
-                            query.setStationCode(device);
+                            query.setStationCode(device);*/
                             List<WorkOrder> collect = workOrderService.list().stream()
                                     .sorted(Comparator.comparing(WorkOrder::getCreateTime).reversed())
                                     .collect(Collectors.toList());
-                            if (CollUtil.isNotEmpty(collect)){
+                            /*if (CollUtil.isNotEmpty(collect)){
                                 query.setProductNum(collect.get(0).getProductNum());
-                            }
+                            }*/
 //                            ProductOrderVO vo = daPassingStationCollectionService.queryMessFromLine(query);
                             ProductOrderVO vo = new ProductOrderVO();
                             ProductOrderChild child = new ProductOrderChild();
@@ -289,16 +305,7 @@
                             log.info("鍐欏叆鍒板伐浣峽}鐨凴ecordDataDone鏁版嵁锛歿}",device,21);
                         }
                     }
-                } else if (Constants.RECORD_SN.equals(tab)){
-                    if (Constants.ONE.equals(valueString)){
-                        if (Constants.OP070.equals(device)){
-                            //OP070涓嬪彂浜у搧妯$粍鐮�
-                            String string = UUID.randomUUID().toString();
-                            miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ModuleCode").value(string).build());
-                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(1).build());
-                        }
-                    }
-                } else if (Constants.RECORD_CHECK_CODE_1.equals(tab)) {
+                }  else if (Constants.RECORD_CHECK_CODE_1.equals(tab)) {
                     if (Constants.OP100_1.equals(device)){
                         //閽㈠甫鏉$爜鏍¢獙--鍙戦�佺粰宸ュ巶mes
                         miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ScanerResult11").value(11).build());
@@ -314,193 +321,320 @@
         }
     }
 
+
+
     /**
-     * 淇濆瓨鐢佃姱杩囩珯璁板綍
+     * 璇诲彇鐢佃姱鐮�
      * @param thoroughfare 閫氶亾
      * @param device 宸ヤ綅
      * @return list
      * @throws Exception e
      */
-    private static List<DaPassingStationCollection> getDaPassingStationCollections(String thoroughfare, String device) throws Exception {
+    private static List<String> readCellCodeList(String thoroughfare, String device){
+        List<String> cellCodeList = new ArrayList<>();
+        //鐢佃姱鐮佸湴鍧�
         List<String> readList = new ArrayList<>();
         readList.add(thoroughfare + "." + device +".CellCode_1");
         readList.add(thoroughfare + "." + device +".CellCode_2");
         readList.add(thoroughfare + "." + device +".CellCode_3");
         readList.add(thoroughfare + "." + device +".CellCode_4");
-        List<String> keyCodeList = new ArrayList<>();
-        List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(readList);
-        List<DaPassingStationCollection> passingList = new ArrayList<>();
-        for (ReadWriteEntity readWriteEntity : readWriteEntityList) {
-            DaPassingStationCollection passingStationCollection = new DaPassingStationCollection();
-            passingStationCollection.setLocationCode(device);
-            passingStationCollection.setInboundTime(new Date());
-            if (ObjectUtil.isNotNull(readWriteEntity.getValue())){
-                passingStationCollection.setKeyCode(readWriteEntity.getValue().toString());
-                keyCodeList.add(readWriteEntity.getValue().toString());
+        try {
+            List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(readList);//鐢佃姱鐮�
+            for (ReadWriteEntity readWriteEntity : readWriteEntityList) {
+                if (ObjectUtil.isNotNull(readWriteEntity.getValue())){
+                    cellCodeList.add(readWriteEntity.getValue().toString());//灏佽鐢佃姱鐮�
+                }
             }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        return cellCodeList;
+    }
+
+    /**
+     * 淇濆瓨杩囩珯鏁版嵁
+     * @param thoroughfare 閫氶亾
+     * @param device 宸ヤ綅
+     * @param cellCodeList 鐢佃姱鐮侀泦鍚�
+     * @return list
+     * @throws Exception e
+     */
+    private static Integer savePassingStation(String thoroughfare, String device,List<String> cellCodeList){
+        Integer result = 21;
+
+        try {
+            //璇昏繘绔欐椂闂�
+            Date startTime = new Date();
+            ReadWriteEntity startTimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StartTime");//杩涚珯鏃堕棿
+            if (ObjectUtil.isNotNull(startTimeRead.getValue())){
+                String stringStartTime = startTimeRead.getValue().toString();
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+                startTime = sdf.parse(stringStartTime);
+            }else{
+                result = 23;
+                log.info("璇诲彇鍒板伐浣峽}鐨凷tartTime鏁版嵁锛歿},杩斿洖RecordDataDone鐨勫�间负{}",device,"IS NULL锛�",result);
+            }
+
+            //璇诲伐绔欑姸鎬�
             String stationStatus = Constants.PASS;
-            ReadWriteEntity stationStatusRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StationStatus");
+            ReadWriteEntity stationStatusRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StationStatus");//绔欑姸鎬佸湴鍧�
             if (ObjectUtil.isNotNull(stationStatusRead.getValue())){
                 String string = stationStatusRead.getValue().toString();
                 if (Constants.TWO.equals(string)){
                     stationStatus = Constants.UN_PASS;
                 }
+            }else{
+                result = 23;
+                log.info("璇诲彇鍒板伐浣峽}StationStatuss鏁版嵁锛歿},杩斿洖RecordDataDone鐨勫�间负{}",device,"IS NULL锛�",result);
             }
-            passingStationCollection.setOutRsSign(stationStatus);
-            passingStationCollection.setCreateTime(new Date());
-            passingList.add(passingStationCollection);
+
+            List<DaPassingStationCollection> passingList = new ArrayList<>();
+            for (String cellCode : cellCodeList) {
+                DaPassingStationCollection passingStationCollection = new DaPassingStationCollection();
+                if (ObjectUtil.isNotNull(cellCode)){
+                    passingStationCollection.setKeyCode(cellCode);//鐢佃姱鐮�
+                    passingStationCollection.setLocationCode(device);//宸ヤ綅
+                    passingStationCollection.setInboundTime(startTime);//杩涚珯鏃堕棿
+                    passingStationCollection.setOutboundTime(new Date());//鍑虹珯鏃堕棿
+                    passingStationCollection.setOutRsSign(stationStatus);//绔欑姸鎬佸��
+                    passingStationCollection.setCollectionTime(new Date());//閲囬泦鏃堕棿
+                    passingList.add(passingStationCollection);
+                }else{
+                    result = 23;
+                    log.info("璇诲彇鍒板伐浣峽}CellCode鏁版嵁锛歿},杩斿洖RecordDataDone鐨勫�间负{}",device,"IS NULL锛�",result);
+                }
+            }
+
+            if (CollUtil.isNotEmpty(passingList)){
+                daPassingStationCollectionService.insertBatch(passingList);//瀛樺偍杩囩珯閲囬泦鏁版嵁
+            }
+
+        } catch (Exception e) {
+            throw new RuntimeException(e);
         }
-        //鍙傛暟閲囬泦
-        //淇濆瓨鍙傛暟閲囬泦鏁版嵁
-        List<DaCollectionParamConf> list = collectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>()
-                .eq(DaCollectionParamConf::getProcessesCode, device)
-                .eq(DaCollectionParamConf::getRemarks, Constants.ONE));
-        if (CollUtil.isNotEmpty(list)){
-            List<DaParamCollection> saveParamList = new ArrayList<>();
-            List<DaCollectionParamConf> confColl1 = list.stream().filter(x -> Constants.INT_ONE.equals(x.getKeyNum())).collect(Collectors.toList());
-            List<DaCollectionParamConf> confColl2 = list.stream().filter(x -> Constants.INT_TWO.equals(x.getKeyNum())).collect(Collectors.toList());
-            List<DaCollectionParamConf> confColl3 = list.stream().filter(x -> Constants.INT_THREE.equals(x.getKeyNum())).collect(Collectors.toList());
-            List<DaCollectionParamConf> confColl4 = list.stream().filter(x -> Constants.INT_FOUR.equals(x.getKeyNum())).collect(Collectors.toList());
-            List<DaCollectionParamConf> confColl0 = list.stream().filter(x -> Constants.INT_ZERO.equals(x.getKeyNum())).collect(Collectors.toList());
-            List<String> collect1 = confColl1.stream().map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList());
-            List<ReadWriteEntity> paramCollectionList1 = miloService.readFromOpcUa(collect1);
-            List<String> collect2 = confColl2.stream()
-                    .map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList());
-            List<ReadWriteEntity> paramCollectionList2 = miloService.readFromOpcUa(collect2);
-            List<String> collect3 = confColl3.stream()
-                    .map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList());
-            List<ReadWriteEntity> paramCollectionList3 = miloService.readFromOpcUa(collect3);
-            List<String> collect4 = confColl4.stream()
-                    .map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList());
-            List<ReadWriteEntity> paramCollectionList4 = miloService.readFromOpcUa(collect4);
-            List<String> collect0 = confColl0.stream()
-                    .map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList());
-            List<ReadWriteEntity> paramCollectionList0 = miloService.readFromOpcUa(collect0);
 
+        return result;
+    }
 
-            if (CollUtil.isNotEmpty(paramCollectionList1)){
-                List<ChildVO> checkList = new ArrayList<>();
-                for (int i = 0; i < paramCollectionList1.size(); i++) {
-                    DaParamCollection daParamCollection = new DaParamCollection();
-                    if (CollUtil.isNotEmpty(keyCodeList) && keyCodeList.size() == 4){
-                        daParamCollection.setKeyCode(keyCodeList.get(0));
-                    }
+    /**
+     * 淇濆瓨鐢佃姱杩囩珯璁板綍
+     * @param thoroughfare 閫氶亾
+     * @param device 宸ヤ綅
+     * @param cellCodeList 鐢佃姱鐮侀泦鍚�
+     * @return list
+     * @throws Exception e
+     */
+    private static Integer saveParamCollection(String thoroughfare, String device,List<String> cellCodeList){
+        Integer result = 21;//杩斿洖缁撴灉
+        List<List<ChildVO>> mesList = new ArrayList<>();//瀛樺偍4涓數鑺殑鍙戦�佺粰MES鐨勫��
 
-                    daParamCollection.setParamCode(paramCollectionList1.get(i).getIdentifier());
-                    String paramValue = "";
-                    if (ObjectUtil.isNotNull(paramCollectionList1.get(i).getValue())){
-                        paramValue = paramCollectionList1.get(i).getValue().toString();
-                    }
-                    daParamCollection.setParamValue(paramValue);
-                    daParamCollection.setLocationCode(device);
-                    daParamCollection.setCollectionTime(new Date());
-                    saveParamList.add(daParamCollection);
-                    ChildVO childVO = new ChildVO();
-                    childVO.setItemCode(confColl1.get(i).getCollectParameterName());
-                    childVO.setItemType(confColl1.get(i).getItemType());
-                    childVO.setItemValue(paramValue);
-                    childVO.setItemText(confColl1.get(i).getParameterSetName());
-                    childVO.setCheckResult("1");
-                    childVO.setCheckTime(new Date().toString());
-                    checkList.add(childVO);
-                }
-                //涓婁紶鍒板伐鍘俶es
-                ParentVO vo = new ParentVO();
-                vo.setStationCode(device);
-                vo.setCheckList(checkList);
-                vo.setSiteCode("3983");
-                vo.setRecordId(UUID.randomUUID().toString());
-                vo.setTotalResult("1");
-                if (CollUtil.isNotEmpty(keyCodeList) && keyCodeList.size() == 4){
-                    vo.setProductNum(keyCodeList.get(0));
-                }
-                try{
-                    CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> {
-                        log.info("寮�濮嬫墽琛屽紓姝ユ柟娉�");
-                        HttpResponse execute = HttpRequest.post(orderLineUrl).body(JSONUtil.toJsonStr(vo)).execute();
-                        System.out.println(execute.body());
-                        log.info("寮傛鏂规硶鎵ц缁撴潫");
-                    });
-                }catch (Exception e){
-                    System.out.println(e.getMessage());
-                }
-            }
-            if (CollUtil.isNotEmpty(paramCollectionList2)){
-                for (int i = 0; i < paramCollectionList2.size(); i++) {
-                    DaParamCollection daParamCollection = new DaParamCollection();
-                    if (CollUtil.isNotEmpty(keyCodeList) && keyCodeList.size() == 4){
-                        daParamCollection.setKeyCode(keyCodeList.get(1));
-                    }
+        try {
+            //鏌ヨ鍙傛暟閰嶇疆琛�
+            List<DaCollectionParamConf> list = collectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>()
+                    .eq(DaCollectionParamConf::getProcessesCode, device)//宸ヤ綅
+                    .eq(DaCollectionParamConf::getRemarks, Constants.ONE));//绫诲瀷
+            if (CollUtil.isNotEmpty(list)) {
+                List<DaParamCollection> saveParamList = new ArrayList<>();//灏佽鍙傛暟閲囬泦list
+                List<DaCollectionParamConf> confColl1 = list.stream().filter(x -> Constants.INT_ONE.equals(x.getKeyNum())).collect(Collectors.toList());
+                List<DaCollectionParamConf> confColl2 = list.stream().filter(x -> Constants.INT_TWO.equals(x.getKeyNum())).collect(Collectors.toList());
+                List<DaCollectionParamConf> confColl3 = list.stream().filter(x -> Constants.INT_THREE.equals(x.getKeyNum())).collect(Collectors.toList());
+                List<DaCollectionParamConf> confColl4 = list.stream().filter(x -> Constants.INT_FOUR.equals(x.getKeyNum())).collect(Collectors.toList());
+                List<DaCollectionParamConf> confColl0 = list.stream().filter(x -> Constants.INT_ZERO.equals(x.getKeyNum())).collect(Collectors.toList());
 
-                    daParamCollection.setParamCode(paramCollectionList2.get(i).getIdentifier());
-                    String paramValue = "";
-                    if (ObjectUtil.isNotNull(paramCollectionList2.get(i).getValue())){
-                        paramValue = paramCollectionList2.get(i).getValue().toString();
-                    }
-                    daParamCollection.setParamValue(paramValue);
-                    daParamCollection.setLocationCode(device);
-                    daParamCollection.setCollectionTime(new Date());
-                    saveParamList.add(daParamCollection);
-                }
-            }
-            if (CollUtil.isNotEmpty(paramCollectionList3)){
-                for (int i = 0; i < paramCollectionList3.size(); i++) {
-                    DaParamCollection daParamCollection = new DaParamCollection();
-                    if (CollUtil.isNotEmpty(keyCodeList) && keyCodeList.size() == 4){
-                        daParamCollection.setKeyCode(keyCodeList.get(2));
-                    }
+                List<String> collect1 = confColl1.stream()
+                        .map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList());
+                List<ReadWriteEntity> paramCollectionList1 = miloService.readFromOpcUa(collect1);//鐢佃姱1 鍙傛暟鍊�
 
-                    daParamCollection.setParamCode(paramCollectionList3.get(i).getIdentifier());
-                    String paramValue = "";
-                    if (ObjectUtil.isNotNull(paramCollectionList3.get(i).getValue())){
-                        paramValue = paramCollectionList3.get(i).getValue().toString();
-                    }
-                    daParamCollection.setParamValue(paramValue);
-                    daParamCollection.setLocationCode(device);
-                    daParamCollection.setCollectionTime(new Date());
-                    saveParamList.add(daParamCollection);
-                }
-            }
-            if (CollUtil.isNotEmpty(paramCollectionList4)){
-                for (int i = 0; i < paramCollectionList4.size(); i++) {
-                    DaParamCollection daParamCollection = new DaParamCollection();
-                    if (CollUtil.isNotEmpty(keyCodeList) && keyCodeList.size() == 4){
-                        daParamCollection.setKeyCode(keyCodeList.get(3));
-                    }
+                List<String> collect2 = confColl2.stream()
+                        .map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList());
+                List<ReadWriteEntity> paramCollectionList2 = miloService.readFromOpcUa(collect2);//鐢佃姱2 鍙傛暟鍊�
 
-                    daParamCollection.setParamCode(paramCollectionList4.get(i).getIdentifier());
-                    String paramValue = "";
-                    if (ObjectUtil.isNotNull(paramCollectionList4.get(i).getValue())){
-                        paramValue = paramCollectionList4.get(i).getValue().toString();
-                    }
-                    daParamCollection.setParamValue(paramValue);
-                    daParamCollection.setLocationCode(device);
-                    daParamCollection.setCollectionTime(new Date());
-                    saveParamList.add(daParamCollection);
-                }
-            }
-            if (CollUtil.isNotEmpty(paramCollectionList0)){
-                for (int i = 0; i < paramCollectionList0.size(); i++) {
-                    if (CollUtil.isNotEmpty(keyCodeList) && keyCodeList.size() == 4){
-                        for (String s : keyCodeList) {
-                            DaParamCollection daParamCollection = new DaParamCollection();
-                            daParamCollection.setKeyCode(s);
-                            daParamCollection.setParamCode(paramCollectionList0.get(i).getIdentifier());
-                            String paramValue = "";
-                            if (ObjectUtil.isNotNull(paramCollectionList0.get(i).getValue())){
-                                paramValue = paramCollectionList0.get(i).getValue().toString();
-                            }
-                            daParamCollection.setParamValue(paramValue);
-                            daParamCollection.setLocationCode(device);
-                            daParamCollection.setCollectionTime(new Date());
-                            saveParamList.add(daParamCollection);
+                List<String> collect3 = confColl3.stream()
+                        .map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList());
+                List<ReadWriteEntity> paramCollectionList3 = miloService.readFromOpcUa(collect3);//鐢佃姱3 鍙傛暟鍊�
+
+                List<String> collect4 = confColl4.stream()
+                        .map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList());
+                List<ReadWriteEntity> paramCollectionList4 = miloService.readFromOpcUa(collect4);//鐢佃姱4 鍙傛暟鍊�
+
+                List<String> collect0 = confColl0.stream()
+                        .map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList());
+                List<ReadWriteEntity> paramCollectionList0 = miloService.readFromOpcUa(collect0);//鐢佃姱 鍙傛暟鍊�
+
+                //绗竴涓數鑺殑鏁版嵁
+                if (CollUtil.isNotEmpty(paramCollectionList1)) {
+                    List<ChildVO> mesChildList1 = new ArrayList<>();//灏佽缁欏伐鍘侻ES鍙戦�佺殑childlist1
+                    for (int i = 0; i < paramCollectionList1.size(); i++) {
+                        DaParamCollection daParamCollection = new DaParamCollection();
+                        daParamCollection.setSfcCode(cellCodeList.get(0));//鐢佃姱鐮�
+                        daParamCollection.setParamCode(confColl1.get(i).getCollectParameterId());//鍙傛暟缂栫爜
+                        daParamCollection.setParamName(confColl1.get(i).getCollectParameterName());//鍙傛暟鍚嶇О
+                        String paramValue = "";
+                        if (ObjectUtil.isNotNull(paramCollectionList1.get(i).getValue())) {
+                            paramValue = paramCollectionList1.get(i).getValue().toString();//鍙傛暟鍊�
                         }
+                        daParamCollection.setParamValue(paramValue);//鍙傛暟鍊�
+                        daParamCollection.setLocationCode(device);//宸ヤ綅
+                        daParamCollection.setCollectionTime(new Date());//閲囬泦鏃堕棿
+                        saveParamList.add(daParamCollection);//灏佽鍙傛暟閲囬泦list
+
+                        //鍙戦�佺粰宸ュ巶mes鍙傛暟灏佽
+                        ChildVO childVO = new ChildVO();
+                        childVO.setItemCode(confColl1.get(i).getCollectParameterName());//鍙傛暟
+                        childVO.setItemType(confColl1.get(i).getItemType());
+                        childVO.setItemValue(paramValue);//鍙傛暟鍊�
+                        childVO.setItemText(confColl1.get(i).getParameterSetName());
+                        childVO.setCheckResult("1");
+                        childVO.setCheckTime(new Date().toString());
+                        mesChildList1.add(childVO);
+                        mesList.add(0, mesChildList1);
                     }
                 }
+                if (CollUtil.isNotEmpty(paramCollectionList2)) {
+                    List<ChildVO> mesChildList2 = new ArrayList<>();//灏佽缁欏伐鍘侻ES鍙戦�佺殑childlist2
+
+                    for (int i = 0; i < paramCollectionList2.size(); i++) {
+                        DaParamCollection daParamCollection = new DaParamCollection();
+                        daParamCollection.setSfcCode(cellCodeList.get(1));//鐢佃姱鐮�
+                        daParamCollection.setParamCode(confColl2.get(i).getCollectParameterId());//鍙傛暟缂栫爜
+                        daParamCollection.setParamName(confColl2.get(i).getCollectParameterName());//鍙傛暟鍚嶇О
+                        String paramValue = "";
+                        if (ObjectUtil.isNotNull(paramCollectionList2.get(i).getValue())) {
+                            paramValue = paramCollectionList2.get(i).getValue().toString();//鍙傛暟鍊�
+                        }
+                        daParamCollection.setParamValue(paramValue);//鍙傛暟鍊�
+                        daParamCollection.setLocationCode(device);//宸ヤ綅
+                        daParamCollection.setCollectionTime(new Date());//閲囬泦鏃堕棿
+                        saveParamList.add(daParamCollection);//灏佽鍙傛暟閲囬泦list
+
+                        //鍙戦�佺粰宸ュ巶mes鍙傛暟灏佽
+                        ChildVO childVO = new ChildVO();
+                        childVO.setItemCode(confColl2.get(i).getCollectParameterName());//鍙傛暟
+                        childVO.setItemType(confColl2.get(i).getItemType());
+                        childVO.setItemValue(paramValue);//鍙傛暟鍊�
+                        childVO.setItemText(confColl2.get(i).getParameterSetName());
+                        childVO.setCheckResult("1");
+                        childVO.setCheckTime(new Date().toString());
+                        mesChildList2.add(childVO);
+                        mesList.add(1, mesChildList2);
+                    }
+                }
+                if (CollUtil.isNotEmpty(paramCollectionList3)) {
+                    List<ChildVO> mesChildList3 = new ArrayList<>();//灏佽缁欏伐鍘侻ES鍙戦�佺殑childlist3
+                    for (int i = 0; i < paramCollectionList3.size(); i++) {
+                        DaParamCollection daParamCollection = new DaParamCollection();
+                        daParamCollection.setSfcCode(cellCodeList.get(2));//鐢佃姱鐮�
+                        daParamCollection.setParamCode(confColl3.get(i).getCollectParameterId());//鍙傛暟缂栫爜
+                        daParamCollection.setParamName(confColl3.get(i).getCollectParameterName());//鍙傛暟鍚嶇О
+                        String paramValue = "";
+                        if (ObjectUtil.isNotNull(paramCollectionList3.get(i).getValue())) {
+                            paramValue = paramCollectionList3.get(i).getValue().toString();//鍙傛暟鍊�
+                        }
+                        daParamCollection.setParamValue(paramValue);//鍙傛暟鍊�
+                        daParamCollection.setLocationCode(device);//宸ヤ綅
+                        daParamCollection.setCollectionTime(new Date());//閲囬泦鏃堕棿
+                        saveParamList.add(daParamCollection);//灏佽鍙傛暟閲囬泦list
+
+                        //鍙戦�佺粰宸ュ巶mes鍙傛暟灏佽
+                        ChildVO childVO = new ChildVO();
+                        childVO.setItemCode(confColl3.get(i).getCollectParameterName());//鍙傛暟
+                        childVO.setItemType(confColl3.get(i).getItemType());
+                        childVO.setItemValue(paramValue);//鍙傛暟鍊�
+                        childVO.setItemText(confColl3.get(i).getParameterSetName());
+                        childVO.setCheckResult("1");
+                        childVO.setCheckTime(new Date().toString());
+                        mesChildList3.add(childVO);
+                        mesList.add(2, mesChildList3);
+                    }
+                }
+                if (CollUtil.isNotEmpty(paramCollectionList4)) {
+                    List<ChildVO> mesChildList4 = new ArrayList<>();//灏佽缁欏伐鍘侻ES鍙戦�佺殑childlist4
+                    for (int i = 0; i < paramCollectionList4.size(); i++) {
+                        DaParamCollection daParamCollection = new DaParamCollection();
+                        daParamCollection.setSfcCode(cellCodeList.get(3));//鐢佃姱鐮�
+                        daParamCollection.setParamCode(confColl4.get(i).getCollectParameterId());//鍙傛暟缂栫爜
+                        daParamCollection.setParamName(confColl4.get(i).getCollectParameterName());//鍙傛暟鍚嶇О
+                        String paramValue = "";
+                        if (ObjectUtil.isNotNull(paramCollectionList4.get(i).getValue())) {
+                            paramValue = paramCollectionList4.get(i).getValue().toString();//鍙傛暟鍊�
+                        }
+                        daParamCollection.setParamValue(paramValue);//鍙傛暟鍊�
+                        daParamCollection.setLocationCode(device);//宸ヤ綅
+                        daParamCollection.setCollectionTime(new Date());//閲囬泦鏃堕棿
+                        saveParamList.add(daParamCollection);//灏佽鍙傛暟閲囬泦list
+
+                        //鍙戦�佺粰宸ュ巶mes鍙傛暟灏佽
+                        ChildVO childVO = new ChildVO();
+                        childVO.setItemCode(confColl4.get(i).getCollectParameterName());//鍙傛暟
+                        childVO.setItemType(confColl4.get(i).getItemType());
+                        childVO.setItemValue(paramValue);//鍙傛暟鍊�
+                        childVO.setItemText(confColl4.get(i).getParameterSetName());
+                        childVO.setCheckResult("1");
+                        childVO.setCheckTime(new Date().toString());
+                        mesChildList4.add(childVO);
+                        mesList.add(3, mesChildList4);
+                    }
+                }
+
+                //鍏叡鍙傛暟
+                if (CollUtil.isNotEmpty(paramCollectionList0)) {
+                    for (int i = 0; i < cellCodeList.size(); i++) {//寰幆4涓數鑺�
+                        List<ChildVO> mesChildList0 = new ArrayList<>();//灏佽缁欏伐鍘侻ES鍙戦�佺殑childlist0
+                        for (int j = 0; j < paramCollectionList0.size(); j++) {
+                            DaParamCollection daParamCollection = new DaParamCollection();
+                            daParamCollection.setSfcCode(cellCodeList.get(i));//鐢佃姱鐮�
+                            daParamCollection.setParamCode(confColl0.get(j).getCollectParameterId());//鍙傛暟缂栫爜
+                            daParamCollection.setParamName(confColl0.get(j).getCollectParameterName());//鍙傛暟鍚嶇О
+                            String paramValue = "";
+                            if (ObjectUtil.isNotNull(paramCollectionList0.get(j).getValue())) {
+                                paramValue = paramCollectionList0.get(j).getValue().toString();//鍙傛暟鍊�
+                            }
+                            daParamCollection.setParamValue(paramValue);//鍙傛暟鍊�
+                            daParamCollection.setLocationCode(device);//宸ヤ綅
+                            daParamCollection.setCollectionTime(new Date());//閲囬泦鏃堕棿
+                            saveParamList.add(daParamCollection);
+
+                            //鍙戦�佺粰宸ュ巶mes鍙傛暟灏佽
+                            ChildVO childVO = new ChildVO();
+                            childVO.setItemCode(confColl0.get(j).getCollectParameterName());//鍙傛暟
+                            childVO.setItemType(confColl0.get(j).getItemType());
+                            childVO.setItemValue(paramValue);//鍙傛暟鍊�
+                            childVO.setItemText(confColl0.get(j).getParameterSetName());
+                            childVO.setCheckResult("1");
+                            childVO.setCheckTime(new Date().toString());
+                            mesChildList0.add(childVO);
+                        }
+                        mesList.get(i).addAll(mesChildList0);
+                        /* mesList.add(mesChildList0);*/
+                    }
+
+                }
+
+                CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> {
+                    //鎻掑叆鍙傛暟閲囬泦琛�
+                    daParamCollectionService.insertBatch(saveParamList);
+                    //涓婁紶鍒板伐鍘俶es
+                    ParentVO parentVO = new ParentVO();
+                    parentVO.setStationCode(device);//宸ヤ綅
+                    parentVO.setSiteCode("3983");
+
+                    parentVO.setRecordId(UUID.randomUUID().toString());
+                    parentVO.setTotalResult("1");
+                    for (int i = 0; i < cellCodeList.size(); i++) {//寰幆4涓數鑺�
+                        parentVO.setProductNum(cellCodeList.get(i));//鐢佃姱鐮�
+                        parentVO.setCheckList(mesList.get(i));//鍙傛暟
+                        //CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> {
+                        log.info("鎵ц宸ュ巶MES鏂规硶start锛屼紶鍏ユ暟鎹細{}",parentVO);
+                        HttpResponse execute = HttpRequest.post(orderLineUrl).body(JSONUtil.toJsonStr(parentVO)).execute();
+                        log.info("鎵ц宸ュ巶MES鏂规硶end锛岃繑鍥炴暟鎹細{}",execute.body());
+                        //});
+                    }
+                });
             }
-                daParamCollectionService.insertBatch(saveParamList);
-            }
-        return passingList;
+        }catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        return result;
     }
 
     /**

--
Gitblit v1.9.3