weaver-hrm-salary/src/com/engine/salary/biz/SIArchivesBiz.java

1826 lines
96 KiB
Java
Raw Normal View History

2022-03-15 09:34:53 +08:00
package com.engine.salary.biz;
2022-03-18 18:00:51 +08:00
import com.alibaba.fastjson.JSON;
2022-03-16 17:04:21 +08:00
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.api.browser.bean.SearchConditionGroup;
import com.api.browser.bean.SearchConditionItem;
import com.api.browser.bean.SearchConditionOption;
2022-03-31 14:22:42 +08:00
import com.api.browser.util.ConditionFactory;
import com.api.browser.util.ConditionType;
2022-03-22 19:47:46 +08:00
import com.cloudstore.eccom.pc.table.WeaTable;
import com.cloudstore.eccom.pc.table.WeaTableCheckboxpopedom;
2022-03-18 18:00:51 +08:00
import com.cloudstore.eccom.pc.table.WeaTableColumn;
2022-03-22 19:47:46 +08:00
import com.cloudstore.eccom.result.WeaResultMsg;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
2022-05-24 09:23:17 +08:00
import com.engine.salary.encrypt.AESEncryptUtil;
import com.engine.salary.encrypt.EncryptUtil;
2022-03-15 09:34:53 +08:00
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
2022-03-15 17:39:19 +08:00
import com.engine.salary.entity.siarchives.bo.InsuranceArchivesBO;
import com.engine.salary.entity.siarchives.dto.InsuranceArchivesBaseDTO;
import com.engine.salary.entity.siarchives.dto.InsuranceArchivesFundSchemeDTO;
import com.engine.salary.entity.siarchives.dto.InsuranceArchivesOtherSchemeDTO;
import com.engine.salary.entity.siarchives.dto.InsuranceArchivesSocialSchemeDTO;
2022-03-18 18:00:51 +08:00
import com.engine.salary.entity.siarchives.param.*;
2022-04-14 11:54:16 +08:00
import com.engine.salary.entity.siarchives.po.*;
2022-03-16 17:04:21 +08:00
import com.engine.salary.entity.sicategory.po.ICategoryPO;
import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO;
2022-03-15 17:39:19 +08:00
import com.engine.salary.entity.sischeme.po.InsuranceSchemePO;
2022-06-06 16:55:02 +08:00
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
2022-03-22 19:47:46 +08:00
import com.engine.salary.enums.UserStatusEnum;
import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum;
import com.engine.salary.enums.siaccount.EmployeeStatusEnum;
2022-03-18 18:00:51 +08:00
import com.engine.salary.enums.sicategory.*;
import com.engine.salary.exception.SalaryRunTimeException;
2022-03-16 17:04:21 +08:00
import com.engine.salary.mapper.siarchives.FundSchemeMapper;
import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper;
2022-03-16 17:04:21 +08:00
import com.engine.salary.mapper.siarchives.OtherSchemeMapper;
import com.engine.salary.mapper.siarchives.SocialSchemeMapper;
2022-03-18 18:00:51 +08:00
import com.engine.salary.mapper.sicategory.ICategoryMapper;
2022-03-16 17:04:21 +08:00
import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper;
2022-03-18 18:00:51 +08:00
import com.engine.salary.mapper.sischeme.InsuranceSchemeMapper;
import com.engine.salary.mapper.taxagent.TaxAgentMapper;
2023-04-12 15:27:35 +08:00
import com.engine.salary.service.SalaryEmployeeService;
import com.engine.salary.service.impl.SalaryEmployeeServiceImpl;
2022-03-21 20:09:10 +08:00
import com.engine.salary.util.SalaryAssert;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryFormItemUtil;
import com.engine.salary.util.*;
import com.engine.salary.util.db.MapperProxyFactory;
2022-03-18 18:00:51 +08:00
import com.engine.salary.util.page.PageInfo;
2022-05-25 13:10:03 +08:00
import com.engine.salary.util.page.SalaryPageUtil;
import com.engine.salary.wrapper.TaxAgentWrapper;
2022-06-15 10:23:39 +08:00
import com.google.common.collect.Lists;
import dm.jdbc.util.IdGenerator;
2022-06-06 16:55:02 +08:00
import lombok.Data;
2022-06-10 16:35:01 +08:00
import lombok.extern.slf4j.Slf4j;
2022-04-14 11:54:16 +08:00
import org.apache.commons.collections.CollectionUtils;
2022-06-01 14:53:16 +08:00
import org.apache.commons.lang.StringUtils;
2022-03-15 17:39:19 +08:00
import org.apache.ibatis.session.SqlSession;
2022-11-03 11:14:59 +08:00
import org.springframework.util.StopWatch;
2022-03-15 17:39:19 +08:00
import weaver.conn.mybatis.MyBatisFactory;
2022-03-16 17:04:21 +08:00
import weaver.general.Util;
import weaver.hrm.User;
2022-03-15 09:34:53 +08:00
2022-06-01 14:53:16 +08:00
import java.math.BigDecimal;
2022-03-16 17:04:21 +08:00
import java.util.*;
2022-03-18 18:00:51 +08:00
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
2022-03-16 17:04:21 +08:00
import java.util.stream.Collectors;
2022-03-15 09:34:53 +08:00
/**
* @Author weaver_cl
2022-07-08 11:30:10 +08:00
* @Description:
2022-03-15 09:34:53 +08:00
* @Date 2022/3/12
* @Version V1.0
**/
2022-06-06 16:55:02 +08:00
@Data
2022-06-10 16:35:01 +08:00
@Slf4j
2022-03-15 09:34:53 +08:00
public class SIArchivesBiz {
Boolean needAuth;
2022-06-06 16:55:02 +08:00
Collection<TaxAgentPO> taxAgentPOS;
private EncryptUtil encryptUtil = new EncryptUtil();
private TaxAgentMapper getTaxAgentMapper() {
return MapperProxyFactory.getProxy(TaxAgentMapper.class);
}
private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() {
return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class);
}
private InsuranceSchemeDetailMapper getInsuranceSchemeDetailMapper() {
return MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class);
}
private SocialSchemeMapper getSocialSchemeMapper() {
return MapperProxyFactory.getProxy(SocialSchemeMapper.class);
}
private FundSchemeMapper getFundSchemeMapper() {
return MapperProxyFactory.getProxy(FundSchemeMapper.class);
}
private OtherSchemeMapper getOtherSchemeMapper() {
return MapperProxyFactory.getProxy(OtherSchemeMapper.class);
}
private TaxAgentWrapper getTaxAgentWrapper(User user) {
return ServiceUtil.getService(TaxAgentWrapper.class, user);
}
2023-04-12 15:27:35 +08:00
private SalaryEmployeeService getSalaryEmployeeService(User user) {
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
}
2022-03-16 17:04:21 +08:00
/**
* @param welfareType
* @param employeeId
* @param operateId
* @param user
* @return
*/
public Map<String, Object> getBaseForm(WelfareTypeEnum welfareType, Long employeeId, Long operateId, User user, Long paymentOrganization) {
2022-03-15 17:39:19 +08:00
Map<String, Object> data = new HashMap<>(16);
2022-03-15 09:34:53 +08:00
SalaryAssert.notNull(employeeId, "员工id不可为空");
2023-04-12 15:27:35 +08:00
List<DataCollectionEmployee> employeeByIds = getSalaryEmployeeService(user).getEmployeeByIdsAll(Collections.singletonList(employeeId));
2022-06-06 16:55:02 +08:00
SalaryAssert.notEmpty(employeeByIds, "员工信息不存在");
2022-03-15 09:34:53 +08:00
DataCollectionEmployee item = employeeByIds.get(0);
2022-03-15 17:39:19 +08:00
if (welfareType == null) {
//基础信息表单
InsuranceArchivesBaseDTO insuranceArchivesBaseDTO = InsuranceArchivesBaseDTO.builder().department(item.getDepartmentName())
2022-04-28 10:05:27 +08:00
.hiredate(item.getCompanystartdate())
2022-03-15 17:39:19 +08:00
.position(item.getJobtitleName())
.username(item.getUsername())
.telephone(item.getMobile())
2022-05-05 10:35:58 +08:00
.dimissionDate(item.getDismissdate())
2022-03-15 17:39:19 +08:00
.build();
2022-03-22 19:47:46 +08:00
// if (item.getStatus() == UserStatusEnum.unavailable) {
2022-03-15 17:39:19 +08:00
// InsuranceArchivesListParam insuranceArchivesListParam = new InsuranceArchivesListParam();
// insuranceArchivesListParam.setEmployeeIds(Collections.singletonList(employeeId));
// List<InsuranceArchivesEmployeePO> insuranceArchivesEmployeePOS = siArchivesSocialMapper.queryEmployeeList(insuranceArchivesListParam, tenantKey);
// if (CollectionUtils.isNotEmpty(insuranceArchivesEmployeePOS)) {
// insuranceArchivesBaseDTO.setDimissionDate(SalaryDateUtil.getFormatLocalDate(insuranceArchivesEmployeePOS.get(0).getDimissionDate()));
// }
// }
//WeaForm weaForm = SalaryFormatUtil.<InsuranceArchivesBaseDTO>getInstance().buildForm(InsuranceArchivesBaseDTO.class, insuranceArchivesBaseDTO);
2022-06-06 16:55:02 +08:00
// weaForm.getGroups().add(new WeaFormGroup("g1", "员工信息"));
// weaForm.getLayout().forEach(items -> items.forEach(e -> e.setGroupId("g1")));
data.put("data", insuranceArchivesBaseDTO);
2022-03-15 17:39:19 +08:00
return data;
}
SISchemeBiz siSchemeBiz = new SISchemeBiz();
List<InsuranceSchemePO> list = siSchemeBiz.listAll();
// 过滤可见性范围
list = filterList(list);
2022-03-16 17:04:21 +08:00
List<SearchConditionItem> selectItems = new ArrayList<>();
List<SearchConditionGroup> addGroups = new ArrayList<>();
List<SearchConditionOption> paymentOptions = paymentOrganizationOptions();
List<SearchConditionOption> underTakeOptions = Arrays.stream(UndertakerEnum.values()).map(e -> new SearchConditionOption(e.getValue().toString(), e.getDefaultLabel())).collect(Collectors.toList());
2022-03-16 17:04:21 +08:00
2022-03-15 17:39:19 +08:00
//返回数据
switch (welfareType) {
case SOCIAL_SECURITY:
InsuranceArchivesSocialSchemeDTO insuranceArchivesSocialSchemeDTO = buildSocialForm(employeeId, operateId, paymentOrganization);
2022-03-16 17:04:21 +08:00
List<InsuranceSchemePO> socialList = list.stream().filter(e -> Objects.equals(e.getWelfareType(), WelfareTypeEnum.SOCIAL_SECURITY.getValue())).collect(Collectors.toList());
2022-06-06 16:55:02 +08:00
List<SearchConditionOption> socialOptions = new ArrayList<>();
2022-03-16 17:04:21 +08:00
socialList.forEach(social -> {
2022-06-06 16:55:02 +08:00
socialOptions.add(new SearchConditionOption(Util.null2String(social.getId()), social.getSchemeName()));
2022-03-16 17:04:21 +08:00
});
SearchConditionItem socialName = SalaryFormItemUtil.selectItem(user, socialOptions, 2, 12, 6, false, "社保方案名称", "socialSchemeId");
2022-06-06 16:55:02 +08:00
SearchConditionItem organizationName = SalaryFormItemUtil.selectItem(user, paymentOptions, 2, 12, 6, false, "社保缴纳组织", "paymentOrganization");
SearchConditionItem underTakeName = SalaryFormItemUtil.selectItem(user, underTakeOptions, 2, 12, 6, false, "社保个人实际承担方", "underTake");
2022-03-16 17:04:21 +08:00
selectItems.add(socialName);
selectItems.add(organizationName);
selectItems.add(underTakeName);
2022-06-06 16:55:02 +08:00
addGroups.add(new SearchConditionGroup("社保基础信息", true, selectItems));
data.put("data", insuranceArchivesSocialSchemeDTO);
data.put("items", addGroups);
2022-03-15 17:39:19 +08:00
break;
case ACCUMULATION_FUND:
InsuranceArchivesFundSchemeDTO insuranceArchivesFundSchemeDTO = buildFundForm(employeeId, operateId, paymentOrganization);
2022-03-16 17:04:21 +08:00
List<InsuranceSchemePO> fundList = list.stream().filter(e -> Objects.equals(e.getWelfareType(), WelfareTypeEnum.ACCUMULATION_FUND.getValue())).collect(Collectors.toList());
2022-06-06 16:55:02 +08:00
List<SearchConditionOption> fundOptions = new ArrayList<>();
2022-03-16 17:04:21 +08:00
fundList.forEach(social -> {
2022-06-06 16:55:02 +08:00
fundOptions.add(new SearchConditionOption(Util.null2String(social.getId()), social.getSchemeName()));
2022-03-16 17:04:21 +08:00
});
SearchConditionItem fundName = SalaryFormItemUtil.selectItem(user, fundOptions, 2, 12, 6, false, "公积金方案名称", "fundSchemeId");
2022-06-06 16:55:02 +08:00
SearchConditionItem organizationFundName = SalaryFormItemUtil.selectItem(user, paymentOptions, 2, 12, 6, false, "公积金缴纳组织", "paymentOrganization");
SearchConditionItem underTakeFundName = SalaryFormItemUtil.selectItem(user, underTakeOptions, 2, 12, 6, false, "公积金个人实际承担方", "underTake");
2022-03-16 17:04:21 +08:00
selectItems.add(fundName);
selectItems.add(organizationFundName);
selectItems.add(underTakeFundName);
2022-06-06 16:55:02 +08:00
addGroups.add(new SearchConditionGroup("公积金基础信息", true, selectItems));
data.put("data", insuranceArchivesFundSchemeDTO);
data.put("items", addGroups);
2022-03-15 17:39:19 +08:00
break;
case OTHER:
InsuranceArchivesOtherSchemeDTO insuranceArchivesOtherSchemeDTO = buildOtherForm(employeeId, operateId, paymentOrganization);
2022-03-16 17:04:21 +08:00
List<InsuranceSchemePO> otherList = list.stream().filter(e -> Objects.equals(e.getWelfareType(), WelfareTypeEnum.OTHER.getValue())).collect(Collectors.toList());
2022-06-06 16:55:02 +08:00
List<SearchConditionOption> otherOptions = new ArrayList<>();
2022-03-16 17:04:21 +08:00
otherList.forEach(social -> {
2022-06-06 16:55:02 +08:00
otherOptions.add(new SearchConditionOption(Util.null2String(social.getId()), social.getSchemeName()));
2022-03-16 17:04:21 +08:00
});
SearchConditionItem otherName = SalaryFormItemUtil.selectItem(user, otherOptions, 2, 12, 6, false, "其它福利名称", "otherSchemeId");
2022-06-06 16:55:02 +08:00
SearchConditionItem organizationOtherName = SalaryFormItemUtil.selectItem(user, paymentOptions, 2, 12, 6, false, "其它福利缴纳组织", "paymentOrganization");
SearchConditionItem underTakeOtherName = SalaryFormItemUtil.selectItem(user, underTakeOptions, 2, 12, 6, false, "其它福利个人实际承担方", "underTake");
2022-03-16 17:04:21 +08:00
selectItems.add(otherName);
selectItems.add(organizationOtherName);
selectItems.add(underTakeOtherName);
2022-06-06 16:55:02 +08:00
addGroups.add(new SearchConditionGroup("其它福利基础信息", true, selectItems));
data.put("data", insuranceArchivesOtherSchemeDTO);
data.put("items", addGroups);
2022-03-16 17:04:21 +08:00
break;
default:
}
return data;
}
/***
* @description 过滤没有权限访问的
* @return List<InsuranceSchemePO>
* @author Harryxzy
* @date 2022/9/19 18:32
*/
List<InsuranceSchemePO> filterList(List<InsuranceSchemePO> list){
2022-09-21 14:42:39 +08:00
List<String> ids = taxAgentPOS.stream().map(i -> String.valueOf(i.getId())).collect(Collectors.toList());
List<InsuranceSchemePO> result = list.stream().filter(item -> {
boolean flag = true;
if (item.getSharedType()!= null && item.getSharedType().equals("1")) {
flag = false;
String taxAgentIds = item.getTaxAgentIds();
2022-09-21 14:42:39 +08:00
if(StringUtils.isNotBlank(taxAgentIds)){
String splitFlag = ",";
String[] split = taxAgentIds.split(splitFlag);
for (int i = 0; i < split.length; i++) {
if (ids.contains(split[i])) {
flag = true;
}
}
}
}
return flag;
}).collect(Collectors.toList());
return result;
}
2022-03-16 17:04:21 +08:00
/**
2022-06-06 16:55:02 +08:00
* 获取详细表单
*
2022-03-16 17:04:21 +08:00
* @param user
* @param welfareType
* @param employeeId
* @param operateId
* @param schemeId
* @return
*/
public Map<String, Object> getPaymentForm(User user, WelfareTypeEnum welfareType, Long employeeId, long operateId, Long schemeId, Long paymentOrganization) {
2022-03-16 17:04:21 +08:00
Map<String, Object> data = new HashMap<>(16);
switch (welfareType) {
case SOCIAL_SECURITY:
data = buildSocialPaymentForm(user, employeeId, schemeId, operateId, welfareType.getValue(), paymentOrganization);
2022-03-16 17:04:21 +08:00
break;
case ACCUMULATION_FUND:
data = buildFundPaymentForm(user, employeeId, schemeId, operateId, welfareType.getValue(), paymentOrganization);
2022-03-16 17:04:21 +08:00
break;
case OTHER:
data = buildOtherPaymentForm(user, employeeId, schemeId, operateId, welfareType.getValue(), paymentOrganization);
2022-03-15 17:39:19 +08:00
break;
default:
}
return data;
2022-03-15 09:34:53 +08:00
}
2022-03-15 17:39:19 +08:00
2022-03-16 17:04:21 +08:00
/**
* 其他payForm
2022-06-06 16:55:02 +08:00
*
2022-03-16 17:04:21 +08:00
* @param employeeId
* @param schemeId
* @param operateId
* @return
*/
public Map<String, Object> buildOtherPaymentForm(User user, Long employeeId, Long schemeId, long operateId, Integer welfareType, Long paymentOrganization) {
2022-03-16 17:04:21 +08:00
Map<String, Object> dataMap = new HashMap<>();
InsuranceArchivesOtherSchemeDTO data = buildOtherForm(employeeId, operateId, paymentOrganization);
2022-03-16 17:04:21 +08:00
if (data != null) {
2022-06-06 16:55:02 +08:00
dataMap.put("data", JSONObject.parseObject(data.getOtherPaymentBaseString(), new TypeReference<Map<String, Object>>() {
2022-03-16 17:04:21 +08:00
}));
}
List<SearchConditionGroup> addGroups = new ArrayList<>();
2022-06-06 16:55:02 +08:00
List<SearchConditionItem> inputItems = buildPaymentBase(user, schemeId, welfareType);
addGroups.add(new SearchConditionGroup("其它福利缴纳基数", true, inputItems));
dataMap.put("items", addGroups);
2022-03-16 17:04:21 +08:00
return dataMap;
}
/**
* 公积金payForm
2022-06-06 16:55:02 +08:00
*
2022-03-16 17:04:21 +08:00
* @param employeeId
* @param schemeId
* @param operateId
* @return
*/
public Map<String, Object> buildFundPaymentForm(User user, Long employeeId, Long schemeId, long operateId, Integer welfareType, Long paymentOrganization) {
2022-03-16 17:04:21 +08:00
Map<String, Object> dataMap = new HashMap<>();
InsuranceArchivesFundSchemeDTO data = buildFundForm(employeeId, operateId, paymentOrganization);
2022-03-16 17:04:21 +08:00
if (data != null) {
2022-06-06 16:55:02 +08:00
dataMap.put("data", JSONObject.parseObject(data.getFundPaymentBaseString(), new TypeReference<Map<String, Object>>() {
2022-03-16 17:04:21 +08:00
}));
}
List<SearchConditionGroup> addGroups = new ArrayList<>();
2022-06-06 16:55:02 +08:00
List<SearchConditionItem> inputItems = buildPaymentBase(user, schemeId, welfareType);
addGroups.add(new SearchConditionGroup("公积金缴纳基数", true, inputItems));
dataMap.put("items", addGroups);
2022-03-16 17:04:21 +08:00
return dataMap;
}
/**
* 社保payForm
2022-06-06 16:55:02 +08:00
*
2022-03-16 17:04:21 +08:00
* @param employeeId
* @param schemeId
* @param operateId
* @return
*/
public Map<String, Object> buildSocialPaymentForm(User user, Long employeeId, Long schemeId, long operateId, Integer welfareType, Long paymentOrganization) {
2022-03-16 17:04:21 +08:00
Map<String, Object> dataMap = new HashMap<>();
InsuranceArchivesSocialSchemeDTO data = buildSocialForm(employeeId, operateId, paymentOrganization);
2022-03-16 17:04:21 +08:00
if (data != null) {
2022-06-06 16:55:02 +08:00
dataMap.put("data", JSONObject.parseObject(data.getSchemePaymentBaseString(), new TypeReference<Map<String, Object>>() {
2022-03-16 17:04:21 +08:00
}));
}
List<SearchConditionGroup> addGroups = new ArrayList<>();
2022-06-06 16:55:02 +08:00
List<SearchConditionItem> inputItems = buildPaymentBase(user, schemeId, welfareType);
addGroups.add(new SearchConditionGroup("社保缴纳基数", true, inputItems));
dataMap.put("items", addGroups);
2022-03-16 17:04:21 +08:00
return dataMap;
}
/**
2022-06-06 16:55:02 +08:00
* 构造payment(items)
*
2022-03-16 17:04:21 +08:00
* @param schemeId
* @return
*/
2022-06-06 16:55:02 +08:00
public List<SearchConditionItem> buildPaymentBase(User user, Long schemeId, Integer welfareType) {
2022-03-16 17:04:21 +08:00
List<SearchConditionItem> inputItems = new ArrayList<>();
2022-06-06 16:55:02 +08:00
if (schemeId == null) {
2022-03-16 17:04:21 +08:00
return new ArrayList<>();
}
2022-06-06 16:55:02 +08:00
List<InsuranceSchemeDetailPO> list = queryListByPrimaryIdIsPayment(schemeId, welfareType).stream().collect(Collectors.collectingAndThen(
2022-03-16 17:04:21 +08:00
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(InsuranceSchemeDetailPO::getInsuranceId))), ArrayList::new)
);
SICategoryBiz siCategoryBiz = new SICategoryBiz();
2022-06-06 16:55:02 +08:00
list.forEach(insuranceSchemeDetail -> {
2022-03-16 17:04:21 +08:00
ICategoryPO iCategoryPO = siCategoryBiz.getByID(insuranceSchemeDetail.getInsuranceId());
if (iCategoryPO != null) {
// inputItems.add(SalaryFormItemUtil.inputNumberItem(user, "precision:2", 2, 12, 2, iCategoryPO.getInsuranceName(), String.valueOf(insuranceSchemeDetail.getInsuranceId())));
inputItems.add(SalaryFormItemUtil.inputNumberItemWithMaxAndMin(user, "precision:2", 2, 12, 2, iCategoryPO.getInsuranceName(), String.valueOf(insuranceSchemeDetail.getInsuranceId())
, insuranceSchemeDetail.getUpperLimit(), insuranceSchemeDetail.getLowerLimit()));
2022-03-16 17:04:21 +08:00
}
});
return inputItems;
}
/**
* 获取方案明细
2022-06-06 16:55:02 +08:00
*
2022-03-16 17:04:21 +08:00
* @param schemeId
* @return
*/
2022-06-06 16:55:02 +08:00
public List<InsuranceSchemeDetailPO> queryListByPrimaryIdIsPayment(Long schemeId, Integer welfareType) {
2022-03-16 17:04:21 +08:00
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
2022-06-06 16:55:02 +08:00
try {
2022-03-16 17:04:21 +08:00
InsuranceSchemeDetailMapper insuranceSchemeDetailMapper = sqlSession.getMapper(InsuranceSchemeDetailMapper.class);
2022-05-24 09:23:17 +08:00
List<InsuranceSchemeDetailPO> insuranceSchemeDetailPOS = insuranceSchemeDetailMapper.queryListByPrimaryIdIsPayment(schemeId, IsPaymentEnum.YES.getValue(), welfareType);
encryptUtil.decryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class);
2022-06-02 17:01:26 +08:00
return insuranceSchemeDetailPOS;
} finally {
2022-03-16 17:04:21 +08:00
sqlSession.close();
}
}
/**
2022-06-06 16:55:02 +08:00
* 社保缴纳组织
*
2022-03-16 17:04:21 +08:00
* @return
*/
public List<SearchConditionOption> paymentOrganizationOptions() {
Collection<TaxAgentPO> list = taxAgentPOS;
if (CollectionUtils.isEmpty(list)) {
return new ArrayList<>();
2022-03-16 17:04:21 +08:00
}
return list
.stream()
.map(item -> new SearchConditionOption(String.valueOf(item.getId()), item.getName())).collect(Collectors.toList());
2022-03-16 17:04:21 +08:00
}
2022-03-15 17:39:19 +08:00
/**
* 其它基础表单
2022-06-06 16:55:02 +08:00
*
2022-03-15 17:39:19 +08:00
* @param employeeId
* @param operateId
* @return
*/
public InsuranceArchivesOtherSchemeDTO buildOtherForm(Long employeeId, Long operateId, Long paymentOrganization) {
2022-03-15 17:39:19 +08:00
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class);
// List<InsuranceArchivesOtherSchemePO> otherList = otherSchemeMapper.getOtherByEmployeeId(Collections.singletonList(employeeId));
List<InsuranceArchivesOtherSchemePO> otherList = otherSchemeMapper.getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder()
.employeeId(employeeId)
.paymentOrganization(paymentOrganization)
.build());
encryptUtil.decryptList(otherList, InsuranceArchivesOtherSchemePO.class);
2022-03-21 16:13:08 +08:00
InsuranceArchivesOtherSchemePO insuranceArchivesOtherSchemePO = otherList.size() != 0 ? otherList.get(0) : null;
2022-03-15 17:39:19 +08:00
InsuranceArchivesOtherSchemeDTO data = InsuranceArchivesBO.convertOtherPOtoDTO(insuranceArchivesOtherSchemePO, employeeId);
if (insuranceArchivesOtherSchemePO == null) {
data.setEmployeeId(employeeId);
data.setUnderTake(UndertakerEnum.SCOPE_PERSON.getValue().toString());
2022-03-15 17:39:19 +08:00
}
return data;
2022-06-06 16:55:02 +08:00
} finally {
2022-03-15 17:39:19 +08:00
sqlSession.close();
}
}
/**
* 公积金基础表单
2022-06-06 16:55:02 +08:00
*
2022-03-15 17:39:19 +08:00
* @param employeeId
* @param operateId
* @return
*/
public InsuranceArchivesFundSchemeDTO buildFundForm(Long employeeId, Long operateId, Long paymentOrganization) {
2022-03-15 17:39:19 +08:00
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class);
// List<InsuranceArchivesFundSchemePO> fundList = fundSchemeMapper.getFundByEmployeeId(Collections.singletonList(employeeId));
List<InsuranceArchivesFundSchemePO> fundList = fundSchemeMapper.getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder()
.employeeId(employeeId)
.paymentOrganization(paymentOrganization)
.build());
encryptUtil.decryptList(fundList, InsuranceArchivesFundSchemePO.class);
2022-03-21 16:13:08 +08:00
InsuranceArchivesFundSchemePO insuranceArchivesFundSchemePO = fundList.size() != 0 ? fundList.get(0) : null;
2022-03-15 17:39:19 +08:00
InsuranceArchivesFundSchemeDTO data = InsuranceArchivesBO.convertFundPOtoDTO(insuranceArchivesFundSchemePO, employeeId);
if (insuranceArchivesFundSchemePO == null) {
data.setEmployeeId(employeeId);
data.setUnderTake(UndertakerEnum.SCOPE_PERSON.getValue().toString());
2022-03-15 17:39:19 +08:00
}
return data;
2022-06-06 16:55:02 +08:00
} finally {
2022-03-15 17:39:19 +08:00
sqlSession.close();
}
}
/**
* 社保基础表单
2022-06-06 16:55:02 +08:00
*
2022-03-15 17:39:19 +08:00
* @param employeeId
* @param operateId
* @return
*/
public InsuranceArchivesSocialSchemeDTO buildSocialForm(Long employeeId, Long operateId, Long paymentOrganization) {
InsuranceArchivesSocialSchemePO insuranceArchivesSocialSchemePO = getSocialByEmployeeId(employeeId, paymentOrganization);
2022-03-15 17:39:19 +08:00
InsuranceArchivesSocialSchemeDTO data = InsuranceArchivesBO.convertSocialPOtoDTO(insuranceArchivesSocialSchemePO, employeeId);
if (insuranceArchivesSocialSchemePO == null) {
data.setEmployeeId(employeeId);
data.setUnderTake(UndertakerEnum.SCOPE_PERSON.getValue().toString());
2022-03-15 17:39:19 +08:00
}
return data;
}
/**
* 获取社保档案表
2022-06-06 16:55:02 +08:00
*
2022-03-15 17:39:19 +08:00
* @param employeeId
* @return
*/
public InsuranceArchivesSocialSchemePO getSocialByEmployeeId(Long employeeId, Long paymentOrganization) {
2022-03-15 17:39:19 +08:00
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class);
List<InsuranceArchivesSocialSchemePO> socialList = socialSchemeMapper.getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder()
.employeeId(employeeId)
.paymentOrganization(paymentOrganization)
.build());
encryptUtil.decryptList(socialList, InsuranceArchivesSocialSchemePO.class);
return socialList.size() != 0 ? socialList.get(0) : null;
2022-06-06 16:55:02 +08:00
} finally {
2022-03-15 17:39:19 +08:00
sqlSession.close();
}
}
2022-06-15 10:23:39 +08:00
public List<InsuranceArchivesSocialSchemePO> getSocialByEmployeeIds(List<Long> employeeIds) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class);
List<List<Long>> partition = Lists.partition(employeeIds, 1000);
List<InsuranceArchivesSocialSchemePO> allList = new ArrayList<>();
for (List<Long> longs : partition) {
List<InsuranceArchivesSocialSchemePO> socialList = socialSchemeMapper.getSocialByEmployeeId(longs);
allList.addAll(socialList);
}
return allList;
} finally {
sqlSession.close();
}
}
public List<InsuranceArchivesFundSchemePO> getFundByEmployeeIds(List<Long> employeeIds) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class);
List<List<Long>> partition = Lists.partition(employeeIds, 1000);
List<InsuranceArchivesFundSchemePO> allList = new ArrayList<>();
for (List<Long> longs : partition) {
List<InsuranceArchivesFundSchemePO> fundList = fundSchemeMapper.getFundByEmployeeId(longs);
allList.addAll(fundList);
}
return allList;
} finally {
sqlSession.close();
}
}
public List<InsuranceArchivesOtherSchemePO> getOtherByEmployeeIds(List<Long> employeeIds) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class);
List<List<Long>> partition = Lists.partition(employeeIds, 1000);
List<InsuranceArchivesOtherSchemePO> allList = new ArrayList<>();
for (List<Long> longs : partition) {
List<InsuranceArchivesOtherSchemePO> otherList = otherSchemeMapper.getOtherByEmployeeId(longs);
allList.addAll(otherList);
}
return allList;
} finally {
sqlSession.close();
}
}
/**
* 根据人员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);
2022-11-03 13:22:15 +08:00
if (socialList.size() > 0) {
allList.add(socialList.get(0));
}
}
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);
2022-11-03 13:22:15 +08:00
if (fundList.size() > 0) {
allList.add(fundList.get(0));
}
}
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);
2022-11-03 13:22:15 +08:00
if (otherList.size() > 0) {
allList.add(otherList.get(0));
}
}
return allList;
} finally {
sqlSession.close();
}
}
2022-03-15 17:39:19 +08:00
/**
* 新增
2022-06-06 16:55:02 +08:00
*
* @param param
* @param employeeId
*/
public void insert(InsuranceArchivesSaveParam param, long employeeId) {
SalaryAssert.notNull(param.getWelfareType(), "福利类型为空");
switch (param.getWelfareType()) {
case SOCIAL_SECURITY:
socialSave(param, employeeId);
break;
case ACCUMULATION_FUND:
2022-03-17 15:26:33 +08:00
fundSave(param, employeeId);
break;
case OTHER:
2022-03-17 15:26:33 +08:00
otherSave(param, employeeId);
break;
default:
throw new SalaryRunTimeException("福利类型不存在");
}
}
2022-03-17 15:26:33 +08:00
/**
* @param paramReq
* @param employeeId
*/
public void otherSave(InsuranceArchivesSaveParam paramReq, long employeeId) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class);
InsuranceArchivesOtherSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesOtherSaveParam.class);
2022-06-06 16:55:02 +08:00
SalaryAssert.notNull("员工id为空", param, param.getEmployeeId());
if (StringUtils.isNotBlank(param.getOtherStartTime()) && !SalaryDateUtil.checkYearMonth(param.getOtherStartTime())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(542532, "其他福利起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd"));
}
if (StringUtils.isNotBlank(param.getOtherEndTime()) && !SalaryDateUtil.checkYearMonth(param.getOtherEndTime())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(542533, "其他福利最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd"));
}
List<Long> otherIds = new ArrayList();
otherIds.add(param.getId());
List<InsuranceArchivesOtherSchemePO> oldOtherInfoList = otherSchemeMapper.getOtherById(otherIds);
if (oldOtherInfoList.size() == 1) {
InsuranceArchivesOtherSchemePO oldOtherInfo = oldOtherInfoList.get(0);
InsuranceArchivesOtherSchemePO updateOtherInfo =
InsuranceArchivesOtherSchemePO.builder()
.id(oldOtherInfo.getId())
.otherSchemeId(param.getOtherSchemeId())
.otherStartTime(StringUtils.isNotBlank(param.getOtherStartTime()) ? param.getOtherStartTime() : null)
.underTake(param.getUnderTake())
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.welfareType(paramReq.getWelfareType().getValue())
.otherEndTime(StringUtils.isNotBlank(param.getOtherEndTime()) ? param.getOtherEndTime() : null)
.employeeId(param.getEmployeeId())
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
.updateTime(new Date())
.nonPayment(param.getNonPayment())
.creator(employeeId)
.paymentOrganization(param.getPaymentOrganization())
.otherPaymentBaseString(paramReq.getPaymentForm())
.build();
//校验福利基数是否符合上下限要求,
if (!checkWelBaseLimit(updateOtherInfo.getOtherSchemeId(),updateOtherInfo.getOtherPaymentBaseString())) {
throw new SalaryRunTimeException("其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!");
}
encryptUtil.encrypt(updateOtherInfo, InsuranceArchivesOtherSchemePO.class);
otherSchemeMapper.updateById(updateOtherInfo);
//更新base_info表状态
InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId());
if(baseInfoPO != null && baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) {
//对于非系统人员,编辑后状态切换为正在缴纳
baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue());
getInsuranceBaseInfoMapper().updateById(baseInfoPO);
}
sqlSession.commit();
} else {
otherSchemeMapper.deleteByEmployeeIdAndPayOrg(InsuranceArchivesOtherSchemePO.builder()
.employeeId(param.getEmployeeId())
.paymentOrganization(param.getPaymentOrganization())
.build());
//新建社保档案,并关联主表
InsuranceArchivesOtherSchemePO insertOtherInfo = InsuranceArchivesOtherSchemePO.builder()
.otherSchemeId(param.getOtherSchemeId())
.otherStartTime(StringUtils.isNotBlank(param.getOtherStartTime()) ? param.getOtherStartTime() : null)
.underTake(param.getUnderTake())
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.welfareType(paramReq.getWelfareType().getValue())
.otherEndTime(StringUtils.isNotBlank(param.getOtherEndTime()) ? param.getOtherEndTime() : null)
.employeeId(param.getEmployeeId())
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
.createTime(new Date())
.updateTime(new Date())
.nonPayment(param.getNonPayment())
.creator(employeeId)
.paymentOrganization(param.getPaymentOrganization())
.otherPaymentBaseString(paramReq.getPaymentForm())
.build();
//校验福利基数是否符合上下限要求,
if (!checkWelBaseLimit(insertOtherInfo.getOtherSchemeId(),insertOtherInfo.getOtherPaymentBaseString())) {
throw new SalaryRunTimeException("其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!");
}
encryptUtil.encrypt(insertOtherInfo, InsuranceArchivesOtherSchemePO.class);
otherSchemeMapper.insert(insertOtherInfo);
sqlSession.commit();
InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId());
if(baseInfoPO != null) {
List<InsuranceArchivesOtherSchemePO> otherInfos = otherSchemeMapper.getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder()
.employeeId(param.getEmployeeId())
.paymentOrganization(param.getPaymentOrganization())
.build());
baseInfoPO.setOtherArchivesId(otherInfos.get(0).getId());
//对于非系统人员,编辑后状态切换为正在缴纳
if (baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) {
baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue());
}
getInsuranceBaseInfoMapper().updateById(baseInfoPO);
} else {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "档案不存在!"));
}
}
2022-06-06 16:55:02 +08:00
} finally {
2022-03-17 15:26:33 +08:00
sqlSession.close();
}
}
/**
* @param paramReq
* @param employeeId
*/
public void fundSave(InsuranceArchivesSaveParam paramReq, long employeeId) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class);
InsuranceArchivesFundSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesFundSaveParam.class);
SalaryAssert.notNull("员工id为空", param, param.getEmployeeId());
if (StringUtils.isNotBlank(param.getFundStartTime()) && !SalaryDateUtil.checkYearMonth(param.getFundStartTime())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(542530, "公积金起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd"));
}
if (StringUtils.isNotBlank(param.getFundEndTime()) && !SalaryDateUtil.checkYearMonth(param.getFundEndTime())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(542531, "公积金最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd"));
}
List<Long> fundIds = new ArrayList();
fundIds.add(param.getId());
List<InsuranceArchivesFundSchemePO> oldFundInfoList = fundSchemeMapper.getFundById(fundIds);
if (oldFundInfoList.size() == 1) {
InsuranceArchivesFundSchemePO oldFundInfo = oldFundInfoList.get(0);
InsuranceArchivesFundSchemePO updateFundInfo = InsuranceArchivesFundSchemePO.builder()
.id(oldFundInfo.getId())
.fundSchemeId(param.getFundSchemeId())
.fundAccount(param.getFundAccount())
.fundEndTime(StringUtils.isNotBlank(param.getFundEndTime()) ? param.getFundEndTime() : null)
.fundStartTime(StringUtils.isNotBlank(param.getFundStartTime()) ? param.getFundStartTime() : null)
.fundPaymentBaseString(paramReq.getPaymentForm())
.supplementFundAccount(param.getSupplementFundAccount())
.creator(employeeId)
.nonPayment(param.getNonPayment())
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.underTake(param.getUnderTake())
.paymentOrganization(param.getPaymentOrganization())
.updateTime(new Date())
.welfareType(paramReq.getWelfareType().getValue())
.employeeId(param.getEmployeeId())
.build();
//校验福利基数是否符合上下限要求,
if (!checkWelBaseLimit(updateFundInfo.getFundSchemeId(),updateFundInfo.getFundPaymentBaseString())) {
throw new SalaryRunTimeException("公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!");
}
encryptUtil.encrypt(updateFundInfo, InsuranceArchivesFundSchemePO.class);
fundSchemeMapper.updateById(updateFundInfo);
//更新base_info表状态
InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId());
if(baseInfoPO != null && baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) {
//对于非系统人员,编辑后状态切换为正在缴纳
baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue());
getInsuranceBaseInfoMapper().updateById(baseInfoPO);
}
sqlSession.commit();
} else {
fundSchemeMapper.deleteByEmployeeIdAndPayOrg(InsuranceArchivesFundSchemePO.builder()
.employeeId(param.getEmployeeId())
.paymentOrganization(param.getPaymentOrganization())
.build());
//新建社保档案,并关联主表
InsuranceArchivesFundSchemePO insertFundInfo = InsuranceArchivesFundSchemePO.builder()
.fundSchemeId(param.getFundSchemeId())
.fundAccount(param.getFundAccount())
.fundEndTime(StringUtils.isNotBlank(param.getFundEndTime()) ? param.getFundEndTime() : null)
.fundStartTime(StringUtils.isNotBlank(param.getFundStartTime()) ? param.getFundStartTime() : null)
.fundPaymentBaseString(paramReq.getPaymentForm())
.supplementFundAccount(param.getSupplementFundAccount())
.creator(employeeId)
.nonPayment(param.getNonPayment())
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.underTake(param.getUnderTake())
.paymentOrganization(param.getPaymentOrganization())
.createTime(new Date())
.updateTime(new Date())
.welfareType(paramReq.getWelfareType().getValue())
.employeeId(param.getEmployeeId())
.build();
//校验福利基数是否符合上下限要求,
if (!checkWelBaseLimit(insertFundInfo.getFundSchemeId(),insertFundInfo.getFundPaymentBaseString())) {
throw new SalaryRunTimeException("公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!");
}
encryptUtil.encrypt(insertFundInfo, InsuranceArchivesFundSchemePO.class);
fundSchemeMapper.insert(insertFundInfo);
sqlSession.commit();
InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId());
if(baseInfoPO != null) {
List<InsuranceArchivesFundSchemePO> fundInfos = fundSchemeMapper.getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder()
.employeeId(param.getEmployeeId())
.paymentOrganization(param.getPaymentOrganization())
.build());
baseInfoPO.setFundArchivesId(fundInfos.get(0).getId());
//对于非系统人员,编辑后状态切换为正在缴纳
if (baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) {
baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue());
}
getInsuranceBaseInfoMapper().updateById(baseInfoPO);
} else {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "档案不存在!"));
}
}
2022-06-06 16:55:02 +08:00
} finally {
2022-03-17 15:26:33 +08:00
sqlSession.close();
}
}
/**
* @param paramReq
* @param employeeId
*/
public void socialSave(InsuranceArchivesSaveParam paramReq, long employeeId) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class);
InsuranceArchivesSocialSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesSocialSaveParam.class);
SalaryAssert.notNull("员工id为空", param, param.getEmployeeId());
if (StringUtils.isNotBlank(param.getSocialStartTime()) && !SalaryDateUtil.checkYearMonth(param.getSocialStartTime())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(542528, "社保起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd"));
}
if (StringUtils.isNotBlank(param.getSocialEndTime()) && !SalaryDateUtil.checkYearMonth(param.getSocialEndTime())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(542529, "社保最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd"));
}
// //删除社保数据
// socialSchemeMapper.batchDeleteByEmployeeIds(Collections.singletonList(param.getEmployeeId()));
//查询已有数据
List<Long> socialIds = new ArrayList();
socialIds.add(param.getId());
List<InsuranceArchivesSocialSchemePO> oldSocialInfoList = socialSchemeMapper.getSocialById(socialIds);
//组装新数据
if (oldSocialInfoList.size() == 1) {
InsuranceArchivesSocialSchemePO oldSocialInfo = oldSocialInfoList.get(0);
InsuranceArchivesSocialSchemePO updateSocialInfo =
InsuranceArchivesSocialSchemePO.builder()
.id(oldSocialInfo.getId())
.welfareType(paramReq.getWelfareType().getValue())
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
.socialPaymentBaseString(paramReq.getPaymentForm())
.socialSchemeId(param.getSocialSchemeId())
.socialEndTime(StringUtils.isNotBlank(param.getSocialEndTime()) ? param.getSocialEndTime() : null)
.socialStartTime(StringUtils.isNotBlank(param.getSocialStartTime()) ? param.getSocialStartTime() : null)
.creator(employeeId)
.nonPayment(param.getNonPayment())
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.employeeId(param.getEmployeeId())
.updateTime(new Date())
.underTake(param.getUnderTake())
.socialAccount(param.getSchemeAccount())
.paymentOrganization(param.getPaymentOrganization())
.build();
//校验福利基数是否符合上下限要求
if (!checkWelBaseLimit(updateSocialInfo.getSocialSchemeId(),updateSocialInfo.getSocialPaymentBaseString())) {
throw new SalaryRunTimeException("社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!");
}
encryptUtil.encrypt(updateSocialInfo, InsuranceArchivesSocialSchemePO.class);
socialSchemeMapper.updateById(updateSocialInfo);
//更新base_info表状态
InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId());
if(baseInfoPO != null && baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) {
//对于非系统人员,编辑后状态切换为正在缴纳
baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue());
getInsuranceBaseInfoMapper().updateById(baseInfoPO);
}
sqlSession.commit();
} else {
socialSchemeMapper.deleteByEmployeeIdAndPayOrg(InsuranceArchivesSocialSchemePO.builder()
.employeeId(param.getEmployeeId())
.paymentOrganization(param.getPaymentOrganization())
.build());
//新建社保档案,并关联主表
InsuranceArchivesSocialSchemePO insertSocialInfo =
InsuranceArchivesSocialSchemePO.builder()
.welfareType(paramReq.getWelfareType().getValue())
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
.socialPaymentBaseString(paramReq.getPaymentForm())
.socialSchemeId(param.getSocialSchemeId())
.socialEndTime(StringUtils.isNotBlank(param.getSocialEndTime()) ? param.getSocialEndTime() : null)
.socialStartTime(StringUtils.isNotBlank(param.getSocialStartTime()) ? param.getSocialStartTime() : null)
.creator(employeeId)
.nonPayment(param.getNonPayment())
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.employeeId(param.getEmployeeId())
.createTime(new Date())
.updateTime(new Date())
.underTake(param.getUnderTake())
.socialAccount(param.getSchemeAccount())
.paymentOrganization(param.getPaymentOrganization())
.build();
//校验福利基数是否符合上下限要求
if (!checkWelBaseLimit(insertSocialInfo.getSocialSchemeId(),insertSocialInfo.getSocialPaymentBaseString())) {
throw new SalaryRunTimeException("社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!");
}
encryptUtil.encrypt(insertSocialInfo, InsuranceArchivesSocialSchemePO.class);
socialSchemeMapper.insert(insertSocialInfo);
sqlSession.commit();
InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId());
if(baseInfoPO != null) {
List<InsuranceArchivesSocialSchemePO> socialInfos = socialSchemeMapper.getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder()
.employeeId(param.getEmployeeId())
.paymentOrganization(param.getPaymentOrganization())
.build());
baseInfoPO.setSocialArchivesId(socialInfos.get(0).getId());
//对于非系统人员,编辑后状态切换为正在缴纳
if (baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) {
baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue());
}
getInsuranceBaseInfoMapper().updateById(baseInfoPO);
} else {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "档案不存在!"));
}
}
2022-06-06 16:55:02 +08:00
} finally {
sqlSession.close();
}
}
2022-03-18 18:00:51 +08:00
/**
* 校验福利基数是否符合上下限要求
* @param primaryId
* @param paymentBaseString
* @return
*/
public Boolean checkWelBaseLimit(Long primaryId, String paymentBaseString) {
if (primaryId ==null || paymentBaseString == null) {
return true;
}
//设置缴纳对象和缴费状态
2022-11-03 21:04:47 +08:00
// Integer paymentScope = 2;
// Integer isPayment = 1;
Map<String, String> paymentBaseJson = JSON.parseObject(paymentBaseString, new HashMap<String, String>().getClass());
if (paymentBaseJson == null) {
return true;
}
for (Map.Entry<String, String> entry : paymentBaseJson.entrySet()) {
//判断福利值是否为空/数字
if (entry.getValue() == null || entry.getValue().length() == 0) {
continue;
} else if (!isNumeric(entry.getValue())) {
2022-11-03 13:32:31 +08:00
log.info("福利值非数字!");
return false;
}
//根据福利方案id、险种id、缴纳对象、缴费状态查询明细
2022-11-03 21:04:47 +08:00
List<InsuranceSchemeDetailPO> insuranceSchemeDetailPOList = getInsuranceSchemeDetailMapper().getByPI(primaryId, Long.valueOf(entry.getKey()));
log.info("福利方案id: {},, 福利明细项id{}", primaryId, Long.valueOf(entry.getKey()));
if (insuranceSchemeDetailPOList.size() == 0) {
log.info("根据福利方案id、险种id、缴纳对象查询明细为null福利方案id: {}, 福利明细项id{}", primaryId, Long.valueOf(entry.getKey()));
return false;
}
List<InsuranceSchemeDetailPO> isPaymentList = insuranceSchemeDetailPOList.stream()
.filter(f -> f.getIsPayment().equals(IsPaymentEnum.YES.getValue()) && f.getPaymentScope().equals(PaymentScopeEnum.SCOPE_PERSON.getValue())).collect(Collectors.toList());
if (isPaymentList.size() > 0) {
InsuranceSchemeDetailPO insuranceSchemeDetailPO = isPaymentList.get(0);
encryptUtil.decrypt(insuranceSchemeDetailPO, InsuranceSchemeDetailPO.class);
String lowerLimit = "0.000".equals(insuranceSchemeDetailPO.getLowerLimit()) ? null : insuranceSchemeDetailPO.getLowerLimit();
String upperLimit = "0.000".equals(insuranceSchemeDetailPO.getUpperLimit()) ? null : insuranceSchemeDetailPO.getUpperLimit();
if (lowerLimit != null && lowerLimit.length() > 0 && Double.parseDouble(entry.getValue()) < Double.parseDouble(lowerLimit)) {
//数值低于对应福利明细下限
log.info("社保基数 {} 数值 {} 低于对应福利明细下限 {}", entry.getKey(), entry.getValue(), lowerLimit);
return false;
}
if (upperLimit != null && upperLimit.length() > 0 && Double.parseDouble(entry.getValue()) > Double.parseDouble(upperLimit)) {
//数值高于对应福利明细上限
log.info("社保基数 {} 数值 {} 高于对应福利明细上限 {} ", entry.getKey(), entry.getValue(), upperLimit);
return false;
}
} else {
log.info("福利明细项属于未缴费状态,不对上下限进行约束");
}
}
return true;
}
2022-03-18 18:00:51 +08:00
/**
* 档案列表
* <p>
* 这里是一个含有比较多动态字段的列表用的是手动拼装的方式
2022-06-06 16:55:02 +08:00
*
* @param param 高级搜索条件
2022-03-18 18:00:51 +08:00
* @param operateId 操作员id
* @return table
*/
public Map<String, Object> listPage(InsuranceArchivesListParam param, long operateId) {
Map<String, Object> apidatas = new HashMap<>(16);
InsuranceArchivesListParam request = InsuranceArchivesListParam.builder().build();
if (param.getHireDate() != null && param.getHireDate().length == 2) {
param.setHiredateStart(param.getHireDate()[0]);
param.setHiredateEnd(param.getHireDate()[1]);
}
if (param.getDimissionDate() != null && param.getDimissionDate().length == 2) {
param.setDimissionDateStart(param.getDimissionDate()[0]);
param.setDimissionDateEnd(param.getDimissionDate()[1]);
}
2022-06-01 14:53:16 +08:00
2022-06-06 16:55:02 +08:00
if (StringUtils.isNotBlank(param.getDepartmentIdsStr())) {
2022-06-01 14:53:16 +08:00
request.setDepartmentIds(Arrays.stream(param.getDepartmentIdsStr().split(",")).map(BigDecimal::new).collect(Collectors.toList()));
}
if (StringUtils.isNotBlank(param.getSubcompanyIdsStr())) {
request.setSubcompanyIds(Arrays.stream(param.getSubcompanyIdsStr().split(",")).map(BigDecimal::new).collect(Collectors.toList()));
}
2022-06-06 16:55:02 +08:00
if (StringUtils.isNotBlank(param.getPositionsStr())) {
2022-08-11 10:27:15 +08:00
request.setPositions(Arrays.stream(param.getPositionsStr().split(",")).map(BigDecimal::new).collect(Collectors.toList()));
2022-06-01 14:53:16 +08:00
}
if (StringUtils.isNotBlank(param.getStatusesStr())) {
request.setStatuses(Arrays.stream(param.getStatusesStr().split(",")).map(String::new).collect(Collectors.toList()));
}
2022-06-06 16:55:02 +08:00
request.setNeedAuth(param.getNeedAuth());
request.setTaxAgentEmployeeIds(param.getTaxAgentEmployeeIds());
request.setTaxAgentIds(param.getTaxAgentIds());
2022-06-06 16:55:02 +08:00
2022-03-21 16:13:08 +08:00
Integer current = param.getCurrent() == null ? 1 : param.getCurrent();
Integer pageSize = param.getPageSize() == null ? 10 : param.getPageSize();
2022-03-18 18:00:51 +08:00
long startNum = (current - 1) * pageSize;
param.setStartNum(startNum);
param.setPageSize(pageSize);
// request.setStatuses(param.getStatuses());
2022-08-11 10:27:15 +08:00
request.setKeyword(param.getUserName());
request.setSiSchemeId(param.getSiSchemeId());
request.setFundSchemeId(param.getFundSchemeId());
request.setOtherSchemeId(param.getOtherSchemeId());
2022-03-18 18:00:51 +08:00
2022-08-16 15:49:15 +08:00
request.setPageSize(param.getPageSize());
request.setCurrent(param.getCurrent());
request.setJobNum(param.getJobNum());
2022-09-26 18:51:17 +08:00
request.setOrderRule(param.getOrderRule());
request.setRunStatuses(param.getRunStatuses());
request.setTaxAgentId(param.getTaxAgentId());
request.setExtWelArchiveList(param.isExtWelArchiveList());
2022-03-18 18:00:51 +08:00
apidatas = listPageEmployeePOS(request, operateId);
return apidatas;
}
/**
* 获取员工的基本信息
* <p>
* 此处主要是一个公共接口有多处引用我们薪资系统只保存员工idemployeeId
* 但是页面上需要展示员工的更多信息姓名部门状态
* 所以这里主要是用于接收联表数据的一个接口
*
2022-06-06 16:55:02 +08:00
* @param param 高级搜索条件用于过滤数据
2022-03-18 18:00:51 +08:00
* @param operateId 操作员id
* @return list
*/
public Map<String, Object> listPageEmployeePOS(InsuranceArchivesListParam param, long operateId) {
2022-06-06 16:55:02 +08:00
//是否分权
Boolean needAuth = param.getNeedAuth();
2022-11-03 11:14:59 +08:00
StopWatch sw = new StopWatch();
2022-03-18 18:00:51 +08:00
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
Map<String, Object> datas = new HashMap<>(16);
try {
SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class);
2022-06-06 16:55:02 +08:00
List<InsuranceArchivesEmployeePO> page = new ArrayList<>();
PageInfo<InsuranceArchivesEmployeePO> pageInfo = new PageInfo<>(InsuranceArchivesEmployeePO.class);
// //生成福利档案历史基础信息(在福利档案基础信息表为空时)
// createOldInsuranceBaseInfo(operateId);
//获取福利档案列表数据
2022-06-06 16:55:02 +08:00
if (needAuth) {
Collection<Long> taxAgentEmployeeIds = param.getTaxAgentEmployeeIds();
Collection<Long> taxAgentIds = param.getTaxAgentIds();
2022-11-03 13:22:15 +08:00
log.info("从数据库获取档案列表数据开始");
2022-11-03 11:14:59 +08:00
sw.start("获取福利档案列表数据");
if (param.isExtWelArchiveList()) {
page = socialSchemeMapper.queryExtEmployeeList(param);
} else {
page = socialSchemeMapper.queryEmployeeList(param);
}
2022-11-03 11:14:59 +08:00
sw.stop();
2022-11-03 13:22:15 +08:00
log.info("从数据库获取档案列表数据完成!");
2022-06-06 16:55:02 +08:00
page = page.stream().filter(f ->
// taxAgentEmployeeIds.contains(f.getEmployeeId())||
2022-08-04 16:17:05 +08:00
taxAgentIds.contains(f.getPaymentOrganization())
2022-06-06 16:55:02 +08:00
).collect(Collectors.toList());
2022-11-03 11:14:59 +08:00
2022-06-06 16:55:02 +08:00
// 填充总数和当页数据
// 分页参数
pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), InsuranceArchivesEmployeePO.class);
pageInfo.setTotal(page.size());
pageInfo.setList(SalaryPageUtil.subList(pageInfo.getPageNum(), pageInfo.getPageSize(), page));
} else {
2022-11-03 13:22:15 +08:00
log.info("从数据库获取档案列表数据开始");
2022-11-03 11:14:59 +08:00
sw.start("获取档案列表数据");
if (param.isExtWelArchiveList()) {
page = socialSchemeMapper.queryExtEmployeeList(param);
} else {
page = socialSchemeMapper.queryEmployeeList(param);
}
2022-11-03 11:14:59 +08:00
sw.stop();
2022-11-03 13:22:15 +08:00
log.info("从数据库获取档案列表数据完成!");
2022-12-12 10:25:55 +08:00
pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(),
page, InsuranceArchivesEmployeePO.class);
2022-06-06 16:55:02 +08:00
}
2022-07-29 17:18:38 +08:00
List<Map<String, Object>> records = null;
2022-11-03 13:22:15 +08:00
log.info("buildTableData方法处理福利档案列表数据开始");
2022-11-03 11:14:59 +08:00
sw.start("buildTableData方法处理福利档案列表数据");
2022-08-04 16:17:05 +08:00
if (param.getExportData() != null && param.getExportData()) {
records = buildTableData(pageInfo.getList(), true);
2022-08-04 16:17:05 +08:00
} else {
records = buildTableData(pageInfo.getList(), false);
2022-07-29 17:18:38 +08:00
}
2022-11-03 11:14:59 +08:00
sw.stop();
2022-11-03 13:22:15 +08:00
log.info("buildTableData方法处理福利档案列表数据完成");
log.info("buildWeaTableColumns方法处理福利档案列表数据开始");
2022-11-03 11:14:59 +08:00
sw.start("buildWeaTableColumns方法处理福利档案列表数据");
2023-03-30 22:52:52 +08:00
List<WeaTableColumn> columns = buildWeaTableColumns(pageInfo.getList(), operateId);
2022-11-03 11:14:59 +08:00
sw.stop();
2022-11-03 13:22:15 +08:00
log.info("buildWeaTableColumns方法处理福利档案列表数据完成");
2022-03-22 19:47:46 +08:00
WeaTable table = new WeaTable();
table.setColumns(columns);
//设置check是否可用
List<WeaTableCheckboxpopedom> checkboxpopedomList = new ArrayList<>();
WeaTableCheckboxpopedom checkboxpopedom = new WeaTableCheckboxpopedom();
checkboxpopedom.setPopedompara("column:system_type");
checkboxpopedom.setShowmethod("com.engine.salary.transmethod.TaxRateTransMethod.getCheckBoxPopedom");
checkboxpopedomList.add(checkboxpopedom);
table.setCheckboxList(checkboxpopedomList);
table.setCheckboxpopedom(null);
WeaResultMsg result = new WeaResultMsg(false);
result.putAll(table.makeDataResult());
result.success();
2022-03-18 18:00:51 +08:00
datas.put("pageInfo", pageInfo);
2022-06-06 16:55:02 +08:00
datas.put("datas", records);
datas.put("columns", columns);
datas.put("dataKey", result.getResultMap());
2022-11-03 11:14:59 +08:00
log.info("各操作计时 {}", sw.prettyPrint());
2022-03-18 18:00:51 +08:00
return datas;
2022-06-06 16:55:02 +08:00
} finally {
2022-03-18 18:00:51 +08:00
sqlSession.close();
}
}
/**
* @param
* @param operateId
* @return
*/
2022-04-16 16:43:33 +08:00
public List<WeaTableColumn> buildWeaTableColumns(List<InsuranceArchivesEmployeePO> insuranceArchivesEmployeePOS, long operateId) {
2022-03-18 18:00:51 +08:00
Map<Integer, Map<String, String>> titleMap = buildColumnTitle(insuranceArchivesEmployeePOS, operateId);
List<WeaTableColumn> list = new ArrayList<>();
2022-06-06 16:55:02 +08:00
WeaTableColumn nameColumn = new WeaTableColumn("100px", "姓名", "employeeName");
2022-03-18 18:00:51 +08:00
nameColumn.setFixed("left");
list.add(nameColumn);
list.add(new WeaTableColumn("150px", "个税扣缴义务人", "paymentOrganizationName"));
list.add(new WeaTableColumn("150px", "分部", "subcompanyName"));
2022-06-06 16:55:02 +08:00
list.add(new WeaTableColumn("150px", "部门", "departmentName"));
list.add(new WeaTableColumn("150px", "手机号", "mobile"));
list.add(new WeaTableColumn("150px", "员工状态", "status"));
list.add(new WeaTableColumn("150px", "工号", "jobNum"));
list.add(new WeaTableColumn("150px", "入职日期", "companystartdate"));
// list.add(new WeaTableColumn("150px", "合同到期日期", "dismissdate"));
2022-06-06 16:55:02 +08:00
list.add(new WeaTableColumn("150px", "社保方案名称", "socialName"));
2022-03-31 13:41:40 +08:00
titleMap.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> list.add(new WeaTableColumn("150px", v, k)));
2022-06-06 16:55:02 +08:00
list.add(new WeaTableColumn("150px", "社保账号", "socialAccount"));
list.add(new WeaTableColumn("150px", "社保起始缴纳月", "socialStartTime"));
list.add(new WeaTableColumn("150px", "社保最后缴纳月", "socialEndTime"));
list.add(new WeaTableColumn("150px", "公积金方案名称", "fundName"));
list.add(new WeaTableColumn("150px", "公积金账号", "fundAccount"));
titleMap.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> list.add(new WeaTableColumn("150px", v, k)));
list.add(new WeaTableColumn("150px", "补充公积金账号", "supplementFundAccount"));
list.add(new WeaTableColumn("150px", "公积金起始缴纳月", "fundStartTime"));
list.add(new WeaTableColumn("150px", "公积金最后缴纳月", "fundEndTime"));
list.add(new WeaTableColumn("150px", "其他福利方案名称", "otherName"));
2022-03-31 13:41:40 +08:00
titleMap.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> list.add(new WeaTableColumn("150px", v, k)));
2022-06-06 16:55:02 +08:00
list.add(new WeaTableColumn("150px", "其他福利起始缴纳月", "otherStartTime"));
list.add(new WeaTableColumn("150px", "其他福利最后缴纳月", "otherEndTime"));
2022-03-18 18:00:51 +08:00
return list;
}
/**
* @param insuranceArchivesEmployeePOS
* @param operateId
* @return
*/
public Map<Integer, Map<String, String>> buildColumnTitle(List<InsuranceArchivesEmployeePO> insuranceArchivesEmployeePOS, long operateId) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
Map<Integer, Map<String, String>> result = new HashMap<>();
insuranceArchivesEmployeePOS = insuranceArchivesEmployeePOS.stream().filter(f -> f.getEmployeeId() != null).collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(InsuranceArchivesEmployeePO::getEmployeeId))), ArrayList::new));
2022-03-18 18:00:51 +08:00
try {
2022-03-21 16:13:08 +08:00
2022-03-18 18:00:51 +08:00
SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class);
FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class);
OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class);
ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class);
Set<String> socialSet = new HashSet<>();
Set<String> fundSet = new HashSet<>();
Set<String> otherSet = new HashSet<>();
2022-03-18 18:00:51 +08:00
insuranceArchivesEmployeePOS.forEach(item -> {
2022-03-21 16:13:08 +08:00
List<InsuranceArchivesSocialSchemePO> socialList = socialSchemeMapper.getSocialByEmployeeId(Collections.singletonList(item.getEmployeeId()));
encryptUtil.decryptList(socialList, InsuranceArchivesSocialSchemePO.class);
// InsuranceArchivesSocialSchemePO socialItem = socialList.size() != 0 ? socialList.get(0) : null;
2022-03-21 16:13:08 +08:00
List<InsuranceArchivesFundSchemePO> fundList = fundSchemeMapper.getFundByEmployeeId(Collections.singletonList(item.getEmployeeId()));
encryptUtil.decryptList(fundList, InsuranceArchivesFundSchemePO.class);
// InsuranceArchivesFundSchemePO fundItem = fundList.size() != 0 ? fundList.get(0) : null;
2022-03-21 16:13:08 +08:00
List<InsuranceArchivesOtherSchemePO> otherList = otherSchemeMapper.getOtherByEmployeeId(Collections.singletonList(item.getEmployeeId()));
encryptUtil.decryptList(otherList, InsuranceArchivesOtherSchemePO.class);
// InsuranceArchivesOtherSchemePO otherItem = otherList.size() != 0 ? otherList.get(0) : null;
if (socialList.size() > 0) {
for (InsuranceArchivesSocialSchemePO socialSchemePO : socialList) {
Map<String, Object> socialJson = JSON.parseObject(socialSchemePO.getSocialPaymentBaseString(), new TypeReference<Map<String, Object>>() {
});
if (socialJson != null) {
socialJson.forEach((k, v) -> socialSet.add(k));
}
2022-03-18 18:00:51 +08:00
}
2022-03-18 18:00:51 +08:00
}
if (fundList.size() > 0) {
for (InsuranceArchivesFundSchemePO fundSchemePO : fundList) {
Map<String, Object> fundJson = JSON.parseObject(fundSchemePO.getFundPaymentBaseString(), new TypeReference<Map<String, Object>>() {
});
if (fundJson != null) {
fundJson.forEach((k, v) -> fundSet.add(k));
}
2022-03-18 18:00:51 +08:00
}
2022-03-18 18:00:51 +08:00
}
if (otherList.size() > 0) {
for (InsuranceArchivesOtherSchemePO otherSchemePO : otherList) {
Map<String, Object> otherJson = JSON.parseObject(otherSchemePO.getOtherPaymentBaseString(), new TypeReference<Map<String, Object>>() {
});
if (otherJson != null) {
otherJson.forEach((k, v) -> otherSet.add(k));
}
2022-03-18 18:00:51 +08:00
}
2022-03-18 18:00:51 +08:00
}
});
Map<String, String> socialMap = new HashMap<>();
Map<Long, ICategoryPO> socialCollect = new HashMap<>();
2022-06-06 16:55:02 +08:00
Map<Long, ICategoryPO> customSocial = iCategoryMapper.listByWelfareType(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), null)
2022-03-18 18:00:51 +08:00
.stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity()));
2022-06-06 16:55:02 +08:00
Map<Long, ICategoryPO> sysSocial = iCategoryMapper.listByWelfareType(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), DataTypeEnum.SYSTEM.getValue())
2022-03-18 18:00:51 +08:00
.stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity()));
socialCollect.putAll(customSocial);
socialCollect.putAll(sysSocial);
socialSet.forEach(item -> {
if (socialCollect.containsKey(Long.valueOf(item))) {
2022-06-06 16:55:02 +08:00
socialMap.put(item, socialCollect.get(Long.valueOf(item)).getInsuranceName() + "申报基数");
2022-03-18 18:00:51 +08:00
}
});
Map<String, String> fundMap = new HashMap<>();
Map<Long, ICategoryPO> fundCollect = new HashMap<>();
2022-06-06 16:55:02 +08:00
Map<Long, ICategoryPO> customFund = iCategoryMapper.listByWelfareType(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), null).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity()));
Map<Long, ICategoryPO> sysFund = iCategoryMapper.listByWelfareType(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), DataTypeEnum.SYSTEM.getValue()).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity()));
2022-03-18 18:00:51 +08:00
fundCollect.putAll(customFund);
fundCollect.putAll(sysFund);
fundSet.forEach(item -> {
if (fundCollect.containsKey(Long.valueOf(item))) {
fundMap.put(item, fundCollect.get(Long.valueOf(item)).getInsuranceName() + "申报基数");
}
});
Map<String, String> otherMap = new HashMap<>();
Map<Long, ICategoryPO> otherCollect = new HashMap<>();
2022-06-06 16:55:02 +08:00
Map<Long, ICategoryPO> customOther = iCategoryMapper.listByWelfareType(WelfareTypeEnum.OTHER.getValue(), null).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity()));
Map<Long, ICategoryPO> sysOther = iCategoryMapper.listByWelfareType(WelfareTypeEnum.OTHER.getValue(), DataTypeEnum.SYSTEM.getValue()).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity()));
2022-03-18 18:00:51 +08:00
otherCollect.putAll(customOther);
otherCollect.putAll(sysOther);
otherSet.forEach(item -> {
if (otherCollect.containsKey(Long.valueOf(item))) {
otherMap.put(item, otherCollect.get(Long.valueOf(item)).getInsuranceName() + "申报基数");
}
});
// map根据key排序
LinkedHashMap<String, String> socialMapWithAscKey = socialMap.entrySet().stream()
.sorted(Map.Entry.comparingByKey())
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue,
LinkedHashMap::new));
LinkedHashMap<String, String> fundMapWithAscKey = fundMap.entrySet().stream()
.sorted(Map.Entry.comparingByKey())
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue,
LinkedHashMap::new));
LinkedHashMap<String, String> otherMapWithAscKey = otherMap.entrySet().stream()
.sorted(Map.Entry.comparingByKey())
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue,
LinkedHashMap::new));
result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialMapWithAscKey);
result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundMapWithAscKey);
result.put(WelfareTypeEnum.OTHER.getValue(), otherMapWithAscKey);
2022-03-18 18:00:51 +08:00
return result;
2022-06-06 16:55:02 +08:00
} finally {
2022-03-18 18:00:51 +08:00
sqlSession.close();
}
}
2022-08-04 16:17:05 +08:00
public List<Map<String, Object>> buildTableData(List<InsuranceArchivesEmployeePO> insuranceArchivesEmployeePOS) {
return buildTableData(insuranceArchivesEmployeePOS, false);
2022-07-29 17:18:38 +08:00
}
2022-03-18 18:00:51 +08:00
/**
* @param insuranceArchivesEmployeePOS
* @return
*/
2022-08-04 16:17:05 +08:00
public List<Map<String, Object>> buildTableData(List<InsuranceArchivesEmployeePO> insuranceArchivesEmployeePOS, boolean export) {
List<TaxAgentPO> taxAgentPOS = getTaxAgentMapper().listAll();
Map<Long, TaxAgentPO> longTaxAgentPOMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId);
2022-03-18 18:00:51 +08:00
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
List<Map<String, Object>> records = new ArrayList<>();
try {
SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class);
FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class);
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 = encryptUtil.decryptList(this.getSocialByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS), InsuranceArchivesSocialSchemePO.class)
.stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getId, Function.identity()));
2022-03-18 18:00:51 +08:00
Map<Long, InsuranceArchivesFundSchemePO> fundSchemePOMap = encryptUtil.decryptList(this.getFundByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS), InsuranceArchivesFundSchemePO.class)
.stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getId, Function.identity()));
List<InsuranceArchivesOtherSchemePO> otherByEmployeeList = this.getOtherByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS);
encryptUtil.decryptList(otherByEmployeeList, InsuranceArchivesOtherSchemePO.class);
2022-05-31 16:02:41 +08:00
Map<Long, InsuranceArchivesOtherSchemePO> otherSchemePOMap = otherByEmployeeList
.stream().collect(Collectors.toMap(InsuranceArchivesOtherSchemePO::getId, Function.identity()));
2022-03-18 18:00:51 +08:00
insuranceArchivesEmployeePOS.forEach(item -> {
InsuranceArchivesSocialSchemePO socialItem = socialSchemePOMap.get(item.getSocialId());
InsuranceArchivesFundSchemePO fundItem = fundSchemePOMap.get(item.getFundId());
InsuranceArchivesOtherSchemePO otherItem = otherSchemePOMap.get(item.getOtherId());
2022-03-18 18:00:51 +08:00
Map<String, Object> map = new HashMap<>();
map.put("employeeName", item.getUserName());
map.put("paymentOrganizationName", longTaxAgentPOMap.get(item.getPaymentOrganization()) != null ? longTaxAgentPOMap.get(item.getPaymentOrganization()).getName() : "");
2022-03-18 18:00:51 +08:00
map.put("employeeId", item.getEmployeeId());
map.put("departmentName", item.getDepartmentName());
map.put("subcompanyName", item.getSubcompanyName());
2022-03-18 18:00:51 +08:00
map.put("departmentId", item.getDepartmentId());
map.put("jobNum", item.getJobNum());
map.put("companystartdate", item.getCompanystartdate());
map.put("dismissdate", item.getDimissionDate());
2022-03-18 18:00:51 +08:00
map.put("mobile", item.getTelephone());
2022-05-09 16:40:14 +08:00
map.put("siSchemeId", item.getSiSchemeId());
map.put("fundSchemeId", item.getFundSchemeId());
2022-06-06 16:55:02 +08:00
map.put("otherSchemeId", item.getOtherSchemeId());
map.put("status", item.getUserStatus() != null ? UserStatusEnum.getDefaultLabelByValue(item.getUserStatus()) : "");
map.put("baseInfo", item.getBaseInfoId());
map.put("paymentOrganization", item.getPaymentOrganization());
2022-03-18 18:00:51 +08:00
if (socialItem != null) {
map.put("socialName", insuranceSchemeMapper.querySchemeName(socialItem.getSocialSchemeId()));
Map<String, Object> socialJson = JSON.parseObject(socialItem.getSocialPaymentBaseString(), new TypeReference<Map<String, Object>>() {
});
if (socialJson != null) {
2022-08-04 16:17:05 +08:00
map.putAll(socialJson);
2022-03-18 18:00:51 +08:00
}
map.put("socialAccount", socialItem.getSocialAccount());
map.put("socialStartTime", socialItem.getSocialStartTime());
map.put("socialEndTime", socialItem.getSocialEndTime());
}
if (fundItem != null) {
map.put("fundName", insuranceSchemeMapper.querySchemeName(fundItem.getFundSchemeId()));
map.put("fundAccount", fundItem.getFundAccount());
Map<String, Object> fundJson = JSON.parseObject(fundItem.getFundPaymentBaseString(), new TypeReference<Map<String, Object>>() {
});
if (fundJson != null) {
2022-08-04 16:17:05 +08:00
map.putAll(fundJson);
2022-03-18 18:00:51 +08:00
}
map.put("supplementFundAccount", fundItem.getSupplementFundAccount());
map.put("fundStartTime", fundItem.getFundStartTime());
map.put("fundEndTime", fundItem.getFundEndTime());
}
if (otherItem != null) {
map.put("otherName", insuranceSchemeMapper.querySchemeName(otherItem.getOtherSchemeId()));
Map<String, Object> otherJson = JSON.parseObject(otherItem.getOtherPaymentBaseString(), new TypeReference<Map<String, Object>>() {
});
if (otherJson != null) {
2022-08-04 16:17:05 +08:00
map.putAll(otherJson);
2022-03-18 18:00:51 +08:00
}
map.put("otherStartTime", otherItem.getOtherStartTime());
map.put("otherEndTime", otherItem.getOtherEndTime());
}
records.add(map);
});
return records;
2022-06-06 16:55:02 +08:00
} finally {
2022-03-18 18:00:51 +08:00
sqlSession.close();
}
}
2022-03-22 19:47:46 +08:00
/**
* 获取信息提示
*/
public void tips() {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class);
List<Long> employeeIds = socialSchemeMapper.tips();
2022-06-06 16:55:02 +08:00
SalaryAssert.isEmpty(employeeIds, "当前有离职人员档案存在福利缴纳起始月,未维护福利最后缴纳月,请尽快处理");
2022-03-22 19:47:46 +08:00
2022-06-06 16:55:02 +08:00
} finally {
2022-03-22 19:47:46 +08:00
sqlSession.close();
}
}
/**
* 高级搜索
2022-06-06 16:55:02 +08:00
*
2022-03-22 19:47:46 +08:00
* @return
*/
public Map<String, Object> getSearchCondition(User user) {
2022-03-31 14:22:42 +08:00
List<SearchConditionOption> userStatusOptions = Arrays.stream(UserStatusEnum.values()).map(e -> new SearchConditionOption(String.valueOf(e.getValue()), e.getDefaultLabel())).collect(Collectors.toList());
2022-06-06 16:55:02 +08:00
List<InsuranceSchemePO> list = new SISchemeBiz().listAll();
2022-03-22 19:47:46 +08:00
2022-06-06 16:55:02 +08:00
List<SearchConditionOption> schemeOption = list.stream().filter(item -> Objects.equals(item.getWelfareType(), WelfareTypeEnum.SOCIAL_SECURITY.getValue()))
.collect(Collectors.toList())
.stream().map(item -> new SearchConditionOption(item.getId().toString(), item.getSchemeName())).collect(Collectors.toList());
2022-03-22 19:47:46 +08:00
2022-06-06 16:55:02 +08:00
List<SearchConditionOption> fundOption = list.stream().filter(item -> Objects.equals(item.getWelfareType(), WelfareTypeEnum.ACCUMULATION_FUND.getValue()))
.collect(Collectors.toList())
.stream().map(item -> new SearchConditionOption(item.getId().toString(), item.getSchemeName())).collect(Collectors.toList());
2022-03-22 19:47:46 +08:00
2022-06-06 16:55:02 +08:00
List<SearchConditionOption> otherOption = list.stream().filter(item -> Objects.equals(item.getWelfareType(), WelfareTypeEnum.OTHER.getValue()))
.collect(Collectors.toList())
.stream().map(item -> new SearchConditionOption(item.getId().toString(), item.getSchemeName())).collect(Collectors.toList());
2022-03-22 19:47:46 +08:00
List<Map<String, Object>> taxAgentList = getTaxAgentWrapper(user).selectListAsAdmin();
List<SearchConditionOption> taxAgentOption = taxAgentList.stream().map(item -> new SearchConditionOption(item.get("id").toString(), item.get("content").toString())).collect(Collectors.toList());
2022-03-22 19:47:46 +08:00
2022-03-31 14:22:42 +08:00
Map<String, Object> apidatas = new HashMap<String, Object>();
ConditionFactory conditionFactory = new ConditionFactory(user);
//条件组
List<SearchConditionGroup> addGroups = new ArrayList<SearchConditionGroup>();
List<SearchConditionItem> conditionItems = new ArrayList<SearchConditionItem>();
//文本输入框
2022-06-06 16:55:02 +08:00
SearchConditionItem username = conditionFactory.createCondition(ConditionType.INPUT, 25034, "username");
2022-05-18 18:53:30 +08:00
username.setInputType("input");
2022-03-31 14:22:42 +08:00
username.setColSpan(2);//定义一行显示条件数默认值为2,当值为1时标识该条件单独占一行
2022-06-06 16:55:02 +08:00
username.setFieldcol(16); //条件输入框所占宽度默认值18
2022-03-31 14:22:42 +08:00
username.setLabelcol(8);
username.setViewAttr(2); // 编辑权限 1只读2可编辑 3必填 默认2
username.setLabel("姓名"); //设置文本值 这个将覆盖多语言标签的值
conditionItems.add(username);
//文本输入框
2022-06-06 16:55:02 +08:00
SearchConditionItem jobNum = conditionFactory.createCondition(ConditionType.INPUT, 25034, "jobNum");
2022-05-18 18:53:30 +08:00
jobNum.setInputType("input");
jobNum.setColSpan(2);//定义一行显示条件数默认值为2,当值为1时标识该条件单独占一行
2022-06-06 16:55:02 +08:00
jobNum.setFieldcol(16); //条件输入框所占宽度默认值18
2022-05-18 18:53:30 +08:00
jobNum.setLabelcol(8);
jobNum.setViewAttr(2); // 编辑权限 1只读2可编辑 3必填 默认2
jobNum.setLabel("工号"); //设置文本值 这个将覆盖多语言标签的值
2022-03-31 14:22:42 +08:00
conditionItems.add(jobNum);
2022-06-06 16:55:02 +08:00
SearchConditionItem departmentIds = conditionFactory.createCondition(ConditionType.BROWSER, 502329, "departmentIdsStr", "57");
2022-03-31 14:22:42 +08:00
departmentIds.setColSpan(2);
departmentIds.setFieldcol(16);
departmentIds.setLabelcol(8);
departmentIds.setLabel("部门");
conditionItems.add(departmentIds);
SearchConditionItem statuses = conditionFactory.createCondition(ConditionType.SELECT, 502327, "statusesStr");
2022-05-18 18:53:30 +08:00
statuses.setInputType("select");
statuses.setMultiple(true);
2022-03-31 14:22:42 +08:00
statuses.setOptions(userStatusOptions);
statuses.setColSpan(2);
statuses.setFieldcol(16);
statuses.setLabelcol(8);
statuses.setIsQuickSearch(true);
statuses.setLabel("状态");
conditionItems.add(statuses);
2022-06-06 16:55:02 +08:00
SearchConditionItem positions = conditionFactory.createCondition(ConditionType.BROWSER, 502327, "positionsStr", "278");
2022-05-18 18:53:30 +08:00
positions.setInputType("browser");
2022-03-31 14:22:42 +08:00
positions.setColSpan(2);
positions.setFieldcol(16);
positions.setLabelcol(8);
positions.setIsQuickSearch(true);
positions.setLabel("岗位");
conditionItems.add(positions);
SearchConditionItem subcompanyIds = conditionFactory.createCondition(ConditionType.BROWSER, 502327, "subcompanyIdsStr", "194");
subcompanyIds.setInputType("browser");
subcompanyIds.setColSpan(2);
subcompanyIds.setFieldcol(16);
subcompanyIds.setLabelcol(8);
subcompanyIds.setIsQuickSearch(true);
subcompanyIds.setLabel("分部");
conditionItems.add(subcompanyIds);
2022-03-31 14:22:42 +08:00
2022-05-18 18:53:30 +08:00
// SearchConditionItem hireDate = conditionFactory.createCondition(ConditionType.TIMEPICKER,502327,new String[]{"hireDate", "hireDate"});
// hireDate.setInputType("timepicker");
// hireDate.setColSpan(2);
// hireDate.setFieldcol(16);
// hireDate.setViewAttr(8);
// hireDate.setFormat("yyyy-MM-dd");
// hireDate.setLabel("入职日期");
// conditionItems.add(hireDate);
//
//
// SearchConditionItem dimissionDate = conditionFactory.createCondition(ConditionType.TIMEPICKER,502327,new String[]{"dimissionDate", "dimissionDate"});
// dimissionDate.setInputType("timepicker");
// dimissionDate.setColSpan(2);
// dimissionDate.setFieldcol(16);
// dimissionDate.setViewAttr(8);
// dimissionDate.setFormat("yyyy-MM-dd");
// dimissionDate.setLabel("离职日期");
// conditionItems.add(dimissionDate);
2022-03-31 14:22:42 +08:00
2022-06-06 16:55:02 +08:00
SearchConditionItem siSchemeId = conditionFactory.createCondition(ConditionType.SELECT, 502327, "siSchemeId");
2022-05-18 18:53:30 +08:00
siSchemeId.setInputType("select");
2022-03-31 14:22:42 +08:00
siSchemeId.setOptions(schemeOption);
siSchemeId.setColSpan(2);
siSchemeId.setFieldcol(16);
siSchemeId.setLabelcol(8);
siSchemeId.setIsQuickSearch(true);
siSchemeId.setLabel("社保方案");
conditionItems.add(siSchemeId);
2022-06-06 16:55:02 +08:00
SearchConditionItem fundSchemeId = conditionFactory.createCondition(ConditionType.SELECT, 502327, "fundSchemeId");
2022-05-18 18:53:30 +08:00
fundSchemeId.setInputType("select");
2022-03-31 14:22:42 +08:00
fundSchemeId.setOptions(fundOption);
fundSchemeId.setColSpan(2);
fundSchemeId.setFieldcol(16);
fundSchemeId.setLabelcol(8);
fundSchemeId.setIsQuickSearch(true);
fundSchemeId.setLabel("公积金方案");
conditionItems.add(fundSchemeId);
2022-06-06 16:55:02 +08:00
SearchConditionItem otherSchemeId = conditionFactory.createCondition(ConditionType.SELECT, 502327, "otherSchemeId");
2022-05-18 18:53:30 +08:00
otherSchemeId.setInputType("select");
2022-03-31 14:22:42 +08:00
otherSchemeId.setOptions(otherOption);
otherSchemeId.setColSpan(2);
otherSchemeId.setFieldcol(16);
otherSchemeId.setLabelcol(8);
otherSchemeId.setIsQuickSearch(true);
otherSchemeId.setLabel("其它福利方案");
conditionItems.add(otherSchemeId);
SearchConditionItem taxAgentId = conditionFactory.createCondition(ConditionType.SELECT, 502327, "taxAgentId");
taxAgentId.setInputType("select");
taxAgentId.setOptions(taxAgentOption);
taxAgentId.setColSpan(2);
taxAgentId.setFieldcol(16);
taxAgentId.setLabelcol(8);
taxAgentId.setIsQuickSearch(true);
taxAgentId.setLabel("个税扣缴义务人");
conditionItems.add(taxAgentId);
2022-06-06 16:55:02 +08:00
addGroups.add(new SearchConditionGroup("常用条件", true, conditionItems));
apidatas.put("condition", addGroups);
2022-03-31 14:22:42 +08:00
return apidatas;
2022-04-14 11:54:16 +08:00
}
2022-03-31 14:22:42 +08:00
2022-04-14 11:54:16 +08:00
/**
* 组装员工的社保公积金其他福利数据
*
* @param ids 员工id集合
2022-04-14 11:54:16 +08:00
* @return map
*/
public Map<Long, InsuranceArchivesAccountPO> buildBatchAccount(List<Long> ids, Long paymentOrganization) {
2022-04-14 11:54:16 +08:00
if (CollectionUtils.isEmpty(ids)) {
return new HashMap<>();
}
//设置获取社保/公积金/其他福利档案方法的入参
List<InsuranceArchivesEmployeePO> insuranceArchivesEmployeePOS = new ArrayList<>();
for (Long employeeId : ids) {
insuranceArchivesEmployeePOS.add(InsuranceArchivesEmployeePO.builder()
.employeeId(employeeId)
.paymentOrganization(paymentOrganization)
.build());
}
2022-04-14 11:54:16 +08:00
Map<Long, InsuranceArchivesAccountPO> result = new HashMap<>();
Map<Long, InsuranceArchivesSocialSchemePO> socialMap = new HashMap<>();
Map<Long, InsuranceArchivesFundSchemePO> funMap = new HashMap<>();
Map<Long, InsuranceArchivesOtherSchemePO> otherMap = new HashMap<>();
List<InsuranceArchivesSocialSchemePO> socialPOS = encryptUtil.decryptList(this.getSocialByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS), InsuranceArchivesSocialSchemePO.class);
2022-04-14 11:54:16 +08:00
if (CollectionUtils.isNotEmpty(socialPOS)) {
socialMap = socialPOS.stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getEmployeeId, Function.identity()));
}
List<InsuranceArchivesFundSchemePO> fundPOS = encryptUtil.decryptList(this.getFundByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS), InsuranceArchivesFundSchemePO.class);
2022-04-14 11:54:16 +08:00
if (CollectionUtils.isNotEmpty(fundPOS)) {
funMap = fundPOS.stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getEmployeeId, Function.identity()));
}
List<InsuranceArchivesOtherSchemePO> otherPOS = this.getOtherByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS);
encryptUtil.decryptList(otherPOS, InsuranceArchivesOtherSchemePO.class);
2022-04-14 11:54:16 +08:00
if (CollectionUtils.isNotEmpty(otherPOS)) {
otherMap = otherPOS.stream().collect(Collectors.toMap(InsuranceArchivesOtherSchemePO::getEmployeeId, Function.identity()));
}
for (Long id : ids) {
InsuranceArchivesAccountPO po = new InsuranceArchivesAccountPO();
po.setSocial(socialMap.get(id));
po.setFund(funMap.get(id));
po.setOther(otherMap.get(id));
result.put(id, po);
}
return result;
2022-03-22 19:47:46 +08:00
}
2022-04-14 11:54:16 +08:00
2022-05-24 09:23:17 +08:00
private List<InsuranceSchemeDetailPO> decryptSchemeDetailList(List<InsuranceSchemeDetailPO> encryptList) {
encryptList.forEach(item -> {
item.setUpperLimit(AESEncryptUtil.decrypt(item.getUpperLimit()));
item.setFixedCost(AESEncryptUtil.decrypt(item.getFixedCost()));
item.setLowerLimit(AESEncryptUtil.decrypt(item.getLowerLimit()));
});
return encryptList;
}
/**
* 判断是否需要生成历史福利档案基本信息
*/
public Boolean createOldInsuranceBaseInfo(Long creator) {
2022-11-03 11:14:59 +08:00
log.info("判断是否需要生成历史数据");
List<InsuranceArchivesBaseInfoPO> nowBaseInfoList = getInsuranceBaseInfoMapper().getInsuranceBaseInfoList();
if (nowBaseInfoList.size() == 0) {
StopWatch sw = new StopWatch();
2022-11-03 11:14:59 +08:00
log.info("福利档案基础信息表为空,开始生成历史数据:");
//处理公积金、其他福利档案中个税扣缴义务人为空的情况
2022-11-03 11:14:59 +08:00
sw.start("处理公积金、其他福利档案中个税扣缴义务人为空的情况");
List<InsuranceArchivesSocialSchemePO> socialList = getSocialSchemeMapper().listAll();
List<InsuranceArchivesFundSchemePO> fundList = getFundSchemeMapper().listAll();
List<InsuranceArchivesOtherSchemePO> otherList = getOtherSchemeMapper().listAll();
List<InsuranceArchivesFundSchemePO> updateFundList = new ArrayList<>();
List<InsuranceArchivesOtherSchemePO> updateOtherList = new ArrayList<>();
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) {
2022-11-03 11:14:59 +08:00
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) {
2022-11-03 11:14:59 +08:00
InsuranceArchivesOtherSchemePO toDealOtherPO = toDealOtherList.get(0);
toDealOtherPO.setPaymentOrganization(socialSchemePO.getPaymentOrganization());
updateOtherList.add(toDealOtherPO);
2022-11-03 11:14:59 +08:00
}
2022-11-03 11:14:59 +08:00
}
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<>();
2022-11-03 11:14:59 +08:00
List<InsuranceArchivesBaseInfoPO> oldBaseInfoList = getInsuranceBaseInfoMapper().getInsuranceBaseInfoListByInsuranceDetail(null);
2022-11-03 11:14:59 +08:00
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) {
po.setId(IdGenerator.generate());
po.setCreateTime(new Date());
po.setDeleteType(0);
po.setCreator(creator);
po.setRunStatus(EmployeeStatusEnum.STAY_ADD.getValue());
po.setUpdateTime(new Date());
po.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
addBaseInfoList.add(po);
}
//将历史基本信息入库
List<List<InsuranceArchivesBaseInfoPO>> partition = Lists.partition(addBaseInfoList, 50);
partition.forEach(getInsuranceBaseInfoMapper()::batchSave);
sw.stop();
log.info("各操作计时 {}", sw.prettyPrint());
return true;
}else {
return false;
}
} else {
return false;
}
}
/**
* 判断字符串是否为整数或者小数或者负数
*/
public static boolean isNumeric(String str){
Pattern pattern = Pattern.compile("^-?\\d+(\\.\\d+)?$");
Matcher isNum = pattern.matcher(str);
if (!isNum.matches()) {
return false;
}
return true;
}
/**
* 获取没有设置社保公积金最后缴纳月的档案
* @param employeeIds
* @return
*/
public List<InsuranceArchivesBaseInfoPO> listEndDateIsNull(List<Long> employeeIds) {
if (CollectionUtils.isEmpty(employeeIds)) {
return Collections.emptyList();
}
return getInsuranceBaseInfoMapper().listEndDateIsNull(employeeIds);
}
2022-03-15 09:34:53 +08:00
}