This commit is contained in:
钱涛 2023-02-17 10:54:18 +08:00
parent 1d0a02554e
commit da9b548480
4 changed files with 78 additions and 18 deletions

View File

@ -93,6 +93,7 @@ public class SalaryItemBO {
SalaryDataTypeEnum salaryDataTypeEnum = SalaryDataTypeEnum.parseByValue(salaryItemPO.getDataType());
return SalaryItemListDTO.builder()
.id(salaryItemPO.getId())
.code(salaryItemPO.getCode())
.name(salaryItemPO.getName())
.systemName(sysSalaryItemNameMap.getOrDefault(salaryItemPO.getSysSalaryItemId(), StringUtils.EMPTY))
.useInEmployeeSalary(salaryItemPO.getUseInEmployeeSalary())
@ -220,10 +221,10 @@ public class SalaryItemBO {
.taxAgentIds(saveParam.getTaxAgentIds())
.build();
// 开启了"薪资档案引用"取值方式固定为输入
if (Objects.equals(saveParam.getUseInEmployeeSalary(), NumberUtils.INTEGER_ONE)) {
salaryItemPO.setValueType(SalaryValueTypeEnum.INPUT.getValue());
salaryItemPO.setFormulaId(NumberUtils.LONG_ZERO);
}
// if (Objects.equals(saveParam.getUseInEmployeeSalary(), NumberUtils.INTEGER_ONE)) {
// salaryItemPO.setValueType(SalaryValueTypeEnum.INPUT.getValue());
// salaryItemPO.setFormulaId(NumberUtils.LONG_ZERO);
// }
return salaryItemPO;
}
}

View File

@ -35,6 +35,7 @@ public class SalaryItemListDTO {
@SalaryTableColumn(text = "名称", width = "10%", column = "name")
@TableTitle(title = "名称",dataIndex = "name",key = "name")
private String name;
private String code;
@SalaryTableColumn(text = "系统名", width = "10%", column = "systemName")
@TableTitle(title = "系统名",dataIndex = "systemName",key = "systemName")

View File

@ -193,7 +193,7 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
newSalaryItemPO.setUseInEmployeeSalary(saveParam.getUseInEmployeeSalary());
newSalaryItemPO.setRoundingMode(saveParam.getRoundingMode());
newSalaryItemPO.setPattern(saveParam.getPattern());
newSalaryItemPO.setValueType(saveParam.getValueType());
// newSalaryItemPO.setValueType(saveParam.getValueType());
newSalaryItemPO.setDataType(saveParam.getDataType());
newSalaryItemPO.setFormulaId(Objects.equals(saveParam.getValueType(), SalaryValueTypeEnum.INPUT.getValue()) ? 0L : saveParam.getFormulaId());
newSalaryItemPO.setDescription(saveParam.getDescription());
@ -224,6 +224,9 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
if (CollectionUtils.isNotEmpty(salarySobItemPOS)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98322, "薪资账套正在使用该薪资项目,不允许删除"));
}
// 删除薪资项目
ids = SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getId);
salaryItemBiz.deleteByIds(ids);

View File

@ -25,6 +25,7 @@ import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.valid.RuntimeTypeEnum;
import com.engine.salary.util.valid.ValidUtil;
import lombok.Builder;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.lang3.StringUtils;
@ -99,7 +100,7 @@ public class SalaryItemWrapper extends Service {
usingItemIds.addAll(backItemIds);
List<FormulaVar> formulaVars = getSalaryFormulaService(user).listVarByFormulaIds(effectiveFormulaIds);
SalaryEntityUtil.properties(formulaVars, FormulaVar::getFieldId, Collectors.toList());
List<String> itemCode = formulaVars.stream().map(FormulaVar::getFieldId).map(v -> v.replaceAll("salaryItem_", "")).collect(Collectors.toList());
//!!! 从2023-01-23起薪资项目这里不再查询薪资档案引用的项目 !!!
//薪资档案引用的项目转移到字段管理功能项
@ -128,21 +129,10 @@ public class SalaryItemWrapper extends Service {
List<SalaryItemListDTO> salaryItemListDTOS = SalaryItemBO.convert2ListDTO(salaryItemList, expressFormulas, sysSalaryItemPOS);
//系统项目不删除
salaryItemListDTOS.forEach(dto -> {
if (StringUtils.isNotBlank(dto.getSystemName()) || usingItemIds.contains(dto.getId()) ) {
if (StringUtils.isNotBlank(dto.getSystemName()) || usingItemIds.contains(dto.getId()) || itemCode.contains(dto.getCode())) {
dto.setCanDelete(false);
}
});
//3被引用的薪资项目不能删除
Set<Long> salaryItemIds = SalaryEntityUtil.properties(salaryItemList, SalaryItemPO::getId);
salarySobItems = getSalarySobItemService(user).listBySalaryItemIds(salaryItemIds);
if (CollectionUtils.isNotEmpty(salarySobItems)) {
Set<Long> salaryItemIdsUseBySob = SalaryEntityUtil.properties(salarySobItems, SalarySobItemPO::getSalaryItemId);
salaryItemListDTOS.forEach(dto -> {
if (salaryItemIdsUseBySob.contains(dto.getId())) {
dto.setCanDelete(false);
}
});
}
salaryItemListDTOPage.setList(salaryItemListDTOS);
}
@ -277,6 +267,71 @@ public class SalaryItemWrapper extends Service {
* @param ids 主键id
*/
public void delete(Collection<Long> ids) {
//清除未被引用的公式
List<Long> effectiveFormulaIds = getEffectiveFormulaIds();
//删除无用公式
// getSalaryFormulaService(user).deleteNotIn(effectiveFormulaIds);
//账套里的项目项目里的项目
List<Long> sobItemIds = SalaryEntityUtil.properties(sobItems, SalarySobItemPO::getSalaryItemId, Collectors.toList());
List<Long> backItemIds = SalaryEntityUtil.properties(backItems, SalarySobBackItemPO::getSalaryItemId, Collectors.toList());
List<Long> usingItemIds = new ArrayList<>();
usingItemIds.addAll(sobItemIds);
usingItemIds.addAll(backItemIds);
List<FormulaVar> formulaVars = getSalaryFormulaService(user).listVarByFormulaIds(effectiveFormulaIds);
List<String> itemCode = formulaVars.stream().map(FormulaVar::getFieldId).map(v -> v.replaceAll("salaryItem_", "")).collect(Collectors.toList());
// 查询薪资项目
List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listByIds(ids);
if (CollectionUtils.isEmpty(salaryItemPOS)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98299, "参数错误,薪资项目不存在或已被删除"));
}
if (CollectionUtils.containsAny(usingItemIds, ids)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98322, "薪资账套正在使用该薪资项目,不允许删除"));
}
List<String> codes = SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getCode, Collectors.toList());
if (CollectionUtils.containsAny(itemCode, codes)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98322, "公式正在使用该薪资项目,不允许删除"));
}
getSalaryItemService(user).deleteByIds(ids);
}
private usingItemAndFormulaIds getUsingFormulaIds() {
//系统项目
List<SysSalaryItemPO> sysItems = getSysSalaryItemService(user).listAll();
List<Long> sysItemFormulaIds = SalaryEntityUtil.properties(sysItems, SysSalaryItemPO::getFormulaId, Collectors.toList());
//薪资项目
List<SalaryItemPO> items = getSalaryItemService(user).listAll();
List<Long> itemFormulaIds = SalaryEntityUtil.properties(items, SalaryItemPO::getFormulaId, Collectors.toList());
//账套项目
List<SalarySobItemPO> sobItems = getSalarySobItemService(user).list();
List<Long> sobItemFormulaIds = SalaryEntityUtil.properties(sobItems, SalarySobItemPO::getFormulaId, Collectors.toList());
//回算项目
List<SalarySobBackItemPO> backItems = getSalarySobBackItemService(user).listAll();
List<Long> backItemFormulaIds = SalaryEntityUtil.properties(backItems, SalarySobBackItemPO::getFormulaId, Collectors.toList());
List<Long> usingFormulaIds = new ArrayList<>();
usingFormulaIds.addAll(sysItemFormulaIds);
usingFormulaIds.addAll(itemFormulaIds);
usingFormulaIds.addAll(sobItemFormulaIds);
usingFormulaIds.addAll(backItemFormulaIds);
return usingFormulaIds;
}
@Builder
class UsingItemAndFormulaIds {
private List<Long> usingFormulaIds;
private List<Long> usingItemIds;
}
}