From 4e24c63554a7a234c7b79fdcd8991b8024ef7a5f Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期四, 04 九月 2025 10:48:02 +0800 Subject: [PATCH] 保养规范修改导入与返回值 --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamMaintenanceStandardServiceImpl.java | 55 +++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 41 insertions(+), 14 deletions(-) diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamMaintenanceStandardServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamMaintenanceStandardServiceImpl.java index f7a0afa..a3171aa 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamMaintenanceStandardServiceImpl.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamMaintenanceStandardServiceImpl.java @@ -1213,11 +1213,7 @@ // 妫�鏌ラ」鐩悕绉板垪 Cell nameCell = row.getCell(1); - if (nameCell != null && nameCell.getCellType() != CellType.BLANK) { - return false; - } - - return true; + return nameCell == null || nameCell.getCellType() == CellType.BLANK; } /** @@ -1324,7 +1320,7 @@ EamMaintenanceStandard oldStandardForRevision = null; Map<String, Integer> deviceVersionMap = new HashMap<>(); Map<String, Integer> compositeVersionMap = new HashMap<>(); - + List<String> notFoundEquipmentCodes = new ArrayList<>(); // 鑾峰彇鏂囨。涓殑鎵�鏈夋钀� List<XWPFParagraph> paragraphs = doc.getParagraphs(); @@ -1358,6 +1354,21 @@ EamMaintenanceStandard standard = extractDeviceInfo(table, type); if (standard == null) { throw new ImportException("琛ㄦ牸" + (i+1) + "锛氳澶囦俊鎭彁鍙栧け璐�"); + } + + if (StrUtil.isEmpty(standard.getEquipmentId())) { + // 璁板綍鏈壘鍒扮殑璁惧缂栫爜 + if (StrUtil.isNotEmpty(standard.getEquipmentCode())) { + notFoundEquipmentCodes.add(standard.getEquipmentCode()); + } else { + notFoundEquipmentCodes.add("鏈煡缂栫爜锛堣〃鏍�" + (i+1) + "锛�"); + } + + // 璺宠繃褰撳墠璁惧锛岀户缁鐞嗕笅涓�涓� + do { + i++; + } while (i < tables.size() && !isDeviceInfoTable(tables.get(i))); + continue; } // 浠庢枃妗d腑鑾峰彇鏍囬锛堣〃鏍煎墠鐨勬钀斤級 @@ -1409,6 +1420,11 @@ // 鏍¢獙璁惧鏁伴噺 if (standards.isEmpty()) { + // 濡傛灉鎵�鏈夎澶囬兘鏈壘鍒帮紝杩斿洖鐗瑰畾閿欒 + if (!notFoundEquipmentCodes.isEmpty()) { + return Result.error(fileName + "锛氭墍鏈夎澶囩紪鐮佸潎鏈壘鍒帮細" + + String.join(", ", notFoundEquipmentCodes)); + } return Result.error(fileName + "锛氭湭鎵惧埌鏈夋晥鐨勮澶囦俊鎭〃鏍�"); } @@ -1431,7 +1447,15 @@ // 浣滃簾鏃х増鏈紙淇濈暀鏈�鏂扮増鏈級 obsoleteOldVersionsByCompositeKey(deviceVersionMap); + if (!notFoundEquipmentCodes.isEmpty()) { + String successMsg = fileName + "閮ㄥ垎瀵煎叆鎴愬姛锛岃澶囨暟锛�" + standards.size() + + "锛岄」鐩暟锛�" + allItems.size(); + String errorMsg = "浠ヤ笅璁惧缂栫爜鏈壘鍒帮細" + String.join(", ", notFoundEquipmentCodes); + return Result.ok(successMsg + "锛涗絾" + errorMsg); + } + return Result.ok(fileName + "瀵煎叆鎴愬姛锛岃澶囨暟锛�" + standards.size() + "锛岄」鐩暟锛�" + allItems.size()); + } catch (ImportException e) { return Result.error(fileName + "锛�" + e.getMessage()); @@ -1471,13 +1495,10 @@ /** - * 浠庤〃鏍煎墠鐨勬钀戒腑鎻愬彇鏍囬锛堜慨澶嶇増锛� + * 浠庤〃鏍煎墠鐨勬钀戒腑鎻愬彇鏍囬 */ private String extractTitleBeforeTable(XWPFTable table, List<XWPFParagraph> paragraphs) { try { - // 鑾峰彇琛ㄦ牸鐨凜TTbl瀵硅薄 - CTTbl ctTbl = table.getCTTbl(); - // 鑾峰彇琛ㄦ牸鎵�鍦ㄧ殑body IBody body = table.getBody(); @@ -1513,7 +1534,7 @@ XWPFTableRow firstRow = table.getRow(0); for (XWPFTableCell cell : firstRow.getTableCells()) { String text = getCellText(cell); - if (text != null && text.contains("淇濆吇瑙勮寖")) { + if (text.contains("淇濆吇瑙勮寖")) { return text.trim(); } } @@ -1864,15 +1885,21 @@ standard.setEquipmentName(row2Data.get("璁惧鍚嶇О")); standard.setEquipmentModel(row2Data.get("璁惧鍨嬪彿")); - // 鍏宠仈璁惧ID + // 鍏宠仈璁惧ID - 淇敼鐐癸細璁惧鏈壘鍒版椂涓嶆姏鍑哄紓甯� if (StrUtil.isNotEmpty(standard.getEquipmentCode())) { EamEquipment equipment = eamEquipmentService.selectByEquipmentCode(standard.getEquipmentCode()); if (equipment == null) { - log.warn("璁惧缂栫爜鏈壘鍒�: {}", standard.getEquipmentCode()); - return null; + // 璁板綍鏈壘鍒拌澶囩紪鐮佺殑鏃ュ織 + log.error("璁惧缂栫爜鏈壘鍒�: {}", standard.getEquipmentCode()); + // 杩斿洖瀵硅薄浣嗚澶嘔D涓虹┖锛岃〃绀鸿澶囨湭鎵惧埌 + return standard; } else { standard.setEquipmentId(equipment.getId()); } + } else { + // 澶勭悊璁惧缂栫爜涓虹┖鐨勬儏鍐� + log.error("璁惧缂栫爜涓虹┖"); + return standard; } return standard; -- Gitblit v1.9.3