Bläddra i källkod

保存当前工作进度

胡北宽 1 vecka sedan
förälder
incheckning
7c3356361d

+ 29
- 20
src/main/java/com/example/backend/service/contract/impl/SalesContractServiceImpl.java Visa fil

1415
 //                                if (Objects.isNull(entity.getInTaxRate())) {
1415
 //                                if (Objects.isNull(entity.getInTaxRate())) {
1416
 //                                    errors.add("产品明细(Sheet2) 合同号 " + currentSono + " 第 " + (i + 1) + " 行:增值税率不能为空");
1416
 //                                    errors.add("产品明细(Sheet2) 合同号 " + currentSono + " 第 " + (i + 1) + " 行:增值税率不能为空");
1417
 //                                }
1417
 //                                }
1418
-                               // 销售合同产品明细校验
1418
+                                // 销售合同产品明细校验
1419
                                 if (StringUtils.isEmpty(entity1.getFno())) {
1419
                                 if (StringUtils.isEmpty(entity1.getFno())) {
1420
                                     errors.add("产品明细(Sheet2) 第 " + currentRow + " 行:销售合同号不能为空!");
1420
                                     errors.add("产品明细(Sheet2) 第 " + currentRow + " 行:销售合同号不能为空!");
1421
                                 }
1421
                                 }
1702
                         }
1702
                         }
1703
 
1703
 
1704
                         // 单个记录校验
1704
                         // 单个记录校验
1705
+                        boolean hasRCenterErrors = false;
1705
                         for (int i = 0; i < currentRCenterDtlList.size(); i++) {
1706
                         for (int i = 0; i < currentRCenterDtlList.size(); i++) {
1706
                             RCenterDtlExcelDTO dto = currentRCenterDtlList.get(i);
1707
                             RCenterDtlExcelDTO dto = currentRCenterDtlList.get(i);
1707
 
1708
 
1708
-//                            if (StringUtils.isEmpty(dto.getPersonDeptNm())) {
1709
-//                                errors.add("责任中心(Sheet4) 合同号 " + currentSono + " 第 " + (i + 1) + " 行:部门名称不能为空!");
1710
-//                            }
1711
-                            // ... 保持原有的责任中心校验逻辑
1712
                             if (StringUtils.isEmpty(dto.getFno())) {
1709
                             if (StringUtils.isEmpty(dto.getFno())) {
1713
                                 errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:销售合同号不能为空!");
1710
                                 errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:销售合同号不能为空!");
1711
+                                hasRCenterErrors = true;
1714
                             }
1712
                             }
1715
                             if (StringUtils.isEmpty(dto.getPersonDeptNm())) {
1713
                             if (StringUtils.isEmpty(dto.getPersonDeptNm())) {
1716
                                 errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:部门名称不能为空!");
1714
                                 errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:部门名称不能为空!");
1715
+                                hasRCenterErrors = true;
1717
                             }
1716
                             }
1717
+
1718
                             List<CustCtrl> personDeptNmList = custCtrlMapper.selectByPersonDeptNm(dto.getPersonDeptNm());
1718
                             List<CustCtrl> personDeptNmList = custCtrlMapper.selectByPersonDeptNm(dto.getPersonDeptNm());
1719
                             if (personDeptNmList == null || personDeptNmList.isEmpty()) {
1719
                             if (personDeptNmList == null || personDeptNmList.isEmpty()) {
1720
                                 errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:部门名称有误!");
1720
                                 errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:部门名称有误!");
1721
+                                hasRCenterErrors = true;
1721
                             }
1722
                             }
1722
 
1723
 
1723
                             if (personDeptNmList != null && !personDeptNmList.isEmpty() && personDeptNmList.get(0).getDeptCode().isEmpty()) {
1724
                             if (personDeptNmList != null && !personDeptNmList.isEmpty() && personDeptNmList.get(0).getDeptCode().isEmpty()) {
1724
                                 errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:匹配到的部门编码为空");
1725
                                 errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:匹配到的部门编码为空");
1726
+                                hasRCenterErrors = true;
1725
                             }
1727
                             }
1726
 
1728
 
1727
                             if (personDeptNmList != null && !personDeptNmList.isEmpty() && !personDeptNmList.get(0).getDeptCode().isEmpty()) {
1729
                             if (personDeptNmList != null && !personDeptNmList.isEmpty() && !personDeptNmList.get(0).getDeptCode().isEmpty()) {
1728
                                 dto.setPersonDeptId(personDeptNmList.get(0).getDeptCode());
1730
                                 dto.setPersonDeptId(personDeptNmList.get(0).getDeptCode());
1729
                             }
1731
                             }
1730
 
1732
 
1731
-                            if (personDeptNmList != null && !personDeptNmList.isEmpty() && StringUtils.isEmpty(dto.getInstitutionNm())
1732
-                                    && !personDeptNmList.get(0).getCpny().isEmpty()) {
1733
-                                if (dto.getInstitutionNm().equals(personDeptNmList.get(0).getCpny())) {
1733
+                            // 修复公司名称校验逻辑
1734
+                            if (personDeptNmList != null && !personDeptNmList.isEmpty() && !StringUtils.isEmpty(dto.getInstitutionNm())) {
1735
+                                if (!dto.getInstitutionNm().equals(personDeptNmList.get(0).getCpny())) {
1734
                                     errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:公司名称与匹配到的公司名称不一致!");
1736
                                     errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:公司名称与匹配到的公司名称不一致!");
1737
+                                    hasRCenterErrors = true;
1735
                                 }
1738
                                 }
1736
                             }
1739
                             }
1737
 
1740
 
1738
-                            if (personDeptNmList != null && !personDeptNmList.isEmpty() && StringUtils.isEmpty(dto.getInstitutionId())
1739
-                                    && !personDeptNmList.get(0).getFno().isEmpty()) {
1740
-                                if (dto.getInstitutionId().equals(personDeptNmList.get(0).getFno())) {
1741
+                            // 修复公司代码校验逻辑
1742
+                            if (personDeptNmList != null && !personDeptNmList.isEmpty() && !StringUtils.isEmpty(dto.getInstitutionId())) {
1743
+                                if (!dto.getInstitutionId().equals(personDeptNmList.get(0).getFno())) {
1741
                                     errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:公司代码与匹配到的公司代码不一致!");
1744
                                     errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:公司代码与匹配到的公司代码不一致!");
1745
+                                    hasRCenterErrors = true;
1742
                                 }
1746
                                 }
1743
                             }
1747
                             }
1744
 
1748
 
1746
                                 List<SysUser> createByList = sysUserMapper.selectByCreateBy(dto.getCreateBy());
1750
                                 List<SysUser> createByList = sysUserMapper.selectByCreateBy(dto.getCreateBy());
1747
                                 if (createByList == null || createByList.isEmpty()) {
1751
                                 if (createByList == null || createByList.isEmpty()) {
1748
                                     errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:制单人代码有误!");
1752
                                     errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:制单人代码有误!");
1753
+                                    hasRCenterErrors = true;
1749
                                 }
1754
                                 }
1750
 
1755
 
1751
                                 if (createByList != null && !createByList.isEmpty() && createByList.get(0).getId().isEmpty()) {
1756
                                 if (createByList != null && !createByList.isEmpty() && createByList.get(0).getId().isEmpty()) {
1752
                                     errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:制单人代码查到的制单人部门编码为空!");
1757
                                     errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:制单人代码查到的制单人部门编码为空!");
1758
+                                    hasRCenterErrors = true;
1753
                                 }
1759
                                 }
1754
 
1760
 
1755
                                 if (createByList != null && !createByList.isEmpty() && !createByList.get(0).getId().isEmpty()) {
1761
                                 if (createByList != null && !createByList.isEmpty() && !createByList.get(0).getId().isEmpty()) {
1758
 
1764
 
1759
                                 if (createByList != null && !createByList.isEmpty() && createByList.get(0).getDeptName().isEmpty()) {
1765
                                 if (createByList != null && !createByList.isEmpty() && createByList.get(0).getDeptName().isEmpty()) {
1760
                                     errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:制单人代码查到的制单人部门名称为空!");
1766
                                     errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:制单人代码查到的制单人部门名称为空!");
1767
+                                    hasRCenterErrors = true;
1761
                                 }
1768
                                 }
1762
                                 if (createByList != null && !createByList.isEmpty() && !createByList.get(0).getDeptName().isEmpty()) {
1769
                                 if (createByList != null && !createByList.isEmpty() && !createByList.get(0).getDeptName().isEmpty()) {
1763
                                     dto.setDeptName(createByList.get(0).getDeptName());
1770
                                     dto.setDeptName(createByList.get(0).getDeptName());
1766
                                     dto.setCreateByName(createByList.get(0).getUserDesc());
1773
                                     dto.setCreateByName(createByList.get(0).getUserDesc());
1767
                                 }
1774
                                 }
1768
                             }
1775
                             }
1776
+                        }
1769
 
1777
 
1770
-                            // 如果没有错误则插入所有记录
1771
-                            if (errors.stream().noneMatch(error -> error.contains("责任中心(Sheet4) 合同号 " + currentSono))) {
1772
-                                for (RCenterDtlExcelDTO rCenterDtlExcelDTO : currentRCenterDtlList) {
1773
-                                    RCenterDtlEntity entity3 = new RCenterDtlEntity();
1774
-                                    BeanUtils.copyProperties(rCenterDtlExcelDTO, entity3);
1775
-                                    entity3.setRid(mainId);
1776
-                                    rCenterDtlMapper.insert(entity3);
1777
-                                }
1778
+                        // 如果没有错误则插入所有记录 - 移到循环外部
1779
+                        if (!hasRCenterErrors && errors.stream().noneMatch(error -> error.contains("责任中心(Sheet4) 合同号 " + currentSono))) {
1780
+                            for (RCenterDtlExcelDTO rCenterDtlExcelDTO : currentRCenterDtlList) {
1781
+                                RCenterDtlEntity entity3 = new RCenterDtlEntity();
1782
+                                BeanUtils.copyProperties(rCenterDtlExcelDTO, entity3);
1783
+                                entity3.setRid(mainId);
1784
+                                rCenterDtlMapper.insert(entity3);
1778
                             }
1785
                             }
1779
                         }
1786
                         }
1780
 
1787
 
1788
+
1781
                         // ================= 处理费用明细 =================
1789
                         // ================= 处理费用明细 =================
1782
                         List<FeeDtlExcelDTO> currentFeeDtlList = feeDtlList.stream()
1790
                         List<FeeDtlExcelDTO> currentFeeDtlList = feeDtlList.stream()
1783
                                 .filter(dto -> currentSono.equals(dto.getFno()))
1791
                                 .filter(dto -> currentSono.equals(dto.getFno()))
1892
                 }
1900
                 }
1893
             }
1901
             }
1894
 
1902
 
1895
-        } catch (Exception e) {
1903
+        } catch (
1904
+                Exception e) {
1896
             errors.add("系统异常:" + e.getMessage());
1905
             errors.add("系统异常:" + e.getMessage());
1897
         }
1906
         }
1898
 
1907
 

Loading…
Avbryt
Spara