diff --git a/src/com/engine/salary/annotation/SalaryFormulaVar.java b/src/com/engine/salary/annotation/SalaryFormulaVar.java new file mode 100644 index 000000000..5477ea730 --- /dev/null +++ b/src/com/engine/salary/annotation/SalaryFormulaVar.java @@ -0,0 +1,26 @@ +package com.engine.salary.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @description: 薪资公式计算器-变量 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 11/19/21 2:08 PM + * @version:v1.0 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface SalaryFormulaVar { + + int labelId(); + + String defaultLabel(); + + String dataType(); + + String fieldId() default ""; +} diff --git a/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java b/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java index 3a916fec5..3b989c659 100644 --- a/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java +++ b/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java @@ -1,5 +1,6 @@ package com.engine.salary.entity.datacollection; +import com.engine.salary.annotation.SalaryFormulaVar; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -24,20 +25,29 @@ public class DataCollectionEmployee { //员工id private Long employeeId; + // 个税扣缴义务人 + @SalaryFormulaVar(defaultLabel ="个税扣缴义务人", labelId = 86184, dataType = "string") + private String taxAgentName; + //姓名 + @SalaryFormulaVar(defaultLabel ="姓名", labelId = 85429, dataType = "string") private String username; //部门 + @SalaryFormulaVar(defaultLabel ="部门", labelId = 86185, dataType = "string") private String departmentName; private Long departmentId; //岗位 + @SalaryFormulaVar(defaultLabel ="岗位", labelId = 90633, dataType = "string") private String jobtitleName; //入职日期 + @SalaryFormulaVar(defaultLabel ="入职日期", labelId = 86319, dataType = "string") private Date companystartdate; //手机号 + @SalaryFormulaVar(defaultLabel ="手机", labelId = 98621, dataType = "string") private String mobile; //离职日期 @@ -47,21 +57,27 @@ public class DataCollectionEmployee { private String status; //工号 + @SalaryFormulaVar(defaultLabel ="工号", labelId = 98622, dataType = "string") private String workcode; //性别 + @SalaryFormulaVar(defaultLabel ="性别", labelId = 98622, dataType = "string") private String sex; //邮件 + @SalaryFormulaVar(defaultLabel ="邮件", labelId = 92919, dataType = "string") private String email; //电话 + @SalaryFormulaVar(defaultLabel ="电话", labelId = 98620, dataType = "string") private String telephone; //职称 + @SalaryFormulaVar(defaultLabel ="职称", labelId = 98623, dataType = "string") private String jobcall; //生日 + @SalaryFormulaVar(defaultLabel ="出生日期", labelId = 98624, dataType = "string") private String birthday; } diff --git a/src/com/engine/salary/entity/salaryformula/dto/SalaryFormulaEmployeeDTO.java b/src/com/engine/salary/entity/salaryformula/dto/SalaryFormulaEmployeeDTO.java index adebef9c5..07b0ea000 100644 --- a/src/com/engine/salary/entity/salaryformula/dto/SalaryFormulaEmployeeDTO.java +++ b/src/com/engine/salary/entity/salaryformula/dto/SalaryFormulaEmployeeDTO.java @@ -1,5 +1,6 @@ package com.engine.salary.entity.salaryformula.dto; +import com.engine.salary.annotation.SalaryFormulaVar; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -20,43 +21,43 @@ public class SalaryFormulaEmployeeDTO { private Long employeeId; - //个税扣缴义务人", labelId = 86184, dataType = "string") + @SalaryFormulaVar(defaultLabel ="个税扣缴义务人", labelId = 86184, dataType = "string") private String taxAgentName; - //姓名", labelId = 85429, dataType = "string") + @SalaryFormulaVar(defaultLabel ="姓名", labelId = 85429, dataType = "string") private String username; - //邮件", labelId = 92919, dataType = "string") + @SalaryFormulaVar(defaultLabel ="邮件", labelId = 92919, dataType = "string") private String email; - //手机", labelId = 98621, dataType = "string") + @SalaryFormulaVar(defaultLabel ="手机", labelId = 98621, dataType = "string") private String mobile; - //电话", labelId = 98620, dataType = "string") + @SalaryFormulaVar(defaultLabel ="电话", labelId = 98620, dataType = "string") private String telephone; // //证件号码", labelId = 86318, dataType = "string") // private String idNo; - //性别", labelId = 98622, dataType = "string") + @SalaryFormulaVar(defaultLabel ="性别", labelId = 98622, dataType = "string") private String sex; - //状态", labelId = 91075, dataType = "string") + @SalaryFormulaVar(defaultLabel ="状态", labelId = 91075, dataType = "string") private String status; - //部门", labelId = 86185, dataType = "string") + @SalaryFormulaVar(defaultLabel ="部门", labelId = 86185, dataType = "string") private String departmentName; - //岗位", labelId = 90633, dataType = "string") + @SalaryFormulaVar(defaultLabel ="岗位", labelId = 90633, dataType = "string") private String positionName; - //职级", labelId = 98623, dataType = "string") + @SalaryFormulaVar(defaultLabel ="职级", labelId = 98623, dataType = "string") private String gradeName; - //入职日期", labelId = 86319, dataType = "string") + @SalaryFormulaVar(defaultLabel ="入职日期", labelId = 86319, dataType = "string") private String hireDate; - //出生日期", labelId = 98624, dataType = "string") + @SalaryFormulaVar(defaultLabel ="出生日期", labelId = 98624, dataType = "string") private String birthday; // //首次参加工作日期", labelId = 98625, dataType = "string") diff --git a/src/com/engine/salary/entity/salarysob/bo/SalarySobItemAggregateBO.java b/src/com/engine/salary/entity/salarysob/bo/SalarySobItemAggregateBO.java index 4f57d483d..74e7a4412 100644 --- a/src/com/engine/salary/entity/salarysob/bo/SalarySobItemAggregateBO.java +++ b/src/com/engine/salary/entity/salarysob/bo/SalarySobItemAggregateBO.java @@ -1,5 +1,8 @@ package com.engine.salary.entity.salarysob.bo; +import com.engine.salary.annotation.SalaryFormulaVar; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryformula.dto.SalaryFormulaEmployeeDTO; import com.engine.salary.entity.salaryitem.bo.SalaryItemBO; import com.engine.salary.entity.salaryitem.po.SalaryItemPO; import com.engine.salary.entity.salarysob.dto.SalarySobEmpFieldDTO; @@ -11,12 +14,15 @@ import com.engine.salary.entity.salarysob.po.SalarySobItemGroupPO; import com.engine.salary.entity.salarysob.po.SalarySobItemPO; import com.engine.salary.entity.salarysob.po.SalarySobPO; import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import com.weaver.excel.formula.api.entity.ExpressFormula; import lombok.AllArgsConstructor; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.math.NumberUtils; +import java.lang.reflect.Field; import java.util.*; import java.util.stream.Collectors; @@ -128,21 +134,21 @@ public class SalarySobItemAggregateBO { if (CollectionUtils.isEmpty(salarySobEmpFields)) { return Collections.emptyList(); } -// Field[] declaredFields = SalaryFormulaEmployeeDTO.class.getDeclaredFields(); -// Map empFieldMap = Maps.newHashMapWithExpectedSize(declaredFields.length); -// for (Field declaredField : declaredFields) { -// if (!declaredField.isAnnotationPresent(SalaryFormulaVar.class)) { -// continue; -// } -// SalaryFormulaVar annotation = declaredField.getAnnotation(SalaryFormulaVar.class); -// empFieldMap.put(declaredField.getName(), SalaryI18nUtil.getI18nLabel(annotation.labelId(), annotation.defaultLabel())); -// } + Field[] declaredFields = DataCollectionEmployee.class.getDeclaredFields(); + Map empFieldMap = Maps.newHashMapWithExpectedSize(declaredFields.length); + for (Field declaredField : declaredFields) { + if (!declaredField.isAnnotationPresent(SalaryFormulaVar.class)) { + continue; + } + SalaryFormulaVar annotation = declaredField.getAnnotation(SalaryFormulaVar.class); + empFieldMap.put(declaredField.getName(), SalaryI18nUtil.getI18nLabel(annotation.labelId(), annotation.defaultLabel())); + } return salarySobEmpFields.stream() .map(e -> SalarySobEmpFieldDTO.builder() .id(e.getId()) .salarySobId(e.getSalarySobId()) .fieldId(e.getFieldCode()) -// .fieldName(empFieldMap.getOrDefault(e.getFieldCode(), "")) + .fieldName(empFieldMap.getOrDefault(e.getFieldCode(), "")) .sortedIndex(e.getSortedIndex()) .canDelete(Objects.equals(e.getCanDelete(), NumberUtils.INTEGER_ONE)) .build()) diff --git a/src/com/engine/salary/wrapper/SalarySobItemWrapper.java b/src/com/engine/salary/wrapper/SalarySobItemWrapper.java index c71de4b33..2f0671d21 100644 --- a/src/com/engine/salary/wrapper/SalarySobItemWrapper.java +++ b/src/com/engine/salary/wrapper/SalarySobItemWrapper.java @@ -3,7 +3,9 @@ package com.engine.salary.wrapper; import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; +import com.engine.salary.annotation.SalaryFormulaVar; import com.engine.salary.component.SalaryWeaTable; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.salaryitem.dto.SalaryItemListDTO; import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam; import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO; @@ -16,9 +18,12 @@ import com.engine.salary.service.SalarySobItemService; import com.engine.salary.service.impl.SalaryItemServiceImpl; import com.engine.salary.service.impl.SalarySobItemGroupServiceImpl; import com.engine.salary.service.impl.SalarySobItemServiceImpl; +import com.engine.salary.util.SalaryI18nUtil; +import com.google.common.collect.Maps; import org.springframework.stereotype.Component; import weaver.hrm.User; +import java.lang.reflect.Field; import java.util.*; /** @@ -139,24 +144,25 @@ public class SalarySobItemWrapper extends Service { } + /** + * 基础信息浏览按钮(下拉框) + * @return + */ public Collection> empFieldList() { + Field[] declaredFields = DataCollectionEmployee.class.getDeclaredFields(); + Map empFieldMap = Maps.newHashMapWithExpectedSize(declaredFields.length); List> list = new ArrayList(); - Map taxAgentName = new HashMap<>(); - taxAgentName.put("name", "个税扣缴义务人"); - taxAgentName.put("id", "taxAgentName"); - list.add(taxAgentName); - Map username = new HashMap<>(); - username.put("name", "姓名"); - username.put("id", "username"); - list.add(username); - Map departmentName = new HashMap<>(); - departmentName.put("name", "部门"); - departmentName.put("id", "departmentName"); - list.add(departmentName); - Map email = new HashMap<>(); - email.put("name", "邮件"); - email.put("id", ""); - list.add(email); + for (Field declaredField : declaredFields) { + Map item = new HashMap<>(); + if (!declaredField.isAnnotationPresent(SalaryFormulaVar.class)) { + continue; + } + SalaryFormulaVar annotation = declaredField.getAnnotation(SalaryFormulaVar.class); + empFieldMap.put(declaredField.getName(), SalaryI18nUtil.getI18nLabel(annotation.labelId(), annotation.defaultLabel())); + item.put("name", SalaryI18nUtil.getI18nLabel(annotation.labelId(), annotation.defaultLabel())); + item.put("id", declaredField.getName()); + list.add(item); + } return list; } }