mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 15:55:18 +08:00
完善工资
This commit is contained in:
@@ -21,6 +21,10 @@ import cn.lihongjie.coal.exception.BizException;
|
|||||||
import groovy.lang.GroovyClassLoader;
|
import groovy.lang.GroovyClassLoader;
|
||||||
import groovy.lang.Script;
|
import groovy.lang.Script;
|
||||||
|
|
||||||
|
import io.vavr.Tuple;
|
||||||
|
import io.vavr.Tuple2;
|
||||||
|
import io.vavr.collection.Stream;
|
||||||
|
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import jakarta.persistence.PersistenceContext;
|
import jakarta.persistence.PersistenceContext;
|
||||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||||
@@ -216,40 +220,44 @@ public class EmpSalaryItemService
|
|||||||
item.setDependOnSysItem(new ArrayList<>());
|
item.setDependOnSysItem(new ArrayList<>());
|
||||||
|
|
||||||
// 按照名称长度倒序排序
|
// 按照名称长度倒序排序
|
||||||
enabled.stream()
|
|
||||||
.sorted(
|
|
||||||
Comparator.comparing(
|
|
||||||
x -> x.getName().length(), Comparator.reverseOrder()))
|
|
||||||
.forEachOrdered(
|
|
||||||
x -> {
|
|
||||||
if (StringUtils.isNotEmpty(x.getName())
|
|
||||||
&& formulaAtomic.get().contains(x.getName())) {
|
|
||||||
// 刷新依赖关系
|
|
||||||
dependOn.add(x.getCode());
|
|
||||||
item.getDependOn().add(x.getCode());
|
|
||||||
|
|
||||||
// 把表达式中的名称替换为代码
|
Stream.<Tuple2<String, Object>>ofAll(
|
||||||
formulaAtomic.set(
|
enabled.stream().map(x -> Tuple.of(x.getName(), x)))
|
||||||
formulaAtomic
|
.appendAll(Stream.ofAll(sysItems.stream().map(x -> Tuple.of(x.getName(), x))))
|
||||||
.get()
|
.sorted(Comparator.comparing(x -> x._1.length(), Comparator.reverseOrder()))
|
||||||
.replace(x.getName(), "salary." + x.getCode()));
|
.forEach(
|
||||||
|
x -> {
|
||||||
|
if (StringUtils.isNotEmpty(x._1)
|
||||||
|
&& formulaAtomic.get().contains(x._1)) {
|
||||||
|
|
||||||
|
if (x._2 instanceof EmpSalarySysItemEntity z) {
|
||||||
|
|
||||||
|
// 刷新依赖关系
|
||||||
|
dependOn.add(z.getCode());
|
||||||
|
item.getDependOnSysItem().add(z.getCode());
|
||||||
|
|
||||||
|
// 把表达式中的名称替换为代码
|
||||||
|
formulaAtomic.set(
|
||||||
|
formulaAtomic
|
||||||
|
.get()
|
||||||
|
.replace(z.getName(), z.getCode()));
|
||||||
|
} else if (x._2 instanceof EmpSalaryItemEntity y) {
|
||||||
|
// 刷新依赖关系
|
||||||
|
// 刷新依赖关系
|
||||||
|
dependOn.add(y.getCode());
|
||||||
|
item.getDependOn().add(y.getCode());
|
||||||
|
|
||||||
|
// 把表达式中的名称替换为代码
|
||||||
|
formulaAtomic.set(
|
||||||
|
formulaAtomic
|
||||||
|
.get()
|
||||||
|
.replace(
|
||||||
|
y.getName(),
|
||||||
|
"salary." + y.getCode()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
sysItems.forEach(
|
|
||||||
x -> {
|
|
||||||
if (StringUtils.isNotEmpty(x.getName())
|
|
||||||
&& formulaAtomic.get().contains(x.getName())) {
|
|
||||||
// 刷新依赖关系
|
|
||||||
dependOn.add(x.getCode());
|
|
||||||
item.getDependOnSysItem().add(x.getCode());
|
|
||||||
|
|
||||||
// 把表达式中的名称替换为代码
|
|
||||||
formulaAtomic.set(
|
|
||||||
formulaAtomic.get().replace(x.getName(), x.getCode()));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
item.setDependOn(item.getDependOn().stream().distinct().toList());
|
item.setDependOn(item.getDependOn().stream().distinct().toList());
|
||||||
item.setDependOnSysItem(item.getDependOnSysItem().stream().distinct().toList());
|
item.setDependOnSysItem(item.getDependOnSysItem().stream().distinct().toList());
|
||||||
String formula = formulaAtomic.get();
|
String formula = formulaAtomic.get();
|
||||||
@@ -358,6 +366,14 @@ public class EmpSalaryItemService
|
|||||||
throw new BizException("工资项目名称重复");
|
throw new BizException("工资项目名称重复");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkSysItemName(entity);
|
||||||
|
|
||||||
|
this.repository.save(entity);
|
||||||
|
this.reSyncAll(entity.getOrganizationId(), null, request.getName());
|
||||||
|
return getById(entity.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkSysItemName(EmpSalaryItemEntity entity) {
|
||||||
if (CollectionUtils.isNotEmpty(
|
if (CollectionUtils.isNotEmpty(
|
||||||
empSalarySysItemService.findAll(
|
empSalarySysItemService.findAll(
|
||||||
new Specification<EmpSalarySysItemEntity>() {
|
new Specification<EmpSalarySysItemEntity>() {
|
||||||
@@ -373,10 +389,6 @@ public class EmpSalaryItemService
|
|||||||
}))) {
|
}))) {
|
||||||
throw new BizException("与系统预设项目名称重复, 请换一个名称");
|
throw new BizException("与系统预设项目名称重复, 请换一个名称");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.repository.save(entity);
|
|
||||||
this.reSyncAll(entity.getOrganizationId(), null, request.getName());
|
|
||||||
return getById(entity.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reSyncAll(String organizationId, String oldName, String newName) {
|
private void reSyncAll(String organizationId, String oldName, String newName) {
|
||||||
@@ -475,6 +487,8 @@ public class EmpSalaryItemService
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkSysItemName(entity);
|
||||||
|
|
||||||
this.mapper.updateEntity(entity, request);
|
this.mapper.updateEntity(entity, request);
|
||||||
|
|
||||||
this.repository.save(entity);
|
this.repository.save(entity);
|
||||||
|
|||||||
Reference in New Issue
Block a user