|
|
@@ -36,6 +36,7 @@ import java.text.SimpleDateFormat;
|
|
36
|
36
|
import java.util.*;
|
|
37
|
37
|
import java.util.regex.Matcher;
|
|
38
|
38
|
import java.util.regex.Pattern;
|
|
|
39
|
+import java.util.stream.Collectors;
|
|
39
|
40
|
|
|
40
|
41
|
/**
|
|
41
|
42
|
* 台账合并Excel一键全量导入实现
|
|
|
@@ -230,6 +231,13 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
|
|
230
|
231
|
o.setAreaId(areaId);
|
|
231
|
232
|
}
|
|
232
|
233
|
}
|
|
|
234
|
+ String channelNo = o.getChannelNo();
|
|
|
235
|
+ if (channelNo != null && !channelNo.trim().isEmpty()) {
|
|
|
236
|
+ Long channelId = importCache.getChannelIdByName(channelNo.trim());
|
|
|
237
|
+ if (channelId != null) {
|
|
|
238
|
+ o.setChannelId(channelId);
|
|
|
239
|
+ }
|
|
|
240
|
+ }
|
|
233
|
241
|
}
|
|
234
|
242
|
|
|
235
|
243
|
o.setImportBatch(batchNo);
|
|
|
@@ -373,6 +381,15 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
|
|
373
|
381
|
o.setAreaId(areaId);
|
|
374
|
382
|
}
|
|
375
|
383
|
}
|
|
|
384
|
+
|
|
|
385
|
+ String channelNo = o.getChannelNo();
|
|
|
386
|
+ if (channelNo != null && !channelNo.trim().isEmpty()) {
|
|
|
387
|
+ Long channelId = importCache.getChannelIdByName(channelNo.trim());
|
|
|
388
|
+ if (channelId != null) {
|
|
|
389
|
+ o.setChannelId(channelId);
|
|
|
390
|
+ }
|
|
|
391
|
+ }
|
|
|
392
|
+
|
|
376
|
393
|
}
|
|
377
|
394
|
|
|
378
|
395
|
o.setImportBatch(batchNo);
|
|
|
@@ -442,6 +459,14 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
|
|
442
|
459
|
o.setAreaId(areaId);
|
|
443
|
460
|
}
|
|
444
|
461
|
}
|
|
|
462
|
+ //通道
|
|
|
463
|
+ String channelNo = o.getChannelNo();
|
|
|
464
|
+ if (channelNo != null && !channelNo.trim().isEmpty()) {
|
|
|
465
|
+ Long channelId = importCache.getChannelIdByName(channelNo.trim());
|
|
|
466
|
+ if (channelId != null) {
|
|
|
467
|
+ o.setChannelId(channelId);
|
|
|
468
|
+ }
|
|
|
469
|
+ }
|
|
445
|
470
|
}
|
|
446
|
471
|
|
|
447
|
472
|
o.setImportBatch(batchNo);
|
|
|
@@ -553,6 +578,16 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
|
|
553
|
578
|
o.setAreaId(areaId);
|
|
554
|
579
|
}
|
|
555
|
580
|
}
|
|
|
581
|
+
|
|
|
582
|
+ //通道
|
|
|
583
|
+ String channelNo = o.getChannel();
|
|
|
584
|
+ if (channelNo != null && !channelNo.trim().isEmpty()) {
|
|
|
585
|
+ Long channelId = importCache.getChannelIdByName(channelNo.trim());
|
|
|
586
|
+ if (channelId != null) {
|
|
|
587
|
+ o.setChannelId(channelId);
|
|
|
588
|
+ }
|
|
|
589
|
+ }
|
|
|
590
|
+
|
|
556
|
591
|
}
|
|
557
|
592
|
|
|
558
|
593
|
o.setImportBatch(batchNo);
|
|
|
@@ -734,6 +769,16 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
|
|
734
|
769
|
o.setAreaId(areaId);
|
|
735
|
770
|
}
|
|
736
|
771
|
}
|
|
|
772
|
+
|
|
|
773
|
+ //通道
|
|
|
774
|
+ String channelNo = o.getChannelNo();
|
|
|
775
|
+ if (channelNo != null && !channelNo.trim().isEmpty()) {
|
|
|
776
|
+ Long channelId = importCache.getChannelIdByName(channelNo.trim());
|
|
|
777
|
+ if (channelId != null) {
|
|
|
778
|
+ o.setChannelId(channelId);
|
|
|
779
|
+ }
|
|
|
780
|
+ }
|
|
|
781
|
+
|
|
737
|
782
|
}
|
|
738
|
783
|
|
|
739
|
784
|
o.setImportBatch(batchNo);
|
|
|
@@ -1239,7 +1284,19 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
|
|
1239
|
1284
|
|
|
1240
|
1285
|
private String str(Object[] c, int idx) {
|
|
1241
|
1286
|
if (idx >= c.length || c[idx] == null) return null;
|
|
1242
|
|
- String s = c[idx].toString().trim();
|
|
|
1287
|
+ Object value = c[idx];
|
|
|
1288
|
+ String s;
|
|
|
1289
|
+ // 处理数字类型,去除 .0 后缀
|
|
|
1290
|
+ if (value instanceof Double) {
|
|
|
1291
|
+ Double d = (Double) value;
|
|
|
1292
|
+ if (d == d.longValue()) {
|
|
|
1293
|
+ s = String.valueOf(d.longValue());
|
|
|
1294
|
+ } else {
|
|
|
1295
|
+ s = d.toString();
|
|
|
1296
|
+ }
|
|
|
1297
|
+ } else {
|
|
|
1298
|
+ s = value.toString().trim();
|
|
|
1299
|
+ }
|
|
1243
|
1300
|
return s.isEmpty() ? null : s;
|
|
1244
|
1301
|
}
|
|
1245
|
1302
|
|
|
|
@@ -1372,13 +1429,16 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
|
|
1372
|
1429
|
private final Map<Long, SysDept> deptCache; // Map<部门ID, 部门>
|
|
1373
|
1430
|
private final Map<String, Long> positionCache; // Map<岗位名称, 岗位ID>
|
|
1374
|
1431
|
private final Map<String, Long> areaCache; // Map<区域名称, 区域ID>
|
|
|
1432
|
+ private final Map<String, Long> channelCache; // Map<渠道名称, 渠道ID>
|
|
1375
|
1433
|
|
|
1376
|
1434
|
public ImportCache(Map<String, SysUser> userCache, Map<Long, SysDept> deptCache,
|
|
1377
|
|
- Map<String, Long> positionCache, Map<String, Long> areaCache) {
|
|
|
1435
|
+ Map<String, Long> positionCache, Map<String, Long> areaCache, Map<String, Long> channelCache
|
|
|
1436
|
+ ) {
|
|
1378
|
1437
|
this.userCache = userCache;
|
|
1379
|
1438
|
this.deptCache = deptCache;
|
|
1380
|
1439
|
this.positionCache = positionCache;
|
|
1381
|
1440
|
this.areaCache = areaCache;
|
|
|
1441
|
+ this.channelCache = channelCache;
|
|
1382
|
1442
|
}
|
|
1383
|
1443
|
|
|
1384
|
1444
|
public SysUser getUserByNickName(String nickName) {
|
|
|
@@ -1397,6 +1457,10 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
|
|
1397
|
1457
|
return areaCache.get(areaName);
|
|
1398
|
1458
|
}
|
|
1399
|
1459
|
|
|
|
1460
|
+ public Long getChannelIdByName(String channelName) {
|
|
|
1461
|
+ return channelCache.get(channelName);
|
|
|
1462
|
+ }
|
|
|
1463
|
+
|
|
1400
|
1464
|
public SysDept getDeptByNameAndType(String deptName, String deptType) {
|
|
1401
|
1465
|
for (SysDept dept : deptCache.values()) {
|
|
1402
|
1466
|
if (deptName.equals(dept.getDeptName()) && deptType.equals(dept.getDeptType())) {
|
|
|
@@ -1537,19 +1601,26 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
|
|
1537
|
1601
|
// 构建区域缓存:Map<区域名称, 区域ID>
|
|
1538
|
1602
|
// 从base_position表查询position_type='REGIONAL'的区域
|
|
1539
|
1603
|
Map<String, Long> areaCache = new HashMap<>();
|
|
1540
|
|
- BasePosition queryPosition = new BasePosition();
|
|
1541
|
|
- queryPosition.setPositionType("REGIONAL");
|
|
1542
|
|
- List<BasePosition> allAreas = basePositionMapper.selectBasePositionList(queryPosition);
|
|
|
1604
|
+
|
|
|
1605
|
+ Map<String, Long> channelCache = new HashMap<>();
|
|
|
1606
|
+ List<BasePosition> allAreas = basePositionMapper.selectBasePositionList(new BasePosition());
|
|
1543
|
1607
|
if (allAreas != null) {
|
|
1544
|
|
- for (BasePosition area : allAreas) {
|
|
|
1608
|
+ List<BasePosition> collect = allAreas.stream().filter(area -> "REGIONAL".equals(area.getPositionType())).collect(Collectors.toList());
|
|
|
1609
|
+ for (BasePosition area : collect) {
|
|
1545
|
1610
|
if (area.getName() != null && !area.getName().trim().isEmpty()) {
|
|
1546
|
1611
|
areaCache.put(area.getName().trim(), area.getId());
|
|
1547
|
1612
|
}
|
|
1548
|
1613
|
}
|
|
|
1614
|
+ List<BasePosition> channel = allAreas.stream().filter(area -> "CHANNEL".equals(area.getPositionType())).collect(Collectors.toList());
|
|
|
1615
|
+ for (BasePosition post : channel) {
|
|
|
1616
|
+ if (post.getName() != null && !post.getName().trim().isEmpty()) {
|
|
|
1617
|
+ channelCache.put(post.getName().trim(), post.getId());
|
|
|
1618
|
+ }
|
|
|
1619
|
+ }
|
|
1549
|
1620
|
}
|
|
1550
|
1621
|
|
|
1551
|
1622
|
// 创建统一缓存对象
|
|
1552
|
|
- this.importCache = new ImportCache(userCache, deptCache, positionCache, areaCache);
|
|
|
1623
|
+ this.importCache = new ImportCache(userCache, deptCache, positionCache, areaCache,channelCache);
|
|
1553
|
1624
|
}
|
|
1554
|
1625
|
|
|
1555
|
1626
|
/**
|