weaver-hrm-salary/src/com/engine/salary/wrapper/SalaryFormulaWrapper.java

154 lines
6.2 KiB
Java
Raw Normal View History

2022-04-14 20:46:17 +08:00
package com.engine.salary.wrapper;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.biz.SalaryItemBiz;
2022-04-14 20:46:17 +08:00
import com.engine.salary.entity.salaryformula.ExpressFormula;
import com.engine.salary.entity.salaryformula.bo.SalaryFormulaBO;
import com.engine.salary.entity.salaryformula.dto.ExpressFormulaDTO;
import com.engine.salary.entity.salaryformula.param.SalaryFormulaFieldQueryParam;
2023-03-06 19:45:48 +08:00
import com.engine.salary.entity.salaryformula.param.SalaryFormulaMockParam;
2022-08-03 10:08:43 +08:00
import com.engine.salary.entity.salaryformula.param.SalaryFormulaSaveParam;
import com.engine.salary.entity.salaryformula.po.FormulaPO;
import com.engine.salary.entity.salaryformula.po.FormulaVar;
import com.engine.salary.entity.siaccount.dto.InsuranceAcctDetailImportFieldDTO;
import com.engine.salary.entity.sicategory.po.ICategoryPO;
2022-04-14 20:46:17 +08:00
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.sicategory.ICategoryMapper;
2022-12-13 16:13:45 +08:00
import com.engine.salary.service.FormulaRunService;
2022-04-14 20:46:17 +08:00
import com.engine.salary.service.RemoteExcelService;
import com.engine.salary.service.SalaryFormulaService;
2022-12-13 16:13:45 +08:00
import com.engine.salary.service.impl.FormulaRunServiceImpl;
2022-04-14 20:46:17 +08:00
import com.engine.salary.service.impl.RemoteExcelServiceImpl;
import com.engine.salary.service.impl.SalaryFormulaServiceImpl;
import com.engine.salary.util.db.MapperProxyFactory;
2022-12-13 16:13:45 +08:00
import lombok.extern.slf4j.Slf4j;
2022-04-14 20:46:17 +08:00
import org.apache.commons.collections4.CollectionUtils;
import weaver.hrm.User;
2022-08-03 10:08:43 +08:00
import weaver.servicefiles.DataSourceXML;
2022-04-14 20:46:17 +08:00
2022-12-13 16:13:45 +08:00
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
2023-03-06 19:45:48 +08:00
import java.util.stream.Collectors;
2022-04-14 20:46:17 +08:00
/**
* 薪资项目
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
2022-12-13 16:13:45 +08:00
@Slf4j
2022-04-14 20:46:17 +08:00
public class SalaryFormulaWrapper extends Service {
private RemoteExcelService getRemoteExcelService(User user) {
2022-12-13 16:13:45 +08:00
return ServiceUtil.getService(RemoteExcelServiceImpl.class, user);
2022-04-14 20:46:17 +08:00
}
private SalaryFormulaService getSalaryFormulaService(User user) {
2022-12-13 16:13:45 +08:00
return ServiceUtil.getService(SalaryFormulaServiceImpl.class, user);
}
private FormulaRunService getFormulaRunService(User user) {
return ServiceUtil.getService(FormulaRunServiceImpl.class, user);
2022-04-14 20:46:17 +08:00
}
private SalaryItemBiz salaryItemBiz = new SalaryItemBiz();
2022-04-14 20:46:17 +08:00
private ICategoryMapper getICategoryMapper() {
return MapperProxyFactory.getProxy(ICategoryMapper.class);
}
2022-04-14 20:46:17 +08:00
/**
* 公式字段列表
*
* @param param 查询参数
* @return
*/
public List<FormulaVar> fieldList(SalaryFormulaFieldQueryParam param) {
return getRemoteExcelService(user).fieldList(param.getSourceId(), param.getExtendParam());
}
/**
* 公式字段分类
*
* @param param 查询参数
* @return
*/
public List<Map<String, Object>> fieldGroupList(Map<String, Object> param) {
return getRemoteExcelService(user).fieldGroupList(param);
}
public ExpressFormulaDTO detail(Long formulaId) {
List<ExpressFormula> expressFormulas = getSalaryFormulaService(user).listExpressFormula(Collections.singleton(formulaId));
if (CollectionUtils.isEmpty(expressFormulas)) {
throw new SalaryRunTimeException("获取公式详情失败");
}
return SalaryFormulaBO.convert2DTO(expressFormulas).get(0);
}
2022-04-16 16:49:22 +08:00
public FormulaPO save(SalaryFormulaSaveParam salaryFormulaSaveParam) {
return getSalaryFormulaService(user).save(salaryFormulaSaveParam);
2022-04-14 20:46:17 +08:00
}
2022-08-03 10:08:43 +08:00
public ArrayList datasourceList() {
DataSourceXML dataSourceXML = new DataSourceXML();
ArrayList pointArrayList = dataSourceXML.getPointArrayList();
return pointArrayList;
}
/**
* 获取薪资项目中福利类项目
*/
public List<InsuranceAcctDetailImportFieldDTO> welfareList() {
List<InsuranceAcctDetailImportFieldDTO> welfareList = new ArrayList<>();
SalaryFormulaFieldQueryParam param = new SalaryFormulaFieldQueryParam();
param.setSourceId("welfare");
//获取福利类薪资项目
List<FormulaVar> list = getRemoteExcelService(user).fieldList(param.getSourceId(), param.getExtendParam());
list = list.stream().filter(f -> !(f.getName().contains("正常缴纳") || f.getName().contains("补缴") || f.getName().contains("补差"))).collect(Collectors.toList());
//提取出福利类项目名称
2022-12-13 16:13:45 +08:00
for (FormulaVar formulaVar : list) {
InsuranceAcctDetailImportFieldDTO insuranceAcctDetailImportFieldDTO = new InsuranceAcctDetailImportFieldDTO();
// insuranceAcctDetailImportFieldDTO.setFieldId(formulaVar.getFieldId());
insuranceAcctDetailImportFieldDTO.setSalaryItemName(formulaVar.getName());
welfareList.add(insuranceAcctDetailImportFieldDTO);
}
welfareList.add(new InsuranceAcctDetailImportFieldDTO("社保合计"));
welfareList.add(new InsuranceAcctDetailImportFieldDTO("公积金合计"));
welfareList.add(new InsuranceAcctDetailImportFieldDTO("其他福利合计"));
welfareList.add(new InsuranceAcctDetailImportFieldDTO("合计"));
return welfareList;
}
/**
* 获取福利台账的补差-福利类项目
*/
public List<InsuranceAcctDetailImportFieldDTO> balanceWelfareList() {
List<InsuranceAcctDetailImportFieldDTO> welfareList = welfareList();
welfareList = welfareList.stream().filter(f -> !f.getSalaryItemName().contains("合计")).collect(Collectors.toList());
List<ICategoryPO> noUseICategoryList= getICategoryMapper().listAll().stream().filter(f -> f.getIsUse() == 0).collect(Collectors.toList());
if (noUseICategoryList.size() > 0) {
List<String> noUseNameList = noUseICategoryList.stream().map(ICategoryPO::getInsuranceName).collect(Collectors.toList());
welfareList = welfareList.stream().filter(f -> !noUseNameList.contains(f.getSalaryItemName().substring(0, f.getSalaryItemName().length() - 2))).collect(Collectors.toList());
}
return welfareList;
}
2023-03-06 19:45:48 +08:00
public Object mock(SalaryFormulaMockParam param) {
2022-12-13 16:13:45 +08:00
return getSalaryFormulaService(user).mock(param);
}
2022-04-14 20:46:17 +08:00
}