Ver código fonte

1.完成对销售合同产品明细表的检验导入2.完成对收款计划和责任中心的校验导入

胡北宽 1 mês atrás
pai
commit
2e4ff502a9

+ 28
- 0
src/main/java/com/example/backend/entity/common/CustCtrl.java Ver arquivo

@@ -436,6 +436,10 @@ public class CustCtrl {
436 436
     @TableField(exist = false)
437 437
     private String hsNameEn;
438 438
 
439
+    //牌号
440
+    @TableField(exist = false)
441
+    private String brand;
442
+
439 443
     //增值税率
440 444
     @TableField(exist = false)
441 445
     private BigDecimal inTaxRate;
@@ -448,6 +452,30 @@ public class CustCtrl {
448 452
     @TableField(exist = false)
449 453
     private BigDecimal rate;
450 454
 
455
+    //规格代码
456
+    @TableField(exist = false)
457
+    private String steelProductSpecNo;
458
+
459
+    //规格描述
460
+    @TableField(exist = false)
461
+    private String steelProductSpecularity;
462
+
463
+    //米重
464
+    @TableField(exist = false)
465
+    private BigDecimal fnum4;
466
+
467
+    //收款收证银行名称
468
+    @TableField(exist = false)
469
+    private BigDecimal bankNm;
470
+
471
+    //收款收证银行账号
472
+    @TableField(exist = false)
473
+    private BigDecimal bankAcct;
474
+
475
+    //部门编码
476
+    private String deptCdoe;
477
+
478
+
451 479
 
452 480
 
453 481
 

+ 7
- 0
src/main/java/com/example/backend/entity/common/SysUser.java Ver arquivo

@@ -270,6 +270,13 @@ public class SysUser {
270 270
     @TableField(exist = false)
271 271
     private BigDecimal rateUsd;
272 272
 
273
+    //制单人部门编码
274
+    @TableField(exist = false)
275
+    private String deptCode;
276
+
277
+
278
+
279
+
273 280
 
274 281
 
275 282
 }

+ 1
- 1
src/main/java/com/example/backend/entity/contract/SalesCollectMethodEntity.java Ver arquivo

@@ -8,7 +8,7 @@ import java.math.BigDecimal;
8 8
 import java.time.LocalDateTime;
9 9
 
10 10
 /**
11
- * 销售合同收款方式
11
+ * 销售合同收款计划
12 12
  */
13 13
 @Data
14 14
 @TableName("SGGMIIP.salesCollectMethod")

+ 10
- 10
src/main/java/com/example/backend/excel/RCenterDtlExcelDTO.java Ver arquivo

@@ -24,7 +24,7 @@ public class RCenterDtlExcelDTO {
24 24
     @ExcelProperty("责任中心名称")
25 25
     private String respCtrName;
26 26
 
27
-    @ExcelProperty("考核占比")
27
+    @ExcelProperty("金额考核占比%")
28 28
     private BigDecimal assessRatio;
29 29
 
30 30
     @ExcelProperty("占比金额")
@@ -33,7 +33,7 @@ public class RCenterDtlExcelDTO {
33 33
     @ExcelProperty("流程实例id")
34 34
     private String processInstanceId;
35 35
 
36
-    @ExcelProperty("单据号")
36
+    @ExcelProperty("销售合同号")
37 37
     private String fno;
38 38
 
39 39
     @ExcelProperty("单据日期")
@@ -72,7 +72,7 @@ public class RCenterDtlExcelDTO {
72 72
     @ExcelProperty("是否删除")
73 73
     private Integer delFlag;
74 74
 
75
-    @ExcelProperty("创建账号")
75
+    @ExcelProperty("制单人代码")
76 76
     private String createBy;
77 77
 
78 78
     @ExcelProperty("创建时间")
@@ -90,16 +90,16 @@ public class RCenterDtlExcelDTO {
90 90
     @ExcelProperty("更新人")
91 91
     private String updateByName;
92 92
 
93
-    @ExcelProperty("部门名称")
93
+    @ExcelProperty("制单人部门名称")
94 94
     private String deptName;
95 95
 
96
-    @ExcelProperty("部门代码")
96
+    @ExcelProperty("制单人部门代码")
97 97
     private String deptId;
98 98
 
99 99
     @ExcelProperty("当前版本号")
100 100
     private Integer curChangeVer;
101 101
 
102
-    @ExcelProperty("利润占比")
102
+    @ExcelProperty("利润考核占比%")
103 103
     private BigDecimal assessQtyRate;
104 104
 
105 105
     @ExcelProperty("人员代码")
@@ -108,16 +108,16 @@ public class RCenterDtlExcelDTO {
108 108
     @ExcelProperty("人员名称")
109 109
     private String personname;
110 110
 
111
-    @ExcelProperty("人员部门代码")
111
+    @ExcelProperty("部门代码")
112 112
     private String personDeptId;
113 113
 
114
-    @ExcelProperty("人员部门名称")
114
+    @ExcelProperty("部门名称")
115 115
     private String personDeptNm;
116 116
 
117
-    @ExcelProperty("人员公司代码")
117
+    @ExcelProperty("公司代码")
118 118
     private String institutionId;
119 119
 
120
-    @ExcelProperty("人员公司名称")
120
+    @ExcelProperty("公司名称")
121 121
     private String institutionNm;
122 122
 
123 123
     @ExcelProperty("保供合同一键三联id")

+ 5
- 5
src/main/java/com/example/backend/excel/SalesCollectExcelDTO.java Ver arquivo

@@ -7,7 +7,7 @@ import java.math.BigDecimal;
7 7
 import java.time.LocalDateTime;
8 8
 
9 9
 /**
10
- * 销售合同收款方式
10
+ * 销售合同收款计划
11 11
  */
12 12
 @Data
13 13
 public class SalesCollectExcelDTO {
@@ -27,13 +27,13 @@ public class SalesCollectExcelDTO {
27 27
     @ExcelProperty("付款方式")
28 28
     private String payMode;
29 29
 
30
-    @ExcelProperty("条款备注")
30
+    @ExcelProperty("备注")
31 31
     private String clauseRemark;
32 32
 
33 33
     @ExcelProperty("流程实例id")
34 34
     private String processInstanceId;
35 35
 
36
-    @ExcelProperty("单据号")
36
+    @ExcelProperty("销售合同号")
37 37
     private String fno;
38 38
 
39 39
     @ExcelProperty("单据日期")
@@ -105,10 +105,10 @@ public class SalesCollectExcelDTO {
105 105
     @ExcelProperty("账期")
106 106
     private Integer payDays;
107 107
 
108
-    @ExcelProperty("银行名称")
108
+    @ExcelProperty("收款收证银行名称")
109 109
     private String ourBankNm;
110 110
 
111
-    @ExcelProperty("银行账户")
111
+    @ExcelProperty("收款收证银行账户")
112 112
     private String ourBankAcct;
113 113
 
114 114
     @ExcelProperty("来源类型")

+ 10
- 0
src/main/java/com/example/backend/mapper/contract/CustCtrlMapper.java Ver arquivo

@@ -34,4 +34,14 @@ public interface CustCtrlMapper extends BaseMapper<CustCtrl> {
34 34
     List<CustCtrl> selectByResourceNo(@Param("resourceNo") String resourceNo, @Param("bizProductType") String bizProductType);
35 35
 
36 36
 
37
+    List<CustCtrl> selectByFtype3(@Param("ftype3") String ftype3);
38
+
39
+
40
+    List<CustCtrl> selectByOurBankNm(@Param("ourBankNm") String ourBankNm);
41
+
42
+    List<CustCtrl> selectByOurBankAcct(@Param("ourBankAcct") String ourBankAcct);
43
+
44
+    List<CustCtrl> selectByPersonDeptNm(@Param("personDeptNm") String personDeptNm);
45
+
46
+
37 47
 }

+ 1
- 0
src/main/java/com/example/backend/mapper/contract/DicMapper.java Ver arquivo

@@ -30,4 +30,5 @@ public interface DicMapper extends BaseMapper<DataDic> {
30 30
 
31 31
     List<DataDic> selectByPriceMtd(@Param("priceMtd") String priceMtd);
32 32
 
33
+    List<DataDic> selectByFtyped(@Param("ftype4") String ftype4);
33 34
 }

+ 1
- 0
src/main/java/com/example/backend/mapper/contract/SysUserMapper.java Ver arquivo

@@ -38,4 +38,5 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
38 38
     List<SysUser> selectByCurcy(@Param("curcy") String curcy);
39 39
 
40 40
 
41
+    List<SysUser> selectByCreateBy(@Param("createBy") String createBy);
41 42
 }

+ 273
- 28
src/main/java/com/example/backend/service/contract/impl/SalesContractServiceImpl.java Ver arquivo

@@ -15,10 +15,13 @@ import org.springframework.stereotype.Service;
15 15
 import org.springframework.transaction.annotation.Transactional;
16 16
 import org.springframework.web.multipart.MultipartFile;
17 17
 
18
+import java.math.BigDecimal;
18 19
 import java.time.LocalDateTime;
19 20
 import java.util.ArrayList;
20 21
 import java.util.List;
22
+import java.util.Map;
21 23
 import java.util.Objects;
24
+import java.util.stream.Collectors;
22 25
 
23 26
 
24 27
 @Service
@@ -107,6 +110,9 @@ public class SalesContractServiceImpl implements SalesContractService {
107 110
                     if (bizTypeList == null || bizTypeList.isEmpty()) {
108 111
                         errors.add("输入的合同类型在数据字典中不存在!");
109 112
                     }
113
+
114
+                    bizType = bizTypeList.get(0).getItemValue();
115
+
110 116
                     if (StringUtils.isEmpty(entity.getServiceType())) {
111 117
                         errors.add("业务类型不能为空!");
112 118
                     }
@@ -435,57 +441,120 @@ public class SalesContractServiceImpl implements SalesContractService {
435 441
                     }
436 442
 
437 443
                     List<CustCtrl> curcyList = custCtrlMapper.selectByCurcyPo(entity.getCurcyPo());
438
-                    if(curcyList ==null||curcyList.isEmpty()){
444
+                    if (curcyList == null || curcyList.isEmpty()) {
439 445
                         errors.add("采购币种有误!");
440 446
                     }
441 447
 
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())){
448
+                    if (curcyList != null && !curcyList.isEmpty() && !Objects.isNull(curcyList.get(0).getRate()) && !Objects.isNull(entity.getRatePo())) {
449
+                        if (Objects.equals(entity.getRatePo(), curcyList.get(0).getRate())) {
444 450
                             errors.add("采购汇率和匹配到的采购汇率不符!");
445 451
                         }
446 452
                     }
447 453
 
448 454
 
449
-
450
-                    if("铁矿石".equals(bizProductType)){
451
-                        if(Objects.isNull(entity.getIronCont())){
455
+                    if ("铁矿石".equals(bizProductType)) {
456
+                        if (Objects.isNull(entity.getIronCont())) {
452 457
                             errors.add("合同产品类型为铁矿石时,含铁量%不能为空!");
453 458
                         }
454 459
                     }
455 460
 
456
-                    if("铁矿石".equals(bizProductType)||"煤炭".equals(bizProductType)){
457
-                        if(Objects.isNull(entity.getMoisture())){
461
+                    if ("铁矿石".equals(bizProductType) || "煤炭".equals(bizProductType)) {
462
+                        if (Objects.isNull(entity.getMoisture())) {
458 463
                             errors.add("合同产品类型为铁矿石或煤炭时,水分%不能为空!");
459 464
                         }
460 465
 
461
-                        if(StringUtils.isEmpty(entity.getPriceMtd())){
466
+                        if (StringUtils.isEmpty(entity.getPriceMtd())) {
462 467
                             errors.add("合同产品类型为铁矿石或煤炭时,计价方式不能为空!");
463 468
                         }
464 469
 
465
-                        List<DataDic> priceMtdList =   dicMapper.selectByPriceMtd(entity.getPriceMtd());
466
-                        if(priceMtdList==null || priceMtdList.isEmpty()){
470
+                        List<DataDic> priceMtdList = dicMapper.selectByPriceMtd(entity.getPriceMtd());
471
+                        if (priceMtdList == null || priceMtdList.isEmpty()) {
467 472
                             errors.add("输入的计价方式在数据字典中不存在!");
468 473
                         }
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
+                        if (!StringUtils.isEmpty(entity.getResourceNo())) {
475
+                            List<CustCtrl> resourceNoList = custCtrlMapper.selectByResourceNo(entity.getResourceNo(), bizProductType);
476
+                            if (resourceNoList == null || resourceNoList.isEmpty()) {
477
+                                errors.add("资源号有误!");
478
+                            }
474 479
                         }
475 480
 
476 481
                     }
477 482
 
478
-                    if(Objects.isNull(entity.getPoprice())){
483
+                    if (Objects.isNull(entity.getPoprice())) {
479 484
                         errors.add("采购单价不能为空!");
480 485
                     }
481
-                    if(Objects.isNull(entity.getQty())){
486
+                    if (Objects.isNull(entity.getQty())) {
482 487
                         errors.add("数量不能为空!");
483 488
                     }
484 489
 
490
+                    if ("出口销售".equals(bizType) || "转口销售".equals(bizType)) {
491
+                        if (StringUtils.isEmpty(entity.getBatchNo())) {
492
+                            errors.add("合同类型为出口销售或转口销售时,批次号不能为空!");
493
+                        }
494
+                    }
485 495
 
496
+                    if ("钢产品".equals(bizProductType)) {
497
+                        if (StringUtils.isEmpty(entity.getBrand())) {
498
+                            errors.add("合同产品类型为钢产品时,牌号不能为空!");
499
+                        }
500
+                        List<CustCtrl> itemnoList1 = custCtrlMapper.selectByItemno(entity.getItemno(), bizProductType);
501
+                        if (itemnoList1 != null && !itemnoList1.isEmpty() && !itemnoList1.get(0).getBrand().isEmpty()) {
486 502
 
503
+                            if (!entity.getBrand().equals(itemnoList1.get(0).getBrand())) {
504
+                                errors.add("输入的牌号与匹配到的牌号不一致!");
505
+                            }
506
+                        }
487 507
 
508
+                        if (StringUtils.isEmpty(entity.getFtype3())) {
509
+                            errors.add("合同产品类型为钢产品时,规格描述不能为空!");
510
+                        }
488 511
 
512
+                        List<CustCtrl> ftype3List = custCtrlMapper.selectByFtype3(entity.getFtype3());
513
+                        if (ftype3List == null || ftype3List.isEmpty()) {
514
+                            errors.add("输入的规格描述有误!");
515
+
516
+                        }
517
+                        if (ftype3List != null && !ftype3List.isEmpty() && !Objects.isNull(ftype3List.get(0).getFnum4())
518
+                                && !Objects.isNull(entity.getFnum4())) {
519
+                            if (!Objects.equals(entity.getFnum4(), ftype3List.get(0).getFnum4())) {
520
+                                errors.add("输入的米重与匹配到的米重不一致!");
521
+                            }
522
+
523
+                        }
524
+
525
+
526
+                    }
527
+
528
+
529
+                    if (Objects.isNull(entity.getSoPrice())) {
530
+                        errors.add("销售单价不能为空!");
531
+                    }
532
+
533
+                    if (StringUtils.isEmpty(entity.getItemno()) && (entity.getItemno().contains("0111") ||
534
+                            entity.getItemno().contains("0113") || entity.getItemno().contains("0116") || entity.getItemno().contains("0117"))) {
535
+                        if (Objects.isNull(entity.getFnum7())) {
536
+                            errors.add("商品编号包含0111或0113或0116或0117,长不能为空!");
537
+                        }
538
+                    }
539
+
540
+                    if (StringUtils.isEmpty(entity.getItemno()) && (
541
+                            entity.getItemno().contains("0113") || entity.getItemno().contains("0116"))) {
542
+                        if (Objects.isNull(entity.getFnum4())) {
543
+                            errors.add("商品编号包含0113或0116,米重不能为空!");
544
+                        }
545
+                    }
546
+
547
+                    if ("钢产品".equals(bizProductType)) {
548
+                        if (StringUtils.isEmpty(entity.getFtype4())) {
549
+                            errors.add("合同产品类型为钢产品时,计重方式不能为空!");
550
+                        }
551
+
552
+                        List<DataDic> ftype4List = dicMapper.selectByFtyped(entity.getFtype4());
553
+
554
+                        if (ftype4List == null || ftype4List.isEmpty()) {
555
+                            errors.add("输入的计重方式在数据字典中不存在");
556
+                        }
557
+                    }
489 558
 
490 559
 
491 560
                     salesDtlMapper.insert(entity);
@@ -499,11 +568,74 @@ public class SalesContractServiceImpl implements SalesContractService {
499 568
             try {
500 569
                 List<SalesCollectExcelDTO> list = ExcelUtils.readSalesCollectSheet(file);
501 570
                 if (!list.isEmpty() && cid != null) {
502
-                    SalesCollectExcelDTO dto = list.size() >= 3 ? list.get(2) : list.get(0);
503
-                    SalesCollectMethodEntity entity = new SalesCollectMethodEntity();
504
-                    BeanUtils.copyProperties(dto, entity);
505
-//                    entity.setContractId(cid);
506
-                    salesCollectMethodMapper.insert(entity);
571
+                    // 先进行所有校验
572
+                    Map<String, List<SalesCollectExcelDTO>> groupedByFno = list.stream()
573
+                            .filter(dto -> !StringUtils.isEmpty(dto.getFno()))
574
+                            .collect(Collectors.groupingBy(SalesCollectExcelDTO::getFno));
575
+
576
+                    // 校验比例总和
577
+                    for (Map.Entry<String, List<SalesCollectExcelDTO>> entry : groupedByFno.entrySet()) {
578
+                        String fno = entry.getKey();
579
+                        List<SalesCollectExcelDTO> sameContractList = entry.getValue();
580
+
581
+                        BigDecimal totalRatio = sameContractList.stream()
582
+                                .map(dto -> dto.getPaymentRatio() != null ? dto.getPaymentRatio() : BigDecimal.ZERO)
583
+                                .reduce(BigDecimal.ZERO, BigDecimal::add);
584
+
585
+                        if (totalRatio.compareTo(new BigDecimal("100")) != 0) {
586
+                            errors.add("合同号 " + fno + " 的收款比例总和必须为100%,当前总和为:" + totalRatio + "%");
587
+                        }
588
+                    }
589
+
590
+                    // 校验单个记录
591
+                    for (SalesCollectExcelDTO entity : list) {
592
+                        if (StringUtils.isEmpty(entity.getFno())) {
593
+                            errors.add("销售合同号不能为空!");
594
+                        }
595
+
596
+                        if (StringUtils.isEmpty(entity.getPaymentType())) {
597
+                            errors.add("款项类别不能为空!");
598
+                        }
599
+
600
+                        if ("预付款-发货后".equals(entity.getPaymentType()) || "发票后结算款".equals(entity.getPaymentType())) {
601
+                            if (Objects.isNull(entity.getPayDays())) {
602
+                                errors.add("合同号 " + entity.getFno() + " 的款项类别为'预付款-发货后'或'发票后结算款',账期不能为空!");
603
+                            }
604
+                        }
605
+
606
+                        if (StringUtils.isEmpty(entity.getPayMode())) {
607
+                            errors.add("合同号 " + entity.getFno() + " 的收款方式不能为空!");
608
+                        }
609
+
610
+                        if (!StringUtils.isEmpty(entity.getPayMode()) && entity.getPayMode().contains("信用证")) {
611
+                            if (!"发票后结算款".equals(entity.getPaymentType())) {
612
+                                errors.add("合同号 " + entity.getFno() + " 的收款方式是信用证类型的,款项类别必须是发票后结算款!");
613
+                            }
614
+                        }
615
+
616
+                        if (!StringUtils.isEmpty(entity.getOurBankNm())) {
617
+                            List<CustCtrl> ourBankNmList = custCtrlMapper.selectByOurBankNm(entity.getOurBankNm());
618
+                            if (ourBankNmList == null || ourBankNmList.isEmpty()) {
619
+                                errors.add("收款收证银行名称有误!");
620
+                            }
621
+                        }
622
+                        if (!StringUtils.isEmpty(entity.getOurBankAcct())) {
623
+                            List<CustCtrl> ourBankAcctList = custCtrlMapper.selectByOurBankAcct(entity.getOurBankAcct());
624
+                            if (ourBankAcctList == null || ourBankAcctList.isEmpty()) {
625
+                                errors.add("收款收证银行账户有误!");
626
+                            }
627
+                        }
628
+
629
+                    }
630
+
631
+                    // 只有所有校验都通过时才插入所有记录
632
+                    if (errors.isEmpty()) {
633
+                        for (SalesCollectExcelDTO dto : list) {
634
+                            SalesCollectMethodEntity entity = new SalesCollectMethodEntity();
635
+                            BeanUtils.copyProperties(dto, entity);
636
+                            salesCollectMethodMapper.insert(entity);
637
+                        }
638
+                    }
507 639
                 }
508 640
             } catch (Exception e) {
509 641
                 errors.add("收款计划(Sheet3) 导入失败:" + e.getMessage());
@@ -514,11 +646,124 @@ public class SalesContractServiceImpl implements SalesContractService {
514 646
             try {
515 647
                 List<RCenterDtlExcelDTO> list = ExcelUtils.readRCenterDtlSheet(file);
516 648
                 if (!list.isEmpty() && cid != null) {
517
-                    RCenterDtlExcelDTO dto = list.size() >= 3 ? list.get(2) : list.get(0);
518
-                    RCenterDtlEntity entity = new RCenterDtlEntity();
519
-                    BeanUtils.copyProperties(dto, entity);
520
-//                    entity.setContractId(cid);
521
-                    rCenterDtlMapper.insert(entity);
649
+                    // 按合同号分组
650
+                    Map<String, List<RCenterDtlExcelDTO>> groupedByContract = list.stream()
651
+                            .filter(dto -> !StringUtils.isEmpty(dto.getFno()))
652
+                            .collect(Collectors.groupingBy(RCenterDtlExcelDTO::getFno));
653
+
654
+                    // 对每个合同号进行校验
655
+                    for (Map.Entry<String, List<RCenterDtlExcelDTO>> entry : groupedByContract.entrySet()) {
656
+                        String contractNo = entry.getKey();
657
+                        List<RCenterDtlExcelDTO> contractList = entry.getValue();
658
+
659
+                        // 计算该合同号的利润考核占比总和
660
+                        BigDecimal totalAssessQtyRate = contractList.stream()
661
+                                .map(dto -> dto.getAssessQtyRate() != null ? dto.getAssessQtyRate() : BigDecimal.ZERO)
662
+                                .reduce(BigDecimal.ZERO, BigDecimal::add);
663
+
664
+                        // 计算该合同号的金额考核占比总和
665
+                        BigDecimal totalAssessRatio = contractList.stream()
666
+                                .map(dto -> dto.getAssessRatio() != null ? dto.getAssessRatio() : BigDecimal.ZERO)
667
+                                .reduce(BigDecimal.ZERO, BigDecimal::add);
668
+
669
+                        // 校验利润考核占比总和是否为100%
670
+                        if (totalAssessQtyRate.compareTo(new BigDecimal("100")) != 0) {
671
+                            errors.add("合同号 " + contractNo + " 的利润考核占比总和必须为100%,当前总和为:" + totalAssessQtyRate + "%");
672
+                        }
673
+
674
+                        // 校验金额考核占比总和是否为100%
675
+                        if (totalAssessRatio.compareTo(new BigDecimal("100")) != 0) {
676
+                            errors.add("合同号 " + contractNo + " 的金额考核占比总和必须为100%,当前总和为:" + totalAssessRatio + "%");
677
+                        }
678
+                    }
679
+
680
+                    for (RCenterDtlExcelDTO dto : list) {
681
+                        if (StringUtils.isEmpty(dto.getFno())){
682
+                            errors.add("销售合同号不能为空!");
683
+                        }
684
+                        if(StringUtils.isEmpty(dto.getPersonDeptNm())){
685
+                            errors.add("部门名称不能为空!");
686
+                        }
687
+                        List<CustCtrl> personDeptNmList = custCtrlMapper.selectByPersonDeptNm(dto.getPersonDeptNm());
688
+                        if(personDeptNmList == null || personDeptNmList.isEmpty()){
689
+                            errors.add("部门名称有误!");
690
+                        }
691
+
692
+                        if(personDeptNmList!=null&&!personDeptNmList.isEmpty()&& personDeptNmList.get(0).getDeptCdoe().isEmpty()){
693
+                            errors.add("匹配到的部门编码为空");
694
+                        }
695
+
696
+                        if(personDeptNmList!=null&&!personDeptNmList.isEmpty()&& !personDeptNmList.get(0).getDeptCdoe().isEmpty()){
697
+                            dto.setPersonDeptId(personDeptNmList.get(0).getDeptCdoe());
698
+                        }
699
+
700
+                        if(personDeptNmList!=null&&!personDeptNmList.isEmpty()&&StringUtils.isEmpty(dto.getInstitutionNm())
701
+                                && !personDeptNmList.get(0).getCpny().isEmpty()){
702
+                            if(dto.getInstitutionNm().equals(personDeptNmList.get(0).getCpny())){
703
+                                errors.add("公司名称与匹配到的公司名称不一致!");
704
+                            }
705
+                        }
706
+
707
+                        if(personDeptNmList!=null&&!personDeptNmList.isEmpty()&&StringUtils.isEmpty(dto.getInstitutionId())
708
+                                && !personDeptNmList.get(0).getFno().isEmpty()){
709
+                            if(dto.getInstitutionId().equals(personDeptNmList.get(0).getFno())){
710
+                                errors.add("公司代码与匹配到的公司代码不一致!");
711
+                            }
712
+                        }
713
+
714
+                        if(!StringUtils.isEmpty(dto.getCreateBy())){
715
+                            List<SysUser> createByList = sysUserMapper.selectByCreateBy(dto.getCreateBy());
716
+                            if(createByList==null || createByList.isEmpty()){
717
+                                errors.add("制单人代码有误!");
718
+                            }
719
+
720
+                            if(createByList!=null && !createByList.isEmpty()&&createByList.get(0).getDeptCode().isEmpty()){
721
+                                errors.add("制单人代码查到的制单人部门编码为空!");
722
+                            }
723
+
724
+                            if(createByList!=null && !createByList.isEmpty()&&!createByList.get(0).getDeptCode().isEmpty()){
725
+                                dto.setDeptId(createByList.get(0).getDeptCode());
726
+                            }
727
+
728
+                            if(createByList!=null && !createByList.isEmpty()&&createByList.get(0).getDeptName().isEmpty()){
729
+                                errors.add("制单人代码查到的制单人部门名称为空!");
730
+                            }
731
+                            if(createByList!=null && !createByList.isEmpty()&&!createByList.get(0).getDeptName().isEmpty()){
732
+                                dto.setDeptName(createByList.get(0).getDeptName());
733
+
734
+                            }
735
+                            if(createByList!=null && !createByList.isEmpty()&&!createByList.get(0).getUserDesc().isEmpty()){
736
+                                dto.setCreateByName(createByList.get(0).getUserDesc());
737
+
738
+                            }
739
+
740
+
741
+                        }
742
+
743
+
744
+
745
+                    }
746
+
747
+                    // 只有所有校验都通过时才插入所有记录
748
+                    if (errors.isEmpty()) {
749
+                        for (RCenterDtlExcelDTO dto : list) {
750
+                            RCenterDtlEntity entity = new RCenterDtlEntity();
751
+                            BeanUtils.copyProperties(dto, entity);
752
+                            rCenterDtlMapper.insert(entity);
753
+                        }
754
+                    }
755
+
756
+
757
+                    // 如果有错误,不执行插入操作
758
+                    if (errors.isEmpty()) {
759
+                        // 循环插入所有记录
760
+                        for (RCenterDtlExcelDTO dto : list) {
761
+                            RCenterDtlEntity entity = new RCenterDtlEntity();
762
+                            BeanUtils.copyProperties(dto, entity);
763
+                            // entity.setContractId(cid);
764
+                            rCenterDtlMapper.insert(entity);
765
+                        }
766
+                    }
522 767
                 }
523 768
             } catch (Exception e) {
524 769
                 errors.add("责任中心(Sheet4) 导入失败:" + e.getMessage());

+ 42
- 1
src/main/resources/mapper/CustCtrlMapper.xml Ver arquivo

@@ -63,7 +63,8 @@
63 63
         a.hsCode,
64 64
         a.hsNameCn,
65 65
         a.hsNameEn,
66
-        a.inTaxRate
66
+        a.inTaxRate,
67
+        a.brand
67 68
         from SGGMIIP.invitem a
68 69
         left join (select fno, type_name type_name2
69 70
         from SGGMIIP.product_category
@@ -103,4 +104,44 @@
103 104
         and a.fno =#{resourceNo}
104 105
         order by a.fdate desc,a.fno
105 106
     </select>
107
+    <select id="selectByFtype3" resultType="com.example.backend.entity.common.CustCtrl">
108
+        select steelProductSpecNo,steelProductSpecularity,fnum4
109
+        from SGGMIIP.steelProductSpec
110
+        where ifnull(del_flag, 0) != 1
111
+        and steelProductSpecularity =#{ftype3}
112
+    </select>
113
+    <select id="selectByOurBankNm" resultType="com.example.backend.entity.common.CustCtrl">
114
+        select a.bankNm,a.bankAcct
115
+        from SGGMIIP.custbank a
116
+        left join SGGMIIP.addrctrl b on a.rid = b.id
117
+        where ifnull(a.del_flag, 0) != 1
118
+        and a.stopBank='否'
119
+        and a.bankNm =#{ourBankNm}
120
+    </select>
121
+    <select id="selectByOurBankAcct" resultType="com.example.backend.entity.common.CustCtrl">
122
+        select a.bankNm,a.bankAcct
123
+        from SGGMIIP.custbank a
124
+                 left join SGGMIIP.addrctrl b on a.rid = b.id
125
+        where ifnull(a.del_flag, 0) != 1
126
+          and a.stopBank='否'
127
+          and a.bankNm =#{ourBankAcct}
128
+    </select>
129
+    <select id="selectByPersonDeptNm" resultType="com.example.backend.entity.common.CustCtrl">
130
+        SELECT
131
+            t.fno,
132
+            t.cpny,
133
+            t.deptname,
134
+            t.deptcode
135
+        FROM (
136
+                 SELECT DISTINCT
137
+                     c.fno,
138
+                     c.cpny,
139
+                     a.deptname,
140
+                     a.deptcode
141
+                 FROM SGGMIIP.View_Dept_Code a
142
+                          LEFT JOIN SGGMIIP.View_User_Code b ON a.deptid = b.dept_id
143
+                          LEFT JOIN SGGMIIP.addrctrl c ON a.fourscode = c.hrDeptCode
144
+             ) t
145
+        where t.deptname =#{personDeptNm}
146
+    </select>
106 147
 </mapper>

+ 9
- 0
src/main/resources/mapper/DicMapper.xml Ver arquivo

@@ -48,4 +48,13 @@
48 48
           and i.status = '0'
49 49
           and d.status = '0'
50 50
     </select>
51
+    <select id="selectByFtyped" resultType="com.example.backend.entity.common.DataDic">
52
+        select d.dic_name, i.item_value
53
+        from SGGMIIP.data_dic d
54
+                 left join SGGMIIP.data_item i on d.id = i.dic_id
55
+        where i.item_value = #{ftype4}
56
+          and d.dic_name = '计重方式'
57
+          and i.status = '0'
58
+          and d.status = '0'
59
+    </select>
51 60
 </mapper>

+ 10
- 0
src/main/resources/mapper/SysUserMapper.xml Ver arquivo

@@ -34,4 +34,14 @@
34 34
         and a.ctCnNm = #{ctName}
35 35
         order by a.fno
36 36
     </select>
37
+    <select id="selectByCreateBy" resultType="com.example.backend.entity.common.SysUser">
38
+        select a.DEPT_CODE, a.DEPT_NAME,c.user_desc,c.USER_CODE
39
+        from SGGMIIP.SYS_DEPARTMENT a
40
+                 join SGGMIIP.SYS_USER_DEPARTMENT b on a.id = b.DEPT_ID
41
+                 join SGGMIIP.SYS_USER c on b.USER_ID = c.id
42
+        where c.USER_CODE = #{createBy}
43
+          and a.cancel_flag = '0'
44
+          and b.cancel_flag = '0'
45
+          and c.cancel_flag = '0'
46
+    </select>
37 47
 </mapper>

Carregando…
Cancelar
Salvar