设备手工操作命令接口
This commit is contained in:
parent
292f018bde
commit
3aa7659de4
@ -5,7 +5,7 @@ import com.das.common.constant.MeasType;
|
||||
import com.das.common.constant.SysAuthorityIds;
|
||||
import com.das.common.exceptions.ServiceException;
|
||||
import com.das.common.result.R;
|
||||
import com.das.modules.operation.domain.CommandInfoDto;
|
||||
import com.das.modules.operation.domain.dto.CommandInfoDto;
|
||||
import com.das.modules.operation.service.OperationService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -0,0 +1,36 @@
|
||||
package com.das.modules.operation.controller;
|
||||
|
||||
import com.das.common.result.R;
|
||||
import com.das.common.utils.PageDataInfo;
|
||||
import com.das.modules.operation.domain.dto.EventLogDto;
|
||||
import com.das.modules.operation.domain.vo.SysOperationLogVo;
|
||||
import com.das.modules.operation.service.OperationLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
|
||||
@Slf4j
|
||||
@RequestMapping("/api/operation")
|
||||
@RestController
|
||||
public class OperationLogController {
|
||||
|
||||
@Autowired
|
||||
private OperationLogService operationLogService;
|
||||
|
||||
/**
|
||||
* 获取事件记录
|
||||
*/
|
||||
@PostMapping("/getEventLogList")
|
||||
public R<PageDataInfo<SysOperationLogVo>> getEventLogList(@RequestBody EventLogDto eventLogDto) {
|
||||
if (eventLogDto.getPageNum() ==null){
|
||||
eventLogDto.setPageNum(1);
|
||||
}
|
||||
if (eventLogDto.getPageSize() ==null){
|
||||
eventLogDto.setPageSize(30);
|
||||
}
|
||||
return R.success(operationLogService.getEventLogList(eventLogDto));
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.das.modules.operation.domain;
|
||||
package com.das.modules.operation.domain.dto;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
@ -0,0 +1,22 @@
|
||||
package com.das.modules.operation.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class EventLogDto {
|
||||
|
||||
private String startTime;
|
||||
|
||||
|
||||
private String endTime;
|
||||
|
||||
private String attributeCode;
|
||||
|
||||
private String userName;
|
||||
|
||||
private Integer pageNum;
|
||||
|
||||
private Integer pageSize;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package com.das.modules.operation.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
public class SysOperationLogVo {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 记录id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 操作人账号
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 操作人名称
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date optTime;
|
||||
/**
|
||||
* 操作人IP地址
|
||||
*/
|
||||
private String ipAddress;
|
||||
/**
|
||||
* 操作设备id
|
||||
*/
|
||||
private Long deviceId;
|
||||
/**
|
||||
* 设备属性编码
|
||||
*/
|
||||
private String attributeCode;
|
||||
/**
|
||||
* 设备属性名称
|
||||
*/
|
||||
private String attributeName;
|
||||
/**
|
||||
* 操作描述
|
||||
*/
|
||||
private String optDesc;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -43,4 +43,6 @@ public class SysManualStatus extends BaseEntity {
|
||||
*/
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
|
||||
private Integer count;
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
package com.das.modules.operation.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.das.modules.auth.mapper.BaseMapperPlus;
|
||||
import com.das.modules.operation.entity.SysManualStatus;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface SysManualStatusMapper extends BaseMapper<SysManualStatus> {
|
||||
public interface SysManualStatusMapper extends BaseMapperPlus<SysManualStatus,SysManualStatus> {
|
||||
|
||||
int sysManualStatusInsertOrUpdate(SysManualStatus sysManualStatus);
|
||||
}
|
||||
|
@ -1,9 +1,18 @@
|
||||
package com.das.modules.operation.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.das.modules.auth.mapper.BaseMapperPlus;
|
||||
import com.das.modules.operation.domain.dto.EventLogDto;
|
||||
import com.das.modules.operation.domain.vo.SysOperationLogVo;
|
||||
import com.das.modules.operation.entity.SysOperationLog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface SysOperationLogMapper extends BaseMapper<SysOperationLog> {
|
||||
public interface SysOperationLogMapper extends BaseMapperPlus<SysOperationLog,SysOperationLog> {
|
||||
|
||||
IPage<SysOperationLogVo> getEventLogList(IPage<SysOperationLogVo> page ,
|
||||
@Param("info") EventLogDto eventLogDto);
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
package com.das.modules.operation.service;
|
||||
|
||||
import com.das.common.utils.PageDataInfo;
|
||||
import com.das.modules.operation.domain.dto.EventLogDto;
|
||||
import com.das.modules.operation.domain.vo.SysOperationLogVo;
|
||||
|
||||
public interface OperationLogService {
|
||||
|
||||
PageDataInfo<SysOperationLogVo> getEventLogList(EventLogDto eventLogDto);
|
||||
}
|
@ -12,7 +12,7 @@ import com.das.modules.node.disruptor.TerminalMessageEventHandler;
|
||||
import com.das.modules.node.domain.bo.TerminalMessage;
|
||||
import com.das.modules.node.domain.vo.SysNodeVo;
|
||||
import com.das.modules.node.mapper.SysNodeMapper;
|
||||
import com.das.modules.operation.domain.CommandInfoDto;
|
||||
import com.das.modules.operation.domain.dto.CommandInfoDto;
|
||||
import com.das.modules.operation.entity.SysManualStatus;
|
||||
import com.das.modules.operation.entity.SysOperationLog;
|
||||
import com.das.modules.operation.mapper.SysManualStatusMapper;
|
||||
@ -71,11 +71,11 @@ public class OperationService {
|
||||
sysManualStatus.setDeviceId(cmdInfo.getDeviceId());
|
||||
sysManualStatus.setAttributeCode(cmdInfo.getServiceCode());
|
||||
sysManualStatus.setStatus( Integer.valueOf(cmdInfo.getOpValue().toString()));
|
||||
sysManualStatusMapper.insert(sysManualStatus);
|
||||
sysManualStatusMapper.sysManualStatusInsertOrUpdate(sysManualStatus);
|
||||
// 2、更新redis RT实时数据值
|
||||
String key = String.format("RT:%s:%s", cmdInfo.getDeviceId(), cmdInfo.getServiceCode().toLowerCase());
|
||||
// 存入redis
|
||||
adminRedisTemplate.set(key, cmdInfo.getOpValue());
|
||||
adminRedisTemplate.set(key, cmdInfo.getOpValue());
|
||||
} else {
|
||||
sendCommand(cmdInfo); //发送命令消息
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
package com.das.modules.operation.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.das.common.utils.PageDataInfo;
|
||||
import com.das.common.utils.PageQuery;
|
||||
import com.das.modules.operation.domain.dto.EventLogDto;
|
||||
import com.das.modules.operation.domain.vo.SysOperationLogVo;
|
||||
import com.das.modules.operation.mapper.SysOperationLogMapper;
|
||||
import com.das.modules.operation.service.OperationLogService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class OperationLogServiceImpl implements OperationLogService {
|
||||
|
||||
@Autowired
|
||||
private SysOperationLogMapper sysOperationLogMapper;
|
||||
|
||||
/**
|
||||
* 获取事件记录
|
||||
*/
|
||||
@Override
|
||||
public PageDataInfo<SysOperationLogVo> getEventLogList(EventLogDto eventLogDto) {
|
||||
PageQuery pageQuery = new PageQuery();
|
||||
pageQuery.setPageNum(eventLogDto.getPageNum());
|
||||
pageQuery.setPageSize(eventLogDto.getPageSize());
|
||||
IPage<SysOperationLogVo> iPage = sysOperationLogMapper.getEventLogList(pageQuery.build(), eventLogDto);
|
||||
return PageDataInfo.build(iPage.getRecords(), iPage.getTotal());
|
||||
}
|
||||
}
|
24
das/src/main/resources/mapper/SysManualStatusMapper.xml
Normal file
24
das/src/main/resources/mapper/SysManualStatusMapper.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<?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.das.modules.operation.mapper.SysManualStatusMapper">
|
||||
|
||||
|
||||
<insert id="sysManualStatusInsertOrUpdate" parameterType="com.das.modules.operation.entity.SysManualStatus">
|
||||
<selectKey keyProperty="count" resultType="int" order="BEFORE">
|
||||
select count(*) FROM sys_manual_status where device_id =#{deviceId} and attribute_code =#{attributeCode}
|
||||
</selectKey>
|
||||
<if test="count == 0">
|
||||
INSERT INTO public.sys_manual_status
|
||||
(id, device_id, attribute_code, status)
|
||||
VALUES(#{id}, #{deviceId}, #{attributeCode}, #{status})
|
||||
</if>
|
||||
<if test="count > 0">
|
||||
UPDATE public.sys_manual_status
|
||||
SET status=#{status}
|
||||
WHERE device_id=#{deviceId} AND attribute_code=#{attributeCode}
|
||||
</if>
|
||||
</insert>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
36
das/src/main/resources/mapper/SysOperationLogMapper.xml
Normal file
36
das/src/main/resources/mapper/SysOperationLogMapper.xml
Normal file
@ -0,0 +1,36 @@
|
||||
<?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.das.modules.operation.mapper.SysOperationLogMapper">
|
||||
|
||||
<resultMap type="com.das.modules.operation.domain.vo.SysOperationLogVo" id="EnumValuesMap">
|
||||
<result property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="userId" column="user_id" jdbcType="VARCHAR"/>
|
||||
<result property="userName" column="user_name" jdbcType="VARCHAR"/>
|
||||
<result property="optTime" column="opt_time" jdbcType="VARCHAR"/>
|
||||
<result property="ipAddress" column="ip_address" jdbcType="VARCHAR"/>
|
||||
<result property="deviceId" column="device_id" jdbcType="BIGINT"/>
|
||||
<result property="attributeCode" column="attribute_code" jdbcType="VARCHAR"/>
|
||||
<result property="attributeName" column="attribute_name" jdbcType="VARCHAR"/>
|
||||
<result property="optDesc" column="opt_desc" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getEventLogList" resultMap="EnumValuesMap">
|
||||
select e.* from sys_operation_log e
|
||||
<where>
|
||||
<if test="info.startTime != null and info.endTime != null">
|
||||
and e.opt_time >= to_timestamp(#{info.startTime}, 'YYYY-MM-DD HH24:MI:SS')
|
||||
and e.opt_time <= to_timestamp(#{info.endTime}, 'YYYY-MM-DD HH24:MI:SS')
|
||||
</if>
|
||||
<if test="info.attributeCode != null and info.attributeCode != ''">
|
||||
and e.attribute_code =#{info.attributeCode}
|
||||
</if>
|
||||
<if test="info.userName != null and info.userName != ''">
|
||||
and e.user_name like concat('%',#{info.userName},'%')
|
||||
</if>
|
||||
</where>
|
||||
order by e.opt_time desc
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
193
docs/api/operation.md
Normal file
193
docs/api/operation.md
Normal file
@ -0,0 +1,193 @@
|
||||
# 操作相关模块
|
||||
|
||||
## API接口一览表
|
||||
|
||||
| 接口分类 | 接口描述 | API接口 | 权限 |
|
||||
|---------|-----------------| ------------------------------------- | --------------------------- |
|
||||
| 2.1操作记录 | 2.1.1获取相关操作记录 | /api/operation/getEventLogList | |
|
||||
| 2.2手动操作 | 2.2.1设备遥控操作 下令 | /api/operation/command | SYS_AUTHORITY_ID_DEVICE_CTRL|
|
||||
| | 2.2.2设备遥调操作 下令 | /api/operation/setPoint | SYS_AUTHORITY_ID_DEVICE_CTRL|
|
||||
| | 2.2.3设备手工至位 不下令 | /api/operation/manualCommand | SYS_AUTHORITY_ID_DEVICE_CTRL|
|
||||
|
||||
|
||||
### 2.1 操作相关模块接口
|
||||
|
||||
#### 2.1.1 获取相关操作记录
|
||||
|
||||
POST 请求接口
|
||||
|
||||
> /api/operation/getEventLogList
|
||||
|
||||
请求参数
|
||||
|
||||
```json
|
||||
{
|
||||
"startTime": "2024-10-21 23:00:00:00",
|
||||
"endTime": "2024-10-31 23:00:00:00",
|
||||
"attributeCode": "SC-01",
|
||||
"userName": "张三",
|
||||
"pageNum": 1,
|
||||
"pageSize": 10
|
||||
}
|
||||
```
|
||||
入参描述
|
||||
|
||||
| 参数名 | 参数类型 | 可选 | 描述 |
|
||||
| ------------ |---------|-----|--------|
|
||||
| startTime | String | YES | 开始时间 |
|
||||
| endTime | String | YES | 结束时间 |
|
||||
| attributeCode | String | YES | 风机编号 |
|
||||
| userName | String | YES | 操作人员 |
|
||||
| pageNum | Integer | YES | 当前页 |
|
||||
| pageSize | Integer | YES | 每页显示大小 |
|
||||
|
||||
返回报文
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"success": true,
|
||||
"data": {
|
||||
"total": 2,
|
||||
"rows": [
|
||||
{
|
||||
"id": "1851903283326214146",
|
||||
"userName": "张三",
|
||||
"optTime": "2024-10-31 16:25:24",
|
||||
"deviceId": 863256444266222,
|
||||
"attributeCode": "testCode",
|
||||
"attributeName": "测试遥控2",
|
||||
"optDesc": "手动调试2"
|
||||
}
|
||||
],
|
||||
"code": 200,
|
||||
"msg": "查询成功"
|
||||
},
|
||||
"msg": "操作成功"
|
||||
}
|
||||
```
|
||||
返参描述
|
||||
|
||||
| 参数名 | 参数类型 | 可选 | 描述 |
|
||||
| ------------- |--------| ---- |--------|
|
||||
| id | Long | 否 | id |
|
||||
| optTime | String | 否 | 时间 |
|
||||
| attributeCode | String | 否 | 风机编号 |
|
||||
| attributeName | String | 否 | 操作类型 |
|
||||
| optDesc | String | 否 | 操作详情 |
|
||||
| userName | String | 否 | 操作员 |
|
||||
| deviceId | Long | 否 | 操作设备id |
|
||||
|
||||
|
||||
### 2.2 手动操作相关接口
|
||||
|
||||
#### 2.2.1 设备遥控操作 下令
|
||||
|
||||
POST 请求接口
|
||||
|
||||
> /api/operation/command
|
||||
|
||||
请求参数
|
||||
|
||||
```json
|
||||
{
|
||||
"deviceId": 863256444266222,
|
||||
"serviceCode": "testCode",
|
||||
"serviceName": "测试遥控2",
|
||||
"optDesc": "手动测试2",
|
||||
"opValue": 0
|
||||
}
|
||||
```
|
||||
入参描述
|
||||
|
||||
| 参数名 | 参数类型 | 可选 | 描述 |
|
||||
| ------------ |---------|-----|------|
|
||||
| deviceId | Long | NO | 设备id |
|
||||
| serviceCode | String | NO | 命令编码 |
|
||||
| serviceName | String | NO | 遥控名称 |
|
||||
| optDesc | String | YES | 操作描述 |
|
||||
| opValue | Integer | YES | 遥控值 |
|
||||
|
||||
返回报文
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"success": true,
|
||||
"msg": "操作成功"
|
||||
}
|
||||
```
|
||||
|
||||
#### 2.2.2 设备遥调操作 下令
|
||||
|
||||
POST 请求接口
|
||||
|
||||
> /api/operation/setPoint
|
||||
|
||||
请求参数
|
||||
|
||||
```json
|
||||
{
|
||||
"deviceId": 863256444266222,
|
||||
"serviceCode": "testCode",
|
||||
"serviceName": "测试遥控2",
|
||||
"optDesc": "手动测试2",
|
||||
"opValue": 0
|
||||
}
|
||||
```
|
||||
入参描述
|
||||
|
||||
| 参数名 | 参数类型 | 可选 | 描述 |
|
||||
| ------------ |---------|-----|------|
|
||||
| deviceId | Long | NO | 设备id |
|
||||
| serviceCode | String | NO | 命令编码 |
|
||||
| serviceName | String | NO | 遥控名称 |
|
||||
| optDesc | String | YES | 操作描述 |
|
||||
| opValue | Integer | YES | 遥控值 |
|
||||
|
||||
返回报文
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"success": true,
|
||||
"msg": "操作成功"
|
||||
}
|
||||
```
|
||||
|
||||
#### 2.2.3 设备手工至位 不下令
|
||||
|
||||
POST 请求接口
|
||||
|
||||
> /api/operation/manualCommand
|
||||
|
||||
请求参数
|
||||
|
||||
```json
|
||||
{
|
||||
"deviceId": 863256444266222,
|
||||
"serviceCode": "testCode",
|
||||
"serviceName": "测试遥控2",
|
||||
"optDesc": "手动测试2",
|
||||
"opValue": 0
|
||||
}
|
||||
```
|
||||
入参描述
|
||||
|
||||
| 参数名 | 参数类型 | 可选 | 描述 |
|
||||
| ------------ |---------|-----|------|
|
||||
| deviceId | Long | NO | 设备id |
|
||||
| serviceCode | String | NO | 命令编码 |
|
||||
| serviceName | String | NO | 遥控名称 |
|
||||
| optDesc | String | YES | 操作描述 |
|
||||
| opValue | Integer | YES | 遥控值 |
|
||||
|
||||
返回报文
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"success": true,
|
||||
"msg": "操作成功"
|
||||
}
|
||||
```
|
Loading…
Reference in New Issue
Block a user