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 |   55 +++++++++++++++++++++++++++++++------------------------
 1 files changed, 31 insertions(+), 24 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 80733f6..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
@@ -122,6 +122,22 @@
                         miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ScanerResult1").value(scanResult).build());
                         log.info("鍐欏叆鍒板伐浣峽}鐨凷canerResult1鏁版嵁锛歿}",device,scanResult);
                     }
+                }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鎵樼洏宸插埌绔欙紝璇锋眰涓嬪彂杩涚珯鐘舵��
@@ -155,15 +171,15 @@
                             miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(21).build());
                             log.info("鍐欏叆鍒板伐浣峽}鐨凴ecordDataDone鏁版嵁锛歿}",device,21);
                         }else if (Constants.OP020_OP065.contains(device)){
-                            String result = "21";
+                            Integer result = 21;
                             //璇诲彇鐢佃姱鐮�
                             List<String> cellCodeList = readCellCodeList(thoroughfare, device);
                             if(ObjectUtil.isNull(cellCodeList) && cellCodeList.size() != 4){
-                                result = "23";
+                                result = 23;
                                 miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(23).build());
                             }else{
                                 result = savePassingStation(thoroughfare, device,cellCodeList);//淇濆瓨杩囩珯
-                                if(result.equals("21")) {
+                                if(result==21) {
                                     result = saveParamCollection(thoroughfare, device,cellCodeList);//淇濆瓨鍙傛暟锛屽彂閫佸伐鍘侻ES
                                 }
                             }
@@ -171,15 +187,15 @@
                             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());
@@ -352,8 +359,8 @@
      * @return list
      * @throws Exception e
      */
-    private static String savePassingStation(String thoroughfare, String device,List<String> cellCodeList){
-        String result = "21";
+    private static Integer savePassingStation(String thoroughfare, String device,List<String> cellCodeList){
+        Integer result = 21;
 
         try {
             //璇昏繘绔欐椂闂�
@@ -364,7 +371,7 @@
                 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
                 startTime = sdf.parse(stringStartTime);
             }else{
-                result = "23";
+                result = 23;
                 log.info("璇诲彇鍒板伐浣峽}鐨凷tartTime鏁版嵁锛歿},杩斿洖RecordDataDone鐨勫�间负{}",device,"IS NULL锛�",result);
             }
 
@@ -377,7 +384,7 @@
                     stationStatus = Constants.UN_PASS;
                 }
             }else{
-                result = "23";
+                result = 23;
                 log.info("璇诲彇鍒板伐浣峽}StationStatuss鏁版嵁锛歿},杩斿洖RecordDataDone鐨勫�间负{}",device,"IS NULL锛�",result);
             }
 
@@ -393,7 +400,7 @@
                     passingStationCollection.setCollectionTime(new Date());//閲囬泦鏃堕棿
                     passingList.add(passingStationCollection);
                 }else{
-                    result = "23";
+                    result = 23;
                     log.info("璇诲彇鍒板伐浣峽}CellCode鏁版嵁锛歿},杩斿洖RecordDataDone鐨勫�间负{}",device,"IS NULL锛�",result);
                 }
             }
@@ -417,8 +424,8 @@
      * @return list
      * @throws Exception e
      */
-    private static String saveParamCollection(String thoroughfare, String device,List<String> cellCodeList){
-        String result = "21";//杩斿洖缁撴灉
+    private static Integer saveParamCollection(String thoroughfare, String device,List<String> cellCodeList){
+        Integer result = 21;//杩斿洖缁撴灉
         List<List<ChildVO>> mesList = new ArrayList<>();//瀛樺偍4涓數鑺殑鍙戦�佺粰MES鐨勫��
 
         try {

--
Gitblit v1.9.3