tangzy
2021-09-15 0fa45101a494897fe93b90d805b3ff0aedd36e17
src/main/java/org/springblade/modules/river/controller/RiverRController.java
@@ -137,18 +137,18 @@
      //截取月日
      String[] strss = substrings.split("-");
      //月
      String years= strss[1].toString();
      String years = strss[1].toString();
      //日
      String days = strss[2].toString();
      //定义短信内容头
      String text = year + "月" + day + "日"+hs+"时"+"-"+years+ "月" + days + "日"+hss+"时";
      String text = year + "月" + day + "日" + hs + "时" + "-" + years + "月" + days + "日" + hss + "时";
      String texta = "";
      //定义统计数量
      int number = 0;
      //河道超警信息
      List<Map<String, Object>> selecthd = riverRService.selecthd(beginTime, endTime);
      Map<String, Object> sel = riverRService.sel();
      selecthd.add(sel);
      //Map<String, Object> sel = riverRService.sel();
      //selecthd.add(sel);
      //基本站信息
      List<Map<String, Object>> list1 = riverRService.selectP();
      //用来判断是否重复统计超警信息
@@ -164,6 +164,7 @@
      }
      //不为空遍历数据计算是否超出预警值
      else {
         int c = 0;
         for (int i = 0; i < selecthd.size(); i++) {
            //实时河道水位值
            BigDecimal z = (BigDecimal) selecthd.get(i).get("Z");
@@ -200,7 +201,7 @@
                           texta += "流量暂无数据";
                        } else {
                           DecimalFormat dfs = new DecimalFormat("#0.000");
                           texta += "流量" + dfs.format(Q) + "立方米每秒;";
                           texta += "流量" + Q + "立方米每秒;";
                        }
                     }
                  }
@@ -225,19 +226,19 @@
                        if (selecthd.get(i).get("Q") == null) {
                           texta += "流量暂无数据;";
                        } else {
                           DecimalFormat dfs = new DecimalFormat("#0.000");
                           texta += "流量" + dfs.format(Q) + "立方米每秒;";
                           //DecimalFormat dfs = new DecimalFormat("#0.000");
                           texta += "流量" + Q + "立方米每秒;";
                        }
                     }
                  }
               }
               }
            }
         }
         if (number == 0) {
            text +="暂无河道超警戒信息。"+texta;
            text += "暂无河道超警戒信息。" + texta;
         } else {
            text +="有" + number + "个河道站超警戒。"+texta;
            text += "有" + number + "个河道站超警戒。" + texta;
         }
      }
      //河道涨幅,跌幅信息
@@ -265,50 +266,63 @@
         SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         Date sd1 = df.parse(maxTM);
         Date sd2 = df.parse(minTM);
         //如果最大时间大于最小时间就是涨幅
         if (sd1.after(sd2)) {
            //创建一个map集合保存涨幅数据
            double v = maxZ.doubleValue();
            double v1 = minZ.doubleValue();
            //涨幅值
            double v2 = v - v1;
            double v3 = (double) Math.round(v2 * 100) / 100;
            m1.put(Math.abs(v3), stnm.replaceAll(" ", "") + "站");
            c.put(stcd,Math.abs(v3));
         }
         //跌幅
         else {
            //创建一个map集合保存跌幅数据
            double v = maxZ.doubleValue();
            double v1 = minZ.doubleValue();
            //涨幅值
            double v2 = v1 - v;
            double v3 = (double) Math.round(v2 * 100) / 100;
            m2.put(Math.abs(v3), stnm.replaceAll(" ", "") + "站");
            c.put(stcd,v3);
         }
         double v = maxZ.doubleValue();
         double v1 = minZ.doubleValue();
         //涨幅值
         double v2 = v - v1;
         double v3 = (double) Math.round(v2 * 100) / 100;
         m1.put(v3, stnm.replaceAll(" ", "") + "站");
         c.put(stcd, v3);
      }
      if (m1.size()==0){
         text += "暂无涨幅信息。";
      }
      else {
         //获取涨幅最大的信息
      if (m1.size() != 0) {
         Object maxKey = getMaxKey(m1);
         String s1 = m1.get(maxKey).toString();
         text += "涨幅最大的是:" + s1 + "(涨" + maxKey + "米)。";
         text += " 涨幅最大的是:" + s1 + "(涨" + maxKey + "米)。";
      }
      if (m2.size()==0){
         text += "暂无跌幅信息。";
      }
      else {
         //获取跌幅最大的信息
         Object maxKey2 = getMaxKey(m2);
         String s2 = m2.get(maxKey2).toString();
         text += "跌幅最大的是:" + s2 + "(跌" + maxKey2 + "米)。";
      }
//         //如果最大时间大于最小时间就是涨幅
//         if (sd1.after(sd2)) {
//            //创建一个map集合保存涨幅数据
//            double v = maxZ.doubleValue();
//            double v1 = minZ.doubleValue();
//            //涨幅值
//            double v2 = v - v1;
//            double v3 = (double) Math.round(v2 * 100) / 100;
//            m1.put(Math.abs(v3), stnm.replaceAll(" ", "") + "站");
//            c.put(stcd,Math.abs(v3));
//
//
//         }
//         //跌幅
//         else {
//            //创建一个map集合保存跌幅数据
//            double v = maxZ.doubleValue();
//            double v1 = minZ.doubleValue();
//            //涨幅值
//            double v2 = v1 - v;
//            double v3 = (double) Math.round(v2 * 100) / 100;
//            m2.put(Math.abs(v3), stnm.replaceAll(" ", "") + "站");
//            c.put(stcd,v3);
//
//         }
//      }
//      if (m1.size()==0){
//         text += "暂无涨幅信息。";
//      }
//      else {
//         //获取涨幅最大的信息
//         Object maxKey = getMaxKey(m1);
//         String s1 = m1.get(maxKey).toString();
//         text += "涨幅最大的是:" + s1 + "(涨" + maxKey + "米)。";
//      }
//      if (m2.size()==0){
//         text += "暂无跌幅信息。";
//      }
//      else {
//         //获取跌幅最大的信息
//         Object maxKey2 = getMaxKey(m2);
//         String s2 = m2.get(maxKey2).toString();
//         text += "跌幅最大的是:" + s2 + "(跌" + maxKey2 + "米)。";
//      }
      m.put("text", text);
      m.put("number", number);
      m.put("Yjlist", ylist);
@@ -327,7 +341,7 @@
    */
   @PostMapping("/selecthdt")
   public R selecthdt() throws ParseException {
      int w=1;
      int w = 1;
      SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      String time = df.format(new Date());
      String yearc = time.substring(0, 4);
@@ -336,11 +350,11 @@
      int months = Integer.parseInt(monthc);
      String dayc = time.substring(8, 10);
      int days = Integer.parseInt(dayc);
      int da=days-w;
      int da = days - w;
      String hss = time.substring(11, 13);
      int hs = Integer.parseInt(hss);
      //前一天的8时
      String timec = years +"-" + months + "-"+da+" 08:00:00";
      String timec = years + "-" + months + "-" + da + " 08:00:00";
      //前24小时
      Calendar calendar6 = Calendar.getInstance();
      calendar6.set(Calendar.HOUR_OF_DAY, calendar6.get(Calendar.HOUR_OF_DAY) - 24);
@@ -353,7 +367,7 @@
      //日
      String day = strs[2].toString();
      //定义短信内容头
      String text = year + "月" + day + "日"+hs+"时";
      String text = year + "月" + day + "日" + hs + "时";
      String texta = "";
      //定义统计数量
      int number = 0;
@@ -362,15 +376,15 @@
      //定义List保存未警戒信息
      List blist = new ArrayList();
      //河道超警信息
      List<Map<String, Object>> selecthd = riverRService.selecthdt(dateBegin24,time);
      Map<String, Object> sel = riverRService.sel();
      selecthd.add(sel);
      List<Map<String, Object>> selecthd = riverRService.selecthdt(dateBegin24, time);
      //Map<String, Object> sel = riverRService.sel();
      //selecthd.add(sel);
      List<Map<String, Object>> list1 = riverRService.selectP();
      //用来判断是否重复统计超警信息
      Map mnum = new HashMap();
      //查询数据为空
      if (selecthd.size() == 0) {
         text +="暂无河道超警信息。廖家湾水位暂无数据,流量暂无数据;娄家村水位暂无数据,流量暂无数据;";
         text += "暂无河道超警信息。廖家湾水位暂无数据,流量暂无数据;娄家村水位暂无数据,流量暂无数据;";
      }
      //不为空遍历数据计算是否超出预警值
      else {
@@ -379,7 +393,7 @@
            BigDecimal z = (BigDecimal) selecthd.get(i).get("Z");
            double Z = z.doubleValue();
            //超警戒水位值
            if (selecthd.get(i).get("WRZ") == null || selecthd.get(i).get("Q")==null) {
            if (selecthd.get(i).get("WRZ") == null || selecthd.get(i).get("Q") == null) {
               String stnm = selecthd.get(i).get("STNM").toString();
               if (stnm.equals("廖家湾") || stnm.equals("娄家村")) {
                  String stcd = selecthd.get(i).get("STCD").toString();
@@ -390,15 +404,14 @@
                  DecimalFormat dfc = new DecimalFormat("#0.00");
                  String format = dfc.format(vz);
                  double v = Double.parseDouble(format);
                  texta +=stnm.replaceAll(" ", "") + "水位" + dfc.format(Z) + "米、";
                  if (v<0){
                     texta+="比昨日8时下跌"+Math.abs(v)+"米、";
                  texta += stnm.replaceAll(" ", "") + "水位" + dfc.format(Z) + "米、";
                  if (v < 0) {
                     texta += "比昨日8时下跌" + Math.abs(v) + "米、";
                  } else {
                     texta += "比昨日8时上涨" + Math.abs(v) + "米、";
                  }
                  else {
                     texta+="比昨日8时上涨"+Math.abs(v)+"米、";
                  }
                  if (selecthd.get(i).get("Q")==null){
                     texta+="流量暂无信息;";
                  if (selecthd.get(i).get("Q") == null) {
                     texta += "流量暂无信息;";
                  }
               }
               blist.add(selecthd.get(i));
@@ -419,19 +432,17 @@
                  DecimalFormat dfc = new DecimalFormat("#0.00");
                  String format = dfc.format(vz);
                  double v = Double.parseDouble(format);
                  texta +=stnm.replaceAll(" ", "") + "水位" + dfc.format(Z) + "米、";
                  if (v<0){
                     texta+="比昨日8时下跌"+Math.abs(v)+"米、";
                  texta += stnm.replaceAll(" ", "") + "水位" + dfc.format(Z) + "米、";
                  if (v < 0) {
                     texta += "比昨日8时下跌" + Math.abs(v) + "米、";
                  } else {
                     texta += "比昨日8时上涨" + Math.abs(v) + "米、";
                  }
                  else {
                     texta+="比昨日8时上涨"+Math.abs(v)+"米、";
                  }
                  if (selecthd.get(i).get("Q")==null){
                     texta+="流量暂无数据;";
                  }
                  else {
                     DecimalFormat dfl = new DecimalFormat("#0.000");
                     texta+="流量"+dfl.format(Q)+"立方米每秒;";
                  if (selecthd.get(i).get("Q") == null) {
                     texta += "流量暂无数据;";
                  } else {
                     //DecimalFormat dfl = new DecimalFormat("#0.000");
                     texta += "流量" + Q + "立方米每秒;";
                  }
               }
               blist.add(selecthd.get(i));
@@ -458,28 +469,26 @@
                     DecimalFormat dfc = new DecimalFormat("#0.00");
                     String format = dfc.format(vz);
                     double v = Double.parseDouble(format);
                     texta += "。" + stnm.replaceAll(" ", "") + "站超出警戒水位" + dfc.format(v3) + "米、"+ "水位" + dfc.format(Z) + "米、";
                     if (v<0){
                        texta+="比昨日8时下跌"+Math.abs(v)+"米、";
                     texta += "。" + stnm.replaceAll(" ", "") + "站超出警戒水位" + dfc.format(v3) + "米、" + "水位" + dfc.format(Z) + "米、";
                     if (v < 0) {
                        texta += "比昨日8时下跌" + Math.abs(v) + "米、";
                     } else {
                        texta += "比昨日8时上涨" + Math.abs(v) + "米、";
                     }
                     else {
                        texta+="比昨日8时上涨"+Math.abs(v)+"米、";
                     }
                     if (selecthd.get(i).get("Q")==null){
                        texta+="流量暂无数据、";
                     }
                     else {
                     if (selecthd.get(i).get("Q") == null) {
                        texta += "流量暂无数据、";
                     } else {
                        DecimalFormat dfl = new DecimalFormat("#0.000");
                        texta+="流量"+dfl.format(Q)+"立方米每秒;";
                        texta += "流量" + Q + "立方米每秒;";
                     }
                  }
               }
            }
         }
         if (number == 0) {
            text +="暂无河道超警戒信息。"+texta;
            text += "暂无河道超警戒信息。" + texta;
         } else {
            text +="有" + number + "个河道站超警戒。" + texta;
            text += "有" + number + "个河道站超警戒。" + texta;
         }
      }
      Map m = new HashMap();
@@ -492,13 +501,15 @@
      list.add(m);
      return R.data(list);
   }
   /**
    * 河道实时预警
    *
    * @return
    */
   @ApiLog("河道实时预警")
   @PostMapping("/selecthdyj")
   public R selecthdyj(String times,int k) {
   public R selecthdyj(String times, int k) {
      Date date = null;
      // 把Date按照格式转换成字符串
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
@@ -509,51 +520,44 @@
      }
      String dateEnd = sdf.format(date);
      List<Map<String, Object>> list;
      if(k==13){
         list= riverRService.selecthdyj(times,dateEnd);
      }
      else {
         list= riverRService.selecthdyj(times,dateEnd);
      if (k == 13) {
         list = riverRService.selecthdyj(times, dateEnd);
      } else {
         list = riverRService.selecthdyj(times, dateEnd);
      }
      List<Map<String, Object>> lists = new ArrayList<>();
      for (int i =0;i<list.size();i++) {
      for (int i = 0; i < list.size(); i++) {
         Map<String, Object> maps = new HashMap<String, Object>();
         BigDecimal b = (BigDecimal) list.get(i).get("Z");
         int i1 = b.intValue();
         if(i1==0){
            list.get(i).put("yuc","无预警");
         }
         else {
         if (i1 == 0) {
            list.get(i).put("yuc", "无预警");
         } else {
            BigDecimal bigDecimalz = (BigDecimal) list.get(i).get("Z");//实时水位
            BigDecimal bigDecimalw = (BigDecimal) list.get(i).get("WRZ");//警戒水位
            double wrz = bigDecimalw.doubleValue();//警戒水位
            double z = bigDecimalz.doubleValue();//实时水位
            Double fy= (Double) list.get(i).get("fy");
            Double oy= (Double) list.get(i).get("oy");
            Double toy= (Double) list.get(i).get("toy");
            Double ty= (Double) list.get(i).get("ty");
            if(z<wrz || wrz==0){
               list.get(i).put("yuc","无预警");
            }
            else if(z>=wrz && z<fy){
               list.get(i).put("yuc","蓝色预警");
            }
            else if(z>=fy && z<oy){
               list.get(i).put("yuc","黄色预警");
            }
            else if(z>=oy && z<ty){
               list.get(i).put("yuc","橙色预警");
            }
            else {
               list.get(i).put("yuc","红色预警");
            Double fy = (Double) list.get(i).get("fy");
            Double oy = (Double) list.get(i).get("oy");
            Double toy = (Double) list.get(i).get("toy");
            Double ty = (Double) list.get(i).get("ty");
            if (z < wrz || wrz == 0) {
               list.get(i).put("yuc", "无预警");
            } else if (z >= wrz && z < fy) {
               list.get(i).put("yuc", "蓝色预警");
            } else if (z >= fy && z < oy) {
               list.get(i).put("yuc", "黄色预警");
            } else if (z >= oy && z < ty) {
               list.get(i).put("yuc", "橙色预警");
            } else {
               list.get(i).put("yuc", "红色预警");
            }
         }
         maps.put("YjList",list.get(i));
         maps.put("YjList", list.get(i));
         lists.add(maps);
      }
      return R.data(lists);
   }
   /**