ws183
2025-04-28 b306d1106b915bb13fd7a02217ae9c65de2fd03d
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
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
package com.ld.igds.grain;
 
import com.alibaba.fastjson.JSONObject;
import com.ld.igds.constant.Constant;
import com.ld.igds.constant.DepotType;
import com.ld.igds.grain.dto.*;
import com.ld.igds.models.DepotConf;
import com.ld.igds.models.DicSysConf;
import com.ld.igds.util.NumberUtil;
 
import lombok.extern.slf4j.Slf4j;
 
import org.apache.commons.lang3.StringUtils;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
/**
 * 粮情数据各个类型的转换控制
 *
 * @author jiazx
 */
@Slf4j
public class GrainDataBuilder {
 
    /**
     * @param report
     * @param conf
     *            注意当前参数只是为了获取其全局配置参数,不考虑是否与当前粮情信息是否匹配
     * @return
     */
    public static GrainDataReport updateReport(GrainDataReport report,
            DicSysConf conf) {
        // 根据仓库类型不同进行不同调整
        if (DepotType.TYPE_02.getCode().equals(report.getDepotType())) {// 浅圆仓
 
        } else if (DepotType.TYPE_03.getCode().equals(report.getDepotType())) {
 
        } else if (DepotType.TYPE_04.getCode().equals(report.getDepotType())) {
 
        } else {
            buildLays(report, conf);
        }
 
        report.setPoints(null);
        return report;
    }
 
    /**
     * 根据单个粮情的数据信息,包括采集点和层信息
     *
     * @param result
     * @param dicSysConf
     *            全局系统参数,为空表示不优化
     * @param depotConf
     *            粮情配置参数,不能为空需要根据当前仓库的类型做判断
     */
    public static void updateGrainData(GrainData result, DicSysConf dicSysConf, DepotConf depotConf) {
 
        if (null == depotConf)
            return;
 
        List<GrainPoint> listPoints = new ArrayList<>();
        List<GrainLay> listLays = new ArrayList<>();// 层数据
        List<GrainRow> listRows = new ArrayList<>();// 行数据
 
        // 根据仓库类型不同进行不同调整
        if (DepotType.TYPE_02.getCode().equals(depotConf.getDepotType())) {// 浅圆仓
            result = buildLLaysAndRows2(listPoints, listLays, listRows, result, dicSysConf, depotConf);
 
        } else if (DepotType.TYPE_03.getCode().equals(depotConf.getDepotType())) {
 
            result = buildLLaysAndRows3(listPoints, listLays, listRows, result,
                    dicSysConf, depotConf);
 
        } else if (DepotType.TYPE_04.getCode().equals(depotConf.getDepotType())) {
            result = buildLLaysAndRows2(listPoints, listLays, listRows, result,
                    dicSysConf, depotConf);
 
        } else {
            result = buildLLaysAndRows1(listPoints, listLays, listRows, result,
                    dicSysConf, depotConf);
        }
 
        result.setSysDate(new Date());
        result.setListLays(listLays);
        result.setListRows(listRows);
        result.setListPoints(listPoints);
 
        log.debug("---------{}", JSONObject.toJSONString(result));
    }
 
    /**
     * 油筒仓解析,更新展示效果数据,解析方式同普通筒仓信息
     *
     * @param listPoints
     * @param listLays
     * @param listRows
     * @param result
     * @param dicSysConf
     * @param depotConf
     * @return
     */
    private static GrainData buildLLaysAndRows3(List<GrainPoint> listPoints,
            List<GrainLay> listLays, List<GrainRow> listRows, GrainData result,
            DicSysConf dicSysConf, DepotConf depotConf) {
        if (StringUtils.isEmpty(result.getOilHeight())) {
            result.setOilHeight("0.0-0.0");
            log.warn("油桶仓={} 解析过程中没有获取到油面高度信息,默认显示为0", depotConf.getDepotName());
        } else {
            if (result.getOilHeight().indexOf("-") == -1) {
                result.setOilHeight(result.getOilHeight() + "-"
                        + result.getOilHeight());
                log.warn("油桶仓={} 解析中没有获取建筑物的高度信息,默认建筑物高度等于液位高度",
                        depotConf.getDepotName());
            }
        }
 
        return buildLLaysAndRows2(listPoints, listLays, listRows, result,
                dicSysConf, depotConf);
    }
 
    /**
     * 圆筒仓 更新展示效果数据
     *
     * @param listPoints
     * @param listLays
     * @param listRows
     * @param result
     * @param dicSysConf
     * @param depotConf
     * @return
     */
    private static GrainData buildLLaysAndRows2(List<GrainPoint> listPoints,
            List<GrainLay> listLays, List<GrainRow> listRows, GrainData result,
            DicSysConf dicSysConf, DepotConf depotConf) {
 
        String points = result.getPoints();
        String cableRule = result.getCable();
        String cableCir = result.getCableCir();
 
        if (StringUtils.isEmpty(points)) {
            return result;
        }
 
        // 获取布线规则
        if (StringUtils.isEmpty(cableRule) || StringUtils.isEmpty(cableCir)) {
            return result;
        }
        // 每一圈列数
        String[] cableRuleAtt = result.getCable().split("-");
        // 每一圈层数
        String[] cableCirAtt = result.getCableCir().split("-");
 
        if (cableRuleAtt.length != cableCirAtt.length) {
            log.error("当前仓库:{},布线规则不正确,无法解析粮情信息……", depotConf.getDepotName());
            return result;
        }
 
        // 获取最大的层配置--默认每一圈都一样
        int layMax = Integer.valueOf(cableCirAtt[0]);
         for (int i = 0; i < cableCirAtt.length; i++) {
             if (Integer.valueOf(cableCirAtt[i]) >= layMax) layMax = Integer.valueOf(cableCirAtt[i]);
         }
 
        // 根据层更新层列表信息
        updateListLaysCir(listLays, cableRuleAtt, cableCirAtt, layMax);
 
        String[] attr = points.split(",");
 
        GrainPoint point;
        Double tempT;
        GrainLay lay;
        int x = 0, y = 0, z = 1, fz = 0;// x=所在圈,从0开始;y代表电缆根号从0开始,z=代表所在层从1开始
        List<Integer> listErrorTag = new ArrayList<>();// 故障或者错误的点
        List<Integer> listHighTag = new ArrayList<>();// 高温点
 
        int layNum = layMax;// 当前圈的层数
        int rowNum = 1;// 当前圈的根数
        int index = 0;// 当前温度点的位置
        int startRow = 0;//当前粮情电缆根号
        for (int i = 0; i < cableRuleAtt.length; i++) {
            x = i;
            rowNum = Integer.valueOf(cableRuleAtt[i]);// 根数
            for (int k = 0; k < rowNum; k++) {
                y = k;
                for (int j = 0; j < layNum; j++) {
                    z = j;
                    fz = j + 1;
                    tempT = Double.valueOf(attr[index]);
                    index++;
 
                    point = new GrainPoint(tempT, x, startRow, z, fz);
 
                    // 统计每层数据 --初始化数据
                    lay = listLays.get(z);
                    point.setTemp(tempT);
                    listPoints.add(point);
 
                    if (tempT <= Constant.ERROR_TEMP) {
                        if(tempT != Constant.ADD_TEMP){
                            lay.setSumNum(lay.getSumNum() - 1);
                        }
                    } else {
                        //判断是否高温优化
                        if (null != dicSysConf && null != depotConf && null != depotConf.getTempMax()
                                && Constant.YN_Y.equals(dicSysConf.getGrainMaxAuto())) {
                            if (tempT > depotConf.getTempMax()) {
                                //记录高温点的位置
                                listHighTag.add(listPoints.size() -1);
                            }else {
                                lay.setSumTemp(lay.getSumTemp() + tempT);
                                // 层最高最低
                                if (tempT > lay.getTempMax()) {
                                    lay.setTempMax(tempT);
                                }
                                if (tempT < lay.getTempMin()) {
                                    lay.setTempMin(tempT);
                                }
                            }
                        }else {
                            lay.setSumTemp(lay.getSumTemp() + tempT);
                            // 层最高最低
                            if (tempT > lay.getTempMax()) {
                                lay.setTempMax(tempT);
                            }
                            if (tempT < lay.getTempMin()) {
                                lay.setTempMin(tempT);
                            }
                        }
                    }
                    if (tempT == Constant.ERROR_TEMP || tempT == Constant.FAULT_TEMP) {
                        listErrorTag.add(listPoints.size()-1);
                    }
                }
 
                startRow ++;
            }
 
        }
 
        Double maxTemp = -50.0; //比较最高温
        // 调整层信息
        for (GrainLay detail : listLays) {
            if (0 != detail.getSumNum()) {
                detail.setTempAve(detail.getSumTemp() / detail.getSumNum());
                detail.setTempAve(NumberUtil.keepPrecision(detail.getTempAve(),
                        1));
            }
 
            if (0 != detail.getSumInNum()) {
                detail.setTempAveIn(detail.getSumInTemp()
                        / detail.getSumInNum());
                detail.setTempAveIn(NumberUtil.keepPrecision(
                        detail.getTempAveIn(), 1));
            }
 
            if (0 != detail.getSumOutNum()) {
                detail.setTempAveOut(detail.getSumOutTemp()
                        / detail.getSumOutNum());
                detail.setTempAveOut(NumberUtil.keepPrecision(
                        detail.getTempAveOut(), 1));
            }
            //过滤掉比较的最大最小的值50和-50
            if(detail.getTempMax() == -50){
                detail.setTempMax(0.0);
            }
            if(detail.getTempMin() == 50){
                detail.setTempMin(0.0);
            }
            if (listHighTag.size() > 0) {
                if(detail.getTempMax() > maxTemp){
                    maxTemp = detail.getTempMax();
                }
            }
        }
        //高温点替换为层平均值
        if (null != dicSysConf && null != depotConf && null != depotConf.getTempMax()
                && Constant.YN_Y.equals(dicSysConf.getGrainMaxAuto())) {
            if (listHighTag.size() > 0) {
                for (Integer integer : listHighTag) {
                    point = listPoints.get(integer);
                    // 获取当前层的信息
                    lay = listLays.get(point.getZ());
                    point.setTemp(lay.getTempAve());
                    listPoints.set(integer, point);
                }
                //设置最高温
                result.setTempMax(maxTemp);
            }
        }
        // 最后根据全局参数判断是否需要调整异常点数据进行调整
        if (null != dicSysConf
                && Constant.YN_Y.equals(dicSysConf.getGrainErrorAuto())) {
            if (listErrorTag.size() > 0) {
                for (Integer integer : listErrorTag) {
                    point = listPoints.get(integer);
                    // 获取当前层的信息
                    lay = listLays.get(point.getZ());
                    point.setTemp(lay.getTempAve());
 
                    listPoints.set(integer, point);
                }
            }
        }
        result.setListPoints(listPoints);
        result.setListLays(listLays);
 
        return result;
    }
 
    /**
     * 平方仓 跟新层数据和行数据
     *
     * @param listPoints
     * @param listLays
     * @param dicSysConf
     * @param depotConf
     */
    public static GrainData buildLLaysAndRows1(List<GrainPoint> listPoints,
            List<GrainLay> listLays, List<GrainRow> listRows, GrainData result,
            DicSysConf dicSysConf, DepotConf depotConf) {
 
        String points = result.getPoints();
        String cable = result.getCable();
        // 获取布线规则
        if (StringUtils.isEmpty(cable)) {
            return result;
        }
        if (StringUtils.isEmpty(points)) {
            return result;
        }
 
        String[] attr = cable.split("-");
        int cableZ = Integer.valueOf(attr[0]);
        int cableY = Integer.valueOf(attr[1]);
        int cableX = Integer.valueOf(attr[2]);
 
        // 根据层更新层列表信息
        updateListLays(listLays, cableX, cableY, cableZ);
 
        // 更新行数据的列表
        updateListRows(listRows, cableX, cableY, cableZ);
 
        attr = points.split(",");
 
        GrainPoint point;
        Double tempT;
        GrainLay lay;
        GrainRow row;
        List<Integer> listErrorTag = new ArrayList<>();// 故障或者错误的点
        Double sumAll = 0.0;
 
        Double sumAllTemp = 0.0;
 
        int sumAllNum = 0;
        int tempT2;
        int x = 0, y = 0, z = 0, fz = 0;
        for (int i = 0; i < attr.length; i++) {
            z = i % cableZ;
            fz = z + 1;
            x = i / (cableZ * cableY);
            y = x * (cableZ * cableY);
            y = (i - y) / cableZ;
 
            // 倒转X轴
            x = cableX - 1 - x;
 
            tempT = Double.valueOf(attr[i]);
            point = new GrainPoint(tempT, x, y, z, fz);
 
            // 统计每层数据 --初始化数据
            lay = listLays.get(z);
 
            // 开始封装行数据信息
            row = listRows.get(y);
 
            if (tempT <= Constant.ERROR_TEMP) {
                listErrorTag.add(i);
 
                lay.setSumNum(lay.getSumNum() - 1);
 
                row.setSumNum(row.getSumNum() - 1);
 
                if (x == (cableX - 1) || y == (cableY - 1) || x == 0 || y == 0) {
                    lay.setSumOutNum(lay.getSumOutNum() - 1);
                } else {
                    lay.setSumInNum(lay.getSumInNum() - 1);
                }
            } else {
                sumAllTemp += tempT;
                // 高温优化的启用要求1-处理单个高温点
                if (null != dicSysConf && null != depotConf
                        && null != depotConf.getTempMax()
                        && Constant.YN_Y.equals(dicSysConf.getGrainMaxAuto())) {
 
                    if (tempT > depotConf.getTempMax()) {
                        tempT2 = (int) (tempT - depotConf.getTempMax()) + 1;
                        tempT = NumberUtil.keepPrecision(tempT - tempT2, 1);
                        result.setRemark("粮温检测正常");
                        log.debug("--原值={},--差值={},--结果={}", point.getTemp(),
                                tempT2, tempT);
                    }
                    if (result.getTempMax() > depotConf.getTempMax()) {
                        tempT2 = (int) (result.getTempMax() - depotConf
                                .getTempMax()) + 1;
                        result.setTempMax(NumberUtil.keepPrecision(
                                result.getTempMax() - tempT2, 1));
                    }
                    if (tempT > result.getTempMax()) {
                        result.setTempMax(tempT);
                    }
                }
 
                // 层行列补充
                lay.setSumTemp(lay.getSumTemp() + tempT);
                lay.setSumTemp(NumberUtil.keepPrecision(lay.getSumTemp(),1));
 
                row.setSumTemp(row.getSumTemp() + tempT);
                row.setSumTemp(NumberUtil.keepPrecision(row.getSumTemp(),1));
 
                if (x == (cableX - 1) || y == (cableY - 1) || x == 0 || y == 0) {
                    lay.setSumOutTemp(lay.getSumOutTemp() + tempT);
                } else {
                    lay.setSumInTemp(lay.getSumInTemp() + tempT);
                }
 
                // 层最高最低
                if (tempT > lay.getTempMax()) {
                    lay.setTempMax(tempT);
                }
                if (tempT < lay.getTempMin()) {
                    lay.setTempMin(tempT);
                }
 
                // 行最高最低
                if (tempT > row.getTempMax()) {
                    row.setTempMax(tempT);
                }
                if (tempT < row.getTempMin()) {
                    row.setTempMin(tempT);
                }
 
                // log.info("----温度点={}",tempT);
                sumAll += tempT;
                sumAllNum = sumAllNum + 1;
                point.setTemp(tempT);
            }
            point.setTemp(NumberUtil.keepPrecision(point.getTemp(), 1));
            listPoints.add(point);
        }
 
        // 调整层信息
        for (GrainLay detail : listLays) {
            if (0 != detail.getSumNum()) {
                detail.setTempAve(detail.getSumTemp() / detail.getSumNum());
                detail.setTempAve(NumberUtil.keepPrecision(detail.getTempAve(),
                        1));
            }
 
            if (0 != detail.getSumInNum()) {
                detail.setTempAveIn(detail.getSumInTemp()
                        / detail.getSumInNum());
                detail.setTempAveIn(NumberUtil.keepPrecision(
                        detail.getTempAveIn(), 1));
            }
 
            if (0 != detail.getSumOutNum()) {
                detail.setTempAveOut(detail.getSumOutTemp()
                        / detail.getSumOutNum());
                detail.setTempAveOut(NumberUtil.keepPrecision(
                        detail.getTempAveOut(), 1));
            }
            //过滤掉比较的最大最小的值50和-50
            if(detail.getTempMax() == -50){
                detail.setTempMax(0.0);
            }
            if(detail.getTempMin() == 50){
                detail.setTempMin(0.0);
            }
        }
 
        // 调整行信息
        for (GrainRow detail : listRows) {
            if (0 != detail.getSumNum()) {
                detail.setTempAve(detail.getSumTemp() / detail.getSumNum());
                detail.setTempAve(NumberUtil.keepPrecision(detail.getTempAve(),
                        1));
            }
            //过滤掉比较的最大最小的值50和-50
            if(detail.getTempMax() == -50){
                detail.setTempMax(0.0);
            }
            if(detail.getTempMin() == 50){
                detail.setTempMin(0.0);
            }
        }
 
        // 最后根据全局参数判断是否需要调整异常点数据进行调整
        if (null != dicSysConf
                && Constant.YN_Y.equals(dicSysConf.getGrainErrorAuto())) {
            if (listErrorTag.size() > 0) {
                for (Integer integer : listErrorTag) {
                    point = listPoints.get(integer);
                    // 获取当前层的信息
                    lay = listLays.get(point.getZ());
                    point.setTemp(lay.getTempAve());
 
                    listPoints.set(integer, point);
                }
            }
        }
 
        // 高温优化的启用要求2-重新计算整体平均值
        if (null != dicSysConf && null != depotConf
                && null != depotConf.getTempMax()
                && Constant.YN_Y.equals(dicSysConf.getGrainMaxAuto())) {
            log.debug("---原平均={},后总温={},--后总个数={},后平均={},原总温={}",
                    result.getTempAve(), sumAll, sumAllNum, sumAll / sumAllNum,
                    sumAllTemp);
            result.setTempAve(NumberUtil.keepPrecision((sumAll / sumAllNum), 1));
        }
        return result;
    }
 
    private static void buildLays(GrainDataReport report, DicSysConf dicSysConf) {
        String points = report.getPoints();
        String cable = report.getCable();
        // 获取布线规则
        if (StringUtils.isEmpty(cable)) {
            return;
        }
        if (StringUtils.isEmpty(points)) {
            return;
        }
 
        String[] attr = cable.split("-");
        int cableZ = Integer.valueOf(attr[0]);
        int cableY = Integer.valueOf(attr[1]);
        int cableX = Integer.valueOf(attr[2]);
 
        List<GrainPoint> listPoints = new ArrayList<GrainPoint>();
        List<GrainLay> listLays = initDetail(cableX, cableY, cableZ);
 
        attr = points.split(",");
 
        GrainPoint point;
        Double tempT;
        GrainLay lay;
        List<Integer> listErrorTag = new ArrayList<>();// 故障或者错误的点
        Double sumAll = 0.0;
 
        Double sumAllTemp = 0.0;
 
        int sumAllNum = 0;
        int x = 0, y = 0, z = 0, fz = 0;
        for (int i = 0; i < attr.length; i++) {
            z = i % cableZ;
            fz = z + 1;
            x = i / (cableZ * cableY);
            y = x * (cableZ * cableY);
            y = (i - y) / cableZ;
 
            // 倒转X轴
            x = cableX - 1 - x;
 
            tempT = Double.valueOf(attr[i]);
            point = new GrainPoint(tempT, x, y, z, fz);
 
            // 统计每层数据 --初始化数据
            lay = listLays.get(z);
 
            if (tempT <= Constant.ERROR_TEMP) {
                listErrorTag.add(i);
 
                lay.setSumNum(lay.getSumNum() - 1);
 
                if (x == (cableX - 1) || y == (cableY - 1) || x == 0 || y == 0) {
                    lay.setSumOutNum(lay.getSumOutNum() - 1);
                } else {
                    lay.setSumInNum(lay.getSumInNum() - 1);
                }
            } else {
                sumAllTemp += tempT;
 
                if (tempT > report.getTempMax()) {
                    report.setTempMax(tempT);
                }
 
                // 层行列补充
                lay.setSumTemp(lay.getSumTemp() + tempT);
 
                if (x == (cableX - 1) || y == (cableY - 1) || x == 0 || y == 0) {
                    lay.setSumOutTemp(lay.getSumOutTemp() + tempT);
                } else {
                    lay.setSumInTemp(lay.getSumInTemp() + tempT);
                }
 
                // 层最高最低
                if (tempT > lay.getTempMax()) {
                    lay.setTempMax(tempT);
                }
                if (tempT < lay.getTempMin()) {
                    lay.setTempMin(tempT);
                }
 
                // log.info("----温度点={}",tempT);
                sumAll += tempT;
                sumAllNum = sumAllNum + 1;
                point.setTemp(tempT);
            }
 
            listPoints.add(point);
        }
 
        // 调整层信息
        for (GrainLay detail : listLays) {
            if (0 != detail.getSumNum()) {
                detail.setTempAve(detail.getSumTemp() / detail.getSumNum());
                detail.setTempAve(NumberUtil.keepPrecision(detail.getTempAve(),
                        1));
            }
 
            if (0 != detail.getSumInNum()) {
                detail.setTempAveIn(detail.getSumInTemp()
                        / detail.getSumInNum());
                detail.setTempAveIn(NumberUtil.keepPrecision(
                        detail.getTempAveIn(), 1));
            }
 
            if (0 != detail.getSumOutNum()) {
                detail.setTempAveOut(detail.getSumOutTemp()
                        / detail.getSumOutNum());
                detail.setTempAveOut(NumberUtil.keepPrecision(
                        detail.getTempAveOut(), 1));
            }
 
            // 将层数据转换为行数据
            updateReportLayInfo(report, detail);
        }
    }
    
    /**
     * 根据粮情温度,判断是否警告值,然后转换为页面需要渲染的值,主要备用和故障的值的调整
     * @param temp
     * @return
     */
    public static String renderTempValue(Double temp) {
        
        
        if(temp > 45) return "故障";
        
        if(temp == Constant.ERROR_TEMP) return "备用";
        if(temp == Constant.FAULT_TEMP) return "故障";
        if(temp == Constant.ADD_TEMP) return "--";
 
        return temp+"";
    }
 
    private static void updateReportLayInfo(GrainDataReport report, GrainLay lay) {
 
        if (1 == lay.getFz()) {// 第一层
            report.setZ1(lay.getFz());
            report.setTempAve1(lay.getTempAve() + "");
            report.setTempMax1(lay.getTempMax() + "");
            report.setTempMin1(lay.getTempMin() + "");
        }
        if (2 == lay.getFz()) {// 第一层
            report.setZ2(lay.getFz());
            report.setTempAve2(lay.getTempAve() + "");
            report.setTempMax2(lay.getTempMax() + "");
            report.setTempMin2(lay.getTempMin() + "");
        }
 
        if (3 == lay.getFz()) {// 第一层
            report.setZ3(lay.getFz());
            report.setTempAve3(lay.getTempAve() + "");
            report.setTempMax3(lay.getTempMax() + "");
            report.setTempMin3(lay.getTempMin() + "");
        }
 
        if (4 == lay.getFz()) {// 第一层
            report.setZ4(lay.getFz());
            report.setTempAve4(lay.getTempAve() + "");
            report.setTempMax4(lay.getTempMax() + "");
            report.setTempMin4(lay.getTempMin() + "");
        }
 
        if (5 == lay.getFz()) {// 第一层
            report.setZ5(lay.getFz());
            report.setTempAve5(lay.getTempAve() + "");
            report.setTempMax5(lay.getTempMax() + "");
            report.setTempMin5(lay.getTempMin() + "");
        }
        if (6 == lay.getFz()) {// 第一层
            report.setZ6(lay.getFz());
            report.setTempAve6(lay.getTempAve() + "");
            report.setTempMax6(lay.getTempMax() + "");
            report.setTempMin6(lay.getTempMin() + "");
        }
        if (7 == lay.getFz()) {// 第一层
            report.setZ7(lay.getFz());
            report.setTempAve7(lay.getTempAve() + "");
            report.setTempMax7(lay.getTempMax() + "");
            report.setTempMin7(lay.getTempMin() + "");
        }
        if (8 == lay.getFz()) {// 第一层
            report.setZ8(lay.getFz());
            report.setTempAve8(lay.getTempAve() + "");
            report.setTempMax8(lay.getTempMax() + "");
            report.setTempMin8(lay.getTempMin() + "");
        }
        if (9 == lay.getFz()) {// 第一层
            report.setZ9(lay.getFz());
            report.setTempAve9(lay.getTempAve() + "");
            report.setTempMax9(lay.getTempMax() + "");
            report.setTempMin9(lay.getTempMin() + "");
        }
        if (10 == lay.getFz()) {// 第一层
            report.setZ10(lay.getFz());
            report.setTempAve10(lay.getTempAve() + "");
            report.setTempMax10(lay.getTempMax() + "");
            report.setTempMin10(lay.getTempMin() + "");
        }
    }
 
    private static List<GrainLay> initDetail(int cableX, int cableY, int cableZ) {
        List<GrainLay> result = new ArrayList<>();
        GrainLay lay;
        for (int i = 1; i <= cableZ; i++) {
            lay = new GrainLay(i, i - 1);
            lay.setSumNum(cableY * cableX);
            lay.setSumInNum((cableY - 2) * (cableX - 2));
            lay.setSumOutNum(2 * cableY + 2 * cableX - 4);
            lay.setTempMin(50.0);
            lay.setTempMax(-50.0);
            result.add(lay);
        }
        return result;
    }
 
    private static void updateListLays(List<GrainLay> listLays, int cableX,
            int cableY, int cableZ) {// 层从1开始
        GrainLay lay;
        for (int i = 1; i <= cableZ; i++) {
            lay = new GrainLay(i, i - 1);
            lay.setSumNum(cableY * cableX);
            lay.setSumInNum((cableY - 2) * (cableX - 2));
            lay.setSumOutNum(2 * cableY + 2 * cableX - 4);
            lay.setTempMin(50.0);
            lay.setTempMax(-50.0);
            listLays.add(lay);
        }
    }
 
    private static void updateListRows(List<GrainRow> listRows, int cableX,
            int cableY, int cableZ) {// 从0开始
        GrainRow row;
        for (int i = 0; i < cableY; i++) {
            row = new GrainRow(i);
            row.setSumNum(cableZ * cableX);
            row.setTempMin(50.0);
            row.setTempMax(-50.0);
            listRows.add(row);
        }
    }
 
    /**
     * 圆筒仓--仓温度解析
     *
     * @param listLays
     * @param cableRuleAtt
     * @param cableCirAtt
     */
    private static void updateListLaysCir(List<GrainLay> listLays,
            String[] cableRuleAtt, String[] cableCirAtt, int layMax) {
        GrainLay lay;
        for (int i = 1; i <= layMax; i++) {
            lay = new GrainLay(i, i);
            int sumNum = 0;
            for (int j = 0; j < cableRuleAtt.length; j++) {
                if (Integer.valueOf(cableCirAtt[j]) >= i) {
                    sumNum += Integer.valueOf(cableRuleAtt[j]);
                }
            }
            lay.setSumNum(sumNum);
            lay.setSumInNum(1);
            lay.setSumOutNum(1);
            lay.setTempMin(50.0);
            lay.setTempMax(-50.0);
            listLays.add(lay);
        }
    }
 
 
}