diff --git a/inventory-dao/src/main/java/com/rzyc/bean/task/dto/UserWarningDto.java b/inventory-dao/src/main/java/com/rzyc/bean/task/dto/UserWarningDto.java
new file mode 100644
index 0000000..95e8f73
--- /dev/null
+++ b/inventory-dao/src/main/java/com/rzyc/bean/task/dto/UserWarningDto.java
@@ -0,0 +1,74 @@
+package com.rzyc.bean.task.dto;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author dong
+ * @date 2023-02-08 14:53
+ * @Version V1.0
+ */
+@ApiModel("用户预警")
+public class UserWarningDto {
+
+ @NotNull(message = "用户不能为空")
+ @ApiModelProperty(value = "用户id",required = true)
+ private String userId;
+
+ @ApiModelProperty(value = "预警类型")
+ private String typeId;
+
+ @ApiModelProperty(value = "是否处理 1、未处理 2、已处理")
+ private Integer state;
+
+ @NotNull(message = "页码不能为空")
+ @ApiModelProperty(value = "页码",required = true,example = "1")
+ private Integer page;//当前页
+
+ @NotNull(message = "每页条数不能为空")
+ @ApiModelProperty(value = "每页条数",required = true,example = "10")
+ private Integer pageSize;//每页显示多少条
+
+ public String getTypeId() {
+ return typeId;
+ }
+
+ public void setTypeId(String typeId) {
+ this.typeId = typeId;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public Integer getState() {
+ return state;
+ }
+
+ public void setState(Integer state) {
+ this.state = state;
+ }
+
+ public Integer getPage() {
+ return page;
+ }
+
+ public void setPage(Integer page) {
+ this.page = page;
+ }
+
+ public Integer getPageSize() {
+ return pageSize;
+ }
+
+ public void setPageSize(Integer pageSize) {
+ this.pageSize = pageSize;
+ }
+}
diff --git a/inventory-dao/src/main/java/com/rzyc/mapper/SysWarningMapper.java b/inventory-dao/src/main/java/com/rzyc/mapper/SysWarningMapper.java
index aab7a7c..fe90ff6 100644
--- a/inventory-dao/src/main/java/com/rzyc/mapper/SysWarningMapper.java
+++ b/inventory-dao/src/main/java/com/rzyc/mapper/SysWarningMapper.java
@@ -2,15 +2,17 @@ package com.rzyc.mapper;
import com.rzyc.model.SysWarning;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springframework.stereotype.Repository;
/**
*
* 智能预警 Mapper 接口
*
*
- * @author
+ * @author
* @since 2023-01-09
*/
+@Repository
public interface SysWarningMapper extends BaseMapper {
}
diff --git a/inventory-dao/src/main/java/com/rzyc/mapper/SysWarningTypeMapper.java b/inventory-dao/src/main/java/com/rzyc/mapper/SysWarningTypeMapper.java
index 386b220..d1c4840 100644
--- a/inventory-dao/src/main/java/com/rzyc/mapper/SysWarningTypeMapper.java
+++ b/inventory-dao/src/main/java/com/rzyc/mapper/SysWarningTypeMapper.java
@@ -2,15 +2,27 @@ package com.rzyc.mapper;
import com.rzyc.model.SysWarningType;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+import org.springframework.web.bind.annotation.PostMapping;
+
+import java.util.List;
/**
*
* 预警类型 Mapper 接口
*
*
- * @author
+ * @author
* @since 2023-01-09
*/
+@Repository
public interface SysWarningTypeMapper extends BaseMapper {
+ /*查询所有*/
+ List findAll();
+
+ /**/
+ List userWarningNum(@Param("userId") String userId);
+
}
diff --git a/inventory-dao/src/main/java/com/rzyc/mapper/SysWarningUserMapper.java b/inventory-dao/src/main/java/com/rzyc/mapper/SysWarningUserMapper.java
index 919064b..f799b65 100644
--- a/inventory-dao/src/main/java/com/rzyc/mapper/SysWarningUserMapper.java
+++ b/inventory-dao/src/main/java/com/rzyc/mapper/SysWarningUserMapper.java
@@ -2,15 +2,28 @@ package com.rzyc.mapper;
import com.rzyc.model.SysWarningUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
/**
*
* 预警接收用户 Mapper 接口
*
*
- * @author
+ * @author
* @since 2023-01-09
*/
+@Repository
public interface SysWarningUserMapper extends BaseMapper {
+ /*用户预警列表*/
+ List userWarningList(@Param("userId") String userId,
+ @Param("state") Integer state,
+ @Param("typeId") String typeId);
+
+ /*修改预警状态为已读*/
+ Integer changeState(@Param("warningUserId") String warningUserId);
+
}
diff --git a/inventory-dao/src/main/java/com/rzyc/model/SysWarning.java b/inventory-dao/src/main/java/com/rzyc/model/SysWarning.java
index ac6afce..168d200 100644
--- a/inventory-dao/src/main/java/com/rzyc/model/SysWarning.java
+++ b/inventory-dao/src/main/java/com/rzyc/model/SysWarning.java
@@ -40,7 +40,7 @@ public class SysWarning implements Serializable {
@ApiModelProperty(value = "预警类型id")
@TableField("type_id")
- private Integer typeId;
+ private String typeId;
@ApiModelProperty(value = "删除状态 1:正常 2:已删除")
@TableField("del_state")
@@ -62,11 +62,11 @@ public class SysWarning implements Serializable {
@TableField("modify_by")
private String modifyBy;
- public Integer getTypeId() {
+ public String getTypeId() {
return typeId;
}
- public void setTypeId(Integer typeId) {
+ public void setTypeId(String typeId) {
this.typeId = typeId;
}
diff --git a/inventory-dao/src/main/java/com/rzyc/model/SysWarningType.java b/inventory-dao/src/main/java/com/rzyc/model/SysWarningType.java
index 5c98d6e..4ae46b8 100644
--- a/inventory-dao/src/main/java/com/rzyc/model/SysWarningType.java
+++ b/inventory-dao/src/main/java/com/rzyc/model/SysWarningType.java
@@ -13,7 +13,7 @@ import io.swagger.annotations.ApiModelProperty;
* 预警类型
*
*
- * @author
+ * @author
* @since 2023-01-09
*/
@TableName("sys_warning_type")
@@ -54,6 +54,18 @@ public class SysWarningType implements Serializable {
@TableField("modify_by")
private String modifyBy;
+ @TableField(exist = false)
+ @ApiModelProperty(value = "预警数量")
+ private Integer warningNum;
+
+ public Integer getWarningNum() {
+ return warningNum;
+ }
+
+ public void setWarningNum(Integer warningNum) {
+ this.warningNum = warningNum;
+ }
+
public String getTypeId() {
return typeId;
}
diff --git a/inventory-dao/src/main/java/com/rzyc/model/SysWarningUser.java b/inventory-dao/src/main/java/com/rzyc/model/SysWarningUser.java
index a50ace0..6d13643 100644
--- a/inventory-dao/src/main/java/com/rzyc/model/SysWarningUser.java
+++ b/inventory-dao/src/main/java/com/rzyc/model/SysWarningUser.java
@@ -5,6 +5,8 @@ import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -66,6 +68,51 @@ public class SysWarningUser implements Serializable {
@TableField("modify_by")
private String modifyBy;
+ @TableField(exist = false)
+ @ApiModelProperty(value = "预警类型名")
+ private String typeName;
+
+ @TableField(exist = false)
+ @ApiModelProperty(value = "预警内容")
+ private String warningInfo;
+
+ @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+ @TableField(exist = false)
+ @ApiModelProperty(value = "预警时间")
+ private Date warningTime;
+
+ public String getTypeName() {
+ return typeName;
+ }
+
+ public void setTypeName(String typeName) {
+ this.typeName = typeName;
+ }
+
+ public String getWarningInfo() {
+ return warningInfo;
+ }
+
+ public void setWarningInfo(String warningInfo) {
+ this.warningInfo = warningInfo;
+ }
+
+ public Date getWarningTime() {
+ return warningTime;
+ }
+
+ public void setWarningTime(Date warningTime) {
+ this.warningTime = warningTime;
+ }
+
+ public String getTypeId() {
+ return typeId;
+ }
+
+ public void setTypeId(String typeId) {
+ this.typeId = typeId;
+ }
+
public String getWarningUserId() {
return warningUserId;
}
diff --git a/inventory-dao/src/main/resources/mapper/SysWarningTypeMapper.xml b/inventory-dao/src/main/resources/mapper/SysWarningTypeMapper.xml
index bea5b96..c866d95 100644
--- a/inventory-dao/src/main/resources/mapper/SysWarningTypeMapper.xml
+++ b/inventory-dao/src/main/resources/mapper/SysWarningTypeMapper.xml
@@ -19,4 +19,38 @@
type_id, name, sort_id, del_state, create_time, create_by, modify_time, modify_by
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/inventory-dao/src/main/resources/mapper/SysWarningUserMapper.xml b/inventory-dao/src/main/resources/mapper/SysWarningUserMapper.xml
index c8b42b4..3d895da 100644
--- a/inventory-dao/src/main/resources/mapper/SysWarningUserMapper.xml
+++ b/inventory-dao/src/main/resources/mapper/SysWarningUserMapper.xml
@@ -22,4 +22,44 @@
warning_user_id, warning_id, user_id, type_id,state, handle_time, del_state, create_time, create_by, modify_time, modify_by
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ update sys_warning_user set state = 2 where warning_user_id = #{warningUserId}
+
+
diff --git a/inventory-gov/src/main/java/com/rzyc/controller/BaseController.java b/inventory-gov/src/main/java/com/rzyc/controller/BaseController.java
index 60caa62..78da96e 100644
--- a/inventory-gov/src/main/java/com/rzyc/controller/BaseController.java
+++ b/inventory-gov/src/main/java/com/rzyc/controller/BaseController.java
@@ -507,6 +507,18 @@ public class BaseController {
@Autowired
protected EntPostTaskMapper entPostTaskMapper;
+ //智能预警类型
+ @Autowired
+ protected SysWarningTypeMapper sysWarningTypeMapper;
+
+ //智能预警类型
+ @Autowired
+ protected SysWarningMapper sysWarningMapper;
+
+ //智能预警类型
+ @Autowired
+ protected SysWarningUserMapper sysWarningUserMapper;
+
/**
* 岗位不需要的字符串
diff --git a/inventory-gov/src/main/java/com/rzyc/controller/TaskController.java b/inventory-gov/src/main/java/com/rzyc/controller/TaskController.java
index 455ced4..cd5af48 100644
--- a/inventory-gov/src/main/java/com/rzyc/controller/TaskController.java
+++ b/inventory-gov/src/main/java/com/rzyc/controller/TaskController.java
@@ -3,16 +3,21 @@ package com.rzyc.controller;
import com.common.utils.RandomNumber;
import com.common.utils.StringUtils;
import com.common.utils.model.MultiResult;
+import com.common.utils.model.Pager;
import com.common.utils.model.SingleResult;
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageHelper;
+import com.rzyc.bean.UserDepart;
import com.rzyc.bean.task.dto.AddTaskDto;
import com.rzyc.bean.task.dto.IdDto;
+import com.rzyc.bean.task.dto.UserWarningDto;
import com.rzyc.bean.task.vo.TaskDetailVo;
import com.rzyc.bean.task.vo.TaskNameVo;
import com.rzyc.bean.task.vo.TaskVo;
import com.rzyc.bean.task.vo.ThingVo;
-import com.rzyc.model.OADistribution;
-import com.rzyc.model.OATask;
-import com.rzyc.model.OaTaskType;
+import com.rzyc.enums.DelState;
+import com.rzyc.mapper.SysWarningTypeMapper;
+import com.rzyc.model.*;
import com.rzyc.model.task.dto.TaskAddOrUpdateDto;
import com.rzyc.model.user.SysUser;
import io.swagger.annotations.Api;
@@ -183,8 +188,115 @@ public class TaskController extends BaseController{
return result;
}
- public MultiResult wType()throws Exception{
- MultiResult result = new MultiResult<>();
+
+ /**
+ * 智能预警类型列表
+ * @version v1.0
+ * @author dong
+ * @date 2023/2/8 10:02
+ */
+ @ApiOperation(value = "智能预警类型列表")
+ @GetMapping("warningTypeList")
+ public MultiResult warningTypeList()throws Exception{
+ MultiResult result = new MultiResult<>();
+ List warningTypes = sysWarningTypeMapper.findAll();
+ result.setData(warningTypes);
+// addWarning();
return result;
}
+
+ public void addWarning()throws Exception{
+
+ String uesrId = "8D35010B-EB9A-40EE-BDEB-CDAE969D5EF4";
+
+ SysWarning sysWarning = new SysWarning();
+ sysWarning.setWarningId(RandomNumber.getUUid());
+ sysWarning.setSendId(uesrId);
+ sysWarning.setWarningInfo("企业重大隐患预警");
+ sysWarning.setWarningTime(new Date());
+ sysWarning.setTypeId("110cfd4e-a754-11ed-b840-00163e0c1c62");
+ sysWarning.setDelState(DelState.NOT_DEL.getState());
+ sysWarning.setCreateBy(uesrId);
+ sysWarning.setModifyBy(uesrId);
+ sysWarning.setCreateTime(new Date());
+ sysWarning.setModifyTime(new Date());
+ sysWarningMapper.insert(sysWarning);
+
+ SysWarningUser warningUser = new SysWarningUser();
+ warningUser.setWarningUserId(RandomNumber.getUUid());
+ warningUser.setWarningId(sysWarning.getWarningId());
+ warningUser.setTypeId("110cfd4e-a754-11ed-b840-00163e0c1c62");
+ warningUser.setUserId(uesrId);
+ warningUser.setState(1);
+ warningUser.setDelState(DelState.NOT_DEL.getState());
+ warningUser.setCreateBy(uesrId);
+ warningUser.setModifyBy(uesrId);
+ warningUser.setCreateTime(new Date());
+ warningUser.setModifyTime(new Date());
+ sysWarningUserMapper.insert(warningUser);
+
+ warningUser = new SysWarningUser();
+ warningUser.setWarningUserId(RandomNumber.getUUid());
+ warningUser.setWarningId(sysWarning.getWarningId());
+ warningUser.setTypeId("110cfd4e-a754-11ed-b840-00163e0c1c62");
+ warningUser.setUserId("879a81b3-2379-4ad7-bab8-0ea51dcecf9e");
+ warningUser.setState(1);
+ warningUser.setDelState(DelState.NOT_DEL.getState());
+ warningUser.setCreateBy(uesrId);
+ warningUser.setModifyBy(uesrId);
+ warningUser.setCreateTime(new Date());
+ warningUser.setModifyTime(new Date());
+ sysWarningUserMapper.insert(warningUser);
+
+ }
+
+ /**
+ * 用户智能预警数量
+ * @version v1.0
+ * @author dong
+ * @date 2023/2/8 14:30
+ */
+ @ApiOperation(value = "用户智能预警数量")
+ @ApiImplicitParam(name = "userId",value = "用户id")
+ @GetMapping("userWarningNum/{userId}")
+ public MultiResult userWarningNum(@PathVariable String userId)throws Exception{
+ MultiResult result = new MultiResult<>();
+ List warningTypes = sysWarningTypeMapper.userWarningNum(userId);
+ result.setData(warningTypes);
+ return result;
+ }
+
+ /**
+ * 用户智能预警分页
+ * @version v1.0
+ * @author dong
+ * @date 2023/2/8 14:43
+ */
+ @ApiOperation(value = "用户智能预警分页")
+ @GetMapping("userWarningPage")
+ public SingleResult> userWarningPage(@Valid UserWarningDto userWarningDto)throws Exception{
+ SingleResult> result = new SingleResult<>();
+ PageHelper.startPage(userWarningDto.getPage(), userWarningDto.getPageSize());
+ Page page = (Page)sysWarningUserMapper.userWarningList(userWarningDto.getUserId(),userWarningDto.getState(),userWarningDto.getTypeId());
+ Pager pager = new Pager<>();
+ getDatePage(pager,page);
+ result.setData(pager);
+ return result;
+ }
+
+ /**
+ * 用户智能预警已读
+ * @version v1.0
+ * @author dong
+ * @date 2023/2/8 15:35
+ */
+ @ApiOperation(value = "用户智能预警已读")
+ @ApiImplicitParam(name = "warningUserId",value = "预警接收用户id")
+ @PostMapping("userWarningRead/{warningUserId}")
+ public SingleResult userWarningRead(@PathVariable String warningUserId)throws Exception{
+ SingleResult result = new SingleResult<>();
+ sysWarningUserMapper.changeState(warningUserId);
+ return result;
+ }
+
}