diff --git a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/DgEfficiencyServiceImpl.java b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/DgEfficiencyServiceImpl.java index a22af15d..96d35c84 100644 --- a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/DgEfficiencyServiceImpl.java +++ b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/DgEfficiencyServiceImpl.java @@ -581,18 +581,24 @@ public class DgEfficiencyServiceImpl extends ServiceImpl wrapper = new QueryWrapper<>(); - wrapper.eq("user_id", currentUser).eq("business_id", po.getBusinessId()); - List auditProcessList = dgAuditProcessMapper.selectList(wrapper); - if (auditProcessList != null && auditProcessList.size() != 0) { - //获取累计耗时,完成时间 - HashMap hashMapTime = getTime(po.getBusinessId(), currentUser); - Object countTime = hashMapTime.get("countTime"); - Object endTime = hashMapTime.get("endTime"); - efficiencyListResponse.setTimeConsuming(countTime(String.valueOf(countTime))); - efficiencyListResponse.setCompleteTime(String.valueOf(endTime)); - } + //用户处理过业务,每一个模块统计耗时 + //获取累计耗时,完成时间 + HashMap hashMapTime = getTime(po.getBusinessId(), po.getProcessId(), currentUser); + String countTime = hashMapTime.get("countTime"); + String endTime = hashMapTime.get("endTime"); + efficiencyListResponse.setTimeConsuming(countTime); + efficiencyListResponse.setCompleteTime(endTime); + // QueryWrapper wrapper = new QueryWrapper<>(); + // wrapper.eq("user_id", currentUser).eq("business_id", po.getBusinessId()); + // List auditProcessList = dgAuditProcessMapper.selectList(wrapper); + // if (auditProcessList != null && auditProcessList.size() != 0) { + // //获取累计耗时,完成时间 + // HashMap hashMapTime = getTime(po.getBusinessId(), currentUser); + // String countTime = hashMapTime.get("countTime"); + // String endTime = hashMapTime.get("endTime"); + // efficiencyListResponse.setTimeConsuming(countTime); + // efficiencyListResponse.setCompleteTime(endTime); + // } efficiencyList.add(efficiencyListResponse); }); //遍历map,key值为业务id @@ -638,37 +644,55 @@ public class DgEfficiencyServiceImpl extends ServiceImpl getTime(Integer businessId, Integer userId) { - HashMap hashMap = Maps.newHashMap(); - //根据业务id查询业务流程表 - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("business_id", businessId).orderByAsc("create_time"); - List auditProcessList = dgAuditProcessMapper.selectList(wrapper); - long countTime = 0L; - if (auditProcessList.size() > 1) { - //遍历业务流程数据,统计该用户的耗时 - for (int i = 1; i <= auditProcessList.size() - 1; i++) { - //从第二条数据开始,获取该数据 - DgAuditProcess auditProcess = auditProcessList.get(i); - //该数据是当前用户处理的 - if (auditProcess.getUserId().equals(userId)) { - //获取上一流程的时间节点 - DgAuditProcess previousProcess = auditProcessList.get(i - 1); - Date previousTime = previousProcess.getCreateTime(); - Date currentTime = auditProcess.getCreateTime(); - long currentTimeTime = currentTime.getTime(); - long previousTimeTime = previousTime.getTime(); - //累计耗时,毫秒 - countTime = currentTimeTime - previousTimeTime; - } - } + private HashMap getTime(Integer businessId,Integer processId, Integer userId) { + HashMap hashMap = Maps.newHashMap(); + // 这个逻辑有问题(不建议采用),根据业务id和用户查询该用户操作的业务流程信息 + // QueryWrapper wrapper = new QueryWrapper<>(); + // wrapper.eq("business_id", businessId).eq("user_id",userId).orderByAsc("create_time"); + // List auditProcessList = dgAuditProcessMapper.selectList(wrapper); + // long countTime = 0L; + // if (auditProcessList.size() > 1) { + // //遍历业务流程数据,统计该用户的耗时 + // for (int i = 1; i <= auditProcessList.size() - 1; i++) { + // //从第二条数据开始,获取该数据 + // DgAuditProcess currentProcess = auditProcessList.get(i); + // //获取上一流程的时间节点 + // DgAuditProcess previousProcess = auditProcessList.get(i - 1); + // Date previousTime = previousProcess.getCreateTime(); + // Date currentTime = currentProcess.getCreateTime(); + // //转换成毫秒统计时间差 + // long currentTimeTime = currentTime.getTime(); + // long previousTimeTime = previousTime.getTime(); + // //累计耗时,毫秒 + // countTime = currentTimeTime - previousTimeTime; + // } + // } + long totalTime = 0L; + + //查询用户处理的开始时间 + QueryWrapper beginWrapperTime = new QueryWrapper<>(); + beginWrapperTime.select("create_time","id").eq("business_id", businessId).eq("process_id",processId).eq("user_id", userId).orderByAsc("create_time").last("limit 1"); + DgAuditProcess beginAuditProcess = dgAuditProcessMapper.selectOne(beginWrapperTime); + //如果改流程数据为空直接返回默认值 + if (ObjectUtil.isNull(beginAuditProcess)){ + hashMap.put("countTime", "0天0小时0分钟"); + hashMap.put("endTime", "该用户不统计耗时!"); + return hashMap; } - //查询结束时间 - QueryWrapper wrapperTime = new QueryWrapper<>(); - wrapperTime.eq("business_id", businessId).eq("user_id", userId).orderByDesc("create_time").last("limit 1"); - DgAuditProcess auditProcess = dgAuditProcessMapper.selectOne(wrapperTime); - Date endTime = auditProcess.getCreateTime(); - hashMap.put("countTime", countTime); + Date beginTime = beginAuditProcess.getCreateTime(); + + //查询用户处理的结束时间 + QueryWrapper endWrapperTime = new QueryWrapper<>(); + endWrapperTime.select("create_time","id").eq("business_id", businessId).eq("process_id",processId).eq("user_id", userId).orderByDesc("create_time").last("limit 1"); + DgAuditProcess endAuditProcess = dgAuditProcessMapper.selectOne(endWrapperTime); + Date endTime = endAuditProcess.getCreateTime(); + + //转换成毫秒统计时间差 + long currentTimeTime = endTime.getTime(); + long previousTimeTime = beginTime.getTime(); + //累计耗时,毫秒 + totalTime = currentTimeTime - previousTimeTime; + hashMap.put("countTime", countTime(String.valueOf(totalTime))); hashMap.put("endTime", new SimpleDateFormat("yyyy-MM-dd").format(endTime)); return hashMap; }