Bladeren bron

产品检测详情

钞小赢 1 jaar geleden
bovenliggende
commit
efa1222d8b

+ 109 - 363
src/views/demo/productManage/productInfo/index.vue

@@ -135,85 +135,7 @@
135 135
 
136 136
                 <el-tabs v-model="runDataActiveName" @tab-click="runDataClick">
137 137
     <el-tab-pane label="实时数据" name="realData">
138
-      <h5 style="margin: 20px 0">历史定时任务数据</h5>
139
-      <div class="topCalc">
140
-        <div class="temp">
141
-          <div class="tempName">
142
-            <div>
143
-              <img src="../../../../assets/images/temp.png" alt="" style="width:10px;height:15px;">
144
-            </div>
145
-            <div>温度 (℃)</div>
146
-          </div>
147
-          <div class="tempDetail">
148
-            <div class="bottom">
149
-              <div>最高</div>
150
-              <div style="color:#008775;font-size:16px;font-weight: bolder;">28.4</div>
151
-            </div>
152
-            <div class="Separator"></div>
153
-            <div class="bottom">
154
-              <div>最低</div>
155
-              <div style="color:#008775;font-size:16px;font-weight: bolder;">28.4</div>
156
-            </div>
157
-            <div class="Separator"></div>
158
-            <div class="bottom">
159
-              <div>平均</div>
160
-              <div style="color:#008775;font-size:16px;font-weight: bolder;">28.4</div>
161
-            </div>
162
-          </div>
163
-        </div>
164
-
165
-
166
-        <div class="temp">
167
-          <div class="tempName">
168
-            <div>
169
-              <img src="../../../../assets/images/wet.png" alt="" style="width:10px;height:15px;">
170
-            </div>
171
-            <div>湿度 (%RH)</div>
172
-          </div>
173
-          <div class="tempDetail">
174
-            <div class="bottom">
175
-              <div>最高</div>
176
-              <div style="color:#008775;font-size:16px;font-weight: bolder;">28.4</div>
177
-            </div>
178
-            <div class="Separator"></div>
179
-            <div class="bottom">
180
-              <div>最低</div>
181
-              <div style="color:#008775;font-size:16px;font-weight: bolder;">28.4</div>
182
-            </div>
183
-            <div class="Separator"></div>
184
-            <div class="bottom">
185
-              <div>平均</div>
186
-              <div style="color:#008775;font-size:16px;font-weight: bolder;">28.4</div>
187
-            </div>
188
-          </div>
189
-        </div>
190
-
191
-
192
-        <div class="temp">
193
-          <div class="tempName">
194
-            <div>
195
-              <img src="../../../../assets/images/dew.png" alt="" style="width:10px;height:15px;">
196
-            </div>
197
-            <div>露点温度 (℃)</div>
198
-          </div>
199
-          <div class="tempDetail">
200
-            <div class="bottom">
201
-              <div>最高</div>
202
-              <div style="color:#008775;font-size:16px;font-weight: bolder;">28.4</div>
203
-            </div>
204
-            <div class="Separator"></div>
205
-            <div class="bottom">
206
-              <div>最低</div>
207
-              <div style="color:#008775;font-size:16px;font-weight: bolder;">28.4</div>
208
-            </div>
209
-            <div class="Separator"></div>
210
-            <div class="bottom">
211
-              <div>平均</div>
212
-              <div style="color:#008775;font-size:16px;font-weight: bolder;">28.4</div>
213
-            </div>
214
-          </div>
215
-        </div>
216
-      </div>
138
+       <real-time></real-time>
217 139
     </el-tab-pane>
218 140
     <el-tab-pane label="历史定时任务" name="hisTask">
219 141
                 <h5 style="margin: 20px 0">历史定时任务数据</h5>
@@ -444,162 +366,51 @@
444 366
       </el-dialog>
445 367
       <addDialog :dialogTitle="'产品基本信息'" ref="addDialog"/>
446 368
       <el-dialog title="检测详情" id="dialogStyle" width="800px" :visible.sync="checkDialog">
447
-        <!-- <detailTable ref="detailTable" :detail-table="checkInfo" :title="''" /> -->
448
-        <div class="panel-height-add">
449
-          <div style="padding: 2px">
450
-            <div class="detBox">
451
-              <div
452
-                v-for="(item, i) in checkInfo"
453
-                :key="i"
454
-                class="divF"
455
-                :style="{
456
-                  'line-height':
457
-                    (item.val.length == 0 ? 1 : item.val.length) * 48 + 'px',
458
-                  height:
459
-                    (item.val.length == 0 ? 1 : item.val.length) * 48 + 'px',
460
-                }"
461
-              >
462
-                <div>
463
-                  <div>{{ item.name }}</div>
464
-                </div>
465
-                <div :class="item.name1 == undefined ? 'long' : ''">
466
-                  <el-tooltip
467
-                    v-for="(data, len) in item.val"
468
-                    :key="len"
469
-                    effect="dark"
470
-                    :content="data"
471
-                    :disabled="(data + '').length < 20"
472
-                    placement="top"
473
-                  >
474
-                    <div>{{ data == null ? "" : data }}</div>
475
-                  </el-tooltip>
476
-                </div>
477
-                <div v-if="item.name1 != undefined">
478
-                  <el-tooltip
479
-                    effect="dark"
480
-                    :content="item.name1"
481
-                    :disabled="(item.name1 + '').length < 13"
482
-                    placement="top"
483
-                  >
484
-                    <div>{{ item.name1 }}</div>
485
-                  </el-tooltip>
486
-                </div>
487
-                <div v-if="item.name1 != undefined">
488
-                  <el-tooltip
489
-                    v-for="(data, index) in item.val1"
490
-                    :key="index"
491
-                    effect="dark"
492
-                    :content="data"
493
-                    :disabled="(data + '').length < 22"
494
-                    placement="top"
495
-                  >
496
-                    <div>{{ data == null ? "" : data }}</div>
497
-                  </el-tooltip>
498
-                </div>
499
-                <div v-if="item.name1 != undefined">
500
-                  <el-tooltip
501
-                    effect="dark"
502
-                    :content="item.name2"
503
-                    :disabled="(item.name2 + '').length < 13"
504
-                    placement="top"
505
-                  >
506
-                    <div>{{ item.name2 }}</div>
507
-                  </el-tooltip>
508
-                </div>
509
-                <div v-if="item.name1 != undefined">
510
-                  <el-tooltip
511
-                    v-for="(data, index) in item.val2"
512
-                    :key="index"
513
-                    effect="dark"
514
-                    :content="data"
515
-                    :disabled="(data + '').length < 22"
516
-                    placement="top"
517
-                  >
518
-                    <div>{{ data == null ? "" : data }}</div>
519
-                  </el-tooltip>
520
-                </div>
521
-              </div>
522
-            </div>
523
-          </div>
524
-        </div>
525
-        <div class="panel-height-add">
526
-          <div style="padding: 2px">
527
-            <div class="detBox">
528
-              <div class="title" v-for="(item, i) in checkInfo1" :key="i">{{item.title}}</div>
529
-              <div
530
-                v-for="(item, i) in checkInfo1"
531
-                :key="i"
532
-                class="divF"
533
-                :style="{
534
-                  'line-height':
535
-                    (item.val.length == 0 ? 1 : item.val.length) * 48 + 'px',
536
-                  height:
537
-                    (item.val.length == 0 ? 1 : item.val.length) * 48 + 'px',
538
-                }"
539
-              >
540
-                <div>
541
-                  <div>{{ item.name }}</div>
542
-                </div>
543
-                <div :class="item.name1 == undefined ? 'long' : ''">
544
-                  <el-tooltip
545
-                    v-for="(data, len) in item.val"
546
-                    :key="len"
547
-                    effect="dark"
548
-                    :content="data"
549
-                    :disabled="(data + '').length < 20"
550
-                    placement="top"
551
-                  >
552
-                    <div>{{ data == null ? "" : data }}</div>
553
-                  </el-tooltip>
554
-                </div>
555
-                <div v-if="item.name1 != undefined">
556
-                  <el-tooltip
557
-                    effect="dark"
558
-                    :content="item.name1"
559
-                    :disabled="(item.name1 + '').length < 13"
560
-                    placement="top"
561
-                  >
562
-                    <div>{{ item.name1 }}</div>
563
-                  </el-tooltip>
564
-                </div>
565
-                <div v-if="item.name1 != undefined">
566
-                  <el-tooltip
567
-                    v-for="(data, index) in item.val1"
568
-                    :key="index"
569
-                    effect="dark"
570
-                    :content="data"
571
-                    :disabled="(data + '').length < 22"
572
-                    placement="top"
573
-                  >
574
-                    <div>{{ data == null ? "" : data }}</div>
575
-                  </el-tooltip>
576
-                </div>
577
-                <div v-if="item.name1 != undefined">
578
-                  <el-tooltip
579
-                    effect="dark"
580
-                    :content="item.name2"
581
-                    :disabled="(item.name2 + '').length < 13"
582
-                    placement="top"
583
-                  >
584
-                    <div>{{ item.name2 }}</div>
585
-                  </el-tooltip>
586
-                </div>
587
-                <div v-if="item.name1 != undefined">
588
-                  <el-tooltip
589
-                    v-for="(data, index) in item.val2"
590
-                    :key="index"
591
-                    effect="dark"
592
-                    :content="data"
593
-                    :disabled="(data + '').length < 22"
594
-                    placement="top"
595
-                  >
596
-                    <div>{{ data == null ? "" : data }}</div>
597
-                  </el-tooltip>
598
-                </div>
599
-              </div>
600
-            </div>
601
-          </div>
369
+      
370
+  
371
+        <table border="1" style="border-collapse: collapse;width:100%" class="detailTableStyle" v-if="detailData">
372
+         <tr >
373
+          <td width="20%">检测时间</td>
374
+          <td colspan="5" width="80%">{{detailData.dataTime}}</td>
375
+          
376
+         </tr>
377
+         <tr>
378
+          <td width="20%">最高温度(℃)</td>
379
+          <td width="14%">{{detailData.maxValue}}</td>
380
+          <td width="20%">最低温度(℃)</td>
381
+          <td width="13%">{{detailData.minValue}}</td>
382
+          <td width="20%">平均温度(℃)</td>
383
+          <td width="13%">{{detailData.avgValue}}</td>
384
+         </tr>
385
+         <tr>
386
+          <td width="20%">最高湿度(%RH)</td>
387
+          <td width="14%">{{detailData.maxWet}}</td>
388
+          <td width="20%">最低湿度(%RH)</td>
389
+          <td width="13%">{{detailData.minWet}}</td>
390
+          <td width="20%">平均湿度(%RH)</td>
391
+          <td width="13%">{{detailData.avgWet}}</td>
392
+         </tr>
393
+         <tr>
394
+          <td width="20%">最高露点温度(℃)</td>
395
+          <td width="14%">{{detailData.maxDew}}</td>
396
+          <td width="20%">最低露点温度(℃)</td>
397
+          <td width="13%">{{detailData.minDew}}</td>
398
+          <td width="20%">平均露点温度(℃)</td>
399
+          <td width="13%">{{detailData.avgDew}}</td>
400
+         </tr>
401
+       </table>
402
+
403
+       <div class="sbData"  v-for="(item,index) in sbDetailData" :key="index">
404
+        <div class="sbTitle">{{item.sign}}</div>
405
+        <div class="sbDetail">
406
+          <div class="sbDetailDiv">温度(℃)</div>
407
+          <div class="sbDetailDiv">{{item.tempValue}}</div>
408
+          <div class="sbDetailDiv">湿度(%RH)</div>
409
+          <div class="sbDetailDiv">{{item.wetValue}}</div>
410
+          <div class="sbDetailDiv">露点温度(℃)</div>
411
+          <div class="sbDetailDiv">{{item.dewValue}}</div>
602 412
         </div>
413
+       </div>
603 414
       </el-dialog>
604 415
     </d2-container>
605 416
   </div>
@@ -607,11 +418,12 @@
607 418
 <script>
608 419
 import addDialog from "../compontents/addDialog.vue";
609 420
 import api from "@/api";
421
+import realTime from "./realTime"
610 422
 
611 423
 import detailTable from "@/components/detailTable/index.vue";
612 424
 export default {
613 425
   name: "productInfo",
614
-  components: { detailTable ,addDialog},
426
+  components: { detailTable ,addDialog,realTime},
615 427
   data() {
616 428
     return {
617 429
       runDataActiveName:'realData',
@@ -626,47 +438,9 @@ export default {
626 438
       productData:[{}],
627 439
       productData1:[{}],
628 440
       activeName: "first",
629
-      checkInfo: [
630
-        {
631
-          name: "检测时间",
632
-          val: [""],
633
-        },
634
-        {
635
-          name: "最高温度(℃)",
636
-          val: [""],
637
-          name1: "最低温度(℃)",
638
-          val1: [""],
639
-          name2: "平均温度(℃)",
640
-          val2: [""],
641
-        },
642
-        {
643
-          name: "最高湿度(%RH)",
644
-          val: [""],
645
-          name1: "最低湿度(%RH)",
646
-          val1: [""],
647
-          name2: "平均湿度(%RH)",
648
-          val2: [""],
649
-        },
650
-        {
651
-          name: "最高露点温度(℃)",
652
-          val: [""],
653
-          name1: "最低露点温度(℃)",
654
-          val1: [""],
655
-          name2: "平均露点温度(℃)",
656
-          val2: [""],
657
-        },
658
-      ],
659
-      checkInfo1: [
660
-        {
661
-          title:'设备1(编号/标识/设备名称)',
662
-          name: "温度(℃)",
663
-          val: [""],
664
-          name1: "湿度(%RH)",
665
-          val1: [""],
666
-          name2: "露点温度(℃)",
667
-          val2: [""],
668
-        }
669
-      ],
441
+      detailData:{},
442
+      sbDetailData:[],
443
+     
670 444
       basicInfo: [
671 445
         {
672 446
           name: "产品ID",
@@ -792,54 +566,20 @@ export default {
792 566
       console.log(12);
793 567
       this.$set(this, "checkDialog", true);
794 568
       this.checkDialog = true;
795
-      this.checkInfo=[
796
-        {
797
-          name: "检测时间",
798
-          val: [row.dataTime],
799
-        },
800
-        {
801
-          name: "最高温度(℃)",
802
-          val: [row.maxValue],
803
-          name1: "最低温度(℃)",
804
-          val1: [row.minValue],
805
-          name2: "平均温度(℃)",
806
-          val2: [row.avgValue],
807
-        },
808
-        {
809
-          name: "最高湿度(%RH)",
810
-          val: [row.maxWet],
811
-          name1: "最低湿度(%RH)",
812
-          val1: [row.minWet],
813
-          name2: "平均湿度(%RH)",
814
-          val2: [row.avgWet],
815
-        },
816
-        {
817
-          name: "最高露点温度(℃)",
818
-          val: [row.maxDew],
819
-          name1: "最低露点温度(℃)",
820
-          val1: [row.minDew],
821
-          name2: "平均露点温度(℃)",
822
-          val2: [row.avgDew],
823
-        },
824
-      ]
569
+   
570
+      this.detailData=JSON.parse(JSON.stringify(row))
571
+
572
+      this.detailData.avgDew=(this.detailData.avgDew).toFixed(2)
573
+      this.detailData.avgValue=(this.detailData.avgValue).toFixed(2)
574
+      this.detailData.avgWet=(this.detailData.avgWet).toFixed(2)
575
+      console.log(row,"ooo")
825 576
       api.runDataDetail(row.id)
826 577
         .then((res) => {
827 578
           if (res.code == 200) {
828
-            let data=res.data
829
-            this.checkInfo1=[]
830
-            data.forEach(item=>{
831
-              this.checkInfo1.push(
832
-                {
833
-                  title:item.sign,
834
-                  name: "温度(℃)",
835
-                  val: [item.tempValue],
836
-                  name1: "湿度(%RH)",
837
-                  val1: [item.wetValue],
838
-                  name2: "露点温度(℃)",
839
-                  val2: [item.dewValue],
840
-                }
841
-              )
842
-            })
579
+            this.sbDetailData=res.data
580
+            console.log(res,"检测详情。")
581
+
582
+          
843 583
           }
844 584
         })
845 585
         .catch((err) => {
@@ -1106,49 +846,7 @@ export default {
1106 846
         }
1107 847
       }
1108 848
     }
1109
-    .topCalc{
1110
-     display:flex;
1111
-
1112
-    .temp{
1113
-      width: 250px;
1114
-    height: 110px;
1115
-    background-color:rgba(240, 240, 240, 1);
1116
-    border:2px solid rgba(230, 230, 230, 1);
1117
-      display: flex;
1118
-    flex-direction: column;
1119
-    font-size: 12px;
1120
-    margin-right:20px;
1121 849
   
1122
-    .tempName{
1123
-      height: 35px;
1124
-    display: flex;
1125
-    justify-content: center;
1126
-    align-items: center;
1127
-    color:#000000;
1128
-    border-bottom:2px solid rgba(230, 230, 230, 1);
1129
-
1130
-    
1131
-
1132
-    }
1133
-    .tempDetail{
1134
-    height: 75px;
1135
-    display: flex;
1136
-    justify-content: space-around;
1137
-    align-items: center;
1138
-    .bottom{
1139
-      height: 50px;
1140
-    display: flex;
1141
-    flex-direction: column;
1142
-    justify-content: space-around;
1143
-    }
1144
-    .Separator{
1145
-      height:15px;
1146
-      border:1px solid rgba(230, 230, 230, 1);
1147
-    }
1148
-    }
1149
-    }
1150
-   
1151
-    }
1152 850
   }
1153 851
 }
1154 852
 ::v-deep .el-tabs {
@@ -1286,4 +984,52 @@ export default {
1286 984
         cursor: pointer;
1287 985
     }
1288 986
   }
987
+  .detailTableStyle {
988
+    tr{
989
+   
990
+  height:50px;
991
+  td{
992
+    border: 1px solid #ccc;
993
+    text-align: center;
994
+  }
995
+    }
996
+ 
997
+}
998
+.sbData{
999
+
1000
+  height:60px;
1001
+  
1002
+  border: 2px solid rgb(238, 234, 234);
1003
+  margin:10px 0;
1004
+
1005
+  .sbTitle{
1006
+    padding-left:10px;
1007
+    height:30px;
1008
+    background-color:rgba(234, 234, 234, 1);
1009
+  line-height:30px;
1010
+  }
1011
+  .sbDetail{
1012
+    display:flex;
1013
+    height:30px;
1014
+    align-items: center;
1015
+
1016
+   
1017
+    .sbDetailDiv{
1018
+      flex: 1;
1019
+      height:30px;
1020
+      line-height:30px;
1021
+      border-left:1px solid rgba(234, 234, 234, 1);
1022
+      text-align: center;
1023
+    }
1024
+     .sbDetailDiv:first-child{
1025
+     border:none;
1026
+    }
1027
+    .sbDetailDiv:nth-child(odd){
1028
+     background:rgb(245, 243, 243);
1029
+    }
1030
+   
1031
+  }
1032
+}
1033
+
1289 1034
 </style>
1035
+

+ 445 - 0
src/views/demo/productManage/productInfo/realTime/index.vue

@@ -0,0 +1,445 @@
1
+<template>
2
+  <div>
3
+    <h5 style="margin: 20px 0">全部设备平均实时数据</h5>
4
+    <div class="topCalc">
5
+      <div class="temp">
6
+        <div class="tempName">
7
+          <div>
8
+            <img
9
+              src="../../../../../assets/images/temp.png"
10
+              alt=""
11
+              style="width: 10px; height: 15px; margin-right: 5px"
12
+            />
13
+          </div>
14
+          <div>温度 (℃)</div>
15
+        </div>
16
+        <div class="tempDetail">
17
+          <div class="bottom">
18
+            <div>最高</div>
19
+            <div style="color: #008775; font-size: 16px; font-weight: bolder">
20
+              {{ maxTemp }}
21
+            </div>
22
+          </div>
23
+          <div class="Separator"></div>
24
+          <div class="bottom">
25
+            <div>最低</div>
26
+            <div style="color: #008775; font-size: 16px; font-weight: bolder">
27
+              {{ minTemp }}
28
+            </div>
29
+          </div>
30
+          <div class="Separator"></div>
31
+          <div class="bottom">
32
+            <div>平均</div>
33
+            <div style="color: #008775; font-size: 16px; font-weight: bolder">
34
+              {{ tempAve }}
35
+            </div>
36
+          </div>
37
+        </div>
38
+      </div>
39
+
40
+      <div class="temp">
41
+        <div class="tempName">
42
+          <div>
43
+            <img
44
+              src="../../../../../assets/images/wet.png"
45
+              alt=""
46
+              style="width: 10px; height: 15px; margin-right: 5px"
47
+            />
48
+          </div>
49
+          <div>湿度 (%RH)</div>
50
+        </div>
51
+        <div class="tempDetail">
52
+          <div class="bottom">
53
+            <div>最高</div>
54
+            <div style="color: #008775; font-size: 16px; font-weight: bolder">
55
+              {{ maxWet }}
56
+            </div>
57
+          </div>
58
+          <div class="Separator"></div>
59
+          <div class="bottom">
60
+            <div>最低</div>
61
+            <div style="color: #008775; font-size: 16px; font-weight: bolder">
62
+              {{ minWet }}
63
+            </div>
64
+          </div>
65
+          <div class="Separator"></div>
66
+          <div class="bottom">
67
+            <div>平均</div>
68
+            <div style="color: #008775; font-size: 16px; font-weight: bolder">
69
+              {{ wetAve }}
70
+            </div>
71
+          </div>
72
+        </div>
73
+      </div>
74
+
75
+      <div class="temp">
76
+        <div class="tempName">
77
+          <div>
78
+            <img
79
+              src="../../../../../assets/images/dew.png"
80
+              alt=""
81
+              style="width: 10px; height: 15px; margin-right: 5px"
82
+            />
83
+          </div>
84
+          <div>露点温度 (℃)</div>
85
+        </div>
86
+        <div class="tempDetail">
87
+          <div class="bottom">
88
+            <div>最高</div>
89
+            <div style="color: #008775; font-size: 16px; font-weight: bolder">
90
+              {{ maxDew }}
91
+            </div>
92
+          </div>
93
+          <div class="Separator"></div>
94
+          <div class="bottom">
95
+            <div>最低</div>
96
+            <div style="color: #008775; font-size: 16px; font-weight: bolder">
97
+              {{ minDew }}
98
+            </div>
99
+          </div>
100
+          <div class="Separator"></div>
101
+          <div class="bottom">
102
+            <div>平均</div>
103
+            <div style="color: #008775; font-size: 16px; font-weight: bolder">
104
+              {{ dewAve }}
105
+            </div>
106
+          </div>
107
+        </div>
108
+      </div>
109
+    </div>
110
+    <h5 style="margin: 20px 0">单个测温湿设备实时数据</h5>
111
+    <div class="singleDevice" v-for="(item, index) in showData" :key="index">
112
+      <div class="top">
113
+        <div class="deviceName">
114
+          <span class="shu"></span>
115
+          {{item.sbName}}/{{item.device}}
116
+        </div>
117
+        <div class="deviceDetail">
118
+          <div class="bottom">
119
+            <div>温度 (℃)</div>
120
+            <div style="color: #008775; font-size: 14px; font-weight: bolder">
121
+              {{ item.tempValue }}
122
+            </div>
123
+          </div>
124
+          <div class="Separator"></div>
125
+          <div class="bottom">
126
+            <div>湿度 (%RH)</div>
127
+            <div style="color: #008775; font-size: 14px; font-weight: bolder">
128
+              {{ item.wetValue }}
129
+            </div>
130
+          </div>
131
+          <div class="Separator"></div>
132
+          <div class="bottom">
133
+            <div>露点温度 (℃)</div>
134
+            <div style="color: #008775; font-size: 14px; font-weight: bolder">
135
+              {{ item.dewValue }}
136
+            </div>
137
+          </div>
138
+        </div>
139
+      </div>
140
+    </div>
141
+  </div>
142
+</template>
143
+<script>
144
+import mqtt from "mqtt";
145
+import api from "@/api";
146
+export default {
147
+  data() {
148
+    return {
149
+      showData: [],
150
+      maxTemp: null,
151
+      minTemp: null,
152
+      maxWet: null,
153
+      minWet: null,
154
+      maxDew: null,
155
+      minDew: null,
156
+      tempAve: null,
157
+      dewAve: null,
158
+      wetAve: null,
159
+      //设备列表
160
+      sbList:[]
161
+    };
162
+  },
163
+  methods: {
164
+    connect() {
165
+      let options = {
166
+        //本地
167
+        username: "admin",
168
+        password: "public",
169
+        //测试
170
+        // username: "admin",
171
+        // password: "admin@123",
172
+        //生产
173
+        // username: "admin",
174
+        // password: "admin@2Ld&DDrsk",
175
+        cleanSession: true,
176
+        keepAlive: 60,
177
+        clientId: "mqttjs_" + Math.random().toString(16).substr(2, 8),
178
+        connectTimeout: 4000,
179
+      };
180
+      //本地开发环境
181
+      this.client = mqtt.connect("ws://192.168.50.169:8083/mqtt", options);
182
+      //测试环境
183
+      // this.client = mqtt.connect('ws://172.16.0.5:8083/mqtt',options);
184
+      //正式环境
185
+      // this.client = mqtt.connect('ws://10.105.101.61:8083/mqtt',options);
186
+      this.client.on("connect", (e) => {
187
+        console.log("成功连接服务器2222222:", e);
188
+        //订阅三个名叫'top/#', 'three/#'和'#'的主题
189
+        this.client.subscribe(
190
+          [
191
+            // "/PUSH/c89512024085/DPUT/upload",
192
+            // "/PUSH/X1XXXQ2206090069/DPUT/upload",
193
+            "/PUSH/8951DQ2207200018/DPUT/upload",
194
+            "/PUSH/8951DQ2207200019/DPUT/upload",
195
+          ],
196
+          { qos: 1 },
197
+          (err) => {
198
+            if (!err) {
199
+              console.log("订阅成功");
200
+              //向主题叫“pubtop”发布一则内容为'hello,this is a nice day!'的消息
201
+              this.publish("pubtop", "hello,this is a nice day!");
202
+            } else {
203
+              console.log("消息订阅失败!");
204
+            }
205
+          }
206
+        );
207
+      });
208
+      //重新连接
209
+      this.reconnect();
210
+      //是否已经断开连接
211
+      this.mqttError();
212
+      //监听获取信息
213
+      this.getMessage();
214
+    },
215
+    //发布消息@topic主题  @message发布内容
216
+    publish(topic, message) {
217
+      if (!this.client.connected) {
218
+        console.log("客户端未连接");
219
+        return;
220
+      }
221
+      this.client.publish(topic, message, { qos: 1 }, (err) => {
222
+        if (!err) {
223
+          console.log("主题为" + topic + "发布成功");
224
+        }
225
+      });
226
+    },
227
+    //监听接收消息
228
+    getMessage() {
229
+      this.client.on("message", (topic, message) => {
230
+        if (message) {
231
+          let str = "8951DQ2207200019";
232
+          if (topic.indexOf(str) != -1) {
233
+            console.log("收到来着", topic, "的信息", message.toString());
234
+            var res = JSON.parse(message.toString());
235
+            console.log(res, "resssssss......");
236
+            if (res.data.length > 0) {
237
+              this.showData = res.data;
238
+              this.sbList.forEach(e=>{
239
+                this.showData.forEach(item=>{
240
+                    if(item.device==e.eqCode){
241
+                        item.sbName=e.eqName
242
+                    }
243
+                })
244
+              })
245
+              console.log(this.showData,"ggggg")
246
+              this.calcAve(this.showData);
247
+            } else {
248
+              this.$message({
249
+                message: "暂无数据",
250
+                type: "warning",
251
+              });
252
+            }
253
+          }
254
+
255
+          // 露点
256
+
257
+          // 温度
258
+          // 湿度
259
+        }
260
+      });
261
+    },
262
+    //监听服务器是否连接失败
263
+    mqttError() {
264
+      this.client.on("error", (error) => {
265
+        console.log("连接失败:", error);
266
+        this.client.end();
267
+      });
268
+    },
269
+    unsubscribe() {
270
+      this.client.unsubscribe(this.mtopic, (error) => {
271
+        console.log("主题为" + this.mtopic + "取消订阅成功", error);
272
+      });
273
+    },
274
+
275
+    //断开连接
276
+    unconnect() {
277
+      this.client.end();
278
+      this.client = null;
279
+      console.log("服务器已断开连接!");
280
+    },
281
+    //监听服务器重新连接
282
+    reconnect() {
283
+      this.client.on("reconnect", (error) => {
284
+        console.log("正在重连:", error);
285
+      });
286
+    },
287
+    //计算平均值
288
+    calcAve(arr) {
289
+      // maxTemp:null,
290
+      //  minTemp:null,
291
+      //  maxWet:null,
292
+      //  minWet:null,
293
+      //  maxDew:null,
294
+      //  minDew:null,
295
+      let tempArr = [];
296
+      let wetArr = [];
297
+      let dewArr = [];
298
+      let temp = 0;
299
+      let wet = 0;
300
+      let dew = 0;
301
+      let num = 0;
302
+      arr.forEach((item) => {
303
+        num++;
304
+        tempArr.push(parseInt(item.tempValue));
305
+        wetArr.push(parseInt(item.wetValue));
306
+        dewArr.push(parseInt(item.dewValue));
307
+        temp += parseInt(item.tempValue);
308
+        wet += parseInt(item.wetValue);
309
+        dew += parseInt(item.dewValue);
310
+      });
311
+      console.log(tempArr, wetArr, dewArr);
312
+      console.log(temp, wet, dew, num);
313
+      this.tempAve = (temp / num).toFixed(1);
314
+      this.dewAve = (dew / num).toFixed(1);
315
+      this.wetAve = (wet / num).toFixed(1);
316
+      tempArr = tempArr.sort();
317
+      wetArr = wetArr.sort();
318
+      dewArr = dewArr.sort();
319
+      // maxTemp:null,
320
+      //  minTemp:null,
321
+      //  maxWet:null,
322
+      //  minWet:null,
323
+      //  maxDew:null,
324
+      //  minDew:null,
325
+      this.maxTemp = tempArr[tempArr.length - 1];
326
+      this.minTemp = tempArr[0];
327
+      this.maxWet = wetArr[wetArr.length - 1];
328
+      this.minWet = wetArr[0];
329
+      this.maxDew = dewArr[dewArr.length - 1];
330
+      this.minDew = dewArr[0];
331
+      console.log(tempArr, wetArr, dewArr);
332
+    },
333
+  },
334
+  created() {
335
+    this.connect();
336
+    var condition = {};
337
+      condition.org_code = localStorage.getItem("orgCode");
338
+      condition = JSON.stringify(condition);
339
+      var data = {
340
+        pageIndex: 1,
341
+        pageSize: 999,
342
+        condition: condition,
343
+      };
344
+      api
345
+        .equipmentList(data)
346
+        .then((res) => {
347
+          if (res.code == 200) {
348
+            console.log(res,"设备。。")
349
+            this.sbList=res.data.records
350
+         
351
+          }
352
+        })
353
+        .catch((err) => {
354
+          console.log(err);
355
+        });
356
+  },
357
+};
358
+</script>
359
+<style lang="scss" scoped>
360
+.topCalc {
361
+  display: flex;
362
+
363
+  .temp {
364
+    width: 15%;
365
+    height: 110px;
366
+    background-color: rgba(240, 240, 240, 1);
367
+    border: 2px solid rgba(230, 230, 230, 1);
368
+    display: flex;
369
+    flex-direction: column;
370
+    font-size: 12px;
371
+    margin-right: 20px;
372
+
373
+    .tempName {
374
+      height: 35px;
375
+      display: flex;
376
+      justify-content: center;
377
+      align-items: center;
378
+      color: #000000;
379
+      border-bottom: 2px solid rgba(230, 230, 230, 1);
380
+    }
381
+    .tempDetail {
382
+      height: 75px;
383
+      display: flex;
384
+      justify-content: space-around;
385
+      align-items: center;
386
+      .bottom {
387
+        height: 50px;
388
+        display: flex;
389
+        flex-direction: column;
390
+        justify-content: space-around;
391
+      }
392
+      .Separator {
393
+        height: 15px;
394
+        border: 1px solid rgba(230, 230, 230, 1);
395
+      }
396
+    }
397
+  }
398
+}
399
+.singleDevice {
400
+    width: 15%;
401
+  height: 110px;
402
+  margin: 10px 10px 10px 0;
403
+  background-color: rgba(240, 240, 240, 1);
404
+  border: 2px solid rgba(230, 230, 230, 1);
405
+  display: inline-block;
406
+  flex-direction: column;
407
+  font-size: 12px;
408
+  margin-right: 21px;
409
+ 
410
+  .top {
411
+  }
412
+  .deviceName {
413
+    .shu {
414
+      display: inline-block;
415
+      width: 3px;
416
+      height: 13px;
417
+      background: #008775;
418
+      margin: 0 5px;
419
+    }
420
+    height: 35px;
421
+    display: flex;
422
+
423
+    align-items: center;
424
+    color: #000000;
425
+    border-bottom: 2px solid rgba(230, 230, 230, 1);
426
+  }
427
+  .deviceDetail {
428
+    height: 75px;
429
+    display: flex;
430
+    justify-content: space-around;
431
+    align-items: center;
432
+    .bottom {
433
+      height: 50px;
434
+      display: flex;
435
+      flex-direction: column;
436
+      justify-content: space-around;
437
+      align-items: center;
438
+    }
439
+    .Separator {
440
+      height: 15px;
441
+      border: 1px solid rgba(230, 230, 230, 1);
442
+    }
443
+  }
444
+}
445
+</style>

+ 55 - 23
src/views/system/visualized/index.vue

@@ -48,21 +48,21 @@
48 48
     
49 49
         "
50 50
       >
51
-                <div class="cf-left">
51
+                <div class="cf-left" v-if="tableData.length>0">
52 52
                             
53 53
                   <div
54 54
                   v-for="(e, index) in tableData"
55 55
                             :key="index"
56 56
                     :class="{
57
-                      normalTemp: wetTempStatus == 1,
58
-                      normalTemp1: wetTempStatus == 0,
57
+                      normalTemp: e.wetTempStatus == 1,
58
+                      normalTemp1:e.wetTempStatus == 0,
59 59
                     }"
60 60
                   >
61 61
                     <div class="temp-title">
62 62
                       {{ index + 1 }}号点位温湿度
63 63
                     </div>
64 64
                     <div class="temp-list">
65
-                      <div class="list-left" v-if="wetTempStatus == 1">
65
+                      <div class="list-left" v-if="e.wetTempStatus == 1">
66 66
                         <div class="hxBig">
67 67
                           <img
68 68
                             class="sxxz"
@@ -71,7 +71,7 @@
71 71
                           />
72 72
                         </div>
73 73
                       </div>
74
-                      <div class="list-left" v-if="wetTempStatus == 0">
74
+                      <div class="list-left" v-if="e.wetTempStatus == 0">
75 75
                         <img
76 76
                           src="../../../assets/images/bigScreen/fault.png"
77 77
                           alt=""
@@ -288,9 +288,9 @@
288 288
         </div>
289 289
 
290 290
         <div class="left-bottom">
291
-          <lsyj v-bind:cfCode="cfCode" ref="lsyjCharts"></lsyj>
292
-          <yjxx ></yjxx>
293
-          <wsdbh></wsdbh>
291
+          <lsyj  ref="lsyjCharts"></lsyj>
292
+          <yjxx ref="warnInfo"></yjxx>
293
+          <wsdbh ref="tempWetChange"></wsdbh>
294 294
           <cn-temp></cn-temp>
295 295
         </div>
296 296
       </div>
@@ -412,7 +412,7 @@ export default {
412 412
     },
413 413
     seamlessScrollOption(){
414 414
       return {
415
-        step: 0.8, // 数值越大速度滚动越快
415
+        step: 0, // 数值越大速度滚动越快
416 416
         limitMoveNum:6, // 开始无缝滚动的数据量 this.dataList.length
417 417
         hoverStop: true, // 是否开启鼠标悬停stop
418 418
         direction: 1, // 0向下 1向上 2向左 3向右
@@ -427,11 +427,13 @@ export default {
427 427
     //仓房下拉选改变时
428 428
 
429 429
     cfChange(val) {
430
-      console.log(val, "val..");
430
+   
431 431
       this.cfCode = val;
432 432
       console.log(this.cfCode,"选择的code")
433 433
       this.getPointList();
434
-      this.$refs.lsyjCharts.getHisWarning()
434
+      this.$refs.lsyjCharts.getHisWarning(this.cfCode)
435
+      this.$refs.warnInfo.getWarnInfo(this.cfCode)
436
+      this.$refs.tempWetChange.getTempWet(this.cfCode)
435 437
     },
436 438
     connect() {
437 439
       let options = {
@@ -990,35 +992,43 @@ export default {
990 992
 
991 993
     //公共方法(判断温湿度参数是否正常并添加属性)
992 994
     wetTempPublic(arr) {
995
+      console.log(arr,"arrr..")
993 996
       arr.forEach((ele) => {
994 997
         ele.forEach((item) => {
995 998
           if (this.tempParams) {
999
+           
996 1000
             if (
997 1001
               item.tempValue < this.tempParams.alarmValueMin ||
998 1002
               item.tempValue > this.tempParams.alarmValueMax
999 1003
             ) {
1004
+          
1000 1005
               item.status = 0;
1001
-              this.wetTempStatus = 0;
1006
+              // this.wetTempStatus = 0;
1002 1007
               item.tempStatus = 0;
1003
-            } else {
1008
+            }
1009
+             else {
1010
+             
1004 1011
               item.tempStatus = 1;
1005 1012
               item.status = 1;
1006
-              this.wetTempStatus = 1;
1013
+              // this.wetTempStatus = 1;
1007 1014
             }
1008 1015
           }
1009 1016
 
1010 1017
           if (this.wetParams) {
1018
+          
1011 1019
             if (
1012 1020
               item.wetValue < this.wetParams.alarmValueMin ||
1013 1021
               item.wetValue > this.wetParams.alarmValueMax
1014 1022
             ) {
1023
+           
1015 1024
               item.status = 0;
1016 1025
               item.wetStatus = 0;
1017
-              this.wetTempStatus = 0;
1026
+              // this.wetTempStatus = 0;
1018 1027
             } else {
1028
+          
1019 1029
               item.wetStatus = 1;
1020 1030
               item.status = 1;
1021
-              this.wetTempStatus = 1;
1031
+              // this.wetTempStatus = 1;
1022 1032
             }
1023 1033
           }
1024 1034
         });
@@ -1026,7 +1036,27 @@ export default {
1026 1036
 
1027 1037
       // //取整
1028 1038
       // this.rightDewValue=parseInt(this.rightDewValue/arr.length)
1029
-      console.log(this.tableData, "添加状态");
1039
+      console.log(arr, "添加状态");
1040
+      this.isNormalImg(arr)
1041
+    },
1042
+    //添加判断是否显示正常图片的字段
1043
+    isNormalImg(arr){
1044
+     arr.forEach(e=>{
1045
+      let a= e.some(item=>{
1046
+      return item.tempStatus==1
1047
+     })
1048
+     if(a==true){
1049
+      
1050
+     }
1051
+     console.log(a,"isNormal")
1052
+     })
1053
+    arr.forEach(e=>{
1054
+      let b=e.some(item=>{
1055
+      return item.wetStatus==1
1056
+     })
1057
+     console.log(b,"isNormal")
1058
+     })
1059
+   
1030 1060
     },
1031 1061
 
1032 1062
     //公共方法计算平均值
@@ -1040,7 +1070,7 @@ export default {
1040 1070
       arr.forEach((ele) => {
1041 1071
         ele.forEach((item) => {
1042 1072
           avgNum++;
1043
-          console.log(item, "item");
1073
+          
1044 1074
           item.dewValue = parseInt(item.dewValue);
1045 1075
           item.tempValue = parseInt(item.tempValue);
1046 1076
           item.wetValue = parseInt(item.wetValue);
@@ -1058,11 +1088,11 @@ export default {
1058 1088
         });
1059 1089
       });
1060 1090
       //取整
1061
-      console.log(this.rightDewValue, avgNum, "wwwwww");
1091
+     
1062 1092
       this.rightDewValue = parseInt(this.rightDewValue / avgNum);
1063 1093
       this.rightTempValue = parseInt(this.rightTempValue / avgNum);
1064 1094
       this.rightWetValue = parseInt(this.rightWetValue / avgNum);
1065
-      console.log(this.rightDewValue, "//////");
1095
+      
1066 1096
     },
1067 1097
 
1068 1098
     //热区
@@ -1212,11 +1242,13 @@ export default {
1212 1242
             this.deviceLists = res.data.records;
1213 1243
             this.form.cfValue = res.data.records[0].labelCode;
1214 1244
             this.cfCode=res.data.records[0].labelCode;
1215
-            console.log(this.cfCode,"初始化仓房code")
1245
+           
1216 1246
              //点位列表初始化
1217 1247
            this.getPointList();
1218
-           this.$refs.lsyjCharts.getHisWarning()
1219
-           console.log("到这儿了。。。")
1248
+           this.$refs.lsyjCharts.getHisWarning(this.cfCode)
1249
+           this.$refs.warnInfo.getWarnInfo(this.cfCode)
1250
+           this.$refs.tempWetChange.getTempWet(this.cfCode)
1251
+         
1220 1252
           }
1221 1253
         }
1222 1254
       })

+ 3 - 8
src/views/system/visualized/lsyj/index.vue

@@ -16,12 +16,7 @@
16 16
 import * as echarts from "echarts";
17 17
 import api from "@/api";
18 18
 export default {
19
-  props:{
20
-    cfCode:{
21
-      type:String,
22
-      required:true
23
-    }
24
-  },
19
+
25 20
     data(){
26 21
         return{
27 22
          lsyjData:[],
@@ -31,9 +26,9 @@ export default {
31 26
     },
32 27
     methods:{
33 28
        //历史月趋势
34
-    getHisWarning() {
29
+    getHisWarning(code) {
35 30
       let params = {
36
-        labelCode:this.cfCode,
31
+        labelCode:code,
37 32
   
38 33
         orgCode: localStorage.getItem("orgCode"),
39 34
 

+ 4 - 8
src/views/system/visualized/wsdbh/index.vue

@@ -58,10 +58,10 @@ export default {
58 58
         }
59 59
     },
60 60
     methods:{
61
-         //历史月趋势
62
-    getHisWarning() {
61
+         //温湿度变换趋势
62
+    getTempWet(code) {
63 63
       let params = {
64
-        labelCode: "307038864601222",
64
+        labelCode: code,
65 65
         orgCode: localStorage.getItem("orgCode"),
66 66
 
67 67
         round: 7,
@@ -180,11 +180,7 @@ export default {
180 180
     },
181 181
     },
182 182
     created(){
183
-        this.$nextTick(() => {
184
-     this.getHisWarning()
185
-
186
-
187
-    });
183
+    
188 184
     }
189 185
 }
190 186
 

+ 5 - 10
src/views/system/visualized/yjxx/index.vue

@@ -56,12 +56,7 @@ export default {
56 56
     data(){
57 57
         return{
58 58
           tableData:[
59
-            {
60
-              temp:30,
61
-              shidu:36,
62
-              jcsj:"2021-10-25"
63
-
64
-            }
59
+            
65 60
           ]
66 61
         }
67 62
     },
@@ -80,10 +75,10 @@ export default {
80 75
     },
81 76
   },
82 77
     methods:{
83
-       //历史月趋势
84
-    getWarnInfo() {
78
+       //预警信息
79
+    getWarnInfo(code) {
85 80
       let params = {
86
-        labelCode: "307038864601222",
81
+        labelCode: code,
87 82
         orgCode: localStorage.getItem("orgCode"),
88 83
 
89 84
         pageSize: 5,
@@ -100,7 +95,7 @@ export default {
100 95
     },
101 96
     created(){
102 97
     
103
-        this.getWarnInfo()
98
+       // this.getWarnInfo()
104 99
   
105 100
    
106 101