| | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.github.pagehelper.util.StringUtil; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | |
| | | import com.smartor.domain.DTO.DetailTraceDealDTO; |
| | | import com.smartor.domain.VO.DetailTraceDealVO; |
| | | import com.smartor.domain.VO.SatisfactionExceptConfigQuestionReqVO; |
| | | import com.smartor.domain.VO.ServiceSubtaskDetailTraceVO; |
| | | import com.smartor.mapper.ServiceSubtaskDetailMapper; |
| | | import com.smartor.mapper.ServiceSubtaskDetailTraceMapper; |
| | | import com.smartor.mapper.SvyLibScriptCategoryMapper; |
| | |
| | | /** |
| | | * 查询随访任务异常记录跟踪列表 |
| | | * |
| | | * @param serviceSubtaskDetailTrace 随访任务异常记录跟踪 |
| | | * @param serviceSubtaskDetailTraceVO 随访任务异常记录跟踪 |
| | | * @return 随访任务异常记录跟踪 |
| | | */ |
| | | @Override |
| | | public List<ServiceSubtaskDetailTrace> selectServiceSubtaskDetailTtraceList(ServiceSubtaskDetailTrace serviceSubtaskDetailTrace) { |
| | | return serviceSubtaskDetailTraceMapper.selectServiceSubtaskDetailTtraceList(serviceSubtaskDetailTrace); |
| | | public List<ServiceSubtaskDetailTrace> selectServiceSubtaskDetailTtraceList(ServiceSubtaskDetailTraceVO serviceSubtaskDetailTraceVO) { |
| | | List<ServiceSubtaskDetailTrace> serviceSubtaskDetailTraces = serviceSubtaskDetailTraceMapper.selectServiceSubtaskDetailTtraceList(serviceSubtaskDetailTraceVO); |
| | | for (ServiceSubtaskDetailTrace serviceSubtaskDetailTrace : serviceSubtaskDetailTraces) { |
| | | if (StringUtils.isNotEmpty(serviceSubtaskDetailTrace.getPatdesc())) { |
| | | serviceSubtaskDetailTrace.setPatdescJson(JSON.parseObject(serviceSubtaskDetailTrace.getPatdesc())); |
| | | } |
| | | } |
| | | return serviceSubtaskDetailTraces; |
| | | } |
| | | |
| | | @Override |
| | | public List<DetailTraceDealDTO> tracedeallist(DetailTraceDealVO detailTraceDealVO) { |
| | | // 获取所有需要处理的记录 |
| | | public Map<String, Object> tracedeallist(DetailTraceDealVO detailTraceDealVO) { |
| | | // 分页查询 |
| | | List<ServiceSubtaskDetailTrace> tracedeallist = serviceSubtaskDetailTraceMapper.tracedeallist(detailTraceDealVO); |
| | | |
| | | // 按 questiontext 分组 |
| | | Map<String, List<ServiceSubtaskDetailTrace>> groupByQuestion = tracedeallist.stream() |
| | | .filter(t -> t.getQuestiontext() != null) |
| | | .collect(Collectors.groupingBy(ServiceSubtaskDetailTrace::getQuestiontext)); |
| | | Map<String, List<ServiceSubtaskDetailTrace>> groupByQuestion = tracedeallist.stream().filter(t -> t.getQuestiontext() != null).collect(Collectors.groupingBy(ServiceSubtaskDetailTrace::getQuestiontext)); |
| | | |
| | | List<DetailTraceDealDTO> detailTraceDealDTOList = new ArrayList<>(); |
| | | long totalException = 0L; |
| | | long noDealException = 0L; |
| | | long yesDealException = 0L; |
| | | |
| | | for (Map.Entry<String, List<ServiceSubtaskDetailTrace>> entry : groupByQuestion.entrySet()) { |
| | | List<ServiceSubtaskDetailTrace> group = entry.getValue(); |
| | | DetailTraceDealDTO dto = new DetailTraceDealDTO(); |
| | | |
| | | // 问题内容 |
| | | dto.setQuestiontext(entry.getKey()); |
| | | |
| | | if (CollectionUtils.isNotEmpty(group)) { |
| | | dto.setScriptid(group.get(0).getScriptid()); |
| | | dto.setTemplateType(group.get(0).getTemplateType()); |
| | | } |
| | | // 负责科室(去重) |
| | | List<Map<String, Object>> responsibleDept = group.stream() |
| | | .filter(t -> t.getTodeptcode() != null) |
| | | .collect(Collectors.collectingAndThen( |
| | | Collectors.toMap( |
| | | ServiceSubtaskDetailTrace::getTodeptcode, |
| | | t -> { |
| | | Map<String, Object> deptMap = new HashMap<>(); |
| | | deptMap.put("deptName", t.getTodeptname()); |
| | | deptMap.put("deptCode", t.getTodeptcode()); |
| | | return deptMap; |
| | | }, |
| | | (existing, replacement) -> existing |
| | | ), |
| | | map -> new ArrayList<>(map.values()) |
| | | )); |
| | | List<Map<String, Object>> responsibleDept = group.stream().filter(t -> t.getTodeptcode() != null).collect(Collectors.collectingAndThen(Collectors.toMap(ServiceSubtaskDetailTrace::getTodeptcode, t -> { |
| | | Map<String, Object> deptMap = new HashMap<>(); |
| | | deptMap.put("deptName", t.getTodeptname()); |
| | | deptMap.put("deptCode", t.getTodeptcode()); |
| | | return deptMap; |
| | | }, (existing, replacement) -> existing), map -> new ArrayList<>(map.values()))); |
| | | dto.setResponsibleDept(responsibleDept); |
| | | |
| | | // 有效填写数:通过组内的 scriptid 去 service_subtask_detail 表查询 |
| | | List<Long> scriptIds = group.stream() |
| | | .map(ServiceSubtaskDetailTrace::getScriptid) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | List<Long> scriptIds = group.stream().map(ServiceSubtaskDetailTrace::getScriptid).filter(Objects::nonNull).distinct().collect(Collectors.toList()); |
| | | long effectiveFillNum = 0L; |
| | | if (CollectionUtils.isNotEmpty(scriptIds)) { |
| | | ServiceSubtaskDetail query = new ServiceSubtaskDetail(); |
| | |
| | | exceptionQuesNum.put("all", exceptionFillNum); |
| | | dto.setExceptionQuesNum(exceptionQuesNum); |
| | | |
| | | // 汇总统计累加 |
| | | totalException += exceptionFillNum; |
| | | noDealException += noDeal; |
| | | yesDealException += yesDeal; |
| | | |
| | | // 最新处理人和处理时间(取 handleTime 最新的一条) |
| | | group.stream() |
| | | .filter(t -> t.getHandleTime() != null) |
| | | .max(Comparator.comparing(ServiceSubtaskDetailTrace::getHandleTime)) |
| | | .ifPresent(latest -> { |
| | | dto.setHandleBy(latest.getHandleBy()); |
| | | dto.setHandleTime(latest.getHandleTime()); |
| | | }); |
| | | group.stream().filter(t -> t.getHandleTime() != null).max(Comparator.comparing(ServiceSubtaskDetailTrace::getHandleTime)).ifPresent(latest -> { |
| | | dto.setHandleBy(latest.getHandleBy()); |
| | | dto.setHandleTime(latest.getHandleTime()); |
| | | }); |
| | | |
| | | detailTraceDealDTOList.add(dto); |
| | | } |
| | | |
| | | return detailTraceDealDTOList; |
| | | Map<String, Object> result = new HashMap<>(); |
| | | result.put("detailTraceDealDTOList", detailTraceDealDTOList); |
| | | result.put("totalException", totalException); |
| | | result.put("noDealException", noDealException); |
| | | result.put("yesDealException", yesDealException); |
| | | return result; |
| | | } |
| | | |
| | | /** |