From 1db71a97ff00899a6e07a52542a1ea7093f14f2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Fri, 25 Mar 2022 18:05:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=96=AA=E8=B5=84=E8=B4=A6=E5=A5=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/biz/SalarySobAdjustRuleBiz.java | 44 +++ src/com/engine/salary/biz/SalarySobBiz.java | 12 + .../salary/biz/SalarySobCheckRuleBiz.java | 88 +++++ .../biz/SalarySobDefaultItemGroupBiz.java | 23 ++ .../salary/biz/SalarySobEmpFieldBiz.java | 18 + .../salarysob/bo/SalarySobAdjustRuleBO.java | 99 ++++++ .../salarysob/bo/SalarySobCheckRuleBO.java | 95 ++++++ .../entity/salarysob/bo/SalarySobItemBO.java | 7 +- .../salarysob/dto/SalaryItemBaseDTO.java | 26 ++ .../dto/SalarySobAdjustRuleListDTO.java | 48 +++ .../dto/SalarySobCheckRuleFormDTO.java | 53 +++ .../dto/SalarySobCheckRuleListDTO.java | 47 +++ .../param/SalarySobAdjustRuleQueryParam.java | 6 +- .../param/SalarySobAdjustRuleSaveParam.java | 30 +- .../salarysob/po/SalarySobAdjustRulePO.java | 2 + .../po/SalarySobDefaultItemGroupPO.java | 2 + src/com/engine/salary/init.sql | 3 + .../salarysob/SalarySobAdjustRuleMapper.java | 82 +++++ .../salarysob/SalarySobAdjustRuleMapper.xml | 321 ++++++++++++++++++ .../salarysob/SalarySobCheckRuleMapper.java | 87 +++++ .../salarysob/SalarySobCheckRuleMapper.xml | 308 +++++++++++++++++ .../service/SalarySobAdjustRuleService.java | 47 +++ .../service/SalarySobCheckRuleService.java | 102 ++++++ .../SalarySobDefaultEmpFieldService.java | 10 +- .../impl/SalarySobAdjustRuleServiceImpl.java | 85 +++++ .../impl/SalarySobCheckRuleServiceImpl.java | 191 +++++++++++ .../impl/SalarySobItemServiceImpl.java | 92 +++-- .../impl/SalarySobRangeServiceImpl.java | 2 +- .../service/impl/SalarySobServiceImpl.java | 163 ++++----- .../engine/salary/util/ResponseResult.java | 1 - .../salary/web/SalarySobController.java | 221 +++++++----- .../wrapper/SalarySobAdjustRuleWrapper.java | 96 ++++++ .../wrapper/SalarySobCheckRuleWrapper.java | 118 +++++++ .../salary/wrapper/SalarySobItemWrapper.java | 26 +- 34 files changed, 2332 insertions(+), 223 deletions(-) create mode 100644 src/com/engine/salary/biz/SalarySobAdjustRuleBiz.java create mode 100644 src/com/engine/salary/biz/SalarySobCheckRuleBiz.java create mode 100644 src/com/engine/salary/biz/SalarySobDefaultItemGroupBiz.java create mode 100644 src/com/engine/salary/entity/salarysob/bo/SalarySobAdjustRuleBO.java create mode 100644 src/com/engine/salary/entity/salarysob/bo/SalarySobCheckRuleBO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalaryItemBaseDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobAdjustRuleListDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobCheckRuleFormDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobCheckRuleListDTO.java create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobAdjustRuleMapper.java create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobAdjustRuleMapper.xml create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobCheckRuleMapper.java create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobCheckRuleMapper.xml create mode 100644 src/com/engine/salary/service/SalarySobAdjustRuleService.java create mode 100644 src/com/engine/salary/service/SalarySobCheckRuleService.java create mode 100644 src/com/engine/salary/service/impl/SalarySobAdjustRuleServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalarySobCheckRuleServiceImpl.java create mode 100644 src/com/engine/salary/wrapper/SalarySobAdjustRuleWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalarySobCheckRuleWrapper.java diff --git a/src/com/engine/salary/biz/SalarySobAdjustRuleBiz.java b/src/com/engine/salary/biz/SalarySobAdjustRuleBiz.java new file mode 100644 index 000000000..a7c78feeb --- /dev/null +++ b/src/com/engine/salary/biz/SalarySobAdjustRuleBiz.java @@ -0,0 +1,44 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO; +import com.engine.salary.mapper.salarysob.SalarySobAdjustRuleMapper; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.Collection; +import java.util.List; + +public class SalarySobAdjustRuleBiz { + + public List listBySalarySobId(Long salarySobId) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobAdjustRuleMapper mapper = sqlSession.getMapper(SalarySobAdjustRuleMapper.class); + return mapper.listSome(SalarySobAdjustRulePO.builder().salarySobId(salarySobId).build()); + } finally { + sqlSession.close(); + } + } + + public void deleteBySalarySobIds(Collection salarySobIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobAdjustRuleMapper mapper = sqlSession.getMapper(SalarySobAdjustRuleMapper.class); + mapper.deleteBySalarySobIds(salarySobIds); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void batchInsert(Collection salarySobAdjustRulePOS) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobAdjustRuleMapper mapper = sqlSession.getMapper(SalarySobAdjustRuleMapper.class); + mapper.batchInsert(salarySobAdjustRulePOS); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/SalarySobBiz.java b/src/com/engine/salary/biz/SalarySobBiz.java index a96758926..a2a94c9ff 100644 --- a/src/com/engine/salary/biz/SalarySobBiz.java +++ b/src/com/engine/salary/biz/SalarySobBiz.java @@ -5,6 +5,7 @@ import com.engine.salary.mapper.salarysob.SalarySobMapper; import org.apache.ibatis.session.SqlSession; import weaver.conn.mybatis.MyBatisFactory; +import java.util.Collection; import java.util.List; public class SalarySobBiz { @@ -61,4 +62,15 @@ public class SalarySobBiz { } } + + public void deleteByIds(Collection ids) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobMapper mapper = sqlSession.getMapper(SalarySobMapper.class); + mapper.deleteByIds(ids); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } } diff --git a/src/com/engine/salary/biz/SalarySobCheckRuleBiz.java b/src/com/engine/salary/biz/SalarySobCheckRuleBiz.java new file mode 100644 index 000000000..9e3e9fb01 --- /dev/null +++ b/src/com/engine/salary/biz/SalarySobCheckRuleBiz.java @@ -0,0 +1,88 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.salarysob.po.SalarySobCheckRulePO; +import com.engine.salary.mapper.salarysob.SalarySobCheckRuleMapper; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.Collection; +import java.util.List; + +public class SalarySobCheckRuleBiz { + + + public SalarySobCheckRulePO getById(Long id) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobCheckRuleMapper mapper = sqlSession.getMapper(SalarySobCheckRuleMapper.class); + return mapper.getById(id); + } finally { + sqlSession.close(); + } + } + + public List listSome(SalarySobCheckRulePO build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobCheckRuleMapper mapper = sqlSession.getMapper(SalarySobCheckRuleMapper.class); + return mapper.listSome(build); + } finally { + sqlSession.close(); + } + } + + public void deleteByIds(Collection ids) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobCheckRuleMapper mapper = sqlSession.getMapper(SalarySobCheckRuleMapper.class); + mapper.deleteByIds(ids); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void updateById(SalarySobCheckRulePO newSalarySobCheckRulePO) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobCheckRuleMapper mapper = sqlSession.getMapper(SalarySobCheckRuleMapper.class); + mapper.updateIgnoreNull(newSalarySobCheckRulePO); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void batchInsert(Collection salarySobCheckRulePOS) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobCheckRuleMapper mapper = sqlSession.getMapper(SalarySobCheckRuleMapper.class); + mapper.batchInsert(salarySobCheckRulePOS); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void insert(SalarySobCheckRulePO salarySobCheckRulePO) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobCheckRuleMapper mapper = sqlSession.getMapper(SalarySobCheckRuleMapper.class); + mapper.insertIgnoreNull(salarySobCheckRulePO); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void deleteBySalarySobIds(Collection salarySobIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobCheckRuleMapper mapper = sqlSession.getMapper(SalarySobCheckRuleMapper.class); + mapper.deleteBySalarySobIds(salarySobIds); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/SalarySobDefaultItemGroupBiz.java b/src/com/engine/salary/biz/SalarySobDefaultItemGroupBiz.java new file mode 100644 index 000000000..e9cde90f0 --- /dev/null +++ b/src/com/engine/salary/biz/SalarySobDefaultItemGroupBiz.java @@ -0,0 +1,23 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.salarysob.po.SalarySobDefaultItemGroupPO; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import com.engine.salary.mapper.salarysob.SalarySobDefaultItemGroupMapper; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.List; + +public class SalarySobDefaultItemGroupBiz { + + public List listByIncomeCategory(IncomeCategoryEnum incomeCategory) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobDefaultItemGroupMapper mapper = sqlSession.getMapper(SalarySobDefaultItemGroupMapper.class); + return mapper.listSome(SalarySobDefaultItemGroupPO.builder().incomeCategory(incomeCategory.getValue()).build()); + } finally { + sqlSession.close(); + } + } + +} diff --git a/src/com/engine/salary/biz/SalarySobEmpFieldBiz.java b/src/com/engine/salary/biz/SalarySobEmpFieldBiz.java index d75a75040..8fbe27e95 100644 --- a/src/com/engine/salary/biz/SalarySobEmpFieldBiz.java +++ b/src/com/engine/salary/biz/SalarySobEmpFieldBiz.java @@ -1,6 +1,8 @@ package com.engine.salary.biz; +import com.engine.salary.entity.salarysob.po.SalarySobDefaultEmpFieldPO; import com.engine.salary.entity.salarysob.po.SalarySobEmpFieldPO; +import com.engine.salary.mapper.salarysob.SalarySobDefaultEmpFieldMapper; import com.engine.salary.mapper.salarysob.SalarySobEmpFieldMapper; import org.apache.ibatis.session.SqlSession; import weaver.conn.mybatis.MyBatisFactory; @@ -44,4 +46,20 @@ public class SalarySobEmpFieldBiz { sqlSession.close(); } } + + + + //---------------------------系统默认员工信息字段----------------------------------- + + public List listDefaultEmpField() { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobDefaultEmpFieldMapper mapper = sqlSession.getMapper(SalarySobDefaultEmpFieldMapper.class); + return mapper.listAll(); + } finally { + sqlSession.close(); + } + } + + } diff --git a/src/com/engine/salary/entity/salarysob/bo/SalarySobAdjustRuleBO.java b/src/com/engine/salary/entity/salarysob/bo/SalarySobAdjustRuleBO.java new file mode 100644 index 000000000..f334d1775 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/bo/SalarySobAdjustRuleBO.java @@ -0,0 +1,99 @@ +package com.engine.salary.entity.salarysob.bo; + +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.dto.SalaryItemBaseDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobAdjustRuleListDTO; +import com.engine.salary.entity.salarysob.param.SalarySobAdjustRuleSaveParam; +import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO; +import com.engine.salary.util.SalaryEntityUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.math.NumberUtils; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 调薪规则 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobAdjustRuleBO { + + /** + * 调薪计薪规则po转换成调薪计薪规则列表dto + * + * @param salarySobAdjustRules 调薪计薪规则po + * @param salaryItems 薪资项目po + * @return + */ + public static List convert2ListDTO(List salarySobAdjustRules, List salaryItems) { + if (CollectionUtils.isEmpty(salarySobAdjustRules)) { + return Collections.emptyList(); + } + // key:薪资项目id、value:薪资项目的名称 + Map salaryItemNameMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getId, SalaryItemPO::getName); + return salarySobAdjustRules.stream() + .map(e -> SalarySobAdjustRuleListDTO.builder() + .id(e.getId()) + .salaryItemId(e.getSalaryItemId()) + .salaryItemName(salaryItemNameMap.getOrDefault(e.getSalaryItemId(), "")) + .dayOfMonth(e.getDayOfMonth()) + .beforeAdjustmentType(e.getBeforeAdjustmentType()) + .afterAdjustmentType(e.getAfterAdjustmentType()) + .build()) + .collect(Collectors.toList()); + } + + /** + * 转换成调薪计薪规则可选的薪资项目dto + * 只有开启了"薪资档案引用"的薪资项目才可选 + * + * @param salaryItems 薪资项目po + * @return + */ + public static List convertItemBaseDTO(List salaryItems) { + if (CollectionUtils.isEmpty(salaryItems)) { + return Collections.emptyList(); + } + // 过滤开启了"薪资档案引用"的薪资项目 + return salaryItems.stream() + .filter(salaryItemPO -> Objects.equals(salaryItemPO.getUseInEmployeeSalary(), NumberUtils.INTEGER_ONE)) + .map(salaryItemPO -> new SalaryItemBaseDTO() + .setSalaryItemId(salaryItemPO.getId()) + .setSalaryItemName(salaryItemPO.getName())) + .collect(Collectors.toList()); + + } + + /** + * 保存参数转换成薪资账套的调薪计薪规则po + * + * @param saveParam 保存参数 + * @param employeeId 人员id + * @return + */ + public static List convert2PO(SalarySobAdjustRuleSaveParam saveParam, Long employeeId) { + if (CollectionUtils.isEmpty(saveParam.getRuleParams())) { + return Collections.emptyList(); + } + Date now = new Date(); + return saveParam.getRuleParams().stream() + .map(ruleParam -> new SalarySobAdjustRulePO() +// .setId(IdGenerator.generate()) + .setSalarySobId(saveParam.getSalarySobId()) + .setSalaryItemId(ruleParam.getSalaryItemId()) + .setDayOfMonth(ruleParam.getDayOfMonth()) + .setBeforeAdjustmentType(ruleParam.getBeforeAdjustmentType()) + .setAfterAdjustmentType(ruleParam.getAfterAdjustmentType()) + .setCreator(employeeId) + .setCreateTime(now) + .setUpdateTime(now) + .setDeleteType(NumberUtils.INTEGER_ZERO) + .setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + ).collect(Collectors.toList()); + } +} diff --git a/src/com/engine/salary/entity/salarysob/bo/SalarySobCheckRuleBO.java b/src/com/engine/salary/entity/salarysob/bo/SalarySobCheckRuleBO.java new file mode 100644 index 000000000..b1e52960f --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/bo/SalarySobCheckRuleBO.java @@ -0,0 +1,95 @@ +package com.engine.salary.entity.salarysob.bo; + +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.salarysob.dto.SalarySobCheckRuleFormDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobCheckRuleListDTO; +import com.engine.salary.entity.salarysob.param.SalarySobCheckRuleSaveParam; +import com.engine.salary.entity.salarysob.po.SalarySobCheckRulePO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.weaver.excel.formula.api.entity.ExpressFormula; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪资账套的校验规则 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobCheckRuleBO { + + /** + * 保存参数转换成薪资账套的校验规则po + * + * @param saveParam 保存参数 + * @param employeeId 人员id + * @return + */ + public static SalarySobCheckRulePO convert2PO(SalarySobCheckRuleSaveParam saveParam, Long employeeId) { + if (Objects.isNull(saveParam)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, " 参数错误")); + } + Date now = new Date(); + return SalarySobCheckRulePO.builder() +// .id(IdGenerator.generate()) + .salarySobId(saveParam.getSalarySobId()) + .name(saveParam.getName()) + .formulaId(saveParam.getFormulaId()) + .description(saveParam.getDescription()) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(NumberUtils.INTEGER_ZERO) + .build(); + } + + /** + * 薪资账套的校验规则po转换成校验规则列表dto + * + * @param salarySobCheckRulePOS 薪资账套的校验规则po + * @param expressFormulas 公式详情 + * @return + */ + public static List convert2ListDTO(List salarySobCheckRulePOS, List expressFormulas) { + if (CollectionUtils.isEmpty(salarySobCheckRulePOS)) { + return Collections.emptyList(); + } + // key:公式id、value:公式详情 + Map formulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula); + return salarySobCheckRulePOS.stream() + .map(salarySobCheckRulePO -> new SalarySobCheckRuleListDTO() + .setId(salarySobCheckRulePO.getId()) + .setName(salarySobCheckRulePO.getName()) + .setSalarySobId(salarySobCheckRulePO.getSalarySobId()) + .setFormulaId(salarySobCheckRulePO.getFormulaId()) + .setFormulaContent(formulaMap.getOrDefault(salarySobCheckRulePO.getFormulaId(), StringUtils.EMPTY)) + .setDescription(salarySobCheckRulePO.getDescription()) + ).collect(Collectors.toList()); + } + + /** + * 转换成校验规则详情dto + * + * @param salarySobCheckRulePO 校验规则po + * @param expressFormula 公式详情 + * @return + */ + public static SalarySobCheckRuleFormDTO convert2FormDTO(SalarySobCheckRulePO salarySobCheckRulePO, ExpressFormula expressFormula) { + return new SalarySobCheckRuleFormDTO() + .setId(salarySobCheckRulePO.getId()) + .setName(salarySobCheckRulePO.getName()) + .setSalarySobId(salarySobCheckRulePO.getSalarySobId()) + .setFormulaId(salarySobCheckRulePO.getFormulaId()) + .setFormulaContent(Optional.ofNullable(expressFormula).map(ExpressFormula::getFormula).orElse(StringUtils.EMPTY)) + .setDescription(salarySobCheckRulePO.getDescription()); + } +} diff --git a/src/com/engine/salary/entity/salarysob/bo/SalarySobItemBO.java b/src/com/engine/salary/entity/salarysob/bo/SalarySobItemBO.java index f8801ee99..02599367e 100644 --- a/src/com/engine/salary/entity/salarysob/bo/SalarySobItemBO.java +++ b/src/com/engine/salary/entity/salarysob/bo/SalarySobItemBO.java @@ -1,5 +1,6 @@ package com.engine.salary.entity.salarysob.bo; +import com.engine.salary.constant.SalaryDefaultTenantConstant; import com.engine.salary.entity.salaryitem.po.SalaryItemPO; import com.engine.salary.entity.salarysob.po.*; import com.engine.salary.util.SalaryEntityUtil; @@ -33,10 +34,9 @@ public class SalarySobItemBO { * @param salarySobId 薪资账套id * @param defaultEmpFieldList 默认包含的员工信息字段 * @param employeeId 当前登陆人员id - * @param tenantKey 当前登陆人员的租户key * @return */ - public static List convert2EmpFieldPO(Long salarySobId, List defaultEmpFieldList, Long employeeId, String tenantKey) { + public static List convert2EmpFieldPO(Long salarySobId, List defaultEmpFieldList, Long employeeId) { Date now = new Date(); return defaultEmpFieldList.stream() .map(field -> new SalarySobEmpFieldPO() @@ -49,7 +49,7 @@ public class SalarySobItemBO { .setCreateTime(now) .setUpdateTime(now) .setDeleteType(0) - .setTenantKey(tenantKey)) + .setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)) .collect(Collectors.toList()); } @@ -98,6 +98,7 @@ public class SalarySobItemBO { .collect(Collectors.toMap(SalaryItemPO::getSysSalaryItemId, Function.identity(), (a, b) -> a)); for (SalarySobDefaultItemPO salarySobDefaultItemPO : salarySobDefaultItemPOS) { SalaryItemPO salaryItemPO = salaryItemPOMap.get(salarySobDefaultItemPO.getSysSalaryItemId()); + if (salaryItemPO==null)continue; salarySobItems.add(SalarySobItemPO.builder() // .id(IdGenerator.generate()) .salarySobId(salarySobId) diff --git a/src/com/engine/salary/entity/salarysob/dto/SalaryItemBaseDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalaryItemBaseDTO.java new file mode 100644 index 000000000..4b6266ff1 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalaryItemBaseDTO.java @@ -0,0 +1,26 @@ +package com.engine.salary.entity.salarysob.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +/** + * 薪资账套的薪资项目副本 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class SalaryItemBaseDTO { + //薪资项目id + private Long salaryItemId; + + //薪资项目名称 + private String salaryItemName; +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobAdjustRuleListDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobAdjustRuleListDTO.java new file mode 100644 index 000000000..208bc21a5 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobAdjustRuleListDTO.java @@ -0,0 +1,48 @@ +package com.engine.salary.entity.salarysob.dto; + +import com.engine.salary.enums.salarysob.SalarySobAdjustRuleTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 调薪规则列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobAdjustRuleListDTO { + + //主键id + private Long id; + + //薪资项目的id + private Long salaryItemId; + + //薪资项目的名称 + private String salaryItemName; + + //生效日期 + private Integer dayOfMonth; + + /** + * 在生效日期之前调薪如何调整 + * + * @see SalarySobAdjustRuleTypeEnum + */ + private Integer beforeAdjustmentType; + + /** + * 在生效日期之后调薪如何调整 + * + * @see SalarySobAdjustRuleTypeEnum + */ + private Integer afterAdjustmentType; +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobCheckRuleFormDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobCheckRuleFormDTO.java new file mode 100644 index 000000000..2dd4decd5 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobCheckRuleFormDTO.java @@ -0,0 +1,53 @@ +package com.engine.salary.entity.salarysob.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +/** + * 薪资账套校验规则表单 + */ +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobCheckRuleFormDTO { + + //主键id") + private Long id; + + //薪资账套id") +// @NotNull(message = "薪资账套id不允许为空") + private Long salarySobId; + +// @SalaryForm( +// label = "规则名称", +// labelId = 100173, +// items = @SalaryFormItem(itemType = WeaFormItemType.INPUT, required = true, maxLength = "15") +// ) + //规则名称") +// @NotEmpty(message = "规则名称不允许为空") + private String name; + + //公式id") +// @NotNull(message = "校验规则不允许为空") +// @Positive(message = "校验规则不允许为空") + private Long formulaId; + +// @SalaryForm( +// label = "校验规则", +// labelId = 86126, +// items = @SalaryFormItem(itemType = WeaFormItemType.INPUT, required = true) +// ) + //校验规则") + private String formulaContent; + +// @SalaryForm( +// label = "备注", +// labelId = 84961, +// items = @SalaryFormItem(itemType = WeaFormItemType.INPUT, maxLength = "20") +// ) + //备注") + private String description; +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobCheckRuleListDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobCheckRuleListDTO.java new file mode 100644 index 000000000..d0c07da84 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobCheckRuleListDTO.java @@ -0,0 +1,47 @@ +package com.engine.salary.entity.salarysob.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.SalaryTableOperate; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +/** + * 薪资账套校验规则列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-4d11-adn9-7d06e54y6rj8", tableType = WeaTableType.CHECKBOX, operates = { + @SalaryTableOperate(index = "0", text = "编辑"), + @SalaryTableOperate(index = "1", text = "删除"), +}) +public class SalarySobCheckRuleListDTO { + + //主键id + private Long id; + + //薪资账套id + private Long salarySobId; + + @SalaryTableColumn(text = "名称", width = "10%", column = "name") + private String name; + + //公式id + private Long formulaId; + + @SalaryTableColumn(text = "校验规则", width = "10%", column = "formulaContent") + private String formulaContent; + + @SalaryTableColumn(text = "备注", width = "10%", column = "description") + private String description; +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobAdjustRuleQueryParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobAdjustRuleQueryParam.java index 6ec5a7461..1b77845cc 100644 --- a/src/com/engine/salary/entity/salarysob/param/SalarySobAdjustRuleQueryParam.java +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobAdjustRuleQueryParam.java @@ -1,5 +1,6 @@ package com.engine.salary.entity.salarysob.param; +import com.engine.salary.util.valid.DataCheck; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -18,10 +19,7 @@ import lombok.NoArgsConstructor; @AllArgsConstructor public class SalarySobAdjustRuleQueryParam { - /** - * 薪资账套的ID不允许为空 - */ -// //@NotNull(message = "LABEL:86575") // //薪资账套的id") + @DataCheck(require = true, message = "薪资账套的ID不允许为空") private Long salarySobId; } diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobAdjustRuleSaveParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobAdjustRuleSaveParam.java index b69b722fd..58a39981f 100644 --- a/src/com/engine/salary/entity/salarysob/param/SalarySobAdjustRuleSaveParam.java +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobAdjustRuleSaveParam.java @@ -1,6 +1,7 @@ package com.engine.salary.entity.salarysob.param; import com.engine.salary.enums.salarysob.SalarySobAdjustRuleTypeEnum; +import com.engine.salary.util.valid.DataCheck; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -21,14 +22,11 @@ import java.util.List; @AllArgsConstructor public class SalarySobAdjustRuleSaveParam { - /** - * 薪资账套的ID不允许为空 - */ -// //@NotNull(message = "LABEL:86575") -// //薪资账套的id") + //薪资账套的id + @DataCheck(require = true, message = "薪资账套的ID不允许为空") private Long salarySobId; - //规则参数") + //规则参数 private List ruleParams; @Data @@ -37,16 +35,24 @@ public class SalarySobAdjustRuleSaveParam { @AllArgsConstructor public static class RuleParam { - //薪资项目的id") + //薪资项目的id private Long salaryItemId; - //生效日期") + //生效日期 private Integer dayOfMonth; - //在生效日期之前调薪如何调整") - private SalarySobAdjustRuleTypeEnum beforeAdjustmentType; + /** + * 在生效日期之前调薪如何调整 + * + * @see SalarySobAdjustRuleTypeEnum + */ + private Integer beforeAdjustmentType; - //在生效日期之后调薪如何调整") - private SalarySobAdjustRuleTypeEnum afterAdjustmentType; + /** + * 在生效日期之后调薪如何调整 + * + * @see SalarySobAdjustRuleTypeEnum + */ + private Integer afterAdjustmentType; } } diff --git a/src/com/engine/salary/entity/salarysob/po/SalarySobAdjustRulePO.java b/src/com/engine/salary/entity/salarysob/po/SalarySobAdjustRulePO.java index 86bd64c40..bf646ede5 100644 --- a/src/com/engine/salary/entity/salarysob/po/SalarySobAdjustRulePO.java +++ b/src/com/engine/salary/entity/salarysob/po/SalarySobAdjustRulePO.java @@ -2,6 +2,7 @@ package com.engine.salary.entity.salarysob.po; import com.engine.salary.enums.salarysob.SalarySobAdjustRuleTypeEnum; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; @@ -21,6 +22,7 @@ import java.util.Date; @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor +@Builder //hrsa_salary_sob_adjust_rule public class SalarySobAdjustRulePO { diff --git a/src/com/engine/salary/entity/salarysob/po/SalarySobDefaultItemGroupPO.java b/src/com/engine/salary/entity/salarysob/po/SalarySobDefaultItemGroupPO.java index 0c6ecd524..bca70753e 100644 --- a/src/com/engine/salary/entity/salarysob/po/SalarySobDefaultItemGroupPO.java +++ b/src/com/engine/salary/entity/salarysob/po/SalarySobDefaultItemGroupPO.java @@ -1,6 +1,7 @@ package com.engine.salary.entity.salarysob.po; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; @@ -17,6 +18,7 @@ import java.util.Date; * @version 1.0 **/ @Data +@Builder @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor diff --git a/src/com/engine/salary/init.sql b/src/com/engine/salary/init.sql index 015716eac..4825b79ad 100644 --- a/src/com/engine/salary/init.sql +++ b/src/com/engine/salary/init.sql @@ -12,6 +12,9 @@ alter table hrsa_salary_item modify id bigint auto_increment; alter table hrsa_salary_sob modify id bigint auto_increment; alter table hrsa_salary_sob_range modify id bigint auto_increment; alter table hrsa_salary_sob_item_group modify id bigint auto_increment; +alter table hrsa_salary_sob_emp_field modify id bigint auto_increment; +alter table hrsa_salary_sob_adjust_rule modify id bigint auto_increment; + --福利方案主键自增增加 diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobAdjustRuleMapper.java b/src/com/engine/salary/mapper/salarysob/SalarySobAdjustRuleMapper.java new file mode 100644 index 000000000..281e45521 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobAdjustRuleMapper.java @@ -0,0 +1,82 @@ +package com.engine.salary.mapper.salarysob; + +import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SalarySobAdjustRuleMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalarySobAdjustRulePO salarySobAdjustRule); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalarySobAdjustRulePO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salarySobAdjustRule 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalarySobAdjustRulePO salarySobAdjustRule); + + /** + * 修改,修改所有字段 + * + * @param salarySobAdjustRule 修改的记录 + * @return 返回影响行数 + */ + int update(SalarySobAdjustRulePO salarySobAdjustRule); + + /** + * 修改,忽略null字段 + * + * @param salarySobAdjustRule 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalarySobAdjustRulePO salarySobAdjustRule); + + /** + * 删除记录 + * + * @param salarySobAdjustRule 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalarySobAdjustRulePO salarySobAdjustRule); + + + /** + * 批量插入 + * + * @param salaryAdjustmentRules + */ + void batchInsert(@Param("collection") Collection salaryAdjustmentRules); + + /** + * 根据账套id批量删除 + * + * @param salarySobIds + */ + void deleteBySalarySobIds(@Param("salarySobIds") Collection salarySobIds); + + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobAdjustRuleMapper.xml b/src/com/engine/salary/mapper/salarysob/SalarySobAdjustRuleMapper.xml new file mode 100644 index 000000000..f91f06e11 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobAdjustRuleMapper.xml @@ -0,0 +1,321 @@ + + + + + + + + + + + + + + + + + + + + t + . + id + , t.salary_sob_id + , t.salary_item_id + , t.day_of_month + , t.before_adjustment_type + , t.after_adjustment_type + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_sob_adjust_rule + + + + id, + + + salary_sob_id, + + + salary_item_id, + + + day_of_month, + + + before_adjustment_type, + + + after_adjustment_type, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{salarySobId}, + + + #{salaryItemId}, + + + #{dayOfMonth}, + + + #{beforeAdjustmentType}, + + + #{afterAdjustmentType}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_salary_sob_adjust_rule + + salary_sob_id=#{salarySobId}, + salary_item_id=#{salaryItemId}, + day_of_month=#{dayOfMonth}, + before_adjustment_type=#{beforeAdjustmentType}, + after_adjustment_type=#{afterAdjustmentType}, + creator=#{creator}, + create_time=#{createTime}, + update_time=#{updateTime}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_adjust_rule + + + salary_sob_id=#{salarySobId}, + + + salary_item_id=#{salaryItemId}, + + + day_of_month=#{dayOfMonth}, + + + before_adjustment_type=#{beforeAdjustmentType}, + + + after_adjustment_type=#{afterAdjustmentType}, + + + creator=#{creator}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_adjust_rule + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + INSERT INTO hrsa_salary_sob_adjust_rule + ( salary_sob_id, salary_item_id, day_of_month, + before_adjustment_type, after_adjustment_type, creator, create_time, update_time, + delete_type, tenant_key) + VALUES + + ( + #{item.salarySobId}, + #{item.salaryItemId}, + #{item.dayOfMonth}, + #{item.beforeAdjustmentType}, + #{item.afterAdjustmentType}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_salary_sob_adjust_rule + ( salary_sob_id, salary_item_id, day_of_month, + before_adjustment_type, after_adjustment_type, creator, create_time, update_time, + delete_type, tenant_key) + + + select + #{item.salarySobId}, + #{item.salaryItemId}, + #{item.dayOfMonth}, + #{item.beforeAdjustmentType}, + #{item.afterAdjustmentType}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey} + from dual + + + + INSERT INTO hrsa_salary_sob_adjust_rule + (salary_sob_id, salary_item_id, day_of_month, + before_adjustment_type, after_adjustment_type, creator, create_time, update_time, + delete_type, tenant_key) + VALUES + + ( + #{item.salarySobId}, + #{item.salaryItemId}, + #{item.dayOfMonth}, + #{item.beforeAdjustmentType}, + #{item.afterAdjustmentType}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + + UPDATE hrsa_salary_sob_adjust_rule + SET delete_type = 1 + WHERE delete_type = 0 + AND salary_sob_id IN + + #{salarySobId} + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobCheckRuleMapper.java b/src/com/engine/salary/mapper/salarysob/SalarySobCheckRuleMapper.java new file mode 100644 index 000000000..de1b1a476 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobCheckRuleMapper.java @@ -0,0 +1,87 @@ +package com.engine.salary.mapper.salarysob; + +import com.engine.salary.entity.salarysob.po.SalarySobCheckRulePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SalarySobCheckRuleMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalarySobCheckRulePO salarySobCheckRule); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalarySobCheckRulePO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salarySobCheckRule 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalarySobCheckRulePO salarySobCheckRule); + + /** + * 修改,修改所有字段 + * + * @param salarySobCheckRule 修改的记录 + * @return 返回影响行数 + */ + int update(SalarySobCheckRulePO salarySobCheckRule); + + /** + * 修改,忽略null字段 + * + * @param salarySobCheckRule 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalarySobCheckRulePO salarySobCheckRule); + + /** + * 删除记录 + * + * @param salarySobCheckRule 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalarySobCheckRulePO salarySobCheckRule); + + /** + * 根据主键id删除 + * + * @param ids + */ + void deleteByIds(@Param("ids") Collection ids); + + /** + * 根据薪资账套id删除 + * + * @param salarySobIds + */ + void deleteBySalarySobIds(@Param("salarySobIds") Collection salarySobIds); + + /** + * 批量保存 + * + * @param salarySobCheckRules + */ + void batchInsert(@Param("collection") Collection salarySobCheckRules); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobCheckRuleMapper.xml b/src/com/engine/salary/mapper/salarysob/SalarySobCheckRuleMapper.xml new file mode 100644 index 000000000..06f81164e --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobCheckRuleMapper.xml @@ -0,0 +1,308 @@ + + + + + + + + + + + + + + + + + + + t + . + id + , t.salary_sob_id + , t.name + , t.formula_id + , t.description + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_sob_check_rule + + + + id, + + + salary_sob_id, + + + name, + + + formula_id, + + + description, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{salarySobId}, + + + #{name}, + + + #{formulaId}, + + + #{description}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_salary_sob_check_rule + + salary_sob_id=#{salarySobId}, + name=#{name}, + formula_id=#{formulaId}, + description=#{description}, + create_time=#{createTime}, + update_time=#{updateTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_check_rule + + + salary_sob_id=#{salarySobId}, + + + name=#{name}, + + + formula_id=#{formulaId}, + + + description=#{description}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_check_rule + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + UPDATE hrsa_salary_sob_check_rule + SET delete_type = 1 + WHERE tenant_key = #{tenantKey} AND delete_type = 0 + AND id IN + + #{id} + + + + + UPDATE hrsa_salary_sob_check_rule + SET delete_type = 1 + WHERE delete_type = 0 + AND salary_sob_id IN + + #{salarySobId} + + + + + INSERT INTO hrsa_salary_sob_check_rule( salary_sob_id, name, formula_id, description, create_time, + update_time, creator, delete_type, tenant_key) + VALUES + + ( + #{item.salarySobId}, + #{item.name}, + #{item.formulaId}, + #{item.description}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_salary_sob_check_rule(salary_sob_id, name, formula_id, description, create_time, + update_time, creator, delete_type, tenant_key) + + + select + #{item.salarySobId}, + #{item.name}, + #{item.formulaId}, + #{item.description}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.deleteType}, + #{item.tenantKey} + from dual + + + + INSERT INTO hrsa_salary_sob_check_rule(salary_sob_id, name, formula_id, description, create_time, + update_time, creator, delete_type, tenant_key) + VALUES + + ( + #{item.salarySobId}, + #{item.name}, + #{item.formulaId}, + #{item.description}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/service/SalarySobAdjustRuleService.java b/src/com/engine/salary/service/SalarySobAdjustRuleService.java new file mode 100644 index 000000000..18c326ebb --- /dev/null +++ b/src/com/engine/salary/service/SalarySobAdjustRuleService.java @@ -0,0 +1,47 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salarysob.param.SalarySobAdjustRuleSaveParam; +import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO; + +import java.util.Collection; +import java.util.List; + +/** + * 调薪计薪规则 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalarySobAdjustRuleService { + + /** + * 根据薪资账套id查询薪资账套的调薪计薪规则 + * + * @param salarySobId 薪资账套id + * @return + */ + List listBySalarySobId(Long salarySobId); + + /** + * 保存调薪计薪酬规则 + * + * @param saveParam + */ + void save(SalarySobAdjustRuleSaveParam saveParam); + + /** + * 批量保存 + * + * @param salarySobAdjustRulePOS 薪资账套的调薪计薪规则 + */ + void batchSave(Collection salarySobAdjustRulePOS); + + /** + * 根据薪资账套id删除调薪计薪酬规则 + * + * @param salarySobIds 薪资账套id + */ + void deleteBySalarySobIds(Collection salarySobIds); +} diff --git a/src/com/engine/salary/service/SalarySobCheckRuleService.java b/src/com/engine/salary/service/SalarySobCheckRuleService.java new file mode 100644 index 000000000..8a3d83dc5 --- /dev/null +++ b/src/com/engine/salary/service/SalarySobCheckRuleService.java @@ -0,0 +1,102 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salarysob.param.SalarySobCheckRuleSaveParam; +import com.engine.salary.entity.salarysob.param.UpdateCheckRuleFormulaParam; +import com.engine.salary.entity.salarysob.po.SalarySobCheckRulePO; + +import java.util.Collection; +import java.util.List; + +/** + * 薪资账套的校验规则 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalarySobCheckRuleService { + + /** + * 根据主键id获取单个薪资账套的校验规则 + * + * @param id 主键id + * @return + */ + SalarySobCheckRulePO getById(Long id); + + /** + * 根据主键id查询薪资账套的校验规则 + * + * @param ids 主键id + * @return + */ + List listByIds(Collection ids); + + /** + * 根据薪资账套id查询薪资账套的校验规则 + * + * @param salarySobId 薪资账套的id + * @return + */ + List listBySalarySobId(Long salarySobId); + + /** + * 根据薪资账套id、名称(精确匹配)查询薪资账套的校验规则 + * + * @param salarySobId 薪资账套的id + * @param name 名称 + * @return + */ + List listBySalarySobIdAndName(Long salarySobId, String name); + + /** + * 根据列表搜索条件查询薪资账套的校验规则(分页) + * + * @param queryParam 搜索条件 + * @return + */ +// Page listPageByParam(SalarySobCheckRuleQueryParam queryParam); + + /** + * 保存 + * + * @param saveParam 保存 + */ + void save(SalarySobCheckRuleSaveParam saveParam); + + /** + * 批量保存 + * + * @param salarySobCheckRulePOS 薪资账套的校验规则 + */ + void batchSave(Collection salarySobCheckRulePOS); + + /** + * 更新 + * + * @param updateParam 更新参数 + */ + void update(SalarySobCheckRuleSaveParam updateParam); + + /** + * 更新校验规则的公式 + * + * @param updateParam 更新参数 + */ + void updateFormulaId(UpdateCheckRuleFormulaParam updateParam); + + /** + * 根据主键id删除薪资账套的校验规则 + * + * @param ids 主键id + */ + void deleteByIds(Collection ids); + + /** + * 根据薪资账套id删除薪资账套的校验规则 + * + * @param salarySobIds 薪资账套id + */ + void deleteBySalarySobIds(Collection salarySobIds); +} diff --git a/src/com/engine/salary/service/SalarySobDefaultEmpFieldService.java b/src/com/engine/salary/service/SalarySobDefaultEmpFieldService.java index 81f524a4d..a221b9f3c 100644 --- a/src/com/engine/salary/service/SalarySobDefaultEmpFieldService.java +++ b/src/com/engine/salary/service/SalarySobDefaultEmpFieldService.java @@ -9,10 +9,10 @@ package com.engine.salary.service; */ public interface SalarySobDefaultEmpFieldService { - /** - * 获取所有的薪资账套默认的员工信息字段 - * - * @return - */ +// /** +// * 获取所有的薪资账套默认的员工信息字段 +// * +// * @return +// */ // List list(); } diff --git a/src/com/engine/salary/service/impl/SalarySobAdjustRuleServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobAdjustRuleServiceImpl.java new file mode 100644 index 000000000..269e78285 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalarySobAdjustRuleServiceImpl.java @@ -0,0 +1,85 @@ +package com.engine.salary.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.biz.SalarySobAdjustRuleBiz; +import com.engine.salary.biz.SalarySobBiz; +import com.engine.salary.entity.salarysob.bo.SalarySobAdjustRuleBO; +import com.engine.salary.entity.salarysob.param.SalarySobAdjustRuleSaveParam; +import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.SalarySobAdjustRuleService; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.valid.ValidUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * 调薪计薪规则 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobAdjustRuleServiceImpl extends Service implements SalarySobAdjustRuleService { + + private SalarySobBiz salarySobBiz = new SalarySobBiz(); + private SalarySobAdjustRuleBiz salarySobAdjustRuleMapper = new SalarySobAdjustRuleBiz(); +// private LoggerTemplate salarySobLoggerTemplate; + + @Override + public List listBySalarySobId(Long salarySobId) { + + if (salarySobId == null) { + return Collections.emptyList(); + } + + return salarySobAdjustRuleMapper.listBySalarySobId(salarySobId); + + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(SalarySobAdjustRuleSaveParam saveParam) { + + ValidUtil.doValidator(saveParam); + + // 查询薪资账套 + SalarySobPO salarySobPO = salarySobBiz.getById(saveParam.getSalarySobId()); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + // 删除之前的调薪计薪规则 + salarySobAdjustRuleMapper.deleteBySalarySobIds(Collections.singleton(saveParam.getSalarySobId())); + // 保存参数转换成薪资账套的调薪计薪规则po + List salarySobAdjustRulePOS = SalarySobAdjustRuleBO.convert2PO(saveParam, (long) user.getUID()); + // 保存 + if (CollectionUtils.isNotEmpty(salarySobAdjustRulePOS)) { + salarySobAdjustRuleMapper.batchInsert(salarySobAdjustRulePOS); + } + // 记录日志 +// LoggerContext loggerContext = new LoggerContext<>(); +// loggerContext.setTargetId(String.valueOf(salarySobPO.getId())); +// loggerContext.setTargetName(salarySobPO.getName()); +// loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); +// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(98614, "保存调薪计薪规则")); +// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(98614, "保存调薪计薪规则")); +// salarySobLoggerTemplate.write(loggerContext); + } + + @Override + public void batchSave(Collection salarySobAdjustRulePOS) { + salarySobAdjustRuleMapper.batchInsert(salarySobAdjustRulePOS); + } + + @Override + public void deleteBySalarySobIds(Collection salarySobIds) { + salarySobAdjustRuleMapper.deleteBySalarySobIds(salarySobIds); + } +} diff --git a/src/com/engine/salary/service/impl/SalarySobCheckRuleServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobCheckRuleServiceImpl.java new file mode 100644 index 000000000..168539862 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalarySobCheckRuleServiceImpl.java @@ -0,0 +1,191 @@ +package com.engine.salary.service.impl; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.biz.SalarySobCheckRuleBiz; +import com.engine.salary.entity.salarysob.bo.SalarySobCheckRuleBO; +import com.engine.salary.entity.salarysob.param.SalarySobCheckRuleSaveParam; +import com.engine.salary.entity.salarysob.param.UpdateCheckRuleFormulaParam; +import com.engine.salary.entity.salarysob.po.SalarySobCheckRulePO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.SalarySobCheckRuleService; +import com.engine.salary.service.SalarySobService; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.beans.BeanUtils; +import weaver.hrm.User; + +import java.util.*; + +/** + * 薪资账套的校验规则 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobCheckRuleServiceImpl extends Service implements SalarySobCheckRuleService { + + private SalarySobCheckRuleBiz salarySobCheckRuleMapper; + private SalarySobService getSalarySobService(User user) { + return (SalarySobService) ServiceUtil.getService(AttendQuoteFieldSettingServiceImpl.class, user); + } +// private LoggerTemplate salarySobLoggerTemplate; + + @Override + public SalarySobCheckRulePO getById(Long id) { + return salarySobCheckRuleMapper.getById(id); + } + + @Override + public List listByIds(Collection ids) { + return salarySobCheckRuleMapper.listSome(SalarySobCheckRulePO.builder().ids(ids).build()); + } + + @Override + public List listBySalarySobId(Long salarySobId) { + return salarySobCheckRuleMapper.listSome(SalarySobCheckRulePO.builder().salarySobId(salarySobId).build()); + } + + @Override + public List listBySalarySobIdAndName(Long salarySobId, String name) { + return salarySobCheckRuleMapper.listSome(SalarySobCheckRulePO.builder().salarySobId(salarySobId).name(name).build()); + } + +// @Override +// public Page listPageByParam(SalarySobCheckRuleQueryParam queryParam) { +// // 分页参数 +// Page page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize()); +// // 查询薪资账套的校验规则 +// return new LambdaQueryChainWrapper<>(salarySobCheckRuleMapper) +// .eq(SalarySobCheckRulePO::getTenantKey, tenantKey) +// .eq(SalarySobCheckRulePO::getDeleteType, 0) +// .eq(SalarySobCheckRulePO::getSalarySobId, queryParam.getSalarySobId()) +// .like(SalaryEntityUtil.isNotNullOrEmpty(queryParam.getName()), SalarySobCheckRulePO::getName, queryParam.getName()) +// .orderByDesc(SalarySobCheckRulePO::getId) +// .page(page); +// } + + @Override + public void save(SalarySobCheckRuleSaveParam saveParam) { + // 查询薪资账套的校验规则 + List salarySobCheckRulePOS = listBySalarySobIdAndName(saveParam.getSalarySobId(), saveParam.getName()); + if (CollectionUtils.isNotEmpty(salarySobCheckRulePOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98629, "名称已经存在")); + } + // 查询薪资账套 + SalarySobPO salarySobPO = getSalarySobService(user).getById(saveParam.getSalarySobId()); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + // 保存参数转换成薪资账套的校验规则po + SalarySobCheckRulePO salarySobCheckRulePO = SalarySobCheckRuleBO.convert2PO(saveParam, (long) user.getUID()); + // 保存 + salarySobCheckRuleMapper.insert(salarySobCheckRulePO); + //todo 记录日志 +// LoggerContext loggerContext = new LoggerContext<>(); +// loggerContext.setTargetId("" + salarySobPO.getId()); +// loggerContext.setTargetName(salarySobPO.getName()); +// loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); +// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(93872, "添加校验规则")); +// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(93872, "添加校验规则") + ": " + salarySobCheckRulePO.getName()); +// loggerContext.setNewValues(salarySobCheckRulePO); +// salarySobLoggerTemplate.write(loggerContext); + } + + @Override + public void batchSave(Collection salarySobCheckRulePOS) { + salarySobCheckRuleMapper.batchInsert(salarySobCheckRulePOS); + } + + @Override + public void update(SalarySobCheckRuleSaveParam updateParam) { + // 名称不允许重复 + List salarySobCheckRulePOS = listBySalarySobIdAndName(updateParam.getSalarySobId(), updateParam.getName()); + boolean nameExist = salarySobCheckRulePOS.stream().anyMatch(salarySobCheckRulePO -> !Objects.equals(salarySobCheckRulePO.getId(), updateParam.getId())); + if (nameExist) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98629, "名称已经存在")); + } + // 查询薪资账套的校验规则 + SalarySobCheckRulePO salarySobCheckRulePO = getById(updateParam.getId()); + if (Objects.isNull(salarySobCheckRulePO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98636, "校验规则不存在或者已被删除")); + } + // 查询薪资账套 + SalarySobPO salarySobPO = getSalarySobService(user).getById(updateParam.getSalarySobId()); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + // 更新 + SalarySobCheckRulePO newSalarySobCheckRulePO = new SalarySobCheckRulePO(); + BeanUtils.copyProperties(salarySobCheckRulePO, newSalarySobCheckRulePO); + newSalarySobCheckRulePO.setName(updateParam.getName()); + newSalarySobCheckRulePO.setFormulaId(updateParam.getFormulaId()); + newSalarySobCheckRulePO.setUpdateTime(new Date()); + salarySobCheckRuleMapper.updateById(newSalarySobCheckRulePO); + //todo 记录日志 +// LoggerContext loggerContext = new LoggerContext<>(); +// loggerContext.setTargetId("" + salarySobPO.getId()); +// loggerContext.setTargetName(salarySobPO.getName()); +// loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); +// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(93870, "编辑校验规则")); +// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(93870, "编辑校验规则") + ": " + newSalarySobCheckRulePO.getName()); +// loggerContext.setOldValues(salarySobCheckRulePO); +// loggerContext.setNewValues(newSalarySobCheckRulePO); +// salarySobLoggerTemplate.write(loggerContext); + } + + @Override + public void updateFormulaId(UpdateCheckRuleFormulaParam updateParam) { + // 查询薪资账套的校验规则 + SalarySobCheckRulePO salarySobCheckRulePO = getById(updateParam.getId()); + if (Objects.isNull(salarySobCheckRulePO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98636, "校验规则不存在或者已被删除")); + } + // 更新 + SalarySobCheckRuleSaveParam salarySobCheckRuleSaveParam = new SalarySobCheckRuleSaveParam() + .setId(updateParam.getId()) + .setName(salarySobCheckRulePO.getName()) + .setSalarySobId(salarySobCheckRulePO.getSalarySobId()) + .setFormulaId(updateParam.getFormulaId()) + .setDescription(salarySobCheckRulePO.getDescription()); + update(salarySobCheckRuleSaveParam); + } + + @Override + public void deleteByIds(Collection ids) { + // 查询薪资账套的校验规则 + List salarySobCheckRulePOS = listByIds(ids); + if (CollectionUtils.isEmpty(salarySobCheckRulePOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98636, "校验规则不存在或者已被删除")); + } + // 删除薪资账套的考验规则 + ids = SalaryEntityUtil.properties(salarySobCheckRulePOS, SalarySobCheckRulePO::getId); + salarySobCheckRuleMapper.deleteByIds(ids); + // 查询薪资账套 + Set salarySobIds = SalaryEntityUtil.properties(salarySobCheckRulePOS, SalarySobCheckRulePO::getSalarySobId); + List salarySobPOS = getSalarySobService(user).listByIds(salarySobIds); + // 将薪资账套list转换成map + Map salarySobPOMap = SalaryEntityUtil.convert2Map(salarySobPOS, SalarySobPO::getId); + //todo 记录日志 +// salarySobCheckRulePOS.forEach(salarySobCheckRulePO -> { +// SalarySobPO salarySobPO = salarySobPOMap.get(salarySobCheckRulePO.getSalarySobId()); +// LoggerContext loggerContext = new LoggerContext<>(); +// loggerContext.setTargetId("" + salarySobPO.getId()); +// loggerContext.setTargetName(salarySobPO.getName()); +// loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); +// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(98646, "删除校验规则")); +// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(98646, "删除校验规则") + ": " + salarySobCheckRulePO.getName()); +// loggerContext.setOldValues(salarySobCheckRulePO); +// salarySobLoggerTemplate.write(loggerContext); +// }); + } + + @Override + public void deleteBySalarySobIds(Collection salarySobIds) { + salarySobCheckRuleMapper.deleteBySalarySobIds(salarySobIds); + } +} diff --git a/src/com/engine/salary/service/impl/SalarySobItemServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobItemServiceImpl.java index 3499a3f14..304021a52 100644 --- a/src/com/engine/salary/service/impl/SalarySobItemServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySobItemServiceImpl.java @@ -8,7 +8,6 @@ import com.engine.salary.biz.SalarySobItemGroupBiz; import com.engine.salary.constant.SalaryDefaultTenantConstant; import com.engine.salary.entity.salaryitem.po.SalaryItemPO; import com.engine.salary.entity.salarysob.bo.SalarySobItemAggregateBO; -import com.engine.salary.entity.salarysob.bo.SalarySobItemSaveBO; import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO; import com.engine.salary.entity.salarysob.param.SalarySobItemSaveParam; import com.engine.salary.entity.salarysob.po.SalarySobEmpFieldPO; @@ -122,16 +121,48 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe @Override public void save(SalarySobItemSaveParam saveParam) { - long employeeId = (long)user.getUID(); - Date now = new Date(); Long salarySobId = saveParam.getSalarySobId(); - // 查询薪资账套 + // 校验 + validSaveParam(salarySobId); + + + //清除原数据 + cleanOldData(salarySobId); + + //保存 + saveSobItem(saveParam); + + //todo 记录日志 +// LoggerContext loggerContext = new LoggerContext<>(); +// loggerContext.setTargetId("" + salarySobPO.getId()); +// loggerContext.setTargetName(salarySobPO.getName()); +// loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); +// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(98613, "编辑薪资账套薪资项目")); +// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(98613, "编辑薪资账套薪资项目")); +// salarySobLoggerTemplate.write(loggerContext); + } + + /** + * 校验 + * @param salarySobId + */ + private void validSaveParam(Long salarySobId) { + //1、账套存在 SalarySobPO salarySobPO = salarySobBiz.getById(salarySobId); if (Objects.isNull(salarySobPO)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); } + + // todo 2、分类名称唯一 + } + + /** + * 清楚原相关数据 + * @param salarySobId + */ + private void cleanOldData(Long salarySobId) { //todo // 删除薪资账套的员工信息字段 getSalarySobEmpFieldService(user).deleteBySalarySobIds(Collections.singleton(salarySobId)); @@ -139,17 +170,39 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe deleteBySalarySobIds(Collections.singleton(salarySobId)); // 删除薪资账套的薪资项目分类 getSalarySobItemGroupService(user).deleteBySalarySobIds(Collections.singleton(salarySobId)); + } + + /** + * 保存项目信息 + * @param saveParam + */ + private void saveSobItem(SalarySobItemSaveParam saveParam) { + long employeeId = (long) user.getUID(); + Date now = new Date(); + Long salarySobId = saveParam.getSalarySobId(); - // 处理保存参数 - SalarySobItemSaveBO.Result result = SalarySobItemSaveBO.handle(saveParam,(long)user.getUID()); // 保存薪资账套的员工信息字段 - if (CollectionUtils.isNotEmpty(result.getNeedInsertSalarySobEmpFields())) { -// getSalarySobEmpFieldService(user).batchSave(result.getNeedInsertSalarySobEmpFields()); + Collection needInsertSalarySobEmpFields = new ArrayList<>(); + for (SalarySobItemSaveParam.SalarySobEmpFieldParam salarySobEmpFieldParam : saveParam.getEmpFields()) { + SalarySobEmpFieldPO salarySobEmpFieldPO = SalarySobEmpFieldPO.builder() +// .id(IdGenerator.generate()) + .salarySobId(saveParam.getSalarySobId()) + .fieldCode(salarySobEmpFieldParam.getFieldId()) + .sortedIndex(salarySobEmpFieldParam.getSortedIndex()) + .canDelete(NumberUtils.INTEGER_ONE) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + needInsertSalarySobEmpFields.add(salarySobEmpFieldPO); } + getSalarySobEmpFieldService(user).batchSave(needInsertSalarySobEmpFields); - Collection salarySobItems = new ArrayList<>(); - //先保存项目分类获取分类id + //先保存项目分类获,取分类id + Collection salarySobItems = new ArrayList<>(); int sortedIndex = 0; for (SalarySobItemSaveParam.SalarySobItemGroupParam itemGroupParam : saveParam.getItemGroups()) { SalarySobItemGroupPO salarySobItemGroupPO = SalarySobItemGroupPO.builder() @@ -163,7 +216,9 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe .deleteType(NumberUtils.INTEGER_ZERO) .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) .build(); + //保存分类 salarySobItemGroupBiz.insert(salarySobItemGroupPO); + //获取分类id List salarySobItemGroupPOS = salarySobItemGroupBiz.listSome(SalarySobItemGroupPO.builder().salarySobId(salarySobId).name(itemGroupParam.getName()).build()); Long salarySobItemGroupId = salarySobItemGroupPOS.get(0).getId(); @@ -204,23 +259,8 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe salarySobItems.add(salarySobItemPO); } - // 保存薪资账套的薪资项目副本 - if (CollectionUtils.isNotEmpty(result.getNeedInsertSalarySobItems())) { - batchSave(salarySobItems); - } - // 保存薪资账套的薪资项目分类 -// if (CollectionUtils.isNotEmpty(result.getNeedInsertSalarySobItemGroups())) { -// getSalarySobItemGroupService(user).batchSave(result.getNeedInsertSalarySobItemGroups()); -// } - //todo 记录日志 -// LoggerContext loggerContext = new LoggerContext<>(); -// loggerContext.setTargetId("" + salarySobPO.getId()); -// loggerContext.setTargetName(salarySobPO.getName()); -// loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); -// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(98613, "编辑薪资账套薪资项目")); -// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(98613, "编辑薪资账套薪资项目")); -// salarySobLoggerTemplate.write(loggerContext); + batchSave(salarySobItems); } @Override diff --git a/src/com/engine/salary/service/impl/SalarySobRangeServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobRangeServiceImpl.java index 197bada7e..191ca0391 100644 --- a/src/com/engine/salary/service/impl/SalarySobRangeServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySobRangeServiceImpl.java @@ -44,7 +44,7 @@ public class SalarySobRangeServiceImpl extends Service implements SalarySobRange private SalarySobRangeBiz salarySobRangeBiz = new SalarySobRangeBiz(); private EmployBiz employBiz = new EmployBiz(); - OrganizationShowSetBiz orgBiz = new OrganizationShowSetBiz(); + private OrganizationShowSetBiz orgBiz = new OrganizationShowSetBiz(); private SalarySobService getSalarySobService(User user) { diff --git a/src/com/engine/salary/service/impl/SalarySobServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobServiceImpl.java index fb0ae33b6..48097f82b 100644 --- a/src/com/engine/salary/service/impl/SalarySobServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySobServiceImpl.java @@ -1,31 +1,39 @@ package com.engine.salary.service.impl; +import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; -import com.engine.salary.biz.SalarySobBiz; +import com.engine.salary.biz.*; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.salaryitem.bo.SysSalaryItemBO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO; import com.engine.salary.entity.salarysob.bo.SalarySobBO; import com.engine.salary.entity.salarysob.bo.SalarySobCycleBO; +import com.engine.salary.entity.salarysob.bo.SalarySobItemBO; import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; import com.engine.salary.entity.salarysob.param.SalarySobBasicSaveParam; import com.engine.salary.entity.salarysob.param.SalarySobDisableParam; import com.engine.salary.entity.salarysob.param.SalarySobDuplicateParam; -import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.salarysob.po.*; +import com.engine.salary.enums.SalarySystemTypeEnum; import com.engine.salary.enums.salarysob.IncomeCategoryEnum; import com.engine.salary.exception.SalaryRunTimeException; -import com.engine.salary.service.SalaryItemService; -import com.engine.salary.service.SalarySobDefaultItemService; -import com.engine.salary.service.SalarySobService; -import com.engine.salary.service.SysSalaryItemService; +import com.engine.salary.service.*; import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.valid.RuntimeTypeEnum; import com.engine.salary.util.valid.ValidUtil; +import com.google.common.collect.Lists; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; import org.springframework.beans.BeanUtils; import org.springframework.transaction.annotation.Transactional; +import weaver.hrm.User; import java.time.YearMonth; import java.util.*; +import java.util.stream.Collectors; /** * 薪资账套 @@ -39,25 +47,22 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { private SalarySobBiz salarySobMapper = new SalarySobBiz(); - -// private SalarySobRangeService salarySobRangeService; - -// private SalarySobDefaultEmpFieldService salarySobDefaultEmpFieldService; - -// private SalarySobEmpFieldService salarySobEmpFieldService; -// - private SalarySobDefaultItemService salarySobDefaultItemService; + private SalarySobRangeBiz salarySobRangeService = new SalarySobRangeBiz(); + private SalarySobEmpFieldBiz empFieldBiz = new SalarySobEmpFieldBiz(); + private SalarySobDefaultItemGroupBiz defaultItemGroupBiz = new SalarySobDefaultItemGroupBiz(); + private SalarySobEmpFieldBiz salarySobEmpFieldService = new SalarySobEmpFieldBiz(); + private SalarySobDefaultItemBiz salarySobDefaultItemService = new SalarySobDefaultItemBiz(); + private SalarySobItemBiz salarySobItemService = new SalarySobItemBiz(); + private SalarySobItemGroupBiz salarySobItemGroupService = new SalarySobItemGroupBiz(); + private SalaryItemService getSalaryItemService(User user) { + return (SalaryItemService) ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } -// -// private SalarySobItemService salarySobItemService; -// - private SalaryItemService salaryItemService; -// - private SysSalaryItemService sysSalaryItemService; -// -// private SalarySobItemGroupService salarySobItemGroupService; + private SysSalaryItemService getSysSalaryItemService(User user) { + return (SysSalaryItemService) ServiceUtil.getService(SysSalaryItemServiceImpl.class, user); + } // // private SalarySobAdjustRuleService salarySobAdjustRuleService; // @@ -157,16 +162,15 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { * @param salarySobPO 薪资账套 */ private void saveDefaultEmpField(SalarySobPO salarySobPO) { -// // 查询薪资账套默认的员工信息字段 -// List salarySobDefaultEmpFieldPOS = salarySobDefaultEmpFieldService.list(); -// // 转换成薪资账套员工信息字段po -// List salarySobEmpFieldPOS = SalarySobItemBO.convert2EmpFieldPO(salarySobPO.getId(), salarySobDefaultEmpFieldPOS, employeeId, tenantKey); -// // 保存 -// salarySobEmpFieldService.batchSave(salarySobEmpFieldPOS); + // 查询薪资账套默认的员工信息字段 + List salarySobDefaultEmpFieldPOS = empFieldBiz.listDefaultEmpField(); + // 转换成薪资账套员工信息字段po + List salarySobEmpFieldPOS = SalarySobItemBO.convert2EmpFieldPO(salarySobPO.getId(), salarySobDefaultEmpFieldPOS, (long) user.getUID()); + // 保存 + empFieldBiz.batchInsert(salarySobEmpFieldPOS); } /** - * todo * 新建薪资账套时,保存默认的薪资项目 * 1、薪资账套默认引用的系统薪资项目 * 2、自定义薪资项目中开启了"默认使用"的薪资项目 @@ -174,39 +178,44 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { * @param salarySobPO 薪资账套 */ private void saveDefaultItem(SalarySobPO salarySobPO) { -// // 1、根据薪资类型查询薪资账套默认引用的系统薪资项目 -// List salarySobDefaultItemPOS = salarySobDefaultItemService.listByIncomeCategory(IncomeCategoryEnum.parseByValue(salarySobPO.getIncomeCategory())); -// // 2、薪资账套默认引用的系统薪资项目如果没有添加到薪资项目中,这里要给添加保存 -// // 2.1、查询已经添加到薪资项目中的系统薪资项目 -// Set defaultSysSalaryItemIds = SalaryEntityUtil.properties(salarySobDefaultItemPOS, SalarySobDefaultItemPO::getSysSalaryItemId); -// List salaryItemPOS = salaryItemService.listBySysSalaryItemIds(defaultSysSalaryItemIds, tenantKey); -// Set sysSalaryItemIds = SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getSysSalaryItemId); -// // 2.2、需要添加进薪资项目中的系统薪资项目id -// Set needAddSysSalaryItemIds = salarySobDefaultItemPOS.stream() -// .filter(salarySobDefaultItemPO -> !sysSalaryItemIds.contains(salarySobDefaultItemPO.getSysSalaryItemId())) -// .map(SalarySobDefaultItemPO::getSysSalaryItemId) -// .collect(Collectors.toSet()); -// List needAddSysSalaryItemPOS = sysSalaryItemService.listByIds(needAddSysSalaryItemIds); -// // 2.3、需要保存的薪资项目 -// List needInsertSalaryItemPOS = SysSalaryItemBO.convert2SalaryItemPO(needAddSysSalaryItemPOS, (long)user.getUID()); -// if (CollectionUtils.isNotEmpty(needInsertSalaryItemPOS)) { -// salaryItemService.batchSave(needInsertSalaryItemPOS); -// } -// -// // 3、查询开启了"默认使用"的自定义薪资项目 -// List useDefaultSalaryItemPOS = salaryItemService.listBySystemTypeAndUseDefault(SalarySystemTypeEnum.CUSTOM, NumberUtils.INTEGER_ONE); -// -// // 4、默认引用的薪资项目(=薪资账套默认引用的系统薪资项目(已添加进薪资项目中的) + 薪资账套默认引用的系统薪资项目(待添加进薪资项目中的) + 自定义薪资项目中开启了"默认使用"的薪资项目) -// List defaultSalaryItemPOS = Lists.newArrayListWithExpectedSize(salaryItemPOS.size() + needInsertSalaryItemPOS.size() + useDefaultSalaryItemPOS.size()); -// defaultSalaryItemPOS.addAll(salaryItemPOS); -// defaultSalaryItemPOS.addAll(needInsertSalaryItemPOS); -// defaultSalaryItemPOS.addAll(useDefaultSalaryItemPOS); -// -// // 5、保存 -// List salarySobItemPOS = SalarySobItemBO.convert2ItemPO(salarySobPO.getId(), defaultSalaryItemPOS, employeeId); -// if (CollectionUtils.isNotEmpty(salarySobItemPOS)) { -// salarySobItemService.batchSave(salarySobItemPOS); -// } + // 1、根据薪资类型查询薪资账套默认使用的薪资项目分类以及薪资项目 + IncomeCategoryEnum incomeCategoryEnum = IncomeCategoryEnum.parseByValue(salarySobPO.getIncomeCategory()); + List salarySobDefaultItemGroupPOS = defaultItemGroupBiz.listByIncomeCategory(incomeCategoryEnum); + List salarySobDefaultItemPOS = salarySobDefaultItemService.listByIncomeCategory(SalarySobDefaultItemPO.builder().incomeCategory(incomeCategoryEnum.getValue()).build()); + // 2、薪资账套默认引用的系统薪资项目如果没有添加到薪资项目中,这里要给添加保存 + // 2.1、查询已经添加到薪资项目中的系统薪资项目 + Set defaultSysSalaryItemIds = SalaryEntityUtil.properties(salarySobDefaultItemPOS, SalarySobDefaultItemPO::getSysSalaryItemId); + List salaryItemPOS = getSalaryItemService(user).listBySysSalaryItemIds(defaultSysSalaryItemIds); + Set sysSalaryItemIds = SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getSysSalaryItemId); + // 2.2、需要添加进薪资项目中的系统薪资项目id + Set needAddSysSalaryItemIds = salarySobDefaultItemPOS.stream() + .map(SalarySobDefaultItemPO::getSysSalaryItemId) + .filter(sysSalaryItemId -> !sysSalaryItemIds.contains(sysSalaryItemId)) + .collect(Collectors.toSet()); + List needAddSysSalaryItemPOS = getSysSalaryItemService(user).listByIds(needAddSysSalaryItemIds); + // 2.3、需要保存的薪资项目 + List needInsertSalaryItemPOS = SysSalaryItemBO.convert2SalaryItemPO(needAddSysSalaryItemPOS, (long) user.getUID()); + if (CollectionUtils.isNotEmpty(needInsertSalaryItemPOS)) { + getSalaryItemService(user).batchSave(needInsertSalaryItemPOS); + } + + // 3、查询开启了"默认使用"的自定义薪资项目 + List useDefaultSalaryItemPOS = getSalaryItemService(user).listBySystemTypeAndUseDefault(SalarySystemTypeEnum.CUSTOM, NumberUtils.INTEGER_ONE); + + // 4、默认引用的薪资项目(=薪资账套默认引用的系统薪资项目(已添加进薪资项目中的) + 薪资账套默认引用的系统薪资项目(待添加进薪资项目中的) + 自定义薪资项目中开启了"默认使用"的薪资项目) + List defaultSalaryItemPOS = Lists.newArrayListWithExpectedSize(salaryItemPOS.size() + needInsertSalaryItemPOS.size() + useDefaultSalaryItemPOS.size()); + defaultSalaryItemPOS.addAll(salaryItemPOS); + defaultSalaryItemPOS.addAll(needInsertSalaryItemPOS); + defaultSalaryItemPOS.addAll(useDefaultSalaryItemPOS); + + // 5、保存 + SalarySobItemBO.Result result = SalarySobItemBO.initSalarySobItem(salarySobPO.getId(), salarySobDefaultItemGroupPOS, salarySobDefaultItemPOS, defaultSalaryItemPOS, (long) user.getUID(), SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + if (CollectionUtils.isNotEmpty(result.getNeedInsertSalarySobItems())) { + salarySobItemService.batchInsert(result.getNeedInsertSalarySobItems()); + } + if (CollectionUtils.isNotEmpty(result.getNeedInsertSalarySobItemGroups())) { + salarySobItemGroupService.batchInsert(result.getNeedInsertSalarySobItemGroups()); + } } @Override @@ -290,17 +299,17 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { // if (CollectionUtils.isNotEmpty(salaryAcctRecordPOS)) { // throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99713, "账套已用于薪资核算,不能删除")); // } -// // 删除薪资账套 -// salarySobMapper.deleteByIds(ids, tenantKey); -// // 删除薪资账套的人员范围 -// salarySobRangeService.deleteBySalarySobIds(ids, tenantKey); -// // 删除薪资账套的人员信息字段 -// salarySobEmpFieldService.deleteBySalarySobIds(ids, tenantKey); -// // 删除薪资账套的薪资项目 -// salarySobItemService.deleteBySalarySobIds(ids, tenantKey); -// // 删除薪资账套的薪资项目分类 -// salarySobItemGroupService.deleteBySalarySobIds(ids, tenantKey); -// // 删除薪资账套的调薪计薪规则 + // 删除薪资账套 + salarySobMapper.deleteByIds(ids); + // 删除薪资账套的人员范围 + salarySobRangeService.deleteBySalarySobIds(ids); + // 删除薪资账套的人员信息字段 + salarySobEmpFieldService.deleteBySalarySobIds(ids); + // 删除薪资账套的薪资项目 + salarySobItemService.deleteBySalarySobIds(ids); + // 删除薪资账套的薪资项目分类 + salarySobItemGroupService.deleteBySalarySobIds(ids); + // 删除薪资账套的调薪计薪规则 // salarySobAdjustRuleService.deleteBySalarySobIds(ids, tenantKey); // // 删除薪资账套的校验规则 // salarySobCheckRuleService.deleteBySalarySobIds(ids, tenantKey); @@ -334,12 +343,12 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { // // 查询薪资账套的薪资项目副本 // List salarySobItemPOS = salarySobItemService.listBySalarySobId(duplicateParam.getId()); // // 查询薪资账套的薪资项目分类 -// List salarySobItemGroupPOS = salarySobItemGroupService.listBySalarySobId(duplicateParam.getId(), tenantKey); +// List salarySobItemGroupPOS = salarySobItemGroupService.listBySalarySobId(duplicateParam.getId()); // // 查询薪资账套的调薪计薪规则 -// List salarySobAdjustRulePOS = salarySobAdjustRuleService.listBySalarySobId(duplicateParam.getId(), tenantKey); +// List salarySobAdjustRulePOS = salarySobAdjustRuleService.listBySalarySobId(duplicateParam.getId()); // // 查询薪资账套的校验规则 -// List salarySobCheckRulePOS = salarySobCheckRuleService.listBySalarySobId(duplicateParam.getId(), tenantKey); -// +// List salarySobCheckRulePOS = salarySobCheckRuleService.listBySalarySobId(duplicateParam.getId()); + // // 复制 // SalarySobDuplicateBO salarySobDuplicateBO = new SalarySobDuplicateBO(salarySobPO, salarySobEmpFieldPOS, salarySobItemPOS, // salarySobItemGroupPOS, salarySobAdjustRulePOS, salarySobCheckRulePOS); diff --git a/src/com/engine/salary/util/ResponseResult.java b/src/com/engine/salary/util/ResponseResult.java index 0936c0584..da3742f9a 100644 --- a/src/com/engine/salary/util/ResponseResult.java +++ b/src/com/engine/salary/util/ResponseResult.java @@ -141,5 +141,4 @@ public class ResponseResult { return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); } - } diff --git a/src/com/engine/salary/web/SalarySobController.java b/src/com/engine/salary/web/SalarySobController.java index 34147f33d..91e8a6e15 100644 --- a/src/com/engine/salary/web/SalarySobController.java +++ b/src/com/engine/salary/web/SalarySobController.java @@ -2,17 +2,14 @@ package com.engine.salary.web; import com.engine.common.util.ServiceUtil; import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam; -import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO; -import com.engine.salary.entity.salarysob.dto.SalarySobRangeListDTO; +import com.engine.salary.entity.salarysob.dto.*; import com.engine.salary.entity.salarysob.param.*; import com.engine.salary.entity.salarysob.po.SalarySobItemGroupPO; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.util.ResponseResult; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.page.PageInfo; -import com.engine.salary.wrapper.SalarySobItemWrapper; -import com.engine.salary.wrapper.SalarySobRangeWrapper; -import com.engine.salary.wrapper.SalarySobWrapper; +import com.engine.salary.wrapper.*; import io.swagger.v3.oas.annotations.parameters.RequestBody; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -28,6 +25,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import java.util.Collection; +import java.util.List; import java.util.Map; /** @@ -53,9 +51,13 @@ public class SalarySobController { return ServiceUtil.getService(SalarySobItemWrapper.class, user); } -// private SalarySobAdjustRuleWrapper salarySobAdjustRuleWrapper; -// private SalarySobCheckRuleWrapper salarySobCheckRuleWrapper; + private SalarySobAdjustRuleWrapper getSalarySobAdjustRuleWrapper(User user) { + return ServiceUtil.getService(SalarySobAdjustRuleWrapper.class, user); + } + private SalarySobCheckRuleWrapper getSalarySobCheckRuleWrapper(User user) { + return ServiceUtil.getService(SalarySobCheckRuleWrapper.class, user); + } /**********************************薪资账套 start*********************************/ @@ -218,7 +220,7 @@ public class SalarySobController { User user = HrmUserVarify.getUser(request, response); String idStr = request.getParameter("id"); Long id = null; - if(StringUtils.isNotBlank(idStr)){ + if (StringUtils.isNotBlank(idStr)) { id = Long.valueOf(idStr); } return new ResponseResult().run(getSalarySobItemWrapper(user)::getGroupForm, id); @@ -234,7 +236,7 @@ public class SalarySobController { User user = HrmUserVarify.getUser(request, response); String salarySobIdStr = request.getParameter("salarySobId"); Long salarySobId = null; - if(StringUtils.isNotBlank(salarySobIdStr)){ + if (StringUtils.isNotBlank(salarySobIdStr)) { salarySobId = Long.valueOf(salarySobIdStr); } return new ResponseResult().run(getSalarySobItemWrapper(user)::getForm, salarySobId); @@ -243,92 +245,127 @@ public class SalarySobController { /** * 保存薪资账套薪资项目 */ - @POST - @Path("/item/save") + @GET + @Path("/empField/list") @Produces(MediaType.APPLICATION_JSON) - public String saveSalarySobItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobItemSaveParam saveParam) { + public String empFieldList(@Context HttpServletRequest request, @Context HttpServletResponse response) { User user = HrmUserVarify.getUser(request, response); - return new ResponseResult().run(getSalarySobItemWrapper(user)::save, saveParam); + return new ResponseResult>>().run(getSalarySobItemWrapper(user)::empFieldList); } -// /**********************************薪资账套的薪资项目 end*********************************/ -// -// /**********************************调薪计薪规则 start*********************************/ -// -// @PostMapping("/adjustmentrule/list") -// @ApiOperation("调薪计薪规则列表") -// @WeaPermission -// public WeaResult> listAdjustmentRule(@RequestBody @Validated SalarySobAdjustRuleQueryParam queryParam) { -// List salarySobAdjustRuleListDTOS = salarySobAdjustRuleWrapper.list(queryParam, TenantContext.getCurrentTenantKey()); -// return WeaResult.success(salarySobAdjustRuleListDTOS); + /**********************************薪资账套的薪资项目 end*********************************/ + + /**********************************调薪计薪规则 start*********************************/ + + + /** + * 调薪计薪规则列表 + */ + @POST + @Path("/adjustmentrule/list") + @Produces(MediaType.APPLICATION_JSON) + public String listAdjustmentRule(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobAdjustRuleQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>().run(getSalarySobAdjustRuleWrapper(user)::list, queryParam); + } + + + /** + * 调薪计薪规则保存 + */ + @POST + @Path("/adjustmentrule/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveAdjustmentRule(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobAdjustRuleSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult().run(getSalarySobAdjustRuleWrapper(user)::save, saveParam); + } + + /** + * 调薪计薪规则可选的薪资项目列表 + */ + @POST + @Path("/adjustmentrule/listSalarySobItem") + @Produces(MediaType.APPLICATION_JSON) + public String listSalarySobItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobAdjustRuleItemQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>().run(getSalarySobAdjustRuleWrapper(user)::list4SalarySobItem, queryParam); + } + + /**********************************调薪计薪规则 end*********************************/ + + /**********************************校验规则 start*********************************/ + + + /** + * 薪资账套校验规则列表 + */ +// @POST +// @Path("/checkrule/list") +// @Produces(MediaType.APPLICATION_JSON) +// public String listSalarySobCheckRule(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobCheckRuleQueryParam queryParam) { +// User user = HrmUserVarify.getUser(request, response); +// return new ResponseResult>().run(getSalarySobCheckRuleWrapper(user)::listPage, queryParam); // } -// -// @PostMapping("/adjustmentrule/save") -// @ApiOperation("调薪计薪规则保存") -// @WeaPermission -// public WeaResult saveAdjustmentRule(@RequestBody @Validated SalarySobAdjustRuleSaveParam saveParam) { -// salarySobAdjustRuleWrapper.save(saveParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()); -// return WeaResult.success(null); -// } -// -// @PostMapping("/adjustmentrule/listSalarySobItem") -// @ApiOperation("调薪计薪规则列表") -// @WeaPermission -// public WeaResult> listSalarySobItem(@RequestBody @Validated SalarySobAdjustRuleItemQueryParam queryParam) { -// List salaryItemBaseDTOS = salarySobAdjustRuleWrapper.list4SalarySobItem(queryParam, TenantContext.getCurrentTenantKey()); -// return WeaResult.success(salaryItemBaseDTOS); -// } -// -// /**********************************调薪计薪规则 end*********************************/ -// -// /**********************************校验规则 start*********************************/ -// -// @PostMapping("/checkrule/list") -// @ApiOperation("薪资账套校验规则列表") -// @WeaPermission -// public WeaResult> listSalarySobCheckRule(@RequestBody SalarySobCheckRuleQueryParam queryParam) { -// WeaTable weaTable = salarySobCheckRuleWrapper.listPage(queryParam, TenantContext.getCurrentTenantKey()); -// return WeaResult.success(weaTable); -// } -// -// @GetMapping("/checkrule/getForm") -// @ApiOperation("薪资账套校验规则表单") -// @WeaPermission -// public WeaResult getSalarySobCheckRuleForm(@RequestParam(name = "id", required = false) Long id) { -// WeaForm weaForm = salarySobCheckRuleWrapper.getForm(id, TenantContext.getCurrentTenantKey()); -// return WeaResult.success(weaForm); -// } -// -// @PostMapping("/checkrule/save") -// @ApiOperation("保存薪资账套校验规则") -// @WeaPermission -// public WeaResult saveSalarySobCheckRule(@RequestBody @Validated SalarySobCheckRuleSaveParam saveParam) { -// if (saveParam.getId() == null || saveParam.getId() <= 0) { -// salarySobCheckRuleWrapper.save(saveParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()); -// } else { -// salarySobCheckRuleWrapper.update(saveParam, TenantContext.getCurrentTenantKey()); -// } -// return WeaResult.success(null); -// } -// -// @PostMapping("/checkrule/formula/update") -// @ApiOperation("编辑薪资账套校验规则公式") -// @WeaPermission -// public WeaResult updateSalarySobCheckRuleFormula(@RequestBody @Validated UpdateCheckRuleFormulaParam updateParam) { -// salarySobCheckRuleWrapper.updateFormulaId(updateParam, TenantContext.getCurrentTenantKey()); -// return WeaResult.success(null); -// } -// -// @PostMapping("/checkrule/delete") -// @ApiOperation("删除薪资账套校验规则") -// @WeaPermission -// public WeaResult deleteSalarySobCheckRule(@RequestBody Collection ids) { -// if (CollectionUtils.isEmpty(ids)) { -// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); -// } -// salarySobCheckRuleWrapper.delete(ids, TenantContext.getCurrentTenantKey()); -// return WeaResult.success(null); -// } -// -// /**********************************校验规则 end*********************************/ + + /** + * 薪资账套校验规则表单 + */ + @POST + @Path("/checkrule/getForm") + @Produces(MediaType.APPLICATION_JSON) + public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + String idStr = request.getParameter("id"); + Long id = null; + if (StringUtils.isNotBlank(idStr)) { + id = Long.valueOf(idStr); + } + return new ResponseResult().run(getSalarySobCheckRuleWrapper(user)::getForm, id); + } + + /** + * 保存薪资账套校验规则 + */ + @POST + @Path("/checkrule/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveSalarySobCheckRule(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobCheckRuleSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + if (saveParam.getId() == null || saveParam.getId() <= 0) { + return new ResponseResult().run(getSalarySobCheckRuleWrapper(user)::save, saveParam); + } else { + return new ResponseResult().run(getSalarySobCheckRuleWrapper(user)::update, saveParam); + } + + } + + /** + * 编辑薪资账套校验规则公式 + */ + @POST + @Path("/checkrule/formula/update") + @Produces(MediaType.APPLICATION_JSON) + public String updateSalarySobCheckRuleFormula(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody UpdateCheckRuleFormulaParam updateParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult().run(getSalarySobCheckRuleWrapper(user)::updateFormulaId, updateParam); + } + + /** + * 删除薪资账套校验规则 + */ + @POST + @Path("/checkrule/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSalarySobCheckRule(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + if (CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + return new ResponseResult, String>().run(getSalarySobCheckRuleWrapper(user)::delete, ids); + } + + + /**********************************校验规则 end*********************************/ + } diff --git a/src/com/engine/salary/wrapper/SalarySobAdjustRuleWrapper.java b/src/com/engine/salary/wrapper/SalarySobAdjustRuleWrapper.java new file mode 100644 index 000000000..33d7b350d --- /dev/null +++ b/src/com/engine/salary/wrapper/SalarySobAdjustRuleWrapper.java @@ -0,0 +1,96 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.bo.SalarySobAdjustRuleBO; +import com.engine.salary.entity.salarysob.dto.SalaryItemBaseDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobAdjustRuleListDTO; +import com.engine.salary.entity.salarysob.param.SalarySobAdjustRuleItemQueryParam; +import com.engine.salary.entity.salarysob.param.SalarySobAdjustRuleQueryParam; +import com.engine.salary.entity.salarysob.param.SalarySobAdjustRuleSaveParam; +import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO; +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import com.engine.salary.service.SalaryItemService; +import com.engine.salary.service.SalarySobAdjustRuleService; +import com.engine.salary.service.SalarySobItemService; +import com.engine.salary.service.impl.SalaryItemServiceImpl; +import com.engine.salary.service.impl.SalarySobAdjustRuleServiceImpl; +import com.engine.salary.service.impl.SalarySobItemServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.valid.ValidUtil; +import weaver.hrm.User; + +import java.util.List; +import java.util.Set; + +/** + * 薪资账套的调薪计薪规则 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobAdjustRuleWrapper extends Service { + + private SalarySobAdjustRuleService getSalarySobAdjustRuleService(User user) { + return (SalarySobAdjustRuleService) ServiceUtil.getService(SalarySobAdjustRuleServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return (SalaryItemService) ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalarySobItemService getSalarySobItemService(User user) { + return (SalarySobItemService) ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + } + + + /** + * 薪资账套的调薪计薪规则列表 + * + * @param queryParam 查询参数 + * @return + */ + public List list(SalarySobAdjustRuleQueryParam queryParam) { + + ValidUtil.doValidator(queryParam); + + // 查询调薪计薪规则po + List salarySobAdjustRulePOS = getSalarySobAdjustRuleService(user).listBySalarySobId(queryParam.getSalarySobId()); + // 查询薪资项目 + Set salaryItemIds = SalaryEntityUtil.properties(salarySobAdjustRulePOS, SalarySobAdjustRulePO::getSalaryItemId); + List salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds); + // 转换成dto + return SalarySobAdjustRuleBO.convert2ListDTO(salarySobAdjustRulePOS, salaryItemPOS); + } + + /** + * 查询调薪计薪规则可选的薪资项目 + * + * @param queryParam 查询条件 + * @return + */ + public List list4SalarySobItem(SalarySobAdjustRuleItemQueryParam queryParam) { + + ValidUtil.doValidator(queryParam); + + // 查询薪资账套的薪资项目副本 + List salarySobItemPOS = getSalarySobItemService(user).listBySalarySobIdAndSalaryItemIdNotIn(queryParam.getSalarySobId(), queryParam.getExcludeSalaryItemIds()); + // 查询薪资项目 + Set salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId); + List salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds); + // 转换成dto + return SalarySobAdjustRuleBO.convertItemBaseDTO(salaryItemPOS); + } + + /** + * 保存调薪计薪规则 + * + * @param saveParam 保存参数 + */ + public void save(SalarySobAdjustRuleSaveParam saveParam) { + getSalarySobAdjustRuleService(user).save(saveParam); + } +} diff --git a/src/com/engine/salary/wrapper/SalarySobCheckRuleWrapper.java b/src/com/engine/salary/wrapper/SalarySobCheckRuleWrapper.java new file mode 100644 index 000000000..c9804dbc1 --- /dev/null +++ b/src/com/engine/salary/wrapper/SalarySobCheckRuleWrapper.java @@ -0,0 +1,118 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.salarysob.bo.SalarySobCheckRuleBO; +import com.engine.salary.entity.salarysob.dto.SalarySobCheckRuleFormDTO; +import com.engine.salary.entity.salarysob.param.SalarySobCheckRuleSaveParam; +import com.engine.salary.entity.salarysob.param.UpdateCheckRuleFormulaParam; +import com.engine.salary.entity.salarysob.po.SalarySobCheckRulePO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.SalaryFormulaService; +import com.engine.salary.service.SalarySobCheckRuleService; +import com.engine.salary.service.impl.SalarySobCheckRuleServiceImpl; +import com.engine.salary.util.SalaryI18nUtil; +import com.weaver.excel.formula.api.entity.ExpressFormula; +import weaver.hrm.User; + +import java.util.Collection; +import java.util.Objects; + +/** + * 薪资账套的校验规则 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobCheckRuleWrapper extends Service { + + + private SalarySobCheckRuleService getSalarySobCheckRuleService(User user) { + return (SalarySobCheckRuleService) ServiceUtil.getService(SalarySobCheckRuleServiceImpl.class, user); + } + + + private SalaryFormulaService salaryFormulaService; + + /** + * 薪资账套的校验规则列表 + * + * @param queryParam 列表查询条件 + * @param tenantKey 租户key + * @return + */ +// public WeaTable listPage(SalarySobCheckRuleQueryParam queryParam, String tenantKey) { +// // 分页查询薪资账套的校验规则 +// Page page = salarySobCheckRuleService.listPageByParam(queryParam, tenantKey); +// // 查询公式详情 +// Set formulaIds = SalaryEntityUtil.properties(page.getRecords(), SalarySobCheckRulePO::getFormulaId); +// List expressFormulas = salaryFormulaService.listExpressFormula(formulaIds, tenantKey); +// // 转换成dto +// List salarySobCheckRuleListDTOS = SalarySobCheckRuleBO.convert2ListDTO(page.getRecords(), expressFormulas); +// // 转换成前端所需的数据格式 +// Page dtoPage = new Page<>(page.getCurrent(), page.getSize(), page.getTotal(), page.isSearchCount()); +// dtoPage.setRecords(salarySobCheckRuleListDTOS); +// return SalaryFormatUtil.getInstance().buildTable(SalarySobCheckRuleListDTO.class, dtoPage); +// } + + /** + * 薪资账套的校验规则详情 + * + * @param id 校验规则的id + * @return + */ + public SalarySobCheckRuleFormDTO getForm(Long id) { + SalarySobCheckRuleFormDTO checkRuleFormDTO = new SalarySobCheckRuleFormDTO(); + if (!Objects.isNull(id)) { + // 查询校验规则 + SalarySobCheckRulePO salarySobCheckRulePO = getSalarySobCheckRuleService(user).getById(id); + if (Objects.isNull(salarySobCheckRulePO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98636, "校验规则不存在或者已被删除")); + } + // 查询公式详情 + ExpressFormula expressFormula = salaryFormulaService.getExpressFormula(salarySobCheckRulePO.getFormulaId()); + // 转换成详情dto + checkRuleFormDTO = SalarySobCheckRuleBO.convert2FormDTO(salarySobCheckRulePO, expressFormula); + } + // 转换成前端所需的数据格式 + return checkRuleFormDTO; + } + + /** + * 保存 + * + * @param saveParam 保存参数 + */ + public void save(SalarySobCheckRuleSaveParam saveParam) { + getSalarySobCheckRuleService(user).save(saveParam); + } + + /** + * 更新 + * + * @param updateParam 更新参数 + */ + public void update(SalarySobCheckRuleSaveParam updateParam) { + getSalarySobCheckRuleService(user).update(updateParam); + } + + /** + * 更新校验规则的公式 + * + * @param updateParam 更新参数 + */ + public void updateFormulaId(UpdateCheckRuleFormulaParam updateParam) { + getSalarySobCheckRuleService(user).updateFormulaId(updateParam); + } + + /** + * 删除 + * + * @param ids 校验规则的id + */ + public void delete(Collection ids) { + getSalarySobCheckRuleService(user).deleteByIds(ids); + } +} diff --git a/src/com/engine/salary/wrapper/SalarySobItemWrapper.java b/src/com/engine/salary/wrapper/SalarySobItemWrapper.java index d5a07f9b0..c71de4b33 100644 --- a/src/com/engine/salary/wrapper/SalarySobItemWrapper.java +++ b/src/com/engine/salary/wrapper/SalarySobItemWrapper.java @@ -19,7 +19,7 @@ import com.engine.salary.service.impl.SalarySobItemServiceImpl; import org.springframework.stereotype.Component; import weaver.hrm.User; -import java.util.Map; +import java.util.*; /** * 薪资账套的薪资项目 @@ -132,9 +132,31 @@ public class SalarySobItemWrapper extends Service { /** * 保存 * - * @param saveParam 保存参数 + * @param saveParam 保存参数 */ public void save(SalarySobItemSaveParam saveParam) { getSalarySobItemService(user).save(saveParam); } + + + public Collection> empFieldList() { + List> list = new ArrayList(); + Map taxAgentName = new HashMap<>(); + taxAgentName.put("name", "个税扣缴义务人"); + taxAgentName.put("id", "taxAgentName"); + list.add(taxAgentName); + Map username = new HashMap<>(); + username.put("name", "姓名"); + username.put("id", "username"); + list.add(username); + Map departmentName = new HashMap<>(); + departmentName.put("name", "部门"); + departmentName.put("id", "departmentName"); + list.add(departmentName); + Map email = new HashMap<>(); + email.put("name", "邮件"); + email.put("id", ""); + list.add(email); + return list; + } }