修复薪资档案个税扣缴义务人不显示的问题

处理历史数据改为异步
This commit is contained in:
钱涛 2022-11-07 15:11:24 +08:00
parent dc4f4d9032
commit 2da0455c46
2 changed files with 36 additions and 73 deletions

View File

@ -1,6 +1,6 @@
package com.engine.salary.service.impl;
import com.api.formmode.mybatis.util.SqlProxyHandle;
import com.cloudstore.dev.api.util.Util_DataCache;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.biz.*;
@ -26,9 +26,9 @@ import com.engine.salary.enums.taxagent.TaxAgentEmpChangeModuleEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.archive.SalaryArchiveItemMapper;
import com.engine.salary.mapper.archive.SalaryArchiveMapper;
import com.engine.salary.mapper.sys.SalarySysConfMapper;
import com.engine.salary.service.*;
import com.engine.salary.sys.entity.vo.OrderRuleVO;
import com.engine.salary.sys.enums.OpenEnum;
import com.engine.salary.sys.service.SalarySysConfService;
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
import com.engine.salary.util.SalaryDateUtil;
@ -118,11 +118,6 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
return ServiceUtil.getService(SalaryArchiveItemServiceImpl.class, user);
}
private SalarySysConfMapper getSalarySysConfMapper() {
return SqlProxyHandle.getProxy(SalarySysConfMapper.class);
}
@Override
public SalaryArchivePO getById(Long salaryArchiveId) {
return salaryArchiveMapper.getById(salaryArchiveId);
@ -131,10 +126,10 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
@Override
public List<SalaryArchivePO> listSome(SalaryArchivePO po) {
Collection<Long> ids = po.getIds();
if(CollectionUtils.isNotEmpty(ids)){
if (CollectionUtils.isNotEmpty(ids)) {
List<SalaryArchivePO> list = new ArrayList<>();
List<List<Long>> partition = Lists.partition((List<Long>) ids, 1000);
partition.forEach(idss->{
partition.forEach(idss -> {
po.setIds(idss);
list.addAll(getSalaryArchiveMapper().listSome(po));
});
@ -142,10 +137,10 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
}
Collection<Long> employeeIds = po.getEmployeeIds();
if(CollectionUtils.isNotEmpty(employeeIds)){
if (CollectionUtils.isNotEmpty(employeeIds)) {
List<SalaryArchivePO> list = new ArrayList<>();
List<List<Long>> partition = Lists.partition((List<Long>) employeeIds, 1000);
partition.forEach(emps->{
partition.forEach(emps -> {
po.setEmployeeIds(emps);
list.addAll(getSalaryArchiveMapper().listSome(po));
});
@ -160,13 +155,24 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
public PageInfo<SalaryArchiveListDTO> listPage(SalaryArchiveQueryParam queryParam) {
long currentEmployeeId = user.getUID();
// 1.历史数据处理
handleHistory(currentEmployeeId);
// 2.待停薪自动处理
handleSuspendData(currentEmployeeId);
// 3.增量数据处理
handleChangeData(currentEmployeeId);
/**
* 异步处理档案数据
*/
String handleable = Util.null2String(Util_DataCache.getObjVal("salaryArchiveHandleable"));
if (StringUtils.isBlank(handleable) || OpenEnum.OPEN.getValue().equals(handleable)) {
new Thread() {
public void run() {
Util_DataCache.setObjVal("salaryArchiveHandleable", "0");
// 1.历史数据处理
handleHistory(currentEmployeeId);
// 2.待停薪自动处理
handleSuspendData(currentEmployeeId);
// 3.增量数据处理
handleChangeData(currentEmployeeId);
Util_DataCache.setObjVal("salaryArchiveHandleable", "1");
}
}.start();
}
Boolean needAuth = getTaxAgentService(user).isNeedAuth(currentEmployeeId);
@ -1107,9 +1113,9 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
}
List<SalaryArchivePO> oldList = listSome(SalaryArchivePO.builder()
.ids(ids)
.runStatus(SalaryArchiveStatusEnum.PENDING.getValue())
.build());
.ids(ids)
.runStatus(SalaryArchiveStatusEnum.PENDING.getValue())
.build());
if (CollectionUtils.isEmpty(oldList)) {
@ -1192,9 +1198,9 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录"));
}
List<SalaryArchivePO> oldList = listSome(SalaryArchivePO.builder()
.ids(ids)
.runStatus(SalaryArchiveStatusEnum.SUSPEND.getValue())
.build());
.ids(ids)
.runStatus(SalaryArchiveStatusEnum.SUSPEND.getValue())
.build());
if (CollectionUtils.isEmpty(oldList)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "档案不存在!"));
@ -1241,9 +1247,9 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
}
List<SalaryArchivePO> oldList = listSome(SalaryArchivePO.builder()
.ids(ids)
.runStatus(SalaryArchiveStatusEnum.SUSPEND.getValue())
.build());
.ids(ids)
.runStatus(SalaryArchiveStatusEnum.SUSPEND.getValue())
.build());
List<SalaryArchivePO> unableList = oldList.stream().filter(f -> Objects.nonNull(f.getPayEndDate()) && !f.getPayEndDate().after(new Date())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(unableList)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(115789, "最后发薪日必须晚于今天"));

View File

@ -15,7 +15,6 @@ import com.engine.salary.entity.salaryarchive.param.*;
import com.engine.salary.entity.salaryarchive.po.SalaryArchiveDimissionPO;
import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO;
import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO;
import com.engine.salary.entity.salaryarchive.po.SalaryArchiveTaxAgentPO;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.taxagent.dto.TaxAgentListDTO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
@ -323,16 +322,8 @@ public class SalaryArchiveWrapper extends Service {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100465, "薪资档案员工信息不存在"));
}
// 获取当前已生效个税扣缴义务人
List<SalaryArchiveTaxAgentPO> taxAgentList = getSalaryArchiveService(user).getCurrentEffectiveTaxAgentList(Collections.singletonList(salaryArchiveId));
// 获取所有个税扣缴义务人
Collection<TaxAgentListDTO> taxAgentLists = getTaxAgentService(user).findAll();
String taxAgent = "";
if (CollectionUtils.isNotEmpty(taxAgentList)) {
SalaryArchiveTaxAgentPO salaryArchiveTaxAgent = taxAgentList.get(0);
Optional<TaxAgentListDTO> taxAgentOptional = taxAgentLists.stream().filter(f -> f.getId().equals(salaryArchiveTaxAgent.getTaxAgentId())).findFirst();
taxAgent = taxAgentOptional.isPresent() ? taxAgentOptional.get().getName() : taxAgent;
}
Long taxAgentId = po.getTaxAgentId();
TaxAgentPO taxAgent = getTaxAgentService(user).getById(taxAgentId);
// 1.基本信息表单
Map<String, Object> baseInfo = new HashMap<>();
@ -343,7 +334,7 @@ public class SalaryArchiveWrapper extends Service {
.position(employee.getJobtitleName() == null ? "" : employee.getJobtitleName())
.hiredate(employee.getCompanystartdate())
.mobile(employee.getMobile())
.taxAgent(taxAgent)
.taxAgent(taxAgent.getName())
.build();
baseInfo.put("employee", build);
@ -422,31 +413,6 @@ public class SalaryArchiveWrapper extends Service {
return importTypes;
}
// /**
// * 导出薪资档案
// *
// * @param queryParam
// * @param employeeId
// * @param tenantKey
// * @return
// */
// public Map<String, Object> exportList(SalaryArchiveQueryParam queryParam, Long employeeId, String tenantKey) {
// // 构建异步导出参数
// Map<String, Object> map = salaryBatchService.buildeExportParam("exportSalaryArchive");
// String username = UserContext.getCurrentUser().getUsername();
// String eteamsId = TenantRpcContext.getEteamsId();
// taskExecutor.execute(() -> {
// try {
// DSTenantKeyThreadVar.tenantKey.set(tenantKey);
// getSalaryArchiveService(user).exportList(map, username, eteamsId, queryParam, employeeId, tenantKey);
// } finally {
// DSTenantKeyThreadVar.tenantKey.remove();
// }
// });
//
// return map;
// }
//
/**
* 下载导入模板
@ -561,15 +527,6 @@ public class SalaryArchiveWrapper extends Service {
return getSalaryArchiveExcelService(user).processInit(importData);
}
// public Map<String, Object> importSalaryArchiveSalaryItemAdjust(SalaryArchiveImportActionParam importData) {
// importData.setListType("FIXED");
// importData.setImportType("salaryItemAdjust");
// importData.setAddData(true);
// return getSalaryArchiveExcelService(user).processInit(importData);
// }
/**
* 停薪
*