diff --git a/casic-metering-service/src/main/java/com/casic/missiles/service/Impl/eqpt/standard/impl/PressureGaugeHandler.java b/casic-metering-service/src/main/java/com/casic/missiles/service/Impl/eqpt/standard/impl/PressureGaugeHandler.java index 35a24e2..445b6e7 100644 --- a/casic-metering-service/src/main/java/com/casic/missiles/service/Impl/eqpt/standard/impl/PressureGaugeHandler.java +++ b/casic-metering-service/src/main/java/com/casic/missiles/service/Impl/eqpt/standard/impl/PressureGaugeHandler.java @@ -119,12 +119,7 @@ List setPointGaugeList = new ArrayList<>(); List setPointList = new ArrayList<>(); //过滤不能生成证书的 - if (CollectionUtil.isEmpty(measureItemInfo.getMeasureDataPistonGaugeList())) { - List bizBusinessDeviceMeasureDataPistonGaugeList = new ArrayList<>(); - bizBusinessDeviceMeasureDataPistonGaugeList.add(new BizBusinessDeviceMeasureDataPistonGauge()); - measureItemInfo.setMeasureDataPistonGaugeList(bizBusinessDeviceMeasureDataPistonGaugeList); - resultList.add(new BizBusinessDeviceMeasureDataPistonGauge()); - } else { + if (CollectionUtil.isNotEmpty(measureItemInfo.getMeasureDataPistonGaugeList())) { if (org.apache.commons.collections.CollectionUtils.isNotEmpty(measureItemInfo.getMeasureDataPistonGaugeList())) { for (BizBusinessDeviceMeasureDataPistonGauge pistonGauge : measureItemInfo.getMeasureDataPistonGaugeList()) { BizBusinessDeviceMeasureDataPistonGauge safety = (BizBusinessDeviceMeasureDataPistonGauge) BeanUtils.cloneBean(pistonGauge); @@ -215,12 +210,7 @@ List setPointGaugeList = new ArrayList<>(); List setPointList = new ArrayList<>(); //过滤不能生成证书的 - if (CollectionUtil.isEmpty(measureItemInfo.getMeasureDataPistonGaugeList())) { - List bizBusinessDeviceMeasureDataPistonGaugeList = new ArrayList<>(); - bizBusinessDeviceMeasureDataPistonGaugeList.add(new BizBusinessDeviceMeasureDataPistonGauge()); - measureItemInfo.setMeasureDataPistonGaugeList(bizBusinessDeviceMeasureDataPistonGaugeList); - resultList.add(new BizBusinessDeviceMeasureDataPistonGauge()); - } else { + if (CollectionUtil.isNotEmpty(measureItemInfo.getMeasureDataPistonGaugeList())) { List safetyList = new ArrayList<>(); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(measureItemInfo.getMeasureDataPistonGaugeList())) { for (BizBusinessDeviceMeasureDataPistonGauge pistonGauge : measureItemInfo.getMeasureDataPistonGaugeList()) { diff --git a/casic-metering-service/src/main/java/com/casic/missiles/service/Impl/eqpt/standard/impl/PressureGaugeHandler.java b/casic-metering-service/src/main/java/com/casic/missiles/service/Impl/eqpt/standard/impl/PressureGaugeHandler.java index 35a24e2..445b6e7 100644 --- a/casic-metering-service/src/main/java/com/casic/missiles/service/Impl/eqpt/standard/impl/PressureGaugeHandler.java +++ b/casic-metering-service/src/main/java/com/casic/missiles/service/Impl/eqpt/standard/impl/PressureGaugeHandler.java @@ -119,12 +119,7 @@ List setPointGaugeList = new ArrayList<>(); List setPointList = new ArrayList<>(); //过滤不能生成证书的 - if (CollectionUtil.isEmpty(measureItemInfo.getMeasureDataPistonGaugeList())) { - List bizBusinessDeviceMeasureDataPistonGaugeList = new ArrayList<>(); - bizBusinessDeviceMeasureDataPistonGaugeList.add(new BizBusinessDeviceMeasureDataPistonGauge()); - measureItemInfo.setMeasureDataPistonGaugeList(bizBusinessDeviceMeasureDataPistonGaugeList); - resultList.add(new BizBusinessDeviceMeasureDataPistonGauge()); - } else { + if (CollectionUtil.isNotEmpty(measureItemInfo.getMeasureDataPistonGaugeList())) { if (org.apache.commons.collections.CollectionUtils.isNotEmpty(measureItemInfo.getMeasureDataPistonGaugeList())) { for (BizBusinessDeviceMeasureDataPistonGauge pistonGauge : measureItemInfo.getMeasureDataPistonGaugeList()) { BizBusinessDeviceMeasureDataPistonGauge safety = (BizBusinessDeviceMeasureDataPistonGauge) BeanUtils.cloneBean(pistonGauge); @@ -215,12 +210,7 @@ List setPointGaugeList = new ArrayList<>(); List setPointList = new ArrayList<>(); //过滤不能生成证书的 - if (CollectionUtil.isEmpty(measureItemInfo.getMeasureDataPistonGaugeList())) { - List bizBusinessDeviceMeasureDataPistonGaugeList = new ArrayList<>(); - bizBusinessDeviceMeasureDataPistonGaugeList.add(new BizBusinessDeviceMeasureDataPistonGauge()); - measureItemInfo.setMeasureDataPistonGaugeList(bizBusinessDeviceMeasureDataPistonGaugeList); - resultList.add(new BizBusinessDeviceMeasureDataPistonGauge()); - } else { + if (CollectionUtil.isNotEmpty(measureItemInfo.getMeasureDataPistonGaugeList())) { List safetyList = new ArrayList<>(); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(measureItemInfo.getMeasureDataPistonGaugeList())) { for (BizBusinessDeviceMeasureDataPistonGauge pistonGauge : measureItemInfo.getMeasureDataPistonGaugeList()) { diff --git a/casic-metering-service/src/main/java/com/casic/missiles/service/listeners/register/util/ParseWord07.java b/casic-metering-service/src/main/java/com/casic/missiles/service/listeners/register/util/ParseWord07.java index 64df2cb..a3aea80 100644 --- a/casic-metering-service/src/main/java/com/casic/missiles/service/listeners/register/util/ParseWord07.java +++ b/casic-metering-service/src/main/java/com/casic/missiles/service/listeners/register/util/ParseWord07.java @@ -228,44 +228,63 @@ int positionIndex = tryGetInitialMergeRow(table); //查询合并索引的列 List mergeIndexList = checkThisTableCellMergeIndex(positionIndex, table, mergeColNames); - Map mergeIndexMap = mergeIndexList.stream().collect(Collectors.toMap(e -> e, e -> e)); - //直到查询的上下列不一样的时候,停止遍历列的循环,停止遍历 - while (positionIndex < table.getNumberOfRows()) { - XWPFTableRow row = table.getRow(positionIndex); - if (row == null) { - return; - } - int tempIndex = 1; - int startIndex = positionIndex, maxEndIndex = positionIndex; - for (int i = 0; i < row.getTableCells().size(); i++) { - if (!mergeIndexMap.containsKey(i)) { - continue; - } - int endIndex = positionIndex; - int rowIndex = positionIndex + 1; - while ((maxEndIndex > positionIndex && rowIndex <= maxEndIndex) || tempIndex == 1) { - if (rowIndex >= table.getRows().size()) { - break; - } - if (table.getRow(rowIndex).getTableCells().get(i).getText().equals(row.getCell(i).getText())) { - endIndex = rowIndex; - rowIndex++; - } else { - break; - } - } - maxEndIndex = endIndex; - if (endIndex > startIndex) { - doMergeCell(table, startIndex, endIndex, i); - } - tempIndex++; - } - positionIndex = maxEndIndex + 1; + if (!ObjectUtils.isEmpty(table.getRows()) && !ObjectUtils.isEmpty(mergeIndexMap)) { + recursiveMergeCell(table.getRows().get(0).getTableCells().size(), 0, 1, table.getNumberOfRows(), table, mergeIndexMap); } } } + /** + * 递归合并相同列的上下行,cz + * + * @param maxColIndex 最大列下标 + * @param currentColIndex 当前列下标 + * @param startRowIndex 开始行下标 + * @param maxRowIndex 最大行下标 + * @param table 当前表 + * @param mergeIndexMap 合并列集合 + */ + private void recursiveMergeCell(Integer maxColIndex, int currentColIndex, int startRowIndex, int maxRowIndex, XWPFTable table, Map mergeIndexMap) { + Integer endRowIndex = startRowIndex; + if (currentColIndex >= maxColIndex) { + return; + } + //是否满足需要进行合并 + if (!mergeIndexMap.containsKey(currentColIndex)) { + //当前列不做合并,不合并则进行下列进行查询 + recursiveMergeCell(endRowIndex, currentColIndex + 1, startRowIndex, maxRowIndex, table, mergeIndexMap); + return; + } + while (endRowIndex < maxRowIndex) { + //参考行列的文本内容 + String lastRow = ""; + //健壮性校验 + while (endRowIndex < maxRowIndex && ObjectUtils.isEmpty(table.getRow(startRowIndex))) { + startRowIndex++; + } + lastRow = table.getRow(startRowIndex).getTableCells().get(currentColIndex).getText(); + Integer tempIndex = startRowIndex + 1; + //循环判断文本是否一致,并满足健壮性的校验 + while (tempIndex < maxRowIndex + && !ObjectUtils.isEmpty(table.getRow(tempIndex)) + && table.getRow(tempIndex).getTableCells().get(currentColIndex).getText().equals(lastRow)) { + endRowIndex = tempIndex; + tempIndex++; + } + //如果当前偏移行数大于起始行数,则需要合并 + if (endRowIndex > startRowIndex) { + //执行单元格行合并 + doMergeCell(table, startRowIndex, endRowIndex, currentColIndex); + //递归到下一列进行判断 + recursiveMergeCell(endRowIndex, currentColIndex + 1, startRowIndex, maxRowIndex, table, mergeIndexMap); + } + //继续判断合并以后的行数,是否满足最后的大查询 + startRowIndex = endRowIndex + 1; + endRowIndex = startRowIndex; + } + } + private Integer tryGetInitialMergeRow(XWPFTable table) { int positionIndex = 1, initialMergeRow = 0; while (positionIndex < table.getNumberOfRows()) {