From b0da16d64a5ea89a642d884b5cba259cd26315b3 Mon Sep 17 00:00:00 2001 From: yangwei <867012372@qq.com> Date: Mon, 10 Mar 2025 17:31:55 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=201=E3=80=81=E4=BF=AE=E6=94=B9=E9=A2=84?= =?UTF-8?q?=E8=AD=A6=E7=BB=9F=E8=AE=A1=E6=8E=A5=E5=8F=A3,=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=A2=84=E8=AD=A6=E5=AF=B9=E6=AF=94=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=202=E3=80=81=E5=BC=80=E5=8F=91=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E6=B5=81=E5=BC=80=E5=A7=8B=E5=BD=95=E5=88=B6=E3=80=81?= =?UTF-8?q?=E5=81=9C=E6=AD=A2=E5=BD=95=E5=88=B6=E3=80=81=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=BD=95=E5=88=B6=E3=80=81=E8=8E=B7=E5=8F=96=E6=88=AA=E5=9B=BE?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=B9=B6=E4=B8=94?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessAlertStatisticsController.java | 4 +- .../controller/BusinessVideoController.java | 4 +- ...a => IBusinessAlertStatisticsService.java} | 2 +- ...ervice.java => IBusinessVideoService.java} | 4 +- .../BusinessAlertStatisticsServiceImpl.java | 6 +- .../impl/BusinessVideoServiceImpl.java | 56 +++++++++++-------- 6 files changed, 41 insertions(+), 35 deletions(-) rename dk-modules/business/src/main/java/org/dromara/business/service/{BusinessAlertStatisticsService.java => IBusinessAlertStatisticsService.java} (93%) rename dk-modules/business/src/main/java/org/dromara/business/service/{BusinessVideoService.java => IBusinessVideoService.java} (78%) diff --git a/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java b/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java index d2ce01a..70fa519 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java +++ b/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") diff --git a/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessVideoController.java b/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessVideoController.java index 182287f..db4f6ed 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessVideoController.java +++ b/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; /** diff --git a/dk-modules/business/src/main/java/org/dromara/business/service/BusinessAlertStatisticsService.java b/dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java similarity index 93% rename from dk-modules/business/src/main/java/org/dromara/business/service/BusinessAlertStatisticsService.java rename to dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java index a3041a2..d95ba00 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/service/BusinessAlertStatisticsService.java +++ b/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 countMonthAlert(BusinessAlertBo businessAlertBo); List countDepartAlert(BusinessAlertBo businessAlertBo); diff --git a/dk-modules/business/src/main/java/org/dromara/business/service/BusinessVideoService.java b/dk-modules/business/src/main/java/org/dromara/business/service/IBusinessVideoService.java similarity index 78% rename from dk-modules/business/src/main/java/org/dromara/business/service/BusinessVideoService.java rename to dk-modules/business/src/main/java/org/dromara/business/service/IBusinessVideoService.java index 3a03385..f61671b 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/service/BusinessVideoService.java +++ b/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); diff --git a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java b/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java index 05a8caa..3189668 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java +++ b/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; diff --git a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessVideoServiceImpl.java b/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessVideoServiceImpl.java index 2e565ba..3cb1158 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessVideoServiceImpl.java +++ b/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 response = restTemplate.getForEntity(url, String.class); if (response.getStatusCode().is2xxSuccessful()) { - Map result = objectMapper.readValue(response.getBody(), Map.class); - log.info("录制启动成功: {}", result); + Map 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 response = restTemplate.getForEntity(url, String.class); if (response.getStatusCode().is2xxSuccessful()) { - Map result = objectMapper.readValue(response.getBody(), Map.class); - log.info("录制停止成功: {}", result); + Map 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 response = restTemplate.getForEntity(url, String.class); if (response.getStatusCode().is2xxSuccessful()) { Map 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 response = restTemplate.getForEntity(url, String.class); if (response.getStatusCode().is2xxSuccessful()) { - Map result = objectMapper.readValue(response.getBody(), Map.class); + Map 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 response = restTemplate.getForEntity(url, String.class); if (response.getStatusCode().is2xxSuccessful()) { - Map result = objectMapper.readValue(response.getBody(), Map.class); - log.info("设置录像流播放位置成功: {}", result); + Map 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; } }