diff --git a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesEmployeePO.java b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesEmployeePO.java index 2fb5297ce..5131f1377 100644 --- a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesEmployeePO.java +++ b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesEmployeePO.java @@ -48,7 +48,15 @@ public class InsuranceArchivesEmployeePO { private String subcompanyName; - private BigDecimal position; + /** + * 岗位 + */ + private Long position; + + /** + * 职务(岗位类别) + */ + private Long jobactivityid; private Integer userStatus; @@ -66,6 +74,15 @@ public class InsuranceArchivesEmployeePO { */ private String dimissionDate; + /** + * 司龄 + */ + private BigDecimal companyworkyear; + + /** + * 职务(岗位类别) + */ + private Long siSchemeId; private Long fundSchemeId; diff --git a/src/com/engine/salary/entity/siarchives/po/UfHrSbjsgzbPO.java b/src/com/engine/salary/entity/siarchives/po/UfHrSbjsgzbPO.java new file mode 100644 index 000000000..9402aa03e --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/po/UfHrSbjsgzbPO.java @@ -0,0 +1,38 @@ +package com.engine.salary.entity.siarchives.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.Collection; + +/** + * @author Harryxzy + * @ClassName UfHrSbjsgzbPO + * @date 2024/12/20 10:01 + * @description 社保基数规则表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UfHrSbjsgzbPO { + private BigDecimal gjjjs; + private Integer glsx; + private Integer glxx; + private BigDecimal gongshangjs; + private String gw; + private String gwfl; + private Integer gzbs; + private Integer id; + private BigDecimal shengyujs; + private BigDecimal shiyejs; + private BigDecimal yanglaojs; + private BigDecimal yiliaojs; + + //主键id集合 + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/siarchives/SocialSchemeMapper.xml b/src/com/engine/salary/mapper/siarchives/SocialSchemeMapper.xml index 18823cca7..e3da47b10 100644 --- a/src/com/engine/salary/mapper/siarchives/SocialSchemeMapper.xml +++ b/src/com/engine/salary/mapper/siarchives/SocialSchemeMapper.xml @@ -365,12 +365,15 @@ other.id AS otherId, e.companystartdate as companystartdate, e.enddate as dismissdate, - c.subcompanyname as subcompanyName + c.subcompanyname as subcompanyName, + t.JOBACTIVITYID as jobactivityid, + e.companyworkyear as companyworkyear 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 hrmjobtitles t ON t.id = e.JOBTITLE 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 diff --git a/src/com/engine/salary/mapper/siarchives/UfHrSbjsgzbMapper.java b/src/com/engine/salary/mapper/siarchives/UfHrSbjsgzbMapper.java new file mode 100644 index 000000000..9bdb7b5d2 --- /dev/null +++ b/src/com/engine/salary/mapper/siarchives/UfHrSbjsgzbMapper.java @@ -0,0 +1,62 @@ +package com.engine.salary.mapper.siarchives; + +import com.engine.salary.entity.siarchives.po.UfHrSbjsgzbPO; + +import java.util.List; + +/** + * @author Harryxzy + * @ClassName UfHrSbjsgzbMapper + * @date 2024/12/20 10:17 + * @description + */ +public interface UfHrSbjsgzbMapper { + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(UfHrSbjsgzbPO ufHrSbjsgzb); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + UfHrSbjsgzbPO getById(Integer id); + + /** + * 新增,忽略null字段 + * + * @param ufHrSbjsgzb 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(UfHrSbjsgzbPO ufHrSbjsgzb); + + /** + * 修改,修改所有字段 + * + * @param ufHrSbjsgzb 修改的记录 + * @return 返回影响行数 + */ + int update(UfHrSbjsgzbPO ufHrSbjsgzb); + + /** + * 修改,忽略null字段 + * + * @param ufHrSbjsgzb 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(UfHrSbjsgzbPO ufHrSbjsgzb); + + +} diff --git a/src/com/engine/salary/mapper/siarchives/UfHrSbjsgzbMapper.xml b/src/com/engine/salary/mapper/siarchives/UfHrSbjsgzbMapper.xml new file mode 100644 index 000000000..7c7f7f52a --- /dev/null +++ b/src/com/engine/salary/mapper/siarchives/UfHrSbjsgzbMapper.xml @@ -0,0 +1,238 @@ + + + + + + + + + + + + + + + + + + + + + + t.gjjjs + , t.glsx + , t.glxx + , t.gongshangjs + , t.gw + , t.gwfl + , t.gzbs + , t.id + , t.shengyujs + , t.shiyejs + , t.yanglaojs + , t.yiliaojs + + + + + + + + + + + + + + + INSERT INTO uf_hr_sbjsgzb + + + gjjjs, + + + glsx, + + + glxx, + + + gongshangjs, + + + gw, + + + gwfl, + + + gzbs, + + + shengyujs, + + + shiyejs, + + + yanglaojs, + + + yiliaojs, + + + + + #{gjjjs}, + + + #{glsx}, + + + #{glxx}, + + + #{gongshangjs}, + + + #{gw}, + + + #{gwfl}, + + + #{gzbs}, + + + #{shengyujs}, + + + #{shiyejs}, + + + #{yanglaojs}, + + + #{yiliaojs}, + + + + + + + UPDATE uf_hr_sbjsgzb + + gjjjs=#{gjjjs}, + glsx=#{glsx}, + glxx=#{glxx}, + gongshangjs=#{gongshangjs}, + gw=#{gw}, + gwfl=#{gwfl}, + gzbs=#{gzbs}, + shengyujs=#{shengyujs}, + shiyejs=#{shiyejs}, + yanglaojs=#{yanglaojs}, + yiliaojs=#{yiliaojs}, + + WHERE id = #{id} + + + + + + UPDATE uf_hr_sbjsgzb + + + gjjjs=#{gjjjs}, + + + glsx=#{glsx}, + + + glxx=#{glxx}, + + + gongshangjs=#{gongshangjs}, + + + gw=#{gw}, + + + gwfl=#{gwfl}, + + + gzbs=#{gzbs}, + + + shengyujs=#{shengyujs}, + + + shiyejs=#{shiyejs}, + + + yanglaojs=#{yanglaojs}, + + + yiliaojs=#{yiliaojs}, + + + WHERE id = #{id} + + + + \ No newline at end of file diff --git a/src/com/engine/salary/service/SIArchivesService.java b/src/com/engine/salary/service/SIArchivesService.java index dd13f472a..525eec4cb 100644 --- a/src/com/engine/salary/service/SIArchivesService.java +++ b/src/com/engine/salary/service/SIArchivesService.java @@ -27,6 +27,9 @@ public interface SIArchivesService { Map getPaymentForm(Map params); + + UfHrSbjsgzbPO getGzByEmp(InsuranceArchivesEmployeePO archiveEmp, Map gwGzMap, Map> gwflGzMap, List glGzList); + String insert(InsuranceArchivesSaveParam param); Map listPage(InsuranceArchivesListParam insuranceArchivesListParam); diff --git a/src/com/engine/salary/service/UfHrSbjsgzbService.java b/src/com/engine/salary/service/UfHrSbjsgzbService.java new file mode 100644 index 000000000..6c4878df6 --- /dev/null +++ b/src/com/engine/salary/service/UfHrSbjsgzbService.java @@ -0,0 +1,54 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.siarchives.po.UfHrSbjsgzbPO; + +import java.util.List; + +/** + * @author Harryxzy + * @ClassName UfHrSbjsgzbService + * @date 2024/12/20 10:03 + * @description 社保基数规则 + */ +public interface UfHrSbjsgzbService { + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + UfHrSbjsgzbPO getById(Integer id); + + /** + * 新增,忽略null字段 + * + * @param ufHrSbjsgzb 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(UfHrSbjsgzbPO ufHrSbjsgzb); + + /** + * 修改,修改所有字段 + * + * @param ufHrSbjsgzb 修改的记录 + * @return 返回影响行数 + */ + int update(UfHrSbjsgzbPO ufHrSbjsgzb); + + /** + * 修改,忽略null字段 + * + * @param ufHrSbjsgzb 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(UfHrSbjsgzbPO ufHrSbjsgzb); + +} diff --git a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java index 6d45abc1f..8f9f262db 100644 --- a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java @@ -67,6 +67,7 @@ import com.google.common.collect.Lists; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; import org.apache.ibatis.session.SqlSession; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.beans.BeanUtils; @@ -173,6 +174,9 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService return MapperProxyFactory.getProxy(ICategoryMapper.class); } + private UfHrSbjsgzbService getUfHrSbjsgzbService(User user) { + return ServiceUtil.getService(UfHrSbjsgzbServiceImpl.class, user); + } @Override public Map getTips(Map params) { @@ -204,12 +208,13 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService Long employeeId = Long.valueOf(Util.null2String(params.get("employeeId"))); String schemeIdStr = Util.null2String(params.get("schemeId")); Long paymentOrganization = Long.valueOf(Util.null2String(params.get("paymentOrganization"))); + boolean changeScheme = Util.null2String(params.get("changeScheme")).equals("true"); Long schemeId = null; if (StringUtils.isNotBlank(schemeIdStr)) { schemeId = Long.valueOf(schemeIdStr); } // apidatas = siArchivesBiz.getPaymentForm(user, welfareTypeEnum, employeeId, (long) user.getUID(), schemeId, paymentOrganization); - apidatas = getPaymentForm(user, welfareTypeEnum, employeeId, schemeId, paymentOrganization); + apidatas = getPaymentForm(user, welfareTypeEnum, employeeId, schemeId, paymentOrganization, changeScheme); return apidatas; } @@ -2572,7 +2577,7 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService * @param schemeId * @return */ - public Map getPaymentForm(User user, WelfareTypeEnum welfareType, Long employeeId, Long schemeId, Long paymentOrganization) { + public Map getPaymentForm(User user, WelfareTypeEnum welfareType, Long employeeId, Long schemeId, Long paymentOrganization, boolean changeScheme) { Map data = new HashMap<>(16); //判断是否要区分个人和单位福利基数 SalarySysConfPO welBaseDiff = getSalarySysConfService(user).getOneByCode(WEL_BASE_DIFF_BY_PER_AND_COM); @@ -2581,12 +2586,43 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService SalarySysConfPO welBaseAutoAdjust = getSalarySysConfService(user).getOneByCode(WEL_BASE_AUTO_ADJUST); boolean welBaseAutoAdjustSign = welBaseAutoAdjust != null && welBaseAutoAdjust.getConfValue().equals(OpenEnum.OPEN.getValue()); + // 根据员工获取社保规则 + InsuranceArchivesListParam archivesListParam = InsuranceArchivesListParam.builder().taxAgentId(paymentOrganization).employeeIds(Collections.singletonList(employeeId)).build(); + List archiveEmp = getSocialSchemeMapper().queryEmployeeList(archivesListParam); + // 获取建模基数信息 + List ufHrSbjsgzbList = getUfHrSbjsgzbService(user).listAll(); + // 岗位规则 + Map gwGzMap = new HashMap<>(); + // 岗位分类规则 + Map> gwflGzMap = new HashMap<>(); + // 工龄规则 + List glGzList = new ArrayList<>(); + for (UfHrSbjsgzbPO po : ufHrSbjsgzbList) { + if (StringUtils.isNotBlank(po.getGw())) { + // 岗位不为空 + Arrays.stream(po.getGw().split(",")) + .map(Long::valueOf) + .forEach(gw -> { + gwGzMap.put(Long.valueOf(gw), po); + }); + } else if (NumberUtils.isCreatable(po.getGwfl())) { + // 岗位分类(职务)不为空 + List list = gwflGzMap.computeIfAbsent(Long.valueOf(NumberUtils.isCreatable(po.getGwfl()) ? po.getGwfl() : "0"), k -> new ArrayList<>()); + list.add(po); + gwflGzMap.put(Long.valueOf(po.getGwfl()), list); + } else { + // 剩余根据工龄匹配 + glGzList.add(po); + } + } + UfHrSbjsgzbPO sbjsgzPO = getGzByEmp(CollectionUtils.isEmpty(archiveEmp) ? null : archiveEmp.get(0), gwGzMap, gwflGzMap, glGzList); + switch (welfareType) { case SOCIAL_SECURITY: - data = buildSocialPaymentForm(user, employeeId, schemeId,welfareType.getValue(), paymentOrganization, welBaseDiffSign, welBaseAutoAdjustSign); + data = buildSocialPaymentForm(user, employeeId, schemeId,welfareType.getValue(), paymentOrganization, welBaseDiffSign, welBaseAutoAdjustSign, changeScheme, sbjsgzPO); break; case ACCUMULATION_FUND: - data = buildFundPaymentForm(user, employeeId, schemeId, welfareType.getValue(), paymentOrganization, welBaseDiffSign, welBaseAutoAdjustSign); + data = buildFundPaymentForm(user, employeeId, schemeId, welfareType.getValue(), paymentOrganization, welBaseDiffSign, welBaseAutoAdjustSign, changeScheme, sbjsgzPO); break; case OTHER: data = buildOtherPaymentForm(user, employeeId, schemeId, welfareType.getValue(), paymentOrganization, welBaseDiffSign, welBaseAutoAdjustSign); @@ -2596,6 +2632,43 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService return data; } + /** + * 中航富士达 根据员工确定社保基数规则 + * @param archiveEmp + * @param gwGzMap + * @param gwflGzMap + * @param glGzList + * @return + */ + public UfHrSbjsgzbPO getGzByEmp(InsuranceArchivesEmployeePO archiveEmp, Map gwGzMap, Map> gwflGzMap, List glGzList) { + if (archiveEmp == null) { + return null; + } + if (gwGzMap.keySet().contains(archiveEmp.getPosition())) { + // 1、匹配岗位 + return gwGzMap.get(archiveEmp.getPosition()); + } else if (gwflGzMap.keySet().contains(archiveEmp.getJobactivityid())) { + // 2、匹配职务(岗位分类) + List poList = gwflGzMap.get(archiveEmp.getJobactivityid()); + if (CollectionUtils.isNotEmpty(poList)) { + // 根据司龄过滤 + List collect = poList.stream().filter(po -> { + double companyWorkYear = archiveEmp.getCompanyworkyear().doubleValue(); + return companyWorkYear > po.getGlxx() && companyWorkYear <= po.getGlsx(); + }).collect(Collectors.toList()); + return CollectionUtils.isNotEmpty(collect) ? null : collect.get(0); + } + } else { + // 3、以上都不匹配,根据司龄匹配 + double companyWorkYear = archiveEmp.getCompanyworkyear().doubleValue(); + List collect = glGzList.stream().filter(po -> { + return companyWorkYear > po.getGlxx() && companyWorkYear <= po.getGlsx(); + }).collect(Collectors.toList()); + return CollectionUtils.isEmpty(collect) ? null : collect.get(0); + } + return null; + } + /** * 其他payForm * @@ -2654,7 +2727,10 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService * @param schemeId * @return */ - public Map buildFundPaymentForm(User user, Long employeeId, Long schemeId, Integer welfareType, Long paymentOrganization, boolean welBaseDiffSign, boolean welBaseAutoAdjustSign) { + public Map buildFundPaymentForm(User user, Long employeeId, Long schemeId, Integer welfareType, + Long paymentOrganization, boolean welBaseDiffSign, + boolean welBaseAutoAdjustSign, boolean changeScheme, + UfHrSbjsgzbPO gzPO) { Map dataMap = new HashMap<>(); InsuranceArchivesFundSchemeDTO data = buildFundForm(employeeId, paymentOrganization); @@ -2678,6 +2754,11 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; insuranceValueMap.put(insuranceId, basicValue); } + if (changeScheme) { + if (insuranceId.equals("9006")) { + insuranceValueMap.put("9006",Util.null2String(gzPO.getGjjjs())); + } + } } dataMap.put("data", insuranceValueMap); addGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0, "公积金缴纳基数"), true, inputItems)); @@ -2694,6 +2775,11 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; insuranceComValueMap.put(insuranceId, basicValue); } + if (changeScheme) { + if (insuranceId.equals("9006")) { + insuranceComValueMap.put("9006",Util.null2String(gzPO.getGjjjs())); + } + } } dataMap.put("comData", insuranceComValueMap); } @@ -2707,7 +2793,10 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService * @param schemeId * @return */ - public Map buildSocialPaymentForm(User user, Long employeeId, Long schemeId, Integer welfareType, Long paymentOrganization, boolean welBaseDiffSign, boolean welBaseAutoAdjustSign) { + public Map buildSocialPaymentForm(User user, Long employeeId, Long schemeId, Integer welfareType, + Long paymentOrganization, boolean welBaseDiffSign, + boolean welBaseAutoAdjustSign, boolean changeScheme, + UfHrSbjsgzbPO gzPO) { Map dataMap = new HashMap<>(); InsuranceArchivesSocialSchemeDTO data = buildSocialForm(employeeId, paymentOrganization); Map insuranceValueMap = new HashMap<>(); @@ -2730,6 +2819,19 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; insuranceValueMap.put(insuranceId, basicValue); } + if (changeScheme) { + if (insuranceId.equals("9001")) { + insuranceValueMap.put("9001",Util.null2String(gzPO.getYanglaojs())); + } else if (insuranceId.equals("9002")) { + insuranceValueMap.put("9002",Util.null2String(gzPO.getYiliaojs())); + } else if (insuranceId.equals("9003")) { + insuranceValueMap.put("9003",Util.null2String(gzPO.getGongshangjs())); + } else if (insuranceId.equals("9004")) { + insuranceValueMap.put("9004",Util.null2String(gzPO.getShiyejs())); + } else if (insuranceId.equals("9005")) { + insuranceValueMap.put("9005",Util.null2String(gzPO.getShengyujs())); + } + } } dataMap.put("data", insuranceValueMap); addGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0, "社保缴纳基数"), true, inputItems)); @@ -2746,6 +2848,19 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; insuranceComValueMap.put(insuranceId, basicValue); } + if (changeScheme) { + if (insuranceId.equals("9001")) { + insuranceComValueMap.put("9001",Util.null2String(gzPO.getYanglaojs())); + } else if (insuranceId.equals("9002")) { + insuranceComValueMap.put("9002",Util.null2String(gzPO.getYiliaojs())); + } else if (insuranceId.equals("9003")) { + insuranceComValueMap.put("9003",Util.null2String(gzPO.getGongshangjs())); + } else if (insuranceId.equals("9004")) { + insuranceComValueMap.put("9004",Util.null2String(gzPO.getShiyejs())); + } else if (insuranceId.equals("9005")) { + insuranceComValueMap.put("9005",Util.null2String(gzPO.getShengyujs())); + } + } } dataMap.put("comData", insuranceComValueMap); } diff --git a/src/com/engine/salary/service/impl/UfHrSbjsgzbServiceImpl.java b/src/com/engine/salary/service/impl/UfHrSbjsgzbServiceImpl.java new file mode 100644 index 000000000..a6f986d8c --- /dev/null +++ b/src/com/engine/salary/service/impl/UfHrSbjsgzbServiceImpl.java @@ -0,0 +1,72 @@ +package com.engine.salary.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.entity.siarchives.po.UfHrSbjsgzbPO; +import com.engine.salary.mapper.siarchives.UfHrSbjsgzbMapper; +import com.engine.salary.service.UfHrSbjsgzbService; +import com.engine.salary.util.db.MapperProxyFactory; + +import java.util.List; + +/** + * @author Harryxzy + * @ClassName UfHrSbjsgzbService + * @date 2024/12/20 10:06 + * @description + */ +public class UfHrSbjsgzbServiceImpl extends Service implements UfHrSbjsgzbService { + + private UfHrSbjsgzbMapper getUfHrSbjsgzbMapper(){ + return MapperProxyFactory.getProxy(UfHrSbjsgzbMapper.class); + } + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + public List listAll() { + return getUfHrSbjsgzbMapper().listAll(); + } + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + public UfHrSbjsgzbPO getById(Integer id) { + return getUfHrSbjsgzbMapper().getById(id); + } + + /** + * 新增,忽略null字段 + * + * @param ufHrSbjsgzb 新增的记录 + * @return 返回影响行数 + */ + public int insertIgnoreNull(UfHrSbjsgzbPO ufHrSbjsgzb) { + return getUfHrSbjsgzbMapper().insertIgnoreNull(ufHrSbjsgzb); + } + + /** + * 修改,修改所有字段 + * + * @param ufHrSbjsgzb 修改的记录 + * @return 返回影响行数 + */ + public int update(UfHrSbjsgzbPO ufHrSbjsgzb) { + return getUfHrSbjsgzbMapper().update(ufHrSbjsgzb); + } + + /** + * 修改,忽略null字段 + * + * @param ufHrSbjsgzb 修改的记录 + * @return 返回影响行数 + */ + public int updateIgnoreNull(UfHrSbjsgzbPO ufHrSbjsgzb) { + return getUfHrSbjsgzbMapper().updateIgnoreNull(ufHrSbjsgzb); + } +} diff --git a/src/com/engine/salary/timer/SyncSIBaseJob.java b/src/com/engine/salary/timer/SyncSIBaseJob.java new file mode 100644 index 000000000..aceddf0ef --- /dev/null +++ b/src/com/engine/salary/timer/SyncSIBaseJob.java @@ -0,0 +1,199 @@ +package com.engine.salary.timer; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; +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 com.engine.salary.entity.siarchives.po.UfHrSbjsgzbPO; +import com.engine.salary.enums.siaccount.EmployeeStatusEnum; +import com.engine.salary.mapper.siarchives.FundSchemeMapper; +import com.engine.salary.mapper.siarchives.SocialSchemeMapper; +import com.engine.salary.service.SIArchivesService; +import com.engine.salary.service.UfHrSbjsgzbService; +import com.engine.salary.service.impl.SIArchivesServiceImpl; +import com.engine.salary.service.impl.UfHrSbjsgzbServiceImpl; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +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.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.schedule.BaseCronJob; + +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.sys.constant.SalarySysConstant.WEL_BASE_DIFF_BY_PER_AND_COM; + +/** + * @ClassName SyncSIBaseJob + * @author Harryxzy + * @date 2024/12/20 9:55 + * @description 中航富士达 设置员工社保福利档案基数 + */ +@Slf4j +public class SyncSIBaseJob extends BaseCronJob { + + private UfHrSbjsgzbService getUfHrSbjsgzbService(User user) { + return ServiceUtil.getService(UfHrSbjsgzbServiceImpl.class, user); + } + + private SocialSchemeMapper getSocialSchemeMapper() { + return MapperProxyFactory.getProxy(SocialSchemeMapper.class); + } + + public SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class,user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + private FundSchemeMapper getFundSchemeMapper() { + return MapperProxyFactory.getProxy(FundSchemeMapper.class); + } + + @Override + public void execute() { + User user = new User(); + user.setUid(1); + EncryptUtil encryptUtil = new EncryptUtil(); + // 获取建模基数信息 + List ufHrSbjsgzbList = getUfHrSbjsgzbService(user).listAll(); + // 岗位规则 + Map gwGzMap = new HashMap<>(); + // 岗位分类规则 + Map> gwflGzMap = new HashMap<>(); + // 工龄规则 + List glGzList = new ArrayList<>(); + for (UfHrSbjsgzbPO po : ufHrSbjsgzbList) { + if (StringUtils.isNotBlank(po.getGw())) { + // 岗位不为空 + Arrays.stream(po.getGw().split(",")) + .map(Long::valueOf) + .forEach(gw -> { + gwGzMap.put(Long.valueOf(gw), po); + }); + } else if (NumberUtils.isCreatable(po.getGwfl())) { + // 岗位分类(职务)不为空 + List list = gwflGzMap.computeIfAbsent(Long.valueOf(NumberUtils.isCreatable(po.getGwfl()) ? po.getGwfl() : "0"), k -> new ArrayList<>()); + list.add(po); + gwflGzMap.put(Long.valueOf(po.getGwfl()), list); + } else { + // 剩余根据工龄匹配 + glGzList.add(po); + } + } + + // 获取社保福利档案信息(只获取在缴、待减员数据) + List statusList = Arrays.asList(EmployeeStatusEnum.PAYING.getValue(), EmployeeStatusEnum.STAY_DEL.getValue()); + InsuranceArchivesListParam archivesListParam = InsuranceArchivesListParam.builder().runStatuses(statusList).build(); + List insuranceArchivesEmployeePOS = getSocialSchemeMapper().queryEmployeeList(archivesListParam); + // 获取这些人的社保具体数据 + List socialIdList = insuranceArchivesEmployeePOS.stream().map(InsuranceArchivesEmployeePO::getSocialId).collect(Collectors.toList()); + List socialArchiveList = getSIArchivesService(user).listInsuranceArchivesSocialSchemeByIds(socialIdList); + encryptUtil.decryptList(socialArchiveList, InsuranceArchivesSocialSchemePO.class); + Map socialArchiveMap = SalaryEntityUtil.convert2Map(socialArchiveList, InsuranceArchivesSocialSchemePO::getId); + // 获取这些人的公积金具体数据 + List fundIdList = insuranceArchivesEmployeePOS.stream().map(InsuranceArchivesEmployeePO::getFundId).collect(Collectors.toList()); + List fundArchiveList = getSIArchivesService(user).listInsuranceArchivesFundSchemeByIds(fundIdList); + encryptUtil.decryptList(fundArchiveList, InsuranceArchivesFundSchemePO.class); + Map fundArchiveMap = SalaryEntityUtil.convert2Map(fundArchiveList, InsuranceArchivesFundSchemePO::getId); + + //判断是否要区分个人和单位福利基数 + SalarySysConfPO welBaseDiff = getSalarySysConfService(user).getOneByCode(WEL_BASE_DIFF_BY_PER_AND_COM); + boolean welBaseDiffSign = welBaseDiff != null && welBaseDiff.getConfValue().equals(OpenEnum.OPEN.getValue()); + + insuranceArchivesEmployeePOS.stream().forEach(archiveEmp -> { + // 确定唯一规则 + UfHrSbjsgzbPO gzPO = getSIArchivesService(user).getGzByEmp(archiveEmp, gwGzMap, gwflGzMap, glGzList); + // 处理社保数据 + InsuranceArchivesSocialSchemePO socialArchive = socialArchiveMap.get(archiveEmp.getSocialId()); + if (socialArchive != null && socialArchive.getSocialSchemeId() != null && gzPO != null) { + Map socialJson = JSON.parseObject(socialArchive.getSocialPaymentBaseString(), new TypeReference>() { + }); + if (socialJson != null) { + for (Map.Entry entry : socialJson.entrySet()) { + if (entry.getKey().equals("9001")) { + socialJson.put("9001",Util.null2String(gzPO.getYanglaojs())); + } else if (entry.getKey().equals("9002")) { + socialJson.put("9002",Util.null2String(gzPO.getYiliaojs())); + } else if (entry.getKey().equals("9003")) { + socialJson.put("9003",Util.null2String(gzPO.getGongshangjs())); + } else if (entry.getKey().equals("9004")) { + socialJson.put("9004",Util.null2String(gzPO.getShiyejs())); + } else if (entry.getKey().equals("9005")) { + socialJson.put("9005",Util.null2String(gzPO.getShengyujs())); + } + } + socialArchive.setSocialPaymentBaseString(JSON.toJSONString(socialJson)); + } + //如果需要区分个人和公司福利基数 + if (welBaseDiffSign) { + Map socialComJson = JSON.parseObject(socialArchive.getSocialPaymentComBaseString(), new TypeReference>() { + }); + if (socialComJson != null) { + for (Map.Entry entry : socialComJson.entrySet()) { + if (entry.getKey().equals("9001")) { + socialComJson.put("9001",Util.null2String(gzPO.getYanglaojs())); + } else if (entry.getKey().equals("9002")) { + socialComJson.put("9002",Util.null2String(gzPO.getYiliaojs())); + } else if (entry.getKey().equals("9003")) { + socialComJson.put("9003",Util.null2String(gzPO.getGongshangjs())); + } else if (entry.getKey().equals("9004")) { + socialComJson.put("9004",Util.null2String(gzPO.getShiyejs())); + } else if (entry.getKey().equals("9005")) { + socialComJson.put("9005",Util.null2String(gzPO.getShengyujs())); + } + } + socialArchive.setSocialPaymentComBaseString(JSON.toJSONString(socialComJson)); + } + } + // 更新(加密) + encryptUtil.encrypt(socialArchive, InsuranceArchivesSocialSchemePO.class); + getSocialSchemeMapper().updateById(socialArchive); + } + + // 处理公积金数据 + InsuranceArchivesFundSchemePO fundArchive = fundArchiveMap.get(archiveEmp.getFundId()); + if (fundArchive != null && fundArchive.getFundSchemeId() != null && gzPO != null) { + Map fundJson = JSON.parseObject(fundArchive.getFundPaymentBaseString(), new TypeReference>() { + }); + if (fundJson != null) { + for (Map.Entry entry : fundJson.entrySet()) { + if (entry.getKey().equals("9006")) { + fundJson.put("9006", Util.null2String(gzPO.getGjjjs())); + } + } + fundArchive.setFundPaymentBaseString(JSON.toJSONString(fundJson)); + } + //如果需要区分个人和公司福利基数 + if (welBaseDiffSign) { + Map fundComJson = JSON.parseObject(fundArchive.getFundPaymentComBaseString(), new TypeReference>() { + }); + if (fundComJson != null) { + for (Map.Entry entry : fundComJson.entrySet()) { + if (entry.getKey().equals("9006")) { + fundComJson.put("9006",Util.null2String(gzPO.getGjjjs())); + } + } + fundArchive.setFundPaymentComBaseString(JSON.toJSONString(fundComJson)); + } + } + // 更新(加密) + encryptUtil.encrypt(fundArchive, InsuranceArchivesFundSchemePO.class); + getFundSchemeMapper().updateById(fundArchive); + } + }); + } +}