瀏覽代碼

Merge branch 'master' of http://124.70.58.209:3000/ytrd-project-management/GeoHazardMonitor

hexiao 2 年之前
父節點
當前提交
d70adf31dc

+ 5 - 0
business-service/src/main/java/com/ozs/service/mapper/MsgAlarmMapper.java

@@ -1,11 +1,13 @@
 package com.ozs.service.mapper;
 
+import com.ozs.common.core.domain.entity.SysUser;
 import com.ozs.service.entity.MsgAlarm;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ozs.service.entity.vo.AlarmStatisticDto;
 import com.ozs.service.entity.vo.AlarmStatisticMonthDto;
 import com.ozs.service.entity.vo.AlarmStatisticVo;
 
+import com.ozs.service.entity.vo.MsgAlarmVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -37,4 +39,7 @@ public interface MsgAlarmMapper extends BaseMapper<MsgAlarm> {
     Map selectCameraCode(@Param("cameraCode") String cameraCode);
 
     MsgAlarm selectByCameraCode(@Param("cameraCode") String cameraCode);
+
+
+    List<MsgAlarm> selectMsgAlarmList(MsgAlarmVo msgAlarmVo);
 }

+ 3 - 0
business-service/src/main/java/com/ozs/service/service/MsgAlarmService.java

@@ -7,6 +7,7 @@ import com.ozs.service.entity.vo.AlarmStatisticDto;
 import com.ozs.service.entity.vo.AlarmStatisticMonthDto;
 import com.ozs.service.entity.vo.AlarmStatisticResVo;
 import com.ozs.service.entity.vo.AlarmStatisticVo;
+import com.ozs.service.entity.vo.MsgAlarmVo;
 
 import javax.servlet.http.HttpServletResponse;
 import java.util.List;
@@ -38,4 +39,6 @@ public interface MsgAlarmService extends IService<MsgAlarm> {
      * @return
      */
     MsgAlarm selectByCameraCode(String cameraCode);
+
+    IPage<MsgAlarm> queryPage(MsgAlarmVo msgAlarmVo);
 }

+ 16 - 1
business-service/src/main/java/com/ozs/service/service/impl/MsgAlarmServiceImpl.java

@@ -2,17 +2,19 @@ package com.ozs.service.service.impl;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.ozs.common.utils.StringUtils;
+import com.github.pagehelper.PageHelper;
 import com.ozs.service.entity.MsgAlarm;
 import com.ozs.service.entity.vo.AlarmStatisticDto;
 import com.ozs.service.entity.vo.AlarmStatisticMonthDto;
 import com.ozs.service.entity.vo.AlarmStatisticResVo;
 import com.ozs.service.entity.vo.AlarmStatisticVo;
+import com.ozs.service.entity.vo.MsgAlarmVo;
 import com.ozs.service.mapper.BaseDictDataMapper;
 import com.ozs.service.mapper.MsgAlarmMapper;
 import com.ozs.service.service.MsgAlarmService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.ss.usermodel.*;
 import org.springframework.beans.BeanUtils;
@@ -85,4 +87,17 @@ public class MsgAlarmServiceImpl extends ServiceImpl<MsgAlarmMapper, MsgAlarm> i
         return msgAlarmMapper.selectByCameraCode(cameraCode);
     }
 
+    @Override
+    public IPage<MsgAlarm> queryPage(MsgAlarmVo vo) {
+        int pageNum = Integer.parseInt(vo.getPageNum().toString());
+        int pageSize = Integer.parseInt(vo.getPageSize().toString());
+        com.github.pagehelper.Page<MsgAlarm> page = PageHelper.startPage(pageNum, pageSize)
+                .doSelectPage(() -> msgAlarmMapper.selectMsgAlarmList(vo));
+        com.baomidou.mybatisplus.extension.plugins.pagination.Page<MsgAlarm> pageR =
+                new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(pageNum, pageSize);
+        pageR.setRecords(page.getResult());
+        pageR.setTotal(page.getTotal());
+        return pageR;
+    }
+
 }

+ 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>();

+ 63 - 0
business-service/src/main/resources/mapper/service/MsgAlarmMapper.xml

@@ -176,4 +176,67 @@
     <select id="selectByCameraCode" parameterType="java.lang.String" resultType="com.ozs.service.entity.MsgAlarm">
         select *, max(alarm_time) from msg_alarm where camera_code = #{cameraCode}
     </select>
+    <select id="selectMsgAlarmList" resultType="com.ozs.service.entity.MsgAlarm"
+            parameterType="com.ozs.service.entity.vo.MsgAlarmVo">
+        SELECT
+        a.alarm_id AS alarmId,
+        a.alarm_time AS alarmTime,
+        a.alarm_mile AS alarmMile,
+        a.line_dir AS lineDir,
+        a.alarm_type AS alarmType,
+        a.camera_code AS cameraCode,
+        b.id  AS id,
+        a.content AS content,
+        a.alarm_confidence AS alarmConfidence,
+        a.alarm_attr AS alarmAttr,
+        a.image_url AS imageUrl,
+        a.released_by AS releasedBy,
+        a.is_lock AS isLock,
+        a.released_time AS releasedTime
+        FROM
+        msg_alarm AS a left join
+        base_camera_management AS b on a.camera_code=b.camera_code
+        <where>
+            <if test="railwayCode != null and railwayCode != ''">
+                and b.railway_code=#{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="!dsFlay">
+            and (
+                <if test="dsUserId != null and dsUserId != ''">
+                     a.create_by=#{dsUserId}  or
+                </if>
+                <if test="dsDeptId != null and dsDeptId != 0">
+                     b.dept_id=#{dsDeptId}  or
+                </if>
+                <if test="dsDeptIds != null">
+                     b.dept_id in
+                    <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
+                        #{item}
+                    </foreach>
+                </if>
+                )
+            </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="beginAlarmTime != null and beginAlarmTime != 0">
+                <![CDATA[and MONTH(a.alarm_time) >=#{beginAlarmTime}]]>
+            </if>
+            <if test="endAlarmTime != null and endAlarmTime != 0">
+                <![CDATA[and MONTH(a.alarm_time) <=#{endAlarmTime}]]>
+            </if>
+        </where>
+    </select>
 </mapper>

+ 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>
 

+ 1 - 1
hazard-admin/src/main/java/com/ozs/web/controller/accountmanagment/BaseCameraManagementController.java

@@ -665,7 +665,7 @@ public class BaseCameraManagementController extends BaseController {
             msgAlarmResp.setAlarmMile(baseCameraManagement.getInstallMile().toString());
             return AjaxResult.success(msgAlarmResp);
         } else {
-            return AjaxResult.success(new  MsgAlarmResp());
+            return error("该相机编码:"+cameraCode+"没有报警消息");
         }
     }
 }

+ 0 - 4
hazard-admin/src/main/java/com/ozs/web/controller/accountmanagment/BaseRailwayManagementController.java

@@ -71,11 +71,7 @@ public class BaseRailwayManagementController extends BaseController {
     @ApiOperation(value = "线路管理表分页")
     @PostMapping("/list")
     public AjaxResult selectBaseLineManagement(@RequestBody BaseRailwayManagementVo baseRailwayManagementVo) {
-        List<String> userIds = baseCameraManagementService.getUserIdList(getUserId());
         LambdaQueryWrapper<BaseRailwayManagement> lw = new LambdaQueryWrapper<BaseRailwayManagement>();
-        if (!ObjectUtils.isEmpty(userIds)) {
-            lw.in(BaseRailwayManagement::getCreateBy, userIds);
-        }
         if (!StringUtils.isBlank(baseRailwayManagementVo.getRailwayCode())) {
             lw.like(BaseRailwayManagement::getRailwayCode, "%" + baseRailwayManagementVo.getRailwayCode() + "%");
         }

+ 10 - 45
hazard-admin/src/main/java/com/ozs/web/controller/accountmanagment/MsgAlarmController.java

@@ -16,6 +16,7 @@ import com.ozs.service.entity.*;
 import com.ozs.service.entity.vo.*;
 import com.ozs.service.mapper.MsgAlarmMapper;
 import com.ozs.service.service.*;
+import com.ozs.system.service.DataScoreUtil;
 import com.ozs.system.service.ISysDictDataService;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -80,7 +81,8 @@ public class MsgAlarmController extends BaseController {
     private MsgWebPushService msgWebPushService;
     @Autowired
     private ISysDictDataService dictDataService;
-
+    @Autowired
+    private DataScoreUtil dataScoreUtil;
 
     /**
      * web更多消息-总数,已读数
@@ -136,49 +138,13 @@ public class MsgAlarmController extends BaseController {
     @ApiOperation(value = "报警信息分页")
     @PostMapping("/list")
     public AjaxResult selectMsgAlarm(@RequestBody MsgAlarmVo msgAlarmVo) {
-        List<BaseCameraManagement> baseCameraManagementList = new ArrayList<>();
-        LambdaQueryWrapper<BaseCameraManagement> wrapper = new LambdaQueryWrapper<BaseCameraManagement>();
-        if (!ObjectUtils.isEmpty(msgAlarmVo.getRailwayCode())) {
-            wrapper.eq(BaseCameraManagement::getRailwayCode, msgAlarmVo.getRailwayCode());
-        }
-        if (!ObjectUtils.isEmpty(msgAlarmVo.getBeginMile())) {
-            wrapper.ge(BaseCameraManagement::getBeginMile, msgAlarmVo.getBeginMile());
-        }
-        if (!ObjectUtils.isEmpty(msgAlarmVo.getEndMile())) {
-            wrapper.le(BaseCameraManagement::getEndMile, msgAlarmVo.getEndMile());
-        }
-        if (!ObjectUtils.isEmpty(msgAlarmVo.getRailwayCode()) || !ObjectUtils.isEmpty(msgAlarmVo.getBeginMile()) || !ObjectUtils.isEmpty(msgAlarmVo.getEndMile())) {
-            baseCameraManagementList = baseCameraManagementService.list(wrapper);
-        }
-        List<String> userIds = baseCameraManagementService.getUserIdList(getUserId());
-        LambdaQueryWrapper<MsgAlarm> lw = new LambdaQueryWrapper<MsgAlarm>();
-        if (!ObjectUtils.isEmpty(userIds)) {
-            lw.in(MsgAlarm::getCreateBy, userIds);
-        }
-        if (!ObjectUtils.isEmpty(msgAlarmVo.getLineDir())) {
-            lw.eq(MsgAlarm::getLineDir, msgAlarmVo.getLineDir());
-        }
-        if (baseCameraManagementList.size() > 0) {
-            List<String> collect = baseCameraManagementList.stream().map(BaseCameraManagement::getCameraCode).collect(Collectors.toList());
-            lw.in(MsgAlarm::getCameraCode, collect);
-        }
-        if (!ObjectUtils.isEmpty(msgAlarmVo.getAlarmType())) {
-            lw.eq(MsgAlarm::getAlarmType, msgAlarmVo.getAlarmType());
-        }
-        if (!ObjectUtils.isEmpty(msgAlarmVo.getAlarmMile()) && msgAlarmVo.getAlarmMile() != 0) {
-            lw.eq(MsgAlarm::getAlarmMile, msgAlarmVo.getAlarmMile());
-        }
-        if (!ObjectUtils.isEmpty(msgAlarmVo.getBeginAlarmTime())) {
-            lw.ge(MsgAlarm::getAlarmTime, msgAlarmVo.getBeginAlarmTime());
-        }
-        if (!ObjectUtils.isEmpty(msgAlarmVo.getEndAlarmTime())) {
-            lw.le(MsgAlarm::getAlarmTime, msgAlarmVo.getEndAlarmTime());
-        }
-        if (!ObjectUtils.isEmpty(msgAlarmVo.getIsLock())) {
-            lw.eq(MsgAlarm::getIsLock, msgAlarmVo.getIsLock());
-        }
-        IPage<MsgAlarm> page = msgAlarmService.page(new Page<>(msgAlarmVo.getPageNum(), msgAlarmVo.getPageSize()), lw);
-        if (!ObjectUtils.isEmpty(page) && !ObjectUtils.isEmpty(page.getRecords())) {
+        msgAlarmVo = (MsgAlarmVo) dataScoreUtil.setDataScore(getUserId(), msgAlarmVo);
+        IPage<MsgAlarm> page = msgAlarmService.queryPage(msgAlarmVo);
+        page.setTotal(page.getTotal());
+        page.setCurrent(page.getCurrent());
+        page.setPages(page.getPages());
+
+        if (!ObjectUtils.isEmpty(page) && page.getRecords().size() > 0) {
             List<MsgAlarm> dto1 = page.getRecords().stream().map(o -> {
                 String[] split = o.getImageUrl().split(";");
                 ArrayList<String> objects = new ArrayList<>(Arrays.asList(split));
@@ -193,7 +159,6 @@ public class MsgAlarmController extends BaseController {
                     queryWrapper.eq(BaseRailwayManagement::getRailwayCode, cameraManagement.getRailwayCode());
                 }
                 BaseRailwayManagement baseRailwayManagement = baseRailwayManagementService.getOne(queryWrapper);
-
                 o.setRailwayName(baseRailwayManagement.getRailwayName());
                 String mils = AppendUtils.stringAppend(cameraManagement.getInstallMile());
                 o.setAlarmMiles(mils);