优化数据表导出 格式化上传时间和批次

This commit is contained in:
liuchengqian 2022-05-17 11:46:47 +08:00
parent 68f56278a5
commit 5bd5146105
2 changed files with 26 additions and 10 deletions

View File

@ -345,7 +345,7 @@ public class QcSourceServiceImpl implements QcSourceService {
return null; return null;
} }
for (Map<String, Object> room : mapList) { for (Map<String, Object> 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)) { if (!room.containsKey(qcItemNo)) {
return room; return room;
} }
@ -401,13 +401,14 @@ public class QcSourceServiceImpl implements QcSourceService {
formatResultList.add(headList); formatResultList.add(headList);
for (Map<String, Object> dataMap : resultList) { for (Map<String, Object> dataMap : resultList) {
List<String> dataList = new ArrayList<>(); List<String> dataList = new ArrayList<>();
dataList.add((String) dataMap.getOrDefault(EXCEL_HEAD_STYLE_ONE_NO.get(0), "")); dataList.add((String) dataMap.get(EXCEL_HEAD_STYLE_ONE_NO.get(0)));
dataList.add((String) dataMap.getOrDefault(EXCEL_HEAD_STYLE_ONE_NO.get(1), "")); dataList.add((String) dataMap.get(EXCEL_HEAD_STYLE_ONE_NO.get(1)));
dataList.add((String) dataMap.getOrDefault(EXCEL_HEAD_STYLE_ONE_NO.get(2), "")); dataList.add((String) dataMap.get(EXCEL_HEAD_STYLE_ONE_NO.get(2)));
dataList.add((String) dataMap.getOrDefault(EXCEL_HEAD_STYLE_ONE_NO.get(3), "")); dataList.add((String) dataMap.get(EXCEL_HEAD_STYLE_ONE_NO.get(3)));
dataList.add((String) dataMap.getOrDefault(EXCEL_HEAD_STYLE_ONE_NO.get(4), "")); dataList.add((String) dataMap.get(EXCEL_HEAD_STYLE_ONE_NO.get(4)));
dataList.add((String) dataMap.getOrDefault(EXCEL_HEAD_STYLE_ONE_NO.get(5), "")); dataList.add((String) dataMap.get(EXCEL_HEAD_STYLE_ONE_NO.get(5)));
dataList.add((String) dataMap.getOrDefault(EXCEL_HEAD_STYLE_ONE_NO.get(6), "")); 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) { for (QcItemEntity entity : qcItemList) {
String value = (String) dataMap.getOrDefault(entity.getQcItemNo(), ""); String value = (String) dataMap.getOrDefault(entity.getQcItemNo(), "");
if (Constant.QC_ITEM_TYPE_STRING.equals(entity.getQcItemType())) { if (Constant.QC_ITEM_TYPE_STRING.equals(entity.getQcItemType())) {
@ -436,8 +437,8 @@ public class QcSourceServiceImpl implements QcSourceService {
//建立新的sheet对象excel的表单 //建立新的sheet对象excel的表单
XSSFSheet sheet = workbook.createSheet("检验数据表"); XSSFSheet sheet = workbook.createSheet("检验数据表");
for (int i = 0; i < dataListList.get(0).size(); i++) { for (int i = 0; i < dataListList.get(0).size(); i++) {
if (i <= 5) { if (i <= 7) {
sheet.setColumnWidth(i, 20 * 256); sheet.setColumnWidth(i, 22 * 256);
} else { } else {
sheet.setColumnWidth(i, 14 * 256); sheet.setColumnWidth(i, 14 * 256);
} }

View File

@ -13,8 +13,23 @@ public class LocalDateUtils {
return String.valueOf(new Date().getTime() / 1000L); return String.valueOf(new Date().getTime() / 1000L);
} }
/**
* 返回给前端用的日期格式化
*
* @param second 秒时间戳
*/
public static String formatCurrentSecond(String second) { public static String formatCurrentSecond(String second) {
long timeMillis = Long.parseLong(second + "000"); long timeMillis = Long.parseLong(second + "000");
return DateUtil.format(new Date(timeMillis), "yyyy-MM-dd HH:mm:ss"); 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");
}
} }