admin
2024-08-12 4280d7277bc0f9b5c3dfad6d59d833aa89294f69
提交 | 用户 | 时间
b78728 1 <template>
A 2   <div class="app-container">
3    <el-row :gutter="5">
bf111f 4      <el-col :span="7">
A 5        <el-card style="height: 71px;padding-top: 6px" shadow="never">
6           <span class="head-font">工位编号 : {{headContent.processesCode}}</span>
b78728 7        </el-card>
A 8      </el-col>
dd5d35 9      <el-col :span="17">
b78728 10        <el-card shadow="never">
dd5d35 11          <span class="head-font">物料编码 : </span>
3c3c4d 12          <el-input style="width: 50%" ref="inputData" v-model="materialCode" @change="handleEnter" placeholder="请扫描物料编码"></el-input>
dd5d35 13          <el-button @click="clearClick" style="float: right" type="danger" >清除</el-button>
b78728 14        </el-card>
A 15      </el-col>
16
17    </el-row>
18    <el-row :gutter="5" style="margin-top: 5px">
19      <el-col :span="7" >
20        <el-card class="bottom-card">
21          <div slot="header" class="clearfix">
22            <i class="el-icon-tickets"></i>
23            <span style="font-weight: bold">当前工件信息</span>
24          </div>
25          <el-descriptions :column="1" border :content-style="{'min-width': '140px'}">
dd5d35 26            <el-descriptions-item label="产品序列号">
A 27              <span>{{headContent.sfcCode}}</span>
28            </el-descriptions-item>
b78728 29            <el-descriptions-item label="工单编号">
A 30                <span>{{workpieceInformation.workOrderNo}}</span>
31            </el-descriptions-item>
32            <el-descriptions-item label="物料编码">
33              <span>{{workpieceInformation.materialCode}}</span>
34            </el-descriptions-item>
35            <el-descriptions-item label="计划数量">
36              <span>{{workpieceInformation.planQty}}</span>
37            </el-descriptions-item>
38            <el-descriptions-item label="开始时间">
39              <span>{{workpieceInformation.inboundTime}}</span>
40            </el-descriptions-item>
41          </el-descriptions>
42          <el-divider></el-divider>
43          <el-row>
44            <el-col :span="12">
45              <el-button class="circle-button" :class="cakeLamp.plcState ? 'circle-green-animate':'circle-red'" circle></el-button>
46              <span style="display: none">{{cakeLamp.plcState}}</span>
47              <span>&nbsp;PLC状态</span>
48            </el-col>
49            <el-col :span="12">
50              <el-button class="circle-button" :class="cakeLamp.scannerState ? 'circle-green-animate':'circle-red'" circle></el-button>
51              <span style="display: none">{{cakeLamp.scannerState}}</span>
52              <span>&nbsp;扫码枪状态</span>
53            </el-col>
54          </el-row>
55          <el-row style="margin-top: 20px">
56            <el-col :span="12">
57              <el-button class="circle-button" :class="cakeLamp.InPlace ? 'circle-green':'circle-red'" circle></el-button>
58              <span style="display: none">{{cakeLamp.InPlace}}</span>
59              <span>&nbsp;工件到位</span>
60            </el-col>
61            <el-col :span="12">
62              <el-button class="circle-button" :class="cakeLamp.scanFinish ? 'circle-green':'circle-red'" circle></el-button>
63              <span style="display: none">{{cakeLamp.scanFinish}}</span>
64              <span>&nbsp;扫码完成</span>
65            </el-col>
66          </el-row>
67          <el-row style="margin-top: 20px">
68            <el-col :span="12">
69              <el-button class="circle-button" :class="cakeLamp.startWork ? 'circle-green':'circle-red'" circle></el-button>
70              <span style="display: none">{{cakeLamp.startWork}}</span>
71              <span>&nbsp;开始作业</span>
72            </el-col>
73            <el-col :span="12">
74              <el-button class="circle-button" :class="cakeLamp.release ? 'circle-green':'circle-red'" circle></el-button>
75              <span style="display: none">{{cakeLamp.release}}</span>
76              <span>&nbsp;允许放行</span>
77            </el-col>
78          </el-row>
79          <el-row v-show="orderFlag" style="margin-top: 20px">
4280d7 80 <!--           <el-button @click="getWorkOrders" type="warning" size="mini">接收工单</el-button>-->
b78728 81          </el-row>
A 82        </el-card>
83
84      </el-col>
85      <el-col :span="17">
777422 86        <el-tabs type="border-card"  style="height: 600px" v-model="activeName">
b78728 87          <el-tab-pane name="first">
A 88            <span slot="label"> <a class="el-icon-date"></a>首页</span>
89            <el-col :span="24">
90              <el-table height="500" :cell-style="rowStyle" :data="formulaChildList">
91                <el-table-column label="拧紧步号" width="80" align="center" prop="stepSort">
92                </el-table-column>
93                <el-table-column label="操作内容" align="center" prop="operationSteps">
94                </el-table-column>
95                <el-table-column label="产品编号" width="80" align="center" prop="productCode">
96                </el-table-column>
97                <el-table-column label="物料编码" width="110" align="center" prop="materialCode">
98                </el-table-column>
99                <el-table-column label="采集值" align="center" prop="collectData">
100                </el-table-column>
101                <el-table-column label="结果" width="60" align="center" prop="results">
102                </el-table-column>
103
104              </el-table>
105            </el-col>
106          </el-tab-pane>
107        </el-tabs>
108      </el-col>
109    </el-row>
110   </div>
111 </template>
112 <script>
113 import {listWorkReport} from "@/api/main/om/workReport/workReport";
114 import {listStationConf,getIpv4} from "@/api/main/sc/stationConf";
115 import {
116   clearWorkpieceRelease,
117   fistSetpNumber, initializedData,
118   listFormulaChild,
119   noPageListFormulaChild,
120   releaseCheck, unfinishedProcess,
121   updateResults,
122   updateTighteningFormula,
123   workpieceRelease
124 } from "@/api/main/bs/formulaChild/formulaChild";
125 import MySerialPort from "@/utils/MySerialPort";
126 import USBDevice from "@/utils/usb.json";
127 import {
128   bindYzSfcFlag,
129   checkCarCode, checkYzSfcCode,
130   findBytrolleyYardGetOne,
131   listProductionOrde, mozuReceivingWorkOrders,
132   receivingWorkOrders,
133   trolleyYardBinDing
134 } from "@/api/main/om/productionOrde/productionOrde";
135 import {addPassingStationCollection} from "@/api/main/da/passingStationCollection/passingStationCollection";
136 import {
137   addBasicParameters,
138   addParamCollection,
139   addTighteningParameters,
140   saveCampaignTimeParameters,
141   replaceAssemblyCode, checkRecordDataDone,
142 } from "@/api/main/da/paramCollection/paramCollection";
143 import {addFormula} from "@/api/main/bs/formula/formula";
144
145 export default {
146   name: "stationTerminal",
147   data() {
148     return {
dd5d35 149       materialCode: '', // 物料编码
b78728 150       carCode: '',
A 151       showInput: false,
152       onLineBinDing: false,
153
154       serialPortContent: '',
155       // 查询参数
156       formulaChildParams: {
157         pageNum: 1,
158         pageSize: 10,
159         productCode: null,
160         processesCode: null,
161       },
162       // 配方配置子信息表格数据
163       formulaChildList: [],
164       ipAddress: '',
165       imgSrc: '',
166       headContent: {
167         processesCode: 'OP1010',
168         processesName: '贴标机-贴码',
169         sfcCode: '',
170         yzSfcCode: '',
171         cardCode: '',
172       },
173       workpieceInformation: {
174         workOrderNo: null,
175         productCode: null,
176         productModel: null,
177         productName: null,
178         inboundTime: null,
179         materialCode: null,
180         planQty: null,
181       },
182       // 查询参数
183       queryParams: {
184         pageNum: 1,
185         pageSize: 10,
186         sfcCode: null,
187       },
188       // 查询参数
189       StationConfQueryParams: {
190         pageNum: 1,
191         pageSize: 10,
192         ipAddress: null,
193       },
194       cakeLamp: {
195         plcState: 1, //plc
196         scannerState: 1, //扫码枪
197         InPlace: 0, //工件到位
198         scanFinish: 0,
199         startWork: 0,
200         release: 0 //允许放行
201       },
202       content: '',
d0af65 203       url: "ws://10.103.210.248:8080/websocket/message/",
A 204       // url: "ws://192.168.20.250:8080/websocket/message/",
b78728 205
A 206       passingStationForm: {},
207       originalArray: [],
777422 208       orderFlag: true,
A 209       activeName: 'first',
210
b78728 211     }
d5a701 212   },
C 213   mounted() {
214     this.setFocus()
b78728 215   },
A 216   beforeDestroy() {
217     this.exit();
218   },
219   created() {
220     this.initStation();
221   },
222   computed: {
223     isDisable() {
224       return this.btnType === "danger";
225     },
226   },
227   methods: {
d5a701 228     setFocus(){
C 229       this.$nextTick(()=>{
230         this.$refs.inputData.focus()
231       })
232     },
777422 233     changeMenu(tab, event) {
A 234       console.log(tab, event);
235     },
dd5d35 236     handleEnter() {
3c3c4d 237       this.serialPortMethod(this.materialCode);
dd5d35 238       this.$message("扫描物料编码"+this.materialCode);
5b939f 239       this.setFocus();
C 240       this.materialCode="";
dd5d35 241     },
4280d7 242     // getWorkOrders(){
A 243     //   if(this.headContent.sfcCode === '' || this.headContent.sfcCode === null){
244     //     //接收工单
245     //     const param = {
246     //       lineCode: this.headContent.processesCode
247     //     }
248     //     mozuReceivingWorkOrders(param).then(response => {
249     //       this.headContent.sfcCode = response.msg;
250     //       this.queryParams.productNum = response.msg;
251     //       this.getList()
252     //       this.cakeLamp.scanFinish = 1
253     //       this.cakeLamp.startWork = 1
254     //       this.cakeLamp.InPlace = 1
255     //     });
256     //   }else {
257     //     this.$message.error("已经有工单了,不能接收!");
258     //   }
259     // },
b78728 260     serialLink() {
A 261       this.open1 = true
262     },
263     serialPortMethod(value){
264       let formulaChildParams = {
265         scanBarcode: value,
266         sfcBarcode: this.headContent.sfcCode,
267         workOrderNo: this.workpieceInformation.workOrderNo,
268         productCode: this.workpieceInformation.productCode,
269         locationCode: this.headContent.processesCode,
270         collectionTime: new Date()
271       }
272       updateResults(formulaChildParams).then(response => {
273         console.log(response)
274         if(response.msg === "3"){
275           this.cakeLamp.release= 1 //允许放行
276         }else if(response.msg === "2"){
277           this.$message.error('扫码重复请重新扫码!');
278         }
279         this.getListFormulaChild()
280       });
281     },
282     rowStyle({ row }) {
283       if (row.results === 'OK') {
284         return 'background-color: PaleGreen';
285       } else if (row.results === 'NG') {
286         return 'background-color: LightSalmon';
287       }
288       return '';
289     },
290     /** 查询配方配置子信息列表 */
291     getListFormulaChild() {
292       // this.formulaChildList = []
293       this.formulaChildParams.productCode = this.workpieceInformation.productCode
294       this.formulaChildParams.processesCode = this.headContent.processesCode
295       console.log(this.formulaChildParams)
296       noPageListFormulaChild(this.formulaChildParams).then(response => {
297         this.formulaChildList = response.rows;
298         if (this.formulaChildList.length >0){
299           let pos = 0
300           const tempArr = this.formulaChildList.filter(x=> 'OK' === x.results)
301           if (tempArr.length>0){
302             pos = tempArr.length
303             this.$nextTick(() => {
304               let temp33 = document.getElementsByClassName('el-table__row')
305               console.log('temp33',temp33)
306               console.log('len',temp33.item(pos))
307               if (temp33.length > 0){
308                 console.log('1111111111111111')
309                 let arr = temp33[pos-1]
310                 console.log('srr',arr)
311                 arr.scrollIntoView({ block: 'center' })
312               }
313             })
314           }
315
316         }
317
318       });
319     },
320     endClear(){
321       this.cakeLamp.InPlace= 0 //工件到位
322       this.cakeLamp.scanFinish= 0
323       this.cakeLamp.startWork= 0
324       this.cakeLamp.release= 0 //允许放行
325
326       this.formulaChildList = []
327       this.workpieceInformation.productCode = null;
328       this.workpieceInformation.workOrderNo = null;
329       this.workpieceInformation.productModel = null;
330       this.workpieceInformation.productName = null;
331       this.workpieceInformation.inboundTime = null;
332       this.headContent.sfcCode = '';
333       this.headContent.yzSfcCode = '';
334       this.headContent.cardCode = '';
777422 335       this.workpieceInformation.planQty = ''
b78728 336     },
A 337     clearClick(){
338       const param = {
339         workOrderNo: this.workpieceInformation.workOrderNo,
340         productCode: this.workpieceInformation.productCode,
341         locationCode: this.headContent.processesCode,
342         productBarcode: this.headContent.sfcCode,
343       }
344       this.endClear()
345       clearWorkpieceRelease(param).then(response => {});
346       this.headContent.sfcCode = ''
347       this.$message('清除成功!');
348     },
349     /** 查询工单列表 */
350     async getList() {
351       await listProductionOrde(this.queryParams).then(response => {
352         let rowsData = response.rows[0];
353         console.log(rowsData)
354         this.workpieceInformation.workOrderNo = rowsData.workOrderNo;
355         this.workpieceInformation.productCode = rowsData.productCode;
356         this.workpieceInformation.materialCode = rowsData.materialCode;
357         this.workpieceInformation.planQty = rowsData.planQty;
358         this.headContent.cardCode = rowsData.trolleyYard;
359       });
360       this.getListFormulaChild()
361       this.workpieceInformation.inboundTime = this.getCurrentTime()
4280d7 362
b78728 363     },
A 364
365     initializedData(){
366       const param = {
367         locationCode: this.headContent.processesCode,
368       }
369       initializedData(param).then(response => {
370         if(response.msg !== ''){
371           this.headContent.sfcCode = response.msg;
372           this.queryParams.productNum = response.msg;
373           this.getList()
374           this.cakeLamp.scanFinish = 1
375           this.cakeLamp.startWork = 1
376           this.cakeLamp.InPlace = 1
377         }
378       });
379     },
380
381     getCurrentTime() {
382       const now = new Date();
383       const year = now.getFullYear();
384       const month = this.padTimeUnit(now.getMonth() + 1); // 月份是从0开始的
385       const day = this.padTimeUnit(now.getDate());
386       const hours = this.padTimeUnit(now.getHours());
387       const minutes = this.padTimeUnit(now.getMinutes());
388       const seconds = this.padTimeUnit(now.getSeconds());
389       return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
390     },
391     padTimeUnit(value) {
392       return value.toString().padStart(2, '0');
393     },
394
395     exit() {
396       if (this.ws) {
397         this.ws.close();
398         this.ws = null;
399       }
400     },
401     send() {
402       if (this.ws) {
403         this.ws.send(this.message);
404       } else {
405         alert("未连接到服务器");
406       }
407     },
408
409     initStation: async function () {
410       await getIpv4().then(response => {
411         this.StationConfQueryParams.ipAddress = response.msg
412         console.log('查询到本工位IP为' + this.StationConfQueryParams.ipAddress)
413       });
414       await listStationConf(this.StationConfQueryParams).then(response => {
415         let rows = response.rows[0]
416         if (response.rows.length === 0) {
417           this.$message('该工位没有配置IP,请联系管理员配置IP');
418           return
419         }
420         this.headContent.processesName = rows.processesName
421         this.headContent.processesCode = rows.processesCode
422         this.initializedData()
423
424       });
425       console.log('websocket连接工位为' + this.headContent.processesCode)
426       const wsuri = this.url + this.headContent.processesCode;
427       this.ws = new WebSocket(wsuri);
428       const self = this;
429       this.ws.onopen = function (event) {
dd5d35 430         self.$message('websocket连接成功!');
b78728 431       };
A 432
433
434       //socket从后台向前台推送数据
435       this.ws.onmessage = function (event) {
436         if (event.data === "IN") {
437           self.cakeLamp.InPlace = 1;
438         } else if (event.data === "OUT") {
439           self.cakeLamp.release = 1;
440         } else if (event.data === "END") {
441
442           const formulaChildIndex = self.formulaChildList.length-1
443
444           const orderParam = {
445             productNum: self.headContent.sfcCode,
446           }
447
448           if(self.headContent.sfcCode=== ''||self.headContent.sfcCode=== null){
449             self.$message('总成码为空,请扫码!')
450             unfinishedProcess({processesCode: self.headContent.processesCode,recordDataDone: 26}).then(response => {});
451             return;
452           }
453
454           if(self.formulaChildList[formulaChildIndex].results !== 'OK'){
455             self.$message('未做完工序禁止放行');
456             unfinishedProcess({processesCode: self.headContent.processesCode,recordDataDone: 25}).then(response => {});
457             return;
458           }
459
460
461           const param = {
462             workOrderNo: self.workpieceInformation.workOrderNo,
463             productCode: self.workpieceInformation.productCode,
464             locationCode: self.headContent.processesCode,
465             productBarcode: self.headContent.sfcCode,
466             inboundTime: self.workpieceInformation.inboundTime,
467             formulaChildEntity: self.formulaChildList[formulaChildIndex]
468           }
469
470           console.log("进入最终方法")
471           self.endSaveData(param)
472
fd4ea6 473         } else if(event.data.includes("productNum")){//产品序列号
b78728 474           let productNum = event.data.split(',')[1];
A 475           self.headContent.sfcCode = productNum;
476           self.queryParams.productNum = productNum;
477           self.getList()
478           self.cakeLamp.scanFinish = 1
479           self.cakeLamp.startWork = 1
480           self.cakeLamp.InPlace = 1
481
4280d7 482           const param = {
A 483             processesCode: self.headContent.processesCode,
484             productCode: self.workpieceInformation.productCode
485           }
486           fistSetpNumber(param).then(response => {
487             console.log("fistSetpNumber------"+response.msg)
488           });
489
fd4ea6 490         }else if (event.data.includes("[")) {//拧紧
C 491           let formulaChilds = "";
492           self.formulaChildList.sort((a, b) => a.stepSort - b.stepSort);
493           self.formulaChildList
494             .filter((formulaChild) => formulaChild.operationType === '1');
495           for (let i = 0; i < self.formulaChildList.length; i++) {
496             let formulaChild = self.formulaChildList[i];
497             let results = formulaChild.results;
498
499             if (results === '' || results === null || results === 'NG') {
500               formulaChilds = formulaChild;
501               break;
502             }
503           }
504           if(formulaChilds === ""){
505             self.$message.error('本工位已工作完成!');
506             return;
507           }
508           const param = {
509             id: formulaChilds.id,
510             tightenTheArray: event.data,
511             paramCode: formulaChilds.paramCode,
512             workOrderNo: self.workpieceInformation.workOrderNo,
513             productCode: self.workpieceInformation.productCode,
514             locationCode: self.headContent.processesCode,
515             productBarcode: self.headContent.sfcCode,
516             spareField1: formulaChilds.spareField1,
517             spareField2: formulaChilds.spareField2,
518             spareField3: formulaChilds.spareField3,
519             spareField4: formulaChilds.spareField4,
520             stepSort: formulaChilds.stepSort,
521             ngTimes: formulaChilds.ngTimes,
522           }
523           if(formulaChilds.paramCode === null||formulaChilds.paramCode ===''){
524             self.$message('未找到参数码,请检查参数码是否正确');
525             return;
526           }
527           self.formulaChildParams.artificialNgFlag = null
528           console.log("self.formulaChildParams.artificialNgFlag"+self.formulaChildParams.artificialNgFlag)
529           if(self.headContent.sfcCode!==null||self.headContent.sfcCode!==''){
530             updateTighteningFormula(param).then(response => {
531               //addTighteningParameters(param).then(response => {});
532               self.getListFormulaChild()
533             }).catch(error =>{
534               self.getListFormulaChild()
535             });
536           }
b78728 537         }
A 538       };
539     },
540
541     endSaveData(param){
542       saveCampaignTimeParameters(param).then(response => {
543       this.cakeLamp.release = 1;
544       this.endClear()
545       workpieceRelease(param).then(response => {});
546       });
547     },
548   }
549 }
550
551 </script>
552 <style scoped>
553 .bottom-card{
554   height: 600px;
555 }
556 .circle-button{
557   height: 30px;
558   width: 30px;
559 }
560 .circle-red {
561   background-color: #e01a4f;
562 }
563 .circle-green {
564   background-color: green;
565 }
566 .circle-green-animate {
567   background-color: green;
568   animation: circle-green-animate 2s infinite;
569 }
570   @keyframes circle-green-animate {
571     50% {
572       opacity: 0.6;
573     }
574     0% {
575       opacity: 0.2;
576     }
577   }
578 .head-font{
579   /*font-weight: bold;*/
580   /*font-size: 25px;*/
581 }
582 span{
583   font-size: 15px;
584 }
585 .el-table .warning-row {
586   background: oldlace;
587 }
588
589 .el-table .success-row {
590   background: #f0f9eb;
591 }
592 </style>
593