diff --git a/src/main/java/cn/lihongjie/coal/empSalaryItem/dto/CreateEmpSalaryItemDto.java b/src/main/java/cn/lihongjie/coal/empSalaryItem/dto/CreateEmpSalaryItemDto.java index 7547bd3a..19b00dec 100644 --- a/src/main/java/cn/lihongjie/coal/empSalaryItem/dto/CreateEmpSalaryItemDto.java +++ b/src/main/java/cn/lihongjie/coal/empSalaryItem/dto/CreateEmpSalaryItemDto.java @@ -8,8 +8,12 @@ import org.hibernate.annotations.Comment; import org.hibernate.annotations.Formula; @Data + public class CreateEmpSalaryItemDto extends OrgCommonDto { + + @Comment("是否展示") + private Boolean show; @Comment("上级名称") private String parentName; diff --git a/src/main/java/cn/lihongjie/coal/empSalaryItem/dto/EmpSalaryItemDto.java b/src/main/java/cn/lihongjie/coal/empSalaryItem/dto/EmpSalaryItemDto.java index cf06756e..9ffd8216 100644 --- a/src/main/java/cn/lihongjie/coal/empSalaryItem/dto/EmpSalaryItemDto.java +++ b/src/main/java/cn/lihongjie/coal/empSalaryItem/dto/EmpSalaryItemDto.java @@ -15,6 +15,8 @@ public class EmpSalaryItemDto extends OrgCommonDto { @Comment("上级名称") private String parentName; + @Comment("是否展示") + private Boolean show; @Comment("工资项目类型") diff --git a/src/main/java/cn/lihongjie/coal/empSalaryItem/dto/UpdateEmpSalaryItemDto.java b/src/main/java/cn/lihongjie/coal/empSalaryItem/dto/UpdateEmpSalaryItemDto.java index 93887b4e..eda5b8f5 100644 --- a/src/main/java/cn/lihongjie/coal/empSalaryItem/dto/UpdateEmpSalaryItemDto.java +++ b/src/main/java/cn/lihongjie/coal/empSalaryItem/dto/UpdateEmpSalaryItemDto.java @@ -16,6 +16,8 @@ public class UpdateEmpSalaryItemDto extends OrgCommonDto { + @Comment("是否展示") + private Boolean show; @Comment("工资项目类型") private String itemType; diff --git a/src/main/java/cn/lihongjie/coal/empSalaryItem/entity/EmpSalaryItemEntity.java b/src/main/java/cn/lihongjie/coal/empSalaryItem/entity/EmpSalaryItemEntity.java index 8a55b706..b8d49a9b 100644 --- a/src/main/java/cn/lihongjie/coal/empSalaryItem/entity/EmpSalaryItemEntity.java +++ b/src/main/java/cn/lihongjie/coal/empSalaryItem/entity/EmpSalaryItemEntity.java @@ -15,6 +15,8 @@ import java.util.List; @Entity public class EmpSalaryItemEntity extends OrgCommonEntity { + @Comment("是否展示") + private Boolean show; @Comment("上级名称") private String parentName; diff --git a/src/main/java/cn/lihongjie/coal/empSalaryItem/service/EmpSalaryItemService.java b/src/main/java/cn/lihongjie/coal/empSalaryItem/service/EmpSalaryItemService.java index 1cb1f683..9b596690 100644 --- a/src/main/java/cn/lihongjie/coal/empSalaryItem/service/EmpSalaryItemService.java +++ b/src/main/java/cn/lihongjie/coal/empSalaryItem/service/EmpSalaryItemService.java @@ -13,6 +13,7 @@ import cn.lihongjie.coal.empSalaryItem.dto.UpdateEmpSalaryItemDto; import cn.lihongjie.coal.empSalaryItem.entity.EmpSalaryItemEntity; import cn.lihongjie.coal.empSalaryItem.mapper.EmpSalaryItemMapper; import cn.lihongjie.coal.empSalaryItem.repository.EmpSalaryItemRepository; +import cn.lihongjie.coal.empSalaryItemConfig.entity.EmpSalaryItemConfigEntity; import cn.lihongjie.coal.empSalaryItemConfig.service.EmpSalaryItemConfigService; import cn.lihongjie.coal.empSalaryStandard.dto.EmpSalaryStandardResult; import cn.lihongjie.coal.empSalaryStandard.service.EmpSalaryStandardService; @@ -64,7 +65,7 @@ public class EmpSalaryItemService @Autowired private EmpSalaryItemConfigService empSalaryItemConfigService; @Autowired private EmpSalaryStandardService empSalaryStandardService; - private static void updatePriority(List enabled) { + private void updatePriority(List enabled) { DefaultDirectedGraph graph = new DefaultDirectedGraph<>(DefaultEdge.class); @@ -110,8 +111,24 @@ public class EmpSalaryItemService } } - private static void updateDep( - List enabled, List allItems) { + private void updateDep(List enabled, List allItems) { + + List all = + empSalaryItemConfigService.findAll( + new Specification() { + @Override + public Predicate toPredicate( + Root root, + CriteriaQuery query, + CriteriaBuilder criteriaBuilder) { + return criteriaBuilder.and( + criteriaBuilder.equal( + root.get("organizationId"), + Ctx.currentUser().getOrganizationId()), + criteriaBuilder.equal(root.get("status"), 1)); + } + }); + for (EmpSalaryItemEntity item : enabled) { if (StringUtils.equalsAnyIgnoreCase(item.getInputType(), "1")) { @@ -129,24 +146,38 @@ public class EmpSalaryItemService String formula = item.getFormulaShow(); List dependOn = new ArrayList<>(); - for (EmpSalaryItemEntity it : allItems) { - - var tmp = RegExUtils.replaceAll(formula, Pattern.quote(it.getName()), it.getCode()); + // for (EmpSalaryItemEntity it : allItems) { + // + // var tmp = RegExUtils.replaceAll(formula, Pattern.quote(it.getName()), + // it.getCode()); + // + // if (!StringUtils.equals(tmp, formula)) { + // + // if (it.getStatus() != 1) { + // throw new BizException("公式计算项依赖项未启用: " + it.getName()); + // } + // + // formula = tmp; + // + // dependOn.add(it.getCode()); + // } + // } + for (EmpSalaryItemConfigEntity it : all) { + var tmp = + RegExUtils.replaceAll( + formula, Pattern.quote(it.getName()), it.getExpression()); if (!StringUtils.equals(tmp, formula)) { - - if (it.getStatus() != 1) { - throw new BizException("公式计算项依赖项未启用: " + it.getName()); - } - formula = tmp; - dependOn.add(it.getCode()); + // 如果是工资字段 + if (StringUtils.equals(it.getItemType(), "1")){ + dependOn.add(it.getCode().replace("salary_", "")); + } } } item.setDependOn(dependOn); - try { GroovyScriptUtils.validate(formula); } catch (Exception e) { @@ -165,7 +196,7 @@ public class EmpSalaryItemService * @param yfItems * @param kfItems */ - private static void handleHeji( + private void handleHeji( List enabled, List yfItems, List kfItems) { @@ -192,6 +223,12 @@ public class EmpSalaryItemService kfHeji.setFormulaShow( kfItems.stream().map(x -> x.getName()).collect(Collectors.joining(" + "))); + yfHeji.setFormula(StringUtils.defaultIfEmpty(yfHeji.getFormula(), "0")); + kfHeji.setFormula(StringUtils.defaultIfEmpty(kfHeji.getFormula(), "0")); + + yfHeji.setFormulaShow(StringUtils.defaultIfEmpty(yfHeji.getFormulaShow(), "0")); + kfHeji.setFormulaShow(StringUtils.defaultIfEmpty(kfHeji.getFormulaShow(), "0")); + yfHeji.setPriority(1000); kfHeji.setPriority(1000); } @@ -414,13 +451,12 @@ public class EmpSalaryItemService long totalTime = stdTime + newInstanceTime + setPropertyTime + runTime + genClassTime; log.info( - "totalTime: {} ns {} ms {}%\n" + "totalTime: {} ns {} ms {}%\n" + "genClassTime: {} ns {} ms {}%\n" + "stdTime: {} ns {} ms {}%\n" + "newInstanceTime: {} ns {} ms {}%\n" + "setPropertyTime: {} ns {} ms {}%\n" - + "runTime: {} ns {} ms {}%\n" - , + + "runTime: {} ns {} ms {}%\n", totalTime, totalTime / 1000000, 1L * 100.0, diff --git a/src/main/java/cn/lihongjie/coal/empSalaryItemConfig/service/EmpSalaryItemConfigService.java b/src/main/java/cn/lihongjie/coal/empSalaryItemConfig/service/EmpSalaryItemConfigService.java index cd84c412..9e28f1e1 100644 --- a/src/main/java/cn/lihongjie/coal/empSalaryItemConfig/service/EmpSalaryItemConfigService.java +++ b/src/main/java/cn/lihongjie/coal/empSalaryItemConfig/service/EmpSalaryItemConfigService.java @@ -86,9 +86,10 @@ public class EmpSalaryItemConfigService @Autowired EmpSalaryItemService empSalaryItemService; @NotNull - private static EmpSalaryItemConfigEntity createEmpConfig(String organizationId, String expression, String expressionShow, boolean systemPreset, String itemType) { + private static EmpSalaryItemConfigEntity createEmpConfig(String organizationId,String name, String code, String expression, String expressionShow, boolean systemPreset, String itemType) { EmpSalaryItemConfigEntity config = new EmpSalaryItemConfigEntity(); - config.setName(expressionShow); + config.setName(name); + config.setCode(code); config.setOrganizationId(organizationId); config.setItemType(itemType); config.setExpression(expression); @@ -150,9 +151,9 @@ public class EmpSalaryItemConfigService long delete = repository.deleteByOrganizationIdAndItemType(organizationId, "3"); - this.repository.save(createEmpConfig(organizationId, "batch?.batchYearMonth?.year", "发放年度", false, "3")); - this.repository.save(createEmpConfig(organizationId, "batch?.batchYearMonth?.monthValue", "发放月份", false, "3")); - this.repository.save(createEmpConfig(organizationId, "batch?.batchNo", "发放批次号", false, "3")); + this.repository.save(createEmpConfig(organizationId, "发放年度", "batchYear", "batch?.batchYearMonth?.year", "发放年度", false, "3")); + this.repository.save(createEmpConfig(organizationId, "发放月份", "batchMonth", "batch?.batchYearMonth?.monthValue", "发放月份", false, "3")); + this.repository.save(createEmpConfig(organizationId, "发放批次号", "batchNo", "batch?.batchNo", "发放批次号", false, "3")); } @@ -178,7 +179,7 @@ public class EmpSalaryItemConfigService for (EmpSalaryStandardEntity item : items) { - this.repository.save(createEmpConfig(organizationId, "stdMap[\"" + item.getName() + "\"]", item.getName(),true, "2")); + this.repository.save(createEmpConfig(organizationId, item.getName(), "std_" + item.getCode(), "stdMap[\"" + item.getName() + "\"]", item.getName(),true, "2")); } } @@ -187,35 +188,35 @@ public class EmpSalaryItemConfigService long delete = repository.deleteByOrganizationIdAndItemType(organizationId, "0"); - this.repository.save(createEmpConfig(organizationId, "emp?.department?.code", "部门编码", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp?.department?.name", "部门名称", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp?.jobPost?.code", "岗位编码", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp?.jobPost?.name", "岗位名称", false, "0")); + this.repository.save(createEmpConfig(organizationId,"部门编码", "emp_departmentCode", "emp?.department?.code", "部门编码", false, "0")); + this.repository.save(createEmpConfig(organizationId,"部门名称", "emp_departmentName", "emp?.department?.name", "部门名称", false, "0")); + this.repository.save(createEmpConfig(organizationId,"岗位编码", "emp_jobPostCode", "emp?.jobPost?.code", "岗位编码", false, "0")); + this.repository.save(createEmpConfig(organizationId,"岗位名称", "emp_jobPostName", "emp?.jobPost?.name", "岗位名称", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.insurance1Base", "养老保险基数", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.insurance1Base", "养老保险基数", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.insurance1Percent", "养老保险比例", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.insurance2Base", "医疗保险基数", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.insurance2Percent", "医疗保险比例", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.insurance3Base", "失业保险基数", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.insurance3Percent", "失业保险比例", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.insurance4Base", "工伤保险基数", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.insurance4Percent", "工伤保险比例", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.insurance5Base", "生育保险基数", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.insurance5Percent", "生育保险比例", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.insurance6Base", "住房公积金基数", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.insurance6Percent", "住房公积金比例", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.name", "姓名", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.sex", "性别", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.nation", "民族", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.marriage", "婚姻状况", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.entryDate", "入职时间", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.resignDate", "离职时间", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.idCard", "身份证号", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.education", "学历", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.phone", "手机号", false, "0")); - this.repository.save(createEmpConfig(organizationId, "emp.empStatus", "员工状态", false, "0")); + this.repository.save(createEmpConfig(organizationId,"养老保险基数", "emp_insurance1Base", "emp.insurance1Base", "养老保险基数", false, "0")); + this.repository.save(createEmpConfig(organizationId,"养老保险基数", "emp_insurance1Base", "emp.insurance1Base", "养老保险基数", false, "0")); + this.repository.save(createEmpConfig(organizationId,"养老保险比例", "emp_insurance1Percent", "emp.insurance1Percent", "养老保险比例", false, "0")); + this.repository.save(createEmpConfig(organizationId,"医疗保险基数", "emp_insurance2Base", "emp.insurance2Base", "医疗保险基数", false, "0")); + this.repository.save(createEmpConfig(organizationId,"医疗保险比例", "emp_insurance2Percent", "emp.insurance2Percent", "医疗保险比例", false, "0")); + this.repository.save(createEmpConfig(organizationId,"失业保险基数", "emp_insurance3Base", "emp.insurance3Base", "失业保险基数", false, "0")); + this.repository.save(createEmpConfig(organizationId,"失业保险比例", "emp_insurance3Percent", "emp.insurance3Percent", "失业保险比例", false, "0")); + this.repository.save(createEmpConfig(organizationId,"工伤保险基数", "emp_insurance4Base", "emp.insurance4Base", "工伤保险基数", false, "0")); + this.repository.save(createEmpConfig(organizationId,"工伤保险比例", "emp_insurance4Percent", "emp.insurance4Percent", "工伤保险比例", false, "0")); + this.repository.save(createEmpConfig(organizationId,"生育保险基数", "emp_insurance5Base", "emp.insurance5Base", "生育保险基数", false, "0")); + this.repository.save(createEmpConfig(organizationId,"生育保险比例", "emp_insurance5Percent", "emp.insurance5Percent", "生育保险比例", false, "0")); + this.repository.save(createEmpConfig(organizationId,"住房公积金基数", "emp_insurance6Base", "emp.insurance6Base", "住房公积金基数", false, "0")); + this.repository.save(createEmpConfig(organizationId,"住房公积金比例", "emp_insurance6Percent", "emp.insurance6Percent", "住房公积金比例", false, "0")); + this.repository.save(createEmpConfig(organizationId,"姓名", "emp_name", "emp.name", "姓名", false, "0")); + this.repository.save(createEmpConfig(organizationId,"性别", "emp_sex", "emp.sex", "性别", false, "0")); + this.repository.save(createEmpConfig(organizationId,"民族", "emp_nation", "emp.nation", "民族", false, "0")); + this.repository.save(createEmpConfig(organizationId,"婚姻状况", "emp_marriage", "emp.marriage", "婚姻状况", false, "0")); + this.repository.save(createEmpConfig(organizationId,"入职时间", "emp_entryDate", "emp.entryDate", "入职时间", false, "0")); + this.repository.save(createEmpConfig(organizationId,"离职时间", "emp_resignDate", "emp.resignDate", "离职时间", false, "0")); + this.repository.save(createEmpConfig(organizationId,"身份证号", "emp_idCard", "emp.idCard", "身份证号", false, "0")); + this.repository.save(createEmpConfig(organizationId,"学历", "emp_education", "emp.education", "学历", false, "0")); + this.repository.save(createEmpConfig(organizationId,"手机号", "emp_phone", "emp.phone", "手机号", false, "0")); + this.repository.save(createEmpConfig(organizationId, "员工状态", "emp_empStatus","emp.empStatus", "员工状态", false, "0")); } @@ -242,7 +243,7 @@ public class EmpSalaryItemConfigService for (EmpSalaryItemEntity item : items) { - this.repository.save(createEmpConfig(organizationId, "salary." + item.getCode(), item.getName(), true, "1")); + this.repository.save(createEmpConfig(organizationId, item.getName(), "salary_" + item.getCode(),"salary." + item.getCode(), item.getName(), true, "1")); } }