工作流修改判断
This commit is contained in:
parent
fb91b3350f
commit
0336abec3b
@ -168,19 +168,35 @@ public class XzProjectOrgServiceImpl extends ServiceImpl<XzProjectOrgMapper, XzP
|
||||
// 判断是否存在工作流的流程中
|
||||
List<HistoricProcessInstance> list = historyService.createHistoricProcessInstanceQuery().unfinished().list();
|
||||
Set<String> processDefinitionId = list.stream().map(l -> l.getProcessDefinitionId()).collect(Collectors.toSet());
|
||||
List<String> modelName = new ArrayList<>();
|
||||
if (processDefinitionId.size() > 0) {
|
||||
List<WflowModels> models = wflowModelsMapper.selectList(Wrappers.<WflowModels>lambdaQuery()
|
||||
.in(WflowModels::getProcessDefId, processDefinitionId));
|
||||
List<String> modelName = new ArrayList<>();
|
||||
for (WflowModels model : models) {
|
||||
List<String> orgIds = new ArrayList<>();
|
||||
getOrg(model, orgIds);
|
||||
if (orgIds.contains(id)) {
|
||||
modelName.add(model.getFormName());
|
||||
}
|
||||
|
||||
List<String> 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());
|
||||
}
|
||||
}
|
||||
if (modelName.size() > 0) {
|
||||
throw new CustomException("该组织有正在进行中审批流程,请完成流程后再删除", HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
List<WflowModels> modelList = wflowModelsMapper.selectList(null);
|
||||
modelName = new ArrayList<>();
|
||||
for (WflowModels model : modelList) {
|
||||
@ -189,6 +205,19 @@ public class XzProjectOrgServiceImpl extends ServiceImpl<XzProjectOrgMapper, XzP
|
||||
if (orgIds.contains(id)) {
|
||||
modelName.add(model.getFormName());
|
||||
}
|
||||
List<String> 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());
|
||||
}
|
||||
}
|
||||
if (modelName.size() > 0) {
|
||||
throw new CustomException("该组织有参与工作流流程审批,请调整流程后再删除", HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
@ -206,7 +235,7 @@ public class XzProjectOrgServiceImpl extends ServiceImpl<XzProjectOrgMapper, XzP
|
||||
List<SystemUser> systemUserList = systemUserMapper.selectList(new LambdaQueryWrapper<SystemUser>()
|
||||
.eq(SystemUser::getXzProjectOrgId, id));
|
||||
if (CollUtil.isNotEmpty(systemUserList)) {
|
||||
throw new OpenAlertException("该部门下有人员,无法删除");
|
||||
throw new OpenAlertException("该组织下有人员,无法删除");
|
||||
}
|
||||
baseMapper.deleteById(id);
|
||||
}
|
||||
@ -319,4 +348,20 @@ public class XzProjectOrgServiceImpl extends ServiceImpl<XzProjectOrgMapper, XzP
|
||||
}
|
||||
}
|
||||
|
||||
private void getUserIds(JSONObject children, List<String> userIds) {
|
||||
if (children != null) {
|
||||
JSONObject props = children.getJSONObject("props");
|
||||
if (props != null) {
|
||||
getUserIds(children.getJSONObject("children"), userIds);
|
||||
JSONArray assignedUser = props.getJSONArray("assignedUser");
|
||||
if (assignedUser != null) {
|
||||
for (int i = 0; i < assignedUser.size(); i++) {
|
||||
JSONObject jsonObject = assignedUser.getJSONObject(i);
|
||||
userIds.add(jsonObject.getString("id"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user