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