| | |
| | | import cn.gistack.sm.intelligentCall.service.CallService; |
| | | import cn.gistack.sm.intelligentCall.vo.CallTaskResultVO; |
| | | import cn.gistack.sm.intelligentCall.vo.CallTaskStatistic; |
| | | import cn.gistack.sm.sjztmd.entity.AttAdBase; |
| | | import cn.gistack.sm.sjztmd.service.IAttAdBaseService; |
| | | import cn.gistack.sm.sjztmd.vo.AttAdBaseVO; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | |
| | | |
| | | @Autowired |
| | | private CallTaskMapper callTaskMapper; |
| | | |
| | | @Autowired |
| | | private IAttAdBaseService attAdBaseService; |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | |
| | | CompletableFuture.allOf(callTaskStatisticCompletableFuture,threeDayNotCallConnect,twoDayNotCallConnect,oneDayNotCallConnect).get(); |
| | | // 数据处理 |
| | | List<CallTaskStatistic> callTaskStatistics = getCallTaskStatistics(callTaskStatisticCompletableFuture, oneDay, threeDayNotCallConnect, twoDayNotCallConnect, oneDayNotCallConnect); |
| | | // 取当前行政区总数据 |
| | | List<CallTaskStatistic> totalList = getTotalCallTaskStatistics(callTaskStatistics,callTaskStatistic); |
| | | // 排序 |
| | | callTaskStatistics = getCallTaskStatisticsByOrder(callTaskStatistic, callTaskStatistics); |
| | | // 合并数据 |
| | | totalList.addAll(callTaskStatistics); |
| | | // 返回数据 |
| | | if (null!= callTaskStatistic.getIsPage()) { |
| | | return callTaskStatistics; |
| | | return totalList; |
| | | }else { |
| | | return page.setRecords(callTaskStatistics); |
| | | return page.setRecords(totalList); |
| | | } |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | |
| | | } |
| | | // 返回 |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 获取当前行政区总数据 |
| | | * @param callTaskStatistics |
| | | * @param callTaskStatisticEntity |
| | | * @return |
| | | */ |
| | | private List<CallTaskStatistic> getTotalCallTaskStatistics(List<CallTaskStatistic> callTaskStatistics,CallTaskStatistic callTaskStatisticEntity) { |
| | | List<CallTaskStatistic> statistics = new ArrayList<>(); |
| | | CallTaskStatistic callTaskStatistic = new CallTaskStatistic(); |
| | | Integer totalCalleeNumberCount = 0; |
| | | Integer totalConnectionCount = 0; |
| | | Integer totalThreeNoConnectCount = 0; |
| | | Integer totalTwoNoConnectCount = 0; |
| | | Integer totalRefuseConnectCount = 0; |
| | | // 遍历 |
| | | for (CallTaskStatistic taskStatistic : callTaskStatistics) { |
| | | totalCalleeNumberCount += Integer.parseInt(taskStatistic.getCalleeNumberCount()); |
| | | totalConnectionCount += Integer.parseInt(taskStatistic.getConnectionCount()); |
| | | totalThreeNoConnectCount += taskStatistic.getThreeNoConnectCount(); |
| | | totalTwoNoConnectCount += taskStatistic.getTwoNoConnectCount(); |
| | | totalRefuseConnectCount += taskStatistic.getRefuseConnectCount(); |
| | | } |
| | | // 设置数据 |
| | | callTaskStatistic.setCalleeNumberCount(totalCalleeNumberCount.toString()); |
| | | callTaskStatistic.setConnectionCount(totalConnectionCount.toString()); |
| | | callTaskStatistic.setThreeNoConnectCount(totalThreeNoConnectCount); |
| | | callTaskStatistic.setTwoNoConnectCount(totalTwoNoConnectCount); |
| | | callTaskStatistic.setRefuseConnectCount(totalRefuseConnectCount); |
| | | callTaskStatistic.setCreateTime(callTaskStatistics.get(0).getCreateTime()); |
| | | // 查询当前行政区名称 |
| | | AttAdBase attAdBase = new AttAdBase(); |
| | | attAdBase.setGuid(callTaskStatisticEntity.getAdCode()); |
| | | AttAdBaseVO detail = attAdBaseService.getDetail(attAdBase); |
| | | callTaskStatistic.setAdCode(callTaskStatisticEntity.getAdCode()); |
| | | if (null != detail){ |
| | | callTaskStatistic.setAdName(detail.getAdName()); |
| | | } |
| | | // 计算比例 |
| | | //格式化小数 |
| | | DecimalFormat df = new DecimalFormat("0.00"); |
| | | callTaskStatistic.setCallCompletingRate(df.format((float)totalConnectionCount/totalCalleeNumberCount*100)); |
| | | statistics.add(callTaskStatistic); |
| | | // 返回 |
| | | return statistics; |
| | | } |
| | | |
| | | /** |
| | |
| | | List<CallTaskStatistic> outgoingStatisticList = new ArrayList<>(); |
| | | // 判断是否分页 |
| | | if (null!= callTaskStatistic.getIsPage()){ |
| | | // 不分页 |
| | | outgoingStatisticList = callTaskMapper.getOutgoingStatisticList(null,callTaskStatistic,null); |
| | | }else { |
| | | // 按天查询数据 |