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

180 lines
7.7 KiB
Java
Raw Normal View History

2022-03-15 09:34:53 +08:00
package com.engine.salary.biz;
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;
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;
2022-03-15 09:34:53 +08:00
import com.engine.salary.util.SalaryAssert;
2022-03-15 17:39:19 +08:00
import com.engine.salary.util.SalaryDateUtil;
import org.apache.ibatis.session.SqlSession;
import weaver.conn.mybatis.MyBatisFactory;
2022-03-15 09:34:53 +08:00
import java.util.Collections;
2022-03-15 17:39:19 +08:00
import java.util.HashMap;
2022-03-15 09:34:53 +08:00
import java.util.List;
2022-03-15 17:39:19 +08:00
import java.util.Map;
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-15 17:39:19 +08:00
public Map<String,Object> getBaseForm(WelfareTypeEnum welfareType, Long employeeId, Long operateId) {
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();
//返回组件
//返回数据
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;
2022-03-15 09:34:53 +08:00
}
2022-03-15 17:39:19 +08:00
/**
* 其它基础表单
* @param list
* @param employeeId
* @param operateId
* @return
*/
public InsuranceArchivesOtherSchemeDTO buildOtherForm(List<InsuranceSchemePO> 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<InsuranceSchemePO> 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<InsuranceSchemePO> 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();
}
}
2022-03-15 09:34:53 +08:00
}