gao.qiang преди 3 седмици
родител
ревизия
0ec4a7d5c0
променени са 1 файла, в които са добавени 32 реда и са изтрити 60 реда
  1. 32 60
      business-service/src/main/resources/mapper/service/MsgAlarmMapper.xml

+ 32 - 60
business-service/src/main/resources/mapper/service/MsgAlarmMapper.xml

@@ -390,66 +390,38 @@
         a.released_reason AS releasedReason,
         a.remark AS remark
         FROM
-        msg_alarm AS a join
-        base_camera_management AS b on a.camera_code=b.camera_code join
-        base_railway_management AS l on b.railway_code=l.railway_code
-        <where>
-            <if test="railwayCode != null and railwayCode != ''">
-                concat(l.railway_name,l.railway_code)
-                like concat("%",#{railwayCode},"%")
-            </if>
-            <if test="beginMile != null and beginMile != 0">
-                and b.begin_mile &gt;=#{beginMile}
-            </if>
-            <if test="endMile != null and endMile != 0">
-                and b.end_mile &lt;=#{endMile}
-            </if>
-            <if test="ids != null and ids.size>0">
-                and a.id in
-                <foreach item="items" collection="ids" separator="," open="(" close=")" index="">
-                    #{items}
-                </foreach>
-            </if>
-            <if test="!dsFlay">
-                and
-                <trim prefix="(" prefixOverrides="or" suffix=")">
-                    <if test="dsUserId != null and dsUserId != ''">
-                        or a.create_by=#{dsUserId}
-                    </if>
-                    <if test="dsDeptId != null and dsDeptId != 0">
-                        or b.dept_id=#{dsDeptId}
-                    </if>
-                    <if test="dsDeptIds != null">
-                        or b.dept_id in
-                        <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
-                            #{item}
-                        </foreach>
-                    </if>
-                </trim>
-            </if>
-            <if test="alarmType != null and alarmType != 0">
-                and a.alarm_type=#{alarmType}
-            </if>
-            <if test="alarmMile != null and alarmMile != 0">
-                and a.alarm_mile=#{alarmMile}
-            </if>
-            <if test="isLock != null and isLock != 0">
-                and a.is_lock=#{isLock}
-            </if>
-            <if test="lineDir != null and lineDir != 0">
-                and a.line_dir =#{lineDir}
-            </if>
-            <if test="releasedType != null and releasedType != 0">
-                and a.released_type =#{releasedType}
-            </if>
-            <if test="beginAlarmTime != null and beginAlarmTime != ''">
-                and date_format(a.alarm_time,'%Y-%m-%d') &gt;= date_format(#{beginAlarmTime},'%Y-%m-%d')
-            </if>
-            <if test="endAlarmTime != null and endAlarmTime != ''">
-                AND date_format(a.alarm_time,'%Y-%m-%d') &lt;= date_format(#{endAlarmTime},'%Y-%m-%d')
-            </if>
-        </where>
-        order by a.alarm_time desc
+        msg_alarm AS a
+        JOIN
+        base_camera_management AS b ON a.camera_code = b.camera_code
+        JOIN
+        base_railway_management AS l ON b.railway_code = l.railway_code
+        WHERE
+        (railwayCode IS NULL OR railwayCode = '' OR CONCAT(l.railway_name, l.railway_code) LIKE CONCAT('%', #{railwayCode}, '%'))
+        AND (beginMile IS NULL OR beginMile = 0 OR b.begin_mile >= #{beginMile})
+        AND (endMile IS NULL OR endMile = 0 OR b.end_mile <= #{endMile})
+        AND (ids IS NULL OR ids.size = 0 OR a.id IN
+        <foreach item="item" collection="ids" separator=",">
+            #{item}
+        </foreach>)
+        AND (dsFlay OR (
+        (dsUserId IS NULL OR dsUserId = '' OR a.create_by = #{dsUserId}) OR
+        (dsDeptId IS NULL OR dsDeptId = 0 OR b.dept_id = #{dsDeptId}) OR
+        (dsDeptIds IS NULL OR (
+        b.dept_id IN
+        <foreach item="item" collection="dsDeptIds" separator=",">
+            #{item}
+        </foreach>
+        ))
+        ))
+        AND (alarmType IS NULL OR alarmType = 0 OR a.alarm_type = #{alarmType})
+        AND (alarmMile IS NULL OR alarmMile = 0 OR a.alarm_mile = #{alarmMile})
+        AND (isLock IS NULL OR isLock = 0 OR a.is_lock = #{isLock})
+        AND (lineDir IS NULL OR lineDir = 0 OR a.line_dir = #{lineDir})
+        AND (releasedType IS NULL OR releasedType = 0 OR a.released_type = #{releasedType})
+        AND (beginAlarmTime IS NULL OR beginAlarmTime = '' OR DATE_FORMAT(a.alarm_time, '%Y-%m-%d') >= DATE_FORMAT(#{beginAlarmTime}, '%Y-%m-%d'))
+        AND (endAlarmTime IS NULL OR endAlarmTime = '' OR DATE_FORMAT(a.alarm_time, '%Y-%m-%d') <= DATE_FORMAT(#{endAlarmTime}, '%Y-%m-%d'))
+        ORDER BY
+        a.alarm_time DESC;
     </select>
 
     <select id="getByAlarmId" resultType="com.ozs.service.entity.MsgAlarm" parameterType="java.lang.String">