sunhh пре 2 година
родитељ
комит
df2a7a1c34

+ 6 - 1
business-service/src/main/java/com/ozs/service/service/impl/MsgWebPushServiceImpl.java

@@ -50,9 +50,14 @@ public class MsgWebPushServiceImpl extends ServiceImpl<MsgWebPushMapper, MsgWebP
     public Map webAlarm(String userId) {
         List<String> userIds = baseCameraManagementService.getUserIds(userId);
         Map<String, Object> webAlarmMap = new HashMap<>();
+        List<MsgAlarmResp> msgAlarmRespList = new ArrayList<>();
+        if (StringUtils.isEmpty(userIds)) {
+            webAlarmMap.put("webAlarmNum", 0);
+            webAlarmMap.put("webAlarm", msgAlarmRespList);
+            return webAlarmMap;
+        }
         Integer webAlarmNum = msgWebPushMapper.webAlarmNum(userIds);
         List<MsgAlarm> webAlarm = msgWebPushMapper.webAlarm(userIds);
-        List<MsgAlarmResp> msgAlarmRespList = new ArrayList<>();
         if (!StringUtils.isEmpty(webAlarm) && webAlarm.size() > 0) {
             for (MsgAlarm msgAlarm : webAlarm) {
                 LambdaQueryWrapper<BaseCameraManagement> lw = new LambdaQueryWrapper<BaseCameraManagement>();

+ 55 - 48
business-service/src/main/resources/mapper/service/MsgWebPushMapper.xml

@@ -3,18 +3,24 @@
 <mapper namespace="com.ozs.service.mapper.MsgWebPushMapper">
 
     <select id="webAlarmNum" parameterType="java.lang.String" resultType="java.lang.Integer">
-        select count(*) from msg_web_push where status = 1 and receive_by in
-        <foreach item="item" collection="userIds" separator="," open="(" close=")" index="">
-            #{item}
-        </foreach>
+        select count(*) from msg_web_push where status = 1
+        <if test="userIds != null and userIds != ''">
+            and receive_by in
+            <foreach item="item" collection="userIds" separator="," open="(" close=")" index="">
+                #{item}
+            </foreach>
+        </if>
     </select>
 
     <select id="webAlarm" parameterType="java.lang.String" resultType="com.ozs.service.entity.MsgAlarm">
         select b.* from (
-            select alarm_id from msg_web_push where status = 1 and receive_by in
-            <foreach item="item" collection="userIds" separator="," open="(" close=")" index="">
-                #{item}
-            </foreach>
+            select alarm_id from msg_web_push where status = 1
+                <if test="userIds != null and userIds != ''">
+                    and receive_by in
+                    <foreach item="item" collection="userIds" separator="," open="(" close=")" index="">
+                        #{item}
+                    </foreach>
+                </if>
         ) a left join (
             select * from msg_alarm
         ) b on a.alarm_id = b.alarm_id
@@ -27,49 +33,50 @@
         </foreach>
     </select>
 
-    <select id="messageMore" parameterType="com.ozs.service.entity.vo.MsgAlarmVo" resultType="com.ozs.service.entity.MsgAlarm">
+    <select id="messageMore" parameterType="com.ozs.service.entity.vo.MsgAlarmVo"
+            resultType="com.ozs.service.entity.MsgAlarm">
         select b.* from (
-            select alarm_id from msg_web_push
-            <where>
-                <if test="status != null  and status != ''">
-                    and status = #{status}
-                </if>
-                <if test="userIds != null and userIds != ''">
-                    and receive_by in
-                    <foreach item="item" collection="userIds" index="index" separator="," open="(" close=")">
-                        #{item}
-                    </foreach>
-                </if>
-            </where>
+        select alarm_id from msg_web_push
+        <where>
+            <if test="status != null  and status != ''">
+                and status = #{status}
+            </if>
+            <if test="userIds != null and userIds != ''">
+                and receive_by in
+                <foreach item="item" collection="userIds" index="index" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
         ) a left join (
-            select * from msg_alarm
-            <where>
-                <if test="alarmType != null and alarmType != ''">
-                    and alarm_type = #{alarmType}
-                </if>
-                <if test="beginAlarmTime != null and beginAlarmTime != ''">
-                    and alarm_time &gt;= #{beginAlarmTime}
-                </if>
-                <if test="endAlarmTime != null and endAlarmTime != ''">
-                    and alarm_time &lt;= #{endAlarmTime}
-                </if>
-                <if test="isLock != null and isLock != ''">
-                    and is_lock = #{isLock}
-                </if>
-            </where>
+        select * from msg_alarm
+        <where>
+            <if test="alarmType != null and alarmType != ''">
+                and alarm_type = #{alarmType}
+            </if>
+            <if test="beginAlarmTime != null and beginAlarmTime != ''">
+                and alarm_time &gt;= #{beginAlarmTime}
+            </if>
+            <if test="endAlarmTime != null and endAlarmTime != ''">
+                and alarm_time &lt;= #{endAlarmTime}
+            </if>
+            <if test="isLock != null and isLock != ''">
+                and is_lock = #{isLock}
+            </if>
+        </where>
         ) b on a.alarm_id = b.alarm_id left join (
-            select * from base_camera_management
-            <where>
-                <if test="railwayCode != null and railwayCode != ''">
-                    and railway_code = #{railwayCode}
-                </if>
-                <if test="beginMile != null and beginMile != ''">
-                    and begin_mile &gt;= #{beginMile}
-                </if>
-                <if test="endMile != null and endMile != ''">
-                    and end_mile &lt;= #{endMile}
-                </if>
-            </where>
+        select * from base_camera_management
+        <where>
+            <if test="railwayCode != null and railwayCode != ''">
+                and railway_code = #{railwayCode}
+            </if>
+            <if test="beginMile != null and beginMile != ''">
+                and begin_mile &gt;= #{beginMile}
+            </if>
+            <if test="endMile != null and endMile != ''">
+                and end_mile &lt;= #{endMile}
+            </if>
+        </where>
         ) c on b.camera_code = c.camera_code
     </select>