diff --git a/stwzhj-modules/stwzhj-location/src/main/java/org/dromara/location/service/impl/SearchServiceImpl.java b/stwzhj-modules/stwzhj-location/src/main/java/org/dromara/location/service/impl/SearchServiceImpl.java index 32d38951..37df8370 100644 --- a/stwzhj-modules/stwzhj-location/src/main/java/org/dromara/location/service/impl/SearchServiceImpl.java +++ b/stwzhj-modules/stwzhj-location/src/main/java/org/dromara/location/service/impl/SearchServiceImpl.java @@ -29,10 +29,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.io.IOException; import java.text.SimpleDateFormat; -import java.time.Instant; -import java.time.ZoneId; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; +import java.time.*; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -131,7 +128,7 @@ public class SearchServiceImpl implements ISearchService { for (int i = 0; i < len; i++) { hash = dateTimes.get(i).toString(); hash = hash.substring(0, 10).replaceAll("-",""); - list.add("gpsinfo" + hash); + list.add("rs_gpsinfo" + hash); } return list; } @@ -194,23 +191,13 @@ public class SearchServiceImpl implements ISearchService { gpsInfoVO2.setDeviceCode(deviceCode); gpsInfoVO2.setDeviceType(source.get("deviceType").toString()); 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); - Date utcDate = Date.from(instant); - // 方法2:使用 Hutool + 时区转换 - Date date = DateUtil.parse(isoString); - // 将时间调整为 UTC 时区 - ZonedDateTime utcZdt = date.toInstant().atZone(ZoneId.of("UTC")); - Date utcDate2 = Date.from(utcZdt.toInstant()); + Instant correctedInstant = instant.minus(Duration.ofHours(8)); - // 验证结果 - log.error("原始 UTC 时间: " + isoString); - log.error("方法1转换结果: " + utcDate); - log.error("方法2转换结果: " + utcDate2); - log.error("时间戳: " + utcDate.getTime()); - - gpsInfoVO2.setGpsTime(new Date(timestamp)); + long correctedTimestamp = correctedInstant.toEpochMilli(); + gpsInfoVO2.setGpsTime(new Date(correctedTimestamp)); gpsInfoVO2.setLat(lat+""); gpsInfoVO2.setLng(lon+""); log.info("gpsInfoVO2={}",gpsInfoVO2.toString()); diff --git a/stwzhj-modules/stwzhj-location/src/main/resources/application.yml b/stwzhj-modules/stwzhj-location/src/main/resources/application.yml index 525847aa..57888d4b 100644 --- a/stwzhj-modules/stwzhj-location/src/main/resources/application.yml +++ b/stwzhj-modules/stwzhj-location/src/main/resources/application.yml @@ -10,8 +10,8 @@ spring: profiles: # 环境配置 active: @profiles.active@ - autoconfigure: - exclude: org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration + autoconfigure: + exclude: org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration --- # nacos 配置 spring: diff --git a/stwzhj-modules/stwzhj-system/src/main/java/org/dromara/system/controller/system/TDeviceController.java b/stwzhj-modules/stwzhj-system/src/main/java/org/dromara/system/controller/system/TDeviceController.java index 8e7f87da..a8e93399 100644 --- a/stwzhj-modules/stwzhj-system/src/main/java/org/dromara/system/controller/system/TDeviceController.java +++ b/stwzhj-modules/stwzhj-system/src/main/java/org/dromara/system/controller/system/TDeviceController.java @@ -1,11 +1,13 @@ package org.dromara.system.controller; import java.util.List; +import java.util.Objects; import lombok.RequiredArgsConstructor; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.constraints.*; import cn.dev33.satoken.annotation.SaCheckPermission; +import org.dromara.system.exception.MyBusinessException; import org.springframework.web.bind.annotation.*; import org.springframework.validation.annotation.Validated; import org.dromara.common.idempotent.annotation.RepeatSubmit; @@ -46,6 +48,18 @@ public class TDeviceController extends BaseController { return tDeviceService.queryPageList(bo, pageQuery); } + @PostMapping("/getDeviceList") + public TableDataInfo 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列表 */ diff --git a/stwzhj-modules/stwzhj-system/src/main/java/org/dromara/system/domain/bo/TDeviceBo.java b/stwzhj-modules/stwzhj-system/src/main/java/org/dromara/system/domain/bo/TDeviceBo.java index 4f697e88..2c7f1324 100644 --- a/stwzhj-modules/stwzhj-system/src/main/java/org/dromara/system/domain/bo/TDeviceBo.java +++ b/stwzhj-modules/stwzhj-system/src/main/java/org/dromara/system/domain/bo/TDeviceBo.java @@ -109,5 +109,9 @@ public class TDeviceBo extends BaseEntity { private String xgrsfzh; + private int pageNum; + + private int pageSize; + } diff --git a/stwzhj-modules/stwzhj-system/src/main/java/org/dromara/system/exception/MyBusinessException.java b/stwzhj-modules/stwzhj-system/src/main/java/org/dromara/system/exception/MyBusinessException.java new file mode 100644 index 00000000..6a692bce --- /dev/null +++ b/stwzhj-modules/stwzhj-system/src/main/java/org/dromara/system/exception/MyBusinessException.java @@ -0,0 +1,54 @@ +package org.dromara.system.exception; + +/** + *

description:

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