admin
2024-09-18 2d564a5921cec98b2c7e6065cc8f066abd614b76
jcdm-ui/src/views/main/kb/stationTerminal/index.vue
@@ -10,7 +10,6 @@
       <el-card shadow="never">
         <span class="head-font">物料编码 : </span>
         <el-input style="width: 50%" ref="inputData" v-model="materialCode" @change="handleEnter" placeholder="请扫描物料编码"></el-input>
         <el-button type="primary" style="float: right" icon="el-icon-search"  @click="serialLink">串口连接</el-button>
         <el-button @click="clearClick" style="float: right" type="danger" >清除</el-button>
       </el-card>
     </el-col>
@@ -30,8 +29,8 @@
           <el-descriptions-item label="工单编号">
               <span>{{workpieceInformation.workOrderNo}}</span>
           </el-descriptions-item>
           <el-descriptions-item label="物料编码">
             <span>{{workpieceInformation.materialCode}}</span>
           <el-descriptions-item label="产品编码">
             <span>{{workpieceInformation.productCode}}</span>
           </el-descriptions-item>
           <el-descriptions-item label="计划数量">
             <span>{{workpieceInformation.planQty}}</span>
@@ -77,8 +76,146 @@
             <span>&nbsp;允许放行</span>
           </el-col>
         </el-row>
         <el-row v-show="printFlag" style="margin-top: 20px">
           <el-button id="print" v-print="'#printMe'" type="primary">打印</el-button>
           <div style="display: none">
             <div id="printMe">
               <div style="text-align: center;margin-top: 64px">
                 <span style="font-size: 29px;">电驱系统总成</span>
               </div>
               <div style="display: flex;margin-top: 2px;margin-left: 39px;font-size: 15px">
                 <div class="div1">
                   <div >
                     <span>电机型号:</span><span>TZ180XSDSZX01</span><br>
                   </div>
                   <div style="margin-top: 4px">
                     <span>额定功率:</span><span>30KW</span><br>
                   </div>
                   <div style="margin-top: 4px">
                     <span>额定扭矩:</span><span>70N.m</span><br>
                   </div>
                   <div style="margin-top: 4px">
                     <span>额定电压:</span><span>336VDS</span><br>
                   </div>
                   <div style="margin-top: 4px">
                     <span>额工作制:</span><span>S9</span><br>
                   </div>
                   <div style="margin-top: 4px">
                     <span>持续工作电流:</span><span>115A</span><br>
                   </div>
                   <div style="margin-top: 4px">
                     <span>相数:</span><span>3</span><br>
                   </div>
                   <div style="margin-top: 4px">
                     <span>零件号:</span><span>9900200461</span><br>
                   </div>
                 </div>
                 <div class="div2" style="font-size: 15px;margin-left: 4px">
                   <div>
                     <span>控制器型号:</span><span>KTZ34X23SZX07</span><br>
                   </div>
                   <div style="margin-top: 4px">
                     <span>峰值功率:</span><span>60KW</span><br>
                   </div>
                   <div style="margin-top: 4px">
                     <span>峰值转矩:</span><span>175N.m</span><br>
                   </div>
                   <div style="margin-top: 4px">
                     <span>最高转速:</span><span>12000rpm</span><br>
                   </div>
                   <div style="margin-top: 4px">
                     <span>防护等级:</span><span>IP67</span><br>
                   </div>
                   <div style="margin-top: 4px">
                     <span>峰值工作电流:</span><span>230A</span><br>
                   </div>
                   <div style="margin-top: 4px">
                     <span>绝缘等级:</span><span>H</span><br>
                   </div>
                   <div style="margin-top: 4px">
                     <span>出厂编号:</span><span>{{headContent.sfcCode}}</span><br>
                   </div>
                 </div>
               </div>
               <div style="margin-top: 2px;margin-left: 70px">
                 <span style="font-size: 26px;">湖州智芯动力系统发展有限公司</span>
               </div>
               <div style="text-align: center;margin-top: 101px;font-size: 20px">
                 <div style="margin-top: 8px">
                   <span style="font-size: 22px">TZ180XSDSZX01</span><br>
                 </div>
                 <div style="margin-top: 4px">
                   <span style="font-size: 22px">KTZ34X23SZX07</span><br>
                 </div>
                 <div style="margin-top: 4px">
                   <span style="font-size: 22px">993983</span><br>
                 </div>
                 <div style="margin-top: 4px">
                   <span style="font-size: 22px">9900200461</span><br>
                 </div>
                 <div style="margin-top: 4px">
                   <span style="font-size: 22px">{{headContent.sfcCode}}</span>
                 </div>
               </div>
               <div style="margin-top: 61px;display: flex;margin-left: 40px">
                 <div style="width: 30%;flex: 1">
                   <VueQr :size='80' :margin='0' :text='this.text'></VueQr>
                 </div>
                 <div style="width: 70%;flex: 1;margin-top: 18px;margin-right: 29px">
                        <span style="margin-left: -80px;font-size: 20px;font-family: FangSong;letter-spacing: -0.8px">
                          P9900200461#T{{headContent.sfcCode}}
                        </span><br>
                   <span style="margin-left: -80px;font-size: 20px;font-family: FangSong;letter-spacing: -0.8px">
                          #V993983#SSW002.005#HHW001.001#NMCU
                        </span>
                   <!--                      <span style="font-size: 10px;word-break: break-all;display: flex;justify-content: center;width: 155px;margin-left: 9px">P9900166410#T{{text1}}#V993983#SSW002.005#HHW001.001#NBMS#</span>-->
                 </div>
               </div>
               <div style="margin-top: 48px;display: flex;margin-left: 40px">
                 <div style="width: 30%;flex: 1">
                   <VueQr :size='80' :margin='0' :text='this.text'></VueQr>
                 </div>
                 <div style="width: 70%;flex: 1;margin-top: 18px;margin-right: 29px">
                        <span style="margin-left: -80px;font-size: 20px;font-family: FangSong;letter-spacing: -0.8px">
                          P9900200461#T{{headContent.sfcCode}}
                        </span><br>
                   <span style="margin-left: -80px;font-size: 20px;font-family: FangSong;letter-spacing: -0.8px">
                          #V993983#SSW002.005#HHW001.001#NMCU
                        </span>
                   <!--                      <span style="font-size: 10px;word-break: break-all;display: flex;justify-content: center;width: 155px;margin-left: 9px">P9900166410#T{{text1}}#V993983#SSW002.005#HHW001.001#NBMS#</span>-->
                 </div>
               </div>
               <div style="text-align: center;margin-left: -190px;margin-top: 35px">
                 <div style="margin-top: 4px">
                   <span>9900200461</span><br>
                 </div>
                 <div style="margin-top: 8px">
                   <span>MCU</span><br>
                 </div>
                 <div style="margin-top: 8px">
                   <span>HW 001.001</span><br>
                 </div>
                 <div style="margin-top: 8px">
                   <span>SW 001.001</span><br>
                 </div>
               </div>
             </div>
           </div>
         </el-row>
         <el-row v-show="orderFlag" style="margin-top: 20px">
           <el-button @click="getWorkOrders" type="warning" size="mini">接收工单</el-button>
<!--           <el-button @click="getWorkOrders" type="warning" size="mini">接收工单</el-button>-->
         </el-row>
       </el-card>
@@ -129,7 +266,7 @@
  bindYzSfcFlag,
  checkCarCode, checkYzSfcCode,
  findBytrolleyYardGetOne,
  listProductionOrde, mozuReceivingWorkOrders,
  listProductionOrde, listProductionOrdeLoopLine, mozuReceivingWorkOrders,
  receivingWorkOrders,
  trolleyYardBinDing
} from "@/api/main/om/productionOrde/productionOrde";
@@ -142,11 +279,17 @@
  replaceAssemblyCode, checkRecordDataDone,
} from "@/api/main/da/paramCollection/paramCollection";
import {addFormula} from "@/api/main/bs/formula/formula";
import QRCode from "qrcodejs2";
import VueQr from "vue-qr";
export default {
  components: {
    VueQr
  },
  name: "stationTerminal",
  data() {
    return {
      text: 'P9900200461#T2408170000004#V993983#SSW001.001#HHW001.001#NMCU',
      materialCode: '', // 物料编码
      carCode: '',
      showInput: false,
@@ -201,11 +344,13 @@
        release: 0 //允许放行
      },
      content: '',
      // url: "ws://10.103.214.26:8080/websocket/message/",
      url: "ws://192.168.20.250:8080/websocket/message/",
      passingStationForm: {},
      originalArray: [],
      orderFlag: true,
      printFlag: false,
      activeName: 'first',
    }
@@ -234,27 +379,49 @@
      console.log(tab, event);
    },
    handleEnter() {
      this.serialPortMethod(this.materialCode);
      this.materialCode="";
      this.setFocus();
      this.$message("扫描物料编码"+this.materialCode);
    },
    getWorkOrders(){
      if(this.headContent.sfcCode === '' || this.headContent.sfcCode === null){
        //接收工单
        const param = {
          lineCode: this.headContent.processesCode
      console.log("物料码:"+this.materialCode);
      if(this.materialCode.includes("9900200461") || this.materialCode.includes("9900207783")){
        if(this.headContent.processesCode === "OP170" || this.headContent.processesCode === "OP180" ||
           this.headContent.processesCode === "OP190" || this.headContent.processesCode === "OP200" ||
           this.headContent.processesCode === "OP210" || this.headContent.processesCode === "OP220" ||
          this.headContent.processesCode === "OP230"
        ){
          if(this.materialCode.length>25){
            let code = this.materialCode.substring(13,26);
            // this.headContent.sfcCode = code;
            this.queryParams.productNum = code;
            this.getList();
            this.cakeLamp.scanFinish = 1
            this.cakeLamp.startWork = 1
            this.cakeLamp.InPlace = 1
            const param = {
              processesCode: this.headContent.processesCode,
              productCode: this.workpieceInformation.productCode,
              sfcBarcode:code,
            }
            fistSetpNumber(param).then(response => {
              console.log("fistSetpNumber------"+response.msg)
            });
            this.$message("扫描物料编码"+this.materialCode);
            this.materialCode="";
            this.setFocus();
          }else{
            this.$message("扫描物料编码错误!"+this.materialCode);
            this.materialCode="";
            this.setFocus();
          }
        }
        mozuReceivingWorkOrders(param).then(response => {
          this.headContent.sfcCode = response.msg;
          this.queryParams.productNum = response.msg;
          this.getList()
          this.cakeLamp.scanFinish = 1
          this.cakeLamp.startWork = 1
          this.cakeLamp.InPlace = 1
        });
      }else {
        this.$message.error("已经有工单了,不能接收!");
      }else{
        if(this.headContent.sfcCode === '' || this.headContent.sfcCode === null){
          this.$message("请先扫描产品条码!");
        }else{
          this.serialPortMethod(this.materialCode);
          this.$message("扫描物料编码"+this.materialCode);
          this.setFocus();
          this.materialCode="";
        }
      }
    },
    serialLink() {
@@ -341,24 +508,40 @@
        locationCode: this.headContent.processesCode,
        productBarcode: this.headContent.sfcCode,
      }
      this.endClear()
      // this.endClear()
      clearWorkpieceRelease(param).then(response => {});
      this.headContent.sfcCode = ''
      // this.headContent.sfcCode = ''
      this.$message('清除成功!');
      this.setFocus();
      this.getList()
    },
    /** 查询工单列表 */
    async getList() {
      await listProductionOrde(this.queryParams).then(response => {
      await listProductionOrdeLoopLine(this.queryParams).then(response => {
        let rowsData = response.rows[0];
        console.log(rowsData)
        this.workpieceInformation.workOrderNo = rowsData.workOrderNo;
        this.workpieceInformation.productCode = rowsData.productCode;
        this.workpieceInformation.materialCode = rowsData.materialCode;
        this.workpieceInformation.planQty = rowsData.planQty;
        this.headContent.cardCode = rowsData.trolleyYard;
        if(rowsData){
          if(this.headContent.processesCode === 'OP170'
            ||this.headContent.processesCode === 'OP180'||
            this.headContent.processesCode === 'OP190'||
            this.headContent.processesCode === 'OP200'||
            this.headContent.processesCode === 'OP210'||
            this.headContent.processesCode === 'OP220'||
            this.headContent.processesCode === 'OP230'
          ){
            this.headContent.sfcCode = rowsData.productNum
          }
          this.workpieceInformation.workOrderNo = rowsData.workOrderNo;
          this.workpieceInformation.productCode = rowsData.productCode;
          this.workpieceInformation.materialCode = rowsData.materialCode;
          this.workpieceInformation.planQty = rowsData.planQty;
          this.headContent.cardCode = rowsData.trolleyYard;
          this.getListFormulaChild()
          this.workpieceInformation.inboundTime = this.getCurrentTime()
        }else {
          this.$message.error('系统没有此工单,请重新扫码!');
        }
      });
      this.getListFormulaChild()
      this.workpieceInformation.inboundTime = this.getCurrentTime()
    },
    initializedData(){
@@ -373,6 +556,9 @@
          this.cakeLamp.scanFinish = 1
          this.cakeLamp.startWork = 1
          this.cakeLamp.InPlace = 1
          // this.test1()
          // this.test2()
          this.text = 'P9900200461#T'+this.headContent.sfcCode+'#V993983#SSW001.001#HHW001.001#NMCU'
        }
      });
    },
@@ -397,6 +583,32 @@
        this.ws = null;
      }
    },
    test1(){
      document.getElementById('canvasWrapper1').innerHTML = '';
      this.$nextTick(() => {
          let qrCode = new QRCode('canvasWrapper1',{
            width: 83,
            height: 83,
            text: 'P9900200461#T'+this.headContent.sfcCode+'#V993983#SSW001.001#HHW001.001#NMCU',
            colorDark: '#000',
            colorLight: '#fff'
          })
        }
      )
    },
    test2(){
      document.getElementById('canvasWrapper2').innerHTML = '';
      this.$nextTick(() => {
          let qrCode = new QRCode('canvasWrapper2',{
            width: 83,
            height: 83,
            text: 'P9900200461#T'+this.headContent.sfcCode+'#V993983#SSW001.001#HHW001.001#NMCU',
            colorDark: '#000',
            colorLight: '#fff'
          })
        }
      )
    },
    send() {
      if (this.ws) {
        this.ws.send(this.message);
@@ -419,6 +631,9 @@
        this.headContent.processesName = rows.processesName
        this.headContent.processesCode = rows.processesCode
        this.initializedData()
        if(this.headContent.processesCode === 'OP165'){
          this.printFlag = true
        }
      });
      console.log('websocket连接工位为' + this.headContent.processesCode)
@@ -432,8 +647,13 @@
      //socket从后台向前台推送数据
      this.ws.onmessage = function (event) {
        if (event.data === "IN") {
        if (event.data === "print") {
          document.getElementById('print').click();
          unfinishedProcess({processesCode: self.headContent.processesCode,recordDataDone: 21}).then(response => {});
        }else if (event.data === "IN") {
          self.cakeLamp.InPlace = 1;
        }else if(event.data === "twoHundredAndThirtyEND"){
          self.endClear()
        } else if (event.data === "OUT") {
          self.cakeLamp.release = 1;
        } else if (event.data === "END") {
@@ -469,15 +689,83 @@
          console.log("进入最终方法")
          self.endSaveData(param)
        } else if(event.data.includes("productNum")){
        } else if(event.data.includes("productNum")){//产品序列号
          let productNum = event.data.split(',')[1];
          self.headContent.sfcCode = productNum;
          if(self.headContent.processesCode === 'OP165'){
            console.log("进去截取总成码方法165工站原始值是"+productNum+"截取之后的是"+productNum.substring(13,26))
            self.headContent.sfcCode = productNum.substring(13,26)
            console.log("self.headContent.sfcCode"+self.headContent.sfcCode)
          }else {
            self.headContent.sfcCode = productNum;
          }
          self.queryParams.productNum = productNum;
          self.getList()
          self.cakeLamp.scanFinish = 1
          self.cakeLamp.startWork = 1
          self.cakeLamp.InPlace = 1
          const param = {
            processesCode: self.headContent.processesCode,
            productCode: self.workpieceInformation.productCode
          }
          fistSetpNumber(param).then(response => {
            console.log("fistSetpNumber------"+response.msg)
          });
          //打印
          if(self.headContent.processesCode === "OP165"){
            // self.test1()
            // self.test2()
            self.text = 'P9900200461#T'+self.headContent.sfcCode+'#V993983#SSW002.005#HHW001.001#NMCU#'
          }
        }else if (event.data.includes("[")) {//拧紧
          let formulaChilds = "";
          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 (results === '' || results === null || results === 'NG') {
              formulaChilds = formulaChild;
              break;
            }
          }
          if(formulaChilds === ""){
            self.$message.error('本工位已工作完成!');
            return;
          }
          const param = {
            id: formulaChilds.id,
            tightenTheArray: event.data,
            paramCode: formulaChilds.paramCode,
            workOrderNo: self.workpieceInformation.workOrderNo,
            productCode: self.workpieceInformation.productCode,
            locationCode: self.headContent.processesCode,
            productBarcode: self.headContent.sfcCode,
            spareField1: formulaChilds.spareField1,
            spareField2: formulaChilds.spareField2,
            spareField3: formulaChilds.spareField3,
            spareField4: formulaChilds.spareField4,
            stepSort: formulaChilds.stepSort,
            ngTimes: formulaChilds.ngTimes,
          }
          if(formulaChilds.paramCode === null||formulaChilds.paramCode ===''){
            self.$message('未找到参数码,请检查参数码是否正确');
            return;
          }
          self.formulaChildParams.artificialNgFlag = null
          console.log("self.formulaChildParams.artificialNgFlag"+self.formulaChildParams.artificialNgFlag)
          if(self.headContent.sfcCode!==null||self.headContent.sfcCode!==''){
            updateTighteningFormula(param).then(response => {
              //addTighteningParameters(param).then(response => {});
              self.getListFormulaChild()
            }).catch(error =>{
              self.getListFormulaChild()
            });
          }
        }
      };
    },
@@ -494,6 +782,15 @@
</script>
<style scoped>
.div1, .div2 {
  flex: 1; /* 两个div平分容器宽度 */
}
.span{
  font-family: 'Microsoft YaHei', sans-serif;
}
.div2{
  margin-left: 30px;
}
.bottom-card{
  height: 600px;
}