|
|
@@ -4,7 +4,10 @@ import com.alibaba.excel.EasyExcel;
|
|
4
|
4
|
import com.alibaba.excel.context.AnalysisContext;
|
|
5
|
5
|
import com.alibaba.excel.event.AnalysisEventListener;
|
|
6
|
6
|
import com.alibaba.excel.exception.ExcelDataConvertException;
|
|
|
7
|
+import com.example.backend.entity.common.SysUser;
|
|
|
8
|
+import com.example.backend.mapper.contract.SysUserMapper;
|
|
7
|
9
|
import com.example.backend.pAndSExe.dto.*;
|
|
|
10
|
+import com.example.backend.pAndSExe.mapper.GongyingshangMapper;
|
|
8
|
11
|
import com.example.backend.pAndSExe.mapper.InfExe1AmountMapper;
|
|
9
|
12
|
import com.example.backend.pAndSExe.mapper.InfExe1Mapper;
|
|
10
|
13
|
import com.example.backend.pAndSExe.mapper.ShangpinkuMapper;
|
|
|
@@ -45,6 +48,9 @@ public class PsExeExcelUtil {
|
|
45
|
48
|
@Autowired
|
|
46
|
49
|
private ShangpinkuMapper shangpinkuMapper;
|
|
47
|
50
|
|
|
|
51
|
+ @Autowired
|
|
|
52
|
+ private GongyingshangMapper gongyingshangMapper;
|
|
|
53
|
+
|
|
48
|
54
|
|
|
49
|
55
|
// 日期格式化器
|
|
50
|
56
|
private final String[] DATE_FORMATS = {"yyyy-MM-dd", "yyyy.MM.dd", "yyyy/MM/dd"};
|
|
|
@@ -607,14 +613,20 @@ public class PsExeExcelUtil {
|
|
607
|
613
|
if (dto.getCombinedPaymentInfo() == null || dto.getCombinedPaymentInfo().trim().isEmpty()) {
|
|
608
|
614
|
errorLogList.add("收款/受益人名称+银行名称+银行账号为空");
|
|
609
|
615
|
}else {
|
|
610
|
|
- if (dto.getCombinedPaymentInfo().contains(",")||dto.getCombinedPaymentInfo().contains(",")) {
|
|
611
|
|
- String[] strings = splitCombinedField(dto.getCombinedPaymentInfo());
|
|
612
|
|
- if ("无".equals(strings[1]) || "无".equals(strings[2])) {
|
|
|
616
|
+ String[] strings = splitCombinedField(dto.getCombinedPaymentInfo());
|
|
|
617
|
+ if (strings.length<3) {
|
|
|
618
|
+ errorLogList.add("收款人名称+收款人银行+银行账号格式不正确");
|
|
|
619
|
+ }else {
|
|
|
620
|
+ Gongyingshang gongyingshang = gongyingshangMapper.selectGongyingshangByName(strings[0]);
|
|
|
621
|
+ if (gongyingshang == null) {
|
|
|
622
|
+ errorLogList.add("供应商名称没有审批通过,需要先申请供应商; ");
|
|
|
623
|
+ }
|
|
|
624
|
+ else if ("无".equals(strings[1]) || "无".equals(strings[2]) || "".equals(gongyingshang.getCtBankAcct())||gongyingshang.getCtBankAcct()==null) {
|
|
613
|
625
|
errorLogList.add("银行名称/账号为空,需要申请客商银行信息");
|
|
614
|
626
|
}
|
|
615
|
|
- }else {
|
|
616
|
|
- errorLogList.add("收款/受益人信息格式错误,请按照收款/受益人名称+银行名称+银行账号格式填写,不可缺少");
|
|
617
|
627
|
}
|
|
|
628
|
+
|
|
|
629
|
+
|
|
618
|
630
|
}
|
|
619
|
631
|
|
|
620
|
632
|
// 付款类型:非空校验
|
|
|
@@ -732,9 +744,19 @@ public class PsExeExcelUtil {
|
|
732
|
744
|
}
|
|
733
|
745
|
else {
|
|
734
|
746
|
String[] strings = splitCombinedField(dto.getCombinedSuppInfo());
|
|
735
|
|
- if("无".equals(strings[1])||"无".equals(strings[2])){
|
|
736
|
|
- errorLogList.add("银行名称/账号为空,需要申请客商银行信息");
|
|
|
747
|
+ if (strings.length<3) {
|
|
|
748
|
+ errorLogList.add("收款人名称+收款人银行+银行账号格式不正确");
|
|
|
749
|
+ }else {
|
|
|
750
|
+ Gongyingshang gongyingshang = gongyingshangMapper.selectGongyingshangByName(strings[0]);
|
|
|
751
|
+ if (gongyingshang == null) {
|
|
|
752
|
+ errorLogList.add("供应商名称没有审批通过,需要先申请供应商; ");
|
|
|
753
|
+ }
|
|
|
754
|
+ else if ("无".equals(strings[1]) || "无".equals(strings[2]) || "".equals(gongyingshang.getCtBankAcct())||gongyingshang.getCtBankAcct()==null) {
|
|
|
755
|
+ errorLogList.add("银行名称/账号为空,需要申请客商银行信息");
|
|
|
756
|
+ }
|
|
737
|
757
|
}
|
|
|
758
|
+
|
|
|
759
|
+
|
|
738
|
760
|
}
|
|
739
|
761
|
|
|
740
|
762
|
// 付款方式:非空校验(和Exe3一致)
|
|
|
@@ -1148,8 +1170,6 @@ public class PsExeExcelUtil {
|
|
1148
|
1170
|
// 金额:非空 + 正数校验
|
|
1149
|
1171
|
if (dto.getAmount() == null) {
|
|
1150
|
1172
|
errorLogList.add("金额为空");
|
|
1151
|
|
- } else if (dto.getAmount() <= 0) {
|
|
1152
|
|
- errorLogList.add("金额必须大于0,当前值:" + dto.getAmount());
|
|
1153
|
1173
|
}
|
|
1154
|
1174
|
|
|
1155
|
1175
|
// 3. 构建错误日志
|
|
|
@@ -1232,25 +1252,36 @@ public class PsExeExcelUtil {
|
|
1232
|
1252
|
} else {
|
|
1233
|
1253
|
// 拆分规则:按第一个空格/逗号拆分,左侧为编号,右侧为名称
|
|
1234
|
1254
|
|
|
1235
|
|
- String[] ctArr = ctNoCtName.split("[,\\s]+", 2);
|
|
|
1255
|
+ String[] ctArr = ctNoCtName.split("[-,\\s]+");
|
|
|
1256
|
+
|
|
|
1257
|
+ if (ctArr.length<2) {
|
|
|
1258
|
+ errorLogList.add("客户编号+客户名称格式不正确");
|
|
|
1259
|
+ }else {
|
|
|
1260
|
+ Gongyingshang gongyingshang = gongyingshangMapper.selectGongyingshangByFno(ctArr[0].trim());
|
|
|
1261
|
+ if (gongyingshang == null) {
|
|
|
1262
|
+ errorLogList.add("供应商没有,需要先申请供应商; ");
|
|
|
1263
|
+ }
|
|
|
1264
|
+ else if (!ctArr[1].trim().equals(gongyingshang.getCtCnNm())) {
|
|
|
1265
|
+ errorLogList.add("客商编码和客商名称不匹配");
|
|
|
1266
|
+ }
|
|
|
1267
|
+ }
|
|
1236
|
1268
|
if (ctArr.length >= 1) {
|
|
1237
|
1269
|
ctNo = ctArr[0];
|
|
1238
|
1270
|
ctName = ctArr.length == 2 ? ctArr[1] : "";
|
|
1239
|
1271
|
}
|
|
1240
|
|
- if (ctNo.isEmpty()) {
|
|
1241
|
|
- errorLogList.add("客户编号解析失败,原始值:" + ctNoCtName);
|
|
1242
|
|
- }
|
|
1243
|
1272
|
}
|
|
1244
|
1273
|
|
|
|
1274
|
+
|
|
|
1275
|
+
|
|
1245
|
1276
|
// 认领金额:非空 + 正数校验
|
|
1246
|
1277
|
BigDecimal claimedAmt = BigDecimal.ZERO;
|
|
1247
|
1278
|
if (dto.getClaimedAmt() == null) {
|
|
1248
|
1279
|
errorLogList.add("认领金额为空");
|
|
1249
|
1280
|
} else {
|
|
1250
|
1281
|
claimedAmt = BigDecimal.valueOf(dto.getClaimedAmt()).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
1251
|
|
- if (claimedAmt.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
1282
|
+ /*if (claimedAmt.compareTo(BigDecimal.ZERO) <= 0) {
|
|
1252
|
1283
|
errorLogList.add("认领金额必须大于0,当前值:" + dto.getClaimedAmt());
|
|
1253
|
|
- }
|
|
|
1284
|
+ }*/
|
|
1254
|
1285
|
}
|
|
1255
|
1286
|
|
|
1256
|
1287
|
// 币别:非空校验
|
|
|
@@ -1419,9 +1450,9 @@ public class PsExeExcelUtil {
|
|
1419
|
1450
|
errorLogList.add("数量为空");
|
|
1420
|
1451
|
} else {
|
|
1421
|
1452
|
qty = BigDecimal.valueOf(dto.getQty()).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
1422
|
|
- if (qty.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
1453
|
+ /* if (qty.compareTo(BigDecimal.ZERO) <= 0) {
|
|
1423
|
1454
|
errorLogList.add("数量必须大于0,当前值:" + dto.getQty());
|
|
1424
|
|
- }
|
|
|
1455
|
+ }*/
|
|
1425
|
1456
|
}
|
|
1426
|
1457
|
|
|
1427
|
1458
|
// -------------------- 金额校验(非空+正数) --------------------
|
|
|
@@ -1430,9 +1461,9 @@ public class PsExeExcelUtil {
|
|
1430
|
1461
|
errorLogList.add("含税金额为空");
|
|
1431
|
1462
|
} else {
|
|
1432
|
1463
|
soamt = BigDecimal.valueOf(dto.getSoamt()).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
1433
|
|
- if (soamt.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
1464
|
+ /*if (soamt.compareTo(BigDecimal.ZERO) <= 0) {
|
|
1434
|
1465
|
errorLogList.add("金额必须大于0,当前值:" + dto.getSoamt());
|
|
1435
|
|
- }
|
|
|
1466
|
+ }*/
|
|
1436
|
1467
|
}
|
|
1437
|
1468
|
|
|
1438
|
1469
|
BigDecimal ntSoAmt = BigDecimal.ZERO;
|
|
|
@@ -1440,9 +1471,9 @@ public class PsExeExcelUtil {
|
|
1440
|
1471
|
errorLogList.add("不含税金额为空");
|
|
1441
|
1472
|
} else {
|
|
1442
|
1473
|
ntSoAmt = BigDecimal.valueOf(dto.getNtSoAmt()).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
1443
|
|
- if (soamt.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
1474
|
+ /*if (soamt.compareTo(BigDecimal.ZERO) <= 0) {
|
|
1444
|
1475
|
errorLogList.add("金额必须大于0,当前值:" + dto.getSoamt());
|
|
1445
|
|
- }
|
|
|
1476
|
+ }*/
|
|
1446
|
1477
|
}
|
|
1447
|
1478
|
|
|
1448
|
1479
|
// -------------------- 销项税率校验(非空+0-100之间) --------------------
|
|
|
@@ -1713,18 +1744,18 @@ public class PsExeExcelUtil {
|
|
1713
|
1744
|
errorLogList.add("金额为空");
|
|
1714
|
1745
|
} else {
|
|
1715
|
1746
|
soamt = BigDecimal.valueOf(dto.getSoamt()).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
1716
|
|
- if (soamt.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
1747
|
+ /*if (soamt.compareTo(BigDecimal.ZERO) <= 0) {
|
|
1717
|
1748
|
errorLogList.add("金额必须大于0,当前值:" + dto.getSoamt());
|
|
1718
|
|
- }
|
|
|
1749
|
+ }*/
|
|
1719
|
1750
|
}
|
|
1720
|
1751
|
BigDecimal ntSoAmt = BigDecimal.ZERO;
|
|
1721
|
1752
|
if (dto.getNtSoAmt() == null) {
|
|
1722
|
1753
|
errorLogList.add("不含税金额为空");
|
|
1723
|
1754
|
} else {
|
|
1724
|
1755
|
ntSoAmt = BigDecimal.valueOf(dto.getNtSoAmt()).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
1725
|
|
- if (soamt.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
1756
|
+ /*if (soamt.compareTo(BigDecimal.ZERO) <= 0) {
|
|
1726
|
1757
|
errorLogList.add("金额必须大于0,当前值:" + dto.getSoamt());
|
|
1727
|
|
- }
|
|
|
1758
|
+ }*/
|
|
1728
|
1759
|
}
|
|
1729
|
1760
|
|
|
1730
|
1761
|
|