Browse Source

Merge remote-tracking branch 'origin/master'

main
parent
commit
a596cb399d
  1. 17
      pom.xml
  2. 58
      src/main/java/com/biutag/supervision/controller/work/AlarmNotificationController.java
  3. 14
      src/main/java/com/biutag/supervision/mapper/AlarmNotificationMapper.java
  4. 131
      src/main/java/com/biutag/supervision/pojo/entity/AlarmNotification.java
  5. 62
      src/main/java/com/biutag/supervision/pojo/param/AlarmParam.java
  6. 42
      src/main/java/com/biutag/supervision/service/AlarmNotificationService.java
  7. 62
      src/main/resources/logback-spring.xml
  8. 7
      src/main/resources/mapper/AlarmNotificationMapper.xml

17
pom.xml

@ -166,6 +166,11 @@
<artifactId>DmJdbcDriver18</artifactId>
<version>8.1.3.140</version>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>4.9</version>
</dependency>
</dependencies>
@ -183,7 +188,17 @@
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<!--打包跳过测试-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
@ -230,4 +245,4 @@
</profile>
</profiles>
</project>
</project>

58
src/main/java/com/biutag/supervision/controller/work/AlarmNotificationController.java

@ -0,0 +1,58 @@
package com.biutag.supervision.controller.work;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.biutag.supervision.pojo.Result;
import com.biutag.supervision.pojo.entity.AlarmNotification;
import com.biutag.supervision.pojo.param.AlarmParam;
import com.biutag.supervision.service.AlarmNotificationService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author kami on 2024-11-16 11:30:34
* @version 0.0.1
* @since 1.8
*/
@Slf4j
@RestController
@RequestMapping("/alarm/notification")
@AllArgsConstructor
public class AlarmNotificationController {
private final AlarmNotificationService notificationService;
/**
* 预警通知分页查询
* @param param 请求参数
* @return 预警通知分页数据
*/
@PostMapping("/pages")
public Result<Page<AlarmNotification>> pages(@RequestBody AlarmParam param) {
return Result.success(notificationService.pages(param));
}
/**
* 回复内容
* @param data 数据
* @return 响应
*/
@PostMapping("/reply")
public Result<Void> alarmNotificationReply(@RequestBody AlarmNotification data) {
AlarmNotification notification = new AlarmNotification();
if(data.getId() == null) {
return Result.failed(5000, "未找到对用数据");
}
notification.setId(data.getId());
notification.setReplyResultContent(data.getReplyResultContent());
notification.setReplyState(1);
boolean res = notificationService.updateById(notification);
if(!res) {
return Result.failed(5000, "修改失败");
}
return Result.success();
}
}

14
src/main/java/com/biutag/supervision/mapper/AlarmNotificationMapper.java

@ -0,0 +1,14 @@
package com.biutag.supervision.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.supervision.pojo.entity.AlarmNotification;
/**
* @author kami on 2024-11-16 11:05:28
* @version 0.0.1
* @since 1.8
*/
@DS("master")
public interface AlarmNotificationMapper extends BaseMapper<AlarmNotification> {
}

131
src/main/java/com/biutag/supervision/pojo/entity/AlarmNotification.java

@ -0,0 +1,131 @@
package com.biutag.supervision.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 预警通知
* @author kami on 2024-11-16 10:51:18
* @version 0.0.1
* @since 1.8
*/
@Data
@TableName("`alarm_notification`")
public class AlarmNotification implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(value = "id", type = IdType.AUTO)
private String id;
/**
* 预警时间
*/
@TableField("`alarm_time`")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
LocalDateTime alarmTime;
@TableField("`alarm_type_id`")
Long alarmTypeId;
/**
* 预警类型
*/
@TableField("`alarm_type`")
String alarmType;
/**
* 被通知单位机构代码
*/
@TableField("`notification_depart_code`")
String notificationDepartCode;
/**
* 被通知单位机构名称
*/
@TableField("`notification_depart_name`")
String notificationDepartName;
/**
* 通知内容
*/
@TableField("`alarm_content`")
String alarmContent;
/**
* 回复状态0未回复1已回复
*/
@TableField("`reply_state`")
Integer replyState;
/**
* 回复情况内容
*/
@TableField("`reply_result_content`")
String replyResultContent;
/**
* 创建时间
*/
@TableField("`crt_time`")
LocalDateTime crtTime;
/**
* 创建用户
*/
@TableField("`crt_user`")
String crtUser;
/**
* 创建单位
*/
@TableField("`crt_depart_id`")
String crtDepartId;
/**
* 创建人名称
*/
@TableField("`crt_name`")
String crtName;
/**
* 创建ip
*/
@TableField("`crt_host`")
String crtHost;
/**
* 创建用户
*/
@TableField("`upd_user`")
String updUser;
/**
* 创建单位
*/
@TableField("`upd_depart_id`")
String updDepartId;
/**
* 创建人名称
*/
@TableField("`upd_name`")
String updName;
/**
* 创建ip
*/
@TableField("`upd_host`")
String updHost;
/**
* 修改时间
*/
@TableField("`upd_time`")
LocalDateTime updTime;
}

62
src/main/java/com/biutag/supervision/pojo/param/AlarmParam.java

@ -0,0 +1,62 @@
package com.biutag.supervision.pojo.param;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
/**
* @author kami on 2024-11-16 11:12:34
* @version 0.0.1
* @since 1.8
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class AlarmParam extends BasePage implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 预警类型id
*/
Long alarmTypeId;
/**
* 预警开始时间
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
LocalDateTime startTime;
/**
* 预警开始时间
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
LocalDateTime endTime;
/**
* 回复情况0-未回复 1-已回复
*/
Integer replyState;
/**
* 被通知单位机构编码
*/
String notificationDepartCode;
/**
* 回复情况
*/
String alarmContent;
}

42
src/main/java/com/biutag/supervision/service/AlarmNotificationService.java

@ -0,0 +1,42 @@
package com.biutag.supervision.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.supervision.mapper.AlarmNotificationMapper;
import com.biutag.supervision.pojo.entity.AlarmNotification;
import com.biutag.supervision.pojo.entity.BaseUser;
import com.biutag.supervision.pojo.model.UserModel;
import com.biutag.supervision.pojo.param.AlarmParam;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
/**
* @author kami on 2024-11-16 11:07:43
* @version 0.0.1
* @since 1.8
*/
@Service
public class AlarmNotificationService extends ServiceImpl<AlarmNotificationMapper, AlarmNotification> {
public Page<AlarmNotification> pages(AlarmParam param) {
LambdaQueryWrapper<AlarmNotification> query = new LambdaQueryWrapper<AlarmNotification>();
if(param.getAlarmTypeId() != null && param.getAlarmTypeId() != -1) {
query.eq(AlarmNotification::getAlarmTypeId, param.getAlarmTypeId());
}
if(param.getStartTime() != null) {
query.between(AlarmNotification::getAlarmTime, param.getStartTime(), param.getEndTime());
}
if(param.getReplyState() != null && param.getReplyState() != -1) {
query.eq(AlarmNotification::getReplyState, param.getReplyState());
}
if(param.getNotificationDepartCode() != null) {
query.eq(AlarmNotification::getNotificationDepartCode, param.getNotificationDepartCode());
}
if(param.getAlarmContent() != null) {
query.like(AlarmNotification::getAlarmContent, param.getAlarmContent());
}
return page(Page.of(param.getCurrent(), param.getSize()), query.orderByDesc(AlarmNotification::getAlarmTime));
}
}

62
src/main/resources/logback-spring.xml

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<contextName>logs</contextName>
<!-- 日志位置 -->
<property name="log.path" value="/work/log"/>
<!-- 日志保留时长 -->
<property name="log.maxHistory" value="7"/>
<!-- 控制台格式化及颜色 -->
<property name="log.colorPattern"
value="%magenta([%X{trace_id}][%d{yyyy-MM-dd'T'HH:mm:ss.SSS}]) %highlight(%-5level) %red(%thread) %green(%logger) %msg%n"/>
<property name="log.pattern" value="[%X{trace_id}][%d{yyyy-MM-dd'T'HH:mm:ss.SSS}] %-5level %thread %logger %msg%n"/>
<!--输出到控制台-->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.colorPattern}</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!--输出到文件-->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/info/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<MaxHistory>${log.maxHistory}</MaxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/error/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<MaxHistory>${log.maxHistory}</MaxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<logger name="com.biutag.supervision" level="INFO"/>
<!-- 日志类型为debug时,输出到控制台 -->
<root level="debug">
<appender-ref ref="console"/>
</root>
<!-- 日志类型为info时,输出到配置好的文件 -->
<root level="info">
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
</configuration>

7
src/main/resources/mapper/AlarmNotificationMapper.xml

@ -0,0 +1,7 @@
<?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.biutag.supervision.mapper.AlarmNotificationMapper">
</mapper>
Loading…
Cancel
Save