From a3a19f8a7f2d3e3f5c1db1be04cc03fa98bb005f Mon Sep 17 00:00:00 2001 From: kami <605128600@qq.com> Date: Sat, 16 Nov 2024 14:25:12 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E8=AD=A6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 17 ++- .../work/AlarmNotificationController.java | 58 ++++++++ .../mapper/AlarmNotificationMapper.java | 14 ++ .../pojo/entity/AlarmNotification.java | 131 ++++++++++++++++++ .../supervision/pojo/param/AlarmParam.java | 62 +++++++++ .../service/AlarmNotificationService.java | 42 ++++++ src/main/resources/logback-spring.xml | 62 +++++++++ .../mapper/AlarmNotificationMapper.xml | 7 + 8 files changed, 392 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/biutag/supervision/controller/work/AlarmNotificationController.java create mode 100644 src/main/java/com/biutag/supervision/mapper/AlarmNotificationMapper.java create mode 100644 src/main/java/com/biutag/supervision/pojo/entity/AlarmNotification.java create mode 100644 src/main/java/com/biutag/supervision/pojo/param/AlarmParam.java create mode 100644 src/main/java/com/biutag/supervision/service/AlarmNotificationService.java create mode 100644 src/main/resources/logback-spring.xml create mode 100644 src/main/resources/mapper/AlarmNotificationMapper.xml diff --git a/pom.xml b/pom.xml index 63c17e0..2631f6a 100644 --- a/pom.xml +++ b/pom.xml @@ -166,6 +166,11 @@ DmJdbcDriver18 8.1.3.140 + + net.logstash.logback + logstash-logback-encoder + 4.9 + @@ -183,7 +188,17 @@ true + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.2.5 + + true + + org.springframework.boot spring-boot-maven-plugin @@ -230,4 +245,4 @@ - \ No newline at end of file + diff --git a/src/main/java/com/biutag/supervision/controller/work/AlarmNotificationController.java b/src/main/java/com/biutag/supervision/controller/work/AlarmNotificationController.java new file mode 100644 index 0000000..71a2f3b --- /dev/null +++ b/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> pages(@RequestBody AlarmParam param) { + return Result.success(notificationService.pages(param)); + } + + /** + * 回复内容 + * @param data 数据 + * @return 响应 + */ + @PostMapping("/reply") + public Result 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(); + } +} diff --git a/src/main/java/com/biutag/supervision/mapper/AlarmNotificationMapper.java b/src/main/java/com/biutag/supervision/mapper/AlarmNotificationMapper.java new file mode 100644 index 0000000..dc10a6e --- /dev/null +++ b/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 { +} diff --git a/src/main/java/com/biutag/supervision/pojo/entity/AlarmNotification.java b/src/main/java/com/biutag/supervision/pojo/entity/AlarmNotification.java new file mode 100644 index 0000000..25f7611 --- /dev/null +++ b/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; + +} diff --git a/src/main/java/com/biutag/supervision/pojo/param/AlarmParam.java b/src/main/java/com/biutag/supervision/pojo/param/AlarmParam.java new file mode 100644 index 0000000..d13a17b --- /dev/null +++ b/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; + +} diff --git a/src/main/java/com/biutag/supervision/service/AlarmNotificationService.java b/src/main/java/com/biutag/supervision/service/AlarmNotificationService.java new file mode 100644 index 0000000..60f9493 --- /dev/null +++ b/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 { + + public Page pages(AlarmParam param) { + LambdaQueryWrapper query = new LambdaQueryWrapper(); + 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)); + } +} diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..39b0463 --- /dev/null +++ b/src/main/resources/logback-spring.xml @@ -0,0 +1,62 @@ + + + logs + + + + + + + + + + + + ${log.colorPattern} + UTF-8 + + + + + + + ${log.path}/info/info.%d{yyyy-MM-dd}.log + ${log.maxHistory} + + + ${log.pattern} + + + INFO + ACCEPT + DENY + + + + + + ${log.path}/error/error.%d{yyyy-MM-dd}.log + ${log.maxHistory} + + + ${log.pattern} + + + ERROR + ACCEPT + DENY + + + + + + + + + + + + + + diff --git a/src/main/resources/mapper/AlarmNotificationMapper.xml b/src/main/resources/mapper/AlarmNotificationMapper.xml new file mode 100644 index 0000000..748b212 --- /dev/null +++ b/src/main/resources/mapper/AlarmNotificationMapper.xml @@ -0,0 +1,7 @@ + + + + +