Commit 0176bd1069c7f1a819722774ca34778cc17089a8

Authored by 房远帅
1 parent 43f8eea2

采购:内贸客户资信新增客户简称且要唯一

@@ -1472,6 +1472,7 @@ CREATE TABLE `procurement_domestic_customer_credit` @@ -1472,6 +1472,7 @@ CREATE TABLE `procurement_domestic_customer_credit`
1472 ( 1472 (
1473 `id` varchar(32) NOT NULL COMMENT 'ID', 1473 `id` varchar(32) NOT NULL COMMENT 'ID',
1474 `unit_name` varchar(200) NOT NULL COMMENT '单位名称', 1474 `unit_name` varchar(200) NOT NULL COMMENT '单位名称',
  1475 + `customer_short_name` varchar(200) NOT NULL COMMENT '客户简称',
1475 `company_nature` varchar(200) NOT NULL COMMENT '公司性质', 1476 `company_nature` varchar(200) NOT NULL COMMENT '公司性质',
1476 `bank_name` varchar(200) NOT NULL COMMENT '开户行', 1477 `bank_name` varchar(200) NOT NULL COMMENT '开户行',
1477 `bank_account` varchar(200) NOT NULL COMMENT '账号', 1478 `bank_account` varchar(200) NOT NULL COMMENT '账号',
@@ -1526,6 +1527,7 @@ CREATE TABLE `procurement_domestic_customer_credit` @@ -1526,6 +1527,7 @@ CREATE TABLE `procurement_domestic_customer_credit`
1526 `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 1527 `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
1527 `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', 1528 `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
1528 PRIMARY KEY (`id`), 1529 PRIMARY KEY (`id`),
  1530 + UNIQUE KEY `uk_pdcc_customer_short_name` (`customer_short_name`),
1529 KEY `idx_pdcc_unit_name` (`unit_name`), 1531 KEY `idx_pdcc_unit_name` (`unit_name`),
1530 KEY `idx_pdcc_purchase_department` (`purchase_department`), 1532 KEY `idx_pdcc_purchase_department` (`purchase_department`),
1531 KEY `idx_pdcc_review_valid_until` (`review_valid_until`), 1533 KEY `idx_pdcc_review_valid_until` (`review_valid_until`),
@@ -29,6 +29,11 @@ public class ProcurementDomesticCustomerCredit extends BaseEntity implements Bas @@ -29,6 +29,11 @@ public class ProcurementDomesticCustomerCredit extends BaseEntity implements Bas
29 private String unitName; 29 private String unitName;
30 30
31 /** 31 /**
  32 + * 客户简称
  33 + */
  34 + private String customerShortName;
  35 +
  36 + /**
32 * 公司性质 37 * 公司性质
33 */ 38 */
34 private String companyNature; 39 private String companyNature;
1 package com.lframework.xingyun.sc.procurement.impl.credit; 1 package com.lframework.xingyun.sc.procurement.impl.credit;
2 2
  3 +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
3 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; 4 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
4 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; 5 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
5 import com.baomidou.mybatisplus.core.toolkit.Wrappers; 6 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -131,9 +132,17 @@ public class ProcurementDomesticCustomerCreditServiceImpl @@ -131,9 +132,17 @@ public class ProcurementDomesticCustomerCreditServiceImpl
131 throw new DefaultClientException("当前用户不存在!"); 132 throw new DefaultClientException("当前用户不存在!");
132 } 133 }
133 134
  135 + SysUser investigator = sysUserService.findById(vo.getInvestigatorId());
  136 + if (investigator == null) {
  137 + throw new DefaultClientException("资信调查人不存在!");
  138 + }
  139 +
  140 + checkCustomerShortNameUnique(vo.getCustomerShortName(), null);
  141 +
134 ProcurementDomesticCustomerCredit data = new ProcurementDomesticCustomerCredit(); 142 ProcurementDomesticCustomerCredit data = new ProcurementDomesticCustomerCredit();
135 data.setId(IdUtil.getId()); 143 data.setId(IdUtil.getId());
136 data.setUnitName(vo.getUnitName()); 144 data.setUnitName(vo.getUnitName());
  145 + data.setCustomerShortName(vo.getCustomerShortName());
137 data.setCompanyNature(vo.getCompanyNature()); 146 data.setCompanyNature(vo.getCompanyNature());
138 data.setBankName(vo.getBankName()); 147 data.setBankName(vo.getBankName());
139 data.setBankAccount(vo.getBankAccount()); 148 data.setBankAccount(vo.getBankAccount());
@@ -176,7 +185,7 @@ public class ProcurementDomesticCustomerCreditServiceImpl @@ -176,7 +185,7 @@ public class ProcurementDomesticCustomerCreditServiceImpl
176 data.setAttachmentFileIds(vo.getAttachmentFileIds()); 185 data.setAttachmentFileIds(vo.getAttachmentFileIds());
177 data.setAttachmentFileNames(vo.getAttachmentFileNames()); 186 data.setAttachmentFileNames(vo.getAttachmentFileNames());
178 data.setInvestigatorId(vo.getInvestigatorId()); 187 data.setInvestigatorId(vo.getInvestigatorId());
179 - data.setInvestigatorName(currentUser.getName()); 188 + data.setInvestigatorName(investigator.getName());
180 data.setPurchaseDepartment(vo.getPurchaseDepartment()); 189 data.setPurchaseDepartment(vo.getPurchaseDepartment());
181 data.setReviewValidUntil(vo.getReviewValidUntil()); 190 data.setReviewValidUntil(vo.getReviewValidUntil());
182 data.setStatus("AUDIT"); 191 data.setStatus("AUDIT");
@@ -206,6 +215,8 @@ public class ProcurementDomesticCustomerCreditServiceImpl @@ -206,6 +215,8 @@ public class ProcurementDomesticCustomerCreditServiceImpl
206 throw new DefaultClientException("采购内贸资信调查表不存在!"); 215 throw new DefaultClientException("采购内贸资信调查表不存在!");
207 } 216 }
208 217
  218 + checkCustomerShortNameUnique(vo.getCustomerShortName(), vo.getId());
  219 +
209 SysUser currentUser = sysUserService.findById(vo.getInvestigatorId()); 220 SysUser currentUser = sysUserService.findById(vo.getInvestigatorId());
210 if (currentUser == null) { 221 if (currentUser == null) {
211 throw new DefaultClientException("资信调查人不存在!"); 222 throw new DefaultClientException("资信调查人不存在!");
@@ -213,6 +224,7 @@ public class ProcurementDomesticCustomerCreditServiceImpl @@ -213,6 +224,7 @@ public class ProcurementDomesticCustomerCreditServiceImpl
213 224
214 data.setId(vo.getId()); 225 data.setId(vo.getId());
215 data.setUnitName(vo.getUnitName()); 226 data.setUnitName(vo.getUnitName());
  227 + data.setCustomerShortName(vo.getCustomerShortName());
216 data.setCompanyNature(vo.getCompanyNature()); 228 data.setCompanyNature(vo.getCompanyNature());
217 data.setBankName(vo.getBankName()); 229 data.setBankName(vo.getBankName());
218 data.setBankAccount(vo.getBankAccount()); 230 data.setBankAccount(vo.getBankAccount());
@@ -326,4 +338,24 @@ public class ProcurementDomesticCustomerCreditServiceImpl @@ -326,4 +338,24 @@ public class ProcurementDomesticCustomerCreditServiceImpl
326 DomesticReviewerDto reviewer = getBaseMapper().getReviewerById(id); 338 DomesticReviewerDto reviewer = getBaseMapper().getReviewerById(id);
327 return reviewer == null ? new DomesticReviewerDto() : reviewer; 339 return reviewer == null ? new DomesticReviewerDto() : reviewer;
328 } 340 }
  341 +
  342 + /**
  343 + * 校验客户简称唯一性
  344 + *
  345 + * @param customerShortName 客户简称
  346 + * @param excludeId 排除的资信ID
  347 + */
  348 + private void checkCustomerShortNameUnique(String customerShortName, String excludeId) {
  349 + LambdaQueryWrapper<ProcurementDomesticCustomerCredit> queryWrapper =
  350 + Wrappers.lambdaQuery(ProcurementDomesticCustomerCredit.class)
  351 + .eq(ProcurementDomesticCustomerCredit::getCustomerShortName, customerShortName);
  352 + if (StringUtils.isNotBlank(excludeId)) {
  353 + queryWrapper.ne(ProcurementDomesticCustomerCredit::getId, excludeId);
  354 + }
  355 +
  356 + Integer count = getBaseMapper().selectCount(queryWrapper);
  357 + if (count != null && count > 0) {
  358 + throw new DefaultClientException("客户简称已存在,请重新输入!");
  359 + }
  360 + }
329 } 361 }
@@ -21,6 +21,11 @@ public class CreateProcurementDomesticCustomerCreditVo implements BaseVo, Serial @@ -21,6 +21,11 @@ public class CreateProcurementDomesticCustomerCreditVo implements BaseVo, Serial
21 @Length(max = 200, message = "单位名称最多允许200个字符!") 21 @Length(max = 200, message = "单位名称最多允许200个字符!")
22 private String unitName; 22 private String unitName;
23 23
  24 + @ApiModelProperty(value = "客户简称", required = true)
  25 + @NotBlank(message = "客户简称不能为空!")
  26 + @Length(max = 200, message = "客户简称最多允许200个字符!")
  27 + private String customerShortName;
  28 +
24 @ApiModelProperty(value = "公司性质", required = true) 29 @ApiModelProperty(value = "公司性质", required = true)
25 @NotBlank(message = "公司性质不能为空!") 30 @NotBlank(message = "公司性质不能为空!")
26 @Length(max = 200, message = "公司性质最多允许200个字符!") 31 @Length(max = 200, message = "公司性质最多允许200个字符!")
@@ -212,9 +217,6 @@ public class CreateProcurementDomesticCustomerCreditVo implements BaseVo, Serial @@ -212,9 +217,6 @@ public class CreateProcurementDomesticCustomerCreditVo implements BaseVo, Serial
212 @Length(max = 65535, message = "附件文件名称集合内容过长!") 217 @Length(max = 65535, message = "附件文件名称集合内容过长!")
213 private String attachmentFileNames; 218 private String attachmentFileNames;
214 219
215 - /**  
216 - * 资信调查人ID  
217 - */  
218 @ApiModelProperty("资信调查人ID") 220 @ApiModelProperty("资信调查人ID")
219 @NotBlank(message = "资信调查人ID!") 221 @NotBlank(message = "资信调查人ID!")
220 @Length(max = 200, message = "资信调查人ID内容过长!") 222 @Length(max = 200, message = "资信调查人ID内容过长!")
@@ -15,6 +15,9 @@ public class QueryProcurementDomesticCustomerCreditVo extends PageVo implements @@ -15,6 +15,9 @@ public class QueryProcurementDomesticCustomerCreditVo extends PageVo implements
15 @ApiModelProperty("单位名称") 15 @ApiModelProperty("单位名称")
16 private String unitName; 16 private String unitName;
17 17
  18 + @ApiModelProperty("客户简称")
  19 + private String customerShortName;
  20 +
18 @ApiModelProperty("公司性质") 21 @ApiModelProperty("公司性质")
19 private String companyNature; 22 private String companyNature;
20 23
@@ -29,6 +29,11 @@ public class UpdateProcurementDomesticCustomerCreditVo implements BaseVo, Serial @@ -29,6 +29,11 @@ public class UpdateProcurementDomesticCustomerCreditVo implements BaseVo, Serial
29 @Length(max = 200, message = "单位名称最多允许200个字符!") 29 @Length(max = 200, message = "单位名称最多允许200个字符!")
30 private String unitName; 30 private String unitName;
31 31
  32 + @ApiModelProperty(value = "客户简称", required = true)
  33 + @NotBlank(message = "客户简称不能为空!")
  34 + @Length(max = 200, message = "客户简称最多允许200个字符!")
  35 + private String customerShortName;
  36 +
32 @ApiModelProperty(value = "公司性质", required = true) 37 @ApiModelProperty(value = "公司性质", required = true)
33 @NotBlank(message = "公司性质不能为空!") 38 @NotBlank(message = "公司性质不能为空!")
34 @Length(max = 200, message = "公司性质最多允许200个字符!") 39 @Length(max = 200, message = "公司性质最多允许200个字符!")
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 type="com.lframework.xingyun.sc.procurement.entity.ProcurementDomesticCustomerCredit"> 6 type="com.lframework.xingyun.sc.procurement.entity.ProcurementDomesticCustomerCredit">
7 <id column="id" property="id"/> 7 <id column="id" property="id"/>
8 <result column="unit_name" property="unitName"/> 8 <result column="unit_name" property="unitName"/>
  9 + <result column="customer_short_name" property="customerShortName"/>
9 <result column="company_nature" property="companyNature"/> 10 <result column="company_nature" property="companyNature"/>
10 <result column="bank_name" property="bankName"/> 11 <result column="bank_name" property="bankName"/>
11 <result column="bank_account" property="bankAccount"/> 12 <result column="bank_account" property="bankAccount"/>
@@ -67,6 +68,7 @@ @@ -67,6 +68,7 @@
67 SELECT 68 SELECT
68 tb.id, 69 tb.id,
69 tb.unit_name, 70 tb.unit_name,
  71 + tb.customer_short_name,
70 tb.company_nature, 72 tb.company_nature,
71 tb.bank_name, 73 tb.bank_name,
72 tb.bank_account, 74 tb.bank_account,
@@ -132,6 +134,9 @@ @@ -132,6 +134,9 @@
132 <if test="vo.unitName != null and vo.unitName != ''"> 134 <if test="vo.unitName != null and vo.unitName != ''">
133 AND tb.unit_name LIKE CONCAT('%', #{vo.unitName}, '%') 135 AND tb.unit_name LIKE CONCAT('%', #{vo.unitName}, '%')
134 </if> 136 </if>
  137 + <if test="vo.customerShortName != null and vo.customerShortName != ''">
  138 + AND tb.customer_short_name LIKE CONCAT('%', #{vo.customerShortName}, '%')
  139 + </if>
135 <if test="vo.companyNature != null and vo.companyNature != ''"> 140 <if test="vo.companyNature != null and vo.companyNature != ''">
136 AND tb.company_nature LIKE CONCAT('%', #{vo.companyNature}, '%') 141 AND tb.company_nature LIKE CONCAT('%', #{vo.companyNature}, '%')
137 </if> 142 </if>