|
@@ -3,12 +3,11 @@ package cn.iocoder.yudao.module.pms.controller.admin.alarm;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.alarm.vo.IotVideoAlarmPageReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.alarm.vo.IotVideoAlarmPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.alarm.vo.IotVideoAlarmRespVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.alarm.vo.IotVideoAlarmRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.alarm.vo.IotVideoAlarmSaveReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.alarm.vo.IotVideoAlarmSaveReqVO;
|
|
|
-import cn.iocoder.yudao.module.pms.controller.admin.inspect.order.vo.IotInspectOrderRespVO;
|
|
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.alarm.IotVideoAlarmDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.alarm.IotVideoAlarmDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.yanfan.sip.device.channel.YfSipDeviceChannelDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.yanfan.sip.device.channel.YfSipDeviceChannelDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.yanfan.sip.device.channel.YfSipDeviceChannelMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.yanfan.sip.device.channel.YfSipDeviceChannelMapper;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.hik.HikIsapiService;
|
|
|
import cn.iocoder.yudao.module.pms.service.alarm.IotVideoAlarmService;
|
|
import cn.iocoder.yudao.module.pms.service.alarm.IotVideoAlarmService;
|
|
|
-import cn.iocoder.yudao.module.pms.service.yanfan.sip.device.channel.YfSipDeviceChannelService;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
@@ -48,6 +47,8 @@ public class IotVideoAlarmController {
|
|
|
private IotVideoAlarmService iotVideoAlarmService;
|
|
private IotVideoAlarmService iotVideoAlarmService;
|
|
|
@Resource
|
|
@Resource
|
|
|
private YfSipDeviceChannelMapper yfsipDeviceChannelMapper;
|
|
private YfSipDeviceChannelMapper yfsipDeviceChannelMapper;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private HikIsapiService hikIsapiService;
|
|
|
|
|
|
|
|
@PostMapping("/create")
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建资料")
|
|
@Operation(summary = "创建资料")
|
|
@@ -115,4 +116,38 @@ public class IotVideoAlarmController {
|
|
|
BeanUtils.toBean(list, IotVideoAlarmRespVO.class));
|
|
BeanUtils.toBean(list, IotVideoAlarmRespVO.class));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/pic/{id}")
|
|
|
|
|
+ @Operation(summary = "获得视频告警图片")
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-video-alarm:query')")
|
|
|
|
|
+ public CommonResult<String> getAlarmPic(@PathVariable Long id) throws IOException {
|
|
|
|
|
+ IotVideoAlarmDO iotVideoAlarm = iotVideoAlarmService.getIotVideoAlarm(id);
|
|
|
|
|
+ String url = "";
|
|
|
|
|
+ if (iotVideoAlarm != null) {
|
|
|
|
|
+ if (StringUtils.isNotBlank(iotVideoAlarm.getUrl())) {
|
|
|
|
|
+ url = iotVideoAlarm.getUrl();
|
|
|
|
|
+ } else if (StringUtils.isNotBlank(iotVideoAlarm.getImageUrl())){
|
|
|
|
|
+ url = iotVideoAlarm.getImageUrl();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ byte[] picInfo = new byte[0];
|
|
|
|
|
+ if (StringUtils.isNotBlank(url)) {
|
|
|
|
|
+ picInfo = hikIsapiService.getPicInfo("nvr-001", url);
|
|
|
|
|
+ }
|
|
|
|
|
+// // 2. 设置响应头,告诉前端这是图片流
|
|
|
|
|
+// HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
+// // 根据实际图片格式调整(海康通常返回jpeg)
|
|
|
|
|
+// headers.setContentType(MediaType.IMAGE_JPEG);
|
|
|
|
|
+// // 设置内容长度,提升传输效率
|
|
|
|
|
+// headers.setContentLength(picInfo.length);
|
|
|
|
|
+// // 禁止缓存(可选,根据业务需求)
|
|
|
|
|
+// headers.setCacheControl("no-cache, no-store, must-revalidate");
|
|
|
|
|
+//
|
|
|
|
|
+// // 3. 返回二进制流和响应头
|
|
|
|
|
+// return success(new ByteArrayInputStream(picInfo));
|
|
|
|
|
+ String base64Pic = Base64.getEncoder().encodeToString(picInfo);
|
|
|
|
|
+
|
|
|
|
|
+ // 4. 用CommonResult封装返回
|
|
|
|
|
+ return success(base64Pic);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|