From c72fa7fd7c5feb79304cc2aa5b775ec2972a630e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Mon, 2 Sep 2024 14:13:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E8=B4=A6=E5=A5=97=E8=81=94?= =?UTF-8?q?=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../param/SalarySobBasicSaveParam.java | 4 + .../entity/salarysob/po/SobTaxLinkPO.java | 72 ++++++ .../mapper/salarysob/SobTaxLinkMapper.java | 73 ++++++ .../mapper/salarysob/SobTaxLinkMapper.xml | 215 ++++++++++++++++++ .../service/impl/SalarySobServiceImpl.java | 31 +++ 5 files changed, 395 insertions(+) create mode 100644 src/com/engine/salary/entity/salarysob/po/SobTaxLinkPO.java create mode 100644 src/com/engine/salary/mapper/salarysob/SobTaxLinkMapper.java create mode 100644 src/com/engine/salary/mapper/salarysob/SobTaxLinkMapper.xml diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobBasicSaveParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobBasicSaveParam.java index bd86de4d6..8742eaa24 100644 --- a/src/com/engine/salary/entity/salarysob/param/SalarySobBasicSaveParam.java +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobBasicSaveParam.java @@ -9,6 +9,8 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + /** * 薪资账套保存参数 @@ -39,6 +41,8 @@ public class SalarySobBasicSaveParam { @DataCheck(require = true, message = "个税扣缴义务人的主键id不允许为空") private Long taxAgentId; + private List taxAgentIds; + /** * 薪资类型不允许为空 * diff --git a/src/com/engine/salary/entity/salarysob/po/SobTaxLinkPO.java b/src/com/engine/salary/entity/salarysob/po/SobTaxLinkPO.java new file mode 100644 index 000000000..31ead3a94 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/po/SobTaxLinkPO.java @@ -0,0 +1,72 @@ +package com.engine.salary.entity.salarysob.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 +public class SobTaxLinkPO { + + @ElogTransform(name = "id") + private Long id; + + /** + * 账套id + */ + @ElogTransform(name = "账套id") + private Long sobId; + + /** + * 扣缴义务人id + */ + @ElogTransform(name = "扣缴义务人id") + private Long taxAgentId; + + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform(name = "是否已删除。0:未删除、1:已删除") + private Integer deleteType; + + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + + /** + * 租户ID + */ + @ElogTransform(name = "租户ID") + private String tenantKey; + + //主键id集合 + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SobTaxLinkMapper.java b/src/com/engine/salary/mapper/salarysob/SobTaxLinkMapper.java new file mode 100644 index 000000000..8192f5e21 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SobTaxLinkMapper.java @@ -0,0 +1,73 @@ +package com.engine.salary.mapper.salarysob; + +import com.engine.salary.entity.salarysob.po.SobTaxLinkPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SobTaxLinkMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SobTaxLinkPO sobTaxLink); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SobTaxLinkPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param sobTaxLink 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SobTaxLinkPO sobTaxLink); + + /** + * 修改,修改所有字段 + * + * @param sobTaxLink 修改的记录 + * @return 返回影响行数 + */ + int update(SobTaxLinkPO sobTaxLink); + + /** + * 修改,忽略null字段 + * + * @param sobTaxLink 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SobTaxLinkPO sobTaxLink); + + /** + * 删除记录 + * + * @param sobTaxLink 待删除的记录 + * @return 返回影响行数 + */ + int delete(SobTaxLinkPO sobTaxLink); + + /** + * 批量删除记录 + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + + void deleteBySobId(Long id); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SobTaxLinkMapper.xml b/src/com/engine/salary/mapper/salarysob/SobTaxLinkMapper.xml new file mode 100644 index 000000000..ef377aa5f --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SobTaxLinkMapper.xml @@ -0,0 +1,215 @@ + + + + + + + + + + + + + + + + + t + . + create_time + , t.creator + , t.delete_type + , t.id + , t.sob_id + , t.tax_agent_id + , t.tenant_key + , t.update_time + + + + + + + + + + + + + + + INSERT INTO hrsa_sob_tax_link + + + + create_time, + + + creator, + + + delete_type, + + + id, + + + sob_id, + + + tax_agent_id, + + + tenant_key, + + + update_time, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{id}, + + + #{sobId}, + + + #{taxAgentId}, + + + #{tenantKey}, + + + #{updateTime}, + + + + + + + + UPDATE hrsa_sob_tax_link + + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + sob_id=#{sobId}, + tax_agent_id=#{taxAgentId}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_sob_tax_link + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + sob_id=#{sobId}, + + + tax_agent_id=#{taxAgentId}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_sob_tax_link + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_sob_tax_link + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + UPDATE hrsa_sob_tax_link + SET delete_type = 1 + WHERE delete_type = 0 + AND sob_id=#{sobId} + + + \ No newline at end of file diff --git a/src/com/engine/salary/service/impl/SalarySobServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobServiceImpl.java index d39b2c306..d132cb7ff 100644 --- a/src/com/engine/salary/service/impl/SalarySobServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySobServiceImpl.java @@ -30,6 +30,7 @@ import com.engine.salary.enums.salarysob.IncomeCategoryEnum; import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.salarysob.SalarySobMapper; +import com.engine.salary.mapper.salarysob.SobTaxLinkMapper; import com.engine.salary.mapper.taxagent.TaxAgentExtRangeMapper; import com.engine.salary.service.*; import com.engine.salary.service.auth.AuthService; @@ -118,6 +119,11 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { return MapperProxyFactory.getProxy(TaxAgentExtRangeMapper.class); } + private SobTaxLinkMapper getSobTaxLinkMapper() { + return MapperProxyFactory.getProxy(SobTaxLinkMapper.class); + } + + private SalarySobExtRangeService getSalarySobExtRangeService(User user) { return ServiceUtil.getService(SalarySobExtRangeServiceImpl.class, user); } @@ -345,6 +351,9 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新建薪资账套") + ": " + salarySobPO.getName()); loggerContext.setNewValues(salarySobPO); SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext); + + //保存个税扣缴义务人联系 + saveSobTaxLink(saveParam, salarySobPO); // 新建薪资账套时,保存默认的员工信息字段 saveDefaultEmpField(salarySobPO); // 新建薪资账套时,保存默认的薪资项目 @@ -355,6 +364,24 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { return salarySobPO.getId(); } + private void saveSobTaxLink(SalarySobBasicSaveParam saveParam, SalarySobPO salarySobPO) { + getSobTaxLinkMapper().deleteBySobId(salarySobPO.getId()); + List taxAgentIds = saveParam.getTaxAgentIds(); + for (Long taxAgentId : taxAgentIds) { + SobTaxLinkPO taxLinkPO = SobTaxLinkPO.builder() + .id(IdGenerator.generate()) + .taxAgentId(taxAgentId) + .sobId(salarySobPO.getId()) + .creator((long) user.getUID()) + .createTime(new Date()) + .updateTime(new Date()) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + getSobTaxLinkMapper().insertIgnoreNull(taxLinkPO); + } + } + /** * 新建薪资账套时,保存默认的员工信息字段 @@ -578,6 +605,10 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { .setDescription(saveParam.getDescription()) .setUpdateTime(new Date()); salarySobMapper.updateById(newSalarySobPO); + + //保存个税扣缴义务人联系 + saveSobTaxLink(saveParam, salarySobPO); + // 记录日志 SalarySobPO salarySobPO4log = getSalarySobMapper().getById(newSalarySobPO.getId()); LoggerContext loggerContext = new LoggerContext<>();