From c800257cb6c8b45e7edc20e2e9018cd90b230806 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期三, 09 七月 2025 19:50:00 +0800 Subject: [PATCH] art: 技术状态鉴定-基础代码生成 --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamMaintenanceStandardServiceImpl.java | 482 ++++++++++++++++++++++++++++------------------------ 1 files changed, 258 insertions(+), 224 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 d6c9e23..ab2dd0c 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 @@ -127,9 +127,11 @@ List<BaseFactoryUser> baseFactoryUserList=baseFactoryUserService. list(new LambdaQueryWrapper<BaseFactoryUser>().eq(BaseFactoryUser::getUserId,sysUser.getId())); if(!CollectionUtils.isEmpty(baseFactoryUserList)){ - List<String> factoryIds = baseFactoryUserList.stream().map(BaseFactoryUser::getFactoryId).collect(Collectors.toList()); - List<String> factoryCode= baseFactoryService.listByIds(factoryIds).stream().map(BaseFactory::getFactoryCode).collect(Collectors.toList()); + Set<String> factoryIds = baseFactoryUserList.stream().map(BaseFactoryUser::getFactoryId).collect(Collectors.toSet()); + Set<String> factoryCode= baseFactoryService.listByIds(factoryIds).stream().map(BaseFactory::getOrgCode).collect(Collectors.toSet()); queryWrapper.in("e.factory_org_code", factoryCode); + } else { + return page; } } if(eamMaintenanceStandard != null) { @@ -181,7 +183,7 @@ //鍒犻櫎鏍囪 entity.setDelFlag(CommonConstant.DEL_FLAG_0); //閲嶅鎬ф牎楠� - EamMaintenanceStandard exist = checkDuplicate(entity.getEquipmentId(), entity.getMaintenanceCategory()); + EamMaintenanceStandard exist = checkDuplicate(entity.getEquipmentId(), entity.getMaintenanceCategory(),MaintenanceStandardStatusEnum.WAIT_SUBMIT.name()); if(exist != null){ throw new JeecgBootException("璁惧鏍囧噯宸插瓨鍦紝涓嶈兘閲嶅娣诲姞锛�"); } @@ -265,7 +267,7 @@ //鍒犻櫎鏍囪 newEntity.setDelFlag(CommonConstant.DEL_FLAG_0); //閲嶅鎬ф牎楠� - EamMaintenanceStandard exist = checkDuplicate(newEntity.getEquipmentId(), newEntity.getMaintenanceCategory()); + EamMaintenanceStandard exist = checkDuplicate(newEntity.getEquipmentId(), newEntity.getMaintenanceCategory(),MaintenanceStandardStatusEnum.WAIT_SUBMIT.name()); if(exist != null){ throw new JeecgBootException("璁惧鏍囧噯宸插瓨鍦紝涓嶈兘閲嶅娣诲姞锛�"); } @@ -286,12 +288,12 @@ } @Override - public EamMaintenanceStandard checkDuplicate(String equipmentId, String maintenanceCategory) { + public EamMaintenanceStandard checkDuplicate(String equipmentId, String maintenanceCategory,String standardStatus) { LambdaQueryWrapper<EamMaintenanceStandard> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(EamMaintenanceStandard::getEquipmentId, equipmentId); queryWrapper.eq(EamMaintenanceStandard::getMaintenanceCategory, maintenanceCategory); queryWrapper.eq(EamMaintenanceStandard::getDelFlag, CommonConstant.DEL_FLAG_0); - queryWrapper.eq(EamMaintenanceStandard::getStandardStatus, MaintenanceStandardStatusEnum.WAIT_SUBMIT.name()); + queryWrapper.eq(EamMaintenanceStandard::getStandardStatus, standardStatus); queryWrapper.orderByDesc(EamMaintenanceStandard::getStandardVersion); List<EamMaintenanceStandard> list = eamMaintenanceStandardMapper.selectList(queryWrapper); @@ -567,6 +569,12 @@ } eamMaintenanceStandard.setStandardName(name); + + EamMaintenanceStandard exist = checkDuplicate(eamMaintenanceStandard.getEquipmentId(), eamMaintenanceStandard.getMaintenanceCategory(),MaintenanceStandardStatusEnum.START.name()); + if(exist != null){ + return Result.error(name + ": 璁惧鏍囧噯宸插瓨鍦紝涓嶈兘閲嶅娣诲姞"); + } + eamMaintenanceStandardMapper.insert(eamMaintenanceStandard); // 2. 鎻愬彇姣忔棩鐐规椤圭洰 @@ -932,6 +940,7 @@ /*瀵煎叆鐐规鏂囦欢Excel--------------------------缁撴潫*/ /*瀵煎叆浜屼繚涓変繚鏂囦欢Excel--------------------------寮�濮�*/ + /** * 缁熶竴淇濆吇瑙勮寖瀵煎叆鍏ュ彛 * @param file 涓婁紶鏂囦欢 @@ -949,40 +958,68 @@ return Result.error(fileName + ": 鏂囨。涓湭鎵惧埌琛ㄦ牸"); } - XWPFTable table = doc.getTables().get(0); + List<XWPFTable> tables = doc.getTables(); + EamMaintenanceStandard standard = null; + List<EamMaintenanceStandardDetail> items = new ArrayList<>(); + String standardId = null; - // 鏂囨。绫诲瀷鏍¢獙 - 闃叉浜屼繚浼犲叆涓変繚鎴栧弽涔� - if (isWrongDocumentType(table, type)) { - return Result.error(fileName + ": 鏂囨。绫诲瀷涓嶅尮閰� - " + - ("SECOND".equals(type) ? "璇峰鍏ヤ簩绾т繚鍏绘枃妗�" : "璇峰鍏ヤ笁绾т繚鍏绘枃妗�")); + // 1. 澶勭悊鎵�鏈夎〃鏍� + for (int i = 0; i < tables.size(); i++) { + XWPFTable table = tables.get(i); + + if (i == 0) { // 绗竴椤佃〃鏍� + // 楠岃瘉璁惧淇℃伅琛ㄦ牸 + if (isWrongDocumentType(table, type)) { + return Result.error(fileName + ": 鏂囨。绫诲瀷涓嶅尮閰� - " + + ("SECOND".equals(type) ? "璇峰鍏ヤ簩绾т繚鍏绘枃妗�" : "璇峰鍏ヤ笁绾т繚鍏绘枃妗�")); + } + + // 鎻愬彇璁惧淇℃伅 + standard = extractDeviceInfo(table,type); + if (standard == null) { + return Result.error(fileName + ": 璁惧淇℃伅鎻愬彇澶辫触"); + } + + // 閰嶇疆绫诲瀷鐩稿叧鍙傛暟 + configureStandard(standard, type, file); + EamMaintenanceStandard exist = checkDuplicate(standard.getEquipmentId(), standard.getMaintenanceCategory(),MaintenanceStandardStatusEnum.START.name()); + if(exist != null){ + return Result.error(fileName + ": 璁惧鏍囧噯宸插瓨鍦紝涓嶈兘閲嶅娣诲姞"); + } + eamMaintenanceStandardMapper.insert(standard); + standardId = standard.getId(); + + // 鎻愬彇绗竴椤电殑淇濆吇椤圭洰 + if ("SECOND".equals(type)) { + items.addAll(extractSecondMaintenanceItems(table, standardId, true)); + } else if ("THIRD".equals(type)) { + items.addAll(extractThirdMaintenanceItems(table, standardId, true)); + } + + } else { // 鍚庣画椤甸潰 + // 鎻愬彇鍚庣画椤甸潰鐨勪繚鍏婚」鐩� + if ("SECOND".equals(type)) { + items.addAll(extractSecondMaintenanceItems(table, standardId, false)); + } else if ("THIRD".equals(type)) { + items.addAll(extractThirdMaintenanceItems(table, standardId, false)); + } + } } - EamMaintenanceStandard standard = extractDeviceInfo(table); + // 楠岃瘉璁惧淇℃伅鎻愬彇 if (standard == null) { return Result.error(fileName + ": 璁惧淇℃伅鎻愬彇澶辫触"); } - // 閰嶇疆绫诲瀷鐩稿叧鍙傛暟 - configureStandard(standard, type, file); - eamMaintenanceStandardMapper.insert(standard); - String standardId = standard.getId(); + // 2. 鍚庡鐞嗭細鏍规嵁涓嶅悓绫诲瀷杩涜澶勭悊 + processItemsAfterExtraction(items, type); - // 鎻愬彇淇濆吇椤圭洰 - List<EamMaintenanceStandardDetail> items; - if ("SECOND".equals(type)) { - items = extractSecondMaintenanceItems(table, standardId); - } else if ("THIRD".equals(type)) { - items = extractThirdMaintenanceItems(table, standardId); - } else { - return Result.error(fileName + ": 涓嶆敮鎸佺殑淇濆吇绫诲瀷: " + type); - } - - // 椤圭洰楠岃瘉 + // 3. 椤圭洰楠岃瘉 if (items.isEmpty()) { return Result.error(fileName + ": 鏈彁鍙栧埌浠讳綍淇濆吇椤圭洰"); } - // 淇濆瓨椤圭洰 + // 4. 淇濆瓨椤圭洰 eamMaintenanceStandardDetailService.saveBatch(items); return Result.ok(fileName + ": 瀵煎叆鎴愬姛, 椤圭洰鏁�: " + items.size()); @@ -992,6 +1029,194 @@ } catch (Exception e) { return Result.error(fileName + ": 绯荤粺閿欒 - " + e.getClass().getSimpleName()); } + } + + /** + * 鍚庡鐞嗘柟娉曪細鏍规嵁涓嶅悓绫诲瀷杩涜澶勭悊 + */ + private void processItemsAfterExtraction(List<EamMaintenanceStandardDetail> items, String type) { + if ("SECOND".equals(type)) { + // 浜岀骇淇濆吇: 鍒犻櫎娌℃湁搴忓彿鐨勬暟鎹� + items.removeIf(item -> item.getItemCode() == null); + } else { + // 涓夌骇淇濆吇: + // 1. 鍒犻櫎绗竴鏉℃暟鎹紙閫氬父鏄爣棰樿锛� + if (!items.isEmpty()) { + items.remove(0); + } + + // 2. 涓虹己澶遍儴浣嶇殑鏁版嵁濉厖鍓嶄竴鏉$殑淇濆吇閮ㄤ綅 + String lastPart = ""; + for (EamMaintenanceStandardDetail item : items) { + if (item.getItemPart() != null && !item.getItemPart().isEmpty()) { + lastPart = item.getItemPart(); + } else if (!lastPart.isEmpty()) { + item.setItemPart(lastPart); + } + } + } + } + /** + * 鎻愬彇浜岀骇淇濆吇椤圭洰锛堝尯鍒嗙涓�椤靛拰鍚庣画椤甸潰锛� + */ + private List<EamMaintenanceStandardDetail> extractSecondMaintenanceItems( + XWPFTable table, String standardId, boolean isFirstTable) { + + List<EamMaintenanceStandardDetail> items = new ArrayList<>(); + String currentCategory = null; + int startRow = 0; + + // 瀵逛簬绗竴椤佃〃鏍硷紝璺宠繃鍓嶄袱琛岋紙璁惧淇℃伅琛岋級 + if (isFirstTable && table.getNumberOfRows() > 2) { + startRow = 2; // 浠庣涓夎寮�濮嬫槸淇濆吇鍐呭 + } + + for (int i = startRow; i < table.getNumberOfRows(); i++) { + XWPFTableRow row = table.getRow(i); + if (row == null) continue; + + // 妫�鏌ユ槸鍚︽槸鏍囬琛岋紙缁翠慨浜哄憳淇濆吇鍐呭鎴栨搷浣滀汉鍛樹繚鍏诲唴瀹癸級 + String firstCell = getCellText(row.getCell(0)); + // 澶勭悊绌鸿鍚庣殑閮ㄤ綅缁ф壙 + if (firstCell.contains(REPAIR_TITLE)) { + currentCategory = "REPAIRER_MAINTENANCE"; + } else if (firstCell.contains(OPERATOR_TITLE)) { + currentCategory = "OPERATOR_MAINTENANCE"; + } + + // 澶勭悊鏅�氶」鐩 + if (currentCategory != null && isValidItemRow(row)) { + EamMaintenanceStandardDetail item = new EamMaintenanceStandardDetail(); + item.setItemCategory(currentCategory); + item.setStandardId(standardId); + + // 鎻愬彇搴忓彿锛堢浜屽垪锛� + if (row.getTableCells().size() > 1) { + String seqText = getCellText(row.getCell(1)); + try { + if (!seqText.equals("搴忓彿")){ + item.setItemCode(Integer.parseInt(seqText.trim())); + } + } catch (NumberFormatException e) { + // 蹇界暐搴忓彿瑙f瀽閿欒 + } + } + + // 鎻愬彇鍐呭锛堢涓夊垪锛� + if (row.getTableCells().size() > 2) { + String seqText = getCellText(row.getCell(2)); + item.setItemName(seqText); + } + + items.add(item); + } + } + return items; + } + + /** + * 鎻愬彇涓夌骇淇濆吇椤圭洰锛堣В鍐宠法椤电┖琛岄棶棰橈級 + */ + private List<EamMaintenanceStandardDetail> extractThirdMaintenanceItems( + XWPFTable table, String standardId, boolean isFirstTable) { + + List<EamMaintenanceStandardDetail> items = new ArrayList<>(); + String currentPart = ""; + int startRow = 0; + + // 瀵逛簬绗竴椤佃〃鏍硷紝璺宠繃鍓嶄袱琛岋紙璁惧淇℃伅琛岋級 + if (isFirstTable && table.getNumberOfRows() > 2) { + startRow = 2; // 浠庣涓夎寮�濮嬫槸淇濆吇鍐呭 + } + + for (int i = startRow; i < table.getNumberOfRows(); i++) { + XWPFTableRow row = table.getRow(i); + if (row == null) continue; // 纭繚琛屽璞′笉涓虹┖ + + // 妫�鏌ユ槸鍚︽槸绌鸿锛堝寘鍚墍鏈夊崟鍏冩牸閮戒负绌虹殑鎯呭喌锛� + if (isRowEmpty(row)) { + // 绌鸿澶勭悊锛氫繚鐣欏綋鍓嶄綅缃絾涓嶅垱寤洪」鐩� + continue; + } + + // 鍒涘缓淇濆吇椤圭洰 + EamMaintenanceStandardDetail item = new EamMaintenanceStandardDetail(); + item.setItemCategory("THIRD_MAINTENANCE"); + item.setStandardId(standardId); + int colCount = row.getTableCells().size(); + + // 澶勭悊閮ㄤ綅鍒楋紙绗竴鍒楋級 + if (colCount > 0) { + String firstCell = getCellText(row.getCell(0)).trim(); + + // 鍏抽敭鏀硅繘锛氭纭鐞嗙┖琛屽悗鐨勯儴浣嶇户鎵� + if (!firstCell.isEmpty() && !firstCell.equals("淇濆吇閮ㄤ綅")) { + // 鏇存柊褰撳墠閮ㄤ綅 + currentPart = firstCell; + } + item.setItemPart(currentPart); + } else { + // 濡傛灉娌℃湁鍗曞厓鏍硷紝浣跨敤褰撳墠閮ㄤ綅 + item.setItemPart(currentPart); + } + + // 鏍规嵁鍒楁暟鎻愬彇鍐呭锛堣�冭檻鍚堝苟鍗曞厓鏍兼儏鍐碉級 + List<String> cellContents = new ArrayList<>(); + for (int j = 0; j < colCount; j++) { + XWPFTableCell cell = row.getCell(j); + String text = getCellText(cell).trim(); + + // 鐗规畩澶勭悊锛氱浜岄〉绗竴琛屽彲鑳芥槸绌鸿鍚庣殑鍐呭 + if (j == 0 && !text.isEmpty() && !text.equals(currentPart)) { + // 濡傛灉涓嶆槸閮ㄤ綅鍒楋紝鍒欐坊鍔犱负鍐呭 + cellContents.add(text); + } else if (j > 0) { + // 鍏朵粬鍒椾綔涓哄唴瀹� + cellContents.add(text); + } + } + + // 鏅鸿兘瑙f瀽鍗曞厓鏍煎唴瀹� + if (cellContents.size() >= 2) { + // 榛樿澶勭悊鏂瑰紡锛氭渶鍚庝袱涓綔涓哄唴瀹瑰拰鏍囧噯 + item.setItemName(cellContents.get(cellContents.size() - 2)); + item.setItemDemand(cellContents.get(cellContents.size() - 1)); + } else if (cellContents.size() == 1) { + // 鍗曞垪妯″紡锛氳涓哄唴瀹� + item.setItemName(cellContents.get(0)); + } else if (!isRowEmpty(row)) { + // 鐗规畩澶勭悊锛氳闈炵┖浣嗘病鏈夋彁鍙栧埌鍐呭锛堝彲鑳芥槸澶嶆潅鍚堝苟鍗曞厓鏍硷級 + // 灏濊瘯鎻愬彇鏁磋鏂囨湰浣滀负鍐呭 + StringBuilder content = new StringBuilder(); + for (XWPFTableCell cell : row.getTableCells()) { + content.append(getCellText(cell).trim()).append(" "); + } + item.setItemName(content.toString().trim()); + } + + items.add(item); + } + return items; + } + + /** + * 浼樺寲鍚庣殑绌鸿妫�娴嬶紙瑙e喅璺ㄩ〉绌鸿闂锛� + */ + private boolean isRowEmpty(XWPFTableRow row) { + if (row == null || row.getTableCells().isEmpty()) { + return true; + } + + boolean allCellsEmpty = true; + for (XWPFTableCell cell : row.getTableCells()) { + String text = getCellText(cell).trim(); + // 淇濈暀鍖呭惈鎹㈣绗︾瓑鐨勫崟鍏冩牸浣滀负闈炵┖琛� + if (!text.isEmpty() && !text.replaceAll("\\s+", "").isEmpty()) { + allCellsEmpty = false; + break; + } + } + return allCellsEmpty; } /** @@ -1043,7 +1268,7 @@ /** * 鎻愬彇璁惧鍩烘湰淇℃伅 */ - private EamMaintenanceStandard extractDeviceInfo(XWPFTable table) { + private EamMaintenanceStandard extractDeviceInfo(XWPFTable table,String type) { if (table.getNumberOfRows() < 2) return null; // 鎻愬彇鍓嶄袱琛屾暟鎹� @@ -1065,15 +1290,15 @@ }else { standard.setEquipmentId(equipments.getId()); } + if (type.equals("THIRD")){ + EamEquipmentExtend eamEquipmentExtend=eamEquipmentExtendService.getById(standard.getEquipmentId()); + standard.setMaintenancePeriod(eamEquipmentExtend.getThirdMaintenancePeriod()); + } } return standard; } - // 绠�鏄撶増瀛楃涓查潪绌哄垽鏂� - private boolean isNotBlank(String str) { - return str != null && !str.trim().isEmpty(); - } /** * 琛ㄦ牸琛屾暟鎹В鏋� @@ -1157,161 +1382,6 @@ } /** - * 鎻愬彇浜岀骇淇濆吇椤圭洰 - */ - private List<EamMaintenanceStandardDetail> extractSecondMaintenanceItems( - XWPFTable table, String standardId) { - - List<EamMaintenanceStandardDetail> items = new ArrayList<>(); - EamMaintenanceStandardDetailCategory currentCategory = null; - - for (int i = 0; i < table.getNumberOfRows(); i++) { - XWPFTableRow row = table.getRow(i); - if (row == null) continue; - - // 妫�鏌ユ槸鍚︽槸鏍囬琛岋紙缁翠慨浜哄憳淇濆吇鍐呭鎴栨搷浣滀汉鍛樹繚鍏诲唴瀹癸級 - String firstCell = getCellText(row.getCell(0)); - if (firstCell != null) { - for (String title : SECOND_CATEGORY_MAPPING.keySet()) { - if (firstCell.contains(title)) { - currentCategory = SECOND_CATEGORY_MAPPING.get(title); - - // 妫�鏌ョ浜屽垪鍜岀涓夊垪鏄惁鏄�"搴忓彿"鍜�"淇濆吇鍐呭" - if (row.getTableCells().size() > 2) { - String secondCell = getCellText(row.getCell(1)); - String thirdCell = getCellText(row.getCell(2)); - - // 鏄庣‘璺宠繃鏍囬琛� - if ("搴忓彿".equals(secondCell) && "淇濆吇鍐呭".equals(thirdCell)) { - continue; // 璺宠繃杩欎竴琛� - } - } - - // 灏濊瘯鎻愬彇鏍囬琛屼腑鐨勯」鐩紙濡傛灉瀛樺湪锛� - if (row.getTableCells().size() > 2) { - String content = getCellText(row.getCell(2)); - if (content != null && !content.trim().isEmpty() && - !"淇濆吇鍐呭".equals(content.trim())) { // 杩囨护鏃犳晥鍐呭 - items.add(createItem(currentCategory, content.trim(), standardId)); - } - } - continue; - } - } - } - - // 澶勭悊鏅�氶」鐩 - if (currentCategory != null && isValidItemRow(row)) { - // 鑾峰彇鍐呭 - String content = row.getTableCells().size() > 2 ? - getCellText(row.getCell(2)) : ""; - - // 鎺掗櫎鏍囬鍐呭 - if ("淇濆吇鍐呭".equals(content) || - "搴忓彿".equals(content) || - content.contains("缁翠慨浜哄憳淇濆吇鍐呭") || - content.contains("鎿嶄綔浜哄憳淇濆吇鍐呭")) { - continue; - } - - EamMaintenanceStandardDetail item = new EamMaintenanceStandardDetail(); - item.setItemCategory(String.valueOf(currentCategory)); - item.setStandardId(standardId); - item.setItemName(cleanContent(content)); - - // 澶勭悊搴忓彿锛堢浜屽垪锛� - if (row.getTableCells().size() > 1) { - String seqText = getCellText(row.getCell(1)); - try { - if (seqText != null && !seqText.trim().isEmpty()) { - item.setItemCode(Integer.parseInt(seqText.trim())); - } - } catch (NumberFormatException e) { - // 蹇界暐搴忓彿瑙f瀽閿欒 - } - } - - items.add(item); - } - } - return items; - } - - /** - * 鍒涘缓淇濆吇椤圭洰 - */ - private EamMaintenanceStandardDetail createItem( - EamMaintenanceStandardDetailCategory category, - String content, - String standardId) { - - EamMaintenanceStandardDetail item = new EamMaintenanceStandardDetail(); - item.setItemCategory(category.name()); - item.setStandardId(standardId); - item.setItemName(cleanContent(content)); - return item; - } - - /** - * 鎻愬彇涓夌骇淇濆吇椤圭洰锛堟棤绫诲瀷锛� - */ - private List<EamMaintenanceStandardDetail> extractThirdMaintenanceItems( - XWPFTable table, String standardId) { - - List<EamMaintenanceStandardDetail> items = new ArrayList<>(); - String currentPart = ""; - int itemCount = 1; - - // 浠庣涓夎寮�濮嬶紙璺宠繃琛ㄥご鍜岃澶囦俊鎭級 - for (int i = 2; i < table.getNumberOfRows(); i++) { - XWPFTableRow row = table.getRow(i); - if (row == null || isRowEmpty(row)) continue; - - // 璺宠繃"淇濆吇閮ㄤ綅"鏍囬琛� - String firstCell = getCellText(row.getCell(0)); - if ("淇濆吇閮ㄤ綅".equals(firstCell)) { - continue; - } - - EamMaintenanceStandardDetail item = new EamMaintenanceStandardDetail(); - // 涓夌骇淇濆吇涓嶉渶瑕佺被鍨嬶紝涓嶈缃甶temCategory - item.setStandardId(standardId); - item.setItemCode(itemCount++); - - // 澶勭悊閮ㄤ綅鍒� - if (!row.getTableCells().isEmpty()) { - String partCell = getCellText(row.getCell(0)); - if (!partCell.trim().isEmpty()) { - currentPart = partCell.trim(); - } - } - item.setItemPart(currentPart); - - // 鏍规嵁鍒楁暟纭畾鍐呭鍜屾爣鍑嗙殑浣嶇疆 - int cellCount = row.getTableCells().size(); - if (cellCount == 3) { // 閮ㄤ綅|鍐呭|鏍囧噯 - item.setItemName(getCellText(row.getCell(1))); - item.setItemDemand(getCellText(row.getCell(2))); - } - else if (cellCount == 2) { // 鍐呭|鏍囧噯 - item.setItemName(getCellText(row.getCell(0))); - item.setItemDemand(getCellText(row.getCell(1))); - } - else if (cellCount == 1) { // 鍗曞垪鍐呭 - item.setItemName(getCellText(row.getCell(0))); - } - else if (cellCount > 3) { // 澶氬垪澶勭悊 - // 鍙栫2鍒椾綔涓哄唴瀹癸紝鏈�鍚庝竴鍒椾綔涓烘爣鍑� - item.setItemName(getCellText(row.getCell(1))); - item.setItemDemand(getCellText(row.getCell(cellCount - 1))); - } - - items.add(item); - } - return items; - } - - /** * 鍏煎鐗堝崟鍏冩牸鏂囨湰鎻愬彇 */ private String getCellText(XWPFTableCell cell) { @@ -1334,48 +1404,12 @@ } /** - * 鍐呭娓呯悊 - */ - private String cleanContent(String text) { - if (text == null) return ""; - - // 鏇挎崲鐗规畩绌烘牸鍜屽悎骞惰繛缁┖鏍� - text = text.replace('\u00A0', ' ') - .replace('\u2007', ' ') - .replace('\u202F', ' ') - .replaceAll("\\s+", " "); - - // 瑙勮寖鏍囩偣绗﹀彿 - return text.replace(',', '銆�') - .replace('锛�', '銆�') - .replace(';', '锛�') - .replace('锛�', '锛�') - .replace(':', '锛�') - .replace('锛�', '锛�') - .trim(); - } - - /** * 楠岃瘉鏈夋晥椤圭洰琛� */ private boolean isValidItemRow(XWPFTableRow row) { return row != null && row.getTableCells().size() >= 2 && !getCellText(row.getCell(1)).trim().isEmpty(); - } - - /** - * 绌鸿妫�娴� - */ - private boolean isRowEmpty(XWPFTableRow row) { - if (row == null) return true; - for (XWPFTableCell cell : row.getTableCells()) { - String text = getCellText(cell); - if (text != null && !text.trim().isEmpty()) { - return false; - } - } - return true; } /*瀵煎叆浜屼繚涓変繚鏂囦欢Excel--------------------------缁撴潫*/ -- Gitblit v1.9.3