guoshilong
2023-06-21 529682cbca2ad473324f78a3c34f30bd07e6c2f9
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/intelligentCall/service/impl/CallServiceImpl.java
@@ -22,6 +22,7 @@
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@@ -272,6 +273,11 @@
    */
   @Override
   public Object getOutgoingStatisticList(IPage<CallTaskStatistic> page,CallTaskStatistic callTaskStatistic) {
      if (null==callTaskStatistic.getCreateTime() || callTaskStatistic.getCreateTime().equals("")){
         long l = System.currentTimeMillis();
         // 设置当前时间的前一天
         callTaskStatistic.setCreateTime(new SimpleDateFormat("yyyy-MM-dd").format(new Date(l - 60*60*24*1000)));
      }
      List<String> list = new ArrayList<>();
      if (null!= callTaskStatistic.getAdName() && !callTaskStatistic.getAdName().equals("")){
         // 查询所有下级区域code
@@ -285,7 +291,26 @@
      if (null!= callTaskStatistic.getIsPage()){
         return callTaskMapper.getOutgoingStatisticList(null,callTaskStatistic,list);
      }
      return page.setRecords(callTaskMapper.getOutgoingStatisticList(page,callTaskStatistic,list));
      // 按天查询数据
      List<CallTaskStatistic> outgoingStatisticList = callTaskMapper.getOutgoingStatisticList(page, callTaskStatistic, list);
      // 查询 按区域统计连续三天,连续两天未接通,前一天拒接对应的数量
      Map<String, Object> threeDay = computationTime(callTaskStatistic.getCreateTime(), 2);
      Map<String, Object> twoDay = computationTime(callTaskStatistic.getCreateTime(), 1);
      Map<String, Object> oneDay = computationTime(callTaskStatistic.getCreateTime(), 0);
      // 查询
      List<CallTaskStatistic> notCallConnectStatisticList = callTaskMapper.getNotCallConnectStatisticList(callTaskStatistic,list,threeDay,twoDay,oneDay);
      // 遍历
      for (CallTaskStatistic taskStatistic : outgoingStatisticList) {
         for (CallTaskStatistic statistic : notCallConnectStatisticList) {
            if (taskStatistic.getGuid().equals(statistic.getGuid())){
               taskStatistic.setThreeNoConnectCount(statistic.getThreeNoConnectCount());
               taskStatistic.setTwoNoConnectCount(statistic.getTwoNoConnectCount());
               taskStatistic.setRefuseConnectCount(statistic.getRefuseConnectCount());
            }
         }
      }
      // 返回
      return page.setRecords(outgoingStatisticList);
   }
   /**
@@ -533,6 +558,32 @@
   }
   /**
    * 计算时间
    * @param time 传入的时间
    * @param day 天数
    */
   private Map<String,Object> computationTime(String time,Integer day) {
      HashMap<String, Object> map = new HashMap<>(2);
      long l = 0;
      try {
         l = new SimpleDateFormat("yyyy-MM-dd").parse(time).getTime();
      } catch (ParseException e) {
         e.printStackTrace();
      }
      long m = 60*60*24*1000*day;
      // 相减得到时间
      Long x = l-m;
      // 格式化日期
      String startTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date(x));
      String endTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date(l));
      // 加入到参数中
      map.put("startTime",startTime);
      map.put("endTime",endTime);
      // 返回
      return map;
   }
   /**
    * 调用中台接口查询出所有需要发任务的水库巡查责任人相关信息(该处需要将是否超汛限条件传入)
    * @param params
    * @return