非系统人员档案自动化

This commit is contained in:
钱涛 2023-03-08 16:36:47 +08:00
parent a423790a35
commit 487dd9f972
22 changed files with 828 additions and 69 deletions

View File

@ -0,0 +1,6 @@
select max(id) FROM hrsa_salary_archive where tax_agent_id = 35 and delete_type = 0 GROUP BY employee_id HAVING COUNT(employee_id)>1;
update hrsa_salary_archive set delete_type =3 where tax_agent_id = 35 and delete_type = 0
and id in (select max(id) FROM hrsa_salary_archive where tax_agent_id = 35 and delete_type = 0 GROUP BY employee_id HAVING COUNT(employee_id)>1);

View File

@ -323,6 +323,7 @@ public class SalaryArchiveBO {
.id(IdGenerator.generate())
.employeeId(change.getEmployeeId())
.taxAgentId(change.getTaxAgentId())
.employeeType(change.getEmployeeType())
.runStatus(SalaryArchiveStatusEnum.PENDING.getValue())
// .incomeCategory(IncomeCategoryEnum.WAGES_AND_SALARIES.getValue())
// .modifier(0L)

View File

@ -1,5 +1,6 @@
package com.engine.salary.entity.salaryarchive.po;
import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum;
import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum;
import com.engine.salary.enums.salaryarchive.SalaryArchiveAddTypeEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
@ -57,6 +58,14 @@ public class SalaryArchivePO {
*/
private String runStatus;
/**
* 人员类型,0或null组织架构,1非系统人员
*
* @see DataCollectionEmployeeTypeEnum
*/
private Integer employeeType;
/**
* 定薪类型
*
@ -102,6 +111,7 @@ public class SalaryArchivePO {
private Long taxAgentId;
//---------条件-------
private Collection<Long> ids;
private Collection<Long> employeeIds;

View File

@ -0,0 +1,36 @@
package com.engine.salary.entity.taxagent.param;
import lombok.Data;
import java.util.List;
/**
* 外部人员管理范围保存参数
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Data
public class TaxAgentManageRangeExtSaveParam {
/**
* 对象id
*/
private List<Long> targetIds;
/**
* 对象类型1外部人员
*/
private Long targetType;
/**
* 个税扣缴义务人的id
*/
private Long taxAgentId;
//是否同步/异步执行生成档案
private boolean sync;
}

View File

@ -1,5 +1,6 @@
package com.engine.salary.entity.taxagent.po;
import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum;
import com.engine.salary.enums.taxagent.TaxAgentEmpChangeModuleEnum;
import com.engine.salary.enums.taxagent.TaxAgentEmpChangeTypeEnum;
import lombok.AllArgsConstructor;
@ -59,6 +60,13 @@ public class TaxAgentEmpChangePO {
*/
private Integer moduleType;
/**
* 人员类型,0或null组织架构,1非系统人员
*
* @see DataCollectionEmployeeTypeEnum
*/
private Integer employeeType;
/**
* 租户key
*/

View File

@ -1,5 +1,6 @@
package com.engine.salary.entity.taxagent.po;
import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -68,6 +69,13 @@ public class TaxAgentEmpPO {
*/
private Date updateTime;
/**
* 人员类型,0或null组织架构,1非系统人员
*
* @see DataCollectionEmployeeTypeEnum
*/
private Integer employeeType;
private Collection<Long> taxAgentIds;
private Collection<Long> ids;
}

View File

@ -0,0 +1,61 @@
package com.engine.salary.entity.taxagent.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 TaxAgentExtRangePO {
/**
* 主键id
*/
private Long id;
/**
* 对象id
*/
private Long targetId;
/**
* 对象类型1外部人员
*/
private Integer targetType;
/**
* 个税扣缴义务人的id
*/
private Long taxAgentId;
/**
* 租户ID
*/
private String tenantKey;
/**
* 更新时间
*/
private Date updateTime;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private Long creator;
/**
* 是否已删除0未删除1已删除
*/
private Integer deleteType;
//主键id集合
private Collection<Long> ids;
}

View File

@ -0,0 +1,53 @@
package com.engine.salary.enums.datacollection;
import com.engine.salary.enums.BaseEnum;
import java.util.Arrays;
import java.util.Optional;
/**
* 人员类型
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public enum DataCollectionEmployeeTypeEnum implements BaseEnum<Integer> {
ORGANIZATION(0, "组织架构", 109125),
EXT_EMPLOYEE(1, "非系统人员", 119127),
;
private int value;
private String defaultLabel;
private int labelId;
DataCollectionEmployeeTypeEnum(int value, String defaultLabel, int labelId) {
this.value = value;
this.defaultLabel = defaultLabel;
this.labelId = labelId;
}
@Override
public Integer getValue() {
return value;
}
@Override
public Integer getLabelId() {
return labelId;
}
@Override
public String getDefaultLabel() {
return defaultLabel;
}
public static String getNameByValue(String value) {
Optional<DataCollectionEmployeeTypeEnum> optional = Arrays.stream(DataCollectionEmployeeTypeEnum.values()).filter(r -> r.getValue().toString().equals(value)).findFirst();
return optional.isPresent() ? optional.get().name() : "";
}
}

View File

@ -13,6 +13,7 @@
<result column="pay_start_date" property="payStartDate"/>
<result column="pay_end_date" property="payEndDate"/>
<result column="run_status" property="runStatus"/>
<result column="employee_type" property="employeeType"/>
</resultMap>
<!-- 表字段 -->
@ -30,6 +31,7 @@
, t.pay_start_date
, t.pay_end_date
, t.run_status
, t.employee_type
</sql>
<!-- 查询全部 -->
@ -53,6 +55,7 @@
pay_start_date=#{payStartDate},
pay_end_date=#{payEndDate},
run_status=#{runStatus},
employee_type=#{employeeType},
</set>
WHERE id = #{id}
</update>
@ -88,6 +91,7 @@
, t.pay_start_date
, t.pay_end_date
, t.run_status
, t.employee_type
, e.mobile
, e.workcode
, e.lastname as username
@ -110,6 +114,7 @@
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
WHERE t.delete_type = 0
and t.employee_type is null
and e.status not in (7)
and (e.accounttype is null or e.accounttype = 0)
<if test="param.ids != null and param.ids.size()>0">
@ -185,6 +190,7 @@
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
WHERE t.delete_type = 0
and t.employee_type is null
and e.status not in (7)
and (e.accounttype is null or e.accounttype = 0)
<if test="param.ids != null and param.ids.size()>0">
@ -258,6 +264,7 @@
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
WHERE t.delete_type = 0
and t.employee_type is null
and e.status not in (7)
and (e.accounttype is null or e.accounttype = 0)
<if test="param.ids != null and param.ids.size()>0">
@ -331,7 +338,8 @@
tax_agent_id,
pay_start_date,
pay_end_date,
run_status
run_status,
employee_type
)
VALUES
<foreach collection="collection" item="item" separator=",">
@ -345,7 +353,8 @@
#{item.taxAgentId},
#{item.payStartDate},
#{item.payEndDate},
#{item.runStatus}
#{item.runStatus},
#{item.employeeType}
)
</foreach>
</insert>
@ -360,7 +369,8 @@
tax_agent_id,
pay_start_date,
pay_end_date,
run_status
run_status,
employee_type
)
<foreach collection="collection" item="item" separator="union all">
@ -374,7 +384,8 @@
#{item.taxAgentId,jdbcType=DOUBLE},
#{item.payStartDate,jdbcType=DATE},
#{item.payEndDate,jdbcType=DATE},
#{item.runStatus,jdbcType=VARCHAR}
#{item.runStatus,jdbcType=VARCHAR},
#{item.employeeType,jdbcType=INTEGER}
from dual
</foreach>
</insert>
@ -390,7 +401,8 @@
tax_agent_id,
pay_start_date,
pay_end_date,
run_status
run_status,
employee_type
)
VALUES
(
@ -403,7 +415,8 @@
#{item.taxAgentId},
#{item.payStartDate},
#{item.payEndDate},
#{item.runStatus}
#{item.runStatus},
#{item.employeeType}
)
</foreach>
</insert>

View File

@ -20,7 +20,7 @@ public interface ExternalEmployeeMapper {
* @param id 主键
* @return 返回记录没有返回null
*/
ExtEmpPO getById(Integer id);
ExtEmpPO getById(Long id);
List<ExtEmpPO> listSome(ExtEmpPO po);

View File

@ -13,6 +13,7 @@
<result column="tax_agent_id" property="taxAgentId"/>
<result column="tenant_key" property="tenantKey"/>
<result column="update_time" property="updateTime"/>
<result column="employee_type" property="employeeType"/>
</resultMap>
<!-- 表字段 -->
@ -30,6 +31,7 @@
, t.tax_agent_id
, t.tenant_key
, t.update_time
, t.employee_type
</sql>
<!-- 查询全部 -->
@ -89,6 +91,9 @@
<if test="updateTime != null">
AND update_time = #{updateTime}
</if>
<if test="employeeType != null">
AND employee_type = #{employeeType}
</if>
<if test="ids != null and ids.size()>0">
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
@ -137,6 +142,9 @@
<if test="updateTime != null">
update_time,
</if>
<if test="employeeType != null">
employee_type,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="changeType != null">
@ -172,6 +180,9 @@
<if test="updateTime != null">
#{updateTime},
</if>
<if test="employeeType != null">
#{employeeType},
</if>
</trim>
</insert>
@ -189,6 +200,7 @@
tax_agent_id=#{taxAgentId},
tenant_key=#{tenantKey},
update_time=#{updateTime},
employee_type=#{employeeType},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
@ -228,6 +240,9 @@
<if test="updateTime != null">
update_time=#{updateTime},
</if>
<if test="employeeType != null">
employee_type=#{employeeType},
</if>
</set>
WHERE id = #{id} AND delete_type = 0
</update>
@ -273,6 +288,7 @@
create_time,
update_time,
creator,
employee_type,
tenant_key
)
VALUES
@ -287,6 +303,7 @@
#{item.createTime},
#{item.updateTime},
#{item.creator},
#{item.employeeType},
#{item.tenantKey}
)
</foreach>
@ -302,6 +319,7 @@
create_time,
update_time,
creator,
employee_type,
tenant_key
)
@ -316,6 +334,7 @@
#{item.createTime,jdbcType=DATE},
#{item.updateTime,jdbcType=DATE},
#{item.creator,jdbcType=DOUBLE},
#{item.employeeType,jdbcType=INTEGER},
#{item.tenantKey,jdbcType=VARCHAR}
from dual
</foreach>
@ -332,6 +351,7 @@
create_time,
update_time,
creator,
employee_type,
tenant_key
)
VALUES
@ -345,6 +365,7 @@
#{item.createTime},
#{item.updateTime},
#{item.creator},
#{item.employeeType},
#{item.tenantKey}
)
</foreach>

View File

@ -11,11 +11,14 @@
<result column="tax_agent_id" property="taxAgentId"/>
<result column="tenant_key" property="tenantKey"/>
<result column="update_time" property="updateTime"/>
<result column="employee_type" property="employeeType"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t.create_time
t
.
create_time
, t.creator
, t.delete_type
, t.employee_id
@ -24,6 +27,7 @@
, t.tax_agent_id
, t.tenant_key
, t.update_time
, t.employee_type
</sql>
<!-- 查询全部 -->
@ -75,6 +79,9 @@
<if test="updateTime != null">
AND update_time = #{updateTime}
</if>
<if test="employeeType != null">
AND employee_type = #{employeeType}
</if>
<if test="taxAgentIds != null and taxAgentIds.size()>0">
AND tax_agent_id IN
<foreach collection="taxAgentIds" open="(" item="taxAgentId" separator="," close=")">
@ -123,6 +130,9 @@
<if test="updateTime != null">
update_time,
</if>
<if test="employeeType != null">
employee_type,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="createTime != null">
@ -152,6 +162,9 @@
<if test="updateTime != null">
#{updateTime},
</if>
<if test="employeeType != null">
#{employeeType},
</if>
</trim>
</insert>
@ -167,6 +180,7 @@
tax_agent_id=#{taxAgentId},
tenant_key=#{tenantKey},
update_time=#{updateTime},
employee_type=#{employeeType},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
@ -200,6 +214,9 @@
<if test="updateTime != null">
update_time=#{updateTime},
</if>
<if test="employeeType != null">
employee_type=#{employeeType},
</if>
</set>
WHERE id = #{id} AND delete_type = 0
</update>
@ -209,7 +226,8 @@
<delete id="delete" parameterType="com.engine.salary.entity.taxagent.po.TaxAgentEmpPO">
UPDATE hrsa_tax_agent_emp
SET delete_type=1
WHERE id = #{id} AND delete_type = 0
WHERE id = #{id}
AND delete_type = 0
</delete>
<delete id="deleteByIds">
@ -231,6 +249,7 @@
create_time,
update_time,
creator,
employee_type,
tenant_key
)
VALUES
@ -243,6 +262,7 @@
#{item.createTime},
#{item.updateTime},
#{item.creator},
#{item.employeeType},
#{item.tenantKey}
)
</foreach>
@ -256,6 +276,7 @@
create_time,
update_time,
creator,
employee_type,
tenant_key
)
@ -268,6 +289,7 @@
#{item.createTime,jdbcType=DATE},
#{item.updateTime,jdbcType=DATE},
#{item.creator,jdbcType=DOUBLE},
#{item.employeeType,jdbcType=INTEGER},
#{item.tenantKey,jdbcType=VARCHAR}
from dual
</foreach>
@ -282,6 +304,7 @@
create_time,
update_time,
creator,
employee_type,
tenant_key
)
VALUES
@ -293,6 +316,7 @@
#{item.createTime},
#{item.updateTime},
#{item.creator},
#{item.employeeType},
#{item.tenantKey}
)
</foreach>

View File

@ -0,0 +1,64 @@
package com.engine.salary.mapper.taxagent;
import com.engine.salary.entity.taxagent.po.TaxAgentExtRangePO;
import java.util.List;
public interface TaxAgentExtRangeMapper {
/**
* 查询所有记录
*
* @return 返回集合没有返回空List
*/
List<TaxAgentExtRangePO> listAll();
/**
* 条件查询
*
* @return 返回集合没有返回空List
*/
List<TaxAgentExtRangePO> listSome(TaxAgentExtRangePO taxAgentExtRange);
/**
* 根据主键查询
*
* @param id 主键
* @return 返回记录没有返回null
*/
TaxAgentExtRangePO getById(Long id);
/**
* 新增忽略null字段
*
* @param taxAgentExtRange 新增的记录
* @return 返回影响行数
*/
int insertIgnoreNull(TaxAgentExtRangePO taxAgentExtRange);
/**
* 修改修改所有字段
*
* @param taxAgentExtRange 修改的记录
* @return 返回影响行数
*/
int update(TaxAgentExtRangePO taxAgentExtRange);
/**
* 修改忽略null字段
*
* @param taxAgentExtRange 修改的记录
* @return 返回影响行数
*/
int updateIgnoreNull(TaxAgentExtRangePO taxAgentExtRange);
/**
* 删除记录
*
* @param taxAgentExtRange 待删除的记录
* @return 返回影响行数
*/
int delete(TaxAgentExtRangePO taxAgentExtRange);
}

View File

@ -0,0 +1,214 @@
<?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.taxagent.TaxAgentExtRangeMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.taxagent.po.TaxAgentExtRangePO">
<result column="create_time" property="createTime"/>
<result column="creator" property="creator"/>
<result column="delete_type" property="deleteType"/>
<result column="id" property="id"/>
<result column="target_id" property="targetId"/>
<result column="target_type" property="targetType"/>
<result column="tax_agent_id" property="taxAgentId"/>
<result column="tenant_key" property="tenantKey"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t
.
create_time
, t.creator
, t.delete_type
, t.id
, t.target_id
, t.target_type
, t.tax_agent_id
, t.tenant_key
, t.update_time
</sql>
<!-- 查询全部 -->
<select id="listAll" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_agent_ext_range t
WHERE delete_type = 0
</select>
<!-- 根据主键获取单条记录 -->
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_agent_ext_range t
WHERE id = #{id} AND delete_type = 0
</select>
<!-- 条件查询 -->
<select id="listSome" resultMap="BaseResultMap"
parameterType="com.engine.salary.entity.taxagent.po.TaxAgentExtRangePO">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_agent_ext_range t
WHERE delete_type = 0
<if test="createTime != null">
AND create_time = #{createTime}
</if>
<if test="creator != null">
AND creator = #{creator}
</if>
<if test="deleteType != null">
AND delete_type = #{deleteType}
</if>
<if test="id != null">
AND id = #{id}
</if>
<if test="targetId != null">
AND target_id = #{targetId}
</if>
<if test="targetType != null">
AND target_type = #{targetType}
</if>
<if test="taxAgentId != null">
AND tax_agent_id = #{taxAgentId}
</if>
<if test="tenantKey != null">
AND tenant_key = #{tenantKey}
</if>
<if test="updateTime != null">
AND update_time = #{updateTime}
</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.taxagent.po.TaxAgentExtRangePO">
INSERT INTO hrsa_tax_agent_ext_range
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="createTime != null">
create_time,
</if>
<if test="creator != null">
creator,
</if>
<if test="deleteType != null">
delete_type,
</if>
<if test="id != null">
id,
</if>
<if test="targetId != null">
target_id,
</if>
<if test="targetType != null">
target_type,
</if>
<if test="taxAgentId != null">
tax_agent_id,
</if>
<if test="tenantKey != null">
tenant_key,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="createTime != null">
#{createTime},
</if>
<if test="creator != null">
#{creator},
</if>
<if test="deleteType != null">
#{deleteType},
</if>
<if test="id != null">
#{id},
</if>
<if test="targetId != null">
#{targetId},
</if>
<if test="targetType != null">
#{targetType},
</if>
<if test="taxAgentId != null">
#{taxAgentId},
</if>
<if test="tenantKey != null">
#{tenantKey},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
</trim>
</insert>
<!-- 更新,更新全部字段 -->
<update id="update" parameterType="com.engine.salary.entity.taxagent.po.TaxAgentExtRangePO">
UPDATE hrsa_tax_agent_ext_range
<set>
create_time=#{createTime},
creator=#{creator},
delete_type=#{deleteType},
target_id=#{targetId},
target_type=#{targetType},
tax_agent_id=#{taxAgentId},
tenant_key=#{tenantKey},
update_time=#{updateTime},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 更新不为NULL的字段 -->
<update id="updateIgnoreNull" parameterType="com.engine.salary.entity.taxagent.po.TaxAgentExtRangePO">
UPDATE hrsa_tax_agent_ext_range
<set>
<if test="createTime != null">
create_time=#{createTime},
</if>
<if test="creator != null">
creator=#{creator},
</if>
<if test="deleteType != null">
delete_type=#{deleteType},
</if>
<if test="targetId != null">
target_id=#{targetId},
</if>
<if test="targetType != null">
target_type=#{targetType},
</if>
<if test="taxAgentId != null">
tax_agent_id=#{taxAgentId},
</if>
<if test="tenantKey != null">
tenant_key=#{tenantKey},
</if>
<if test="updateTime != null">
update_time=#{updateTime},
</if>
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 根据主键删除记录 -->
<delete id="delete" parameterType="com.engine.salary.entity.taxagent.po.TaxAgentExtRangePO">
UPDATE hrsa_tax_agent_ext_range
SET delete_type=1
WHERE id = #{id}
AND delete_type = 0
</delete>
</mapper>

View File

@ -1,5 +1,6 @@
package com.engine.salary.service;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.extemp.param.ExtEmpQueryParam;
import com.engine.salary.entity.extemp.param.ExtEmpSaveParam;
import com.engine.salary.entity.extemp.po.ExtEmpPO;
@ -20,4 +21,13 @@ public interface ExtEmpService {
void delete(Collection<Long> ids);
DataCollectionEmployee getEmployeeById(Long id);
/**
* 获取人员信息
* @param ids
* @return
*/
List<DataCollectionEmployee> getEmployeeByIds(List<Long> ids);
}

View File

@ -38,4 +38,11 @@ public interface TaxAgentEmpService{
* @param currentEmployeeId
*/
void syncTaxAgentEmployee(List<TaxAgentEmpSaveParam> taxAgentEmpSaveParamList, Long currentEmployeeId);
/**
* 同步外部人员
* @param taxAgentEmpSaveParamList
* @param currentEmployeeId
*/
void syncTaxAgentExtEmployee(List<TaxAgentEmpSaveParam> taxAgentEmpSaveParamList, Long currentEmployeeId);
}

View File

@ -1,10 +1,7 @@
package com.engine.salary.service;
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeListDTO;
import com.engine.salary.entity.taxagent.param.TaxAgentImportParam;
import com.engine.salary.entity.taxagent.param.TaxAgentRangeQueryParam;
import com.engine.salary.entity.taxagent.param.TaxAgentRangeSaveParam;
import com.engine.salary.entity.taxagent.param.TaxAgentSubAdminRangeQueryParam;
import com.engine.salary.entity.taxagent.param.*;
import com.engine.salary.entity.taxagent.po.TaxAgentManageRangePO;
import com.engine.salary.util.page.PageInfo;
@ -55,6 +52,12 @@ public interface TaxAgentManageRangeService {
*/
void save(TaxAgentRangeSaveParam saveParam);
/**
* 保存外部人员范围
* @param saveParam
*/
void saveExtRange(TaxAgentManageRangeExtSaveParam saveParam);
/**
* 根据主键id删除管理范围

View File

@ -14,6 +14,7 @@ import dm.jdbc.util.IdGenerator;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
@ -82,10 +83,43 @@ public class ExtEmpServiceImpl extends Service implements ExtEmpService {
}
}
public List<DataCollectionEmployee> cover(List<ExtEmpPO> extEmps) {
@Override
public DataCollectionEmployee getEmployeeById(Long id) {
ExtEmpPO po = getExternalEmployeeMapper().getById(id);
return cover(po);
}
@Override
public List<DataCollectionEmployee> getEmployeeByIds(List<Long> ids) {
if (CollectionUtils.isEmpty(ids)) {
return new ArrayList<>();
}
List<ExtEmpPO> extEmpPOS = getExternalEmployeeMapper().listSome(ExtEmpPO.builder().ids(ids).build());
return coverList(extEmpPOS);
}
public DataCollectionEmployee cover(ExtEmpPO extPo) {
if (extPo == null) {
return null;
}
DataCollectionEmployee employee = new DataCollectionEmployee();
BeanUtils.copyProperties(extPo, employee);
employee.setEmployeeId(extPo.getId());
return employee;
}
public List<DataCollectionEmployee> coverList(List<ExtEmpPO> extEmps) {
if (CollectionUtils.isEmpty(extEmps)) {
return new ArrayList<>();
}
return extEmps.stream().map(emp -> {
DataCollectionEmployee employee = new DataCollectionEmployee();
BeanUtils.copyProperties(emp, employee);
employee.setEmployeeId(emp.getId());
return employee;
}).collect(Collectors.toList());
}

View File

@ -7,6 +7,7 @@ import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.taxagent.param.TaxAgentEmpSaveParam;
import com.engine.salary.entity.taxagent.po.TaxAgentEmpChangePO;
import com.engine.salary.entity.taxagent.po.TaxAgentEmpPO;
import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum;
import com.engine.salary.enums.taxagent.TaxAgentEmpChangeModuleEnum;
import com.engine.salary.enums.taxagent.TaxAgentEmpChangeTypeEnum;
import com.engine.salary.mapper.taxagent.TaxAgentEmpMapper;
@ -154,4 +155,100 @@ public class TaxAgentEmpServiceImpl extends Service implements TaxAgentEmpServic
getTaxAgentEmpChangeService(user).batchInsert(taxAgentEmpChangeList);
}
}
@Override
public void syncTaxAgentExtEmployee(List<TaxAgentEmpSaveParam> taxAgentEmpSaveParamList, Long currentEmployeeId) {
if (CollectionUtils.isEmpty(taxAgentEmpSaveParamList)) {
return;
}
List<Long> taxAgentIds = taxAgentEmpSaveParamList.stream().map(TaxAgentEmpSaveParam::getTaxAgentId).collect(Collectors.toList());
List<TaxAgentEmpPO> taxAgentEmployeeExistList = this.listByTaxAgentIds(taxAgentIds);
Date now = new Date();
// 关联表
List<TaxAgentEmpPO> taxAgentEmployeeAddList = Lists.newArrayList();
List<Long> taxAgentEmployeeDelIds = Lists.newArrayList();
// 增量表
List<TaxAgentEmpChangePO> taxAgentEmpChangeList = Lists.newArrayList();
taxAgentEmpSaveParamList.forEach(saveParam -> {
List<TaxAgentEmpPO> existList = taxAgentEmployeeExistList.stream().filter(f -> f.getTaxAgentId().equals(saveParam.getTaxAgentId())).collect(Collectors.toList());
Map<String, TaxAgentEmpPO> taxAgentEmployeeMap = SalaryEntityUtil.convert2Map(existList, e -> e.getTaxAgentId() + "-" + e.getEmployeeId());
for (DataCollectionEmployee se : saveParam.getSalaryEmployeeList()) {
String key = saveParam.getTaxAgentId() + "-" + se.getEmployeeId();
// 本地有的不动
if (taxAgentEmployeeMap.containsKey(key)) {
taxAgentEmployeeMap.remove(key);
continue;
}
taxAgentEmployeeAddList.add(TaxAgentEmpPO.builder()
.id(IdGenerator.generate())
.taxAgentId(saveParam.getTaxAgentId())
.employeeId(se.getEmployeeId())
.employeeName(se.getUsername())
.employeeType(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())
.creator(currentEmployeeId)
.createTime(now)
.updateTime(now)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.deleteType(0)
.build());
Arrays.stream(TaxAgentEmpChangeModuleEnum.values()).forEach(e -> {
taxAgentEmpChangeList.add(TaxAgentEmpChangePO.builder()
.id(IdGenerator.generate())
.taxAgentId(saveParam.getTaxAgentId())
.employeeId(se.getEmployeeId())
.employeeName(se.getUsername())
.changeType(TaxAgentEmpChangeTypeEnum.ADD.getValue())
.moduleType(e.getValue())
.employeeType(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())
.creator(currentEmployeeId)
.createTime(now)
.updateTime(now)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.deleteType(0)
.build());
});
}
//遍历剩余的就是删除的
for (String key : taxAgentEmployeeMap.keySet()) {
TaxAgentEmpPO value = taxAgentEmployeeMap.get(key);
taxAgentEmployeeDelIds.add(value.getId());
Arrays.stream(TaxAgentEmpChangeModuleEnum.values()).forEach(e -> {
taxAgentEmpChangeList.add(TaxAgentEmpChangePO.builder()
.id(IdGenerator.generate())
.taxAgentId(saveParam.getTaxAgentId())
.employeeId(value.getEmployeeId())
.employeeName(value.getEmployeeName())
.changeType(TaxAgentEmpChangeTypeEnum.DEL.getValue())
.moduleType(e.getValue())
.employeeType(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())
.creator(currentEmployeeId)
.createTime(now)
.updateTime(now)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.deleteType(0)
.build());
});
}
});
// 关联表====================================================
// 新增
if (CollectionUtils.isNotEmpty(taxAgentEmployeeAddList)) {
List<List<TaxAgentEmpPO>> partition = Lists.partition(taxAgentEmployeeAddList, 100);
partition.forEach(getTaxAgentEmpMapper()::batchInsert);
}
// 删除
if (CollectionUtils.isNotEmpty(taxAgentEmployeeDelIds)) {
List<List<Long>> partition = Lists.partition(taxAgentEmployeeDelIds, 100);
partition.forEach(getTaxAgentEmpMapper()::deleteByIds);
}
// 增量表====================================================
if (CollectionUtils.isNotEmpty(taxAgentEmpChangeList)) {
getTaxAgentEmpChangeService(user).batchInsert(taxAgentEmpChangeList);
}
}
}

View File

@ -21,6 +21,7 @@ import com.engine.salary.enums.salarysob.TargetTypeEnum;
import com.engine.salary.enums.taxagent.TaxAgentRangeTypeEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.sys.SalarySysConfMapper;
import com.engine.salary.mapper.taxagent.TaxAgentExtRangeMapper;
import com.engine.salary.mapper.taxagent.TaxAgentManageRangeMapper;
import com.engine.salary.service.*;
import com.engine.salary.sys.entity.po.SalarySysConfPO;
@ -68,6 +69,10 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
return MapperProxyFactory.getProxy(TaxAgentManageRangeMapper.class);
}
private TaxAgentExtRangeMapper getTaxAgentExtRangeMapper() {
return MapperProxyFactory.getProxy(TaxAgentExtRangeMapper.class);
}
private TaxAgentService getTaxAgentService(User user) {
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
@ -84,6 +89,11 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
}
private ExtEmpService getExtEmpService(User user) {
return ServiceUtil.getService(ExtEmpServiceImpl.class, user);
}
private SalarySysConfMapper getSalarySysConfMapper() {
return SqlProxyHandle.getProxy(SalarySysConfMapper.class);
}
@ -348,6 +358,64 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
}
/**
* 根据个税口角义务人id保存管理范围
*
* @param saveParam 保存参数
*/
@Override
public void saveExtRange(TaxAgentManageRangeExtSaveParam saveParam) {
if (saveParam == null) {
throw new SalaryRunTimeException("参数错误");
}
Long taxAgentId = saveParam.getTaxAgentId();
if (Objects.isNull(taxAgentId)) {
throw new SalaryRunTimeException("个税扣缴义务人的id不允许为空");
}
// 查询个税扣缴义务人
TaxAgentPO taxAgent = getTaxAgentService(user).getById(taxAgentId);
if (Objects.isNull(taxAgent)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(108605, "参数错误,个税扣缴义务人不存在或不在权限范围内"));
}
List<Long> targetIds = saveParam.getTargetIds();
List<DataCollectionEmployee> employees = getExtEmpService(user).getEmployeeByIds(targetIds);
if (Objects.isNull(employees)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(108605, "参数错误,无此外部人员"));
}
/* 同步本地人员范围的关联人员=========================== */
if (saveParam.isSync()) {
//同步执行
syncLocalExtEmp(taxAgentId, employees);
} else {
taskExecutor.execute(() -> {
syncLocalExtEmp(taxAgentId, employees);
});
}
}
private void syncLocalExtEmp(Long taxAgentId, List<DataCollectionEmployee> allSalaryEmployees) {
List<TaxAgentEmpSaveParam> taxAgentEmpSaveParamList = Collections.singletonList(getTaxAgentEmpSyncParam(taxAgentId, allSalaryEmployees));
// 同步个税扣缴义务人的人员
getTaxAgentEmpService(user).syncTaxAgentExtEmployee(taxAgentEmpSaveParamList, (long) user.getUID());
// //生成档案
getSalaryArchiveService(user).handleChangeData(1L);
// //生成社保福利档案
// String welSign = (String) Util_DataCache.getObjVal("welfareChangeSign");
// if (welSign == null || "0".equals(welSign)) {
// getSIArchivesService(user).handleChangeData(1L);
// }
}
/**
* 获取个税口角义务人的管理范围
*
@ -549,6 +617,7 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
/**
* 导入数据
*
* @param taxAgentImportParam
* @return
*/

View File

@ -253,6 +253,14 @@ public class TaxAgentController {
return new ResponseResult<TaxAgentRangeSaveParam, String>(user).run(getTaxAgentWrapper(user)::saveRange, saveParam);
}
@POST
@Path("/range/ext/save")
@Produces(MediaType.APPLICATION_JSON)
public String saveExtRange(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentManageRangeExtSaveParam saveParam) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<TaxAgentManageRangeExtSaveParam, String>(user).run(getTaxAgentWrapper(user)::saveExtRange, saveParam);
}
//删除人员范围
@POST
@Path("/range/delete")

View File

@ -347,6 +347,16 @@ public class TaxAgentWrapper extends Service {
return StringUtils.EMPTY;
}
/**
* 外部人员范围
* @param saveParam
* @return
*/
public String saveExtRange(TaxAgentManageRangeExtSaveParam saveParam) {
getTaxAgentManageRangeService(user).saveExtRange(saveParam);
return StringUtils.EMPTY;
}
/**
* 删除管理范围
*
@ -438,4 +448,6 @@ public class TaxAgentWrapper extends Service {
public Map<String, Object> importData(TaxAgentImportParam taxAgentImportParam) {
return getTaxAgentManageRangeService(user).importData(taxAgentImportParam);
}
}