智能预警相关接口
This commit is contained in:
parent
04d332caec
commit
a9892e3373
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 智能预警 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author
|
||||
* @author
|
||||
* @since 2023-01-09
|
||||
*/
|
||||
@Repository
|
||||
public interface SysWarningMapper extends BaseMapper<SysWarning> {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 预警类型 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author
|
||||
* @author
|
||||
* @since 2023-01-09
|
||||
*/
|
||||
@Repository
|
||||
public interface SysWarningTypeMapper extends BaseMapper<SysWarningType> {
|
||||
|
||||
/*查询所有*/
|
||||
List<SysWarningType> findAll();
|
||||
|
||||
/**/
|
||||
List<SysWarningType> userWarningNum(@Param("userId") String userId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 预警接收用户 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author
|
||||
* @author
|
||||
* @since 2023-01-09
|
||||
*/
|
||||
@Repository
|
||||
public interface SysWarningUserMapper extends BaseMapper<SysWarningUser> {
|
||||
|
||||
/*用户预警列表*/
|
||||
List<SysWarningUser> userWarningList(@Param("userId") String userId,
|
||||
@Param("state") Integer state,
|
||||
@Param("typeId") String typeId);
|
||||
|
||||
/*修改预警状态为已读*/
|
||||
Integer changeState(@Param("warningUserId") String warningUserId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import io.swagger.annotations.ApiModelProperty;
|
|||
* 预警类型
|
||||
* </p>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,4 +19,38 @@
|
|||
type_id, name, sort_id, del_state, create_time, create_by, modify_time, modify_by
|
||||
</sql>
|
||||
|
||||
<!--查询所有智能预警-->
|
||||
<select id="findAll" resultMap="BaseResultMap">
|
||||
SELECT wt.* FROM `sys_warning_type` wt
|
||||
ORDER BY wt.`sort_id` ASC;
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 用户智能预警数量 -->
|
||||
<resultMap id="UserWarningResultMap" type="com.rzyc.model.SysWarningType">
|
||||
<id column="type_id" property="typeId" />
|
||||
<result column="name" property="name" />
|
||||
<result column="sort_id" property="sortId" />
|
||||
<result column="del_state" property="delState" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="create_by" property="createBy" />
|
||||
<result column="modify_time" property="modifyTime" />
|
||||
<result column="modify_by" property="modifyBy" />
|
||||
</resultMap>
|
||||
|
||||
<!--用户智能预警数量-->
|
||||
<select id="userWarningNum" resultMap="UserWarningResultMap">
|
||||
SELECT wt.* ,
|
||||
(
|
||||
SELECT COUNT(*) FROM `sys_warning_user` wu
|
||||
WHERE wu.type_id = wt.`type_id`
|
||||
AND wu.del_state = 1
|
||||
AND wu.state = 1
|
||||
AND wu.user_id =#{userId}
|
||||
) warningNum
|
||||
FROM `sys_warning_type` wt
|
||||
WHERE wt.`del_state` = 1
|
||||
ORDER BY wt.`sort_id` ASC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
</sql>
|
||||
|
||||
|
||||
<!-- 用户预警列表 -->
|
||||
<resultMap id="UserWarningResultMap" type="com.rzyc.model.SysWarningUser">
|
||||
<id column="warning_user_id" property="warningUserId" />
|
||||
<result column="warning_id" property="warningId" />
|
||||
<result column="user_id" property="userId" />
|
||||
<result column="type_id" property="typeId" />
|
||||
<result column="state" property="state" />
|
||||
<result column="handle_time" property="handleTime" />
|
||||
<result column="del_state" property="delState" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="create_by" property="createBy" />
|
||||
<result column="modify_time" property="modifyTime" />
|
||||
<result column="modify_by" property="modifyBy" />
|
||||
<result column="typeName" property="typeName" />
|
||||
<result column="warning_info" property="warningInfo" />
|
||||
<result column="warning_time" property="warningTime" />
|
||||
</resultMap>
|
||||
|
||||
<!--用户预警列表-->
|
||||
<select id="userWarningList" resultMap="UserWarningResultMap">
|
||||
SELECT wt.`name` typeName,sw.`warning_info`,sw.`warning_time`, wu.*
|
||||
FROM `sys_warning_user` wu
|
||||
LEFT JOIN `sys_warning` sw ON wu.`warning_id` = sw.`warning_id`
|
||||
LEFT JOIN `sys_warning_type` wt ON wu.`type_id` = wt.`type_id`
|
||||
WHERE wu.user_id = #{userId}
|
||||
<if test="null != state">
|
||||
AND wu.`state` = #{state}
|
||||
</if>
|
||||
<if test="null != typeId and '' != typeId">
|
||||
AND wu.`type_id` = #{typeId}
|
||||
</if>
|
||||
ORDER BY sw.`warning_time` DESC
|
||||
</select>
|
||||
|
||||
<!--修改预警状态为已读-->
|
||||
<update id="changeState">
|
||||
update sys_warning_user set state = 2 where warning_user_id = #{warningUserId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -507,6 +507,18 @@ public class BaseController {
|
|||
@Autowired
|
||||
protected EntPostTaskMapper entPostTaskMapper;
|
||||
|
||||
//智能预警类型
|
||||
@Autowired
|
||||
protected SysWarningTypeMapper sysWarningTypeMapper;
|
||||
|
||||
//智能预警类型
|
||||
@Autowired
|
||||
protected SysWarningMapper sysWarningMapper;
|
||||
|
||||
//智能预警类型
|
||||
@Autowired
|
||||
protected SysWarningUserMapper sysWarningUserMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 岗位不需要的字符串
|
||||
|
|
|
|||
|
|
@ -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<String> wType()throws Exception{
|
||||
MultiResult<String> result = new MultiResult<>();
|
||||
|
||||
/**
|
||||
* 智能预警类型列表
|
||||
* @version v1.0
|
||||
* @author dong
|
||||
* @date 2023/2/8 10:02
|
||||
*/
|
||||
@ApiOperation(value = "智能预警类型列表")
|
||||
@GetMapping("warningTypeList")
|
||||
public MultiResult<SysWarningType> warningTypeList()throws Exception{
|
||||
MultiResult<SysWarningType> result = new MultiResult<>();
|
||||
List<SysWarningType> 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<SysWarningType> userWarningNum(@PathVariable String userId)throws Exception{
|
||||
MultiResult<SysWarningType> result = new MultiResult<>();
|
||||
List<SysWarningType> 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<Pager<SysWarningUser>> userWarningPage(@Valid UserWarningDto userWarningDto)throws Exception{
|
||||
SingleResult<Pager<SysWarningUser>> result = new SingleResult<>();
|
||||
PageHelper.startPage(userWarningDto.getPage(), userWarningDto.getPageSize());
|
||||
Page<SysWarningUser> page = (Page<SysWarningUser>)sysWarningUserMapper.userWarningList(userWarningDto.getUserId(),userWarningDto.getState(),userWarningDto.getTypeId());
|
||||
Pager<SysWarningUser> 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<String> userWarningRead(@PathVariable String warningUserId)throws Exception{
|
||||
SingleResult<String> result = new SingleResult<>();
|
||||
sysWarningUserMapper.changeState(warningUserId);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user