From 08a9ab7b0dac374d5dea15692fda04c04c5ea96c Mon Sep 17 00:00:00 2001 From: dxfeng Date: Wed, 10 Aug 2022 15:25:34 +0800 Subject: [PATCH] =?UTF-8?q?BUG=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/hrmresource/SystemDataMapper.java | 1 + .../mapper/hrmresource/SystemDataMapper.xml | 7 ++ .../service/impl/StaffServiceImpl.java | 65 ++++++++++++++----- .../cusfielddata/CusFieldDataTrigger.java | 19 +++--- .../organization/wrapper/JclOrgWrapper.java | 2 +- 5 files changed, 70 insertions(+), 24 deletions(-) diff --git a/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.java b/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.java index 1beec466..5389c1a3 100644 --- a/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.java +++ b/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.java @@ -72,5 +72,6 @@ public interface SystemDataMapper { int updateCusFieldData(CusFieldData cusFieldData); + Long getHrmResourceMaxId(); } diff --git a/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.xml b/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.xml index f7626da1..497b989e 100644 --- a/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.xml +++ b/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.xml @@ -32,6 +32,9 @@ update cus_fielddata + field100001=#{field100001}, + field100002=#{field100002}, + field100003=#{field100003}, field100008=#{field100008}, field100006=#{field100006}, field100007=#{field100007}, @@ -167,6 +170,10 @@ and scopeid = #{scopeId} and id = #{id} + \ No newline at end of file diff --git a/src/com/engine/organization/service/impl/StaffServiceImpl.java b/src/com/engine/organization/service/impl/StaffServiceImpl.java index 7a3c76c5..b798a96d 100644 --- a/src/com/engine/organization/service/impl/StaffServiceImpl.java +++ b/src/com/engine/organization/service/impl/StaffServiceImpl.java @@ -13,6 +13,7 @@ import com.engine.organization.entity.browser.po.CustomBrowserBean; import com.engine.organization.entity.staff.bo.StaffBO; import com.engine.organization.entity.staff.param.StaffSearchParam; import com.engine.organization.entity.staff.po.StaffPO; +import com.engine.organization.entity.staff.po.StaffPlanPO; import com.engine.organization.entity.staff.po.StaffsPO; import com.engine.organization.entity.staff.vo.StaffTableVO; import com.engine.organization.mapper.comp.CompMapper; @@ -87,6 +88,7 @@ public class StaffServiceImpl extends Service implements StaffService { public int saveStaff(StaffSearchParam param) { HasRightUtil.hasRight(user, RIGHT_NAME, false); StaffPO staffPO = StaffBO.convertParamToPO(param, (long) user.getUID()); + checkRequired(staffPO); return getStaffMapper().insertIgnoreNull(staffPO); } @@ -95,7 +97,7 @@ public class StaffServiceImpl extends Service implements StaffService { HasRightUtil.hasRight(user, RIGHT_NAME, false); StaffPO staffByID = getStaffMapper().getStaffByID(param.getId()); StaffPO staffPO = StaffBO.convertParamToPO(param, (long) user.getUID()); - + checkRequired(staffPO); Integer changeNum = param.getChangeNum(); if (null == changeNum) { // 插入明细表数据 @@ -228,20 +230,26 @@ public class StaffServiceImpl extends Service implements StaffService { planIdItemBean.setReplaceDatas(planIdMaps); planIdItem.setBrowserConditionParam(planIdItemBean); - BrowserBean compIdItemBean = compIdItem.getBrowserConditionParam(); - List> compIdMaps = getCompMapper().listCompsByIds(DeleteParam.builder().ids(staffPO.getCompId().toString()).build().getIds()); - compIdItemBean.setReplaceDatas(compIdMaps); - compIdItem.setBrowserConditionParam(compIdItemBean); - - BrowserBean deptIdItemBean = deptIdItem.getBrowserConditionParam(); - List> deptIdMaps = getDepartmentMapper().listDeptsByIds(DeleteParam.builder().ids(staffPO.getDeptId().toString()).build().getIds()); - deptIdItemBean.setReplaceDatas(deptIdMaps); - deptIdItem.setBrowserConditionParam(deptIdItemBean); - - BrowserBean jobIdItemBean = jobIdItem.getBrowserConditionParam(); - List> jobIdMaps = getJobMapper().listJobsByIds(DeleteParam.builder().ids(staffPO.getJobId().toString()).build().getIds()); - jobIdItemBean.setReplaceDatas(jobIdMaps); - jobIdItem.setBrowserConditionParam(jobIdItemBean); + if (null != staffPO.getCompId()) { + BrowserBean compIdItemBean = compIdItem.getBrowserConditionParam(); + List> compIdMaps = getCompMapper().listCompsByIds(DeleteParam.builder().ids(staffPO.getCompId().toString()).build().getIds()); + compIdItemBean.setReplaceDatas(compIdMaps); + compIdItem.setBrowserConditionParam(compIdItemBean); + } + + if (null != staffPO.getDeptId()) { + BrowserBean deptIdItemBean = deptIdItem.getBrowserConditionParam(); + List> deptIdMaps = getDepartmentMapper().listDeptsByIds(DeleteParam.builder().ids(staffPO.getDeptId().toString()).build().getIds()); + deptIdItemBean.setReplaceDatas(deptIdMaps); + deptIdItem.setBrowserConditionParam(deptIdItemBean); + } + + if (null != staffPO.getJobId()) { + BrowserBean jobIdItemBean = jobIdItem.getBrowserConditionParam(); + List> jobIdMaps = getJobMapper().listJobsByIds(DeleteParam.builder().ids(staffPO.getJobId().toString()).build().getIds()); + jobIdItemBean.setReplaceDatas(jobIdMaps); + jobIdItem.setBrowserConditionParam(jobIdItemBean); + } staffNumItem.setValue(staffPO.getStaffNum()); controlPolicyItem.setValue(staffPO.getControlPolicy() + ""); @@ -353,4 +361,31 @@ public class StaffServiceImpl extends Service implements StaffService { return sqlWhere; } + /** + * 校验必填字段 + * + * @param staffPO + */ + private void checkRequired(StaffPO staffPO) { + // 根据维度、校验必填字段 + StaffPlanPO staffPlanByID = getStaffPlanMapper().getStaffPlanByID(staffPO.getPlanId()); + switch (staffPlanByID.getControlDimension()) { + case "1":// 分部 + OrganizationAssert.notNull(staffPO.getCompId(), "编制维度选择分部时,分部必填!"); + break; + case "2":// 部门 + OrganizationAssert.notNull(staffPO.getCompId(), "编制维度选择部门时,分部必填!"); + OrganizationAssert.notNull(staffPO.getDeptId(), "编制维度选择部门时,部门必填!"); + break; + case "3": // 岗位 + OrganizationAssert.notNull(staffPO.getCompId(), "编制维度选择岗位时,分部必填!"); + OrganizationAssert.notNull(staffPO.getDeptId(), "编制维度选择岗位时,部门必填!"); + OrganizationAssert.notNull(staffPO.getJobId(), "编制维度选择岗位时,岗位必填!"); + break; + default: + break; + + } + } + } diff --git a/src/com/engine/organization/trigger/cusfielddata/CusFieldDataTrigger.java b/src/com/engine/organization/trigger/cusfielddata/CusFieldDataTrigger.java index 73786857..f5615bf5 100644 --- a/src/com/engine/organization/trigger/cusfielddata/CusFieldDataTrigger.java +++ b/src/com/engine/organization/trigger/cusfielddata/CusFieldDataTrigger.java @@ -34,7 +34,11 @@ public class CusFieldDataTrigger { public static void run(Long id) { if (null == id) { - return; + // 查询人员表最新插入的ID + id = MapperProxyFactory.getProxy(SystemDataMapper.class).getHrmResourceMaxId(); + if (null == id) { + return; + } } boolean updateFlag = false; // 查询当前操作的数据 @@ -50,14 +54,12 @@ public class CusFieldDataTrigger { directionData.setScope("HrmCustomFieldByInfoType"); directionData.setScopeId(3L); directionData.setId(id); - directionData.setField100001(sourceField100001); - directionData.setField100002(sourceField100002); - directionData.setField100003(sourceField100003); MapperProxyFactory.getProxy(SystemDataMapper.class).insertCusFieldData(directionData); } // field100001更新 if (null != sourceField100001 && sourceField100001.split("_").length == 2 && !sourceField100001.equals(directionData.getField100001())) { + directionData.setField100001(sourceField100001); String[] field100001Array = sourceField100001.split("_"); // 职等 long zdId = Long.parseLong(field100001Array[1]); @@ -79,9 +81,9 @@ public class CusFieldDataTrigger { } // field100002更新 - if (null != sourceField100002 && sourceField100002.split("_").length == 2 && !sourceField100002.equals(directionData.getField100002())) { - String[] field100002Array = sourceField100002.split("_"); - Long gwId = Long.parseLong(field100002Array[1]); + if (null != sourceField100002 && !sourceField100002.equals(directionData.getField100002())) { + directionData.setField100002(sourceField100002); + Long gwId = Long.parseLong(sourceField100002); JobPO jobById = MapperProxyFactory.getProxy(JobMapper.class).getJobById(gwId); JSONObject hrmJobTitleByName = MapperProxyFactory.getProxy(SystemDataMapper.class).getHrmJobTitleByName(jobById.getJobName()); Long ecGwId = hrmJobTitleByName.getLong("id"); @@ -94,11 +96,12 @@ public class CusFieldDataTrigger { hrmResourceMap.put("departmentid", ecBmId); // 公司 hrmResourceMap.put("subcompanyid1", ecGsId); - MapperProxyFactory.getProxy(ExtMapper.class).updateExt(ExtendInfoParams.builder().id(id).tableName("").params(hrmResourceMap).build()); + MapperProxyFactory.getProxy(ExtMapper.class).updateExt(ExtendInfoParams.builder().id(id).tableName("hrmresource").params(hrmResourceMap).build()); updateFlag = true; } if (null != sourceField100003 && sourceField100003.split("_").length == 2 && !sourceField100003.equals(directionData.getField100003())) { + directionData.setField100003(sourceField100003); String[] field100003Array = sourceField100003.split("_"); long zwId = Long.parseLong(field100003Array[1]); // 职务 diff --git a/src/com/engine/organization/wrapper/JclOrgWrapper.java b/src/com/engine/organization/wrapper/JclOrgWrapper.java index b3ae6dab..1f75a4c9 100644 --- a/src/com/engine/organization/wrapper/JclOrgWrapper.java +++ b/src/com/engine/organization/wrapper/JclOrgWrapper.java @@ -55,6 +55,6 @@ public class JclOrgWrapper extends OrganizationWrapper { } public void syncCusFieldData(String id) { - new CusFieldDataTrigger().run(Long.parseLong(id)); + new CusFieldDataTrigger().run(StringUtils.isNotBlank(id) ? Long.parseLong(id) : null); } }