Commit 34623b64 authored by chenhao's avatar chenhao

bug 5569

parent aeb3fdd1
...@@ -13,7 +13,8 @@ public enum RuleTypeEnum { ...@@ -13,7 +13,8 @@ public enum RuleTypeEnum {
计划提交("计划提交", "addPlan","auditPage", RuleConstant.WEB, RuleConstant.TASK), 计划提交("计划提交", "addPlan","auditPage", RuleConstant.WEB, RuleConstant.TASK),
计划审核("计划审核", "planAudit", "auditPage", RuleConstant.APP_WEB, RuleConstant.NOTIFY), 计划审核("计划审核", "planAudit", "auditPage", RuleConstant.APP_WEB, RuleConstant.NOTIFY),
计划审核完成("计划审核完成", "planAuditAll", "formulatePage", RuleConstant.APP_WEB, RuleConstant.TASK), 计划审核完成("计划审核完成", "planAuditAll", "formulatePage", RuleConstant.APP_WEB, RuleConstant.TASK),
计划生成("计划生成", "addPlanTask", null, RuleConstant.APP, RuleConstant.NOTIFY), 消息型计划生成("计划生成", "addPlanTask", null, RuleConstant.APP, RuleConstant.NOTIFY),
任务型计划生成("计划生成", "addPlanTask", null, RuleConstant.APP, RuleConstant.TASK),
计划完成("计划完成", "planCompleted", null, RuleConstant.APP_WEB, RuleConstant.NOTIFY), 计划完成("计划完成", "planCompleted", null, RuleConstant.APP_WEB, RuleConstant.NOTIFY),
// 隐患 // 隐患
......
...@@ -75,127 +75,127 @@ import java.util.stream.Collectors; ...@@ -75,127 +75,127 @@ import java.util.stream.Collectors;
@Service("planTaskService") @Service("planTaskService")
public class PlanTaskServiceImpl implements IPlanTaskService { public class PlanTaskServiceImpl implements IPlanTaskService {
private final Logger log = LoggerFactory.getLogger(PlanTaskServiceImpl.class); private final Logger log = LoggerFactory.getLogger(PlanTaskServiceImpl.class);
@Autowired @Autowired
PlanTaskMapper planTaskMapper; PlanTaskMapper planTaskMapper;
@Autowired @Autowired
PlanTaskDetailMapper planTaskDetailMapper; PlanTaskDetailMapper planTaskDetailMapper;
@Autowired @Autowired
PlanMapper planMapper; PlanMapper planMapper;
@Autowired @Autowired
IPlanTaskDao iplanTaskDao; IPlanTaskDao iplanTaskDao;
@Autowired @Autowired
IPlanDao iplanDao; IPlanDao iplanDao;
@Autowired @Autowired
private ICheckDao checkDao; private ICheckDao checkDao;
@Autowired @Autowired
private RemoteSecurityService remoteSecurityService; private RemoteSecurityService remoteSecurityService;
@Autowired @Autowired
private IPlanTaskDetailDao planTaskDetail; private IPlanTaskDetailDao planTaskDetail;
@Autowired @Autowired
IRoutePointDao iRoutePointDao; IRoutePointDao iRoutePointDao;
@Autowired @Autowired
IJobService jobService; IJobService jobService;
@Autowired @Autowired
private ICheckService checkService; private ICheckService checkService;
@Autowired @Autowired
private Business business; private Business business;
@Autowired @Autowired
private EquipFeign equipFeign; private EquipFeign equipFeign;
@Autowired @Autowired
private IPointInputItemDao pointInputItemDao; private IPointInputItemDao pointInputItemDao;
@Autowired @Autowired
private RoutePointItemMapper routePointItemMapper; private RoutePointItemMapper routePointItemMapper;
@Autowired @Autowired
private RulePlanService rulePlanService; private RulePlanService rulePlanService;
@Autowired @Autowired
RedisUtils redisUtils; RedisUtils redisUtils;
@Autowired @Autowired
PointMapper pointMapper; PointMapper pointMapper;
@Autowired @Autowired
private JCSFeignClient jcsFeignClient; private JCSFeignClient jcsFeignClient;
// 防火监督检查负责人角色名称 // 防火监督检查负责人角色名称
@Value("${supervision.person.charger.role:Person_charge_unit_fire_protection_supervision_inspection}") @Value("${supervision.person.charger.role:Person_charge_unit_fire_protection_supervision_inspection}")
private String supervisionPersonChargerRole; private String supervisionPersonChargerRole;
@Override @Override
public Page<HashMap<String, Object>> getPlanTaskInfo(PlanTaskPageParam params) { public Page<HashMap<String, Object>> getPlanTaskInfo(PlanTaskPageParam params) {
long total = planTaskMapper.countPlanTask(params); long total = planTaskMapper.countPlanTask(params);
List<HashMap<String, Object>> content = planTaskMapper.getPlanTaskInfo(params); List<HashMap<String, Object>> content = planTaskMapper.getPlanTaskInfo(params);
return new PageImpl<>(content, params, total); return new PageImpl<>(content, params, total);
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void reGenPlanTask(HashMap<String, Object> param) throws ParseException { public void reGenPlanTask(HashMap<String, Object> param) throws ParseException {
//1.公共参数准备 // 1.公共参数准备
String planId = param.get("planId").toString();//重做的计划编号id String planId = param.get("planId").toString();// 重做的计划编号id
String strBeginDate = param.get("beginDate").toString();//开始日期(yyyy-MM-dd) String strBeginDate = param.get("beginDate").toString();// 开始日期(yyyy-MM-dd)
String strEndDate = param.get("endDate").toString();//结束日期(yyyy-MM-dd) String strEndDate = param.get("endDate").toString();// 结束日期(yyyy-MM-dd)
String flag = param.get("changeFlag").toString();//是否记为合格标记:0-否,1-是 String flag = param.get("changeFlag").toString();// 是否记为合格标记:0-否,1-是
Plan plan = iplanDao.findById(Long.parseLong(planId)).get();// Plan plan = iplanDao.findById(Long.parseLong(planId)).get();//
if (StringUtil.isNotEmpty(plan.getUserId())) { if (StringUtil.isNotEmpty(plan.getUserId())) {
//2.数据必输校验,不满足直接return,不再向下进行 // 2.数据必输校验,不满足直接return,不再向下进行
Boolean fileFlag = PlanTaskUtil.checkMustFile(plan); Boolean fileFlag = PlanTaskUtil.checkMustFile(plan);
if (!fileFlag) { if (!fileFlag) {
return; return;
} }
//3.计算生成数据的日期区间(前10位:yyyy-MM-dd) // 3.计算生成数据的日期区间(前10位:yyyy-MM-dd)
CalDateVo vo = PlanTaskUtil.reGenPlanTaskData(plan, strBeginDate, strEndDate); CalDateVo vo = PlanTaskUtil.reGenPlanTaskData(plan, strBeginDate, strEndDate);
if (null == vo) {//计划未开始,则结束 if (null == vo) {// 计划未开始,则结束
return; return;
} }
if (!vo.getIsGenData()) {// 日期不符合条件直接结束
if (!vo.getIsGenData()) {//日期不符合条件直接结束 return;
return; }
}
// 3.删除planTask表,按照计划id+日期
//3.删除planTask表,按照计划id+日期 deletePlanTaskAndDet(param);
deletePlanTaskAndDet(param);
// 5.执行数据生成(具体时间 + 人员)
//5.执行数据生成(具体时间 + 人员) List<HashMap<String, Object>> list = genAllExeDate(plan, vo, XJConstant.REGEN_FLAG);
List<HashMap<String, Object>> list = genAllExeDate(plan, vo, XJConstant.REGEN_FLAG);
// 6.插入planTask及planTaskDetail
//6.插入planTask及planTaskDetail insertPlanTaskAndDet(list, plan, flag, new Date());
insertPlanTaskAndDet(list, plan, flag, new Date());
// 7.重新统计计划
//7.重新统计计划 if (ObjectUtils.isEmpty(plan.getUserId())) {
if (ObjectUtils.isEmpty(plan.getUserId())) { return;
return; }
} reformStatisticsPlanTask(strBeginDate, strEndDate, plan.getUserId(), plan.getOrgCode());
reformStatisticsPlanTask(strBeginDate, strEndDate, plan.getUserId(), plan.getOrgCode()); }
} }
}
@Override
@Override public void reformStatisticsPlanTask(String strBginDate, String strEndDate, String userId, String orgCode)
public void reformStatisticsPlanTask(String strBginDate, String strEndDate, String userId, String orgCode) throws ParseException { throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date startTime = sdf.parse(strBginDate); Date startTime = sdf.parse(strBginDate);
Date endTime = sdf.parse(strEndDate); Date endTime = sdf.parse(strEndDate);
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTime(startTime); cal.setTime(startTime);
Date currentDate = new Date(); Date currentDate = new Date();
String strCurrentDate = sdf.format(currentDate); String strCurrentDate = sdf.format(currentDate);
long abortTime = endTime.getTime(); long abortTime = endTime.getTime();
if (endTime.getTime() >= sdf.parse(strCurrentDate).getTime()) { if (endTime.getTime() >= sdf.parse(strCurrentDate).getTime()) {
abortTime = sdf.parse(strCurrentDate).getTime(); abortTime = sdf.parse(strCurrentDate).getTime();
} }
String[] ids = userId.split(","); String[] ids = userId.split(",");
// StringBuffer orgCodeBuffer = new StringBuffer(); // StringBuffer orgCodeBuffer = new StringBuffer();
// Map<String,String> deptMap =new HashMap<>(); // Map<String,String> deptMap =new HashMap<>();
// Set<Object> userIds =new HashSet<>(); // Set<Object> userIds =new HashSet<>();
...@@ -222,70 +222,74 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -222,70 +222,74 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
// userIdOrgCodeMap = idOrgCodeList.stream().collect(Collectors.toMap(x-> String.valueOf(x.get( // userIdOrgCodeMap = idOrgCodeList.stream().collect(Collectors.toMap(x-> String.valueOf(x.get(
// "id")), x->x.get("org_code"))); // "id")), x->x.get("org_code")));
// } // }
while (cal.getTime().getTime() <= abortTime) { while (cal.getTime().getTime() <= abortTime) {
String refDate = sdf.format(cal.getTime()); String refDate = sdf.format(cal.getTime());
for (String id : ids) { for (String id : ids) {
if (!ObjectUtils.isEmpty(id)) { if (!ObjectUtils.isEmpty(id)) {
planTaskMapper.reformStatistics(id, refDate, orgCode); planTaskMapper.reformStatistics(id, refDate, orgCode);
// planTaskMapper.reformStatistics(id, refDate, userIdOrgCodeMap.get(id)); // planTaskMapper.reformStatistics(id, refDate, userIdOrgCodeMap.get(id));
} }
} }
cal.add(Calendar.DATE, 1); cal.add(Calendar.DATE, 1);
} }
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void planTaskDet(String[] strArry) { public void planTaskDet(String[] strArry) {
if (strArry.length <= 0) { if (strArry.length <= 0) {
throw new YeeException("删除数据内容不能为空"); throw new YeeException("删除数据内容不能为空");
} }
Set<Long> taskNos = new HashSet<>(); Set<Long> taskNos = new HashSet<>();
for (String id : strArry) { for (String id : strArry) {
PlanTaskDetail planTkDet = planTaskDetail.findById(Long.parseLong(id)).get(); PlanTaskDetail planTkDet = planTaskDetail.findById(Long.parseLong(id)).get();
if (null != planTkDet) { if (null != planTkDet) {
taskNos.add(planTkDet.getTaskNo()); taskNos.add(planTkDet.getTaskNo());
} }
} }
planTaskMapper.planTaskDet(strArry);// 删除数据 planTaskMapper.planTaskDet(strArry);// 删除数据
HashMap<String, Object> param = new HashMap<String, Object>(); HashMap<String, Object> param = new HashMap<String, Object>();
param.put("IDS", new ArrayList<>(taskNos)); param.put("IDS", new ArrayList<>(taskNos));
param.put("FINISH_YES", XJConstant.PLAN_TASK_DET_FINISH_YES); param.put("FINISH_YES", XJConstant.PLAN_TASK_DET_FINISH_YES);
planTaskMapper.updatePlanTaskPtInfo(param);// 更新主表,点数量,完成数量 planTaskMapper.updatePlanTaskPtInfo(param);// 更新主表,点数量,完成数量
} }
@Override @Override
public List<PlanTaskVo> planTaskReport(String toke, String product, String appKey, PlanTaskPageParam param) { public List<PlanTaskVo> planTaskReport(String toke, String product, String appKey, PlanTaskPageParam param) {
List<PlanTaskVo> content = planTaskMapper.getPlanTaskInfoList(param); List<PlanTaskVo> content = planTaskMapper.getPlanTaskInfoList(param);
String userIds = ""; String userIds = "";
String deptIds = ""; String deptIds = "";
Set<String> set = new HashSet<>(); Set<String> set = new HashSet<>();
Set<String> deptIdSet = new HashSet<>(); Set<String> deptIdSet = new HashSet<>();
content.forEach(s -> { content.forEach(s -> {
if (s.getUserName() != null) { if (s.getUserName() != null) {
set.add(s.getUserName()); set.add(s.getUserName());
} }
if (s.getDeptId() > 0) { if (s.getDeptId() > 0) {
deptIdSet.add(s.getDeptId() + ""); deptIdSet.add(s.getDeptId() + "");
} }
}); });
List<String> userList = new ArrayList<>(set); List<String> userList = new ArrayList<>(set);
List<String> deptList = new ArrayList<>(deptIdSet); List<String> deptList = new ArrayList<>(deptIdSet);
Map<String, String> LoginName = new HashMap<>(); Map<String, String> LoginName = new HashMap<>();
Map<String, String> userMap = new HashMap<>(); Map<String, String> userMap = new HashMap<>();
Map<String, String> depMap = new HashMap<>(); Map<String, String> depMap = new HashMap<>();
if (!CollectionUtils.isEmpty(userList)) { if (!CollectionUtils.isEmpty(userList)) {
userIds = String.join(",", userList); userIds = String.join(",", userList);
List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(toke, product, appKey, userIds); List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(toke, product, appKey,
userMap = userModelList.stream().collect(Collectors.toMap(AgencyUserModel::getUserId, AgencyUserModel::getRealName, (k1, k2) -> k2)); userIds);
for (AgencyUserModel agencyUserModel : userModelList) { userMap = userModelList.stream().collect(
LoginName.put(agencyUserModel.getUserId(), agencyUserModel.getMobile() != null ? agencyUserModel.getMobile() : agencyUserModel.getLandlinePhone()); Collectors.toMap(AgencyUserModel::getUserId, AgencyUserModel::getRealName, (k1, k2) -> k2));
} for (AgencyUserModel agencyUserModel : userModelList) {
} LoginName.put(agencyUserModel.getUserId(),
agencyUserModel.getMobile() != null ? agencyUserModel.getMobile()
: agencyUserModel.getLandlinePhone());
}
}
// if(!CollectionUtils.isEmpty(deptList)){ // if(!CollectionUtils.isEmpty(deptList)){
// String dept = String.join(",", deptList); // String dept = String.join(",", deptList);
// List<LinkedHashMap> deptL = remoteSecurityService.listDepartmentByDeptIds(toke, product, appKey,dept); // List<LinkedHashMap> deptL = remoteSecurityService.listDepartmentByDeptIds(toke, product, appKey,dept);
...@@ -301,825 +305,933 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -301,825 +305,933 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
// }); // });
// } // }
// } // }
//新安全 // 新安全
content.forEach(s -> { content.forEach(s -> {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
if (s.getUserDept().indexOf("@") > 0) { if (s.getUserDept().indexOf("@") > 0) {
String[] dept = s.getUserDept().split(","); String[] dept = s.getUserDept().split(",");
Arrays.asList(dept).stream().forEach(x -> { Arrays.asList(dept).stream().forEach(x -> {
String[] deptTemp = x.split("@"); String[] deptTemp = x.split("@");
List<LinkedHashMap> deptL = remoteSecurityService.listDepartmentByDeptIds(toke, product, appKey, deptTemp[1]); List<LinkedHashMap> deptL = remoteSecurityService.listDepartmentByDeptIds(toke, product, appKey,
if (deptL.size() > 0) { deptTemp[1]);
buffer.append(deptL.get(0).get("departmentName")).append(","); if (deptL.size() > 0) {
} else { buffer.append(deptL.get(0).get("departmentName")).append(",");
buffer.append("其他").append(","); } else {
} buffer.append("其他").append(",");
}
});
} else { });
String[] deptTemp = s.getUserDept().split(","); } else {
List<LinkedHashMap> deptL = remoteSecurityService.listDepartmentByDeptIds(toke, product, appKey, deptTemp[1]); String[] deptTemp = s.getUserDept().split(",");
if (deptL.size() > 0) { List<LinkedHashMap> deptL = remoteSecurityService.listDepartmentByDeptIds(toke, product, appKey,
buffer.append(deptL.get(0).get("departmentName")).append(","); deptTemp[1]);
} else { if (deptL.size() > 0) {
buffer.append("其他").append(","); buffer.append(deptL.get(0).get("departmentName")).append(",");
} } else {
buffer.append("其他").append(",");
} }
s.setDeptName(buffer.substring(0, buffer.length() - 1));
}); }
Map<String, String> finalUserMap = userMap; s.setDeptName(buffer.substring(0, buffer.length() - 1));
content.forEach(c -> { });
StringBuilder userNames = new StringBuilder(""); Map<String, String> finalUserMap = userMap;
List<String> userIdsList = Arrays.asList(c.getUserName().split(",")); content.forEach(c -> {
for (String userId : userIdsList) { StringBuilder userNames = new StringBuilder("");
userNames.append(finalUserMap.get(userId)); List<String> userIdsList = Arrays.asList(c.getUserName().split(","));
userNames.append(","); for (String userId : userIdsList) {
} userNames.append(finalUserMap.get(userId));
c.setUserName(userNames.toString()); userNames.append(",");
}); }
c.setUserName(userNames.toString());
});
return content;
} return content;
}
/**
* 自动任务执行 /**
*/ * 自动任务执行
@Override */
@Transactional(rollbackFor = Exception.class) @Override
public void taskExecution(String runDate) { @Transactional(rollbackFor = Exception.class)
//1.扫描plan表查询,需要生成执行数据的任务信息,无则return public void taskExecution(String runDate) {
Date now = new Date();//今天 // 1.扫描plan表查询,需要生成执行数据的任务信息,无则return
if (runDate != null) {//上送则已上送的为准 Date now = new Date();// 今天
now = DateUtil.str2Date(runDate, "yyyyMMdd"); if (runDate != null) {// 上送则已上送的为准
} now = DateUtil.str2Date(runDate, "yyyyMMdd");
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); }
String strDate = df.format(now); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String tomorrow = DateUtil.getIntervalDateStr(now, 1, "yyyy-MM-dd");//下一天 String strDate = df.format(now);
// 根据计划状态5,6和next_gen_date查询需要生成任务的计划 String tomorrow = DateUtil.getIntervalDateStr(now, 1, "yyyy-MM-dd");// 下一天
List<Plan> planList = iplanDao.queryScheduledPlan(strDate, String.valueOf(PlanStatusEnum.EXAMINE_DEVELOPED.getValue()), String.valueOf(PlanStatusEnum.IN_EXECUTION.getValue())); // 根据计划状态5,6和next_gen_date查询需要生成任务的计划
if (planList == null || planList.size() <= 0) { List<Plan> planList = iplanDao.queryScheduledPlan(strDate,
log.info(strDate + " " + " 暂无待生成执行数据的计划"); String.valueOf(PlanStatusEnum.EXAMINE_DEVELOPED.getValue()),
return; String.valueOf(PlanStatusEnum.IN_EXECUTION.getValue()));
} if (planList == null || planList.size() <= 0) {
//2.循环遍历执行 log.info(strDate + " " + " 暂无待生成执行数据的计划");
HashMap<String, Object> paramMap = new HashMap<String, Object>(); return;
for (Plan plan : planList) { }
if (StringUtils.isEmpty(plan.getUserId())) // 2.循环遍历执行
continue; HashMap<String, Object> paramMap = new HashMap<String, Object>();
paramMap.clear(); for (Plan plan : planList) {
paramMap.put("id", plan.getId()); if (StringUtils.isEmpty(plan.getUserId()))
//2.1计划数据合法性校验 continue;
Boolean fileFlag = PlanTaskUtil.checkMustFile(plan); paramMap.clear();
if (!fileFlag) { paramMap.put("id", plan.getId());
paramMap.put("next_gen_date", tomorrow); // 2.1计划数据合法性校验
planMapper.updPlanStatusOrGenDate(paramMap);//更新为明天 Boolean fileFlag = PlanTaskUtil.checkMustFile(plan);
continue; if (!fileFlag) {
} paramMap.put("next_gen_date", tomorrow);
//2.2.计算生成数据的日期区间 planMapper.updPlanStatusOrGenDate(paramMap);// 更新为明天
CalDateVo vo = PlanTaskUtil.reGenPlanTaskData(plan, tomorrow, tomorrow); continue;
}
//计划未开始,则更新生成时间为明天 // 2.2.计算生成数据的日期区间
if (null == vo) { CalDateVo vo = PlanTaskUtil.reGenPlanTaskData(plan, tomorrow, tomorrow);
paramMap.put("next_gen_date", tomorrow);
planMapper.updPlanStatusOrGenDate(paramMap);//更新为明天 // 计划未开始,则更新生成时间为明天
continue; if (null == vo) {
} paramMap.put("next_gen_date", tomorrow);
//计划已过期,则更新status = 7,已完成 planMapper.updPlanStatusOrGenDate(paramMap);// 更新为明天
if (!vo.getIsGenData()) { continue;
paramMap.put("status", PlanStatusEnum.COMPLETED.getValue()); }
planMapper.updPlanStatusOrGenDate(paramMap); // 计划已过期,则更新status = 7,已完成
continue; if (!vo.getIsGenData()) {
} paramMap.put("status", PlanStatusEnum.COMPLETED.getValue());
planMapper.updPlanStatusOrGenDate(paramMap);
//2.3.执行数据生成(具体时间 + 人员) continue;
List<HashMap<String, Object>> list = genAllExeDate(plan, vo, XJConstant.SCHED_FLAG); }
if (XJConstant.UPD_PLAN_GEN_DATE.equals(vo.getUpdFlag())) { // 2.3.执行数据生成(具体时间 + 人员)
paramMap.put("next_gen_date", tomorrow); List<HashMap<String, Object>> list = genAllExeDate(plan, vo, XJConstant.SCHED_FLAG);
planMapper.updPlanStatusOrGenDate(paramMap);//更新为明天
continue; if (XJConstant.UPD_PLAN_GEN_DATE.equals(vo.getUpdFlag())) {
} else if (XJConstant.UPD_PLAN_STATUS.equals(vo.getUpdFlag())) { paramMap.put("next_gen_date", tomorrow);
paramMap.put("status", XJConstant.PLAN_STATUS_STOP); planMapper.updPlanStatusOrGenDate(paramMap);// 更新为明天
planMapper.updPlanStatusOrGenDate(paramMap);//更新status = 1,停用 continue;
continue; } else if (XJConstant.UPD_PLAN_STATUS.equals(vo.getUpdFlag())) {
} paramMap.put("status", XJConstant.PLAN_STATUS_STOP);
planMapper.updPlanStatusOrGenDate(paramMap);// 更新status = 1,停用
//2.4.删除今天可能重做生成的数据(计划重做后进行了计划的编辑) continue;
if (iplanTaskDao.findById(plan.getPlanTaskId()) != null && plan.getFirstFlag() == XJConstant.PLAN_FIRST_STATUS_YES) }
if (iplanTaskDao.existsById(plan.getPlanTaskId())) {
iplanTaskDao.deleteById(plan.getPlanTaskId()); // 2.4.删除今天可能重做生成的数据(计划重做后进行了计划的编辑)
} if (iplanTaskDao.findById(plan.getPlanTaskId()) != null
&& plan.getFirstFlag() == XJConstant.PLAN_FIRST_STATUS_YES)
//2.5.插入planTask及planTaskDetail if (iplanTaskDao.existsById(plan.getPlanTaskId())) {
insertPlanTaskAndDet(list, plan, XJConstant.SCHED_FLAG, now); iplanTaskDao.deleteById(plan.getPlanTaskId());
} }
}
// 2.5.插入planTask及planTaskDetail
/** insertPlanTaskAndDet(list, plan, XJConstant.SCHED_FLAG, now);
* 删除plantask及det }
* }
* @param param
*/ /*
public void deletePlanTaskAndDet(HashMap<String, Object> param) { * 用于隐患导入之后的任务生成,不能使用时间获取所有的任务,而是当前时间的任务
param.put("beginDate", param.get("beginDate") + " " + "00:00:00"); *
param.put("endDate", param.get("endDate") + " " + "23:59:59"); */
List<Long> ids = planTaskMapper.getGenPlanTask(param); @Override
for (long id : ids) { @Transactional(rollbackFor = Exception.class)
iplanTaskDao.deleteById(id); public void taskExecutionImportPlan(List<Plan> planList) {
; Date now = new Date();// 今天
} SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String strDate = df.format(now);
} String tomorrow = DateUtil.getIntervalDateStr(now, 1, "yyyy-MM-dd");// 下一天
if (planList == null || planList.size() <= 0) {
/** log.info(" 暂无待生成执行数据的计划");
* 执行数据生成 return;
* }
* @param plan // 2.循环遍历执行
* @param vo HashMap<String, Object> paramMap = new HashMap<String, Object>();
* @return for (Plan plan : planList) {
*/ if (StringUtils.isEmpty(plan.getUserId()))
public List<HashMap<String, Object>> genAllExeDate(Plan plan, CalDateVo vo, String flag) { continue;
//1.生成前8位日期(yyyy-MM-dd) paramMap.clear();
List<HashMap<String, Date>> list = PlanTaskUtil.genExeDate(plan, vo, flag); paramMap.put("id", plan.getId());
if (list == null || list.size() <= 0) { // 2.1计划数据合法性校验
vo.setUpdFlag(XJConstant.UPD_PLAN_GEN_DATE); Boolean fileFlag = PlanTaskUtil.checkMustFile(plan);
return null; if (!fileFlag) {
} paramMap.put("next_gen_date", tomorrow);
//2.生成完整时间(yyyy-MM-dd HH:mm:ss) planMapper.updPlanStatusOrGenDate(paramMap);// 更新为明天
List<HashMap<String, Object>> timeList = PlanTaskUtil.genWholeExeDate(list, plan); continue;
if (timeList == null || timeList.size() <= 0) { }
vo.setUpdFlag(XJConstant.UPD_PLAN_STATUS); // 2.2.计算生成数据的日期区间
} CalDateVo vo = PlanTaskUtil.reGenPlanTaskData(plan, tomorrow, tomorrow);
//3.生成含有人员信息的日期执行数据
return PlanTaskUtil.genWholeExeData(timeList, plan); // 计划未开始,则更新生成时间为明天
} if (null == vo) {
paramMap.put("next_gen_date", tomorrow);
planMapper.updPlanStatusOrGenDate(paramMap);// 更新为明天
/** continue;
* plantask及det入库 }
* // 计划已过期,则更新status = 7,已完成
* @param list if (!vo.getIsGenData()) {
* @param plan paramMap.put("status", PlanStatusEnum.COMPLETED.getValue());
* @param flag 是否初始状态0-初始 1-非初始 planMapper.updPlanStatusOrGenDate(paramMap);
*/ continue;
public void insertPlanTaskAndDet(List<HashMap<String, Object>> list, Plan plan, String flag, Date now) { }
if (list == null || list.size() <= 0) {
HashMap<String, Object> paramMap = new HashMap<String, Object>(); // 2.3.执行数据生成(具体时间 + 人员)
paramMap.put("id", plan.getId()); List<HashMap<String, Object>> list = genAllExeDate(plan, vo, XJConstant.SCHED_FLAG);
paramMap.put("next_gen_date", DateUtil.formatDatrToStr(now, "yyyy-MM-dd"));
// 更新下次任务生成日期 if (XJConstant.UPD_PLAN_GEN_DATE.equals(vo.getUpdFlag())) {
planMapper.updPlanStatusOrGenDate(paramMap); paramMap.put("next_gen_date", tomorrow);
} planMapper.updPlanStatusOrGenDate(paramMap);// 更新为明天
try { continue;
// 是否固定日期 } else if (XJConstant.UPD_PLAN_STATUS.equals(vo.getUpdFlag())) {
String isFixDate = plan.getIsFixedDate(); paramMap.put("status", XJConstant.PLAN_STATUS_STOP);
List<Long> pointIdList = iRoutePointDao.queryRoutePointIds(plan.getRouteId()); planMapper.updPlanStatusOrGenDate(paramMap);// 更新status = 1,停用
int pointNum = iRoutePointDao.countRoutePoint(plan.getRouteId()); continue;
long batchNo = now.getTime(); }
for (int i = 0; i < list.size(); i++) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 2.4.删除今天可能重做生成的数据(计划重做后进行了计划的编辑)
String startTime = list.get(i).get("BEGIN_TIME").toString(); if (iplanTaskDao.findById(plan.getPlanTaskId()) != null
String endTime = list.get(i).get("END_TIME").toString(); && plan.getFirstFlag() == XJConstant.PLAN_FIRST_STATUS_YES)
String userId = list.get(i).get("USER_ID") == null ? "-1" : list.get(i).get("USER_ID").toString(); if (iplanTaskDao.existsById(plan.getPlanTaskId())) {
String userName = list.get(i).get("USER_NAME") == null ? "" : list.get(i).get("USER_NAME").toString(); iplanTaskDao.deleteById(plan.getPlanTaskId());
PlanTask planTask = iplanTaskDao.findByUserIdAndBeginTimeAndEndTimeAndPlanIdAndRouteId(userId, startTime, endTime, plan.getId(), plan.getRouteId()); }
if (planTask != null) {
continue; // 2.5.插入planTask及planTaskDetail
} insertPlanTaskAndDet(list, plan, XJConstant.SCHED_FLAG, now);
planTask = new PlanTask(); }
planTask.setOrgCode(plan.getOrgCode()); }
planTask.setUserName(userName);
planTask.setPlanId(plan.getId()); /**
planTask.setBatchNo(batchNo); * 删除plantask及det
planTask.setRouteId(plan.getRouteId()); *
planTask.setInOrder(plan.getInOrder()); * @param param
planTask.setUserId(userId); */
planTask.setPointNum(pointNum); public void deletePlanTaskAndDet(HashMap<String, Object> param) {
if (XJConstant.FIX_DATE_NO.equals(isFixDate)) { param.put("beginDate", param.get("beginDate") + " " + "00:00:00");
if (sdf.parse(startTime).getTime() <= now.getTime() && sdf.parse(endTime).getTime() >= now.getTime()) { param.put("endDate", param.get("endDate") + " " + "23:59:59");
planTask.setFinishStatus(XJConstant.TASK_STATUS_DEAL); List<Long> ids = planTaskMapper.getGenPlanTask(param);
planTask.setFinishNum(0); for (long id : ids) {
} else { iplanTaskDao.deleteById(id);
if (sdf.parse(endTime).getTime() < now.getTime()) { ;
planTask.setFinishStatus(XJConstant.TASK_STATUS_TIMEOUT); }
planTask.setFinishNum(0);
} }
}
} else { /**
if (sdf.parse(startTime).getTime() <= now.getTime() && sdf.parse(endTime).getTime() >= now.getTime()) { * 执行数据生成
planTask.setFinishStatus(XJConstant.TASK_STATUS_DEAL); *
planTask.setFinishNum(0); * @param plan
} * @param vo
if (sdf.parse(endTime).getTime() < now.getTime()) { * @return
planTask.setFinishStatus(XJConstant.TASK_STATUS_TIMEOUT); */
planTask.setFinishNum(0); public List<HashMap<String, Object>> genAllExeDate(Plan plan, CalDateVo vo, String flag) {
} // 1.生成前8位日期(yyyy-MM-dd)
} List<HashMap<String, Date>> list = PlanTaskUtil.genExeDate(plan, vo, flag);
if (XJConstant.CHECK_CHANGE_YES.equals(flag)) { if (list == null || list.size() <= 0) {
planTask.setFinishStatus(XJConstant.TASK_STATUS_FINISH); vo.setUpdFlag(XJConstant.UPD_PLAN_GEN_DATE);
planTask.setFinishNum(pointNum); return null;
} }
if (XJConstant.FIX_DATE_YES.equals(isFixDate) || (XJConstant.FIX_DATE_NO.equals(isFixDate) // 2.生成完整时间(yyyy-MM-dd HH:mm:ss)
&& XJConstant.PLAN_TYPE_DAY.equals(plan.getPlanType()))) { List<HashMap<String, Object>> timeList = PlanTaskUtil.genWholeExeDate(list, plan);
planTask.setCheckDate(list.get(i).get("BEGIN_TIME").toString().substring(0, 10)); if (timeList == null || timeList.size() <= 0) {
} vo.setUpdFlag(XJConstant.UPD_PLAN_STATUS);
planTask.setBeginTime(startTime); }
planTask.setEndTime(endTime); // 3.生成含有人员信息的日期执行数据
// 1.保存执行数据主表 return PlanTaskUtil.genWholeExeData(timeList, plan);
iplanTaskDao.saveAndFlush(planTask); }
long planId = planTask.getId();
for (Number pointId : pointIdList) { /**
PlanTaskDetail planTaskDetailInstance = new PlanTaskDetail(); * plantask及det入库
planTaskDetailInstance.setPointId(pointId.longValue()); *
planTaskDetailInstance.setTaskNo(planId); * @param list
planTaskDetailInstance.setStatus("0"); * @param plan
if (XJConstant.TASK_STATUS_TIMEOUT == planTask.getFinishStatus()) { * @param flag 是否初始状态0-初始 1-非初始
planTaskDetailInstance.setIsFinish(Integer.parseInt(XJConstant.PLAN_TASK_DET_FINISH_OUT)); */
planTaskDetailInstance.setStatus("3"); public void insertPlanTaskAndDet(List<HashMap<String, Object>> list, Plan plan, String flag, Date now) {
} if (list == null || list.size() <= 0) {
if (XJConstant.CHECK_CHANGE_YES.equals(flag)) { HashMap<String, Object> paramMap = new HashMap<String, Object>();
planTaskDetailInstance.setIsFinish(Integer.parseInt(XJConstant.PLAN_TASK_DET_FINISH_YES)); paramMap.put("id", plan.getId());
planTaskDetailInstance.setStatus("1"); paramMap.put("next_gen_date", DateUtil.formatDatrToStr(now, "yyyy-MM-dd"));
} // 更新下次任务生成日期
planMapper.updPlanStatusOrGenDate(paramMap);
// 查询点下检查项的个数 }
try {
// 是否固定日期
String isFixDate = plan.getIsFixedDate();
List<Long> pointIdList = iRoutePointDao.queryRoutePointIds(plan.getRouteId());
int pointNum = iRoutePointDao.countRoutePoint(plan.getRouteId());
long batchNo = now.getTime();
for (int i = 0; i < list.size(); i++) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startTime = list.get(i).get("BEGIN_TIME").toString();
String endTime = list.get(i).get("END_TIME").toString();
String userId = list.get(i).get("USER_ID") == null ? "-1" : list.get(i).get("USER_ID").toString();
String userName = list.get(i).get("USER_NAME") == null ? "" : list.get(i).get("USER_NAME").toString();
PlanTask planTask = iplanTaskDao.findByUserIdAndBeginTimeAndEndTimeAndPlanIdAndRouteId(userId,
startTime, endTime, plan.getId(), plan.getRouteId());
if (planTask != null) {
continue;
}
planTask = new PlanTask();
planTask.setOrgCode(plan.getOrgCode());
planTask.setUserName(userName);
planTask.setPlanId(plan.getId());
planTask.setBatchNo(batchNo);
planTask.setRouteId(plan.getRouteId());
planTask.setInOrder(plan.getInOrder());
planTask.setUserId(userId);
planTask.setPointNum(pointNum);
if (XJConstant.FIX_DATE_NO.equals(isFixDate)) {
if (sdf.parse(startTime).getTime() <= now.getTime()
&& sdf.parse(endTime).getTime() >= now.getTime()) {
planTask.setFinishStatus(XJConstant.TASK_STATUS_DEAL);
planTask.setFinishNum(0);
} else {
if (sdf.parse(endTime).getTime() < now.getTime()) {
planTask.setFinishStatus(XJConstant.TASK_STATUS_TIMEOUT);
planTask.setFinishNum(0);
}
}
} else {
if (sdf.parse(startTime).getTime() <= now.getTime()
&& sdf.parse(endTime).getTime() >= now.getTime()) {
planTask.setFinishStatus(XJConstant.TASK_STATUS_DEAL);
planTask.setFinishNum(0);
}
if (sdf.parse(endTime).getTime() < now.getTime()) {
planTask.setFinishStatus(XJConstant.TASK_STATUS_TIMEOUT);
planTask.setFinishNum(0);
}
}
if (XJConstant.CHECK_CHANGE_YES.equals(flag)) {
planTask.setFinishStatus(XJConstant.TASK_STATUS_FINISH);
planTask.setFinishNum(pointNum);
}
if (XJConstant.FIX_DATE_YES.equals(isFixDate) || (XJConstant.FIX_DATE_NO.equals(isFixDate)
&& XJConstant.PLAN_TYPE_DAY.equals(plan.getPlanType()))) {
planTask.setCheckDate(list.get(i).get("BEGIN_TIME").toString().substring(0, 10));
}
planTask.setBeginTime(startTime);
planTask.setEndTime(endTime);
// 1.保存执行数据主表
iplanTaskDao.saveAndFlush(planTask);
long planId = planTask.getId();
for (Number pointId : pointIdList) {
PlanTaskDetail planTaskDetailInstance = new PlanTaskDetail();
planTaskDetailInstance.setPointId(pointId.longValue());
planTaskDetailInstance.setTaskNo(planId);
planTaskDetailInstance.setStatus("0");
if (XJConstant.TASK_STATUS_TIMEOUT == planTask.getFinishStatus()) {
planTaskDetailInstance.setIsFinish(Integer.parseInt(XJConstant.PLAN_TASK_DET_FINISH_OUT));
planTaskDetailInstance.setStatus("3");
}
if (XJConstant.CHECK_CHANGE_YES.equals(flag)) {
planTaskDetailInstance.setIsFinish(Integer.parseInt(XJConstant.PLAN_TASK_DET_FINISH_YES));
planTaskDetailInstance.setStatus("1");
}
// 查询点下检查项的个数
// List<PointInputItem> pointInputItemByPointId = pointInputItemDao.getPointInputItemByPointId(pointId.longValue()); // List<PointInputItem> pointInputItemByPointId = pointInputItemDao.getPointInputItemByPointId(pointId.longValue());
Long routeId = plan.getRouteId(); Long routeId = plan.getRouteId();
int itemCount = routePointItemMapper.getPointItemCount(routeId, pointId.longValue()); int itemCount = routePointItemMapper.getPointItemCount(routeId, pointId.longValue());
planTaskDetailInstance.setItemNum(itemCount); planTaskDetailInstance.setItemNum(itemCount);
// 2.保存执行数据明细表 // 2.保存执行数据明细表
planTaskDetail.saveAndFlush(planTaskDetailInstance); planTaskDetail.saveAndFlush(planTaskDetailInstance);
} }
sendMessage(plan); sendMessage(plan);
// 定时任务监控 // 定时任务监控
jobService.planTaskAddJob(planTask); jobService.planTaskAddJob(planTask);
} }
// 3.如果为自动任务调用,则更新id,如果重做或且下次时间大于等于明天,则更新planTaskId到plan表 // 3.如果为自动任务调用,则更新id,如果重做或且下次时间大于等于明天,则更新planTaskId到plan表
Date genDate = DateUtil.str2Date(list.get(list.size() - 1).get("NEXT_GEN_DATE").toString(), "yyyy-MM-dd");//下次生成日期 Date genDate = DateUtil.str2Date(list.get(list.size() - 1).get("NEXT_GEN_DATE").toString(), "yyyy-MM-dd");// 下次生成日期
//明天 // 明天
Date tomorrow = DateUtil.getIntervalDate(now, 1); Date tomorrow = DateUtil.getIntervalDate(now, 1);
String strGenDate = list.get(list.size() - 1).get("NEXT_GEN_DATE").toString().substring(0, 10); String strGenDate = list.get(list.size() - 1).get("NEXT_GEN_DATE").toString().substring(0, 10);
HashMap<String, Object> paramMap = new HashMap<String, Object>(); HashMap<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("id", plan.getId()); paramMap.put("id", plan.getId());
paramMap.put("next_gen_date", strGenDate); paramMap.put("next_gen_date", strGenDate);
if (XJConstant.SCHED_FLAG.equals(flag)) { if (XJConstant.SCHED_FLAG.equals(flag)) {
paramMap.put("plan_task_id", 0);//修改为初始值 paramMap.put("plan_task_id", 0);// 修改为初始值
paramMap.put("first_flag", XJConstant.PLAN_FIRST_STATUS_NO); paramMap.put("first_flag", XJConstant.PLAN_FIRST_STATUS_NO);
} else if (!XJConstant.SCHED_FLAG.equals(flag) && (genDate.getTime() - tomorrow.getTime() >= 0) && XJConstant.FIX_DATE_NO.equals(plan.getIsFixedDate())) {//更新日期及plantaskId到plan表 } else if (!XJConstant.SCHED_FLAG.equals(flag) && (genDate.getTime() - tomorrow.getTime() >= 0)
long planTaskId = iplanTaskDao.findMaxIdByBatchNo(batchNo); && XJConstant.FIX_DATE_NO.equals(plan.getIsFixedDate())) {// 更新日期及plantaskId到plan表
paramMap.put("plan_task_id", planTaskId);// 更新新的任务id到plan long planTaskId = iplanTaskDao.findMaxIdByBatchNo(batchNo);
paramMap.put("first_flag", XJConstant.PLAN_FIRST_STATUS_NO); paramMap.put("plan_task_id", planTaskId);// 更新新的任务id到plan
} paramMap.put("first_flag", XJConstant.PLAN_FIRST_STATUS_NO);
if (DateUtil.str2Date(strGenDate, "yyyy-MM-dd").getTime() - now.getTime() < 0 || org.apache.commons.lang.StringUtils.isBlank(strGenDate)) { }
paramMap.put("next_gen_date", DateUtil.formatDatrToStr(now, "yyyy-MM-dd")); if (DateUtil.str2Date(strGenDate, "yyyy-MM-dd").getTime() - now.getTime() < 0
} || org.apache.commons.lang.StringUtils.isBlank(strGenDate)) {
planMapper.updPlanStatusOrGenDate(paramMap);// 更新下次任务生成日期 paramMap.put("next_gen_date", DateUtil.formatDatrToStr(now, "yyyy-MM-dd"));
}
} catch (Exception e) { planMapper.updPlanStatusOrGenDate(paramMap);// 更新下次任务生成日期
log.error(e.getMessage(), e);
} } catch (Exception e) {
} log.error(e.getMessage(), e);
}
public void sendMessage(Plan plan) throws Exception { }
// 查询检查对象对应防火监督负责人id
List<String> extraUserIds = Lists.newArrayList(); public void sendMessage(Plan plan) throws Exception {
List<Point> pointList = pointMapper.getPointByPlanId(String.valueOf(plan.getId())); // 查询检查对象对应防火监督负责人id
if (!ValidationUtil.isEmpty(pointList)) { List<String> extraUserIds = Lists.newArrayList();
List<String> originalIdList = Lists.transform(pointList, Point::getOriginalId); List<Point> pointList = pointMapper.getPointByPlanId(String.valueOf(plan.getId()));
List<OrgUsrFormDto> personList = if (!ValidationUtil.isEmpty(pointList)) {
jcsFeignClient.getPersonListByCompanyIdList(Joiner.on(",").join(originalIdList)).getResult(); List<String> originalIdList = Lists.transform(pointList, Point::getOriginalId);
List<String> personIdList = Lists.transform(personList, OrgUsrFormDto::getAmosOrgId); List<OrgUsrFormDto> personList = jcsFeignClient
List<RoleModel> roleList = .getPersonListByCompanyIdList(Joiner.on(",").join(originalIdList)).getResult();
Privilege.roleClient.queryRoleList(supervisionPersonChargerRole, null).getResult(); List<String> personIdList = Lists.transform(personList, OrgUsrFormDto::getAmosOrgId);
if (!ValidationUtil.isEmpty(roleList)) { List<RoleModel> roleList = Privilege.roleClient.queryRoleList(supervisionPersonChargerRole, null)
List<AgencyUserModel> agencyUserModelList = Privilege.agencyUserClient.queryByRoleId( .getResult();
String.valueOf(roleList.get(0).getSequenceNbr()), null).getResult(); if (!ValidationUtil.isEmpty(roleList)) {
if (!ValidationUtil.isEmpty(agencyUserModelList)) { List<AgencyUserModel> agencyUserModelList = Privilege.agencyUserClient
agencyUserModelList.forEach(userModel -> { .queryByRoleId(String.valueOf(roleList.get(0).getSequenceNbr()), null).getResult();
if (personIdList.contains(userModel.getUserId())) { if (!ValidationUtil.isEmpty(agencyUserModelList)) {
extraUserIds.add(userModel.getUserId()); agencyUserModelList.forEach(userModel -> {
} if (personIdList.contains(userModel.getUserId())) {
}); extraUserIds.add(userModel.getUserId());
} }
} });
} }
log.info(String.format("计划对象:%s", JSON.toJSON(plan))); }
// 规则推送消息 }
rulePlanService.addPlanRule(plan, null, RuleTypeEnum.计划生成, extraUserIds);//根据bug4150 将此处的计划生成的枚举值变成了消息,既TASK -> NOTIFY log.info(String.format("计划对象:%s", JSON.toJSON(plan)));
} // 规则推送消息
rulePlanService.addPlanRule(plan, null, RuleTypeEnum.消息型计划生成, extraUserIds);// 根据bug4150 将此处的计划生成的枚举值变成了消息,既TASK ->
@Override // NOTIFY
public List<PlanTask> getPlanTaskByRouteId(Long routeId) { String userIdString = plan.getUserId();
List<PlanTask> planTaskList = planTaskMapper.getPlanTaskByRouteId(routeId); if (org.apache.commons.lang3.StringUtils.isNotBlank(userIdString)) {
return planTaskList; String[] userIdArr = userIdString.split(",");
} List<String> userIdList = Arrays.asList(userIdArr);
// 规则推送消息
@Override rulePlanService.addPlanRule(plan, null, RuleTypeEnum.任务型计划生成, userIdList);
public void disablePlanTask(Long[] planTaskIds) { // 根据bug5569
// planTask表中status字段置为1 }
for (long planTaskId : planTaskIds) { }
List<PlanTask> planTaskList = getPlanTaskByRouteId(planTaskId);
for (PlanTask planTask : planTaskList) { @Override
planTask.setStatus((byte) 1); public List<PlanTask> getPlanTaskByRouteId(Long routeId) {
iplanTaskDao.save(planTask); List<PlanTask> planTaskList = planTaskMapper.getPlanTaskByRouteId(routeId);
} return planTaskList;
} }
}
@Override
@Override public void disablePlanTask(Long[] planTaskIds) {
public List getPlanTaskInfo(HashMap<String, Object> param) { // planTask表中status字段置为1
return planTaskMapper.getPlanTaskByPointId(param); for (long planTaskId : planTaskIds) {
} List<PlanTask> planTaskList = getPlanTaskByRouteId(planTaskId);
for (PlanTask planTask : planTaskList) {
@Override planTask.setStatus((byte) 1);
public Map findPlanTaskByTaskIdAndPointId(long plantaskId, long pointId) { iplanTaskDao.save(planTask);
return planTaskDetailMapper.findPlanTaskByTaskIdAndPointId(plantaskId, pointId); }
} }
}
@Override
public Page<HashMap<String, Object>> getPlanTasks(HashMap<String, Object> params, CommonPageable pageParam) { @Override
List<HashMap<String, Object>> content = Lists.newArrayList(); public List getPlanTaskInfo(HashMap<String, Object> param) {
ReginParams reginParam = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId() return planTaskMapper.getPlanTaskByPointId(param);
, RequestContext.getToken())).toString(), ReginParams.class); }
params.put("loginUserId", reginParam.getPersonIdentity().getPersonSeq());
long total = planTaskMapper.getPlanTasksCount(params); @Override
if (total == 0) { public Map findPlanTaskByTaskIdAndPointId(long plantaskId, long pointId) {
return new PageImpl<>(content, pageParam, total); return planTaskDetailMapper.findPlanTaskByTaskIdAndPointId(plantaskId, pointId);
} }
params.put("offset", pageParam.getOffset());
params.put("pageSize", pageParam.getPageSize()); @Override
content = planTaskMapper.getPlanTasks(params); public Page<HashMap<String, Object>> getPlanTasks(HashMap<String, Object> params, CommonPageable pageParam) {
content.forEach(c -> { List<HashMap<String, Object>> content = Lists.newArrayList();
if (c.containsKey("finishStatus")) { ReginParams reginParam = JSON.parseObject(redisUtils
String finishStatusDesc = PlanTaskFinishStatusEnum.getName(Integer.parseInt(c.get("finishStatus").toString())); .get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(),
c.put("finishStatusDesc", finishStatusDesc); ReginParams.class);
} params.put("loginUserId", reginParam.getPersonIdentity().getPersonSeq());
}); long total = planTaskMapper.getPlanTasksCount(params);
return new PageImpl<>(content, pageParam, total); if (total == 0) {
} return new PageImpl<>(content, pageParam, total);
}
@Override params.put("offset", pageParam.getOffset());
public int countWaitingTaskByUser(String userId) { params.put("pageSize", pageParam.getPageSize());
return planTaskMapper.countWaitingTaskByUser(userId); content = planTaskMapper.getPlanTasks(params);
} content.forEach(c -> {
if (c.containsKey("finishStatus")) {
@Override String finishStatusDesc = PlanTaskFinishStatusEnum
public Map queryPlanTaskById(Long planTaskId) { .getName(Integer.parseInt(c.get("finishStatus").toString()));
Map map = new HashMap(); c.put("finishStatusDesc", finishStatusDesc);
map = planTaskMapper.queryPlanTaskById(planTaskId); }
if (map.containsKey("finishStatus")) { });
String finishStatusDesc = PlanTaskFinishStatusEnum.getName(Integer.parseInt(map.get("finishStatus").toString())); return new PageImpl<>(content, pageParam, total);
map.put("finishStatusDesc", finishStatusDesc); }
}
return map; @Override
} public int countWaitingTaskByUser(String userId) {
return planTaskMapper.countWaitingTaskByUser(userId);
@Override }
public Page<Map<String, Object>> getPlanTaskPoints(HashMap<String, Object> params, CommonPageable pageable) {
List<Map<String, Object>> content = Lists.newArrayList(); @Override
long total = planTaskMapper.getPlanTaskPointsCount(params); public Map queryPlanTaskById(Long planTaskId) {
if (total == 0) { Map map = new HashMap();
return new PageImpl<>(content, pageable, total); map = planTaskMapper.queryPlanTaskById(planTaskId);
} if (map.containsKey("finishStatus")) {
params.put("offset", pageable.getOffset()); String finishStatusDesc = PlanTaskFinishStatusEnum
params.put("pageSize", pageable.getPageSize()); .getName(Integer.parseInt(map.get("finishStatus").toString()));
List<Map<String, Object>> result = planTaskMapper.getPlanTaskPoints(params); map.put("finishStatusDesc", finishStatusDesc);
result.forEach(r -> { }
if (r.containsKey("finish")) { return map;
String isFinishDesc = PlanTaskDetailIsFinishEnum.getName(Integer.parseInt(r.get("finish").toString())); }
r.put("isFinishDesc", isFinishDesc);
} @Override
}); public Page<Map<String, Object>> getPlanTaskPoints(HashMap<String, Object> params, CommonPageable pageable) {
return new PageImpl<>(result, pageable, total); List<Map<String, Object>> content = Lists.newArrayList();
long total = planTaskMapper.getPlanTaskPointsCount(params);
if (total == 0) {
return new PageImpl<>(content, pageable, total);
}
params.put("offset", pageable.getOffset());
params.put("pageSize", pageable.getPageSize());
List<Map<String, Object>> result = planTaskMapper.getPlanTaskPoints(params);
result.forEach(r -> {
if (r.containsKey("finish")) {
String isFinishDesc = PlanTaskDetailIsFinishEnum.getName(Integer.parseInt(r.get("finish").toString()));
r.put("isFinishDesc", isFinishDesc);
}
});
return new PageImpl<>(result, pageable, total);
// return result; // return result;
} }
@Override @Override
public int getCurrentPlanTaskCount(String userId) { public int getCurrentPlanTaskCount(String userId) {
return planTaskMapper.getCurrentPlanTaskCount(userId); return planTaskMapper.getCurrentPlanTaskCount(userId);
} }
@Override @Override
public List<PlanTaskVo> getPlanTaskListByIds(String toke, String product, String appKey, Long[] ids) { public List<PlanTaskVo> getPlanTaskListByIds(String toke, String product, String appKey, Long[] ids) {
List<PlanTaskVo> content = planTaskMapper.getPlanTaskListByIds(ids); List<PlanTaskVo> content = planTaskMapper.getPlanTaskListByIds(ids);
String userIds = ""; String userIds = "";
String deptIds = ""; String deptIds = "";
Set<String> set = new HashSet<>(); Set<String> set = new HashSet<>();
Set<String> deptIdSet = new HashSet<>(); Set<String> deptIdSet = new HashSet<>();
Map<Long, Set<String>> deptMap = new HashMap<>(); Map<Long, Set<String>> deptMap = new HashMap<>();
content.forEach(s -> { content.forEach(s -> {
String userDept = s.getUserDept(); String userDept = s.getUserDept();
if (!ValidationUtil.isEmpty(userDept)) { if (!ValidationUtil.isEmpty(userDept)) {
String[] udStrs = userDept.split(","); String[] udStrs = userDept.split(",");
for (String udStr : udStrs) { for (String udStr : udStrs) {
try { try {
String[] split = udStr.split("@"); String[] split = udStr.split("@");
set.add(split[0]); set.add(split[0]);
if (split.length > 1) { if (split.length > 1) {
if (!"-1".equals(split[1])) { if (!"-1".equals(split[1])) {
deptIdSet.add(split[1]); deptIdSet.add(split[1]);
} }
if (!deptMap.containsKey(s.getId())) { if (!deptMap.containsKey(s.getId())) {
deptMap.put(s.getId(), new HashSet<>()); deptMap.put(s.getId(), new HashSet<>());
} }
deptMap.get(s.getId()).add(split[1]); deptMap.get(s.getId()).add(split[1]);
} }
} catch (Exception e) { } catch (Exception e) {
} }
} }
} }
}); });
List<String> userList = new ArrayList<>(set); List<String> userList = new ArrayList<>(set);
List<String> deptList = new ArrayList<>(deptIdSet); List<String> deptList = new ArrayList<>(deptIdSet);
Map<String, String> LoginName = new HashMap<>(); Map<String, String> LoginName = new HashMap<>();
Map<String, String> userMap = new HashMap<>(); Map<String, String> userMap = new HashMap<>();
Map<String, String> depMap = new HashMap<>(); Map<String, String> depMap = new HashMap<>();
if (!CollectionUtils.isEmpty(userList)) { if (!CollectionUtils.isEmpty(userList)) {
userIds = String.join(",", userList); userIds = String.join(",", userList);
List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(toke, product, appKey, userIds); List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(toke, product, appKey,
userMap = userModelList.stream().collect(Collectors.toMap(AgencyUserModel::getUserId, AgencyUserModel::getRealName, (k1, k2) -> k2)); userIds);
for (AgencyUserModel agencyUserModel : userModelList) { userMap = userModelList.stream().collect(
LoginName.put(agencyUserModel.getUserId(), agencyUserModel.getMobile() != null ? agencyUserModel.getMobile() : agencyUserModel.getLandlinePhone()); Collectors.toMap(AgencyUserModel::getUserId, AgencyUserModel::getRealName, (k1, k2) -> k2));
} for (AgencyUserModel agencyUserModel : userModelList) {
} LoginName.put(agencyUserModel.getUserId(),
if (!CollectionUtils.isEmpty(deptList)) { agencyUserModel.getMobile() != null ? agencyUserModel.getMobile()
String dept = String.join(",", deptList); : agencyUserModel.getLandlinePhone());
List<LinkedHashMap> deptL = remoteSecurityService.listDepartmentByDeptIds(toke, product, appKey, dept); }
if (deptL != null && deptL.size() > 0) { }
//新安全 if (!CollectionUtils.isEmpty(deptList)) {
content.forEach(s -> { String dept = String.join(",", deptList);
Set<String> set1 = deptMap.get(s.getId()); List<LinkedHashMap> deptL = remoteSecurityService.listDepartmentByDeptIds(toke, product, appKey, dept);
if (!ValidationUtil.isEmpty(set1)) { if (deptL != null && deptL.size() > 0) {
deptL.forEach(s1 -> { // 新安全
if (set1.contains(s1.get("sequenceNbr"))) { content.forEach(s -> {
if (!ValidationUtil.isEmpty(s.getDeptName())) { Set<String> set1 = deptMap.get(s.getId());
s.setDeptName(s.getDeptName() + "," + s1.get("departmentName")); if (!ValidationUtil.isEmpty(set1)) {
} else { deptL.forEach(s1 -> {
s.setDeptName(s1.get("departmentName").toString()); if (set1.contains(s1.get("sequenceNbr"))) {
} if (!ValidationUtil.isEmpty(s.getDeptName())) {
} s.setDeptName(s.getDeptName() + "," + s1.get("departmentName"));
}); } else {
if (set1.contains("-1")) { s.setDeptName(s1.get("departmentName").toString());
if (!ValidationUtil.isEmpty(s.getDeptName())) { }
s.setDeptName(s.getDeptName() + "," + "其他"); }
} else { });
s.setDeptName("其他"); if (set1.contains("-1")) {
} if (!ValidationUtil.isEmpty(s.getDeptName())) {
} s.setDeptName(s.getDeptName() + "," + "其他");
} } else {
}); s.setDeptName("其他");
} }
} }
Map<String, String> finalUserMap = userMap; }
content.forEach(c -> { });
StringBuilder userNames = new StringBuilder(""); }
List<String> userIdsList = Arrays.asList(c.getUserName().split(",")); }
for (String userId : userIdsList) { Map<String, String> finalUserMap = userMap;
userNames.append(finalUserMap.get(userId)); content.forEach(c -> {
userNames.append(","); StringBuilder userNames = new StringBuilder("");
} List<String> userIdsList = Arrays.asList(c.getUserName().split(","));
c.setUserName(userNames.toString()); for (String userId : userIdsList) {
}); userNames.append(finalUserMap.get(userId));
return content; userNames.append(",");
} }
c.setUserName(userNames.toString());
@Override });
public Page<CheckChkExListBo> getChkExList(String toke, String product, String appKey, CheckPtListPageParam param) { return content;
long total = planTaskMapper.countChkExListData(param); }
List<CheckChkExListBo> content = planTaskMapper.getChkExList(param);
@Override
//获取用户联系方式 public Page<CheckChkExListBo> getChkExList(String toke, String product, String appKey, CheckPtListPageParam param) {
String userIds = ""; long total = planTaskMapper.countChkExListData(param);
Set<String> set = new HashSet<>(); List<CheckChkExListBo> content = planTaskMapper.getChkExList(param);
content.forEach(s -> {
if (s.getRealName() != null) { // 获取用户联系方式
String[] sArr = s.getRealName().split(","); String userIds = "";
set.addAll(Arrays.asList(sArr)); Set<String> set = new HashSet<>();
} content.forEach(s -> {
}); if (s.getRealName() != null) {
List<String> userList = new ArrayList<>(set); String[] sArr = s.getRealName().split(",");
Map<String, AgencyUserModel> agencyUserModelMap = new HashMap<>(); set.addAll(Arrays.asList(sArr));
if (!CollectionUtils.isEmpty(userList)) { }
userIds = String.join(",", userList); });
List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(toke, product, appKey, userIds); List<String> userList = new ArrayList<>(set);
agencyUserModelMap = userModelList.stream().collect(Collectors.toMap(AgencyUserModel::getUserId, Function.identity())); Map<String, AgencyUserModel> agencyUserModelMap = new HashMap<>();
} if (!CollectionUtils.isEmpty(userList)) {
for (CheckChkExListBo bo : content) { userIds = String.join(",", userList);
ArrayList<String> names = new ArrayList<>(); List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(toke, product, appKey,
ArrayList<String> mobiles = new ArrayList<>(); userIds);
String nameStrings = String.join(",", names); agencyUserModelMap = userModelList.stream()
.collect(Collectors.toMap(AgencyUserModel::getUserId, Function.identity()));
String[] realNames = bo.getRealName().split(","); }
if (realNames.length > 1) { for (CheckChkExListBo bo : content) {
System.out.println("asd"); ArrayList<String> names = new ArrayList<>();
} ArrayList<String> mobiles = new ArrayList<>();
for (int i = 0; i < realNames.length; i++) { String nameStrings = String.join(",", names);
if (agencyUserModelMap.containsKey(realNames[i])) {
AgencyUserModel agencyUserModel = agencyUserModelMap.get(realNames[i]); String[] realNames = bo.getRealName().split(",");
names.add(agencyUserModel.getRealName()); if (realNames.length > 1) {
if (StringUtil.isNotEmpty(agencyUserModel.getMobile())) { System.out.println("asd");
mobiles.add(agencyUserModel.getMobile()); }
} for (int i = 0; i < realNames.length; i++) {
} if (agencyUserModelMap.containsKey(realNames[i])) {
AgencyUserModel agencyUserModel = agencyUserModelMap.get(realNames[i]);
} names.add(agencyUserModel.getRealName());
bo.setRealName(String.join(",", names)); if (StringUtil.isNotEmpty(agencyUserModel.getMobile())) {
if (mobiles.size() > 0) { mobiles.add(agencyUserModel.getMobile());
bo.setLoginName(String.join(",", mobiles)); }
} }
}
Page<CheckChkExListBo> result = new PageImpl<CheckChkExListBo>(content, param, total); }
return result; bo.setRealName(String.join(",", names));
} if (mobiles.size() > 0) {
bo.setLoginName(String.join(",", mobiles));
@Override }
public Map<String, Object> getPlanTaskStatisticsForApp(HashMap<String, Object> params) { }
return planTaskMapper.getPlanTaskStatisticsForApp(params); Page<CheckChkExListBo> result = new PageImpl<CheckChkExListBo>(content, param, total);
} return result;
}
@Override
public AppPointCheckRespone queryPointPlanTaskDetail(String toke, String product, String appKey, Long planTaskId, Long pointId) { @Override
AppPointCheckRespone pointCheckRespone = new AppPointCheckRespone(); public Map<String, Object> getPlanTaskStatisticsForApp(HashMap<String, Object> params) {
Check check = checkDao.findByPlanTaskIdAndPointId(planTaskId, pointId); return planTaskMapper.getPlanTaskStatisticsForApp(params);
if (check != null) { }
pointCheckRespone = checkService.queryCheckPointDetail(toke, product, appKey, check.getId());
} else { @Override
PointCheckDetailBo planPointInfo = planTaskMapper.getPointPlanTaskInfo(planTaskId, pointId); public AppPointCheckRespone queryPointPlanTaskDetail(String toke, String product, String appKey, Long planTaskId,
Long pointId) {
AppPointCheckRespone pointCheckRespone = new AppPointCheckRespone();
if (planPointInfo != null) { Check check = checkDao.findByPlanTaskIdAndPointId(planTaskId, pointId);
List<String> userIds = Arrays.asList(planPointInfo.getUsername().split(",")); if (check != null) {
List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(toke, product, appKey, planPointInfo.getUsername()); pointCheckRespone = checkService.queryCheckPointDetail(toke, product, appKey, check.getId());
Map<String, String> userModelMap = userModelList.stream().collect(Collectors.toMap(AgencyUserModel::getUserId, AgencyUserModel::getRealName, (k1, k2) -> k2)); } else {
if (userModelMap != null) { PointCheckDetailBo planPointInfo = planTaskMapper.getPointPlanTaskInfo(planTaskId, pointId);
List<String> userNameList = new ArrayList<>();
for (String userId : userIds) { if (planPointInfo != null) {
userNameList.add(userModelMap.get(userId)); List<String> userIds = Arrays.asList(planPointInfo.getUsername().split(","));
} List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(toke, product, appKey,
userNameList.remove(""); planPointInfo.getUsername());
userNameList.remove(null); Map<String, String> userModelMap = userModelList.stream().collect(
pointCheckRespone.setUsername(Joiner.on(",").join(userNameList)); Collectors.toMap(AgencyUserModel::getUserId, AgencyUserModel::getRealName, (k1, k2) -> k2));
} if (userModelMap != null) {
DepartmentModel departmentBo = remoteSecurityService.getDepartmentByDeptId(toke, product, appKey, planPointInfo.getUsername()); List<String> userNameList = new ArrayList<>();
if (departmentBo != null) { for (String userId : userIds) {
pointCheckRespone.setDepartmentName(departmentBo.getDepartmentName()); userNameList.add(userModelMap.get(userId));
} }
pointCheckRespone.setPointId(pointId); userNameList.remove("");
pointCheckRespone.setPointName(planPointInfo.getPointName()); userNameList.remove(null);
pointCheckRespone.setPointNo(planPointInfo.getPointNo()); pointCheckRespone.setUsername(Joiner.on(",").join(userNameList));
pointCheckRespone.setPointStatus("0"); }
pointCheckRespone.setPlanName(planPointInfo.getPlanName()); DepartmentModel departmentBo = remoteSecurityService.getDepartmentByDeptId(toke, product, appKey,
List<PointCheckDetailBo> pointInputs = planTaskMapper.getPointInputByRouteIdAndPointId(planPointInfo.getRouteId(), planPointInfo.getPointId()); planPointInfo.getUsername());
JSONObject appResponeMap = new JSONObject(); if (departmentBo != null) {
pointInputs.forEach(action -> { pointCheckRespone.setDepartmentName(departmentBo.getDepartmentName());
AppCheckInputRespone input = new AppCheckInputRespone(); }
input.setInputName(action.getInputName()); pointCheckRespone.setPointId(pointId);
input.setCheckInputId(action.getCheckInputId()); pointCheckRespone.setPointName(planPointInfo.getPointName());
input.setDataJson(action.getDataJson()); pointCheckRespone.setPointNo(planPointInfo.getPointNo());
input.setIsMultiline(action.getIsMultiline()); pointCheckRespone.setPointStatus("0");
input.setIsMust(action.getIsMust()); pointCheckRespone.setPlanName(planPointInfo.getPlanName());
input.setItemType(action.getItemType()); List<PointCheckDetailBo> pointInputs = planTaskMapper
input.setOrderNo(action.getOrderNo()); .getPointInputByRouteIdAndPointId(planPointInfo.getRouteId(), planPointInfo.getPointId());
input.setPictureJson(action.getPictureJson()); JSONObject appResponeMap = new JSONObject();
input.setClassifyId(action.getClassifyId()); pointInputs.forEach(action -> {
input.setClassifyName(action.getClassifyName()); AppCheckInputRespone input = new AppCheckInputRespone();
String key = ObjectUtils.isEmpty(action.getClassifyName()) ? "其他" : action.getClassifyName(); input.setInputName(action.getInputName());
if (appResponeMap.containsKey(key)) { input.setCheckInputId(action.getCheckInputId());
appResponeMap.getJSONArray(key).add(input); input.setDataJson(action.getDataJson());
} else { input.setIsMultiline(action.getIsMultiline());
List<AppCheckInputRespone> appCheckInputResponeList = new ArrayList<AppCheckInputRespone>(); input.setIsMust(action.getIsMust());
appCheckInputResponeList.add(input); input.setItemType(action.getItemType());
appResponeMap.put(key, appCheckInputResponeList); input.setOrderNo(action.getOrderNo());
} input.setPictureJson(action.getPictureJson());
}); input.setClassifyId(action.getClassifyId());
pointCheckRespone.setAppCheckInput(appResponeMap); input.setClassifyName(action.getClassifyName());
} else { String key = ObjectUtils.isEmpty(action.getClassifyName()) ? "其他" : action.getClassifyName();
return null; if (appResponeMap.containsKey(key)) {
} appResponeMap.getJSONArray(key).add(input);
} } else {
List<AppCheckInputRespone> appCheckInputResponeList = new ArrayList<AppCheckInputRespone>();
return pointCheckRespone; appCheckInputResponeList.add(input);
} appResponeMap.put(key, appCheckInputResponeList);
}
@Override });
public AppPointCheckRespone queryPointPlanTaskDetailInVersion2(String toke, String product, String appKey, Long planTaskId, Long pointId) { pointCheckRespone.setAppCheckInput(appResponeMap);
AppPointCheckRespone pointCheckRespone = new AppPointCheckRespone(); } else {
Check check = checkDao.findByPlanTaskIdAndPointId(planTaskId, pointId); return null;
if (check != null) { }
pointCheckRespone = checkService.queryCheckPointDetailInVersion2(toke, product, appKey, check.getId()); }
} else {
PointCheckDetailBo planPointInfo = planTaskMapper.getPointPlanTaskInfo(planTaskId, pointId); return pointCheckRespone;
}
if (planPointInfo != null) {
pointCheckRespone.setPointId(pointId); @Override
pointCheckRespone.setPointName(planPointInfo.getPointName()); public AppPointCheckRespone queryPointPlanTaskDetailInVersion2(String toke, String product, String appKey,
pointCheckRespone.setPointNo(planPointInfo.getPointNo()); Long planTaskId, Long pointId) {
pointCheckRespone.setPointStatus("0"); AppPointCheckRespone pointCheckRespone = new AppPointCheckRespone();
pointCheckRespone.setPlanName(planPointInfo.getPlanName()); Check check = checkDao.findByPlanTaskIdAndPointId(planTaskId, pointId);
List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(toke, product, appKey, planPointInfo.getUserId()); if (check != null) {
for (AgencyUserModel userModel : userModelList) { pointCheckRespone = checkService.queryCheckPointDetailInVersion2(toke, product, appKey, check.getId());
pointCheckRespone.setUsername(userModel.getRealName()); } else {
} PointCheckDetailBo planPointInfo = planTaskMapper.getPointPlanTaskInfo(planTaskId, pointId);
if (planPointInfo != null) {
pointCheckRespone.setPointId(pointId);
pointCheckRespone.setPointName(planPointInfo.getPointName());
pointCheckRespone.setPointNo(planPointInfo.getPointNo());
pointCheckRespone.setPointStatus("0");
pointCheckRespone.setPlanName(planPointInfo.getPlanName());
List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(toke, product, appKey,
planPointInfo.getUserId());
for (AgencyUserModel userModel : userModelList) {
pointCheckRespone.setUsername(userModel.getRealName());
}
// DepartmentModel departmentModel= remoteSecurityService.getDepartmentByDeptId(toke, product, appKey,planPointInfo.getCheckDepartmentId()); // DepartmentModel departmentModel= remoteSecurityService.getDepartmentByDeptId(toke, product, appKey,planPointInfo.getCheckDepartmentId());
DepartmentModel departmentModel = new DepartmentModel(); DepartmentModel departmentModel = new DepartmentModel();
pointCheckRespone.setDepartmentName(departmentModel.getDepartmentName()); pointCheckRespone.setDepartmentName(departmentModel.getDepartmentName());
List<PointCheckDetailBo> pointInputs = planTaskMapper.getPointInputByRouteIdAndPointId(planPointInfo.getRouteId(), planPointInfo.getPointId()); List<PointCheckDetailBo> pointInputs = planTaskMapper
.getPointInputByRouteIdAndPointId(planPointInfo.getRouteId(), planPointInfo.getPointId());
JSONObject appResponeMap = new JSONObject();
pointInputs.forEach(action -> { JSONObject appResponeMap = new JSONObject();
AppCheckInputRespone input = new AppCheckInputRespone(); pointInputs.forEach(action -> {
input.setInputName(action.getInputName()); AppCheckInputRespone input = new AppCheckInputRespone();
input.setCheckInputId(action.getCheckInputId()); input.setInputName(action.getInputName());
input.setDataJson(action.getDataJson()); input.setCheckInputId(action.getCheckInputId());
input.setIsMultiline(action.getIsMultiline()); input.setDataJson(action.getDataJson());
input.setIsMust(action.getIsMust()); input.setIsMultiline(action.getIsMultiline());
input.setItemType(action.getItemType()); input.setIsMust(action.getIsMust());
input.setOrderNo(action.getOrderNo()); input.setItemType(action.getItemType());
input.setPictureJson(action.getPictureJson()); input.setOrderNo(action.getOrderNo());
input.setClassifyId(action.getClassifyId()); input.setPictureJson(action.getPictureJson());
input.setClassifyName(action.getClassifyName()); input.setClassifyId(action.getClassifyId());
String classifyName = action.getClassifyName(); input.setClassifyName(action.getClassifyName());
if (!StringUtil.isNotEmpty(classifyName)) { String classifyName = action.getClassifyName();
classifyName = "其他"; if (!StringUtil.isNotEmpty(classifyName)) {
} classifyName = "其他";
String riskDesc = action.getRiskDesc(); }
if (!StringUtil.isNotEmpty(riskDesc)) { String riskDesc = action.getRiskDesc();
riskDesc = XJConstant.DEFAULT_RISKDESC; if (!StringUtil.isNotEmpty(riskDesc)) {
} riskDesc = XJConstant.DEFAULT_RISKDESC;
JSONObject classifyJson; }
if (appResponeMap.containsKey(classifyName)) { JSONObject classifyJson;
classifyJson = appResponeMap.getJSONObject(classifyName); if (appResponeMap.containsKey(classifyName)) {
} else { classifyJson = appResponeMap.getJSONObject(classifyName);
classifyJson = new JSONObject(); } else {
} classifyJson = new JSONObject();
JSONArray riskDescArr; }
if (classifyJson.containsKey(riskDesc)) { JSONArray riskDescArr;
riskDescArr = classifyJson.getJSONArray(riskDesc); if (classifyJson.containsKey(riskDesc)) {
} else { riskDescArr = classifyJson.getJSONArray(riskDesc);
riskDescArr = new JSONArray(); } else {
} riskDescArr = new JSONArray();
riskDescArr.add(action); }
classifyJson.put(riskDesc, riskDescArr); riskDescArr.add(action);
appResponeMap.put(classifyName, classifyJson); classifyJson.put(riskDesc, riskDescArr);
}); appResponeMap.put(classifyName, classifyJson);
pointCheckRespone.setAppCheckInput(appResponeMap); });
} else { pointCheckRespone.setAppCheckInput(appResponeMap);
return null; } else {
} return null;
} }
return pointCheckRespone; }
} return pointCheckRespone;
}
@Override
public String getCumulativePlanCountByOrgCode(String loginOrgCode) { @Override
return planTaskMapper.getCumulativePlanCountByOrgCode(loginOrgCode); public String getCumulativePlanCountByOrgCode(String loginOrgCode) {
} return planTaskMapper.getCumulativePlanCountByOrgCode(loginOrgCode);
}
@Override
public List<LeavePlanTaskVo> queryLeavePlanTask(HashMap<String, Object> params) { @Override
return planTaskMapper.queryLeavePlanTask(params); public List<LeavePlanTaskVo> queryLeavePlanTask(HashMap<String, Object> params) {
} return planTaskMapper.queryLeavePlanTask(params);
}
@Override
public List<CodeOrderVo> queryCodeOrderVo(HashMap<String, Object> params) { @Override
return planTaskMapper.queryCodeOrderVo(params); public List<CodeOrderVo> queryCodeOrderVo(HashMap<String, Object> params) {
} return planTaskMapper.queryCodeOrderVo(params);
}
@Override
public PlanTask selectPlanTaskStatus(Long id) { @Override
// TODO Auto-generated method stub public PlanTask selectPlanTaskStatus(Long id) {
if (iplanTaskDao.existsById(id)) { // TODO Auto-generated method stub
return iplanTaskDao.findById(id).get(); if (iplanTaskDao.existsById(id)) {
} return iplanTaskDao.findById(id).get();
return null; }
} return null;
}
@Override
public void initPlanStatusOrGenDate() { @Override
planMapper.initUpdatePlanStatus(); public void initPlanStatusOrGenDate() {
planMapper.initUpdatePlanNextGenDate(); planMapper.initUpdatePlanStatus();
} planMapper.initUpdatePlanNextGenDate();
}
@Override
public List<Map<String, Object>> queryPlanTaskTimeAxis(Long userId, Integer createDate) { @Override
HashMap<String, Object> params = new HashMap<>(); public List<Map<String, Object>> queryPlanTaskTimeAxis(Long userId, Integer createDate) {
params.put("userId", userId); HashMap<String, Object> params = new HashMap<>();
String endTime = DateUtil.getShortCurrentDate(); params.put("userId", userId);
; String endTime = DateUtil.getShortCurrentDate();
String beginTime = ""; ;
if (createDate != null && createDate == 7) { String beginTime = "";
beginTime = DateUtil.getIntervalDateStr(new Date(), -7, "yyyy-MM-dd"); if (createDate != null && createDate == 7) {
} else if (createDate != null && createDate == 30) { beginTime = DateUtil.getIntervalDateStr(new Date(), -7, "yyyy-MM-dd");
beginTime = DateUtil.getIntervalDateStr(new Date(), -30, "yyyy-MM-dd"); } else if (createDate != null && createDate == 30) {
} else { beginTime = DateUtil.getIntervalDateStr(new Date(), -30, "yyyy-MM-dd");
beginTime = DateUtil.getShortCurrentDate(); } else {
} beginTime = DateUtil.getShortCurrentDate();
}
params.put("beginTime", beginTime + " 00:00:00");
params.put("endTime", endTime + " 23:59:59"); params.put("beginTime", beginTime + " 00:00:00");
List<Map<String, Object>> content = planTaskMapper.queryPlanTaskTimeAxis(params); params.put("endTime", endTime + " 23:59:59");
if (!CollectionUtils.isEmpty(content)) { List<Map<String, Object>> content = planTaskMapper.queryPlanTaskTimeAxis(params);
Set<String> userIds = Sets.newHashSet(); if (!CollectionUtils.isEmpty(content)) {
content.forEach(e -> { Set<String> userIds = Sets.newHashSet();
content.forEach(e -> {
String id = e.get("userId").toString();
if (StringUtil.isNotEmpty(id)) { String id = e.get("userId").toString();
userIds.add(id); if (StringUtil.isNotEmpty(id)) {
} userIds.add(id);
}); }
Toke toke = remoteSecurityService.getServerToken(); });
List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(toke.getToke(), toke.getProduct(), toke.getAppKey(), Joiner.on(",").join(userIds)); Toke toke = remoteSecurityService.getServerToken();
Map<String, String> userModelMap = userModelList.stream().collect(Collectors.toMap(AgencyUserModel::getUserId, AgencyUserModel::getRealName, (k1, k2) -> k2)); List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(toke.getToke(),
toke.getProduct(), toke.getAppKey(), Joiner.on(",").join(userIds));
content.forEach(e -> { Map<String, String> userModelMap = userModelList.stream().collect(
StringBuffer userNames = new StringBuffer(); Collectors.toMap(AgencyUserModel::getUserId, AgencyUserModel::getRealName, (k1, k2) -> k2));
List<String> userIds1 = Arrays.asList(e.get("userId").toString().split(","));
for (String userId1 : userIds1) { content.forEach(e -> {
userNames.append(userModelMap.get(userId1)).append(","); StringBuffer userNames = new StringBuffer();
} List<String> userIds1 = Arrays.asList(e.get("userId").toString().split(","));
e.put("userName", userNames.substring(0, userNames.length() - 1)); for (String userId1 : userIds1) {
e.put("beginTime", DateUtil.formatDatrToStr((Date) e.get("beginTime"), DateUtil.LONG_PATTERN)); userNames.append(userModelMap.get(userId1)).append(",");
e.put("endTime", DateUtil.formatDatrToStr((Date) e.get("endTime"), DateUtil.LONG_PATTERN)); }
}); e.put("userName", userNames.substring(0, userNames.length() - 1));
} e.put("beginTime", DateUtil.formatDatrToStr((Date) e.get("beginTime"), DateUtil.LONG_PATTERN));
return content; e.put("endTime", DateUtil.formatDatrToStr((Date) e.get("endTime"), DateUtil.LONG_PATTERN));
} });
}
@Override return content;
public List<Map<String, Object>> queryTimeAxis(Long userId, Integer createDate) { }
HashMap<String, Object> params = new HashMap<>();
params.put("userId", userId); @Override
String endTime = DateUtil.getShortCurrentDate(); public List<Map<String, Object>> queryTimeAxis(Long userId, Integer createDate) {
; HashMap<String, Object> params = new HashMap<>();
String beginTime = ""; params.put("userId", userId);
if (createDate != null && createDate == 7) { String endTime = DateUtil.getShortCurrentDate();
beginTime = DateUtil.getIntervalDateStr(new Date(), -7, "yyyy-MM-dd"); ;
} else if (createDate != null && createDate == 30) { String beginTime = "";
beginTime = DateUtil.getIntervalDateStr(new Date(), -30, "yyyy-MM-dd"); if (createDate != null && createDate == 7) {
} else { beginTime = DateUtil.getIntervalDateStr(new Date(), -7, "yyyy-MM-dd");
beginTime = DateUtil.getShortCurrentDate(); } else if (createDate != null && createDate == 30) {
} beginTime = DateUtil.getIntervalDateStr(new Date(), -30, "yyyy-MM-dd");
} else {
params.put("beginTime", beginTime + " 00:00:00"); beginTime = DateUtil.getShortCurrentDate();
params.put("endTime", endTime + " 23:59:59"); }
String structListString = equipFeign.getStructureNameAll();
JSONObject jsonObject = JSONObject.parseObject(structListString); params.put("beginTime", beginTime + " 00:00:00");
JSONArray structList = jsonObject.getJSONArray("result"); params.put("endTime", endTime + " 23:59:59");
List<Map<String, Object>> result = new ArrayList<>(); String structListString = equipFeign.getStructureNameAll();
JSONObject jsonObject = JSONObject.parseObject(structListString);
List<Map<String, Object>> content = planTaskMapper.queryTimeAxis(params); JSONArray structList = jsonObject.getJSONArray("result");
if (!CollectionUtils.isEmpty(content)) { List<Map<String, Object>> result = new ArrayList<>();
Set<String> userIds = Sets.newHashSet();
content.forEach(e -> { List<Map<String, Object>> content = planTaskMapper.queryTimeAxis(params);
if (!CollectionUtils.isEmpty(content)) {
String id = e.get("userId").toString(); Set<String> userIds = Sets.newHashSet();
if (StringUtil.isNotEmpty(id)) { content.forEach(e -> {
userIds.add(id);
} String id = e.get("userId").toString();
}); if (StringUtil.isNotEmpty(id)) {
Toke toke = remoteSecurityService.getServerToken(); userIds.add(id);
List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(toke.getToke(), toke.getProduct(), toke.getAppKey(), Joiner.on(",").join(userIds)); }
Map<String, String> userModelMap = userModelList.stream().collect(Collectors.toMap(AgencyUserModel::getUserId, AgencyUserModel::getRealName, (k1, k2) -> k2)); });
Toke toke = remoteSecurityService.getServerToken();
content.forEach(e -> { List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(toke.getToke(),
StringBuffer userNames = new StringBuffer(); toke.getProduct(), toke.getAppKey(), Joiner.on(",").join(userIds));
List<String> userIds1 = Arrays.asList(e.get("userId").toString().split(",")); Map<String, String> userModelMap = userModelList.stream().collect(
for (String userId1 : userIds1) { Collectors.toMap(AgencyUserModel::getUserId, AgencyUserModel::getRealName, (k1, k2) -> k2));
userNames.append(userModelMap.get(userId1)).append(",");
} content.forEach(e -> {
HashMap<String, Object> map = new HashMap(); StringBuffer userNames = new StringBuffer();
map.put("userName", userNames.substring(0, userNames.length() - 1)); List<String> userIds1 = Arrays.asList(e.get("userId").toString().split(","));
map.put("beginTime", DateUtil.formatDatrToStr((Date) e.get("beginTime"), DateUtil.LONG_PATTERN)); for (String userId1 : userIds1) {
map.put("endTime", DateUtil.formatDatrToStr((Date) e.get("endTime"), DateUtil.LONG_PATTERN)); userNames.append(userModelMap.get(userId1)).append(",");
map.put("leftName", "巡检点"); }
map.put("titleName", userNames.substring(0, userNames.length() - 1) + "-" + e.get("name").toString() + "-" + e.get("STATUS").toString()); HashMap<String, Object> map = new HashMap();
String structName = ""; map.put("userName", userNames.substring(0, userNames.length() - 1));
if (!StringUtils.isEmpty(e.get("risk_source_id"))) { map.put("beginTime", DateUtil.formatDatrToStr((Date) e.get("beginTime"), DateUtil.LONG_PATTERN));
for (int i = 0; i < structList.size(); i++) { map.put("endTime", DateUtil.formatDatrToStr((Date) e.get("endTime"), DateUtil.LONG_PATTERN));
if (structList.getJSONObject(i).get("id").equals(e.get("risk_source_id"))) { map.put("leftName", "巡检点");
structName = structList.getJSONObject(i).get("name").toString(); map.put("titleName", userNames.substring(0, userNames.length() - 1) + "-" + e.get("name").toString()
} + "-" + e.get("STATUS").toString());
} String structName = "";
} else { if (!StringUtils.isEmpty(e.get("risk_source_id"))) {
structName = "无"; for (int i = 0; i < structList.size(); i++) {
} if (structList.getJSONObject(i).get("id").equals(e.get("risk_source_id"))) {
structName = structList.getJSONObject(i).get("name").toString();
if (!StringUtils.isEmpty(e.get("executorDate"))) { }
map.put("firstPropsValue", structName + "-" + e.get("executorDate")); }
} else { } else {
map.put("firstPropsValue", structName + "-无"); structName = "无";
} }
result.add(map); if (!StringUtils.isEmpty(e.get("executorDate"))) {
}); map.put("firstPropsValue", structName + "-" + e.get("executorDate"));
} } else {
return result; map.put("firstPropsValue", structName + "-无");
} }
result.add(map);
});
}
return result;
}
} }
...@@ -16,6 +16,7 @@ import org.springframework.data.domain.Page; ...@@ -16,6 +16,7 @@ import org.springframework.data.domain.Page;
import com.yeejoin.amos.supervision.business.param.CheckPtListPageParam; import com.yeejoin.amos.supervision.business.param.CheckPtListPageParam;
import com.yeejoin.amos.supervision.business.param.PlanTaskPageParam; import com.yeejoin.amos.supervision.business.param.PlanTaskPageParam;
import com.yeejoin.amos.supervision.core.common.response.AppPointCheckRespone; import com.yeejoin.amos.supervision.core.common.response.AppPointCheckRespone;
import com.yeejoin.amos.supervision.dao.entity.Plan;
import com.yeejoin.amos.supervision.dao.entity.PlanTask; import com.yeejoin.amos.supervision.dao.entity.PlanTask;
public interface IPlanTaskService { public interface IPlanTaskService {
...@@ -171,4 +172,6 @@ public interface IPlanTaskService { ...@@ -171,4 +172,6 @@ public interface IPlanTaskService {
List<Map<String, Object>> queryPlanTaskTimeAxis(Long userId, Integer createDate); List<Map<String, Object>> queryPlanTaskTimeAxis(Long userId, Integer createDate);
List<Map<String, Object>> queryTimeAxis(Long userId, Integer createDate); List<Map<String, Object>> queryTimeAxis(Long userId, Integer createDate);
void taskExecutionImportPlan(List<Plan> planList);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment