Merge remote-tracking branch 'origin/release/3.0.0.2311.01' into release/3.0.0.2311.01

This commit is contained in:
Harryxzy 2023-11-09 16:19:35 +08:00
commit c88db43e55
54 changed files with 1877 additions and 122 deletions

View File

@ -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;
/

View File

@ -0,0 +1,3 @@
alter table hrsa_salary_stats_report add time_type int;
/

View File

@ -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;
/

View File

@ -0,0 +1,3 @@
alter table hrsa_salary_stats_report add time_type int;
/

View File

@ -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;
/

View File

@ -0,0 +1,3 @@
alter table hrsa_salary_stats_report add time_type int;
/

View File

@ -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) ;

View File

@ -0,0 +1,2 @@
alter table hrsa_salary_stats_report add time_type int
;

View File

@ -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
/

View File

@ -0,0 +1,2 @@
alter table hrsa_salary_stats_report add time_type int
/

View File

@ -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 ;

View File

@ -0,0 +1,2 @@
alter table hrsa_salary_stats_report add time_type int;
/

View File

@ -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

View File

@ -0,0 +1,2 @@
alter table hrsa_salary_stats_report add time_type int
GO

View File

@ -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;
/

View File

@ -0,0 +1,3 @@
alter table hrsa_salary_stats_report add time_type int;
/

View File

@ -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加密

View File

@ -6,6 +6,8 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Map;
/**
* 员工基本信息
* <p>Copyright: Copyright (c) 2022</p>
@ -108,5 +110,10 @@ public class DataCollectionEmployee {
//是否外部人员
private boolean extEmp;
/**
* 扩展数据
*/
private Map<String,String> extendData;
}

View File

@ -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;
/**
* 人员扩展参数
* <p>Copyright: Copyright (c) 2023</p>
* <p>Company: 泛微软件</p>
*
* @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<FieldSetting> fieldSettings;
}

View File

@ -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;
}

View File

@ -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<Long> ids;
}

View File

@ -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;

View File

@ -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<ExpandFieldSettingsPO> listAll();
/**
* 条件查询
*
* @return 返回集合没有返回空List
*/
List<ExpandFieldSettingsPO> 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<Long> ids);
ExpandFieldSettingsPO getByModule(String module);
}

View File

@ -0,0 +1,259 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.engine.salary.mapper.hrm.ExpandFieldSettingsMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.hrm.po.ExpandFieldSettingsPO">
<result column="id" property="id"/>
<result column="module" property="module"/>
<result column="module_info" property="moduleInfo"/>
<result column="pk" property="pk"/>
<result column="expand_sql" property="expandSql"/>
<result column="field_setting" property="fieldSetting"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="creator" property="creator"/>
<result column="delete_type" property="deleteType"/>
<result column="tenant_key" property="tenantKey"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
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
</sql>
<!-- 查询全部 -->
<select id="listAll" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_expand_field_settings t
WHERE delete_type = 0
</select>
<!-- 根据主键获取单条记录 -->
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
SELECT
<include refid="baseColumns"/>
FROM hrsa_expand_field_settings t
WHERE id = #{id} AND delete_type = 0
</select>
<!-- 条件查询 -->
<select id="listSome" resultMap="BaseResultMap"
parameterType="com.engine.salary.entity.hrm.po.ExpandFieldSettingsPO">
SELECT
<include refid="baseColumns"/>
FROM hrsa_expand_field_settings t
WHERE delete_type = 0
<if test="module != null">
AND module = #{module}
</if>
<if test="moduleInfo != null">
AND module_info = #{moduleInfo}
</if>
<if test="pk != null">
AND pk = #{pk}
</if>
<if test="expandSql != null">
AND expand_sql = #{expandSql}
</if>
<if test="fieldSetting != null">
AND field_setting = #{fieldSetting}
</if>
<if test="createTime != null">
AND create_time = #{createTime}
</if>
<if test="updateTime != null">
AND update_time = #{updateTime}
</if>
<if test="creator != null">
AND creator = #{creator}
</if>
<if test="deleteType != null">
AND delete_type = #{deleteType}
</if>
<if test="tenantKey != null">
AND tenant_key = #{tenantKey}
</if>
<if test="ids != null and ids.size()>0">
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
ORDER BY id DESC
</select>
<!-- 插入不为NULL的字段 -->
<insert id="insertIgnoreNull" parameterType="com.engine.salary.entity.hrm.po.ExpandFieldSettingsPO">
INSERT INTO hrsa_expand_field_settings
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="module != null">
module,
</if>
<if test="moduleInfo != null">
module_info,
</if>
<if test="pk != null">
pk,
</if>
<if test="expandSql != null">
expand_sql,
</if>
<if test="fieldSetting != null">
field_setting,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="creator != null">
creator,
</if>
<if test="deleteType != null">
delete_type,
</if>
<if test="tenantKey != null">
tenant_key,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id},
</if>
<if test="module != null">
#{module},
</if>
<if test="moduleInfo != null">
#{moduleInfo},
</if>
<if test="pk != null">
#{pk},
</if>
<if test="expandSql != null">
#{expandSql},
</if>
<if test="fieldSetting != null">
#{fieldSetting},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="creator != null">
#{creator},
</if>
<if test="deleteType != null">
#{deleteType},
</if>
<if test="tenantKey != null">
#{tenantKey},
</if>
</trim>
</insert>
<!-- 更新,更新全部字段 -->
<update id="update" parameterType="com.engine.salary.entity.hrm.po.ExpandFieldSettingsPO">
UPDATE hrsa_expand_field_settings
<set>
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},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 更新不为NULL的字段 -->
<update id="updateIgnoreNull" parameterType="com.engine.salary.entity.hrm.po.ExpandFieldSettingsPO">
UPDATE hrsa_expand_field_settings
<set>
<if test="module != null">
module=#{module},
</if>
<if test="moduleInfo != null">
module_info=#{moduleInfo},
</if>
<if test="pk != null">
pk=#{pk},
</if>
<if test="expandSql != null">
expand_sql=#{expandSql},
</if>
<if test="fieldSetting != null">
field_setting=#{fieldSetting},
</if>
<if test="createTime != null">
create_time=#{createTime},
</if>
<if test="updateTime != null">
update_time=#{updateTime},
</if>
<if test="creator != null">
creator=#{creator},
</if>
<if test="deleteType != null">
delete_type=#{deleteType},
</if>
<if test="tenantKey != null">
tenant_key=#{tenantKey},
</if>
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 根据主键删除记录 -->
<delete id="delete">
UPDATE hrsa_expand_field_settings
SET delete_type=1
WHERE id = #{id}
AND delete_type = 0
</delete>
<delete id="deleteByIds">
UPDATE hrsa_expand_field_settings
SET delete_type = 1
WHERE delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 根据主键获取单条记录 -->
<select id="getByModule" resultMap="BaseResultMap" >
SELECT
<include refid="baseColumns"/>
FROM hrsa_expand_field_settings t
WHERE module = #{module} AND delete_type = 0
</select>
</mapper>

View File

@ -19,6 +19,10 @@
<result column="tenant_key" property="tenantKey"/>
<result column="unit_type" property="unitType"/>
<result column="update_time" property="updateTime"/>
<result column="last_rule" property="lastRule"/>
<result column="old_rule" property="oldRule"/>
<result column="frequent_rule" property="frequentRule"/>
<result column="tile_rule" property="tileRule"/>
</resultMap>
<!-- 表字段 -->
@ -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
</sql>
<!-- 查询全部 -->
@ -184,6 +192,18 @@
<if test="updateTime != null">
update_time,
</if>
<if test="lastRule != null">
last_rule,
</if>
<if test="oldRule != null">
old_rule,
</if>
<if test="frequentRule != null">
frequent_rule,
</if>
<if test="tileRule != null">
tile_rule,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="avgRule != null">
@ -237,6 +257,18 @@
<if test="updateTime != null">
#{updateTime},
</if>
<if test="lastRule != null">
#{lastRule},
</if>
<if test="oldRule != null">
#{oldRule},
</if>
<if test="frequentRule != null">
#{frequentRule},
</if>
<if test="tileRule != null">
#{tileRule},
</if>
</trim>
</insert>
@ -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},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
@ -317,6 +353,18 @@
<if test="updateTime != null">
update_time=#{updateTime},
</if>
<if test="lastRule != null">
last_rule=#{lastRule},
</if>
<if test="oldRule != null">
old_rule=#{oldRule},
</if>
<if test="frequentRule != null">
frequent_rule=#{frequentRule},
</if>
<if test="tileRule != null">
tile_rule=#{tileRule},
</if>
</set>
WHERE id = #{id} AND delete_type = 0
</update>

View File

@ -16,6 +16,7 @@
<result column="position_setting" property="positionSetting"/>
<result column="remark" property="remark"/>
<result column="report_name" property="reportName"/>
<result column="time_type" property="timeType"/>
<result column="salary_end_month" property="salaryEndMonth"/>
<result column="salary_start_month" property="salaryStartMonth"/>
<result column="second_dimension" property="secondDimension"/>
@ -56,6 +57,7 @@
, t.tax_agent_setting
, t.tenant_key
, t.update_time
, t.time_type
</sql>
<!-- 查询全部 -->
@ -123,6 +125,9 @@
<if test="reportName != null">
AND report_name = #{reportName}
</if>
<if test="timeType != null">
AND time_type = #{timeType}
</if>
<if test="salaryEndMonth != null">
AND salary_end_month = #{salaryEndMonth}
</if>
@ -210,6 +215,9 @@
<if test="reportName != null">
report_name,
</if>
<if test="timeType != null">
time_type,
</if>
<if test="salaryEndMonth != null">
salary_end_month,
</if>
@ -284,6 +292,9 @@
<if test="reportName != null">
#{reportName},
</if>
<if test="timeType != null">
#{timeType},
</if>
<if test="salaryEndMonth != null">
#{salaryEndMonth},
</if>
@ -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 @@
<if test="reportName != null">
report_name=#{reportName},
</if>
<if test="timeType != null">
time_type=#{timeType},
</if>
<if test="salaryEndMonth != null">
salary_end_month=#{salaryEndMonth},
</if>

View File

@ -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<Map>) 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<Map>) JSON.parseArray(po.getTaxAgentSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList()));
}
// param.setIncomeCategory(((List<Map>) JSON.parseArray(po.getIncomeCategorySetting(), Map.class)).stream().map(m -> Integer.valueOf(m.get(key).toString())).collect(Collectors.toList()));
param.setSubCompany(((List<Map>) JSON.parseArray(po.getSubCompanySetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList()));
param.setDepart(((List<Map>) 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<Map>) 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<Map>) JSON.parseArray(po.getDepartSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList()));
}
// param.setGrade(((List<Map>) JSON.parseArray(po.getGradeSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList()));
// param.setPosition(((List<Map>) JSON.parseArray(po.getPositionSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList()));
// param.setStatus(((List<Map>) JSON.parseArray(po.getStatusSetting(), Map.class)).stream().map(m -> m.get(key).toString()).collect(Collectors.toList()));
param.setEmployee(((List<Map>) 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<Map>) 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<String, String> result, SalaryStatisticsItemPO item, List<Map<String, String>> nowDetail, List<Map<String, String>> lastDetail, List<Map<String, String>> sameDetail) {
SalaryStatisticsItemRuleDTO lastRule = JSON.parseObject(item.getLastRule(), SalaryStatisticsItemRuleDTO.class);
if (lastRule == null || lastRule.getTotalValue() != 1) {
return;
}
String lastValue = "";
// 本期
if (lastRule.getTotalValue() == 1) {
List<String> decimalList = Lists.newArrayList();
if (StringUtils.isNotEmpty(item.getItemValue())) {
String[] itemValues = item.getItemValue().split(COMMA);
for (String itemId : itemValues) {
for (Map<String, String> 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<String, String> result, SalaryStatisticsItemPO item, List<Map<String, String>> nowDetail, List<Map<String, String>> lastDetail, List<Map<String, String>> sameDetail) {
SalaryStatisticsItemRuleDTO oldRule = JSON.parseObject(item.getOldRule(), SalaryStatisticsItemRuleDTO.class);
if (oldRule == null || oldRule.getTotalValue() != 1) {
return;
}
String value = "";
// 本期
if (oldRule.getTotalValue() == 1) {
List<String> decimalList = Lists.newArrayList();
if (StringUtils.isNotEmpty(item.getItemValue())) {
String[] itemValues = item.getItemValue().split(COMMA);
for (String itemId : itemValues) {
for (Map<String, String> 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<String, String> result, SalaryStatisticsItemPO item, List<Map<String, String>> nowDetail, List<Map<String, String>> lastDetail, List<Map<String, String>> sameDetail) {
SalaryStatisticsItemRuleDTO frequentRule = JSON.parseObject(item.getOldRule(), SalaryStatisticsItemRuleDTO.class);
if (frequentRule == null || frequentRule.getTotalValue() != 1) {
return;
}
String value = "";
// 本期
if (frequentRule.getTotalValue() == 1) {
List<String> decimalList = Lists.newArrayList();
if (StringUtils.isNotEmpty(item.getItemValue())) {
String[] itemValues = item.getItemValue().split(COMMA);
for (String itemId : itemValues) {
for (Map<String, String> 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<String, String> result, SalaryStatisticsItemPO item, List<Map<String, String>> nowDetail, List<Map<String, String>> lastDetail, List<Map<String, String>> sameDetail) {
SalaryStatisticsItemRuleDTO tileRule = JSON.parseObject(item.getOldRule(), SalaryStatisticsItemRuleDTO.class);
if (tileRule == null || tileRule.getTotalValue() != 1) {
return;
}
String value = "";
// 本期
if (tileRule.getTotalValue() == 1) {
List<String> decimalList = Lists.newArrayList();
if (StringUtils.isNotEmpty(item.getItemValue())) {
String[] itemValues = item.getItemValue().split(COMMA);
for (String itemId : itemValues) {
for (Map<String, String> 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<String, String> 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<String> list) {
if (CollectionUtils.isEmpty(list)) {
return "";
}
return list.get(0);
}
/**
* 最旧的值
*
* @param list
* @return
*/
public static String old(List<String> list) {
if (CollectionUtils.isEmpty(list)) {
return "";
}
return list.get(list.size() - 1);
}
/**
* 最频繁
*
* @param list
* @return
*/
public static String frequent(List<String> 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<String> list) {
if (CollectionUtils.isEmpty(list)) {
return "";
}
return Joiner.on(",").join((Iterable<?>) list);
}
public static List<Map<String, String>> po2map(List<SalaryAcctEmployeePO> list, Map<Long, Map<String, String>> 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<FieldSetting> 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<Long, SalaryStatisticsItemPO> itemMap = salaryStatisticsItemList.stream().collect(Collectors.toMap(SalaryStatisticsItemPO::getId, Function.identity()));
Map<Long, String> 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);
});

View File

@ -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;
}

View File

@ -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;
}

View File

@ -0,0 +1,26 @@
package com.engine.salary.report.entity.param;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 薪酬统计报表自定义统计项目保存参数
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SalaryStatisticsItemGetFormParam {
//统计项目id
private Long id;
//统计项目
private Long itemId;
}

View File

@ -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<String> 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;
}

View File

@ -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;

View File

@ -126,11 +126,47 @@ public class SalaryStatisticsItemPO implements Serializable {
//中位数规则")
private String medianRule;
/**
* 最近值
* <p>
* "totalValue":"1", 是否使用
*/
private String lastRule;
/**
* 最早值
* <p>
* {
* "totalValue":"1", 是否使用
* }
*/
private String oldRule;
/**
* 出现最多
* <p>
* {
* "totalValue":"1", 是否使用
* }
*/
private String frequentRule;
/**
* 平铺
* <p>
* {
* "totalValue":"1", 是否使用
* }
*/
private String tileRule;
//顺序")
private Integer indexValue;
/**
* 统计单位
*
* @see UnitTypeEnum
*/
//统计单位")

View File

@ -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;

View File

@ -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<String> {
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;
}
}

View File

@ -3,6 +3,7 @@ package com.engine.salary.report.enums;
import com.engine.salary.enums.BaseEnum;
public enum UnitTypeEnum implements BaseEnum<Integer> {
empty(0, 152745, ""),
REN(1, 157087, ""),
YUAN(2, 152739, ""),
QIAN(3, 157088, ""),

View File

@ -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<SalaryStatisticsDimensionPO> listAllDefaultDimension();
}

View File

@ -70,6 +70,13 @@ public interface SalaryStatisticsReportService {
*/
Map<String, Object> delete(Collection<Long> ids );
/**
* 复制
* @param id
*/
void duplicate(Long id);
/**
* 保存统计范围
*
@ -106,5 +113,4 @@ public interface SalaryStatisticsReportService {
*/
void removeReportCache();
}

View File

@ -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<String, Object> delete(Collection<Long> ids) {
if (CollectionUtils.isEmpty(ids)) {

View File

@ -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);

View File

@ -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<SalaryStatisticsItemPO> itemPOS = getSalaryStatisticsItemService(user).listByStatisticsReportId(id);
List<SalaryStatisticsItemPO> 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<Map<String, Object>> buildReportRecords(SalaryStatisticsDimensionPO dimension, SalaryStatisticsReportDataQueryParam param, List<SalaryStatisticsItemPO> salaryStatisticsItemList) {
Map<String, Boolean> checkMap = SalaryStatisticsReportBO.checkLoad(salaryStatisticsItemList);
// 如果一个都没有直接返回
if (!checkMap.get("isNow")) {
return new PageInfo<Map<String, Object>>();
}
// if (!checkMap.get("isNow")) {
// return new PageInfo<Map<String, Object>>();
// }
// 获取本期报表分权后的核算人员
@ -392,8 +429,8 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary
Map<Long, Map<String, String>> resultMap = new HashMap<>();
List<Long> salaryAcctEmployeeIds = salaryAcctEmployeeList.stream().map(SalaryAcctEmployeePO::getId).collect(Collectors.toList());
if( NumberUtils.isCreatable(dimension.getDimCode()) ){
List<SalaryAcctResultPO> salaryAcctResultValues = getSalaryAcctResultService(user).listByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmployeeIds,Collections.singleton(Long.valueOf(dimension.getDimCode())));
if (NumberUtils.isCreatable(dimension.getDimCode())) {
List<SalaryAcctResultPO> salaryAcctResultValues = getSalaryAcctResultService(user).listByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmployeeIds, Collections.singleton(Long.valueOf(dimension.getDimCode())));
List<Long> finalSalaryAcctEmpIds = getSalaryAcctResultService(user).listAcctEmpIdByAcctEmpId(salaryAcctEmployeeIds);
Map<Long, List<SalaryAcctResultPO>> 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<String, Object> 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<Long, List<SalaryAcctEmployeePO>> employeeListMap = accountDetailPOList.stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getEmployeeId));
Map<Long, List<SalaryAcctEmployeePO>> lastEmployeeListMap = data.getLastList().stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getEmployeeId));
Map<Long, List<SalaryAcctEmployeePO>> sameEmployeeListMap = data.getSameList().stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getEmployeeId));
Map<Long, DataCollectionEmployee> employeeByIdMap = getSalaryEmployeeService(user).getEmployeeByIdsAll(accountDetailPOList.stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList())).stream().collect(Collectors.toMap(DataCollectionEmployee::getEmployeeId, o -> o));
List<Long> empIds = accountDetailPOList.stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList());
Map<Long, DataCollectionEmployee> employeeByIdMap = getSalaryEmployeeService(user).getEmployeeByIdsAll(empIds)
.stream()
.collect(Collectors.toMap(DataCollectionEmployee::getEmployeeId, o -> o));
//人员维度扩展属性
EmployeeInfoExpandDTO employeeInfoExpandDTO = getSalaryStatisticsDimensionService(user).getExpandFieldSettings("dim_employee");
List<FieldSetting> fieldSettings = Optional.ofNullable(Optional.ofNullable(employeeInfoExpandDTO).orElse(new EmployeeInfoExpandDTO()).getFieldSettings()).orElse(new ArrayList<>());
Map<Long, Map<String, String>> expandEmployeeMap = getSalaryEmployeeService(user).expandEmployeeMap(empIds, employeeInfoExpandDTO);
log.info("扩展属性"+expandEmployeeMap);
// List<ExtEmployeePO> extEmployees = extEmployeeService.listByIdsWithDeleted(accountDetailPOList.stream().filter(e -> EmployeeTypeEnum.EXT_EMPLOYEE.getValue().equals(e.getEmployeeType())).map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()), data.getTenantKey());
// Map<Long, String> employeeExtByIdMap = SalaryEntityUtil.convert2Map(extEmployees, ExtEmployeePO::getId, ExtEmployeePO::getUsername);
@ -1025,8 +1073,11 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary
Map<String, Object> 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())) {

View File

@ -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<Long, SalaryStatisticsDimensionFormDTO>(user).run(getSalaryStatisticsDimensionWrapper(user)::getFrom, id);
}
@ -78,6 +79,33 @@ public class SalaryStatisticsDimensionController {
return new ResponseResult<SalaryStatisticsDimensionSaveParam, String>(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<EmployeeInfoExpandDTO, String>(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<String, EmployeeInfoExpandDTO>(user).run(getSalaryStatisticsDimensionWrapper(user)::getExpandFieldSettings, module);
}
/**
* 删除薪酬统计维度
*

View File

@ -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<Long, SalaryStatisticsItemFormDTO>(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<Long, SalaryStatisticsItemFormDTO>(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<Long, List<Map<String, Object>>>(user).run(getSalaryStatisticsItemWrapper(user)::list, statisticsReportId);
}

View File

@ -95,6 +95,20 @@ public class SalaryStatisticsReportController {
return new ResponseResult<Collection<Long>, Map<String, Object>>(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<Long, String>(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 {

View File

@ -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<SalaryStatisticsDimensionListDTO> list(SalaryStatisticsDimensionQueryParam queryParam) {
PageInfo<SalaryStatisticsDimensionPO> page = salaryStatisticsDimensionService(user).listPage(queryParam);
List<SalaryStatisticsDimensionPO> list = page.getList();
List<SalaryStatisticsDimensionListDTO> dtoList= new ArrayList<>();
List<SalaryStatisticsDimensionListDTO> dtoList = new ArrayList<>();
// 获取默认维度统计
List<SalaryStatisticsDimensionPO> 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<SalaryStatisticsDimensionListDTO> salaryStatisticsDimensionListDTOPageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize());
PageInfo<SalaryStatisticsDimensionListDTO> 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());
}
}

View File

@ -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<String, Object> weaForm = new HashMap<>();
Map<String, Object> 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<SalaryItemPO> salaryItems = getSalaryItemService(user).listAll();
Map<String, String> itemsMap = SalaryEntityUtil.convert2Map(salaryItems, k -> k.getId().toString(), SalaryItemPO::getName);
Map<String, SalaryItemPO> itemsMap = SalaryEntityUtil.convert2Map(salaryItems, k -> k.getId().toString());
List<Map<String, String>> welfareItems = new ArrayList<>();
Arrays.stream(itemValue.split(",")).forEach(value -> {
Map<String, String> 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<String, Object> 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<String, Object> ruleData = buildRule(SalaryDataTypeEnum.parseByValue(po.getDataType()), null);
return SalaryStatisticsItemFormDTO.builder().ruleData(ruleData).build();
}
public Map<String, Object> buildRule(SalaryDataTypeEnum dataType, SalaryStatisticsItemPO salaryStatisticsItem) {
Map<String, Object> weaTable;
if (dataType == null || dataType == SalaryDataTypeEnum.NUMBER) {
weaTable = buildNumberRule(salaryStatisticsItem);
} else {
weaTable = buildStringRule(salaryStatisticsItem);
}
return weaTable;
}
/**
* 字符取值规则
*
* @param salaryStatisticsItem 统计项
* @return
*/
private Map<String, Object> buildStringRule(SalaryStatisticsItemPO salaryStatisticsItem) {
Map<String, Object> weaTable = new HashMap<>();
List<WeaTableColumn> list = new ArrayList<>();
WeaTableColumn ruleName = new WeaTableColumn("20%", SalaryI18nUtil.getI18nLabel(157532, "字符取值规则"), "ruleName");
list.add(ruleName);
weaTable.put("columns", list);
List<Map<String, Object>> result = new ArrayList<>();
if (salaryStatisticsItem == null) {
for (SalaryStatisticsItemStringRuleEnum ruleEnum : SalaryStatisticsItemStringRuleEnum.values()) {
Map<String, Object> 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<String, Object> 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<String, Object> buildNumberRule(SalaryStatisticsItemPO salaryStatisticsItem) {
Map<String, Object> weaTable = new HashMap<>();
List<WeaTableColumn> list = new ArrayList<>();
WeaTableColumn ruleName = new WeaTableColumn("20%", SalaryI18nUtil.getI18nLabel(157532, "统计规则"), "ruleName");
@ -126,22 +209,22 @@ public class SalaryStatisticsItemWrapper extends Service {
Map<String, Object> rule = new HashMap<>();
switch (ruleList.get(i)) {
case "count":
rule = JSON.parseObject(salaryStatisticsItem.getCountRule(), new HashMap<String, String>().getClass());
rule = JSON.parseObject(salaryStatisticsItem.getCountRule(), HashMap.class);
break;
case "sum":
rule = JSON.parseObject(salaryStatisticsItem.getSumRule(), new HashMap<String, String>().getClass());
rule = JSON.parseObject(salaryStatisticsItem.getSumRule(), HashMap.class);
break;
case "avg":
rule = JSON.parseObject(salaryStatisticsItem.getAvgRule(), new HashMap<String, String>().getClass());
rule = JSON.parseObject(salaryStatisticsItem.getAvgRule(), HashMap.class);
break;
case "max":
rule = JSON.parseObject(salaryStatisticsItem.getMaxRule(), new HashMap<String, String>().getClass());
rule = JSON.parseObject(salaryStatisticsItem.getMaxRule(), HashMap.class);
break;
case "min":
rule = JSON.parseObject(salaryStatisticsItem.getMinRule(), new HashMap<String, String>().getClass());
rule = JSON.parseObject(salaryStatisticsItem.getMinRule(), HashMap.class);
break;
case "median":
rule = JSON.parseObject(salaryStatisticsItem.getMedianRule(), new HashMap<String, String>().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);
}
}

View File

@ -130,7 +130,9 @@ public class SalaryStatisticsReportWrapper extends Service {
Map<String, Object> 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<String> 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<String, Object> 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) {

View File

@ -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<Long, String> getResignationMapByDate(String formatDate);
/**
* 扩展人员信息
* @param ids
* @param param
* @return
*/
List<DataCollectionEmployee> expandEmployeeInfo(List<Long> ids, EmployeeInfoExpandDTO param);
Map<Long,Map<String,String>> expandEmployeeMap(List<Long> ids, EmployeeInfoExpandDTO param);
/**
* 保存扩展信息
* @param param
*/
void saveEmployeeExpandFieldSettings(EmployeeInfoExpandDTO param);
/**
* 获取扩展信息
* @param module
* @return
*/
EmployeeInfoExpandDTO getExpandFieldSettings(String module);
}

View File

@ -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<DataCollectionEmployee> employeeList = employBiz.listByDismissDate(dismissDate);
return SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getDismissdate);
}
@Override
public List<DataCollectionEmployee> expandEmployeeInfo(List<Long> ids, EmployeeInfoExpandDTO param) {
List<DataCollectionEmployee> 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<String, String> 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<Long, Map<String, String>> expandEmployeeMap(List<Long> ids, EmployeeInfoExpandDTO param) {
if (CollectionUtils.isNotEmpty(ids) && param != null) {
Map<Long, Map<String, String>> map = new HashMap<>();
List<List<Long>> partition = Lists.partition(ids, 5);
for (int i = 0; i < partition.size(); i++) {
List<Long> 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<String, String> 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<FieldSetting> 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;
}
}

View File

@ -119,24 +119,7 @@ public class SalaryFormulaServiceImpl extends Service implements SalaryFormulaSe
}
//将select因XSS过滤造成的异常字符转换回来
param.setFormula(param.getFormula().replaceAll("", "select"));
param.setFormula(param.getFormula().replaceAll("", "SELECT"));
param.setFormula(param.getFormula().replaceAll("", "join"));
param.setFormula(param.getFormula().replaceAll("", "JOIN"));
param.setFormula(param.getFormula().replaceAll("", "and"));
param.setFormula(param.getFormula().replaceAll("", "AND"));
param.setFormula(param.getFormula().replaceAll("", "or"));
param.setFormula(param.getFormula().replaceAll("", "OR"));
param.setFormula(param.getFormula().replaceAll("", "in"));
param.setFormula(param.getFormula().replaceAll("", "IN"));
param.setFormula(param.getFormula().replaceAll("", "like"));
param.setFormula(param.getFormula().replaceAll("", "like"));
param.setFormula(param.getFormula().replaceAll("", "exists"));
param.setFormula(param.getFormula().replaceAll("", "EXISTS"));
param.setFormula(param.getFormula().replaceAll("", "between"));
param.setFormula(param.getFormula().replaceAll("", "BETWEEN"));
param.setFormula(param.getFormula().replaceAll("", "union"));
param.setFormula(param.getFormula().replaceAll("", "UNION"));
ValidUtil.modify(param);
// 解析公式中的参数
if (ReferenceTypeEnum.parseByValue(param.getReferenceType()) == ReferenceTypeEnum.FORMULA) {

View File

@ -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;
}

View File

@ -0,0 +1,13 @@
package com.engine.salary.util.valid;
/**
* 修改参数值
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public enum ModifyTypeEnum {
TRIM, RESTORE_SQL
}

View File

@ -139,6 +139,21 @@ public class ValidUtil {
return value;
}
private static <T> 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 <T> 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")
.replace("", "SELECT")
.replace("", "join")
.replace("", "JOIN")
.replace("", "and")
.replace("", "AND")
.replace("", "or")
.replace("", "OR")
.replace("", "in")
.replace("", "IN")
.replace("", "like")
.replace("", "like")
.replace("", "exists")
.replace("", "EXISTS")
.replace("", "between")
.replace("", "BETWEEN")
.replace("", "union")
.replace("", "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));
}
}
}
}
}

View File

@ -0,0 +1,13 @@
package com.engine.salary.util.valid;
/**
* 值类型
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public enum ValueTypeEnum {
STRING, OBJECT,ARRAY
}