From 54f4184f2bf36b75638810b4136a05e4d4a171a2 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Sun, 18 Feb 2024 11:12:52 +0800 Subject: [PATCH] =?UTF-8?q?#=E6=BC=94=E7=A4=BA=E5=B9=B3=E5=8F=B0=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E3=80=8130=E5=A4=A9=E5=8F=91=E7=94=B5=E9=87=8F?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/operational/data/vo/StationNumberVo.java | 19 ++++++++++++ .../data/controller/HzimsDataController.java | 10 +++---- .../operational/data/service/HzimsDataService.java | 4 ++- .../data/service/impl/HzimsDataServiceImpl.java | 34 +++++++++++++++++----- 4 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/data/vo/StationNumberVo.java diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/data/vo/StationNumberVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/data/vo/StationNumberVo.java new file mode 100644 index 0000000..dfef722 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/data/vo/StationNumberVo.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.operational.data.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "水利站点首页对象") +public class StationNumberVo { + + @ApiModelProperty(value = "站点类型") + private Integer type; + + @ApiModelProperty(value = "站点数量") + private Integer count; +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java index 373f3c9..d925cf7 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java @@ -35,11 +35,11 @@ public class HzimsDataController { } @ApiLog - @GetMapping("/saveStation") - @ApiOperationSupport(order = 2) - @ApiOperation(value = "获取站点统计数据", notes = "无需传入参数") - public R saveStation() { - return R.data(service.saveStation()); + @GetMapping("/stationNumber") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "站点数量", notes = "无需传入参数") + public R stationNumber() { + return R.data(service.stationNumber()); } @ApiLog diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/HzimsDataService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/HzimsDataService.java index 8c6a8bb..5974bd1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/HzimsDataService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/HzimsDataService.java @@ -1,12 +1,14 @@ package com.hnac.hzims.operational.data.service; import com.hnac.hzims.operational.data.vo.PowerConvertVo; +import com.hnac.hzims.operational.data.vo.StationNumberVo; import com.hnac.hzims.operational.data.vo.WeatherWaterVo; import com.hnac.hzims.operational.main.vo.HydropowerStationVo; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.util.List; /** * @author ysj @@ -19,7 +21,7 @@ public interface HzimsDataService { */ boolean saveArea(); - boolean saveStation(); + List stationNumber(); HydropowerStationVo station(String stationCode); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java index af4d929..d96bdbe 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java @@ -20,7 +20,6 @@ import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.service.IHzimsAnalyzeModelStationService; import com.hnac.hzims.operational.station.service.IStationService; -import com.hnac.hzims.operational.station.vo.HzimsStationCountVo; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; import lombok.RequiredArgsConstructor; @@ -88,8 +87,11 @@ public class HzimsDataServiceImpl implements HzimsDataService { @Value("${hzims.operation.save.station.url}") public String STATION_URL; + private final static String charge = "hzims:operation:key:charge"; + private final static String conver_power_key = "hzims:operation:conver:power:"; + private final static String conver_weather_key = "hzims:operation:conver:weather:"; private final static String recent_year_power_data = "hzims:operation:key:power:data"; @@ -136,17 +138,33 @@ public class HzimsDataServiceImpl implements HzimsDataService { return this.sendMessage(JSONObject.toJSONBytes(list),AREA_URL); } + /** - * 获取站点统计数据 + * 站点数量统计 * @return */ @Override - public boolean saveStation() { - List list = this.stationService.getStationCount(); - if(CollectionUtil.isEmpty(list)){ - return false; - } - return this.sendMessage(JSONObject.toJSONBytes(list),STATION_URL); + public List stationNumber() { + List numbers = new ArrayList<>(); + List stations = stationService.list(Wrappers.lambdaQuery(). + in(StationEntity::getType,Arrays.asList(0,1,5,8)) + ); + if(!CollectionUtil.isEmpty(stations)){ + stations.stream().collect(Collectors.groupingBy(StationEntity::getType)).forEach((key, value) -> { + StationNumberVo number = new StationNumberVo(); + number.setType(key); + number.setCount(value.size()); + numbers.add(number); + }); + } + TargetVo target = (TargetVo) redisTemplate.opsForValue().get(charge); + if(!ObjectUtil.isEmpty(target)){ + StationNumberVo number = new StationNumberVo(); + number.setType(7); + number.setCount(target.getCharge()); + numbers.add(number); + } + return numbers; }