diff --git a/src/main/java/neatlogic/module/process/condition/handler/ProcessTaskOwnerUserIdCondition.java b/src/main/java/neatlogic/module/process/condition/handler/ProcessTaskOwnerUserIdCondition.java new file mode 100644 index 0000000000000000000000000000000000000000..45b7fea36f858118d9b7cbdda27ab3f0f180ac23 --- /dev/null +++ b/src/main/java/neatlogic/module/process/condition/handler/ProcessTaskOwnerUserIdCondition.java @@ -0,0 +1,166 @@ +/*Copyright (C) 2024 深圳极向量科技有限公司 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.JSONArray; +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.common.constvalue.FormHandlerType; +import neatlogic.framework.common.constvalue.GroupSearch; +import neatlogic.framework.common.constvalue.ParamType; +import neatlogic.framework.common.constvalue.UserType; +import neatlogic.framework.dao.mapper.UserMapper; +import neatlogic.framework.dto.UserVo; +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.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + +@Component +public class ProcessTaskOwnerUserIdCondition extends ProcessTaskConditionBase implements IProcessTaskCondition { + + @Resource + private ProcessTaskMapper processTaskMapper; + + @Resource + private UserMapper userMapper; + + @Override + public String getName() { + return "owneruserid"; + } + + @Override + public String getDisplayName() { + return "上报人用户ID"; + } + + @Override + public String getHandler(FormConditionModel processWorkcenterConditionType) { + return FormHandlerType.USERSELECT.toString(); + } + + @Override + public String getType() { + return ProcessFieldType.COMMON.getValue(); + } + + @Override + public JSONObject getConfig(ConditionConfigType configType) { + JSONObject config = new JSONObject(); + config.put("type", FormHandlerType.USERSELECT.toString()); + config.put("multiple", true); + config.put("initConfig", new JSONObject() { + { + this.put("excludeList", new JSONArray() {{ + if (ConditionConfigType.WORKCENTER.getValue().equals(configType.getValue())) { + this.add(GroupSearch.COMMON.getValuePlugin() + UserType.ALL.getValue()); + } + }}); + this.put("groupList", new JSONArray() { + { + if (ConditionConfigType.WORKCENTER.getValue().equals(configType.getValue())) { + this.add(GroupSearch.COMMON.getValue()); + } + this.add(GroupSearch.USER.getValue()); + } + }); + this.put("includeList", new JSONArray() { + { + if (ConditionConfigType.WORKCENTER.getValue().equals(configType.getValue())) { + this.add(GroupSearch.COMMON.getValuePlugin() + UserType.VIP_USER.getValue()); + this.add(GroupSearch.COMMON.getValuePlugin() + UserType.LOGIN_USER.getValue()); + } + } + }); + } + }); + /* 以下代码是为了兼容旧数据结构,前端有些地方还在用 **/ + config.put("isMultiple", true); + return config; + } + + @Override + public Integer getSort() { + return 4; + } + + @Override + public ParamType getParamType() { + return ParamType.ARRAY; + } + + @Override + public Object valueConversionText(Object value, JSONObject config) { + if (value != null) { + if (value instanceof String) { + UserVo userVo = userMapper.getUserByUserId(value.toString()); + if (userVo != null) { + return userVo.getUserName(); + } + } else if (value instanceof List) { + List valueList = JSON.parseArray(JSON.toJSONString(value), String.class); + List textList = new ArrayList<>(); + for (String valueStr : valueList) { + UserVo userVo = userMapper.getUserByUserId(valueStr); + if (userVo != null) { + textList.add(userVo.getUserName()); + } 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; + } + UserVo user = userMapper.getUserBaseInfoByUuid(processTaskVo.getOwner()); + if (user != null) { + return user.getUserId(); + } + return null; + } + + @Override + public Object getConditionParamDataForHumanization(ProcessTaskStepVo processTaskStepVo) { + ProcessTaskVo processTaskVo = processTaskMapper.getProcessTaskById(processTaskStepVo.getProcessTaskId()); + if (processTaskVo == null) { + return null; + } + UserVo user = userMapper.getUserBaseInfoByUuid(processTaskVo.getOwner()); + if (user != null) { + return user.getUserName(); + } + return null; + } + +}