aix
2024-08-17 39081183f7cc171aefc435f33b077d3ce41fd2ea
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
package cn.gistack.sm.sjztmd.word.vo;
 
import cn.gistack.sm.sjztmd.entity.*;
import cn.gistack.sm.sjztmd.word.enums.*;
import cn.gistack.sm.sjztmd.word.util.WordUtil;
import com.alibaba.nacos.common.utils.StringUtils;
import lombok.Data;
import org.checkerframework.checker.formatter.qual.UnknownFormat;
import org.springblade.core.tool.utils.StringUtil;
 
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
 
@Data
public class TbWordVO {
 
    //水库名称
    private String resName;
 
    //========================tb_att_res_base=======================
    //市
    private String cityName;
 
    //区
    private String countyName;
 
    //镇
    private String townName;
 
 
    //河流名称(tb_att_res_base)
    private String locRvName;
 
    //水库功能 前端写死的(三个及三个以上需要加等综合)
    private String resFuncText;
 
    //工程等别
    private String engGrad;
 
    //工程始建时间
    private String startTime;
 
    //下闸蓄水时间
    private String waterStorageTm;
 
    //========================tb_att_res_stag_char=======================
 
    //调节性能 前端写死
    private String adjustPropText;
 
    //水库坝址以上控制流域面积
    private String conArea;
 
    //流域多年平均降雨量
    private String moyearRainAvg;
 
    //多年平均年径流量
    private String moyearFlAvg;
 
    //设计洪水标准
    private String desFlSta;
 
    //校核洪水标准
    private String checFlSta;
 
    //总库容
    private String totalCap;
 
    //有就加,没有就不加
    //水文特征(兴利库容,调洪库容,死库容,校核洪水位、设计洪水位,正常蓄水位,死水位)
    private String hydrologicalCharacteristics;
 
    //挡水建筑物数量(例:主坝、{{副坝}}  或    主坝、{{副坝(2座)}} )
    private String buildingText;
 
 
    //======================tb_att_res_water_block====================
 
    //主坝信息 (主坝为粘土心墙坝,坝顶高程55.00m,最大坝高22m,坝长230m,坝顶宽5.5m)
    private String mainDamInfo;
 
    //副坝信息
    private String subDamInfo;
 
    //正常溢洪道信息
    private String norspiInfo;
 
    //泄洪洞信息
    private String rsbSpillwayInfo;
 
    //电站信息
    private String powerStationInfo;
 
    private String buildingInfo;
 
 
    //===================tb_att_res_water_delivery”===================
    // (输水建筑物)若有两个以上输水建筑物,则描述设计流量较大的,若只有一个输水建筑物则去掉“主要
 
    //输水道形式
    private String aqueductType;
 
    //断面尺寸(sectionWide X sectionHigh)
    private String section;
 
    //进口底槛高程
    private String thresholdElevation;
 
    //设计流量
    private String designFlow;
 
    //===================tb_att_res_eng_bene”===================
    //保护城市
    private String protectCity;
 
    //保护人口(万),耕地(亩)
    private String protectPersonLand;
 
    //铁路、公路、管线、企业几个依次罗列,超过三个列出第二个后为“XX等”,后面不需罗列
    //保护铁路
    private String protectThings;
 
    //经济效益
    private String economicBenefit;
 
 
    //==========================tb_att_res_safety_monitor===================
 
    private String safetyMonitorText;
 
 
    //========================tb_att_res_mgr_sys_b======================
    //管理单位名称
    private String mUnitName;
 
    //管理单位性质
    private String mUnitNature;
 
    //管理单位职工人数
    private String mUnitPersonNumber;
 
    //============================att_res_mgr_sys_b===============
    //主管部门名称
    private String cUnitName;
 
    //==========================att_res_manage_person================
    //主管部门责任人(2)
    //主管部门责任人信息
    private String competentDepartmentInfo;
 
    //行政主管信息(1)
    private String administrativeInfo;
 
    //行政主管单位
    private String administrativeUnit;
 
 
    public TbWordVO(TbAttResBase tbAttResBase, TbAttResStagChar tbAttResStagChar,
                    List<TbAttResWaterBlock> tbAttResWaterBlockList, Map<String, Object> resRsbNorsipiVerspiMionitorDetailByGuid, List<TbAttResPowerStation> tbAttResPowerStationList,
                    List<TbAttResWaterDelivery> tbAttResWaterDeliveryList, TbAttResEngBene tbAttResEngBene,
                    TbAttResSafetyMonitor tbAttResSafetyMonitor, TbAttResMgrSysB tbAttResMgrSysB,
                    List<AttResManagePerson> attResManagePeople) {
 
        //取设计流量大的进行描述
//        List<TbAttResWaterDelivery> sortList =
//            tbAttResWaterDeliveryList.stream()
//                .sorted((a, b) -> {
//                    Optional<Double> flowA = Optional.ofNullable(a.getDesignFlow());
//                    Optional<Double> flowB = Optional.ofNullable(b.getDesignFlow());
//                    return flowA.isPresent() && flowB.isPresent() ? flowA.get().compareTo(flowB.get()) : (flowA.isPresent() ? 1 : (flowB.isPresent() ? -1 : 0));
//                })
//                .collect(Collectors.toList());
 
        List<TbAttResWaterDelivery> sortList = tbAttResWaterDeliveryList.stream()
            .sorted(Comparator.nullsLast(
                Comparator.comparingDouble(a -> a.getDesignFlow() == null ? Double.POSITIVE_INFINITY : a.getDesignFlow())
            ))
            .collect(Collectors.toList());
 
        formatTbAttResBase(tbAttResBase);
        formatTbAttResStagChar(tbAttResStagChar);
 
        formatMultiInfo(tbAttResWaterBlockList, sortList, resRsbNorsipiVerspiMionitorDetailByGuid, tbAttResPowerStationList);
 
 
        formatTbAttResWaterDelivery(sortList);
        formatTbAttResEngBene(tbAttResEngBene);
        formatTbAttResSafetyMonitor(tbAttResSafetyMonitor);
        formatTbAttResMgrSysB(tbAttResMgrSysB);
        formatAttResManagePerson(attResManagePeople);
 
    }
 
    private void formatMultiInfo(List<TbAttResWaterBlock> tbAttResWaterBlockList, List<TbAttResWaterDelivery> tbAttResWaterDeliveryList, Map<String, Object> resRsbNorsipiVerspiMionitorDetailByGuid, List<TbAttResPowerStation> tbAttResPowerStationList) {
 
        //正常溢洪道
        List<TbAttResRsbNorspi> tbAttResRsbNorspiList = (List<TbAttResRsbNorspi>) resRsbNorsipiVerspiMionitorDetailByGuid.get("tbAttResRsbNorspiList");
        //非常溢洪道
        List<TbAttResRsbVerspi> tbAttResRsbVerspiList = (List<TbAttResRsbVerspi>) resRsbNorsipiVerspiMionitorDetailByGuid.get("tbAttResRsbVerspiList");
        //泄洪洞
        List<TbAttResRsbSpillway> tbAttResRsbSpillwayList = (List<TbAttResRsbSpillway>) resRsbNorsipiVerspiMionitorDetailByGuid.get("tbAttResRsbSpillwayList");
 
 
        List<String> buildingList = new ArrayList<>();
        this.subDamInfo = "";
        //大坝数量
        int damCount = tbAttResWaterBlockList.size();
        if (damCount > 1) {
            buildingList.add(StringUtil.format("副坝({}座)", damCount - 1));
 
            //根据名字判断主坝
            List<TbAttResWaterBlock> mainDamList = tbAttResWaterBlockList.stream().filter(tbAttResWaterBlock -> tbAttResWaterBlock.getName().indexOf("主坝") > -1).collect(Collectors.toList());
 
            if (mainDamList.size() > 0) {
                TbAttResWaterBlock mainDam = mainDamList.get(0);
                this.mainDamInfo = GenerateDamInfo("主坝", mainDam);
            }
 
            TbAttResWaterBlock subDam = tbAttResWaterBlockList.get(1);
            String subDamName = "";
            if (subDam.getName().equals("")) {
                subDamName = "副坝";
            } else {
                subDamName = subDam.getName();
            }
 
            this.subDamInfo = GenerateDamInfo(subDamName, subDam);
        }else if (damCount == 1){
            TbAttResWaterBlock mainDam = tbAttResWaterBlockList.get(0);
            //第一个就是主坝
            this.mainDamInfo = GenerateDamInfo("主坝", mainDam);
        }
 
        //正常溢洪道
        if (tbAttResRsbNorspiList.size()>0&&tbAttResRsbNorspiList.get(0).getNum()  != null && tbAttResRsbNorspiList.get(0).getNum() > 0) {
            buildingList.add("正常溢洪道");
            this.norspiInfo = "";
            this.norspiInfo = GenerateNorspiInfo(tbAttResRsbNorspiList.get(0));
        }
 
        //泄洪洞
        if (tbAttResRsbSpillwayList.size()>0&&tbAttResRsbSpillwayList.get(0).getNum()  != null && tbAttResRsbSpillwayList.get(0).getNum() > 0) {
            buildingList.add("泄洪洞");
            this.rsbSpillwayInfo = "";
            this.rsbSpillwayInfo = GenerateRsbSpillwayInfo(tbAttResRsbSpillwayList.get(0));
        }
 
        //输水建筑物
        if (tbAttResWaterDeliveryList.size()>0&&tbAttResWaterDeliveryList.get(0).getNum()  != null &&  tbAttResWaterDeliveryList.get(0).getNum() > 0) {
//            tbAttResWaterDeliveryList.forEach(tbAttResWaterDelivery -> {
////                buildingList.add( convertType(tbAttResWaterDelivery.getAqueductType(),"AqueductTypeEnum"));
//                buildingList.add("输水建筑物");
//            });
            if (tbAttResWaterDeliveryList.size() > 1) {
                buildingList.add(StringUtil.format("输水建筑物({}座)",tbAttResWaterDeliveryList.size()));
            } else {
                buildingList.add("输水建筑物");
            }
        }
 
        //电站
        if (tbAttResPowerStationList.size()>0&&tbAttResPowerStationList.get(0).getNum()  != null && tbAttResPowerStationList.get(0).getNum() > 0) {
            buildingList.add("水电站");
            this.powerStationInfo = "";
            this.powerStationInfo = GenerateStationPowerInfo(tbAttResPowerStationList.get(0));
        }
 
        //非常溢洪道
        if (tbAttResRsbVerspiList.size()>0&&tbAttResRsbVerspiList.get(0).getNum()  != null && tbAttResRsbVerspiList.get(0).getNum() > 0) {
            buildingList.add("非常溢洪道");
        }
 
        //挡水建筑物泄洪建筑物正常溢洪道
        this.buildingText = String.join("、", buildingList);
 
 
        if (StringUtil.isNotBlank(this.norspiInfo)) {
            this.buildingInfo = this.subDamInfo + this.norspiInfo;
        } else {
            this.buildingInfo = this.subDamInfo + this.rsbSpillwayInfo;
        }
    }
 
    private String GenerateStationPowerInfo(TbAttResPowerStation stationPower) {
        String text = "";
        /**
         * 水电站(若有)为坝后XX式(厂房布置型式),装机容量XXkW,年均利用小时XXh
         */
 
        String type = PlantLayoutTypeEnum.find(stationPower.getPlantLayoutType()).getLabel();
        String capacity = String.valueOf(stationPower.getInstalledCapacity());
        String hour = String.valueOf(stationPower.getYearAvgHour());
 
        text = StringUtil.format("水电站为{},装机容量{}kW,年均利用小时{}h。",
            type,WordUtil.removeTrailingZero(capacity),WordUtil.removeTrailingZero(hour));
 
        return text;
    }
 
    /**
     * 生成正常溢洪道描述
     *
     * @param norspi 正常溢洪道对象
     * @return
     */
    private String GenerateNorspiInfo(TbAttResRsbNorspi norspi) {
        if(null == norspi || StringUtil.isBlank(norspi.getName())) {
            return "";
        }
        /**
         * 溢洪道(第一座泄水建筑物为溢洪道)为正槽式溢洪道(溢洪道型式),
         * 有闸控制(溢洪道根据是否有闸控制确定,填有闸控制、无闸控制),堰顶高程XXm,堰顶净宽XXm,
         * 设X孔(溢洪道闸门数量,有闸控制写,无闸不写,1孔“设X孔”改为“单孔”),最大泄洪量XXm³/s。
         */
 
        String typeName = SpillwayTypeEnum.find(norspi.getSpillwayType()).getLabel();
//        String typeName = norspi.getName();
        if (StringUtil.isBlank(typeName) && norspi.getSpillwayType().indexOf(",") > -1) {
            String [] tmpSt = norspi.getSpillwayType().split(",");
            if (tmpSt[0].equals("9")) {
                typeName = tmpSt[1];
            }
        }
 
        String gateText = "";
        String holeText = "";
        if (norspi.getIsGate().equals("是")) {
            gateText = "有闸控制";
            String hole = norspi.getGateNum() == 1 ? "单" : String.valueOf(norspi.getGateNum());
            holeText = StringUtil.format(",{}孔", hole);
        } else {
            gateText = "无闸控制";
        }
 
        //堰顶高程
        String weirTopElevation = isNull(norspi.getWeirTopElevation());
 
        //堰顶净宽
        String weirTopWidth = isNull(norspi.getWeirTopWidth());
 
        String disCharge = isNull(norspi.getCheckingFloodDischarge());
 
        String text = StringUtil.format("溢洪道为{},{},堰顶高程{}m,堰顶净宽{}m{},最大泄洪量{}m³/s。",
            typeName, gateText, String.format("%.2f",norspi.getWeirTopElevation()), WordUtil.removeTrailingZero(weirTopWidth), holeText, WordUtil.removeTrailingZero(disCharge));
 
        return text;
    }
 
    /**
     * 生成泄洪洞描述
     *
     * @param tbAttResRsbSpillway
     * @return
     */
    private String GenerateRsbSpillwayInfo(TbAttResRsbSpillway tbAttResRsbSpillway) {
 
        /**
         * 泄洪洞(有溢洪道则不需介绍泄洪洞,无溢洪道则介绍泄洪洞)为XX(泄洪洞型式,若为“其他”,同上生成其他具体内容)泄洪洞,
         * XX(泄洪洞个数,1个为“单”孔)孔,洞长XXm,进口底槛高程XXm,最大泄量(最大泄洪流量)XXm³/s。
         */
 
        //需要对其他类型进行判断;
        String type = tbAttResRsbSpillway==null?"":tbAttResRsbSpillway.getSpillwayType();
        String holeNum = tbAttResRsbSpillway.getSectionNum()==null?"":tbAttResRsbSpillway.getSectionNum() == 1 ? "单" : String.valueOf(tbAttResRsbSpillway.getSectionNum());
        String coveLength = tbAttResRsbSpillway==null?"":isNull(tbAttResRsbSpillway.getCoveLength());
        String thresholdElevation = tbAttResRsbSpillway==null?"":isNull(tbAttResRsbSpillway.getThresholdElevation());
        String chec = tbAttResRsbSpillway==null?"":isNull(tbAttResRsbSpillway.getCheckFlDisCharge());
 
        String text = StringUtil.format("泄洪洞为{},{}孔,洞长{}m,进口底槛高程{}m,最大泄量(最大泄洪流量){}m³/s。",
            type, holeNum, coveLength, thresholdElevation, chec);
 
        return text;
    }
 
    /**
     * 生成大坝描述
     *
     * @param name               名字
     * @param tbAttResWaterBlock 大坝对象
     * @return
     */
    private String GenerateDamInfo(String name, TbAttResWaterBlock tbAttResWaterBlock) {
 
        /**
         * XX为XX坝(坝型,填“其他”则对应具体其他内容,下同),坝顶高程XXm,最大坝高XXm,坝长XXm,坝顶宽Xm。
         */
        //坝型
        String mainDamType = DamTypeEnum.find(tbAttResWaterBlock.getDamType()).getLabel();
        //坝高
        String mainDamTopElevation = isNull(tbAttResWaterBlock.getDamTopElevation());
        //最大坝高
        String mainDamHeight = isNull(tbAttResWaterBlock.getDamHeight());
        //坝长
        String mainDamTopLength = isNull(tbAttResWaterBlock.getDamTopLength());
        //坝宽
        String mainDamWidth = isNull(tbAttResWaterBlock.getDamWidth());
 
 
        String info = StringUtil.format("{}为{},坝顶高程{}m,最大坝高{}m,坝长{}m,坝顶宽{}m。",
            name, mainDamType, String.format("%.2f",tbAttResWaterBlock.getDamTopElevation()), mainDamHeight, WordUtil.removeTrailingZero(mainDamTopLength), WordUtil.removeTrailingZero(mainDamWidth));
 
        return info;
    }
 
 
    private void formatAttResManagePerson(List<AttResManagePerson> attResManagePeople) {
        for (int i = 0; i < attResManagePeople.size(); i++) {
            AttResManagePerson attResManagePerson = attResManagePeople.get(i);
 
            if (attResManagePerson.getType().equals("1")) {
                //行政
                this.administrativeInfo = StringUtil.format("{}({},{})",
                    attResManagePerson.getUserName(), attResManagePerson.getPosition(), attResManagePerson.getUserPhone());
 
                this.administrativeUnit = attResManagePerson.getUserUnit();
            }
 
            if (attResManagePerson.getType().equals("3")) {
                //主管
                this.competentDepartmentInfo = StringUtil.format("{}({},{})",
                    attResManagePerson.getUserName(), attResManagePerson.getPosition(), attResManagePerson.getUserPhone());
 
            }
        }
    }
 
 
    private void formatTbAttResBase(TbAttResBase tbAttResBase) {
 
        if (tbAttResBase == null){
            return;
        }
 
        //水库名称
        this.resName = tbAttResBase.getName();
        //所在河流
        this.locRvName = tbAttResBase.getLocRvName();
 
        //行政区划 市、县、镇
        if (StringUtil.isNotBlank(tbAttResBase.getBuildAddress())) {
            List<String> regionList = Arrays.asList(tbAttResBase.getBuildAddress().split("-"));
            if (regionList.size() == 4) {
                this.cityName = regionList.get(1);
                this.countyName = regionList.get(2);
                this.townName = regionList.get(3);
            }else if (regionList.size() == 3) {
                this.cityName = regionList.get(1);
                this.countyName = regionList.get(2);
                this.townName = "";
            } else if (regionList.size() == 2){
                this.cityName = regionList.get(1);
                this.countyName = "";
                this.townName = "";
            } else {
                this.cityName = "";
                this.countyName = "";
                this.townName = "";
            }
 
        }
 
        //水库功能
        if (StringUtil.isNotBlank(tbAttResBase.getResFunc())) {
            List<String> resFucList = Arrays.asList(tbAttResBase.getResFunc().split(","));
            List<String> resFucTextList = new ArrayList<>();
            for (int i = 0; i < resFucList.size(); i++) {
                //最多三个,三个后加上等综合
                if (i > 2) {
                    break;
                }
                String key = resFucList.get(i);
                ResFucEnum resFucEnum = ResFucEnum.find(key);
                resFucTextList.add(resFucEnum.getLabel());
            }
 
            String resFuncText = String.join("、", resFucTextList);
            if (resFucList.size() >= 3) {
                resFuncText = resFuncText + "等";
            }
            this.resFuncText = resFuncText;
 
        }
 
        //工程等别
        if (tbAttResBase.getEngGrad() != null){
            this.engGrad = tbAttResBase.getEngGrad();
        }
 
        if (tbAttResBase.getStartTime() != null){
            //开工时间 (2022年9月)
            this.startTime = new SimpleDateFormat("yyyy年MM月").format(tbAttResBase.getStartTime());
        }
 
        if (tbAttResBase.getWaterStorageTm() != null){
            //蓄水时间(2022年9月)
            this.waterStorageTm = new SimpleDateFormat("yyyy年MM月").format(tbAttResBase.getWaterStorageTm());
        }
 
    }
 
    private void formatTbAttResStagChar(TbAttResStagChar tbAttResStagChar) {
        if (tbAttResStagChar == null){
            return;
        }
 
        //调节性能
        this.adjustPropText = AdjustPropEnum.find(tbAttResStagChar.getAdjustProp()).getLabel();
 
        this.conArea = isNull(tbAttResStagChar.getConArea());
 
        this.moyearRainAvg = isNull(tbAttResStagChar.getMoyearRainAvg());
 
        this.moyearFlAvg = isNull(tbAttResStagChar.getMoyearFlAvg());
 
        this.desFlSta = DesFlStaEnum.find(tbAttResStagChar.getDesFlSta()).getLabel();
 
        this.checFlSta = ChecFlStaEnum.find(tbAttResStagChar.getChecFlSta()).getLabel();
 
        this.totalCap = isNull(tbAttResStagChar.getTotalCap());
        //水文特征
        List<String> hydrologicalCharacteristicsList = new ArrayList<>();
 
        List<String> hydrologicalCharacteristicsList2 = new ArrayList<>();
 
        if (tbAttResStagChar.getAdjustStorCap() != null) {
            hydrologicalCharacteristicsList.add(StringUtil.format("兴利库容{}万m³", WordUtil.removeTrailingZero(tbAttResStagChar.getAdjustStorCap().toString())));
        }
        if (tbAttResStagChar.getFlprCap() != null) {
            hydrologicalCharacteristicsList.add(StringUtil.format("调洪库容{}万m³", WordUtil.removeTrailingZero(tbAttResStagChar.getFlprCap().toString())));
        }
        if (tbAttResStagChar.getDeadCap() != null) {
            hydrologicalCharacteristicsList.add(StringUtil.format("死库容{}万m³", WordUtil.removeTrailingZero(tbAttResStagChar.getDeadCap().toString())));
        }
        if (tbAttResStagChar.getChecFlStag() != null) {
            hydrologicalCharacteristicsList2.add(StringUtil.format("水库校核洪水位{}m", String.format("%.2f",tbAttResStagChar.getChecFlStag())));
        }
        if (tbAttResStagChar.getDesFlStag() != null) {
            hydrologicalCharacteristicsList2.add(StringUtil.format("设计洪水位{}m", String.format("%.2f",tbAttResStagChar.getDesFlStag())));
        }
        if (tbAttResStagChar.getCorNormStag() != null) {
            hydrologicalCharacteristicsList2.add(StringUtil.format("正常蓄水位{}m", String.format("%.2f",tbAttResStagChar.getCorNormStag())));
        }
        if (tbAttResStagChar.getDeadStag() != null) {
            hydrologicalCharacteristicsList2.add(StringUtil.format("死水位{}m", String.format("%.2f",tbAttResStagChar.getDeadStag())));
        }
 
        this.hydrologicalCharacteristics = String.join(",", hydrologicalCharacteristicsList) + "。" + String.join(",", hydrologicalCharacteristicsList2);
    }
 
    private void formatTbAttResWaterDelivery(List<TbAttResWaterDelivery> tbAttResWaterDeliveryList) {
        if (tbAttResWaterDeliveryList.size() == 0){
            return;
        }
 
 
        TbAttResWaterDelivery tbAttResWaterDelivery = tbAttResWaterDeliveryList.get(0);
        if (tbAttResWaterDeliveryList.size() > 1) {
            this.aqueductType = "水库主要采用";
        } else {
            this.aqueductType = "水库采用";
        }
 
        if (StringUtil.isNotBlank(tbAttResWaterDelivery.getAqueductType())) {
            this.aqueductType = this.aqueductType + convertType(tbAttResWaterDelivery.getAqueductType(),"AqueductTypeEnum") + "输水";
        } else {
            this.aqueductType = "";
        }
 
 
 
        if (null != tbAttResWaterDelivery.getSectionWide()  && null != tbAttResWaterDelivery.getSectionHigh()) {
            if (StringUtil.isNotBlank(this.aqueductType)) {
                this.section = ",断面尺寸";
            }
            this.section = this.section + isNull(tbAttResWaterDelivery.getSectionWide()) + "×" + isNull(tbAttResWaterDelivery.getSectionHigh()) + "m";
        } else {
            if (null != tbAttResWaterDelivery.getSectionWide()) {
                if (StringUtil.isNotBlank(this.aqueductType)) {
                    this.section = ",断面尺寸";
                }
                this.section = this.section + isNull(tbAttResWaterDelivery.getSectionWide()) + "m";
            } else {
                this.section = "";
            }
        }
 
        if (null != tbAttResWaterDelivery.getThresholdElevation()) {
            if (StringUtil.isNotBlank(this.aqueductType) || StringUtil.isNotBlank(this.section)) {
                this.thresholdElevation = ",进口底槛高程";
            }
            this.thresholdElevation = this.thresholdElevation + String.format("%.2f",tbAttResWaterDelivery.getThresholdElevation()) + "m";
        }
 
 
        if (null != tbAttResWaterDelivery.getDesignFlow()) {
            if (StringUtil.isNotBlank(this.aqueductType) || StringUtil.isNotBlank(this.section) || StringUtil.isNotBlank(this.thresholdElevation)) {
                this.designFlow = ",设计流量";
            }
            this.designFlow = this.designFlow + WordUtil.removeTrailingZero(isNull(tbAttResWaterDelivery.getDesignFlow())) + "m³/s。";
        }
 
 
    }
 
 
    private void formatTbAttResEngBene(TbAttResEngBene tbAttResEngBene) {
        if (tbAttResEngBene == null){
            return;
        }
 
        this.protectCity = tbAttResEngBene.getCity().equals("无")?"保护下游" + tbAttResEngBene.getTown():"保护下游" + tbAttResEngBene.getCity();
        if (StringUtil.isBlank(this.protectCity)) {
            this.protectCity = tbAttResEngBene.getTown().equals("无")?"":"保护下游" + tbAttResEngBene.getTown();
        }
 
        double person = tbAttResEngBene.getFlControlPerson() / 10000.0;
 
        if (person > 0) {
            this.protectPersonLand = WordUtil.removeTrailingZero(String.format("%.2f",person)) + "万人口";
        }
 
        if (tbAttResEngBene.getFlControlLand() > 0) {
            if (StringUtil.isBlank(this.protectPersonLand)) {
                this.protectPersonLand = WordUtil.removeTrailingZero(String.format("%.2f", tbAttResEngBene.getFlControlLand())) + "万亩耕地";
            } else {
                this.protectPersonLand = this.protectPersonLand + "、" + WordUtil.removeTrailingZero(String.format("%.2f", tbAttResEngBene.getFlControlLand())) + "万亩耕地";
            }
        }
 
//        this.protectPersonLand =
//            StringUtil.format("{}万人口、{}万亩耕地", WordUtil.removeTrailingZero(String.format("%.2f",person)) , WordUtil.removeTrailingZero(String.format("%.2f", tbAttResEngBene.getFlControlLand() / 1000)));
 
        ////铁路、公路、管线、企业几个依次罗列,超过三个列出第二个后为“XX等”,后面不需罗列
 
        String railway = tbAttResEngBene.getRailway();
        String highway = tbAttResEngBene.getHighway();
        String importCommunication = tbAttResEngBene.getImportCommunication();
        String importFactory = tbAttResEngBene.getImportFactory();
 
        List<String> protectList = new ArrayList<>();
 
        if (StringUtil.isNotBlank(railway) && !railway.equals("无")) {
            protectList.add(railway);
        }
 
        if (StringUtil.isNotBlank(highway)&& !highway.equals("无")) {
            protectList.add(highway);
        }
 
        if (StringUtil.isNotBlank(importCommunication)&& !importCommunication.equals("无")) {
            protectList.add(importCommunication);
        }
 
        if (StringUtil.isNotBlank(importFactory)&& !importFactory.equals("无")) {
            protectList.add(importFactory);
        }
        this.protectThings = "";
        //超过三个列出第二个后为“XX等”,后面不需罗列
        if (protectList.size() > 3) {
            List<String> sublist = protectList.subList(0, 2);
            this.protectThings = "及" + String.join("、", sublist) + "等";
        } else if(protectList.size() >= 1 ){
            this.protectThings = "及" + String.join("、", protectList);
        } else {
            this.protectThings = "";
        }
 
        if ((this.protectCity.equals("无") || StringUtil.isBlank(this.protectCity) || this.protectCity.equals("保护下游无")) &&
            StringUtil.isBlank(this.protectPersonLand) &&
            StringUtil.isBlank(this.protectThings)) {
            this.protectCity = "无防洪保护对象";
        } else {
            this.protectThings = this.protectThings  + "的防洪安全";
        }
 
        this.economicBenefit = "";
        //若既有灌溉又有供水,则有“此外,”,
        if (StringUtils.isNotBlank(tbAttResEngBene.getIrrObject())) {
            this.economicBenefit =
                StringUtil.format("水库为{}提供灌溉用水,设计灌溉面积{}万亩,有效灌溉面积{}万亩,多年平均灌溉水量{}万m³。",
                    tbAttResEngBene.getIrrObject(),
                    WordUtil.removeTrailingZero(String.format("%.2f", tbAttResEngBene.getDesIrrArea() / 10000)),
                    WordUtil.removeTrailingZero(String.format("%.2f", tbAttResEngBene.getChecIrrArea() / 10000)),
                    WordUtil.removeTrailingZero(tbAttResEngBene.getMoyearIrrAvg().toString()));
        }
 
        if (StringUtil.isNotBlank(tbAttResEngBene.getSupplyObject())) {
            if (StringUtils.isNotBlank(this.economicBenefit)) {
                this.economicBenefit = this.economicBenefit +
                    StringUtil.format("此外,水库为{}{}万人提供生活用水,年均供水量{}万m³。",
                        tbAttResEngBene.getSupplyObject(),
                        StringUtil.isBlank(tbAttResEngBene.getSupplyPopulation())?"":String.format("%.2f", Double.parseDouble(tbAttResEngBene.getSupplyPopulation())),
                        tbAttResEngBene.getMoyearSupplyAvg());
            } else {
                //无灌溉有供水直接介绍供水
                this.economicBenefit =
                    StringUtil.format("水库为{}{}万人提供生活用水,年均供水量{}万m³。",
                        tbAttResEngBene.getSupplyObject(),
                        String.format("%.2f", StringUtil.isBlank(tbAttResEngBene.getSupplyPopulation())?"":Double.parseDouble(tbAttResEngBene.getSupplyPopulation())),
                        tbAttResEngBene.getMoyearSupplyAvg());
            }
        }
 
 
    }
 
    private void formatTbAttResSafetyMonitor(TbAttResSafetyMonitor tbAttResSafetyMonitor) {
        if (tbAttResSafetyMonitor ==null){
            return;
        }
        String time = "";
        if (tbAttResSafetyMonitor.getSafetyAppraisalTime() != null){
             time = new SimpleDateFormat("yyyy年MM月").format(tbAttResSafetyMonitor.getSafetyAppraisalTime());
        }
        String type = SafetyAppraisalTypeEnum.find(tbAttResSafetyMonitor.getSafetyAppraisalResult()).getLabel();
        String surveyProblem = tbAttResSafetyMonitor.getSurveyProblem();
        //(若一类坝,不介绍问题,二、三类坝介绍)
        if (tbAttResSafetyMonitor.getSafetyAppraisalResult().equals("1")) {
            this.safetyMonitorText = StringUtil.format("{},水库进行安全鉴定,鉴定结果为“{}”。",
                time, type).replaceAll("。。","。");
        } else if (tbAttResSafetyMonitor.getSafetyAppraisalResult().equals("2") || tbAttResSafetyMonitor.getSafetyAppraisalResult().equals("3")) {
            this.safetyMonitorText = StringUtil.format("{},水库进行安全鉴定,鉴定结果为“{}”,工程主要存在问题为{}。",
                time, type, surveyProblem).replaceAll("。。","。");
        }
    }
 
    private void formatTbAttResMgrSysB(TbAttResMgrSysB tbAttResMgrSysB) {
 
        if (tbAttResMgrSysB == null){
            return;
        }
 
        this.mUnitName = tbAttResMgrSysB.getMUnitName();
        this.mUnitNature = tbAttResMgrSysB.getMUnitNature().replace("公益类","事业单位");
        this.mUnitPersonNumber = tbAttResMgrSysB.getMUnitPersonNumber() + "";
    }
 
    //对有补充说明的选项进行转换
    private String convertType(String type, String enumName) {
        String text = "";
 
        List<String> typeList = Arrays.asList(type.split(","));
        String typeKey = typeList.get(0);
        String explain ="";
        if (typeList.size()>1){
             explain = typeList.get(1);
        }
 
        //key值表示其他
        if (StringUtil.isNotBlank(typeKey)) {
            if (typeKey.equals("9") || typeKey.equals("其他") || Integer.parseInt(typeKey) == 9 ) {
                text = explain.trim();
            }else{
                switch (enumName) {
                    case "AqueductTypeEnum":
                        text = AqueductTypeEnum.find(typeKey).getLabel();
                        break;
                    case "SpillwayHoleType":
                        text = typeKey;
                        break;
                }
            }
        }
 
 
        return text;
    }
 
    private String isNull(Double target) {
        if (target == null) {
            return "";
        } else {
            return target.toString();
        }
    }
 
 
}