diff --git a/src/main/java/com/xkrs/service/impl/QcSourceServiceImpl.java b/src/main/java/com/xkrs/service/impl/QcSourceServiceImpl.java index 511e710..65228ea 100644 --- a/src/main/java/com/xkrs/service/impl/QcSourceServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/QcSourceServiceImpl.java @@ -394,23 +394,39 @@ public class QcSourceServiceImpl implements QcSourceService { if (resultList == null || resultList.isEmpty()) { return formatResultList; } - List headList = new ArrayList<>(EXCEL_HEAD_STYLE_ONE_NAME); + boolean needProcessBatch = needProcessBatch(resultList); + List headList = new ArrayList<>(); + for (int i = 0; i < EXCEL_HEAD_STYLE_ONE_NAME.size(); i++) { + if (i == 7) { + if (needProcessBatch) { + headList.add(EXCEL_HEAD_STYLE_ONE_NAME.get(i)); + } + } else { + headList.add(EXCEL_HEAD_STYLE_ONE_NAME.get(i)); + } + } for (QcItemEntity qcItemEntity : qcItemList) { headList.add(qcItemEntity.getQcItemName()); } formatResultList.add(headList); - for (Map dataMap : resultList) { + for (Map result : resultList) { List dataList = new ArrayList<>(); - dataList.add((String) dataMap.get(EXCEL_HEAD_STYLE_ONE_NO.get(0))); - dataList.add((String) dataMap.get(EXCEL_HEAD_STYLE_ONE_NO.get(1))); - dataList.add((String) dataMap.get(EXCEL_HEAD_STYLE_ONE_NO.get(2))); - dataList.add((String) dataMap.get(EXCEL_HEAD_STYLE_ONE_NO.get(3))); - dataList.add((String) dataMap.get(EXCEL_HEAD_STYLE_ONE_NO.get(4))); - dataList.add((String) dataMap.get(EXCEL_HEAD_STYLE_ONE_NO.get(5))); - dataList.add(LocalDateUtils.exportFormatCurrentSecond((String) dataMap.get(EXCEL_HEAD_STYLE_ONE_NO.get(6)))); - dataList.add((String) dataMap.get(EXCEL_HEAD_STYLE_ONE_NO.get(7))); + dataList.add((String) result.get(EXCEL_HEAD_STYLE_ONE_NO.get(0))); + dataList.add((String) result.get(EXCEL_HEAD_STYLE_ONE_NO.get(1))); + dataList.add((String) result.get(EXCEL_HEAD_STYLE_ONE_NO.get(2))); + dataList.add((String) result.get(EXCEL_HEAD_STYLE_ONE_NO.get(3))); + dataList.add((String) result.get(EXCEL_HEAD_STYLE_ONE_NO.get(4))); + dataList.add((String) result.get(EXCEL_HEAD_STYLE_ONE_NO.get(5))); + dataList.add(LocalDateUtils.exportFormatCurrentSecond((String) result.get(EXCEL_HEAD_STYLE_ONE_NO.get(6)))); + if (needProcessBatch) { + if (isProcessBatch(result)) { + dataList.add((String) result.get(EXCEL_HEAD_STYLE_ONE_NO.get(7))); + } else { + dataList.add(""); + } + } for (QcItemEntity entity : qcItemList) { - String value = (String) dataMap.getOrDefault(entity.getQcItemNo(), ""); + String value = (String) result.getOrDefault(entity.getQcItemNo(), ""); if (Constant.QC_ITEM_TYPE_STRING.equals(entity.getQcItemType())) { dataList.add(value); } else if (Constant.QC_ITEM_TYPE_PICTURE.equals(entity.getQcItemType())) { @@ -428,6 +444,30 @@ public class QcSourceServiceImpl implements QcSourceService { return formatResultList; } + /** + * 这个表格是否需要过程抽检批次这个表头 + * 只要存在一条项目工艺编号为U001的数据,就需要这个表头 + */ + private boolean needProcessBatch(List> resultList) { + for (Map result : resultList) { + if ("U001".equals((String) result.get(EXCEL_HEAD_STYLE_ONE_NO.get(5)))) { + return true; + } + } + return false; + } + + /** + * 表格中的本行记录是否是成型过程工检数据 + * 如果项目工艺编号为U001,那就是 + */ + private boolean isProcessBatch(Map result) { + if ("U001".equals((String) result.get(EXCEL_HEAD_STYLE_ONE_NO.get(5)))) { + return true; + } + return false; + } + /** * 将格式化后的结果集数据导出为Excel文件 */