修改遥控遥调操作的api接口
This commit is contained in:
parent
a4e52d6742
commit
357a053b4d
@ -232,10 +232,22 @@ public class SysNodeController {
|
||||
return R.success("导入失败");
|
||||
}
|
||||
|
||||
/** 遥控遥调 */
|
||||
@PostMapping("/link/deviceControl")
|
||||
public void deviceControl(@RequestBody DeviceControlDto device) {
|
||||
sysNodeService.deviceControl(device);
|
||||
/**
|
||||
* 设备遥控操作
|
||||
* @param deviceInfo 遥控信息
|
||||
*/
|
||||
@PostMapping("/link/command")
|
||||
public void deviceCommand(@RequestBody DeviceCommandDto deviceInfo) {
|
||||
sysNodeService.deviceCommand(deviceInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备遥调操作
|
||||
* @param deviceInfo 遥控信息
|
||||
*/
|
||||
@PostMapping("/link/setPoint")
|
||||
public void deviceSetPoint(@RequestBody DeviceSetPointDto deviceInfo) {
|
||||
sysNodeService.deviceSetPoint(deviceInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,17 +4,23 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 设备控制 输入参数
|
||||
*/
|
||||
@Data
|
||||
public class DeviceControlDto {
|
||||
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long nodeId;
|
||||
|
||||
public class DeviceCommandDto {
|
||||
/**
|
||||
* 设备ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long deviceId;
|
||||
|
||||
/**
|
||||
* 遥控命令
|
||||
*/
|
||||
private String serviceName;
|
||||
|
||||
/**
|
||||
*遥控值, 1或者0
|
||||
*/
|
||||
private Integer opValue;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
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;
|
||||
|
||||
@Data
|
||||
public class DeviceSetPointDto {
|
||||
/**
|
||||
* 设备ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long deviceId;
|
||||
|
||||
/**
|
||||
* 遥调命令
|
||||
*/
|
||||
private String serviceName;
|
||||
/**
|
||||
*遥调值,浮点数
|
||||
*/
|
||||
private Float opValue;
|
||||
}
|
@ -43,5 +43,15 @@ public interface SysNodeService {
|
||||
|
||||
boolean importMappingList(String linkId, MultipartFile file);
|
||||
|
||||
void deviceControl(DeviceControlDto device);
|
||||
/**
|
||||
* 设备遥控操作
|
||||
* @param deviceInfo 遥控具体的设备信息,设备id、遥控命令、遥控值
|
||||
*/
|
||||
void deviceCommand(DeviceCommandDto deviceInfo);
|
||||
|
||||
/**
|
||||
* 设备遥调操作
|
||||
* @param deviceInfo 遥调具体的设备信息,设备id、遥调命令、遥调值
|
||||
*/
|
||||
void deviceSetPoint(DeviceSetPointDto deviceInfo);
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deviceControl(DeviceControlDto device) {
|
||||
public void deviceCommand(DeviceCommandDto device) {
|
||||
try {
|
||||
HashMap map = new HashMap<>();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
@ -345,6 +345,12 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
map.put("serviceName", device.getServiceName());
|
||||
map.put("opValue", device.getOpValue());
|
||||
|
||||
//激活的node节点Id
|
||||
long activeNodeId = getActiveNodeId();
|
||||
if(activeNodeId==0){
|
||||
throw new RuntimeException("找不到激活的节点信息");
|
||||
}
|
||||
|
||||
// 将 HashMap 转换为 JsonNode
|
||||
ObjectNode jsonNode = objectMapper.convertValue(map, ObjectNode.class);
|
||||
TerminalMessage configUpdate = TerminalMessage.builder()
|
||||
@ -353,13 +359,58 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
.time(time)
|
||||
.data(jsonNode)
|
||||
.build();
|
||||
terminalMessageEventHandler.sendTerminalMessageWithResult(device.getNodeId(), configUpdate);
|
||||
terminalMessageEventHandler.sendTerminalMessageWithResult(activeNodeId, configUpdate);
|
||||
} catch (Exception e) {
|
||||
log.error("设备控制失败 ", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deviceSetPoint(DeviceSetPointDto device) {
|
||||
try {
|
||||
HashMap map = new HashMap<>();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String cmd = NodeConstant.DEVICE_CONTROL;
|
||||
Long time = System.currentTimeMillis();
|
||||
|
||||
map.put("deviceId", device.getDeviceId());
|
||||
map.put("serviceName", device.getServiceName());
|
||||
map.put("opValue", device.getOpValue());
|
||||
|
||||
//激活的node节点Id
|
||||
long activeNodeId = getActiveNodeId();
|
||||
if(activeNodeId==0){
|
||||
throw new RuntimeException("找不到激活的节点信息");
|
||||
}
|
||||
|
||||
// 将 HashMap 转换为 JsonNode
|
||||
ObjectNode jsonNode = objectMapper.convertValue(map, ObjectNode.class);
|
||||
TerminalMessage configUpdate = TerminalMessage.builder()
|
||||
.cmd(cmd)
|
||||
.cmdId(String.valueOf(device.getDeviceId()))
|
||||
.time(time)
|
||||
.data(jsonNode)
|
||||
.build();
|
||||
terminalMessageEventHandler.sendTerminalMessageWithResult(activeNodeId, configUpdate);
|
||||
} catch (Exception e) {
|
||||
log.error("设备控制失败 ", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得当前激活的节点id
|
||||
* @return 节点id
|
||||
*/
|
||||
private long getActiveNodeId(){
|
||||
List<SysNodeVo> list = sysNodeMapper.querySysNodeList();
|
||||
if(list.isEmpty()){
|
||||
return 0;
|
||||
}else{
|
||||
return list.get(0).getId();
|
||||
}
|
||||
}
|
||||
|
||||
// 绑定设备的测点信息,不是绑定设备到映射表
|
||||
private void addSysImptabmapping(List<BindEquipmentInfoDto> equipmentId, Long linkId, SysUserVo sysUserVo, List<SysImptabmapping> addList) {
|
||||
|
||||
|
@ -1,17 +1,29 @@
|
||||
package com.das.modules.page.controller;
|
||||
|
||||
import com.das.common.result.R;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author houwei
|
||||
* @date 2024-10-24
|
||||
* @description: 风机列表页面 对应的 后端api
|
||||
*/
|
||||
@Slf4j
|
||||
@RequestMapping("/api/page")
|
||||
@RequestMapping("/api/page/turbines")
|
||||
@RestController
|
||||
public class WindTurbinesPageController {
|
||||
|
||||
/**
|
||||
* 获取风机机组所属线路列表
|
||||
* @return 返回字符串数组
|
||||
*/
|
||||
@PostMapping("/lines")
|
||||
public R<List<String>> queryBelongLines() {
|
||||
//TODO: 查询sql: select distinct belong_line as name from sys_equipment t where t.object_type = 10002 and belong_line !='';
|
||||
return R.success();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user