|
@@ -1,12 +1,17 @@
|
|
|
package com.sooka.sponest.event.centereventteventcatalogue.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ruoyi.common.core.domain.R;
|
|
|
import com.ruoyi.common.core.utils.StringUtils;
|
|
|
+import com.ruoyi.common.core.web.controller.BaseController;
|
|
|
+import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
|
import com.sooka.sponest.event.centereventteventcatalogue.domain.dahua.DaHuaFireEventVO;
|
|
|
import com.sooka.sponest.event.centereventteventcatalogue.domain.dahua.DaHuaOtherEventVO;
|
|
|
import com.sooka.sponest.event.centereventteventcatalogue.domain.haikang.HaiKangEventVo;
|
|
|
import com.sooka.sponest.event.centereventteventcatalogue.domain.tower.TowerEventVo;
|
|
|
+import com.sooka.sponest.event.centereventteventcatalogue.domain.vo.DroneVO;
|
|
|
import com.sooka.sponest.event.centereventteventcatalogue.service.AlarmEventService;
|
|
|
import com.sooka.sponest.event.centereventtreportmessage.domain.CentereventTReportmessage;
|
|
|
import com.sooka.sponest.event.centereventtreportmessage.service.ICentereventTReportmessageService;
|
|
@@ -20,13 +25,15 @@ 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 com.sooka.sponest.event.utils.URLToJSONConverter;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Api(tags = "海康")
|
|
|
@RestController
|
|
|
@RequestMapping("AlarmEventController")
|
|
|
-public class AlarmEventController {
|
|
|
+public class AlarmEventController extends BaseController {
|
|
|
|
|
|
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
|
|
@@ -203,4 +210,49 @@ public class AlarmEventController {
|
|
|
}
|
|
|
return R.ok();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 无人机上报
|
|
|
+ */
|
|
|
+ /*
|
|
|
+ * {"data":
|
|
|
+ * [{
|
|
|
+ * "timeStamp":0, //时间戳
|
|
|
+ * "altitude":0.0, //海拔高度
|
|
|
+ * "alarmType":"Sleep", //隐患类型
|
|
|
+ * "createTime":1742354657000, //隐患时间
|
|
|
+ * "photoPath":"https://47.93.50.30:443/media/dji-photos/wayline/1742354657053.JPG", //隐患图片地址
|
|
|
+ * "latitude":38.185382, //隐患纬度
|
|
|
+ * "photoId":518, //隐患图片id
|
|
|
+ * "longitude":107.487296322 //隐患经度
|
|
|
+ * }]
|
|
|
+ * }
|
|
|
+ */
|
|
|
+ @PostMapping("/droneReport")
|
|
|
+ public AjaxResult droneReport(@RequestBody String jsonStr) {
|
|
|
+ if (StringUtils.isEmpty(jsonStr)) {
|
|
|
+ logger.error("参数为空");
|
|
|
+ return AjaxResult.error("参数为空");
|
|
|
+ }
|
|
|
+ logger.info("无人机数据: {}", jsonStr);
|
|
|
+
|
|
|
+ try {
|
|
|
+ JSONObject jsonObject = JSON.parseObject(URLToJSONConverter.convertURLToJSON(jsonStr));
|
|
|
+ JSONArray dataArray = jsonObject.getJSONArray("data");
|
|
|
+
|
|
|
+ if (dataArray == null || dataArray.isEmpty()) {
|
|
|
+ logger.error("数据格式异常: 缺少data数组");
|
|
|
+ return AjaxResult.error("数据格式异常");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<DroneVO> droneArray = dataArray.stream()
|
|
|
+ .map(data -> JSON.parseObject(data.toString(), DroneVO.class))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ return toAjax(alarmEventService.insertDroneEvent(droneArray));
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("数据处理失败: {}", e.getMessage());
|
|
|
+ return AjaxResult.error("处理失败: " + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|