|
@@ -0,0 +1,63 @@
|
|
|
|
+package com.huimv.eartag2.api.controller;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.huimv.eartag2.api.mapper.CameraTestMapper;
|
|
|
|
+import com.huimv.eartag2.api.pojo.CameraTest;
|
|
|
|
+import com.huimv.eartag2.api.pojo.pojovo.CameraTestVo;
|
|
|
|
+import com.huimv.eartag2.api.service.ICameraTestService;
|
|
|
|
+import com.huimv.eartag2.api.utils.IpUtil;
|
|
|
|
+import com.huimv.eartag2.common.utils.Result;
|
|
|
|
+import com.huimv.eartag2.common.utils.ResultCode;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * <p>
|
|
|
|
+ * 前端控制器
|
|
|
|
+ * </p>
|
|
|
|
+ *
|
|
|
|
+ * @author author
|
|
|
|
+ * @since 2024-04-19
|
|
|
|
+ */
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("/camera-test")
|
|
|
|
+public class CameraTestController {
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICameraTestService testService;
|
|
|
|
+
|
|
|
|
+ @GetMapping("/getUrl")
|
|
|
|
+ public void getUrl(HttpServletRequest request, @RequestParam(value = "farmId") Integer farmId) {
|
|
|
|
+ String ipAddr = IpUtil.getIpAddr(request);
|
|
|
|
+ QueryWrapper<CameraTest> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("farm_id", farmId);
|
|
|
|
+ List<CameraTest> areas = testService.list();
|
|
|
|
+ for (CameraTest area : areas) {
|
|
|
|
+ area.setIpAddr(ipAddr+":9080");
|
|
|
|
+ area.setUpdateDate(new Date());
|
|
|
|
+ testService.updateById(area);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/list")
|
|
|
|
+ public Result list() {
|
|
|
|
+ List<CameraTest> areas = testService.list();
|
|
|
|
+ List<CameraTestVo> cameraTestVos = new ArrayList<>();
|
|
|
|
+ for (CameraTest area : areas) {
|
|
|
|
+ CameraTestVo vo = new CameraTestVo();
|
|
|
|
+ vo.setWsUrl("ws://" + area.getIpAddr() + "/camera_relay?tcpaddr=" + area.getAccount() + "%3A" + area.getPassword() + "%40" + area.getCameraIp());
|
|
|
|
+ vo.setRtspUrl("rtsp://" + area.getAccount() + ":" + area.getPassword() + "@" + area.getCameraIp() +" /stream1&channel=1");
|
|
|
|
+ vo.setCameraName(area.getCameraName());
|
|
|
|
+ cameraTestVos.add(vo);
|
|
|
|
+ }
|
|
|
|
+ return new Result(ResultCode.SUCCESS, cameraTestVos);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|