From fd57c8510934444df5320029653d530a1abeff67 Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期五, 11 七月 2025 17:57:18 +0800 Subject: [PATCH] 修改查询 --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamSecondMaintenanceOrderServiceImpl.java | 46 ++-- lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/rule/WorkShopOrgCodeProRule.java | 2 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamSecondMaintenanceRequest.java | 6 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/SecondMaintenanceOrderGenerateJob.java | 4 lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/constant/TechnologyStatusEnum.java | 8 lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/BaseFactoryServiceImpl.java | 84 +----- lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java | 2 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java | 4 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamMaintenanceStandardServiceImpl.java | 494 +++++++++++++++++++++++++++----------------- 9 files changed, 360 insertions(+), 290 deletions(-) diff --git a/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/constant/TechnologyStatusEnum.java b/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/constant/TechnologyStatusEnum.java new file mode 100644 index 0000000..2fbfdb6 --- /dev/null +++ b/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/constant/TechnologyStatusEnum.java @@ -0,0 +1,8 @@ +package org.jeecg.modules.eam.constant; + +public enum TechnologyStatusEnum { + QUALIFIED, //鍚堟牸 + RESTRICTED, //闄愮敤 + PROHIBITED, //绂佺敤 + ; +} diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java index 743d9ec..f6ee810 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java @@ -238,7 +238,9 @@ baseFactoryService.factoryDataNameByOrgCode(eamEquipmentDto.getZxfactoryOrgCode()) +"/"+ baseFactoryService.factoryDataNameByOrgCode(eamEquipmentDto.getFactoryOrgCode())); } - eamEquipmentDto.setEquipmentWeightStr(eamEquipmentDto.getEquipmentWeight().toEngineeringString()); + if (eamEquipmentDto.getEquipmentWeight()!=null){ + eamEquipmentDto.setEquipmentWeightStr(eamEquipmentDto.getEquipmentWeight().toEngineeringString()); + } eamEquipmentDtos.add(eamEquipmentDto); }); // Step.3 AutoPoi 瀵煎嚭Excel diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/SecondMaintenanceOrderGenerateJob.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/SecondMaintenanceOrderGenerateJob.java index be828db..111a0ea 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/SecondMaintenanceOrderGenerateJob.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/SecondMaintenanceOrderGenerateJob.java @@ -113,9 +113,9 @@ for (EamMaintenanceStandardDetail msd : standardDetailList) { EamSecondMaintenanceOrderDetail sod = new EamSecondMaintenanceOrderDetail(); sod.setItemCode(msd.getItemCode()); + sod.setItemCategory(msd.getItemPart()); sod.setItemName(msd.getItemName()); - sod.setItemDemand(msd.getItemDemand()); - sod.setItemPart(msd.getItemPart()); + sod.setMaintenanceResult(msd.getItemDemand()); tableDetailList.add(sod); } // List<EamSecondMaintenanceOrderDetail> collect = standardDetailList.stream().map(EamSecondMaintenanceOrderDetail::new).collect(Collectors.toList()); diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamSecondMaintenanceRequest.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamSecondMaintenanceRequest.java index bcad399..140cd99 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamSecondMaintenanceRequest.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamSecondMaintenanceRequest.java @@ -41,12 +41,6 @@ /**淇濆吇浜�*/ @ApiModelProperty(value = "淇濆吇浜�") private String operator; - /**淇濆吇鍥剧墖*/ - @ApiModelProperty(value = "淇濆吇鍥剧墖") - private String imageFiles; - /**淇濆吇鍥剧墖*/ - @ApiModelProperty(value = "淇濆吇鍥剧墖") - private List<FileUploadResult> imageFilesResult; /**澶囨敞*/ @ApiModelProperty(value = "澶囨敞") private String remark; 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 356394f..0f997e7 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 @@ -554,31 +554,31 @@ // 1. 鎻愬彇璁惧淇℃伅 EamMaintenanceStandard eamMaintenanceStandard = extractDeviceInfo(sheet); - if (eamMaintenanceStandard == null) { + if (eamMaintenanceStandard == null || eamMaintenanceStandard.getEquipmentId() == null) { return Result.error("璁惧淇℃伅鎻愬彇澶辫触"); - } else { - if (eamMaintenanceStandard.getEquipmentId() == null) { - return Result.error("璁惧淇℃伅鎻愬彇澶辫触"); - } } eamMaintenanceStandard.setStandardName(name); - EamMaintenanceStandard exist = checkDuplicate(eamMaintenanceStandard.getEquipmentId(), eamMaintenanceStandard.getMaintenanceCategory(), MaintenanceStandardStatusEnum.START.name()); + // 妫�鏌ラ噸澶� + EamMaintenanceStandard exist = checkDuplicate(eamMaintenanceStandard.getEquipmentId(), + eamMaintenanceStandard.getMaintenanceCategory(), MaintenanceStandardStatusEnum.START.name()); if (exist != null) { return Result.error(name + ": 璁惧鏍囧噯宸插瓨鍦紝涓嶈兘閲嶅娣诲姞"); } eamMaintenanceStandardMapper.insert(eamMaintenanceStandard); - // 2. 鎻愬彇姣忔棩鐐规椤圭洰 - List<EamMaintenanceStandardDetail> dailyDetails = extractDailyItems(sheet, eamMaintenanceStandard); + Map<Integer, String> rowErrors = new HashMap<>(); + + // 2. 鎻愬彇姣忔棩鐐规椤圭洰锛堜紭鍖栫┖琛屽拰缁撴潫鏍囪澶勭悊锛� + List<EamMaintenanceStandardDetail> dailyDetails = extractDailyItems(sheet, eamMaintenanceStandard, rowErrors); if (dailyDetails.isEmpty()) { return Result.error("鏈壘鍒版瘡鏃ョ偣妫�椤圭洰"); } // 3. 鎻愬彇鍛ㄤ繚鍏婚」鐩� - List<EamMaintenanceStandardDetail> weeklyDetails = extractWeeklyItems(sheet, eamMaintenanceStandard); + List<EamMaintenanceStandardDetail> weeklyDetails = extractWeeklyItems(sheet, eamMaintenanceStandard, rowErrors); if (weeklyDetails.isEmpty()) { return Result.error("鏈壘鍒板懆淇濆吇椤圭洰"); } @@ -592,14 +592,11 @@ eamMaintenanceStandardDetailService.saveBatch(allDetails); } + // 瑙﹀彂淇濆吇娴佺▼ SysParams sysParams = sysParamsService.getSysPramBySettingKey("maintenance_import_type"); - - if (sysParams != null) { - if (sysParams.getSettingValue().equals("1")) { - //瑙﹀彂淇濆吇娴佺▼ - eamMaintenanceStandard.setStandardStatus(MaintenanceStandardStatusEnum.WAIT_SUBMIT.name()); - eamMaintenanceStandardMapper.updateById(eamMaintenanceStandard); - } + if (sysParams != null && sysParams.getSettingValue().equals("1")) { + eamMaintenanceStandard.setStandardStatus(MaintenanceStandardStatusEnum.WAIT_SUBMIT.name()); + eamMaintenanceStandardMapper.updateById(eamMaintenanceStandard); } else { return Result.error("鏈壘鍒颁繚鍏绘祦绋嬪鍏ョ浉鍏抽厤缃�,璇疯仈绯荤鐞嗗憳"); } @@ -728,171 +725,6 @@ } /** - * 鎻愬彇姣忔棩鐐规椤圭洰 - */ - private List<EamMaintenanceStandardDetail> extractDailyItems(Sheet sheet, EamMaintenanceStandard standard) { - return extractItems(sheet, standard, "鐐规椤圭洰", "瀹屾垚鏁版嵁/瑕佹眰", "DAY_INSPECTION"); - } - - /** - * 鎻愬彇鍛ㄤ繚鍏婚」鐩� - */ - private List<EamMaintenanceStandardDetail> extractWeeklyItems(Sheet sheet, EamMaintenanceStandard standard) { - return extractItems(sheet, standard, "鍛ㄤ繚鍏婚」鐩�", "妫�鏌ユ爣鍑�", "WEEK_INSPECTION"); - } - - /** - * 閫氱敤椤圭洰鎻愬彇鏂规硶 - */ - private List<EamMaintenanceStandardDetail> extractItems(Sheet sheet, EamMaintenanceStandard standard, - String primaryHeader, String secondaryHeader, - String itemCategory) { - int[] section = findTableSection(sheet, primaryHeader, secondaryHeader); - if (section == null) { - return Collections.emptyList(); - } - - List<EamMaintenanceStandardDetail> details = new ArrayList<>(); - for (int rowIdx = section[0]; rowIdx <= section[1]; rowIdx++) { - Row row = sheet.getRow(rowIdx); - if (row == null || isEmptyRow(row)) { - continue; - } - - // 纭繚绗竴鍒楁槸搴忓彿锛堟暟瀛楋級 - Cell seqCell = row.getCell(0); - if (seqCell == null || seqCell.getCellType() != CellType.NUMERIC) { - continue; - } - - // 鍒涘缓椤圭洰璇︽儏 - EamMaintenanceStandardDetail detail = new EamMaintenanceStandardDetail(); - detail.setStandardId(standard.getId()); - detail.setItemCode(Integer.parseInt(getCellStringValue(row.getCell(0)))); - detail.setItemName(getCellStringValue(row.getCell(1))); - detail.setItemCategory(itemCategory); - - // 鏍规嵁椤圭洰绫诲瀷璁剧疆闇�姹傚瓧娈� - if ("DAY_INSPECTION".equals(itemCategory)) { - detail.setItemDemand(getCellStringValue(row.getCell(2))); - } else if ("WEEK_INSPECTION".equals(itemCategory)) { - detail.setItemDemand(getCellStringValue(row.getCell(2))); - } - - details.add(detail); - } - - return details; - } - - /** - * 鏌ユ壘琛ㄦ牸鍖哄煙 - */ - private int[] findTableSection(Sheet sheet, String primaryHeader, String secondaryHeader) { - for (int rowIdx = 0; rowIdx <= sheet.getLastRowNum(); rowIdx++) { - Row row = sheet.getRow(rowIdx); - if (row == null) continue; - - if (isHeaderRow(row, primaryHeader, secondaryHeader)) { - int startRow = rowIdx + 1; - int endRow = findDataEnd(sheet, startRow); - return new int[]{startRow, endRow}; - } - } - return null; - } - - /** - * 妫�鏌ユ槸鍚︿负琛ㄥご琛� - */ - private boolean isHeaderRow(Row row, String header1, String header2) { - boolean foundHeader1 = false; - boolean foundHeader2 = false; - - for (int colIdx = 0; colIdx < row.getLastCellNum(); colIdx++) { - Cell cell = row.getCell(colIdx); - if (cell == null) continue; - - String cellValue = getCellStringValue(cell); - if (cellValue.contains(header1)) foundHeader1 = true; - if (cellValue.contains(header2)) foundHeader2 = true; - } - - return foundHeader1 && foundHeader2; - } - - /** - * 鏌ユ壘鏁版嵁缁撴潫浣嶇疆 - */ - private int findDataEnd(Sheet sheet, int startRow) { - for (int rowIdx = startRow; rowIdx <= sheet.getLastRowNum(); rowIdx++) { - Row row = sheet.getRow(rowIdx); - if (row == null) return rowIdx - 1; - - // 妫�鏌ユ槸鍚︾粨鏉熸爣蹇楄锛堝绛惧瓧琛岋級 - if (isSignatureRow(row)) { - return rowIdx - 1; - } - - // 妫�鏌ユ槸鍚︽柊鐨勮〃澶村紑濮� - if (isNewHeaderStart(row)) { - return rowIdx - 1; - } - } - return sheet.getLastRowNum(); - } - - /** - * 璇嗗埆绛惧瓧琛岀壒寰� - */ - private boolean isSignatureRow(Row row) { - for (int colIdx = 0; colIdx < row.getLastCellNum(); colIdx++) { - Cell cell = row.getCell(colIdx); - if (cell == null) continue; - - String value = getCellStringValue(cell); - if (value.contains("绛惧瓧") || value.contains("璐d换浜�") || - value.contains("鎵ц") || value.contains("纭")) { - return true; - } - } - return false; - } - - /** - * 璇嗗埆鏂拌〃澶村紑濮� - */ - private boolean isNewHeaderStart(Row row) { - for (int colIdx = 0; colIdx < row.getLastCellNum(); colIdx++) { - Cell cell = row.getCell(colIdx); - if (cell == null) continue; - - String value = getCellStringValue(cell); - if ("搴忓彿".equals(value) || "鐐规椤圭洰".equals(value) || "鍛ㄤ繚鍏婚」鐩�".equals(value)) { - return true; - } - } - return false; - } - - /** - * 妫�鏌ヨ鏄惁涓虹┖ - */ - private boolean isEmptyRow(Row row) { - if (row == null) return true; - for (int colIdx = 0; colIdx < row.getLastCellNum(); colIdx++) { - Cell cell = row.getCell(colIdx); - if (cell != null && cell.getCellType() != CellType.BLANK) { - String value = getCellStringValue(cell); - if (StringUtils.isNotBlank(value)) { - return false; - } - } - } - return true; - } - - /** * 浣跨敤姝e垯鎻愬彇瀛楁 */ private String extractField(String text, String regex) { @@ -903,10 +735,139 @@ } /** - * 鑾峰彇鍗曞厓鏍煎瓧绗︿覆鍊� + * 鎻愬彇姣忔棩鐐规椤圭洰 + */ + private List<EamMaintenanceStandardDetail> extractDailyItems(Sheet sheet, EamMaintenanceStandard standard, Map<Integer, String> rowErrors) { + // 浣跨敤澶氬叧閿瘝鍖归厤 + String[] primaryHeaders = {"鐐规椤圭洰", "鏃ュ父鐐规", "姣忔棩妫�鏌�"}; + String[] secondaryHeaders = {"瀹屾垚鏁版嵁/瑕佹眰", "妫�鏌ユ爣鍑�", "瑕佹眰"}; + return extractItems(sheet, standard, primaryHeaders, secondaryHeaders, "DAY_INSPECTION", rowErrors); + } + + /** + * 鎻愬彇鍛ㄤ繚鍏婚」鐩� + */ + private List<EamMaintenanceStandardDetail> extractWeeklyItems(Sheet sheet, EamMaintenanceStandard standard, Map<Integer, String> rowErrors) { + // 浣跨敤澶氬叧閿瘝鍖归厤 + String[] primaryHeaders = {"鍛ㄤ繚鍏婚」鐩�", "鍛ㄤ繚鍏�", "姣忓懆淇濆吇"}; + String[] secondaryHeaders = {"妫�鏌ユ爣鍑�", "淇濆吇瑕佹眰", "鏍囧噯"}; + return extractItems(sheet, standard, primaryHeaders, secondaryHeaders, "WEEK_INSPECTION", rowErrors); + } + + /** + * 鏍稿績鏀硅繘锛氫紭鍖栬〃鏍煎尯鍩熻瘑鍒拰鏁版嵁鎻愬彇 + */ + private List<EamMaintenanceStandardDetail> extractItems(Sheet sheet, + EamMaintenanceStandard standard, + String[] primaryHeaders, + String[] secondaryHeaders, + String itemCategory, + Map<Integer, String> rowErrors) { + + // 1. 瀹氫綅琛ㄦ牸鍖哄煙锛堢簿纭尮閰嶈〃澶达級 + int startRow = findHeaderRow(sheet, primaryHeaders, secondaryHeaders); + if (startRow == -1) { + rowErrors.put(-1, "鏈壘鍒�" + Arrays.toString(primaryHeaders) + "琛ㄥご鍖哄煙"); + return Collections.emptyList(); + } + + int endRow = findDataEnd(sheet, startRow + 1, "鍛ㄤ繚鍏婚」鐩�"); + + // 鎻愬彇鏃ュ織锛堝疄闄呬娇鐢ㄦ椂鍙互鍘绘帀锛� + System.out.println("鎻愬彇鍖哄煙: " + (startRow + 1) + "琛屽埌" + (endRow + 1) + "琛�"); + + // 2. 鎻愬彇鏁版嵁琛� + List<EamMaintenanceStandardDetail> details = new ArrayList<>(); + for (int rowIdx = startRow + 1; rowIdx <= endRow; rowIdx++) { + Row row = sheet.getRow(rowIdx); + if (row == null) continue; + + try { + // 搴忓彿鍒楀鐞� + Cell seqCell = row.getCell(0); + if (seqCell == null || seqCell.getCellType() == CellType.BLANK) { + continue; + } + + // 鑾峰彇搴忓彿鍊硷紙鏀寔鏁板瓧鍜屾枃鏈牸寮忥級 + int seqValue = 0; + try { + if (seqCell.getCellType() == CellType.NUMERIC) { + seqValue = (int) seqCell.getNumericCellValue(); + } else if (seqCell.getCellType() == CellType.STRING) { + seqValue = Integer.parseInt(seqCell.getStringCellValue().trim()); + } + } catch (NumberFormatException e) { + rowErrors.put(rowIdx + 1, "搴忓彿鏍煎紡閿欒"); + continue; + } + + // 椤圭洰鍚嶇О鍒楋紙绗簩鍒楋級 + Cell nameCell = row.getCell(1); + if (nameCell == null || nameCell.getCellType() == CellType.BLANK) { + continue; + } + String itemName = getCellStringValue(nameCell).trim(); + + // 瑕佹眰/鏍囧噯鍒楋紙绗笁鍒楋級 + String demand = ""; + if (row.getLastCellNum() >= 3) { + Cell demandCell = row.getCell(2); + if (demandCell != null) { + demand = getCellStringValue(demandCell).trim(); + } + } + + // 鍒涘缓璇︽儏瀵硅薄 + EamMaintenanceStandardDetail detail = new EamMaintenanceStandardDetail(); + detail.setStandardId(standard.getId()); + detail.setItemCode(seqValue); + detail.setItemName(itemName); + detail.setItemDemand(demand); + detail.setItemCategory(itemCategory); + details.add(detail); + + } catch (Exception e) { + rowErrors.put(rowIdx + 1, "瑙f瀽閿欒: " + e.getMessage()); + } + } + return details; + } + + /** + * 鑾峰彇琛屼腑鎵�鏈夊崟鍏冩牸鐨勫瓧绗︿覆鍊� + */ + private List<String> getRowStringValues(Row row) { + List<String> values = new ArrayList<>(); + if (row == null) return values; + + for (int cellIdx = 0; cellIdx < row.getLastCellNum(); cellIdx++) { + Cell cell = row.getCell(cellIdx); + if (cell != null) { + values.add(getCellStringValue(cell)); + } else { + values.add(""); // 瀵逛簬绌哄崟鍏冩牸娣诲姞绌哄瓧绗︿覆 + } + } + return values; + } + + /** + * 鑾峰彇鍗曞厓鏍煎瓧绗︿覆鍊硷紙澧炲己鍏紡澶勭悊锛� */ private String getCellStringValue(Cell cell) { - if (cell == null) return ""; + if (cell == null) { + return ""; + } + // 淇濇寔涓嶅彉锛屼絾娣诲姞鏁板瓧绫诲瀷澶勭悊 + if (cell.getCellType() == CellType.NUMERIC) { + // 鏁存暟澶勭悊 + double num = cell.getNumericCellValue(); + if (num == (int) num) { + return String.valueOf((int) num); + } + return String.valueOf(num); + } switch (cell.getCellType()) { case STRING: return cell.getStringCellValue().trim(); @@ -918,22 +879,117 @@ case BOOLEAN: return String.valueOf(cell.getBooleanCellValue()); case FORMULA: - return handleFormulaCell(cell); + return getFormulaCellValue(cell); default: return ""; } } /** - * 澶勭悊鍏紡鍗曞厓鏍� + * 绮剧‘鏌ユ壘琛ㄥご琛� + */ + private int findHeaderRow(Sheet sheet, String[] primaryHeaders, String[] secondaryHeaders) { + for (int rowIdx = 0; rowIdx <= sheet.getLastRowNum(); rowIdx++) { + Row row = sheet.getRow(rowIdx); + if (row == null) continue; + + String rowText = getRowStringValues(row).stream().collect(Collectors.joining()); + + // 妫�鏌ヤ富鏍囬鍜屽壇鏍囬 + boolean hasPrimary = false; + boolean hasSecondary = false; + + for (String header : primaryHeaders) { + if (rowText.contains(header)) { + hasPrimary = true; + break; + } + } + + for (String header : secondaryHeaders) { + if (rowText.contains(header)) { + hasSecondary = true; + break; + } + } + + if (hasPrimary && hasSecondary) { + return rowIdx; + } + } + return -1; + } + + /** + * 鏌ユ壘鏁版嵁缁撴潫浣嶇疆锛堟牴鎹偍鐨凟xcel缁撴瀯浼樺寲锛� */ - private String handleFormulaCell(Cell cell) { + private int findDataEnd(Sheet sheet, int startRow, String nextSectionKeyword) { + int consecutiveEmptyRows = 0; + final int MAX_EMPTY_ROWS = 3; + + for (int rowIdx = startRow; rowIdx <= sheet.getLastRowNum(); rowIdx++) { + Row row = sheet.getRow(rowIdx); + + // 鍏抽敭鏀硅繘1锛氱┖琛屽鐞� + if (isEssentiallyEmpty(row)) { + consecutiveEmptyRows++; + if (consecutiveEmptyRows >= MAX_EMPTY_ROWS) { + return rowIdx - consecutiveEmptyRows; + } + continue; + } else { + consecutiveEmptyRows = 0; + } + + // 鍏抽敭鏀硅繘2锛氱粨鏉熸爣璁版娴� + String rowText = getRowStringValues(row).stream().collect(Collectors.joining()); + + // 鏍规嵁鎮ㄧ殑Excel缁撴瀯锛岀瀛楄鏈夌壒瀹氭牸寮� + if (rowText.contains("缁存姢璐d换浜虹瀛�")) { + return rowIdx - 1; + } + + // 妫�娴嬩笅涓�涓尯鍩熺殑寮�濮嬶紙濡傚懆淇濆吇椤圭洰锛� + if (StringUtils.isNotBlank(nextSectionKeyword) && + rowText.contains(nextSectionKeyword)) { + return rowIdx - 1; + } + } + return sheet.getLastRowNum(); + } + + /** + * 鍒ゆ柇鏉′欢锛氬墠涓ゅ垪涓虹┖鍗宠涓虹┖琛� + */ + private boolean isEssentiallyEmpty(Row row) { + if (row == null) return true; + + // 妫�鏌ュ簭鍙峰垪 + Cell indexCell = row.getCell(0); + if (indexCell != null && indexCell.getCellType() != CellType.BLANK) { + return false; + } + + // 妫�鏌ラ」鐩悕绉板垪 + Cell nameCell = row.getCell(1); + if (nameCell != null && nameCell.getCellType() != CellType.BLANK) { + return false; + } + + return true; + } + + /** + * 鑾峰彇鍏紡鍗曞厓鏍煎�� + */ + private String getFormulaCellValue(Cell cell) { try { - FormulaEvaluator evaluator = cell.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator(); + Workbook workbook = cell.getSheet().getWorkbook(); + FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); CellValue cellValue = evaluator.evaluate(cell); - - if (cellValue == null) return ""; - + if (cellValue == null) { + return ""; + } switch (cellValue.getCellType()) { case STRING: return cellValue.getStringValue(); @@ -945,9 +1001,67 @@ return ""; } } catch (Exception e) { + log.warn("瑙f瀽鍏紡鍗曞厓鏍煎け璐�"); return ""; } } + + + private int findDataEnd(Sheet sheet, int startRow) { + int consecutiveEmptyRows = 0; + final int MAX_EMPTY_ROWS = 2; + boolean foundData = false; + + for (int rowIdx = startRow; rowIdx <= sheet.getLastRowNum(); rowIdx++) { + Row row = sheet.getRow(rowIdx); + + // 鍏抽敭浼樺寲1锛氬厛妫�鏌ユ槸鍚︿负绌鸿 + if (isEmptyRow(row)) { + consecutiveEmptyRows++; + if (consecutiveEmptyRows >= MAX_EMPTY_ROWS) { + return foundData ? rowIdx - consecutiveEmptyRows : startRow; + } + continue; + } else { + consecutiveEmptyRows = 0; + } + + // 鍏抽敭浼樺寲2锛氫弗鏍奸檺瀹氱粨鏉熸爣璁扮殑璇嗗埆鏉′欢 + if (isStrongEndMarker(row)) { + return foundData ? rowIdx - 1 : startRow; + } + + // 鍏抽敭浼樺寲3锛氭爣璁板凡鎵惧埌鏈夋晥鏁版嵁 + foundData = true; + } + return sheet.getLastRowNum(); + } + + // 澧炲己鐗堢粨鏉熸爣璁拌瘑鍒� + private boolean isStrongEndMarker(Row row) { + String rowText = String.join("", getRowStringValues(row)).toLowerCase(); + + return + // 绮剧‘鍖归厤绛惧瓧鐗瑰緛锛堝嚭鐜板湪琛岄锛� + (rowText.startsWith("缁存姢璐d换浜虹瀛�") || + rowText.startsWith("鎵ц浜虹瀛�")) || + // 绮剧‘鍖归厤鏂版澘鍧楁爣棰� + rowText.matches("^\\s*鍛ㄤ繚鍏婚」鐩甛\s*$") || + rowText.contains("骞村害淇濆吇椤圭洰"); + } + + // 绌鸿妫�娴嬩紭鍖栵紙鍏佽閮ㄥ垎鍒椾负绌猴級 + private boolean isEmptyRow(Row row) { + if (row == null) return true; + // 鍙鏌ュ墠3鍒楋紙搴忓彿鍒�+椤圭洰鍚�+瑕佹眰锛� + for (int cellIdx = 0; cellIdx < Math.min(3, row.getLastCellNum()); cellIdx++) { + Cell cell = row.getCell(cellIdx); + if (cell != null && cell.getCellType() != CellType.BLANK) { + return false; + } + } + return true; + } /*瀵煎叆鐐规鏂囦欢Excel--------------------------缁撴潫*/ /*瀵煎叆浜屼繚涓変繚鏂囦欢Excel--------------------------寮�濮�*/ diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamSecondMaintenanceOrderServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamSecondMaintenanceOrderServiceImpl.java index d19d873..1827589 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamSecondMaintenanceOrderServiceImpl.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamSecondMaintenanceOrderServiceImpl.java @@ -3,12 +3,12 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; import org.flowable.engine.TaskService; @@ -33,6 +33,10 @@ import org.jeecg.modules.flowable.apithird.service.FlowCommonService; import org.jeecg.modules.flowable.service.IFlowDefinitionService; import org.jeecg.modules.flowable.service.IFlowTaskService; +import org.jeecg.modules.system.entity.BaseFactory; +import org.jeecg.modules.system.entity.BaseFactoryUser; +import org.jeecg.modules.system.service.IBaseFactoryService; +import org.jeecg.modules.system.service.IBaseFactoryUserService; import org.jeecg.modules.system.service.ISysUserService; import org.jeecg.modules.system.vo.UserSelector; import org.springframework.beans.factory.annotation.Autowired; @@ -66,7 +70,10 @@ private TaskService taskService; @Autowired private IFlowTaskService flowTaskService; - + @Autowired + private IBaseFactoryUserService baseFactoryUserService; + @Autowired + private IBaseFactoryService baseFactoryService; @Autowired private ISysUserService sysUserService; @Autowired @@ -84,13 +91,21 @@ if (sysUser == null) { return page; } - if (StringUtils.isNotBlank(sysUser.getEquipmentIds())) { + if (StringUtils.isNotBlank(sysUser.getEamEquipmentIds())) { //閫夋嫨浜嗚澶囷紝鏍规嵁璁惧id杩囨护璁惧 - List<String> equipArr = Arrays.asList(sysUser.getEquipmentIds().split(",")); + List<String> equipArr = Arrays.asList(sysUser.getEamEquipmentIds().split(",")); queryWrapper.in("e.equipment_code", equipArr); } else { - //娌℃湁閫夋嫨璁惧锛屾牴鎹溅闂磋繃婊よ澶� - queryWrapper.exists("select 1 from mdc_user_production t where t.user_id={0} and t.pro_id=e.org_id ", sysUser.getId()); + //娌℃湁閫夋嫨璁惧锛屾牴鎹腑蹇冭繃婊よ澶� + List<BaseFactoryUser> baseFactoryUserList=baseFactoryUserService. + list(new LambdaQueryWrapper<BaseFactoryUser>().eq(BaseFactoryUser::getUserId,sysUser.getId())); + if(!CollectionUtils.isEmpty(baseFactoryUserList)){ + 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 (query != null) { @@ -370,17 +385,6 @@ //璁剧疆entity entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.WAIT_CONFIRM.name()); entity.setActualEndTime(new Date()); - //澶勭悊闄勪欢 - if (CollectionUtil.isNotEmpty(request.getImageFilesResult())) { - List<FileUploadResult> fileUploadResultList = request.getImageFilesResult(); - ObjectMapper mapper = new ObjectMapper(); - try { - String referenceFile = mapper.writeValueAsString(fileUploadResultList); - entity.setImageFiles(referenceFile); - } catch (JsonProcessingException e) { - log.error("JSON杞崲澶辫触锛�" + e.getMessage(), e); - } - } //澶勭悊璇︽儏 if (CollectionUtil.isNotEmpty(request.getTableDetailList())) { secondMaintenanceOrderDetailService.updateBatchById(request.getTableDetailList()); @@ -403,10 +407,7 @@ request.setComment(request.getConfirmComment()); //璁剧疆entity entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.WAIT_LEADER_CONFIRM.name()); - entity.setConfirmUser(user.getUsername()); - entity.setConfirmComment(request.getConfirmComment()); entity.setConfirmTime(new Date()); - entity.setConfirmDealType(request.getConfirmDealType()); if (CommonConstant.HAS_CANCLE.equals(request.getConfirmDealType())) { //椹冲洖 userApprovalList = new ArrayList<>(); @@ -427,9 +428,6 @@ request.setComment(request.getLeaderConfirmComment()); //璁剧疆entity entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.COMPLETE.name()); - entity.setConfirmLeader(user.getUsername()); - entity.setLeaderConfirmComment(request.getLeaderConfirmComment()); - entity.setLeaderConfirmTime(new Date()); //鏇存柊璁惧淇濆吇鐘舵�� eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.NORMAL.name()); break; diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/util/WorkShopOrgCodeProRule.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/rule/WorkShopOrgCodeProRule.java similarity index 98% rename from lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/util/WorkShopOrgCodeProRule.java rename to lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/rule/WorkShopOrgCodeProRule.java index f78635a..4a6ed59 100644 --- a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/util/WorkShopOrgCodeProRule.java +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/rule/WorkShopOrgCodeProRule.java @@ -1,4 +1,4 @@ -package org.jeecg.modules.system.util; +package org.jeecg.modules.system.rule; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/BaseFactoryServiceImpl.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/BaseFactoryServiceImpl.java index 3406dd7..0062273 100644 --- a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/BaseFactoryServiceImpl.java +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/BaseFactoryServiceImpl.java @@ -122,87 +122,47 @@ String[] levels = path.split("/"); int depth = levels.length; - // 鏀寔澶氱鏍煎紡锛氫腑蹇�/宸ュ尯銆佷腑蹇�/宸ユ銆佷腑蹇�/宸ュ尯/宸ユ + // 鏀寔鏍煎紡锛氫腑蹇�/宸ュ尯銆佷腑蹇�/宸ユ銆佷腑蹇�/宸ュ尯/宸ユ if (depth < 2 || depth > 3) { return null; } - // 浠庡簳灞傚紑濮嬫煡璇細鏈�鍚庝竴绾у彲鑳芥槸宸ュ尯鎴栧伐娈� - String lastName = levels[depth - 1]; - BaseFactory lastLevel = searchForLastLevel(lastName); - if (lastLevel == null) return null; + // 浠庨《灞傚紑濮嬫煡璇� - 绗�1绾э細涓績鑺傜偣 + BaseFactory center = findFactory(levels[0], 1, null); + if (center == null) return null; - return validatePath(levels, lastLevel); - } - - private BaseFactory validatePath(String[] levels, BaseFactory lastLevel) { - if (levels.length == 2) { - // 涓績/宸ュ尯 鎴� 涓績/宸ユ - BaseFactory center = findParentCenter(lastLevel); - if (center != null && - center.getFactoryName().equals(levels[0]) && - ("1").equals(center.getFactoryCategory())) { - return lastLevel; + // 绗�2绾ф煡璇細宸ュ尯鎴栧伐娈� + BaseFactory secondLevel; + if (depth == 2) { + // 鍏煎鏂规锛氫紭鍏堟煡宸ユ鍐嶆煡宸ュ尯 + secondLevel = findFactory(levels[1], 3, center.getId()); + if (secondLevel == null) { + secondLevel = findFactory(levels[1], 2, center.getId()); } + return secondLevel; // 鍙兘涓簄ull } else { - // 涓績/宸ュ尯/宸ユ - if (!("3").equals(lastLevel.getFactoryCategory())) return null; + // 绗�2绾у繀椤绘槸宸ュ尯 + BaseFactory workArea = findFactory(levels[1], 2, center.getId()); + if (workArea == null) return null; - BaseFactory workArea = getById(lastLevel.getParentId()); - if (workArea == null || - !("2").equals(workArea.getFactoryCategory())) return null; - - BaseFactory center = getById(workArea.getParentId()); - if (center == null || - !("1").equals(center.getFactoryCategory())) return null; - - if (workArea.getFactoryName().equals(levels[1]) && - center.getFactoryName().equals(levels[0])) { - return lastLevel; - } + // 绗�3绾э細宸ユ + return findFactory(levels[2], 3, workArea.getId()); } - return null; } - private BaseFactory searchForLastLevel(String name) { - // 鍏堝皾璇曟煡璇㈠伐娈碉紙绫诲埆3锛� - BaseFactory workshop = findFactory(name, 3, null); - if (workshop != null) return workshop; - - // 濡傛灉娌℃湁鎵惧埌宸ユ锛屽皾璇曟煡璇㈠伐鍖猴紙绫诲埆2锛� - return findFactory(name, 2, null); - } - - private BaseFactory findParentCenter(BaseFactory entity) { - if (("1").equals(entity.getFactoryCategory())) { - return entity; // 鏈韩灏辨槸涓績 - } - - BaseFactory parent = getById(entity.getParentId()); - if (parent == null) return null; - - if (("1").equals(parent.getFactoryCategory())) { - return parent; // 鐩存帴鐖剁骇鏄腑蹇� - } - - // 濡傛灉鐖剁骇涓嶆槸涓績锛屽皾璇曟壘鐖剁骇鐨勭埗绾� - return getById(parent.getParentId()); - } - + // 淇濇寔涓嶅彉 private BaseFactory searchByCodeOrName(String keyword) { - // 浣跨敤鍒嗛〉鏂瑰紡鍏煎SQL Server LambdaQueryWrapper<BaseFactory> query = new LambdaQueryWrapper<>(); query.and(q -> q.eq(BaseFactory::getFactoryName, keyword) .or() .like(BaseFactory::getFactoryCode, keyword)); - // 浣跨敤鍒嗛〉鏌ヨ鑾峰彇绗竴鏉¤褰� Page<BaseFactory> page = new Page<>(1, 1); Page<BaseFactory> resultPage = baseMapper.selectPage(page, query); - return resultPage.getRecords().isEmpty() ? null : resultPage.getRecords().get(0); } + // 淇濇寔涓嶅彉 private BaseFactory findFactory(String name, Integer category, String parentId) { LambdaQueryWrapper<BaseFactory> query = new LambdaQueryWrapper<>(); query.eq(BaseFactory::getFactoryName, name); @@ -210,17 +170,11 @@ if (category != null) query.eq(BaseFactory::getFactoryCategory, category); if (parentId != null) query.eq(BaseFactory::getParentId, parentId); - // 浣跨敤鍒嗛〉鏂瑰紡鍏煎SQL Server Page<BaseFactory> page = new Page<>(1, 1); Page<BaseFactory> resultPage = baseMapper.selectPage(page, query); - return resultPage.getRecords().isEmpty() ? null : resultPage.getRecords().get(0); } - private BaseFactory getById(String id) { - if (StringUtils.isBlank(id)) return null; - return baseMapper.selectById(id); - } /** * saveProductionData 瀵瑰簲 add 淇濆瓨鐢ㄦ埛鍦ㄩ〉闈㈡坊鍔犵殑鏂扮殑璁惧杞﹂棿绠$悊瀵硅薄鏁版嵁 diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java index cb14a54..8d4621f 100644 --- a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java @@ -796,7 +796,7 @@ if (CollectionUtil.isNotEmpty(factoryIds)) { String factory = String.join(",", factoryIds); String inClause = "(" + factory + ")"; - queryWrapper.exists("select 1 from eam_base_factory_user t where t.user_id=sys_user.id and t.factory_id in {0}", inClause); + queryWrapper.exists("select 1 from eam_base_factory_user t where t.user_id=sys_user.id and t.factory_id in "+inClause); } else { return Collections.emptyList(); } -- Gitblit v1.9.3