From 4e83fa344f6cba81412fb354e7f32a88a8f34fde Mon Sep 17 00:00:00 2001
From: admin <15939171744@163.com>
Date: 星期二, 09 七月 2024 09:39:11 +0800
Subject: [PATCH] -切换大模组代码更改

---
 jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java |  165 ++++++++++++++++++++++++++++--------------------------
 1 files changed, 85 insertions(+), 80 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 dca43ce..5624a2a 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
@@ -48,29 +48,36 @@
     private static final Logger logger = LoggerFactory.getLogger("sys-user");
 
     public SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-
     //鏂拌嚜鍔ㄥ伐绔�
-    public List<String> automaticList = Arrays.asList("OP280","OP310A","OP310B", "OP300A","OP300B", "OP320A","OP320B", "OP340A","OP340B", "OP350A","OP350B", "OP360","OP365","OP370", "OP390", "OP470");
+    public List<String> automaticList = Arrays.asList("POP270","POP282", "POP281", "POP283", "POP285", "POP286", "POP290","OP365","POP300", "POP320", "POP400");
 
     //閲囬泦妯$粍宸ヤ綅 ModuleCode
-    public List<String> moduleCodeList = Arrays.asList("OP300A","OP310A","OP310B","OP300B","OP320A","OP320B","OP340A","OP340B","OP365", "OP350A", "OP350B", "OP330");
-
-    //鍖哄垎妯$粍鍨嬪彿宸ヤ綅
-    public List<String> distinguishingModules = Arrays.asList("OP300","OP310", "OP340", "OP350", "OP330");
+    public List<String> moduleCodeList = Arrays.asList("POP281","POP282","POP283","POP285","OP365", "POP286", "POP284");
 
     //鍖哄垎灏忚溅鐮�
-    public List<String> agvId = Arrays.asList("OP360", "OP390", "OP470","OP280");
-
-
-    //鍖哄垎pack鍨嬪彿鐨勫伐浣�
-    public List<String> packIdList = Arrays.asList("OP280","OP360","OP390","OP470");
+    public List<String> agvId = Arrays.asList("POP290", "POP320", "POP400","POP270");
 
     //娴嬭瘯璁惧鎵嬪姩宸ヤ綅
-    public List<String> testList = Arrays.asList("OP430-1","OP430-2","OP430-3","OP430-4","OP480-1","OP480-2","OP480-3","OP440");
-
+    public List<String> testList = Arrays.asList("POP360-1","POP360-2","POP360-3","POP360-4","POP410-1","POP410-2","POP410-3","POP370","POP420-1","POP420-2","POP420-3");
 
     //绌虹殑
     public List<String> nullList = Arrays.asList("OP250","OP260");
+
+//    //鏂拌嚜鍔ㄥ伐绔�
+//    public List<String> automaticList = Arrays.asList("OP280","OP310A","OP310B", "OP300A","OP300B", "OP320A","OP320B", "OP340A","OP340B", "OP350A","OP350B", "OP360","OP365","OP370", "OP390", "OP470");
+//
+//    //閲囬泦妯$粍宸ヤ綅 ModuleCode
+//    public List<String> moduleCodeList = Arrays.asList("OP300A","OP310A","OP310B","OP300B","OP320A","OP320B","OP340A","OP340B","OP365", "OP350A", "OP350B", "OP330");
+//
+//    //鍖哄垎灏忚溅鐮�
+//    public List<String> agvId = Arrays.asList("OP360", "OP390", "OP470","OP280");
+//
+//    //娴嬭瘯璁惧鎵嬪姩宸ヤ綅
+//    public List<String> testList = Arrays.asList("OP430-1","OP430-2","OP430-3","OP430-4","OP480-1","OP480-2","OP480-3","OP440");
+//
+//
+//    //绌虹殑
+//    public List<String> nullList = Arrays.asList("OP250","OP260");
 
 
     public static MiloService miloService;
@@ -193,10 +200,10 @@
                         if(automaticList.stream().anyMatch(s -> s.equals(device))){
                             //鑷姩宸ヤ綅
                             //鍑虹珯淇濆瓨鏁版嵁
-                            recordDataDoneValue = outSaveDate(thoroughfare,device);
+                            outSaveDate(thoroughfare,device);
                             //璁板綍鏁版嵁瀹屾垚
-                            String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
-                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(Integer.valueOf(recordDataDoneValue)).build());
+                            /*String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
+                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(Integer.valueOf(recordDataDoneValue)).build());*/
                         }else {
                             //鎵嬪姩宸ヤ綅
 //                            if(device.contains("OP330")){
@@ -219,7 +226,7 @@
 //                                }
 //
 //                                if (deviceInterfaceOne != null && "1".equals(deviceInterfaceOne.getTotalResult())) {
-//                                    writeToOpc(RecordDataDoneAddress, (short) 21);
+//                                writeToOpcShort(RecordDataDoneAddress, (short) 21);
 //                                } else {
 //                                    writeToOpc(RecordDataDoneAddress, (short) 22);
 //                                }
@@ -233,8 +240,8 @@
                     }
                 }
                 //淇濆瓨鎷х揣鏁版嵁
-                else if (("AngleResult").equals(tab)) {
-                    if("1".equals(tabVlaue)||"2".equals(tabVlaue)){
+                else if (("TighteningFrequency").equals(tab)) {
+                    if(!"0".equals(tabVlaue)){
                         List<String> list = new ArrayList<>();
                         String[] suffixes = {"Torque", "Angle", "TorqueResult", "AngleResult"};
 
@@ -246,9 +253,7 @@
                         List<Object> collect = list1.stream().map(ReadWriteEntity::getValue).collect(Collectors.toList());
                         String joinedString = String.join(",", collect.toString());
                         WebSocketUsers.sendMessageToUserByText(map.get(device), TightenTheConversionOkNg(joinedString));
-                        if(device.contains("270") || device.contains("260")){
-                            logger.info("璇诲彇鍒板伐浣峽}鐨凷caner鏁版嵁锛歿}",device,TightenTheConversionOkNg(joinedString));
-                        }
+                        logger.info("璇诲彇鍒板伐浣峽}鐨凷caner鏁版嵁锛歿}",device,TightenTheConversionOkNg(joinedString));
                     }
                 }
             }
@@ -271,26 +276,22 @@
     /**
      * 鍑虹珯淇濆瓨鏁版嵁
      */
-    public String outSaveDate(String thoroughfare,String device) {
+    public void outSaveDate(String thoroughfare,String device) {
         String snCode = "";
         String result = "";
         String read = thoroughfare + "." + device + ".";
 
         try {
-            if(nullList.stream().noneMatch(s -> s.equals(device))){
+            if(nullList.stream().noneMatch(s -> s.equals(device))){//鍒犻櫎鈥︹�︹�︹�︹�︹�︹�︹�︹�︹�︹�︹�︹�︹�︹�︹�︹�︹�︹�︹��
                 if(moduleCodeList.stream().anyMatch(s -> s.equals(device))){
                     read = read + "ModuleCode";
-
                 }else {
                     read = read + "PACKCode";
                 }
             }
             if(device.equals("OP365")){
                 try {
-                    result = saveStationInfo365(thoroughfare,device);
-                    return result;
-//                    return saveStationInfo365(thoroughfare,device);
-//                    return result;
+                   saveStationInfo365(thoroughfare,device);
                 }catch (Exception e){
                     e.printStackTrace();
                 }
@@ -298,7 +299,8 @@
                 snCode = miloService.readFromOpcUa(read).getValue().toString();
 
                 if(null == snCode || "".equals(snCode)){
-                    result = "22";
+                    String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
+                    miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(Integer.valueOf("22")).build());
                 }else{
 
                     String workOrderNo = "";
@@ -319,24 +321,22 @@
                     List<DaParamCollection> daParamCollectionList = SaveParamData(snCode,thoroughfare,device,workOrderNo,productCode);
 
                     //濡傛灉鏄湯灏惧伐绔欒鎶ュ伐
-                    if(device.equals("OP500")){
+                    if(device.equals("POP430")){
                         RestfulService.getWorkReportResultFeedback(snCode,device,format.format(new Date()));
                         //1銆佹洿鏂板伐鍗曚俊鎭�
                         updateOrderInfo(snCode);
                     }
+
                     try{
                         daParamCollectionService.automaticWorkstationPushGeelycvMesFeedback(snCode,device,daParamCollectionList);
                     }catch (Exception e){
                     }
-                    result = "21";
-
                 }
 
             }
         }catch (Exception e) {
             logger.error("鍑虹珯淇濆瓨鏁版嵁寮傚父锛�"+e);
         }
-        return result;
     }
 
 
@@ -374,6 +374,7 @@
      * 淇濆瓨杩囩珯閲囬泦
      */
     public void saveStationInfo(String packCode,String thoroughfare,String device,String workOrderNo,String productCode) throws Exception {
+        logger.info("杩涘叆宸ヤ綅{}-鏂规硶saveStationInfo",device);
         SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
         sdf.setTimeZone(TimeZone.getTimeZone("GMT+8")); // CST閫氬父琛ㄧず涓浗鏍囧噯鏃堕棿锛屽嵆涓滃叓鍖�
         String prefix = thoroughfare+"."+device+".";
@@ -392,9 +393,11 @@
         daPassingStationCollection.setOutboundTime(format.parse(TimeUtil.test(end)));//鍑虹珯鏃堕棿
         daPassingStationCollection.setOutRsSign(stationStatus);//鍑虹珯鏄惁鍚堟牸
         daPassingStationCollectionService.insertDaPassingStationCollection(daPassingStationCollection);
+        logger.info("缁撴潫宸ヤ綅{}-鏂规硶saveStationInfo",device);
     }
 
     public static List<DaParamCollection> SaveParamData(String packCode,String thoroughfare,String device,String workOrderNo,String productType) throws Exception {
+        logger.info("杩涘叆宸ヤ綅{}-鏂规硶SaveParamData",device);
         List<DaCollectionParamConf> list;
         DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf();
         daCollectionParamConf.setGatherAddress(thoroughfare+ "." + device);
@@ -408,54 +411,47 @@
 
         if(!nodeIdList.isEmpty()){
             List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(nodeIdList);
-            for (int i = 0; i < readWriteEntityList.size(); i++) {
+            for(int i=0;i<nodeIdList.size();i++){
                 if(readWriteEntityList.get(i).getValue() == null){
                     readWriteEntityList.get(i).setValue(" ");
                 }
-            }
-
-            for(int i=0;i<nodeIdList.size();i++){
-                if(!readWriteEntityList.get(i).getValue().toString().equals("0.0")){
-                    String tt = readWriteEntityList.get(i).getValue().toString();
-                    DaParamCollection ParamCollection = new DaParamCollection();
-                    ChildVO childVO = new ChildVO();
-                    ParamCollection.setParamCode(list.get(i).getCollectParameterId());
-                    ParamCollection.setLocationCode(device);
-                    if(tt.contains("Time")){
-//                        String str = TimeUtil.getTimestamp(TimeUtil.stringProcessing(tt));
-//                        ParamCollection.setParamValue(str);
-                        ParamCollection.setParamValue(TimeUtil.test(TimeUtil.stringProcessing(tt)));
-                    }else {
-                        ParamCollection.setParamValue(readWriteEntityList.get(i).getValue().toString());
-                    }
-                    ParamCollection.setSfcCode(packCode);
-                    if(device.contains("OP360")){
-                        String node = nodeIdList.get(i);
-                        Object value = miloService.readFromOpcUa("PACK.OP360.ModuleSNCode"+node.charAt(node.length()-1)).getValue();
-                        if(value!=null){
-                            ParamCollection.setModuleCode(value.toString());
-                        }
-                    }
-                    ParamCollection.setParamName(list.get(i).getCollectParameterName());
-                    ParamCollection.setParamUpper(list.get(i).getParamUpper());
-                    ParamCollection.setParamLower(list.get(i).getParamLower());
-                    ParamCollection.setUnit(list.get(i).getCollectParameterUnit());
-                    //ParamCollection.setState("鍚堟牸");
-                    ParamCollection.setType(list.get(i).getCollectParameterType());
-                    ParamCollection.setCollectionTime(new Date());
-                    ParamCollection.setWorkOrderNo(workOrderNo);
-                    ParamCollection.setProductCode(productType);
-                    daParamCollectionlist.add(ParamCollection);
-//                    daParamCollectionService.insertDaParamCollection(ParamCollection);
+                String paramValue = readWriteEntityList.get(i).getValue().toString();
+                DaParamCollection ParamCollection = new DaParamCollection();
+                ParamCollection.setParamCode(list.get(i).getCollectParameterId());
+                ParamCollection.setLocationCode(device);
+                if(paramValue.contains("Time")){
+                    ParamCollection.setParamValue(TimeUtil.test(TimeUtil.stringProcessing(paramValue)));
+                }else {
+                    ParamCollection.setParamValue(readWriteEntityList.get(i).getValue().toString());
                 }
+                ParamCollection.setSfcCode(packCode);
+                if(device.contains("OP360")){
+                    String node = nodeIdList.get(i);
+                    Object value = miloService.readFromOpcUa("PACK.OP360.ModuleSNCode"+node.charAt(node.length()-1)).getValue();
+                    if(value!=null){
+                        ParamCollection.setModuleCode(value.toString());
+                    }
+                }
+                ParamCollection.setParamName(list.get(i).getCollectParameterName());
+                ParamCollection.setParamUpper(list.get(i).getParamUpper());
+                ParamCollection.setParamLower(list.get(i).getParamLower());
+                ParamCollection.setUnit(list.get(i).getCollectParameterUnit());
+                ParamCollection.setType(list.get(i).getCollectParameterType());
+                ParamCollection.setCollectionTime(new Date());
+                ParamCollection.setWorkOrderNo(workOrderNo);
+                ParamCollection.setProductCode(productType);
+                daParamCollectionlist.add(ParamCollection);
             }
-            daParamCollectionService.saveBeachDaParamCollection(daParamCollectionlist);
-
         }
+        String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
+        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(Integer.valueOf("21")).build());
+        logger.info("缁欏伐浣峽}鍐欎簡21",device);
+        daParamCollectionService.saveBeachDaParamCollection(daParamCollectionlist);
         List<DaParamCollection> baseDataList = addBaseData(workOrderNo,productType,device,packCode);
         for (int i = 0; i < baseDataList.size(); i++){
             daParamCollectionlist.add(baseDataList.get(i));
         }
+        logger.info("缁撴潫宸ヤ綅{}-鏂规硶SaveParamData",device);
         return daParamCollectionlist;
     }
 
@@ -527,13 +523,22 @@
             try {
                 value = Float.parseFloat(part); // 灏濊瘯灏嗗瓧绗︿覆杞崲涓烘诞鐐规暟
                 String replacement;
-                if (value == 1f) {
+                if(i<2){
+                    replacement = part;
+                }else{
+                    if (value == 1f) {
+                        replacement = "OK";
+                    } else{
+                        replacement = "NG";
+                    }
+                }
+            /*    if (value == 1f) {
                     replacement = "OK";
                 } else if (value == 2f) {
                     replacement = "NG";
                 } else {
                     replacement = part; // 濡傛灉涓嶆槸1鎴�2锛屽垯淇濇寔涓嶅彉
-                }
+                }*/
                 sb.append(replacement);
                 if (i < parts.length - 1) {
                     sb.append(','); // 娣诲姞閫楀彿锛堥櫎浜嗘渶鍚庝竴涓厓绱狅級
@@ -566,7 +571,7 @@
     /**
      * 淇濆瓨杩囩珯閲囬泦
      */
-    public String saveStationInfo365(String thoroughfare,String device) throws Exception {
+    public void saveStationInfo365(String thoroughfare,String device) throws Exception {
         String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
         String prefix = thoroughfare+"."+device+".";
         List<DaPassingStationCollection> passingStationCollections = new ArrayList<>();
@@ -603,15 +608,15 @@
                 passingStationCollections.add(daPassingStationCollection);
             }
             daPassingStationCollectionService.saveBeachDaPassingStationCollection(passingStationCollections);
-//            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(21).build());
-            return "21";
+            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(21).build());
+            logger.info("宸ヤ綅{}鍥炲21",device);
+
         }else {
-//            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(22).build());
-            return "22";
+            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(22).build());
         }
     }
 
-    private static void writeToOpc(String identifier, short value) {
+    private static void writeToOpcShort(String identifier, short value) {
         try {
             miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(identifier).value(value).build());
         } catch (Exception e) {

--
Gitblit v1.9.3