diff --git a/resource/sqlupgrade/DM/sql202311070403.sql b/resource/sqlupgrade/DM/sql202311070403.sql new file mode 100644 index 000000000..9de83415e --- /dev/null +++ b/resource/sqlupgrade/DM/sql202311070403.sql @@ -0,0 +1,27 @@ +CREATE TABLE hrsa_expand_field_settings ( + id NUMBER(38,0) primary key NOT NULL, + module varchar2(100) NOT NULL , + module_info varchar2(1000) , + pk varchar2(100) NOT NULL, + expand_sql varchar2(4000) NOT NULL , + field_setting varchar2(4000) NOT NULL, + create_time date DEFAULT sysdate, + update_time date DEFAULT sysdate, + creator NUMBER(38,0) NOT NULL , + delete_type number NOT NULL , + tenant_key varchar2(10) NOT NULL +); +/ + +ALTER TABLE hrsa_salary_statistics_item ADD last_rule VARCHAR2(500) NULL; +/ + +ALTER TABLE hrsa_salary_statistics_item ADD old_rule VARCHAR2(500) NULL; +/ + +ALTER TABLE hrsa_salary_statistics_item ADD frequent_rule VARCHAR2(500) NULL; +/ + +ALTER TABLE hrsa_salary_statistics_item ADD tile_rule VARCHAR2(500) NULL; +/ + diff --git a/resource/sqlupgrade/DM/sql202311080603.sql b/resource/sqlupgrade/DM/sql202311080603.sql new file mode 100644 index 000000000..f65fcd62b --- /dev/null +++ b/resource/sqlupgrade/DM/sql202311080603.sql @@ -0,0 +1,3 @@ +alter table hrsa_salary_stats_report add time_type int; +/ + diff --git a/resource/sqlupgrade/GS/sql202311070403.sql b/resource/sqlupgrade/GS/sql202311070403.sql new file mode 100644 index 000000000..9de83415e --- /dev/null +++ b/resource/sqlupgrade/GS/sql202311070403.sql @@ -0,0 +1,27 @@ +CREATE TABLE hrsa_expand_field_settings ( + id NUMBER(38,0) primary key NOT NULL, + module varchar2(100) NOT NULL , + module_info varchar2(1000) , + pk varchar2(100) NOT NULL, + expand_sql varchar2(4000) NOT NULL , + field_setting varchar2(4000) NOT NULL, + create_time date DEFAULT sysdate, + update_time date DEFAULT sysdate, + creator NUMBER(38,0) NOT NULL , + delete_type number NOT NULL , + tenant_key varchar2(10) NOT NULL +); +/ + +ALTER TABLE hrsa_salary_statistics_item ADD last_rule VARCHAR2(500) NULL; +/ + +ALTER TABLE hrsa_salary_statistics_item ADD old_rule VARCHAR2(500) NULL; +/ + +ALTER TABLE hrsa_salary_statistics_item ADD frequent_rule VARCHAR2(500) NULL; +/ + +ALTER TABLE hrsa_salary_statistics_item ADD tile_rule VARCHAR2(500) NULL; +/ + diff --git a/resource/sqlupgrade/GS/sql202311080603.sql b/resource/sqlupgrade/GS/sql202311080603.sql new file mode 100644 index 000000000..f65fcd62b --- /dev/null +++ b/resource/sqlupgrade/GS/sql202311080603.sql @@ -0,0 +1,3 @@ +alter table hrsa_salary_stats_report add time_type int; +/ + diff --git a/resource/sqlupgrade/JC/sql202311070403.sql b/resource/sqlupgrade/JC/sql202311070403.sql new file mode 100644 index 000000000..9de83415e --- /dev/null +++ b/resource/sqlupgrade/JC/sql202311070403.sql @@ -0,0 +1,27 @@ +CREATE TABLE hrsa_expand_field_settings ( + id NUMBER(38,0) primary key NOT NULL, + module varchar2(100) NOT NULL , + module_info varchar2(1000) , + pk varchar2(100) NOT NULL, + expand_sql varchar2(4000) NOT NULL , + field_setting varchar2(4000) NOT NULL, + create_time date DEFAULT sysdate, + update_time date DEFAULT sysdate, + creator NUMBER(38,0) NOT NULL , + delete_type number NOT NULL , + tenant_key varchar2(10) NOT NULL +); +/ + +ALTER TABLE hrsa_salary_statistics_item ADD last_rule VARCHAR2(500) NULL; +/ + +ALTER TABLE hrsa_salary_statistics_item ADD old_rule VARCHAR2(500) NULL; +/ + +ALTER TABLE hrsa_salary_statistics_item ADD frequent_rule VARCHAR2(500) NULL; +/ + +ALTER TABLE hrsa_salary_statistics_item ADD tile_rule VARCHAR2(500) NULL; +/ + diff --git a/resource/sqlupgrade/JC/sql202311080603.sql b/resource/sqlupgrade/JC/sql202311080603.sql new file mode 100644 index 000000000..f65fcd62b --- /dev/null +++ b/resource/sqlupgrade/JC/sql202311080603.sql @@ -0,0 +1,3 @@ +alter table hrsa_salary_stats_report add time_type int; +/ + diff --git a/resource/sqlupgrade/Mysql/sql202311070403.sql b/resource/sqlupgrade/Mysql/sql202311070403.sql new file mode 100644 index 000000000..73e04bef8 --- /dev/null +++ b/resource/sqlupgrade/Mysql/sql202311070403.sql @@ -0,0 +1,21 @@ +CREATE TABLE hrsa_expand_field_settings ( + id bigint(0) NOT NULL, + module varchar(100) NOT NULL , + module_info varchar(1000) , + pk varchar(100) NOT NULL, + expand_sql varchar(4000) NOT NULL , + field_setting varchar(4000) NOT NULL, + create_time datetime(0) NOT NULL , + update_time datetime(0) NOT NULL , + creator bigint(0) NOT NULL , + delete_type int(0) NOT NULL , + tenant_key varchar(10) NOT NULL , + PRIMARY KEY (id) USING BTREE +) ; + + +ALTER TABLE hrsa_salary_statistics_item +ADD COLUMN last_rule varchar(500) , +ADD COLUMN old_rule varchar(500) , +ADD COLUMN frequent_rule varchar(500) , +ADD COLUMN tile_rule varchar(500) ; diff --git a/resource/sqlupgrade/Mysql/sql202311080603.sql b/resource/sqlupgrade/Mysql/sql202311080603.sql new file mode 100644 index 000000000..024e94be3 --- /dev/null +++ b/resource/sqlupgrade/Mysql/sql202311080603.sql @@ -0,0 +1,2 @@ +alter table hrsa_salary_stats_report add time_type int +; \ No newline at end of file diff --git a/resource/sqlupgrade/Oracle/sql202311070403.sql b/resource/sqlupgrade/Oracle/sql202311070403.sql new file mode 100644 index 000000000..6f101c9eb --- /dev/null +++ b/resource/sqlupgrade/Oracle/sql202311070403.sql @@ -0,0 +1,23 @@ +CREATE TABLE hrsa_expand_field_settings ( + id NUMBER(38,0) primary key NOT NULL, + module varchar2(100) NOT NULL , + module_info varchar2(1000) , + pk varchar2(100) NOT NULL, + expand_sql varchar2(4000) NOT NULL , + field_setting varchar2(4000) NOT NULL, + create_time date DEFAULT sysdate, + update_time date DEFAULT sysdate, + creator NUMBER(38,0) NOT NULL , + delete_type number NOT NULL , + tenant_key varchar2(10) NOT NULL +) +/ + +ALTER TABLE hrsa_salary_statistics_item ADD last_rule VARCHAR2(500) NULL +/ +ALTER TABLE hrsa_salary_statistics_item ADD old_rule VARCHAR2(500) NULL +/ +ALTER TABLE hrsa_salary_statistics_item ADD frequent_rule VARCHAR2(500) NULL +/ +ALTER TABLE hrsa_salary_statistics_item ADD tile_rule VARCHAR2(500) NULL +/ \ No newline at end of file diff --git a/resource/sqlupgrade/Oracle/sql202311080603.sql b/resource/sqlupgrade/Oracle/sql202311080603.sql new file mode 100644 index 000000000..a53c1e2da --- /dev/null +++ b/resource/sqlupgrade/Oracle/sql202311080603.sql @@ -0,0 +1,2 @@ +alter table hrsa_salary_stats_report add time_type int +/ \ No newline at end of file diff --git a/resource/sqlupgrade/PG/sql202311070403.sql b/resource/sqlupgrade/PG/sql202311070403.sql new file mode 100644 index 000000000..2382b2f76 --- /dev/null +++ b/resource/sqlupgrade/PG/sql202311070403.sql @@ -0,0 +1,20 @@ +create table hrsa_expand_field_settings +( + id bigserial not null , + module varchar(100) NOT NULL , + module_info varchar(1000) , + pk varchar(100) NOT NULL, + expand_sql varchar(4000) NOT NULL , + field_setting varchar(4000) NOT NULL, + create_time timestamp, + update_time timestamp, + creator bigint NOT NULL , + delete_type int NOT NULL , + tenant_key varchar(10) NOT NULL , + PRIMARY KEY ( id ) +); + +ALTER TABLE hrsa_salary_statistics_item ADD COLUMN last_rule varchar(500) NULL ; +ALTER TABLE hrsa_salary_statistics_item ADD COLUMN old_rule varchar(500) NULL ; +ALTER TABLE hrsa_salary_statistics_item ADD COLUMN frequent_rule varchar(500) NULL ; +ALTER TABLE hrsa_salary_statistics_item ADD COLUMN tile_rule varchar(500) NULL ; \ No newline at end of file diff --git a/resource/sqlupgrade/PG/sql202311080603.sql b/resource/sqlupgrade/PG/sql202311080603.sql new file mode 100644 index 000000000..afa28833d --- /dev/null +++ b/resource/sqlupgrade/PG/sql202311080603.sql @@ -0,0 +1,2 @@ +alter table hrsa_salary_stats_report add time_type int; +/ \ No newline at end of file diff --git a/resource/sqlupgrade/SQLServer/sql202311070403.sql b/resource/sqlupgrade/SQLServer/sql202311070403.sql new file mode 100644 index 000000000..360da08cd --- /dev/null +++ b/resource/sqlupgrade/SQLServer/sql202311070403.sql @@ -0,0 +1,27 @@ +CREATE TABLE hrsa_expand_field_settings ( + id bigint NOT NULL, + module varchar(100) NOT NULL , + module_info varchar(1000) NOT NULL , + pk varchar(100) NULL DEFAULT NULL , + expand_sql varchar(4000) NOT NULL , + field_setting varchar(4000) NOT NULL, + create_time datetime NOT NULL , + update_time datetime NOT NULL , + creator bigint NOT NULL , + delete_type int NOT NULL , + tenant_key varchar(10) NOT NULL , + PRIMARY KEY (id) +) +GO + +ALTER TABLE hrsa_salary_statistics_item ADD last_rule varchar(500) NULL +GO + +ALTER TABLE hrsa_salary_statistics_item ADD old_rule varchar(500) NULL +GO + +ALTER TABLE hrsa_salary_statistics_item ADD frequent_rule varchar(500) NULL +GO + +ALTER TABLE hrsa_salary_statistics_item ADD tile_rule varchar(500) NULL +GO \ No newline at end of file diff --git a/resource/sqlupgrade/SQLServer/sql202311080603.sql b/resource/sqlupgrade/SQLServer/sql202311080603.sql new file mode 100644 index 000000000..005efd521 --- /dev/null +++ b/resource/sqlupgrade/SQLServer/sql202311080603.sql @@ -0,0 +1,2 @@ +alter table hrsa_salary_stats_report add time_type int +GO \ No newline at end of file diff --git a/resource/sqlupgrade/ST/sql202311070403.sql b/resource/sqlupgrade/ST/sql202311070403.sql new file mode 100644 index 000000000..9de83415e --- /dev/null +++ b/resource/sqlupgrade/ST/sql202311070403.sql @@ -0,0 +1,27 @@ +CREATE TABLE hrsa_expand_field_settings ( + id NUMBER(38,0) primary key NOT NULL, + module varchar2(100) NOT NULL , + module_info varchar2(1000) , + pk varchar2(100) NOT NULL, + expand_sql varchar2(4000) NOT NULL , + field_setting varchar2(4000) NOT NULL, + create_time date DEFAULT sysdate, + update_time date DEFAULT sysdate, + creator NUMBER(38,0) NOT NULL , + delete_type number NOT NULL , + tenant_key varchar2(10) NOT NULL +); +/ + +ALTER TABLE hrsa_salary_statistics_item ADD last_rule VARCHAR2(500) NULL; +/ + +ALTER TABLE hrsa_salary_statistics_item ADD old_rule VARCHAR2(500) NULL; +/ + +ALTER TABLE hrsa_salary_statistics_item ADD frequent_rule VARCHAR2(500) NULL; +/ + +ALTER TABLE hrsa_salary_statistics_item ADD tile_rule VARCHAR2(500) NULL; +/ + diff --git a/resource/sqlupgrade/ST/sql202311080603.sql b/resource/sqlupgrade/ST/sql202311080603.sql new file mode 100644 index 000000000..f65fcd62b --- /dev/null +++ b/resource/sqlupgrade/ST/sql202311080603.sql @@ -0,0 +1,3 @@ +alter table hrsa_salary_stats_report add time_type int; +/ + diff --git a/src/com/engine/salary/encrypt/AESEncryptUtil.java b/src/com/engine/salary/encrypt/AESEncryptUtil.java index ec1cc2aed..e54ebea02 100644 --- a/src/com/engine/salary/encrypt/AESEncryptUtil.java +++ b/src/com/engine/salary/encrypt/AESEncryptUtil.java @@ -3,7 +3,6 @@ package com.engine.salary.encrypt; import com.engine.salary.sys.constant.SalarySysConstant; import com.engine.salary.sys.entity.po.SalarySysConfPO; import com.engine.salary.sys.enums.OpenEnum; -import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; import org.apache.commons.lang3.StringUtils; import weaver.general.AES; import weaver.general.BaseBean; @@ -20,7 +19,6 @@ public class AESEncryptUtil { static BaseBean bb = new BaseBean(); static String aesEncryptScrect = bb.getPropValue("hrmSalary", "AESEncryptScrect"); - static SalarySysConfServiceImpl salarySysConfService = new SalarySysConfServiceImpl(); /** * AES加密 diff --git a/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java b/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java index 1b0931ff3..d18c8759b 100644 --- a/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java +++ b/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java @@ -6,6 +6,8 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.Map; + /** * 员工基本信息 *

Copyright: Copyright (c) 2022

@@ -108,5 +110,10 @@ public class DataCollectionEmployee { //是否外部人员 private boolean extEmp; + /** + * 扩展数据 + */ + private Map extendData; + } diff --git a/src/com/engine/salary/entity/hrm/dto/EmployeeInfoExpandDTO.java b/src/com/engine/salary/entity/hrm/dto/EmployeeInfoExpandDTO.java new file mode 100644 index 000000000..f24cbffc6 --- /dev/null +++ b/src/com/engine/salary/entity/hrm/dto/EmployeeInfoExpandDTO.java @@ -0,0 +1,53 @@ +package com.engine.salary.entity.hrm.dto; + +import com.engine.salary.util.valid.Modify; +import com.engine.salary.util.valid.ModifyTypeEnum; +import com.engine.salary.util.valid.ValueTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 人员扩展参数 + *

Copyright: Copyright (c) 2023

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class EmployeeInfoExpandDTO { + + private Long id; + /** + * 功能模块 + */ + private String module; + /** + * 模块信息 + */ + private String moduleInfo; + /** + * 主键 + */ + private String pk; + + /** + * sql + */ + @Modify(modifyType = ModifyTypeEnum.RESTORE_SQL) + private String expandSql; + + /** + * 字段设置 + */ + @Modify(valueType = ValueTypeEnum.ARRAY) + private List fieldSettings; + +} diff --git a/src/com/engine/salary/entity/hrm/dto/FieldSetting.java b/src/com/engine/salary/entity/hrm/dto/FieldSetting.java new file mode 100644 index 000000000..1174b59ae --- /dev/null +++ b/src/com/engine/salary/entity/hrm/dto/FieldSetting.java @@ -0,0 +1,35 @@ +package com.engine.salary.entity.hrm.dto; + +import com.engine.salary.util.valid.Modify; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class FieldSetting { + + /** + * 字段 + */ + @Modify() + private String field; + + /** + * 显示 + */ + private String name; + + /** + * 值 + */ + private String value; + + /** + * 排序 + */ + private Integer index; +} diff --git a/src/com/engine/salary/entity/hrm/po/ExpandFieldSettingsPO.java b/src/com/engine/salary/entity/hrm/po/ExpandFieldSettingsPO.java new file mode 100644 index 000000000..8908ab69f --- /dev/null +++ b/src/com/engine/salary/entity/hrm/po/ExpandFieldSettingsPO.java @@ -0,0 +1,74 @@ +package com.engine.salary.entity.hrm.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 人员维度扩展表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ExpandFieldSettingsPO { + private Long id; + + /** + * 功能模块 + */ + private String module; + + /** + * 模块信息 + */ + private String moduleInfo; + + /** + * 主键 + */ + private String pk; + + /** + * sql + */ + private String expandSql; + + /** + * 字段设置 + */ + private String fieldSetting; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 创建人 + */ + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + /** + * 租户ID + */ + private String tenantKey; + + //主键id集合 + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/salaryformula/param/SalaryFormulaSaveParam.java b/src/com/engine/salary/entity/salaryformula/param/SalaryFormulaSaveParam.java index 41a7cdfeb..705e09268 100644 --- a/src/com/engine/salary/entity/salaryformula/param/SalaryFormulaSaveParam.java +++ b/src/com/engine/salary/entity/salaryformula/param/SalaryFormulaSaveParam.java @@ -2,6 +2,8 @@ package com.engine.salary.entity.salaryformula.param; import com.engine.salary.entity.salaryformula.po.FormulaVar; import com.engine.salary.util.valid.DataCheck; +import com.engine.salary.util.valid.Modify; +import com.engine.salary.util.valid.ModifyTypeEnum; import com.engine.salary.util.valid.RuntimeTypeEnum; import lombok.AllArgsConstructor; import lombok.Builder; @@ -61,6 +63,7 @@ public class SalaryFormulaSaveParam { * 公式内容 */ @DataCheck(require = true,message = "公式内容为空") + @Modify(modifyType = ModifyTypeEnum.RESTORE_SQL) private String formula; diff --git a/src/com/engine/salary/mapper/hrm/ExpandFieldSettingsMapper.java b/src/com/engine/salary/mapper/hrm/ExpandFieldSettingsMapper.java new file mode 100644 index 000000000..9d1c9fab9 --- /dev/null +++ b/src/com/engine/salary/mapper/hrm/ExpandFieldSettingsMapper.java @@ -0,0 +1,73 @@ +package com.engine.salary.mapper.hrm; + +import com.engine.salary.entity.hrm.po.ExpandFieldSettingsPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface ExpandFieldSettingsMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(ExpandFieldSettingsPO expandFieldSettings); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + ExpandFieldSettingsPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param expandFieldSettings 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(ExpandFieldSettingsPO expandFieldSettings); + + /** + * 修改,修改所有字段 + * + * @param expandFieldSettings 修改的记录 + * @return 返回影响行数 + */ + int update(ExpandFieldSettingsPO expandFieldSettings); + + /** + * 修改,忽略null字段 + * + * @param expandFieldSettings 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(ExpandFieldSettingsPO expandFieldSettings); + + /** + * 删除记录 + * + * @param expandFieldSettings 待删除的记录 + * @return 返回影响行数 + */ + int delete(ExpandFieldSettingsPO expandFieldSettings); + + /** + * 批量删除记录 + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + + ExpandFieldSettingsPO getByModule(String module); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/hrm/ExpandFieldSettingsMapper.xml b/src/com/engine/salary/mapper/hrm/ExpandFieldSettingsMapper.xml new file mode 100644 index 000000000..47a24568e --- /dev/null +++ b/src/com/engine/salary/mapper/hrm/ExpandFieldSettingsMapper.xml @@ -0,0 +1,259 @@ + + + + + + + + + + + + + + + + + + + + t + . + id + , t.module + , t.module_info + , t.pk + , t.expand_sql + , t.field_setting + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + INSERT INTO hrsa_expand_field_settings + + + id, + + + module, + + + module_info, + + + pk, + + + expand_sql, + + + field_setting, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{module}, + + + #{moduleInfo}, + + + #{pk}, + + + #{expandSql}, + + + #{fieldSetting}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + + + UPDATE hrsa_expand_field_settings + + module=#{module}, + module_info=#{moduleInfo}, + pk=#{pk}, + expand_sql=#{expandSql}, + field_setting=#{fieldSetting}, + create_time=#{createTime}, + update_time=#{updateTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_expand_field_settings + + + module=#{module}, + + + module_info=#{moduleInfo}, + + + pk=#{pk}, + + + expand_sql=#{expandSql}, + + + field_setting=#{fieldSetting}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_expand_field_settings + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_expand_field_settings + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/report/SalaryStatisticsItemMapper.xml b/src/com/engine/salary/mapper/report/SalaryStatisticsItemMapper.xml index 68d44970b..69abc9536 100644 --- a/src/com/engine/salary/mapper/report/SalaryStatisticsItemMapper.xml +++ b/src/com/engine/salary/mapper/report/SalaryStatisticsItemMapper.xml @@ -19,6 +19,10 @@ + + + + @@ -42,6 +46,10 @@ , t.tenant_key , t.unit_type , t.update_time + , t.last_rule + , t.old_rule + , t.frequent_rule + , t.tile_rule @@ -184,6 +192,18 @@ update_time, + + last_rule, + + + old_rule, + + + frequent_rule, + + + tile_rule, + @@ -237,6 +257,18 @@ #{updateTime}, + + #{lastRule}, + + + #{oldRule}, + + + #{frequentRule}, + + + #{tileRule}, + @@ -260,6 +292,10 @@ tenant_key=#{tenantKey}, unit_type=#{unitType}, update_time=#{updateTime}, + last_rule=#{lastRule}, + old_rule=#{oldRule}, + frequent_rule=#{frequentRule}, + tile_rule=#{tileRule}, WHERE id = #{id} AND delete_type = 0 @@ -317,6 +353,18 @@ update_time=#{updateTime}, + + last_rule=#{lastRule}, + + + old_rule=#{oldRule}, + + + frequent_rule=#{frequentRule}, + + + tile_rule=#{tileRule}, + WHERE id = #{id} AND delete_type = 0 diff --git a/src/com/engine/salary/mapper/report/SalaryStatisticsReportMapper.xml b/src/com/engine/salary/mapper/report/SalaryStatisticsReportMapper.xml index 61a42b1ab..d85fc85bd 100644 --- a/src/com/engine/salary/mapper/report/SalaryStatisticsReportMapper.xml +++ b/src/com/engine/salary/mapper/report/SalaryStatisticsReportMapper.xml @@ -16,6 +16,7 @@ + @@ -56,6 +57,7 @@ , t.tax_agent_setting , t.tenant_key , t.update_time + , t.time_type @@ -123,6 +125,9 @@ AND report_name = #{reportName} + + AND time_type = #{timeType} + AND salary_end_month = #{salaryEndMonth} @@ -210,6 +215,9 @@ report_name, + + time_type, + salary_end_month, @@ -284,6 +292,9 @@ #{reportName}, + + #{timeType}, + #{salaryEndMonth}, @@ -334,6 +345,7 @@ position_setting=#{positionSetting}, remark=#{remark}, report_name=#{reportName}, + time_type=#{timeType}, salary_end_month=#{salaryEndMonth}, salary_start_month=#{salaryStartMonth}, second_dimension=#{secondDimension}, @@ -392,6 +404,9 @@ report_name=#{reportName}, + + time_type=#{timeType}, + salary_end_month=#{salaryEndMonth}, diff --git a/src/com/engine/salary/report/entity/bo/SalaryStatisticsReportBO.java b/src/com/engine/salary/report/entity/bo/SalaryStatisticsReportBO.java index 1a76e5883..88adfe57d 100644 --- a/src/com/engine/salary/report/entity/bo/SalaryStatisticsReportBO.java +++ b/src/com/engine/salary/report/entity/bo/SalaryStatisticsReportBO.java @@ -2,7 +2,10 @@ package com.engine.salary.report.entity.bo; import com.alibaba.fastjson.JSON; import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.common.util.ServiceUtil; import com.engine.salary.component.WeaTableColumnGroup; +import com.engine.salary.entity.hrm.dto.EmployeeInfoExpandDTO; +import com.engine.salary.entity.hrm.dto.FieldSetting; import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; import com.engine.salary.report.common.constant.SalaryStatisticsDimensionConstant; import com.engine.salary.report.entity.dto.SalaryStatisticsItemRuleDTO; @@ -13,13 +16,17 @@ import com.engine.salary.report.entity.param.SalaryStatisticsReportDataQueryPara import com.engine.salary.report.entity.po.SalaryStatisticsDimensionPO; import com.engine.salary.report.entity.po.SalaryStatisticsItemPO; import com.engine.salary.report.entity.po.SalaryStatisticsReportPO; +import com.engine.salary.report.enums.SalaryStatisticsItemStringRuleEnum; import com.engine.salary.report.enums.UnitTypeEnum; +import com.engine.salary.report.service.SalaryStatisticsDimensionService; +import com.engine.salary.report.service.impl.SalaryStatisticsDimensionServiceImpl; import com.engine.salary.report.util.ReportDataUtil; import com.engine.salary.report.util.ReportTimeUtil; import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.page.PageInfo; +import com.google.common.base.Joiner; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import org.apache.commons.collections4.CollectionUtils; @@ -27,6 +34,7 @@ import org.apache.commons.collections4.MapUtils; import org.apache.commons.compress.utils.Lists; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; +import weaver.hrm.User; import java.math.BigDecimal; import java.math.RoundingMode; @@ -80,6 +88,10 @@ public class SalaryStatisticsReportBO { public static final String G_YEAR = "year"; public static final String G_ITEM = "ITEM"; + private static SalaryStatisticsDimensionService getSalaryStatisticsDimensionService() { + return ServiceUtil.getService(SalaryStatisticsDimensionServiceImpl.class, new User(1)); + } + /** * 参数转换 * @@ -87,19 +99,39 @@ public class SalaryStatisticsReportBO { * @param po */ public static void poToQueryParam(SalaryStatisticsReportDataQueryParam param, SalaryStatisticsReportPO po) { - param.setSalaryStartMonth(SalaryDateUtil.getFormatYearMonth(po.getSalaryStartMonth())); - param.setSalaryEndMonth(SalaryDateUtil.getFormatYearMonth(po.getSalaryEndMonth())); + String salaryStartMonth = param.getSalaryStartMonth(); + if (salaryStartMonth == null) { + param.setSalaryStartMonth(SalaryDateUtil.getFormatYearMonth(po.getSalaryStartMonth())); + } else { + param.setSalaryStartMonth(SalaryDateUtil.getFormatYearMonth(SalaryDateUtil.dateStrToLocalDate(salaryStartMonth))); + } + String salaryEndMonth = param.getSalaryEndMonth(); + if (salaryEndMonth == null) { + param.setSalaryEndMonth(SalaryDateUtil.getFormatYearMonth(po.getSalaryEndMonth())); + } else { + param.setSalaryEndMonth(SalaryDateUtil.getFormatYearMonth(SalaryDateUtil.dateStrToLocalDate(salaryEndMonth))); + } String key = "id"; - param.setTaxAgent(((List) JSON.parseArray(po.getTaxAgentSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + if (po.getTaxAgentSetting() != null) { + param.setTaxAgent(((List) JSON.parseArray(po.getTaxAgentSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + } // param.setIncomeCategory(((List) JSON.parseArray(po.getIncomeCategorySetting(), Map.class)).stream().map(m -> Integer.valueOf(m.get(key).toString())).collect(Collectors.toList())); - param.setSubCompany(((List) JSON.parseArray(po.getSubCompanySetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); - param.setDepart(((List) JSON.parseArray(po.getDepartSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + if (po.getSubCompanySetting() != null) { + param.setSubCompany(((List) JSON.parseArray(po.getSubCompanySetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + } + if (po.getDepartSetting() != null) { + param.setDepart(((List) JSON.parseArray(po.getDepartSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + } // param.setGrade(((List) JSON.parseArray(po.getGradeSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); // param.setPosition(((List) JSON.parseArray(po.getPositionSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); // param.setStatus(((List) JSON.parseArray(po.getStatusSetting(), Map.class)).stream().map(m -> m.get(key).toString()).collect(Collectors.toList())); - param.setEmployee(((List) JSON.parseArray(po.getEmployeeSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); - param.setHiredate(JSON.parseArray(po.getHiredateSetting(), Date.class)); + if (po.getEmployeeSetting() != null) { + param.setEmployee(((List) JSON.parseArray(po.getEmployeeSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + } + if (po.getHiredateSetting() != null) { + param.setHiredate(JSON.parseArray(po.getHiredateSetting(), Date.class)); + } // param.setLeavedate(JSON.parseArray(po.getLeavedateSetting(), LocalDate.class)); } @@ -172,6 +204,14 @@ public class SalaryStatisticsReportBO { calculate4Min(result, item, nowDetail, lastDetail, sameDetail); // 6.中位数规则数据处理 calculate4Median(result, item, nowDetail, lastDetail, sameDetail); + // 7.最近值 + calculate4Last(result, item, nowDetail, lastDetail, sameDetail); + // 8.最久值 + calculate4Old(result, item, nowDetail, lastDetail, sameDetail); + // 9.最频繁 + calculate4Frequent(result, item, nowDetail, lastDetail, sameDetail); + // 10.平铺 + calculate4Tile(result, item, nowDetail, lastDetail, sameDetail); }); return result; } @@ -479,6 +519,143 @@ public class SalaryStatisticsReportBO { } } + /** + * 最新的值 + * + * @param result + * @param item + * @param nowDetail + * @param lastDetail + * @param sameDetail + */ + private static void calculate4Last(Map result, SalaryStatisticsItemPO item, List> nowDetail, List> lastDetail, List> sameDetail) { + SalaryStatisticsItemRuleDTO lastRule = JSON.parseObject(item.getLastRule(), SalaryStatisticsItemRuleDTO.class); + if (lastRule == null || lastRule.getTotalValue() != 1) { + return; + } + String lastValue = ""; + // 本期 + if (lastRule.getTotalValue() == 1) { + List decimalList = Lists.newArrayList(); + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] itemValues = item.getItemValue().split(COMMA); + for (String itemId : itemValues) { + for (Map x : nowDetail) { + if (MapUtils.isNotEmpty(x) && StringUtils.isNotBlank(x.get(itemId))) { + decimalList.add(x.get(itemId)); + } + } + } + } + // 本期最近值 + lastValue = last(decimalList); + nowAndRatio(result, item, lastRule, SalaryStatisticsItemStringRuleEnum.LAST.getValue(), lastValue); + } + } + + /** + * 最旧的值 + * + * @param result + * @param item + * @param nowDetail + * @param lastDetail + * @param sameDetail + */ + private static void calculate4Old(Map result, SalaryStatisticsItemPO item, List> nowDetail, List> lastDetail, List> sameDetail) { + SalaryStatisticsItemRuleDTO oldRule = JSON.parseObject(item.getOldRule(), SalaryStatisticsItemRuleDTO.class); + if (oldRule == null || oldRule.getTotalValue() != 1) { + return; + } + String value = ""; + // 本期 + if (oldRule.getTotalValue() == 1) { + List decimalList = Lists.newArrayList(); + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] itemValues = item.getItemValue().split(COMMA); + for (String itemId : itemValues) { + for (Map x : nowDetail) { + if (MapUtils.isNotEmpty(x) && StringUtils.isNotBlank(x.get(itemId))) { + decimalList.add(x.get(itemId)); + } + } + } + } + // 本期最近值 + value = old(decimalList); + nowAndRatio(result, item, oldRule, SalaryStatisticsItemStringRuleEnum.OLD.getValue(), value); + } + } + + /** + * 最频繁 + * + * @param result + * @param item + * @param nowDetail + * @param lastDetail + * @param sameDetail + */ + private static void calculate4Frequent(Map result, SalaryStatisticsItemPO item, List> nowDetail, List> lastDetail, List> sameDetail) { + SalaryStatisticsItemRuleDTO frequentRule = JSON.parseObject(item.getOldRule(), SalaryStatisticsItemRuleDTO.class); + if (frequentRule == null || frequentRule.getTotalValue() != 1) { + return; + } + String value = ""; + // 本期 + if (frequentRule.getTotalValue() == 1) { + List decimalList = Lists.newArrayList(); + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] itemValues = item.getItemValue().split(COMMA); + for (String itemId : itemValues) { + for (Map x : nowDetail) { + if (MapUtils.isNotEmpty(x) && StringUtils.isNotBlank(x.get(itemId))) { + decimalList.add(x.get(itemId)); + } + } + } + } + // 本期最近值 + value = frequent(decimalList); + nowAndRatio(result, item, frequentRule, SalaryStatisticsItemStringRuleEnum.FREQUENT.getValue(), value); + } + } + + /** + * 平铺 + * + * @param result + * @param item + * @param nowDetail + * @param lastDetail + * @param sameDetail + */ + private static void calculate4Tile(Map result, SalaryStatisticsItemPO item, List> nowDetail, List> lastDetail, List> sameDetail) { + SalaryStatisticsItemRuleDTO tileRule = JSON.parseObject(item.getOldRule(), SalaryStatisticsItemRuleDTO.class); + if (tileRule == null || tileRule.getTotalValue() != 1) { + return; + } + String value = ""; + // 本期 + if (tileRule.getTotalValue() == 1) { + List decimalList = Lists.newArrayList(); + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] itemValues = item.getItemValue().split(COMMA); + for (String itemId : itemValues) { + for (Map x : nowDetail) { + if (MapUtils.isNotEmpty(x) && StringUtils.isNotBlank(x.get(itemId))) { + decimalList.add(x.get(itemId)); + } + } + } + } + // 本期最近值 + value = tile(decimalList); + nowAndRatio(result, item, tileRule, SalaryStatisticsItemStringRuleEnum.TILE.getValue(), value); + } + } + + /** * 本期和占比赋值 * @@ -498,6 +675,21 @@ public class SalaryStatisticsReportBO { } } + /** + * 本期和占比赋值 + * + * @param result + * @param item + * @param rule + * @param ruleKey + * @param sumDecimal + */ + private static void nowAndRatio(Map result, SalaryStatisticsItemPO item, SalaryStatisticsItemRuleDTO rule, String ruleKey, String sumDecimal) { + String keyPrefix = item.getId().toString() + UD + ruleKey; + // 本期合计 + result.put(keyPrefix + K_NOW, sumDecimal); + } + /** * 环比赋值 * @@ -596,6 +788,65 @@ public class SalaryStatisticsReportBO { } } + /** + * 最新的值 + * + * @param list + * @return + */ + public static String last(List list) { + if (CollectionUtils.isEmpty(list)) { + return ""; + } + return list.get(0); + } + + /** + * 最旧的值 + * + * @param list + * @return + */ + public static String old(List list) { + if (CollectionUtils.isEmpty(list)) { + return ""; + } + return list.get(list.size() - 1); + } + + /** + * 最频繁 + * + * @param list + * @return + */ + public static String frequent(List list) { + if (CollectionUtils.isEmpty(list)) { + return ""; + } + return list.stream() + .collect(Collectors.groupingBy(Function.identity(), Collectors.counting())) + .entrySet() + .stream() + .max(Map.Entry.comparingByValue()) + .map(Map.Entry::getKey) + .orElse(""); + } + + /** + * 平铺 + * + * @param list + * @return + */ + public static String tile(List list) { + if (CollectionUtils.isEmpty(list)) { + return ""; + } + return Joiner.on(",").join((Iterable) list); + } + + public static List> po2map(List list, Map> salaryAcctResultValueMap) { if (CollectionUtils.isEmpty(list)) { return new ArrayList<>(); @@ -832,11 +1083,12 @@ public class SalaryStatisticsReportBO { result.add(new WeaTableColumnGroup("150", dimensionName.getDimName(), "dimension")); - //人员维度新增部门和工号 - if (SalaryStatisticsDimensionConstant.DM_EMPLOYEE.equals(dimensionName.getDimCode())) { - result.add(new WeaTableColumnGroup("150", "部门", "departmentName")); - result.add(new WeaTableColumnGroup("150", "工号", "workcode")); - } + //扩展维度属性 + EmployeeInfoExpandDTO expandFieldSettings = getSalaryStatisticsDimensionService().getExpandFieldSettings("dim_" + dimensionName.getDimCode()); + List fieldSettings = Optional.ofNullable(Optional.ofNullable(expandFieldSettings).orElse(new EmployeeInfoExpandDTO()).getFieldSettings()).orElse(new ArrayList<>()); + fieldSettings.stream().sorted(Comparator.comparing(FieldSetting::getIndex)).forEach(setting -> { + result.add(new WeaTableColumnGroup("150", setting.getName(), setting.getField())); + }); Map itemMap = salaryStatisticsItemList.stream().collect(Collectors.toMap(SalaryStatisticsItemPO::getId, Function.identity())); Map itemIdNameMap = salaryStatisticsItemList.stream().collect(LinkedHashMap::new, (map, item) -> map.put(item.getId(), item.getItemName()), LinkedHashMap::putAll); @@ -952,6 +1204,26 @@ public class SalaryStatisticsReportBO { children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174376, "中位数同比差值"), k + UD + MEDIAN + P_Y2Y_D_VALUE)); children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174377, "中位数同比增幅"), k + UD + MEDIAN + P_Y2Y_INCREASE)); } + // 7.最新值children + SalaryStatisticsItemRuleDTO lastRule = JSON.parseObject(itemPO.getLastRule(), SalaryStatisticsItemRuleDTO.class); + if (lastRule != null && 1 == lastRule.getTotalValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174246, "最新值"), k + UD + SalaryStatisticsItemStringRuleEnum.LAST.getValue() + P_NOW)); + } + // 8.最旧值children + SalaryStatisticsItemRuleDTO oldRule = JSON.parseObject(itemPO.getOldRule(), SalaryStatisticsItemRuleDTO.class); + if (oldRule != null && 1 == oldRule.getTotalValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174246, "最旧值"), k + UD + SalaryStatisticsItemStringRuleEnum.OLD.getValue() + P_NOW)); + } + // 9.最频繁children + SalaryStatisticsItemRuleDTO frequentRule = JSON.parseObject(itemPO.getFrequentRule(), SalaryStatisticsItemRuleDTO.class); + if (frequentRule != null && 1 == frequentRule.getTotalValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174246, "最频繁"), k + UD + SalaryStatisticsItemStringRuleEnum.FREQUENT.getValue() + P_NOW)); + } + // 10.平铺children + SalaryStatisticsItemRuleDTO tileRule = JSON.parseObject(itemPO.getTileRule(), SalaryStatisticsItemRuleDTO.class); + if (tileRule != null && 1 == tileRule.getTotalValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174246, "平铺"), k + UD + SalaryStatisticsItemStringRuleEnum.TILE.getValue() + P_NOW)); + } weaTableColumn.setChildren(children); result.add(weaTableColumn); }); diff --git a/src/com/engine/salary/report/entity/dto/SalaryStatisticsItemRuleDTO.java b/src/com/engine/salary/report/entity/dto/SalaryStatisticsItemRuleDTO.java index c64881c59..02cce6b8b 100644 --- a/src/com/engine/salary/report/entity/dto/SalaryStatisticsItemRuleDTO.java +++ b/src/com/engine/salary/report/entity/dto/SalaryStatisticsItemRuleDTO.java @@ -14,30 +14,29 @@ import java.math.BigDecimal; @Builder @NoArgsConstructor @AllArgsConstructor -//"薪酬统计报表自定义统计项目规则") public class SalaryStatisticsItemRuleDTO { - //是否有合计列") + //是否有合计列。若是文本,代表是否显示 private Integer totalValue; - //是否有占比列") + //是否有占比列 private Integer ratioValue; - //是否有环比列") + //是否有环比列 private Integer m2mValue; - //合计环比上限") + //合计环比上限 private BigDecimal m2mUpperLimit; - //合计环比下限") + //合计环比下限 private BigDecimal m2mLowerLimit; - //是否有同比列") + //是否有同比列 private Integer y2yValue; - //合计同比上限") + //合计同比上限 private BigDecimal y2yUpperLimit; - //合计同比下限") + //合计同比下限 private BigDecimal y2yLowerLimit; } diff --git a/src/com/engine/salary/report/entity/dto/SalaryStatisticsItemStringRuleDTO.java b/src/com/engine/salary/report/entity/dto/SalaryStatisticsItemStringRuleDTO.java new file mode 100644 index 000000000..d41c75db1 --- /dev/null +++ b/src/com/engine/salary/report/entity/dto/SalaryStatisticsItemStringRuleDTO.java @@ -0,0 +1,23 @@ +package com.engine.salary.report.entity.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪酬统计报表自定义统计字符项目规则 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryStatisticsItemStringRuleDTO { + + + /** + * 是否启用 + */ + private Integer ableValue; + +} diff --git a/src/com/engine/salary/report/entity/param/SalaryStatisticsItemGetFormParam.java b/src/com/engine/salary/report/entity/param/SalaryStatisticsItemGetFormParam.java new file mode 100644 index 000000000..47371c1bf --- /dev/null +++ b/src/com/engine/salary/report/entity/param/SalaryStatisticsItemGetFormParam.java @@ -0,0 +1,26 @@ +package com.engine.salary.report.entity.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪酬统计报表自定义统计项目保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryStatisticsItemGetFormParam { + //统计项目id + private Long id; + + //统计项目 + private Long itemId; +} diff --git a/src/com/engine/salary/report/entity/param/SalaryStatisticsItemSaveParam.java b/src/com/engine/salary/report/entity/param/SalaryStatisticsItemSaveParam.java index 77803d374..933843736 100644 --- a/src/com/engine/salary/report/entity/param/SalaryStatisticsItemSaveParam.java +++ b/src/com/engine/salary/report/entity/param/SalaryStatisticsItemSaveParam.java @@ -20,38 +20,50 @@ import java.util.List; @Builder @NoArgsConstructor @AllArgsConstructor -//"薪酬统计报表自定义统计项目保存参数") public class SalaryStatisticsItemSaveParam { - //统计项目id") + //统计项目id private Long id; - // 报表id") + // 报表id private Long statReportId; - //统计项目") + //统计项目 private List itemValue; - //统计项名称") + //统计项名称 private String itemName; - //计数规则") + //计数规则 private SalaryStatisticsItemRuleDTO countRule; - //求和规则") + //求和规则 private SalaryStatisticsItemRuleDTO sumRule; - //平均值规则") + //平均值规则 private SalaryStatisticsItemRuleDTO avgRule; - //最大值规则") + //最大值规则 private SalaryStatisticsItemRuleDTO maxRule; - //最小值规则") + //最小值规则 private SalaryStatisticsItemRuleDTO minRule; - //中位数规则") + //中位数规则 private SalaryStatisticsItemRuleDTO medianRule; - //统计单位") + //最近值 + private SalaryStatisticsItemRuleDTO lastRule; + + //最旧值 + private SalaryStatisticsItemRuleDTO oldRule; + + //频繁出现 + private SalaryStatisticsItemRuleDTO frequentRule; + + //平铺 + private SalaryStatisticsItemRuleDTO tileRule; + + + //统计单位 private Integer unitType; } diff --git a/src/com/engine/salary/report/entity/param/SalaryStatisticsSearchConditionSaveParam.java b/src/com/engine/salary/report/entity/param/SalaryStatisticsSearchConditionSaveParam.java index 2ea00c161..ff0bc3964 100644 --- a/src/com/engine/salary/report/entity/param/SalaryStatisticsSearchConditionSaveParam.java +++ b/src/com/engine/salary/report/entity/param/SalaryStatisticsSearchConditionSaveParam.java @@ -28,6 +28,21 @@ public class SalaryStatisticsSearchConditionSaveParam { //统计维度 private Long dimension; + /** + * 1、上月 + * 2、本月 + * 3、一季度 + * 4、二季度 + * 5、三季度 + * 6、四季度 + * 7、上半年 + * 8、下半年 + * 9、本年 + * 10、自定义 + */ + //事件类型 + private Integer timeType; + //薪资所属月-开始月 private Date salaryStartMonth; diff --git a/src/com/engine/salary/report/entity/po/SalaryStatisticsItemPO.java b/src/com/engine/salary/report/entity/po/SalaryStatisticsItemPO.java index 6acfff40d..bcf430d57 100644 --- a/src/com/engine/salary/report/entity/po/SalaryStatisticsItemPO.java +++ b/src/com/engine/salary/report/entity/po/SalaryStatisticsItemPO.java @@ -126,11 +126,47 @@ public class SalaryStatisticsItemPO implements Serializable { //中位数规则") private String medianRule; + + /** + * 最近值 + *

+ * "totalValue":"1", 是否使用 + */ + private String lastRule; + + /** + * 最早值 + *

+ * { + * "totalValue":"1", 是否使用 + * } + */ + private String oldRule; + + /** + * 出现最多 + *

+ * { + * "totalValue":"1", 是否使用 + * } + */ + private String frequentRule; + + /** + * 平铺 + *

+ * { + * "totalValue":"1", 是否使用 + * } + */ + private String tileRule; + //顺序") private Integer indexValue; /** * 统计单位 + * * @see UnitTypeEnum */ //统计单位") diff --git a/src/com/engine/salary/report/entity/po/SalaryStatisticsReportPO.java b/src/com/engine/salary/report/entity/po/SalaryStatisticsReportPO.java index a465e7add..cdf364f62 100644 --- a/src/com/engine/salary/report/entity/po/SalaryStatisticsReportPO.java +++ b/src/com/engine/salary/report/entity/po/SalaryStatisticsReportPO.java @@ -21,15 +21,15 @@ import java.util.Date; @Builder @NoArgsConstructor @AllArgsConstructor -//hrsa_salary_stats_report") +//hrsa_salary_stats_report public class SalaryStatisticsReportPO implements Serializable { private static final long serialVersionUID = 6526480959578343197L; - //主键id") + //主键id private Long id; - //报表名称") + //报表名称 private String reportName; private String remark; @@ -38,58 +38,61 @@ public class SalaryStatisticsReportPO implements Serializable { private String sortIndex; private String sortType; - //统计维度") + //时间类型 + private Integer timeType; + + //统计维度 private String dimension; - //薪资所属月-起始") + //薪资所属月-起始 private Date salaryStartMonth; - //薪资所属月-截止") + //薪资所属月-截止 private Date salaryEndMonth; - //个税扣缴义务人配置") + //个税扣缴义务人配置 private String taxAgentSetting; - //收入所得项目配置") + //收入所得项目配置 private String incomeCategorySetting; - //分部配置") + //分部配置 private String subCompanySetting; - //部门配置") + //部门配置 private String departSetting; - //职级配置") + //职级配置 private String gradeSetting; - //岗位配置") + //岗位配置 private String positionSetting; - //人员状态配置") + //人员状态配置 private String statusSetting; - //人员配置") + //人员配置 private String employeeSetting; - //入职日期配置") + //入职日期配置 private String hiredateSetting; - //离职日期配置") + //离职日期配置 private String leavedateSetting; - //租户key", ignore = true) + //租户key private String tenantKey; - //创建人id", ignore = true) + //创建人id private Long creator; - //是否删除", ignore = true) + //是否删除 private Integer deleteType; - //创建时间", ignore = true) + //创建时间 private Date createTime; - //更新时间", ignore = true) + //更新时间 private Date updateTime; diff --git a/src/com/engine/salary/report/enums/SalaryStatisticsItemStringRuleEnum.java b/src/com/engine/salary/report/enums/SalaryStatisticsItemStringRuleEnum.java new file mode 100644 index 000000000..3ca0bdcff --- /dev/null +++ b/src/com/engine/salary/report/enums/SalaryStatisticsItemStringRuleEnum.java @@ -0,0 +1,52 @@ +package com.engine.salary.report.enums; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Objects; + +public enum SalaryStatisticsItemStringRuleEnum implements BaseEnum { + + + LAST("last", "最近值", 83993), + OLD("old", "最早值", 83994), + FREQUENT("frequent", "最频繁", 83994), + TILE("tile", "平铺", 83994), + ; + + private String value; + + private String defaultLabel; + + private int labelId; + + SalaryStatisticsItemStringRuleEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static SalaryStatisticsItemStringRuleEnum parseByValue(String value) { + for (SalaryStatisticsItemStringRuleEnum typeEnum : SalaryStatisticsItemStringRuleEnum.values()) { + if (Objects.equals(typeEnum.getValue(), value)) { + return typeEnum; + } + } + return null; + } + +} diff --git a/src/com/engine/salary/report/enums/UnitTypeEnum.java b/src/com/engine/salary/report/enums/UnitTypeEnum.java index 7b93dfca9..35b1fc49b 100644 --- a/src/com/engine/salary/report/enums/UnitTypeEnum.java +++ b/src/com/engine/salary/report/enums/UnitTypeEnum.java @@ -3,6 +3,7 @@ package com.engine.salary.report.enums; import com.engine.salary.enums.BaseEnum; public enum UnitTypeEnum implements BaseEnum { + empty(0, 152745, ""), REN(1, 157087, "人"), YUAN(2, 152739, "元"), QIAN(3, 157088, "千"), diff --git a/src/com/engine/salary/report/service/SalaryStatisticsDimensionService.java b/src/com/engine/salary/report/service/SalaryStatisticsDimensionService.java index 7f3dd8b38..e3a657209 100644 --- a/src/com/engine/salary/report/service/SalaryStatisticsDimensionService.java +++ b/src/com/engine/salary/report/service/SalaryStatisticsDimensionService.java @@ -1,5 +1,6 @@ package com.engine.salary.report.service; +import com.engine.salary.entity.hrm.dto.EmployeeInfoExpandDTO; import com.engine.salary.report.entity.param.SalaryStatisticsDimensionQueryParam; import com.engine.salary.report.entity.param.SalaryStatisticsDimensionSaveParam; import com.engine.salary.report.entity.po.SalaryStatisticsDimensionPO; @@ -58,6 +59,20 @@ public interface SalaryStatisticsDimensionService { */ String save(SalaryStatisticsDimensionSaveParam saveParam); + /** + * 保存字段扩展 + * @param saveParam + * @return + */ + void saveExpandFieldSettings(EmployeeInfoExpandDTO saveParam); + + /** + * 查询薪酬统计维度扩展字段设置 + * @param module + * @return + */ + EmployeeInfoExpandDTO getExpandFieldSettings(String module); + /** * 删除薪酬统计维度 * @@ -72,4 +87,5 @@ public interface SalaryStatisticsDimensionService { * @return */ List listAllDefaultDimension(); + } diff --git a/src/com/engine/salary/report/service/SalaryStatisticsReportService.java b/src/com/engine/salary/report/service/SalaryStatisticsReportService.java index 4355552cb..069793ecf 100644 --- a/src/com/engine/salary/report/service/SalaryStatisticsReportService.java +++ b/src/com/engine/salary/report/service/SalaryStatisticsReportService.java @@ -70,6 +70,13 @@ public interface SalaryStatisticsReportService { */ Map delete(Collection ids ); + /** + * 复制 + * @param id + */ + void duplicate(Long id); + + /** * 保存统计范围 * @@ -106,5 +113,4 @@ public interface SalaryStatisticsReportService { */ void removeReportCache(); - } diff --git a/src/com/engine/salary/report/service/impl/SalaryStatisticsDimensionServiceImpl.java b/src/com/engine/salary/report/service/impl/SalaryStatisticsDimensionServiceImpl.java index 865015758..c855e0037 100644 --- a/src/com/engine/salary/report/service/impl/SalaryStatisticsDimensionServiceImpl.java +++ b/src/com/engine/salary/report/service/impl/SalaryStatisticsDimensionServiceImpl.java @@ -3,6 +3,7 @@ package com.engine.salary.report.service.impl; import com.alibaba.fastjson.JSON; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; +import com.engine.salary.entity.hrm.dto.EmployeeInfoExpandDTO; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.report.SalaryStatisticsDimensionMapper; import com.engine.salary.report.common.constant.SalaryStatisticsDimensionConstant; @@ -13,6 +14,8 @@ import com.engine.salary.report.entity.po.SalaryStatisticsReportPO; import com.engine.salary.report.enums.SalaryStatisticsDimensionTypeEnum; import com.engine.salary.report.service.SalaryStatisticsDimensionService; import com.engine.salary.report.service.SalaryStatisticsReportService; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.impl.SalaryEmployeeServiceImpl; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.page.PageInfo; @@ -46,6 +49,10 @@ public class SalaryStatisticsDimensionServiceImpl extends Service implements Sal return ServiceUtil.getService(SalaryStatisticsReportServiceImpl.class, user); } + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + /** * 初始化默认维度 */ @@ -197,6 +204,16 @@ public class SalaryStatisticsDimensionServiceImpl extends Service implements Sal return StringUtils.EMPTY; } + @Override + public void saveExpandFieldSettings(EmployeeInfoExpandDTO saveParam) { + getSalaryEmployeeService(user).saveEmployeeExpandFieldSettings(saveParam); + } + + @Override + public EmployeeInfoExpandDTO getExpandFieldSettings(String module) { + return getSalaryEmployeeService(user).getExpandFieldSettings(module); + } + @Override public Map delete(Collection ids) { if (CollectionUtils.isEmpty(ids)) { diff --git a/src/com/engine/salary/report/service/impl/SalaryStatisticsItemServiceImpl.java b/src/com/engine/salary/report/service/impl/SalaryStatisticsItemServiceImpl.java index 8c56dc7ef..6468f3f4b 100644 --- a/src/com/engine/salary/report/service/impl/SalaryStatisticsItemServiceImpl.java +++ b/src/com/engine/salary/report/service/impl/SalaryStatisticsItemServiceImpl.java @@ -116,6 +116,10 @@ public class SalaryStatisticsItemServiceImpl extends Service implements SalarySt .maxRule(SalaryEntityUtil.toJSONString(saveParam.getMaxRule())) .minRule(SalaryEntityUtil.toJSONString(saveParam.getMinRule())) .medianRule(SalaryEntityUtil.toJSONString(saveParam.getMedianRule())) + .lastRule(SalaryEntityUtil.toJSONString(saveParam.getMedianRule())) + .oldRule(SalaryEntityUtil.toJSONString(saveParam.getMedianRule())) + .frequentRule(SalaryEntityUtil.toJSONString(saveParam.getMedianRule())) + .tileRule(SalaryEntityUtil.toJSONString(saveParam.getMedianRule())) .indexValue(max + 1) .statReportId(saveParam.getStatReportId()) .unitType(saveParam.getUnitType() == null ? UnitTypeEnum.YUAN.getValue() : saveParam.getUnitType()) @@ -149,6 +153,10 @@ public class SalaryStatisticsItemServiceImpl extends Service implements SalarySt itemPO.setMaxRule(SalaryEntityUtil.toJSONString(saveParam.getMaxRule())); itemPO.setMinRule(SalaryEntityUtil.toJSONString(saveParam.getMinRule())); itemPO.setMedianRule(SalaryEntityUtil.toJSONString(saveParam.getMedianRule())); + itemPO.setLastRule(SalaryEntityUtil.toJSONString(saveParam.getLastRule())); + itemPO.setOldRule(SalaryEntityUtil.toJSONString(saveParam.getOldRule())); + itemPO.setFrequentRule(SalaryEntityUtil.toJSONString(saveParam.getFrequentRule())); + itemPO.setTileRule(SalaryEntityUtil.toJSONString(saveParam.getTileRule())); } getSalaryStatisticsItemMapper().updateIgnoreNull(itemPO); diff --git a/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java b/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java index ecadc58bf..c71f5193c 100644 --- a/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java +++ b/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java @@ -6,6 +6,8 @@ import com.engine.core.impl.Service; import com.engine.salary.cache.SalaryCacheKey; import com.engine.salary.constant.SalaryDefaultTenantConstant; import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.hrm.dto.EmployeeInfoExpandDTO; +import com.engine.salary.entity.hrm.dto.FieldSetting; import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; @@ -22,6 +24,7 @@ import com.engine.salary.report.entity.po.SalaryStatisticsDimensionPO; import com.engine.salary.report.entity.po.SalaryStatisticsItemPO; import com.engine.salary.report.entity.po.SalaryStatisticsReportPO; import com.engine.salary.report.enums.SalaryStatisticsDimensionTypeEnum; +import com.engine.salary.report.service.SalaryStatisticsDimensionService; import com.engine.salary.report.service.SalaryStatisticsItemService; import com.engine.salary.report.service.SalaryStatisticsReportService; import com.engine.salary.report.util.ReportTimeUtil; @@ -70,6 +73,10 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary return MapperProxyFactory.getProxy(SalaryStatisticsReportMapper.class); } + private SalaryStatisticsDimensionService getSalaryStatisticsDimensionService(User user) { + return ServiceUtil.getService(SalaryStatisticsDimensionServiceImpl.class, user); + } + private SalaryStatisticsItemService getSalaryStatisticsItemService(User user) { return ServiceUtil.getService(SalaryStatisticsItemServiceImpl.class, user); } @@ -265,6 +272,8 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary po.setLeavedateSetting(JSON.toJSONString(param.getLeavedate())); } + po.setTimeType(param.getTimeType()); + getSalaryStatisticsReportMapper().updateIgnoreNull(po); // 获取自定义统计项目 @@ -331,13 +340,41 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary return resultMap; } + @Override + public void duplicate(Long id) { + long uid = user.getUID(); + Date now = new Date(); + + SalaryStatisticsReportPO po = getById(id); + SalaryAssert.notNull(po, SalaryI18nUtil.getI18nLabel(152563, "报表不存在")); + + po.setId(IdGenerator.generate()); + po.setCreator(uid); + po.setCreateTime(now); + po.setUpdateTime(now); + po.setReportName(po.getReportName()+"_copy"); + + getSalaryStatisticsReportMapper().insertIgnoreNull(po); + + List itemPOS = getSalaryStatisticsItemService(user).listByStatisticsReportId(id); + List itemList = itemPOS.stream().map(item -> { + item.setId(IdGenerator.generate()); + item.setStatReportId(po.getId()); + item.setCreator(uid); + item.setCreateTime(now); + item.setUpdateTime(now); + return item; + }).collect(Collectors.toList()); + getSalaryStatisticsItemService(user).saveOrUpdateBatch(itemList); + } + @Override public PageInfo> buildReportRecords(SalaryStatisticsDimensionPO dimension, SalaryStatisticsReportDataQueryParam param, List salaryStatisticsItemList) { Map checkMap = SalaryStatisticsReportBO.checkLoad(salaryStatisticsItemList); // 如果一个都没有,直接返回 - if (!checkMap.get("isNow")) { - return new PageInfo>(); - } +// if (!checkMap.get("isNow")) { +// return new PageInfo>(); +// } // 获取本期报表分权后的核算人员 @@ -392,8 +429,8 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary Map> resultMap = new HashMap<>(); List salaryAcctEmployeeIds = salaryAcctEmployeeList.stream().map(SalaryAcctEmployeePO::getId).collect(Collectors.toList()); - if( NumberUtils.isCreatable(dimension.getDimCode()) ){ - List salaryAcctResultValues = getSalaryAcctResultService(user).listByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmployeeIds,Collections.singleton(Long.valueOf(dimension.getDimCode()))); + if (NumberUtils.isCreatable(dimension.getDimCode())) { + List salaryAcctResultValues = getSalaryAcctResultService(user).listByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmployeeIds, Collections.singleton(Long.valueOf(dimension.getDimCode()))); List finalSalaryAcctEmpIds = getSalaryAcctResultService(user).listAcctEmpIdByAcctEmpId(salaryAcctEmployeeIds); Map> salaryAcctEmpResultMap = SalaryEntityUtil.group2Map(salaryAcctResultValues, SalaryAcctResultPO::getSalaryAcctEmpId); salaryAcctEmpResultMap.forEach((k, v) -> { @@ -401,8 +438,8 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary resultMap.put(k, collect); }); salaryAcctEmployeeIds.stream().forEach(id -> { - if(!resultMap.containsKey(id) && finalSalaryAcctEmpIds.contains(id)) - resultMap.put(id,Collections.emptyMap()); + if (!resultMap.containsKey(id) && finalSalaryAcctEmpIds.contains(id)) + resultMap.put(id, Collections.emptyMap()); }); } @@ -464,7 +501,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary } public List getReportCache() { - List report = new ArrayList<>(); + List report = new ArrayList<>(); //获取所有缓存报表的id String salaryReportIds = Utils.null2String(getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_IDS)); @@ -473,13 +510,13 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary if (StringUtils.isNotBlank(id)) { //报表下条件id String salaryReportConditions = getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_CONDITIONS + id); - List c= new ArrayList<>(); + List c = new ArrayList<>(); if (StringUtils.isNotBlank(salaryReportConditions)) { Arrays.asList(salaryReportConditions.split(",")).forEach(paramMd5 -> { if (StringUtils.isNotBlank(paramMd5)) { Map data = getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_DATA + paramMd5); - Map kv= new HashMap<>(); - kv.put(paramMd5,data); + Map kv = new HashMap<>(); + kv.put(paramMd5, data); c.add(kv); } } @@ -1014,7 +1051,18 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary Map> employeeListMap = accountDetailPOList.stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getEmployeeId)); Map> lastEmployeeListMap = data.getLastList().stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getEmployeeId)); Map> sameEmployeeListMap = data.getSameList().stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getEmployeeId)); - Map employeeByIdMap = getSalaryEmployeeService(user).getEmployeeByIdsAll(accountDetailPOList.stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList())).stream().collect(Collectors.toMap(DataCollectionEmployee::getEmployeeId, o -> o)); + + List empIds = accountDetailPOList.stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + Map employeeByIdMap = getSalaryEmployeeService(user).getEmployeeByIdsAll(empIds) + .stream() + .collect(Collectors.toMap(DataCollectionEmployee::getEmployeeId, o -> o)); + + //人员维度扩展属性 + EmployeeInfoExpandDTO employeeInfoExpandDTO = getSalaryStatisticsDimensionService(user).getExpandFieldSettings("dim_employee"); + List fieldSettings = Optional.ofNullable(Optional.ofNullable(employeeInfoExpandDTO).orElse(new EmployeeInfoExpandDTO()).getFieldSettings()).orElse(new ArrayList<>()); + Map> expandEmployeeMap = getSalaryEmployeeService(user).expandEmployeeMap(empIds, employeeInfoExpandDTO); + + log.info("扩展属性"+expandEmployeeMap); // List extEmployees = extEmployeeService.listByIdsWithDeleted(accountDetailPOList.stream().filter(e -> EmployeeTypeEnum.EXT_EMPLOYEE.getValue().equals(e.getEmployeeType())).map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()), data.getTenantKey()); // Map employeeExtByIdMap = SalaryEntityUtil.convert2Map(extEmployees, ExtEmployeePO::getId, ExtEmployeePO::getUsername); @@ -1025,8 +1073,11 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary Map temp = new HashMap<>(); // temp.put(DM, Objects.nonNull(employeeByIdMap.get(k)) ? employeeByIdMap.get(k) : employeeExtByIdMap.get(k)); temp.put(DM, employeeByIdMap.get(k).getUsername()); - temp.put("departmentName", employeeByIdMap.get(k).getDepartmentName()); - temp.put("workcode", employeeByIdMap.get(k).getWorkcode()); + fieldSettings.forEach( + fieldSetting -> { + temp.put(fieldSetting.getField(), expandEmployeeMap.getOrDefault(k,new HashMap<>()).get(fieldSetting.getField())); + } + ); temp.putAll(SalaryStatisticsReportBO.calculateItem(v, lastEmployeeListMap.get(k), sameEmployeeListMap.get(k), salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); records.add(temp); } else if (StringUtils.equals(dimensionValue, employeeByIdMap.get(k).getUsername())) { diff --git a/src/com/engine/salary/report/web/SalaryStatisticsDimensionController.java b/src/com/engine/salary/report/web/SalaryStatisticsDimensionController.java index e0f26bb8d..16c4a64d0 100644 --- a/src/com/engine/salary/report/web/SalaryStatisticsDimensionController.java +++ b/src/com/engine/salary/report/web/SalaryStatisticsDimensionController.java @@ -1,6 +1,7 @@ package com.engine.salary.report.web; import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.hrm.dto.EmployeeInfoExpandDTO; import com.engine.salary.report.entity.dto.SalaryStatisticsDimensionFormDTO; import com.engine.salary.report.entity.dto.SalaryStatisticsDimensionListDTO; import com.engine.salary.report.entity.param.SalaryStatisticsDimensionQueryParam; @@ -58,7 +59,7 @@ public class SalaryStatisticsDimensionController { @GET @Path("/getForm") @Produces(MediaType.APPLICATION_JSON) - public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id")Long id) { + public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { User user = HrmUserVarify.getUser(request, response); return new ResponseResult(user).run(getSalaryStatisticsDimensionWrapper(user)::getFrom, id); } @@ -78,6 +79,33 @@ public class SalaryStatisticsDimensionController { return new ResponseResult(user).run(getSalaryStatisticsDimensionWrapper(user)::save, saveParam); } + /** + * 保存薪酬统计维度扩展字段设置 + * + * @param saveParam + * @return + */ + @POST + @Path("/saveExpandFieldSettings") + @Produces(MediaType.APPLICATION_JSON) + public String saveExpandFieldSettings(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody EmployeeInfoExpandDTO saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryStatisticsDimensionWrapper(user)::saveExpandFieldSettings, saveParam); + } + + /** + * 查询薪酬统计维度扩展字段设置 + * + * @return + */ + @GET + @Path("/getExpandFieldSettings") + @Produces(MediaType.APPLICATION_JSON) + public String getExpandFieldSettings(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "module") String module) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryStatisticsDimensionWrapper(user)::getExpandFieldSettings, module); + } + /** * 删除薪酬统计维度 * diff --git a/src/com/engine/salary/report/web/SalaryStatisticsItemController.java b/src/com/engine/salary/report/web/SalaryStatisticsItemController.java index 0c8b1ee95..c59c12b3b 100644 --- a/src/com/engine/salary/report/web/SalaryStatisticsItemController.java +++ b/src/com/engine/salary/report/web/SalaryStatisticsItemController.java @@ -31,6 +31,7 @@ public class SalaryStatisticsItemController { private SalaryStatisticsItemWrapper getSalaryStatisticsItemWrapper(User user) { return ServiceUtil.getService(SalaryStatisticsItemWrapper.class, user); } + /** * 获取自定义统计项目表单 * @@ -40,11 +41,26 @@ public class SalaryStatisticsItemController { @GET @Path("/getForm") @Produces(MediaType.APPLICATION_JSON) - public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id")Long id) { + public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { User user = HrmUserVarify.getUser(request, response); return new ResponseResult(user).run(getSalaryStatisticsItemWrapper(user)::getForm, id); } + /** + * 切换薪资项目 + * @param request + * @param response + * @param itemId + * @return + */ + @GET + @Path("/changeTab") + @Produces(MediaType.APPLICATION_JSON) + public String changeTab(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "itemId") Long itemId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryStatisticsItemWrapper(user)::changeTab, itemId); + } + /** * 自定义统计项目列表 @@ -55,7 +71,7 @@ public class SalaryStatisticsItemController { @GET @Path("/list") @Produces(MediaType.APPLICATION_JSON) - public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "statisticsReportId")Long statisticsReportId) { + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "statisticsReportId") Long statisticsReportId) { User user = HrmUserVarify.getUser(request, response); return new ResponseResult>>(user).run(getSalaryStatisticsItemWrapper(user)::list, statisticsReportId); } diff --git a/src/com/engine/salary/report/web/SalaryStatisticsReportController.java b/src/com/engine/salary/report/web/SalaryStatisticsReportController.java index 010547fab..6fa9b5c24 100644 --- a/src/com/engine/salary/report/web/SalaryStatisticsReportController.java +++ b/src/com/engine/salary/report/web/SalaryStatisticsReportController.java @@ -95,6 +95,20 @@ public class SalaryStatisticsReportController { return new ResponseResult, Map>(user).run(getSalaryStatisticsReportWrapper(user)::delete, ids); } + /** + * 复制薪酬统计报表 + * + * @param id + * @return + */ + @GET + @Path("/duplicate") + @Produces(MediaType.APPLICATION_JSON) + public String duplicate(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryStatisticsReportWrapper(user)::duplicate, id); + } + /** * 获取薪酬统计报表查询条件 * @@ -151,6 +165,8 @@ public class SalaryStatisticsReportController { SalaryStatisticsReportDataQueryParam param = SalaryStatisticsReportDataQueryParam.builder() .id(Long.parseLong(request.getParameter("id"))) .dimensionId(Long.parseLong(request.getParameter("dimensionId"))) + .salaryStartMonth(request.getParameter("salaryStartMonth")) + .salaryEndMonth(request.getParameter("salaryEndMonth")) .isShare(StringUtils.equals(request.getParameter("isShare"), "true")) .build(); try { diff --git a/src/com/engine/salary/report/wrapper/SalaryStatisticsDimensionWrapper.java b/src/com/engine/salary/report/wrapper/SalaryStatisticsDimensionWrapper.java index 11619c545..7e8c8a374 100644 --- a/src/com/engine/salary/report/wrapper/SalaryStatisticsDimensionWrapper.java +++ b/src/com/engine/salary/report/wrapper/SalaryStatisticsDimensionWrapper.java @@ -3,6 +3,7 @@ package com.engine.salary.report.wrapper; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.component.WeaFormOption; +import com.engine.salary.entity.hrm.dto.EmployeeInfoExpandDTO; import com.engine.salary.entity.salaryitem.po.SalaryItemPO; import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; import com.engine.salary.exception.SalaryRunTimeException; @@ -24,6 +25,7 @@ import com.engine.salary.util.JsonUtil; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; import com.google.common.collect.Lists; import org.apache.commons.collections4.CollectionUtils; import weaver.hrm.User; @@ -43,11 +45,11 @@ public class SalaryStatisticsDimensionWrapper extends Service { private SalaryStatisticsDimensionService salaryStatisticsDimensionService(User user) { - return ServiceUtil.getService(SalaryStatisticsDimensionServiceImpl.class, user); + return ServiceUtil.getService(SalaryStatisticsDimensionServiceImpl.class, user); } private SalaryItemService salaryItemService(User user) { - return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); } private SalaryStatisticsDimensionService getSalaryStatisticsDimensionService(User user) { @@ -67,7 +69,7 @@ public class SalaryStatisticsDimensionWrapper extends Service { public PageInfo list(SalaryStatisticsDimensionQueryParam queryParam) { PageInfo page = salaryStatisticsDimensionService(user).listPage(queryParam); List list = page.getList(); - List dtoList= new ArrayList<>(); + List dtoList = new ArrayList<>(); // 获取默认维度统计 List defaultSalaryStatisticsDimensions = getSalaryStatisticsDimensionService(user).listAllDefaultDimension(); @@ -87,11 +89,11 @@ public class SalaryStatisticsDimensionWrapper extends Service { .canEdit(true) .canDelete(true) .build(); - if (defaultDimensionIds.contains(dto.getId())){ + if (defaultDimensionIds.contains(dto.getId())) { // 默认维度不允许修改、删除 dto.setCanEdit(false); dto.setCanDelete(false); - }else if(haveUsedDimIds.contains(dto.getId().toString())){ + } else if (haveUsedDimIds.contains(dto.getId().toString())) { // 被薪资统计报表引用的不能删除 dto.setCanDelete(false); } @@ -99,7 +101,7 @@ public class SalaryStatisticsDimensionWrapper extends Service { }); } - PageInfo salaryStatisticsDimensionListDTOPageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize()); + PageInfo salaryStatisticsDimensionListDTOPageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize()); salaryStatisticsDimensionListDTOPageInfo.setList(dtoList); salaryStatisticsDimensionListDTOPageInfo.setTotal(page.getTotal()); return salaryStatisticsDimensionListDTOPageInfo; @@ -138,8 +140,8 @@ public class SalaryStatisticsDimensionWrapper extends Service { .map(item -> new WeaFormOption(item.getId().toString(), item.getName())).collect(Collectors.toList())); // 1.构建基础信息表单 Map baseForm = new HashMap<>(); - baseForm.put("statsDimOptions",statsDimOptions); - baseForm.put("groupDimOptions",groupDimOptions); + baseForm.put("statsDimOptions", statsDimOptions); + baseForm.put("groupDimOptions", groupDimOptions); // 2.分组设置 String groupSetting = "[]"; if (id != null) { @@ -187,6 +189,28 @@ public class SalaryStatisticsDimensionWrapper extends Service { return salaryStatisticsDimensionService(user).save(saveParam); } + /** + * 保存薪酬统计维度扩展设置 + * + * @param saveParam + * @return + */ + public void saveExpandFieldSettings(EmployeeInfoExpandDTO saveParam) { + ValidUtil.modify(saveParam); +// Optional.ofNullable(saveParam.getFieldSettings()).orElse(new ArrayList<>()).forEach(fieldSetting -> fieldSetting.setField(fieldSetting.getField().trim())); + salaryStatisticsDimensionService(user).saveExpandFieldSettings(saveParam); + } + + + /** + * 查询薪酬统计维度扩展字段设置 + * + * @return + */ + public EmployeeInfoExpandDTO getExpandFieldSettings(String module) { + return salaryStatisticsDimensionService(user).getExpandFieldSettings(module); + } + /** * 删除薪酬统计维度 * @@ -211,4 +235,5 @@ public class SalaryStatisticsDimensionWrapper extends Service { return map; }).collect(Collectors.toList()); } + } diff --git a/src/com/engine/salary/report/wrapper/SalaryStatisticsItemWrapper.java b/src/com/engine/salary/report/wrapper/SalaryStatisticsItemWrapper.java index b424cc43e..9d3e66d2e 100644 --- a/src/com/engine/salary/report/wrapper/SalaryStatisticsItemWrapper.java +++ b/src/com/engine/salary/report/wrapper/SalaryStatisticsItemWrapper.java @@ -5,9 +5,11 @@ import com.cloudstore.eccom.pc.table.WeaTableColumn; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; import com.engine.salary.report.entity.dto.SalaryStatisticsItemFormDTO; import com.engine.salary.report.entity.param.SalaryStatisticsItemSaveParam; import com.engine.salary.report.entity.po.SalaryStatisticsItemPO; +import com.engine.salary.report.enums.SalaryStatisticsItemStringRuleEnum; import com.engine.salary.report.enums.UnitTypeEnum; import com.engine.salary.report.service.SalaryStatisticsItemService; import com.engine.salary.report.service.impl.SalaryStatisticsItemServiceImpl; @@ -47,7 +49,7 @@ public class SalaryStatisticsItemWrapper extends Service { * @return */ public SalaryStatisticsItemFormDTO getForm(Long id) { - Map weaForm = new HashMap(); + Map weaForm = new HashMap<>(); Map ruleData = new HashMap<>(); if (Objects.nonNull(id)) { SalaryStatisticsItemPO salaryStatisticsItem = getSalaryStatisticsItemService(user).getById(id); @@ -55,22 +57,24 @@ public class SalaryStatisticsItemWrapper extends Service { String itemValue = salaryStatisticsItem.getItemValue(); if (StringUtils.isNotBlank(itemValue)) { List salaryItems = getSalaryItemService(user).listAll(); - Map itemsMap = SalaryEntityUtil.convert2Map(salaryItems, k -> k.getId().toString(), SalaryItemPO::getName); + Map itemsMap = SalaryEntityUtil.convert2Map(salaryItems, k -> k.getId().toString()); List> welfareItems = new ArrayList<>(); Arrays.stream(itemValue.split(",")).forEach(value -> { Map welfareItem = new HashMap<>(); welfareItem.put("id", value); - welfareItem.put("name", itemsMap.get(value)); + welfareItem.put("name", itemsMap.get(value).getName()); + welfareItem.put("dataType", itemsMap.get(value).getDataType()); welfareItems.add(welfareItem); }); - Map map = new HashMap(); - map.put("itemValue", welfareItems); + Map map = new HashMap<>(); + //版本变更,由多选变成单选 + map.put("itemValue", welfareItems.get(0)); map.put("itemName", salaryStatisticsItem.getItemName()); weaForm.put("data", map); - ruleData = buildRule(salaryStatisticsItem); + ruleData = buildRule(SalaryDataTypeEnum.parseByValue(welfareItems.get(0).get("dataType")), salaryStatisticsItem); } } else { - ruleData = buildRule(null); + ruleData = buildRule(null, null); } return SalaryStatisticsItemFormDTO.builder() @@ -80,7 +84,86 @@ public class SalaryStatisticsItemWrapper extends Service { .build(); } - public Map buildRule(SalaryStatisticsItemPO salaryStatisticsItem) { + public SalaryStatisticsItemFormDTO changeTab(Long itemId) { + SalaryItemPO po = getSalaryItemService(user).getById(itemId); + Map ruleData = buildRule(SalaryDataTypeEnum.parseByValue(po.getDataType()), null); + return SalaryStatisticsItemFormDTO.builder().ruleData(ruleData).build(); + + } + + public Map buildRule(SalaryDataTypeEnum dataType, SalaryStatisticsItemPO salaryStatisticsItem) { + Map weaTable; + if (dataType == null || dataType == SalaryDataTypeEnum.NUMBER) { + weaTable = buildNumberRule(salaryStatisticsItem); + } else { + weaTable = buildStringRule(salaryStatisticsItem); + } + return weaTable; + } + + /** + * 字符取值规则 + * + * @param salaryStatisticsItem 统计项 + * @return + */ + private Map buildStringRule(SalaryStatisticsItemPO salaryStatisticsItem) { + Map weaTable = new HashMap<>(); + + List list = new ArrayList<>(); + WeaTableColumn ruleName = new WeaTableColumn("20%", SalaryI18nUtil.getI18nLabel(157532, "字符取值规则"), "ruleName"); + list.add(ruleName); + weaTable.put("columns", list); + + List> result = new ArrayList<>(); + if (salaryStatisticsItem == null) { + for (SalaryStatisticsItemStringRuleEnum ruleEnum : SalaryStatisticsItemStringRuleEnum.values()) { + Map rule = new HashMap<>(); + rule.put("id", ruleEnum.getValue()); + rule.put("ruleName", ruleEnum.getDefaultLabel()); + rule.put("totalValue", 0); + result.add(rule); + } + } else { + for (SalaryStatisticsItemStringRuleEnum ruleEnum : SalaryStatisticsItemStringRuleEnum.values()) { + Map rule = new HashMap<>(); + switch (ruleEnum) { + case LAST: + rule = JSON.parseObject(salaryStatisticsItem.getLastRule(), HashMap.class); + break; + case OLD: + rule = JSON.parseObject(salaryStatisticsItem.getOldRule(), HashMap.class); + break; + case FREQUENT: + rule = JSON.parseObject(salaryStatisticsItem.getFrequentRule(), HashMap.class); + break; + case TILE: + rule = JSON.parseObject(salaryStatisticsItem.getTileRule(), HashMap.class); + break; + default: + break; + } + if (rule == null) { + rule = new HashMap<>(); + } + rule.put("id", ruleEnum.getValue()); + rule.put("ruleName", ruleEnum.getDefaultLabel()); + rule.put("totalValue", Optional.ofNullable(rule.get("totalValue")).orElse(0)); + result.add(rule); + } + } + weaTable.put("data", result); + + return weaTable; + } + + /** + * 数值取值规则 + * + * @param salaryStatisticsItem 统计项 + * @return + */ + private Map buildNumberRule(SalaryStatisticsItemPO salaryStatisticsItem) { Map weaTable = new HashMap<>(); List list = new ArrayList<>(); WeaTableColumn ruleName = new WeaTableColumn("20%", SalaryI18nUtil.getI18nLabel(157532, "统计规则"), "ruleName"); @@ -126,22 +209,22 @@ public class SalaryStatisticsItemWrapper extends Service { Map rule = new HashMap<>(); switch (ruleList.get(i)) { case "count": - rule = JSON.parseObject(salaryStatisticsItem.getCountRule(), new HashMap().getClass()); + rule = JSON.parseObject(salaryStatisticsItem.getCountRule(), HashMap.class); break; case "sum": - rule = JSON.parseObject(salaryStatisticsItem.getSumRule(), new HashMap().getClass()); + rule = JSON.parseObject(salaryStatisticsItem.getSumRule(), HashMap.class); break; case "avg": - rule = JSON.parseObject(salaryStatisticsItem.getAvgRule(), new HashMap().getClass()); + rule = JSON.parseObject(salaryStatisticsItem.getAvgRule(), HashMap.class); break; case "max": - rule = JSON.parseObject(salaryStatisticsItem.getMaxRule(), new HashMap().getClass()); + rule = JSON.parseObject(salaryStatisticsItem.getMaxRule(), HashMap.class); break; case "min": - rule = JSON.parseObject(salaryStatisticsItem.getMinRule(), new HashMap().getClass()); + rule = JSON.parseObject(salaryStatisticsItem.getMinRule(), HashMap.class); break; case "median": - rule = JSON.parseObject(salaryStatisticsItem.getMedianRule(), new HashMap().getClass()); + rule = JSON.parseObject(salaryStatisticsItem.getMedianRule(), HashMap.class); break; default: break; @@ -213,4 +296,5 @@ public class SalaryStatisticsItemWrapper extends Service { public String save(SalaryStatisticsItemSaveParam saveParam) { return getSalaryStatisticsItemService(user).save(saveParam); } + } diff --git a/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java b/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java index 895b09ba9..ce270b1fa 100644 --- a/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java +++ b/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java @@ -130,7 +130,9 @@ public class SalaryStatisticsReportWrapper extends Service { Map temp = new HashMap<>(); temp.put("id", po.getId().toString()); temp.put("reportName", po.getReportName()); - + temp.put("timeType", po.getTimeType() == null ? 10 : po.getTimeType()); + temp.put("salaryStartMonth", SalaryDateUtil.getFormatYearMonth(po.getSalaryStartMonth())); + temp.put("salaryEndMonth", SalaryDateUtil.getFormatYearMonth(po.getSalaryEndMonth())); List dimNames = Arrays.stream(po.getDimension().split(",")).map(dim -> Optional.ofNullable(salaryStatisticsDimensionMap.get(dim)).orElse("")).collect(Collectors.toList()); temp.put("dimension", StringUtils.join(dimNames, ",")); temp.put("dimensionId", po.getDimension()); @@ -212,6 +214,16 @@ public class SalaryStatisticsReportWrapper extends Service { return getSalaryStatisticsReportService(user).delete(ids); } + /** + * 复制薪资账套 + * @param id + */ + public void duplicate(Long id) { + if (id == null) { + throw new SalaryRunTimeException("id为空"); + } + getSalaryStatisticsReportService(user).duplicate(id); + } /** * 获取统计条件 @@ -228,6 +240,7 @@ public class SalaryStatisticsReportWrapper extends Service { SalaryAssert.notNull(po, SalaryI18nUtil.getI18nLabel(152563, "报表不存在")); Map data = new HashMap<>(); + data.put("timeType", po.getTimeType() == null ? 10 : po.getTimeType()); data.put("salaryStartMonth", SalaryDateUtil.getFormatYearMonth(po.getSalaryStartMonth())); data.put("salaryEndMonth", SalaryDateUtil.getFormatYearMonth(po.getSalaryEndMonth())); data.put("taxAgent", JSONArray.parseArray(po.getTaxAgentSetting())); @@ -470,8 +483,9 @@ public class SalaryStatisticsReportWrapper extends Service { /** * 权限校验 + * * @param isShared 是否是被分享的报表 - * @param po 报表po + * @param po 报表po */ private void sharedReportCheck(boolean isShared, SalaryStatisticsReportPO po) { if (isShared) { diff --git a/src/com/engine/salary/service/SalaryEmployeeService.java b/src/com/engine/salary/service/SalaryEmployeeService.java index 1832d4772..33898e40a 100644 --- a/src/com/engine/salary/service/SalaryEmployeeService.java +++ b/src/com/engine/salary/service/SalaryEmployeeService.java @@ -4,6 +4,7 @@ import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.hrm.DeptInfo; import com.engine.salary.entity.hrm.PositionInfo; import com.engine.salary.entity.hrm.SubCompanyInfo; +import com.engine.salary.entity.hrm.dto.EmployeeInfoExpandDTO; import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam; import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum; @@ -99,4 +100,28 @@ public interface SalaryEmployeeService { * @param formatDate */ Map getResignationMapByDate(String formatDate); + + /** + * 扩展人员信息 + * @param ids + * @param param + * @return + */ + List expandEmployeeInfo(List ids, EmployeeInfoExpandDTO param); + + Map> expandEmployeeMap(List ids, EmployeeInfoExpandDTO param); + + + /** + * 保存扩展信息 + * @param param + */ + void saveEmployeeExpandFieldSettings(EmployeeInfoExpandDTO param); + + /** + * 获取扩展信息 + * @param module + * @return + */ + EmployeeInfoExpandDTO getExpandFieldSettings(String module); } diff --git a/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java b/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java index 6f0f8fb55..e1f096f63 100644 --- a/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java @@ -1,20 +1,25 @@ package com.engine.salary.service.impl; +import com.alibaba.fastjson.JSON; import com.api.formmode.mybatis.util.SqlProxyHandle; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.biz.EmployBiz; +import com.engine.salary.constant.SalaryDefaultTenantConstant; import com.engine.salary.entity.SalarySobExtRangePO; import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.hrm.DeptInfo; import com.engine.salary.entity.hrm.PositionInfo; import com.engine.salary.entity.hrm.SubCompanyInfo; +import com.engine.salary.entity.hrm.dto.EmployeeInfoExpandDTO; +import com.engine.salary.entity.hrm.dto.FieldSetting; +import com.engine.salary.entity.hrm.po.ExpandFieldSettingsPO; import com.engine.salary.entity.salarysob.bo.SalarySobRangeBO; import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam; import com.engine.salary.entity.salarysob.po.SalarySobRangePO; import com.engine.salary.enums.UserStatusEnum; import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum; -import com.engine.salary.mapper.datacollection.EmployMapper; +import com.engine.salary.mapper.hrm.ExpandFieldSettingsMapper; import com.engine.salary.mapper.sys.SalarySysConfMapper; import com.engine.salary.service.ExtEmpService; import com.engine.salary.service.SalaryEmployeeService; @@ -22,11 +27,13 @@ import com.engine.salary.service.SalarySobExtRangeService; import com.engine.salary.service.SalarySobRangeService; import com.engine.salary.sys.entity.po.SalarySysConfPO; import com.engine.salary.util.SalaryEntityUtil; -import com.engine.salary.util.db.MapperProxyFactory; import com.google.common.collect.Lists; +import dm.jdbc.util.IdGenerator; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; +import weaver.conn.RecordSet; import weaver.hrm.User; import java.util.*; @@ -40,6 +47,7 @@ import java.util.stream.Collectors; * @author qiantao * @version 1.0 **/ +@Slf4j public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployeeService { private EmployBiz employBiz = new EmployBiz(); @@ -48,15 +56,16 @@ public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployee return ServiceUtil.getService(SalarySobRangeServiceImpl.class, user); } - private EmployMapper getEmployMapper() { - return MapperProxyFactory.getProxy(EmployMapper.class); - } - private SalarySysConfMapper getSalarySysConfMapper() { return SqlProxyHandle.getProxy(SalarySysConfMapper.class); } + private ExpandFieldSettingsMapper getExpandFieldSettingsMapper() { + return SqlProxyHandle.getProxy(ExpandFieldSettingsMapper.class); + } + + private ExtEmpService getExtEmpService(User user) { return ServiceUtil.getService(ExtEmpServiceImpl.class, user); } @@ -272,6 +281,7 @@ public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployee /** * 根据离职日期获取离职信息 + * * @param dismissDate * @return */ @@ -283,4 +293,128 @@ public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployee List employeeList = employBiz.listByDismissDate(dismissDate); return SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getDismissdate); } + + @Override + public List expandEmployeeInfo(List ids, EmployeeInfoExpandDTO param) { + + List employees = getEmployeeByIdsAll(ids); + + if (param != null) { + RecordSet rs = new RecordSet(); + String sql = param.getExpandSql().replace("=$人员id$", "in (" + StringUtils.join(ids, ",") + ")") + .replace("in($人员id$)", "in (" + StringUtils.join(ids, ",") + ")"); + String primaryKey = param.getPk(); + rs.executeQuery(sql); + while (rs.next()) { + Map extendData = new HashMap<>(); + param.getFieldSettings().forEach(setting -> { + String field = setting.getField(); + String value = rs.getString(field); + setting.setValue(value); + extendData.put(field, value); + }); + + String id = rs.getString(primaryKey); + employees.stream() + .filter(e -> id.equals(e.getEmployeeId().toString())) + .forEach(e -> e.setExtendData(extendData)); + } + } + return employees; + } + + @Override + public Map> expandEmployeeMap(List ids, EmployeeInfoExpandDTO param) { + if (CollectionUtils.isNotEmpty(ids) && param != null) { + Map> map = new HashMap<>(); + + List> partition = Lists.partition(ids, 5); + for (int i = 0; i < partition.size(); i++) { + List idList = partition.get(i); + RecordSet rs = new RecordSet(); + String sql = param.getExpandSql().replace("=$人员id$", " in (" + StringUtils.join(idList, ",") + ")") + .replace("in($人员id$)", " in (" + StringUtils.join(idList, ",") + ")"); + String primaryKey = param.getPk(); + rs.executeQuery(sql); + + log.info("扩展属性sql" + sql); + + while (rs.next()) { + Map extendData = new HashMap<>(); + param.getFieldSettings().forEach(setting -> { + String field = setting.getField(); + String value = rs.getString(field); + setting.setValue(value); + extendData.put(field, value); + }); + + String id = rs.getString(primaryKey); + map.put(Long.valueOf(id), extendData); + } + } + + return map; + } + return new HashMap<>(); + } + + @Override + public void saveEmployeeExpandFieldSettings(EmployeeInfoExpandDTO param) { + String settings = JSON.toJSONString(param.getFieldSettings()); + + Date now = new Date(); + + if (Objects.nonNull(param.getId())) { + ExpandFieldSettingsPO po = getExpandFieldSettingsMapper().getById(param.getId()); + if (po == null) { + throw new RuntimeException("配置不存在!"); + } + + po.setPk(param.getPk()); + po.setExpandSql(param.getExpandSql()); + po.setFieldSetting(settings); + po.setCreator((long) user.getUID()); + po.setUpdateTime(now); + getExpandFieldSettingsMapper().update(po); + + } else { + ExpandFieldSettingsPO po = ExpandFieldSettingsPO.builder() + .id(IdGenerator.generate()) + .module(param.getModule()) + .moduleInfo(param.getModuleInfo()) + .pk(param.getPk()) + .fieldSetting(settings) + .expandSql(param.getExpandSql()) + .deleteType(0) + .creator((long) user.getUID()) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + getExpandFieldSettingsMapper().insertIgnoreNull(po); + } + + } + + + @Override + public EmployeeInfoExpandDTO getExpandFieldSettings(String module) { + + ExpandFieldSettingsPO po = getExpandFieldSettingsMapper().getByModule(module); + + if (po != null) { + List list = JSON.parseArray(po.getFieldSetting(), FieldSetting.class); + return EmployeeInfoExpandDTO.builder() + .id(po.getId()) + .module(po.getModule()) + .moduleInfo(po.getModuleInfo()) + .pk(po.getPk()) + .expandSql(po.getExpandSql()) + .fieldSettings(list) + .build(); + + } + + return null; + } } diff --git a/src/com/engine/salary/service/impl/SalaryFormulaServiceImpl.java b/src/com/engine/salary/service/impl/SalaryFormulaServiceImpl.java index 3e34a2715..e15006e2b 100644 --- a/src/com/engine/salary/service/impl/SalaryFormulaServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryFormulaServiceImpl.java @@ -119,24 +119,7 @@ public class SalaryFormulaServiceImpl extends Service implements SalaryFormulaSe } //将select因XSS过滤造成的异常字符转换回来 - param.setFormula(param.getFormula().replaceAll("select", "select")); - param.setFormula(param.getFormula().replaceAll("SELECT", "SELECT")); - param.setFormula(param.getFormula().replaceAll("join", "join")); - param.setFormula(param.getFormula().replaceAll("JOIN", "JOIN")); - param.setFormula(param.getFormula().replaceAll("and", "and")); - param.setFormula(param.getFormula().replaceAll("AND", "AND")); - param.setFormula(param.getFormula().replaceAll("or", "or")); - param.setFormula(param.getFormula().replaceAll("OR", "OR")); - param.setFormula(param.getFormula().replaceAll("in", "in")); - param.setFormula(param.getFormula().replaceAll("IN", "IN")); - param.setFormula(param.getFormula().replaceAll("like", "like")); - param.setFormula(param.getFormula().replaceAll("LIKE", "like")); - param.setFormula(param.getFormula().replaceAll("exists", "exists")); - param.setFormula(param.getFormula().replaceAll("EXISTS", "EXISTS")); - param.setFormula(param.getFormula().replaceAll("between", "between")); - param.setFormula(param.getFormula().replaceAll("BETWEEN", "BETWEEN")); - param.setFormula(param.getFormula().replaceAll("union", "union")); - param.setFormula(param.getFormula().replaceAll("UNION", "UNION")); + ValidUtil.modify(param); // 解析公式中的参数 if (ReferenceTypeEnum.parseByValue(param.getReferenceType()) == ReferenceTypeEnum.FORMULA) { diff --git a/src/com/engine/salary/util/valid/Modify.java b/src/com/engine/salary/util/valid/Modify.java new file mode 100644 index 000000000..bf61ec974 --- /dev/null +++ b/src/com/engine/salary/util/valid/Modify.java @@ -0,0 +1,15 @@ +package com.engine.salary.util.valid; + +import java.lang.annotation.*; + +/** + * 数据参数合法性注解 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface Modify { + ModifyTypeEnum[] modifyType() default ModifyTypeEnum.TRIM; + + ValueTypeEnum valueType() default ValueTypeEnum.STRING; +} \ No newline at end of file diff --git a/src/com/engine/salary/util/valid/ModifyTypeEnum.java b/src/com/engine/salary/util/valid/ModifyTypeEnum.java new file mode 100644 index 000000000..e40ea143d --- /dev/null +++ b/src/com/engine/salary/util/valid/ModifyTypeEnum.java @@ -0,0 +1,13 @@ +package com.engine.salary.util.valid; + +/** + * 修改参数值 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum ModifyTypeEnum { + TRIM, RESTORE_SQL +} diff --git a/src/com/engine/salary/util/valid/ValidUtil.java b/src/com/engine/salary/util/valid/ValidUtil.java index 6b1964c45..8c0d0932d 100644 --- a/src/com/engine/salary/util/valid/ValidUtil.java +++ b/src/com/engine/salary/util/valid/ValidUtil.java @@ -139,6 +139,21 @@ public class ValidUtil { return value; } + private static void setValue(T t, String fieldName, Object value) { + try { + BeanInfo beanInfo = Introspector.getBeanInfo(t.getClass()); + PropertyDescriptor[] props = beanInfo.getPropertyDescriptors(); + for (PropertyDescriptor property : props) { + if (fieldName.equals(property.getName())) { + Method method = property.getWriteMethod(); + method.invoke(t, value); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + private static boolean notNull(Object value) { if (null == value) { return false; @@ -184,4 +199,57 @@ public class ValidUtil { return convertSuccess; } + public static void modify(T t) { + Class clazz = t.getClass(); + Field[] fields = clazz.getDeclaredFields(); + for (Field field : fields) { + Modify rule = field.getDeclaredAnnotation(Modify.class); + + if (null == rule) { + continue; + } + + ModifyTypeEnum[] modifyTypeEnums = rule.modifyType(); + ValueTypeEnum valueTypeEnum = rule.valueType(); + for (int i = 0; i < modifyTypeEnums.length; i++) { + Object value = getValue(t, field.getName()); + if (valueTypeEnum == ValueTypeEnum.STRING) { + String result = value.toString(); + + if (modifyTypeEnums[i] == ModifyTypeEnum.TRIM) { + result = result.trim(); + } + + if (modifyTypeEnums[i] == ModifyTypeEnum.RESTORE_SQL) { + result = result.replace("select", "select") + .replace("SELECT", "SELECT") + .replace("join", "join") + .replace("JOIN", "JOIN") + .replace("and", "and") + .replace("AND", "AND") + .replace("or", "or") + .replace("OR", "OR") + .replace("in", "in") + .replace("IN", "IN") + .replace("like", "like") + .replace("LIKE", "like") + .replace("exists", "exists") + .replace("EXISTS", "EXISTS") + .replace("between", "between") + .replace("BETWEEN", "BETWEEN") + .replace("union", "union") + .replace("UNION", "UNION"); + } + setValue(t, field.getName(), result); + } else if (valueTypeEnum == ValueTypeEnum.OBJECT) { + modify(value); + } else if (valueTypeEnum == ValueTypeEnum.ARRAY) { + Collection list = (Collection) value; + list.forEach(l -> modify(l)); + } + } + } + } + + } diff --git a/src/com/engine/salary/util/valid/ValueTypeEnum.java b/src/com/engine/salary/util/valid/ValueTypeEnum.java new file mode 100644 index 000000000..f2227d689 --- /dev/null +++ b/src/com/engine/salary/util/valid/ValueTypeEnum.java @@ -0,0 +1,13 @@ +package com.engine.salary.util.valid; + +/** + * 值类型 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum ValueTypeEnum { + STRING, OBJECT,ARRAY +}