2 Коміти de89aedb80 ... 4487792ac9

Автор SHA1 Опис Дата
  tianye 4487792ac9 Merge remote-tracking branch 'origin/master' 2 роки тому
  tianye 75404c8d3c 调整pgsql方言问题 2 роки тому

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

@@ -73,7 +73,7 @@
         <where>
         1=1
             <if test="startdate !=null and enddate !=null">
-                and a.alarmdate &gt;= #{startdate} and a.alarmdate &lt;= #{enddate}
+                and a.alarmdate &gt;= #{startdate,jdbcType=DATE} and a.alarmdate &lt;= #{enddate,jdbcType=DATE}
             </if>
             <if test="stationid !=null and stationid !=''">
                 and ss.stationid=#{stationid}

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

@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.gyee.wisdom.alarm.sharding.mapper.AlarmHisotryMapper">
 
@@ -13,7 +13,7 @@
         <foreach collection="list" item="item" index="index" separator="union all" >
             ( select
             #{item.id}, cast(#{item.alertTime} as  timestamp), #{item.messageType},#{item.snapId},#{item.dataInfo},#{item.alertTextLast}
-            from dual )
+             )
         </foreach>
     </insert>
 

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

@@ -81,7 +81,7 @@
                 #{item.isOpened},#{item.lastUpdateTime},#{item.stationName},#{item.projectName},
                 #{item.lineName},#{item.windturbineName},#{item.alertText},#{item.modelId},
                 #{item.testingpointKey},#{item.dataInfo}
-            from dual )
+             )
         </foreach>
     </insert>
 
@@ -125,7 +125,7 @@
 
     <select id="getTopNumAlarm" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.AlarmSnap">
         select * from ( select * from alarmsnap h order by h.lastupdatetime desc) t
-        where t.category1 = #{category1}  limit 0 OFFSET #{topnum}
+        where t.category1 = #{category1}  limit #{topnum} OFFSET 0
     </select>
 
     <select id="getRecentAlarm" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.AlarmSnap">

+ 92 - 53
warning-web/src/main/resources/mappers-postgresql/Alertrule2Mapper.xml

@@ -6,47 +6,75 @@
           WARNING - @mbg.generated
           This element is automatically generated by MyBatis Generator, do not modify.
         -->
-        <id column="id" property="id" />
-        <result column="name"  property="name" />
-        <result column="description"  property="description" />
-        <result column="expression"  property="expression" />
-        <result column="rank"  property="rank" />
-        <result column="rank"  property="rank" />
-        <result column="enabled"  property="enabled" />
-        <result column="modelId"  property="modelId" />
-        <result column="ednaValue"  property="ednaValue" />
-        <result column="category"  property="category" />
-        <result column="range"  property="range" />
-        <result column="station"  property="station" />
-        <result column="windturbine"  property="windturbine" />
-        <result column="line"  property="line" />
-        <result column="project"  property="project" />
-        <result column="electrical"  property="electrical" />
-        <result column="taskstart"  property="taskstart" />
-        <result column="relatedParts"  property="relatedParts" />
+        <id column="id" property="id"/>
+        <result column="name" property="name"/>
+        <result column="description" property="description"/>
+        <result column="expression" property="expression"/>
+        <result column="rank" property="rank"/>
+        <result column="rank" property="rank"/>
+        <result column="enabled" property="enabled"/>
+        <result column="modelId" property="modelId"/>
+        <result column="ednaValue" property="ednaValue"/>
+        <result column="category" property="category"/>
+        <result column="range" property="range"/>
+        <result column="station" property="station"/>
+        <result column="windturbine" property="windturbine"/>
+        <result column="line" property="line"/>
+        <result column="project" property="project"/>
+        <result column="electrical" property="electrical"/>
+        <result column="taskstart" property="taskstart"/>
+        <result column="relatedParts" property="relatedParts"/>
     </resultMap>
     <resultMap type="Alertrule2" id="Alertrule2Result">
-        <result property="id"    column="id"    />
-        <result property="name"    column="name"    />
-        <result property="station"    column="station"    />
-        <result property="relatedParts"    column="relatedParts"    />
-        <association  property="windPowerStation"  column="station"     javaType="WindPowerStation"  select="com.gyee.wisdom.alarm.sharding.mapper.WindPowerStationMapper.selectByid"/>
-        <association  property="datadictionary"  column="relatedParts"     javaType="Datadictionary"  select="com.gyee.wisdom.alarm.sharding.mapper.DatadictionaryMapper.selectBycode"/>
+        <result property="id" column="id"/>
+        <result property="name" column="name"/>
+        <result property="station" column="station"/>
+        <result property="relatedParts" column="relatedParts"/>
+        <association property="windPowerStation" column="station" javaType="WindPowerStation"
+                     select="com.gyee.wisdom.alarm.sharding.mapper.WindPowerStationMapper.selectByid"/>
+        <association property="datadictionary" column="relatedParts" javaType="Datadictionary"
+                     select="com.gyee.wisdom.alarm.sharding.mapper.DatadictionaryMapper.selectBycode"/>
     </resultMap>
-    <select id="pageQueryAll" parameterType="java.util.Map" resultMap="Alertrule2Result">
-        select a.* from  ALERTRULE2 a
+
+    <resultMap type="com.gyee.wisdom.alarm.sharding.entity.Alertrule2" id="alertRule2ResultToPostgreSql">
+        <result property="id" column="id"/>
+        <result property="name" column="name"/>
+        <result property="description" column="description"/>
+        <result property="expression" column="expression"/>
+        <result property="tag" column="tag"/>
+        <result property="rank" column="rank"/>
+        <result property="enabled" column="specialenable"/>
+        <result property="modelId" column="modelid"/>
+        <result property="ednaValue" column="ednavalue"/>
+        <result property="category" column="category"/>
+        <result property="range" column="range"/>
+        <result property="station" column="station"/>
+        <result property="windturbine" column="windturbine"/>
+        <result property="line" column="line"/>
+        <result property="project" column="project"/>
+        <result property="electrical" column="electrical"/>
+        <result property="taskstart" column="taskstart"/>
+        <result property="relatedParts" column="relatedParts"/>
+        <association property="windPowerStation" column="station" javaType="WindPowerStation"
+                     select="com.gyee.wisdom.alarm.sharding.mapper.WindPowerStationMapper.selectByid"/>
+        <association property="datadictionary" column="relatedParts" javaType="Datadictionary"
+                     select="com.gyee.wisdom.alarm.sharding.mapper.DatadictionaryMapper.selectBycode"/>
+    </resultMap>
+
+    <select id="pageQueryAll" parameterType="java.util.Map" resultMap="alertRule2ResultToPostgreSql">
+        select a.*, (case a.enabled   WHEN 't' then 1  when 'f' then 0  else 0 end) as specialenable from ALERTRULE2 a
         left join windpowerstation w on w.id = a.station
         <where>
             1=1
 
             <if test="name !=null and name !=''">
-                and a.name like  '%${name}%'
+                and a.name like '%${name}%'
             </if>
             <if test="station !=null and station !=''">
-                and a.station like  '%${station}%'
+                and a.station like '%${station}%'
             </if>
             <if test="modelId !=null and modelId !=''">
-                and a.modelid like  '%${modelId}%'
+                and a.modelid like '%${modelId}%'
             </if>
             <if test="rank !=null and rank !=''">
                 and a.rank = #{rank}
@@ -55,27 +83,34 @@
                 and a.category = #{category}
             </if>
             <if test="enabled !=null and enabled !=''">
-                and a.enabled = #{enabled}
+                <if test="enabled ='1'">
+                    and a.enabled = true
+                </if>
+                <if test="enabled ='0'">
+                    and a.enabled = false
+                </if>
             </if>
-<!--            and a.range = 0-->
+
+            <!--            and a.range = 0-->
         </where>
-        order by a.createtime desc
+
     </select>
 
     <select id="getMaxEdnaValue" parameterType="java.util.Map" resultType="java.lang.Integer">
-        select max(a.ednavalue) from  ALERTRULE2 a
+        select max(a.ednavalue) from ALERTRULE2 a
     </select>
-    <select id="getAllByStationIdAndModelId" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
-        select * from  ALERTRULE2 a
+    <select id="getAllByStationIdAndModelId" parameterType="java.util.Map"
+            resultMap="alertRule2ResultToPostgreSql">
+        select *, (case a.enabled   WHEN 't' then 1  when 'f' then 0  else 0 end) as specialenable from ALERTRULE2 a
         <where>
             1=1
             <if test="idString !=null and idString !=''">
-                and a.id like  '%${idString}%'
+                and a.id like '%${idString}%'
             </if>
         </where>
     </select>
     <select id="getById" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
-        select * from  ALERTRULE2 a
+        select *, (case a.enabled   WHEN 't' then 1  when 'f' then 0  else 0 end) as specialenable from ALERTRULE2 a
         <where>
             1=1
             <if test="idString !=null and idString !=''">
@@ -84,13 +119,13 @@
         </where>
     </select>
 
-    <select id="quertByrelatedParts"  resultType="java.util.HashMap">
-        select a.name from  ALERTRULE2 a
+    <select id="quertByrelatedParts" resultType="java.util.HashMap">
+        select a.name from ALERTRULE2 a
         where a.relatedparts = #{relatedParts}
         group by a.name
     </select>
 
-    <select id="queryTree" resultMap="Alertrule2Result" >
+    <select id="queryTree" resultMap="Alertrule2Result">
         select distinct a.relatedparts,a.name,d.name from alertrule2 a
         left join DATADICTIONARY d
         on d.code = a.relatedparts
@@ -100,13 +135,14 @@
 
     <select id="queryMap" resultType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
         select t.relatedparts,d.name from
-            (select a.relatedparts from alertrule2 a
-             where relatedparts  is not null
-             group by a.relatedparts) t
+        (select a.relatedparts from alertrule2 a
+        where relatedparts is not null
+        group by a.relatedparts) t
         left join DATADICTIONARY d
         on d.code = t.relatedparts
     </select>
-    <insert id="insertAlerture2" parameterType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2" useGeneratedKeys="true" keyProperty="id">
+    <insert id="insertAlerture2" parameterType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2"
+            useGeneratedKeys="true" keyProperty="id">
         insert into alertrule2
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="id != null">id,</if>
@@ -153,13 +189,15 @@
     </insert>
     <update id="updateByAlertrule2Id" parameterType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
         update alertrule2 a
-        <set >
+        <set>
             <if test="name != null">a.name = #{name},</if>
             <if test="description != null">a.description = #{description},</if>
             <if test="expression != null">a.expression = #{expression},</if>
             <if test="tag != null">a.tag = #{tag},</if>
             <if test="rank != null">a.rank = #{rank},</if>
-            <if test="enabled != null">a.enabled = #{enabled},</if>
+
+            <if test="enabled != null"><if test="enabled == 1">a.enabled = true,</if><if test="enabled == 0">a.enabled = false,</if></if>
+
             <if test="modelId != null">a.modelId = #{modelId},</if>
             <if test="ednaValue != null and ednaValue!=0">a.ednaValue = #{ednaValue},</if>
             <if test="category != null">a.category = #{category},</if>
@@ -177,13 +215,12 @@
     </update>
 
 
-
     <select id="selectByAlertrule2Id" resultType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
-        select * from  alertrule2 a where a.id=#{id}
+        select *, (case a.enabled   WHEN 't' then 1  when 'f' then 0  else 0 end) as specialenable from ALERTRULE2 a where a.id=#{id}
     </select>
 
     <select id="selectByNameAndSataionAndModelid" resultType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
-        select * from  alertrule2 a
+        select *, (case a.enabled   WHEN 't' then 1  when 'f' then 0  else 0 end) as specialenable from ALERTRULE2 a
         <where>
             1=1
             <if test="name !=null and name !=''">
@@ -198,7 +235,8 @@
         </where>
     </select>
 
-    <select id="selectByExample" parameterType="com.gyee.wisdom.alarm.sharding.model.Alertrule2Example" resultMap="BaseResultMap">
+    <select id="selectByExample" parameterType="com.gyee.wisdom.alarm.sharding.model.Alertrule2Example"
+            resultMap="BaseResultMap">
         <!--
           WARNING - @mbg.generated
           This element is automatically generated by MyBatis Generator, do not modify.
@@ -208,10 +246,10 @@
             distinct
         </if>
         *
-<!--        <include refid="Base_Column_List" />-->
+        <!--        <include refid="Base_Column_List" />-->
         from ALERTRULE2
         <if test="_parameter != null">
-            <include refid="Example_Where_Clause" />
+            <include refid="Example_Where_Clause"/>
         </if>
         <if test="orderByClause != null">
             order by ${orderByClause}
@@ -249,7 +287,8 @@
                                 </when>
                                 <when test="criterion.listValue">
                                     and ${criterion.condition}
-                                    <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
+                                             separator=",">
                                         #{listItem}
                                     </foreach>
                                 </when>

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

@@ -10,10 +10,9 @@
             <if test="windturbineid !=null and windturbineid !=''">
                 and e.windturbineid = #{windturbineid}
             </if>
-            and e.statdate >= current_date-1 and e.statdate &lt; current_date;
+            and e.statdate >= current_date-1 and e.statdate &lt;current_date
         </where>
     </select>
 
 
-
 </mapper>

+ 3 - 3
warning-web/src/main/resources/mappers-postgresql/FaultHistoryMapper.xml

@@ -6,8 +6,8 @@
         insert into faulthistory (id, faulttime, operator, snapid,confirmtype, confirmtime, confirmperson,messagetype,alerttextlast)
         <foreach collection="list" item="item" index="index" separator="union all" >
             ( select
-            #{item.id}, #{item.faultTime}, #{item.operator},#{item.snapId},#{item.confirmType},#{item.confirmTime},#{item.confirmPerson},#{item.messageType},#{item.alertTextLast}
-            from dual )
+            #{item.id}, cast(#{item.faultTime} as  timestamp), #{item.operator},#{item.snapId},#{item.confirmType},cast(#{item.confirmTime} as  timestamp),#{item.confirmPerson},#{item.messageType},#{item.alertTextLast}
+             )
         </foreach>
     </insert>
 
@@ -37,7 +37,7 @@
             CONFIRMTYPE = #{confirmType} ,
             CONFIRMPERSON = #{confirmPerson} ,
             ALERTSNAPID = #{alertSnapId} ,
-            CONFIRMTIME = #{confirmTime}
+            CONFIRMTIME = cast(#{confirmTime} as  timestamp)
         WHERE SNAPID = #{snapId}
     </update>
 

+ 4 - 4
warning-web/src/main/resources/mappers-postgresql/FaultSnapMapper.xml

@@ -8,10 +8,10 @@
             ( select
                 #{item.id},#{item.stationId},#{item.projectId},#{item.lineId},#{item.windturbineId},
                 #{item.alertValue},#{item.category1},#{item.category2},#{item.category3},#{item.rank},
-                #{item.isOpened},#{item.lastUpdateTime},#{item.stationName},#{item.projectName},
+                #{item.isOpened},cast(#{item.lastUpdateTime} as  timestamp),#{item.stationName},#{item.projectName},
                 #{item.lineName},#{item.windturbineName},#{item.alertText},#{item.modelId},
                 #{item.testingpointKey},#{item.alarmSnapId}
-            from dual )
+            )
         </foreach>
     </insert>
 
@@ -20,7 +20,7 @@
             UPDATE faultsnap
             <set>
                 <if test="item.isOpened != null">ISOPENED = #{item.isOpened},</if>
-                <if test="item.lastUpdateTime != null">LASTUPDATETIME = #{item.lastUpdateTime},</if>
+                <if test="item.lastUpdateTime != null">LASTUPDATETIME = cast(#{item.lastUpdateTime} as  timestamp),</if>
                 <if test="item.alertText != null">ALERTTEXT = #{item.alertText},</if>
             </set>
             <where>
@@ -68,7 +68,7 @@
 
     <select id="getTopNumFault" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.FaultSnap">
         select * from ( select * from faultsnap h order by h.lastupdatetime desc) t
-         limit 0 OFFSET #{topnum}
+         limit #{topnum} OFFSET 0
     </select>
 
 </mapper>

+ 25 - 4
warning-web/src/main/resources/mappers-postgresql/ScadabjMapper.xml

@@ -2,8 +2,24 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.gyee.wisdom.alarm.sharding.mapper.ScadabjMapper">
 
-    <select id="pageQueryAll" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.Scadabj">
-        select * from  SCADABJ a
+
+    <resultMap type="com.gyee.wisdom.alarm.sharding.entity.Scadabj" id="scadabjResultToPostgreSql">
+        <result property="id" column="id"/>
+        <result property="pointKey" column="pointkey"/>
+        <result property="description" column="description"/>
+        <result property="category1" column="category1"/>
+        <result property="category2" column="category2"/>
+        <result property="category3" column="category3"/>
+        <result property="category4" column="category4"/>
+        <result property="stationId" column="stationid"/>
+        <result property="deviceId" column="deviceid"/>
+        <result property="rank" column="rank"/>
+        <result property="enabled" column="specialenable"/>
+        <result property="alarmType" column="alarmtype"/>
+    </resultMap>
+
+    <select id="pageQueryAll" parameterType="java.util.Map" resultMap="scadabjResultToPostgreSql">
+        select a.*,(case a.enabled   WHEN 't' then 1  when 'f' then 0  else 0 end) as specialenable from  SCADABJ a
         <where>
             1=1
             <if test="pointKey !=null and pointKey !=''">
@@ -13,7 +29,12 @@
                 and a.stationId=#{stationId}
             </if>
             <if test="enable !=null and enable !=''">
-                and a.enabled=#{enable}
+                <if test="enable ='1'">
+                    and a.enabled = true
+                </if>
+                <if test="enable ='0'">
+                    and a.enabled = false
+                </if>
             </if>
             <if test="description !=null and description !=''">
                 and a.description like  '%${description}%'
@@ -22,7 +43,7 @@
     </select>
 
     <select id="getAll" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.Scadabj">
-        select * from  SCADABJ a
+        select a.*,(case a.enabled   WHEN 't' then 1  when 'f' then 0  else 0 end) as specialenable from  SCADABJ a
 
     </select>
 

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

@@ -3,7 +3,7 @@
 <mapper namespace="com.gyee.wisdom.alarm.sharding.mapper.WindTurbineTestingPointAiMapper">
 
     <select id="getWindTurbineTestingPointAi" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.WindTurbineTestingPointAi">
-        select * from  windturbinetestingpointnew a
+        select * from  windturbinetestingpointai a
         <where>
             1=1
             <if test="wtId !=null and wtId !=''">
@@ -16,7 +16,7 @@
     </select>
 
     <select id="getPointList" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.WindTurbineTestingPointAi">
-        select * from  windturbinetestingpointnew a
+        select * from  windturbinetestingpointai a
         <where>
             1=1
             <if test="uniformCodeList  !=null and uniformCodeList.size > 0 ">