|
@@ -0,0 +1,180 @@
|
|
|
|
+package com.aidex.web.controller.camera;
|
|
|
|
+
|
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
|
+import com.aidex.common.annotation.Log;
|
|
|
|
+import com.aidex.common.constant.Constants;
|
|
|
|
+import com.aidex.common.core.controller.BaseController;
|
|
|
|
+import com.aidex.common.core.domain.BaseEntity;
|
|
|
|
+import com.aidex.common.core.domain.R;
|
|
|
|
+import com.aidex.common.core.page.PageDomain;
|
|
|
|
+import com.aidex.common.core.redis.RedisCache;
|
|
|
|
+import com.aidex.common.enums.BusinessType;
|
|
|
|
+import com.aidex.common.utils.poi.ExcelUtil;
|
|
|
|
+import com.aidex.framework.cache.ConfigUtils;
|
|
|
|
+import com.aidex.framework.cache.DictUtils;
|
|
|
|
+import com.aidex.system.domain.SysCamera;
|
|
|
|
+import com.aidex.system.domain.SysConfig;
|
|
|
|
+import com.aidex.system.domain.SysWharf;
|
|
|
|
+import com.aidex.system.service.SysWharfService;
|
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 摄像头管理Controller
|
|
|
|
+ * @author ChenSir
|
|
|
|
+ * @email 914769835
|
|
|
|
+ * @date 2024-03-16
|
|
|
|
+ */
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("/system/camera")
|
|
|
|
+public class SysCameraController extends BaseController {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysWharfService sysWharfService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private RedisCache redisCache;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询摄像头管理列表
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/list")
|
|
|
|
+ public R list(SysCamera sysCamera, HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
+ String result = "";
|
|
|
|
+ sysCamera.setPage(new PageDomain(request, response));
|
|
|
|
+ String accessToken = redisCache.getStringValue(Constants.CAMERA_ACCESS_TOKEN_PREFIX);
|
|
|
|
+ SysConfig configUrl = ConfigUtils.getConfigByKey("sys.monitor.camera.url");
|
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
|
+ params.put("pageNum", sysCamera.getPage().getPageNum());
|
|
|
|
+ params.put("pageSize", sysCamera.getPage().getPageSize());
|
|
|
|
+ params.put("accessToken", accessToken);
|
|
|
|
+ /*JSONObject params1 = JSONObject.parseObject(JSON.toJSONString(sysCamera));
|
|
|
|
+ params.putAll(params1);*/
|
|
|
|
+ if (configUrl != null){
|
|
|
|
+ String url = configUrl.getConfigValue();
|
|
|
|
+ //链式构建请求
|
|
|
|
+ result = HttpRequest.post(url + "/api/device-service/lapp/v1/camera/list")
|
|
|
|
+ .body(params.toJSONString())//表单内容
|
|
|
|
+ .timeout(50000)//超时,毫秒
|
|
|
|
+ .execute().body();
|
|
|
|
+ R resultR = JSONObject.parseObject(result, R.class);
|
|
|
|
+ return resultR;
|
|
|
|
+ }
|
|
|
|
+ return R.data(null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询码头管理列表
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/openLive")
|
|
|
|
+ public R openLive(@RequestBody @Validated SysCamera sysCamera) {
|
|
|
|
+ String result = "";
|
|
|
|
+ String accessToken = redisCache.getStringValue(Constants.CAMERA_ACCESS_TOKEN_PREFIX);
|
|
|
|
+ SysConfig configUrl = ConfigUtils.getConfigByKey("sys.monitor.camera.url");
|
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
|
+ params.put("deviceSn", sysCamera.getDeviceSn());
|
|
|
|
+ params.put("channelNo", sysCamera.getChannelNo());
|
|
|
|
+ // 有效期 30天 可以取30s-360d
|
|
|
|
+ params.put("expireTime", 60*60*24*30);
|
|
|
|
+ // 流播放协议,0-rtc、1-hls、2-rtsp、3-rtmp、4-flv,默认为 0
|
|
|
|
+ params.put("protocol", 4);
|
|
|
|
+ // 视频清晰度,0-流畅(子码流)、1-高清(主码流)默认为 0
|
|
|
|
+ params.put("quality", 1);
|
|
|
|
+ params.put("accessToken", accessToken);
|
|
|
|
+ if (configUrl != null){
|
|
|
|
+ String url = configUrl.getConfigValue();
|
|
|
|
+ //链式构建请求
|
|
|
|
+ result = HttpRequest.post(url + "/api/device-service/lapp/v1/live/address/get")
|
|
|
|
+ .body(params.toJSONString())//表单内容
|
|
|
|
+ .timeout(50000)//超时,毫秒
|
|
|
|
+ .execute().body();
|
|
|
|
+ R resultR = JSONObject.parseObject(result, R.class);
|
|
|
|
+ return resultR;
|
|
|
|
+ }
|
|
|
|
+ return R.data(null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取码头管理详细信息
|
|
|
|
+ */
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:sysWharf:query')")
|
|
|
|
+ @GetMapping(value = "/{id}")
|
|
|
|
+ public R<SysWharf> detail(@PathVariable("id") String id) {
|
|
|
|
+ return R.data(sysWharfService.get(id));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 新增码头管理
|
|
|
|
+ */
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:sysWharf:add')")
|
|
|
|
+ @Log(title = "码头管理", businessType = BusinessType.INSERT)
|
|
|
|
+ @PostMapping
|
|
|
|
+ public R add(@RequestBody @Validated SysWharf sysWharf) {
|
|
|
|
+ return R.status(sysWharfService.save(sysWharf));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 修改码头管理
|
|
|
|
+ */
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:sysWharf:edit')")
|
|
|
|
+ @Log(title = "码头管理", businessType = BusinessType.UPDATE)
|
|
|
|
+ @PutMapping
|
|
|
|
+ public R edit(@RequestBody @Validated SysWharf sysWharf) {
|
|
|
|
+ return R.status(sysWharfService.save(sysWharf));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 修改码头状态
|
|
|
|
+ */
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:sysWharf:edit')")
|
|
|
|
+ @Log(title = "码头管理", businessType = BusinessType.UPDATE)
|
|
|
|
+ @PutMapping("/updateStatus")
|
|
|
|
+ public R updateStatus(@RequestBody @Validated SysWharf sysWharf) {
|
|
|
|
+ return R.status(sysWharfService.updateStatus(sysWharf));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除码头管理
|
|
|
|
+ */
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:sysWharf:remove')")
|
|
|
|
+ @Log(title = "码头管理", businessType = BusinessType.DELETE)
|
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
|
+ public R remove(@PathVariable String[] ids) {
|
|
|
|
+ return R.status(sysWharfService.deleteSysWharfByIds(ids));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 导出码头管理列表
|
|
|
|
+ */
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:sysWharf:export')")
|
|
|
|
+ @Log(title = "码头管理", businessType = BusinessType.EXPORT)
|
|
|
|
+ @GetMapping("/export")
|
|
|
|
+ public R export(SysWharf sysWharf) {
|
|
|
|
+ List<SysWharf> list = sysWharfService.findList(sysWharf);
|
|
|
|
+ ExcelUtil<SysWharf> util = new ExcelUtil<SysWharf>(SysWharf.class);
|
|
|
|
+ return util.exportExcel(list, "码头管理数据");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据字典类型查询字典数据信息等其他自定义信息
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/getInitData/{dictTypes}")
|
|
|
|
+ public R getInitData(@PathVariable String dictTypes) {
|
|
|
|
+ Map<String, Object> dataMap = new HashMap<String, Object>();
|
|
|
|
+ dataMap.putAll(DictUtils.getMultiDictList(dictTypes));
|
|
|
|
+ return R.data(dataMap);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|