weaver-hrm-salary/src/com/engine/salary/service/impl/SalarySobAdjustRuleServiceI...

101 lines
3.9 KiB
Java
Raw Normal View History

2022-03-25 18:05:07 +08:00
package com.engine.salary.service.impl;
import com.engine.core.impl.Service;
import com.engine.salary.biz.SalarySobAdjustRuleBiz;
2024-01-30 09:58:13 +08:00
import com.engine.salary.config.SalaryElogConfig;
2024-03-12 14:34:44 +08:00
import com.engine.hrmelog.entity.dto.LoggerContext;
2022-03-25 18:05:07 +08:00
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;
2024-01-30 09:58:13 +08:00
import com.engine.salary.enums.OperateTypeEnum;
2022-03-25 18:05:07 +08:00
import com.engine.salary.exception.SalaryRunTimeException;
2022-03-30 20:27:17 +08:00
import com.engine.salary.mapper.salarysob.SalarySobAdjustRuleMapper;
2022-03-30 18:32:44 +08:00
import com.engine.salary.mapper.salarysob.SalarySobMapper;
2022-03-25 18:05:07 +08:00
import com.engine.salary.service.SalarySobAdjustRuleService;
import com.engine.salary.util.SalaryI18nUtil;
2022-04-11 20:46:25 +08:00
import com.engine.salary.util.db.MapperProxyFactory;
2022-03-25 18:05:07 +08:00
import com.engine.salary.util.valid.ValidUtil;
import org.apache.commons.collections4.CollectionUtils;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
/**
* 调薪计薪规则
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public class SalarySobAdjustRuleServiceImpl extends Service implements SalarySobAdjustRuleService {
private SalarySobAdjustRuleBiz salarySobAdjustRuleMapper = new SalarySobAdjustRuleBiz();
2022-04-21 14:15:56 +08:00
SalarySobMapper getSalarySobMapper(){
return MapperProxyFactory.getProxy(SalarySobMapper.class);
}
SalarySobAdjustRuleMapper getSalarySobAdjustRuleMapper(){
return MapperProxyFactory.getProxy(SalarySobAdjustRuleMapper.class);
}
2022-03-25 18:05:07 +08:00
@Override
public List<SalarySobAdjustRulePO> listBySalarySobId(Long salarySobId) {
if (salarySobId == null) {
return Collections.emptyList();
}
return salarySobAdjustRuleMapper.listBySalarySobId(salarySobId);
}
@Override
public void save(SalarySobAdjustRuleSaveParam saveParam) {
ValidUtil.doValidator(saveParam);
2022-03-30 20:27:17 +08:00
//开启事务
2022-04-21 14:15:56 +08:00
// SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
// try {
// 查询薪资账套
SalarySobPO salarySobPO = getSalarySobMapper().getById(saveParam.getSalarySobId());
if (Objects.isNull(salarySobPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(user.getLanguage(),542420, "参数错误,薪资账套不存在或者已被删除"));
2022-04-21 14:15:56 +08:00
}
// 删除之前的调薪计薪规则
getSalarySobAdjustRuleMapper().deleteBySalarySobIds(Collections.singleton(saveParam.getSalarySobId()));
// 保存参数转换成薪资账套的调薪计薪规则po
List<SalarySobAdjustRulePO> salarySobAdjustRulePOS = SalarySobAdjustRuleBO.convert2PO(saveParam, (long) user.getUID());
// 保存
if (CollectionUtils.isNotEmpty(salarySobAdjustRulePOS)) {
salarySobAdjustRuleMapper.batchInsert(salarySobAdjustRulePOS);
}
// 记录日志
2024-01-30 09:58:13 +08:00
LoggerContext<SalarySobPO> loggerContext = new LoggerContext<>();
2024-02-21 18:19:02 +08:00
loggerContext.setUser(user);
2024-01-30 09:58:13 +08:00
loggerContext.setTargetId(String.valueOf(salarySobPO.getId()));
loggerContext.setTargetName(salarySobPO.getName());
loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
2024-02-21 18:19:02 +08:00
loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "保存调薪计薪规则"));
loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "保存调薪计薪规则"));
2024-01-30 09:58:13 +08:00
SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext);
2022-03-25 18:05:07 +08:00
}
@Override
public void batchSave(Collection<SalarySobAdjustRulePO> salarySobAdjustRulePOS) {
salarySobAdjustRuleMapper.batchInsert(salarySobAdjustRulePOS);
}
@Override
public void deleteBySalarySobIds(Collection<Long> salarySobIds) {
salarySobAdjustRuleMapper.deleteBySalarySobIds(salarySobIds);
}
}