guoshilong
2024-01-11 bfd74f51e9b832cd9a99aa41c5ed6faa9c9c0be6
skjcmanager/skjcmanager-service/skjcmanager-nky/src/main/java/cn/gistack/nky/service/impl/HsybServiceImpl.java
@@ -75,61 +75,84 @@
    * @return
    */
   public List<List<String>> filterPredictData(List<List<String>> data) {
      String formatter = "yyyy-MM-dd";
      String today = DateUtil.format(new Date(), formatter);
      Long time = new Date().getTime() + 60 * 60 * 24 * 1000;
      Date tomorrowDate = new Date(time);
      String tomorrow = DateUtil.format(tomorrowDate, formatter);
      //获取当前时间
      String formatter = "HH:00";
      String nowTime = DateUtil.format(new Date(), formatter);
      //获取等于当前时间的水位数据
      List<List<String>> collect = data.stream().filter(infoList -> infoList.get(0).equals(nowTime)).collect(Collectors.toList());
      String nowHour = DateUtil.format(new Date(),"HH");
      //过滤空值数据
      List<List<String>> collect = data.stream().filter(item -> item.get(0) != null).collect(Collectors.toList());
      //切割过去数据
      Integer nowIndex = findIndex(collect, nowHour);
      List<List<String>> subList = collect.subList(nowIndex, collect.size());
      int index = -1;
      //添加日期
      for (int i = 0; i < subList.size(); i++) {
         List<String> temp = subList.get(i);
         if (index == -1 && temp.get(0).indexOf("/")>-1){
            index = i;
            temp.set(0,tomorrow + " " +temp.get(0).substring(5));
         }
         if (index != -1){
            temp.set(0,tomorrow + " " + temp.get(0).substring(5));
         }else {
            //给后面的时间添加今天的日期
            temp.set(0,today + " " +  temp.get(0));
         }
      }
      //截取掉时间部分
      subList.forEach(e->{
         e.set(0,e.get(0).split(" ")[0]);
      collect.forEach(infoList->{
         //给第一项重新赋值,因为后面取的是第一项,且预测参数时间只要日期
         infoList.set(0,infoList.get(4).split(" ")[0]);
      });
      //去除重复数据
      List<List<String>> distinctList = subList.stream().distinct().collect(Collectors.toList());
      return collect;
      //去重
      for  ( int  i  =   0 ; i  <  distinctList.size()  -   1 ; i ++ )  {
         for  ( int  j  =  distinctList.size()  -   1 ; j  >  i; j -- )  {
            // 这里是对象的比较,如果去重条件不一样,在这里修改即可
            if  (distinctList.get(j).get(0).equals(distinctList.get(i).get(0)))  {
               distinctList.remove(i);
            }
         }
      }
      return distinctList;
//
//      String formatter = "yyyy-MM-dd";
//      String today = DateUtil.format(new Date(), formatter);
//
//      Long time = new Date().getTime() + 60 * 60 * 24 * 1000;
//      Date tomorrowDate = new Date(time);
//      String tomorrow = DateUtil.format(tomorrowDate, formatter);
//
//
//      String nowHour = DateUtil.format(new Date(),"HH");
//
//      //过滤空值数据
//      List<List<String>> collect = data.stream().filter(item -> item.get(0) != null).collect(Collectors.toList());
//
//      //切割过去数据
//      Integer nowIndex = findIndex(collect, nowHour);
//      List<List<String>> subList = collect.subList(nowIndex, collect.size());
//      int index = -1;
//      //添加日期
//      for (int i = 0; i < subList.size(); i++) {
//         List<String> temp = subList.get(i);
//         if (index == -1 && temp.get(0).indexOf("/")>-1){
//            index = i;
//            temp.set(0,tomorrow + " " +temp.get(0).substring(5));
//         }
//
//         if (index != -1){
//            temp.set(0,tomorrow + " " + temp.get(0).substring(5));
//         }else {
//            //给后面的时间添加今天的日期
//            temp.set(0,today + " " +  temp.get(0));
//         }
//
//      }
//
//
//      //截取掉时间部分
//      subList.forEach(e->{
//         e.set(0,e.get(0).split(" ")[0]);
//      });
//
//      //去除重复数据
//      List<List<String>> distinctList = subList.stream().distinct().collect(Collectors.toList());
//
//
//      //去重
//      for  ( int  i  =   0 ; i  <  distinctList.size()  -   1 ; i ++ )  {
//         for  ( int  j  =  distinctList.size()  -   1 ; j  >  i; j -- )  {
//            // 这里是对象的比较,如果去重条件不一样,在这里修改即可
//            if  (distinctList.get(j).get(0).equals(distinctList.get(i).get(0)))  {
//               distinctList.remove(i);
//            }
//         }
//      }
//      return distinctList;
   }
   public Integer findIndex(List<List<String>> list,String reg){