mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-23 12:35:07 +08:00
新增 netty整合mqtt协议,与车位相机通讯并保存通讯信息
This commit is contained in:
@@ -4,18 +4,19 @@ import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.netty.server.mqtt.BootNettyMqttChannelInboundHandler;
|
||||
import com.jsowell.netty.service.camera.CameraBusinessService;
|
||||
import com.jsowell.pile.dto.camera.CameraHeartBeatDTO;
|
||||
import com.jsowell.pile.dto.camera.CameraIdentifyResultsDTO;
|
||||
import com.jsowell.pile.dto.camera.SendMsg2TopicDTO;
|
||||
import com.jsowell.thirdparty.camera.common.CameraCommonResult;
|
||||
import com.jsowell.thirdparty.camera.service.CameraService;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 充电相机 controller
|
||||
*
|
||||
@@ -29,6 +30,12 @@ public class CameraController extends BaseController {
|
||||
@Autowired
|
||||
private CameraService cameraService;
|
||||
|
||||
@Autowired
|
||||
private CameraBusinessService cameraBusinessService;
|
||||
|
||||
@Autowired
|
||||
private BootNettyMqttChannelInboundHandler handler;
|
||||
|
||||
/**
|
||||
* 心跳
|
||||
* @param dto
|
||||
@@ -36,6 +43,7 @@ public class CameraController extends BaseController {
|
||||
@PostMapping("/v1/receiveHeartBeat")
|
||||
public CameraCommonResult receiveHeartBeat(@RequestBody CameraHeartBeatDTO dto) {
|
||||
logger.info("接收相机系统心跳包 params:{}", JSON.toJSONString(dto));
|
||||
cameraService.saveHeartBeat2Redis(dto);
|
||||
CameraCommonResult result = new CameraCommonResult();
|
||||
logger.info("接收相机系统心跳包 result:{}", JSON.toJSONString(result.successResponse()));
|
||||
return result.successResponse();
|
||||
@@ -53,4 +61,20 @@ public class CameraController extends BaseController {
|
||||
cameraService.receiveIdentifyResults(jsonObject);
|
||||
return result.successResponse();
|
||||
}
|
||||
|
||||
@PostMapping("/sendMsg2Topic")
|
||||
public void sendMsg2Topic(@RequestBody SendMsg2TopicDTO dto) {
|
||||
try {
|
||||
cameraBusinessService.sendGroundLockCommand(dto.getSn(), dto.getMsgType(), dto.getMsgPrefix(), dto.getTopic());
|
||||
} catch (Exception e) {
|
||||
logger.error("发送消息 error, ", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// @PostMapping("/sendMsg2Topic")
|
||||
// public void sendMsg2Topic(@RequestBody SendMsg2TopicDTO dto) throws InterruptedException {
|
||||
// ChannelFuture channelFuture = handler.sendMsg(dto.getChannelId(), dto.getTopic(), dto.getRequestMsg().toString());
|
||||
// System.out.println("123");
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user