Browse Source

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

gao.qiang 2 years ago
parent
commit
7eed35efd5

+ 12 - 12
.idea/jarRepositories.xml

@@ -2,8 +2,8 @@
 <project version="4">
   <component name="RemoteRepositoriesConfiguration">
     <remote-repository>
-      <option name="id" value="public" />
-      <option name="name" value="aliyun nexus" />
+      <option name="id" value="central" />
+      <option name="name" value="Central Repository" />
       <option name="url" value="https://maven.aliyun.com/repository/public" />
     </remote-repository>
     <remote-repository>
@@ -11,6 +11,16 @@
       <option name="name" value="Central Repository" />
       <option name="url" value="https://repo.maven.apache.org/maven2" />
     </remote-repository>
+    <remote-repository>
+      <option name="id" value="public" />
+      <option name="name" value="aliyun nexus" />
+      <option name="url" value="https://maven.aliyun.com/repository/public" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="central" />
+      <option name="name" value="Maven Central repository" />
+      <option name="url" value="https://repo1.maven.org/maven2" />
+    </remote-repository>
     <remote-repository>
       <option name="id" value="central" />
       <option name="name" value="Central Repository" />
@@ -26,11 +36,6 @@
       <option name="name" value="Central Repository" />
       <option name="url" value="http://maven.aliyun.com/nexus/content/repositories/central/" />
     </remote-repository>
-    <remote-repository>
-      <option name="id" value="central" />
-      <option name="name" value="Maven Central repository" />
-      <option name="url" value="https://repo1.maven.org/maven2" />
-    </remote-repository>
     <remote-repository>
       <option name="id" value="custom_group" />
       <option name="name" value="Nexus Repository" />
@@ -41,10 +46,5 @@
       <option name="name" value="JBoss Community repository" />
       <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
     </remote-repository>
-    <remote-repository>
-      <option name="id" value="central" />
-      <option name="name" value="Central Repository" />
-      <option name="url" value="https://maven.aliyun.com/repository/public" />
-    </remote-repository>
   </component>
 </project>

+ 6 - 0
business-service/pom.xml

@@ -35,6 +35,12 @@
             <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.ozs</groupId>
+            <artifactId>base-system</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 
 </project>

+ 72 - 0
business-service/src/main/java/com/ozs/service/entity/vo/AlarmStatisticDto.java

@@ -0,0 +1,72 @@
+package com.ozs.service.entity.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ozs.common.annotation.Excel;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author wyy
+ * @subject
+ * @creat 2023/3/15
+ */
+@Data
+public class AlarmStatisticDto {
+    /**
+     * 报警唯一标识
+     */
+    private String alarmId;
+    /**
+     * 线路名称
+     */
+    @Excel(name = "线路名称")
+    private String railwayName;
+
+    /**
+     * 报警时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "报警时间")
+    private Date alarmTime;
+
+    /**
+     * 行别编码
+     */
+    private String lineDir;
+
+    /**
+     * 行别
+     */
+    @Excel(name = "行别")
+    private String lineDirValue;
+
+    /**
+     * 报警类型编码
+     */
+    private String alarmType;
+
+    /**
+     * 报警类型
+     */
+    @Excel(name = "报警类型")
+    private String alarmTypeValue;
+
+    /**
+     * 报警里程位置
+     */
+    @Excel(name = "里程位置")
+    private String alarmMile;
+
+    /**
+     * 监控范围开始里程位置
+     */
+    @Excel(name = "里程起始范围km")
+    private Integer beginMile;
+
+    /**
+     * 监控范围结束里程位置
+     */
+    @Excel(name = "里程结束范围km")
+    private Integer endMile;
+}

+ 56 - 0
business-service/src/main/java/com/ozs/service/entity/vo/AlarmStatisticMonthDto.java

@@ -0,0 +1,56 @@
+package com.ozs.service.entity.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ozs.common.annotation.Excel;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author wyy
+ * @subject
+ * @creat 2023/3/15
+ */
+@Data
+public class AlarmStatisticMonthDto {
+    /**
+     * 报警唯一标识
+     */
+    private String alarmId;
+
+    /**
+     * 线路名称
+     */
+    @Excel(name = "线路名称")
+    private String railwayName;
+
+    /**
+     * 报警类型编码
+     */
+    private String alarmType;
+
+    /**
+     * 报警类型
+     */
+    @Excel(name = "报警类型")
+    private String alarmTypeValue;
+
+    /**
+     * 报警月份
+     */
+    @Excel(name = "报警月份")
+    private Integer monthsta;
+
+    /**
+     * 报警次数
+     */
+    @Excel(name = "报警次数")
+    private Integer frequency;
+
+    /**
+     * 报警时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "报警时间")
+    private Date alarmTime;
+}

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

@@ -42,6 +42,7 @@ public class MsgAlarmResp implements Serializable {
      * 报警行别(1上行2下行)
      */
     private Integer lineDir;
+    private String lineDirStr;
 
     /**
      * 所属工务段编码(单位id)

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

@@ -2,6 +2,8 @@ package com.ozs.service.mapper;
 
 import com.ozs.service.entity.MsgAlarm;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ozs.service.entity.vo.AlarmStatisticDto;
+import com.ozs.service.entity.vo.AlarmStatisticMonthDto;
 import com.ozs.service.entity.vo.AlarmStatisticVo;
 
 import org.apache.ibatis.annotations.Mapper;
@@ -22,6 +24,12 @@ public interface MsgAlarmMapper extends BaseMapper<MsgAlarm> {
     //报警数据详情
     List<AlarmStatisticVo> list(@Param("railwayCode") String railwayCode, @Param("startMonth") Integer startMonth, @Param("endMonth") Integer endMonth, @Param("alarmType") String alarmType, @Param("userId") String userId);
 
+    //报警数据详情导出数据集合
+    List<AlarmStatisticDto> listDto(@Param("railwayCode") String railwayCode, @Param("startMonth") Integer startMonth, @Param("endMonth") Integer endMonth, @Param("alarmType") String alarmType, @Param("userId") String userId);
+
     //报警月统计数据
     List<AlarmStatisticVo> listMonth(@Param("railwayCode") String railwayCode, @Param("startMonth") Integer startMonth, @Param("endMonth") Integer endMonth, @Param("alarmType") String alarmType, @Param("userId") String userId);
+
+    //报警月统计数据导出数据集合
+    List<AlarmStatisticMonthDto> listDtoMonth(@Param("railwayCode") String railwayCode, @Param("startMonth") Integer startMonth, @Param("endMonth") Integer endMonth, @Param("alarmType") String alarmType, @Param("userId") String userId);
 }

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

@@ -3,6 +3,8 @@ package com.ozs.service.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.ozs.service.entity.MsgAlarm;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.ozs.service.entity.vo.AlarmStatisticDto;
+import com.ozs.service.entity.vo.AlarmStatisticMonthDto;
 import com.ozs.service.entity.vo.AlarmStatisticResVo;
 import com.ozs.service.entity.vo.AlarmStatisticVo;
 
@@ -24,9 +26,9 @@ public interface MsgAlarmService extends IService<MsgAlarm> {
     //web数据统计 报警月统计数据
     List<AlarmStatisticVo> getCount(String railwayCode, Integer startMonth, Integer endMonth, String alarmType, String userId);
 
-    //web数据统计 报警数据详情导出
-    void exportExcel(HttpServletResponse response, AlarmStatisticResVo alarmStatisticResVo, String userId) throws Exception;
+    //报警数据详情导出数据集合
+    List<AlarmStatisticDto> exportExcel(AlarmStatisticResVo alarmStatisticResVo, String userId);
 
     //web数据统计 报警月统计数据导出
-    void exportExcelMonth(HttpServletResponse response, AlarmStatisticResVo alarmStatisticResVo, String userId) throws Exception;
+    List<AlarmStatisticMonthDto> exportExcelMonth(AlarmStatisticResVo alarmStatisticResVo, String userId) throws Exception;
 }

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

@@ -8,6 +8,6 @@ import com.ozs.service.entity.MsgWebPush;
  * @Author : sunhh
  * @create 2023/3/15 14:33
  */
-public interface MsgWebPushService extends IService<MsgWebPush>  {
+public interface MsgWebPushService extends IService<MsgWebPush> {
     int read(MsgWebPush msgWebPush);
 }

+ 26 - 160
business-service/src/main/java/com/ozs/service/service/impl/MsgAlarmServiceImpl.java

@@ -4,11 +4,15 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ozs.common.utils.StringUtils;
 import com.ozs.service.entity.MsgAlarm;
+import com.ozs.service.entity.vo.AlarmStatisticDto;
+import com.ozs.service.entity.vo.AlarmStatisticMonthDto;
 import com.ozs.service.entity.vo.AlarmStatisticResVo;
 import com.ozs.service.entity.vo.AlarmStatisticVo;
 import com.ozs.service.mapper.MsgAlarmMapper;
 import com.ozs.service.service.MsgAlarmService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ozs.system.mapper.SysDictDataMapper;
+import org.apache.commons.lang3.ObjectUtils;
 import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.ss.usermodel.*;
 import org.springframework.beans.BeanUtils;
@@ -33,6 +37,8 @@ import java.util.*;
 public class MsgAlarmServiceImpl extends ServiceImpl<MsgAlarmMapper, MsgAlarm> implements MsgAlarmService {
     @Autowired
     MsgAlarmMapper msgAlarmMapper;
+    @Autowired
+    SysDictDataMapper sysDictDataMapper;
 
     public static IPage listToPage(List list, int pageNum, int pageSize) {
         List pageList = new ArrayList<>();
@@ -61,171 +67,31 @@ public class MsgAlarmServiceImpl extends ServiceImpl<MsgAlarmMapper, MsgAlarm> i
     }
 
     @Override
-    public void exportExcel(HttpServletResponse response, AlarmStatisticResVo alarmStatisticResVo, String userId) throws Exception {
-        // 第一步,创建一个webbook,对应一个Excel文件
-        HSSFWorkbook wb = new HSSFWorkbook();
-        // 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet
-        HSSFSheet sheet = wb.createSheet("报警数据详情");
-        // 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short
-        HSSFRow row = sheet.createRow(0);
-        // 第四步,创建单元格,并设置值表头 设置表头居中
-        HSSFCellStyle style = wb.createCellStyle();
-        //单元格边框
-        //style.setAlignment(BorderStyle.THIN); // 创建一个居中格式
-        style.setBorderBottom(BorderStyle.THIN); //下边框
-        style.setBorderLeft(BorderStyle.THIN);//左边框
-        style.setBorderTop(BorderStyle.THIN);//上边框
-        style.setBorderRight(BorderStyle.THIN);//右边框
-        //设置单元格字体大小
-        HSSFFont font = wb.createFont();
-        font.setFontName("宋体");
-        font.setFontHeightInPoints((short) 11);//设置字体大小
-        //font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//粗体显示
-        style.setFont(font);//选择需要用到的字体格式
-
-        HSSFCell cell = row.createCell(0);
-        cell.setCellValue("线路");
-        cell.setCellStyle(style);
-        cell = row.createCell(1);
-        cell.setCellValue("时间");
-        cell.setCellStyle(style);
-        cell = row.createCell(2);
-        cell.setCellValue("行别");
-        cell.setCellStyle(style);
-        cell = row.createCell(3);
-        cell.setCellValue("报警类型");
-        cell.setCellStyle(style);
-        cell = row.createCell(4);
-        cell.setCellValue("里程位置");
-        cell.setCellStyle(style);
-        cell = row.createCell(5);
-        cell.setCellValue("里程起始范围km");
-        cell.setCellStyle(style);
-        cell = row.createCell(6);
-        cell.setCellValue("里程结束范围km");
-        cell.setCellStyle(style);
-
-        //调取数据
-        List<AlarmStatisticVo> list = msgAlarmMapper.list(alarmStatisticResVo.getRailwayCode(), alarmStatisticResVo.getStartMonth(),
+    public List<AlarmStatisticDto> exportExcel(AlarmStatisticResVo alarmStatisticResVo, String userId) {
+        List<AlarmStatisticDto> listDto = msgAlarmMapper.listDto(alarmStatisticResVo.getRailwayCode(), alarmStatisticResVo.getStartMonth(),
                 alarmStatisticResVo.getEndMonth(), alarmStatisticResVo.getAlarmType(), userId);
-        //将数据写入表格
-        for (int i = 0; i < list.size(); i++) {
-            row = sheet.createRow(i + 1);
-            AlarmStatisticVo vo = list.get(i);
-            // 第四步,创建单元格,并设置值
-            if (StringUtils.isNotEmpty(vo.getBaseCameraManagement().getRailwayCode())) {
-                row.createCell(0).setCellValue(vo.getBaseCameraManagement().getRailwayCode());
-            }
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            if (vo.getAlarmTime() != null) {
-                String dateStr = sdf.format(vo.getAlarmTime());
-                row.createCell(1).setCellValue(dateStr);
-            }
-            if (vo.getLineDir() != null) {
-                row.createCell(2).setCellValue(vo.getLineDir());
-            }
-            if (vo.getAlarmType() != null) {
-                row.createCell(3).setCellValue(vo.getAlarmType());
-            }
-            if (vo.getBaseCameraManagement().getInstallMile() != null) {
-                row.createCell(4).setCellValue(vo.getBaseCameraManagement().getInstallMile());
-            }
-            if (vo.getBaseCameraManagement().getBeginMile() != null) {
-                row.createCell(5).setCellValue(vo.getBaseCameraManagement().getBeginMile());
-            }
-            if (vo.getBaseCameraManagement().getEndMile() != null) {
-                row.createCell(6).setCellValue(vo.getBaseCameraManagement().getEndMile());
-            }
-        }
-        //第六步,输出Excel文件
-        OutputStream output = response.getOutputStream();
-        response.reset();
-        response.setContentType("application/vnd.ms-excel");
+        listDto.forEach(l -> {
+            String alarmType = l.getAlarmType();
+            String alarmTypeValue = sysDictDataMapper.selectDictLabel("sys_alarm_type", alarmType);
+            l.setAlarmTypeValue(alarmTypeValue);
 
-        //设置文件头:最后一个参数是设置下载文件名
-        long filename = System.currentTimeMillis();
-        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
-        String fileName = "报警数据详情";
-        response.addHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
-        wb.write(output);
-        output.close();
+            String lineDir = l.getLineDir();
+            String lineDirValue = sysDictDataMapper.selectDictLabel("sys_line_dir", lineDir);
+            l.setLineDirValue(lineDirValue);
+        });
+        return listDto;
     }
 
     @Override
-    public void exportExcelMonth(HttpServletResponse response, AlarmStatisticResVo alarmStatisticResVo, String userId) throws Exception {
-        // 第一步,创建一个webbook,对应一个Excel文件
-        HSSFWorkbook wb = new HSSFWorkbook();
-        // 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet
-        HSSFSheet sheet = wb.createSheet("报警月统计数据");
-        // 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short
-        HSSFRow row = sheet.createRow(0);
-        // 第四步,创建单元格,并设置值表头 设置表头居中
-        HSSFCellStyle style = wb.createCellStyle();
-        //单元格边框
-        //style.setAlignment(BorderStyle.THIN); // 创建一个居中格式
-        style.setBorderBottom(BorderStyle.THIN); //下边框
-        style.setBorderLeft(BorderStyle.THIN);//左边框
-        style.setBorderTop(BorderStyle.THIN);//上边框
-        style.setBorderRight(BorderStyle.THIN);//右边框
-        //设置单元格字体大小
-        HSSFFont font = wb.createFont();
-        font.setFontName("宋体");
-        font.setFontHeightInPoints((short) 11);//设置字体大小
-        //font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//粗体显示
-        style.setFont(font);//选择需要用到的字体格式
-
-        HSSFCell cell = row.createCell(0);
-        cell.setCellValue("线路");
-        cell.setCellStyle(style);
-        cell = row.createCell(1);
-        cell.setCellValue("报警类型");
-        cell.setCellStyle(style);
-        cell = row.createCell(2);
-        cell.setCellValue("报警月份");
-        cell.setCellStyle(style);
-        cell = row.createCell(3);
-        cell.setCellValue("报警次数");
-        cell.setCellStyle(style);
-        cell = row.createCell(4);
-        cell.setCellValue("报警时间");
-        cell.setCellStyle(style);
-
-        //调取数据
-        List<AlarmStatisticVo> list = msgAlarmMapper.listMonth(alarmStatisticResVo.getRailwayCode(), alarmStatisticResVo.getStartMonth(),
+    public List<AlarmStatisticMonthDto> exportExcelMonth(AlarmStatisticResVo alarmStatisticResVo, String userId) throws Exception {
+        List<AlarmStatisticMonthDto> listDto = msgAlarmMapper.listDtoMonth(alarmStatisticResVo.getRailwayCode(), alarmStatisticResVo.getStartMonth(),
                 alarmStatisticResVo.getEndMonth(), alarmStatisticResVo.getAlarmType(), userId);
-        //将数据写入表格
-        for (int i = 0; i < list.size(); i++) {
-            row = sheet.createRow(i + 1);
-            AlarmStatisticVo vo = list.get(i);
-            // 第四步,创建单元格,并设置值
-            if (StringUtils.isNotEmpty(vo.getBaseCameraManagement().getRailwayCode())) {
-                row.createCell(0).setCellValue(vo.getBaseCameraManagement().getRailwayCode());
-            }
-            if (vo.getAlarmType() != null) {
-                row.createCell(1).setCellValue(vo.getAlarmType());
-            }
-            if (vo.getMonthsta() != null) {
-                row.createCell(2).setCellValue(vo.getMonthsta());
-            }
-            if (vo.getFrequency() != null) {
-                row.createCell(3).setCellValue(vo.getFrequency());
-            }
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            if (vo.getAlarmTime() != null) {
-                String dateStr = sdf.format(vo.getAlarmTime());
-                row.createCell(4).setCellValue(dateStr);
-            }
-        }
-        //第六步,输出Excel文件
-        OutputStream output = response.getOutputStream();
-        response.reset();
-        response.setContentType("application/vnd.ms-excel");
-        //设置文件头:最后一个参数是设置下载文件名
-        long filename = System.currentTimeMillis();
-        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
-        String fileName = "报警月统计数据";
-        response.addHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
-        wb.write(output);
-        output.close();
+        listDto.forEach(l -> {
+            String alarmType = l.getAlarmType();
+            String alarmTypeValue = sysDictDataMapper.selectDictLabel("sys_alarm_type", alarmType);
+            l.setAlarmTypeValue(alarmTypeValue);
+        });
+        return listDto;
     }
+
 }

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

@@ -126,4 +126,96 @@
         group by a.alarm_id,MONTH(a.alarm_time)
 
     </select>
+
+    <resultMap id="AlarmStatisticDtoResult" type="com.ozs.service.entity.vo.AlarmStatisticDto">
+        <id column="id" property="id"/>
+        <result column="alarmId" property="alarmId"/>
+        <result column="railwayName" property="railwayName"/>
+        <result column="alarmTime" property="alarmTime"/>
+        <result column="lineDir" property="lineDir"/>
+        <result column="lineDirValue" property="lineDirValue"/>
+        <result column="alarmType" property="alarmType"/>
+        <result column="alarmTypeValue" property="alarmTypeValue"/>
+        <result column="alarmMile" property="alarmMile"/>
+        <result column="beginMile" property="beginMile"/>
+        <result column="endMile" property="endMile"/>
+    </resultMap>
+    <select id="listDto" resultMap="AlarmStatisticDtoResult">
+        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,
+        c.railway_name AS railwayName,
+        b.begin_mile AS beginMile,
+        b.end_mile AS endMile
+        FROM
+        msg_alarm AS a left join
+        base_camera_management AS b on a.camera_code=b.camera_code left join
+        msg_web_push m on a.alarm_id = m.alarm_id 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="startMonth != null and startMonth != 0">
+                <![CDATA[and MONTH(a.alarm_time) >=#{startMonth}]]>
+            </if>
+            <if test="endMonth != null and endMonth != 0">
+                <![CDATA[and MONTH(a.alarm_time) <=#{endMonth}]]>
+            </if>
+            <if test="alarmType != null and alarmType != ''">
+                and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
+            </if>
+            <if test="userId != null and userId != ''">
+                and UPPER(m.receive_by) like UPPER(CONCAT('%',#{userId},'%'))
+            </if>
+        </where>
+        group by a.alarm_id
+    </select>
+    <resultMap id="AlarmStatisticMonthDtoResult" type="com.ozs.service.entity.vo.AlarmStatisticMonthDto">
+        <id column="id" property="id"/>
+        <result column="alarmId" property="alarmId"/>
+        <result column="railwayName" property="railwayName"/>
+        <result column="alarmType" property="alarmType"/>
+        <result column="alarmTime" property="alarmTime"/>
+        <result column="monthsta" property="monthsta"/>
+        <result column="frequency" property="frequency"/>
+    </resultMap>
+    <select id="listDtoMonth" resultMap="AlarmStatisticMonthDtoResult">
+        SELECT
+        a.alarm_id AS alarmId,
+        MONTH(a.alarm_time) as monthsta,
+        count(DISTINCT a.alarm_id) as frequency,
+        a.alarm_type AS alarmType,
+        a.alarm_time AS alarmTime,
+        c.railway_name AS railwayName
+        FROM
+        msg_alarm AS a left join
+        base_camera_management AS b on a.camera_code=b.camera_code left join
+        msg_web_push m on a.alarm_id = m.alarm_id 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="startMonth != null and startMonth != 0">
+                <![CDATA[and MONTH(a.alarm_time) >=#{startMonth}]]>
+            </if>
+            <if test="endMonth != null and endMonth != 0">
+                <![CDATA[and MONTH(a.alarm_time) <=#{endMonth}]]>
+            </if>
+            <if test="alarmType != null and alarmType != ''">
+                and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
+            </if>
+            <if test="userId != null and userId != ''">
+                and UPPER(m.receive_by) like UPPER(CONCAT('%',#{userId},'%'))
+            </if>
+        </where>
+        group by a.alarm_id,MONTH(a.alarm_time)
+
+    </select>
 </mapper>

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

@@ -95,7 +95,7 @@ public class BaseCameraManagementController extends BaseController {
     /**
      * 所有相机列表+权限
      */
-    @ApiOperation(value = "相机台账管理分页")
+    @ApiOperation(value = "相机台账管理")
     @GetMapping("/selectCameraAll")
     public AjaxResult selectCameraAll() {
         String userId = getUserId();

+ 50 - 22
hazard-admin/src/main/java/com/ozs/web/controller/accountmanagment/MsgAlarmController.java

@@ -7,16 +7,30 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ozs.common.core.controller.BaseController;
 import com.ozs.common.core.domain.AjaxResult;
+import com.ozs.common.core.domain.entity.SysDept;
 import com.ozs.common.utils.AppendUtils;
 import com.ozs.common.utils.StringUtils;
-import com.ozs.service.entity.*;
+import com.ozs.common.utils.poi.ExcelUtil;
+import com.ozs.service.entity.BaseCameraManagement;
+import com.ozs.service.entity.BaseRailwayManagement;
+import com.ozs.service.entity.MsgAlarm;
+import com.ozs.service.entity.MsgAlarmFrequency;
 import com.ozs.service.entity.vo.*;
 import com.ozs.service.mapper.MsgAlarmMapper;
-import com.ozs.service.service.*;
+import com.ozs.service.service.BaseCameraManagementService;
+import com.ozs.service.service.BaseRailwayManagementService;
+import com.ozs.service.service.MsgAlarmFrequencyService;
+import com.ozs.service.service.MsgAlarmService;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
@@ -32,7 +46,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -62,19 +80,25 @@ public class MsgAlarmController extends BaseController {
     BaseRailwayManagementService baseRailwayManagementService;
     @Value("${base.imgUrl:http://124.71.171.71:18801/picbucket}")
     private String imgUrl;
-    @Autowired
-    private MsgWebPushService msgWebPushService;
+
 
     /**
-     * web消息已读
+     * 测试消息推送
      */
-    @PostMapping("/read")
+    @PostMapping("/push")
     @ApiOperation(value = "预报警信息分页")
-    public AjaxResult read(@RequestBody MsgWebPush msgWebPush) {
-        if (StringUtils.isEmpty(msgWebPush) || StringUtils.isEmpty(msgWebPush.getId())) {
-            return AjaxResult.error("主键ID不能为空!");
-        }
-        return toAjax(msgWebPushService.read(msgWebPush));
+    public AjaxResult insertDate(String[] args) {
+        // 模拟需要推送的用户群
+        ArrayList<String> ids = new ArrayList<>();
+        ids.add("001");
+        ids.add("002");
+        ids.add("003");
+        ids.add("004");
+        ids.add("005");
+//
+//        WebSocketService webSocketService = new WebSocketService();
+//        webSocketService.sendMsgToUsers(ids);
+        return AjaxResult.success("推送成功");
     }
 
     /**
@@ -86,7 +110,7 @@ public class MsgAlarmController extends BaseController {
     @ApiOperation(value = "报警信息分页")
     @PostMapping("/list")
     public AjaxResult selectMsgAlarm(@RequestBody MsgAlarmVo msgAlarmVo) {
-        List<BaseCameraManagement> baseCameraManagementList = new ArrayList<>();
+        List<BaseCameraManagement> baseCameraManagementList=new ArrayList<>();
         LambdaQueryWrapper<BaseCameraManagement> wrapper = new LambdaQueryWrapper<BaseCameraManagement>();
         if (!ObjectUtils.isEmpty(msgAlarmVo.getRailwayCode())) {
             wrapper.eq(BaseCameraManagement::getRailwayCode, msgAlarmVo.getRailwayCode());
@@ -97,7 +121,7 @@ public class MsgAlarmController extends BaseController {
         if (!ObjectUtils.isEmpty(msgAlarmVo.getEndMile())) {
             wrapper.le(BaseCameraManagement::getEndMile, msgAlarmVo.getEndMile());
         }
-        if (!ObjectUtils.isEmpty(msgAlarmVo.getRailwayCode()) || !ObjectUtils.isEmpty(msgAlarmVo.getBeginMile()) || !ObjectUtils.isEmpty(msgAlarmVo.getEndMile())) {
+        if (!ObjectUtils.isEmpty(msgAlarmVo.getRailwayCode())||!ObjectUtils.isEmpty(msgAlarmVo.getBeginMile())||!ObjectUtils.isEmpty(msgAlarmVo.getEndMile())) {
             baseCameraManagementList = baseCameraManagementService.list(wrapper);
         }
         List<String> userIds = baseCameraManagementService.getUserIds(getUserId());
@@ -108,14 +132,14 @@ public class MsgAlarmController extends BaseController {
         if (!ObjectUtils.isEmpty(msgAlarmVo.getLineDir())) {
             lw.eq(MsgAlarm::getLineDir, msgAlarmVo.getLineDir());
         }
-        if (baseCameraManagementList.size() > 0) {
+        if (baseCameraManagementList.size()>0) {
             List<String> collect = baseCameraManagementList.stream().map(BaseCameraManagement::getCameraCode).collect(Collectors.toList());
             lw.in(MsgAlarm::getCameraCode, collect);
         }
         if (!ObjectUtils.isEmpty(msgAlarmVo.getAlarmType())) {
             lw.eq(MsgAlarm::getAlarmType, msgAlarmVo.getAlarmType());
         }
-        if (!ObjectUtils.isEmpty(msgAlarmVo.getAlarmMile()) && msgAlarmVo.getAlarmMile() != 0) {
+        if (!ObjectUtils.isEmpty(msgAlarmVo.getAlarmMile())&& msgAlarmVo.getAlarmMile() != 0) {
             lw.eq(MsgAlarm::getAlarmMile, msgAlarmVo.getAlarmMile());
         }
         if (!ObjectUtils.isEmpty(msgAlarmVo.getBeginAlarmTime())) {
@@ -128,7 +152,7 @@ public class MsgAlarmController extends BaseController {
             lw.eq(MsgAlarm::getIsLock, msgAlarmVo.getIsLock());
         }
         IPage<MsgAlarm> page = msgAlarmService.page(new Page<>(msgAlarmVo.getPageNum(), msgAlarmVo.getPageSize()), lw);
-        if (!ObjectUtils.isEmpty(page) && !ObjectUtils.isEmpty(page.getRecords())) {
+        if(!ObjectUtils.isEmpty(page) && !ObjectUtils.isEmpty(page.getRecords())){
             List<MsgAlarm> dto1 = page.getRecords().stream().map(o -> {
                 ArrayList<String> objects = new ArrayList<>();
                 String[] split = o.getImageUrl().split(";");
@@ -155,7 +179,7 @@ public class MsgAlarmController extends BaseController {
                 o.setEndMile(end);
                 String begin = AppendUtils.stringAppend(cameraManagement.getBeginMile());
                 o.setBeginMile(begin);
-                o.setAlarmCount((int) msgAlarmFrequencyService.count() + 1);
+                o.setAlarmCount((int) msgAlarmFrequencyService.count()+1);
                 return o;
             }).collect(Collectors.toList());
             page.setRecords(dto1);
@@ -183,11 +207,11 @@ public class MsgAlarmController extends BaseController {
         msgAlarmResp.setDeptId(baseCameraManagement.getDeptId());
         String begin = AppendUtils.stringAppend(baseCameraManagement.getBeginMile());
         String end = AppendUtils.stringAppend(baseCameraManagement.getEndMile());
-        String endMile = begin + "-" + end;
+        String endMile=begin+"-"+end;
         msgAlarmResp.setBeginMile(endMile);
         String mile = AppendUtils.stringAppend(baseCameraManagement.getInstallMile());
         msgAlarmResp.setAlarmMile(mile);
-        msgAlarmResp.setInstallLongitude(baseCameraManagement.getInstallLongitude() + "," + baseCameraManagement.getInstallLatitude());
+        msgAlarmResp.setInstallLongitude(baseCameraManagement.getInstallLongitude()+","+baseCameraManagement.getInstallLatitude());
         ArrayList<String> objects = new ArrayList<>();
         String[] split = msgAlarm.getImageUrl().split(";");
         for (String s : split) {
@@ -301,7 +325,9 @@ public class MsgAlarmController extends BaseController {
             userId = "";
         }
         try {
-            msgAlarmService.exportExcel(response, alarmStatisticResVo, userId);
+            List<AlarmStatisticDto> list = msgAlarmService.exportExcel(alarmStatisticResVo, userId);
+            ExcelUtil<AlarmStatisticDto> util = new ExcelUtil<>(AlarmStatisticDto.class);
+            util.exportExcel(response, list, "报警数据详情");
         } catch (Exception e) {
             e.printStackTrace();
             log.info(e.getMessage());
@@ -309,7 +335,7 @@ public class MsgAlarmController extends BaseController {
     }
 
     /**
-     * web数据统计 数据导出
+     * web数据统计 报警月统计数据导出
      *
      * @param
      * @return
@@ -328,7 +354,9 @@ public class MsgAlarmController extends BaseController {
             userId = "";
         }
         try {
-            msgAlarmService.exportExcelMonth(response, alarmStatisticResVo, userId);
+            List<AlarmStatisticMonthDto> list = msgAlarmService.exportExcelMonth(alarmStatisticResVo, userId);
+            ExcelUtil<AlarmStatisticMonthDto> util = new ExcelUtil<>(AlarmStatisticMonthDto.class);
+            util.exportExcel(response, list, "报警月统计数据");
         } catch (Exception e) {
             e.printStackTrace();
             log.info(e.getMessage());

+ 48 - 12
hazard-admin/src/main/java/com/ozs/web/controller/monitor/SysLoginInfoController.java

@@ -2,14 +2,16 @@ package com.ozs.web.controller.monitor;
 
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ozs.common.core.domain.vo.SysLoginInfoVo;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.util.ObjectUtils;
+import org.springframework.web.bind.annotation.*;
 import com.ozs.common.annotation.Log;
 import com.ozs.common.core.controller.BaseController;
 import com.ozs.common.core.domain.AjaxResult;
@@ -34,12 +36,46 @@ public class SysLoginInfoController extends BaseController {
     @Autowired
     private SysPasswordService passwordService;
 
-    @PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
-    @GetMapping("/list")
-    public TableDataInfo list(SysLoginInfo logininfor) {
-        startPage();
-        List<SysLoginInfo> list = logininforService.selectLogininforList(logininfor);
-        return getDataTable(list);
+//    @PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
+//    @GetMapping("/list")
+//    public TableDataInfo list(SysLoginInfo logininfor) {
+//        startPage();
+//        List<SysLoginInfo> list = logininforService.selectLogininforList(logininfor);
+//        return getDataTable(list);
+//    }
+
+    /**
+     * 获取登录日志分页列表
+     *
+     * @param sysLoginInfoVo
+     * @return
+     */
+    @ApiOperation(value = "获取登录日志分页列表")
+    @PostMapping("/list")
+    public AjaxResult list(@RequestBody SysLoginInfoVo sysLoginInfoVo) {
+        LambdaQueryWrapper<SysLoginInfo> wrapper = new LambdaQueryWrapper<SysLoginInfo>();
+        if (!ObjectUtils.isEmpty(sysLoginInfoVo.getIpaddr())) {
+            wrapper.like(SysLoginInfo::getIpaddr, sysLoginInfoVo.getIpaddr());
+        }
+        if (!ObjectUtils.isEmpty(sysLoginInfoVo.getUserName())) {
+            wrapper.like(SysLoginInfo::getUserName, sysLoginInfoVo.getUserName());
+        }
+        if (!ObjectUtils.isEmpty(sysLoginInfoVo.getStatus())) {
+            wrapper.like(SysLoginInfo::getStatus, sysLoginInfoVo.getStatus());
+        }
+        if (!ObjectUtils.isEmpty(sysLoginInfoVo.getLoginTime())) {
+            wrapper.like(SysLoginInfo::getLoginTime, sysLoginInfoVo.getLoginTime());
+        }
+        IPage<SysLoginInfo> page = logininforService.page(new Page<>(sysLoginInfoVo.getPageNum(), sysLoginInfoVo.getPageSize()), wrapper);
+        return AjaxResult.success(page);
+    }
+
+    @ApiOperation(value = "获取登录日志详细")
+    @PreAuthorize("@ss.hasPermi('monitor:logininfor:detail')")
+    @PostMapping("/detail")
+    public AjaxResult remove(Long infoId) {
+        SysLoginInfo info = logininforService.selectLoginLogById(infoId);
+        return AjaxResult.success(info);
     }
 
     @Log(title = "登录日志", businessType = BusinessType.EXPORT)

+ 53 - 16
hazard-admin/src/main/java/com/ozs/web/controller/monitor/SysOperlogController.java

@@ -2,14 +2,18 @@ package com.ozs.web.controller.monitor;
 
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ozs.common.core.domain.vo.SysLoginInfoVo;
+import com.ozs.common.core.domain.vo.SysOperlogVo;
+import com.ozs.system.domain.SysLoginInfo;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.util.ObjectUtils;
+import org.springframework.web.bind.annotation.*;
 import com.ozs.common.annotation.Log;
 import com.ozs.common.core.controller.BaseController;
 import com.ozs.common.core.domain.AjaxResult;
@@ -26,25 +30,58 @@ import com.ozs.system.service.ISysOperLogService;
  */
 @RestController
 @RequestMapping("/monitor/operlog")
-public class SysOperlogController extends BaseController
-{
+public class SysOperlogController extends BaseController {
     @Autowired
     private ISysOperLogService operLogService;
 
+//    @PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
+//    @GetMapping("/list")
+//    public TableDataInfo list(SysOperLog operLog)
+//    {
+//        startPage();
+//        List<SysOperLog> list = operLogService.selectOperLogList(operLog);
+//        return getDataTable(list);
+//    }
+
+    /**
+     * 获取操作日志分页列表
+     *
+     * @param sysOperlogVo
+     * @return
+     */
     @PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
-    @GetMapping("/list")
-    public TableDataInfo list(SysOperLog operLog)
-    {
-        startPage();
-        List<SysOperLog> list = operLogService.selectOperLogList(operLog);
-        return getDataTable(list);
+    @ApiOperation(value = "获取操作日志分页列表")
+    @PostMapping("/list")
+    public AjaxResult list(@RequestBody SysOperlogVo sysOperlogVo) {
+        LambdaQueryWrapper<SysOperLog> wrapper = new LambdaQueryWrapper<SysOperLog>();
+        if (!ObjectUtils.isEmpty(sysOperlogVo.getOperId())) {
+            wrapper.like(SysOperLog::getOperId, sysOperlogVo.getOperId());
+        }
+        if (!ObjectUtils.isEmpty(sysOperlogVo.getUserId())) {
+            wrapper.like(SysOperLog::getUserId, sysOperlogVo.getUserId());
+        }
+        if (!ObjectUtils.isEmpty(sysOperlogVo.getOperatorType())) {
+            wrapper.like(SysOperLog::getOperatorType, sysOperlogVo.getOperatorType());
+        }
+        if (!ObjectUtils.isEmpty(sysOperlogVo.getOperTime())) {
+            wrapper.like(SysOperLog::getOperTime, sysOperlogVo.getOperTime());
+        }
+        IPage<SysOperLog> page = operLogService.page(new Page<>(sysOperlogVo.getPageNum(), sysOperlogVo.getPageSize()), wrapper);
+        return AjaxResult.success(page);
+    }
+
+    @ApiOperation(value = "获取操作日志详细")
+    @PostMapping("/detail")
+    @PreAuthorize("@ss.hasPermi('monitor:operlog:detail')")
+    public AjaxResult detail(Long operId) {
+        SysOperLog sysOperLog = operLogService.selectOperLogById(operId);
+        return AjaxResult.success(sysOperLog);
     }
 
     @Log(title = "操作日志", businessType = BusinessType.EXPORT)
     @PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
     @PostMapping("/export")
-    public void export(HttpServletResponse response, SysOperLog operLog)
-    {
+    public void export(HttpServletResponse response, SysOperLog operLog) {
         List<SysOperLog> list = operLogService.selectOperLogList(operLog);
         ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
         util.exportExcel(response, list, "操作日志");

+ 4 - 4
hazard-admin/src/main/java/com/ozs/web/controller/system/SysUserController.java

@@ -183,8 +183,8 @@ public class SysUserController extends BaseController {
     @PostMapping("/add")
     public AjaxResult add(@Validated @RequestBody SysUser user) {
         boolean matches = user.getPassword().matches(PW_PATTERN);
-        if (!matches){
-            return  error("您的密码太简单!需要包含大小英文、数字、特殊字符、并且长度8-20");
+        if (!matches) {
+            return error("您的密码太简单!需要包含大小英文、数字、特殊字符、并且长度8-20");
         }
         if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user))) {
             return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
@@ -205,8 +205,8 @@ public class SysUserController extends BaseController {
     @RequestMapping(value ="/edit",method = RequestMethod.PUT)
     public AjaxResult edit(@Validated @RequestBody SysUser user) {
         boolean matches = user.getPassword().matches(PW_PATTERN);
-        if (!matches){
-            return  error("您的密码太简单!需要包含大小英文、数字、特殊字符、并且长度8-20");
+        if (!matches) {
+            return error("您的密码太简单!需要包含大小英文、数字、特殊字符、并且长度8-20");
         }
         userService.checkUserAllowed(user);
         userService.checkUserDataScope(user.getId());

+ 6 - 4
hazard-admin/src/main/java/com/ozs/web/controller/websocket/WebSocketConteoller.java

@@ -63,7 +63,8 @@ public class WebSocketConteoller extends BaseController {
         msgAlarmResp.setAlarmMile(mile);
         String cameraCode = baseCameraManagement.getCameraCode();
         String cameraName = baseRailwayManagementService.getCameraNameByCameraCode(cameraCode);
-        msgAlarmResp.setRailwayName(cameraName);
+        msgAlarmResp.setRailwayName(cameraName != null ? cameraName : "");
+        msgAlarmResp.setLineDirStr(baseCameraManagement.getLineDir() == 1 ? "上行" : "下行");
         // 推送消息reqMsgAlarmVo
         webSocketServer.sendMoreMessage(list, objStr(msgAlarmResp));
 
@@ -77,8 +78,8 @@ public class WebSocketConteoller extends BaseController {
         String formatDate = sdf.format(alarmTime != null ? alarmTime : new Date());
         JPushUtil.sendToRegistrationId(
                 alias,
-                "报警通知!", cameraName,
-                formatDate + "     " + (msgAlarmResp.getAlarmType() == 1 ? "泥石流" : msgAlarmResp.getAlarmType()) + "     " + mile + "     " + endMile,
+                "报警通知!", cameraName != null ? cameraName : "",
+                formatDate + "     " + (msgAlarmResp.getAlarmType() == 1 ? "泥石流" : msgAlarmResp.getAlarmType())+ "     " + (baseCameraManagement.getLineDir() == 1 ? "上行" : "下行") + "     " + mile + "     " + endMile,
                 "");
         HashMap<String, Object> map = new HashMap<>();
         map.put("code", 200);
@@ -87,7 +88,8 @@ public class WebSocketConteoller extends BaseController {
 
     private String objStr(MsgAlarmResp msgAlarmResp) {
         JSONObject obj = new JSONObject();
-        obj.put("pipelineId", msgAlarmResp); //流水线ID
+        obj.put("data", msgAlarmResp); //data
+        obj.put("code", 110); //code
         log.info("【websocket消息】 单点消息:" + obj.toJSONString());
         return obj.toJSONString();
     }