钱智需求

This commit is contained in:
钱涛 2025-09-23 14:20:52 +08:00
parent 2b92c2f5d6
commit 613478b19c
10 changed files with 715 additions and 1 deletions

View File

@ -0,0 +1,15 @@
CREATE TABLE hrsa_employee_declare_opt
(
id bigint(0) NOT NULL,
create_time datetime(0),
update_time datetime(0),
creator bigint(0),
delete_type int(0),
tenant_key varchar(10),
tax_agent_id bigint(0),
status varchar(255),
last_operate_time datetime(0),
last_operate varchar(255),
tax_cycle datetime(0),
PRIMARY KEY (id) USING BTREE
);

View File

@ -1,11 +1,14 @@
package com.engine.salary.entity.employeedeclare.dto;
import com.engine.salary.annotation.TableTitle;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.Date;
import java.util.Set;
/**
@ -27,7 +30,28 @@ public class TaxAgentDeclareListDTO {
private Long id;
// 个税扣缴义务人
@TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentName", key = "taxAgentName")
private String taxAgentName;
/**
* 最后操作功能
*/
@TableTitle(title = "最后操作功能", dataIndex = "lastOperate", key = "lastOperate")
private String lastOperate;
/**
* 最后操作时间
*/
@TableTitle(title = "最后操作时间", dataIndex = "lastOperateTime", key = "lastOperateTime")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date lastOperateTime;
/**
* 报送状态
*/
@TableTitle(title = "报送状态", dataIndex = "status", key = "status")
public String status;
Set<String> opts;
}

View File

@ -6,6 +6,8 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* 人员报送个税扣缴义务人查询条件
* <p>Copyright: Copyright (c) 2023</p>
@ -22,4 +24,13 @@ public class TaxAgentDeclareListQueryParam extends BaseQueryParam {
// "个税扣缴义务人名称"
private String taxAgentName;
// 最后操作
private List<String> lastOperates;
/**
* 操作状态
*/
private List<String> statuses;
}

View File

@ -0,0 +1,101 @@
package com.engine.salary.entity.employeedeclare.po;
import com.engine.hrmelog.annotation.ElogTransform;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Collection;
import java.util.Date;
/**
* 人员报送
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
//hrsa_employee_declare_opt
public class EmployeeDeclareOptPO {
/**
* ID
*/
@ElogTransform(name = "ID")
private Long id;
/**
* 个税扣缴义务人
*/
@ElogTransform(name = "个税扣缴义务人")
private Long taxAgentId;
/**
* 税款所属期
*/
@ElogTransform(name = "税款所属期")
private Date taxCycle;
/**
* 报送状态
*/
@ElogTransform(name = "操作状态")
private String status;
/**
* 最后操作
*/
@ElogTransform(name = "最后操作")
private String lastOperate;
/**
* 最后操作时间
*/
@ElogTransform(name = "最后操作时间")
private Date lastOperateTime;
/**
* 创建时间
*/
@ElogTransform(name = "创建时间")
private Date createTime;
/**
* 修改时间
*/
@ElogTransform(name = "修改时间")
private Date updateTime;
/**
* 创建人id
*/
@ElogTransform(name = "创建人id")
private Long creator;
/**
* 是否删除
*/
@ElogTransform(name = "是否删除")
private Integer deleteType;
/**
* 租户KEY
*/
@ElogTransform(name = "租户KEY")
private String tenantKey;
//主键id集合
private Collection<Long> ids;
private Collection<Long> taxAgentIds;
private Collection<String> lastOperates;
private Collection<String> statuses;
}

View File

@ -0,0 +1,56 @@
package com.engine.salary.enums.employeedeclare;
import com.engine.salary.enums.BaseEnum;
import java.util.Objects;
/**
* 操作枚举
* <p>Copyright: Copyright (c) 2025</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public enum DeclareOptEnum implements BaseEnum<String> {
BAT_REFRESH("1", "批量刷新", 158772),
BAT_DECLARE("2", "批量报送", 158770),
BAT_DECLARE_FEEDBACK("3", "批量获取反馈", 158774);
DeclareOptEnum(String value, String defaultLabel, int labelId) {
this.value = value;
this.defaultLabel = defaultLabel;
this.labelId = labelId;
}
private String value;
private String defaultLabel;
private int labelId;
@Override
public String getValue() {
return value;
}
@Override
public String getDefaultLabel() {
return defaultLabel;
}
@Override
public Integer getLabelId() {
return labelId;
}
public static DeclareOptEnum getByValue(String value) {
for (DeclareOptEnum e : DeclareOptEnum.values()) {
if (Objects.equals(e.getValue(), value)) {
return e;
}
}
return BAT_REFRESH;
}
}

View File

@ -0,0 +1,73 @@
package com.engine.salary.mapper.employeedeclare;
import com.engine.salary.entity.employeedeclare.po.EmployeeDeclareOptPO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
public interface EmployeeDeclareOptMapper {
/**
* 查询所有记录
*
* @return 返回集合没有返回空List
*/
List<EmployeeDeclareOptPO> listAll();
/**
* 条件查询
*
* @return 返回集合没有返回空List
*/
List<EmployeeDeclareOptPO> listSome(EmployeeDeclareOptPO employeeDeclareOpt);
/**
* 根据主键查询
*
* @param id 主键
* @return 返回记录没有返回null
*/
EmployeeDeclareOptPO getById(Long id);
/**
* 新增忽略null字段
*
* @param employeeDeclareOpt 新增的记录
* @return 返回影响行数
*/
int insertIgnoreNull(EmployeeDeclareOptPO employeeDeclareOpt);
/**
* 修改修改所有字段
*
* @param employeeDeclareOpt 修改的记录
* @return 返回影响行数
*/
int update(EmployeeDeclareOptPO employeeDeclareOpt);
/**
* 修改忽略null字段
*
* @param employeeDeclareOpt 修改的记录
* @return 返回影响行数
*/
int updateIgnoreNull(EmployeeDeclareOptPO employeeDeclareOpt);
/**
* 删除记录
*
* @param employeeDeclareOpt 待删除的记录
* @return 返回影响行数
*/
int delete(EmployeeDeclareOptPO employeeDeclareOpt);
/**
* 批量删除记录
* @param ids 主键id集合
*/
void deleteByIds(@Param("ids") Collection<Long> ids);
EmployeeDeclareOptPO getByTaxAgentId(Long taxAgentId);
}

View File

@ -0,0 +1,278 @@
<?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.employeedeclare.EmployeeDeclareOptMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.employeedeclare.po.EmployeeDeclareOptPO">
<result column="create_time" property="createTime"/>
<result column="creator" property="creator"/>
<result column="delete_type" property="deleteType"/>
<result column="id" property="id"/>
<result column="last_operate" property="lastOperate"/>
<result column="last_operate_time" property="lastOperateTime"/>
<result column="status" property="status"/>
<result column="tax_cycle" property="taxCycle"/>
<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.last_operate
, t.last_operate_time
, t.status
, t.tax_agent_id
, t.tenant_key
, t.update_time
, t.tax_cycle
</sql>
<!-- 查询全部 -->
<select id="listAll" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_employee_declare_opt t
WHERE delete_type = 0
</select>
<!-- 根据主键获取单条记录 -->
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
SELECT
<include refid="baseColumns"/>
FROM hrsa_employee_declare_opt t
WHERE id = #{id} AND delete_type = 0
</select>
<!-- 条件查询 -->
<select id="listSome" resultMap="BaseResultMap"
parameterType="com.engine.salary.entity.employeedeclare.po.EmployeeDeclareOptPO">
SELECT
<include refid="baseColumns"/>
FROM hrsa_employee_declare_opt 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="lastOperate != null">
AND last_operate = #{lastOperate}
</if>
<if test="lastOperateTime != null">
AND last_operate_time = #{lastOperateTime}
</if>
<if test="status != null">
AND status = #{status}
</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="taxCycle != null">
AND tax_cycle = #{taxCycle}
</if>
<if test="ids != null and ids.size()>0">
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
<if test="taxAgentIds != null and taxAgentIds.size()>0">
AND tax_agent_id IN
<foreach collection="taxAgentIds" open="(" item="taxAgentId" separator="," close=")">
#{taxAgentId}
</foreach>
</if>
<if test="lastOperates != null and lastOperates.size()>0">
AND last_operate IN
<foreach collection="lastOperates" open="(" item="lastOperate" separator="," close=")">
#{lastOperate}
</foreach>
</if>
<if test="statuses != null and statuses.size()>0">
AND status IN
<foreach collection="statuses" open="(" item="status" separator="," close=")">
#{status}
</foreach>
</if>
ORDER BY id DESC
</select>
<!-- 插入不为NULL的字段 -->
<insert id="insertIgnoreNull" parameterType="com.engine.salary.entity.employeedeclare.po.EmployeeDeclareOptPO">
INSERT INTO hrsa_employee_declare_opt
<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="lastOperate != null">
last_operate,
</if>
<if test="lastOperateTime != null">
last_operate_time,
</if>
<if test="status != null">
status,
</if>
<if test="taxAgentId != null">
tax_agent_id,
</if>
<if test="tenantKey != null">
tenant_key,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="taxCycle != null">
tax_cycle,
</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="lastOperate != null">
#{lastOperate},
</if>
<if test="lastOperateTime != null">
#{lastOperateTime},
</if>
<if test="status != null">
#{status},
</if>
<if test="taxAgentId != null">
#{taxAgentId},
</if>
<if test="tenantKey != null">
#{tenantKey},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="taxCycle != null">
#{taxCycle},
</if>
</trim>
</insert>
<!-- 更新,更新全部字段 -->
<update id="update" parameterType="com.engine.salary.entity.employeedeclare.po.EmployeeDeclareOptPO">
UPDATE hrsa_employee_declare_opt
<set>
create_time=#{createTime},
creator=#{creator},
delete_type=#{deleteType},
last_operate=#{lastOperate},
last_operate_time=#{lastOperateTime},
status=#{status},
tax_agent_id=#{taxAgentId},
tenant_key=#{tenantKey},
update_time=#{updateTime},
tax_cycle=#{taxCycle},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 更新不为NULL的字段 -->
<update id="updateIgnoreNull" parameterType="com.engine.salary.entity.employeedeclare.po.EmployeeDeclareOptPO">
UPDATE hrsa_employee_declare_opt
<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="lastOperate != null">
last_operate=#{lastOperate},
</if>
<if test="lastOperateTime != null">
last_operate_time=#{lastOperateTime},
</if>
<if test="status != null">
status=#{status},
</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>
<if test="taxCycle != null">
tax_cycle=#{taxCycle},
</if>
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 根据主键删除记录 -->
<delete id="delete">
UPDATE hrsa_employee_declare_opt
SET delete_type=1
WHERE id = #{id}
AND delete_type = 0
</delete>
<delete id="deleteByIds">
UPDATE hrsa_employee_declare_opt
SET delete_type = 1
WHERE delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="getByTaxAgentId" resultMap="BaseResultMap" parameterType="Long">
SELECT
<include refid="baseColumns"/>
FROM hrsa_employee_declare_opt t
WHERE id = #{taxAgentId} AND delete_type = 0
</select>
</mapper>

View File

@ -0,0 +1,28 @@
package com.engine.salary.service;
import com.engine.salary.entity.employeedeclare.po.EmployeeDeclareOptPO;
import java.util.List;
/**
* 人员报送人员
* <p>Copyright: Copyright (c) 2023</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public interface EmployeeDeclareOptService {
/**
* 查询操作记录
* @param po
* @return
*/
List<EmployeeDeclareOptPO> listSome(EmployeeDeclareOptPO po);
/**
* 记录操作
* @param po
*/
void record(EmployeeDeclareOptPO po);
}

View File

@ -0,0 +1,63 @@
package com.engine.salary.service.impl;
import com.engine.core.impl.Service;
import com.engine.salary.entity.employeedeclare.po.EmployeeDeclareOptPO;
import com.engine.salary.mapper.employeedeclare.EmployeeDeclareOptMapper;
import com.engine.salary.service.EmployeeDeclareOptService;
import com.engine.salary.util.db.IdGenerator;
import com.engine.salary.util.db.MapperProxyFactory;
import java.util.Date;
import java.util.List;
import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY;
/**
* 员工报送记录
* <p>Copyright: Copyright (c) 2023</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public class EmployeeDeclareOptServiceImpl extends Service implements EmployeeDeclareOptService {
private EmployeeDeclareOptMapper getEmployeeDeclareOptMapper() {
return MapperProxyFactory.getProxy(EmployeeDeclareOptMapper.class);
}
@Override
public List<EmployeeDeclareOptPO> listSome(EmployeeDeclareOptPO po) {
return getEmployeeDeclareOptMapper().listSome(po);
}
@Override
public void record(EmployeeDeclareOptPO po) {
Date now = new Date();
Long taxAgentId = po.getTaxAgentId();
EmployeeDeclareOptPO optPO = getEmployeeDeclareOptMapper().getByTaxAgentId(taxAgentId);
if (optPO == null) {
po = EmployeeDeclareOptPO.builder()
.id(IdGenerator.generate())
.taxAgentId(taxAgentId)
.status(po.getStatus())
.lastOperate(po.getLastOperate())
.lastOperateTime(now)
.creator((long)user.getUID())
.createTime(now)
.updateTime(now)
.deleteType(0)
.tenantKey(DEFAULT_TENANT_KEY)
.build();
getEmployeeDeclareOptMapper().insertIgnoreNull(po);
}else {
optPO.setStatus(po.getStatus());
optPO.setLastOperate(po.getLastOperate());
optPO.setLastOperateTime(now);
getEmployeeDeclareOptMapper().updateIgnoreNull(optPO);
}
}
}

View File

@ -1,5 +1,6 @@
package com.engine.salary.wrapper;
import cn.hutool.core.collection.CollUtil;
import com.cloudstore.dev.api.util.Util_DataCache;
import com.cloudstore.eccom.result.WeaResultMsg;
import com.engine.common.util.ServiceUtil;
@ -10,6 +11,7 @@ import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.employeedeclare.bo.EmployeeDeclareList;
import com.engine.salary.entity.employeedeclare.dto.*;
import com.engine.salary.entity.employeedeclare.param.*;
import com.engine.salary.entity.employeedeclare.po.EmployeeDeclareOptPO;
import com.engine.salary.entity.employeedeclare.po.EmployeeDeclarePO;
import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
@ -79,6 +81,11 @@ public class EmployeeDeclareWrapper extends Service {
return ServiceUtil.getService(EmployeeDeclareExcelServiceImpl.class, user);
}
private EmployeeDeclareOptService getEmployeeDeclareOptService(User user) {
return ServiceUtil.getService(EmployeeDeclareOptServiceImpl.class, user);
}
/**
* 人员报送的个税扣缴义务人列表
*
@ -93,14 +100,53 @@ public class EmployeeDeclareWrapper extends Service {
if (StringUtils.isNotEmpty(queryParam.getTaxAgentName())) {
taxAgents = taxAgents.stream().filter(e -> StringUtils.contains(e.getName(), queryParam.getTaxAgentName())).collect(Collectors.toList());
}
//查询操作状态
List<String> lastOperates = queryParam.getLastOperates();
List<String> statuses = queryParam.getStatuses();
EmployeeDeclareOptPO declareOptPO = EmployeeDeclareOptPO.builder()
.taxAgentIds(SalaryEntityUtil.properties(taxAgents, TaxAgentPO::getId))
.lastOperates(lastOperates)
.statuses(statuses)
.build();
List<EmployeeDeclareOptPO> employeeDeclareOptPOS = getEmployeeDeclareOptService(user).listSome(declareOptPO);
Map<Long, EmployeeDeclareOptPO> longEmployeeDeclareOptPOMap = SalaryEntityUtil.convert2Map(employeeDeclareOptPOS, EmployeeDeclareOptPO::getTaxAgentId);
// 分页
List<TaxAgentDeclareListDTO> dtoList = Lists.newArrayList();
for (TaxAgentPO taxAgent : taxAgents) {
EmployeeDeclareOptPO optPO = longEmployeeDeclareOptPOMap.get(taxAgent.getId());
optPO = optPO == null ? new EmployeeDeclareOptPO() : optPO;
Date taxCycle = optPO.getTaxCycle();
EmployeeDeclareInfoDTO declareInfo = getDeclareInfo(EmployeeDeclareParam.builder().taxAgentId(taxAgent.getId()).taxCycle(taxCycle).build());
String status;
if (declareInfo.getNotDeclareSize() > 0) {
status = DeclareStatusEnum.NOT_DECLARE.getDefaultLabel();
} else if (declareInfo.getDeclareFailSize() > 0) {
status = DeclareStatusEnum.DECLARE_FAIL.getDefaultLabel();
} else {
status = DeclareStatusEnum.DECLARE_SUCCESS.getDefaultLabel();
}
TaxAgentDeclareListDTO dto = TaxAgentDeclareListDTO.builder()
.id(taxAgent.getId())
.taxAgentName(taxAgent.getName())
.status(status)
.lastOperate(DeclareOptEnum.getByValue(optPO.getLastOperate()).getDefaultLabel())
.lastOperateTime(optPO.getLastOperateTime())
.opts(Sets.newHashSet("admin"))
.build();
//如果根据报送状态和最后操作功能筛选则过滤掉没有查询到操作记录的数据
if (CollUtil.isNotEmpty(lastOperates) && !lastOperates.contains(optPO.getLastOperate())) {
continue;
}
if (CollUtil.isNotEmpty(statuses) && !statuses.contains(status)) {
continue;
}
dtoList.add(dto);
}
return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), dtoList, TaxAgentDeclareListDTO.class);
@ -468,6 +514,12 @@ public class EmployeeDeclareWrapper extends Service {
fail++;
} finally {
}
EmployeeDeclareOptPO po = EmployeeDeclareOptPO.builder()
.taxAgentId(taxAgentId)
.taxCycle(param.getTaxCycle())
.lastOperate(DeclareOptEnum.BAT_REFRESH.getValue())
.build();
getEmployeeDeclareOptService(user).record(po);
}
return "成功:" + success + "个,失败:" + fail + "个,失败原因:" + msg;
}
@ -533,6 +585,12 @@ public class EmployeeDeclareWrapper extends Service {
fail++;
} finally {
}
EmployeeDeclareOptPO po = EmployeeDeclareOptPO.builder()
.taxAgentId(taxAgentId)
.taxCycle(param.getTaxCycle())
.lastOperate(DeclareOptEnum.BAT_DECLARE.getValue())
.build();
getEmployeeDeclareOptService(user).record(po);
}
return "成功:" + success + "个,失败:" + fail + "个,失败原因:" + msg;
}
@ -585,7 +643,7 @@ public class EmployeeDeclareWrapper extends Service {
.setStatus(true)
.setFinish(false)
.setMsg("");
getEmployeeDeclareService(user).getDeclareFeedback(param,employeeDeclareRate);
getEmployeeDeclareService(user).getDeclareFeedback(param, employeeDeclareRate);
success++;
} catch (Exception e) {
log.error("获取报送结果反馈失败:{}", e.getMessage(), e);
@ -593,6 +651,13 @@ public class EmployeeDeclareWrapper extends Service {
fail++;
} finally {
}
EmployeeDeclareOptPO po = EmployeeDeclareOptPO.builder()
.taxAgentId(taxAgentId)
.taxCycle(param.getTaxCycle())
.lastOperate(DeclareOptEnum.BAT_DECLARE_FEEDBACK.getValue())
.build();
getEmployeeDeclareOptService(user).record(po);
}
return "成功:" + success + "个,失败:" + fail + "个,失败原因:" + msg;
}