weaver-hrm-salary/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java

107 lines
4.0 KiB
Java
Raw Normal View History

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;
import com.engine.salary.exception.SalaryRunTimeException;
2022-08-11 10:27:15 +08:00
import com.engine.salary.mapper.sys.SalarySysConfMapper;
import com.engine.salary.sys.entity.po.SalarySysConfPO;
import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum;
import com.engine.salary.sys.service.SalarySysConfService;
import dm.jdbc.util.IdGenerator;
import java.util.Date;
import java.util.List;
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);
}
@Override
public List<SalarySysConfPO> listSome(SalarySysConfPO po) {
return getSalarySysConfMapper().listSome(po);
}
@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-15 15:43:47 +08:00
salarySysConfPO.setModule("custom");
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-08-11 10:27:15 +08:00
}