同步字段名称到项目公式
This commit is contained in:
parent
bf8ae9fd09
commit
6e889ccc70
|
|
@ -148,13 +148,13 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
|
|||
.sorted(new Comparator<SalaryItemPO>() {
|
||||
@Override
|
||||
public int compare(SalaryItemPO o1, SalaryItemPO o2) {
|
||||
if(o1.getSortedIndex() == null && o2.getSortedIndex() == null){
|
||||
Integer systemType1=o1.getSystemType() == null ? 0 : o1.getSystemType();
|
||||
Integer systemType2=o2.getSystemType() == null ? 0 : o2.getSystemType();
|
||||
if (o1.getSortedIndex() == null && o2.getSortedIndex() == null) {
|
||||
Integer systemType1 = o1.getSystemType() == null ? 0 : o1.getSystemType();
|
||||
Integer systemType2 = o2.getSystemType() == null ? 0 : o2.getSystemType();
|
||||
return systemType1.compareTo(systemType2);
|
||||
}else{
|
||||
Integer sortedIndex1=o1.getSortedIndex() == null ? 0 : o1.getSortedIndex();
|
||||
Integer sortedIndex2=o2.getSortedIndex() == null ? 0 : o2.getSortedIndex();
|
||||
} else {
|
||||
Integer sortedIndex1 = o1.getSortedIndex() == null ? 0 : o1.getSortedIndex();
|
||||
Integer sortedIndex2 = o2.getSortedIndex() == null ? 0 : o2.getSortedIndex();
|
||||
return sortedIndex2.compareTo(sortedIndex1);
|
||||
}
|
||||
}
|
||||
|
|
@ -263,35 +263,24 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
|
|||
if (!StringUtils.equals(oldName, newName)) {
|
||||
|
||||
//薪资项目
|
||||
String itemPrefix = newSalaryItemPO.getUseInEmployeeSalary() == 0 ? "salaryItem_" : "salaryArchives_";
|
||||
String fieldNamePrefix = newSalaryItemPO.getUseInEmployeeSalary() == 0 ? "{薪资项目.%s}" : "{薪资档案.%s}";
|
||||
|
||||
String code = itemPrefix + salaryItemPO.getCode();
|
||||
Date now = new Date();
|
||||
List<FormulaVar> formulaVars = getSalaryFormulaService(user).listByCode(code);
|
||||
formulaVars.forEach(v -> {
|
||||
FormulaVar formulaVar = FormulaVar.builder()
|
||||
.id(v.getId())
|
||||
.name(newName)
|
||||
.fieldName(String.format(fieldNamePrefix, newName))
|
||||
.updateTime(now)
|
||||
.build();
|
||||
getSalaryFormulaService(user).updateVar(formulaVar);
|
||||
});
|
||||
if (newSalaryItemPO.getUseInEmployeeSalary() == 0) {
|
||||
String itemPrefix = "salaryItem_";
|
||||
String fieldNamePrefix = "{薪资项目.%s}";
|
||||
changeName(salaryItemPO, oldName, newName, itemPrefix, fieldNamePrefix);
|
||||
}
|
||||
|
||||
List<Long> formulaIds = SalaryEntityUtil.properties(formulaVars, FormulaVar::getFormulaId, Collectors.toList());
|
||||
List<FormulaPO> formulaPOS = getSalaryFormulaService(user).listByIds(formulaIds);
|
||||
formulaPOS.forEach(f -> {
|
||||
String formula = f.getFormula();
|
||||
formula = formula.replace(String.format(fieldNamePrefix, oldName), String.format(fieldNamePrefix, newName));
|
||||
FormulaPO formulaPO = FormulaPO.builder()
|
||||
.id(f.getId())
|
||||
.formula(formula)
|
||||
.updateTime(now)
|
||||
.build();
|
||||
getSalaryFormulaService(user).update(formulaPO);
|
||||
});
|
||||
if (newSalaryItemPO.getUseInEmployeeSalary() == 1) {
|
||||
//引用档案
|
||||
String itemPrefix = "salaryArchives_";
|
||||
String fieldNamePrefix = "{薪资档案.%s}";
|
||||
changeName(salaryItemPO, oldName, newName, itemPrefix, fieldNamePrefix);
|
||||
|
||||
//引用项目
|
||||
itemPrefix = "salaryItem_";
|
||||
fieldNamePrefix = "{薪资项目.%s}";
|
||||
changeName(salaryItemPO, oldName, newName, itemPrefix, fieldNamePrefix);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -307,6 +296,34 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
|
|||
// salaryItemLoggerTemplate.write(loggerContext);
|
||||
}
|
||||
|
||||
private void changeName(SalaryItemPO salaryItemPO, String oldName, String newName, String itemPrefix, String fieldNamePrefix) {
|
||||
String code = itemPrefix + salaryItemPO.getCode();
|
||||
Date now = new Date();
|
||||
List<FormulaVar> formulaVars = getSalaryFormulaService(user).listByCode(code);
|
||||
formulaVars.forEach(v -> {
|
||||
FormulaVar formulaVar = FormulaVar.builder()
|
||||
.id(v.getId())
|
||||
.name(newName)
|
||||
.fieldName(String.format(fieldNamePrefix, newName))
|
||||
.updateTime(now)
|
||||
.build();
|
||||
getSalaryFormulaService(user).updateVar(formulaVar);
|
||||
});
|
||||
|
||||
List<Long> formulaIds = SalaryEntityUtil.properties(formulaVars, FormulaVar::getFormulaId, Collectors.toList());
|
||||
List<FormulaPO> formulaPOS = getSalaryFormulaService(user).listByIds(formulaIds);
|
||||
formulaPOS.forEach(f -> {
|
||||
String formula = f.getFormula();
|
||||
formula = formula.replace(String.format(fieldNamePrefix, oldName), String.format(fieldNamePrefix, newName));
|
||||
FormulaPO formulaPO = FormulaPO.builder()
|
||||
.id(f.getId())
|
||||
.formula(formula)
|
||||
.updateTime(now)
|
||||
.build();
|
||||
getSalaryFormulaService(user).update(formulaPO);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByIds(Collection<Long> ids) {
|
||||
SalaryItemServiceImpl.UsingItem usingItem = getUsingItem();
|
||||
|
|
@ -423,7 +440,7 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
|
|||
}
|
||||
// 获取薪资账套中薪资项目信息
|
||||
List<SalarySobItemPO> salarySobItemPOS = getSalarySobItemService(user).listBySalaryItemIds(Collections.singleton(param.getSalaryItemId()));
|
||||
salarySobItemPOS = salarySobItemPOS.stream().filter( po -> param.getSalarySobIds().contains(po.getSalarySobId())).collect(Collectors.toList());
|
||||
salarySobItemPOS = salarySobItemPOS.stream().filter(po -> param.getSalarySobIds().contains(po.getSalarySobId())).collect(Collectors.toList());
|
||||
// 更新薪资账套中的薪资项目信息
|
||||
Date now = new Date();
|
||||
for (SalarySobItemPO sobItem : salarySobItemPOS) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue