更新 UTC 时间 转成 GMT+8 东八区时间

Этот коммит содержится в:
caixiang 2024-01-22 14:57:26 +08:00
родитель ed054a2bf2
Коммит 60a46c3248
5 изменённых файлов: 64 добавлений и 39 удалений

Просмотреть файл

@ -1,23 +1,4 @@
**项目说明**
- 这是根据renren框架重新修改出来的框架
- 采用SpringBoot、MyBatis、spring security框架
- 提供了代码生成器只需编写30%左右代码,其余的代码交给系统自动生成,可快速完成开发任务
- 代码生成器是用的Velocity模版引擎如果需要可以在ym-generator模块中进行vm模板的修改和一些包名等基础修改
<br>
**新增业务模块需要注意**
- 新增业务模块时业务模块需要依赖ym-admin并且ym-gateway模块maven需要依赖新建模块
- 自动生成的controller接口都带鉴权注解如果开发阶段可以先注释掉后面开发完成之后再把鉴权添加到数据库
<br>
**技术选型:**
- 核心框架Spring Boot 2.7
- 安全框架Spring Security
- 持久层框架MyBatis 3.5
- 定时器Quartz 2.3
- 数据库连接池HikariCP
- 日志管理log4j2
- 页面交互Vue2.x
spc 主项目
<br>

Просмотреть файл

@ -1,6 +1,11 @@
package com.cnbm.common.spc.util;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
@ -13,14 +18,18 @@ import java.util.List;
*/
public class DataUtils {
public static void main(String[] args) {
ArrayList<Integer> arrs = new ArrayList<>();
for(int i=0;i<100;i++){
arrs.add(i);
}
List<List<Integer>> lists = fixedGroup(arrs, 10);
System.out.println();
// ArrayList<Integer> arrs = new ArrayList<>();
//
// for(int i=0;i<100;i++){
// arrs.add(i);
// }
// List<List<Integer>> lists = fixedGroup(arrs, 10);
// System.out.println();
LocalDateTime now = LocalDateTime.now();
Instant instant1 = now.atZone(ZoneId.systemDefault()).toInstant();
Instant instant2 = now.toInstant(ZoneOffset.UTC);
Instant instant3 = StringToInstant("2024-01-22 12:00:00");
System.out.println(instant1+" - "+instant2+" - "+instant3);
}
@ -46,7 +55,20 @@ public class DataUtils {
return result;
}
public static final Instant StringToInstant(String string) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime parse = LocalDateTime.parse(string, dateTimeFormatter);
//return parse.toInstant(ZoneOffset.UTC);
return parse.atZone(ZoneId.systemDefault()).toInstant();
}
public static final Instant StringToInstantPlus8(String string) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
//LocalDateTime parse = LocalDateTime.parse(string, dateTimeFormatter).plusHours(8);
LocalDateTime parse = LocalDateTime.parse(string, dateTimeFormatter).minusHours(8);
return parse.toInstant(ZoneOffset.UTC);
}
public static String splitToNeed(String s,Integer type){
String[] s1 = s.split(" ");
String[] split = s1[0].split("-");

Просмотреть файл

@ -1,5 +1,6 @@
package com.cnbm.influx.config;
import com.cnbm.common.spc.util.DataUtils;
import com.cnbm.influx.constant.Constant;
import com.cnbm.influx.param.*;
import com.cnbm.influx.template.Event;
@ -118,6 +119,8 @@ public enum InfluxClient {
.addTag("argName", event.getArgName())
.addField("argValue", event.getArgValue())
.time(event.getTime().toEpochMilli(), WritePrecision.MS);
//.time(DataUtils.StringToInstantPlus8(event.getTime().toString()).toEpochMilli(), WritePrecision.MS);
}else {
point = Point.measurement(measurement)
.addTag("transationId", event.getTransationId()==null ? "" : event.getTransationId())
@ -130,6 +133,7 @@ public enum InfluxClient {
.addTag("argName", event.getArgName())
.addField("argValue", event.getArgValue())
.time(event.getTime().toEpochMilli(), WritePrecision.MS);
//.time(DataUtils.StringToInstantPlus8(event.getTime().toString()).toEpochMilli(), WritePrecision.MS);
}
list.add(point);
}

Просмотреть файл

@ -182,7 +182,8 @@ public class ProcessInspectionController {
QueryDataGroupByTimeParam queryDataParam = new QueryDataGroupByTimeParam();
// queryDataParam.setMeasurement(Constant.measurement);
queryDataParam.setMeasurement(graphArg.getProcedureName());
queryDataParam.setRange(new Range( graphArg.getBegin().toInstant() , graphArg.getEnd().toInstant() ));
//queryDataParam.setRange(new Range( graphArg.getBegin().toInstant() , graphArg.getEnd().toInstant() ));
queryDataParam.setRange(new Range( DataUtils.StringToInstant(graphArg.getBegin()) , DataUtils.StringToInstant(graphArg.getEnd()) ));
queryDataParam.setTimeType(graphArg.getGroupType());
npGraph.initialDate(queryDataParam);
@ -310,7 +311,9 @@ public class ProcessInspectionController {
QueryDataParam queryDataParam = new QueryDataParam();
// queryDataParam.setMeasurement(Constant.measurement);
queryDataParam.setMeasurement(graphArg.getProcedureName());
queryDataParam.setRange(new Range(graphArg.getBegin().toInstant(), graphArg.getEnd().toInstant()));
//queryDataParam.setRange(new Range(graphArg.getBegin().toInstant(), graphArg.getEnd().toInstant()));
queryDataParam.setRange(new Range( DataUtils.StringToInstant(graphArg.getBegin()) , DataUtils.StringToInstant(graphArg.getEnd()) ));
meanStandardDeviationGraph.initialDate(queryDataParam);
XbarSGraphData xbarSGraphData = new XbarSGraphData(
@ -347,7 +350,8 @@ public class ProcessInspectionController {
// queryDataParam.setMeasurement(Constant.measurement);
queryDataParam.setMeasurement(graphArg.getProcedureName());
queryDataParam.setRange(new Range(graphArg.getBegin().toInstant(), graphArg.getEnd().toInstant()));
//queryDataParam.setRange(new Range(graphArg.getBegin().toInstant(), graphArg.getEnd().toInstant()));
queryDataParam.setRange(new Range( DataUtils.StringToInstant(graphArg.getBegin()) , DataUtils.StringToInstant(graphArg.getEnd()) ));
meanRGraph.initialDate(queryDataParam);
@ -383,7 +387,8 @@ public class ProcessInspectionController {
QueryDataParam queryDataParam = new QueryDataParam();
// queryDataParam.setMeasurement(Constant.measurement);
queryDataParam.setMeasurement(graphArg.getProcedureName());
queryDataParam.setRange(new Range(graphArg.getBegin().toInstant(), graphArg.getEnd().toInstant()));
//queryDataParam.setRange(new Range(graphArg.getBegin().toInstant(), graphArg.getEnd().toInstant()));
queryDataParam.setRange(new Range( DataUtils.StringToInstant(graphArg.getBegin()) , DataUtils.StringToInstant(graphArg.getEnd()) ));
xmrGraph.initialDate(queryDataParam);
XMRGraphData xmrGraphData = new XMRGraphData(
@ -413,7 +418,8 @@ public class ProcessInspectionController {
QueryDataGroupByTimeParam queryDataParam = new QueryDataGroupByTimeParam();
// queryDataParam.setMeasurement(Constant.measurement);
queryDataParam.setMeasurement(graphArg.getProcedureName());
queryDataParam.setRange(new Range( graphArg.getBegin().toInstant() , graphArg.getEnd().toInstant() ));
//queryDataParam.setRange(new Range( graphArg.getBegin().toInstant() , graphArg.getEnd().toInstant() ));
queryDataParam.setRange(new Range( DataUtils.StringToInstant(graphArg.getBegin()) , DataUtils.StringToInstant(graphArg.getEnd()) ));
queryDataParam.setTimeType(graphArg.getGroupType());
pGraph.initialDate(queryDataParam);
@ -435,7 +441,8 @@ public class ProcessInspectionController {
QueryDataGroupByTimeParam queryDataParam = new QueryDataGroupByTimeParam();
// queryDataParam.setMeasurement(Constant.measurement);
queryDataParam.setMeasurement(graphArg.getProcedureName());
queryDataParam.setRange(new Range( graphArg.getBegin().toInstant() , graphArg.getEnd().toInstant() ));
//queryDataParam.setRange(new Range( graphArg.getBegin().toInstant() , graphArg.getEnd().toInstant() ));
queryDataParam.setRange(new Range( DataUtils.StringToInstant(graphArg.getBegin()) , DataUtils.StringToInstant(graphArg.getEnd()) ));
queryDataParam.setTimeType(graphArg.getGroupType());
cGraph.initialDate(queryDataParam);
@ -458,7 +465,8 @@ public class ProcessInspectionController {
QueryDataGroupByTimeParam queryDataParam = new QueryDataGroupByTimeParam();
// queryDataParam.setMeasurement(Constant.measurement);
queryDataParam.setMeasurement(graphArg.getProcedureName());
queryDataParam.setRange(new Range( graphArg.getBegin().toInstant() , graphArg.getEnd().toInstant() ));
//queryDataParam.setRange(new Range( graphArg.getBegin().toInstant() , graphArg.getEnd().toInstant() ));
queryDataParam.setRange(new Range( DataUtils.StringToInstant(graphArg.getBegin()) , DataUtils.StringToInstant(graphArg.getEnd()) ));
queryDataParam.setTimeType(graphArg.getGroupType());
uGraph.initialDate(queryDataParam);

Просмотреть файл

@ -23,15 +23,25 @@ public class GraphArg {
@NotNull(message = "检验特性Id 不能为空")
private Long productFeaturesId;
// @ApiModelProperty(value = "查询时间段,开始")
// @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd")
// @NotNull(message = "时间段,开始 不能为空")
// private Date begin;
//
// @ApiModelProperty(value = "查询时间段,结束")
// @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd")
// @NotNull(message = "时间段,结束 不能为空")
// private Date end;
@ApiModelProperty(value = "查询时间段,开始")
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd")
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
@NotNull(message = "时间段,开始 不能为空")
private Date begin;
private String begin;
@ApiModelProperty(value = "查询时间段,结束")
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd")
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
@NotNull(message = "时间段,结束 不能为空")
private Date end;
private String end;
@ApiModelProperty(value = "判读方案列表,只用于 计量型")
private List<InterpretationListArg> interpretationScheme;