工作流日志

This commit is contained in:
pengjie 2024-07-02 16:20:29 +08:00
parent 7102984088
commit 5d80626d9b

View File

@ -911,31 +911,33 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
if (!systemUser1.getXzProjectOrgId().toString().equals(systemUser.getXzProjectOrgId().toString())) { if (!systemUser1.getXzProjectOrgId().toString().equals(systemUser.getXzProjectOrgId().toString())) {
// 判断是否存在工作流的流程中 // 判断是否存在工作流的流程中
List<HistoricProcessInstance> list = historyService.createHistoricProcessInstanceQuery().unfinished().list(); List<HistoricProcessInstance> list = historyService.createHistoricProcessInstanceQuery().unfinished().list();
Set<String> processDefinitionId = list.stream().map(l -> l.getProcessDefinitionId()).collect(Collectors.toSet()); if (list.size() > 0) {
Set<String> startUserIds = list.stream().map(l -> l.getStartUserId()).collect(Collectors.toSet()); Set<String> processDefinitionId = list.stream().map(l -> l.getProcessDefinitionId()).collect(Collectors.toSet());
List<WflowModels> models = wflowModelsMapper.selectList(Wrappers.<WflowModels>lambdaQuery() Set<String> startUserIds = list.stream().map(l -> l.getStartUserId()).collect(Collectors.toSet());
.in(WflowModels::getProcessDefId, processDefinitionId)); List<WflowModels> models = wflowModelsMapper.selectList(Wrappers.<WflowModels>lambdaQuery()
List<String> modelName = new ArrayList<>(); .in(WflowModels::getProcessDefId, processDefinitionId));
for (WflowModels model : models) { List<String> modelName = new ArrayList<>();
List<String> userIds = new ArrayList<>(); for (WflowModels model : models) {
JSONObject process = JSONObject.parseObject(model.getProcess()); List<String> userIds = new ArrayList<>();
JSONArray assignedUser1 = process.getJSONObject("props").getJSONArray("assignedUser"); JSONObject process = JSONObject.parseObject(model.getProcess());
if (assignedUser1 != null) { JSONArray assignedUser1 = process.getJSONObject("props").getJSONArray("assignedUser");
for (int i = 0; i < assignedUser1.size(); i++) { if (assignedUser1 != null) {
JSONObject jsonObject = assignedUser1.getJSONObject(i); for (int i = 0; i < assignedUser1.size(); i++) {
userIds.add(jsonObject.getString("id")); JSONObject jsonObject = assignedUser1.getJSONObject(i);
userIds.add(jsonObject.getString("id"));
}
}
getUserIds(process.getJSONObject("children"), userIds);
if (userIds.contains(systemUser.getUserId().toString())) {
modelName.add(model.getFormName());
} }
} }
getUserIds(process.getJSONObject("children"), userIds); if (startUserIds.contains(systemUser.getUserId().toString())) {
if (userIds.contains(systemUser.getUserId().toString())) { throw new OpenAlertException("该人员有正在进行中的审批流程,不可修改组织机构信息,请完成流程后再进行修改");
modelName.add(model.getFormName()); }
if (modelName.size() > 0) {
throw new OpenAlertException("该人员有正在进行中的审批流程,不可修改组织机构信息,请完成流程后再进行修改");
} }
}
if (startUserIds.contains(systemUser.getUserId().toString())) {
throw new OpenAlertException("该人员有正在进行中的审批流程,不可修改组织机构信息,请完成流程后再进行修改");
}
if (modelName.size() > 0) {
throw new OpenAlertException("该人员有正在进行中的审批流程,不可修改组织机构信息,请完成流程后再进行修改");
} }
} }
QueryWrapper<SystemUser> queryWrapper = new QueryWrapper<>(); QueryWrapper<SystemUser> queryWrapper = new QueryWrapper<>();
@ -1249,107 +1251,109 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
String id = MapUtils.getString(map, "id"); String id = MapUtils.getString(map, "id");
// 判断是否存在工作流的流程中 // 判断是否存在工作流的流程中
List<HistoricProcessInstance> list = historyService.createHistoricProcessInstanceQuery().unfinished().list(); List<HistoricProcessInstance> list = historyService.createHistoricProcessInstanceQuery().unfinished().list();
Set<String> processDefinitionId = list.stream().map(l -> l.getProcessDefinitionId()).collect(Collectors.toSet()); if (list.size() > 0) {
StringBuilder stringBuilder = new StringBuilder("该人员有正在进行中的"); Set<String> processDefinitionId = list.stream().map(l -> l.getProcessDefinitionId()).collect(Collectors.toSet());
List<String> modelName = new ArrayList<>(); StringBuilder stringBuilder = new StringBuilder("该人员有正在进行中的");
if (processDefinitionId.size() > 0) { List<String> modelName = new ArrayList<>();
Set<String> startUserIds = list.stream().map(l -> l.getStartUserId()).collect(Collectors.toSet());
if (processDefinitionId.size() > 0) { if (processDefinitionId.size() > 0) {
List<WflowModels> models = wflowModelsMapper.selectList(Wrappers.<WflowModels>lambdaQuery() Set<String> startUserIds = list.stream().map(l -> l.getStartUserId()).collect(Collectors.toSet());
.in(WflowModels::getProcessDefId, processDefinitionId)); if (processDefinitionId.size() > 0) {
for (WflowModels model : models) { List<WflowModels> models = wflowModelsMapper.selectList(Wrappers.<WflowModels>lambdaQuery()
List<String> userIds = new ArrayList<>(); .in(WflowModels::getProcessDefId, processDefinitionId));
JSONObject process = JSONObject.parseObject(model.getProcess()); for (WflowModels model : models) {
JSONArray assignedUser1 = process.getJSONObject("props").getJSONArray("assignedUser"); List<String> userIds = new ArrayList<>();
if (assignedUser1 != null) { JSONObject process = JSONObject.parseObject(model.getProcess());
for (int i = 0; i < assignedUser1.size(); i++) { JSONArray assignedUser1 = process.getJSONObject("props").getJSONArray("assignedUser");
JSONObject jsonObject = assignedUser1.getJSONObject(i); if (assignedUser1 != null) {
userIds.add(jsonObject.getString("id")); for (int i = 0; i < assignedUser1.size(); i++) {
JSONObject jsonObject = assignedUser1.getJSONObject(i);
userIds.add(jsonObject.getString("id"));
}
}
getUserIds(process.getJSONObject("children"), userIds);
if (userIds.contains(id)) {
modelName.add(model.getFormName());
} }
} }
getUserIds(process.getJSONObject("children"), userIds); if (modelName.size() > 0 || startUserIds.contains(id)) {
if (userIds.contains(id)) { stringBuilder.append("审批流程");
modelName.add(model.getFormName());
} }
} }
if (modelName.size() > 0 || startUserIds.contains(id)) { }
stringBuilder.append("审批流程"); // 判断是否存在安全检查中
List<XzSecurityQualityInspectionRecord> xzSecurityQualityInspectionRecords = xzSecurityQualityInspectionRecordService.list(Wrappers.<XzSecurityQualityInspectionRecord>lambdaQuery()
.ne(XzSecurityQualityInspectionRecord::getStatus, 5)
.ne(XzSecurityQualityInspectionRecord::getStatus, 6)
.and(item -> item.eq(XzSecurityQualityInspectionRecord::getChangeId, id)
.or().eq(XzSecurityQualityInspectionRecord::getReviewId, id)
.or().eq(XzSecurityQualityInspectionRecord::getVerifyManId, id)
.or().eq(XzSecurityQualityInspectionRecord::getInspectManId, id)));
if (xzSecurityQualityInspectionRecords.size() > 0) {
if (stringBuilder.length() > 10) {
stringBuilder.append("");
} }
stringBuilder.append("安全检查台账");
} }
} // 判断是否存在质量检查中
// 判断是否存在安全检查中 List<QualityInspectionRecord> qualityInspectionRecords = qualityInspectionRecordService.list(Wrappers.<QualityInspectionRecord>lambdaQuery()
List<XzSecurityQualityInspectionRecord> xzSecurityQualityInspectionRecords = xzSecurityQualityInspectionRecordService.list(Wrappers.<XzSecurityQualityInspectionRecord>lambdaQuery() .ne(QualityInspectionRecord::getStatus, 5)
.ne(XzSecurityQualityInspectionRecord::getStatus, 5) .ne(QualityInspectionRecord::getStatus, 6)
.ne(XzSecurityQualityInspectionRecord::getStatus, 6) .and(item -> item.eq(QualityInspectionRecord::getChangeId, id)
.and(item -> item.eq(XzSecurityQualityInspectionRecord::getChangeId, id) .or().eq(QualityInspectionRecord::getReviewId, id)
.or().eq(XzSecurityQualityInspectionRecord::getReviewId, id) .or().eq(QualityInspectionRecord::getVerifyManId, id)
.or().eq(XzSecurityQualityInspectionRecord::getVerifyManId, id) .or().eq(QualityInspectionRecord::getInspectManId, id)));
.or().eq(XzSecurityQualityInspectionRecord::getInspectManId, id))); if (qualityInspectionRecords.size() > 0) {
if (xzSecurityQualityInspectionRecords.size() > 0) { if (stringBuilder.length() > 10) {
if (stringBuilder.length() > 10) { stringBuilder.append("");
stringBuilder.append(""); }
stringBuilder.append("质量检查台账");
} }
stringBuilder.append("安全检查台账"); List<XzCheckingRoute> checkingPointList = xzCheckingRouteService.list(Wrappers.<XzCheckingRoute>lambdaQuery()
} .apply("find_in_set({0}, inspect_user_ids)", id)
// 判断是否存在质量检查中 .or()
List<QualityInspectionRecord> qualityInspectionRecords = qualityInspectionRecordService.list(Wrappers.<QualityInspectionRecord>lambdaQuery() .apply("find_in_set({0}, notice_user_ids)", id));
.ne(QualityInspectionRecord::getStatus, 5) label:
.ne(QualityInspectionRecord::getStatus, 6) for (XzCheckingRoute xzCheckingRoute : checkingPointList) {
.and(item -> item.eq(QualityInspectionRecord::getChangeId, id) List<XzCheckingRouteTask> xzCheckingRouteTasks = xzCheckingRouteTaskService.list(Wrappers.<XzCheckingRouteTask>lambdaQuery()
.or().eq(QualityInspectionRecord::getReviewId, id) .eq(XzCheckingRouteTask::getXzCheckingRouteId, xzCheckingRoute.getId()));
.or().eq(QualityInspectionRecord::getVerifyManId, id) for (XzCheckingRouteTask xzCheckingRouteTask : xzCheckingRouteTasks) {
.or().eq(QualityInspectionRecord::getInspectManId, id))); List<CheckingPointInfo> checkingPointInfos = checkingPointInfoService.list(Wrappers.<CheckingPointInfo>lambdaQuery()
if (qualityInspectionRecords.size() > 0) { .eq(CheckingPointInfo::getXzCheckingRouteTaskId, xzCheckingRouteTask.getId())
if (stringBuilder.length() > 10) { .eq(CheckingPointInfo::getCheckingPointUserId, id));
stringBuilder.append(""); if (checkingPointInfos == null || checkingPointInfos.size() == 0) {
} if (stringBuilder.length() > 10) {
stringBuilder.append("质量检查台账"); stringBuilder.append("");
} }
List<XzCheckingRoute> checkingPointList = xzCheckingRouteService.list(Wrappers.<XzCheckingRoute>lambdaQuery() stringBuilder.append("巡检任务");
.apply("find_in_set({0}, inspect_user_ids)", id) break label;
.or()
.apply("find_in_set({0}, notice_user_ids)", id));
label:
for (XzCheckingRoute xzCheckingRoute : checkingPointList) {
List<XzCheckingRouteTask> xzCheckingRouteTasks = xzCheckingRouteTaskService.list(Wrappers.<XzCheckingRouteTask>lambdaQuery()
.eq(XzCheckingRouteTask::getXzCheckingRouteId, xzCheckingRoute.getId()));
for (XzCheckingRouteTask xzCheckingRouteTask : xzCheckingRouteTasks) {
List<CheckingPointInfo> checkingPointInfos = checkingPointInfoService.list(Wrappers.<CheckingPointInfo>lambdaQuery()
.eq(CheckingPointInfo::getXzCheckingRouteTaskId, xzCheckingRouteTask.getId())
.eq(CheckingPointInfo::getCheckingPointUserId, id));
if (checkingPointInfos == null || checkingPointInfos.size() == 0) {
if (stringBuilder.length() > 10) {
stringBuilder.append("");
} }
stringBuilder.append("巡检任务");
break label;
} }
} }
} if (stringBuilder.length() > 10) {
if (stringBuilder.length() > 10) { throw new CustomException(stringBuilder + ",请完成流程后再删除账号", HttpStatus.INTERNAL_SERVER_ERROR);
throw new CustomException(stringBuilder + ",请完成流程后再删除账号", HttpStatus.INTERNAL_SERVER_ERROR); }
} // 判断是否有参与到流程审批中
// 判断是否有参与到流程审批中 List<WflowModels> modelList = wflowModelsMapper.selectList(null);
List<WflowModels> modelList = wflowModelsMapper.selectList(null); modelName = new ArrayList<>();
modelName = new ArrayList<>(); for (WflowModels model : modelList) {
for (WflowModels model : modelList) { List<String> userIds = new ArrayList<>();
List<String> userIds = new ArrayList<>(); JSONObject process = JSONObject.parseObject(model.getProcess());
JSONObject process = JSONObject.parseObject(model.getProcess()); JSONArray assignedUser1 = process.getJSONObject("props").getJSONArray("assignedUser");
JSONArray assignedUser1 = process.getJSONObject("props").getJSONArray("assignedUser"); if (assignedUser1 != null) {
if (assignedUser1 != null) { for (int i = 0; i < assignedUser1.size(); i++) {
for (int i = 0; i < assignedUser1.size(); i++) { JSONObject jsonObject = assignedUser1.getJSONObject(i);
JSONObject jsonObject = assignedUser1.getJSONObject(i); userIds.add(jsonObject.getString("id"));
userIds.add(jsonObject.getString("id")); }
}
getUserIds(process.getJSONObject("children"), userIds);
if (userIds.contains(id)) {
modelName.add(model.getFormName());
} }
} }
getUserIds(process.getJSONObject("children"), userIds); if (modelName.size() > 0) {
if (userIds.contains(id)) { throw new CustomException("该人员有参与工作流流程审批,请调整流程后再删除账号", HttpStatus.INTERNAL_SERVER_ERROR);
modelName.add(model.getFormName());
} }
} }
if (modelName.size() > 0) {
throw new CustomException("该人员有参与工作流流程审批,请调整流程后再删除账号", HttpStatus.INTERNAL_SERVER_ERROR);
}
String projectSn = MapUtils.getString(map, "projectSn"); String projectSn = MapUtils.getString(map, "projectSn");
SystemUser systemUser = getById(id); SystemUser systemUser = getById(id);
if (systemUser == null) { if (systemUser == null) {