|
|
@@ -3,11 +3,10 @@ package cn.reghao.tnb.content.app.disk.controller;
|
|
|
import cn.reghao.jutil.jdk.result.Result;
|
|
|
import cn.reghao.jutil.web.WebResult;
|
|
|
import cn.reghao.tnb.common.auth.AuthUser;
|
|
|
+import cn.reghao.tnb.content.app.disk.model.dto.CamDeviceDto;
|
|
|
import cn.reghao.tnb.content.app.disk.model.dto.CamRecordDto;
|
|
|
-import cn.reghao.tnb.content.app.disk.model.vo.CamRecordDetail;
|
|
|
-import cn.reghao.tnb.content.app.disk.model.vo.CamRecordInfo;
|
|
|
-import cn.reghao.tnb.content.app.disk.model.vo.CamSearch;
|
|
|
-import cn.reghao.tnb.content.app.disk.model.vo.MarkDay;
|
|
|
+import cn.reghao.tnb.content.app.disk.model.po.CamDevice;
|
|
|
+import cn.reghao.tnb.content.app.disk.model.vo.*;
|
|
|
import cn.reghao.tnb.content.app.disk.service.CamRecordService;
|
|
|
import cn.reghao.tnb.content.app.disk.service.CamService;
|
|
|
import cn.reghao.tnb.content.app.geo.model.vo.SelectOption;
|
|
|
@@ -17,7 +16,6 @@ import org.springframework.http.MediaType;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
import java.time.LocalDate;
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -38,16 +36,30 @@ public class CamController {
|
|
|
this.camRecordService = camRecordService;
|
|
|
}
|
|
|
|
|
|
- @Operation(summary = "摄像头 key-value 列表", description = "N")
|
|
|
+ @Operation(summary = "添加摄像头", description = "N")
|
|
|
+ @PostMapping(value = "/device", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String addCamDevice(@RequestBody @Validated CamDeviceDto camDeviceDto) {
|
|
|
+ camService.addCamDevice(camDeviceDto);
|
|
|
+ return WebResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Operation(summary = "添加录像文件", description = "N")
|
|
|
+ @PostMapping(value = "/record", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String addCamRecord(@Validated @RequestBody CamRecordDto camRecordDto) {
|
|
|
+ Result result = camRecordService.addCamRecord(camRecordDto);
|
|
|
+ return WebResult.result(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Operation(summary = "摄像头 kv 列表", description = "N")
|
|
|
@GetMapping("/kv")
|
|
|
public String getCamKeyValues() {
|
|
|
List<SelectOption> kvs = camService.getCamKeyValues();
|
|
|
return WebResult.success(kvs);
|
|
|
}
|
|
|
|
|
|
- @Operation(summary = "摄像头详情页面", description = "N")
|
|
|
+ @Operation(summary = "摄像头详情", description = "N")
|
|
|
@GetMapping("/detail")
|
|
|
- public String getCamDetail(CamSearch camSearch) {
|
|
|
+ public String getCamDetail(@Validated CamSearch camSearch) {
|
|
|
List<SelectOption> kvs = camService.getCamKeyValues();
|
|
|
if (kvs.isEmpty()) {
|
|
|
return WebResult.failWithMsg("No Cam");
|
|
|
@@ -61,59 +73,26 @@ public class CamController {
|
|
|
|
|
|
Long camId = camSearch.getCamId();
|
|
|
if (camId == null) {
|
|
|
- camId = Long.parseLong(kvs.get(0).getLabel());
|
|
|
+ camId = Long.parseLong(kvs.get(0).getValue());
|
|
|
}
|
|
|
|
|
|
- String currentMonthStr = currentDayStr.substring(0, currentDayStr.lastIndexOf("-"));
|
|
|
- List<MarkDay> markDays = camRecordService.getDaysInMonth(camId, currentMonthStr);
|
|
|
- List<CamRecordInfo> dayRecords = camRecordService.getCamRecords(camId, currentDayStr);
|
|
|
- if (!dayRecords.isEmpty()) {
|
|
|
- CamRecordInfo camRecordInfo = dayRecords.get(0);
|
|
|
- long recordId = camRecordInfo.getRecordId();
|
|
|
- CamRecordDetail camRecordDetail = camRecordService.getCamRecord(recordId);
|
|
|
- if (camRecordDetail != null) {
|
|
|
- /*model.addAttribute("coverUrl", camRecordDetail.getCoverUrl());
|
|
|
- model.addAttribute("videoUrl", camRecordDetail.getVideoUrl());*/
|
|
|
- }
|
|
|
- } else {
|
|
|
- String videoUrl = "";
|
|
|
- CamRecordDetail camRecordDetail = camRecordService.getLatestRecord(camId);
|
|
|
- if (camRecordDetail != null) {
|
|
|
- //videoUrl = camRecordDetail.getVideoUrl();
|
|
|
- /*model.addAttribute("coverUrl", camRecordDetail.getCoverUrl());
|
|
|
- model.addAttribute("videoUrl", videoUrl);*/
|
|
|
- } else {
|
|
|
- /*model.addAttribute("coverUrl", "");
|
|
|
- model.addAttribute("videoUrl", videoUrl);*/
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /*model.addAttribute("camId", camId);
|
|
|
- model.addAttribute("kvs", kvs);
|
|
|
- model.addAttribute("markDays", markDays);
|
|
|
- model.addAttribute("dayRecords", dayRecords);
|
|
|
- model.addAttribute("viewDate", currentDayStr);*/
|
|
|
- return WebResult.success();
|
|
|
- }
|
|
|
-
|
|
|
- @Operation(summary = "添加录像", description = "N")
|
|
|
- @PostMapping(value = "/record", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public String addCamRecord(@Validated @RequestBody CamRecordDto camRecordDto) {
|
|
|
- Result result = camRecordService.add(camRecordDto);
|
|
|
- return WebResult.result(result);
|
|
|
+ CamDevice camDevice = camService.getCamDevice(camId);
|
|
|
+ List<CamRecordInfo> dayRecords = camRecordService.getCamRecordByDay(camId, currentDayStr);
|
|
|
+ CamDetail camDetail = new CamDetail(camDevice, yearMonthDay, dayRecords);
|
|
|
+ return WebResult.success(camDetail);
|
|
|
}
|
|
|
|
|
|
@Operation(summary = "某个月中哪些天有录像", description = "N")
|
|
|
@GetMapping(value = "/record/month", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public String getCamRecordByMonth(Long camId, String yearMonth) {
|
|
|
- List<MarkDay> list = camRecordService.getDaysInMonth(camId, yearMonth);
|
|
|
+ public String getCamRecordByMonth(@Validated CamSearch camSearch) {
|
|
|
+ List<String> list = camRecordService.getDaysInMonth(camSearch.getCamId(), camSearch.getYearMonth());
|
|
|
return WebResult.success(list);
|
|
|
}
|
|
|
|
|
|
- @Operation(summary = "获取录像", description = "N")
|
|
|
+ @Operation(summary = "获取某个录像的 URL", description = "N")
|
|
|
@GetMapping(value = "/record/url/{recordId}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
public String getCamRecord(@PathVariable("recordId") long recordId) {
|
|
|
- CamRecordDetail camRecord = camRecordService.getCamRecord(recordId);
|
|
|
+ CamRecordDetail camRecord = camRecordService.getCamRecordDetail(recordId);
|
|
|
if (camRecord != null) {
|
|
|
return WebResult.success(camRecord);
|
|
|
}
|
|
|
@@ -121,20 +100,6 @@ public class CamController {
|
|
|
return WebResult.fail();
|
|
|
}
|
|
|
|
|
|
- @Operation(summary = "开启/关闭摄像头", description = "N")
|
|
|
- @PostMapping(value = "/data", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public String submit(String deviceId, String content) throws IOException {
|
|
|
- camService.setCamState(deviceId);
|
|
|
- return WebResult.success();
|
|
|
- }
|
|
|
-
|
|
|
- @Operation(summary = "设置 cam 状态", description = "N")
|
|
|
- @PostMapping(value = "/state", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public String updateCamState(String deviceId, boolean onStream) throws IOException {
|
|
|
- camService.updateCamState(deviceId, onStream);
|
|
|
- return WebResult.success();
|
|
|
- }
|
|
|
-
|
|
|
@Operation(summary = "添加活动接口", description = "N")
|
|
|
@PostMapping(value = "/activity", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
public String addActivity() {
|