Browse Source
feat(srm): 添加税率管理功能并优化供应商数据映射
feat(srm): 添加税率管理功能并优化供应商数据映射
- 新增 SrmTax 实体类用于税率信息管理 - 添加 SrmTaxController 提供税率列表、增删改查接口 - 实现 SrmTaxService 和 SrmTaxServiceImpl 业务逻辑 - 创建 SrmTaxMapper 数据访问层及对应的 XML 映射文件 - 修正供应商映射文件中的字段命名规范,统一使用驼峰命名 - 移除未使用的 SrmDeliveryTerm 导入依赖master
8 changed files with 281 additions and 9 deletions
-
1src/main/java/com/xujie/modules/baseInformation/controller/SrmPaymentTermController.java
-
53src/main/java/com/xujie/modules/baseInformation/controller/SrmTaxController.java
-
19src/main/java/com/xujie/modules/baseInformation/entity/SrmTax.java
-
22src/main/java/com/xujie/modules/baseInformation/mapper/SrmTaxMapper.java
-
15src/main/java/com/xujie/modules/baseInformation/service/SrmTaxService.java
-
75src/main/java/com/xujie/modules/baseInformation/service/impl/SrmTaxServiceImpl.java
-
89src/main/resources/mapper/baseInformation/SrmTaxMapper.xml
-
16src/main/resources/mapper/srm/SrmSupplierMapper.xml
@ -0,0 +1,53 @@ |
|||
package com.xujie.modules.baseInformation.controller; |
|||
|
|||
import com.xujie.common.utils.PageUtils; |
|||
import com.xujie.common.utils.R; |
|||
import com.xujie.modules.baseInformation.entity.SrmTax; |
|||
import com.xujie.modules.baseInformation.service.SrmTaxService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
@RestController |
|||
@RequestMapping("/srmTax") |
|||
public class SrmTaxController { |
|||
|
|||
@Autowired |
|||
private SrmTaxService srmTaxService; |
|||
|
|||
/** |
|||
* 获取税号列表 |
|||
*/ |
|||
@PostMapping("/getTaxListPaging") |
|||
public R getTaxListPaging(@RequestBody SrmTax tax) { |
|||
PageUtils page = srmTaxService.getTaxListPaging(tax); |
|||
return R.ok().put("data", page); |
|||
} |
|||
|
|||
/** |
|||
* 新增税率信息 |
|||
*/ |
|||
@PostMapping("/saveTax") |
|||
public R saveTax(@RequestBody SrmTax tax) { |
|||
return srmTaxService.saveTax(tax); |
|||
} |
|||
|
|||
/** |
|||
* 更新税率信息 |
|||
*/ |
|||
@PostMapping("/updateTax") |
|||
public R updateTax(@RequestBody SrmTax tax) { |
|||
return srmTaxService.updateTax(tax); |
|||
} |
|||
|
|||
/** |
|||
* 删除税率信息 |
|||
*/ |
|||
@PostMapping("/deleteTax") |
|||
public R deleteTax(@RequestBody SrmTax tax) { |
|||
return srmTaxService.deleteTax(tax); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
package com.xujie.modules.baseInformation.entity; |
|||
|
|||
import com.xujie.common.utils.QueryPage; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class SrmTax extends QueryPage { |
|||
|
|||
private String taxCode; |
|||
|
|||
private String taxDesc; |
|||
|
|||
private String site; |
|||
|
|||
private String taxRate; |
|||
|
|||
private String active; |
|||
|
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
package com.xujie.modules.baseInformation.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.xujie.modules.baseInformation.entity.SrmPaymentTerm; |
|||
import com.xujie.modules.baseInformation.entity.SrmTax; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
@Mapper |
|||
public interface SrmTaxMapper { |
|||
IPage<SrmPaymentTerm> selectTaxWithPaging(Page<SrmPaymentTerm> page, SrmTax tax); |
|||
|
|||
SrmTax selectTaxByCode(String taxCode, String site); |
|||
|
|||
int insertTax(SrmTax tax); |
|||
|
|||
int updateTax(SrmTax tax); |
|||
|
|||
Integer checkTaxReference(String taxCode, String site); |
|||
|
|||
int deleteTax(String taxCode, String site); |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
package com.xujie.modules.baseInformation.service; |
|||
|
|||
import com.xujie.common.utils.PageUtils; |
|||
import com.xujie.common.utils.R; |
|||
import com.xujie.modules.baseInformation.entity.SrmTax; |
|||
|
|||
public interface SrmTaxService { |
|||
PageUtils getTaxListPaging(SrmTax tax); |
|||
|
|||
R saveTax(SrmTax tax); |
|||
|
|||
R updateTax(SrmTax tax); |
|||
|
|||
R deleteTax(SrmTax tax); |
|||
} |
|||
@ -0,0 +1,75 @@ |
|||
package com.xujie.modules.baseInformation.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.xujie.common.utils.PageUtils; |
|||
import com.xujie.common.utils.R; |
|||
import com.xujie.modules.baseInformation.entity.SrmPaymentTerm; |
|||
import com.xujie.modules.baseInformation.entity.SrmTax; |
|||
import com.xujie.modules.baseInformation.mapper.SrmTaxMapper; |
|||
import com.xujie.modules.baseInformation.service.SrmTaxService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class SrmTaxServiceImpl implements SrmTaxService { |
|||
|
|||
@Autowired |
|||
private SrmTaxMapper srmTaxMapper; |
|||
|
|||
@Override |
|||
public PageUtils getTaxListPaging(SrmTax tax) { |
|||
Page<SrmPaymentTerm> page = new Page<>(tax.getPage(), tax.getLimit()); |
|||
IPage<SrmPaymentTerm> iPage = this.srmTaxMapper.selectTaxWithPaging(page, tax); |
|||
return new PageUtils(iPage); |
|||
} |
|||
|
|||
@Override |
|||
public R saveTax(SrmTax tax) { |
|||
|
|||
//检查是否存在相同的税号和site |
|||
SrmTax existing = srmTaxMapper.selectTaxByCode(tax.getTaxCode(), tax.getSite()); |
|||
if (existing != null) { |
|||
return R.error("税号已存在"); |
|||
} |
|||
|
|||
int result = srmTaxMapper.insertTax(tax); |
|||
if (result > 0) { |
|||
return R.ok().put("msg", "税号新增成功"); |
|||
}else { |
|||
return R.error("税号新增失败"); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public R updateTax(SrmTax tax) { |
|||
//检查是否存在税号和site |
|||
SrmTax existing = srmTaxMapper.selectTaxByCode(tax.getTaxCode(), tax.getSite()); |
|||
if (existing == null) { |
|||
return R.error("税号已存在"); |
|||
} |
|||
|
|||
int result = srmTaxMapper.updateTax(tax); |
|||
if (result > 0) { |
|||
return R.ok().put("msg", "税号更新成功"); |
|||
}else { |
|||
return R.error("税号更新失败"); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public R deleteTax(SrmTax tax) { |
|||
//检查税率编号是否被引用 |
|||
Integer referenceCount = srmTaxMapper.checkTaxReference(tax.getTaxCode(), tax.getSite()); |
|||
if (referenceCount > 0){ |
|||
return R.error("税率编号正在被使用,无法删除"); |
|||
} |
|||
|
|||
int result = srmTaxMapper.deleteTax(tax.getTaxCode(), tax.getSite()); |
|||
if (result > 0) { |
|||
return R.ok().put("msg", "税率编号删除成功"); |
|||
}else { |
|||
return R.error("税率编号删除失败"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,89 @@ |
|||
<?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.xujie.modules.baseInformation.mapper.SrmTaxMapper"> |
|||
<resultMap id="TaxMap" type="com.xujie.modules.baseInformation.entity.SrmTax"> |
|||
<result property="taxCode" column="Taxcode"/> |
|||
<result property="site" column="Site"/> |
|||
<result property="taxDesc" column="TaxDesc"/> |
|||
<result property="taxRate" column="TaxRate"/> |
|||
<result property="active" column="Active"/> |
|||
</resultMap> |
|||
|
|||
|
|||
<select id="selectTaxWithPaging" resultMap="TaxMap"> |
|||
SELECT |
|||
Taxcode, |
|||
Site, |
|||
TaxDesc, |
|||
TaxRate, |
|||
Active |
|||
FROM Tax |
|||
<where> |
|||
<if test="tax.site != null and tax.site != ''"> |
|||
AND Site = #{tax.site} |
|||
</if> |
|||
<if test="tax.taxCode != null and tax.taxCode != ''"> |
|||
AND Taxcode = #{tax.taxCode} |
|||
</if> |
|||
<if test="tax.taxDesc != null and tax.taxDesc != ''"> |
|||
AND TaxDesc LIKE '%' + #{tax.taxDesc} + '%' |
|||
</if> |
|||
<if test="tax.active != null and tax.active != ''"> |
|||
AND Active = #{tax.active} |
|||
</if> |
|||
</where> |
|||
ORDER BY Taxcode |
|||
</select> |
|||
<select id="selectTaxByCode" resultMap="TaxMap"> |
|||
SELECT |
|||
Taxcode, |
|||
Site, |
|||
TaxDesc, |
|||
TaxRate, |
|||
Active |
|||
FROM Tax |
|||
WHERE Taxcode = #{taxCode} AND Site = #{site} |
|||
</select> |
|||
|
|||
<insert id="insertTax"> |
|||
INSERT INTO Tax ( |
|||
Taxcode, |
|||
Site, |
|||
TaxDesc, |
|||
TaxRate, |
|||
Active |
|||
) VALUES ( |
|||
#{taxCode}, |
|||
#{site}, |
|||
#{taxDesc}, |
|||
#{taxRate}, |
|||
#{active} |
|||
) |
|||
</insert> |
|||
|
|||
<update id="updateTax"> |
|||
UPDATE Tax |
|||
<set> |
|||
<if test="taxDesc != null and taxDesc != ''"> |
|||
TaxDesc = #{taxDesc}, |
|||
</if> |
|||
<if test="taxRate != null and taxRate != ''"> |
|||
TaxRate = #{taxRate}, |
|||
</if> |
|||
<if test="active != null and active != ''"> |
|||
Active = #{active} |
|||
</if> |
|||
</set> |
|||
WHERE Taxcode = #{taxCode} AND Site = #{site} |
|||
</update> |
|||
<update id="checkTaxReference"> |
|||
SELECT COUNT(1) |
|||
from srm_supplier |
|||
WHERE Tax = #{taxCode} AND site = #{site} |
|||
</update> |
|||
|
|||
<delete id="deleteTax"> |
|||
DELETE FROM Tax |
|||
WHERE Taxcode = #{taxCode} AND Site = #{site} |
|||
</delete> |
|||
</mapper> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue