Browse Source

规避 alarmcount 中因pg库 中alarmdate 字段为date 而导致singleInsert,batchInsert写入失败问题
规避方法cast(#{item.alarmDate} as timestamp)

wangchangsheng 2 years atrás
parent
commit
0c80897bb1

+ 3 - 5
schedule-job/alarm-schedule/src/main/resources/mappers-postgresql/AlarmCountMapper.xml

@@ -15,20 +15,18 @@
     <insert id="singleInsert" >
         insert into alarmcount (id, alarmdate, snapid, count)
         values
-        (#{item.id}, #{item.alarmdate}, #{item.snapId}, #{item.count})
+        (#{item.id}, cast(#{item.alarmDate} as  timestamp), #{item.snapId}, #{item.count})
     </insert>
 
     <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="false">
         insert into alarmcount ( ID, alarmdate, snapid, count,time )
         <foreach collection="list" item="item" index="index" separator="union all" >
             ( select
-            #{item.id}, #{item.alarmDate}, #{item.snapId}, #{item.count} ,#{item.time}
-            from dual )
+            #{item.id}, cast(#{item.alarmDate} as  timestamp), #{item.snapId}, #{item.count} ,#{item.time}
+            )
         </foreach>
     </insert>
 
-
-
     <select id="selectAlarmHistoryBySnapid" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.schedule.entity.AlarmHistory"  >
              select * from ${alarmhistory} where snapid = #{snapid}
              and alerttime &gt;= #{startdate,jdbcType=DATE} and alerttime &lt; #{enddate,jdbcType=DATE} order by alerttime asc