Browse Source

1.预警规则编辑 支持postgresql

wanghs 2 years ago
parent
commit
3c329e17ee
1 changed files with 30 additions and 28 deletions
  1. 30 28
      warning-web/src/main/resources/mappers-postgresql/Alertrule2Mapper.xml

+ 30 - 28
warning-web/src/main/resources/mappers-postgresql/Alertrule2Mapper.xml

@@ -62,7 +62,7 @@
     </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
+        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
@@ -101,7 +101,7 @@
     </select>
     <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
+        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 !=''">
@@ -110,7 +110,7 @@
         </where>
     </select>
     <select id="getById" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
-        select *, (case a.enabled   WHEN 't' then 1  when 'f' then 0  else 0 end) as specialenable 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 !=''">
@@ -188,39 +188,41 @@
         </trim>
     </insert>
     <update id="updateByAlertrule2Id" parameterType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
-        update alertrule2 a
+        update alertrule2
         <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"><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>
-            <if test="range != null">a.range = #{range},</if>
-            <if test="station != null">a.station = #{station},</if>
-            <if test="windturbine != null">a.windturbine = #{windturbine},</if>
-            <if test="line != null">a.line = #{line},</if>
-            <if test="project != null">a.project = #{project},</if>
-            <if test="electrical != null">a.electrical = #{electrical},</if>
-            <if test="taskstart != null">a.taskstart = #{taskstart},</if>
-            <if test="relatedParts != null">a.relatedParts = #{relatedParts},</if>
-            <if test="createtime != null">a.createtime = #{createtime}</if>
+            <if test="name != null">name = #{name},</if>
+            <if test="description != null">description = #{description},</if>
+            <if test="expression != null">expression = #{expression},</if>
+            <if test="tag != null">tag = #{tag},</if>
+            <if test="rank != null">rank = #{rank},</if>
+            <if test="enabled != null">
+                <if test="enabled == 1">enabled = 't',</if>
+                <if test="enabled == 0">enabled = 'f',</if>
+            </if>
+            <if test="modelId != null">modelId = #{modelId},</if>
+            <if test="ednaValue != null and ednaValue!=0">ednaValue = #{ednaValue},</if>
+            <if test="category != null">category = #{category},</if>
+            <if test="range != null">range = #{range},</if>
+            <if test="station != null">station = #{station},</if>
+            <if test="windturbine != null">windturbine = #{windturbine},</if>
+            <if test="line != null">line = #{line},</if>
+            <if test="project != null">project = #{project},</if>
+            <if test="electrical != null">electrical = #{electrical},</if>
+            <if test="taskstart != null">taskstart = #{taskstart},</if>
+            <if test="relatedParts != null">relatedParts = #{relatedParts},</if>
+            <if test="createtime != null">createtime = #{createtime}</if>
         </set>
-        where a.id = #{id}
+        where id = #{id}
     </update>
 
 
-    <select id="selectByAlertrule2Id" resultType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
-        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 id="selectByAlertrule2Id" resultMap="alertRule2ResultToPostgreSql">
+        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 *, (case a.enabled   WHEN 't' then 1  when 'f' then 0  else 0 end) as specialenable 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 !=''">