From 925f48ff8132f175a69d381e00559a17ccafc379 Mon Sep 17 00:00:00 2001 From: huangzj <826100833@qq.com> Date: Thu, 2 Nov 2023 15:53:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/njcn/csharmonic/pojo/vo/ThdDataVO.java | 8 +++++--- .../service/impl/DeviceDataTrendServiceImpl.java | 2 +- .../service/impl/StableDataServiceImpl.java | 14 +++++++------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/vo/ThdDataVO.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/vo/ThdDataVO.java index 4b6fa7f..9efbb40 100644 --- a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/vo/ThdDataVO.java +++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/vo/ThdDataVO.java @@ -1,9 +1,12 @@ package com.njcn.csharmonic.pojo.vo; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.njcn.common.utils.serializer.InstantDateSerializer; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; +import java.time.Instant; import java.time.LocalDateTime; /** @@ -15,9 +18,8 @@ import java.time.LocalDateTime; */ @Data public class ThdDataVO { - @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") - private LocalDateTime time; + @JsonSerialize(using = InstantDateSerializer.class) + private Instant time; private String lineId; private String position; private String lineName; diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/DeviceDataTrendServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/DeviceDataTrendServiceImpl.java index 147fc1b..b3b6df6 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/DeviceDataTrendServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/DeviceDataTrendServiceImpl.java @@ -64,7 +64,7 @@ public class DeviceDataTrendServiceImpl implements DeviceDataTrendService { vo.setLineId(statisticalDataDTO.getLineId()); vo.setPhase(statisticalDataDTO.getPhaseType()); - vo.setTime(statisticalDataDTO.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime()); + vo.setTime(statisticalDataDTO.getTime()); vo.setStatMethod(statisticalDataDTO.getValueType()); vo.setStatisticalData(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(4, RoundingMode.UP).doubleValue()); vo.setStatisticalIndex(temp.getDataId()); diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/StableDataServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/StableDataServiceImpl.java index 252a7ef..7d80cfe 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/StableDataServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/StableDataServiceImpl.java @@ -80,7 +80,7 @@ public class StableDataServiceImpl implements StableDataService { ThdDataVO thdDataVO = new ThdDataVO(); BeanUtils.copyProperties(temp,thdDataVO); thdDataVO.setStatisticalName(statisticalName); - thdDataVO.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime()); + thdDataVO.setTime(temp.getTime()); String position = csLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), thdDataVO.getLineId())).collect(Collectors.toList()).get(0).getPosition(); thdDataVO.setPosition(position); Double statisticalValue = 0.00; @@ -106,7 +106,7 @@ public class StableDataServiceImpl implements StableDataService { ThdDataVO thdDataVO = new ThdDataVO(); BeanUtils.copyProperties(temp,thdDataVO); thdDataVO.setStatisticalName(thdDataQueryParm.getStatisticalName()); - thdDataVO.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime()); + thdDataVO.setTime(temp.getTime()); String position = csLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), thdDataVO.getLineId())).collect(Collectors.toList()).get(0).getPosition(); thdDataVO.setPosition(position); Double statisticalValue = 0.00; @@ -133,7 +133,7 @@ public class StableDataServiceImpl implements StableDataService { ThdDataVO thdDataVO = new ThdDataVO(); BeanUtils.copyProperties(temp,thdDataVO); thdDataVO.setStatisticalName(statisticalName); - thdDataVO.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime()); + thdDataVO.setTime(temp.getTime()); String position = csLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), thdDataVO.getLineId())).collect(Collectors.toList()).get(0).getPosition(); thdDataVO.setPosition(position); Double statisticalValue = 0.00; @@ -158,7 +158,7 @@ public class StableDataServiceImpl implements StableDataService { ThdDataVO thdDataVO = new ThdDataVO(); BeanUtils.copyProperties(temp,thdDataVO); thdDataVO.setStatisticalName(thdDataQueryParm.getStatisticalName()); - thdDataVO.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime()); + thdDataVO.setTime(temp.getTime()); String position = csLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), thdDataVO.getLineId())).collect(Collectors.toList()).get(0).getPosition(); thdDataVO.setPosition(position); Double statisticalValue = 0.00; @@ -214,7 +214,7 @@ public class StableDataServiceImpl implements StableDataService { vo.setPhase(phaseReflection(temp.getPhaseType())); String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition(); vo.setPosition(position); - vo.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime()); + vo.setTime(temp.getTime()); vo.setStatMethod(temp.getValueType()); vo.setStatisticalData(Double.valueOf(df.format(temp.getValue()))); vo.setStatisticalIndex(data.getId()); @@ -265,7 +265,7 @@ public class StableDataServiceImpl implements StableDataService { vo.setPhase(temp.getPhaseType()); String position = csLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition(); vo.setPosition(position); - vo.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime()); + vo.setTime(temp.getTime()); vo.setStatMethod(temp.getValueType()); vo.setStatisticalData(Double.valueOf(df.format(temp.getValue()))); vo.setStatisticalIndex(epdPqd.getId()); @@ -325,7 +325,7 @@ public class StableDataServiceImpl implements StableDataService { vo.setLineName(lineName); vo.setPosition(position); - vo.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime()); + vo.setTime(temp.getTime()); vo.setStatMethod(temp.getValueType()); vo.setStatisticalData(Double.valueOf(df.format(temp.getValue()))); vo.setStatisticalIndex(epdPqd.getId());