249 lines
12 KiB
Java
249 lines
12 KiB
Java
|
|
//package com.engine.salary.wrapper;
|
||
|
|
//
|
||
|
|
//import com.engine.salary.entity.salaryitem.dto.SalaryItemListDTO;
|
||
|
|
//import com.engine.salary.entity.salaryitem.param.SalaryItemSaveParam;
|
||
|
|
//import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam;
|
||
|
|
//import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
||
|
|
//import com.google.common.collect.Lists;
|
||
|
|
//import com.weaver.common.component.form.WeaForm;
|
||
|
|
//import com.weaver.common.component.form.item.WeaFormItem;
|
||
|
|
//import com.weaver.common.component.form.item.WeaFormOption;
|
||
|
|
//import com.weaver.common.component.search.WeaSearchCondition;
|
||
|
|
//import com.weaver.common.component.table.WeaTable;
|
||
|
|
//import com.weaver.common.component.table.page.Page;
|
||
|
|
//import com.weaver.common.component.table.permission.Permission;
|
||
|
|
//import com.weaver.common.component.table.type.WeaTableTypeEnum;
|
||
|
|
//import com.weaver.excel.formula.api.entity.ExpressFormula;
|
||
|
|
//import com.weaver.hrm.salary.entity.salaryitem.bo.SalaryItemBO;
|
||
|
|
//import com.weaver.hrm.salary.entity.salaryitem.bo.SysSalaryItemBO;
|
||
|
|
//import com.weaver.hrm.salary.entity.salaryitem.dto.SalaryItemFormDTO;
|
||
|
|
//import com.weaver.hrm.salary.entity.salaryitem.dto.SalaryItemSearchConditionDTO;
|
||
|
|
//import com.weaver.hrm.salary.entity.salaryitem.po.SysSalaryItemPO;
|
||
|
|
//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobItemPO;
|
||
|
|
//import com.weaver.hrm.salary.enums.SalaryItemTypeEnum;
|
||
|
|
//import com.weaver.hrm.salary.exception.SalaryRunTimeException;
|
||
|
|
//import com.weaver.hrm.salary.service.SalaryFormulaService;
|
||
|
|
//import com.weaver.hrm.salary.service.SalaryItemService;
|
||
|
|
//import com.weaver.hrm.salary.service.SalarySobItemService;
|
||
|
|
//import com.weaver.hrm.salary.service.SysSalaryItemService;
|
||
|
|
//import com.weaver.hrm.salary.util.SalaryEntityUtil;
|
||
|
|
//import com.weaver.hrm.salary.util.SalaryFormatUtil;
|
||
|
|
//import com.weaver.hrm.salary.util.SalaryI18nUtil;
|
||
|
|
//import org.apache.commons.collections4.CollectionUtils;
|
||
|
|
//import org.apache.commons.lang3.math.NumberUtils;
|
||
|
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
//import org.springframework.stereotype.Component;
|
||
|
|
//
|
||
|
|
//import java.util.*;
|
||
|
|
//
|
||
|
|
///**
|
||
|
|
// * @description: 薪资项目
|
||
|
|
// * @author: xiajun
|
||
|
|
// * @modified By: xiajun
|
||
|
|
// * @date: Created in 1/17/22 4:00 PM
|
||
|
|
// * @version:v1.0
|
||
|
|
// */
|
||
|
|
//@Component
|
||
|
|
//public class SalaryItemWrapper {
|
||
|
|
//
|
||
|
|
// @Autowired
|
||
|
|
// private SalaryItemService salaryItemService;
|
||
|
|
// @Autowired
|
||
|
|
// private SalaryFormulaService salaryFormulaService;
|
||
|
|
// @Autowired
|
||
|
|
// private SalarySobItemService salarySobItemService;
|
||
|
|
// @Autowired
|
||
|
|
// private SysSalaryItemService sysSalaryItemService;
|
||
|
|
//
|
||
|
|
// /**
|
||
|
|
// * 薪资项目列表
|
||
|
|
// *
|
||
|
|
// * @param searchParam 查询参数
|
||
|
|
// * @param employeeId 人员id
|
||
|
|
// * @param tenantKey 租户key
|
||
|
|
// * @return
|
||
|
|
// */
|
||
|
|
// public WeaTable<SalaryItemListDTO> listPage(SalaryItemSearchParam searchParam, Long employeeId, String tenantKey) {
|
||
|
|
// // 查询薪资项目
|
||
|
|
// Page<SalaryItemPO> page = salaryItemService.listPageByParam(searchParam, tenantKey);
|
||
|
|
// Page<SalaryItemListDTO> dtoPage = new Page<>(page.getCurrent(), page.getSize(), page.getTotal(), page.isSearchCount());
|
||
|
|
// // 被薪资账套引用的薪资项目
|
||
|
|
// List<SalarySobItemPO> salarySobItems = Lists.newArrayListWithExpectedSize((int) page.getSize());
|
||
|
|
// if (CollectionUtils.isNotEmpty(page.getRecords())) {
|
||
|
|
// // 查询公式
|
||
|
|
// Set<Long> formulaIds = SalaryEntityUtil.properties(page.getRecords(), SalaryItemPO::getFormulaId);
|
||
|
|
// List<ExpressFormula> expressFormulas = salaryFormulaService.listExpressFormula(formulaIds, tenantKey);
|
||
|
|
// // 转换成薪资项目列表dto
|
||
|
|
// dtoPage.setRecords(SalaryItemBO.convert2ListDTO(page.getRecords(), expressFormulas));
|
||
|
|
// // 查询被账套引用的薪资项目
|
||
|
|
// Set<Long> salaryItemIds = SalaryEntityUtil.properties(page.getRecords(), SalaryItemPO::getId);
|
||
|
|
// salarySobItems = salarySobItemService.listBySalaryItemIds(salaryItemIds, tenantKey);
|
||
|
|
// }
|
||
|
|
// // 构建前端所需的数据格式
|
||
|
|
// WeaTable<SalaryItemListDTO> weaTable = SalaryFormatUtil.<SalaryItemListDTO>getInstance().buildTable(SalaryItemListDTO.class, dtoPage);
|
||
|
|
// // 被薪资账套引用的薪资项目不可删除
|
||
|
|
// if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isNotEmpty(salarySobItems)) {
|
||
|
|
// Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItems, SalarySobItemPO::getSalaryItemId);
|
||
|
|
// for (int i = 0; i < page.getRecords().size(); i++) {
|
||
|
|
// SalaryItemPO salaryItemPO = page.getRecords().get(i);
|
||
|
|
// if (salaryItemIds.contains(salaryItemPO.getId())) {
|
||
|
|
// Permission permission = weaTable.getOperatesPermission().get(i).get(1);
|
||
|
|
// permission.setVisible(false);
|
||
|
|
// permission.setDisabled(true);
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// return weaTable;
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// /**
|
||
|
|
// * 可以删除的薪资项目列表
|
||
|
|
// *
|
||
|
|
// * @param searchParam 查询人员
|
||
|
|
// * @param employeeId 人员id
|
||
|
|
// * @param tenantKey 租户key
|
||
|
|
// * @return
|
||
|
|
// */
|
||
|
|
// public WeaTable<SalaryItemListDTO> listPage4CanDelete(SalaryItemSearchParam searchParam, Long employeeId, String tenantKey) {
|
||
|
|
// // 查询所有薪资账套中的薪资项目副本
|
||
|
|
// List<SalarySobItemPO> salarySobItemPOS = salarySobItemService.list(tenantKey);
|
||
|
|
// // 被引用的薪资项目id
|
||
|
|
// Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
|
||
|
|
// // 排除被引用的薪资项目(被引用的薪资项目不可以删除)
|
||
|
|
// searchParam.setExcludeIds(salaryItemIds);
|
||
|
|
// // 转换成前端所需的数据格式
|
||
|
|
// WeaTable<SalaryItemListDTO> weaTable = listPage(searchParam, employeeId, tenantKey);
|
||
|
|
// weaTable.setTableType(WeaTableTypeEnum.CHECKBOX);
|
||
|
|
// weaTable.setOperates(Collections.emptyList());
|
||
|
|
// weaTable.setPageUid("canDeleteSalaryItemList");
|
||
|
|
// return weaTable;
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// /**
|
||
|
|
// * 根据主键id获取薪资项目详情
|
||
|
|
// *
|
||
|
|
// * @param ids 薪资项目的主键id
|
||
|
|
// * @param tenantKey 租户key
|
||
|
|
// * @return
|
||
|
|
// */
|
||
|
|
// public List<SalaryItemListDTO> listByIds(Collection<Long> ids, String tenantKey) {
|
||
|
|
// List<SalaryItemPO> salaryItemPOS = salaryItemService.listByIds(ids, tenantKey);
|
||
|
|
// if (CollectionUtils.isEmpty(salaryItemPOS)) {
|
||
|
|
// return Collections.emptyList();
|
||
|
|
// }
|
||
|
|
// // 查询公式详情
|
||
|
|
// Set<Long> formulaIds = SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getFormulaId);
|
||
|
|
// List<ExpressFormula> expressFormulas = salaryFormulaService.listExpressFormula(formulaIds, tenantKey);
|
||
|
|
// // 转换成薪资项目列表dto
|
||
|
|
// return SalaryItemBO.convert2ListDTO(salaryItemPOS, expressFormulas);
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// /**
|
||
|
|
// * 薪资项目列表的高级搜索
|
||
|
|
// *
|
||
|
|
// * @return
|
||
|
|
// */
|
||
|
|
// public WeaSearchCondition getSearchCondition() {
|
||
|
|
// WeaSearchCondition searchCondition = SalaryFormatUtil.<SalaryItemSearchConditionDTO>getInstance()
|
||
|
|
// .buildCondition(SalaryItemSearchConditionDTO.class, new SalaryItemSearchConditionDTO(), "salaryItemCondition");
|
||
|
|
// // "其他条件"不要
|
||
|
|
// searchCondition.getGroups().remove(1);
|
||
|
|
// return searchCondition;
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// /**
|
||
|
|
// * 薪资项目详情
|
||
|
|
// *
|
||
|
|
// * @param id 主键id
|
||
|
|
// * @param employeeId 人员id
|
||
|
|
// * @param tenantKey 租户key
|
||
|
|
// * @return
|
||
|
|
// */
|
||
|
|
// public WeaForm getForm(Long id, Long employeeId, String tenantKey) {
|
||
|
|
// SalaryItemFormDTO salaryItemFormDTO = new SalaryItemFormDTO();
|
||
|
|
// // 默认可以编辑
|
||
|
|
// salaryItemFormDTO.setCanEdit(NumberUtils.INTEGER_ONE);
|
||
|
|
// if (!Objects.isNull(id)) {
|
||
|
|
// // 查询薪资项目
|
||
|
|
// SalaryItemPO salaryItemPO = salaryItemService.getById(id, tenantKey);
|
||
|
|
// // 系统薪资项目
|
||
|
|
// SysSalaryItemPO sysSalaryItemPO = sysSalaryItemService.getById(id);
|
||
|
|
// if (Objects.isNull(salaryItemPO) && Objects.isNull(sysSalaryItemPO)) {
|
||
|
|
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 98299, "参数错误,薪资项目不存在或已被删除"));
|
||
|
|
// }
|
||
|
|
// // 公式详情
|
||
|
|
// ExpressFormula expressFormula;
|
||
|
|
// // 转换成薪资项目详情dto
|
||
|
|
// if (Objects.isNull(salaryItemPO)) {
|
||
|
|
// salaryItemFormDTO = SysSalaryItemBO.convert2FormDTO(sysSalaryItemPO);
|
||
|
|
// expressFormula = salaryFormulaService.getExpressFormula(sysSalaryItemPO.getFormulaId(), tenantKey);
|
||
|
|
// } else {
|
||
|
|
// salaryItemFormDTO = SalaryItemBO.convert2FormDTO(salaryItemPO);
|
||
|
|
// expressFormula = salaryFormulaService.getExpressFormula(salaryItemPO.getFormulaId(), tenantKey);
|
||
|
|
// }
|
||
|
|
// salaryItemFormDTO.setFormulaContent(Optional.ofNullable(expressFormula).map(ExpressFormula::getFormula).orElse(""));
|
||
|
|
// }
|
||
|
|
// // 转换成前端所需的数据格式
|
||
|
|
// WeaForm weaForm = SalaryFormatUtil.<SalaryItemFormDTO>getInstance().buildForm(SalaryItemFormDTO.class, salaryItemFormDTO);
|
||
|
|
// if (Objects.nonNull(id)) {
|
||
|
|
// for (Map.Entry<String, WeaFormItem> entry : weaForm.getItems().entrySet()) {
|
||
|
|
// // 取值方式是否可以编辑
|
||
|
|
// if (("valueType".equals(entry.getKey()) || "useInEmployeeSalary".equals(entry.getKey()))
|
||
|
|
// && Objects.equals(salaryItemFormDTO.getCanEdit(), NumberUtils.INTEGER_ZERO)) {
|
||
|
|
// entry.getValue().setReadOnly(true);
|
||
|
|
// }
|
||
|
|
// // 属性"、"类型"不允许编辑
|
||
|
|
// if ("category".equals(entry.getKey()) || "itemType".equals(entry.getKey())) {
|
||
|
|
// entry.getValue().setReadOnly(true);
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// return weaForm;
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// /**
|
||
|
|
// * 获取薪资项目可选的类型(与属性有联动)
|
||
|
|
// *
|
||
|
|
// * @param employeeId 人员id
|
||
|
|
// * @param tenantKey 租户key
|
||
|
|
// * @return
|
||
|
|
// */
|
||
|
|
// public Map<String, List<WeaFormOption>> listSalaryItemTypeOption(Long employeeId, String tenantKey) {
|
||
|
|
// return SalaryEntityUtil.group2ListMap(Arrays.asList(SalaryItemTypeEnum.values()),
|
||
|
|
// e -> e.getCategory().name(),
|
||
|
|
// e -> new WeaFormOption(e.name(), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, e.getLabelId(), e.getDefaultLabel())));
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// /**
|
||
|
|
// * 保存薪资项目
|
||
|
|
// *
|
||
|
|
// * @param saveParam 保存参数
|
||
|
|
// * @param employeeId 人员id
|
||
|
|
// * @param tenantKey 租户key
|
||
|
|
// */
|
||
|
|
// public void save(SalaryItemSaveParam saveParam, Long employeeId, String tenantKey) {
|
||
|
|
// salaryItemService.save(saveParam, employeeId, tenantKey);
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// /**
|
||
|
|
// * 编辑薪资项目
|
||
|
|
// *
|
||
|
|
// * @param saveParam 更新参数
|
||
|
|
// * @param employeeId 人员id
|
||
|
|
// * @param tenantKey 租户key
|
||
|
|
// */
|
||
|
|
// public void update(SalaryItemSaveParam saveParam, Long employeeId, String tenantKey) {
|
||
|
|
// salaryItemService.update(saveParam, employeeId, tenantKey);
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// /**
|
||
|
|
// * 删除薪资项目
|
||
|
|
// *
|
||
|
|
// * @param ids 主键id
|
||
|
|
// * @param tenantKey 租户key
|
||
|
|
// */
|
||
|
|
// public void delete(Collection<Long> ids, String tenantKey) {
|
||
|
|
// salaryItemService.deleteByIds(ids, tenantKey);
|
||
|
|
// }
|
||
|
|
//}
|