From 5bd5146105af5c790bada6acbc1422f7e1ad6b6c Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Tue, 17 May 2022 11:46:47 +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=A0=BC=E5=BC=8F=E5=8C=96=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E6=97=B6=E9=97=B4=E5=92=8C=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 | 21 ++++++++++--------- .../java/com/xkrs/util/LocalDateUtils.java | 15 +++++++++++++ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/xkrs/service/impl/QcSourceServiceImpl.java b/src/main/java/com/xkrs/service/impl/QcSourceServiceImpl.java index 31f9896..c7d42e4 100644 --- a/src/main/java/com/xkrs/service/impl/QcSourceServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/QcSourceServiceImpl.java @@ -345,7 +345,7 @@ public class QcSourceServiceImpl implements QcSourceService { return null; } for (Map room : mapList) { - if (room.getOrDefault("batchNo", "").equals(batchNo) && room.getOrDefault("machineNo", "").equals(machineNo) && room.getOrDefault("materialNo", "").equals(materialNo) && room.getOrDefault("mouldNo", "").equals(mouldNo) && room.getOrDefault("varietyNo", "").equals(varietyNo) && room.getOrDefault("craftItemNo", "").equals(craftItemNo)) { + if (room.get(EXCEL_HEAD_STYLE_ONE_NO.get(0)).equals(batchNo) && room.get(EXCEL_HEAD_STYLE_ONE_NO.get(1)).equals(machineNo) && room.get(EXCEL_HEAD_STYLE_ONE_NO.get(2)).equals(materialNo) && room.get(EXCEL_HEAD_STYLE_ONE_NO.get(3)).equals(mouldNo) && room.get(EXCEL_HEAD_STYLE_ONE_NO.get(4)).equals(varietyNo) && room.get(EXCEL_HEAD_STYLE_ONE_NO.get(5)).equals(craftItemNo)) { if (!room.containsKey(qcItemNo)) { return room; } @@ -401,13 +401,14 @@ public class QcSourceServiceImpl implements QcSourceService { formatResultList.add(headList); for (Map dataMap : resultList) { List dataList = new ArrayList<>(); - dataList.add((String) dataMap.getOrDefault(EXCEL_HEAD_STYLE_ONE_NO.get(0), "")); - dataList.add((String) dataMap.getOrDefault(EXCEL_HEAD_STYLE_ONE_NO.get(1), "")); - dataList.add((String) dataMap.getOrDefault(EXCEL_HEAD_STYLE_ONE_NO.get(2), "")); - dataList.add((String) dataMap.getOrDefault(EXCEL_HEAD_STYLE_ONE_NO.get(3), "")); - dataList.add((String) dataMap.getOrDefault(EXCEL_HEAD_STYLE_ONE_NO.get(4), "")); - dataList.add((String) dataMap.getOrDefault(EXCEL_HEAD_STYLE_ONE_NO.get(5), "")); - dataList.add((String) dataMap.getOrDefault(EXCEL_HEAD_STYLE_ONE_NO.get(6), "")); + 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))); for (QcItemEntity entity : qcItemList) { String value = (String) dataMap.getOrDefault(entity.getQcItemNo(), ""); if (Constant.QC_ITEM_TYPE_STRING.equals(entity.getQcItemType())) { @@ -436,8 +437,8 @@ public class QcSourceServiceImpl implements QcSourceService { //建立新的sheet对象(excel的表单) XSSFSheet sheet = workbook.createSheet("检验数据表"); for (int i = 0; i < dataListList.get(0).size(); i++) { - if (i <= 5) { - sheet.setColumnWidth(i, 20 * 256); + if (i <= 7) { + sheet.setColumnWidth(i, 22 * 256); } else { sheet.setColumnWidth(i, 14 * 256); } diff --git a/src/main/java/com/xkrs/util/LocalDateUtils.java b/src/main/java/com/xkrs/util/LocalDateUtils.java index c77d008..1c55126 100644 --- a/src/main/java/com/xkrs/util/LocalDateUtils.java +++ b/src/main/java/com/xkrs/util/LocalDateUtils.java @@ -13,8 +13,23 @@ public class LocalDateUtils { return String.valueOf(new Date().getTime() / 1000L); } + /** + * 返回给前端用的日期格式化 + * + * @param second 秒时间戳 + */ public static String formatCurrentSecond(String second) { long timeMillis = Long.parseLong(second + "000"); return DateUtil.format(new Date(timeMillis), "yyyy-MM-dd HH:mm:ss"); } + + /** + * 导出表格用的日期格式化 + * + * @param second 秒时间戳 + */ + public static String exportFormatCurrentSecond(String second) { + long timeMillis = Long.parseLong(second + "000"); + return DateUtil.format(new Date(timeMillis), "yyyy-MM-dd HH"); + } }