2022-08-11 10:27:15 +08:00
|
|
|
package com.engine.salary.sys.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.api.formmode.mybatis.util.SqlProxyHandle;
|
|
|
|
|
import com.engine.core.impl.Service;
|
2022-09-15 15:15:34 +08:00
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
2022-08-11 10:27:15 +08:00
|
|
|
import com.engine.salary.mapper.sys.SalarySysConfMapper;
|
2022-09-19 16:44:32 +08:00
|
|
|
import com.engine.salary.sys.entity.param.OrderRuleParam;
|
2022-08-11 10:27:15 +08:00
|
|
|
import com.engine.salary.sys.entity.po.SalarySysConfPO;
|
2022-09-19 16:44:32 +08:00
|
|
|
import com.engine.salary.sys.entity.vo.OrderRuleVO;
|
|
|
|
|
import com.engine.salary.sys.enums.AscOrDescEnum;
|
2022-09-19 13:41:09 +08:00
|
|
|
import com.engine.salary.sys.enums.OrderRuleEnum;
|
2022-08-11 10:27:15 +08:00
|
|
|
import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum;
|
|
|
|
|
import com.engine.salary.sys.service.SalarySysConfService;
|
|
|
|
|
import dm.jdbc.util.IdGenerator;
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
2022-09-14 11:28:17 +08:00
|
|
|
import java.util.List;
|
2022-08-11 10:27:15 +08:00
|
|
|
|
2022-09-19 16:44:32 +08:00
|
|
|
import static com.engine.salary.sys.constant.SalarySysConstant.*;
|
2022-09-19 13:41:09 +08:00
|
|
|
|
2022-08-11 10:27:15 +08:00
|
|
|
/**
|
|
|
|
|
* 薪酬系统配置类
|
|
|
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
*
|
|
|
|
|
* @author qiantao
|
|
|
|
|
* @version 1.0
|
|
|
|
|
**/
|
|
|
|
|
public class SalarySysConfServiceImpl extends Service implements SalarySysConfService {
|
|
|
|
|
|
|
|
|
|
private SalarySysConfMapper getSalarySysConfMapper() {
|
|
|
|
|
return SqlProxyHandle.getProxy(SalarySysConfMapper.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 操作是否需要申报功能
|
|
|
|
|
*
|
|
|
|
|
* @param flag 开启 0/关闭 1/重新开启 2
|
|
|
|
|
* @return 执行结果
|
|
|
|
|
*/
|
|
|
|
|
public boolean operateTaxDeclarationFunction(TaxDeclarationFunctionEnum flag) {
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
SalarySysConfPO taxDeclarationFunction = getSalarySysConfMapper().getOneByCode("taxDeclarationFunction");
|
|
|
|
|
if (taxDeclarationFunction == null) {
|
|
|
|
|
taxDeclarationFunction = SalarySysConfPO.builder().id(IdGenerator.generate()).confKey("taxDeclarationFunction").confValue(flag.getValue()).title(flag.getDefaultLabel()).module("taxDeclaration").orderWeight(0).createTime(date).updateTime(date).deleteType(0).build();
|
|
|
|
|
getSalarySysConfMapper().insertIgnoreNull(taxDeclarationFunction);
|
|
|
|
|
} else {
|
|
|
|
|
TaxDeclarationFunctionEnum oldFunctionEnum = TaxDeclarationFunctionEnum.parseByValue(taxDeclarationFunction.getConfValue());
|
|
|
|
|
//不改变
|
|
|
|
|
if (flag == oldFunctionEnum) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
//关闭
|
|
|
|
|
if (flag == TaxDeclarationFunctionEnum.CLOSURE) {
|
|
|
|
|
taxDeclarationFunction.setConfValue(flag.getValue());
|
|
|
|
|
taxDeclarationFunction.setTitle(flag.getDefaultLabel());
|
|
|
|
|
taxDeclarationFunction.setUpdateTime(new Date());
|
|
|
|
|
}
|
|
|
|
|
//重启
|
|
|
|
|
if (flag == TaxDeclarationFunctionEnum.OPEN && oldFunctionEnum == TaxDeclarationFunctionEnum.CLOSURE) {
|
|
|
|
|
taxDeclarationFunction.setConfValue(flag.getValue());
|
|
|
|
|
taxDeclarationFunction.setTitle(flag.getDefaultLabel());
|
|
|
|
|
taxDeclarationFunction.setUpdateTime(new Date());
|
|
|
|
|
}
|
|
|
|
|
getSalarySysConfMapper().updateIgnoreNull(taxDeclarationFunction);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-08-24 20:00:57 +08:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public SalarySysConfPO getOneByCode(String code) {
|
|
|
|
|
return getSalarySysConfMapper().getOneByCode(code);
|
|
|
|
|
}
|
2022-09-14 11:28:17 +08:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SalarySysConfPO> listSome(SalarySysConfPO po) {
|
|
|
|
|
return getSalarySysConfMapper().listSome(po);
|
|
|
|
|
}
|
2022-09-15 15:15:34 +08:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void save(SalarySysConfPO salarySysConfPO) {
|
|
|
|
|
salarySysConfPO.setId(IdGenerator.generate());
|
|
|
|
|
salarySysConfPO.setUpdateTime(new Date());
|
|
|
|
|
salarySysConfPO.setCreateTime(new Date());
|
|
|
|
|
salarySysConfPO.setDeleteType(0);
|
|
|
|
|
salarySysConfPO.setOrderWeight(0);
|
2022-09-19 13:41:09 +08:00
|
|
|
salarySysConfPO.setModule(CUSTOM_CODE);
|
2022-09-15 15:15:34 +08:00
|
|
|
|
|
|
|
|
getSalarySysConfMapper().insertIgnoreNull(salarySysConfPO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void update(SalarySysConfPO salarySysConfPO) {
|
|
|
|
|
SalarySysConfPO po = getSalarySysConfMapper().getById(salarySysConfPO.getId());
|
|
|
|
|
if (po == null) {
|
|
|
|
|
throw new SalaryRunTimeException("系统配置不存在");
|
|
|
|
|
}
|
|
|
|
|
salarySysConfPO.setUpdateTime(new Date());
|
|
|
|
|
getSalarySysConfMapper().updateIgnoreNull(salarySysConfPO);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-15 15:41:48 +08:00
|
|
|
@Override
|
|
|
|
|
public SalarySysConfPO getById(Long id) {
|
|
|
|
|
SalarySysConfPO po = getSalarySysConfMapper().getById(id);
|
|
|
|
|
if (po == null) {
|
|
|
|
|
throw new SalaryRunTimeException("系统配置不存在");
|
|
|
|
|
}
|
|
|
|
|
return po;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-19 13:41:09 +08:00
|
|
|
@Override
|
|
|
|
|
public void updateByCode(SalarySysConfPO po) {
|
|
|
|
|
SalarySysConfPO sysConfPO = getSalarySysConfMapper().getOneByCode(po.getConfKey());
|
|
|
|
|
if (sysConfPO == null) {
|
|
|
|
|
throw new SalaryRunTimeException("系统配置不存在");
|
|
|
|
|
}
|
|
|
|
|
sysConfPO.setConfValue(po.getConfValue());
|
|
|
|
|
sysConfPO.setUpdateTime(new Date());
|
|
|
|
|
getSalarySysConfMapper().updateIgnoreNull(sysConfPO);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-09-19 16:44:32 +08:00
|
|
|
public OrderRuleVO orderRule() {
|
|
|
|
|
SalarySysConfPO rulePO = getSalarySysConfMapper().getOneByCode(ORDER_RULE_CODE);
|
|
|
|
|
SalarySysConfPO orderPO = getSalarySysConfMapper().getOneByCode(ASCORDESC_CODE);
|
|
|
|
|
OrderRuleVO orderRuleVO = OrderRuleVO.builder().build();
|
|
|
|
|
if (rulePO == null) {
|
|
|
|
|
orderRuleVO.setOrderRule(OrderRuleEnum.DSPORDER);
|
|
|
|
|
} else {
|
|
|
|
|
orderRuleVO.setOrderRule(OrderRuleEnum.parseByValue(rulePO.getConfValue()));
|
|
|
|
|
}
|
|
|
|
|
if (orderPO == null) {
|
|
|
|
|
orderRuleVO.setAscOrDesc(AscOrDescEnum.ASC);
|
|
|
|
|
} else {
|
|
|
|
|
orderRuleVO.setAscOrDesc(AscOrDescEnum.parseByValue(orderPO.getConfValue()));
|
|
|
|
|
}
|
|
|
|
|
return orderRuleVO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void updateOrderRule(OrderRuleParam param) {
|
|
|
|
|
if (param == null || OrderRuleEnum.parseByValue(param.getOrderRule()) == null || AscOrDescEnum.parseByValue(param.getAscOrDesc()) == null) {
|
|
|
|
|
throw new SalaryRunTimeException("配置内容异常!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//更新排序规则
|
|
|
|
|
SalarySysConfPO orderRulePo = getSalarySysConfMapper().getOneByCode(ORDER_RULE_CODE);
|
|
|
|
|
if (orderRulePo == null) {
|
|
|
|
|
SalarySysConfPO build = SalarySysConfPO.builder()
|
|
|
|
|
.id(IdGenerator.generate())
|
|
|
|
|
.confKey(ORDER_RULE_CODE)
|
|
|
|
|
.confValue(param.getOrderRule())
|
|
|
|
|
.title("排序规则")
|
|
|
|
|
.orderWeight(0)
|
|
|
|
|
.module("basic")
|
|
|
|
|
.updateTime(new Date())
|
|
|
|
|
.createTime(new Date())
|
|
|
|
|
.deleteType(0)
|
|
|
|
|
.build();
|
|
|
|
|
getSalarySysConfMapper().insertIgnoreNull(build);
|
|
|
|
|
} else {
|
|
|
|
|
orderRulePo.setConfValue(param.getOrderRule());
|
|
|
|
|
orderRulePo.setUpdateTime(new Date());
|
|
|
|
|
getSalarySysConfMapper().updateIgnoreNull(orderRulePo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//更新顺序配置
|
|
|
|
|
SalarySysConfPO ascOrDescPo = getSalarySysConfMapper().getOneByCode(ASCORDESC_CODE);
|
|
|
|
|
if (ascOrDescPo == null) {
|
|
|
|
|
SalarySysConfPO build = SalarySysConfPO.builder()
|
|
|
|
|
.id(IdGenerator.generate())
|
|
|
|
|
.confKey(ASCORDESC_CODE)
|
|
|
|
|
.confValue(param.getAscOrDesc())
|
|
|
|
|
.title("排序顺序")
|
|
|
|
|
.orderWeight(0)
|
|
|
|
|
.module("basic")
|
|
|
|
|
.updateTime(new Date())
|
|
|
|
|
.createTime(new Date())
|
|
|
|
|
.deleteType(0)
|
|
|
|
|
.build();
|
|
|
|
|
getSalarySysConfMapper().insertIgnoreNull(build);
|
|
|
|
|
} else {
|
|
|
|
|
ascOrDescPo.setConfValue(param.getAscOrDesc());
|
|
|
|
|
ascOrDescPo.setUpdateTime(new Date());
|
|
|
|
|
getSalarySysConfMapper().updateIgnoreNull(ascOrDescPo);
|
2022-09-19 13:41:09 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-11 10:27:15 +08:00
|
|
|
}
|