216 lines
9.7 KiB
Java
216 lines
9.7 KiB
Java
|
|
package com.engine.salary.wrapper;
|
||
|
|
|
||
|
|
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
||
|
|
import com.engine.salary.entity.salaryacct.bo.SalaryAcctResultBO;
|
||
|
|
import com.engine.salary.entity.salaryacct.dto.ConsolidatedTaxDetailDTO;
|
||
|
|
import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultDetailDTO;
|
||
|
|
import com.engine.salary.entity.salaryacct.param.SalaryAcctResultSaveParam;
|
||
|
|
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
|
||
|
|
import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO;
|
||
|
|
import com.engine.salary.service.SalaryAcctRecordService;
|
||
|
|
import com.engine.salary.service.SalaryAcctResultService;
|
||
|
|
import com.engine.salary.service.SalarySobItemService;
|
||
|
|
import com.engine.salary.service.TaxAgentService;
|
||
|
|
import org.springframework.stereotype.Component;
|
||
|
|
|
||
|
|
import java.util.List;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 薪资核算结果
|
||
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
||
|
|
* <p>Company: 泛微软件</p>
|
||
|
|
*
|
||
|
|
* @author qiantao
|
||
|
|
* @version 1.0
|
||
|
|
**/
|
||
|
|
@Component
|
||
|
|
public class SalaryAcctResultWrapper {
|
||
|
|
|
||
|
|
|
||
|
|
private SalaryAcctResultService salaryAcctResultService;
|
||
|
|
|
||
|
|
private SalaryAcctRecordService salaryAcctRecordService;
|
||
|
|
|
||
|
|
private SalarySobItemService salarySobItemService;
|
||
|
|
|
||
|
|
private SalaryAcctEmployeeWrapper salaryAcctEmployeeWrapper;
|
||
|
|
|
||
|
|
// private SalaryAcctProgressService salaryAcctProgressService;
|
||
|
|
|
||
|
|
// private SalaryCheckResultService salaryCheckResultService;
|
||
|
|
|
||
|
|
private TaxAgentService taxAgentService;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 薪资核算列表
|
||
|
|
*
|
||
|
|
* @param queryParam 列表查询条件
|
||
|
|
* @param tenantKey 租户key
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
// public WeaTable<Map<String, Object>> listPage(SalaryAcctResultQueryParam queryParam, String tenantKey) {
|
||
|
|
// // 查询薪资核算记录
|
||
|
|
// SalaryAcctRecordPO salaryAcctRecordPO = salaryAcctRecordService.getById(queryParam.getSalaryAcctRecordId());
|
||
|
|
// if (Objects.isNull(salaryAcctRecordPO)) {
|
||
|
|
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
|
||
|
|
// }
|
||
|
|
// // 构建薪资核算结果列表的表头
|
||
|
|
// List<WeaTableColumn> weaTableColumns = listWeaTableColumn(salaryAcctRecordPO, tenantKey);
|
||
|
|
// // 查询薪资核算结果(分页)
|
||
|
|
// Page<Map<String, Object>> page = salaryAcctResultService.listPageByParam(queryParam, tenantKey);
|
||
|
|
// // 转换成前端所需的数据格式
|
||
|
|
// WeaTable<Map<String, Object>> weaTable = new WeaTable<>();
|
||
|
|
// weaTable.setColumns(weaTableColumns);
|
||
|
|
// weaTable.setPage(page);
|
||
|
|
// weaTable.setData(page.getRecords());
|
||
|
|
// weaTable.setDisplayData(page.getRecords());
|
||
|
|
// weaTable.setPageUid("salaryAcctResultList");
|
||
|
|
// weaTable.setModule("hrmsalary");
|
||
|
|
// // 列表操作列
|
||
|
|
// if (Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())) {
|
||
|
|
// weaTable.setOperates(Collections.singletonList(new WeaTableOperate("edit", SalaryI18nUtil.getI18nLabel(87058, "编辑"), 0, true, true)));
|
||
|
|
// List<List<Permission>> operatesPermission = page.getRecords().stream().map(e -> Collections.singletonList(new Permission())).collect(Collectors.toList());
|
||
|
|
// weaTable.setOperatesPermission(operatesPermission);
|
||
|
|
// }
|
||
|
|
// return weaTable;
|
||
|
|
// }
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 构建薪资核算结果列表的表头
|
||
|
|
*
|
||
|
|
* @param salaryAcctRecordPO 薪资核算记录
|
||
|
|
* @param tenantKey 租户key
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
public List<WeaTableColumn> listWeaTableColumn(SalaryAcctRecordPO salaryAcctRecordPO, String tenantKey) {
|
||
|
|
// 查询薪资账套下的薪资项目+员工信息字段
|
||
|
|
SalarySobItemAggregateDTO salarySobItemAggregateDTO = salarySobItemService.getAggregateBySalarySobId(salaryAcctRecordPO.getSalarySobId());
|
||
|
|
// 构建薪资核算结果列表表头
|
||
|
|
return SalaryAcctResultBO.buildTableColumns(salarySobItemAggregateDTO);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 获取薪资核算列表的高级搜索
|
||
|
|
*
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
// public WeaSearchCondition getSearchCondition(String tenantKey) {
|
||
|
|
// SalaryAcctResultSearchConditionDTO searchConditionDTO = new SalaryAcctResultSearchConditionDTO();
|
||
|
|
// WeaSearchCondition searchCondition = SalaryFormatUtil.<SalaryAcctResultSearchConditionDTO>getInstance()
|
||
|
|
// .buildCondition(SalaryAcctResultSearchConditionDTO.class, searchConditionDTO, "SalaryAcctResultCondition");
|
||
|
|
// // 查询个税扣缴义务人
|
||
|
|
// List<TaxAgentPO> taxAgentPOS = taxAgentService.listAll(tenantKey);
|
||
|
|
// List<WeaSearchConditionOption> weaSearchConditionOptions = taxAgentPOS.stream()
|
||
|
|
// .map(taxAgentPO -> new WeaSearchConditionOption(String.valueOf(taxAgentPO.getId()), taxAgentPO.getName()))
|
||
|
|
// .collect(Collectors.toList());
|
||
|
|
// // 给查询条件中的个税扣缴义务人填充下拉项
|
||
|
|
// searchCondition.getItems().forEach((k, v) -> {
|
||
|
|
// if (StringUtils.equals("taxAgentId", k)) {
|
||
|
|
// v.setOptions(weaSearchConditionOptions);
|
||
|
|
// }
|
||
|
|
// });
|
||
|
|
// // 其他条件不要
|
||
|
|
// searchCondition.getGroups().remove(1);
|
||
|
|
// return searchCondition;
|
||
|
|
// }
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 薪资核算结果详情
|
||
|
|
*
|
||
|
|
* @param salaryAcctEmployeeId 薪资核算人员id
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
public SalaryAcctResultDetailDTO getForm(Long salaryAcctEmployeeId) {
|
||
|
|
// 获取薪资核算结果详情
|
||
|
|
return salaryAcctResultService.getBySalaryAcctEmployeeId(salaryAcctEmployeeId);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 获取合并计税详情
|
||
|
|
*
|
||
|
|
* @param salaryAcctEmployeeId 薪资核算人员id
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
public ConsolidatedTaxDetailDTO getConsolidatedTaxDetail(Long salaryAcctEmployeeId) {
|
||
|
|
// 获取合并计税详情
|
||
|
|
return salaryAcctResultService.getConsolidatedTaxDetail(salaryAcctEmployeeId);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 保存薪资核算结果
|
||
|
|
*
|
||
|
|
* @param saveParam 保存参数
|
||
|
|
*/
|
||
|
|
public void save(SalaryAcctResultSaveParam saveParam) {
|
||
|
|
salaryAcctResultService.save(saveParam);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 薪资核算-核算
|
||
|
|
*
|
||
|
|
* @param calculateParam 薪资核算的参数
|
||
|
|
* @param simpleEmployee 当前登陆人员
|
||
|
|
* @param tenantKey 租户key
|
||
|
|
*/
|
||
|
|
// public void calculate(SalaryAcctCalculateParam calculateParam, DataCollectionEmployee simpleEmployee) {
|
||
|
|
// // 检查薪资核算人员的个税扣缴义务人
|
||
|
|
// salaryAcctEmployeeWrapper.checkTaxAgent(calculateParam.getSalaryAcctRecordId());
|
||
|
|
// // 检查是否正在核算中
|
||
|
|
// SalaryAcctProgressDTO salaryAcctProgressDTO = salaryAcctProgressService.getProgress("" + calculateParam.getSalaryAcctRecordId(), simpleEmployee.getEmployeeId(), tenantKey);
|
||
|
|
// if (Objects.nonNull(salaryAcctProgressDTO) && salaryAcctProgressDTO.isStatus() && Optional.ofNullable(salaryAcctProgressDTO.getProgress()).orElse(BigDecimal.ZERO).compareTo(BigDecimal.ONE) < 0) {
|
||
|
|
// return;
|
||
|
|
// }
|
||
|
|
// // 初始化进度
|
||
|
|
// SalaryAcctProgressDTO initProgress = new SalaryAcctProgressDTO()
|
||
|
|
// .setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中"))
|
||
|
|
// .setTitleLabelId(97515L)
|
||
|
|
// .setTotalQuantity(NumberUtils.INTEGER_ONE)
|
||
|
|
// .setCalculatedQuantity(NumberUtils.INTEGER_ZERO)
|
||
|
|
// .setProgress(BigDecimal.ZERO)
|
||
|
|
// .setStatus(true)
|
||
|
|
// .setMessage(StringUtils.EMPTY);
|
||
|
|
// salaryAcctProgressService.initProgress("" + calculateParam.getSalaryAcctRecordId(), initProgress, simpleEmployee.getEmployeeId(), tenantKey);
|
||
|
|
// // 异步执行薪资核算
|
||
|
|
// LocalRunnable localRunnable = new LocalRunnable() {
|
||
|
|
// @Override
|
||
|
|
// public void execute() {
|
||
|
|
// salaryAcctResultService.calculate(calculateParam, simpleEmployee, tenantKey);
|
||
|
|
// }
|
||
|
|
// };
|
||
|
|
// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "salaryAcctCalculate", localRunnable);
|
||
|
|
// }
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 薪资核算-校验
|
||
|
|
*
|
||
|
|
* @param checkParam 薪资核算的参数
|
||
|
|
* @param simpleEmployee 当前登陆人员
|
||
|
|
* @param tenantKey 租户key
|
||
|
|
*/
|
||
|
|
// public void check(SalaryAcctCheckParam checkParam, SimpleEmployee simpleEmployee, String tenantKey) {
|
||
|
|
// // 检查是否正在核算中
|
||
|
|
// SalaryAcctProgressDTO salaryAcctProgressDTO = salaryAcctProgressService.getProgress("" + checkParam.getSalaryAcctRecordId(), simpleEmployee.getEmployeeId(), tenantKey);
|
||
|
|
// if (Objects.nonNull(salaryAcctProgressDTO) && salaryAcctProgressDTO.isStatus() && Optional.ofNullable(salaryAcctProgressDTO.getProgress()).orElse(BigDecimal.ZERO).compareTo(BigDecimal.ONE) < 0) {
|
||
|
|
// return;
|
||
|
|
// }
|
||
|
|
// // 初始化进度
|
||
|
|
// SalaryAcctProgressDTO initProgress = new SalaryAcctProgressDTO()
|
||
|
|
// .setTitle(SalaryI18nUtil.getI18nLabel(99664, "正在运行校验规则"))
|
||
|
|
// .setTitleLabelId(99664L)
|
||
|
|
// .setTotalQuantity(NumberUtils.INTEGER_ONE)
|
||
|
|
// .setCalculatedQuantity(NumberUtils.INTEGER_ZERO)
|
||
|
|
// .setProgress(BigDecimal.ZERO)
|
||
|
|
// .setStatus(true)
|
||
|
|
// .setMessage(StringUtils.EMPTY);
|
||
|
|
// salaryAcctProgressService.initProgress("" + checkParam.getSalaryAcctRecordId(), initProgress, simpleEmployee.getEmployeeId(), tenantKey);
|
||
|
|
// // 异步执行校验
|
||
|
|
// LocalRunnable localRunnable = new LocalRunnable() {
|
||
|
|
// @Override
|
||
|
|
// public void execute() {
|
||
|
|
// salaryCheckResultService.check(checkParam, false, simpleEmployee, tenantKey);
|
||
|
|
// }
|
||
|
|
// };
|
||
|
|
// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "salaryAcctCheck", localRunnable);
|
||
|
|
// }
|
||
|
|
}
|