Sfoglia il codice sorgente

[0806] 风速曲线图、温度曲线图、湿度曲线图、气压曲线图、辐照曲线图 | 修复Mapper timezone查询exception

taosj 2 mesi fa
parent
commit
247ced3c37

+ 8 - 2
forecast-backend-server/src/main/resources/mybatis/weather/DataWeatherLocalMapper.xml

@@ -35,11 +35,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
     </select>
 
+    <!--
+        tm 为 TIMESTAMPTZ,插入时已按各自来源时区归一化为 UTC 时刻存储,
+        因此与 startTime/endTime(unix秒,绝对时刻)直接按时刻比较即可,
+        不依赖任何固定时区(如 GMT+8)。to_timestamp(double precision) 以
+        UTC 为基准,与会话时区无关。
+    -->
     <select id="selectDataWeatherLocalListByTimeRange" resultMap="DataWeatherLocalResult">
         <include refid="selectDataWeatherLocalVo"/>
         where config_station_id = #{stationId}
-          and (tm at time zone 'Asia/Shanghai') &gt;= (to_timestamp(#{startTime}::double precision) at time zone 'Asia/Shanghai')
-          and (tm at time zone 'Asia/Shanghai') &lt;= (to_timestamp(#{endTime}::double precision) at time zone 'Asia/Shanghai')
+          and tm &gt;= to_timestamp(#{startTime})
+          and tm &lt;= to_timestamp(#{endTime})
         order by tm asc
     </select>