Browse Source

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

gao.qiang 1 year atrás
parent
commit
f9fd8f920d

+ 1 - 1
business-service/src/main/java/com/ozs/service/entity/vo/MsgAlarmVo.java

@@ -68,7 +68,7 @@ public class MsgAlarmVo extends PageVo implements Serializable {
     /**
      * 用户userID
      */
-    private List<String> userIds;
+    private String userId;
 
     /**
      * 状态:1未读;2已读

+ 1 - 1
business-service/src/main/java/com/ozs/service/entity/vo/MsgAppPushVo.java

@@ -77,7 +77,7 @@ public class MsgAppPushVo extends PageVo implements Serializable {
     private String receiveBy;
 
     /**
-     * 状态:0未读;1已读
+     * 状态:1未读;2已读
      */
     private Integer status;
 

+ 1 - 1
business-service/src/main/java/com/ozs/service/mapper/MsgAppPushMapper.java

@@ -22,7 +22,7 @@ public interface MsgAppPushMapper extends BaseMapper<MsgAppPush> {
      * @param
      * @return
      */
-    List<MsgAppPushVo> alarmPushMsg(Integer status);
+    List<MsgAppPushVo> alarmPushMsg(MsgAppPushVo msgAppPushVo);
 
     /**
      * app推送报警信息记录修改状态

+ 3 - 3
business-service/src/main/java/com/ozs/service/mapper/MsgWebPushMapper.java

@@ -16,11 +16,11 @@ import java.util.Map;
  */
 @Mapper
 public interface MsgWebPushMapper extends BaseMapper<MsgWebPush> {
-    Integer webAlarmNum(MsgAlarmVo msgAlarmParameter);
+    Integer webAlarmNum(@Param("userId") String userId);
 
-    List<MsgAlarm> webAlarm(MsgAlarmVo msgAlarmParameter);
+    List<MsgAlarm> webAlarm(@Param("userId") String userId);
 
     List<MsgAlarm> messageMore(MsgAlarmVo msgAlarmVo);
 
-    Map<String, Integer> messageMoreNum(MsgAlarmVo msgAlarmVo);
+    Map<String, Integer> messageMoreNum(@Param("userId") String userId);
 }

+ 2 - 1
business-service/src/main/java/com/ozs/service/service/MsgAppPushService.java

@@ -1,5 +1,6 @@
 package com.ozs.service.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ozs.service.entity.MsgAppPush;
 import com.ozs.service.entity.vo.MsgAppPushVo;
@@ -20,7 +21,7 @@ public interface MsgAppPushService extends IService<MsgAppPush> {
      * @param
      * @return
      */
-    List<MsgAppPushVo> alarmPushMsg(Integer status);
+    IPage<MsgAppPushVo> alarmPushMsg(MsgAppPushVo msgAppPushVo);
 
     /**
      * app推送报警信息记录修改状态

+ 2 - 2
business-service/src/main/java/com/ozs/service/service/MsgWebPushService.java

@@ -17,9 +17,9 @@ import java.util.Map;
 public interface MsgWebPushService extends IService<MsgWebPush> {
     int read(MsgWebPush msgWebPush);
 
-    Map webAlarm(MsgAlarmVo msgAlarm);
+    Map webAlarm(String userId);
 
     IPage<MsgAlarm> messageMore(MsgAlarmVo msgAlarmVo);
 
-    Map<String, Integer> messageMoreNum(MsgAlarmVo msgAlarmVo);
+    Map<String, Integer> messageMoreNum(String userId);
 }

+ 14 - 3
business-service/src/main/java/com/ozs/service/service/impl/MsgAppPushServiceImpl.java

@@ -1,8 +1,12 @@
 package com.ozs.service.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageHelper;
 import com.ozs.common.utils.StringUtils;
+import com.ozs.service.entity.MsgAlarm;
 import com.ozs.service.entity.MsgAppPush;
 import com.ozs.service.entity.vo.MsgAppPushVo;
 import com.ozs.service.mapper.MsgAppPushMapper;
@@ -23,9 +27,16 @@ public class MsgAppPushServiceImpl extends ServiceImpl<MsgAppPushMapper, MsgAppP
     MsgAppPushMapper msgAppPushMapper;
 
     @Override
-    public List<MsgAppPushVo> alarmPushMsg(Integer status) {
-        List<MsgAppPushVo> list = msgAppPushMapper.alarmPushMsg(status);
-        return list;
+    public IPage<MsgAppPushVo> alarmPushMsg(MsgAppPushVo msgAppPushVo) {
+        // List<MsgAppPushVo> list = msgAppPushMapper.alarmPushMsg(status);
+        Page<MsgAppPushVo> page = PageHelper.startPage(msgAppPushVo.getPageNum().intValue(), msgAppPushVo.getPageSize().intValue())
+                .doSelectPage(() -> msgAppPushMapper.alarmPushMsg(msgAppPushVo));
+        com.baomidou.mybatisplus.extension.plugins.pagination.Page<MsgAppPushVo> pageR =
+                new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(msgAppPushVo.getPageNum().intValue(), msgAppPushVo.getPageSize().intValue());
+        pageR.setSize(page.size());
+        pageR.setTotal(page.getTotal());
+        pageR.setRecords(page.getResult());
+        return pageR;
     }
 
     @Override

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

@@ -47,12 +47,12 @@ public class MsgWebPushServiceImpl extends ServiceImpl<MsgWebPushMapper, MsgWebP
     }
 
     @Override
-    public Map webAlarm(MsgAlarmVo msgAlarmParameter) {
+    public Map webAlarm(String userId) {
         // List<String> userIds = baseCameraManagementService.getUserIds(userId);
         Map<String, Object> webAlarmMap = new HashMap<>();
         List<MsgAlarmResp> msgAlarmRespList = new ArrayList<>();
-        Integer webAlarmNum = msgWebPushMapper.webAlarmNum(msgAlarmParameter);
-        List<MsgAlarm> webAlarm = msgWebPushMapper.webAlarm(msgAlarmParameter);
+        Integer webAlarmNum = msgWebPushMapper.webAlarmNum(userId);
+        List<MsgAlarm> webAlarm = msgWebPushMapper.webAlarm(userId);
         if (!StringUtils.isEmpty(webAlarm) && webAlarm.size() > 0) {
             for (MsgAlarm msgAlarm : webAlarm) {
                 LambdaQueryWrapper<BaseCameraManagement> lw = new LambdaQueryWrapper<BaseCameraManagement>();
@@ -125,8 +125,8 @@ public class MsgWebPushServiceImpl extends ServiceImpl<MsgWebPushMapper, MsgWebP
     }
 
     @Override
-    public Map<String, Integer> messageMoreNum(MsgAlarmVo msgAlarmVo) {
-        Map<String, Integer> map = msgWebPushMapper.messageMoreNum(msgAlarmVo);
+    public Map<String, Integer> messageMoreNum(String userId) {
+        Map<String, Integer> map = msgWebPushMapper.messageMoreNum(userId);
         return map;
     }
 }

+ 6 - 4
business-service/src/main/resources/mapper/service/MsgAppPushMapper.xml

@@ -29,7 +29,7 @@
             <result column="install_latitude" property="installLatitude"/>
         </association>
     </resultMap>
-    <select id="alarmPushMsg" resultMap="MsgAppPushVoResult">
+    <select id="alarmPushMsg" resultMap="MsgAppPushVoResult" parameterType="com.ozs.service.entity.vo.MsgAppPushVo">
         select
         m.id,
         m.alarm_id,
@@ -60,11 +60,14 @@
         base_railway_management AS r on b.railway_code=r.railway_code
         <where>
             <if test="status != null and status != 0">
-                and UPPER(status) like UPPER(CONCAT('%',#{status},'%'))
+                and status = = #{status}
+            </if>
+            <if test="receiveBy != null and receiveBy != ''">
+                and receive_by = #{receiveBy}
             </if>
-            and YEAR(a.alarm_time) = YEAR(SYSDATE())
         </where>
     </select>
+
     <update id="update" parameterType="com.ozs.service.entity.MsgAppPush">
         update msg_app_push
         <set>
@@ -75,7 +78,6 @@
         where id = #{id}
     </update>
 
-
     <select id="appAlarmNum" parameterType="java.lang.String" resultType="java.lang.Integer">
         select count(*) from msg_app_push where status = 1 and receive_by = #{userId}
     </select>

+ 15 - 80
business-service/src/main/resources/mapper/service/MsgWebPushMapper.xml

@@ -2,58 +2,21 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="com.ozs.service.mapper.MsgWebPushMapper">
 
-    <select id="webAlarmNum" parameterType="com.ozs.service.entity.vo.MsgAlarmVo" resultType="java.lang.Integer">
-        select count(1)
-        from msg_web_push AS a
-        join msg_alarm AS b on a.alarm_id = b.alarm_id
-        join base_camera_management AS c on b.camera_code = c.camera_code
-        <where>
-            a.status = 1
-            <if test="!dsFlay">
-                and
-                <trim prefix="(" prefixOverrides="or" suffix=")">
-                    <if test="dsUserId != null and dsUserId != ''">
-                        or a.receive_by = #{dsUserId}
-                    </if>
-                    <if test="dsDeptId != null and dsDeptId != 0">
-                        or c.dept_id = #{dsDeptId}
-                    </if>
-                    <if test="dsDeptIds != null">
-                        or c.dept_id in
-                        <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
-                            #{item}
-                        </foreach>
-                    </if>
-                </trim>
-            </if>
-        </where>
+    <select id="webAlarmNum" parameterType="java.lang.String" resultType="java.lang.Integer">
+        select count(1) from msg_web_push where status = 1
+        <if test="userId != null and userId != ''">
+            and receive_by = #{userId}
+        </if>
     </select>
 
-    <select id="webAlarm" parameterType="com.ozs.service.entity.vo.MsgAlarmVo" resultType="com.ozs.service.entity.MsgAlarm">
+    <select id="webAlarm" parameterType="java.lang.String" resultType="com.ozs.service.entity.MsgAlarm">
         select b.*
         from msg_web_push AS a
         join msg_alarm AS b on a.alarm_id = b.alarm_id
-        join base_camera_management AS c on b.camera_code = c.camera_code
-        <where>
-            a.status = 1
-            <if test="!dsFlay">
-                and
-                <trim prefix="(" prefixOverrides="or" suffix=")">
-                    <if test="dsUserId != null and dsUserId != ''">
-                        or a.receive_by = #{dsUserId}
-                    </if>
-                    <if test="dsDeptId != null and dsDeptId != 0">
-                        or c.dept_id = #{dsDeptId}
-                    </if>
-                    <if test="dsDeptIds != null">
-                        or c.dept_id in
-                        <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
-                            #{item}
-                        </foreach>
-                    </if>
-                </trim>
-            </if>
-        </where>
+        where a.status = 1
+        <if test="userId != null and userId != ''">
+            and a.receive_by = #{userId}
+        </if>
     </select>
 
     <select id="messageMore" parameterType="com.ozs.service.entity.vo.MsgAlarmVo"
@@ -63,22 +26,8 @@
         join msg_alarm AS b on a.alarm_id = b.alarm_id
         join base_camera_management AS c on b.camera_code = c.camera_code
         <where>
-            <if test="!dsFlay">
-                and
-                <trim prefix="(" prefixOverrides="or" suffix=")">
-                    <if test="dsUserId != null and dsUserId != ''">
-                        or a.receive_by = #{dsUserId}
-                    </if>
-                    <if test="dsDeptId != null and dsDeptId != 0">
-                        or c.dept_id = #{dsDeptId}
-                    </if>
-                    <if test="dsDeptIds != null">
-                        or c.dept_id in
-                        <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
-                            #{item}
-                        </foreach>
-                    </if>
-                </trim>
+            <if test="userId != null and userId != ''">
+                or a.receive_by = #{userId}
             </if>
             <if test="status != null and status != ''">
                 and a.status = #{status}
@@ -108,24 +57,10 @@
     </select>
 
     <select id="messageMoreNum" parameterType="com.ozs.service.entity.vo.MsgAlarmVo" resultType="java.util.Map">
-        select count(1) count, SUM(CASE a.status WHEN '1' THEN 1 ELSE 0 end) AS 'noCount' from msg_web_push AS a join msg_alarm AS b on a.alarm_id = b.alarm_id join base_camera_management AS c on b.camera_code = c.camera_code
+        select count(1) count, SUM(CASE status WHEN '1' THEN 1 ELSE 0 end) AS 'noCount' from msg_web_push
         <where>
-            <if test="!dsFlay">
-                and
-                <trim prefix="(" prefixOverrides="or" suffix=")">
-                    <if test="dsUserId != null and dsUserId != ''">
-                        or a.receive_by = #{dsUserId}
-                    </if>
-                    <if test="dsDeptId != null and dsDeptId != 0">
-                        or c.dept_id = #{dsDeptId}
-                    </if>
-                    <if test="dsDeptIds != null">
-                        or c.dept_id in
-                        <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
-                            #{item}
-                        </foreach>
-                    </if>
-                </trim>
+            <if test="userId != null and userId != ''">
+                or receive_by = #{userId}
             </if>
         </where>
     </select>

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

@@ -93,8 +93,8 @@ public class MsgAlarmController extends BaseController {
     @ApiOperation("更多消息--总数,已读数")
     @Log(title = "报警信息管理", businessType = BusinessType.SELECT)
     public AjaxResult messageMoreNum(@RequestBody MsgAlarmVo msgAlarmVo) {
-        MsgAlarmVo msgAlarmVo1 = (MsgAlarmVo) dataScoreUtil.setDataScore(getUserId(), msgAlarmVo);
-        Map<String, Integer> messageMore = msgWebPushService.messageMoreNum(msgAlarmVo1);
+        // MsgAlarmVo msgAlarmVo1 = (MsgAlarmVo) dataScoreUtil.setDataScore(getUserId(), msgAlarmVo);
+        Map<String, Integer> messageMore = msgWebPushService.messageMoreNum(getUserId());
         return AjaxResult.success(messageMore);
     }
 
@@ -105,8 +105,12 @@ public class MsgAlarmController extends BaseController {
     @ApiOperation("更多消息")
     @Log(title = "报警信息管理", businessType = BusinessType.SELECT)
     public AjaxResult messageMore(@RequestBody MsgAlarmVo msgAlarmVo) {
-        MsgAlarmVo msgAlarmVo1 = (MsgAlarmVo) dataScoreUtil.setDataScore(getUserId(), msgAlarmVo);
-        IPage<MsgAlarm> messageMore = msgWebPushService.messageMore(msgAlarmVo1);
+        // MsgAlarmVo msgAlarmVo1 = (MsgAlarmVo) dataScoreUtil.setDataScore(getUserId(), msgAlarmVo);
+        String userId = getUserId();
+        if (!StringUtils.isEmpty(userId)){
+            msgAlarmVo.setUserId(userId);
+        }
+        IPage<MsgAlarm> messageMore = msgWebPushService.messageMore(msgAlarmVo);
         return AjaxResult.success(messageMore);
     }
 
@@ -117,8 +121,8 @@ public class MsgAlarmController extends BaseController {
     @ApiOperation("app报警推送次数")
     @Log(title = "报警信息管理", businessType = BusinessType.SELECT)
     public AjaxResult webAlarmNum() {
-        MsgAlarmVo msgAlarm = (MsgAlarmVo) dataScoreUtil.setDataScore(getUserId(), new MsgAlarmVo());
-        Map webAlarm = msgWebPushService.webAlarm(msgAlarm);
+        // MsgAlarmVo msgAlarm = (MsgAlarmVo) dataScoreUtil.setDataScore(getUserId(), new MsgAlarmVo());
+        Map webAlarm = msgWebPushService.webAlarm(getUserId());
         return AjaxResult.success(webAlarm);
     }
 

+ 6 - 1
hazard-admin/src/main/java/com/ozs/web/controller/app/GeoHazardMineController.java

@@ -13,6 +13,7 @@ import com.ozs.common.utils.StringUtils;
 import com.ozs.common.utils.uuid.IdUtils;
 import com.ozs.service.entity.BaseCameraManagement;
 import com.ozs.service.entity.BaseRailwayManagement;
+import com.ozs.service.entity.MsgAlarm;
 import com.ozs.service.entity.MsgAppPush;
 import com.ozs.service.entity.vo.MsgAppPushVo;
 import com.ozs.service.service.MsgAppPushService;
@@ -107,7 +108,11 @@ public class GeoHazardMineController extends BaseController {
     @RequestMapping(value = "/list", method = RequestMethod.POST)
     @ApiOperation("app推送报警信息记录分页显示(全部信息)")
     public AjaxResult list(@RequestBody MsgAppPushVo msgAppPushVo) {
-        List<MsgAppPushVo> list = msgAppPushService.alarmPushMsg(msgAppPushVo.getStatus());
+        String userId = getUserId();
+        if (!StringUtils.isEmpty(userId)) {
+            msgAppPushVo.setReceiveBy(userId);
+        }
+        IPage<MsgAppPushVo> list = msgAppPushService.alarmPushMsg(msgAppPushVo);
         return AjaxResult.success(list);
     }
 

+ 1 - 1
hazard-admin/src/main/java/com/ozs/web/controller/websocket/JPushUtil.java

@@ -43,7 +43,7 @@ public class JPushUtil {
         int result = 0;
         try {
             PushPayload pushPayload = JPushUtil.buildPushObjectAllAliasAlertWithTitle(alias, notification_title, msg_title, msg_content, extrasparam);
-            PushPayload pushPayload1 = JPushUtil.buildPushObjectAllAliasAlertWithTitle(alias, notification_title, msg_title, msg_content, extrasparam);
+            // PushPayload pushPayload1 = JPushUtil.buildPushObjectAllAliasAlertWithTitle(alias, notification_title, msg_title, msg_content, extrasparam);
             PushResult pushResult = jPushClient.sendPush(pushPayload);
             if (pushResult.getResponseCode() == 200) {
                 result = 1;

+ 31 - 43
hazard-admin/src/main/java/com/ozs/web/core/util/CameraUtil.java

@@ -18,6 +18,7 @@ import org.springframework.util.ObjectUtils;
 
 import javax.annotation.PostConstruct;
 import java.io.*;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.regex.Matcher;
@@ -381,15 +382,9 @@ public class CameraUtil {
      * @throws IOException
      * @throws InterruptedException
      */
-    public void deleteFlvExceed() throws IOException, InterruptedException {
+    public void deleteFlvExceed() throws IOException, InterruptedException, ParseException {
         //字典中设置的值
         List<SysDictData> sysCameraRecordTime = dictDataMapper.selectDictDataByType("sys_camera_record_time");
-        log.info("sysCameraRecordTime======================================" + sysCameraRecordTime.get(0).getDictValue());
-        //开启流
-        List<String> rspList = new ArrayList<String>();
-        Process proc = Runtime.getRuntime().exec(transcribeFilePath, null, null);
-        BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
-        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(proc.getOutputStream())), true);
 
         SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
         Date date = new Date();
@@ -404,49 +399,42 @@ public class CameraUtil {
             calendar.add(Calendar.DAY_OF_YEAR, -45);
         }
         date = calendar.getTime();
-        //时间格式化为字符串
-        String formatD = sdf.format(date);
-        log.info("formatD======================================" + formatD);
 
         //遍历每个进行视频录制的摄像头
         File file = new File(transcribeFilePath);
-        if (file.exists()) {
-            String s = HttpUtils.sendGet(transcribeFilePath, null);
-            if (!StringUtils.isBlank(s) || "null".equals(s)) {
-                List<Map<String, Object>> maps = JSON.parseArray(s, Map.class);
-                if (ObjectUtils.isEmpty(maps)) {
-                    return;
-                }
-                List<String> commands = new ArrayList<>();
-                for (Map<String, Object> map : maps) {
-                    Object path = map.get("Path");
-                    log.info("path======================================" + path.toString());
-                    //查出符合条件的视频文件,删掉
-                    if (!ObjectUtils.isEmpty(path)) {
-                        String commit = " rm -rf  " + transcribeFilePath + "/" + path.toString() + "/" + formatD + "*";
-                        commands.add(commit);
+        log.info("file.exists()======================================" + file.exists());
+        if (file.exists() && file.isDirectory()) {
+            //获取文件夹中所有的子文件夹和文件
+            File[] files = file.listFiles();
+            if (!ObjectUtils.isEmpty(files) && files.length > 0) {
+                for (File file1 : files) {
+                    //   file1=/opt/streams/record/flv/34020000001320000167
+                    if (file1.exists() && file1.isDirectory()) {
+                        //相机文件
+                        File[] fs = file1.listFiles();
+                        if (!ObjectUtils.isEmpty(fs) && fs.length > 0) {
+                            for (File f : fs) {
+                                //    f=/opt/streams/record/flv/34020000001320000167/20230328_192033_192037-91509173-cd5a-11ed-8a42-fa163e4e1e9f.flv
+                                //fName=20230328_192033_192037-91509173-cd5a-11ed-8a42-fa163e4e1e9f.flv
+                                String fName = f.getName();
+                                String[] split = fName.split("_");
+                                if (split.length > 0) {
+                                    //20230328
+                                    String s = split[0];
+                                    Date parse = sdf.parse(s);
+                                    long fTime = parse.getTime();
+                                    long dateTime = date.getTime();
+                                    //删除过期文件
+                                    if (fTime < dateTime) {
+                                        f.delete();
+                                    }
+                                }
+                            }
+                        }
                     }
                 }
-                // 删除
-                for (String line : commands) {
-                    out.println(line);
-                    log.info("line======================================" + line);
-                }
             }
         }
-        // 这个命令必须执行,否则in流不结束。
-        out.println("exit");
-        String rspLine = "";
-        while ((rspLine = in.readLine()) != null) {
-            System.out.println(rspLine);
-            rspList.add(rspLine);
-        }
-        int i = proc.waitFor();
-        log.info("执行结果:{}", i);
-        //关闭流
-        in.close();
-        out.close();
-        proc.destroy();
     }