Browse Source

1.规避postgresql alarmhistory流水表 自动建表问题
2.规避 postgresql limit offset 问题

wanghs 2 years ago
parent
commit
7d0e4c7fd3

+ 2 - 2
warning-web/src/main/resources/mappers-postgresql/AlarmHistoryMapper.xml

@@ -361,7 +361,6 @@
     </update>
     <update id="timedAlterTable">
         alter table alarmhistory_${stationname}_${yearmonth}
-            owner to gdprod
     </update>
     <update id="timedCreatAlerttimeIndex">
         create index IX_AH_${stationname}_${yearmonth}_alerttime on alarmhistory_${stationname}_${yearmonth} ("alerttime")
@@ -370,7 +369,8 @@
         create index IX_AH_${stationname}_${yearmonth}_snapid on alarmhistory_${stationname}_${yearmonth} ("snapid")
     </update>
     <select id="isHasTable" resultType="java.lang.Integer">
-        select count(*) from information_schema.TABLES where table_name =upper('alarmhistory_{stationname}_${yearmonth}')
+        select count(*) from information_schema.tables where table_schema='public' and table_type='BASE TABLE' and
+        table_name=LOWER('alarmhistory_${stationname}_${yearmonth}');
     </select>
 
     <select id="getlatestAlarmHistory" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.model.AlarmHistoryInfo">

+ 1 - 1
warning-web/src/main/resources/mappers-postgresql/FaultInfoMapper.xml

@@ -87,7 +87,7 @@
         FROM
         faulthistory h left join faultsnap s on h.snapid = s.id
         order by h.faultTime desc)
-         where limit 0 OFFSET #{topnum}
+         as info limit #{topnum} OFFSET 0
     </select>
 
     <select id="queryFaultInfo1" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.FaultInfo">