Commit 880a79a0 by zhangxk

修改对接时间为GMT+8

1 parent e80ee508
...@@ -40,12 +40,12 @@ public class BehaviorProcess implements Process { ...@@ -40,12 +40,12 @@ public class BehaviorProcess implements Process {
String startStr = video.getString("start_dt"); String startStr = video.getString("start_dt");
String endStr = video.getString("end_dt"); String endStr = video.getString("end_dt");
if (startStr != null && !"".equals(startStr.trim())) { if (startStr != null && !"".equals(startStr.trim())) {
long start = DateUtil.parse(DateUtil.FORMAT_FULL, startStr).getTime(); long start = DateUtil.parse(DateUtil.FORMAT_FULL, startStr,8).getTime();
model.setRecordingStartSecond((int) (start / 1000)); model.setRecordingStartSecond((int) (start / 1000));
model.setRecordingStartMillisecond((int) (start % 1000)); model.setRecordingStartMillisecond((int) (start % 1000));
} }
if (endStr != null && !"".equals(endStr.trim())) { if (endStr != null && !"".equals(endStr.trim())) {
long end = DateUtil.parse(DateUtil.FORMAT_FULL, endStr).getTime(); long end = DateUtil.parse(DateUtil.FORMAT_FULL, endStr,8).getTime();
model.setRecordingEndSecond((int) (end / 1000)); model.setRecordingEndSecond((int) (end / 1000));
model.setRecordingEndMillisecond((int) (end % 1000)); model.setRecordingEndMillisecond((int) (end % 1000));
} }
...@@ -53,7 +53,7 @@ public class BehaviorProcess implements Process { ...@@ -53,7 +53,7 @@ public class BehaviorProcess implements Process {
String eventDtStr = jsonObject.getString("event_dt"); String eventDtStr = jsonObject.getString("event_dt");
if (eventDtStr != null) { if (eventDtStr != null) {
long time = DateUtil.parse(DateUtil.FORMAT_FULL, eventDtStr).getTime(); long time = DateUtil.parse(DateUtil.FORMAT_FULL, eventDtStr,8).getTime();
model.setEventStartSecond((int) (time / 1000)); model.setEventStartSecond((int) (time / 1000));
model.setEventStartMillisecond((int) (time % 1000)); model.setEventStartMillisecond((int) (time % 1000));
//结束时间暂定和开始时间一致 //结束时间暂定和开始时间一致
......
...@@ -6,8 +6,10 @@ import com.viontech.model.BaseModel; ...@@ -6,8 +6,10 @@ import com.viontech.model.BaseModel;
import com.viontech.model.FlowModel; import com.viontech.model.FlowModel;
import com.viontech.utils.DateUtil; import com.viontech.utils.DateUtil;
import com.viontech.utils.IntUtils; import com.viontech.utils.IntUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
/** /**
...@@ -25,7 +27,7 @@ public class FlowProcess implements Process { ...@@ -25,7 +27,7 @@ public class FlowProcess implements Process {
model.setTimeDuring(120); model.setTimeDuring(120);
String eventDtStr = jsonObject.getString("event_dt"); String eventDtStr = jsonObject.getString("event_dt");
if (eventDtStr != null) { if (eventDtStr != null) {
long time = DateUtil.parse(DateUtil.FORMAT_FULL, eventDtStr).getTime(); long time = DateUtil.parse(DateUtil.FORMAT_FULL, eventDtStr,8).getTime();
model.setTime((int) (time / 1000)); model.setTime((int) (time / 1000));
} }
JSONObject eventData = jsonObject.getJSONObject("event_data"); JSONObject eventData = jsonObject.getJSONObject("event_data");
......
...@@ -60,7 +60,7 @@ public class TrafficProcess implements Process { ...@@ -60,7 +60,7 @@ public class TrafficProcess implements Process {
} }
// ------------------------ 车辆信息 车牌信息 -------------- // ------------------------ 车辆信息 车牌信息 --------------
String eventTimeStr = jsonObject.getString("event_dt"); String eventTimeStr = jsonObject.getString("event_dt");
Date eventTime = DateUtil.parse(DateUtil.FORMAT_FULL, eventTimeStr); Date eventTime = DateUtil.parse(DateUtil.FORMAT_FULL, eventTimeStr,8);
long eventTimeL = eventTime.getTime(); long eventTimeL = eventTime.getTime();
model.setDiscernTime(BaseModel.toInt(eventTimeL / 1000)); model.setDiscernTime(BaseModel.toInt(eventTimeL / 1000));
model.setDiscernMillisecondTime(BaseModel.toInt(eventTimeL % 1000)); model.setDiscernMillisecondTime(BaseModel.toInt(eventTimeL % 1000));
...@@ -230,11 +230,11 @@ public class TrafficProcess implements Process { ...@@ -230,11 +230,11 @@ public class TrafficProcess implements Process {
long redStart = 0; long redStart = 0;
long redEnd = 0; long redEnd = 0;
if (redStartStr != null && !"".equals(redStartStr.trim())) { if (redStartStr != null && !"".equals(redStartStr.trim())) {
redStart = DateUtil.parse(DateUtil.FORMAT_FULL, redStartStr).getTime(); redStart = DateUtil.parse(DateUtil.FORMAT_FULL, redStartStr,8).getTime();
} }
String redEndStr = detail.getString("end_dt"); String redEndStr = detail.getString("end_dt");
if (redEndStr != null && !"".equals(redEndStr.trim())) { if (redEndStr != null && !"".equals(redEndStr.trim())) {
redEnd = DateUtil.parse(DateUtil.FORMAT_FULL, redEndStr).getTime(); redEnd = DateUtil.parse(DateUtil.FORMAT_FULL, redEndStr,8).getTime();
} }
model.setRedLightBeginTime((int) (redStart / 1000)); model.setRedLightBeginTime((int) (redStart / 1000));
model.setRedLightBeginMillisecondTime((int) (redStart % 1000)); model.setRedLightBeginMillisecondTime((int) (redStart % 1000));
......
...@@ -1326,6 +1326,12 @@ public class DateUtil extends DateUtils { ...@@ -1326,6 +1326,12 @@ public class DateUtil extends DateUtils {
return parse(dateFormatStr, dateStr, locale); return parse(dateFormatStr, dateStr, locale);
} }
public static Date parse(String dateFormatStr, String dateStr,int offset) throws ParseException {
Locale locale = LocaleContextHolder.getLocale();
Date parse = parse(dateFormatStr, dateStr, locale);
return DateUtils.addHours(parse, offset);
}
public static String format(String dateFormatStr, Date date, Locale locale) { public static String format(String dateFormatStr, Date date, Locale locale) {
SimpleDateFormat sdf = null; SimpleDateFormat sdf = null;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!