Browse Source

报警信息传输云端

gao.qiang 1 month ago
parent
commit
ecf1f3ce81

+ 251 - 0
business-service/src/main/java/com/ozs/service/entity/MsgAlarmCloud.java

@@ -0,0 +1,251 @@
+package com.ozs.service.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ozs.common.annotation.Excel;
+import com.ozs.common.core.domain.BaseEntity;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <p>
+ * 报警信息表
+ * </p>
+ *
+ * @author ozs
+ * @since 2023-02-22
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class MsgAlarmCloud extends BaseEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键ID
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 报警唯一标识
+     */
+    @Excel(name = "报警唯一标识")
+    private String alarmId;
+
+    /**
+     * 相机编码
+     */
+    @Excel(name = "相机编码")
+    private String cameraCode;
+
+    /**
+     * 报警时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "报警时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date alarmTime;
+
+    /**
+     * 报警里程位置
+     */
+    private Integer alarmMile;
+
+    /**
+     * 报警内容
+     */
+    @Excel(name = "报警内容")
+    private String content;
+
+    /**
+     * 报警置信度(百分比)
+     */
+    private Integer alarmConfidence;
+
+    /**
+     * 报警行别(1上行2下行3上下行)
+     */
+    private Integer lineDir;
+
+    /**
+     * 报警病害类型(目前只有1泥石流,后续可扩展使用)
+     */
+    private Integer alarmType;
+
+    /**
+     * 报警病害属性(可以给出泥石流的框定范围)
+     */
+    @Excel(name = "报警病害属性")
+    private String alarmAttr;
+    
+    /**
+     * 报警病害属性文档格式
+     */
+    @TableField(exist = false)
+    private String alarmAttrName;
+
+    /**
+     * 报警图片地址
+     */
+    @Excel(name = "报警图片地址")
+    private String imageUrl;
+
+    /**
+     * 解除人
+     */
+    private String releasedBy;
+
+    /**
+     * 解除时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "解除时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date releasedTime;
+
+    /**
+     * 报警是否解除 1已解除2未解除
+     */
+    private Integer isLock;
+
+    /**
+     * 创建人
+     */
+    private String createBy;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    /**
+     * 修改人
+     */
+    private String updateBy;
+
+    /**
+     * 修改时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+
+    /**
+     * 备注
+     */
+    @Excel(name = "备注")
+    private String remark;
+
+    /**
+     * 解除报警类型1实报2误报
+     */
+    private Integer releasedType;
+
+    /**
+     * 解除原因
+     */
+    @Excel(name = "解除原因")
+    private String releasedReason;
+
+    /**
+     * 解除报警类型名称   1实报2误报
+     */
+    @TableField(exist = false)
+    @Excel(name = "解除报警类型")
+    private String releasedTypeName;
+
+    /**
+     * 线路名称
+     */
+    @TableField(exist = false)
+    @Excel(name = "报警线路")
+    private String railwayName;
+
+    /**
+     * 监控范围开始里程位置
+     */
+    @TableField(exist = false)
+    private String beginMile;
+
+    /**
+     * 监控范围结束里程位置
+     */
+    @TableField(exist = false)
+    private String endMile;
+
+    /**
+     * 报警里程位置字符串形式
+     */
+    @TableField(exist = false)
+    @Excel(name = "报警里程位置")
+    private String alarmMiles;
+
+    /**
+     * 报警次数
+     */
+    @TableField(exist = false)
+    private Integer alarmCount;
+
+    /**
+     * 报警图片地址网络路径
+     */
+    @TableField(exist = false)
+    private List<String> imageUrls;
+
+    /**
+     * 解除人真实姓名
+     */
+    @TableField(exist = false)
+    @Excel(name = "解除人")
+    private String releasedByName;
+
+    /**
+     * 状态:1未读;2已读
+     */
+    @TableField(exist = false)
+    private Integer status;
+
+    /**
+     * 推送消息ID
+     */
+    @TableField(exist = false)
+    private String msgId;
+
+    /**
+     * 报警行别字符串(1上行2下行3上下行)
+     */
+    @TableField(exist = false)
+    @Excel(name = "报警行别")
+    private String lineDirName;
+
+    /**
+     * 报警病害类型(目前只有1泥石流,后续可扩展使用)
+     */
+    @TableField(exist = false)
+    @Excel(name = "报警病害类型")
+    private String alarmTypeName;
+
+    /**
+     * 报警是否解除 1已解除2未解除
+     */
+    @Excel(name = "报警是否解除")
+    @TableField(exist = false)
+    private String  isLockName;
+    
+    private String releasedUrl;
+
+    /**
+     * 1已报警2未报警
+     */
+    @TableField(exist = false)
+    private Integer failureToAlarm;
+}

+ 104 - 0
business-service/src/main/java/com/ozs/service/entity/MsgAlarmFrequencyCloud.java

@@ -0,0 +1,104 @@
+package com.ozs.service.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ozs.common.core.domain.BaseEntity;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 预报警频次表
+ * </p>
+ *
+ * @author ozs
+ * @since 2023-02-23
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class MsgAlarmFrequencyCloud extends BaseEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键ID
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 报警唯一标识
+     */
+    private String alarmId;
+
+    /**
+     * 报警时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date alarmTime;
+
+    /**
+     * 报警内容
+     */
+    private String content;
+
+    /**
+     * 报警置信度(百分比)
+     */
+    private Integer alarmConfidence;
+
+    /**
+     * 报警病害类型(目前只有1泥石流,后续可扩展使用)
+     */
+    private Integer alarmType;
+
+    /**
+     * 报警病害属性(可以给出泥石流的框定范围)
+     */
+    private String alarmAttr;
+
+    /**
+     * 报警图片地址
+     */
+    private String imageUrl;
+
+    /**
+     * 创建人
+     */
+    private String createBy;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 修改人
+     */
+    private String updateBy;
+
+    /**
+     * 修改时间
+     */
+    private Date updateTime;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 报警是否解除 1已解除2未解除
+     */
+    @TableField(exist = false)
+    private Integer isLock;
+}

+ 4 - 4
hazard-sdk/src/main/java/com/ozs/vo/ReqMsgAlarmVo.java

@@ -1,11 +1,8 @@
-package com.ozs.vo;
+package com.ozs.service.entity.vo;
 
-import com.ozs.common.core.domain.entity.SysDept;
 import lombok.Data;
 
 import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
 
 /**
  * @author Administrator
@@ -47,4 +44,7 @@ public class ReqMsgAlarmVo implements Serializable {
 
     /** 报警图片地址 */
     private String[] imageUrls;
+
+    /** 报警行别 */
+    private String lineDirStr;
 }

+ 51 - 0
business-service/src/main/java/com/ozs/service/mapper/MsgAlarmCloudMapper.java

@@ -0,0 +1,51 @@
+package com.ozs.service.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ozs.service.entity.MsgAlarm;
+import com.ozs.service.entity.MsgAlarmCloud;
+import com.ozs.service.entity.vo.*;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 报警信息表 Mapper 接口
+ * </p>
+ *
+ * @author ozs
+ * @since 2023-02-22
+ */
+@Mapper
+public interface MsgAlarmCloudMapper extends BaseMapper<MsgAlarmCloud> {
+    //报警数据详情
+    List<AlarmStatisticVo> list(AlarmStatisticResVo alarmStatisticResVo);
+
+    //报警数据详情导出数据集合
+    List<AlarmStatisticDto> listDto(AlarmStatisticResVo alarmStatisticResVo);
+
+    //报警月统计数据导出数据集合
+    List<AlarmStatisticMonthDto> listDtoMonth(AlarmStatisticResVo alarmStatisticResVo);
+
+    //报警月统计数据导出数据集合(天)
+    List<AlarmStatisticMonthDto> listDtoDay(AlarmStatisticResVo alarmStatisticResVo);
+
+    Integer selectCameraCode(@Param("cameraCode") String cameraCode);
+
+    MsgAlarmCloud selectByCameraCode(@Param("cameraCode") String cameraCode);
+
+    List<MsgAlarmCloud> selectMsgAlarmList(MsgAlarmVo msgAlarmVo);
+
+    MsgAlarmCloud getByAlarmId(@Param("alarmId") String alarmId);
+
+    Integer countMsg(MsgAlarmVo msgAlarmVo);
+
+    Integer countJC(MsgAlarmVo msgAlarmVo);
+
+    Integer countWJC(MsgAlarmVo msgAlarmVo);
+
+    List<MsgAlarmCloud> queryAlarmInfoByAfterTenMinute();
+
+    List<MsgAlarmCloud> selectMsgAlarmListHome(MsgAlarmVo msgAlarmVo);
+}

+ 19 - 0
business-service/src/main/java/com/ozs/service/mapper/MsgAlarmFrequencyCloudMapper.java

@@ -0,0 +1,19 @@
+package com.ozs.service.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ozs.service.entity.MsgAlarmFrequency;
+import com.ozs.service.entity.MsgAlarmFrequencyCloud;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ * 预报警频次表 Mapper 接口
+ * </p>
+ *
+ * @author ozs
+ * @since 2023-02-23
+ */
+@Mapper
+public interface MsgAlarmFrequencyCloudMapper extends BaseMapper<MsgAlarmFrequencyCloud> {
+
+}

+ 67 - 0
business-service/src/main/java/com/ozs/service/service/MsgAlarmCloudService.java

@@ -0,0 +1,67 @@
+package com.ozs.service.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ozs.common.core.domain.AjaxResult;
+import com.ozs.service.entity.BaseCameraManagement;
+import com.ozs.service.entity.MsgAlarm;
+import com.ozs.service.entity.MsgAlarmCloud;
+import com.ozs.service.entity.vo.*;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ * 报警信息表 服务类
+ * </p>
+ *
+ * @author ozs
+ * @since 2023-02-22
+ */
+public interface MsgAlarmCloudService extends IService<MsgAlarmCloud> {
+    IPage<AlarmStatisticVo> list(AlarmStatisticResVo alarmStatisticResVo);
+
+    IPage listToPage(List list, int pageNum, int pageSize);
+
+    //web数据统计 报警月统计数据
+    List<AlarmStatisticMonthDto> getCount(AlarmStatisticResVo alarmStatisticResVo);
+
+    //web数据统计 报警月统计数据(天)
+    List<AlarmStatisticMonthDto> getDayCount(AlarmStatisticResVo alarmStatisticResVo);
+
+    //报警数据详情导出数据集合
+    List<AlarmStatisticDto> exportExcel(AlarmStatisticResVo alarmStatisticResVo);
+
+    /**
+     * 通过相机编码查询未解除预警信息
+     *
+     * @param cameraCode
+     * @return
+     */
+    MsgAlarmCloud selectByCameraCode(String cameraCode);
+
+    IPage<MsgAlarmCloud> queryPage(MsgAlarmVo msgAlarmVo);
+
+    MsgAlarmCloud getByAlarmId(String alarmId);
+
+    Map<String, Integer> statisticsNum(MsgAlarmVo msgAlarmVo);
+
+    Integer appAlarmNum(MsgAlarmVo msgAlarmVo);
+
+    List<MsgAlarmCloud> msgAlarmList(MsgAlarmVo msgAlarmVo);
+
+    List<MsgAlarmCloud> queryAlarmInfoByAfterTenMinute();
+
+    IPage<MsgAlarmCloud> queryPageHome(MsgAlarmVo msgAlarmVo);
+
+    void getNormalBaseCameraManagementsCache(String setType);
+
+    void initializationCameraCache();
+
+    BaseCameraManagement getBaseCameraManagementByCamereCode(String camereCode);
+
+    AjaxResult alarmStatistics(MsgAlarmVo msgAlarmVo1);
+
+    AjaxResult alarmCountSort(MsgAlarmVo msgAlarmVo);
+}

+ 17 - 0
business-service/src/main/java/com/ozs/service/service/MsgAlarmFrequencyCloudService.java

@@ -0,0 +1,17 @@
+package com.ozs.service.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ozs.service.entity.MsgAlarmFrequency;
+import com.ozs.service.entity.MsgAlarmFrequencyCloud;
+
+/**
+ * <p>
+ * 预报警频次表 服务类
+ * </p>
+ *
+ * @author ozs
+ * @since 2023-02-23
+ */
+public interface MsgAlarmFrequencyCloudService extends IService<MsgAlarmFrequencyCloud> {
+
+}

+ 302 - 0
business-service/src/main/java/com/ozs/service/service/impl/MsgAlarmCloudServiceImpl.java

@@ -0,0 +1,302 @@
+package com.ozs.service.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.ozs.common.constant.Constants;
+import com.ozs.common.core.domain.AjaxResult;
+import com.ozs.service.entity.BaseCameraManagement;
+import com.ozs.service.entity.BaseRailwayManagement;
+import com.ozs.service.entity.MsgAlarm;
+import com.ozs.service.entity.MsgAlarmCloud;
+import com.ozs.service.entity.vo.*;
+import com.ozs.service.mapper.BaseCameraManagementMapper;
+import com.ozs.service.mapper.BaseRailwayManagementMapper;
+import com.ozs.service.mapper.MsgAlarmCloudMapper;
+import com.ozs.service.mapper.MsgAlarmMapper;
+import com.ozs.service.service.MsgAlarmCloudService;
+import com.ozs.service.service.MsgAlarmService;
+import com.ozs.service.service.RedisService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.ObjectUtils;
+import org.springframework.util.StringUtils;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * <p>
+ * 报警信息表 服务实现类
+ * </p>
+ *
+ * @author ozs
+ * @since 2023-02-22
+ */
+@Service
+@Slf4j
+public class MsgAlarmCloudServiceImpl extends ServiceImpl<MsgAlarmCloudMapper, MsgAlarmCloud> implements MsgAlarmCloudService {
+    @Autowired
+    private MsgAlarmCloudMapper msgAlarmCloudMapper;
+    @Autowired
+    private BaseCameraManagementMapper baseCameraManagementMapper;
+    @Autowired
+    private RedisService redisService;
+    @Autowired
+    private BaseRailwayManagementMapper baseRailwayManagementMapper;
+
+
+    public IPage listToPage(List list, int pageNum, int pageSize) {
+        List pageList = new ArrayList<>();
+        int curIdx = pageNum > 1 ? (pageNum - 1) * pageSize : 0;
+        for (int i = 0; i < pageSize && curIdx + i < list.size(); i++) {
+            pageList.add(list.get(curIdx + i));
+        }
+        IPage page = new Page<>(pageNum, pageSize);
+        page.setRecords(pageList);
+        page.setTotal(list.size());
+        return page;
+    }
+
+    //web数据统计 报警数据详情
+    @Override
+    public IPage<AlarmStatisticVo> list(AlarmStatisticResVo alarmStatisticResVo) {
+        int pageNum = Integer.parseInt(alarmStatisticResVo.getPageNum().toString());
+        int pageSize = Integer.parseInt(alarmStatisticResVo.getPageSize().toString());
+        com.github.pagehelper.Page<AlarmStatisticVo> page = PageHelper.startPage(pageNum, pageSize)
+                .doSelectPage(() -> msgAlarmCloudMapper.list(alarmStatisticResVo));
+        Page<AlarmStatisticVo> pageR =
+                new Page<>(pageNum, pageSize);
+        pageR.setRecords(page.getResult());
+        pageR.setTotal(page.getTotal());
+        return pageR;
+    }
+
+    @Override
+    public List<AlarmStatisticMonthDto> getCount(AlarmStatisticResVo alarmStatisticResVo) {
+        List<AlarmStatisticMonthDto> list = msgAlarmCloudMapper.listDtoMonth(alarmStatisticResVo);
+        return list;
+    }
+
+    @Override
+    public List<AlarmStatisticMonthDto> getDayCount(AlarmStatisticResVo alarmStatisticResVo) {
+        List<AlarmStatisticMonthDto> list = msgAlarmCloudMapper.listDtoDay(alarmStatisticResVo);
+        return list;
+    }
+
+    @Override
+    public List<AlarmStatisticDto> exportExcel(AlarmStatisticResVo alarmStatisticResVo) {
+        List<AlarmStatisticDto> listDto = msgAlarmCloudMapper.listDto(alarmStatisticResVo);
+        return listDto;
+    }
+
+    @Override
+    public MsgAlarmCloud selectByCameraCode(String cameraCode) {
+        return msgAlarmCloudMapper.selectByCameraCode(cameraCode);
+    }
+
+    @Override
+    public IPage<MsgAlarmCloud> queryPage(MsgAlarmVo vo) {
+        int pageNum = Integer.parseInt(vo.getPageNum().toString());
+        int pageSize = Integer.parseInt(vo.getPageSize().toString());
+        com.github.pagehelper.Page<MsgAlarmCloud> page = PageHelper.startPage(pageNum, pageSize)
+                .doSelectPage(() -> msgAlarmCloudMapper.selectMsgAlarmList(vo));
+        Page<MsgAlarmCloud> pageR =
+                new Page<>(pageNum, pageSize);
+        pageR.setRecords(page.getResult());
+        pageR.setTotal(page.getTotal());
+        return pageR;
+    }
+
+    @Override
+    public MsgAlarmCloud getByAlarmId(String alarmId) {
+        return msgAlarmCloudMapper.getByAlarmId(alarmId);
+    }
+
+    @Override
+    public Map<String, Integer> statisticsNum(MsgAlarmVo msgAlarmVo) {
+        Map<String, Integer> map = new HashMap<>();
+        // 相机数量
+        Integer countCamera = baseCameraManagementMapper.countCamera(msgAlarmVo);
+        // 累计报警次数
+        Integer countMsg = msgAlarmCloudMapper.countMsg(msgAlarmVo);
+        // 解除报警
+//        LambdaQueryWrapper<MsgAlarm> lwJC = new LambdaQueryWrapper<MsgAlarm>();
+//        lwJC.eq(MsgAlarm::getIsLock, "1");
+        Integer countJC = msgAlarmCloudMapper.countJC(msgAlarmVo);
+        // 未解除报警
+//        LambdaQueryWrapper<MsgAlarm> lwWJC = new LambdaQueryWrapper<MsgAlarm>();
+//        lwWJC.eq(MsgAlarm::getIsLock, "2");
+        Integer countWJC = msgAlarmCloudMapper.countWJC(msgAlarmVo);
+        map.put("countCamera", countCamera);
+        map.put("countMsg", countMsg);
+        map.put("countJC", countJC);
+        map.put("countWJC", countWJC);
+        return map;
+    }
+
+    @Override
+    public Integer appAlarmNum(MsgAlarmVo msgAlarmVo) {
+        return msgAlarmCloudMapper.countWJC(msgAlarmVo);
+    }
+
+    @Override
+    public List<MsgAlarmCloud> msgAlarmList(MsgAlarmVo msgAlarmVo) {
+        return msgAlarmCloudMapper.selectMsgAlarmList(msgAlarmVo);
+    }
+
+    @Override
+    public List<MsgAlarmCloud> queryAlarmInfoByAfterTenMinute() {
+        return msgAlarmCloudMapper.queryAlarmInfoByAfterTenMinute();
+    }
+
+    @Override
+    public IPage<MsgAlarmCloud> queryPageHome(MsgAlarmVo msgAlarmVo) {
+        int pageNum = Integer.parseInt(msgAlarmVo.getPageNum().toString());
+        int pageSize = Integer.parseInt(msgAlarmVo.getPageSize().toString());
+        com.github.pagehelper.Page<MsgAlarmCloud> page = PageHelper.startPage(pageNum, pageSize)
+                .doSelectPage(() -> msgAlarmCloudMapper.selectMsgAlarmListHome(msgAlarmVo));
+        Page<MsgAlarmCloud> pageR =
+                new Page<>(pageNum, pageSize);
+        pageR.setRecords(page.getResult());
+        pageR.setTotal(page.getTotal());
+        return pageR;
+    }
+
+    @Override
+    public void getNormalBaseCameraManagementsCache(String setType) {
+        log.info("-----------setType------" + setType);
+        Set<BaseCameraVO> alarmSet = redisService.getSetMembers(Constants.ALARM_SET);
+        log.info("-----------alarmSet------" + alarmSet);
+        if (!ObjectUtils.isEmpty(alarmSet)) {
+            Set<String> cameraCodeSet = new HashSet<>();
+            alarmSet.forEach(camera -> {
+                if (!ObjectUtils.isEmpty(camera)) {
+                    if (!StringUtils.isEmpty(camera.getCameraCode())) {
+                        cameraCodeSet.add(camera.getCameraCode());
+                    }
+                }
+            });
+            log.info("-----------cameraCodeSet------" + cameraCodeSet);
+            QueryWrapper<BaseCameraManagement> queryWrapper = new QueryWrapper<>();
+            log.info("-----------Constants.ALARM_SET------" + Constants.ALARM_SET);
+            if (Constants.ALARM_SET.equals(setType)) {
+                // 使用QueryWrapper和notin方法根据cameraCode列表查询BaseCameraManagement数据
+                queryWrapper.notIn("camera_code", cameraCodeSet);
+                Set<BaseCameraManagement> set = baseCameraManagementMapper.selectList(queryWrapper).stream().collect(Collectors.toSet());
+                log.info("-----------set------" + set);
+                set.forEach(item -> {
+                    BaseCameraVO baseCameraVO = new BaseCameraVO();
+                    baseCameraVO.setCameraCode(item.getCameraCode());
+                    baseCameraVO.setChannel(item.getChannel());
+                    redisService.addToSet(Constants.NORMAL_SET, baseCameraVO);
+                });
+            }
+        }
+    }
+
+    @Override
+    public void initializationCameraCache() {
+        List<MsgAlarmCloud> lockedMsgAlarms = msgAlarmCloudMapper.selectList(new QueryWrapper<MsgAlarmCloud>().eq("is_lock", 2));
+        if (lockedMsgAlarms.isEmpty()) {
+            Set<BaseCameraManagement> normalSet = baseCameraManagementMapper.selectList(null).stream().collect(Collectors.toSet());
+            normalSet.forEach(item -> {
+                BaseCameraVO baseCameraVO = new BaseCameraVO();
+                baseCameraVO.setCameraCode(item.getCameraCode());
+                baseCameraVO.setChannel(item.getChannel());
+                redisService.addToSet(Constants.NORMAL_SET, baseCameraVO);
+            });
+            redisService.addToSet(Constants.ALARM_SET, null);
+        }
+        // 提取cameraCode列表
+        Set<String> cameraCodeSet = lockedMsgAlarms.stream().map(MsgAlarmCloud::getCameraCode).collect(Collectors.toSet());
+        QueryWrapper<BaseCameraManagement> queryWrapperAlarm = new QueryWrapper<>();
+        queryWrapperAlarm.in("camera_code", cameraCodeSet);
+        Set<BaseCameraManagement> alarmSet = baseCameraManagementMapper.selectList(queryWrapperAlarm).stream().collect(Collectors.toSet());
+        alarmSet.forEach(item -> {
+            BaseCameraVO baseCameraVO = new BaseCameraVO();
+            baseCameraVO.setCameraCode(item.getCameraCode());
+            baseCameraVO.setChannel(item.getChannel());
+            redisService.addToSet(Constants.ALARM_SET, baseCameraVO);
+        });
+        QueryWrapper<BaseCameraManagement> queryWrapperNormal = new QueryWrapper<>();
+        queryWrapperNormal.notIn("camera_code", cameraCodeSet);
+        Set<BaseCameraManagement> normalSet = baseCameraManagementMapper.selectList(queryWrapperNormal).stream().collect(Collectors.toSet());
+        normalSet.forEach(item -> {
+            BaseCameraVO baseCameraVO = new BaseCameraVO();
+            baseCameraVO.setCameraCode(item.getCameraCode());
+            baseCameraVO.setChannel(item.getChannel());
+            redisService.addToSet(Constants.NORMAL_SET, baseCameraVO);
+        });
+    }
+
+    @Override
+    public BaseCameraManagement getBaseCameraManagementByCamereCode(String camereCode) {
+        QueryWrapper<BaseCameraManagement> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("camera_code", camereCode);
+        BaseCameraManagement baseCameraManagement = baseCameraManagementMapper.selectOne(queryWrapper);
+        return baseCameraManagement;
+    }
+
+    @Override
+    public AjaxResult alarmStatistics(MsgAlarmVo msgAlarmVo1) {
+        int count = 0;
+        int unresolvedCount = 0;
+        //找出所有报警数据
+        List<MsgAlarmCloud> list = msgAlarmCloudMapper.selectMsgAlarmList(msgAlarmVo1);
+        //未解除的报警
+        msgAlarmVo1.setIsLock(2);
+        List<MsgAlarmCloud> alarmList = msgAlarmCloudMapper.selectMsgAlarmList(msgAlarmVo1);
+        HashMap<String, Integer> map = new HashMap<>();
+        if (!ObjectUtils.isEmpty(list)) {
+            //获取所有报警的相机编码
+            //找出所有报警数据 1=高铁的数量
+            count = (int) list.stream()
+                    .map(base -> baseCameraManagementMapper.selectOne(new LambdaQueryWrapper<BaseCameraManagement>()
+                            .eq(BaseCameraManagement::getCameraCode, base.getCameraCode())))
+                    .filter(Objects::nonNull)  // 确保 management 不是 null
+                    .map(management -> baseRailwayManagementMapper.selectOne(new LambdaQueryWrapper<BaseRailwayManagement>()
+                            .eq(BaseRailwayManagement::getRailwayCode, management.getRailwayCode()))) // 确保管理信息不是空的
+                    .filter(Objects::nonNull) // 确保 baseRailwayManagement 不是 null
+                    .filter(baseRailwayManagement -> baseRailwayManagement.getRailwayType() == 1)
+                    .count();
+            //普铁的数量
+            int pu = list.size() - count;
+            map.put("highAlarmCount", count);
+            map.put("puAlarmCount", pu);
+        } else {
+            map.put("highAlarmCount", 0);
+            map.put("puAlarmCount", 0);
+        }
+        if (!ObjectUtils.isEmpty(alarmList)) {
+            //获取所有报警的相机编码
+            //找出所有未解除报警数据 1=高铁的数量
+            unresolvedCount = (int) alarmList.stream()
+                    .map(base -> baseCameraManagementMapper.selectOne(new LambdaQueryWrapper<BaseCameraManagement>()
+                            .eq(BaseCameraManagement::getCameraCode, base.getCameraCode())))
+                    .filter(Objects::nonNull)
+                    .map(management -> baseRailwayManagementMapper.selectOne(new LambdaQueryWrapper<BaseRailwayManagement>()
+                            .eq(BaseRailwayManagement::getRailwayCode, management.getRailwayCode()))) // 确保管理信息不是空的
+                    .filter(Objects::nonNull) // 确保 baseRailwayManagement 不是 null
+                    .filter(baseRailwayManagement -> baseRailwayManagement.getRailwayType() == 1)
+                    .count();
+            //普铁的数量
+            int puUnresolvedCount = alarmList.size() - unresolvedCount;
+            map.put("highUnresolvedCount", unresolvedCount);
+            map.put("puUnresolvedCount", puUnresolvedCount);
+        } else {
+            map.put("highUnresolvedCount", 0);
+            map.put("puUnresolvedCount", 0);
+        }
+        return AjaxResult.success(map);
+    }
+
+    @Override
+    public AjaxResult alarmCountSort(MsgAlarmVo msgAlarmVo) {
+        return AjaxResult.success(baseCameraManagementMapper.alarmCountSort(msgAlarmVo));
+    }
+}

+ 23 - 0
business-service/src/main/java/com/ozs/service/service/impl/MsgAlarmFrequencyCloudServiceImpl.java

@@ -0,0 +1,23 @@
+package com.ozs.service.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ozs.service.entity.MsgAlarmFrequency;
+import com.ozs.service.entity.MsgAlarmFrequencyCloud;
+import com.ozs.service.mapper.MsgAlarmFrequencyCloudMapper;
+import com.ozs.service.mapper.MsgAlarmFrequencyMapper;
+import com.ozs.service.service.MsgAlarmFrequencyCloudService;
+import com.ozs.service.service.MsgAlarmFrequencyService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 预报警频次表 服务实现类
+ * </p>
+ *
+ * @author ozs
+ * @since 2023-02-23
+ */
+@Service
+public class MsgAlarmFrequencyCloudServiceImpl extends ServiceImpl<MsgAlarmFrequencyCloudMapper, MsgAlarmFrequencyCloud> implements MsgAlarmFrequencyCloudService {
+
+}

+ 39 - 0
business-service/src/main/java/com/ozs/service/utils/PublishClient.java

@@ -16,6 +16,8 @@ import org.eclipse.paho.client.mqttv3.MqttTopic;
 import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
+import org.springframework.util.ObjectUtils;
+import org.springframework.util.StringUtils;
 
 import javax.annotation.PostConstruct;
 import java.security.SecureRandom;
@@ -162,6 +164,43 @@ public class PublishClient {
         }
     }
 
+    public static void alarmPush(ReqMsgAlarmVo reqMsgAlarmVo) {
+        /**
+         * 发布客户端
+         */
+        log.info("alarmPush---start");
+
+            try {
+                if (StringUtils.isEmpty(reqMsgAlarmVo.getAlarmMile())){
+                    reqMsgAlarmVo.setAlarmMile("");
+                }
+                if (ObjectUtils.isEmpty(reqMsgAlarmVo.getLineDir())){
+                    reqMsgAlarmVo.setLineDirStr("");
+                }
+                String s = JSON.toJSONString(reqMsgAlarmVo);
+                MqttMessage message = new MqttMessage();
+                /**
+                 * 保证消息能到达一次
+                 */
+                message.setQos(1);
+                /**
+                 * 消息保留
+                 */
+//                server.message.setRetained(false);
+                /**
+                 * 消息内容
+                 */
+                message.setPayload(s.getBytes());
+                /**
+                 * 发布
+                 */
+                publish(getMqttTopic("alarmPush"), message);
+                log.info("alarmPush---end");
+            } catch (MqttException e) {
+                log.error("alarmPush-------" + e.getMessage());
+            }
+    }
+
     public static void confidenceCoefficient(BaseCameraManagement baseCameraManagement, String value) {
         /**
          * 发布客户端

+ 557 - 0
business-service/src/main/resources/mapper/service/MsgAlarmCloudMapper.xml

@@ -0,0 +1,557 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ozs.service.mapper.MsgAlarmCloudMapper">
+    <resultMap id="AlarmStatisticVoResult" type="com.ozs.service.entity.vo.AlarmStatisticVo">
+        <id column="id" property="id"/>
+        <result column="alarm_id" property="alarmId"/>
+        <result column="railway_name" property="railwayName"/>
+        <result column="camera_code" property="cameraCode"/>
+        <result column="alarm_time" property="alarmTime"/>
+        <result column="remark" property="remark"/>
+        <result column="released_reason" property="releasedReason"/>
+        <result column="released_type" property="releasedType"/>
+        <result column="alarm_mile" property="alarmMile"/>
+        <result column="content" property="content"/>
+        <result column="alarm_confidence" property="alarmConfidence"/>
+        <result column="line_dir" property="lineDir"/>
+        <result column="alarm_type" property="alarmType"/>
+        <result column="alarm_attr" property="alarmAttr"/>
+        <result column="image_url" property="imageUrl"/>
+        <result column="released_by" property="releasedBy"/>
+        <result column="released_time" property="releasedTime"/>
+        <result column="is_lock" property="isLock"/>
+    </resultMap>
+
+    <select id="list" parameterType="com.ozs.service.entity.vo.AlarmStatisticResVo" resultMap="AlarmStatisticVoResult">
+        SELECT
+        a.alarm_id ,
+        a.camera_code ,
+        a.alarm_time ,
+        a.alarm_mile,
+        a.content ,
+        a.alarm_confidence ,
+        a.line_dir,
+        a.alarm_type,
+        a.alarm_attr,
+        a.image_url,
+        a.released_by ,
+        a.released_time,
+        a.released_reason,
+        a.released_type,
+        c.railway_name,
+        a.remark,
+        a.is_lock
+        FROM
+        msg_alarm_cloud AS a inner join
+        base_camera_management AS b on a.camera_code=b.camera_code left join
+        base_railway_management c on b.railway_code=c.railway_code
+
+        <where>
+            <if test="railwayCode != null and railwayCode != ''">
+                and UPPER(b.railway_code) like UPPER(CONCAT('%',#{railwayCode},'%'))
+            </if>
+            <if test="currentYear != null and currentYear != 0">
+                and YEAR(a.alarm_time) like UPPER(CONCAT('%',#{currentYear},'%'))
+            </if>
+            <if test="currentYear == null or currentYear == ''">
+                and YEAR(a.alarm_time) = YEAR(SYSDATE())
+            </if>
+            <if test="currentMonth != null and currentMonth != 0">
+                and MONTH(a.alarm_time) =#{currentMonth}
+            </if>
+            <if test="alarmType != null and alarmType != ''">
+                and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
+            </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>
+        </where>
+        group by a.alarm_id order by a.alarm_time desc
+    </select>
+
+    <resultMap id="AlarmStatisticDtoResult" type="com.ozs.service.entity.vo.AlarmStatisticDto">
+        <id column="id" property="id"/>
+        <result column="alarmId" property="alarmId"/>
+        <result column="cameraCode" property="cameraCode"/>
+        <result column="alarmTime" property="alarmTime"/>
+        <result column="alarmMile" property="alarmMile"/>
+        <result column="content" property="content"/>
+        <result column="alarmConfidence" property="alarmConfidence"/>
+        <result column="lineDir" property="lineDir"/>
+        <result column="alarmType" property="alarmType"/>
+        <result column="alarmAttr" property="alarmAttr"/>
+        <result column="imageUrl" property="imageUrl"/>
+        <result column="releasedBy" property="releasedBy"/>
+        <result column="releasedTime" property="releasedTime"/>
+        <result column="releasedReason" property="releasedReason"/>
+        <result column="releasedType" property="releasedType"/>
+        <result column="railwayName" property="railwayName"/>
+        <result column="remark" property="remark"/>
+        <result column="isLock" property="isLock"/>
+    </resultMap>
+    <select id="listDto" parameterType="com.ozs.service.entity.vo.AlarmStatisticResVo" resultMap="AlarmStatisticDtoResult">
+        SELECT
+        a.alarm_id AS alarmId,
+        a.camera_code AS cameraCode,
+        a.alarm_time AS alarmTime,
+        a.alarm_mile AS alarmMile,
+        a.content AS content,
+        a.alarm_confidence AS alarmConfidence,
+        a.line_dir AS lineDir,
+        a.alarm_type AS alarmType,
+        a.alarm_attr AS alarmAttr,
+        a.image_url AS imageUrl,
+        a.released_by AS releasedBy,
+        a.released_time AS releasedTime,
+        a.released_reason AS releasedReason,
+        a.released_type AS releasedType,
+        c.railway_name AS railwayName,
+        a.remark AS remark,
+        a.is_lock AS isLock
+        FROM
+        msg_alarm_cloud AS a inner join
+        base_camera_management AS b on a.camera_code=b.camera_code left join
+        base_railway_management c on b.railway_code=c.railway_code
+
+        <where>
+            <if test="railwayCode != null and railwayCode != ''">
+                and UPPER(b.railway_code) like UPPER(CONCAT('%',#{railwayCode},'%'))
+            </if>
+            <if test="currentYear != null and currentYear != 0">
+                and YEAR(a.alarm_time) like UPPER(CONCAT('%',#{currentYear},'%'))
+            </if>
+            <if test="currentYear == null or currentYear == ''">
+                and YEAR(a.alarm_time) = YEAR(SYSDATE())
+            </if>
+            <if test="currentMonth != null and currentMonth != 0">
+                and MONTH(a.alarm_time) =#{currentMonth}
+            </if>
+            <if test="alarmType != null and alarmType != ''">
+                and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
+            </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>
+        </where>
+        group by a.alarm_id order by a.alarm_time desc
+    </select>
+    <resultMap id="AlarmStatisticMonthDtoResult" type="com.ozs.service.entity.vo.AlarmStatisticMonthDto">
+        <id column="id" property="id"/>
+        <result column="monthsta" property="monthsta"/>
+        <result column="monthstaString" property="monthstaString"/>
+        <result column="frequency" property="frequency"/>
+        <result column="alarm_type" property="alarmType"/>
+    </resultMap>
+    <select id="listDtoMonth" parameterType="com.ozs.service.entity.vo.AlarmStatisticResVo" resultMap="AlarmStatisticMonthDtoResult">
+        SELECT p.monthsta as monthsta,sum(p.fre) as frequency,p.monthstaString as monthstaString
+        from
+        (SELECT
+        DATE_FORMAT(a.alarm_time,'%Y年%m月') as monthstaString,
+        MONTH(a.alarm_time) as monthsta,
+        count(DISTINCT a.alarm_id) as fre
+        FROM
+        msg_alarm_cloud AS a inner join
+        base_camera_management AS b on a.camera_code=b.camera_code left join
+        base_railway_management c on b.railway_code=c.railway_code
+
+        <where>
+            <if test="railwayCode != null and railwayCode != ''">
+                and UPPER(b.railway_code) like UPPER(CONCAT('%',#{railwayCode},'%'))
+            </if>
+            <if test="currentYear != null and currentYear != 0">
+                and YEAR(a.alarm_time) like UPPER(CONCAT('%',#{currentYear},'%'))
+            </if>
+            <if test="currentYear == null or currentYear == ''">
+                and YEAR(a.alarm_time) = YEAR(SYSDATE())
+            </if>
+            <if test="currentMonth != null and currentMonth != 0">
+                and MONTH(a.alarm_time) =#{currentMonth}
+            </if>
+            <if test="alarmType != null and alarmType != ''">
+                and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
+            </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>
+        </where>
+        group by a.alarm_id) AS p group by p.monthsta order by p.monthsta
+    </select>
+
+    <select id="listDtoDay" parameterType="com.ozs.service.entity.vo.AlarmStatisticResVo" resultMap="AlarmStatisticMonthDtoResult">
+        SELECT p.daysta as monthsta,sum(p.fre) as frequency,p.daystaString as monthstaString
+        from
+        (SELECT
+        DATE_FORMAT(a.alarm_time,'%Y年%m月%d日') as daystaString,
+        DAY(a.alarm_time) as daysta,
+        count(DISTINCT a.alarm_id) as fre
+        FROM
+        msg_alarm_cloud AS a inner join
+        base_camera_management AS b on a.camera_code=b.camera_code left join
+        base_railway_management c on b.railway_code=c.railway_code
+
+        <where>
+            <if test="railwayCode != null and railwayCode != ''">
+                and UPPER(b.railway_code) like UPPER(CONCAT('%',#{railwayCode},'%'))
+            </if>
+            <if test="currentYear != null and currentYear != 0">
+                and YEAR(a.alarm_time) like UPPER(CONCAT('%',#{currentYear},'%'))
+            </if>
+            <if test="currentYear == null or currentYear == ''">
+                and YEAR(a.alarm_time) = YEAR(SYSDATE())
+            </if>
+            <if test="currentMonth != null and currentMonth != 0">
+                and MONTH(a.alarm_time) =#{currentMonth}
+            </if>
+            <if test="alarmType != null and alarmType != ''">
+                and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
+            </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>
+        </where>
+        group by a.alarm_id) AS p group by p.daysta order by p.daysta
+    </select>
+    <select id="selectCameraCode" parameterType="java.lang.String" resultType="java.lang.Integer">
+        select is_lock
+        from msg_alarm_cloud
+        where camera_code = #{cameraCode}
+        ORDER BY alarm_time DESC LIMIT 1
+    </select>
+
+    <select id="selectByCameraCode" parameterType="java.lang.String" resultType="com.ozs.service.entity.MsgAlarmCloud">
+        select *
+        from msg_alarm_cloud
+        where camera_code = #{cameraCode}
+        order by alarm_time desc limit 1
+    </select>
+
+    <select id="selectMsgAlarmListHome" resultType="com.ozs.service.entity.MsgAlarmCloud"
+            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,
+        a.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,
+        a.released_type AS releasedType,
+        a.released_reason AS releasedReason,
+        a.remark AS remark
+        FROM msg_alarm_cloud 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.is_lock desc, a.alarm_time desc
+    </select>
+
+    <select id="selectMsgAlarmList" resultType="com.ozs.service.entity.MsgAlarmCloud"
+            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,
+        a.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,
+        a.released_type AS releasedType,
+        a.released_reason AS releasedReason,
+        a.remark AS remark
+        FROM
+        msg_alarm_cloud 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
+    </select>
+
+    <select id="getByAlarmId" resultType="com.ozs.service.entity.MsgAlarmCloud" parameterType="java.lang.String">
+        select *
+        from msg_alarm_cloud
+        where alarm_id = #{alarmId}
+    </select>
+
+    <select id="countMsg" parameterType="com.ozs.service.entity.vo.MsgAlarmVo" resultType="java.lang.Integer">
+        select count(1) from msg_alarm_cloud AS a join base_camera_management AS b on a.camera_code = b.camera_code
+        <where>
+            <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>
+        </where>
+    </select>
+
+    <select id="countJC" parameterType="com.ozs.service.entity.vo.MsgAlarmVo" resultType="java.lang.Integer">
+        select count(1) from msg_alarm_cloud AS a join base_camera_management AS b on a.camera_code=b.camera_code
+        <where>
+            is_lock = 1
+            <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>
+        </where>
+    </select>
+
+    <select id="countWJC" parameterType="com.ozs.service.entity.vo.MsgAlarmVo" resultType="java.lang.Integer">
+        select count(1) from msg_alarm_cloud AS a join base_camera_management AS b on a.camera_code=b.camera_code
+        <where>
+            is_lock = 2
+            <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>
+        </where>
+    </select>
+
+
+    <select id="queryAlarmInfoByAfterTenMinute" resultType="com.ozs.service.entity.MsgAlarmCloud">
+        SELECT a.id               as id,
+               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,
+               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,
+               a.released_type    AS releasedType,
+               a.released_url     AS releasedUrl,
+               a.released_reason  AS releasedReason,
+               a.remark           AS remark
+        from msg_alarm_cloud AS a
+        where a.is_lock = 2
+          and a.released_url is null
+          and a.alarm_time &lt;= DATE_SUB(NOW(), INTERVAL 10 MINUTE)
+    </select>
+</mapper>

+ 5 - 0
business-service/src/main/resources/mapper/service/MsgAlarmFrequencyCloudMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ozs.service.mapper.MsgAlarmFrequencyCloudMapper">
+
+</mapper>

+ 170 - 92
hazard-sdk/src/main/java/com/ozs/controller/upload/GeoHazardMonitorTokenController.java

@@ -13,30 +13,24 @@ import com.ozs.common.utils.HttpClientUtil;
 import com.ozs.common.utils.StringUtils;
 import com.ozs.common.utils.http.HttpUtils;
 import com.ozs.common.utils.stateSecrets.SM4Utils;
-import com.ozs.service.entity.BaseCameraManagement;
-import com.ozs.service.entity.BaseDeviceDynamicManagement;
-import com.ozs.service.entity.BaseUser;
-import com.ozs.service.entity.MsgAlarm;
-import com.ozs.service.entity.MsgAlarmFrequency;
-import com.ozs.service.entity.SvcAddress;
+import com.ozs.service.entity.*;
 import com.ozs.service.entity.vo.BaseCameraVO;
 import com.ozs.service.service.*;
+import com.ozs.service.utils.PublishClient;
 import com.ozs.vo.ReqDeviceVo;
-import com.ozs.vo.ReqMsgAlarmVo;
+import com.ozs.service.entity.vo.ReqMsgAlarmVo;
 import com.ozs.vo.RespGeoHazardMonitorVo;
 import com.ozs.vo.RespMsgAlarmVo;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.data.redis.core.SetOperations;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.ObjectUtils;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
-import java.nio.charset.StandardCharsets;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.Instant;
@@ -47,7 +41,6 @@ import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
 
 /**
  * 1. 获取身份认证控制层
@@ -67,6 +60,10 @@ public class GeoHazardMonitorTokenController {
     @Autowired
     MsgAlarmFrequencyService msgAlarmFrequencyService;
     @Autowired
+    MsgAlarmCloudService msgAlarmCloudService;
+    @Autowired
+    MsgAlarmFrequencyCloudService msgAlarmFrequencyCloudService;
+    @Autowired
     SvcAddressService svcAddressService;
     @Autowired
     BaseCameraManagementService baseCameraManagementService;
@@ -154,6 +151,9 @@ public class GeoHazardMonitorTokenController {
         log.info("parameter:{}", parameter);
         JSONObject jsonObject = new JSONObject();
         if (StringUtils.isNotEmpty(token)) {
+            String[] split = token.split("-");
+            String key = split[split.length - 2];
+            log.info(key);
             String s = SM4Utils.decryptData_ECB(parameter, "4370780c9a8c43e5");
             ReqMsgAlarmVo reqMsgAlarmVo = JSON.parseObject(s, ReqMsgAlarmVo.class);
             if (!reqMsgAlarmVo.getAlarmAttr().matches(PATTERN)) {
@@ -180,97 +180,175 @@ public class GeoHazardMonitorTokenController {
                 jsonObject.put("data", "你填写的相机编码不存在!!!");
                 return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), "4370780c9a8c43e5");
             }
+            PublishClient.alarmPush(reqMsgAlarmVo);
             if (ObjectUtils.isEmpty(reqMsgAlarmVo.getLineDir())) {
                 reqMsgAlarmVo.setLineDir(baseCameraManagement.getLineDir());
             }
-            LambdaQueryWrapper<MsgAlarm> lw = new LambdaQueryWrapper<MsgAlarm>();
-            if (!ObjectUtils.isEmpty(reqMsgAlarmVo.getAlarmId())) {
-                lw.eq(MsgAlarm::getAlarmId, reqMsgAlarmVo.getAlarmId());
-            }
-            MsgAlarm alarm = msgAlarmService.getOne(lw);
-            log.info("alarm:{}", alarm);
-            BaseUser admin = baseUserService.getUserName("admin");
-            MsgAlarmFrequency msgAlarmVice = new MsgAlarmFrequency();
-            if (ObjectUtils.isEmpty(alarm)) {
-                MsgAlarm msgAlarm = new MsgAlarm();
-                BeanUtils.copyProperties(reqMsgAlarmVo, msgAlarm);
-                BeanUtils.copyProperties(reqMsgAlarmVo, msgAlarmVice);
-                msgAlarm.setCameraCode(String.valueOf(reqMsgAlarmVo.getAlarmCamera()));
-                String[] imageUrl = reqMsgAlarmVo.getImageUrls();
-                StringBuffer buffer = new StringBuffer();
-                for (String ss : imageUrl) {
-                    buffer.append(ss);
-                    buffer.append(";");
+            if (key.equals("1005")) {
+                LambdaQueryWrapper<MsgAlarm> lw = new LambdaQueryWrapper<MsgAlarm>();
+                if (!ObjectUtils.isEmpty(reqMsgAlarmVo.getAlarmId())) {
+                    lw.eq(MsgAlarm::getAlarmId, reqMsgAlarmVo.getAlarmId());
+                }
+                MsgAlarm alarm = msgAlarmService.getOne(lw);
+                log.info("alarm:{}", alarm);
+                BaseUser admin = baseUserService.getUserName("admin");
+                MsgAlarmFrequency msgAlarmVice = new MsgAlarmFrequency();
+                if (ObjectUtils.isEmpty(alarm)) {
+                    MsgAlarm msgAlarm = new MsgAlarm();
+                    BeanUtils.copyProperties(reqMsgAlarmVo, msgAlarm);
+                    BeanUtils.copyProperties(reqMsgAlarmVo, msgAlarmVice);
+                    msgAlarm.setCameraCode(String.valueOf(reqMsgAlarmVo.getAlarmCamera()));
+                    String[] imageUrl = reqMsgAlarmVo.getImageUrls();
+                    StringBuffer buffer = new StringBuffer();
+                    for (String ss : imageUrl) {
+                        buffer.append(ss);
+                        buffer.append(";");
+                    }
+                    String url = buffer.toString();
+                    msgAlarm.setImageUrl(url.substring(0, url.length() - 1));
+                    msgAlarm.setCreateBy(admin.getUserId());
+                    msgAlarm.setUpdateBy(admin.getUserId());
+                    msgAlarm.setAlarmMile(baseCameraManagement.getInstallMile());
+                    log.info("时间++++ long ---- " + reqMsgAlarmVo.getAlarmTime());
+                    log.info("时间++++" + new Date(reqMsgAlarmVo.getAlarmTime()));
+                    msgAlarm.setAlarmTime(new Date(reqMsgAlarmVo.getAlarmTime()));
+                    log.info("时间++++get" + msgAlarm.getAlarmTime());
+                    BaseCameraManagement bcm = msgAlarmService.getBaseCameraManagementByCamereCode(msgAlarm.getCameraCode());
+                    BaseCameraVO baseCameraVO = new BaseCameraVO();
+                    baseCameraVO.setCameraCode(bcm.getCameraCode());
+                    baseCameraVO.setChannel(bcm.getChannel());
+                    redisService.addToSet(Constants.ALARM_SET, baseCameraVO);
+                    msgAlarmService.getNormalBaseCameraManagementsCache(Constants.ALARM_SET);
+                    msgAlarmService.save(msgAlarm);
+                    msgAlarmVice.setImageUrl(url.substring(0, url.length() - 1));
+                    msgAlarmVice.setCreateBy(admin.getUserId());
+                    msgAlarmVice.setUpdateBy(admin.getUserId());
+                    msgAlarmFrequencyService.save(msgAlarmVice);
+                    respMsgAlarmVo.setAlarmId(reqMsgAlarmVo.getAlarmId());
+                    respMsgAlarmVo.setCameraCode(reqMsgAlarmVo.getAlarmCamera());
+                    respMsgAlarmVo.setIsCancel(2);
+                    respMsgAlarmVo.setCancelTime(null);
+                    // 合成报警视频
+                    CompletableFuture.runAsync(() -> {
+                        String alarmUrl = alarmHistoryPlay(baseCameraManagement.getCameraCode(), baseCameraManagement.getChannel(), msgAlarm.getAlarmTime());
+                        msgAlarm.setReleasedUrl(alarmUrl);
+                        msgAlarmService.updateById(msgAlarm);
+                    });
+                } else {
+                    BeanUtils.copyProperties(reqMsgAlarmVo, msgAlarmVice);
+                    String[] imageUrl = reqMsgAlarmVo.getImageUrls();
+                    StringBuffer buffer = new StringBuffer();
+                    for (String ss : imageUrl) {
+                        buffer.append(ss);
+                        buffer.append(";");
+                    }
+                    String url = buffer.toString();
+                    msgAlarmVice.setImageUrl(url.substring(0, url.length() - 1));
+                    msgAlarmVice.setCreateBy(admin.getUserId());
+                    msgAlarmVice.setUpdateBy(admin.getUserId());
+                    msgAlarmFrequencyService.save(msgAlarmVice);
+                    respMsgAlarmVo.setAlarmId(reqMsgAlarmVo.getAlarmId());
+                    respMsgAlarmVo.setCameraCode(reqMsgAlarmVo.getAlarmCamera());
+                    respMsgAlarmVo.setIsCancel(alarm.getIsLock());
+                    if (!ObjectUtils.isEmpty(alarm.getReleasedTime())) {
+                        respMsgAlarmVo.setCancelTime(alarm.getReleasedTime().getTime());
+                    }
+                    respMsgAlarmVo.setCancelTime(null);
                 }
-                String url = buffer.toString();
-                msgAlarm.setImageUrl(url.substring(0, url.length() - 1));
-                msgAlarm.setCreateBy(admin.getUserId());
-                msgAlarm.setUpdateBy(admin.getUserId());
-                msgAlarm.setAlarmMile(baseCameraManagement.getInstallMile());
-                log.info("时间++++ long ---- " + reqMsgAlarmVo.getAlarmTime());
-                log.info("时间++++" + new Date(reqMsgAlarmVo.getAlarmTime()));
-                msgAlarm.setAlarmTime(new Date(reqMsgAlarmVo.getAlarmTime()));
-                log.info("时间++++get" + msgAlarm.getAlarmTime());
-                BaseCameraManagement bcm = msgAlarmService.getBaseCameraManagementByCamereCode(msgAlarm.getCameraCode());
-                BaseCameraVO baseCameraVO = new BaseCameraVO();
-                baseCameraVO.setCameraCode(bcm.getCameraCode());
-                baseCameraVO.setChannel(bcm.getChannel());
-                redisService.addToSet(Constants.ALARM_SET, baseCameraVO);
-                msgAlarmService.getNormalBaseCameraManagementsCache(Constants.ALARM_SET);
-                msgAlarmService.save(msgAlarm);
-                msgAlarmVice.setImageUrl(url.substring(0, url.length() - 1));
-                msgAlarmVice.setCreateBy(admin.getUserId());
-                msgAlarmVice.setUpdateBy(admin.getUserId());
-                msgAlarmFrequencyService.save(msgAlarmVice);
-                respMsgAlarmVo.setAlarmId(reqMsgAlarmVo.getAlarmId());
-                respMsgAlarmVo.setCameraCode(reqMsgAlarmVo.getAlarmCamera());
-                respMsgAlarmVo.setIsCancel(2);
-                respMsgAlarmVo.setCancelTime(null);
-                // 合成报警视频
-                CompletableFuture.runAsync(() -> {
-                    String alarmUrl = alarmHistoryPlay(baseCameraManagement.getCameraCode(), baseCameraManagement.getChannel(), msgAlarm.getAlarmTime());
-                    msgAlarm.setReleasedUrl(alarmUrl);
-                    msgAlarmService.updateById(msgAlarm);
-                });
+                jsonObject.put("resultCode", 1);
+                jsonObject.put("message", "成功");
+                jsonObject.put("data", respMsgAlarmVo);
+                return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), "4370780c9a8c43e5");
             } else {
-                BeanUtils.copyProperties(reqMsgAlarmVo, msgAlarmVice);
-                String[] imageUrl = reqMsgAlarmVo.getImageUrls();
-                StringBuffer buffer = new StringBuffer();
-                for (String ss : imageUrl) {
-                    buffer.append(ss);
-                    buffer.append(";");
+                LambdaQueryWrapper<MsgAlarmCloud> lw = new LambdaQueryWrapper<MsgAlarmCloud>();
+                if (!ObjectUtils.isEmpty(reqMsgAlarmVo.getAlarmId())) {
+                    lw.eq(MsgAlarmCloud::getAlarmId, reqMsgAlarmVo.getAlarmId());
+                }
+                MsgAlarmCloud alarm = msgAlarmCloudService.getOne(lw);
+                log.info("alarm:{}", alarm);
+                BaseUser admin = baseUserService.getUserName("admin");
+                MsgAlarmFrequencyCloud msgAlarmVice = new MsgAlarmFrequencyCloud();
+                if (ObjectUtils.isEmpty(alarm)) {
+                    MsgAlarmCloud msgAlarm = new MsgAlarmCloud();
+                    BeanUtils.copyProperties(reqMsgAlarmVo, msgAlarm);
+                    BeanUtils.copyProperties(reqMsgAlarmVo, msgAlarmVice);
+                    msgAlarm.setCameraCode(String.valueOf(reqMsgAlarmVo.getAlarmCamera()));
+                    String[] imageUrl = reqMsgAlarmVo.getImageUrls();
+                    StringBuffer buffer = new StringBuffer();
+                    for (String ss : imageUrl) {
+                        buffer.append(ss);
+                        buffer.append(";");
+                    }
+                    String url = buffer.toString();
+                    msgAlarm.setImageUrl(url.substring(0, url.length() - 1));
+                    msgAlarm.setCreateBy(admin.getUserId());
+                    msgAlarm.setUpdateBy(admin.getUserId());
+                    msgAlarm.setAlarmMile(baseCameraManagement.getInstallMile());
+                    log.info("时间++++ long ---- " + reqMsgAlarmVo.getAlarmTime());
+                    log.info("时间++++" + new Date(reqMsgAlarmVo.getAlarmTime()));
+                    msgAlarm.setAlarmTime(new Date(reqMsgAlarmVo.getAlarmTime()));
+                    log.info("时间++++get" + msgAlarm.getAlarmTime());
+                    BaseCameraManagement bcm = msgAlarmService.getBaseCameraManagementByCamereCode(msgAlarm.getCameraCode());
+                    BaseCameraVO baseCameraVO = new BaseCameraVO();
+                    baseCameraVO.setCameraCode(bcm.getCameraCode());
+                    baseCameraVO.setChannel(bcm.getChannel());
+                    redisService.addToSet(Constants.ALARM_SET, baseCameraVO);
+                    msgAlarmService.getNormalBaseCameraManagementsCache(Constants.ALARM_SET);
+                    msgAlarmCloudService.save(msgAlarm);
+                    msgAlarmVice.setImageUrl(url.substring(0, url.length() - 1));
+                    msgAlarmVice.setCreateBy(admin.getUserId());
+                    msgAlarmVice.setUpdateBy(admin.getUserId());
+                    msgAlarmFrequencyCloudService.save(msgAlarmVice);
+                    respMsgAlarmVo.setAlarmId(reqMsgAlarmVo.getAlarmId());
+                    respMsgAlarmVo.setCameraCode(reqMsgAlarmVo.getAlarmCamera());
+                    respMsgAlarmVo.setIsCancel(2);
+                    respMsgAlarmVo.setCancelTime(null);
+                    // 合成报警视频
+                    CompletableFuture.runAsync(() -> {
+                        String alarmUrl = alarmHistoryPlay(baseCameraManagement.getCameraCode(), baseCameraManagement.getChannel(), msgAlarm.getAlarmTime());
+                        msgAlarm.setReleasedUrl(alarmUrl);
+                        msgAlarmCloudService.updateById(msgAlarm);
+                    });
+                } else {
+                    BeanUtils.copyProperties(reqMsgAlarmVo, msgAlarmVice);
+                    String[] imageUrl = reqMsgAlarmVo.getImageUrls();
+                    StringBuffer buffer = new StringBuffer();
+                    for (String ss : imageUrl) {
+                        buffer.append(ss);
+                        buffer.append(";");
+                    }
+                    String url = buffer.toString();
+                    msgAlarmVice.setImageUrl(url.substring(0, url.length() - 1));
+                    msgAlarmVice.setCreateBy(admin.getUserId());
+                    msgAlarmVice.setUpdateBy(admin.getUserId());
+                    msgAlarmFrequencyCloudService.save(msgAlarmVice);
+                    respMsgAlarmVo.setAlarmId(reqMsgAlarmVo.getAlarmId());
+                    respMsgAlarmVo.setCameraCode(reqMsgAlarmVo.getAlarmCamera());
+                    respMsgAlarmVo.setIsCancel(alarm.getIsLock());
+                    if (!ObjectUtils.isEmpty(alarm.getReleasedTime())) {
+                        respMsgAlarmVo.setCancelTime(alarm.getReleasedTime().getTime());
+                    }
+                    respMsgAlarmVo.setCancelTime(null);
                 }
-                String url = buffer.toString();
-                msgAlarmVice.setImageUrl(url.substring(0, url.length() - 1));
-                msgAlarmVice.setCreateBy(admin.getUserId());
-                msgAlarmVice.setUpdateBy(admin.getUserId());
-                msgAlarmFrequencyService.save(msgAlarmVice);
-                respMsgAlarmVo.setAlarmId(reqMsgAlarmVo.getAlarmId());
-                respMsgAlarmVo.setCameraCode(reqMsgAlarmVo.getAlarmCamera());
-                respMsgAlarmVo.setIsCancel(alarm.getIsLock());
-                if (!ObjectUtils.isEmpty(alarm.getReleasedTime())) {
-                    respMsgAlarmVo.setCancelTime(alarm.getReleasedTime().getTime());
+                try {
+                    MsgAlarmCloud alarms = msgAlarmCloudService.getOne(lw);
+                    log.info("sdkUrl:{}", sdkUrl);
+                    log.info("alarmJSON :{}", JSON.toJSONString(alarms));
+                    String result = HttpClientUtil.postJson(sdkUrl, JSON.toJSONString(alarms));
+                    log.info("result:{}", result);
+                } catch (Exception e) {
+                    log.info(e.getMessage());
+                    e.printStackTrace();
+                    jsonObject.put("resultCode", 0);
+                    jsonObject.put("message", "失败");
+                    jsonObject.put("data", "消息推送失败");
+                    return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), "4370780c9a8c43e5");
                 }
-                respMsgAlarmVo.setCancelTime(null);
-            }
-            try {
-                MsgAlarm alarms = msgAlarmService.getOne(lw);
-                log.info("sdkUrl:{}", sdkUrl);
-                log.info("alarmJSON :{}", JSON.toJSONString(alarms));
-                String result = HttpClientUtil.postJson(sdkUrl, JSON.toJSONString(alarms));
-                log.info("result:{}", result);
-            } catch (Exception e) {
-                log.info(e.getMessage());
-                e.printStackTrace();
-                jsonObject.put("resultCode", 0);
-                jsonObject.put("message", "失败");
-                jsonObject.put("data", "消息推送失败");
+                jsonObject.put("resultCode", 1);
+                jsonObject.put("message", "成功");
+                jsonObject.put("data", respMsgAlarmVo);
                 return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), "4370780c9a8c43e5");
             }
-            jsonObject.put("resultCode", 1);
-            jsonObject.put("message", "成功");
-            jsonObject.put("data", respMsgAlarmVo);
-            return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), "4370780c9a8c43e5");
         } else {
             jsonObject.put("resultCode", 2);
             jsonObject.put("message", "失败");