package com.engine.salary.biz; import com.engine.salary.entity.datacollection.DataCollectionEmployee; 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; import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO; import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO; import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO; import com.engine.salary.entity.sischeme.po.InsuranceSchemePO; import com.engine.salary.enums.sicategory.UndertakerEnum; import com.engine.salary.enums.sicategory.WelfareTypeEnum; import com.engine.salary.mapper.archives.FundSchemeMapper; import com.engine.salary.mapper.archives.OtherSchemeMapper; import com.engine.salary.mapper.archives.SocialSchemeMapper; import com.engine.salary.util.SalaryAssert; import com.engine.salary.util.SalaryDateUtil; import org.apache.ibatis.session.SqlSession; import weaver.conn.mybatis.MyBatisFactory; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @Author weaver_cl * @Description: TODO * @Date 2022/3/12 * @Version V1.0 **/ public class SIArchivesBiz { public Map getBaseForm(WelfareTypeEnum welfareType, Long employeeId, Long operateId) { Map data = new HashMap<>(16); SalaryAssert.notNull(employeeId, "员工id不可为空"); EmployBiz employBiz = new EmployBiz(); List employeeByIds = employBiz.getEmployeeByIdsAll(Collections.singletonList(employeeId)); SalaryAssert.notEmpty(employeeByIds,"员工信息不存在"); DataCollectionEmployee item = employeeByIds.get(0); 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 insuranceArchivesEmployeePOS = siArchivesSocialMapper.queryEmployeeList(insuranceArchivesListParam, tenantKey); // if (CollectionUtils.isNotEmpty(insuranceArchivesEmployeePOS)) { // insuranceArchivesBaseDTO.setDimissionDate(SalaryDateUtil.getFormatLocalDate(insuranceArchivesEmployeePOS.get(0).getDimissionDate())); // } // } //WeaForm weaForm = SalaryFormatUtil.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 list = siSchemeBiz.listAll(); //返回组件 //返回数据 switch (welfareType) { case SOCIAL_SECURITY: InsuranceArchivesSocialSchemeDTO insuranceArchivesSocialSchemeDTO = buildSocialForm(list, employeeId, operateId ); data.put("data",insuranceArchivesSocialSchemeDTO); break; case ACCUMULATION_FUND: InsuranceArchivesFundSchemeDTO insuranceArchivesFundSchemeDTO = buildFundForm(list, employeeId, operateId); data.put("data",insuranceArchivesFundSchemeDTO); break; case OTHER: InsuranceArchivesOtherSchemeDTO insuranceArchivesOtherSchemeDTO = buildOtherForm(list, employeeId, operateId); data.put("data",insuranceArchivesOtherSchemeDTO); break; default: data.put("data",""); } return data; } /** * 其它基础表单 * @param list * @param employeeId * @param operateId * @return */ public InsuranceArchivesOtherSchemeDTO buildOtherForm(List list, Long employeeId, Long operateId) { SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); try { OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class); InsuranceArchivesOtherSchemePO insuranceArchivesOtherSchemePO = otherSchemeMapper.getOtherByEmployeeId(employeeId); InsuranceArchivesOtherSchemeDTO data = InsuranceArchivesBO.convertOtherPOtoDTO(insuranceArchivesOtherSchemePO, employeeId); if (insuranceArchivesOtherSchemePO == null) { data.setEmployeeId(employeeId); data.setUnderTake(UndertakerEnum.SCOPE_COMPANY); } return data; }finally { sqlSession.close(); } } /** * 公积金基础表单 * @param list * @param employeeId * @param operateId * @return */ public InsuranceArchivesFundSchemeDTO buildFundForm(List list, Long employeeId, Long operateId) { SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); try { FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class); InsuranceArchivesFundSchemePO insuranceArchivesFundSchemePO = fundSchemeMapper.getFundByEmployeeId(employeeId); InsuranceArchivesFundSchemeDTO data = InsuranceArchivesBO.convertFundPOtoDTO(insuranceArchivesFundSchemePO, employeeId); if (insuranceArchivesFundSchemePO == null) { data.setEmployeeId(employeeId); data.setUnderTake(UndertakerEnum.SCOPE_COMPANY); } return data; }finally { sqlSession.close(); } } /** * 社保基础表单 * @param list * @param employeeId * @param operateId * @return */ public InsuranceArchivesSocialSchemeDTO buildSocialForm(List list, Long employeeId, Long operateId) { 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); return socialSchemeMapper.getSocialByEmployeeId(employeeId); }finally { sqlSession.close(); } } }