薪酬系统-福利档案一对多改造v2

This commit is contained in:
sy 2022-10-26 18:51:36 +08:00
parent 5a408e8bfc
commit 47220181ec
8 changed files with 130 additions and 14 deletions

View File

@ -520,6 +520,55 @@ public class SIArchivesBiz {
}
}
/**
* 根据人员id和个税扣缴人id获取记录
*/
public List<InsuranceArchivesSocialSchemePO> getSocialByEmployeeIdAndPayOrg(List<InsuranceArchivesEmployeePO> insuranceArchivesEmployeePOS) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class);
List<InsuranceArchivesSocialSchemePO> allList = new ArrayList<>();
for (InsuranceArchivesEmployeePO po : insuranceArchivesEmployeePOS) {
List<InsuranceArchivesSocialSchemePO> socialList = socialSchemeMapper.getSocialByEmployeeIdAndPayOrg(po);
allList.addAll(socialList);
}
return allList;
} finally {
sqlSession.close();
}
}
public List<InsuranceArchivesFundSchemePO> getFundByEmployeeIdAndPayOrg(List<InsuranceArchivesEmployeePO> insuranceArchivesEmployeePOS) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class);
List<InsuranceArchivesFundSchemePO> allList = new ArrayList<>();
for (InsuranceArchivesEmployeePO po : insuranceArchivesEmployeePOS) {
List<InsuranceArchivesFundSchemePO> fundList = fundSchemeMapper.getFundByEmployeeIdAndPayOrg(po);
allList.addAll(fundList);
}
return allList;
} finally {
sqlSession.close();
}
}
public List<InsuranceArchivesOtherSchemePO> getOtherByEmployeeIdAndPayOrg(List<InsuranceArchivesEmployeePO> insuranceArchivesEmployeePOS) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class);
List<InsuranceArchivesOtherSchemePO> allList = new ArrayList<>();
for (InsuranceArchivesEmployeePO po : insuranceArchivesEmployeePOS) {
List<InsuranceArchivesOtherSchemePO> otherList = otherSchemeMapper.getOtherByEmployeeIdAndPayOrg(po);
allList.addAll(otherList);
}
return allList;
} finally {
sqlSession.close();
}
}
/**
* 新增
@ -979,20 +1028,20 @@ public class SIArchivesBiz {
OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class);
InsuranceSchemeMapper insuranceSchemeMapper = sqlSession.getMapper(InsuranceSchemeMapper.class);
List<Long> employeeIds = insuranceArchivesEmployeePOS.stream().map(InsuranceArchivesEmployeePO::getEmployeeId).collect(Collectors.toList());
Map<Long, InsuranceArchivesSocialSchemePO> socialSchemePOMap = InsuranceArchivesSocialSchemePOEncrypt.decryptList(this.getSocialByEmployeeIds(employeeIds))
.stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getEmployeeId, Function.identity()));
// List<Long> employeeIds = insuranceArchivesEmployeePOS.stream().map(InsuranceArchivesEmployeePO::getEmployeeId).collect(Collectors.toList());
Map<Long, InsuranceArchivesSocialSchemePO> socialSchemePOMap = InsuranceArchivesSocialSchemePOEncrypt.decryptList(this.getSocialByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS))
.stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getId, Function.identity()));
Map<Long, InsuranceArchivesFundSchemePO> fundSchemePOMap = InsuranceArchivesFundSchemePOEncrypt.decryptList(this.getFundByEmployeeIds(employeeIds))
.stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getEmployeeId, Function.identity()));
List<InsuranceArchivesOtherSchemePO> otherByEmployeeList = this.getOtherByEmployeeIds(employeeIds);
Map<Long, InsuranceArchivesFundSchemePO> fundSchemePOMap = InsuranceArchivesFundSchemePOEncrypt.decryptList(this.getFundByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS))
.stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getId, Function.identity()));
List<InsuranceArchivesOtherSchemePO> otherByEmployeeList = this.getOtherByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS);
InsuranceArchivesOtherSchemePOEncrypt.decryptList(otherByEmployeeList);
Map<Long, InsuranceArchivesOtherSchemePO> otherSchemePOMap = otherByEmployeeList
.stream().collect(Collectors.toMap(InsuranceArchivesOtherSchemePO::getEmployeeId, Function.identity()));
.stream().collect(Collectors.toMap(InsuranceArchivesOtherSchemePO::getId, Function.identity()));
insuranceArchivesEmployeePOS.forEach(item -> {
InsuranceArchivesSocialSchemePO socialItem = socialSchemePOMap.get(item.getEmployeeId());
InsuranceArchivesFundSchemePO fundItem = fundSchemePOMap.get(item.getEmployeeId());
InsuranceArchivesOtherSchemePO otherItem = otherSchemePOMap.get(item.getEmployeeId());
InsuranceArchivesSocialSchemePO socialItem = socialSchemePOMap.get(item.getSocialId());
InsuranceArchivesFundSchemePO fundItem = fundSchemePOMap.get(item.getFundId());
InsuranceArchivesOtherSchemePO otherItem = otherSchemePOMap.get(item.getOtherId());
Map<String, Object> map = new HashMap<>();
map.put("employeeName", item.getUserName());
map.put("paymentOrganizationName", longTaxAgentPOMap.get(item.getPaymentOrganization()) != null ? longTaxAgentPOMap.get(item.getPaymentOrganization()).getName() : "");

View File

@ -53,4 +53,12 @@ public class InsuranceArchivesEmployeePO {
private Long otherSchemeId;
private Long baseInfoId;
/**
* 社保公积金其他福利档案id
*/
private Long socialId;
private Long fundId;
private Long otherId;
}

View File

@ -1,5 +1,6 @@
package com.engine.salary.mapper.siarchives;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO;
import org.apache.ibatis.annotations.Param;
@ -22,6 +23,14 @@ public interface FundSchemeMapper {
*/
List<InsuranceArchivesFundSchemePO> getFundByEmployeeId(@Param("employeeIds")List<Long> employeeId);
/**
* 根据人员id和个税扣缴人id获取记录
* @param insuranceArchivesEmployeePO
* @return
*/
List<InsuranceArchivesFundSchemePO> getFundByEmployeeIdAndPayOrg(@Param("param") InsuranceArchivesEmployeePO insuranceArchivesEmployeePO);
/**
* 根据id获取
* @param ids

View File

@ -58,6 +58,16 @@
</select>
<!-- 根据人员id和个税扣缴人id获取记录 -->
<select id="getFundByEmployeeIdAndPayOrg" resultMap="BaseResultMap" >
SELECT
<include refid="baseColumns"/>
FROM hrsa_fund_archives t
WHERE delete_type = 0
AND employee_id = #{param.employeeId}
AND payment_organization = #{param.paymentOrganization}
</select>
<!-- 根据id获取记录 -->
<select id="getFundById" resultMap="BaseResultMap" >
SELECT

View File

@ -1,7 +1,9 @@
package com.engine.salary.mapper.siarchives;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO;
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 org.apache.ibatis.annotations.Param;
import java.util.Collection;
@ -22,6 +24,13 @@ public interface OtherSchemeMapper {
*/
List<InsuranceArchivesOtherSchemePO> getOtherByEmployeeId(@Param("employeeIds")List<Long> employeeId);
/**
* 根据人员id和个税扣缴人id获取记录
* @param insuranceArchivesEmployeePO
* @return
*/
List<InsuranceArchivesOtherSchemePO> getOtherByEmployeeIdAndPayOrg(@Param("param") InsuranceArchivesEmployeePO insuranceArchivesEmployeePO);
/**
* 根据id获取
* @param ids

View File

@ -54,6 +54,16 @@
</select>
<!-- 根据人员id和个税扣缴人id获取记录 -->
<select id="getOtherByEmployeeIdAndPayOrg" resultMap="BaseResultMap" >
SELECT
<include refid="baseColumns"/>
FROM hrsa_other_archives t
WHERE delete_type = 0
AND employee_id = #{param.employeeId}
AND payment_organization = #{param.paymentOrganization}
</select>
<!-- 根据id获取记录 -->
<select id="getOtherById" resultMap="BaseResultMap" >
SELECT

View File

@ -24,6 +24,13 @@ public interface SocialSchemeMapper {
*/
List<InsuranceArchivesSocialSchemePO> getSocialByEmployeeId(@Param("employeeIds")List<Long> employeeId);
/**
* 根据人员id和个税扣缴人id获取记录
* @param insuranceArchivesEmployeePO
* @return
*/
List<InsuranceArchivesSocialSchemePO> getSocialByEmployeeIdAndPayOrg(@Param("param")InsuranceArchivesEmployeePO insuranceArchivesEmployeePO);
/**
* 根据id获取
* @param ids

View File

@ -55,6 +55,16 @@
</if>
</select>
<!-- 根据人员id和个税扣缴人id获取记录 -->
<select id="getSocialByEmployeeIdAndPayOrg" resultMap="BaseResultMap" >
SELECT
<include refid="baseColumns"/>
FROM hrsa_social_archives t
WHERE delete_type = 0
AND employee_id = #{param.employeeId}
AND payment_organization = #{param.paymentOrganization}
</select>
<!-- 根据id获取记录 -->
<select id="getSocialById" resultMap="BaseResultMap" >
SELECT
@ -321,14 +331,18 @@
social.siSchemeId,
base.payment_organization AS paymentOrganization,
fund.fundSchemeId,
other.otherSchemeId
other.otherSchemeId,
social.id AS socialId,
fund.id AS fundId,
other.id AS otherId
FROM hrsa_insurance_base_info base
LEFT JOIN hrmresource e ON base.employee_id = e.id
LEFT JOIN hrmdepartment d ON e.departmentid = d.ID
LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
LEFT JOIN( SELECT social.employee_id, social.social_scheme_id AS siSchemeId, social.payment_organization AS paymentOrganization FROM hrsa_social_archives social WHERE social.delete_type = 0 )social ON e.id = social.employee_id
LEFT JOIN( SELECT fund.employee_id, fund.fund_scheme_id AS fundSchemeId FROM hrsa_fund_archives fund WHERE fund.delete_type = 0 )fund ON e.id = fund.employee_id
LEFT JOIN( SELECT other.employee_id, other.other_scheme_id AS otherSchemeId FROM hrsa_other_archives other WHERE other.delete_type = 0 )other ON e.id = other.employee_id
LEFT JOIN( SELECT social.id, social.employee_id, social.social_scheme_id AS siSchemeId, social.payment_organization FROM hrsa_social_archives social WHERE social.delete_type = 0 )social ON e.id = social.employee_id AND base.payment_organization = social.payment_organization
LEFT JOIN( SELECT fund.id, fund.employee_id, fund.fund_scheme_id AS fundSchemeId, fund.payment_organization FROM hrsa_fund_archives fund WHERE fund.delete_type = 0 )fund ON e.id = fund.employee_id AND base.payment_organization = fund.payment_organization
LEFT JOIN( SELECT other.id, other.employee_id, other.other_scheme_id AS otherSchemeId, other.payment_organization FROM hrsa_other_archives other WHERE other.delete_type = 0 )other ON e.id = other.employee_id AND base.payment_organization = other.payment_organization
WHERE
1=1
AND base.delete_type = 0