省厅位置汇聚ES查询返回时间大8小时问题处理并添加查询设备列表功能
parent
87882579c7
commit
a01837bf6d
|
|
@ -29,10 +29,7 @@ import org.springframework.stereotype.Service;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.Instant;
|
import java.time.*;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -131,7 +128,7 @@ public class SearchServiceImpl implements ISearchService {
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
hash = dateTimes.get(i).toString();
|
hash = dateTimes.get(i).toString();
|
||||||
hash = hash.substring(0, 10).replaceAll("-","");
|
hash = hash.substring(0, 10).replaceAll("-","");
|
||||||
list.add("gpsinfo" + hash);
|
list.add("rs_gpsinfo" + hash);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
@ -194,23 +191,13 @@ public class SearchServiceImpl implements ISearchService {
|
||||||
gpsInfoVO2.setDeviceCode(deviceCode);
|
gpsInfoVO2.setDeviceCode(deviceCode);
|
||||||
gpsInfoVO2.setDeviceType(source.get("deviceType").toString());
|
gpsInfoVO2.setDeviceType(source.get("deviceType").toString());
|
||||||
long timestamp = Instant.parse(source.get("gpsTime").toString()).toEpochMilli();
|
long timestamp = Instant.parse(source.get("gpsTime").toString()).toEpochMilli();
|
||||||
String isoString =source.get("gpsTime").toString();
|
String isoString = source.get("gpsTime").toString();
|
||||||
Instant instant = Instant.parse(isoString);
|
Instant instant = Instant.parse(isoString);
|
||||||
Date utcDate = Date.from(instant);
|
|
||||||
|
|
||||||
// 方法2:使用 Hutool + 时区转换
|
Instant correctedInstant = instant.minus(Duration.ofHours(8));
|
||||||
Date date = DateUtil.parse(isoString);
|
|
||||||
// 将时间调整为 UTC 时区
|
|
||||||
ZonedDateTime utcZdt = date.toInstant().atZone(ZoneId.of("UTC"));
|
|
||||||
Date utcDate2 = Date.from(utcZdt.toInstant());
|
|
||||||
|
|
||||||
// 验证结果
|
long correctedTimestamp = correctedInstant.toEpochMilli();
|
||||||
log.error("原始 UTC 时间: " + isoString);
|
gpsInfoVO2.setGpsTime(new Date(correctedTimestamp));
|
||||||
log.error("方法1转换结果: " + utcDate);
|
|
||||||
log.error("方法2转换结果: " + utcDate2);
|
|
||||||
log.error("时间戳: " + utcDate.getTime());
|
|
||||||
|
|
||||||
gpsInfoVO2.setGpsTime(new Date(timestamp));
|
|
||||||
gpsInfoVO2.setLat(lat+"");
|
gpsInfoVO2.setLat(lat+"");
|
||||||
gpsInfoVO2.setLng(lon+"");
|
gpsInfoVO2.setLng(lon+"");
|
||||||
log.info("gpsInfoVO2={}",gpsInfoVO2.toString());
|
log.info("gpsInfoVO2={}",gpsInfoVO2.toString());
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
package org.dromara.system.controller;
|
package org.dromara.system.controller;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import jakarta.validation.constraints.*;
|
import jakarta.validation.constraints.*;
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import org.dromara.system.exception.MyBusinessException;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||||
|
|
@ -46,6 +48,18 @@ public class TDeviceController extends BaseController {
|
||||||
return tDeviceService.queryPageList(bo, pageQuery);
|
return tDeviceService.queryPageList(bo, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getDeviceList")
|
||||||
|
public TableDataInfo<TDeviceVo> getDeviceList(@RequestBody TDeviceBo bo){
|
||||||
|
PageQuery pageQuery = new PageQuery();
|
||||||
|
if (Objects.isNull(bo)) {
|
||||||
|
throw new MyBusinessException("请求参数不能为空");
|
||||||
|
}
|
||||||
|
pageQuery.setPageNum(bo.getPageNum());
|
||||||
|
pageQuery.setPageSize(bo.getPageSize());
|
||||||
|
return tDeviceService.queryPageList(bo, pageQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出device列表
|
* 导出device列表
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -109,5 +109,9 @@ public class TDeviceBo extends BaseEntity {
|
||||||
|
|
||||||
private String xgrsfzh;
|
private String xgrsfzh;
|
||||||
|
|
||||||
|
private int pageNum;
|
||||||
|
|
||||||
|
private int pageSize;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
package org.dromara.system.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>description: </p>
|
||||||
|
*
|
||||||
|
* @author chenle
|
||||||
|
* @date 2021-06-07 10:56
|
||||||
|
*/
|
||||||
|
public class MyBusinessException extends RuntimeException {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String msg;
|
||||||
|
private int code = 500;
|
||||||
|
|
||||||
|
public MyBusinessException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MyBusinessException(String msg, Throwable e) {
|
||||||
|
super(msg, e);
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MyBusinessException(String msg, int code) {
|
||||||
|
super(msg);
|
||||||
|
this.msg = msg;
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MyBusinessException(String msg, int code, Throwable e) {
|
||||||
|
super(msg, e);
|
||||||
|
this.msg = msg;
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMsg() {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMsg(String msg) {
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(int code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue