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

143 lines
5.5 KiB
Java
Raw Normal View History

package com.engine.salary.service.impl;
import com.engine.core.impl.Service;
2022-03-28 20:04:27 +08:00
import com.engine.salary.biz.TaxAgentBiz;
import com.engine.salary.cmd.TaxAgent.*;
2022-04-21 14:15:56 +08:00
import com.engine.salary.entity.datacollection.AddUpDeduction;
import com.engine.salary.entity.datacollection.AddUpSituation;
import com.engine.salary.entity.datacollection.po.OtherDeductionPO;
import com.engine.salary.entity.salaryarchive.po.SalaryArchiveTaxAgentPO;
2022-03-28 20:04:27 +08:00
import com.engine.salary.entity.taxrate.TaxAgent;
2022-04-21 14:15:56 +08:00
import com.engine.salary.entity.taxrate.param.TaxAgentQueryParam;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.TaxAgentMapper;
import com.engine.salary.mapper.archive.SalaryArchiveTaxAgentMapper;
import com.engine.salary.mapper.datacollection.AddUpDeductionMapper;
import com.engine.salary.mapper.datacollection.AddUpSituationMapper;
import com.engine.salary.mapper.datacollection.OtherDeductionMapper;
import com.engine.salary.service.TaxAgentService;
2022-04-21 14:15:56 +08:00
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
2022-03-28 20:04:27 +08:00
import java.util.Collection;
2022-04-21 14:15:56 +08:00
import java.util.List;
import java.util.Map;
public class TaxAgentServiceImpl extends Service implements TaxAgentService {
2022-04-21 14:15:56 +08:00
private SalaryArchiveTaxAgentMapper getSalaryArchiveTaxAgentMapper() {
return MapperProxyFactory.getProxy(SalaryArchiveTaxAgentMapper.class);
}
private AddUpDeductionMapper getAddUpDeductionMapper() {
return MapperProxyFactory.getProxy(AddUpDeductionMapper.class);
}
private OtherDeductionMapper getOtherDeductionMapper() {
return MapperProxyFactory.getProxy(OtherDeductionMapper.class);
}
private AddUpSituationMapper getAddUpSituationMapper() {
return MapperProxyFactory.getProxy(AddUpSituationMapper.class);
}
private TaxAgentMapper getTaxAgentMapper() {
return MapperProxyFactory.getProxy(TaxAgentMapper.class);
}
@Override
public Map<String, Object> list(Map<String, Object> params) {
2022-04-21 14:15:56 +08:00
return commandExecutor.execute(new TaxAgentListCmd(params, user));
}
@Override
public Map<String, Object> getForm(Map<String, Object> params) {
2022-04-21 14:15:56 +08:00
return commandExecutor.execute(new TaxAgentGetFromCmd(params, user));
}
@Override
public Map<String, Object> save(Map<String, Object> params) {
2022-04-21 14:15:56 +08:00
return commandExecutor.execute(new TaxAgentSaveCmd(params, user));
}
@Override
public Map<String, Object> update(Map<String, Object> params) {
2022-04-21 14:15:56 +08:00
return commandExecutor.execute(new TaxAgentUpdateCmd(params, user));
}
@Override
2022-04-21 14:15:56 +08:00
public String delete(Collection<Long> ids) {
List<TaxAgent> taxAgents = getTaxAgentMapper().listBySome(TaxAgentQueryParam.builder().ids(ids).build());
if (CollectionUtils.isEmpty(taxAgents)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(85382, "要删除的个税扣缴义务人在不存在或已删除"));
}
// 正在使用的记录不允许删除
boolean checkUsed = checkUsed(ids);
if (checkUsed) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100570, "正在使用的记录不允许删除"));
}
getTaxAgentMapper().deleteByIds(ids);
// // 记录日志
// taxAgents.forEach(e -> SalaryLoggerUtil.recordDeleteSingleLog(taxAgentLoggerTemplate,
// e.getId(),
// e.getName(),
// SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100546, "删除个税扣缴义务人"),
// SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100546, "删除个税扣缴义务人") + "" + e.getName(),
// e));
return StringUtils.EMPTY;
}
2022-04-21 14:15:56 +08:00
/**
* 检查正在被使用的记录
*
* @param ids
* @return
*/
private boolean checkUsed(Collection<Long> ids) {
// 被薪资档案引用
List<SalaryArchiveTaxAgentPO> salaryArchiveTaxAgentList = getSalaryArchiveTaxAgentMapper().listSome(SalaryArchiveTaxAgentPO.builder().taxAgentIds(ids).build());
if (CollectionUtils.isNotEmpty(salaryArchiveTaxAgentList)) {
return Boolean.TRUE;
}
// 被累计专项附加扣除引用
List<AddUpDeduction> addUpDeductionList = getAddUpDeductionMapper().listSome(AddUpDeduction.builder().taxAgentIds(ids).build());
if (CollectionUtils.isNotEmpty(addUpDeductionList)) {
return Boolean.TRUE;
}
// 被其他免税扣除引用
List<OtherDeductionPO> otherDeductionList = getOtherDeductionMapper().listSome(OtherDeductionPO.builder().taxAgentIds(ids).build());
if (CollectionUtils.isNotEmpty(otherDeductionList)) {
return Boolean.TRUE;
}
// 被往期累计情况引用
List<AddUpSituation> addUpSituationList = getAddUpSituationMapper().listSome(AddUpSituation.builder().taxAgentIds(ids).build());
if (CollectionUtils.isNotEmpty(addUpSituationList)) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}
@Override
public Map<String, Object> selectList(Map<String, Object> params) {
2022-04-21 14:15:56 +08:00
return commandExecutor.execute(new TaxAgentSelectListCmd(params, user));
}
2022-03-28 20:04:27 +08:00
@Override
public Collection<TaxAgent> findAll() {
return new TaxAgentBiz().listAll();
}
2022-04-21 14:46:45 +08:00
@Override
public TaxAgent getById(Long id) {
return getTaxAgentMapper().getById(id);
}
}