weaver-hrm-salary/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java

190 lines
8.2 KiB
Java
Raw Normal View History

2022-03-15 09:34:53 +08:00
package com.engine.salary.service.impl;
2022-04-19 17:46:24 +08:00
import com.cloudstore.eccom.pc.table.WeaTableColumn;
2022-06-06 16:55:02 +08:00
import com.engine.common.util.ServiceUtil;
2022-03-15 09:34:53 +08:00
import com.engine.core.impl.Service;
2022-03-15 17:39:19 +08:00
import com.engine.salary.biz.SIArchivesBiz;
import com.engine.salary.cmd.siarchives.SIArchivesTipsCmd;
2022-03-18 18:00:51 +08:00
import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam;
import com.engine.salary.entity.siarchives.param.InsuranceArchivesSaveParam;
2022-04-19 17:46:24 +08:00
import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO;
2022-06-06 16:55:02 +08:00
import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
2022-03-15 17:39:19 +08:00
import com.engine.salary.enums.sicategory.WelfareTypeEnum;
2022-04-19 17:46:24 +08:00
import com.engine.salary.mapper.siarchives.SocialSchemeMapper;
2022-03-15 09:34:53 +08:00
import com.engine.salary.service.SIArchivesService;
2022-06-06 16:55:02 +08:00
import com.engine.salary.service.TaxAgentService;
2022-09-26 18:51:17 +08:00
import com.engine.salary.sys.entity.vo.OrderRuleVO;
import com.engine.salary.sys.service.SalarySysConfService;
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
2022-06-06 16:55:02 +08:00
import com.engine.salary.util.SalaryEntityUtil;
2022-04-19 17:46:24 +08:00
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.excel.ExcelUtil;
import org.apache.commons.lang3.StringUtils;
2022-04-19 17:46:24 +08:00
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
2022-03-15 17:39:19 +08:00
import weaver.general.Util;
2022-06-06 16:55:02 +08:00
import weaver.hrm.User;
2022-03-15 09:34:53 +08:00
2022-04-19 17:46:24 +08:00
import java.util.*;
2022-06-06 16:55:02 +08:00
import java.util.stream.Collectors;
2022-03-15 09:34:53 +08:00
/**
* @Author weaver_cl
2022-07-13 11:45:16 +08:00
* @Description:
2022-03-15 09:34:53 +08:00
* @Date 2022/3/11
* @Version V1.0
**/
public class SIArchivesServiceImpl extends Service implements SIArchivesService {
2022-04-19 17:46:24 +08:00
private SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
2022-06-06 16:55:02 +08:00
private TaxAgentService getTaxAgentService(User user) {
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
2022-09-26 18:51:17 +08:00
private SalarySysConfService getSalarySysConfService(User user) {
return ServiceUtil.getService(SalarySysConfServiceImpl.class, user);
}
2022-06-06 16:55:02 +08:00
2022-03-15 09:34:53 +08:00
@Override
public Map<String, Object> getTips(Map<String, Object> params) {
2022-06-06 16:55:02 +08:00
return commandExecutor.execute(new SIArchivesTipsCmd(params, user));
2022-03-15 09:34:53 +08:00
}
@Override
public Map<String, Object> getBaseForm(Map<String, Object> params) {
2022-06-06 16:55:02 +08:00
long currentEmployeeId = user.getUID();
Boolean needAuth = getTaxAgentService(user).isNeedAuth(currentEmployeeId);
Collection<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAllTaxAgentsAsAdmin(currentEmployeeId);
2022-03-15 17:39:19 +08:00
Map<String, Object> apidatas = new HashMap<>(16);
2022-06-06 16:55:02 +08:00
SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
siArchivesBiz.setNeedAuth(needAuth);
siArchivesBiz.setTaxAgentPOS(taxAgentPOS);
WelfareTypeEnum welfareTypeEnum = (WelfareTypeEnum) params.get("welfareTypeEnum");
2022-03-15 17:39:19 +08:00
Long employeeId = Long.valueOf(Util.null2String(params.get("employeeId")));
2022-06-06 16:55:02 +08:00
apidatas = siArchivesBiz.getBaseForm(welfareTypeEnum, employeeId, (long) user.getUID(), user);
2022-03-16 17:04:21 +08:00
return apidatas;
}
2022-03-15 17:39:19 +08:00
2022-03-16 17:04:21 +08:00
@Override
public Map<String, Object> getPaymentForm(Map<String, Object> params) {
Map<String, Object> apidatas = new HashMap<>(16);
2022-06-06 16:55:02 +08:00
SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
WelfareTypeEnum welfareTypeEnum = (WelfareTypeEnum) params.get("welfareTypeEnum");
2022-03-16 17:04:21 +08:00
Long employeeId = Long.valueOf(Util.null2String(params.get("employeeId")));
String schemeIdStr = Util.null2String(params.get("schemeId"));
Long schemeId = null;
if (StringUtils.isNotBlank(schemeIdStr)) {
schemeId = Long.valueOf(schemeIdStr);
}
2022-06-06 16:55:02 +08:00
apidatas = siArchivesBiz.getPaymentForm(user, welfareTypeEnum, employeeId, (long) user.getUID(), schemeId);
2022-03-15 17:39:19 +08:00
return apidatas;
2022-03-15 09:34:53 +08:00
}
@Override
public String insert(InsuranceArchivesSaveParam param) {
2022-06-06 16:55:02 +08:00
SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
siArchivesBiz.insert(param, (long) user.getUID());
return null;
}
2022-03-18 18:00:51 +08:00
@Override
public Map<String, Object> listPage(InsuranceArchivesListParam param) {
2022-06-06 16:55:02 +08:00
long currentEmployeeId = user.getUID();
2022-09-26 18:51:17 +08:00
//排序配置
OrderRuleVO orderRule = getSalarySysConfService(user).orderRule();
param.setOrderRule(orderRule);
2022-06-06 16:55:02 +08:00
Boolean needAuth = getTaxAgentService(user).isNeedAuth(currentEmployeeId);
param.setNeedAuth(needAuth);
if (needAuth) {
List<TaxAgentEmployeeDTO> taxAgentEmployeeDTOS = getTaxAgentService(user).listTaxAgentAndEmployee(currentEmployeeId);
Set<Long> employeeIds = SalaryEntityUtil.properties(taxAgentEmployeeDTOS, TaxAgentEmployeeDTO::getEmployeeId);
Set<Long> taxAgentIds = SalaryEntityUtil.properties(taxAgentEmployeeDTOS, TaxAgentEmployeeDTO::getTaxAgentId);
2022-06-06 16:55:02 +08:00
param.setTaxAgentEmployeeIds(employeeIds);
param.setTaxAgentIds(taxAgentIds);
2022-06-06 16:55:02 +08:00
}
2022-03-18 18:00:51 +08:00
Map<String, Object> apidatas = new HashMap<>(16);
2022-06-06 16:55:02 +08:00
SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
apidatas = siArchivesBiz.listPage(param, (long) user.getUID());
2022-03-18 18:00:51 +08:00
return apidatas;
}
2022-03-22 19:47:46 +08:00
@Override
public Map<String, Object> getSearchCondition(Map<String, Object> param) {
Map<String, Object> apidatas = new HashMap<>(16);
2022-06-06 16:55:02 +08:00
SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
2022-03-22 19:47:46 +08:00
apidatas = siArchivesBiz.getSearchCondition(user);
return apidatas;
}
2022-04-19 17:46:24 +08:00
@Override
public XSSFWorkbook export(InsuranceArchivesListParam param) {
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]);
}
if (Objects.equals("fromQuickSearch", param.getDataSource())) {
request.setStatuses(param.getStatuses());
request.setKeyword(param.getUserName());
} else {
request = param;
}
request.setPageSize(null);
request.setStartNum(null);
List<InsuranceArchivesEmployeePO> insuranceArchivesEmployeePOS = listPageEmployeePOS(request);
if (insuranceArchivesEmployeePOS == null) {
insuranceArchivesEmployeePOS = new ArrayList<>();
}
List<Map<String, Object>> records = siArchivesBiz.buildTableData(insuranceArchivesEmployeePOS);
2022-06-06 16:55:02 +08:00
List<WeaTableColumn> columns = siArchivesBiz.buildWeaTableColumns(insuranceArchivesEmployeePOS, user.getUID());
2022-04-19 17:46:24 +08:00
//工作簿list
List<List<Object>> excelSheetData = new ArrayList<>();
//工作簿名称
String sheetName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案"); //表头
//表头
2022-04-21 15:04:35 +08:00
excelSheetData.add(Arrays.asList(columns.stream().map(WeaTableColumn::getText).toArray(String[]::new)));
2022-04-19 17:46:24 +08:00
//工作簿数据
List<List<Object>> rows = new LinkedList<>();
for (Map<String, Object> recordData : records) {
List<Object> row = new LinkedList<>();
for (WeaTableColumn column : columns) {
row.add(recordData.get(column.getColumn()));
}
rows.add(row);
}
excelSheetData.addAll(rows);
return ExcelUtil.genWorkbookV2(excelSheetData, sheetName);
}
@Override
public List<InsuranceArchivesEmployeePO> listPageEmployeePOS(InsuranceArchivesListParam param) {
2022-06-06 16:55:02 +08:00
long currentEmployeeId = user.getUID();
Boolean needAuth = getTaxAgentService(user).isNeedAuth(currentEmployeeId);
if (needAuth) {
List<TaxAgentEmployeeDTO> taxAgentEmployeeDTOS = getTaxAgentService(user).listTaxAgentAndEmployee(currentEmployeeId);
Set<Long> employeeIds = SalaryEntityUtil.properties(taxAgentEmployeeDTOS, TaxAgentEmployeeDTO::getEmployeeId);
List<InsuranceArchivesEmployeePO> list = MapperProxyFactory.getProxy(SocialSchemeMapper.class).queryEmployeeList(param);
return list.stream().filter(f -> employeeIds.contains(f.getEmployeeId())).collect(Collectors.toList());
}
2022-05-09 16:40:14 +08:00
return MapperProxyFactory.getProxy(SocialSchemeMapper.class).queryEmployeeList(param);
2022-04-19 17:46:24 +08:00
}
2022-03-18 18:00:51 +08:00
2022-03-15 09:34:53 +08:00
}