个人效率累计耗时优化逻辑

master
chen 4 years ago
parent e3cf9577f6
commit b2decc89a6
  1. 108
      dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/DgEfficiencyServiceImpl.java

@ -581,18 +581,24 @@ public class DgEfficiencyServiceImpl extends ServiceImpl<DgEfficiencyMapper, DgA
efficiencyListResponse.setClientName(po.getName()); efficiencyListResponse.setClientName(po.getName());
efficiencyListResponse.setApplicantId(presenterId); efficiencyListResponse.setApplicantId(presenterId);
efficiencyListResponse.setApplicationDate(new SimpleDateFormat("yyyy-MM-dd").format(createTime)); efficiencyListResponse.setApplicationDate(new SimpleDateFormat("yyyy-MM-dd").format(createTime));
//用户处理过业务,统计耗时 //用户处理过业务,每一个模块统计耗时
QueryWrapper<DgAuditProcess> wrapper = new QueryWrapper<>(); //获取累计耗时,完成时间
wrapper.eq("user_id", currentUser).eq("business_id", po.getBusinessId()); HashMap<String, String> hashMapTime = getTime(po.getBusinessId(), po.getProcessId(), currentUser);
List<DgAuditProcess> auditProcessList = dgAuditProcessMapper.selectList(wrapper); String countTime = hashMapTime.get("countTime");
if (auditProcessList != null && auditProcessList.size() != 0) { String endTime = hashMapTime.get("endTime");
//获取累计耗时,完成时间 efficiencyListResponse.setTimeConsuming(countTime);
HashMap<String, Object> hashMapTime = getTime(po.getBusinessId(), currentUser); efficiencyListResponse.setCompleteTime(endTime);
Object countTime = hashMapTime.get("countTime"); // QueryWrapper<DgAuditProcess> wrapper = new QueryWrapper<>();
Object endTime = hashMapTime.get("endTime"); // wrapper.eq("user_id", currentUser).eq("business_id", po.getBusinessId());
efficiencyListResponse.setTimeConsuming(countTime(String.valueOf(countTime))); // List<DgAuditProcess> auditProcessList = dgAuditProcessMapper.selectList(wrapper);
efficiencyListResponse.setCompleteTime(String.valueOf(endTime)); // if (auditProcessList != null && auditProcessList.size() != 0) {
} // //获取累计耗时,完成时间
// HashMap<String, String> hashMapTime = getTime(po.getBusinessId(), currentUser);
// String countTime = hashMapTime.get("countTime");
// String endTime = hashMapTime.get("endTime");
// efficiencyListResponse.setTimeConsuming(countTime);
// efficiencyListResponse.setCompleteTime(endTime);
// }
efficiencyList.add(efficiencyListResponse); efficiencyList.add(efficiencyListResponse);
}); });
//遍历map,key值为业务id //遍历map,key值为业务id
@ -638,37 +644,55 @@ public class DgEfficiencyServiceImpl extends ServiceImpl<DgEfficiencyMapper, DgA
} }
//根据业务id和用户id统计耗时 //根据业务id和用户id统计耗时
private HashMap<String, Object> getTime(Integer businessId, Integer userId) { private HashMap<String, String> getTime(Integer businessId,Integer processId, Integer userId) {
HashMap<String, Object> hashMap = Maps.newHashMap(); HashMap<String, String> hashMap = Maps.newHashMap();
//根据业务id查询业务流程表 // 这个逻辑有问题(不建议采用),根据业务id和用户查询该用户操作的业务流程信息
QueryWrapper<DgAuditProcess> wrapper = new QueryWrapper<>(); // QueryWrapper<DgAuditProcess> wrapper = new QueryWrapper<>();
wrapper.eq("business_id", businessId).orderByAsc("create_time"); // wrapper.eq("business_id", businessId).eq("user_id",userId).orderByAsc("create_time");
List<DgAuditProcess> auditProcessList = dgAuditProcessMapper.selectList(wrapper); // List<DgAuditProcess> auditProcessList = dgAuditProcessMapper.selectList(wrapper);
long countTime = 0L; // long countTime = 0L;
if (auditProcessList.size() > 1) { // if (auditProcessList.size() > 1) {
//遍历业务流程数据,统计该用户的耗时 // //遍历业务流程数据,统计该用户的耗时
for (int i = 1; i <= auditProcessList.size() - 1; i++) { // for (int i = 1; i <= auditProcessList.size() - 1; i++) {
//从第二条数据开始,获取该数据 // //从第二条数据开始,获取该数据
DgAuditProcess auditProcess = auditProcessList.get(i); // DgAuditProcess currentProcess = auditProcessList.get(i);
//该数据是当前用户处理的 // //获取上一流程的时间节点
if (auditProcess.getUserId().equals(userId)) { // DgAuditProcess previousProcess = auditProcessList.get(i - 1);
//获取上一流程的时间节点 // Date previousTime = previousProcess.getCreateTime();
DgAuditProcess previousProcess = auditProcessList.get(i - 1); // Date currentTime = currentProcess.getCreateTime();
Date previousTime = previousProcess.getCreateTime(); // //转换成毫秒统计时间差
Date currentTime = auditProcess.getCreateTime(); // long currentTimeTime = currentTime.getTime();
long currentTimeTime = currentTime.getTime(); // long previousTimeTime = previousTime.getTime();
long previousTimeTime = previousTime.getTime(); // //累计耗时,毫秒
//累计耗时,毫秒 // countTime = currentTimeTime - previousTimeTime;
countTime = currentTimeTime - previousTimeTime; // }
} // }
} long totalTime = 0L;
//查询用户处理的开始时间
QueryWrapper<DgAuditProcess> 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;
} }
//查询结束时间 Date beginTime = beginAuditProcess.getCreateTime();
QueryWrapper<DgAuditProcess> wrapperTime = new QueryWrapper<>();
wrapperTime.eq("business_id", businessId).eq("user_id", userId).orderByDesc("create_time").last("limit 1"); //查询用户处理的结束时间
DgAuditProcess auditProcess = dgAuditProcessMapper.selectOne(wrapperTime); QueryWrapper<DgAuditProcess> endWrapperTime = new QueryWrapper<>();
Date endTime = auditProcess.getCreateTime(); endWrapperTime.select("create_time","id").eq("business_id", businessId).eq("process_id",processId).eq("user_id", userId).orderByDesc("create_time").last("limit 1");
hashMap.put("countTime", countTime); 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)); hashMap.put("endTime", new SimpleDateFormat("yyyy-MM-dd").format(endTime));
return hashMap; return hashMap;
} }

Loading…
Cancel
Save