设备激活接口未保存设备名称bug
ws协议连接mqtt代理一直断线重连问题
add:
mqtt消息转发接口
展连流量计设备实时数据接口
update:
设备在线状态逻辑
设备上电审核接口
This commit is contained in:
蒾酒
2024-12-26 04:36:55 +08:00
parent 27eac91d1c
commit 4760dba312
14 changed files with 160 additions and 75 deletions

View File

@ -1,12 +1,15 @@
package com.fastbee.data.controller;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.dtflys.forest.annotation.Post;
import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.iot.model.dto.DeviceOperationDTO;
import com.fastbee.mqttclient.PubMqttCallBack;
import com.fastbee.mqttclient.PubMqttClient;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@ -77,4 +80,23 @@ public class DeviceOperationController {
return AjaxResult.success();
}
/***
* 下发指令控制设备灵活版
*/
@PostMapping("/control/flexible")
public AjaxResult controlFlexible(@Param("topic")String topic, @RequestBody JSONObject cmd){
try {
if(StringUtils.isBlank(topic)){
return AjaxResult.error("topic不能为空");
}
//构建主题
// String topic ="hzlink/"+productId+"/"+deviceNumber+"/cmd/down";
pubMqttClient.publish(1,true,topic, JSONUtil.toJsonStr(cmd));
return AjaxResult.success();
}catch (Exception e){
return AjaxResult.error("下发指令失败!");
}
}
}

View File

@ -17,16 +17,19 @@ public class DeviceActivationController extends BaseController {
IDeviceActivationService deviceActivationService;
@PutMapping("/activation")
@ApiOperation("项目激活测试接口")
@ApiOperation("上电设备激活接口")
public AjaxResult getDevieceList(@RequestBody DeviceActivationDto deviceActivationDto)
{
System.err.println("-=-=-=-=-=-=-=-=-=-=-=-=-=激活设备名称"+deviceActivationDto.name);
//获取tenantId和tenantName
String[] idAndName=deviceActivationDto.tenantIdAndName.split(",",2);
Long tenantId= Long.valueOf(idAndName[0].replace(" ",""));
String tenantName=idAndName[1].trim();
return AjaxResult.success(deviceActivationService.selectDevice(deviceActivationDto.serialNumber,tenantId,tenantName,deviceActivationDto.longitude,deviceActivationDto.latitude,deviceActivationDto.imgUrl));
return AjaxResult.success(deviceActivationService.selectDevice(deviceActivationDto.serialNumber,
tenantId,tenantName,deviceActivationDto.longitude,
deviceActivationDto.latitude,deviceActivationDto.imgUrl,
deviceActivationDto.name));
}
/*@GetMapping("/info/{userId}")

View File

@ -1,9 +1,12 @@
package com.fastbee.data.controller.deviceActivation;
import lombok.Data;
public class DeviceActivationDto {
public String serialNumber;
public String tenantIdAndName;
public double longitude;
public double latitude;
public String imgUrl;
public String name;//设备名称
}

View File

@ -180,6 +180,7 @@ public class DeviceReportSSEController extends BaseController {
}
deviceReportInfo.setSerialNumber(genDeviceNumber);
deviceReportInfo.setName(genDeviceNumber);
deviceReportInfo.setType(1);
int inserted = deviceReportInfoMapper.insertDeviceReportInfo(deviceReportInfo);
if(inserted==0){
return AjaxResultPro.success(1104,"设备上电审核信息插入失败!",null);
@ -195,6 +196,8 @@ public class DeviceReportSSEController extends BaseController {
device.setStatus(1);//未激活
device.setCreateTime(deviceReportInfo.getPowersTime());
device.setTenantId(1L);//默认总管理员
device.setLocationWay(3);
device.setIsShadow(0);
int inserted1 = deviceMapper.insert(device);
if(inserted1<1){
throw new ServiceException("插入设备信息失败!");

View File

@ -105,4 +105,21 @@ public class ZhanLianFlowDeviceDataController {
}
@GetMapping("/zhanlian/realtimeData")
public AjaxResultPro getDeviceData(@Param("deviceNumber") String deviceNumber){
try {
Map<String, String> deviceRealTimeData = zhanLianBaseService.getDeviceRealTimeData(deviceNumber);
return AjaxResultPro.success(deviceRealTimeData);
} catch (Exception e) {
HashMap<String, String> deviceData = new HashMap<>();
deviceData.put("realTime", "2024-12-21 23:24:52");
deviceData.put("sumFlow_l", "0");
deviceData.put("sumFlow_F", "0");
deviceData.put("deviceId", "3852");
deviceData.put("inFlow", "0");
deviceData.put("status", "2");
return AjaxResultPro.success(deviceData);
}
}
}