wangfei
2024-08-16 af567ea5327037aad91b22030afa9aa7abb997bf
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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
<template>  
  <el-card style="flex: 1;margin-left: 1px;margin-top: 10px;margin-right: 1px;" v-loading="loading">
    <el-scrollbar height="600px">
<div id="top" style="height: 150px;display: flex;">  
  <div class="echarts-container">
  <div v-for="(processData, index) in processesData" :key="index" class="echarts-item">
    <div :id="'pieChart_' + index" class="pie-chart"></div>
  </div>
</div>
</div> 
<div style="display: flex;">
<!-- <div id="centerleft" style="margin-top: 10px;height: 240px;width: 340px;background-color: #911005;">
  <el-table height="240" ref="table" width="340px"
      @selection-change="handleSelectionChange"
      :data="tableData" :header-cell-style="{background:'#F2F3F5 ',color:'#1D2129'}">
        <el-table-column fixed prop="orderId" align="center" :label="$t('large.number')" min-width="110" />
        <el-table-column prop="project" align="center" :label="$t('large.projectname')" min-width="100" />
        <el-table-column prop="responsibleProcess" align="center" :label="$t('large.responsibleprocess')" min-width="100" />
        <el-table-column prop="breakageQuantity" align="center" :label="$t('large.numberfractions')" min-width="110" />
        <el-table-column prop="patchProcesses" align="center" :label="$t('large.process')" min-width="100" />
        <el-table-column fixed="right" :label="$t('large.operate')" align="center" width="100">
          <template #default="scope">
            <el-button size="mini" type="text" plain @click="handleBinda">{{ $t('large.mes') }}</el-button>
          </template>
      </el-table-column>
      </el-table>
</div>  -->
<div class="parter" style="margin-top: 10px;margin-left: 150px; height: 240px;width: 1000px;">
    <img src="../../assets/dpxsa.png" style="margin-left: -10px; width: 100%;height: 100%;" alt="Your Image">
  <div  class="moving-rect lipiana" v-show="woshia"></div>
  <div  class="moving-rect lipianb" v-show="woshia"></div>
  <div  class="moving-rect lipianc" v-show="woshic"></div>
  <div  class="moving-rect lipiand" v-show="woshic"></div>
  <div  class="moving-rect overlaya" v-show="flake"></div>
  <div  class="moving-rect overlayb" v-show="flakeb"></div>
  <div  class="moving-rect overlayc" v-show="flakec"></div>
  <div  class="moving-rect overlayd" v-show="flaked"></div>
  <div  class="moving-rect longa" v-show="dalipiana"></div>
  <div  class="moving-rect longb" v-show="dalipianb"></div>
  <div  class="moving-rect shangpianji" v-show="shangpian"></div>
  <div  class="moving-rect xiapianji" v-show="xiapian"></div>
  <div  class="moving-rect xiapianji1" v-show="xiapian1"></div>
  <div  class="moving-rect xiapianji2" v-show="xiapian2"></div>
  <div  class="moving-rect xiapianji3" v-show="xiapian3"></div>
  <div  class="moving-rect xiapianji4" v-show="xiapian4"></div>
  <div  class="moving-rect xiapianji5" v-show="xiapian5"></div>
  <div  class="moving-rect xiapianji6" v-show="xiapian6"></div>
</div>
<!-- <div class="parter" style="margin-top: 10px;margin-left: 150px; height: 240px;width: 1000px;">
    <img src="../../assets/dpxsa.png" style="margin-left: -10px; width: 100%;height: 100%;" alt="Your Image">
    <div class="moving-rect vertical"></div>
    <div class="moving-rect all"></div>
    <div class="moving-rect horizontal"></div>
    <div class="moving-rect xiao"></div>
    <div class="moving-rect zhan"></div>
    <div class="moving-rect tu"></div>
    <div class="moving-rect zi"></div>
    <div class="moving-rect xia"></div>
    <div class="moving-rect zan"></div>
    <div class="moving-rect fa"></div>
    <div class="moving-rect hua"></div>
    <div class="moving-rect shui"></div>
</div> -->
<!-- <div id="centerright" style="margin-top: 10px;margin-left: 10px; height: 240px;width: 240px;background-color: #911005;">
  <el-table height="240" ref="table" width="340px"
      @selection-change="handleSelectionChange"
      :data="tableDatab" :header-cell-style="{background:'#F2F3F5 ',color:'#1D2129'}">
        <el-table-column prop="projectNo" align="center" :label="$t('large.projectnumber')" min-width="50" />
        <el-table-column prop="projectName" align="center" :label="$t('large.projectname')" min-width="50" />
      </el-table>
</div>  -->
</div>
<div id="bottom" style="margin-top: 10px;height: 190px;background-color: #911005;">
<el-table height="190" ref="table"
      @selection-change="handleSelectionChange"
      :data="tableDatac" :header-cell-style="{background:'#F2F3F5 ',color:'#1D2129'}">
        <el-table-column prop="orderId" align="center" :label="$t('large.orderId')" min-width="50" />
        <el-table-column prop="customerName" align="center" :show-overflow-tooltip="true" :label="$t('large.customerName')" min-width="90" />
        <el-table-column prop="project" align="center" :label="$t('large.project')" min-width="50" />
        <el-table-column prop="area" align="center" :label="$t('large.are')" min-width="50" />
        <el-table-column prop="quantity" align="center" :label="$t('large.quantity')" min-width="50" />
        <el-table-column
          align="center"
          :label="$t('large.warehousing')"
          min-width="50"
          prop="warehousing"
        >
        <template #default="scope">  
      <el-tag :type="getStatusType(scope.row.warehousing)">  
        {{ getStatusText(scope.row.warehousing) }}  
      </el-tag>  
    </template> 
        </el-table-column>
        <el-table-column prop="deliveryDate" align="center" :label="$t('large.deliveryDate')" min-width="100" />
        <el-table-column fixed="right" :label="$t('large.operate')" align="center" width="100">
          <template #default="scope">
            <el-button size="mini" type="text" plain @click="handleBinda(scope.row)">{{ $t('large.mes') }}</el-button>
          </template>
      </el-table-column>
      </el-table>
</div>
</el-scrollbar>
</el-card>
<el-dialog v-model="blinda" top="5vh" width="85%">
  <el-table height="400" ref="table" 
      @selection-change="handleSelectionChange"
      :data="tableData" :header-cell-style="{background:'#F2F3F5 ',color:'#1D2129'}">
        <el-table-column prop="orderId" fixed align="center" :label="$t('large.orderId')" min-width="110" />
        <el-table-column prop="project"  align="center" :label="$t('large.project')" min-width="110" />
        <el-table-column prop="processId"  align="center" :label="$t('large.cardnumber')" min-width="110" />
        <el-table-column prop="orderNumber"  align="center" :label="$t('large.serialnumber')" min-width="110" />
        <el-table-column prop="productName"  align="center" :label="$t('large.productname')" min-width="110" />
        <el-table-column prop="width"  align="center" :label="$t('large.width')" min-width="100" />
        <el-table-column prop="height"  align="center" :label="$t('large.height')" min-width="100" />
        <el-table-column prop="area"  align="center" :label="$t('large.are')" min-width="100" />
        <el-table-column prop="quantity"  align="center" :label="$t('large.number')" min-width="110" />
        <el-table-column prop="numberPatches"  align="center" :label="$t('large.numberpatches')" min-width="110" />
        <el-table-column prop="receivedQuantity"  align="center" :label="$t('large.innumber')" min-width="110" />
        <el-table-column prop="terminationStatus"  align="center" :label="$t('large.productstatus')" min-width="110" />
        <el-table-column
          align="center"
            :label="$t('large.productstatus')"
            min-width="80"
            prop="terminationStatus"
          >
          <template #default="scope">  
          <el-tag  
            :type="scope.row.terminationStatus === 0 ? 'success' : 'danger'"  
          >  
            {{ scope.row.terminationStatus === 0 ? $t('large.right') : $t('large.stop') }}
          </el-tag>  
        </template> 
          </el-table-column> 
        <el-table-column prop="packType"  align="center" :label="$t('large.quantity')" min-width="110" />
        <el-table-column prop="projectNo"  align="center" :label="$t('large.projectnumber')" min-width="110" />
        <!-- <el-table-column prop="processingNote" fixed align="center" :label="$t('large.method')" min-width="110" /> -->
        <!-- <el-table-column prop="deliveryDate" fixed align="center" :label="$t('large.deliveryDate')" min-width="130" /> -->
      </el-table>
  <template #footer>
    <div id="dialog-footer" style="text-align: center;">
      <el-button @click="blinda = false">{{ $t('large.close') }}</el-button>
    </div>
  </template>
</el-dialog>
</template>  
<script setup>  
import { Delete, Upload } from '@element-plus/icons-vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { ref, onMounted , onBeforeUnmount, reactive, computed, shallowRef, onUnmounted, watchEffect } from "vue";
import request from "@/utils/request"
import { WebSocketHost ,host} from '@/utils/constants'
import { initializeWebSocket, closeWebSocket } from '@/utils/WebSocketService';
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
import * as echarts from 'echarts';
const tableData = ref([])
const tableDatab = ref([])
const tableDatac = ref([])
const adjustedRects = ref([]);  
const chartRefs = ref([]);  
const flake = ref(false)
const flakeb = ref(false)
const flakec = ref(false)
const flaked = ref(false)
const woshia = ref(false)
const woshic = ref(false)
const dalipiana = ref(false)
const dalipianb = ref(false)
const shangpian = ref(false)
const xiapian = ref(false)
const xiapian1 = ref(false)
const xiapian2 = ref(false)
const xiapian3 = ref(false)
const xiapian4 = ref(false)
const xiapian5 = ref(false)
const xiapian6 = ref(false)
 
const thisProcess = ref(); // 用于存储process_id的响应式引用 
// 定义一个响应式引用来存储图表实例    
const chartDom = ref(null);  
let chartInstance = null;  
const blinda = ref(false)
const handleBinda = async (row) => {  
  blinda.value = true;
  await fetchFlowCardId(row.orderId);
};  
const processesData = ref([]);
const fetchFlowCardId = async (orderId) => {
  try  {
    const response = await request.post('/loadGlass/order/order/selectOrderdetail',{
      orderId: orderId
    })
    if (response.code == 200) {
      ElMessage.success(response.message);
      tableData.value = response.data;
      console.log(tableData.value);
    } else {
      ElMessage.error(response.message);
    }
}
catch (error) {
    // 处理错误
    console.error(error);
  }
}
function getStatusType(warehousing) {  
switch (warehousing) {  
  case 0:  
    return 'info';  
  case 1:  
    return 'warning';  
  case 2:  
    return 'success';  
}  
}  
function getStatusText(warehousing) {  
switch (warehousing) {
  case 0:  
    return t('large.notstocked');
  case 1:  
    return t('large.inboundstatus');
  case 2:  
  return t('large.allstatus');
}  
}  
let socket = null;
let socket2 = null;
let socket3 = null;
let socket4 = null;
let socket5 = null;
let socket6 = null;
const socketUrl = `ws://${WebSocketHost}:${host}/api/temperingGlass/api/talk/screen`;
const handleMessage = (data) => {
// tableData.value = data.awaitingRepairs[0]
tableDatab.value = data.DoingTask[0]
tableDatac.value = data.orders[0]
  socket.onmessage = (event) => {  
  const data = JSON.parse(event.data);  
  processesData.value = data.device[0].map(rect => ({  
    ...rect,  
    completedQuantity: rect.completedQuantity,  
    breakageQuantity: rect.breakageQuantity,  
    thisProcess: rect.thisProcess,  
  }));  
  renderPieCharts();
}
};
function setChartDom(index, el) {  
if (!chartRefs.value[index]) {  
  chartRefs.value[index] = { dom: el, chart: null };  
} else {  
  chartRefs.value[index].dom = el;  
}  
const socketUrl2 = `ws://${WebSocketHost}:${host}/api/temperingGlass/api/talk/temperingIsRun`;
const handleMessage2 = (data) => {
  const tasks = data.temperingTaskType[0];  
    flake.value = tasks.some(task => task.state == 1);
    flakeb.value = tasks.some(task => task.state == 2);
    flakec.value = tasks.some(task => task.state == 3);
    flaked.value = tasks.some(task => task.state == 4);
};
// 卧式理片
const socketUrl3 = `ws://${WebSocketHost}:${host}/api/cacheGlass/api/talk/cacheGlassIsRun`;
const handleMessage3 = (data) => {
  const tasks = data.taskCaches[0];  
  woshia.value = tasks.some(task => task.line == 2001);  
  woshic.value = tasks.some(task => task.line == 2002);  
  console.log(tasks);
  
};
// 大理片笼
const socketUrl4 = `ws://${WebSocketHost}:${host}/api/cacheVerticalGlass/api/talk/isRun`;
const handleMessage4 = (data) => {
  const tasks = data.bigStorageCageDetailsOutTask[0];  
  const taskss = data.bigStorageCageDetailsFeedTask[0];  
    dalipiana.value = tasks.some(task => task.slot !== null && task.slot !== undefined);  
dalipianb.value = taskss.some(task => task.slot !== null && task.slot !== undefined);  
};
// 上片
const socketUrl5 = `ws://${WebSocketHost}:${host}/api/loadGlass/api/talk/loadGlassIsRun`;
const handleMessage5 = (data) => {
  if(data.engineering.length !==0 ){
    shangpian.value = true;
}
};
// 下片
const socketUrl6 = `ws://${WebSocketHost}:${host}/api/unLoadGlass/api/talk/unLoadGlassIsRun`;
const handleMessage6 = (data) => {
  const tasks = data.downWorkstation[0];  
  if (tasks && tasks.length >= 6) {  
    xiapian.value = tasks.some(task => task.racksNumber!== 0);  
    xiapian1.value = tasks[0].racksNumber !== 0;
    xiapian2.value = tasks[1].racksNumber !== 0;
    xiapian3.value = tasks[2].racksNumber !== 0;
    xiapian4.value = tasks[3].racksNumber !== 0;
    xiapian5.value = tasks[4].racksNumber !== 0;
    xiapian6.value = tasks[5].racksNumber !== 0;
  }
};
const renderPieCharts = () => {
processesData.value.forEach((data, index) => {
  const chart = echarts.init(document.getElementById('pieChart_' + index));
  const options = {
    title: {
        text: `${data.thisProcess} `,
        left: 'center',
      },
    tooltip: {
      trigger: 'item',
    },
    series: [
      {
        name: `${data.thisProcess} `,
        type: 'pie',
        radius: ['40%', '70%'],
        avoidLabelOverlap: false,
        data: [
          { value: data.completedQuantity, name: t('large.completedquantity') },
          { value: data.breakageQuantity, name: t('large.scrapquantity') }
        ],
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
          }
        },
        label: {
          show: false,
          position: 'center',
        },
      labelLine: {
        show: false
      },
      }
    ]
  };
 
  chart.setOption(options);
});
};
onMounted(() => {
  socket = initializeWebSocket(socketUrl, handleMessage);
  socket2 = initializeWebSocket(socketUrl2, handleMessage2);
  socket3 = initializeWebSocket(socketUrl3, handleMessage3);
  socket4 = initializeWebSocket(socketUrl4, handleMessage4);
  socket5 = initializeWebSocket(socketUrl5, handleMessage5);
  socket6 = initializeWebSocket(socketUrl6, handleMessage6);
});
  onUnmounted(() => {
    if (socket) {
    closeWebSocket(socket);
    }
    if (socket2) {
    closeWebSocket2(socket2);
    }
    if (socket3) {
    closeWebSocket3(socket3);
    }
    if (socket4) {
    closeWebSocket4(socket4);
    }
    if (socket5) {
    closeWebSocket5(socket5);
    }
    if (socket6) {
    closeWebSocket6(socket6);
    }
    });
onBeforeUnmount(() => {
console.log("关闭了")
closeWebSocket();
closeWebSocket2();
closeWebSocket3();
closeWebSocket4();
closeWebSocket5();
closeWebSocket6();
});
</script>  
 
<style scoped>  
.echarts-container {
display: flex;
flex-wrap: wrap;
gap: 20px;
}
.echarts-item {
width: 120px;
height: 150px;
margin: 20px;
}
.pie-chart {
width: 100%;
height: 100%;
}
.parter {
    position: relative;
    display: inline-block; /* 使容器大小适应图片大小 */
  width: 1500px;
  margin-left: -300px
}
img {
    display: block; /* 让图片以块级元素显示 */
    max-width: 100%; /* 确保图片不超出容器 */
}
.moving-rect {
    width: 100px;
    height: 50px;
    position: absolute;
}
.longa{
  z-index: 1;
  width: 33px;
  height: 5px;
  background-color: #529b2e;
  margin-top: -15px;
  margin-left: 130px;
}
.longb{
  z-index: 1;
  width: 33px;
  height: 5px;
  background-color: #529b2e;
  margin-top: -15px;
  margin-left: 235px;
}
.xiapianji1{
  z-index: 1;
  width: 12px;
  height: 7px;
  background-color: #529b2e;
  margin-top: -206px;
  margin-left: 173px;
}
.xiapianji2{
  z-index: 1;
  width: 12px;
  height: 7px;
  background-color: #529b2e;
  margin-top: -206px;
  margin-left: 217px;
}
.xiapianji3{
  z-index: 1;
  width: 12px;
  height: 7px;
  background-color: #529b2e;
  margin-top: -195px;
  margin-left: 196px;
}
.xiapianji4{
  z-index: 1;
  width: 12px;
  height: 7px;
  background-color: #529b2e;
  margin-top: -206px;
  margin-left: 270px;
}
.xiapianji5{
  z-index: 1;
  width: 12px;
  height: 7px;
  background-color: #529b2e;
  margin-top: -206px;
  margin-left: 314px;
}
.xiapianji6{
  z-index: 1;
  width: 12px;
  height: 7px;
  background-color: #529b2e;
  margin-top: -195px;
  margin-left: 293px;
}
.xiapianji {
    width: 20px;
    height: 10px;
    background-color: #529b2e;
    top: 9px;
    left: 200px;
    transform: translateX(-50%);
    animation: move-xiapianji 6s infinite;
}
@keyframes move-xiapianji {
    0% {
      left: 200px;
    }
    100% {
      left: calc(100% - 700px);
    }
}
.lipiana {
    width: 15px;
    height: 9px;
    background-color: #529b2e;
    top: 190px;
    right: 530px;
    transform: translateX(-50%);
    animation: move-lipiana 6s infinite;
}
@keyframes move-lipiana {
    0% {
      right: 530px;
    }
    100% {
      right: calc(100% - 350px);
    }
}
.lipianb {
    width: 18px;
    height: 10px;
    background-color: #529b2e;
    top: 160px;
    left: 502px;
    transform: translateX(-50%);
    animation: move-lipianb 6s infinite;
}
@keyframes move-lipianb {
    0% {
        top: 160px;
    }
    100% {
        top: calc(100% - 55px);
    }
}
.lipianc {
    width: 15px;
    height: 9px;
    background-color: #529b2e;
    top: 215px;
    right: 490px;
    transform: translateX(-50%);
    animation: move-lipianc 6s infinite;
}
@keyframes move-lipianc {
    0% {
      right: 490px;
    }
    100% {
      right: calc(100% - 350px);
    }
}
.lipiand {
    width: 25px;
    height: 10px;
    background-color: #529b2e;
    top: 160px;
    left: 555px;
    transform: translateX(-50%);
    animation: move-lipiand 6s infinite;
}
@keyframes move-lipiand {
    0% {
        top: 160px;
    }
    100% {
        top: calc(100% - 40px);
    }
}
.overlaya {
    width: 15px;
    height: 9px;
    background-color: #529b2e;
    top: 213px;
    right: 800px;
    transform: translateX(-50%);
    animation: move-overlaya 6s infinite;
}
@keyframes move-overlaya {
    0% {
      right: 880px;
    }
    100% {
      right: calc(100% - 15px);
    }
}
.overlayb {
    width: 20px;
    height: 10px;
    background-color: #529b2e;
    top: 110px;
    left: 13px;
    transform: translateX(-50%);
    animation: move-overlayb 6s infinite;
}
@keyframes move-overlayb {
    0% {
        top: 160px;
    }
    100% {
        top: calc(100% - 190px);
    }
}
.overlayc {
    width: 20px;
    height: 10px;
    background-color: #529b2e;
    top: 7px;
    left: 13px;
    transform: translateX(-50%);
    animation: move-overlayc 6s infinite;
}
@keyframes move-overlayc {
    0% {
      left: 20px;
    }
    100% {
      left: calc(100% - 900px);
    }
}
.shangpianji {
    width: 20px;
    height: 10px;
    background-color: #529b2e;
    top: 157px;
    right: 90px;
    transform: translateX(-50%);
    animation: move-shangpianji 6s infinite;
}
@keyframes move-shangpianji {
    0% {
      right: 90px;
    }
    100% {
      right: calc(100% - 770px);
    }
}
</style>