Browse Source

feat(srm): 添加税率管理功能并优化供应商数据映射

- 新增 SrmTax 实体类用于税率信息管理
- 添加 SrmTaxController 提供税率列表、增删改查接口
- 实现 SrmTaxService 和 SrmTaxServiceImpl 业务逻辑
- 创建 SrmTaxMapper 数据访问层及对应的 XML 映射文件
- 修正供应商映射文件中的字段命名规范,统一使用驼峰命名
- 移除未使用的 SrmDeliveryTerm 导入依赖
master
qiankanghui 7 days ago
parent
commit
e0f596c6c0
  1. 1
      src/main/java/com/xujie/modules/baseInformation/controller/SrmPaymentTermController.java
  2. 53
      src/main/java/com/xujie/modules/baseInformation/controller/SrmTaxController.java
  3. 19
      src/main/java/com/xujie/modules/baseInformation/entity/SrmTax.java
  4. 22
      src/main/java/com/xujie/modules/baseInformation/mapper/SrmTaxMapper.java
  5. 15
      src/main/java/com/xujie/modules/baseInformation/service/SrmTaxService.java
  6. 75
      src/main/java/com/xujie/modules/baseInformation/service/impl/SrmTaxServiceImpl.java
  7. 89
      src/main/resources/mapper/baseInformation/SrmTaxMapper.xml
  8. 16
      src/main/resources/mapper/srm/SrmSupplierMapper.xml

1
src/main/java/com/xujie/modules/baseInformation/controller/SrmPaymentTermController.java

@ -2,7 +2,6 @@ package com.xujie.modules.baseInformation.controller;
import com.xujie.common.utils.PageUtils;
import com.xujie.common.utils.R;
import com.xujie.modules.baseInformation.entity.SrmDeliveryTerm;
import com.xujie.modules.baseInformation.entity.SrmPaymentTerm;
import com.xujie.modules.baseInformation.service.SrmPaymentTermService;
import org.springframework.beans.factory.annotation.Autowired;

53
src/main/java/com/xujie/modules/baseInformation/controller/SrmTaxController.java

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

19
src/main/java/com/xujie/modules/baseInformation/entity/SrmTax.java

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

22
src/main/java/com/xujie/modules/baseInformation/mapper/SrmTaxMapper.java

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

15
src/main/java/com/xujie/modules/baseInformation/service/SrmTaxService.java

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

75
src/main/java/com/xujie/modules/baseInformation/service/impl/SrmTaxServiceImpl.java

@ -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("税率编号删除失败");
}
}
}

89
src/main/resources/mapper/baseInformation/SrmTaxMapper.xml

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

16
src/main/resources/mapper/srm/SrmSupplierMapper.xml

@ -5,7 +5,7 @@
<!-- 基础字段映射 -->
<sql id="Base_Column_List">
id,site,supplier_no,supplier_name,supplier_group,create_date,create_by,update_date,update_by,supplier_doc_type,
TaxCode,tax,FaxNo,PhoneNo,PhoneNo2,PhoneNo3,Contact,Address,PaymentTerm,DeliveryTerm,Buyer,Sourcing_staff,
TaxCode,tax,FaxNo,PhoneNo,PhoneNo2,PhoneNo3,Contact,Address,PaymentTerm,DeliveryTerm,Buyer,SourcingStaff,
Currency,ABC,Active,BankName,BankAccount,TaxNo,Email,Email2,Other_contact1,Other_contact2,Other_contact3,Memo
</sql>
@ -13,7 +13,7 @@
<select id="searchSrmSupplierList" resultType="SrmSupplierData">
SELECT
s.id,s.site,s.supplier_no,s.supplier_name,s.supplier_group,sg.GroupDesc AS groupDesc,s.supplier_doc_type,
s.create_date,s.create_by,s.update_date,s.update_by,s.Buyer,s.Sourcing_staff AS sourcingStaff,s.PhoneNo,
s.create_date,s.create_by,s.update_date,s.update_by,s.Buyer,s.SourcingStaff AS sourcingStaff,s.PhoneNo,
s.PhoneNo2,s.PhoneNo3,s.FaxNo,s.Contact,s.Address,s.Email,s.Email2,
s.PaymentTerm,pt.PaymentTerm AS paymentTermDesc,
s.DeliveryTerm,dt.DeliveryTerm AS deliveryTermDesc,
@ -57,7 +57,7 @@
<select id="checkSrmSupplierList" resultType="SrmSupplierData">
SELECT
id,site,supplier_no,supplier_name,supplier_group,create_date,create_by,update_date,update_by,supplier_doc_type,
TaxCode,tax,FaxNo,PhoneNo,PhoneNo2,PhoneNo3,Contact,Address,PaymentTerm,DeliveryTerm,Buyer,Sourcing_staff,
TaxCode,tax,FaxNo,PhoneNo,PhoneNo2,PhoneNo3,Contact,Address,PaymentTerm,DeliveryTerm,Buyer,SourcingStaff,
Currency,ABC,Active,BankName,BankAccount,TaxNo,Email,Email2,Other_contact1,Other_contact2,Other_contact3,Memo
FROM srm_supplier
<where>
@ -287,7 +287,7 @@
PaymentTerm,
DeliveryTerm,
Buyer,
Sourcing_staff,
SourcingStaff,
Currency,
ABC,
Active,
@ -402,7 +402,7 @@
Buyer = #{buyer},
</if>
<if test="sourcingstaff != null and sourcingstaff != ''">
Sourcingstaff = #{sourcingstaff},
SourcingStaff = #{sourcingstaff},
</if>
<if test="currency != null and currency != ''">
Currency = #{currency},
@ -429,13 +429,13 @@
Email2 = #{email2},
</if>
<if test="otherContact1 != null and otherContact1 != ''">
OtherContact1 = #{otherContact1},
Other_contact1 = #{otherContact1},
</if>
<if test="otherContact2 != null and otherContact2 != ''">
OtherContact2 = #{otherContact2},
Other_contact2 = #{otherContact2},
</if>
<if test="otherContact3 != null and otherContact3 != ''">
OtherContact3 = #{otherContact3},
Other_contact3 = #{otherContact3},
</if>
<if test="memo != null and memo != ''">
Memo = #{memo}

Loading…
Cancel
Save