Files
jsowell-charger-web/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/CameraController.java

77 lines
2.6 KiB
Java
Raw Normal View History

2024-05-10 15:30:20 +08:00
package com.jsowell.api.thirdparty;
2023-12-05 15:44:59 +08:00
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.service.camera.CameraBusinessService;
2023-12-05 15:44:59 +08:00
import com.jsowell.pile.dto.camera.CameraHeartBeatDTO;
import com.jsowell.pile.dto.camera.SendMsg2TopicDTO;
2023-12-05 15:44:59 +08:00
import com.jsowell.thirdparty.camera.common.CameraCommonResult;
2024-01-06 10:57:30 +08:00
import com.jsowell.service.CameraService;
2023-12-06 11:23:02 +08:00
import org.springframework.beans.factory.annotation.Autowired;
2023-12-05 15:44:59 +08:00
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;
/**
* 充电相机 controller
*
* @author Lemon
* @Date 2023/12/5 9:06:53
*/
@Anonymous
@RestController
@RequestMapping("/camera")
public class CameraController extends BaseController {
2023-12-06 11:23:02 +08:00
@Autowired
private CameraService cameraService;
2023-12-05 15:44:59 +08:00
@Autowired
private CameraBusinessService cameraBusinessService;
2023-12-05 15:44:59 +08:00
/**
* 心跳
* @param dto
*/
@PostMapping("/v1/receiveHeartBeat")
public CameraCommonResult receiveHeartBeat(@RequestBody CameraHeartBeatDTO dto) {
logger.info("接收相机系统心跳包 params:{}", JSON.toJSONString(dto));
cameraService.saveHeartBeat2Redis(dto);
2023-12-05 15:44:59 +08:00
CameraCommonResult result = new CameraCommonResult();
logger.info("接收相机系统心跳包 result:{}", JSON.toJSONString(result.successResponse()));
return result.successResponse();
}
/**
* 识别结果
* @param jsonObject
*/
@PostMapping("/v1/receiveIdentifyResults")
2023-12-06 11:23:02 +08:00
public CameraCommonResult receiveIdentifyResults(@RequestBody JSONObject jsonObject) {
2023-12-05 15:44:59 +08:00
logger.info("相机系统接收识别结果 params:{}", jsonObject);
2023-12-06 11:23:02 +08:00
CameraCommonResult result = new CameraCommonResult();
2024-01-06 15:10:31 +08:00
try {
// 调用service方法处理
cameraService.receiveIdentifyResults(jsonObject);
} catch (Exception e) {
logger.error("相机系统接收识别结果 error,", e);
}
2023-12-06 11:23:02 +08:00
return result.successResponse();
2023-12-05 15:44:59 +08:00
}
2023-12-27 08:17:22 +08:00
/**
* 给某个 Topic 发消息
* @param dto
*/
@PostMapping("/sendMsg2Topic")
public void sendMsg2Topic(@RequestBody SendMsg2TopicDTO dto) {
try {
2024-01-06 10:57:30 +08:00
cameraService.sendMsg2Topic(dto.getSn(), dto.getMsgType(), dto.getMsgPrefix(), dto.getTopic(), dto.getMsgData());
} catch (Exception e) {
logger.error("发送消息 error, ", e);
}
}
2023-12-05 15:44:59 +08:00
}