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

823 lines
41 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.alibaba.nacos.client.naming.utils.CollectionUtils;
import com.api.browser.bean.SearchConditionGroup;
import com.api.browser.bean.SearchConditionItem;
import com.api.browser.bean.SearchConditionOption;
2022-03-18 18:00:51 +08:00
import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
2022-03-18 18:00:51 +08:00
import com.engine.salary.demo.DemoPo;
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.*;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO;
2022-03-15 17:39:19 +08:00
import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO;
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-03-16 17:04:21 +08:00
import com.engine.salary.entity.taxrate.TaxAgent;
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.TaxAgentMapper;
import com.engine.salary.mapper.siarchives.FundSchemeMapper;
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.util.*;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.PageUtil;
2022-03-15 17:39:19 +08:00
import org.apache.ibatis.session.SqlSession;
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-03-17 15:26:33 +08:00
import java.time.LocalDateTime;
2022-03-16 17:04:21 +08:00
import java.util.*;
2022-03-18 18:00:51 +08:00
import java.util.function.Function;
2022-03-16 17:04:21 +08:00
import java.util.stream.Collectors;
2022-03-15 09:34:53 +08:00
/**
* @Author weaver_cl
* @Description: TODO
* @Date 2022/3/12
* @Version V1.0
**/
public class SIArchivesBiz {
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) {
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不可为空");
EmployBiz employBiz = new EmployBiz();
2022-03-15 17:39:19 +08:00
List<DataCollectionEmployee> employeeByIds = employBiz.getEmployeeByIdsAll(Collections.singletonList(employeeId));
2022-03-15 09:34:53 +08:00
SalaryAssert.notEmpty(employeeByIds,"员工信息不存在");
DataCollectionEmployee item = employeeByIds.get(0);
2022-03-15 17:39:19 +08:00
if (welfareType == null) {
//基础信息表单
InsuranceArchivesBaseDTO insuranceArchivesBaseDTO = InsuranceArchivesBaseDTO.builder().department(item.getDepartmentName())
.hiredate(SalaryDateUtil.getFormatLocalDate(item.getCompanystartdate()))
.position(item.getJobtitleName())
.username(item.getUsername())
.telephone(item.getMobile())
.dimissionDate(SalaryDateUtil.getFormatLocalDate(item.getDissmissdate()))
.build();
// if (item.getStatus() == UserStatus.unavailable) {
// 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);
// weaForm.getGroups().add(new WeaFormGroup("g1", "员工信息"));
// weaForm.getLayout().forEach(items -> items.forEach(e -> e.setGroupId("g1")));
data.put("data",insuranceArchivesBaseDTO);
return data;
}
SISchemeBiz siSchemeBiz = new SISchemeBiz();
List<InsuranceSchemePO> list = siSchemeBiz.listAll();
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.name(), e.getDefaultLabel())).collect(Collectors.toList());
2022-03-15 17:39:19 +08:00
//返回数据
switch (welfareType) {
case SOCIAL_SECURITY:
2022-03-16 17:04:21 +08:00
InsuranceArchivesSocialSchemeDTO insuranceArchivesSocialSchemeDTO = buildSocialForm(employeeId, operateId );
List<InsuranceSchemePO> socialList = list.stream().filter(e -> Objects.equals(e.getWelfareType(), WelfareTypeEnum.SOCIAL_SECURITY.getValue())).collect(Collectors.toList());
List<SearchConditionOption> socialOptions = new ArrayList <>();
socialList.forEach(social -> {
socialOptions.add(new SearchConditionOption(Util.null2String(social.getId()),social.getSchemeName()));
});
SearchConditionItem socialName = SalaryFormItemUtil.selectItem(user,socialOptions, 2, 12, 6, false, "社保方案名称");
SearchConditionItem organizationName = SalaryFormItemUtil.selectItem(user, paymentOptions, 2, 12, 6, false, "社保缴纳组织");
SearchConditionItem underTakeName = SalaryFormItemUtil.selectItem(user, underTakeOptions, 2, 12, 6, false, "社保个人实际承担方");
selectItems.add(socialName);
selectItems.add(organizationName);
selectItems.add(underTakeName);
addGroups.add(new SearchConditionGroup("社保基础信息",true,selectItems));
2022-03-15 17:39:19 +08:00
data.put("data",insuranceArchivesSocialSchemeDTO);
2022-03-16 17:04:21 +08:00
data.put("items",addGroups);
2022-03-15 17:39:19 +08:00
break;
case ACCUMULATION_FUND:
2022-03-16 17:04:21 +08:00
InsuranceArchivesFundSchemeDTO insuranceArchivesFundSchemeDTO = buildFundForm(employeeId, operateId);
List<InsuranceSchemePO> fundList = list.stream().filter(e -> Objects.equals(e.getWelfareType(), WelfareTypeEnum.ACCUMULATION_FUND.getValue())).collect(Collectors.toList());
List<SearchConditionOption> fundOptions = new ArrayList <>();
fundList.forEach(social -> {
fundOptions.add(new SearchConditionOption(Util.null2String(social.getId()),social.getSchemeName()));
});
SearchConditionItem fundName = SalaryFormItemUtil.selectItem(user,fundOptions, 2, 12, 6, false, "公积金方案名称");
SearchConditionItem organizationFundName = SalaryFormItemUtil.selectItem(user, paymentOptions, 2, 12, 6, false, "公积金缴纳组织");
SearchConditionItem underTakeFundName = SalaryFormItemUtil.selectItem(user, underTakeOptions, 2, 12, 6, false, "公积金个人实际承担方");
selectItems.add(fundName);
selectItems.add(organizationFundName);
selectItems.add(underTakeFundName);
addGroups.add(new SearchConditionGroup("公积金基础信息",true,selectItems));
2022-03-15 17:39:19 +08:00
data.put("data",insuranceArchivesFundSchemeDTO);
2022-03-16 17:04:21 +08:00
data.put("items",addGroups);
2022-03-15 17:39:19 +08:00
break;
case OTHER:
2022-03-16 17:04:21 +08:00
InsuranceArchivesOtherSchemeDTO insuranceArchivesOtherSchemeDTO = buildOtherForm(employeeId, operateId);
List<InsuranceSchemePO> otherList = list.stream().filter(e -> Objects.equals(e.getWelfareType(), WelfareTypeEnum.OTHER.getValue())).collect(Collectors.toList());
List<SearchConditionOption> otherOptions = new ArrayList <>();
otherList.forEach(social -> {
otherOptions.add(new SearchConditionOption(Util.null2String(social.getId()),social.getSchemeName()));
});
SearchConditionItem otherName = SalaryFormItemUtil.selectItem(user,otherOptions, 2, 12, 6, false, "其它福利名称");
SearchConditionItem organizationOtherName = SalaryFormItemUtil.selectItem(user, paymentOptions, 2, 12, 6, false, "其它福利缴纳组织");
SearchConditionItem underTakeOtherName = SalaryFormItemUtil.selectItem(user, underTakeOptions, 2, 12, 6, false, "其它福利个人实际承担方");
selectItems.add(otherName);
selectItems.add(organizationOtherName);
selectItems.add(underTakeOtherName);
addGroups.add(new SearchConditionGroup("其它福利基础信息",true,selectItems));
2022-03-15 17:39:19 +08:00
data.put("data",insuranceArchivesOtherSchemeDTO);
2022-03-16 17:04:21 +08:00
data.put("items",addGroups);
break;
default:
}
return data;
}
/**
* 获取详细表单
* @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) {
Map<String, Object> data = new HashMap<>(16);
switch (welfareType) {
case SOCIAL_SECURITY:
data = buildSocialPaymentForm(user,employeeId, schemeId, operateId,welfareType.getValue());
break;
case ACCUMULATION_FUND:
data = buildFundPaymentForm(user,employeeId, schemeId, operateId,welfareType.getValue());
break;
case OTHER:
data = buildOtherPaymentForm(user,employeeId, schemeId, operateId,welfareType.getValue());
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
* @param employeeId
* @param schemeId
* @param operateId
* @return
*/
public Map<String, Object> buildOtherPaymentForm(User user,Long employeeId, Long schemeId, long operateId,Integer welfareType) {
Map<String, Object> dataMap = new HashMap<>();
InsuranceArchivesOtherSchemeDTO data = buildOtherForm(employeeId, operateId);
if (data != null) {
dataMap.put("data",JSONObject.parseObject(data.getOtherPaymentBaseString(), new TypeReference<Map<String, Object>>() {
}));
}
List<SearchConditionGroup> addGroups = new ArrayList<>();
List<SearchConditionItem> inputItems = buildPaymentBase(user,schemeId,welfareType);
addGroups.add(new SearchConditionGroup("其它福利缴纳基数",true,inputItems));
dataMap.put("items",addGroups);
return dataMap;
}
/**
* 公积金payForm
* @param employeeId
* @param schemeId
* @param operateId
* @return
*/
public Map<String, Object> buildFundPaymentForm(User user,Long employeeId, Long schemeId, long operateId,Integer welfareType) {
Map<String, Object> dataMap = new HashMap<>();
InsuranceArchivesFundSchemeDTO data = buildFundForm(employeeId, operateId);
if (data != null) {
dataMap.put("data",JSONObject.parseObject(data.getFundPaymentBaseString(), new TypeReference<Map<String, Object>>() {
}));
}
List<SearchConditionGroup> addGroups = new ArrayList<>();
List<SearchConditionItem> inputItems = buildPaymentBase(user,schemeId,welfareType);
addGroups.add(new SearchConditionGroup("公积金缴纳基数",true,inputItems));
dataMap.put("items",addGroups);
return dataMap;
}
/**
* 社保payForm
* @param employeeId
* @param schemeId
* @param operateId
* @return
*/
public Map<String, Object> buildSocialPaymentForm(User user,Long employeeId, Long schemeId, long operateId,Integer welfareType) {
Map<String, Object> dataMap = new HashMap<>();
InsuranceArchivesSocialSchemeDTO data = buildSocialForm(employeeId, operateId);
if (data != null) {
dataMap.put("data",JSONObject.parseObject(data.getSchemePaymentBaseString(), new TypeReference<Map<String, Object>>() {
}));
}
List<SearchConditionGroup> addGroups = new ArrayList<>();
List<SearchConditionItem> inputItems = buildPaymentBase(user,schemeId,welfareType);
addGroups.add(new SearchConditionGroup("社保缴纳基数",true,inputItems));
dataMap.put("items",addGroups);
return dataMap;
}
/**
* 构造payment(items)
* @param schemeId
* @return
*/
public List<SearchConditionItem> buildPaymentBase(User user,Long schemeId,Integer welfareType) {
List<SearchConditionItem> inputItems = new ArrayList<>();
if(schemeId == null) {
return new ArrayList<>();
}
List<InsuranceSchemeDetailPO> list = queryListByPrimaryIdIsPayment(schemeId,welfareType).stream().collect(Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(InsuranceSchemeDetailPO::getInsuranceId))), ArrayList::new)
);
SICategoryBiz siCategoryBiz = new SICategoryBiz();
list.forEach(insuranceSchemeDetail-> {
ICategoryPO iCategoryPO = siCategoryBiz.getByID(insuranceSchemeDetail.getInsuranceId());
if (iCategoryPO != null) {
inputItems.add(SalaryFormItemUtil.inputNumberItem(user,"precision:2",String.valueOf(insuranceSchemeDetail.getInsuranceId()),2,12,2,iCategoryPO.getInsuranceName()));
}
});
return inputItems;
}
/**
* 获取方案明细
* @param schemeId
* @return
*/
public List<InsuranceSchemeDetailPO> queryListByPrimaryIdIsPayment(Long schemeId,Integer welfareType) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try{
InsuranceSchemeDetailMapper insuranceSchemeDetailMapper = sqlSession.getMapper(InsuranceSchemeDetailMapper.class);
return insuranceSchemeDetailMapper.queryListByPrimaryIdIsPayment(schemeId, IsPaymentEnum.YES.getValue(),welfareType);
}finally {
sqlSession.close();
}
}
/**
* 社保缴纳组织
* @return
*/
public List<SearchConditionOption> paymentOrganizationOptions() {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
TaxAgentMapper taxAgentMapper = sqlSession.getMapper(TaxAgentMapper.class);
List<TaxAgent> list = taxAgentMapper.listAll();
if (CollectionUtils.isEmpty(list)) {
return new ArrayList<>();
}
return list
.stream()
.map(item -> new SearchConditionOption(String.valueOf(item.getId()), item.getName())).collect(Collectors.toList());
}finally {
sqlSession.close();
}
}
2022-03-15 17:39:19 +08:00
/**
* 其它基础表单
* @param employeeId
* @param operateId
* @return
*/
2022-03-16 17:04:21 +08:00
public InsuranceArchivesOtherSchemeDTO buildOtherForm(Long employeeId, Long operateId) {
2022-03-15 17:39:19 +08:00
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class);
2022-03-18 18:00:51 +08:00
InsuranceArchivesOtherSchemePO insuranceArchivesOtherSchemePO = otherSchemeMapper.getOtherByEmployeeId(Collections.singletonList(employeeId)).get(0);
2022-03-15 17:39:19 +08:00
InsuranceArchivesOtherSchemeDTO data = InsuranceArchivesBO.convertOtherPOtoDTO(insuranceArchivesOtherSchemePO, employeeId);
if (insuranceArchivesOtherSchemePO == null) {
data.setEmployeeId(employeeId);
data.setUnderTake(UndertakerEnum.SCOPE_COMPANY);
}
return data;
}finally {
sqlSession.close();
}
}
/**
* 公积金基础表单
* @param employeeId
* @param operateId
* @return
*/
2022-03-16 17:04:21 +08:00
public InsuranceArchivesFundSchemeDTO buildFundForm(Long employeeId, Long operateId) {
2022-03-15 17:39:19 +08:00
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class);
2022-03-18 18:00:51 +08:00
InsuranceArchivesFundSchemePO insuranceArchivesFundSchemePO = fundSchemeMapper.getFundByEmployeeId(Collections.singletonList(employeeId)).get(0);
2022-03-15 17:39:19 +08:00
InsuranceArchivesFundSchemeDTO data = InsuranceArchivesBO.convertFundPOtoDTO(insuranceArchivesFundSchemePO, employeeId);
if (insuranceArchivesFundSchemePO == null) {
data.setEmployeeId(employeeId);
data.setUnderTake(UndertakerEnum.SCOPE_COMPANY);
}
return data;
}finally {
sqlSession.close();
}
}
/**
* 社保基础表单
* @param employeeId
* @param operateId
* @return
*/
2022-03-16 17:04:21 +08:00
public InsuranceArchivesSocialSchemeDTO buildSocialForm(Long employeeId, Long operateId) {
2022-03-15 17:39:19 +08:00
InsuranceArchivesSocialSchemePO insuranceArchivesSocialSchemePO = getSocialByEmployeeId(employeeId);
InsuranceArchivesSocialSchemeDTO data = InsuranceArchivesBO.convertSocialPOtoDTO(insuranceArchivesSocialSchemePO, employeeId);
if (insuranceArchivesSocialSchemePO == null) {
data.setEmployeeId(employeeId);
data.setUnderTake(UndertakerEnum.SCOPE_COMPANY);
}
return data;
}
/**
* 获取社保档案表
* @param employeeId
* @return
*/
public InsuranceArchivesSocialSchemePO getSocialByEmployeeId(Long employeeId) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class);
2022-03-18 18:00:51 +08:00
return socialSchemeMapper.getSocialByEmployeeId(Collections.singletonList(employeeId)).get(0);
2022-03-15 17:39:19 +08:00
}finally {
sqlSession.close();
}
}
/**
* 新增
* @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);
SalaryAssert.notNull( "员工id为空", param, param.getEmployeeId());
otherSchemeMapper.batchDeleteByEmployeeIds(Collections.singletonList(param.getEmployeeId()));
InsuranceArchivesOtherSchemePO insuranceArchivesOtherSchemePO =
InsuranceArchivesOtherSchemePO.builder()
.otherSchemeId(param.getOtherName())
.otherStartTime(param.getOtherStartTime())
.underTake(param.getUnderTake().getValue())
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.welfareType(paramReq.getWelfareType().getValue())
.otherEndTime(param.getOtherEndTime())
.employeeId(param.getEmployeeId())
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
.updateTime(new Date())
.createTime(new Date())
//.id(IdGenerator.generate())
.nonPayment(param.getNonPayment())
.creator(employeeId)
.paymentOrganization(param.getPaymentOrganization())
.otherPaymentBaseString(paramReq.getPaymentForm())
.build();
otherSchemeMapper.batchSave(Collections.singletonList(insuranceArchivesOtherSchemePO));
sqlSession.commit();
}finally {
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());
fundSchemeMapper.batchDeleteByEmployeeIds(Collections.singletonList(param.getEmployeeId()));
InsuranceArchivesFundSchemePO insuranceArchivesFundSchemePO = InsuranceArchivesFundSchemePO.builder()
.fundSchemeId(param.getFundName())
.fundAccount(param.getFundAccount())
.fundEndTime(param.getFundEndTime())
.fundStartTime(param.getFundStartTime())
.fundPaymentBaseString(paramReq.getPaymentForm())
.supplementFundAccount(param.getSupplementFundAccount())
//.id(IdGenerator.generate())
.createTime(new Date())
.creator(employeeId)
.nonPayment(param.getNonPayment())
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.underTake(param.getUnderTake().getValue())
.paymentOrganization(param.getPaymentOrganization())
.updateTime(new Date())
.welfareType(paramReq.getWelfareType().getValue())
.employeeId(param.getEmployeeId())
.build();
fundSchemeMapper.batchSave(Collections.singletonList(insuranceArchivesFundSchemePO));
sqlSession.commit();
}finally {
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());
//删除社保数据
socialSchemeMapper.batchDeleteByEmployeeIds(Collections.singletonList(param.getEmployeeId()));
InsuranceArchivesSocialSchemePO insuranceArchivesSocialSchemePO =
InsuranceArchivesSocialSchemePO.builder()
//.id(IdGenerator.generate())
.welfareType(paramReq.getWelfareType().getValue())
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
.socialPaymentBaseString(paramReq.getPaymentForm())
.socialSchemeId(param.getSocialName())
.createTime(new Date())
.socialEndTime(param.getSocialEndTime())
.socialStartTime(param.getSocialStartTime())
.creator(employeeId)
.nonPayment(param.getNonPayment())
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.employeeId(param.getEmployeeId())
.updateTime(new Date())
.underTake(param.getUnderTake().getValue())
.socialAccount(param.getSchemeAccount())
.paymentOrganization(param.getPaymentOrganization())
.build();
socialSchemeMapper.batchSave(Collections.singletonList(insuranceArchivesSocialSchemePO));
sqlSession.commit();
}finally {
sqlSession.close();
}
}
2022-03-18 18:00:51 +08:00
/**
* 档案列表
* <p>
* 这里是一个含有比较多动态字段的列表用的是手动拼装的方式
* @param param 高级搜索条件
* @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]);
}
long current = param.getCurrent() == null ? 1L : param.getCurrent();
long pageSize = param.getPageSize() == null ? 10 : param.getPageSize();
long startNum = (current - 1) * pageSize;
param.setStartNum(startNum);
param.setPageSize(pageSize);
if (Objects.equals("fromQuickSearch", param.getDataSource())) {
request.setStatuses(param.getStatuses());
request.setKeyword(param.getUserName());
request.setStartNum(param.getStartNum());
request.setPageSize(param.getPageSize());
request.setCurrent(current);
} else {
request = param;
}
apidatas = listPageEmployeePOS(request, operateId);
return apidatas;
}
/**
* 获取员工的基本信息
* <p>
* 此处主要是一个公共接口有多处引用我们薪资系统只保存员工idemployeeId
* 但是页面上需要展示员工的更多信息姓名部门状态
* 所以这里主要是用于接收联表数据的一个接口
*
* @param param 高级搜索条件用于过滤数据
* @param operateId 操作员id
* @return list
*/
public Map<String, Object> listPageEmployeePOS(InsuranceArchivesListParam param, long operateId) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
Map<String, Object> datas = new HashMap<>(16);
try {
SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class);
PageUtil.start(param.getCurrent().intValue(), param.getPageSize().intValue());
List<InsuranceArchivesEmployeePO> page = socialSchemeMapper.listPageEmployeePOS(param);
PageInfo<InsuranceArchivesEmployeePO> pageInfo = new PageInfo<>(page, InsuranceArchivesEmployeePO.class);
List<Map<String, Object>> records = buildTableData(param, page);
datas.put("pageInfo", pageInfo);
datas.put("datas",records);
datas.put("columns",buildWeaTableColumns(page, operateId));
return datas;
}finally {
sqlSession.close();
}
}
/**
*
* @param
* @param operateId
* @return
*/
private List<WeaTableColumn> buildWeaTableColumns(List<InsuranceArchivesEmployeePO> insuranceArchivesEmployeePOS, long operateId) {
Map<Integer, Map<String, String>> titleMap = buildColumnTitle(insuranceArchivesEmployeePOS, operateId);
List<WeaTableColumn> list = new ArrayList<>();
WeaTableColumn nameColumn = new WeaTableColumn( "100px","姓名", "employeeName" );
nameColumn.setFixed("left");
list.add(nameColumn);
list.add(new WeaTableColumn("150px","部门", "departmentName"));
list.add(new WeaTableColumn("150px","手机号", "mobile"));
list.add(new WeaTableColumn("150px","员工状态", "status"));
list.add(new WeaTableColumn("150px","社保方案名称", "socialName"));
titleMap.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> list.add(new WeaTableColumn(v, k, "150px")));
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(v, k, "150px")));
list.add(new WeaTableColumn("150px","补充公积金账号", "supplementFundAccount" ));
list.add(new WeaTableColumn("150px","公积金起始缴纳月", "fundStartTime"));
list.add(new WeaTableColumn("150px","公积金最后缴纳月", "fundEndTime"));
list.add(new WeaTableColumn("150px","其他福利方案名称", "otherName"));
titleMap.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> list.add(new WeaTableColumn(v, k, "150px")));
list.add(new WeaTableColumn("150px","其他福利起始缴纳月", "otherStartTime"));
list.add(new WeaTableColumn("150px","其他福利最后缴纳月", "otherEndTime"));
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<>();
try {
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<>();
insuranceArchivesEmployeePOS.forEach(item -> {
InsuranceArchivesSocialSchemePO socialItem = socialSchemeMapper.getSocialByEmployeeId(Collections.singletonList(item.getEmployeeId())).get(0);
InsuranceArchivesFundSchemePO fundItem = fundSchemeMapper.getFundByEmployeeId(Collections.singletonList(item.getEmployeeId())).get(0);
InsuranceArchivesOtherSchemePO otherItem = otherSchemeMapper.getOtherByEmployeeId(Collections.singletonList(item.getEmployeeId())).get(0);
if (socialItem != null) {
Map<String, Object> socialJson = JSON.parseObject(socialItem.getSocialPaymentBaseString(), new TypeReference<Map<String, Object>>() {
});
if (socialJson != null) {
socialJson.forEach((k, v) -> socialSet.add(k));
}
}
if (fundItem != null) {
Map<String, Object> fundJson = JSON.parseObject(fundItem.getFundPaymentBaseString(), new TypeReference<Map<String, Object>>() {
});
if (fundJson != null) {
fundJson.forEach((k, v) -> fundSet.add(k));
}
}
if (otherItem != null) {
Map<String, Object> otherJson = JSON.parseObject(otherItem.getOtherPaymentBaseString(), new TypeReference<Map<String, Object>>() {
});
if (otherJson != null) {
otherJson.forEach((k, v) -> otherSet.add(k));
}
}
});
Map<String, String> socialMap = new HashMap<>();
Map<Long, ICategoryPO> socialCollect = new HashMap<>();
Map<Long, ICategoryPO> customSocial = iCategoryMapper.listByWelfareType(WelfareTypeEnum.SOCIAL_SECURITY.getValue(),null)
.stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity()));
Map<Long, ICategoryPO> sysSocial = iCategoryMapper.listByWelfareType(WelfareTypeEnum.SOCIAL_SECURITY.getValue(),DataTypeEnum.SYSTEM.getValue())
.stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity()));
socialCollect.putAll(customSocial);
socialCollect.putAll(sysSocial);
socialSet.forEach(item -> {
if (socialCollect.containsKey(Long.valueOf(item))) {
socialMap.put(item, socialCollect.get(Long.valueOf(item)).getInsuranceName() + "申报基数");
}
});
Map<String, String> fundMap = new HashMap<>();
Map<Long, ICategoryPO> fundCollect = new HashMap<>();
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()));
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<>();
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()));
otherCollect.putAll(customOther);
otherCollect.putAll(sysOther);
otherSet.forEach(item -> {
if (otherCollect.containsKey(Long.valueOf(item))) {
otherMap.put(item, otherCollect.get(Long.valueOf(item)).getInsuranceName() + "申报基数");
}
});
result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialMap);
result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundMap);
result.put(WelfareTypeEnum.OTHER.getValue(), otherMap);
return result;
}finally {
sqlSession.close();
}
}
/**
*
* @param param
* @param insuranceArchivesEmployeePOS
* @return
*/
private List<Map<String, Object>> buildTableData(InsuranceArchivesListParam param, List<InsuranceArchivesEmployeePO> insuranceArchivesEmployeePOS) {
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 = socialSchemeMapper.getSocialByEmployeeId(employeeIds)
.stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getEmployeeId, Function.identity()));
Map<Long, InsuranceArchivesFundSchemePO> fundSchemePOMap = fundSchemeMapper.getFundByEmployeeId(employeeIds)
.stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getEmployeeId, Function.identity()));
Map<Long, InsuranceArchivesOtherSchemePO> otherSchemePOMap = otherSchemeMapper.getOtherByEmployeeId(employeeIds)
.stream().collect(Collectors.toMap(InsuranceArchivesOtherSchemePO::getEmployeeId, Function.identity()));
insuranceArchivesEmployeePOS.forEach(item -> {
InsuranceArchivesSocialSchemePO socialItem = socialSchemePOMap.get(item.getEmployeeId());
InsuranceArchivesFundSchemePO fundItem = fundSchemePOMap.get(item.getEmployeeId());
InsuranceArchivesOtherSchemePO otherItem = otherSchemePOMap.get(item.getEmployeeId());
Map<String, Object> map = new HashMap<>();
map.put("employeeName", item.getUserName());
map.put("employeeId", item.getEmployeeId());
map.put("departmentName", item.getDepartmentName());
map.put("departmentId", item.getDepartmentId());
map.put("jobNum", item.getJobNum());
map.put("mobile", item.getTelephone());
map.put("status", item.getUserStatus() == null ? "" : item.getUserStatus().getDescription());
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) {
SalaryEntityUtil.thousandthConvert(socialJson, map);
}
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) {
SalaryEntityUtil.thousandthConvert(fundJson, map);
}
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) {
SalaryEntityUtil.thousandthConvert(otherJson, map);
}
map.put("otherStartTime", otherItem.getOtherStartTime());
map.put("otherEndTime", otherItem.getOtherEndTime());
}
records.add(map);
});
return records;
}finally {
sqlSession.close();
}
}
2022-03-15 09:34:53 +08:00
}