Merge remote-tracking branch 'remotes/origin/feature/v2-welHistoryDetail-1104' into release/2.1.2.2211.01
This commit is contained in:
commit
65208fb265
|
|
@ -55,6 +55,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.springframework.util.StopWatch;
|
||||
import weaver.conn.mybatis.MyBatisFactory;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
|
|
@ -911,7 +912,7 @@ public class SIArchivesBiz {
|
|||
public Map<String, Object> listPageEmployeePOS(InsuranceArchivesListParam param, long operateId) {
|
||||
//是否分权
|
||||
Boolean needAuth = param.getNeedAuth();
|
||||
|
||||
StopWatch sw = new StopWatch();
|
||||
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
|
||||
Map<String, Object> datas = new HashMap<>(16);
|
||||
try {
|
||||
|
|
@ -924,11 +925,15 @@ public class SIArchivesBiz {
|
|||
if (needAuth) {
|
||||
Collection<Long> taxAgentEmployeeIds = param.getTaxAgentEmployeeIds();
|
||||
Collection<Long> taxAgentIds = param.getTaxAgentIds();
|
||||
sw.start("获取福利档案列表数据");
|
||||
page = socialSchemeMapper.queryEmployeeList(param);
|
||||
sw.stop();
|
||||
|
||||
page = page.stream().filter(f ->
|
||||
// taxAgentEmployeeIds.contains(f.getEmployeeId())||
|
||||
taxAgentIds.contains(f.getPaymentOrganization())
|
||||
).collect(Collectors.toList());
|
||||
|
||||
// 填充总数和当页数据
|
||||
// 分页参数
|
||||
pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), InsuranceArchivesEmployeePO.class);
|
||||
|
|
@ -937,17 +942,23 @@ public class SIArchivesBiz {
|
|||
} else {
|
||||
SalaryPageUtil.start(param.getCurrent(), param.getPageSize());
|
||||
// List<InsuranceArchivesEmployeePO> page = socialSchemeMapper.listPageEmployeePOS(param);
|
||||
sw.start("获取档案列表数据");
|
||||
page = socialSchemeMapper.queryEmployeeList(param);
|
||||
sw.stop();
|
||||
|
||||
pageInfo = new PageInfo<>(page, InsuranceArchivesEmployeePO.class);
|
||||
}
|
||||
List<Map<String, Object>> records = null;
|
||||
sw.start("buildTableData方法处理福利档案列表数据");
|
||||
if (param.getExportData() != null && param.getExportData()) {
|
||||
records = buildTableData(page, true);
|
||||
} else {
|
||||
records = buildTableData(page, false);
|
||||
}
|
||||
sw.stop();
|
||||
sw.start("buildWeaTableColumns方法处理福利档案列表数据");
|
||||
List<WeaTableColumn> columns = buildWeaTableColumns(page, operateId);
|
||||
|
||||
sw.stop();
|
||||
WeaTable table = new WeaTable();
|
||||
table.setColumns(columns);
|
||||
//设置check是否可用
|
||||
|
|
@ -967,6 +978,8 @@ public class SIArchivesBiz {
|
|||
datas.put("datas", records);
|
||||
datas.put("columns", columns);
|
||||
datas.put("dataKey", result.getResultMap());
|
||||
|
||||
log.info("各操作计时 {}", sw.prettyPrint());
|
||||
return datas;
|
||||
|
||||
} finally {
|
||||
|
|
@ -1422,9 +1435,14 @@ public class SIArchivesBiz {
|
|||
* 判断是否需要生成历史福利档案基本信息
|
||||
*/
|
||||
public void createOldInsuranceBaseInfo(Long creator) {
|
||||
|
||||
StopWatch sw = new StopWatch();
|
||||
log.info("判断是否需要生成历史数据");
|
||||
List<InsuranceArchivesBaseInfoPO> nowBaseInfoList = getInsuranceBaseInfoMapper().getInsuranceBaseInfoList();
|
||||
if (nowBaseInfoList.size() == 0) {
|
||||
log.info("福利档案基础信息表为空,开始生成历史数据:");
|
||||
//处理公积金、其他福利档案中个税扣缴义务人为空的情况
|
||||
sw.start("处理公积金、其他福利档案中个税扣缴义务人为空的情况");
|
||||
List<InsuranceArchivesSocialSchemePO> socialList = getSocialSchemeMapper().listAll();
|
||||
List<InsuranceArchivesFundSchemePO> fundList = getFundSchemeMapper().listAll();
|
||||
List<InsuranceArchivesOtherSchemePO> otherList = getOtherSchemeMapper().listAll();
|
||||
|
|
@ -1434,28 +1452,36 @@ public class SIArchivesBiz {
|
|||
for (InsuranceArchivesSocialSchemePO socialSchemePO : socialList) {
|
||||
List<InsuranceArchivesFundSchemePO> toDealFundList = fundList.stream().filter(f -> f.getEmployeeId().equals(socialSchemePO.getEmployeeId()) && f.getPaymentOrganization() == null).collect(Collectors.toList());
|
||||
if (toDealFundList.size() > 0) {
|
||||
for (InsuranceArchivesFundSchemePO toDealFundPO : toDealFundList) {
|
||||
toDealFundPO.setPaymentOrganization(socialSchemePO.getPaymentOrganization());
|
||||
updateFundList.add(toDealFundPO);
|
||||
}
|
||||
InsuranceArchivesFundSchemePO toDealFundPO = toDealFundList.get(0);
|
||||
toDealFundPO.setPaymentOrganization(socialSchemePO.getPaymentOrganization());
|
||||
updateFundList.add(toDealFundPO);
|
||||
}
|
||||
|
||||
List<InsuranceArchivesOtherSchemePO> toDealOtherList = otherList.stream().filter(f -> f.getEmployeeId().equals(socialSchemePO.getEmployeeId()) && f.getPaymentOrganization() == null).collect(Collectors.toList());
|
||||
if (toDealOtherList.size() > 0) {
|
||||
for (InsuranceArchivesOtherSchemePO toDealOtherPO : toDealOtherList) {
|
||||
toDealOtherPO.setPaymentOrganization(socialSchemePO.getPaymentOrganization());
|
||||
updateOtherList.add(toDealOtherPO);
|
||||
}
|
||||
InsuranceArchivesOtherSchemePO toDealOtherPO = toDealOtherList.get(0);
|
||||
toDealOtherPO.setPaymentOrganization(socialSchemePO.getPaymentOrganization());
|
||||
updateOtherList.add(toDealOtherPO);
|
||||
|
||||
}
|
||||
//更新公积金和其他福利档案
|
||||
updateFundList.forEach(getFundSchemeMapper()::updateById);
|
||||
updateOtherList.forEach(getOtherSchemeMapper()::updateById);
|
||||
|
||||
}
|
||||
log.info("重置个税扣缴义务人id的公积金档案数:{}", updateFundList.size());
|
||||
log.info("重置个税扣缴义务人id的其他福利档案数:{}", updateOtherList.size());
|
||||
//更新公积金和其他福利档案
|
||||
updateFundList.forEach(getFundSchemeMapper()::updateById);
|
||||
updateOtherList.forEach(getOtherSchemeMapper()::updateById);
|
||||
sw.stop();
|
||||
|
||||
|
||||
//
|
||||
sw.start("处理待入库的历史福利档案基础信息并入库");
|
||||
List<InsuranceArchivesBaseInfoPO> addBaseInfoList = new ArrayList<>();
|
||||
|
||||
List<InsuranceArchivesBaseInfoPO> oldBaseInfoList = getInsuranceBaseInfoMapper().getInsuranceBaseInfoListByInsuranceDetail(null);
|
||||
log.info("获取待生成的历史福利档案基础信息条数:{}", oldBaseInfoList.size());
|
||||
//去重
|
||||
oldBaseInfoList = oldBaseInfoList.stream()
|
||||
.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getPaymentOrganization() + "-" + f.getEmployeeId()))), ArrayList::new));
|
||||
log.info("去重后的待生成历史福利档案基础信息条数:{}", oldBaseInfoList.size());
|
||||
if (oldBaseInfoList.size() > 0) {
|
||||
//设置基本信息表字段
|
||||
for (InsuranceArchivesBaseInfoPO po : oldBaseInfoList) {
|
||||
|
|
@ -1473,8 +1499,9 @@ public class SIArchivesBiz {
|
|||
List<List<InsuranceArchivesBaseInfoPO>> partition = Lists.partition(addBaseInfoList, 50);
|
||||
partition.forEach(getInsuranceBaseInfoMapper()::batchSave);
|
||||
}
|
||||
sw.stop();
|
||||
}
|
||||
|
||||
log.info("各操作计时 {}", sw.prettyPrint());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,10 +35,13 @@ import com.engine.salary.util.SalaryI18nUtil;
|
|||
import com.engine.salary.util.db.MapperProxyFactory;
|
||||
import com.engine.salary.util.excel.ExcelUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.icbc.api.internal.apache.http.impl.cookie.S;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StopWatch;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
|
||||
|
|
@ -52,6 +55,7 @@ import java.util.stream.Collectors;
|
|||
* @Date 2022/3/11
|
||||
* @Version V1.0
|
||||
**/
|
||||
@Slf4j
|
||||
public class SIArchivesServiceImpl extends Service implements SIArchivesService {
|
||||
|
||||
private SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
|
||||
|
|
@ -134,13 +138,22 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService
|
|||
@Override
|
||||
public Map<String, Object> listPage(InsuranceArchivesListParam param) {
|
||||
long currentEmployeeId = user.getUID();
|
||||
|
||||
log.info("获取福利档案列表逻辑开始: {}", param);
|
||||
StopWatch sw = new StopWatch();
|
||||
sw.start("福利档案-历史数据处理");
|
||||
// 1.历史数据处理
|
||||
siArchivesBiz.createOldInsuranceBaseInfo(currentEmployeeId);
|
||||
sw.stop();
|
||||
|
||||
sw.start("福利档案-待减员自动处理");
|
||||
// 2.待减员自动处理
|
||||
handleStayDelData(currentEmployeeId);
|
||||
sw.stop();
|
||||
|
||||
sw.start("福利档案-增量数据处理");
|
||||
// 3.增量数据处理
|
||||
handleChangeData(currentEmployeeId);
|
||||
sw.stop();
|
||||
|
||||
//排序配置
|
||||
OrderRuleVO orderRule = getSalarySysConfService(user).orderRule();
|
||||
|
|
@ -160,6 +173,7 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService
|
|||
SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
|
||||
apidatas = siArchivesBiz.listPage(param, (long) user.getUID());
|
||||
|
||||
log.info("各操作计时 {}", sw.prettyPrint());
|
||||
return apidatas;
|
||||
}
|
||||
|
||||
|
|
@ -169,16 +183,17 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService
|
|||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
private void handleStayDelData(long currentEmployeeId) {
|
||||
|
||||
log.info("福利档案中待减员数据自动处理逻辑开始:");
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
|
||||
String today = simpleDateFormat.format(new Date());
|
||||
//part1,员工维护了社保/公积金/其他福利最后缴纳日,且任一类信息大于今天的,自动将待减员状态置为正在缴纳状态
|
||||
List<InsuranceArchivesBaseInfoPO> rePayList = getInsuranceBaseInfoMapper().getRePayList(today);
|
||||
updateInsuranceBaseInfoRunStatus(rePayList, EmployeeStatusEnum.PAYING.getValue());
|
||||
log.info("自动将待减员状态置为正在缴纳状态的档案数量 {}:", rePayList.size());
|
||||
//part2,员工维护了社保/公积金/其他福利最后缴纳日,且三类信息都小于今天的,自动置为待减员状态
|
||||
List<InsuranceArchivesBaseInfoPO> reStayDelList = getInsuranceBaseInfoMapper().getReStayDelList(today);
|
||||
updateInsuranceBaseInfoRunStatus(reStayDelList, EmployeeStatusEnum.STAY_DEL.getValue());
|
||||
|
||||
log.info("自动置为待减员状态的档案数量 {}:", reStayDelList.size());
|
||||
//part3,非在职员工且处于正常缴纳的福利档案置为待减员状态
|
||||
//定义非在职的人事状态
|
||||
List<String> personnelStatuses = new ArrayList<String>() {{
|
||||
|
|
@ -195,7 +210,7 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService
|
|||
|
||||
List<InsuranceArchivesBaseInfoPO> noNormalList = getInsuranceBaseInfoMapper().getAbnormalList(insuranceArchivesListParam);
|
||||
updateInsuranceBaseInfoRunStatus(noNormalList, EmployeeStatusEnum.STAY_DEL.getValue());
|
||||
|
||||
log.info("自动处理非在职员工的档案数量 {}:", noNormalList.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -205,28 +220,35 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService
|
|||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
private void handleChangeData(long currentEmployeeId) {
|
||||
|
||||
log.info("福利档案中增量数据处理逻辑开始:");
|
||||
// 所有增量人员列表
|
||||
List<TaxAgentEmpChangePO> taxAgentEmpChangeList = getTaxAgentEmpChangeService(user).listAllByModule(TaxAgentEmpChangeModuleEnum.INSURANCE_ARCHIVE);
|
||||
log.info("待处理的福利档案增量数据数量 {}:", taxAgentEmpChangeList.size());
|
||||
if (CollectionUtils.isEmpty(taxAgentEmpChangeList)) {
|
||||
return;
|
||||
}
|
||||
// 当前可以管辖的人员
|
||||
Collection<TaxAgentPO> taxAgentList = getTaxAgentService(user).listAllTaxAgents(currentEmployeeId);
|
||||
log.info("当前可以管辖的个税扣缴义务人数量 {}:", taxAgentList.size());
|
||||
taxAgentEmpChangeList = taxAgentEmpChangeList.stream().filter(f -> taxAgentList.stream().anyMatch(e -> e.getId().equals(f.getTaxAgentId()))).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(taxAgentEmpChangeList)) {
|
||||
return;
|
||||
}
|
||||
log.info("根据当前可以管辖的个税扣缴义务人筛选出的可处理增量数据数量 {}:", taxAgentEmpChangeList.size());
|
||||
// 所有福利档案基础信息数据
|
||||
List<InsuranceArchivesBaseInfoPO> baseInfoPOList = getInsuranceBaseInfoMapper().listAll();
|
||||
|
||||
log.info("当前数据库中所有福利档案基础信息数据数量 {}:", baseInfoPOList.size());
|
||||
StopWatch sw = new StopWatch();
|
||||
sw.start("将增量数据进一步处理为新增、更新两类数据");
|
||||
InsuranceArchivesBaseInfoBO.ChangeData changeData = InsuranceArchivesBaseInfoBO.buildChangeData(taxAgentEmpChangeList, baseInfoPOList, currentEmployeeId);
|
||||
sw.stop();
|
||||
// 批量修改福利档案
|
||||
if (CollectionUtils.isNotEmpty(changeData.getBaseInfoUpdateTodoList())) {
|
||||
log.info("增量数据中待更新的数据数量 {}:", changeData.getBaseInfoUpdateTodoList().size());
|
||||
//对于即将调整为“待减员”的数据,更新社保、公积金、其他福利档案的停止缴纳时间
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
|
||||
String today = simpleDateFormat.format(new Date());
|
||||
|
||||
sw.start("生成增量数据中即将置为“待减员”的数据");
|
||||
List<InsuranceArchivesBaseInfoPO> toStayDelList = changeData.getBaseInfoUpdateTodoList().stream()
|
||||
.filter(f -> f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue()))
|
||||
.collect(Collectors.toList());
|
||||
|
|
@ -243,6 +265,9 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService
|
|||
});
|
||||
|
||||
}
|
||||
sw.stop();
|
||||
|
||||
sw.start("生成增量数据中即将置为“逻辑删除”的数据");
|
||||
//对于逻辑删除的数据,同样逻辑删除相关的社保、公积金、其他福利档案
|
||||
List<InsuranceArchivesBaseInfoPO> delList = changeData.getBaseInfoUpdateTodoList().stream()
|
||||
.filter(f -> f.getDeleteType().equals(DeleteTypeEnum.DELETED.getValue()))
|
||||
|
|
@ -263,23 +288,30 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService
|
|||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
sw.stop();
|
||||
//修改福利档案基础信息
|
||||
sw.start("增量数据中待更新数据入库");
|
||||
List<List<InsuranceArchivesBaseInfoPO>> partitionUpdateBase = Lists.partition(changeData.getBaseInfoUpdateTodoList(), 100);
|
||||
partitionUpdateBase.forEach(part-> getInsuranceBaseInfoMapper().batchUpdate(part));
|
||||
|
||||
sw.stop();
|
||||
log.info("增量数据中待更新的数据处理完成!");
|
||||
}
|
||||
|
||||
sw.start("处理增量数据中待新增的数据");
|
||||
// 批量新增福利档案
|
||||
if (CollectionUtils.isNotEmpty(changeData.getBaseInfoAddTodoList())) {
|
||||
log.info("增量数据中待新增的数据数量 {}:", changeData.getBaseInfoAddTodoList().size());
|
||||
//新增社保、公积金、其他福利档案、福利档案基础信息
|
||||
addNewInsuranceBaseInfo(changeData.getBaseInfoAddTodoList(), currentEmployeeId);
|
||||
log.info("增量数据中待新增的数据处理完成!");
|
||||
}
|
||||
sw.stop();
|
||||
|
||||
// 删除增量数据
|
||||
if (CollectionUtils.isNotEmpty(changeData.getChangeIds())) {
|
||||
getTaxAgentEmpChangeService(user).deleleByIds(changeData.getChangeIds());
|
||||
}
|
||||
|
||||
log.info("各操作计时 {}", sw.prettyPrint());
|
||||
}
|
||||
//新增社保、公积金、其他福利档案、福利档案基础信息
|
||||
private List<InsuranceArchivesBaseInfoPO> addNewInsuranceBaseInfo(List<InsuranceArchivesBaseInfoPO> baseInfoPOList, Long currentEmployeeId) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue