春风项目四线(合箱线、总装线)
wujian
2024-07-12 d2daac02fbc20980162799fc7bf6b1ca59f5686a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
<template>
  <div class="app-container">
    <div style="width: 100%">
      <el-card   class="box-card"  style="height: 60px" >
        <template>
          <div class="container" type="flex" justify="center" style="text-align:center">
            <el-divider><span style="font-size:30px;color:black"><strong>活塞连杆扫码上线</strong></span></el-divider>
          </div>
        </template>
      </el-card>
      <el-row :gutter="3">
        <el-col :span="6">
          <el-card shadow="always" class="boxSize">
            <div class="centerImg">
              <img style="width: 140px;height: 30px;" src="@/assets/logo/jcdm2.png" alt="dark">
            </div>
 
          </el-card>
        </el-col>
        <el-col :span="3">
          <el-card shadow="always" class="boxSize">
            <span class="centerText" style="height: 60px">{{locationCode}}</span>
          </el-card>
        </el-col>
        <el-col :span="15">
          <el-card shadow="always" class="boxSize">
            <span class="centerText" >{{locationName}}</span>
          </el-card>
        </el-col>
      </el-row>
      <!--      <el-card class="box-card" >-->
      <!--        <el-form :model="from" size="large" :inline="true" label-width="68px" @submit.native.prevent>-->
      <!--          <el-form-item label-width="200" label="活塞连杆托盘码" :prop="from.scanObject2"  style="align-content: center">-->
      <!--            <input v-model="from.scanObject2"-->
      <!--                   ref="inputdata"-->
      <!--                   style="height: 39px; width: 300px"-->
      <!--                   placeholder="请输入活塞连杆托盘码"-->
      <!--            />-->
      <!--          </el-form-item>-->
      <!--&lt;!&ndash;          <el-button type="primary" icon="el-icon-refresh" @click="handleQuery">查询</el-button>&ndash;&gt;-->
      <!--        </el-form>-->
      <!--      </el-card>-->
      <el-col :span="24" >
        <el-card class="bottom-card">
          <div slot="header" class="clearfix">
            <i class="el-icon-tickets"></i>
            <span style="font-weight: bold">当前产品信息</span>
          </div>
          <el-descriptions :column="1"  :label-style="{'font-size': '20px'}" border  :content-style="{'min-width': '300px'}">
            <el-descriptions-item label="机型">
              <span>{{queryParams.productSeries}}</span>
            </el-descriptions-item>
            <el-descriptions-item label="箱体对应SN码">
              <span>{{queryParams.scanObject1}}</span>
            </el-descriptions-item>
            <el-descriptions-item label="曲轴对应SN码">
              <span>{{queryParams.scanObject2}}</span>
            </el-descriptions-item>
            <el-descriptions-item label="结果">
              <span  style="color: #FFFFFF;"  :style="{ backgroundColor: queryParams.tileColor }">{{queryParams.words}}</span>
            </el-descriptions-item>
          </el-descriptions>
          <el-divider></el-divider>
        </el-card>
      </el-col>
    </div>
  </div>
</template>
<script>
import VueQr from 'vue-qr'
import { listTileMatchRules, getTileMatchRules, delTileMatchRules, addTileMatchRules, updateTileMatchRules } from "@/api/main/bs/tileMatchRules/tileMatchRules";
import {listStationConf,getIp} from "@/api/main/sc/stationConf";
import {setBarcodeup, outSign, getDetailData} from "@/api/main/da/tileMatchMiddleware/tileMatchMiddleware";
import {getUrl} from "@/api/main/bs/orderScheduling/orderScheduling";
import WebSocketReconnect from "@/utils/WebsocketTool";
import result from "../../../../components/Crontab/result.vue";
export default {
  name: "index",
  dicts: ['colour_hex','productseries','axisname','neckname','tilename'],
  components: {
    VueQr,
  },
  data(){
    return{
      scannerFlag: false,
      loading: true,
      locationCode: "未配置",
      locationName: "未配置工位",
      tileMatchKbList: [],
      qrCode: '',
      // 查询参数
      from:{
        pageNum: 1,
        pageSize: 10,
        productSeries: null,
        scanObject1: null,
        //scanObject1: 'P0SQ0-01FZ01-1000;T231224116;DBBBBA',
        scanObject2: null,
        axisName: null,
        neckName: null,
        tileName: null,
        axisParameterNoPosition: null,
        neckParameterPosition: null,
        axisValue: null,
        neckValue: null,
        tileColor: null,
        createUser: null,
        updateUser: null,
        state: null,
        weight: null,
      },
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        productSeries: null,
        scanObject1: null,
        // scanObject1: 'P0SQ0-01FZ01-1000;T231224116;DBBBBA',
        scanObject2: null,
        axisName: null,
        neckName: null,
        tileName: null,
        axisParameterNoPosition: null,
        neckParameterPosition: null,
        axisValue: null,
        neckValue: null,
        words:"",
        tileColor: null,
        createUser: null,
        updateUser: null,
        state: null,
        weight: null,
      },
    }
  },
  mounted() {
    this.getStationConf()
    this.getWebUrl()
    this.getDetailMessage()
  },
  methods:{
    getWebUrl(){
      getUrl().then(res=>{
        this.websocketUrl = res+"OP050"
        console.log('websocketUrl:',this.websocketUrl)
        this.initWebSocket()
      })
    },
    initWebSocket: function (){
      //判断当前浏览器是否支持WebSocket
      if ('WebSocket' in window) {
        //连接WebSocket节点
        this.websocket = new WebSocketReconnect(this.websocketUrl);
        //接收到消息的回调方法
        this.websocket.socket.onmessage = (event) => {
          let data = event.data;
          if (data != null && data !== ''){
            this.result = JSON.parse(data);
            const resultMessage = this.result.server_message.split("*");
            console.log('resultMessage',resultMessage)
            if (resultMessage.length >=2){
              if (resultMessage[1] === "sfcCode"){
                this.queryParams.scanObject1 = resultMessage[0]
                this.queryParams.productSeries = resultMessage[2]
                this.queryParams.scanObject2 = resultMessage[3]
              } else if (resultMessage[1] === "rodCode"){
                this.queryParams.scanObject2 = resultMessage[0]
                this.queryParams.productSeries = resultMessage[2]
              } else if (resultMessage[1] === "clean"){
                this.queryParams.scanObject1 = ""
                this.queryParams.scanObject2 = ""
                this.queryParams.words = ""
                this.queryParams.tileColor = ""
              }
            }
            if (this.queryParams.scanObject1 !== null && this.queryParams.scanObject1 !== ''
              && this.queryParams.scanObject2 !== null && this.queryParams.scanObject2 !== ''){
              if (this.queryParams.scanObject1 === this.queryParams.scanObject2){
                this.queryParams.words = "配对成功"
                this.queryParams.tileColor = "#3dcc1d"
                //请求出站
                // this.passStation()
              }else {
                this.queryParams.words = "配对失败"
                this.queryParams.tileColor = "#f50909"
              }
            }
 
 
            // const parts3 = this.result.server_message.split("*");
            // if (parts3.length >= 2) {
            //   this.from.scanObject2=parts3[0];
            //   this.queryParams.words=parts3[1];
            //   this.queryParams.tileColor= parts3[2];
            //   this.handleQuery();
            // }
          }
        }
        //监听窗口关闭事件,当窗口关闭时,主动去关闭websocket连接,防止连接还没断开就关闭窗口,server端会抛异常。
        window.onbeforeunload = function () {
          this.websocket.close()
        }
        //关闭连接
        function closeWebSocket() {
          this.websocket.close()
        }
        //发送消息
        function send() {
          this.websocket.socket.send({ kk: 123 })
        }
      } else {
        alert('浏览器不支持webSocket')
      }
    },
    //刷新获取信息
    getDetailMessage(){
      getDetailData().then(res => {
        if (res.data == 200){
          console.log('res200',res)
          this.queryParams.scanObject1 = res.SfcCode
          this.queryParams.productSeries = res.productSeries
        }
      })
    },
    /** 查询工位终端配置列表 */
    getStationConf() {
      getIp().then(response => {
        let queryParams = {
          ipAddress: response.msg,
        }
        listStationConf(queryParams).then(response => {
          this.locationName = response.rows[0].processesName
          this.locationCode = response.rows[0].processesCode
        });
      });
    },
    passStation(){
      outSign().then(res =>{
        console.log("res",res)
        if (res.code === 200){
          console.log('1212121')
          this.$message({
            message: '匹配成功,已过站',
            type: 'success',
            duration:3000
          });
          this.queryParams.productSeries = ''
          this.queryParams.scanObject1 = ''
          this.queryParams.scanObject2 = ''
          this.queryParams.words = ''
          this.queryParams.tileColor = ''
 
        }
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.clear();
      if(this.from.scanObject2 !== null)
      {
        this.insetFromToQueryParams();
        //this.getList();
      } else{
        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
        });
      }
    },
    cleanForm(){
      this.queryParams.productSeries = ""
      this.queryParams.scanObject1 = ""
      this.queryParams.scanObject2 = ""
      this.queryParams.words = ""
      this.queryParams.tileColor = ""
    },
    //取配瓦颜色
    getList() {
      let queryParams = {
        productSeries : this.queryParams.productSeries,
        axisName : this.queryParams.axisName,
        neckName : this.queryParams.neckName,
        tileName : this.queryParams.tileName,
        axisValue: this.queryParams.axisValue,
        neckValue: this.queryParams.neckValue,
      }
      console.log(queryParams)
      listTileMatchRules(queryParams).then(response => {
        this.queryParams.tileColor = response.rows[0].tileColor;
      });
    },
    clear(){
      this.queryParams.axisValue=null;
      this.queryParams.neckValue=null;
    },
    insetFromToQueryParams(){
      this.queryParams.productSeries=this.from.productSeries;
      this.queryParams.tileName=this.from.tileName;
      this.queryParams.scanObject2=this.from.scanObject2;
    }
 
  },
}
</script>
 
<style scoped>
::v-deep .el-form-item__label{
  font-size: large;
}
::v-deep .el-card__body{
  padding: 15px 20px 0px 20px;
}
::v-deep .el-input .el-input--medium .el-input--suffix{
  width: 200px;
}
.boxSize{
  height: 60px;
}
.centerText{
  color: black;
  font-weight: bold;
  font-size: 20px;
  display: flex;
  justify-content: center;
  margin-top: 5px
}
</style>