das接口文档修改,das新增映射表相关接口
This commit is contained in:
parent
55122bbd1d
commit
bbccc14fd8
@ -0,0 +1,10 @@
|
||||
package com.das.modules.node.command;
|
||||
|
||||
import com.das.modules.node.domain.bo.TerminalMessage;
|
||||
|
||||
public class AnalogDataCommand implements BaseCommand{
|
||||
@Override
|
||||
public void doCommand(TerminalMessage data) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.das.modules.node.command;
|
||||
|
||||
import com.das.modules.node.domain.bo.TerminalMessage;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public interface BaseCommand {
|
||||
void doCommand(TerminalMessage data);
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.das.modules.node.command;
|
||||
|
||||
import com.das.modules.node.domain.bo.TerminalMessage;
|
||||
|
||||
public class HeartbeatCommand implements BaseCommand{
|
||||
@Override
|
||||
public void doCommand(TerminalMessage data) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.das.modules.node.command;
|
||||
|
||||
import com.das.modules.node.domain.bo.TerminalMessage;
|
||||
|
||||
public class HistoryStateDataCommand implements BaseCommand{
|
||||
@Override
|
||||
public void doCommand(TerminalMessage data) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.das.modules.node.command;
|
||||
|
||||
import com.das.modules.node.domain.bo.TerminalMessage;
|
||||
|
||||
public class InitDeviceDataCommand implements BaseCommand{
|
||||
@Override
|
||||
public void doCommand(TerminalMessage data) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.das.modules.node.command;
|
||||
|
||||
import com.das.modules.node.domain.bo.TerminalMessage;
|
||||
|
||||
public class StateDataCommand implements BaseCommand{
|
||||
@Override
|
||||
public void doCommand(TerminalMessage data) {
|
||||
|
||||
}
|
||||
}
|
@ -6,10 +6,13 @@ import com.das.common.constant.SysAuthorityIds;
|
||||
import com.das.common.exceptions.ServiceException;
|
||||
import com.das.common.result.R;
|
||||
import com.das.common.utils.PageDataInfo;
|
||||
import com.das.modules.node.domain.dto.BindEquipmentDto;
|
||||
import com.das.modules.node.domain.dto.SysCommunicationLinkDto;
|
||||
import com.das.modules.node.domain.dto.SysImptabmappingDto;
|
||||
import com.das.modules.node.domain.dto.SysNodeDto;
|
||||
import com.das.modules.node.domain.vo.ProtocolTypeVo;
|
||||
import com.das.modules.node.domain.vo.SysCommunicationLinkVo;
|
||||
import com.das.modules.node.domain.vo.SysImptabmappingVo;
|
||||
import com.das.modules.node.domain.vo.SysNodeVo;
|
||||
import com.das.modules.node.service.SysNodeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -149,5 +152,50 @@ public class SysNodeController {
|
||||
|
||||
return R.success(typeVoList);
|
||||
}
|
||||
|
||||
/** 获取映射表信息 */
|
||||
@PostMapping("/link/getMappingList")
|
||||
public R<?> getMappingList(@RequestBody SysImptabmappingDto sysImptabmappingDto) {
|
||||
|
||||
//判断是否有权限
|
||||
boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_MGR.toString());
|
||||
if(!hasPermission){
|
||||
return R.fail("没有节点管理权限");
|
||||
}
|
||||
if (sysImptabmappingDto.getLinkId() == null) {
|
||||
throw new ServiceException("参数缺失");
|
||||
}
|
||||
List<SysImptabmappingVo> list = sysNodeService.getMappingList(sysImptabmappingDto.getLinkId());
|
||||
return R.success(list);
|
||||
}
|
||||
|
||||
/** 获取绑定的设备列表信息 */
|
||||
@PostMapping("/link/getBindDeviceTree")
|
||||
public R<?> getBindDeviceTree(@RequestBody SysImptabmappingDto sysImptabmappingDto) {
|
||||
|
||||
//判断是否有权限
|
||||
boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_MGR.toString());
|
||||
if(!hasPermission){
|
||||
return R.fail("没有节点管理权限");
|
||||
}
|
||||
if (sysImptabmappingDto.getLinkId() == null) {
|
||||
throw new ServiceException("参数缺失");
|
||||
}
|
||||
List<SysImptabmappingVo> list = sysNodeService.getBindDeviceTree(sysImptabmappingDto.getLinkId());
|
||||
return R.success(list);
|
||||
}
|
||||
|
||||
/** 绑定设备信息 */
|
||||
@PostMapping("/link/bindDeviceMeas")
|
||||
public R<Void> bindMeas(@RequestBody BindEquipmentDto bindEquipmentDto) {
|
||||
|
||||
//判断是否有权限
|
||||
// boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_MGR.toString());
|
||||
// if(!hasPermission){
|
||||
// return R.fail("没有节点管理权限");
|
||||
// }
|
||||
sysNodeService.bindDeviceMeas(bindEquipmentDto.getEquipmentId(), bindEquipmentDto.getLinkId());
|
||||
return R.success();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.das.modules.node.disruptor;
|
||||
|
||||
import com.das.common.utils.SpringUtils;
|
||||
import com.das.modules.node.command.BaseCommand;
|
||||
import com.das.modules.node.domain.bo.TerminalMessage;
|
||||
import com.das.modules.node.handler.NodeMessageHandler;
|
||||
import com.lmax.disruptor.EventHandler;
|
||||
@ -23,9 +25,23 @@ public class TerminalMessageEventHandler implements EventHandler<TerminalMessage
|
||||
if (callbackMap.containsKey(terminalMessage.getCmdId())){
|
||||
//如果是回调函数,推送到回调函数
|
||||
callbackMap.get(terminalMessage.getCmdId()).complete(terminalMessage);
|
||||
}
|
||||
else{
|
||||
|
||||
} else{
|
||||
String cmd = terminalMessage.getCmd();
|
||||
BaseCommand commander = null;
|
||||
try {
|
||||
commander = SpringUtils.getBean(cmd);
|
||||
} catch (Exception e) {
|
||||
log.debug("当前未找到执行command容器");
|
||||
}
|
||||
if (commander != null) {
|
||||
try {
|
||||
commander.doCommand(terminalMessage);
|
||||
} catch (Exception ex) {
|
||||
log.error(String.format("命令 - %s 处理失败", cmd), ex);
|
||||
}
|
||||
} else {
|
||||
log.error("命令[{}]无效, 未发现实现适配器!", cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.das.modules.node.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class BindEquipmentDto {
|
||||
|
||||
private List<Long> equipmentId;
|
||||
|
||||
private Long linkId;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.das.modules.node.domain.dto;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class SysImptabmappingDto implements Serializable {
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long linkId;
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.das.modules.node.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 映射表前端回显
|
||||
*
|
||||
* @author guchengwei
|
||||
*/
|
||||
@Data
|
||||
public class SysImptabmappingVo {
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long linkId;
|
||||
|
||||
private String linkName;
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long equipmentId;
|
||||
|
||||
private String equipmentName;
|
||||
|
||||
private String equipmentAttribute;
|
||||
|
||||
private String equipmentService;
|
||||
|
||||
private Integer porder;
|
||||
|
||||
private String params;
|
||||
|
||||
private Integer revision;
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package com.das.modules.node.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.das.common.constant.BaseEntity;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 映射表信息
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaojie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sys_imptabmapping")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysImptabmapping extends BaseEntity {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 系统节点ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 对应链路ID
|
||||
*/
|
||||
@TableField("link_id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long linkId;
|
||||
|
||||
/**
|
||||
* 对应设备ID
|
||||
*/
|
||||
@TableField("equipment_id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long equipmentId;
|
||||
|
||||
/**
|
||||
* 对应设备属性
|
||||
*/
|
||||
@TableField("equipment_attribute")
|
||||
private String equipmentAttribute;
|
||||
|
||||
/**
|
||||
* 对应设备服务
|
||||
*/
|
||||
@TableField("equipmentService")
|
||||
private String equipmentService;
|
||||
|
||||
@TableField("porder")
|
||||
private Integer porder;
|
||||
|
||||
@TableField("params")
|
||||
private String params;
|
||||
}
|
@ -51,11 +51,12 @@ public class NodeMessageHandler extends TextWebSocketHandler {
|
||||
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
|
||||
TerminalMessage msg = JsonUtils.parseObject(message.getPayload(), TerminalMessage.class);
|
||||
String nodeId = session.getAttributes().get(NodeConstant.NODE_ID).toString();
|
||||
String version = session.getAttributes().get(NodeConstant.VERSION).toString();
|
||||
String cmdId = msg.getCmdId();
|
||||
String cmd = msg.getCmd();
|
||||
long time = msg.getTime();
|
||||
JsonNode data = msg.getData();
|
||||
|
||||
// 如果version是0,则需要调用一次configUpdate配置更新
|
||||
log.info("收到 Node:{} 命令: {}", nodeId, cmd);
|
||||
log.debug("内容: {}", data.toString());
|
||||
if (dataService == null){
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.das.modules.node.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.das.modules.node.domain.dto.SysCommunicationLinkDto;
|
||||
import com.das.modules.node.domain.vo.SysCommunicationLinkVo;
|
||||
import com.das.modules.node.domain.vo.SysImptabmappingVo;
|
||||
import com.das.modules.node.entity.SysCommunicationLink;
|
||||
import com.das.modules.node.entity.SysImptabmapping;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SysImptabmappingMapper extends BaseMapper<SysImptabmapping> {
|
||||
List<SysImptabmappingVo> getMappingList(Long linkId);
|
||||
|
||||
List<SysImptabmappingVo> getBindDevice(Long linkId);
|
||||
}
|
@ -4,6 +4,7 @@ import com.das.common.utils.PageDataInfo;
|
||||
import com.das.modules.node.domain.dto.SysCommunicationLinkDto;
|
||||
import com.das.modules.node.domain.dto.SysNodeDto;
|
||||
import com.das.modules.node.domain.vo.SysCommunicationLinkVo;
|
||||
import com.das.modules.node.domain.vo.SysImptabmappingVo;
|
||||
import com.das.modules.node.domain.vo.SysNodeVo;
|
||||
|
||||
import java.util.List;
|
||||
@ -25,5 +26,9 @@ public interface SysNodeService {
|
||||
|
||||
void deleteSysCommunicationLink(Long id);
|
||||
|
||||
List<SysImptabmappingVo> getMappingList(Long linkId);
|
||||
|
||||
List<SysImptabmappingVo> getBindDeviceTree(Long linkId);
|
||||
void bindDeviceMeas(List<Long> equipmentId, Long linkId);
|
||||
|
||||
}
|
||||
|
@ -13,16 +13,20 @@ import com.das.modules.auth.mapper.SysOrgMapper;
|
||||
import com.das.modules.node.domain.dto.SysCommunicationLinkDto;
|
||||
import com.das.modules.node.domain.dto.SysNodeDto;
|
||||
import com.das.modules.node.domain.vo.SysCommunicationLinkVo;
|
||||
import com.das.modules.node.domain.vo.SysImptabmappingVo;
|
||||
import com.das.modules.node.domain.vo.SysNodeVo;
|
||||
import com.das.modules.node.entity.SysCommunicationLink;
|
||||
import com.das.modules.node.entity.SysImptabmapping;
|
||||
import com.das.modules.node.entity.SysNode;
|
||||
import com.das.modules.node.mapper.SysCommunicationLinkMapper;
|
||||
import com.das.modules.node.mapper.SysImptabmappingMapper;
|
||||
import com.das.modules.node.mapper.SysNodeMapper;
|
||||
import com.das.modules.node.service.SysNodeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ -40,6 +44,9 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
@Autowired
|
||||
private SysOrgMapper sysOrgMapper;
|
||||
|
||||
@Autowired
|
||||
private SysImptabmappingMapper sysImptabmappingMapper;
|
||||
|
||||
@Override
|
||||
public List<SysNodeVo> querySysNodeList() {
|
||||
List<SysNodeVo> sysNodeVoList = sysNodeMapper.querySysNodeList();
|
||||
@ -147,4 +154,24 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
// 判断节点下是否有链路,有就不能删除
|
||||
sysCommunicationLinkMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysImptabmappingVo> getMappingList(Long linkId) {
|
||||
List<SysImptabmappingVo> list = sysImptabmappingMapper.getMappingList(linkId);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysImptabmappingVo> getBindDeviceTree(Long linkId) {
|
||||
List<SysImptabmappingVo> bindDeviceList = sysImptabmappingMapper.getBindDevice(linkId);
|
||||
return bindDeviceList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindDeviceMeas(List<Long> equipmentId, Long linkId) {
|
||||
List<SysImptabmapping> insertList = new ArrayList<>();
|
||||
List<Long> deleteList = new ArrayList<>();
|
||||
List<SysImptabmapping> deleteMeasList = new ArrayList<>();
|
||||
//获取已经绑定的设备
|
||||
}
|
||||
}
|
||||
|
34
das/src/main/resources/mapper/SysImptabmappingMapper.xml
Normal file
34
das/src/main/resources/mapper/SysImptabmappingMapper.xml
Normal file
@ -0,0 +1,34 @@
|
||||
<?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.node.mapper.SysImptabmappingMapper">
|
||||
|
||||
<resultMap type="com.das.modules.node.domain.vo.SysImptabmappingVo" id="SysImptabmappingMap">
|
||||
<result property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="linkId" column="link_id" jdbcType="BIGINT"/>
|
||||
<result property="linkName" column="linkName" jdbcType="VARCHAR"/>
|
||||
<result property="equipmentId" column="equipment_id" jdbcType="BIGINT"/>
|
||||
<result property="equipmentName" column="equipmentName" jdbcType="VARCHAR"/>
|
||||
<result property="equipmentAttribute" column="equipment_attribute" jdbcType="VARCHAR"/>
|
||||
<result property="equipmentService" column="equipment_service" jdbcType="VARCHAR"/>
|
||||
<result property="params" column="params" jdbcType="VARCHAR"/>
|
||||
<result property="porder" column="porder" jdbcType="INTEGER"/>
|
||||
<result property="revision" column="revision" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getMappingList" resultMap="SysImptabmappingMap">
|
||||
select si.*, sc.link_name as linkName, se."name" as equipmentName from sys_imptabmapping si left join sys_communicationlink sc on si.link_id = sc.id
|
||||
left join sys_equipment se on si.equipment_id = se.id where si.link_id = #{linkId}
|
||||
order by si.porder
|
||||
</select>
|
||||
|
||||
<select id="getBindDevice" resultMap="SysImptabmappingMap">
|
||||
select se.id as equipment_id,se."name" as equipmentName, si.porder from sys_imptabmapping si
|
||||
left join sys_equipment se on se.id = si.equipment_id
|
||||
where si.link_id = #{linkId} order by si.porder
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</mapper>
|
@ -17,6 +17,7 @@
|
||||
| | 1.2.6绑定设备信息 | /api/node/link/bindDeviceMeas | SYS_AUTHORITY_ID_ADMIN |
|
||||
| | 1.2.7导入映射表信息 | /api/node/link/importMappingList | SYS_AUTHORITY_ID_ADMIN |
|
||||
| | 1.2.8导出映射表信息 | /api/node/link/exportMappingList | SYS_AUTHORITY_ID_ADMIN |
|
||||
| | 1.2.9获取绑定设备树信息 | /api/node/link/getBindDeviceTree | SYS_AUTHORITY_ID_ADMIN |
|
||||
|
||||
## 1.1 节点相关接口
|
||||
|
||||
@ -421,4 +422,35 @@ POST 请求接口
|
||||
"linkId": "73556002258550784"
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### 1.2.9 获取绑定设备树信息
|
||||
POST 请求接口
|
||||
|
||||
> /api/node/link/getBindDeviceTree
|
||||
|
||||
请求参数
|
||||
```json
|
||||
{
|
||||
"linkId": "73556002258550784"
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
返回报文
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"success": true,
|
||||
"data": [
|
||||
{
|
||||
"equipmentId": "73714632985149440",
|
||||
"equipmentName": "风电场测试",
|
||||
"porder": 1
|
||||
}
|
||||
],
|
||||
"msg": "操作成功"
|
||||
}
|
||||
```
|
Loading…
Reference in New Issue
Block a user