ke
2024-05-13 659d3e60c6fe5e5bcd8c4cbb3dd8077e29f13a38
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
package cn.gistack.sm.sjztmd.word.util;
 
import cn.gistack.sm.sjztmd.word.vo.TotalInfo;
import org.springblade.core.tool.utils.StringUtil;
 
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
/**
 * @PROJECT_NAME: skjcmanager
 * @DESCRIPTION: 报讯简报
 * @USER: aix
 * @DATE: 2024/5/10 10:54
 */
public class BriefReportUtil {
 
    public static String formatTotalInfo(List<TotalInfo> totalList) {
        int total = 0;
        int big = 0;
        int mid = 0;
        int small = 0;
        int dangerCountTotal = 0;
        int overDangerCountTotal = 0;
        List<String> smallList = new ArrayList<>();
 
 
        for (int i = 0; i < totalList.size(); i++) {
            TotalInfo totalInfo = totalList.get(i);
            total += totalInfo.getCount_all();
            big += totalInfo.getBig_all();
            mid += totalInfo.getMid_all();
            small += totalInfo.getSmall_all();
            dangerCountTotal += totalInfo.getDanger_count_all();
            overDangerCountTotal += totalInfo.getOver_danger_count_all();
 
            if (totalInfo.getSmall_all() == 0) {
                continue;
            }
 
            String smallRegionCout = StringUtil.format("{}{}座", totalInfo.getP_ad_name(), totalInfo.getSmall_all());
            smallList.add(smallRegionCout);
        }
 
        String tm = new SimpleDateFormat("MM月dd日H时").format(new Date());
        String hour = new SimpleDateFormat("H时").format(new Date());
 
        if (total <= 0) {
            return "暂无简报";
        }
 
        String resultStr = "今日{},全省共有{}座水库超汛限水位,其中{},均在平稳消落。全省水库持续安全运行。";
        String dxskStr = "大型水库{}座";
        String zxskStr = "中型水库{}座";
        String xxskStr = "小型水库{}座";
 
        String qzStr = "";
 
        if (big > 0) {
            dxskStr = StringUtil.format(dxskStr, big);
            qzStr += StringUtil.isBlank(qzStr) ? dxskStr : "、" + dxskStr;
        }
        if (mid > 0) {
            zxskStr = StringUtil.format(zxskStr, mid);
            qzStr += StringUtil.isBlank(qzStr) ? zxskStr : "、" + zxskStr;
        }
        if (small > 0) {
            xxskStr = StringUtil.format(xxskStr, small);
            qzStr += StringUtil.isBlank(qzStr) ? xxskStr : "、" + xxskStr;
        }
 
        resultStr = StringUtil.format(resultStr, hour, total, qzStr);
 
        return resultStr;
    }
 
}