同步社保、薪资档案起始发薪日为入职日定时任务
This commit is contained in:
parent
f23b23cd92
commit
0c42e1cb35
|
|
@ -133,4 +133,6 @@ public interface SalaryArchiveMapper {
|
|||
void deleteByIds(@Param("ids")Collection<Long> deleteIds);
|
||||
|
||||
List<SalaryArchivePO> listPayEndDateIsNull(@Param("ids")List<Long> employeeIds);
|
||||
|
||||
List<SalaryArchivePO> listPayStartDateIsNull(@Param("runStatus")String runStatus);
|
||||
}
|
||||
|
|
@ -722,6 +722,15 @@
|
|||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="listPayStartDateIsNull" resultType="com.engine.salary.entity.salaryarchive.po.SalaryArchivePO">
|
||||
SELECT
|
||||
<include refid="baseColumns"/>
|
||||
FROM hrsa_salary_archive t
|
||||
WHERE t.delete_type=0
|
||||
AND pay_start_date is null
|
||||
AND run_status = #{runStatus}
|
||||
</select>
|
||||
|
||||
<update id="updateStatus" parameterType="com.engine.salary.entity.salaryarchive.po.SalaryArchivePO">
|
||||
UPDATE hrsa_salary_archive
|
||||
<set>
|
||||
|
|
|
|||
|
|
@ -127,4 +127,11 @@ public interface InsuranceBaseInfoMapper {
|
|||
* @return
|
||||
*/
|
||||
List<InsuranceArchivesBaseInfoPO> listEndDateIsNull(@Param("employeeIds") List<Long> employeeIds);
|
||||
|
||||
/**
|
||||
* 获取没有设置社保、公积金最后缴纳月的档案
|
||||
* @param employeeIds
|
||||
* @return
|
||||
*/
|
||||
List<InsuranceArchivesBaseInfoPO> listStartDateIsNull(@Param("employeeIds") List<Long> employeeIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -301,6 +301,38 @@
|
|||
</foreach>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="listStartDateIsNull"
|
||||
resultType="com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO">
|
||||
select
|
||||
a.id
|
||||
, a.employee_id
|
||||
, a.payment_organization
|
||||
, a.social_archives_id
|
||||
, a.fund_archives_id
|
||||
, a.other_archives_id
|
||||
, a.run_status
|
||||
, a.create_time
|
||||
, a.update_time
|
||||
, a.creator
|
||||
, a.delete_type
|
||||
, a.tenant_key
|
||||
, a.employee_type
|
||||
from hrsa_insurance_base_info a
|
||||
left join hrsa_social_archives s on a.social_archives_id=s.id and s.delete_type=0
|
||||
left join hrsa_fund_archives f on a.fund_archives_id=f.id and f.delete_type=0
|
||||
left join hrsa_other_archives o on a.other_archives_id=o.id and o.delete_type=0
|
||||
where a.delete_type = 0
|
||||
and (social_start_time is null or social_start_time ='' or fund_start_time is null or fund_start_time =''
|
||||
or other_start_time is null or other_start_time ='' )
|
||||
<if test="employeeIds != null and employeeIds.size()>0">
|
||||
and a.employee_id in
|
||||
<foreach collection="employeeIds" open="(" item="employeeId" separator="," close=")">
|
||||
#{employeeId}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<update id="updateRunStatusByIds" parameterType="com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO">
|
||||
UPDATE hrsa_insurance_base_info
|
||||
<set>
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ import com.engine.salary.entity.siarchives.param.InsuranceArchivesSaveParam;
|
|||
import com.engine.salary.entity.siarchives.param.SIArchiveBaseHistoryListParam;
|
||||
import com.engine.salary.entity.siarchives.po.*;
|
||||
import com.engine.salary.util.page.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
|
|
@ -152,4 +152,12 @@ public interface SIArchivesService {
|
|||
void batchInsertAdjustHistory(List<InsuranceArchivesBaseHistoryPO> adjustHistoryList);
|
||||
|
||||
List<InsuranceArchivesBaseInfoPO> listEndDateIsNull(List<Long> employeeIds);
|
||||
|
||||
List<InsuranceArchivesBaseInfoPO> listStartDateIsNull(List<Long> employeeIds);
|
||||
|
||||
List<InsuranceArchivesSocialSchemePO> listInsuranceArchivesSocialSchemeByIds(List<Long> ids);
|
||||
|
||||
List<InsuranceArchivesFundSchemePO> listInsuranceArchivesFundSchemeByIds(List<Long> ids);
|
||||
|
||||
List<InsuranceArchivesOtherSchemePO> listInsuranceArchivesOtherSchemeByIds(List<Long> ids);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -250,4 +250,10 @@ public interface SalaryArchiveService {
|
|||
*/
|
||||
String syncPayStartDate();
|
||||
|
||||
/**
|
||||
* 根据列表状态获取起始发薪日期为空的薪资档案
|
||||
* @param runStatus
|
||||
* @return
|
||||
*/
|
||||
List<SalaryArchivePO> listPayStartDateIsNull(String runStatus);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3954,5 +3954,48 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService
|
|||
}
|
||||
return getInsuranceBaseInfoMapper().listEndDateIsNull(employeeIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取没有设置社保、公积金最后缴纳月的档案
|
||||
* @param employeeIds
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<InsuranceArchivesBaseInfoPO> listStartDateIsNull(List<Long> employeeIds) {
|
||||
return getInsuranceBaseInfoMapper().listStartDateIsNull(employeeIds);
|
||||
}
|
||||
/*****以上代码为SIArchivesBiz中方法逻辑迁移,旨在减少Biz类的使用*****/
|
||||
|
||||
@Override
|
||||
public List<InsuranceArchivesSocialSchemePO> listInsuranceArchivesSocialSchemeByIds(List<Long> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<List<Long>> partition = Lists.partition(ids, 1000);
|
||||
ArrayList<InsuranceArchivesSocialSchemePO> resultList = new ArrayList<>();
|
||||
partition.forEach(list -> resultList.addAll(getSocialSchemeMapper().getSocialById(list)));
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InsuranceArchivesFundSchemePO> listInsuranceArchivesFundSchemeByIds(List<Long> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<List<Long>> partition = Lists.partition(ids, 1000);
|
||||
ArrayList<InsuranceArchivesFundSchemePO> resultList = new ArrayList<>();
|
||||
partition.forEach(list -> resultList.addAll(getFundSchemeMapper().getFundById(list)));
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InsuranceArchivesOtherSchemePO> listInsuranceArchivesOtherSchemeByIds(List<Long> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<List<Long>> partition = Lists.partition(ids, 1000);
|
||||
ArrayList<InsuranceArchivesOtherSchemePO> resultList = new ArrayList<>();
|
||||
partition.forEach(list -> resultList.addAll(getOtherSchemeMapper().getOtherById(list)));
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,12 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
|
|||
salaryArchiveMapper.batchUpdate(archives);
|
||||
return "执行完毕";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SalaryArchivePO> listPayStartDateIsNull(String runStatus) {
|
||||
if (StringUtils.isBlank(runStatus)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return getSalaryArchiveMapper().listPayStartDateIsNull(runStatus);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,159 @@
|
|||
package com.engine.salary.timer;
|
||||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.salary.biz.SalaryArchiveBiz;
|
||||
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
||||
import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO;
|
||||
import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO;
|
||||
import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO;
|
||||
import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO;
|
||||
import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO;
|
||||
import com.engine.salary.enums.salaryarchive.SalaryArchiveListTypeEnum;
|
||||
import com.engine.salary.enums.siaccount.EmployeeStatusEnum;
|
||||
import com.engine.salary.mapper.siarchives.FundSchemeMapper;
|
||||
import com.engine.salary.mapper.siarchives.OtherSchemeMapper;
|
||||
import com.engine.salary.mapper.siarchives.SocialSchemeMapper;
|
||||
import com.engine.salary.service.SIArchivesService;
|
||||
import com.engine.salary.service.SalaryArchiveService;
|
||||
import com.engine.salary.service.SalaryEmployeeService;
|
||||
import com.engine.salary.service.impl.SIArchivesServiceImpl;
|
||||
import com.engine.salary.service.impl.SalaryArchiveServiceImpl;
|
||||
import com.engine.salary.service.impl.SalaryEmployeeServiceImpl;
|
||||
import com.engine.salary.util.SalaryDateUtil;
|
||||
import com.engine.salary.util.SalaryEntityUtil;
|
||||
import com.engine.salary.util.db.MapperProxyFactory;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.hrm.User;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Harryxzy
|
||||
* @ClassName AutoSyncInsuranceArchiveJob
|
||||
* @date 2023/08/14 9:30
|
||||
* @description 自动同步人员社保福利档案、薪资档案为公司开始日期字段(companystartdate)
|
||||
*/
|
||||
public class AutoSyncEmpArchiveStartDateJob extends BaseCronJob {
|
||||
|
||||
private SalaryArchiveService getSalaryArchiveService(User user) {
|
||||
return ServiceUtil.getService(SalaryArchiveServiceImpl.class,user);
|
||||
}
|
||||
|
||||
private SalaryEmployeeService getSalaryEmployeeService(User user) {
|
||||
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class,user);
|
||||
}
|
||||
|
||||
|
||||
private SIArchivesService getSIArchivesService(User user) {
|
||||
return ServiceUtil.getService(SIArchivesServiceImpl.class,user);
|
||||
}
|
||||
|
||||
private String syncInsuranceArchive;
|
||||
|
||||
private String syncSalaryArchive;
|
||||
|
||||
private SalaryArchiveBiz getSalaryArchiveMapper = new SalaryArchiveBiz();
|
||||
|
||||
private SocialSchemeMapper getSocialSchemeMapper() {
|
||||
return MapperProxyFactory.getProxy(SocialSchemeMapper.class);
|
||||
}
|
||||
|
||||
private FundSchemeMapper getFundSchemeMapper() {
|
||||
return MapperProxyFactory.getProxy(FundSchemeMapper.class);
|
||||
}
|
||||
|
||||
private OtherSchemeMapper getOtherSchemeMapper() {
|
||||
return MapperProxyFactory.getProxy(OtherSchemeMapper.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
User user = new User();
|
||||
user.setUid(1);
|
||||
user.setLoginid("sysadmin");
|
||||
|
||||
if (StringUtils.isBlank(syncInsuranceArchive) || !StringUtils.equals(syncInsuranceArchive,"false")) {
|
||||
// 同步社保福利档案
|
||||
// 获取社保、公积金、其他福利中起始缴纳月任意一个为空的社保档案主表po
|
||||
List<InsuranceArchivesBaseInfoPO> needSyncInsuranceBaseInfoList = getSIArchivesService(user).listStartDateIsNull(Collections.emptyList());
|
||||
// 过滤出档案状态为待增员的
|
||||
needSyncInsuranceBaseInfoList = needSyncInsuranceBaseInfoList.stream().filter(po -> po.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue())).collect(Collectors.toList());
|
||||
// 获取同步人员的公司开始日期
|
||||
List<DataCollectionEmployee> employeeList = getSalaryEmployeeService(user).listByIds(SalaryEntityUtil.properties(needSyncInsuranceBaseInfoList, InsuranceArchivesBaseInfoPO::getEmployeeId, Collectors.toList()));
|
||||
Map<Long, String> empInfoMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId, emp -> {
|
||||
if (StringUtils.isBlank(emp.getCompanystartdate()) || !SalaryDateUtil.checkDay(emp.getCompanystartdate())) {
|
||||
return "";
|
||||
} else {
|
||||
return StringUtils.substring(emp.getCompanystartdate(), 0, 7);
|
||||
}
|
||||
});
|
||||
// 设置社保起始缴纳月信息
|
||||
List<Long> needSyncSocialArchiveIds = SalaryEntityUtil.properties(needSyncInsuranceBaseInfoList, InsuranceArchivesBaseInfoPO::getSocialArchivesId, Collectors.toList());
|
||||
List<InsuranceArchivesSocialSchemePO> insuranceArchivesSocialSchemePOS = getSIArchivesService(user).listInsuranceArchivesSocialSchemeByIds(needSyncSocialArchiveIds);
|
||||
insuranceArchivesSocialSchemePOS.stream().forEach(po -> {
|
||||
if (StringUtils.isBlank(po.getSocialStartTime()) && StringUtils.isNotBlank(empInfoMap.get(po.getEmployeeId()))) {
|
||||
po.setSocialStartTime(empInfoMap.get(po.getEmployeeId()));
|
||||
getSocialSchemeMapper().updateById(po);
|
||||
}
|
||||
});
|
||||
|
||||
// 设置公积金起始缴纳月信息
|
||||
List<Long> needSyncFundArchiveIds = SalaryEntityUtil.properties(needSyncInsuranceBaseInfoList, InsuranceArchivesBaseInfoPO::getFundArchivesId, Collectors.toList());
|
||||
List<InsuranceArchivesFundSchemePO> insuranceArchivesFundSchemePOS = getSIArchivesService(user).listInsuranceArchivesFundSchemeByIds(needSyncFundArchiveIds);
|
||||
insuranceArchivesFundSchemePOS.stream().forEach(po -> {
|
||||
if (StringUtils.isBlank(po.getFundStartTime()) && StringUtils.isNotBlank(empInfoMap.get(po.getEmployeeId()))) {
|
||||
po.setFundStartTime(empInfoMap.get(po.getEmployeeId()));
|
||||
getFundSchemeMapper().updateById(po);
|
||||
}
|
||||
});
|
||||
|
||||
// 设置其他福利起始缴纳月信息
|
||||
List<Long> needSyncOtherArchiveIds = SalaryEntityUtil.properties(needSyncInsuranceBaseInfoList, InsuranceArchivesBaseInfoPO::getOtherArchivesId, Collectors.toList());
|
||||
List<InsuranceArchivesOtherSchemePO> insuranceArchivesOtherSchemePOS = getSIArchivesService(user).listInsuranceArchivesOtherSchemeByIds(needSyncOtherArchiveIds);
|
||||
insuranceArchivesOtherSchemePOS.stream().forEach(po -> {
|
||||
if (StringUtils.isBlank(po.getOtherStartTime()) && StringUtils.isNotBlank(empInfoMap.get(po.getEmployeeId()))) {
|
||||
po.setOtherStartTime(empInfoMap.get(po.getEmployeeId()));
|
||||
getOtherSchemeMapper().updateById(po);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(syncSalaryArchive) || !StringUtils.equals(syncSalaryArchive,"false")) {
|
||||
// 同步薪资档案
|
||||
// 获取薪资档案起始发薪日为空且是待定薪资的档案
|
||||
List<SalaryArchivePO> salaryArchiveList = getSalaryArchiveService(user).listPayStartDateIsNull(SalaryArchiveListTypeEnum.PENDING.getValue());
|
||||
List<Long> empIds = SalaryEntityUtil.properties(salaryArchiveList, SalaryArchivePO::getEmployeeId, Collectors.toList());
|
||||
List<DataCollectionEmployee> employeeList = getSalaryEmployeeService(user).listByIds(empIds);
|
||||
Map<Long, Date> empMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId, emp -> {
|
||||
if (StringUtils.isBlank(emp.getCompanystartdate()) || !SalaryDateUtil.checkDay(emp.getCompanystartdate())) {
|
||||
return null;
|
||||
} else {
|
||||
return SalaryDateUtil.stringToDate(StringUtils.substring(emp.getCompanystartdate(), 0, 10));
|
||||
}
|
||||
});
|
||||
List<SalaryArchivePO> needUpdateArchiveList = salaryArchiveList.stream().filter(archive -> {
|
||||
if (archive.getPayStartDate() == null) {
|
||||
Date startDate = empMap.get(archive.getEmployeeId());
|
||||
if (startDate != null) {
|
||||
archive.setPayStartDate(startDate);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
getSalaryArchiveMapper.batchUpdate(needUpdateArchiveList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue