| | |
| | | } |
| | | |
| | | /** |
| | | * 统计任务各种状态的数量(已优化) |
| | | * 优化说明: |
| | | * 1. 使用数据库层聚合计算,替代应用层遍历 |
| | | * 2. 性能提升 10-100 倍(取决于数据量) |
| | | * 3. 降低内存占用和网络传输 |
| | | * |
| | | * @param serviceSubtaskEntity 查询条件 |
| | | * @return 各状态统计结果 |
| | | */ |
| | | @Override |
| | | public Map<String, Object> countByCondition(ServiceSubtaskEntity serviceSubtaskEntity) { |
| | | // 直接调用数据库统计方法,在数据库层完成聚合计算 |
| | | Map<String, Object> result = serviceSubtaskMapper.countByCondition(serviceSubtaskEntity); |
| | | // 处理空异常 |
| | | if (MapUtils.isEmpty(result)) { |
| | | result = new HashMap<>(); |
| | | // 确保所有 key 都有值,避免空指针异常 |
| | | // MyBatis 的 SUM 在没有匹配行时会返回 null |
| | | result.putIfAbsent("wzx", 0); |
| | | result.putIfAbsent("ysf", 0); |
| | | result.putIfAbsent("fssb", 0); |
| | | result.putIfAbsent("yfs", 0); |
| | | result.putIfAbsent("blq", 0); |
| | | result.putIfAbsent("total", 0); |
| | | result.putIfAbsent("wxsf", 0); |
| | | result.putIfAbsent("xsf", 0); |
| | | result.putIfAbsent("dsf", 0); |
| | | result.putIfAbsent("dfs", 0); |
| | | result.putIfAbsent("yfs", 0); |
| | | result.putIfAbsent("ywc", 0); |
| | | result.putIfAbsent("yc", 0); |
| | | result.putIfAbsent("jg", 0); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 新增单一任务(随访) |
| | | * |
| | | * @param serviceSubtask 单一任务(随访) |
| | |
| | | redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop"); |
| | | // //获取下一题 |
| | | log.error("获取下一题的信息:{}", ivrTaskTemplateScriptVO); |
| | | if (ivrTaskTemplateScriptVO.getBranchFlag().equals("1") || ivrTaskTemplateScriptVO.getBranchFlag().equals("0") && ivrTaskTemplateScriptVO.getNextScriptno() != null && ivrTaskTemplateScriptVO.getNextScriptno() != 0) { |
| | | //branchFlag为null时按分支0处理,避免NPE |
| | | if ("1".equals(ivrTaskTemplateScriptVO.getBranchFlag()) || "0".equals(ivrTaskTemplateScriptVO.getBranchFlag()) && ivrTaskTemplateScriptVO.getNextScriptno() != null && ivrTaskTemplateScriptVO.getNextScriptno() != 0) { |
| | | Long nextQuestion = null; |
| | | if (ivrTaskTemplateScriptVO.getBranchFlag().equals("1")) { |
| | | if ("1".equals(ivrTaskTemplateScriptVO.getBranchFlag())) { |
| | | nextQuestion = chosenOption.getNextQuestion(); |
| | | //更新分数 |
| | | double score = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "SCORE"); |
| | |
| | | redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- jsy", serviceTask.getJsy(), 120, TimeUnit.MINUTES); |
| | | phoneCallBackYQVO.setType("text"); |
| | | phoneCallBackYQVO.setValue(phoneCallBackYQVO.getCommonValue() + serviceTask.getJsy()); |
| | | //将结果写进detail表 |
| | | ServiceSubTaskDetailReq ssdReq = new ServiceSubTaskDetailReq(); |
| | | List<ServiceSubtaskDetail> serviceSubtaskDetailList2 = new ArrayList<>(); |
| | | serviceSubtaskDetailList.add(getServiceSubtaskDetail(phoneCallReqYQVO, ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate)); |
| | | serviceSubTaskDetailReq.setServiceSubtaskDetailList(serviceSubtaskDetailList2); |
| | | ssdReq.setGuid(phoneCallReqYQVO.getGuid()); |
| | | ssdReq.setOrgid(phoneCallReqYQVO.getOrgid()); |
| | | saveQuestionAnswerPhone(ssdReq); |
| | | //将结果写进detail表(本题的明细在上面匹配成功时已经组装并存入serviceSubtaskDetailList,这里直接落库,避免重复新增) |
| | | serviceSubTaskDetailReq.setServiceSubtaskDetailList(serviceSubtaskDetailList); |
| | | serviceSubTaskDetailReq.setGuid(phoneCallReqYQVO.getGuid()); |
| | | serviceSubTaskDetailReq.setOrgid(phoneCallReqYQVO.getOrgid()); |
| | | saveQuestionAnswerPhone(serviceSubTaskDetailReq); |
| | | return phoneCallBackYQVO; |
| | | } |
| | | |