Commit 0176bd1069c7f1a819722774ca34778cc17089a8

Authored by 房远帅
1 parent 43f8eea2

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

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