From 929bdcf5898f03820d9d2ba62005e32a0a0ded14 Mon Sep 17 00:00:00 2001
From: wujian <14790700720@163.com>
Date: 星期日, 28 四月 2024 14:50:26 +0800
Subject: [PATCH] change model9

---
 jcdm-main/src/main/java/com/jcdm/main/da/passingStationCollection/domain/DaPassingStationCollection.java |    3 
 jcdm-main/src/main/java/com/jcdm/main/bs/technologyRouteChild/domain/BsTechnologyRouteChildInfo.java     |    6 +
 jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java                               |  207 ++++++++++++++++++++++++++++-----------------------
 3 files changed, 123 insertions(+), 93 deletions(-)

diff --git a/jcdm-main/src/main/java/com/jcdm/main/bs/technologyRouteChild/domain/BsTechnologyRouteChildInfo.java b/jcdm-main/src/main/java/com/jcdm/main/bs/technologyRouteChild/domain/BsTechnologyRouteChildInfo.java
index f30e6ef..1d54ec1 100644
--- a/jcdm-main/src/main/java/com/jcdm/main/bs/technologyRouteChild/domain/BsTechnologyRouteChildInfo.java
+++ b/jcdm-main/src/main/java/com/jcdm/main/bs/technologyRouteChild/domain/BsTechnologyRouteChildInfo.java
@@ -1,5 +1,7 @@
 package com.jcdm.main.bs.domain;
 
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Data;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import com.jcdm.common.annotation.Excel;
@@ -11,6 +13,7 @@
  * @author ruimin
  * @date 2023-12-09
  */
+@Data
 public class BsTechnologyRouteChildInfo extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
@@ -30,6 +33,9 @@
     @Excel(name = "鍔犲伐椤哄簭")
     private String stepNo;
 
+    @TableField(exist = false)
+    private Integer stepNoNum;
+
     /** 涓嬩竴閬撳伐搴� */
     @Excel(name = "涓嬩竴閬撳伐搴�")
     private String nextProcess;
diff --git a/jcdm-main/src/main/java/com/jcdm/main/da/passingStationCollection/domain/DaPassingStationCollection.java b/jcdm-main/src/main/java/com/jcdm/main/da/passingStationCollection/domain/DaPassingStationCollection.java
index 6ced182..d5a6b59 100644
--- a/jcdm-main/src/main/java/com/jcdm/main/da/passingStationCollection/domain/DaPassingStationCollection.java
+++ b/jcdm-main/src/main/java/com/jcdm/main/da/passingStationCollection/domain/DaPassingStationCollection.java
@@ -41,6 +41,9 @@
 
     private String repairFlag;
 
+    @TableField(exist = false)
+    private Integer stepNo;
+
     /** 鎬绘垚搴忓垪鍙� */
     @Excel(name = "绠变綋缂栫爜")
     @ExcelProperty(value = "绠变綋缂栫爜", index = 1)
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 240336b..8eb4dd6 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
@@ -141,7 +141,33 @@
             Object SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Code").getValue();
             if(null != SNCodeObject) {
                 String SNCode=SNCodeObject.toString();
-                String a=passingStationCollectionServiceImpl.SelectSN(SNCode,parts[1]);
+//                String a=passingStationCollectionServiceImpl.SelectSN(SNCode,parts[1]);
+                String a;
+                BsOrderScheduling bsOrderSchedulingQuery = new BsOrderScheduling();
+                bsOrderSchedulingQuery.setEngineNo(SNCode);
+                List<BsOrderScheduling> queryOrderList = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderSchedulingQuery);
+                if (CollUtil.isNotEmpty(queryOrderList)){
+                    a = "1";
+                }else {
+                    a = "5";
+                }
+                //濡傛灉鏄繑淇伐浣嶉渶瑕佷紶杈撹繑淇伐浣嶅彿
+                if (OPCElement.OP465_ZZ_CODE_CHECK.equals(Node) || OPCElement.OP355_ZZ_CODE_CHECK.equals(Node)
+                        || OPCElement.OP695_ZZ_CODE_CHECK.equals(Node) || OPCElement.OP755_ZZ_CODE_CHECK.equals(Node)){
+                    //杩囩珯璁板綍
+                    DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection();
+                    PassingStationCollection.setSfcCode(SNCode);
+                    List<DaPassingStationCollection> daPassingStationCollections = passingStationCollectionServiceImpl.selectDaPassingStationCollectionList(PassingStationCollection);
+                    if (CollUtil.isNotEmpty(daPassingStationCollections)){
+                        DaPassingStationCollection lastOne = daPassingStationCollections.get(daPassingStationCollections.size() - 1);
+                        String outRsSign = lastOne.getOutRsSign();
+                        if ("鍚堟牸".equals(outRsSign)){
+                            a = "1";
+                        }else {
+                            a = "2";
+                        }
+                    }
+                }
                 log.info("-----杩斿洖codeCheckFeed-----,{}",a);
 //                String a="1";
                 // 1:OK鍙敓浜� 2:NG涓嶅彲鐢熶骇 3:NG鍙繑宸� 4:PC妫�绱㈠け璐ワ紙鏃犺褰曪級5:PC妫�绱㈠け璐ワ紙杞欢锛�
@@ -169,6 +195,7 @@
                     //濡傛灉鏄繑淇伐浣嶉渶瑕佷紶杈撹繑淇伐浣嶅彿
                     if (OPCElement.OP465_ZZ_CODE_CHECK.equals(Node) || OPCElement.OP355_ZZ_CODE_CHECK.equals(Node)
                     || OPCElement.OP695_ZZ_CODE_CHECK.equals(Node) || OPCElement.OP755_ZZ_CODE_CHECK.equals(Node)){
+
                         rework(SNCode,Node);
                     }
                     System.out.println(entity);
@@ -183,11 +210,12 @@
         BsOrderScheduling bsOrderScheduling = new BsOrderScheduling();
         bsOrderScheduling.setEngineNo(SNCode);
         List<String> allProcessCoed = new ArrayList<>();
+        List<BsTechnologyRouteChildInfo> bsTechnologyRouteChildInfos = new ArrayList<>();
         List<String> collect = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling).stream().map(BsOrderScheduling::getModel).collect(Collectors.toList());
         if (CollUtil.isNotEmpty(collect)){
             String s = collect.get(0);
             //鏌ユ壘娆℃満鍨嬬殑瀹屾暣宸ュ簭
-            List<BsTechnologyRouteChildInfo> bsTechnologyRouteChildInfos = bsTechnologyRouteChildInfoService.selectAllTechnologyRouteByProductCode(s);
+            bsTechnologyRouteChildInfos = bsTechnologyRouteChildInfoService.selectAllTechnologyRouteByProductCode(s);
             if (CollUtil.isNotEmpty(bsTechnologyRouteChildInfos)){
                 allProcessCoed = bsTechnologyRouteChildInfos.stream().map(BsTechnologyRouteChildInfo::getProcessesCode).collect(Collectors.toList());
             }
@@ -204,104 +232,97 @@
 
         //鎵�鏈夊弽宸ュ伐浣�
         List<String> collect1 = rmRepairRecords.stream().map(RmRepairRecord::getProcessesCode).collect(Collectors.toList());
-        //鏌ヨ鍑烘墍鏈夐渶瑕佽繑淇伐浣嶇殑鏈�灏弌p鍧�
-        Integer minOP = 0;
         if (CollUtil.isNotEmpty(collect1)){
+            //鏌ヨ鍑烘墍鏈夐渶瑕佽繑淇伐浣嶇殑鏈�灏弌p鍧�
+            Integer minOP = 0;
+            if (CollUtil.isNotEmpty(collect1)){
 
-            List<Integer> sortList = new ArrayList<>();
-            collect1.stream().forEach(x ->{
-                String op = x.replace("OP", "");
-                if (StrUtil.isNotBlank(op)){
-                    int i = Integer.parseInt(op);
-                    sortList.add(i);
+                List<Integer> sortList = new ArrayList<>();
+                collect1.stream().forEach(x ->{
+                    String op = x.replace("OP", "");
+                    if (StrUtil.isNotBlank(op)){
+                        int i = Integer.parseInt(op);
+                        sortList.add(i);
+                    }
+                });
+                if (CollUtil.isNotEmpty(sortList)){
+                    List<Integer> collect2 = sortList.stream().filter(Objects::nonNull).sorted().collect(Collectors.toList());
+                    minOP = collect2.get(0);
                 }
-            });
-            if (CollUtil.isNotEmpty(sortList)){
-                List<Integer> collect2 = sortList.stream().sorted().collect(Collectors.toList());
-                minOP = collect2.get(0);
             }
-        }
-
-        //鎵�鏈夋斁琛屽伐浣�
-        //杩囩珯璁板綍闄ゅ幓杩斾慨璁板綍灏辨槸浼�2锛岃繑淇暟鎹強鍚庨潰鍗犱綅鏁版嵁浼�1
-        List<String> collect3 = daPassingStationCollections.stream().map(DaPassingStationCollection::getLocationCode).collect(Collectors.toList());
-        if (CollUtil.isNotEmpty(collect1)){
-            collect3 = collect3.stream().filter(x -> !collect1.contains(x)).collect(Collectors.toList());
-        }
-        String[] parts = Node.split("[.]");
-        String par = parts[0]+"."+parts[1];
-        if (CollUtil.isNotEmpty(collect3)){
-            collect3.forEach(x -> {
-                ReadWriteEntity readWriteEntity = new ReadWriteEntity();
-                readWriteEntity.setIdentifier(par+"."+x);
-                readWriteEntity.setValue(2);
-                writeList.add(readWriteEntity);
-            });
-        }
-        //闇�鐢熶骇宸ヤ綅
-        List<String> collect4 = allProcessCoed;
-        if (CollUtil.isNotEmpty(collect3)){
-            List<String> finalCollect = collect3;
-            collect4 = allProcessCoed.stream().filter(x -> !finalCollect.contains(x)).collect(Collectors.toList());
-        }
-        if (CollUtil.isNotEmpty(collect4)){
-            //鏁版嵁搴撴煡璇㈠嚭鐨勫伐浣�
-            collect4.forEach(x -> {
-                ReadWriteEntity readWriteEntity = new ReadWriteEntity();
-                readWriteEntity.setIdentifier(par+"."+x);
-                readWriteEntity.setValue(1);
-                writeList.add(readWriteEntity);
-            });
-        }
-//        List<String> collect2 = allProcessCoed;
-//        if (CollUtil.isNotEmpty(rmRepairRecords)){
-//            //鏁版嵁搴撴煡璇㈠嚭鐨勫伐浣�
-//            rmRepairRecords.forEach(x -> {
-//                ReadWriteEntity readWriteEntity = new ReadWriteEntity();
-//                readWriteEntity.setIdentifier(x.getProcessesCode());
-//                readWriteEntity.setValue(1);
-//                writeList.add(readWriteEntity);
-//            });
-//            collect2 = allProcessCoed.stream().filter(x -> !collect1.contains(x)).collect(Collectors.toList());
-//        }
-//        if (CollUtil.isNotEmpty(collect2)){
-//            collect2.forEach(x -> {
-//                ReadWriteEntity readWriteEntity = new ReadWriteEntity();
-//                readWriteEntity.setIdentifier(x);
-//                readWriteEntity.setValue(2);
-//                writeList.add(readWriteEntity);
-//            });
-//        }
-
-//        String a=passingStationCollectionServiceImpl.SelectSN(SNCode,parts[1]);
-//        if (StrUtil.isNotBlank(a)){
-//            int input = Integer.parseInt(a);
-//            ReadWriteEntity entity = new ReadWriteEntity(parts[0]+"."+parts[1]+".CodeCheckFeed", input);
-//            writeList.add(entity);
-//        }
-        ReadWriteEntity readWriteEntity = new ReadWriteEntity();
-        readWriteEntity.setIdentifier(parts[0]+"."+parts[1]+".Repair_sign");
-        readWriteEntity.setValue(minOP);
-        miloService.writeToOpcShort(readWriteEntity);
-        /*if (CollUtil.isNotEmpty(writeList)){
-            List<ReadWriteEntity> tempList = new ArrayList<>();
-            for (int i = 0; i < writeList.size(); i++) {
-                miloService.writeToOpc();
-//                tempList.add(writeList.get(i));
-//                if (tempList.size()>10){
-//                    miloService.writeToOpcByte(tempList);
-//                    log.info("鍐欏叆杩斾慨锛�,{}",tempList);
-//                    tempList = new ArrayList<>();
-//                }
+            //鑾峰彇杩囩珯璁板綍鐨勬渶澶у伐浣�
+            String maxCode = null;
+            if (CollUtil.isNotEmpty(daPassingStationCollections)){
+                DaPassingStationCollection lastOne = daPassingStationCollections.get(daPassingStationCollections.size() - 1);
+                maxCode = lastOne.getLocationCode();
             }
-//            if (CollUtil.isNotEmpty(tempList)){
-//                miloService.writeToOpcByte(tempList);
-//                log.info("鍐欏叆杩斾慨锛�,{}",tempList);
-//            }
 
 
-        }*/
-        miloService.writeToOpcByte(writeList);
+            //鎵�鏈夋斁琛屽伐浣�
+            List<String> passStation = new ArrayList<>();
+            //鎵�鏈夌敓浜у伐浣�
+            List<String> productStation = new ArrayList<>();
+            //鏈�澶у伐浣嶇紪鍙�
+            Integer maxCodeNum = 0;
+            if (StrUtil.isNotEmpty(maxCode)){
+                String finalMaxCode = maxCode;
+                //鑾峰彇褰撳墠宸ヤ綅瀵瑰簲宸ユ鍙�
+                List<String> collect2 = bsTechnologyRouteChildInfos.stream()
+                        .filter(x -> x.getProcessesCode().equals(finalMaxCode))
+                        .map(BsTechnologyRouteChildInfo::getStepNo).collect(Collectors.toList());
+                if (CollUtil.isNotEmpty(collect2)){
+                    String s = collect2.get(0);
+                    if (StrUtil.isNotBlank(s)){
+                        maxCodeNum = Integer.parseInt(s);
+                    }
+                }
+                if (CollUtil.isNotEmpty(bsTechnologyRouteChildInfos)){
+                    bsTechnologyRouteChildInfos.forEach(x -> {
+                        x.setStepNoNum(Integer.parseInt(x.getStepNo()));
+                    });
+                    Integer finalMaxCodeNum = maxCodeNum;
+                    //鍕鹃�夌殑杩斾慨宸ヤ綅涓渶澶х殑宸ヤ綅涔嬪悗鐨勫伐浣�----1
+                    List<BsTechnologyRouteChildInfo> collect3 = bsTechnologyRouteChildInfos.stream()
+                            .filter(x -> x.getStepNoNum() >= finalMaxCodeNum).collect(Collectors.toList());
+                    if (CollUtil.isNotEmpty(collect3)){
+                        //闇�瑕佺敓浜�
+                        productStation.addAll(collect3.stream().map(BsTechnologyRouteChildInfo::getProcessesCode).collect(Collectors.toList()));
+                    }
+                    //浠庣涓�涓伐浣嶅埌杩斾慨鐨勬渶澶у伐浣嶄箣闂达紝
+                    //鍕鹃�変簡杩斾慨鏍囪鐨勯渶瑕佺敓浜�---1锛屾湭鍕鹃�夌殑涓嶇敓浜�---2
+                    productStation.addAll(collect1);
+                }
+            }
+            if (CollUtil.isNotEmpty(productStation)){
+                List<String> collect2 = allProcessCoed.stream().filter(x -> !productStation.contains(x)).collect(Collectors.toList());
+                passStation.addAll(collect2);
+            }
+            String[] parts = Node.split("[.]");
+            String par = parts[0]+"."+parts[1];
+            if (CollUtil.isNotEmpty(passStation)){
+                passStation.forEach(x -> {
+                    ReadWriteEntity readWriteEntity = new ReadWriteEntity();
+                    readWriteEntity.setIdentifier(par+"."+x);
+                    readWriteEntity.setValue(2);
+                    writeList.add(readWriteEntity);
+                });
+            }
+            if (CollUtil.isNotEmpty(productStation)){
+                productStation.forEach(x -> {
+                    ReadWriteEntity readWriteEntity = new ReadWriteEntity();
+                    readWriteEntity.setIdentifier(par+"."+x);
+                    readWriteEntity.setValue(1);
+                    writeList.add(readWriteEntity);
+                });
+            }
+            ReadWriteEntity readWriteEntity = new ReadWriteEntity();
+            readWriteEntity.setIdentifier(parts[0]+"."+parts[1]+".Repair_sign");
+            readWriteEntity.setValue(minOP);
+            miloService.writeToOpcShort(readWriteEntity);
+            miloService.writeToOpcByte(writeList);
+            log.info("杩斾慨鍐欏叆锛�,{}",writeList);
+        }
+
     }
 
 

--
Gitblit v1.9.3