From 3c2299298cadf242bd85e3a805165c32a70833ac Mon Sep 17 00:00:00 2001
From: 懒羊羊 <15939171744@163.com>
Date: 星期一, 18 三月 2024 16:39:23 +0800
Subject: [PATCH] 操作看板

---
 jcdm-main/src/main/java/com/jcdm/main/plcserver/conf/OPCElement.java                                    |   14 ++++
 jcdm-main/src/main/java/com/jcdm/main/bs/formulaChild/service/impl/BsFormulaChildInfoServiceImpl.java   |   25 ++++++++
 jcdm-main/src/main/java/com/jcdm/main/plcserver/CustomRunner.java                                       |    3 +
 jcdm-ui/src/views/main/kb/stationTerminal/index.vue                                                     |   77 ++++++++++++++-----------
 jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/impl/DaParamCollectionServiceImpl.java |    2 
 jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java                              |   22 +++----
 6 files changed, 94 insertions(+), 49 deletions(-)

diff --git a/jcdm-main/src/main/java/com/jcdm/main/bs/formulaChild/service/impl/BsFormulaChildInfoServiceImpl.java b/jcdm-main/src/main/java/com/jcdm/main/bs/formulaChild/service/impl/BsFormulaChildInfoServiceImpl.java
index 3081f83..2fb51e2 100644
--- a/jcdm-main/src/main/java/com/jcdm/main/bs/formulaChild/service/impl/BsFormulaChildInfoServiceImpl.java
+++ b/jcdm-main/src/main/java/com/jcdm/main/bs/formulaChild/service/impl/BsFormulaChildInfoServiceImpl.java
@@ -2,17 +2,23 @@
 
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 import com.jcdm.common.core.domain.AjaxResult;
 import com.jcdm.common.utils.DateUtils;
+import com.jcdm.framework.websocket.WebSocketUsers;
 import com.jcdm.main.da.paramCollection.domain.DaParamCollection;
 import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper;
+import com.kangaroohy.milo.model.ReadWriteEntity;
+import com.kangaroohy.milo.service.MiloService;
 import org.aspectj.weaver.loadtime.Aj;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.jcdm.main.bs.formulaChild.mapper.BsFormulaChildInfoMapper;
 import com.jcdm.main.bs.formulaChild.domain.BsFormulaChildInfo;
 import com.jcdm.main.bs.formulaChild.service.IBsFormulaChildInfoService;
+
+import javax.websocket.Session;
 
 /**
  * 閰嶆柟閰嶇疆瀛愪俊鎭疭ervice涓氬姟灞傚鐞�
@@ -28,6 +34,11 @@
 
     @Autowired
     private DaParamCollectionMapper daParamCollectionMapper;
+
+    @Autowired
+    private MiloService miloService;
+
+    Map<String, Session> map = WebSocketUsers.getUsers();
 
     /**
      * 鏌ヨ閰嶆柟閰嶇疆瀛愪俊鎭�
@@ -133,6 +144,7 @@
         bsFormulaChildInfo.setMaterialCode(bsFormulaChildInfo.getScanBarcode().substring(1,2));
         List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(bsFormulaChildInfo);
         if(bsFormulaChildInfos.size()>0){
+            bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getScanBarcode());
             bsFormulaChildInfos.get(0).setResults("OK");
             bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0));
             bsFormulaChildInfo.setParamValue(bsFormulaChildInfo.getScanBarcode());
@@ -181,6 +193,19 @@
             bsFormulaChildInfos.get(0).setResults("OK");
             bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getTightenTheArray());
             bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0));
+            String spareField4 = bsFormulaChildInfos.get(0).getSpareField4();
+            if (spareField4 != null && !spareField4.isEmpty()) {
+                // 鎵ц鎿嶄綔
+                if(bsFormulaChildInfos.get(0).getSpareField4().equals("1")){
+                    try {
+                        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("OP."+bsFormulaChildInfo.getLocationCode()+".RecordDataDone").value(21).build());
+                        WebSocketUsers.sendMessageToUserByText(map.get(bsFormulaChildInfo.getLocationCode()), "OUT");
+                    } catch (Exception e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+            }
+
         }
         return AjaxResult.success("鎵弿鎴愬姛锛�");
     }
diff --git a/jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/impl/DaParamCollectionServiceImpl.java b/jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/impl/DaParamCollectionServiceImpl.java
index 973d339..3310666 100644
--- a/jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/impl/DaParamCollectionServiceImpl.java
+++ b/jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/impl/DaParamCollectionServiceImpl.java
@@ -127,7 +127,7 @@
             saveData.setWorkOrderNo(daParamCollection.getWorkOrderNo());
             saveData.setProductCode(daParamCollection.getProductCode());
             saveData.setLocationCode(daParamCollection.getLocationCode());
-            saveData.setSfcCode(daParamCollection.getSfcCode());
+            saveData.setSfcCode(daParamCollection.getProductBarcode());
             saveData.setParamCode(daCollectionParamConfs.get(0).getCollectParameterId());
             saveData.setParamName(daCollectionParamConfs.get(0).getCollectParameterName());
             saveData.setCollectionTime(new Date());
diff --git a/jcdm-main/src/main/java/com/jcdm/main/plcserver/CustomRunner.java b/jcdm-main/src/main/java/com/jcdm/main/plcserver/CustomRunner.java
index b836551..ce57a86 100644
--- a/jcdm-main/src/main/java/com/jcdm/main/plcserver/CustomRunner.java
+++ b/jcdm-main/src/main/java/com/jcdm/main/plcserver/CustomRunner.java
@@ -52,6 +52,9 @@
         lists.add(OPCElement.OP_OP010_RecordSN);//璇锋眰涓嬪彂SN鍙�
         lists.add(OPCElement.OP_OP230_RecordData);//璇锋眰璁板綍鏁版嵁
         lists.add(OPCElement.OP_OP240_RecordData);//璇锋眰璁板綍鏁版嵁
+        lists.add(OPCElement.OP_OP240_AngleResult);//璇锋眰璁板綍鏁版嵁
+        lists.add(OPCElement.OP_OP250_RecordData);//璇锋眰璁板綍鏁版嵁
+        lists.add(OPCElement.OP_OP250_AngleResult);//璇锋眰璁板綍鏁版嵁
         return lists;
     }
 }
diff --git a/jcdm-main/src/main/java/com/jcdm/main/plcserver/conf/OPCElement.java b/jcdm-main/src/main/java/com/jcdm/main/plcserver/conf/OPCElement.java
index 93e0c9d..8b2601f 100644
--- a/jcdm-main/src/main/java/com/jcdm/main/plcserver/conf/OPCElement.java
+++ b/jcdm-main/src/main/java/com/jcdm/main/plcserver/conf/OPCElement.java
@@ -8,16 +8,26 @@
 
 
     /**
-     * OP010
+     * OP230
      */
     public static final String OP_OP010_RecordSN = "TestOP.OP1010.RecordSN";//璇锋眰涓嬪彂SN鍙�
     public static final String OP_OP230_RecordData = "OP.OP230.RecordData";//璇锋眰璁板綍鏁版嵁
 
     /**
-     * OP020
+     * OP240
      */
     public static final String OP_OP240_RecordData = "OP.OP240.RecordData";//璇锋眰璁板綍鏁版嵁
 
+    public static final String OP_OP240_AngleResult = "OP.OP240.AngleResult";//璇锋眰鎷х揣鏁版嵁
+
+    /**
+     * OP250
+     */
+    public static final String OP_OP250_RecordData = "OP.OP250.RecordData";//璇锋眰璁板綍鏁版嵁
+
+    public static final String OP_OP250_AngleResult = "OP.OP250.AngleResult";//璇锋眰鎷х揣鏁版嵁
+
+
 
 
 
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 b3f749a..e8db617 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
@@ -81,13 +81,12 @@
                         //杩涚珯淇濆瓨鏁版嵁
 //                        inSaveDate(thoroughfare,device)
                         //璁板綍鏁版嵁瀹屾垚
-                        String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
-                        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(recordDataDoneValue).build());
+//                        String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
+//                        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(recordDataDoneValue).build());
 
                         //缁欏墠绔彂宸ヤ欢鍒颁綅淇″彿
-
+                        WebSocketUsers.sendMessageToUserByText(map.get(device), "IN");
                         //璇锋眰宸ュ崟
-
 
 
 
@@ -98,7 +97,13 @@
                         //璁板綍鏁版嵁瀹屾垚
                         String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
                         miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(recordDataDoneValue).build());
-                    }else if("3".equals(tabVlaue)){
+                    }else {
+                        System.out.println("^");
+                    }
+                }
+                //淇濆瓨鎷х揣鏁版嵁
+                else if (("AngleResult").equals(tab)) {
+                    if("1".equals(tabVlaue)||"2".equals(tabVlaue)){
                         String Torque = thoroughfare + "." + device + ".Torque";
                         String Angle = thoroughfare + "." + device + ".Angle";
                         String Result = thoroughfare + "." + device + ".Result";
@@ -112,14 +117,7 @@
                         List<Object> collect = list1.stream().map(ReadWriteEntity::getValue).collect(Collectors.toList());
                         String joinedString = String.join(",", collect.toString());
                         WebSocketUsers.sendMessageToUserByText(map.get(device), joinedString);
-                    }else {
-                        System.out.println("^");
-
                     }
-
-
-
-
                 }
             }
         } catch (Exception e) {
diff --git a/jcdm-ui/src/views/main/kb/stationTerminal/index.vue b/jcdm-ui/src/views/main/kb/stationTerminal/index.vue
index 55e2968..c9fb425 100644
--- a/jcdm-ui/src/views/main/kb/stationTerminal/index.vue
+++ b/jcdm-ui/src/views/main/kb/stationTerminal/index.vue
@@ -107,7 +107,7 @@
            <span slot="label"> <a class="el-icon-date"></a>棣栭〉</span>
            <el-col :span="24">
              <el-table :cell-style="rowStyle" :data="formulaChildList">
-               <el-table-column label="鎺掑簭" width="60" align="center" prop="stepSort">
+               <el-table-column label="鎺掑簭" width="60" align="center" type="index">
                </el-table-column>
                <el-table-column label="鎿嶄綔鍐呭" :show-overflow-tooltip='true' align="center" prop="operationSteps">
                </el-table-column>
@@ -359,7 +359,7 @@
       },
       content: '',
       activeName: 'first',
-      url: "ws://192.168.11.76:8080/websocket/message/",
+      url: "ws://192.168.10.21:8080/websocket/message/",
       message: "",
       text_content: "",
       ws: null,
@@ -490,11 +490,11 @@
     },
     /** 鏌ヨ閰嶆柟閰嶇疆瀛愪俊鎭垪琛� */
     getListFormulaChild() {
+      this.formulaChildList = []
       this.formulaChildParams.productCode = this.workpieceInformation.productCode
       this.formulaChildParams.processesCode = this.headContent.processesCode
       listFormulaChild(this.formulaChildParams).then(response => {
         this.formulaChildList = response.rows;
-        console.log(this.formulaChildList)
       });
     },
 
@@ -631,32 +631,39 @@
           self.cakeLamp.InPlace = 0;
         } else if (event.data === "OUT") {
           self.cakeLamp.release = 1;
-          setTimeout(() => {
-            self.cakeLamp.InPlace = 0;
-            self.cakeLamp.release = 0;
-            self.cakeLamp.startWork = 0;
-            self.cakeLamp.scanFinish = 0;
-            self.Release();
-          }, DELAY_TIME);
+          // setTimeout(() => {
+          //   self.cakeLamp.InPlace = 0;
+          //   self.cakeLamp.release = 0;
+          //   self.cakeLamp.startWork = 0;
+          //   self.cakeLamp.scanFinish = 0;
+          //   self.Release();
+          // }, DELAY_TIME);
         } else if (event.data === "TIGHTEN") {
           this.formulaChildList = [];
           self.getListFormulaChild();
         } else if (event.data.includes("[")) {
-          // console.log('event.data'+event.data)
-          // let eventArr = event.data.split("[")[1].split("]")[0].split(", ");
-          // let eventArr1 = event.data.replace('[', '').replace(']', '').trim().split(', ');
-          // console.log(eventArr1)
-          // console.log(Array.isArray(eventArr))
           let formulaChilds = "";
-          self.formulaChildList.forEach((formulaChild) => {
-            let operationType = formulaChild.operationType;
+          self.formulaChildList.sort((a, b) => a.stepSort - b.stepSort);
+          self.formulaChildList
+            .filter((formulaChild) => formulaChild.operationType === '1');
+          for (let i = 0; i < self.formulaChildList.length; i++) {
+            let formulaChild = self.formulaChildList[i];
             let results = formulaChild.results;
-            if(operationType === '1' && (results === '' || results === null || results === 'NG')){
+            if (results === '' || results === null || results === 'NG') {
               formulaChilds = formulaChild;
-              return; // 浣跨敤return浠f浛break
+              break;
             }
-            // 鎵ц鍏朵粬鎿嶄綔
-          });
+          }
+          // self.formulaChildList.sort((a, b) => a.stepSort - b.stepSort);
+          // self.formulaChildList.forEach((formulaChild) => {
+          //   let operationType = formulaChild.operationType;
+          //   let results = formulaChild.results;
+          //   if(operationType === '1' && (results === '' || results === null || results === 'NG')){
+          //     formulaChilds = formulaChild;
+          //     return; // 浣跨敤return浠f浛break
+          //   }
+          //   // 鎵ц鍏朵粬鎿嶄綔
+          // });
           const param = {
             tightenTheArray: event.data,
             paramCode: formulaChilds.paramCode,
@@ -678,19 +685,21 @@
       if (this.form1.isShowHistory) this.form1.desc = this.readLi().join("");
       else {
         const scanValue = this.myserialport.hex2atostr(value).replace(/[\r\n]/g, '');
-        this.$message('鎵爜瀹屾垚'+this.content);
-
-        if(this.headContent.sfcCode !== ''){
-          console.log(scanValue)
-          this.serialPortMethod(scanValue)
-        }else {
-          this.headContent.sfcCode = scanValue;
-          this.queryParams.productNum = scanValue;
-          this.getList()
-          // this.getListFormulaChild()
-          this.cakeLamp.scanFinish = 1
-          this.cakeLamp.startWork = 1
-        }
+        // if(this.cakeLamp.InPlace=== 1){
+          if(this.headContent.sfcCode !== ''){
+            console.log(scanValue)
+            this.serialPortMethod(scanValue)
+          }else {
+            this.headContent.sfcCode = scanValue;
+            this.queryParams.productNum = scanValue;
+            this.getList()
+            // this.getListFormulaChild()
+            this.cakeLamp.scanFinish = 1
+            this.cakeLamp.startWork = 1
+          }
+        // }else {
+        //   this.$message('宸ヤ欢鏈埌浣嶇姝㈡壂鐮侊紒');
+        // }
       }
     },
     clearHistory() {

--
Gitblit v1.9.3