Browse Source

[feat]

1、修改预警统计接口,增加预警对比统计接口
2、开发视频流开始录制、停止录制、是否录制、获取截图相关接口,并且测试。
pull/1/head
杨威 3 months ago
parent
commit
b0da16d64a
  1. 4
      dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java
  2. 4
      dk-modules/business/src/main/java/org/dromara/business/controller/BusinessVideoController.java
  3. 2
      dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java
  4. 4
      dk-modules/business/src/main/java/org/dromara/business/service/IBusinessVideoService.java
  5. 6
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java
  6. 56
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessVideoServiceImpl.java

4
dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java

@ -5,7 +5,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.dromara.business.domain.bo.BusinessAlertBo;
import org.dromara.business.domain.model.StatObj;
import org.dromara.business.service.BusinessAlertStatisticsService;
import org.dromara.business.service.IBusinessAlertStatisticsService;
import org.dromara.common.core.domain.R;
import org.dromara.common.web.core.BaseController;
import org.springframework.web.bind.annotation.GetMapping;
@ -24,7 +24,7 @@ import java.util.Map;
@RequestMapping("/alert/statistics")
public class BusinessAlertStatisticsController extends BaseController {
private final BusinessAlertStatisticsService statisticsService;
private final IBusinessAlertStatisticsService statisticsService;
@Operation(summary="panel看板数据", description="panel看板数据")
@GetMapping(value = "/panel/count")

4
dk-modules/business/src/main/java/org/dromara/business/controller/BusinessVideoController.java

@ -5,7 +5,7 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.dromara.business.service.BusinessVideoService;
import org.dromara.business.service.IBusinessVideoService;
import org.dromara.common.core.domain.R;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
@ -23,7 +23,7 @@ import org.springframework.web.bind.annotation.RestController;
@Tag(name = "ZLMediaKit视频流相关操作")
public class BusinessVideoController {
private final BusinessVideoService businessVideoService;
private final IBusinessVideoService businessVideoService;
/**

2
dk-modules/business/src/main/java/org/dromara/business/service/BusinessAlertStatisticsService.java → dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java

@ -7,7 +7,7 @@ import org.dromara.business.domain.model.StatObj;
import java.util.List;
import java.util.Map;
public interface BusinessAlertStatisticsService {
public interface IBusinessAlertStatisticsService {
List<StatObj> countMonthAlert(BusinessAlertBo businessAlertBo);
List<StatObj> countDepartAlert(BusinessAlertBo businessAlertBo);

4
dk-modules/business/src/main/java/org/dromara/business/service/BusinessVideoService.java → dk-modules/business/src/main/java/org/dromara/business/service/IBusinessVideoService.java

@ -1,12 +1,12 @@
package org.dromara.business.service;
public interface BusinessVideoService {
public interface IBusinessVideoService {
Boolean startRecording();
Boolean stopRecording();
String isRecording();
Boolean isRecording();
Boolean setRecordSpeed(Double speed);

6
dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java

@ -6,12 +6,10 @@ import org.apache.dubbo.config.annotation.DubboReference;
import org.dromara.business.domain.bo.BusinessAlertBo;
import org.dromara.business.domain.model.StatObj;
import org.dromara.business.mapper.BusinessAlertMapper;
import org.dromara.business.service.BusinessAlertStatisticsService;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.business.service.IBusinessAlertStatisticsService;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.system.api.RemoteDeptService;
import org.dromara.system.api.domain.vo.RemoteDeptVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
@ -26,7 +24,7 @@ import java.util.stream.Stream;
*/
@RequiredArgsConstructor
@Service
public class BusinessAlertStatisticsServiceImpl implements BusinessAlertStatisticsService {
public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatisticsService {
private final BusinessAlertMapper baseMapper;

56
dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessVideoServiceImpl.java

@ -5,19 +5,17 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.business.config.ZlmConfig;
import org.dromara.business.service.BusinessVideoService;
import org.dromara.business.service.IBusinessVideoService;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;
@Service
@Slf4j
@RequiredArgsConstructor
public class BusinessVideoServiceImpl implements BusinessVideoService {
public class BusinessVideoServiceImpl implements IBusinessVideoService {
private final ZlmConfig zlmConfig;
private static final ObjectMapper objectMapper = new ObjectMapper();
@ -27,6 +25,7 @@ public class BusinessVideoServiceImpl implements BusinessVideoService {
@Override
public Boolean startRecording() {
Boolean result = false;
String url = String.format("%s%s?app=%s&stream=%s&type=%s&vhost=%s&secret=%s",
zlmConfig.getApiUrl(),
zlmConfig.getStartRecordUrl(),
@ -44,19 +43,22 @@ public class BusinessVideoServiceImpl implements BusinessVideoService {
try {
ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
if (response.getStatusCode().is2xxSuccessful()) {
Map<String, Object> result = objectMapper.readValue(response.getBody(), Map.class);
log.info("录制启动成功: {}", result);
Map<String, Object> resultMap = objectMapper.readValue(response.getBody(), Map.class);
result = (Boolean) resultMap.get("status");
log.info("录制启动成功: {}", resultMap);
}
} catch (Exception e) {
log.error("请求异常: {}", e.getMessage(), e);
return false;
return result;
}
return true;
return result;
}
@Override
public Boolean stopRecording() {
Boolean result = false;
String url = String.format("%s%s?app=%s&stream=%s&type=%s&vhost=%s&secret=%s",
zlmConfig.getApiUrl(),
zlmConfig.getStopRecordUrl(),
@ -69,20 +71,21 @@ public class BusinessVideoServiceImpl implements BusinessVideoService {
try {
ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
if (response.getStatusCode().is2xxSuccessful()) {
Map<String, Object> result = objectMapper.readValue(response.getBody(), Map.class);
log.info("录制停止成功: {}", result);
Map<String, Object> resultMap = objectMapper.readValue(response.getBody(), Map.class);
result = (Boolean) resultMap.get("status");
log.info("录制停止成功: {}", resultMap);
}
} catch (Exception e) {
log.error("请求异常: {}", e.getMessage(), e);
return false;
return result;
}
return true;
return result;
}
@Override
public String isRecording() {
String result = null;
public Boolean isRecording() {
Boolean result = false;
String url = String.format("%s%s?app=%s&stream=%s&type=%s&vhost=%s&secret=%s",
zlmConfig.getApiUrl(),
@ -97,13 +100,12 @@ public class BusinessVideoServiceImpl implements BusinessVideoService {
ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
if (response.getStatusCode().is2xxSuccessful()) {
Map<String, Object> resultMap = objectMapper.readValue(response.getBody(), Map.class);
result = resultMap.get("status") + "";
result = (Boolean) resultMap.get("status");
log.info("获取录制状态成功: {}", resultMap);
}
return result;
} catch (Exception e) {
log.error("请求异常: {}", e.getMessage(), e);
return result;
}
return result;
@ -111,6 +113,8 @@ public class BusinessVideoServiceImpl implements BusinessVideoService {
@Override
public Boolean setRecordSpeed(Double speed) {
Boolean result = false;
String url = String.format("%s%s?app=%s&stream=%s&type=%s&vhost=%s&secret=%s&speed=%s",
zlmConfig.getApiUrl(),
zlmConfig.getRecordSpeedUrl(),
@ -124,15 +128,16 @@ public class BusinessVideoServiceImpl implements BusinessVideoService {
try {
ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
if (response.getStatusCode().is2xxSuccessful()) {
Map<String, Object> result = objectMapper.readValue(response.getBody(), Map.class);
Map<String, Object> resultMap = objectMapper.readValue(response.getBody(), Map.class);
result = (Boolean) resultMap.get("status");
log.info("设置录制速度成功: {}", result);
}
} catch (Exception e) {
log.error("请求异常: {}", e.getMessage(), e);
return false;
return result;
}
return true;
return result;
}
@Override
@ -163,6 +168,8 @@ public class BusinessVideoServiceImpl implements BusinessVideoService {
@Override
public Boolean seekRecordStamp(Integer stamp) {
Boolean result = false;
String url = String.format("%s%s?app=%s&stream=%s&vhost=%s&secret=%s&stamp=%s",
zlmConfig.getApiUrl(),
zlmConfig.getSeekRecordStampUrl(),
@ -175,14 +182,15 @@ public class BusinessVideoServiceImpl implements BusinessVideoService {
try {
ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
if (response.getStatusCode().is2xxSuccessful()) {
Map<String, Object> result = objectMapper.readValue(response.getBody(), Map.class);
log.info("设置录像流播放位置成功: {}", result);
Map<String, Object> resultMap = objectMapper.readValue(response.getBody(), Map.class);
result = (Boolean) resultMap.get("status");
log.info("设置录像流播放位置成功: {}", resultMap);
}
} catch (Exception e) {
log.error("请求异常: {}", e.getMessage(), e);
return false;
return result;
}
return true;
return result;
}
}

Loading…
Cancel
Save