|
|
@@ -125,7 +125,6 @@ public class EarlyWarningWithoutSubmitTask { |
|
|
|
List<String> unitIdPathsStr = CollUtils.convert(unitIdPaths, String::valueOf); |
|
|
|
String orderSql = String.format(" order by field(mh_unit_id, %s) desc limit 1", |
|
|
|
CollUtils.join(unitIdPaths, w -> "'" + w + "'", StrUtil.COMMA)); |
|
|
|
log.info("单位ID路径:{}", unitIdPathsStr); |
|
|
|
// 从当前建设单位开始向上获取滞后预警规则 |
|
|
|
WflowEarlyWarning warning = earlyWarningService.getOne(Wrappers.lambdaQuery(WflowEarlyWarning.class) |
|
|
|
.eq(WflowEarlyWarning::getRuleType, WarningRuleTypeEnum.DELAY_WARNING.getCode()) |
|
|
@@ -297,146 +296,6 @@ public class EarlyWarningWithoutSubmitTask { |
|
|
|
} |
|
|
|
stopWatch.stop(); |
|
|
|
log.info("=========== 滞后预警任务结束 耗时{}s", stopWatch.getTotalTimeSeconds()); |
|
|
|
|
|
|
|
//log.info("=========== 滞后预警任务开始 ==========="); |
|
|
|
//StopWatch stopWatch = new StopWatch(); |
|
|
|
//stopWatch.start(); |
|
|
|
//// 1.查询 填报的 滞后预警规则 填报类型的 每个单位的 每个规则 |
|
|
|
//Wrapper<WflowEarlyWarning> query = Wrappers.lambdaQuery(WflowEarlyWarning.class) |
|
|
|
// .eq(WflowEarlyWarning::getRuleType, WarningRuleTypeEnum.DELAY_WARNING.getCode()) |
|
|
|
// .eq(WflowEarlyWarning::getIsOpen, true); |
|
|
|
//List<WflowEarlyWarning> warnings = earlyWarningService.list(query); |
|
|
|
//for (WflowEarlyWarning warning : warnings) { |
|
|
|
// long mhUnitId = warning.getMhUnitId(); |
|
|
|
// String rule = warning.getRule(); |
|
|
|
// if (StringUtils.isNotBlank(rule)) { |
|
|
|
// JSONArray ruleArray = JSON.parseArray(rule); |
|
|
|
// if (CollUtil.isNotEmpty(ruleArray)) { |
|
|
|
// ruleArray.forEach(r -> { |
|
|
|
// JSONObject rJson = JSON.parseObject(JSON.toJSONString(r)); |
|
|
|
// Integer biz = rJson.getInteger("biz"); |
|
|
|
// Integer delayTime = rJson.getInteger("delayTime"); |
|
|
|
// String notice = rJson.getString("notice"); |
|
|
|
// WarningFlowTypeEnum flowType = WarningFlowTypeEnum.getByCode(biz); |
|
|
|
// if (Objects.isNull(delayTime) || Objects.isNull(biz) || flowType == null) { |
|
|
|
// log.warn("规则数据 错误 :{}", rJson); |
|
|
|
// return; |
|
|
|
// } |
|
|
|
// String path = flowType.getPath(); |
|
|
|
// // 查询 所有这个单位 所配置滞后规则节点 未提交的项目 |
|
|
|
// Wrapper<Project> projectQuery = Wrappers.lambdaQuery(Project.class) |
|
|
|
// .eq(Project::getBuildOrgCode, mhUnitId) |
|
|
|
// .eq(Project::getNewest, Boolean.TRUE) |
|
|
|
// .eq(Project::getStatus, flowType.getProjectStatus().getCode()); |
|
|
|
// List<Project> needNextProjects = projectService.list(projectQuery); |
|
|
|
// List<String> projectCodes = CollUtils.fieldList(needNextProjects, Project::getProjectCode); |
|
|
|
// Map<String, ProjectStatusChange> projectStatusChangeMap = MapUtil.newHashMap(); |
|
|
|
// String stepName = null; |
|
|
|
// switch (flowType) { |
|
|
|
// // 已立项未采购 获取 立项时间 |
|
|
|
// case APPROVED_PROJECT_NOT_PURCHASED:{ |
|
|
|
// stepName = TaskConstant.StepName.PURCHASE; |
|
|
|
// if (CollUtil.isNotEmpty(projectCodes)) { |
|
|
|
// Map<String, ProjectStatusChange> approvedProjectNotPurchasedMap = projectStatusChangeService.listLastEventMap(projectCodes, |
|
|
|
// ProjectStateChangeEvent.DECLARED_RECORD_PASS); |
|
|
|
// if (CollUtil.isNotEmpty(approvedProjectNotPurchasedMap)) { |
|
|
|
// projectStatusChangeMap.putAll(approvedProjectNotPurchasedMap); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// break; |
|
|
|
// // 已采购未改造完成 获取合同签订时间 |
|
|
|
// case PURCHASED_UNMODIFIED:{ |
|
|
|
// stepName = TaskConstant.StepName.ADAPT_MODIFY; |
|
|
|
// if (CollUtil.isNotEmpty(projectCodes)) { |
|
|
|
// Map<String, ProjectStatusChange> purchasedUnmodifiedMap = projectStatusChangeService.listLastEventMap(projectCodes, |
|
|
|
// ProjectStateChangeEvent.SUBMIT_PURCHASE_CONTRACT_RECORD); |
|
|
|
// if (CollUtil.isNotEmpty(purchasedUnmodifiedMap)) { |
|
|
|
// projectStatusChangeMap.putAll(purchasedUnmodifiedMap); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// break; |
|
|
|
// // 已改造完成未终验 获取单位确认时间 |
|
|
|
// case MODIFIED_NOT_FINAL_INSPECTION:{ |
|
|
|
// stepName = TaskConstant.StepName.FINAL; |
|
|
|
// if (CollUtil.isNotEmpty(projectCodes)) { |
|
|
|
// Map<String, ProjectStatusChange> modifiedNotFinalInspectionMap = projectStatusChangeService.listLastEventMap(projectCodes, |
|
|
|
// ProjectStateChangeEvent.SUBMIT_PURCHASE_ORG_CONFIRM); |
|
|
|
// if (CollUtil.isNotEmpty(modifiedNotFinalInspectionMap)) { |
|
|
|
// projectStatusChangeMap.putAll(modifiedNotFinalInspectionMap); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// break; |
|
|
|
// default: |
|
|
|
// log.error("Unexpected value: {}", flowType); |
|
|
|
// } |
|
|
|
// // 查询当前预警表中 已存在的的滞后预警数据 |
|
|
|
// Wrapper<ProjectEarlyWarning> warningQuery = Wrappers.lambdaQuery(ProjectEarlyWarning.class) |
|
|
|
// .eq(ProjectEarlyWarning::getRuleType, WarningRuleTypeEnum.DELAY_WARNING.getCode()); |
|
|
|
// List<ProjectEarlyWarning> projectEarlyWarnings = projectEarlyWarningService.list(warningQuery); |
|
|
|
// Map<String, ProjectEarlyWarning> projectEarlyWarningMap = CollUtils.listToMap(projectEarlyWarnings, c -> c.getProjectCode() + StrPool.DASH + c.getStepName()); |
|
|
|
// // 按照当前配置的滞后规则 获取需要首页监测预警展示的项目 |
|
|
|
// // 获取项目 滞后(历时)时间 |
|
|
|
// HashMap<String, LocalDateTime> touchTimeMap = MapUtil.newHashMap(); |
|
|
|
// String finalStepName = stepName; |
|
|
|
// List<ProjectEarlyWarning> needRemoved = Lists.newArrayList(); |
|
|
|
// List<Project> needToWaringProjects = needNextProjects.stream() |
|
|
|
// .filter(p -> { |
|
|
|
// ProjectStatusChange change = projectStatusChangeMap.get(p.getProjectCode()); |
|
|
|
// LocalDateTime touchTime = change == null ? null : change.getCreateOn(); |
|
|
|
// if (touchTime != null) { |
|
|
|
// touchTimeMap.put(p.getProjectCode() + StrPool.DASH + biz, touchTime); |
|
|
|
// long duration = getDurationTime(touchTime,LocalDateTime.now(),getTimeUnit()); |
|
|
|
// if (duration > delayTime) { |
|
|
|
// // 项目 滞后预警 |
|
|
|
// projectEarlyWarningService.earlyWarning(p, WarningRuleTypeEnum.DELAY_WARNING.getCode(), com.wflow.enums.WarningNoticeTypeEnum.DELAY.getCode(), finalStepName); |
|
|
|
// return Boolean.TRUE; |
|
|
|
// }else { |
|
|
|
// // 判断是否已经存在对应节点预警 如果有 从预警信息表中移除 |
|
|
|
// if (projectEarlyWarningMap.containsKey(p.getProjectCode() + StrPool.DASH + finalStepName)) { |
|
|
|
// ProjectEarlyWarning projectEarlyWarning = projectEarlyWarningMap.get(p.getProjectCode() + StrPool.DASH + finalStepName); |
|
|
|
// needRemoved.add(projectEarlyWarning); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// return Boolean.FALSE; |
|
|
|
// }).collect(Collectors.toList()); |
|
|
|
// // 根据当前配置的滞后规则 将不满足规则的历史预警信息从预警信息表中移除 |
|
|
|
// if (CollUtil.isNotEmpty(needRemoved)){ |
|
|
|
// projectEarlyWarningService.removeBatchByIds(needRemoved); |
|
|
|
// } |
|
|
|
// for (Project needToWaringProject : needToWaringProjects) { |
|
|
|
// // 目前没有通知 |
|
|
|
// // 如果去预警通知人 1.超级管理员 2.单位管理员 如果都包含 都要发 |
|
|
|
// List<String> batchEmployees = Lists.newArrayList(); |
|
|
|
// if (StringUtils.isNotBlank(notice) && notice.contains(WarningNoticeTypeEnum.SUPER_ADMIN.getCode().toString())) { |
|
|
|
// // 获取超级管理员用户信息 |
|
|
|
// List<UserInfo> superAdminUsers = userInfoHelper.getEmployeeCodesByRoleEnum(RoleEnum.SUPER_ADMIN); |
|
|
|
// List<String> superAdminEmployeeCodes = superAdminUsers.stream().map(UserInfo::getEmployeeCode).collect(Collectors.toList()); |
|
|
|
// batchEmployees.addAll(superAdminEmployeeCodes); |
|
|
|
// } |
|
|
|
// if (StringUtils.isNotBlank(notice) && notice.contains(WarningNoticeTypeEnum.UNIT_ADMIN.getCode().toString())) { |
|
|
|
// // 获取单位管理员用户信息 |
|
|
|
// List<UserInfo> unitAdminUsers = userInfoHelper.getEmployeeCodesByRoleEnum(RoleEnum.COMPANY_MANAGER); |
|
|
|
// // 过滤出当前项目所属单位的单位管理员 |
|
|
|
// List<String> unitAdminEmployeeCodes = unitAdminUsers.stream().filter(user -> Objects.equals(user.getMhUnitId().toString(), needToWaringProject.getBuildOrgCode())) |
|
|
|
// .map(UserInfo::getEmployeeCode).collect(Collectors.toList()); |
|
|
|
// batchEmployees.addAll(unitAdminEmployeeCodes); |
|
|
|
// } |
|
|
|
// // 保存到预警记录中 |
|
|
|
// earlyWarningManage.doEarlyWarningDelay(warning.getNoticeMethod(), biz, needToWaringProject, |
|
|
|
// WarningRuleTypeEnum.DELAY_WARNING.getCode(), ProjectEarlyWarningStatusEnum.DELAY_TIME.getCode(), |
|
|
|
// path, touchTimeMap); |
|
|
|
// } |
|
|
|
// }); |
|
|
|
// } |
|
|
|
// } |
|
|
|
//} |
|
|
|
// |
|
|
|
//stopWatch.stop(); |
|
|
|
//log.info("=========== 滞后预警任务结束 耗时{}s", stopWatch.getTotalTimeSeconds()); |
|
|
|
} |
|
|
|
|
|
|
|
private boolean isTouch(WarningFlowTypeEnum flowType, Boolean isPurchase, Boolean isModified, Boolean isFinalInspection) { |
|
|
|