diff --git a/src/main/java/com/biutag/supervision/controller/work/AlarmNotificationController.java b/src/main/java/com/biutag/supervision/controller/work/AlarmNotificationController.java index 90a73e8..45d2f3d 100644 --- a/src/main/java/com/biutag/supervision/controller/work/AlarmNotificationController.java +++ b/src/main/java/com/biutag/supervision/controller/work/AlarmNotificationController.java @@ -3,6 +3,7 @@ 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.enums.NotificationType; import com.biutag.supervision.pojo.param.AlarmParam; import com.biutag.supervision.service.AlarmNotificationService; import com.biutag.supervision.service.ProblemSourceService; @@ -14,6 +15,10 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.time.LocalDateTime; +import java.util.Objects; +import java.util.Optional; + /** * @author kami on 2024-11-16 11:30:34 * @version 0.0.1 @@ -40,7 +45,7 @@ public class AlarmNotificationController { /** * 回复内容 * @param data 数据 - * @return 响应 + * @return 是否成功 */ @PostMapping("/reply") public Result alarmNotificationReply(@RequestBody AlarmNotification data) { @@ -52,6 +57,34 @@ public class AlarmNotificationController { notification.setReplyResultContent(data.getReplyResultContent()); notification.setReplyState(1); boolean res = notificationService.updateById(notification); + if(!res) { + return Result.failed(5000, "回复失败"); + } + return Result.success(); + } + + /** + * 新增提醒内容 + * @param data 提交数据 + * @return 是否成功 + */ + @PostMapping("/commit") + public Result alarmNotificationCommit(@RequestBody AlarmNotification data) { + if(Objects.isNull(data.getAlarmTypeId())) { + return Result.failed(5000, "请选择提醒类型"); + } + if(Objects.isNull(data.getNotificationDepartCode())) { + return Result.failed(5000, "请选择要提醒单位"); + } + if(Objects.isNull(data.getAlarmContent())) { + return Result.failed(5000, "请填写要提醒内容"); + } + String alarmType = Optional.ofNullable(NotificationType.contains(data.getAlarmTypeId())) + .orElseThrow(() -> new RuntimeException("未知提醒类型")); + data.setAlarmTime(LocalDateTime.now()); + data.setAlarmType(alarmType); + data.setReplyState(0); + boolean res = notificationService.save(data); if(!res) { return Result.failed(5000, "修改失败"); } diff --git a/src/main/java/com/biutag/supervision/pojo/entity/AlarmNotification.java b/src/main/java/com/biutag/supervision/pojo/entity/AlarmNotification.java index 25f7611..8d4ddc6 100644 --- a/src/main/java/com/biutag/supervision/pojo/entity/AlarmNotification.java +++ b/src/main/java/com/biutag/supervision/pojo/entity/AlarmNotification.java @@ -28,7 +28,7 @@ public class AlarmNotification implements Serializable { * 主键 */ @TableId(value = "id", type = IdType.AUTO) - private String id; + private Integer id; /** * 预警时间 @@ -74,6 +74,23 @@ public class AlarmNotification implements Serializable { */ @TableField("`reply_result_content`") String replyResultContent; + /** + * 线索id + */ + @TableField("`clue_id`") + Integer clueId; + /** + * 民警证件号 + */ + String policeIdCode; + /** + * 民警姓名 + */ + String policeName; + /** + * 警号 + */ + String policeNo; /** * 创建时间 diff --git a/src/main/java/com/biutag/supervision/pojo/enums/NotificationType.java b/src/main/java/com/biutag/supervision/pojo/enums/NotificationType.java new file mode 100644 index 0000000..a645cbf --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/enums/NotificationType.java @@ -0,0 +1,36 @@ +package com.biutag.supervision.pojo.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; + +/** + * @author kami on 2024-06-19 13:52:23 + * @version 0.0.1 + * @since 1.8 + */ +@AllArgsConstructor +@Getter +@Slf4j +public enum NotificationType { + + ALARM( 1l, "预警问题"), + RISK( 2l, "风险问题"), + NOTIFICATION( 3l, "提醒通知"); + + private final Long id; + + private final String desc; + + + + public static String contains(long id) { + for (NotificationType enums : values()) { + if (id == enums.getId()) { + return enums.getDesc(); + } + } + log.info("未找到该类型:{}", id); + return null; + } +}