|
|
@@ -555,18 +555,17 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
|
|
555
|
555
|
|
|
556
|
556
|
/** 7. 通道过检率(pivot表)→ ledger_channel_pass_rate
|
|
557
|
557
|
* R1: 大标题行
|
|
558
|
|
- * R2: 组长(0) 班组(1) 队室内勤(2) 2026年1月平均过检率(3) 2026年2月...(4) ...
|
|
|
558
|
+ * R2: 小组(0) 2026年1月平均过检率(1) 2026年2月...(2) ...
|
|
559
|
559
|
* 每行展开为多条(每月一条)
|
|
560
|
560
|
*/
|
|
561
|
561
|
private int doChannelPassRate(Sheet sheet, String batchNo, String username) {
|
|
562
|
|
- // 读第2行表头(POI 0-indexed = row index 1)
|
|
563
|
562
|
Row headerRow = sheet.getRow(1);
|
|
564
|
563
|
if (headerRow == null) return 0;
|
|
565
|
564
|
|
|
566
|
|
- // 找月份列(从列3开始)
|
|
567
|
|
- List<int[]> monthCols = new ArrayList<>(); // [colIndex, parsedDateMs]
|
|
|
565
|
+ // 找月份列(从列1开始)
|
|
|
566
|
+ List<int[]> monthCols = new ArrayList<>();
|
|
568
|
567
|
Pattern p = Pattern.compile("(\\d{4})年(\\d{1,2})月");
|
|
569
|
|
- for (int ci = 3; ci <= headerRow.getLastCellNum(); ci++) {
|
|
|
568
|
+ for (int ci = 1; ci <= headerRow.getLastCellNum(); ci++) {
|
|
570
|
569
|
Cell cell = headerRow.getCell(ci);
|
|
571
|
570
|
if (cell == null) continue;
|
|
572
|
571
|
String label = formatter.formatCellValue(cell).trim();
|
|
|
@@ -583,44 +582,33 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
|
|
583
|
582
|
|
|
584
|
583
|
List<LedgerChannelPassRate> list = new ArrayList<>();
|
|
585
|
584
|
for (Object[] c : dataRows(sheet, 2)) {
|
|
586
|
|
- String groupLeader = str(c, 0); // 组长(0)
|
|
587
|
|
- String teamName = str(c, 1); // 班组(1)
|
|
588
|
|
- String teamInternalDuty = str(c, 2); // 队室内勤(2)
|
|
589
|
|
-
|
|
590
|
|
- // 根据组长名称查找组织信息和ID
|
|
591
|
|
- Map<String, Object> orgInfo = new HashMap<>();
|
|
592
|
|
- if (groupLeader != null && !groupLeader.trim().isEmpty()) {
|
|
593
|
|
- orgInfo = resolveOrgInfoByNameWithCache(groupLeader);
|
|
594
|
|
- }
|
|
595
|
|
-
|
|
|
585
|
+ String groupName = str(c, 0);
|
|
|
586
|
+
|
|
|
587
|
+ // 通过小组名称查找组织信息(TEAMS → MANAGER → BRIGADE)
|
|
|
588
|
+ Map<String, Object> orgInfo = resolveOrgInfoByGroupName(groupName);
|
|
|
589
|
+
|
|
596
|
590
|
for (int[] mc : monthCols) {
|
|
597
|
591
|
int ci = mc[0];
|
|
598
|
592
|
BigDecimal rate = decimal(c, ci);
|
|
599
|
593
|
if (rate == null) continue;
|
|
600
|
594
|
LedgerChannelPassRate o = new LedgerChannelPassRate();
|
|
601
|
|
- o.setGroupLeader(groupLeader);
|
|
602
|
|
- o.setTeamName(teamName);
|
|
603
|
|
- o.setTeamInternalDuty(teamInternalDuty);
|
|
|
595
|
+ o.setGroupName(groupName);
|
|
604
|
596
|
o.setPassRate(rate);
|
|
605
|
|
- // 用时间戳还原日期
|
|
606
|
597
|
Calendar cal = Calendar.getInstance();
|
|
607
|
598
|
cal.setTimeInMillis((long) mc[1] * 1000);
|
|
608
|
599
|
o.setRecordDate(cal.getTime());
|
|
609
|
600
|
o.setImportBatch(batchNo);
|
|
610
|
601
|
o.setSourceType("1");
|
|
611
|
602
|
o.setCreateBy(username);
|
|
612
|
|
-
|
|
613
|
|
- // 设置组织ID和名称
|
|
|
603
|
+
|
|
614
|
604
|
if (!orgInfo.isEmpty()) {
|
|
615
|
|
- o.setResponsibleId((Long) orgInfo.get("userId"));
|
|
616
|
605
|
o.setDeptId((Long) orgInfo.get("deptId"));
|
|
617
|
606
|
o.setDeptName((String) orgInfo.get("deptName"));
|
|
618
|
607
|
o.setTeamId((Long) orgInfo.get("teamId"));
|
|
619
|
608
|
o.setTeamName((String) orgInfo.get("teamName"));
|
|
620
|
609
|
o.setGroupId((Long) orgInfo.get("groupId"));
|
|
621
|
|
- o.setGroupName((String) orgInfo.get("groupName"));
|
|
622
|
610
|
}
|
|
623
|
|
-
|
|
|
611
|
+
|
|
624
|
612
|
list.add(o);
|
|
625
|
613
|
}
|
|
626
|
614
|
}
|
|
|
@@ -628,6 +616,38 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
|
|
628
|
616
|
return list.size();
|
|
629
|
617
|
}
|
|
630
|
618
|
|
|
|
619
|
+ /**
|
|
|
620
|
+ * 通过小组名称(TEAMS)查找组织信息,向上补齐班组和部门
|
|
|
621
|
+ */
|
|
|
622
|
+ private Map<String, Object> resolveOrgInfoByGroupName(String groupName) {
|
|
|
623
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
624
|
+ if (groupName == null || groupName.trim().isEmpty() || importCache == null) {
|
|
|
625
|
+ return result;
|
|
|
626
|
+ }
|
|
|
627
|
+ SysDept groupDept = importCache.getDeptByNameAndType(groupName.trim(), DeptType.TEAMS.getCode());
|
|
|
628
|
+ if (groupDept == null) {
|
|
|
629
|
+ return result;
|
|
|
630
|
+ }
|
|
|
631
|
+ result.put("groupId", groupDept.getDeptId());
|
|
|
632
|
+ result.put("groupName", groupDept.getDeptName());
|
|
|
633
|
+
|
|
|
634
|
+ if (groupDept.getParentId() != null && groupDept.getParentId() != 0) {
|
|
|
635
|
+ SysDept teamDept = importCache.getDeptById(groupDept.getParentId());
|
|
|
636
|
+ if (teamDept != null) {
|
|
|
637
|
+ result.put("teamId", teamDept.getDeptId());
|
|
|
638
|
+ result.put("teamName", teamDept.getDeptName());
|
|
|
639
|
+ if (teamDept.getParentId() != null && teamDept.getParentId() != 0) {
|
|
|
640
|
+ SysDept brigadeDept = importCache.getDeptById(teamDept.getParentId());
|
|
|
641
|
+ if (brigadeDept != null) {
|
|
|
642
|
+ result.put("deptId", brigadeDept.getDeptId());
|
|
|
643
|
+ result.put("deptName", brigadeDept.getDeptName());
|
|
|
644
|
+ }
|
|
|
645
|
+ }
|
|
|
646
|
+ }
|
|
|
647
|
+ }
|
|
|
648
|
+ return result;
|
|
|
649
|
+ }
|
|
|
650
|
+
|
|
631
|
651
|
/** 8. 不安全事件 → ledger_unsafe_event
|
|
632
|
652
|
* R2: 时间(0) 事件描述(1) 类别(2) 航班号(3) 责任人(4)
|
|
633
|
653
|
* 涉及物品(5) 岗位(6) 区域(7) 通道号(8) 附件(9)
|
|
|
@@ -1339,6 +1359,15 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
|
|
1339
|
1359
|
public Long getAreaIdByName(String areaName) {
|
|
1340
|
1360
|
return areaCache.get(areaName);
|
|
1341
|
1361
|
}
|
|
|
1362
|
+
|
|
|
1363
|
+ public SysDept getDeptByNameAndType(String deptName, String deptType) {
|
|
|
1364
|
+ for (SysDept dept : deptCache.values()) {
|
|
|
1365
|
+ if (deptName.equals(dept.getDeptName()) && deptType.equals(dept.getDeptType())) {
|
|
|
1366
|
+ return dept;
|
|
|
1367
|
+ }
|
|
|
1368
|
+ }
|
|
|
1369
|
+ return null;
|
|
|
1370
|
+ }
|
|
1342
|
1371
|
}
|
|
1343
|
1372
|
|
|
1344
|
1373
|
// ════════════════════════════════════════════════════════════════
|