xieb
2024-05-10 2808080a085d2f79c0c08010c99b4a78f3e2e28d
汛情简报
1 files modified
1 files added
87 ■■■■■ changed files
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/word/controller/DownTemplateController.java 9 ●●●●● patch | view | raw | blame | history
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/word/util/BriefReportUtil.java 78 ●●●●● patch | view | raw | blame | history
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/word/controller/DownTemplateController.java
@@ -4,6 +4,7 @@
import cn.gistack.sm.sjztmd.util.MyDateUtils;
import cn.gistack.sm.sjztmd.word.service.ISjztmdService;
import cn.gistack.sm.sjztmd.word.util.BriefReportUtil;
import cn.gistack.sm.sjztmd.word.util.ExcelUtil;
import cn.gistack.sm.sjztmd.word.util.WordUtil;
import cn.gistack.sm.sjztmd.word.vo.*;
@@ -11,6 +12,7 @@
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
@@ -43,6 +45,13 @@
    private final ISjztmdService sjztmdService;
    @GetMapping(value = "/getBriefReport")
    public R getBriefReport() {
        //获取总览、大中库、明细数据
        List<TotalInfo> totalList = sjztmdService.getTotalInfo("0");
        return R.data(BriefReportUtil.formatTotalInfo(totalList));
    }
    @GetMapping("/download/{resGuid}")
    public ResponseEntity genera(HttpServletResponse response, @PathVariable String resGuid) throws Exception {
        HashMap<String,Object> obj = sjztmdService.getTbWordVO(resGuid);
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/word/util/BriefReportUtil.java
New file
@@ -0,0 +1,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;
    }
}