guoshilong
2024-02-27 0bdd1bda41e6fa8436d070b1f4e5b1f19f86d9d8
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/word/vo/OverWord.java
@@ -7,6 +7,7 @@
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@@ -17,14 +18,28 @@
   private String tm;
   private String hour;
   //超汛限
   //全省超汛限
   private String totalInfo;
   //超汛限小型水库
   private String overSmallInfo;
   //超汛限大型水库
   private String overBigInfo;
   //超汛限中型水库
   private String overMidInfo;
   //省直水库
   private String provinceInfo;
   //全省水库超正常
   private String totalOverNormalInfo;
   //超正常小型水库
   private String overNormalSmallInfo;
   //全省水库超正常10cm以上
   private String totalOverNormal10Info;
   //超正常大型水库
   private String overNormalBigInfo;
   //超正常中型水库
   private String overNormalMidInfo;
   public OverWord(List<TotalInfo> totalList, List<DzkInfo> dzkList, List<OverDetail> overDetailList,List<SzInfo> szInfoList){
      this.tm = new SimpleDateFormat("MM月dd日H时").format(new Date());
@@ -35,6 +50,130 @@
      formatSzInfo(szInfoList);
   }
   public OverWord(List<TotalInfo> totalList, List<DzkInfo> dzkList, List<OverDetail> overDetailList,List<SzInfo> szInfoList,List<TotalInfo> totalOverList, List<TotalInfo> totalOver10List){
      this.tm = new SimpleDateFormat("MM月dd日H时").format(new Date());
      this.hour = new SimpleDateFormat("H时").format(new Date());
      formatTotalInfo(totalList);
      formatDzkInfo(dzkList);
      formatSzInfo(szInfoList);
      formatOverNormal(totalOverList,totalOver10List);
   }
   /**
    * 构建超正常信息
    * @param totalOverList
    * @param totalOver10List
    */
   private void formatOverNormal(List<TotalInfo> totalOverList, List<TotalInfo> totalOver10List) {
      int total = 0;
      int big = 0;
      int mid = 0;
      int small = 0;
      int dangerCountTotal = 0;
      int overDangerCountTotal = 0;
      List<String> smallList = new ArrayList<>();
      List<String> midList = new ArrayList<>();
      List<String> bigList = new ArrayList<>();
      for (int i = 0; i < totalOverList.size(); i++) {
         TotalInfo totalInfo = totalOverList.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){
            String smallRegionCout = StringUtil.format("{}{}座",totalInfo.getP_ad_name(),totalInfo.getSmall_all());
            smallList.add(smallRegionCout);
         }
         // "mid_over_detail": "许家冲水库-5.59,游河水库-1.42,马鞍山水库-0.2,桃园河水库-3.19,白果河水库-1.56,两河口水库-4.97",
         if (totalInfo.getBig_over_detail() != null){
            String bigOverDetail = totalInfo.getBig_over_detail();
            //许家冲水库-5.59   游河水库-1.42  马鞍山水库-0.2
            List<String> list = Arrays.asList(bigOverDetail.split(","));
            list.forEach(item->{
               String reservoirName = item.split("~")[0];
               bigList.add(reservoirName);
            });
         }
         if (totalInfo.getMid_over_detail() != null){
            String midOverDetail = totalInfo.getMid_over_detail();
            //许家冲水库-5.59   游河水库-1.42  马鞍山水库-0.2
            List<String> list = Arrays.asList(midOverDetail.split(","));
            list.forEach(item->{
               String reservoirName = item.split("~")[0];
               midList.add(reservoirName);
            });
         }
      }
      String totalValue =
         StringUtil.format("今日{},全省共有{}座水库超正常水位,其中大型水库{}座、中型水库{}座、小型水库{}座。全省水库持续安全运行。全省病险水库中,有{}座超正常水位,有{}座没有超正常但超了控制运用水位",
            this.hour,total,big,mid,small,dangerCountTotal,overDangerCountTotal);
      String totalOverNormal10Value = getOverNormal10(totalOver10List);
      String smallValue = String.join("、",smallList);
      String bigValue="";
      if (bigList.size()>0){
         bigValue=
            StringUtil.format("    其中,超正常的大型水库有{}。",String.join("、",bigList));
      }else{
         bigValue= "    其中,没有超正常的大型水库。";
      }
      String midValue = "";
      if (midList.size()>0){
         midValue=
            StringUtil.format("    其中,超正常的中型水库有{}。",String.join("、",midList));
      }else{
         midValue= "    其中,没有超正常的中型水库。";
      }
      this.totalOverNormalInfo = totalValue;
      this.overNormalSmallInfo =smallValue;
      this.overNormalBigInfo = bigValue;
      this.overNormalMidInfo = midValue;
      this.totalOverNormal10Info = totalOverNormal10Value;
   }
   //获取超正常10cm的水库
   private String getOverNormal10(List<TotalInfo> totalOver10List) {
      int total = 0;
      int big = 0;
      int mid = 0;
      int small = 0;
      int dangerCountTotal = 0;
      int overDangerCountTotal = 0;
      for (int i = 0; i < totalOver10List.size(); i++) {
         TotalInfo totalInfo = totalOver10List.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();
      }
      String totalValue =
         StringUtil.format("今日{},全省共有{}座水库超正常水位,其中大型水库{}座、中型水库{}座、小型水库{}座。全省水库持续安全运行。全省病险水库中,有{}座超正常水位,有{}座没有超正常但超了控制运用水位",
            this.hour,total,big,mid,small,dangerCountTotal,overDangerCountTotal);
      return totalValue;
   }
   /**
    * 构建省直信息
    * @param szInfoList