薪资回算-薪资账套部分

This commit is contained in:
Harryxzy 2022-11-22 14:36:59 +08:00
parent a5ae8c8ea6
commit 036d2d540b
6 changed files with 116 additions and 24 deletions

View File

@ -120,6 +120,11 @@ public class SalarySobItemBO {
if (sysSalaryItemIds.contains(salaryItemPO.getSysSalaryItemId())) {
continue;
}
// 获取系统默认回算薪资项目的系统id
List<Long> backItemSysItemIds = SalarySobBackItemBO.getDefault().stream().map(SalarySobDefaultBackItemPO::getSysSalaryItemId).collect(Collectors.toList());
if (backItemSysItemIds.contains(salaryItemPO.getSysSalaryItemId())) {
continue;
}
salarySobItems.add(SalarySobItemPO.builder()
.salarySobId(salarySobId)
.salarySobItemGroupId(NumberUtils.LONG_ZERO)
@ -135,6 +140,7 @@ public class SalarySobItemBO {
.deleteType(NumberUtils.INTEGER_ZERO)
.build());
}
// 薪资账套默认的回算薪资项目
List<SalarySobBackItemPO> salarySobBackItems = Lists.newArrayListWithExpectedSize(2);
for (SalarySobDefaultBackItemPO salarySobDefaultBackItemPO : SalarySobBackItemBO.getDefault()) {

View File

@ -78,6 +78,11 @@ public interface SalarySobBackItemMapper {
*/
Long countBySalarySobIdIn(@Param("salarySobIdCollection")Collection<Long> salarySobIdCollection);
/**
* @description 根据薪资账套删除
* @return void
* @author Harryxzy
* @date 2022/11/22 14:17
*/
int deleteBySalarySobIds( @Param("salarySobIdList") Collection<Long> salarySobIdList);
}

View File

@ -373,5 +373,15 @@
</foreach>
</select>
<update id="deleteBySalarySobIds">
update hrsa_salary_sob_back_item
set delete_type = 1
where
salary_sob_id in
<foreach collection="salarySobIdList" item="item" open="(" close=")" separator=",">
#{item,jdbcType=NUMERIC}
</foreach>
</update>
</mapper>

View File

@ -19,6 +19,7 @@ import com.engine.salary.service.SalarySobService;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.math.NumberUtils;
import weaver.hrm.User;
@ -63,7 +64,8 @@ public class SalarySobBackItemServiceImpl extends Service implements SalarySobBa
@Override
public void batchInsert(List<SalarySobBackItemPO> needInsertSalarySobBackItems) {
getSalarySobBackItemMapper().batchInsert(needInsertSalarySobBackItems);
List<List<SalarySobBackItemPO>> partition = Lists.partition(needInsertSalarySobBackItems, 100);
partition.forEach(getSalarySobBackItemMapper()::batchInsert);
}
@Override

View File

@ -23,6 +23,7 @@ import com.engine.salary.enums.SalarySystemTypeEnum;
import com.engine.salary.enums.salarysob.IncomeCategoryEnum;
import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.salarysob.SalarySobBackItemMapper;
import com.engine.salary.mapper.salarysob.SalarySobMapper;
import com.engine.salary.service.*;
import com.engine.salary.util.SalaryEntityUtil;
@ -70,6 +71,10 @@ public class SalarySobServiceImpl extends Service implements SalarySobService {
private SalarySobRangeBiz salarySobRangeBiz = new SalarySobRangeBiz();
private SalarySobBackItemMapper getSalarySobBackItemMapper() {
return MapperProxyFactory.getProxy(SalarySobBackItemMapper.class);
}
private SalarySobMapper getSalarySobMapper() {
return MapperProxyFactory.getProxy(SalarySobMapper.class);
}
@ -300,7 +305,8 @@ public class SalarySobServiceImpl extends Service implements SalarySobService {
// 2.1查询已经添加到薪资项目中的系统薪资项目
Set<Long> defaultSysSalaryItemIds = SalaryEntityUtil.properties(salarySobDefaultItemPOS, SalarySobDefaultItemPO::getSysSalaryItemId);
// 薪资账套的默认的回算薪资项目
defaultSysSalaryItemIds.addAll(SalaryEntityUtil.properties(SalarySobBackItemBO.getDefault(), SalarySobDefaultBackItemPO::getSysSalaryItemId));
Set<Long> SalarySobBackItemIds = SalaryEntityUtil.properties(SalarySobBackItemBO.getDefault(), SalarySobDefaultBackItemPO::getSysSalaryItemId);
defaultSysSalaryItemIds.addAll(SalarySobBackItemIds);
List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listBySysSalaryItemIds(defaultSysSalaryItemIds);
Set<Long> sysSalaryItemIds = SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getSysSalaryItemId);
@ -309,6 +315,8 @@ public class SalarySobServiceImpl extends Service implements SalarySobService {
.map(SalarySobDefaultItemPO::getSysSalaryItemId)
.filter(sysSalaryItemId -> !sysSalaryItemIds.contains(sysSalaryItemId))
.collect(Collectors.toSet());
// 需要添加进薪资项目中的回算薪资项目
needAddSysSalaryItemIds.addAll( SalarySobBackItemIds.stream().filter(salarySobBackItemId -> !sysSalaryItemIds.contains(salarySobBackItemId)).collect(Collectors.toList()) );
List<SysSalaryItemPO> needAddSysSalaryItemPOS = getSysSalaryItemService(user).listByIds(needAddSysSalaryItemIds);
// 2.3需要保存的薪资项目
List<SalaryItemPO> needInsertSalaryItemPOS = SysSalaryItemBO.convert2SalaryItemPO(needAddSysSalaryItemPOS, (long) user.getUID());
@ -375,7 +383,7 @@ public class SalarySobServiceImpl extends Service implements SalarySobService {
/**
* @description 将TaxAgentManageRangeListDTO转换为SalarySobRangePO
* @return List<SalarySangePO>
* @return List<SalarySobRangePO>
* @author Harryxzy
* @date 2022/10/9 16:06
*/
@ -551,7 +559,9 @@ public class SalarySobServiceImpl extends Service implements SalarySobService {
salarySobItemHideService.deleteBySalarySobIds(ids);
// 删除薪资账套的调薪计薪规则
salarySobAdjustRuleService.deleteBySalarySobIds(ids);
// // 删除薪资账套的校验规则
// 删除薪资账套的回算薪资项目
getSalarySobBackItemMapper().deleteBySalarySobIds(ids);
// 删除薪资账套的校验规则
getSalarySobCheckRuleService(user).deleteBySalarySobIds(ids);
// // 记录日志
// salarySobPOS.forEach(salarySobPO -> {

View File

@ -2,30 +2,37 @@ package com.engine.salary.wrapper;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.salaryitem.bo.SysSalaryItemBO;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO;
import com.engine.salary.entity.salarysob.bo.SalarySobBO;
import com.engine.salary.entity.salarysob.bo.SalarySobBackItemBO;
import com.engine.salary.entity.salarysob.dto.SalarySobBasicFormDTO;
import com.engine.salary.entity.salarysob.dto.SalarySobListDTO;
import com.engine.salary.entity.salarysob.param.SalarySobBasicSaveParam;
import com.engine.salary.entity.salarysob.param.SalarySobDisableParam;
import com.engine.salary.entity.salarysob.param.SalarySobDuplicateParam;
import com.engine.salary.entity.salarysob.param.SalarySobListQueryParam;
import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobDefaultBackItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobPO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.enums.salarysob.IncomeCategoryEnum;
import com.engine.salary.enums.sicategory.DeleteTypeEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.service.SalarySobBackItemService;
import com.engine.salary.service.SalarySobService;
import com.engine.salary.service.TaxAgentService;
import com.engine.salary.service.impl.SalarySobBackItemServiceImpl;
import com.engine.salary.service.impl.SalarySobServiceImpl;
import com.engine.salary.service.impl.TaxAgentServiceImpl;
import com.engine.salary.service.*;
import com.engine.salary.service.impl.*;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.SalarySobUtil;
import com.engine.salary.util.page.PageInfo;
import dm.jdbc.util.IdGenerator;
import org.apache.commons.collections4.CollectionUtils;
import weaver.hrm.User;
import java.util.*;
import java.util.stream.Collectors;
/**
* 薪资账套
@ -51,6 +58,14 @@ public class SalarySobWrapper extends Service {
return ServiceUtil.getService(SalarySobBackItemServiceImpl.class, user);
}
private SalaryItemService getSalaryItemService(User user) {
return ServiceUtil.getService(SalaryItemServiceImpl.class, user);
}
private SysSalaryItemService getSysSalaryItemService(User user) {
return ServiceUtil.getService(SysSalaryItemServiceImpl.class, user);
}
/**
* 薪资账套列表
@ -62,13 +77,9 @@ public class SalarySobWrapper extends Service {
// 处理历史数据将薪资账套中将关联人员状态转换为List
SalarySobUtil.handleEmployeeStatusHistory();
// 处理历史数据为薪资账套默认添加回算薪资项目
// handleSalarySobBackItemHistory();
// 查询薪资账套
PageInfo<SalarySobPO> page = getSalarySobService(user).listPageByParam(queryParam);
// 薪资账套po转换成薪资账套列表dto
List<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAll();
Map<Long, String> taxAgentIdTONameMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId, TaxAgentPO::getName);
@ -77,18 +88,66 @@ public class SalarySobWrapper extends Service {
dtoPage.setTotal(page.getTotal());
dtoPage.setPageNum(page.getPageNum());
dtoPage.setPageSize(page.getPageSize());
// 处理历史数据为薪资账套默认添加回算薪资项目
handleSalarySobBackItemHistory(queryParam);
// 转换成前端所需的数据格式
return dtoPage;
}
// private void handleSalarySobBackItemHistory() {
// // 获取个税扣缴义务人下所有的薪资账套
// Long count = getSalarySobBackItemService(user).getCountBySalarySobIdIn();
// if(count.equals(0)){
// //没有回算薪资项目数据给所有薪资账套初始化
//
// }
// }
private void handleSalarySobBackItemHistory(SalarySobListQueryParam queryParam) {
queryParam.setPageSize(100000);
List<SalarySobPO> list = getSalarySobService(user).listPageByParam(queryParam).getList();
if(list != null && list.size()>0){
List<Long> salarySobIds = list.stream().map(SalarySobPO::getId).collect(Collectors.toList());
Long count = getSalarySobBackItemService(user).getCountBySalarySobIdIn(salarySobIds);
if(count.equals(0L)){
// 薪资账套的默认的回算薪资项目
Set<Long> SalarySobBackItemIds = SalaryEntityUtil.properties(SalarySobBackItemBO.getDefault(), SalarySobDefaultBackItemPO::getSysSalaryItemId);
// 获取薪资项目中是否已经添加回算薪资项目
List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listBySysSalaryItemIds(SalarySobBackItemIds);
Set<Long> salaryBackItemSysIds = SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getSysSalaryItemId);
// 需要添加进薪资项目中的回算薪资项目
List<Long> needAddSalaryBackItemIds = SalarySobBackItemIds.stream().filter(salarySobBackItemId -> !salaryBackItemSysIds.contains(salarySobBackItemId)).collect(Collectors.toList());
List<SysSalaryItemPO> needAddSysSalaryBackItemPOS = getSysSalaryItemService(user).listByIds(needAddSalaryBackItemIds);
// 需要保存的回算薪资项目
List<SalaryItemPO> needInsertSalaryItemPOS = SysSalaryItemBO.convert2SalaryItemPO(needAddSysSalaryBackItemPOS, (long) user.getUID());
if (CollectionUtils.isNotEmpty(needInsertSalaryItemPOS)) {
getSalaryItemService(user).batchSave(needInsertSalaryItemPOS);
}
// 没有回算薪资项目数据给所有薪资账套添加默认回算薪资项目
List<SalarySobBackItemPO> salarySobBackItems = new ArrayList<>();
// 获取默认添加后的回算薪资项目
List<SalaryItemPO> salaryBackItemPOS = getSalaryItemService(user).listBySysSalaryItemIds(SalarySobBackItemIds);
for(Long id : salarySobIds){
for (SalarySobDefaultBackItemPO salarySobDefaultBackItemPO : SalarySobBackItemBO.getDefault()) {
Date now = new Date();
Map<Long, SalaryItemPO> sysSalaryItemMap = SalaryEntityUtil.convert2Map(salaryBackItemPOS, SalaryItemPO::getSysSalaryItemId);
SalaryItemPO salaryItemPO = sysSalaryItemMap.get(salarySobDefaultBackItemPO.getSysSalaryItemId());
SalarySobBackItemPO salarySobBackItemPO = SalarySobBackItemPO.builder()
.id(IdGenerator.generate())
.salarySobId(id)
.salaryItemId(salaryItemPO.getId())
.salaryItemCode(salaryItemPO.getCode())
.dataType(salaryItemPO.getDataType())
.roundingMode(salaryItemPO.getRoundingMode())
.pattern(salaryItemPO.getPattern())
.valueType(salaryItemPO.getValueType())
.formulaId(salarySobDefaultBackItemPO.getFormulaId())
.backCalcType(salarySobDefaultBackItemPO.getBackCalcType())
.creator((long)user.getUID())
.createTime(now)
.updateTime(now)
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).build();
salarySobBackItems.add(salarySobBackItemPO);
}
}
// 入库
getSalarySobBackItemService(user).batchInsert(salarySobBackItems);
}
}
}
/**
* 薪资账套详情