|
|
@@ -1415,7 +1415,7 @@ public class SalesContractServiceImpl implements SalesContractService {
|
|
1415
|
1415
|
// if (Objects.isNull(entity.getInTaxRate())) {
|
|
1416
|
1416
|
// errors.add("产品明细(Sheet2) 合同号 " + currentSono + " 第 " + (i + 1) + " 行:增值税率不能为空");
|
|
1417
|
1417
|
// }
|
|
1418
|
|
- // 销售合同产品明细校验
|
|
|
1418
|
+ // 销售合同产品明细校验
|
|
1419
|
1419
|
if (StringUtils.isEmpty(entity1.getFno())) {
|
|
1420
|
1420
|
errors.add("产品明细(Sheet2) 第 " + currentRow + " 行:销售合同号不能为空!");
|
|
1421
|
1421
|
}
|
|
|
@@ -1702,43 +1702,47 @@ public class SalesContractServiceImpl implements SalesContractService {
|
|
1702
|
1702
|
}
|
|
1703
|
1703
|
|
|
1704
|
1704
|
// 单个记录校验
|
|
|
1705
|
+ boolean hasRCenterErrors = false;
|
|
1705
|
1706
|
for (int i = 0; i < currentRCenterDtlList.size(); i++) {
|
|
1706
|
1707
|
RCenterDtlExcelDTO dto = currentRCenterDtlList.get(i);
|
|
1707
|
1708
|
|
|
1708
|
|
-// if (StringUtils.isEmpty(dto.getPersonDeptNm())) {
|
|
1709
|
|
-// errors.add("责任中心(Sheet4) 合同号 " + currentSono + " 第 " + (i + 1) + " 行:部门名称不能为空!");
|
|
1710
|
|
-// }
|
|
1711
|
|
- // ... 保持原有的责任中心校验逻辑
|
|
1712
|
1709
|
if (StringUtils.isEmpty(dto.getFno())) {
|
|
1713
|
1710
|
errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:销售合同号不能为空!");
|
|
|
1711
|
+ hasRCenterErrors = true;
|
|
1714
|
1712
|
}
|
|
1715
|
1713
|
if (StringUtils.isEmpty(dto.getPersonDeptNm())) {
|
|
1716
|
1714
|
errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:部门名称不能为空!");
|
|
|
1715
|
+ hasRCenterErrors = true;
|
|
1717
|
1716
|
}
|
|
|
1717
|
+
|
|
1718
|
1718
|
List<CustCtrl> personDeptNmList = custCtrlMapper.selectByPersonDeptNm(dto.getPersonDeptNm());
|
|
1719
|
1719
|
if (personDeptNmList == null || personDeptNmList.isEmpty()) {
|
|
1720
|
1720
|
errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:部门名称有误!");
|
|
|
1721
|
+ hasRCenterErrors = true;
|
|
1721
|
1722
|
}
|
|
1722
|
1723
|
|
|
1723
|
1724
|
if (personDeptNmList != null && !personDeptNmList.isEmpty() && personDeptNmList.get(0).getDeptCode().isEmpty()) {
|
|
1724
|
1725
|
errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:匹配到的部门编码为空");
|
|
|
1726
|
+ hasRCenterErrors = true;
|
|
1725
|
1727
|
}
|
|
1726
|
1728
|
|
|
1727
|
1729
|
if (personDeptNmList != null && !personDeptNmList.isEmpty() && !personDeptNmList.get(0).getDeptCode().isEmpty()) {
|
|
1728
|
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
|
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
|
1744
|
errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:公司代码与匹配到的公司代码不一致!");
|
|
|
1745
|
+ hasRCenterErrors = true;
|
|
1742
|
1746
|
}
|
|
1743
|
1747
|
}
|
|
1744
|
1748
|
|
|
|
@@ -1746,10 +1750,12 @@ public class SalesContractServiceImpl implements SalesContractService {
|
|
1746
|
1750
|
List<SysUser> createByList = sysUserMapper.selectByCreateBy(dto.getCreateBy());
|
|
1747
|
1751
|
if (createByList == null || createByList.isEmpty()) {
|
|
1748
|
1752
|
errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:制单人代码有误!");
|
|
|
1753
|
+ hasRCenterErrors = true;
|
|
1749
|
1754
|
}
|
|
1750
|
1755
|
|
|
1751
|
1756
|
if (createByList != null && !createByList.isEmpty() && createByList.get(0).getId().isEmpty()) {
|
|
1752
|
1757
|
errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:制单人代码查到的制单人部门编码为空!");
|
|
|
1758
|
+ hasRCenterErrors = true;
|
|
1753
|
1759
|
}
|
|
1754
|
1760
|
|
|
1755
|
1761
|
if (createByList != null && !createByList.isEmpty() && !createByList.get(0).getId().isEmpty()) {
|
|
|
@@ -1758,6 +1764,7 @@ public class SalesContractServiceImpl implements SalesContractService {
|
|
1758
|
1764
|
|
|
1759
|
1765
|
if (createByList != null && !createByList.isEmpty() && createByList.get(0).getDeptName().isEmpty()) {
|
|
1760
|
1766
|
errors.add("责任中心(Sheet4) 第 " + currentRow + " 行:制单人代码查到的制单人部门名称为空!");
|
|
|
1767
|
+ hasRCenterErrors = true;
|
|
1761
|
1768
|
}
|
|
1762
|
1769
|
if (createByList != null && !createByList.isEmpty() && !createByList.get(0).getDeptName().isEmpty()) {
|
|
1763
|
1770
|
dto.setDeptName(createByList.get(0).getDeptName());
|
|
|
@@ -1766,18 +1773,19 @@ public class SalesContractServiceImpl implements SalesContractService {
|
|
1766
|
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
|
1790
|
List<FeeDtlExcelDTO> currentFeeDtlList = feeDtlList.stream()
|
|
1783
|
1791
|
.filter(dto -> currentSono.equals(dto.getFno()))
|
|
|
@@ -1892,7 +1900,8 @@ public class SalesContractServiceImpl implements SalesContractService {
|
|
1892
|
1900
|
}
|
|
1893
|
1901
|
}
|
|
1894
|
1902
|
|
|
1895
|
|
- } catch (Exception e) {
|
|
|
1903
|
+ } catch (
|
|
|
1904
|
+ Exception e) {
|
|
1896
|
1905
|
errors.add("系统异常:" + e.getMessage());
|
|
1897
|
1906
|
}
|
|
1898
|
1907
|
|