From 4c1eb9c1d2af572fa5a37b60428f6f439679f66b Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Sat, 25 May 2024 10:53:32 +0800 Subject: [PATCH] =?UTF-8?q?#=E5=A4=A7=E6=A8=A1=E5=9E=8B=E5=8F=91=E7=94=B5?= =?UTF-8?q?=E9=87=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/fill/feign/IGenerateClient.java | 26 +++++++++++++++ .../fill/feign/IGenerateClientFallback.java | 15 +++++++++ .../controller/InteractiveController.java | 9 +++++ .../interactive/service/IInteractiveService.java | 2 ++ .../service/impl/InteractiveServiceImpl.java | 31 ++++++++++++++++++ .../operational/fill/feign/GenerateClient.java | 38 ++++++++++++++++++++++ 6 files changed, 121 insertions(+) create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClient.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClientFallback.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClient.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClient.java new file mode 100644 index 0000000..d73fa37 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClient.java @@ -0,0 +1,26 @@ +package com.hnac.hzims.operational.fill.feign; + +import com.hnac.hzims.operational.OperationalConstants; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * @author ysj + */ +@FeignClient( + value = OperationalConstants.APP_NAME, + fallback = IGenerateClientFallback.class +) +public interface IGenerateClient { + + String API_PREFIX = "/feign/generate/"; + + String STATION_GENERATE_BY_TIME = API_PREFIX + "/stationGenerateByTime"; + + + @GetMapping(STATION_GENERATE_BY_TIME) + Double stationGenerateByTime(@RequestParam("stationId") String stationId, + @RequestParam("startTime") String startTime, + @RequestParam("endTime") String endTime); +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClientFallback.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClientFallback.java new file mode 100644 index 0000000..da7c067 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClientFallback.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.operational.fill.feign; + +import org.springframework.stereotype.Component; + +/** + * @author hx + */ +@Component +public class IGenerateClientFallback implements IGenerateClient { + + @Override + public Double stationGenerateByTime(String stationId, String startTime, String endTime) { + return 0.0; + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java index 40e79b3..472d092 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java @@ -77,4 +77,13 @@ public class InteractiveController { public R sendRemoteControl(@RequestBody ControlDTO operate) { return interactiveService.sendRemoteControl(operate); } + + @ApiOperation("站点发电量") + @ApiOperationSupport(order = 7) + @RequestMapping(value = "/generation",method = {RequestMethod.GET,RequestMethod.POST}) + public R generation(@RequestParam @ApiParam("站点编号") String stationId, + @RequestParam @ApiParam("开始时间") String startTime, + @RequestParam @ApiParam("结束时间")String endTime) { + return R.data(interactiveService.generation(stationId,startTime,endTime) + "kwh"); + } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java index 2f6588a..acdcb37 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java @@ -43,4 +43,6 @@ public interface IInteractiveService { R knowledgeAsk(String question, String sessionId, String userId, String knowledge); R sendRemoteControl(ControlDTO operate); + + Double generation(String stationId, String startTime, String endTime); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java index f5571dd..7ba145b 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java @@ -14,6 +14,9 @@ import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService; import com.hnac.hzims.bigmodel.interactive.service.IParamsService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import com.hnac.hzims.operational.fill.feign.IGenerateClient; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.feign.IStationClient; import com.xxl.job.core.log.XxlJobLogger; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -54,6 +57,10 @@ public class InteractiveServiceImpl implements IInteractiveService { private final IRemoteClient remoteClient; + private final IStationClient stationClient; + + private final IGenerateClient generateClient; + private final IJumpPageService jumpPageService; private final IParamsService paramsService; @@ -277,4 +284,28 @@ public class InteractiveServiceImpl implements IInteractiveService { public R sendRemoteControl(ControlDTO operate) { return remoteClient.sendCtrl(operate); } + + /** + * 站点发电量 + * @param stationId + * @param startTime + * @param endTime + * @return + */ + @Override + public Double generation(String stationId, String startTime, String endTime) { + // 步骤1.查询站点 + R station = stationClient.getStationByCode(stationId); + if(!station.isSuccess() || ObjectUtil.isEmpty(station.getData())){ + return 0.0; + } + // 步骤2.查询填报发电量 + double fill = generateClient.stationGenerateByTime(stationId,startTime,endTime); + + // 步骤3.查询设备 + + // 步骤4.遍历设备查询发电量 + + return fill; + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java new file mode 100644 index 0000000..54e86ac --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java @@ -0,0 +1,38 @@ +package com.hnac.hzims.operational.fill.feign; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.operational.fill.entity.GenerateEntity; +import com.hnac.hzims.operational.fill.service.GenerateService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + + +/** + * @author ysj + */ +@RestController +@Slf4j +@AllArgsConstructor +public class GenerateClient implements IGenerateClient { + + private final GenerateService generateService; + + @Override + @GetMapping(STATION_GENERATE_BY_TIME) + public Double stationGenerateByTime(String stationId, String startTime, String endTime) { + List generates = generateService.list(Wrappers.lambdaQuery() + .eq(GenerateEntity::getStationCode,stationId) + .ge(GenerateEntity::getFillDate,startTime) + .le(GenerateEntity::getGenerate,endTime) + ); + if(CollectionUtil.isEmpty(generates)){ + return 0.0; + } + return generates.stream().mapToDouble(GenerateEntity::getGenerate).sum(); + } +}