diff --git a/.gitignore b/.gitignore index a85a048..d767065 100644 --- a/.gitignore +++ b/.gitignore @@ -23,7 +23,6 @@ log # should NOT be excluded as they contain compiler settings and other important # information for Eclipse / Flash Builder. -/target/ /log/ .DS_Store /src/main/resources/WEB-INF/prop/weaver.properties @@ -44,6 +43,7 @@ src/main/resources/WEB-INF/sqllog/ java.io.tempdir/ ecology-9-dev.iml src/test/resources/font - +src/main/resources/WEB-INF/vm/outFile +target/ diff --git a/javascript/common/dev.js b/javascript/common/dev.js index 0ceb3ed..4fc86d7 100644 --- a/javascript/common/dev.js +++ b/javascript/common/dev.js @@ -75,6 +75,12 @@ WfForm.bindFieldChangeEvent = function (fieldMarkStr, funobj = (obj, id, value) // }); } +WfForm.bindDetailFieldChangeEvent = function (fieldMarkStr, funobj = (id, rowIndex, value) => { +}) { + +} + + WfForm.controlBtnDisabled = function (isDisabled) { // isDisabled boolean 是 true:按钮全部置灰不可操作,false:恢复按钮可操作状态 // function subimtForm(params){ @@ -133,6 +139,16 @@ WfForm.changeFieldValue = function (fieldMark, valueInfo) { // }); } +/** + * 获取流览框显示值 + * fieldMark String 是 字段标示,格式field${字段ID}_${明细行号} + * splitChar String 否 分隔符,默认以逗号分隔 + * @param fieldMark + * @param splitChar + */ +WfForm.getBrowserShowName = function (fieldMark, splitChar) { +} + /* ******************* 建模表开发依赖 ******************* */ @@ -151,3 +167,6 @@ ModeList.dataLoadAfter = function (data) { }; + + + diff --git a/javascript/youhong.ai/fentian/ecode/workflow_controller.js b/javascript/youhong.ai/fentian/ecode/workflow_controller.js index 3205701..84bd6f7 100644 --- a/javascript/youhong.ai/fentian/ecode/workflow_controller.js +++ b/javascript/youhong.ai/fentian/ecode/workflow_controller.js @@ -20,6 +20,18 @@ class ConfigWorkflowTitle { || item.type === RulesType.SELECT_VALUE || item.type === RulesType.RADIO_VALUE).forEach(item => filedArr.push(item.fieldName)) this.addListenerEvent(filedArr) + this.addListenerSubmitEvent() + } + + + /** + * 监听提交流程动作 + */ + addListenerSubmitEvent = () => { + Utils.registerAction(WfForm.OPER_SAVE + "," + WfForm.OPER_SUBMIT, callback => { + this.changeWorkflowTitle() + callback() + }) } /** @@ -78,6 +90,12 @@ class RulesType { let year = date.getFullYear(); let month = date.getMonth() + 1; let day = date.getDay(); + if (month < 10) { + month = '0' + month + } + if (day < 10) { + day = '0' + day + } return year + "-" + month + "-" + day } } @@ -101,13 +119,13 @@ class RulesType { // 当前月份 static CURRENT_MONTH = { value: 7, - run: () => new Date().getMonth() + 1 + run: () => new Date().getMonth() + 1 < 10 ? new Date().getMonth() + 1 : '0' + new Date().getMonth() + 1 } // 当前天数 static CURRENT_DAY = { value: 8, - run: () => new Date().getDay() + run: () => new Date().getDay() < 10 ? new Date().getDay() : '0' + new Date().getDay() } // 当前小时 @@ -145,6 +163,13 @@ class RulesType { return result.join("") } } + static BROWSER_SHOW_NAME = { + value: 14, + run: item => { + let fieldId = Utils.convertNameObjToId(item.fieldName) + return WfForm.getBrowserShowName(fieldId) + } + } } diff --git a/javascript/youhong.ai/pcn/workflow_code_block.js b/javascript/youhong.ai/pcn/workflow_code_block.js index 74e8d70..e4daf23 100644 --- a/javascript/youhong.ai/pcn/workflow_code_block.js +++ b/javascript/youhong.ai/pcn/workflow_code_block.js @@ -208,7 +208,7 @@ window.workflowCus = Object.assign(window.workflowCus ? window.workflowCus : {}, getLevelByScore: async function (config) { let scoreFiled = config.scoreFiled let score = Utils.getFiledValueByName(scoreFiled); - if(score == 0 || score == ''){ + if (score == 0 || score == '') { return } let result = await Utils.api({ @@ -232,16 +232,69 @@ $(() => { levelField: "level1" } try { - setTimeout(()=>{ - WfForm.bindFieldChangeEvent(Utils.convertNameObjToId(config.scoreFiled),()=>{ - console.log("asdfasdfasdfsadfasdf") + setTimeout(() => { + WfForm.bindFieldChangeEvent(Utils.convertNameObjToId(config.scoreFiled), () => { window.workflowCus.getLevelByScore(config) }) window.workflowCus.getLevelByScore(config) - },100) - }catch (err){ + }, 100) + } catch (err) { console.log(err) } }) /* ******************* apa流程通过apa分数字段带出level字段eng ******************* */ + + +/* ******************* apa(employee)流程明细分数控制 ******************* */ +function addChangeEventListener(configItem) { + let fieldIds = Utils.convertNameToIdUtil([{ + fieldName: configItem.selfEvaluationScore, + table: configItem.table + }, { + fieldName: configItem.leaderScore, + table: configItem.table + }]) + WfForm.bindDetailFieldChangeEvent(fieldIds, (id, rowIndex, value) => { + if (value == '') { + return + } + if (value >= 1 && value <= 5) { + if (value % 0.5 !== 0) { + showHint(id + "_" + rowIndex) + } + } else { + showHint(id + "_" + rowIndex) + } + }) +} + +function showHint(id) { + WfForm.showMessage(`Evaluate your target completion by selecting a score. +The scores are of 0.5 break-down. + 5 - Outstanding + 4 - Exceeds Expectations + 3 - Meets Expectations + 2 - Needs Improvement + 1 - Unsatisfactory`, 2, 10) + setTimeout(() => { + WfForm.changeFieldValue(id, {value: ""}) + }, 100) +} + +$(() => { + let employeeDetailConfig = [{ + table: 'detail_1', + selfEvaluationScore: 'zp', + leaderScore: 'ldpf' + }, { + table: 'detail_2', + selfEvaluationScore: 'zp', + leaderScore: 'ldpf' + }] + employeeDetailConfig.forEach(item => { + addChangeEventListener(item) + }) +}) + +/* ******************* apa(employee)流程明细分数控制end ******************* */ \ No newline at end of file diff --git a/src/main/java/aiyh/utils/Util.java b/src/main/java/aiyh/utils/Util.java index ed2e2e6..2508486 100644 --- a/src/main/java/aiyh/utils/Util.java +++ b/src/main/java/aiyh/utils/Util.java @@ -1,6 +1,7 @@ package aiyh.utils; import aiyh.utils.action.CusBaseAction; +import aiyh.utils.action.SafeCusActionProcessInterface; import aiyh.utils.annotation.*; import aiyh.utils.annotation.recordset.SqlMapper; import aiyh.utils.entity.*; @@ -45,6 +46,8 @@ import weaver.soa.workflow.request.RequestInfo; import weaver.soa.workflow.request.RequestService; import weaver.systeminfo.SystemEnv; import weaver.workflow.request.RequestManager; +import weaver.workflow.workflow.WorkflowBillComInfo; +import weaver.workflow.workflow.WorkflowComInfo; import weaver.workflow.workflow.WorkflowVersion; import javax.servlet.http.HttpServletRequest; @@ -54,10 +57,7 @@ import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.io.*; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; +import java.lang.reflect.*; import java.math.BigDecimal; import java.net.URLDecoder; import java.nio.charset.StandardCharsets; @@ -95,6 +95,7 @@ public class Util extends weaver.general.Util { public static final String UF_CUS_DEV_CONFIG = "uf_cus_dev_config"; private static final UtilService utilService = new UtilService(); private static final RecordsetUtil recordsetUtil = new RecordsetUtil(); + private static final RecordsetUtil recordsetTransUtil = new RecordsetUtil(); private static final UtilMapper mapper = recordsetUtil.getMapper(UtilMapper.class); private static final Map otherLog = new HashMap<>(8); static ToolUtil toolUtil = new ToolUtil(); @@ -1989,7 +1990,7 @@ public class Util extends weaver.general.Util { * @author youHong.ai ****************************************** */ public static T getTransMapper(Class t) { - return recordsetUtil.getMapper(t, false); + return recordsetTransUtil.getMapper(t, false); } /** @@ -2007,7 +2008,7 @@ public class Util extends weaver.general.Util { if (t.getAnnotation(SqlMapper.class) == null) { throw new BindingException("can not find SqlMapper annotation!"); } - return recordsetUtil.getRsManager().commit(t.getName()); + return recordsetTransUtil.getRsManager().commit(t.getName()); } /** @@ -2025,7 +2026,7 @@ public class Util extends weaver.general.Util { if (t.getAnnotation(SqlMapper.class) == null) { throw new BindingException("can not find SqlMapper annotation!"); } - return recordsetUtil.getRsManager().rollback(t.getName()); + return recordsetTransUtil.getRsManager().rollback(t.getName()); } /** @@ -3537,4 +3538,48 @@ public class Util extends weaver.general.Util { } return pathParamMap; } + + public static Object executeActionProcess(String process, RequestInfo requestInfo) { + if (StringUtils.isNullOrEmpty(process)) { + return null; + } + RequestManager requestManager = requestInfo.getRequestManager(); + String billTable = requestManager.getBillTableName(); + String requestId = requestInfo.getRequestid(); + User user = requestInfo.getRequestManager().getUser(); + int workflowId = requestManager.getWorkflowid(); + // 操作类型 submit - 提交 reject - 退回 等 + String src = requestManager.getSrc(); + if ("".equals(billTable)) { + WorkflowComInfo workflowComInfo = new WorkflowComInfo(); + String formId = workflowComInfo.getFormId(String.valueOf(workflowId)); + WorkflowBillComInfo workflowBillComInfo = new WorkflowBillComInfo(); + billTable = workflowBillComInfo.getTablename(formId); + } + Class clazz = SafeCusActionProcessInterface.class; + Class aClass; + try { + aClass = Class.forName(process); + } catch (ClassNotFoundException e) { + throw new IllegalArgumentException("未能找到自定义接口:" + process); + } + if (!clazz.isAssignableFrom(aClass)) { + throw new IllegalArgumentException("自定义接口:" + process + " 不是" + + clazz.getName() + "的子类或实现类!"); + } + Constructor constructor; + try { + constructor = aClass.getConstructor(); + } catch (NoSuchMethodException e) { + throw new IllegalArgumentException(process + "没有空参构造方法,无法获取构造方法对象!"); + } + SafeCusActionProcessInterface o; + try { + o = (SafeCusActionProcessInterface) constructor.newInstance(); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { + throw new IllegalArgumentException("无法构造" + process + "对象!"); + } + Map pathParam = Util.parseCusInterfacePathParam(process); + return o.execute(pathParam, requestId, billTable, workflowId, user, requestInfo); + } } diff --git a/src/main/java/aiyh/utils/action/CusBaseCronJob.java b/src/main/java/aiyh/utils/action/CusBaseCronJob.java index 654f78d..2ac99a4 100644 --- a/src/main/java/aiyh/utils/action/CusBaseCronJob.java +++ b/src/main/java/aiyh/utils/action/CusBaseCronJob.java @@ -16,7 +16,7 @@ import weaver.interfaces.schedule.BaseCronJob; public abstract class CusBaseCronJob extends BaseCronJob { - Logger log = Util.getLogger(); + protected Logger log = Util.getLogger(); @Override @@ -39,8 +39,7 @@ public abstract class CusBaseCronJob extends BaseCronJob { * 2022/12/4 13:59 * ****************************************** * - * @author youHong.ai - * ****************************************** + * @author youHong.ai ****************************************** */ public abstract void runCode(); @@ -51,8 +50,7 @@ public abstract class CusBaseCronJob extends BaseCronJob { * ****************************************** * * @param e 异常类 - * @author youHong.ai - * ****************************************** + * @author youHong.ai ****************************************** */ public void exceptionCallback(Throwable e) { log.error("execute cronJon failure! error detail msg \n" + Util.getErrString(e)); diff --git a/src/main/java/aiyh/utils/action/SafeCusActionProcessInterface.java b/src/main/java/aiyh/utils/action/SafeCusActionProcessInterface.java new file mode 100644 index 0000000..c2a490b --- /dev/null +++ b/src/main/java/aiyh/utils/action/SafeCusActionProcessInterface.java @@ -0,0 +1,37 @@ +package aiyh.utils.action; + +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.Map; + +/** + *

流程自定义前置后置处理方法

+ * + *

create: 2023-01-10 13:19

+ * + * @author youHong.ai + */ + +@FunctionalInterface + +public interface SafeCusActionProcessInterface { + + /** + *

execute 流程action处理方法

+ * 2023/1/10 13:21 + * ************************************************************ + * + * @param pathParams 路径参数 + * @param requestId 流程请求id + * @param billTable 流程主表表名 + * @param workflowId 流程workflowId + * @param user 流程当前操作人 + * @param requestInfo action参数 + * @return Object 返回值 + * @author youHong.ai ****************************************** + */ + + Object execute(Map pathParams, String requestId, String billTable, int workflowId, + User user, RequestInfo requestInfo); +} diff --git a/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java b/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java index bf4d92b..ff116e4 100644 --- a/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java +++ b/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java @@ -281,8 +281,8 @@ public class HttpUtils { public ResponeVo apiGet(String url, Map params, Map headers) throws IOException { Map paramsMap = paramsHandle(params); - String getUrl = urlHandle(url, paramsMap); Map headerMap = headersHandle(headers); + String getUrl = urlHandle(url, paramsMap); CloseableHttpClient httpConnection = HttpManager.getHttpConnection(url, this.credentialsProvider); HttpGet httpGet = new HttpGet(getUrl.trim()); for (Map.Entry entry : headerMap.entrySet()) { @@ -409,6 +409,13 @@ public class HttpUtils { return baseRequest(httpConnection, httpPost); } + public ResponeVo apiPost(String url, List params, Map headers) throws IOException { + CloseableHttpClient httpConnection = HttpManager.getHttpConnection(url, this.credentialsProvider); + Map headerMap = headersHandle(headers); + HttpPost httpPost = handleHttpPost(url, headerMap, params); + return baseRequest(httpConnection, httpPost); + } + public ResponeVo apiPostObject(String url, Object params, Map headers) throws IOException { CloseableHttpClient httpConnection = HttpManager.getHttpConnection(url, this.credentialsProvider); Map headerMap = headersHandle(headers); @@ -1031,6 +1038,10 @@ public class HttpUtils { return handleHttpPostObject(url, headerMap, paramsMap); } + private HttpPost handleHttpPost(String url, Map headerMap, List params) throws UnsupportedEncodingException { + return handleHttpPostObject(url, headerMap, params); + } + /** *

上传文件

* diff --git a/src/main/java/aiyh/utils/recordset/RsThreadLocalManager.java b/src/main/java/aiyh/utils/recordset/RsThreadLocalManager.java index 5950668..e67da90 100644 --- a/src/main/java/aiyh/utils/recordset/RsThreadLocalManager.java +++ b/src/main/java/aiyh/utils/recordset/RsThreadLocalManager.java @@ -22,7 +22,7 @@ import java.util.concurrent.TimeUnit; public class RsThreadLocalManager { - private final ConcurrentHashMap> rsMap = new ConcurrentHashMap<>(); + private static final ConcurrentHashMap> rsMap = new ConcurrentHashMap<>(); private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); diff --git a/src/main/java/com/api/youhong/ai/pcn/mode/apadefaultyear/controller/DefaultQueryYearController.java b/src/main/java/com/api/youhong/ai/pcn/mode/apadefaultyear/controller/DefaultQueryYearController.java new file mode 100644 index 0000000..77700d5 --- /dev/null +++ b/src/main/java/com/api/youhong/ai/pcn/mode/apadefaultyear/controller/DefaultQueryYearController.java @@ -0,0 +1,49 @@ +package com.api.youhong.ai.pcn.mode.apadefaultyear.controller; + +import aiyh.utils.ApiResult; +import aiyh.utils.Util; +import com.api.youhong.ai.pcn.mode.apadefaultyear.service.DefaultQueryYearService; +import org.apache.log4j.Logger; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +/** + *

查询默认的apa年份过滤默认年

+ * + *

create: 2023-01-05 14:54

+ * + * @author youHong.ai + */ + +@Path("ayh/mode/default-year") +public class DefaultQueryYearController { + + private final Logger log = Util.getLogger(); + + private final DefaultQueryYearService service = new DefaultQueryYearService(); + + /** + *

getYear 获取默认的搜索年份

+ * 2023/1/5 15:09 + * ************************************************************ + * + * @return String 年份响应数据 + * @author youHong.ai ****************************************** + */ + @Path("/get-year") + @GET + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public String getYear() { + try { + return ApiResult.success(service.getYear()); + } catch (Exception e) { + log.error("get default year error! exception msg is: \n" + Util.getErrString(e)); + return ApiResult.error(e.getMessage()); + } + } +} diff --git a/src/main/java/com/api/youhong/ai/pcn/mode/apadefaultyear/mapper/DefaultQueryYearMapper.java b/src/main/java/com/api/youhong/ai/pcn/mode/apadefaultyear/mapper/DefaultQueryYearMapper.java new file mode 100644 index 0000000..71adbd5 --- /dev/null +++ b/src/main/java/com/api/youhong/ai/pcn/mode/apadefaultyear/mapper/DefaultQueryYearMapper.java @@ -0,0 +1,29 @@ +package com.api.youhong.ai.pcn.mode.apadefaultyear.mapper; + +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; + +/** + *

查询数据库数据

+ * + *

create: 2023-01-05 15:04

+ * + * @author youHong.ai + */ + +@SqlMapper +public interface DefaultQueryYearMapper { + + + /** + *

selectYearById 通过数据ID查询对应年份

+ * 2023/1/5 15:08 + * ************************************************************ + * + * @param id 数据id + * @return String 对应年份 + * @author youHong.ai ****************************************** + */ + @Select("select nf from uf_hrfunction where id = #{id}") + String selectYearById(Integer id); +} diff --git a/src/main/java/com/api/youhong/ai/pcn/mode/apadefaultyear/service/DefaultQueryYearService.java b/src/main/java/com/api/youhong/ai/pcn/mode/apadefaultyear/service/DefaultQueryYearService.java new file mode 100644 index 0000000..eacef05 --- /dev/null +++ b/src/main/java/com/api/youhong/ai/pcn/mode/apadefaultyear/service/DefaultQueryYearService.java @@ -0,0 +1,33 @@ +package com.api.youhong.ai.pcn.mode.apadefaultyear.service; + +import aiyh.utils.Util; +import cn.hutool.core.lang.Assert; +import com.api.youhong.ai.pcn.mode.apadefaultyear.mapper.DefaultQueryYearMapper; + +/** + *

获取年份

+ * + *

create: 2023-01-05 15:02

+ * + * @author youHong.ai + */ + +public class DefaultQueryYearService { + + + private final DefaultQueryYearMapper mapper = Util.getMapper(DefaultQueryYearMapper.class); + + /** + *

getYear 查询默认搜索年份

+ * 2023/1/5 15:06 + * ************************************************************ + * + * @return String 默认搜索年份 + * @author youHong.ai ****************************************** + */ + public String getYear() { + String year = mapper.selectYearById(1); + Assert.notBlank(year, "query year is null or blank!"); + return year; + } +} diff --git a/src/main/java/weaver/youhong/ai/pcn/schedule/addrolebyhasundering/RegisterRoleMemberByHasUnderingCronJob.java b/src/main/java/weaver/youhong/ai/pcn/schedule/addrolebyhasundering/RegisterRoleMemberByHasUnderingCronJob.java new file mode 100644 index 0000000..29cf61c --- /dev/null +++ b/src/main/java/weaver/youhong/ai/pcn/schedule/addrolebyhasundering/RegisterRoleMemberByHasUnderingCronJob.java @@ -0,0 +1,64 @@ +package weaver.youhong.ai.pcn.schedule.addrolebyhasundering; + +import aiyh.utils.Util; +import aiyh.utils.action.CusBaseCronJob; +import aiyh.utils.annotation.ActionDefaultTestValue; +import aiyh.utils.annotation.ActionDesc; +import aiyh.utils.annotation.PrintParamMark; +import aiyh.utils.annotation.RequiredMark; +import com.alibaba.fastjson.JSON; +import com.engine.common.util.ServiceUtil; +import com.engine.hrm.service.impl.RolesMembersServiceImpl; +import lombok.Getter; +import lombok.Setter; +import weaver.hrm.User; +import weaver.youhong.ai.pcn.schedule.addrolebyhasundering.mapper.RegisterRoleMemberByHasUnderingCronJobMapper; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + *

将有下属的用户添加到指定的角色

+ * + *

create: 2023-01-10 15:20

+ * + * @author youHong.ai + */ +@ActionDesc(author = "youHong.ai", value = "将有下属的用户添加到指定的角色") +@Getter +@Setter +public class RegisterRoleMemberByHasUnderingCronJob extends CusBaseCronJob { + + private final RegisterRoleMemberByHasUnderingCronJobMapper mapper = Util.getMapper(RegisterRoleMemberByHasUnderingCronJobMapper.class); + + @RequiredMark("角色id") + @PrintParamMark + @ActionDefaultTestValue("2") + private String roleId; + + @Override + public void runCode() { + List resourcesIds = mapper.selectResources(); + if (Objects.isNull(resourcesIds) || resourcesIds.isEmpty()) { + log.info(Util.logStr("can not query resourceIds")); + return; + } + User user = new User(1); + RolesMembersServiceImpl service = ServiceUtil.getService(RolesMembersServiceImpl.class, user); + Map map = new HashMap<>(); + map.put("roleId", roleId); + map.put("resourcetype", 1); + map.put("resourceid", Util.intJoin(resourcesIds, ",")); + map.put("rolelevel", 2); + map.put("cmd", "addRolesMembers"); + Map result = service.saveRolesMembers(map, user); + String status = Util.null2String(result.get("status")); + if (!"1".equals(status)) { + log.error(Util.logStr("add roles members fail!, service params is [{}],service return result is [{}]", + JSON.toJSONString(map), + JSON.toJSONString(result))); + } + } +} diff --git a/src/main/java/weaver/youhong/ai/pcn/schedule/addrolebyhasundering/mapper/RegisterRoleMemberByHasUnderingCronJobMapper.java b/src/main/java/weaver/youhong/ai/pcn/schedule/addrolebyhasundering/mapper/RegisterRoleMemberByHasUnderingCronJobMapper.java new file mode 100644 index 0000000..3fc041d --- /dev/null +++ b/src/main/java/weaver/youhong/ai/pcn/schedule/addrolebyhasundering/mapper/RegisterRoleMemberByHasUnderingCronJobMapper.java @@ -0,0 +1,23 @@ +package weaver.youhong.ai.pcn.schedule.addrolebyhasundering.mapper; + +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; + +import java.util.List; + +/** + *

添加人力资源人员到角色成员中

+ * + *

create: 2023-01-04 15:07

+ * + * @author youHong.ai + */ + +@SqlMapper +public interface RegisterRoleMemberByHasUnderingCronJobMapper { + + + @Select("select MANAGERID " + + "from hrmresource where MANAGERID <> 0 and MANAGERID is not null group by MANAGERID") + List selectResources(); +} diff --git a/src/main/java/weaver/youhong/ai/pcn/schedule/addrolemember/RegisterRoleMemberCronJob.java b/src/main/java/weaver/youhong/ai/pcn/schedule/addrolemember/RegisterRoleMemberCronJob.java new file mode 100644 index 0000000..1cecb99 --- /dev/null +++ b/src/main/java/weaver/youhong/ai/pcn/schedule/addrolemember/RegisterRoleMemberCronJob.java @@ -0,0 +1,76 @@ +package weaver.youhong.ai.pcn.schedule.addrolemember; + +import aiyh.utils.Util; +import aiyh.utils.action.CusBaseCronJob; +import aiyh.utils.annotation.ActionDefaultTestValue; +import aiyh.utils.annotation.ActionDesc; +import aiyh.utils.annotation.PrintParamMark; +import aiyh.utils.annotation.RequiredMark; +import com.alibaba.fastjson.JSON; +import com.engine.common.util.ServiceUtil; +import com.engine.hrm.service.impl.RolesMembersServiceImpl; +import lombok.Getter; +import lombok.Setter; +import weaver.hrm.User; +import weaver.youhong.ai.pcn.schedule.addrolemember.mapper.RegisterRoleMemberMapper; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + *

添加指定条件的人力资源人员到角色成员中

+ * + *

create: 2023-01-04 14:58

+ * + * @author youHong.ai + */ + +@ActionDesc(author = "youHong.ai", value = "添加指定条件的人力资源人员到角色成员中") +@Getter +@Setter +public class RegisterRoleMemberCronJob extends CusBaseCronJob { + + private final RegisterRoleMemberMapper mapper = Util.getMapper(RegisterRoleMemberMapper.class); + + @RequiredMark("职级字段的字段名称") + @PrintParamMark + @ActionDefaultTestValue("field3") + private String rankField; + + @RequiredMark("角色id") + @PrintParamMark + @ActionDefaultTestValue("2") + private String roleId; + + @RequiredMark("对应职级id,多个id用','分割,如7,8") + @PrintParamMark + @ActionDefaultTestValue("7,8") + private String rankIds; + + @Override + public void runCode() { + List resourcesIds = mapper.selectResources(rankField, rankIds); + if (Objects.isNull(resourcesIds) || resourcesIds.isEmpty()) { + log.info(Util.logStr("can not query resourceIds by [{}] in [{}]", rankField, rankIds)); + return; + } + User user = new User(1); + RolesMembersServiceImpl service = ServiceUtil.getService(RolesMembersServiceImpl.class, user); + Map map = new HashMap<>(); + map.put("roleId", roleId); + map.put("resourcetype", 1); + map.put("resourceid", Util.intJoin(resourcesIds, ",")); + map.put("rolelevel", 2); + map.put("cmd", "addRolesMembers"); + Map result = service.saveRolesMembers(map, user); + String status = Util.null2String(result.get("status")); + if (!"1".equals(status)) { + log.error(Util.logStr("add roles members fail!, service params is [{}],service return result is [{}]", + JSON.toJSONString(map), + JSON.toJSONString(result))); + } + } + +} diff --git a/src/main/java/weaver/youhong/ai/pcn/schedule/addrolemember/mapper/RegisterRoleMemberMapper.java b/src/main/java/weaver/youhong/ai/pcn/schedule/addrolemember/mapper/RegisterRoleMemberMapper.java new file mode 100644 index 0000000..3056fe0 --- /dev/null +++ b/src/main/java/weaver/youhong/ai/pcn/schedule/addrolemember/mapper/RegisterRoleMemberMapper.java @@ -0,0 +1,31 @@ +package weaver.youhong.ai.pcn.schedule.addrolemember.mapper; + +import aiyh.utils.annotation.recordset.ParamMapper; +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; + +import java.util.List; + +/** + *

添加人力资源人员到角色成员中

+ * + *

create: 2023-01-04 15:07

+ * + * @author youHong.ai + */ + +@SqlMapper +public interface RegisterRoleMemberMapper { + + @Select( + "select hrm.id\n " + + "from hrmresource hrm \n " + + " inner join cus_fielddata cus \n " + + " on cus.ID = hrm.ID \n " + + " and cus.SCOPEID = 1 \n " + + " and cus.SCOPE = 'HrmCustomFieldByInfoType' \n" + + " and cus.$t{rankField} in ($t{rankIds})" + ) + List selectResources(@ParamMapper("rankField") String rankField, + @ParamMapper("rankIds") String rankIds); +} diff --git a/src/test/java/youhong/ai/pcn/RolesTest.java b/src/test/java/youhong/ai/pcn/RolesTest.java new file mode 100644 index 0000000..fc2716b --- /dev/null +++ b/src/test/java/youhong/ai/pcn/RolesTest.java @@ -0,0 +1,61 @@ +package youhong.ai.pcn; + +import aiyh.utils.GenerateFileUtil; +import aiyh.utils.Util; +import basetest.BaseTest; +import com.engine.common.util.ServiceUtil; +import com.engine.hrm.service.impl.RolesMembersServiceImpl; +import org.junit.Test; +import weaver.hrm.User; +import weaver.youhong.ai.pcn.schedule.addrolebyhasundering.RegisterRoleMemberByHasUnderingCronJob; +import weaver.youhong.ai.pcn.schedule.addrolemember.RegisterRoleMemberCronJob; + +import java.util.HashMap; +import java.util.Map; + +/** + *

+ * + *

create: 2023-01-04 13:38

+ * + * @author youHong.ai + */ + +public class RolesTest extends BaseTest { + + + @Test + public void test() { + User user = new User(1); + RolesMembersServiceImpl service = ServiceUtil.getService(RolesMembersServiceImpl.class, user); + Map map = new HashMap<>(); + map.put("roleId", 2); + map.put("resourcetype", 1); + map.put("resourceid", 90); + map.put("rolelevel", 2); + map.put("cmd", "addRolesMembers"); + Map stringObjectMap = service.saveRolesMembers(map, user); + System.out.println(stringObjectMap); + /* String sql = " INSERT INTO HrmRoleMembers ( roleid ,resourceid ,rolelevel ,resourcetype ,alllevel ," + + " seclevelfrom ,seclevelto ,subdepid ,jobtitlelevel) " + + " VALUES ( " + roleId + ", " + arrObjIds[i] + " , '" + rolelevel + "', '" + resourcetype + "', " + + " " + (alllevel.length() == 0 ? "null" : alllevel) + "," + + (seclevelfrom.length() == 0 ? "null" : seclevelfrom) + "," + + " " + (seclevelto.length() == 0 ? "null" : seclevelto) + ", " + + (subdepid.length() == 0 ? "null" : "'" + subdepid + "'") + "," + + (jobtitlelevel.length() == 0 ? "null" : jobtitlelevel) + ")";*/ + } + + + @Test + public void testCronJob() { + Util.cronJobTest(RegisterRoleMemberCronJob.class); + } + + + @Test + public void generateDoc() { + GenerateFileUtil.createCronJobDocument(RegisterRoleMemberByHasUnderingCronJob.class); + } + +}