From 549d799b98f4bffc4a9ec7c3a508cfd3ef34775a Mon Sep 17 00:00:00 2001 From: hxh <762326930@qq.com> Date: Mon, 25 Mar 2024 17:39:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8C=87=E6=A0=87=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/IndicatorController.java | 38 +++++++++++++++++++ .../kms/yxgh/common/dto/WarningQueDto.java | 3 -- .../yxgh/common/mapper/IndicatorMapper.java | 19 ++++++++++ .../yxgh/common/service/IndicatorService.java | 20 ++++++++++ .../common/service/VideoWarningService.java | 10 +---- .../yxgh/common/service/WarningService.java | 12 ------ sql/sy/v1.2.0/全量脚本/statistic.sql | 1 + 7 files changed, 79 insertions(+), 24 deletions(-) create mode 100644 shuili-system/src/main/java/com/kms/yxgh/common/controller/IndicatorController.java diff --git a/shuili-system/src/main/java/com/kms/yxgh/common/controller/IndicatorController.java b/shuili-system/src/main/java/com/kms/yxgh/common/controller/IndicatorController.java new file mode 100644 index 00000000..c92ab94a --- /dev/null +++ b/shuili-system/src/main/java/com/kms/yxgh/common/controller/IndicatorController.java @@ -0,0 +1,38 @@ +package com.kms.yxgh.common.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.kms.yxgh.common.dto.IndicatorDto; +import com.kms.yxgh.common.dto.WarningQueDto; +import com.kms.yxgh.common.service.IndicatorService; +import com.shuili.common.core.domain.SearchParam; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @ClassName: WarningDataController + * @Description: TODO + * @Date: 2024/3/24 下午9:27 + * * + * @author: hxh + * @version: 1.0 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/run/api/indicator") +@Api(tags = "运行管理运行指标相关") +public class IndicatorController { + + private final IndicatorService indicatorService; + + //运行指标列表 + @PostMapping("/list") + @ApiOperation("运行指标列表") + public IPage list(@RequestBody SearchParam sp) { + return indicatorService.list(sp); + } +} diff --git a/shuili-system/src/main/java/com/kms/yxgh/common/dto/WarningQueDto.java b/shuili-system/src/main/java/com/kms/yxgh/common/dto/WarningQueDto.java index 04771369..c8eeda67 100644 --- a/shuili-system/src/main/java/com/kms/yxgh/common/dto/WarningQueDto.java +++ b/shuili-system/src/main/java/com/kms/yxgh/common/dto/WarningQueDto.java @@ -21,9 +21,6 @@ import java.util.List; @ApiModel("预警查询条件") public class WarningQueDto { - @ApiModelProperty("查询的小时数") - private Integer fromTime; - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @ApiModelProperty("开始时间") private Date startTime; diff --git a/shuili-system/src/main/java/com/kms/yxgh/common/mapper/IndicatorMapper.java b/shuili-system/src/main/java/com/kms/yxgh/common/mapper/IndicatorMapper.java index 4ff475a6..64e55e57 100644 --- a/shuili-system/src/main/java/com/kms/yxgh/common/mapper/IndicatorMapper.java +++ b/shuili-system/src/main/java/com/kms/yxgh/common/mapper/IndicatorMapper.java @@ -1,7 +1,13 @@ package com.kms.yxgh.common.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.kms.yxgh.common.domain.Indicator; +import com.kms.yxgh.common.dto.IndicatorDto; +import com.kms.yxgh.common.dto.WarningQueDto; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; import org.springframework.stereotype.Repository; /** @@ -15,4 +21,17 @@ import org.springframework.stereotype.Repository; @Repository public interface IndicatorMapper extends BaseMapper { + + @Select("") + IPage search(Page page, @Param("data") WarningQueDto data); } diff --git a/shuili-system/src/main/java/com/kms/yxgh/common/service/IndicatorService.java b/shuili-system/src/main/java/com/kms/yxgh/common/service/IndicatorService.java index 7e53bcee..dab40c10 100644 --- a/shuili-system/src/main/java/com/kms/yxgh/common/service/IndicatorService.java +++ b/shuili-system/src/main/java/com/kms/yxgh/common/service/IndicatorService.java @@ -1,7 +1,18 @@ package com.kms.yxgh.common.service; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.kms.yxgh.common.domain.Indicator; +import com.kms.yxgh.common.dto.IndicatorDto; +import com.kms.yxgh.common.dto.WarningQueDto; +import com.kms.yxgh.common.mapper.IndicatorMapper; +import com.shuili.common.core.domain.SearchParam; +import com.shuili.common.utils.StringUtils; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import java.util.Optional; + /** * @ClassName: WarningDataService * @Description: TODO @@ -12,5 +23,14 @@ import org.springframework.stereotype.Service; */ @Service +@RequiredArgsConstructor public class IndicatorService { + + private final IndicatorMapper indicatorMapper; + + public IPage list(SearchParam sp) { + Page page = new Page<>(sp.getPageNum(), sp.getPageSize()); + WarningQueDto data = Optional.ofNullable(sp.getData()).orElse(new WarningQueDto()); + return indicatorMapper.search(page, data); + } } diff --git a/shuili-system/src/main/java/com/kms/yxgh/common/service/VideoWarningService.java b/shuili-system/src/main/java/com/kms/yxgh/common/service/VideoWarningService.java index 48b84b59..d704eba8 100644 --- a/shuili-system/src/main/java/com/kms/yxgh/common/service/VideoWarningService.java +++ b/shuili-system/src/main/java/com/kms/yxgh/common/service/VideoWarningService.java @@ -32,9 +32,7 @@ public class VideoWarningService { if (StringUtils.isNotBlank(data.getAdcd())) { data.setAdcd(remove00(data.getAdcd())); } - if (data.getFromTime() != null && data.getStartTime() == null) { - data.setStartTime(getBeforeTime(data.getFromTime())); - } + return videoWarningMapper.search(page, data, getOrderBy(sp.getParams())); } @@ -60,12 +58,6 @@ public class VideoWarningService { return str; } - //计算指定小时数前的时间 - private Date getBeforeTime(Integer fromTime) { - Calendar calendar = Calendar.getInstance(); - calendar.add(Calendar.HOUR, -fromTime); - return calendar.getTime(); - } public VideoWarningDto detail(String id) { return videoWarningMapper.detail(id); diff --git a/shuili-system/src/main/java/com/kms/yxgh/common/service/WarningService.java b/shuili-system/src/main/java/com/kms/yxgh/common/service/WarningService.java index 568b2b55..f3e1d218 100644 --- a/shuili-system/src/main/java/com/kms/yxgh/common/service/WarningService.java +++ b/shuili-system/src/main/java/com/kms/yxgh/common/service/WarningService.java @@ -19,8 +19,6 @@ import lombok.RequiredArgsConstructor; import org.apache.commons.collections.CollectionUtils; import org.springframework.stereotype.Service; -import java.util.Calendar; -import java.util.Date; import java.util.Optional; import java.util.stream.Collectors; @@ -51,9 +49,6 @@ public class WarningService { if (data.getStartTime() != null && data.getEndTime() != null) { wrapper.between(DeviceCheckingRecordView::getWarningTime, data.getStartTime(), data.getEndTime()); - } else if (data.getFromTime() != null) { - Date time = getBeforeTime(data.getFromTime()); - wrapper.ge(DeviceCheckingRecordView::getWarningTime, time); } IPage iPage = warningMapper.selectPage(page, wrapper); return iPage.convert(item -> { @@ -72,13 +67,6 @@ public class WarningService { return str; } - //计算指定小时数前的时间 - private Date getBeforeTime(Integer fromTime) { - Calendar calendar = Calendar.getInstance(); - calendar.add(Calendar.HOUR, -fromTime); - return calendar.getTime(); - } - public WarningStatisticDto statistic(WarningStatisticQueDto sp) { Page page = new Page<>(1, sp.getTopN()); page.setMaxLimit(Long.valueOf(sp.getTopN())); diff --git a/sql/sy/v1.2.0/全量脚本/statistic.sql b/sql/sy/v1.2.0/全量脚本/statistic.sql index ea714491..4a0413a1 100644 --- a/sql/sy/v1.2.0/全量脚本/statistic.sql +++ b/sql/sy/v1.2.0/全量脚本/statistic.sql @@ -1,5 +1,6 @@ SET NAMES utf8mb4; +DROP TABLE IF EXISTS `bs_sgc_stc_jc`; CREATE TABLE `bs_sgc_stc_jc` ( `ID` int NOT NULL AUTO_INCREMENT COMMENT '监测id', `STCD` varchar(255) COLLATE utf8mb4_general_ci COMMENT '测站编码',