From 7c358fe3a0a3707cce57ead008676dfd04b59615 Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Sun, 9 Oct 2022 17:51:30 +0800 Subject: [PATCH] =?UTF-8?q?xzy-fix-=E8=96=AA=E8=B5=84=E6=A1=A3=E6=A1=88?= =?UTF-8?q?=E4=B8=AD=E9=BB=98=E8=AE=A4=E4=BA=BA=E5=91=98=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salarysob/SalaryEmployeeStatusEnum.java | 1 + .../service/impl/SalarySobServiceImpl.java | 111 ++++++++++++++++++ 2 files changed, 112 insertions(+) diff --git a/src/com/engine/salary/enums/salarysob/SalaryEmployeeStatusEnum.java b/src/com/engine/salary/enums/salarysob/SalaryEmployeeStatusEnum.java index 08798646e..b7b944b24 100644 --- a/src/com/engine/salary/enums/salarysob/SalaryEmployeeStatusEnum.java +++ b/src/com/engine/salary/enums/salarysob/SalaryEmployeeStatusEnum.java @@ -75,6 +75,7 @@ public enum SalaryEmployeeStatusEnum implements BaseEnum { return null; } + public static List parseByValues(List value) { ArrayList results = new ArrayList<>(); for (SalaryEmployeeStatusEnum statusEnum : SalaryEmployeeStatusEnum.values()) { diff --git a/src/com/engine/salary/service/impl/SalarySobServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobServiceImpl.java index e586cb2c3..85f80eeee 100644 --- a/src/com/engine/salary/service/impl/SalarySobServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySobServiceImpl.java @@ -18,10 +18,13 @@ import com.engine.salary.entity.salarysob.param.SalarySobDisableParam; import com.engine.salary.entity.salarysob.param.SalarySobDuplicateParam; import com.engine.salary.entity.salarysob.param.SalarySobListQueryParam; import com.engine.salary.entity.salarysob.po.*; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeListDTO; +import com.engine.salary.entity.taxagent.param.TaxAgentRangeQueryParam; import com.engine.salary.entity.taxagent.po.TaxAgentAdminPO; import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.enums.SalarySystemTypeEnum; import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.salarysob.SalarySobMapper; import com.engine.salary.service.*; @@ -68,6 +71,8 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { private SalarySobItemHideBiz salarySobItemHideService = new SalarySobItemHideBiz(); + private SalarySobRangeBiz salarySobRangeBiz = new SalarySobRangeBiz(); + private SalarySobMapper getSalarySobMapper() { return MapperProxyFactory.getProxy(SalarySobMapper.class); } @@ -98,6 +103,10 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { return ServiceUtil.getService(TaxAgentAdminServiceImpl.class, user); } + private TaxAgentManageRangeService getTaxAgentManageRangeService(User user) { + return ServiceUtil.getService(TaxAgentManageRangeServiceImpl.class, user); + } + @Override public SalarySobPO getById(Long id) { @@ -234,6 +243,7 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { if (CollectionUtils.isNotEmpty(salarySobPOS)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98403, "薪资账套名称已存在")); } + // 保存参数转换成薪资账套po SalarySobPO salarySobPO = SalarySobBO.convert2PO(saveParam, (long) user.getUID()); // 保存薪资账套 @@ -251,10 +261,13 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { saveDefaultEmpField(salarySobPO); // 新建薪资账套时,保存默认的薪资项目 saveDefaultItem(salarySobPO); + // 新建薪资账套时,保存默认的关联人员范围及从范围中排除 + saveDefaultEmployeeRange(salarySobPO); // 返回薪资账套的主键id return salarySobPO.getId(); } + /** * 新建薪资账套时,保存默认的员工信息字段 * @@ -322,6 +335,104 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { } } + /** + * @description 新建薪资账套时,保存默认的关联人员范围及从范围中排除 + * @return void + * @author Harryxzy + * @date 2022/10/9 15:30 + */ + private void saveDefaultEmployeeRange(SalarySobPO salarySobPO) { + // 获取人员范围列表 + TaxAgentRangeQueryParam queryParam = TaxAgentRangeQueryParam.builder().taxAgentId(salarySobPO.getTaxAgentId()).build(); + queryParam.setCurrent(1); + queryParam.setPageSize(100000); + List includeList = (List) getTaxAgentManageRangeService(user).listPageByParamAndIncludeType(queryParam, NumberUtils.INTEGER_ONE).getList(); + includeList.stream().forEach(item->{ + item.setEmployeeStatus(parseEnum2ValueStr(item.getEmployeeStatus())); + }); + // 获取从范围中排除 + List excludeList = (List) getTaxAgentManageRangeService(user).listPageByParamAndIncludeType(queryParam, NumberUtils.INTEGER_ZERO).getList(); + excludeList.stream().forEach(item->{ + item.setEmployeeStatus(parseEnum2ValueStr(item.getEmployeeStatus())); + }); + // 将TaxAgentManageRangeListDTO转换为SalarySobRangePO + List rangeList = convert2SalarySobRangePO(salarySobPO.getId(),includeList,excludeList); + // 保存SalarySobRangePO + if (CollectionUtils.isNotEmpty(rangeList)) { + salarySobRangeBiz.batchInsert(rangeList); + } + + } + + + /** + * @description 将TaxAgentManageRangeListDTO转换为SalarySobRangePO + * @return List + * @author Harryxzy + * @date 2022/10/9 16:06 + */ + private List convert2SalarySobRangePO(Long salarySobID,List includeList, List excludeList) { + Date now = new Date(); + ArrayList result = new ArrayList(); + // 关联人员范围 + includeList.stream().forEach(item->{ + SalarySobRangePO salarySobRangePO = SalarySobRangePO.builder() + .salarySobId(salarySobID) + .targetType(item.getTargetType().getValue()) + .targetId(item.getTargetId()) + .employeeStatuses(item.getEmployeeStatus()) + .includeType(1) + .creator(Long.valueOf(user.getUID())) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(0) + .build(); + result.add(salarySobRangePO); + }); + // 从范围中排除 + excludeList.stream().forEach(item->{ + SalarySobRangePO salarySobRangePO = SalarySobRangePO.builder() + .salarySobId(salarySobID) + .targetType(item.getTargetType().getValue()) + .targetId(item.getTargetId()) + .employeeStatuses(item.getEmployeeStatus()) + .includeType(0) + .creator(Long.valueOf(user.getUID())) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(0) + .build(); + result.add(salarySobRangePO); + }); + return result; + } + + + /** + * @description 将枚举的defaultLabel转换为value + * @return String + * @author Harryxzy + * @date 2022/10/9 16:56 + */ + private String parseEnum2ValueStr(String employeeStatus) { + String[] split = employeeStatus.split(","); + StringBuilder sb = new StringBuilder(); + for (SalaryEmployeeStatusEnum statusEnum : SalaryEmployeeStatusEnum.values()) { + for(int i =0;i