添加水电双计设备在线状态维护,以及下发修改设备地址码指令接口等

This commit is contained in:
蒾酒
2024-12-24 01:53:17 +08:00
parent 16b2d0e242
commit 39dafad29c
6 changed files with 87 additions and 10 deletions

View File

@ -29,7 +29,7 @@ public class DeviceOperationController {
private PubMqttCallBack pubMqttCallBack;
/**
* 下发指令控制设备
* 下发指令控制阀门设备
*/
@PostMapping("/control")
public AjaxResult control(@RequestBody DeviceOperationDTO deviceOperationDTO){
@ -57,4 +57,24 @@ public class DeviceOperationController {
return AjaxResult.error("未知命令!");
}
/**
* 下发指令CMD控制设备指令
*/
@PostMapping("/control/cmd")
public AjaxResult controlCmd(@RequestBody DeviceOperationDTO deviceOperationDTO){
//构建主题
String topic ="hzlink/"+deviceOperationDTO.getProductId()+"/"+deviceOperationDTO.getDeviceNumber()+"/cmd/down";
//构建消息
Map<String,Object> param = new HashMap<>();
//远程阀控
param.put("cmd",Integer.parseInt(deviceOperationDTO.getOperationType()));
Map<String,Object> data = new HashMap<>();
data.put("addr",deviceOperationDTO.getAddr());
param.put("data",data);
pubMqttClient.publish(1,true,topic, JSONUtil.toJsonStr(param));
return AjaxResult.success();
}
}

View File

@ -5,6 +5,7 @@ import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -38,6 +39,9 @@ public class DeviceReportInfoController extends BaseController
@Autowired
private IDeviceReportInfoService deviceReportInfoService;
@Autowired
private StringRedisTemplate stringRedisTemplate;
/**
* 查询设备上电审核前上报的基础信息列表
*/
@ -48,6 +52,20 @@ public class DeviceReportInfoController extends BaseController
{
startPage();
List<DeviceReportInfo> list = deviceReportInfoService.selectDeviceReportInfoList(deviceReportInfo);
//查询设备在线状态
list.forEach(d->{
if(d.getType()==1){
Boolean hassed = stringRedisTemplate.hasKey("neixiang_device_online_status:" + 147 + ":" + d.getSerialNumber());
if(hassed){
d.setOnLine(1);
}else{
d.setOnLine(0);
}
} else if ( d.getType()==2) {
//展连流量计设备在线状态判断
}
});
return getDataTable(list);
}

View File

@ -63,7 +63,6 @@ public class UserConsumptionDetailsController extends BaseController
return getDataTable(list);
}
/**
* 导出用户充值卡账单明细记录列表
*/