From 059083082a6d284821b70eb7bb6805763014c402 Mon Sep 17 00:00:00 2001
From: wujian <14790700720@163.com>
Date: 星期六, 16 三月 2024 10:54:46 +0800
Subject: [PATCH] add PLC连接通信 add 扫码数据推送到前端

---
 jcdm-ui/src/views/main/kb/engineCheck/index.vue |  327 +++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 222 insertions(+), 105 deletions(-)

diff --git a/jcdm-ui/src/views/main/kb/engineCheck/index.vue b/jcdm-ui/src/views/main/kb/engineCheck/index.vue
index 7f0964b..2e2ac99 100644
--- a/jcdm-ui/src/views/main/kb/engineCheck/index.vue
+++ b/jcdm-ui/src/views/main/kb/engineCheck/index.vue
@@ -1,84 +1,73 @@
 <template>
   <div class="app-container">
-    <el-card  style="height: 70px;margin-bottom: 10px" class="box-card" >
+    <el-card   class="box-card"  style="height: 60px" >
       <template>
-        <div class="container">
-          <el-row type="flex" justify="center"  style="text-align: center" >
-            <el-col :span="12">
-              <span style="fontSize:30px;color:black">--------------------鍙戝姩鏈烘暟鎹鏌�--------------------</span>
-            </el-col>
-          </el-row>
+        <div class="container" type="flex" justify="center" style="text-align:center">
+<!--          <el-row   type="flex" justify="center" style="text-align:center;height: 12px" >-->
+<!--            <el-col  type="flex" justify="center"  :span="14" style="text-align:center">-->
+          <el-divider><span style="font-size:22px;color:black"><strong>鍙戝姩鏈烘暟鎹鏌�</strong></span></el-divider>
+<!--            </el-col>-->
+<!--          </el-row>-->
         </div>
       </template>
     </el-card>
-   <el-row :gutter="5"  style="margin-top: 10px">
-     <el-col :span="10" >
-       <el-card class="bottom-card">
-         <el-descriptions :column="1" >
-           <el-descriptions-item>
-             <el-form ref="form" :model="form"  label-width="200px" style="height: 60px;margin-top: 20px" >
-               <el-form-item prop="engineNo" >
-      	     <span slot="label" style="font-size:45px;color:black"><strong>鍙戝姩鏈哄彿</strong></span>
-                 <el-input style="font-size:30px" v-model="form.engineNo" placeholder="璇疯緭鍏ュ彂鍔ㄦ満鍙�" >
-                   <el-button slot="append" @click="EngineNohandleChange" icon="el-icon-search"></el-button>
+   <el-row :gutter="0"  >
+     <el-col :span="14">
+       <el-card   class="box-card" style="margin-top: 5px" >
+             <el-form ref="form" :model="form"  label-width="25%"   >
+               <el-form-item prop="engineNo" style="margin-top: 16px">
+      	     <span slot="label" style="font-size:22px;color:black;"><strong>鍙戝姩鏈哄彿</strong></span>
+                 <el-input style="font-size:20px" v-model="form.engineNo" placeholder="璇疯緭鍏ュ彂鍔ㄦ満鍙�" clearable  @keyup.enter.native="EngineNohandleChange" >
+                   <el-button slot="append" plain type="info" @click="EngineNohandleChange(form.engineNo)" icon="el-icon-search"></el-button>
                  </el-input>
                </el-form-item>
              </el-form>
-           </el-descriptions-item>
-           <el-descriptions-item>
-             <el-form ref="form" :model="form"  label-width="200px" style="height: 60px;margin-top: 20px" >
-               <el-form-item   prop="productType" >
-      	     <span slot="label" style="font-size:45px;color:black"><strong>浜у搧鍨嬪彿</strong></span>
-                 <el-input disabled style="font-size:30px" v-model="form.productType" placeholder="" />
+             <el-form ref="form" :model="form"  label-width="25%"  >
+               <el-form-item   prop="productType"style="margin-top: 30px" >
+      	        <span slot="label" style="font-size:22px;color:black"><strong>鏈哄瀷</strong></span>
+                 <el-input disabled style="font-size:20px"  value="form.productType" v-model="form.productType" placeholder="" />
                </el-form-item>
              </el-form>
-           </el-descriptions-item>
-           <el-descriptions-item>
-             <el-form ref="form" :model="form"  label-width="200px" style="height: 60px;margin-top: 20px" >
-               <el-form-item   prop="orderNo" >
-      	     <span  slot="label" style="font-size:45px;color:black"><strong>宸ュ崟缂栧彿</strong></span>
-                 <el-input disabled style="font-size:30px" v-model="form.orderNo" placeholder="" />
+             <el-form ref="form" :model="form"  label-width="25%"  >
+               <el-form-item   prop="orderNo" style="margin-top: 30px">
+      	     <span  slot="label" style="font-size:22px;color:black"><strong>宸ュ崟缂栧彿</strong></span>
+                 <el-input disabled style="font-size:20px" v-model="form.orderNo" placeholder="" />
                </el-form-item>
              </el-form>
-           </el-descriptions-item>
-           <el-descriptions-item>
-             <el-form ref="form" :model="form"  label-width="200px" style="height: 60px;margin-top: 20px" >
-               <el-form-item   prop="qualityStatus" >
-      	     <span slot="label" style="font-size:45px;color:black"><strong>璐ㄩ噺鐘舵��</strong></span>
-                 <el-input disabled style="font-size:30px" v-model="form.qualityStatus" placeholder="" />
+             <el-form ref="form" :model="form"  label-width="25%"  >
+               <el-form-item   prop="currentWorkstation" style="margin-top: 30px">
+      	     <span slot="label" style="font-size:22px;color:black"><strong>璐ㄩ噺鐘舵��</strong></span>
+                 <el-input disabled style="font-size:20px" v-model:value="form.add" placeholder="" />
                </el-form-item>
              </el-form>
-           </el-descriptions-item>
-         </el-descriptions>
          <el-divider></el-divider>
+
          <el-row :gutter="10" class="mb8" type="flex" justify="center"  style="text-align: center">
            <el-col :span="1.5">
-             <el-button plain  style="width:400px;height:160px" v-hasPermi="['bs:formula:add']">
-               <span   class="el-icon-thumb"   style="font-size:45px;color:black"></span>
-               <span style="font-size:45px;color:black"><strong>寮哄埗涓婄嚎</strong></span></el-button>
+             <el-button plain  :disabled="buttondisabled" type="primary" style="width:400px;height:160px" v-hasPermi="['bs:formula:add']">
+               <span   class="el-icon-thumb"   style="font-size:40px;color:black"></span>
+               <span style="font-size:45px;color:black"><strong>寮哄埗涓婄嚎</strong></span>
+             </el-button>
            </el-col>
          </el-row>
        </el-card>
      </el-col>
 
-
-     <el-col :span="14"  inline style="height:600px;width:850px  ">
-       <el-tabs type="border-card"  >
-         <el-card>
-         <el-col :span="14"style="height: 270px;width:800px  ">
+     <el-col :span="10"  inline style="margin-top: 5px">
+         <el-card class="custom-content"  style="height: 264px">
+         <el-col :span="14">
            <span style="font-size:25px"><strong>璐ㄩ噺鐘舵��</strong></span>
            <el-divider></el-divider>
-           {{queryParams.productType}}
+           {{this.form.engineCheckList}}
          </el-col>
          </el-card>
-         <el-card style="margin-top: 10px" >
-         <el-col :span="14"style="height: 270px;width:800px  ">
+         <el-card class="custom-content" style="height: 264px" >
+         <el-col :span="14"style="  ">
            <span style="font-size:25px"><strong>鏈�缁堢粨鏋�</strong></span>
            <el-divider></el-divider>
            {{queryParams.productType}}
          </el-col>
          </el-card>
-       </el-tabs>
      </el-col>
    </el-row>
   </div>
@@ -86,9 +75,43 @@
 <script>
 
 import { listOrderScheduling, getOrderScheduling, delOrderScheduling, addOrderScheduling, updateOrderScheduling } from "@/api/main/bs/orderScheduling/orderScheduling";
-import {listWorkshop} from "@/api/main/bs/workshop/workshop";
-import axios from 'axios';
+import { listPassingStationCollection, getPassingStationCollection, delPassingStationCollection, addPassingStationCollection, updatePassingStationCollection } from "@/api/main/da/passingStationCollection/passingStationCollection";
+import {listLineInfo} from "@/api/main/bs/lineInfo/lineInfo";
+import WebSocketReconnect from "@/utils/WebsocketTool";
 
+// let websocket = null
+// //鍒ゆ柇褰撳墠娴忚鍣ㄦ槸鍚︽敮鎸乄ebSocket
+// if ('WebSocket' in window) {
+//   //杩炴帴WebSocket鑺傜偣
+//   websocket = new WebSocketReconnect('ws://127.0.0.1:8086/websocket/111122')
+// } else {
+//   alert('娴忚鍣ㄤ笉鏀寔webSocket')
+// }
+// //鎺ユ敹鍒版秷鎭殑鍥炶皟鏂规硶
+// websocket.socket.onmessage = function (event) {
+//   let data = event.data
+//   console.log('鍚庣浼犻�掔殑鏁版嵁:' + data)
+//   if (data != null && data !== ''){
+//     this.result = JSON.parse(data)
+//     console.log('this.result',this.result)
+//     // this.form.engineNo = this.result.server_message
+//     this.transEngineNo = this.result.server_message
+//     console.log('this.transEngineNo11111111111',this.transEngineNo)
+//   }
+//
+// }
+// //鐩戝惉绐楀彛鍏抽棴浜嬩欢锛屽綋绐楀彛鍏抽棴鏃讹紝涓诲姩鍘诲叧闂瓀ebsocket杩炴帴锛岄槻姝㈣繛鎺ヨ繕娌℃柇寮�灏卞叧闂獥鍙o紝server绔細鎶涘紓甯搞��
+// window.onbeforeunload = function () {
+//   websocket.close()
+// }
+// //鍏抽棴杩炴帴
+// function closeWebSocket() {
+//   websocket.close()
+// }
+// //鍙戦�佹秷鎭�
+// function send() {
+//   websocket.socket.send({ kk: 123 })
+// }
 
 export default {
   components: { },
@@ -96,80 +119,174 @@
   props: [],
   data() {
     return {
+      websocket: null,
+      result: {},
+      transEngineNo: '',
+      options: [],
+      total: 0,
+      engineCheckList:[],
       showFlag:false,
+      buttondisabled:true,
+      mess:'',
       // 鏌ヨ鍙傛暟
       queryParams: {
         pageNum: 1,
         pageSize: 10,
-        orderNo: null,
         engineNo: null,
-        productType: '666',
-        model: null,
-        productionStatus: null,
-        workingHours: null,
+        productType:null,
+        orderNo:null,
+        qualityStatus:null,
         currentWorkstation: null,
-        qualityStatus: null,
-        whetherOrPrint: null,
-        report10: null,
-        report20: null,
-        combinedBoxTime: null,
-        finalAssemblyTime: null,
-        operator: null,
-        operateTime: null,
-        status: null,
-        spareField1: null,
-        spareField2: null,
-        spareField3: null,
-        spareField4: null,
-        createUser: null,
-        updateUser: null,
-        remarks: null
+        add: null,
+        engineCheckList:'鏆傛棤鏁版嵁',
       },
-
       // 琛ㄥ崟鍙傛暟
-      form: {},
+      form: {
+        engineNo: null,
+        productType:null,
+        orderNo:null,
+        qualityStatus:null,
+        currentWorkstation: null,
+        add: null,
+        engineCheckList:'鏆傛棤鏁版嵁',
+      },
+      add: null,
     };
   },
-
   computed: {},
-  watch: {},
-  created() {
-    this.initOrderScheduling();
+  watch: {
+    // transEngineNo:{
+    //   handler(newVal,oldVal) {
+    //     console.log('newVal',newVal)
+    //     console.log('oldVal',oldVal)
+    //     this.form.engineNo = newVal
+    //     console.log('11111111111111')
+    //     console.log('this.form.engineNo',this.form.engineNo)
+    //   },
+    //   immediate:true
+    // }
   },
-  mounted() {},
+  created() {},
+  mounted() {
+    this.initWebSocket()
+  },
   methods: {
+    initWebSocket: function (){
+      //鍒ゆ柇褰撳墠娴忚鍣ㄦ槸鍚︽敮鎸乄ebSocket
+      if ('WebSocket' in window) {
+        //杩炴帴WebSocket鑺傜偣
+        this.websocket = new WebSocketReconnect('ws://127.0.0.1:8086/websocket/111122')
 
-    EngineNohandleChange(){
-      axios.get('@/api/main/bs/orderScheduling/orderScheduling', {
-        params: {
-          engineNo: this.engineNo,
-        },
-      })
-        .then(response => {
-          const dataFromOrderScheduling = response.data;
-          if (dataFromOrderScheduling.length > 0) {
-            const order = dataFromOrderScheduling[0];
-            this.engineNo = order.engineNo;
-            this.productType = order.productType;
-            this.orderNo = order.orderNo;
-          } else {
-            // Handle case when no data is found
+        //鎺ユ敹鍒版秷鎭殑鍥炶皟鏂规硶
+        this.websocket.socket.onmessage = (event) => {
+          let data = event.data
+          console.log('鍚庣浼犻�掔殑鏁版嵁:' + data)
+          if (data != null && data !== ''){
+            this.result = JSON.parse(data)
+            console.log('this.result',this.result)
+            this.form.engineNo = this.result.server_message
+            // this.transEngineNo = this.result.server_message
+            console.log('this.transEngineNo11111111111',this.transEngineNo)
           }
-        })
-        .catch(error => {
-          console.error(error);
+        }
+//鐩戝惉绐楀彛鍏抽棴浜嬩欢锛屽綋绐楀彛鍏抽棴鏃讹紝涓诲姩鍘诲叧闂瓀ebsocket杩炴帴锛岄槻姝㈣繛鎺ヨ繕娌℃柇寮�灏卞叧闂獥鍙o紝server绔細鎶涘紓甯搞��
+        window.onbeforeunload = function () {
+          this.websocket.close()
+        }
+//鍏抽棴杩炴帴
+        function closeWebSocket() {
+          this.websocket.close()
+        }
+//鍙戦�佹秷鎭�
+        function send() {
+          this.websocket.socket.send({ kk: 123 })
+        }
+      } else {
+        alert('娴忚鍣ㄤ笉鏀寔webSocket')
+      }
+    },
+    reset() {
+      this.form = {
+        engineNo:null,
+        productType:null,
+        orderNo:null,
+        qualityStatus:null,
+        currentWorkstation: null,
+        add: null,
+        engineCheckList:'鏆傛棤鏁版嵁',
+      };
+      this.resetForm("form");
+    },
+    EngineNohandleChange(){
+      if(this.form.engineNo !== null && this.form.engineNo !== undefined){
+        let OrderSchedulingParam = {engineNo: null}
+        OrderSchedulingParam.engineNo = this.form.engineNo;
+        listOrderScheduling(OrderSchedulingParam).then(response => {
+          if(response.total === 1 ){
+            this.form.productType = response.rows[0].model
+            this.form.orderNo = response.rows[0].orderNo
+            this.form.qualityStatus = response.rows[0].qualityStatus
+            this.form.currentWorkstation = response.rows[0].currentWorkstation
+            this.form.add= response.rows[0].currentWorkstation+ response.rows[0].qualityStatus
+            if(this.form.qualityStatus ==='涓嶅悎鏍�'){
+              this.buttondisabled = false;
+            }
+            else{
+              this.buttondisabled = true;
+            }
+          }
+          else{
+            this.reset();
+            this.buttondisabled = true
+            const h = this.$createElement;
+            this.$message({
+              message: h('p',null, [
+                       h('span', null, '璀﹀憡 '),
+                       h('i', { style: 'color: black' }, '杈撳叆鐨勫彂鍔ㄦ満鍙锋湁璇�'),
+                       h()]),
+              type: 'error',
+              center: true,
+              offset:300
+            });
+          }
         });
+        let PassingStationCollectionParam = {sfcCode: null}
+        PassingStationCollectionParam.sfcCode = this.form.engineNo;
+        listPassingStationCollection(PassingStationCollectionParam).then(ponse =>{
+          this.engineCheckList = ponse.rows.locationCode ;
+          if(ponse.rows.length >= 1 && this.form.engineNo !== undefined){
+            this.form.engineCheckList = ''
+            for (let i = 0; i < ponse.rows.length; i++) {
+              this.form.engineCheckList += '   宸ヤ綅:'+ ponse.rows[i].locationCode+'['+ponse.rows[i].outRsSign+']'
+            }
+          }
+          else{
+            this.form.engineCheckList = '鏆傛棤鏁版嵁'
+          }
+        });
+      }
     },
+
+
   },
-
-    initOrderScheduling(){
-      listOrderScheduling(this.queryParams).then(response => {
-        this.form.queryParams = response.rows;
-
-      });
-    },
   }
 
 
 </script>
-
+<style scoped>
+::v-deep .el-input__inner{
+  height: 40px;
+}
+::v-deep .el-form-item__label {
+  line-height: 40px;
+}
+.custom-content {
+  height: 50%; /* 璁剧疆楂樺害涓�50% */
+}
+/*.my-custom-modal .el-dialog__wrapper {*/
+/*  width: 400px; !* 璁剧疆瀹藉害 *!*/
+/*  height: 200px; !* 璁剧疆楂樺害 *!*/
+/*  top: 50px; !* 璁剧疆璺濈椤甸潰椤堕儴鐨勪綅缃� *!*/
+/*  left: 50px; !* 璁剧疆璺濈椤甸潰宸︿晶鐨勪綅缃� *!*/
+/*}*/
+</style>

--
Gitblit v1.9.3