格式化检验数据创建时间

This commit is contained in:
liuchengqian 2022-05-17 10:31:06 +08:00
parent 289dbe69d6
commit 9e2a28914e
7 changed files with 63 additions and 9 deletions

View File

@ -55,4 +55,12 @@ public class QcSourceController {
return qcSourceService.exportExcel(exportSourceExcelQo);
}
/**
* 格式化创建时间历史数据
*/
@GetMapping("/formatCreateTime")
public String formatCreateTime() {
return qcSourceService.formatCreateTime();
}
}

View File

@ -17,7 +17,4 @@ public interface QcSourceDao extends JpaRepository<QcSourceEntity, Integer>, 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<QcSourceEntity> 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<String> queryQcSourceAsc(String batchNo, String machineNo, String materialNo, String mouldNo, String varietyNo, String craftItemNo);
}

View File

@ -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 + '\'' +
'}';
}
}

View File

@ -27,4 +27,8 @@ public interface QcSourceService {
*/
String exportExcel(ExportSourceExcelQo exportSourceExcelQo) throws Exception;
/**
* 格式化创建时间历史数据
*/
String formatCreateTime();
}

View File

@ -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;
}
}

View File

@ -12,6 +12,9 @@ public interface Constant {
*/
String QC_ITEM_TYPE_PICTURE = "1";
long QC_TIME_INTERVAL = 1;
/**
* 检验数据时间分组间隔
*/
long QC_TIME_INTERVAL = 3600;
}

View File

@ -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");
}
}