diff --git a/src/main/java/com/xkrs/controller/QcSourceController.java b/src/main/java/com/xkrs/controller/QcSourceController.java index 6a513af..4c2f3d2 100644 --- a/src/main/java/com/xkrs/controller/QcSourceController.java +++ b/src/main/java/com/xkrs/controller/QcSourceController.java @@ -55,4 +55,12 @@ public class QcSourceController { return qcSourceService.exportExcel(exportSourceExcelQo); } + /** + * 格式化创建时间历史数据 + */ + @GetMapping("/formatCreateTime") + public String formatCreateTime() { + return qcSourceService.formatCreateTime(); + } + } diff --git a/src/main/java/com/xkrs/dao/QcSourceDao.java b/src/main/java/com/xkrs/dao/QcSourceDao.java index 8866738..5b6f60b 100644 --- a/src/main/java/com/xkrs/dao/QcSourceDao.java +++ b/src/main/java/com/xkrs/dao/QcSourceDao.java @@ -17,7 +17,4 @@ public interface QcSourceDao extends JpaRepository, Jpa @Query(value = "SELECT * FROM qc_source WHERE batch_no LIKE %?1% AND machine_no LIKE %?2% AND material_no LIKE %?3% AND mould_no LIKE %?4% AND variety_no LIKE %?5% AND craft_item_no LIKE %?6% ORDER BY create_time DESC", nativeQuery = true) List queryQcSource(String batchNo, String machineNo, String materialNo, String mouldNo, String varietyNo, String craftItemNo); - @Query(value = "SELECT create_time FROM qc_source WHERE batch_no LIKE %?1% AND machine_no LIKE %?2% AND material_no LIKE %?3% AND mould_no LIKE %?4% AND variety_no LIKE %?5% AND craft_item_no LIKE %?6% ORDER BY create_time ASC", nativeQuery = true) - List queryQcSourceAsc(String batchNo, String machineNo, String materialNo, String mouldNo, String varietyNo, String craftItemNo); - } \ No newline at end of file diff --git a/src/main/java/com/xkrs/model/entity/QcSourceEntity.java b/src/main/java/com/xkrs/model/entity/QcSourceEntity.java index 0efbb31..fd1eb48 100644 --- a/src/main/java/com/xkrs/model/entity/QcSourceEntity.java +++ b/src/main/java/com/xkrs/model/entity/QcSourceEntity.java @@ -23,6 +23,12 @@ public class QcSourceEntity { @Column(length = 85, columnDefinition = "varchar(85)") private String createTime; + /** + * 格式化创建时间 + */ + @Column(length = 85, columnDefinition = "varchar(85)") + private String createTimeFormat; + /** * 批次号 */ @@ -90,6 +96,14 @@ public class QcSourceEntity { this.createTime = createTime; } + public String getCreateTimeFormat() { + return createTimeFormat; + } + + public void setCreateTimeFormat(String createTimeFormat) { + this.createTimeFormat = createTimeFormat; + } + public String getBatchNo() { return batchNo; } @@ -156,6 +170,18 @@ public class QcSourceEntity { @Override public String toString() { - return "QcSourceEntity{" + "id=" + id + ", createTime='" + createTime + '\'' + ", batchNo='" + batchNo + '\'' + ", machineNo='" + machineNo + '\'' + ", materialNo='" + materialNo + '\'' + ", mouldNo='" + mouldNo + '\'' + ", varietyNo='" + varietyNo + '\'' + ", craftItemNo='" + craftItemNo + '\'' + ", qcItemNo='" + qcItemNo + '\'' + ", qcValue='" + qcValue + '\'' + '}'; + return "QcSourceEntity{" + + "id=" + id + + ", createTime='" + createTime + '\'' + + ", createTimeFormat='" + createTimeFormat + '\'' + + ", batchNo='" + batchNo + '\'' + + ", machineNo='" + machineNo + '\'' + + ", materialNo='" + materialNo + '\'' + + ", mouldNo='" + mouldNo + '\'' + + ", varietyNo='" + varietyNo + '\'' + + ", craftItemNo='" + craftItemNo + '\'' + + ", qcItemNo='" + qcItemNo + '\'' + + ", qcValue='" + qcValue + '\'' + + '}'; } } diff --git a/src/main/java/com/xkrs/service/QcSourceService.java b/src/main/java/com/xkrs/service/QcSourceService.java index 5728f20..fec1e98 100644 --- a/src/main/java/com/xkrs/service/QcSourceService.java +++ b/src/main/java/com/xkrs/service/QcSourceService.java @@ -27,4 +27,8 @@ public interface QcSourceService { */ String exportExcel(ExportSourceExcelQo exportSourceExcelQo) throws Exception; + /** + * 格式化创建时间历史数据 + */ + String formatCreateTime(); } diff --git a/src/main/java/com/xkrs/service/impl/QcSourceServiceImpl.java b/src/main/java/com/xkrs/service/impl/QcSourceServiceImpl.java index 5795de5..9316720 100644 --- a/src/main/java/com/xkrs/service/impl/QcSourceServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/QcSourceServiceImpl.java @@ -84,7 +84,9 @@ public class QcSourceServiceImpl implements QcSourceService { if (Constant.QC_ITEM_TYPE_STRING.equals(qcItemByNo.get().getQcItemType())) { System.out.println("添加检验数据(文本类型)" + insertQo.toString()); QcSourceEntity entity = new QcSourceEntity(); - entity.setCreateTime(LocalDateUtils.getCurrentSecond()); + String currentSecond = LocalDateUtils.getCurrentSecond(); + entity.setCreateTime(currentSecond); + entity.setCreateTimeFormat(LocalDateUtils.formatCurrentSecond(currentSecond)); entity.setBatchNo(LocalStringUtils.formatEmptyValue(batchNo)); entity.setMachineNo(LocalStringUtils.formatEmptyValue(machineNo)); entity.setMaterialNo(LocalStringUtils.formatEmptyValue(materialNo)); @@ -112,7 +114,9 @@ public class QcSourceServiceImpl implements QcSourceService { return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "上传图片失败!", locale); } QcSourceEntity entity = new QcSourceEntity(); - entity.setCreateTime(LocalDateUtils.getCurrentSecond()); + String currentSecond = LocalDateUtils.getCurrentSecond(); + entity.setCreateTime(currentSecond); + entity.setCreateTimeFormat(LocalDateUtils.formatCurrentSecond(currentSecond)); entity.setBatchNo(LocalStringUtils.formatEmptyValue(batchNo)); entity.setMachineNo(LocalStringUtils.formatEmptyValue(machineNo)); entity.setMaterialNo(LocalStringUtils.formatEmptyValue(materialNo)); @@ -539,5 +543,14 @@ public class QcSourceServiceImpl implements QcSourceService { return "excel/" + excelFileName; } + /** + * 格式化创建时间历史数据 + */ + @Override + public String formatCreateTime() { + + + return null; + } } diff --git a/src/main/java/com/xkrs/util/Constant.java b/src/main/java/com/xkrs/util/Constant.java index 887ad5b..3b645f7 100644 --- a/src/main/java/com/xkrs/util/Constant.java +++ b/src/main/java/com/xkrs/util/Constant.java @@ -12,6 +12,9 @@ public interface Constant { */ String QC_ITEM_TYPE_PICTURE = "1"; - long QC_TIME_INTERVAL = 1; + /** + * 检验数据时间分组间隔 + */ + long QC_TIME_INTERVAL = 3600; } diff --git a/src/main/java/com/xkrs/util/LocalDateUtils.java b/src/main/java/com/xkrs/util/LocalDateUtils.java index 6d91d72..a9b0275 100644 --- a/src/main/java/com/xkrs/util/LocalDateUtils.java +++ b/src/main/java/com/xkrs/util/LocalDateUtils.java @@ -1,5 +1,7 @@ package com.xkrs.util; +import cn.hutool.core.date.DateUtil; + import java.util.Date; public class LocalDateUtils { @@ -8,9 +10,10 @@ public class LocalDateUtils { } public static String getCurrentSecond() { - -// return DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); return String.valueOf(new Date().getTime() / 1000L); + } + public static String formatCurrentSecond(String second) { + return DateUtil.format(new Date(second + "000"), "yyyy-MM-dd HH:mm:ss"); } }