diff --git a/src/main/java/neatlogic/module/process/condition/handler/ProcessTaskOwnerCenterCondition.java b/src/main/java/neatlogic/module/process/condition/handler/ProcessTaskOwnerCenterCondition.java new file mode 100644 index 0000000000000000000000000000000000000000..bb5e8d9eb1c47e9a863ce103407c4b09797a8051 --- /dev/null +++ b/src/main/java/neatlogic/module/process/condition/handler/ProcessTaskOwnerCenterCondition.java @@ -0,0 +1,171 @@ +/*Copyright (C) $today.year 深圳极向量科技有限公司 All Rights Reserved. + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see .*/ + +package neatlogic.module.process.condition.handler; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.common.constvalue.FormHandlerType; +import neatlogic.framework.common.constvalue.ParamType; +import neatlogic.framework.common.constvalue.TeamLevel; +import neatlogic.framework.dao.mapper.TeamMapper; +import neatlogic.framework.dto.TeamVo; +import neatlogic.framework.form.constvalue.FormConditionModel; +import neatlogic.framework.process.condition.core.IProcessTaskCondition; +import neatlogic.framework.process.condition.core.ProcessTaskConditionBase; +import neatlogic.framework.process.constvalue.ConditionConfigType; +import neatlogic.framework.process.constvalue.ProcessFieldType; +import neatlogic.framework.process.dto.ProcessTaskStepVo; +import neatlogic.framework.process.dto.ProcessTaskVo; +import neatlogic.module.process.dao.mapper.processtask.ProcessTaskMapper; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +@Component +public class ProcessTaskOwnerCenterCondition extends ProcessTaskConditionBase implements IProcessTaskCondition { + + @Resource + private ProcessTaskMapper processTaskMapper; + + @Resource + private TeamMapper teamMapper; + + @Override + public String getName() { + return "ownercenter"; + } + + @Override + public String getDisplayName() { + return "上报人中心"; + } + + @Override + public String getHandler(FormConditionModel processWorkcenterConditionType) { + return FormHandlerType.SELECT.toString(); + } + + @Override + public String getType() { + return ProcessFieldType.COMMON.getValue(); + } + + @Override + public JSONObject getConfig(ConditionConfigType type) { + JSONObject config = new JSONObject(); + config.put("type", FormHandlerType.SELECT.toString()); + config.put("search", true); + config.put("dynamicUrl", "/api/rest/team/list/forselect?level=center"); + config.put("rootName", "tbodyList"); + config.put("valueName", "uuid"); + config.put("textName", "name"); + config.put("multiple", true); + config.put("value", ""); + config.put("defaultValue", ""); + /** 以下代码是为了兼容旧数据结构,前端有些地方还在用 **/ + config.put("isMultiple", true); + JSONObject mappingObj = new JSONObject(); + mappingObj.put("value", "uuid"); + mappingObj.put("text", "name"); + config.put("mapping", mappingObj); + return config; + } + + @Override + public Integer getSort() { + return 11; + } + + @Override + public ParamType getParamType() { + return ParamType.ARRAY; + } + + @Override + public Object valueConversionText(Object value, JSONObject config) { + if (value != null) { + if (value instanceof String) { + TeamVo teamVo = teamMapper.getTeamByUuid((String) value); + if (teamVo != null) { + return teamVo.getName(); + } + } else if (value instanceof List) { + List valueList = JSON.parseArray(JSON.toJSONString(value), String.class); + List textList = new ArrayList<>(); + for (String valueStr : valueList) { + TeamVo teamVo = teamMapper.getTeamByUuid(valueStr); + if (teamVo != null) { + textList.add(teamVo.getName()); + } else { + textList.add(valueStr); + } + } + return String.join("、", textList); + } + } + return value; + } + + @Override + public Object getConditionParamData(ProcessTaskStepVo processTaskStepVo) { + ProcessTaskVo processTaskVo = processTaskMapper.getProcessTaskById(processTaskStepVo.getProcessTaskId()); + if (processTaskVo == null) { + return null; + } + List teamUuidList = teamMapper.getTeamUuidListByUserUuid(processTaskVo.getOwner()); + if (CollectionUtils.isNotEmpty(teamUuidList)) { + Set upwardUuidSet = new HashSet<>(); + List teamList = teamMapper.getTeamByUuidList(teamUuidList); + for (TeamVo teamVo : teamList) { + String upwardUuidPath = teamVo.getUpwardUuidPath(); + if (StringUtils.isNotBlank(upwardUuidPath)) { + String[] upwardUuidArray = upwardUuidPath.split(","); + for (String upwardUuid : upwardUuidArray) { + upwardUuidSet.add(upwardUuid); + } + } + } + if (CollectionUtils.isNotEmpty(upwardUuidSet)) { + List upwardTeamList = teamMapper.getTeamByUuidList(new ArrayList<>(upwardUuidSet)); + List centerUuidList = new ArrayList<>(); + for (TeamVo teamVo : upwardTeamList) { + if (TeamLevel.CENTER.getValue().equals(teamVo.getLevel())) { + centerUuidList.add(teamVo.getUuid()); + } + } + return centerUuidList; + } + } + return null; + } + + @Override + public Object getConditionParamDataForHumanization(ProcessTaskStepVo processTaskStepVo) { + List centerUuidList = (List) getConditionParamData(processTaskStepVo); + if (CollectionUtils.isEmpty(centerUuidList)) { + return null; + } + List teamList = teamMapper.getTeamByUuidList(centerUuidList); + return teamList.stream().map(TeamVo::getName).collect(Collectors.toList()); + } +} diff --git a/src/main/java/neatlogic/module/process/condition/handler/ProcessTaskOwnerCompanyCondition.java b/src/main/java/neatlogic/module/process/condition/handler/ProcessTaskOwnerCompanyCondition.java index d87b8c4de52a1a83e9344f976964a668e6cfe96c..bbc754b490a784c233f9486067d458295183e0c5 100644 --- a/src/main/java/neatlogic/module/process/condition/handler/ProcessTaskOwnerCompanyCondition.java +++ b/src/main/java/neatlogic/module/process/condition/handler/ProcessTaskOwnerCompanyCondition.java @@ -1,3 +1,18 @@ +/*Copyright (C) $today.year 深圳极向量科技有限公司 All Rights Reserved. + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see .*/ + package neatlogic.module.process.condition.handler; import com.alibaba.fastjson.JSON; diff --git a/src/main/java/neatlogic/module/process/condition/handler/ProcessTaskOwnerGroupCondition.java b/src/main/java/neatlogic/module/process/condition/handler/ProcessTaskOwnerGroupCondition.java new file mode 100644 index 0000000000000000000000000000000000000000..af6ecf854845a894a7ee121a83ae330cd5d57f25 --- /dev/null +++ b/src/main/java/neatlogic/module/process/condition/handler/ProcessTaskOwnerGroupCondition.java @@ -0,0 +1,171 @@ +/*Copyright (C) $today.year 深圳极向量科技有限公司 All Rights Reserved. + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see .*/ + +package neatlogic.module.process.condition.handler; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.common.constvalue.FormHandlerType; +import neatlogic.framework.common.constvalue.ParamType; +import neatlogic.framework.common.constvalue.TeamLevel; +import neatlogic.framework.dao.mapper.TeamMapper; +import neatlogic.framework.dto.TeamVo; +import neatlogic.framework.form.constvalue.FormConditionModel; +import neatlogic.framework.process.condition.core.IProcessTaskCondition; +import neatlogic.framework.process.condition.core.ProcessTaskConditionBase; +import neatlogic.framework.process.constvalue.ConditionConfigType; +import neatlogic.framework.process.constvalue.ProcessFieldType; +import neatlogic.framework.process.dto.ProcessTaskStepVo; +import neatlogic.framework.process.dto.ProcessTaskVo; +import neatlogic.module.process.dao.mapper.processtask.ProcessTaskMapper; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +@Component +public class ProcessTaskOwnerGroupCondition extends ProcessTaskConditionBase implements IProcessTaskCondition { + + @Resource + private ProcessTaskMapper processTaskMapper; + + @Resource + private TeamMapper teamMapper; + + @Override + public String getName() { + return "ownergroup"; + } + + @Override + public String getDisplayName() { + return "上报人集团"; + } + + @Override + public String getHandler(FormConditionModel processWorkcenterConditionType) { + return FormHandlerType.SELECT.toString(); + } + + @Override + public String getType() { + return ProcessFieldType.COMMON.getValue(); + } + + @Override + public JSONObject getConfig(ConditionConfigType type) { + JSONObject config = new JSONObject(); + config.put("type", FormHandlerType.SELECT.toString()); + config.put("search", true); + config.put("dynamicUrl", "/api/rest/team/list/forselect?level=group"); + config.put("rootName", "tbodyList"); + config.put("valueName", "uuid"); + config.put("textName", "name"); + config.put("multiple", true); + config.put("value", ""); + config.put("defaultValue", ""); + /** 以下代码是为了兼容旧数据结构,前端有些地方还在用 **/ + config.put("isMultiple", true); + JSONObject mappingObj = new JSONObject(); + mappingObj.put("value", "uuid"); + mappingObj.put("text", "name"); + config.put("mapping", mappingObj); + return config; + } + + @Override + public Integer getSort() { + return 11; + } + + @Override + public ParamType getParamType() { + return ParamType.ARRAY; + } + + @Override + public Object valueConversionText(Object value, JSONObject config) { + if (value != null) { + if (value instanceof String) { + TeamVo teamVo = teamMapper.getTeamByUuid((String) value); + if (teamVo != null) { + return teamVo.getName(); + } + } else if (value instanceof List) { + List valueList = JSON.parseArray(JSON.toJSONString(value), String.class); + List textList = new ArrayList<>(); + for (String valueStr : valueList) { + TeamVo teamVo = teamMapper.getTeamByUuid(valueStr); + if (teamVo != null) { + textList.add(teamVo.getName()); + } else { + textList.add(valueStr); + } + } + return String.join("、", textList); + } + } + return value; + } + + @Override + public Object getConditionParamData(ProcessTaskStepVo processTaskStepVo) { + ProcessTaskVo processTaskVo = processTaskMapper.getProcessTaskById(processTaskStepVo.getProcessTaskId()); + if (processTaskVo == null) { + return null; + } + List teamUuidList = teamMapper.getTeamUuidListByUserUuid(processTaskVo.getOwner()); + if (CollectionUtils.isNotEmpty(teamUuidList)) { + Set upwardUuidSet = new HashSet<>(); + List teamList = teamMapper.getTeamByUuidList(teamUuidList); + for (TeamVo teamVo : teamList) { + String upwardUuidPath = teamVo.getUpwardUuidPath(); + if (StringUtils.isNotBlank(upwardUuidPath)) { + String[] upwardUuidArray = upwardUuidPath.split(","); + for (String upwardUuid : upwardUuidArray) { + upwardUuidSet.add(upwardUuid); + } + } + } + if (CollectionUtils.isNotEmpty(upwardUuidSet)) { + List upwardTeamList = teamMapper.getTeamByUuidList(new ArrayList<>(upwardUuidSet)); + List groupUuidList = new ArrayList<>(); + for (TeamVo teamVo : upwardTeamList) { + if (TeamLevel.GROUP.getValue().equals(teamVo.getLevel())) { + groupUuidList.add(teamVo.getUuid()); + } + } + return groupUuidList; + } + } + return null; + } + + @Override + public Object getConditionParamDataForHumanization(ProcessTaskStepVo processTaskStepVo) { + List groupUuidList = (List) getConditionParamData(processTaskStepVo); + if (CollectionUtils.isEmpty(groupUuidList)) { + return null; + } + List teamList = teamMapper.getTeamByUuidList(groupUuidList); + return teamList.stream().map(TeamVo::getName).collect(Collectors.toList()); + } +} diff --git a/src/main/java/neatlogic/module/process/condition/handler/ProcessTaskOwnerTeamCondition.java b/src/main/java/neatlogic/module/process/condition/handler/ProcessTaskOwnerTeamCondition.java new file mode 100644 index 0000000000000000000000000000000000000000..6ea1412ee8f45ffa07b9334f1f45923653657b80 --- /dev/null +++ b/src/main/java/neatlogic/module/process/condition/handler/ProcessTaskOwnerTeamCondition.java @@ -0,0 +1,155 @@ +/*Copyright (C) $today.year 深圳极向量科技有限公司 All Rights Reserved. + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see .*/ + +package neatlogic.module.process.condition.handler; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.common.constvalue.FormHandlerType; +import neatlogic.framework.common.constvalue.ParamType; +import neatlogic.framework.common.constvalue.TeamLevel; +import neatlogic.framework.dao.mapper.TeamMapper; +import neatlogic.framework.dto.TeamVo; +import neatlogic.framework.form.constvalue.FormConditionModel; +import neatlogic.framework.process.condition.core.IProcessTaskCondition; +import neatlogic.framework.process.condition.core.ProcessTaskConditionBase; +import neatlogic.framework.process.constvalue.ConditionConfigType; +import neatlogic.framework.process.constvalue.ProcessFieldType; +import neatlogic.framework.process.dto.ProcessTaskStepVo; +import neatlogic.framework.process.dto.ProcessTaskVo; +import neatlogic.module.process.dao.mapper.processtask.ProcessTaskMapper; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +@Component +public class ProcessTaskOwnerTeamCondition extends ProcessTaskConditionBase implements IProcessTaskCondition { + + @Resource + private ProcessTaskMapper processTaskMapper; + + @Resource + private TeamMapper teamMapper; + + @Override + public String getName() { + return "ownerteam"; + } + + @Override + public String getDisplayName() { + return "上报人组"; + } + + @Override + public String getHandler(FormConditionModel processWorkcenterConditionType) { + return FormHandlerType.SELECT.toString(); + } + + @Override + public String getType() { + return ProcessFieldType.COMMON.getValue(); + } + + @Override + public JSONObject getConfig(ConditionConfigType type) { + JSONObject config = new JSONObject(); + config.put("type", FormHandlerType.SELECT.toString()); + config.put("search", true); + config.put("dynamicUrl", "/api/rest/team/list/forselect?level=team"); + config.put("rootName", "tbodyList"); + config.put("valueName", "uuid"); + config.put("textName", "name"); + config.put("multiple", true); + config.put("value", ""); + config.put("defaultValue", ""); + /** 以下代码是为了兼容旧数据结构,前端有些地方还在用 **/ + config.put("isMultiple", true); + JSONObject mappingObj = new JSONObject(); + mappingObj.put("value", "uuid"); + mappingObj.put("text", "name"); + config.put("mapping", mappingObj); + return config; + } + + @Override + public Integer getSort() { + return 11; + } + + @Override + public ParamType getParamType() { + return ParamType.ARRAY; + } + + @Override + public Object valueConversionText(Object value, JSONObject config) { + if (value != null) { + if (value instanceof String) { + TeamVo teamVo = teamMapper.getTeamByUuid((String) value); + if (teamVo != null) { + return teamVo.getName(); + } + } else if (value instanceof List) { + List valueList = JSON.parseArray(JSON.toJSONString(value), String.class); + List textList = new ArrayList<>(); + for (String valueStr : valueList) { + TeamVo teamVo = teamMapper.getTeamByUuid(valueStr); + if (teamVo != null) { + textList.add(teamVo.getName()); + } else { + textList.add(valueStr); + } + } + return String.join("、", textList); + } + } + return value; + } + + @Override + public Object getConditionParamData(ProcessTaskStepVo processTaskStepVo) { + ProcessTaskVo processTaskVo = processTaskMapper.getProcessTaskById(processTaskStepVo.getProcessTaskId()); + if (processTaskVo == null) { + return null; + } + List teamUuidList = teamMapper.getTeamUuidListByUserUuid(processTaskVo.getOwner()); + if (CollectionUtils.isNotEmpty(teamUuidList)) { + List teamList = teamMapper.getTeamByUuidList(teamUuidList); + List uuidList = new ArrayList<>(); + for (TeamVo teamVo : teamList) { + if (teamVo.getLevel() == null || TeamLevel.TEAM.getValue().equals(teamVo.getLevel())) { + uuidList.add(teamVo.getUuid()); + } + } + return uuidList; + } + return null; + } + + @Override + public Object getConditionParamDataForHumanization(ProcessTaskStepVo processTaskStepVo) { + List teamUuidList = (List) getConditionParamData(processTaskStepVo); + if (CollectionUtils.isEmpty(teamUuidList)) { + return null; + } + List teamList = teamMapper.getTeamByUuidList(teamUuidList); + return teamList.stream().map(TeamVo::getName).collect(Collectors.toList()); + } +}