|
|
@@ -54,7 +54,9 @@ public class SalesContractServiceImpl implements SalesContractService {
|
|
54
|
54
|
|
|
55
|
55
|
List<String> errors = new ArrayList<>(); // 用来记录所有错误
|
|
56
|
56
|
|
|
57
|
|
- Long contractId = null;
|
|
|
57
|
+ Long Id = null;
|
|
|
58
|
+ String bizProductType = null;
|
|
|
59
|
+ String bizType = null;
|
|
58
|
60
|
|
|
59
|
61
|
try {
|
|
60
|
62
|
// ================= 主表 =================
|
|
|
@@ -95,7 +97,9 @@ public class SalesContractServiceImpl implements SalesContractService {
|
|
95
|
97
|
if (bizProdictTypeList == null || bizProdictTypeList.isEmpty()) {
|
|
96
|
98
|
errors.add("输入的合同产品类型在数据字典中不存在!");
|
|
97
|
99
|
}
|
|
98
|
|
-
|
|
|
100
|
+ if (bizProdictTypeList != null && !bizProdictTypeList.get(0).getItemValue().isEmpty()) {
|
|
|
101
|
+ bizProductType = bizProdictTypeList.get(0).getItemValue();
|
|
|
102
|
+ }
|
|
99
|
103
|
if (StringUtils.isEmpty(entity.getBizType())) {
|
|
100
|
104
|
errors.add("合同类型不能为空!");
|
|
101
|
105
|
}
|
|
|
@@ -294,27 +298,27 @@ public class SalesContractServiceImpl implements SalesContractService {
|
|
294
|
298
|
if ("代理-主业进口".equals(entity.getServiceType())) {
|
|
295
|
299
|
if (!StringUtils.isEmpty(entity.getAgentNo())) {
|
|
296
|
300
|
List<CustCtrl> agentNoList = custCtrlMapper.selectByAgentNo(entity.getAgentNo());
|
|
297
|
|
- if(agentNoList==null||agentNoList.isEmpty()){
|
|
|
301
|
+ if (agentNoList == null || agentNoList.isEmpty()) {
|
|
298
|
302
|
errors.add("代理采购协议号有误!");
|
|
299
|
303
|
}
|
|
300
|
304
|
}
|
|
301
|
305
|
|
|
302
|
306
|
}
|
|
303
|
307
|
|
|
304
|
|
- if ("代理-主业进口".equals(entity.getServiceType())||"其他/混合分型".equals(entity.getServiceType())) {
|
|
|
308
|
+ if ("代理-主业进口".equals(entity.getServiceType()) || "其他/混合分型".equals(entity.getServiceType())) {
|
|
305
|
309
|
if (!StringUtils.isEmpty(entity.getAgentNo())) {
|
|
306
|
310
|
List<CustCtrl> agentNoSoList = custCtrlMapper.selectByAgentNoSo(entity.getAgentNoSo());
|
|
307
|
|
- if(agentNoSoList==null||agentNoSoList.isEmpty()){
|
|
|
311
|
+ if (agentNoSoList == null || agentNoSoList.isEmpty()) {
|
|
308
|
312
|
errors.add("代理销售协议号 有误!");
|
|
309
|
313
|
}
|
|
310
|
314
|
}
|
|
311
|
315
|
|
|
312
|
316
|
}
|
|
313
|
317
|
|
|
314
|
|
- if ("钢产品".equals(entity.getBizProductType())||"设备备件".equals(entity.getBizProductType())) {
|
|
|
318
|
+ if ("钢产品".equals(entity.getBizProductType()) || "设备备件".equals(entity.getBizProductType())) {
|
|
315
|
319
|
if (!StringUtils.isEmpty(entity.getCommContrNo())) {
|
|
316
|
320
|
List<CustCtrl> commContrNoSoList = custCtrlMapper.selectCommContrNo(entity.getCommContrNo());
|
|
317
|
|
- if(commContrNoSoList==null||commContrNoSoList.isEmpty()){
|
|
|
321
|
+ if (commContrNoSoList == null || commContrNoSoList.isEmpty()) {
|
|
318
|
322
|
errors.add("佣金合同号 有误!");
|
|
319
|
323
|
}
|
|
320
|
324
|
}
|
|
|
@@ -324,7 +328,7 @@ public class SalesContractServiceImpl implements SalesContractService {
|
|
324
|
328
|
if ("铁矿石".equals(entity.getBizProductType())) {
|
|
325
|
329
|
if (!StringUtils.isEmpty(entity.getSettIndex())) {
|
|
326
|
330
|
List<DataDic> settIndexList = dicMapper.selectBySettIndex(entity.getSettIndex());
|
|
327
|
|
- if(settIndexList==null||settIndexList.isEmpty()){
|
|
|
331
|
+ if (settIndexList == null || settIndexList.isEmpty()) {
|
|
328
|
332
|
errors.add("结算指标在数据字典中不存在!");
|
|
329
|
333
|
}
|
|
330
|
334
|
}
|
|
|
@@ -333,8 +337,8 @@ public class SalesContractServiceImpl implements SalesContractService {
|
|
333
|
337
|
|
|
334
|
338
|
|
|
335
|
339
|
salesContractMapper.insert(entity);
|
|
336
|
|
- contractId = entity.getId();
|
|
337
|
|
- if (contractId == null) {
|
|
|
340
|
+ Id = entity.getId();
|
|
|
341
|
+ if (Id == null) {
|
|
338
|
342
|
errors.add("主表ID生成失败(contractId 为 null)!");
|
|
339
|
343
|
}
|
|
340
|
344
|
}
|
|
|
@@ -344,7 +348,7 @@ public class SalesContractServiceImpl implements SalesContractService {
|
|
344
|
348
|
|
|
345
|
349
|
|
|
346
|
350
|
// 如果主表ID 都没生成,后面也插不了,但不能中断,要继续执行
|
|
347
|
|
- final Long cid = contractId;
|
|
|
351
|
+ final Long cid = Id;
|
|
348
|
352
|
|
|
349
|
353
|
|
|
350
|
354
|
// ================= 产品明细 =================
|
|
|
@@ -354,6 +358,135 @@ public class SalesContractServiceImpl implements SalesContractService {
|
|
354
|
358
|
SalesDtlExcelDTO dto = list.size() >= 3 ? list.get(2) : list.get(0);
|
|
355
|
359
|
SalesDtlEntity entity = new SalesDtlEntity();
|
|
356
|
360
|
BeanUtils.copyProperties(dto, entity);
|
|
|
361
|
+ //销售合同产品明细校验
|
|
|
362
|
+ if (StringUtils.isEmpty(entity.getFno())) {
|
|
|
363
|
+ errors.add("销售合同号不能为空! ");
|
|
|
364
|
+ }
|
|
|
365
|
+ if (StringUtils.isEmpty(entity.getItemno())) {
|
|
|
366
|
+ errors.add("商品编号不能为空!");
|
|
|
367
|
+ }
|
|
|
368
|
+ if (Objects.isNull(entity.getInTaxRate())) {
|
|
|
369
|
+ errors.add("增值税率不能为空");
|
|
|
370
|
+
|
|
|
371
|
+ }
|
|
|
372
|
+ if (StringUtils.isEmpty(entity.getUt())) {
|
|
|
373
|
+ errors.add("单位不能为空");
|
|
|
374
|
+ }
|
|
|
375
|
+ if (StringUtils.isEmpty(entity.getSdesc())) {
|
|
|
376
|
+ errors.add("中文品名不能为空");
|
|
|
377
|
+ }
|
|
|
378
|
+
|
|
|
379
|
+
|
|
|
380
|
+ List<CustCtrl> itemnoList = custCtrlMapper.selectByItemno(entity.getItemno(), bizProductType);
|
|
|
381
|
+ if (itemnoList == null || itemnoList.isEmpty()) {
|
|
|
382
|
+ errors.add("商品编号有误!");
|
|
|
383
|
+ }
|
|
|
384
|
+
|
|
|
385
|
+ if (itemnoList != null && Objects.isNull(itemnoList.get(0).getInTaxRate())) {
|
|
|
386
|
+ errors.add("匹配到的增值税率为空!");
|
|
|
387
|
+ }
|
|
|
388
|
+
|
|
|
389
|
+ if (itemnoList != null && !Objects.isNull(itemnoList.get(0).getInTaxRate())) {
|
|
|
390
|
+ if (!Objects.equals(entity.getInTaxRate(), itemnoList.get(0).getInTaxRate())) {
|
|
|
391
|
+ errors.add("输入的增值税率与匹配增值税率不一致!");
|
|
|
392
|
+ }
|
|
|
393
|
+ }
|
|
|
394
|
+
|
|
|
395
|
+ if (itemnoList != null && !Objects.isNull(itemnoList.get(0).getReTaxRate())) {
|
|
|
396
|
+ entity.setReTaxRate(itemnoList.get(0).getReTaxRate());
|
|
|
397
|
+ }
|
|
|
398
|
+
|
|
|
399
|
+ if (itemnoList != null && itemnoList.get(0).getUt().isEmpty()) {
|
|
|
400
|
+ errors.add("匹配到的单位为空!");
|
|
|
401
|
+ }
|
|
|
402
|
+
|
|
|
403
|
+ if (itemnoList != null && !itemnoList.get(0).getUt().isEmpty()) {
|
|
|
404
|
+ if (!entity.getUt().equals(itemnoList.get(0).getUt())) {
|
|
|
405
|
+ errors.add("输入的单位与匹配单位不一致!");
|
|
|
406
|
+ }
|
|
|
407
|
+ }
|
|
|
408
|
+
|
|
|
409
|
+ if (itemnoList != null && itemnoList.get(0).getSdesc().isEmpty()) {
|
|
|
410
|
+ errors.add("匹配到的中文品名为空!");
|
|
|
411
|
+ }
|
|
|
412
|
+
|
|
|
413
|
+ if (itemnoList != null && !itemnoList.get(0).getSdesc().isEmpty()) {
|
|
|
414
|
+ if (!entity.getSdesc().equals(itemnoList.get(0).getSdesc())) {
|
|
|
415
|
+ errors.add("输入的中文品名与匹配到的中文品名不一致!");
|
|
|
416
|
+ }
|
|
|
417
|
+ }
|
|
|
418
|
+
|
|
|
419
|
+ if (itemnoList != null && !itemnoList.get(0).getEdesc().isEmpty()) {
|
|
|
420
|
+ entity.setEdesc(itemnoList.get(0).getEdesc());
|
|
|
421
|
+ }
|
|
|
422
|
+
|
|
|
423
|
+ if (itemnoList != null && !itemnoList.get(0).getHsCode().isEmpty()) {
|
|
|
424
|
+ entity.setHsCode(itemnoList.get(0).getHsCode());
|
|
|
425
|
+ }
|
|
|
426
|
+ if (itemnoList != null && !itemnoList.get(0).getHsNameCn().isEmpty()) {
|
|
|
427
|
+ entity.setHsNameCn(itemnoList.get(0).getHsNameCn());
|
|
|
428
|
+ }
|
|
|
429
|
+ if (itemnoList != null && !itemnoList.get(0).getHsNameEn().isEmpty()) {
|
|
|
430
|
+ entity.setHsNameEn(itemnoList.get(0).getHsNameEn());
|
|
|
431
|
+ }
|
|
|
432
|
+
|
|
|
433
|
+ if (StringUtils.isEmpty(entity.getCurcyPo())) {
|
|
|
434
|
+ errors.add("采购币种不能为空!");
|
|
|
435
|
+ }
|
|
|
436
|
+
|
|
|
437
|
+ List<CustCtrl> curcyList = custCtrlMapper.selectByCurcyPo(entity.getCurcyPo());
|
|
|
438
|
+ if(curcyList ==null||curcyList.isEmpty()){
|
|
|
439
|
+ errors.add("采购币种有误!");
|
|
|
440
|
+ }
|
|
|
441
|
+
|
|
|
442
|
+ if(curcyList !=null&&!curcyList.isEmpty()&&!Objects.isNull(curcyList.get(0).getRate())&&!Objects.isNull(entity.getRatePo())){
|
|
|
443
|
+ if(Objects.equals(entity.getRatePo(), curcyList.get(0).getRate())){
|
|
|
444
|
+ errors.add("采购汇率和匹配到的采购汇率不符!");
|
|
|
445
|
+ }
|
|
|
446
|
+ }
|
|
|
447
|
+
|
|
|
448
|
+
|
|
|
449
|
+
|
|
|
450
|
+ if("铁矿石".equals(bizProductType)){
|
|
|
451
|
+ if(Objects.isNull(entity.getIronCont())){
|
|
|
452
|
+ errors.add("合同产品类型为铁矿石时,含铁量%不能为空!");
|
|
|
453
|
+ }
|
|
|
454
|
+ }
|
|
|
455
|
+
|
|
|
456
|
+ if("铁矿石".equals(bizProductType)||"煤炭".equals(bizProductType)){
|
|
|
457
|
+ if(Objects.isNull(entity.getMoisture())){
|
|
|
458
|
+ errors.add("合同产品类型为铁矿石或煤炭时,水分%不能为空!");
|
|
|
459
|
+ }
|
|
|
460
|
+
|
|
|
461
|
+ if(StringUtils.isEmpty(entity.getPriceMtd())){
|
|
|
462
|
+ errors.add("合同产品类型为铁矿石或煤炭时,计价方式不能为空!");
|
|
|
463
|
+ }
|
|
|
464
|
+
|
|
|
465
|
+ List<DataDic> priceMtdList = dicMapper.selectByPriceMtd(entity.getPriceMtd());
|
|
|
466
|
+ if(priceMtdList==null || priceMtdList.isEmpty()){
|
|
|
467
|
+ errors.add("输入的计价方式在数据字典中不存在!");
|
|
|
468
|
+ }
|
|
|
469
|
+ if(!StringUtils.isEmpty(entity.getResourceNo())){
|
|
|
470
|
+ List<CustCtrl> resourceNoList = custCtrlMapper.selectByResourceNo(entity.getResourceNo(),bizProductType);
|
|
|
471
|
+ if(resourceNoList==null || resourceNoList.isEmpty()){
|
|
|
472
|
+ errors.add("资源号有误!");
|
|
|
473
|
+ }
|
|
|
474
|
+ }
|
|
|
475
|
+
|
|
|
476
|
+ }
|
|
|
477
|
+
|
|
|
478
|
+ if(Objects.isNull(entity.getPoprice())){
|
|
|
479
|
+ errors.add("采购单价不能为空!");
|
|
|
480
|
+ }
|
|
|
481
|
+ if(Objects.isNull(entity.getQty())){
|
|
|
482
|
+ errors.add("数量不能为空!");
|
|
|
483
|
+ }
|
|
|
484
|
+
|
|
|
485
|
+
|
|
|
486
|
+
|
|
|
487
|
+
|
|
|
488
|
+
|
|
|
489
|
+
|
|
357
|
490
|
|
|
358
|
491
|
salesDtlMapper.insert(entity);
|
|
359
|
492
|
}
|