From 27111d6f87e1b57a68e5ca794281cfa4f6df5fb9 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Wed, 18 May 2022 10:31:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=95=B0=E6=8D=AE=E8=A1=A8?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=20=E6=88=90=E5=9E=8B=E8=BF=87=E7=A8=8B?= =?UTF-8?q?=E6=A3=80=E9=AA=8C=E6=B7=BB=E5=8A=A0=E8=BF=87=E7=A8=8B=E6=8A=BD?= =?UTF-8?q?=E6=A3=80=E6=89=B9=E6=AC=A1=20=E6=88=90=E5=9E=8B=E5=85=88?= =?UTF-8?q?=E8=A1=8C=E5=B7=A5=E6=A3=80=E4=B8=8D=E6=B7=BB=E5=8A=A0=E8=BF=87?= =?UTF-8?q?=E7=A8=8B=E6=8A=BD=E6=A3=80=E6=89=B9=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/QcSourceServiceImpl.java | 62 +++++++++++++++---- 1 file changed, 51 insertions(+), 11 deletions(-) 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文件 */