From 9fc1177fb8a16510eda36cb4a9613b709a3dbdba Mon Sep 17 00:00:00 2001 From: luyie Date: Mon, 19 Aug 2024 20:10:15 +0800 Subject: [PATCH 1/5] =?UTF-8?q?add:=E5=A4=A7=E6=A8=A1=E5=9E=8B=E5=88=86?= =?UTF-8?q?=E6=9E=90=E5=A2=9E=E5=8A=A0=E5=A4=9A=E5=9C=BA=E6=99=AF=E5=88=86?= =?UTF-8?q?=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/api/dto/BigModelAnalysisDTO.java | 20 ---- .../api/dto/BigModelAnalysisRequestDTO.java | 26 +++++ .../api/dto/BigModelAnalysisResponseDTO.java | 56 ++++++++++ .../api/feign/IBigModelAnalysisClient.java | 5 +- .../bigmodel/api/feign/BigModelAnalysisClient.java | 9 +- .../controller/ZhipuAnalysisInfoController.java | 4 +- .../zhipuai/entity/ZhipuAnalysisInfoEntity.java | 5 +- .../handler/AbstractZhipuAnalysisHandler.java | 6 ++ .../bigmodel/zhipuai/handler/ResultStrategy.java | 4 +- .../bigmodel/zhipuai/handler/ZhipuAnalyser.java | 32 ++++-- .../zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java | 12 +-- .../zhipuai/service/ZhipuAnalysisService.java | 4 + .../service/impl/ZhipuAnalysisServiceImpl.java | 119 ++++++++++++++++++++- .../zhipuai/vo/ZhipuAnalysisFileRequest.java | 11 +- .../bigmodel/zhipuai/vo/ZhipuAnalysisResult.java | 2 +- hzims-service/inspect/pom.xml | 4 + .../inspect/task/schedule/VideoTaskSchedule.java | 62 +++++++---- 17 files changed, 303 insertions(+), 78 deletions(-) delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisDTO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisRequestDTO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisResponseDTO.java diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisDTO.java deleted file mode 100644 index 5694e33..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisDTO.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzims.bigmodel.api.dto; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - * @Author: ypj - * @Date: 2024/8/12 16:02 - */ -@Data -@ApiModel(value = "大模型分析",description = "大模型分析参数") -public class BigModelAnalysisDTO { - - @ApiModelProperty("策略编码") - private String code; - - @ApiModelProperty("文件地址或文件的base64文件内容") - private String url; -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisRequestDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisRequestDTO.java new file mode 100644 index 0000000..18dbbbd --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisRequestDTO.java @@ -0,0 +1,26 @@ +package com.hnac.hzims.bigmodel.api.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @Author: ypj + * @Date: 2024/8/12 16:02 + */ +@Data +@ApiModel(value = "大模型分析",description = "大模型分析参数") +public class BigModelAnalysisRequestDTO { + + @ApiModelProperty("策略编码") + private List codeList; + + @ApiModelProperty(value = "检测类型子类") + private List checkTypeSonList; + + @ApiModelProperty("文件地址或文件的base64文件内容") + private String url; +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisResponseDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisResponseDTO.java new file mode 100644 index 0000000..9869fe1 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisResponseDTO.java @@ -0,0 +1,56 @@ +package com.hnac.hzims.bigmodel.api.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; +import java.util.Optional; + +/** + * @Author: ypj + * @Date: 2024/8/19 10:38 + */ +@Data +@ApiModel(description = "分析返回信息") +public class BigModelAnalysisResponseDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "是否成功", required = true) + private Boolean success = null; + + @ApiModelProperty(value = "分析结果数据列表") + private List data; + + @ApiModelProperty(value = "状态码", required = true) + private int code; + + @ApiModelProperty(value = "返回消息") + private String msg; + + + @Data + @ApiModel(description = "分析结果") + public static class BigModelAnalysisResult implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "承载数据") + private Object result; + + @ApiModelProperty(value = "结果字符串") + private String resultStr; + + @ApiModelProperty(value = "结果描述") + private String description; + + @ApiModelProperty(value = "结果描述") + private String checkTypeSon; + } + + public Boolean getSuccess() { + return Optional.ofNullable(success).orElse(Boolean.FALSE); + } +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IBigModelAnalysisClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IBigModelAnalysisClient.java index da57522..e839026 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IBigModelAnalysisClient.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IBigModelAnalysisClient.java @@ -1,7 +1,8 @@ package com.hnac.hzims.bigmodel.api.feign; import com.hnac.hzims.bigmodel.BigModelConstants; -import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisDTO; +import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisRequestDTO; +import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisResponseDTO; import org.springblade.core.tool.api.R; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; @@ -16,5 +17,5 @@ public interface IBigModelAnalysisClient { String PREFIX_API = "feign/bigModel"; @PostMapping(PREFIX_API + "/analysis") - R analysis(@RequestBody BigModelAnalysisDTO analysisInfo); + BigModelAnalysisResponseDTO analysis(@RequestBody BigModelAnalysisRequestDTO analysisInfo); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/BigModelAnalysisClient.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/BigModelAnalysisClient.java index bb0532d..7e2fac1 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/BigModelAnalysisClient.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/BigModelAnalysisClient.java @@ -1,10 +1,9 @@ package com.hnac.hzims.bigmodel.api.feign; -import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisDTO; +import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisRequestDTO; +import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisResponseDTO; import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisService; -import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisFileRequest; import lombok.AllArgsConstructor; -import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; @@ -20,7 +19,7 @@ public class BigModelAnalysisClient implements IBigModelAnalysisClient { @Override @PostMapping(PREFIX_API + "/analysis") - public R analysis(BigModelAnalysisDTO analysisInfo) { - return R.data(analysisService.analysis(ZhipuAnalysisFileRequest.of(analysisInfo))); + public BigModelAnalysisResponseDTO analysis(BigModelAnalysisRequestDTO analysisInfo) { + return analysisService.multiAnalysis(analysisInfo); } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/controller/ZhipuAnalysisInfoController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/controller/ZhipuAnalysisInfoController.java index 905710f..ce4664c 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/controller/ZhipuAnalysisInfoController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/controller/ZhipuAnalysisInfoController.java @@ -32,7 +32,7 @@ public class ZhipuAnalysisInfoController { @PostMapping("/save") @ApiOperation("保存智谱分析信息") @ApiOperationSupport(order = 1) - public R save(@RequestBody @Validated ZhipuAnalysisInfoVO request) { + public R save(@RequestBody ZhipuAnalysisInfoVO request) { return R.status(analysisInfoService.save(request.toEntity())); } @@ -53,7 +53,7 @@ public class ZhipuAnalysisInfoController { @PutMapping("/update") @ApiOperation("更新智谱分析配置信息") @ApiOperationSupport(order = 4) - public R update(@RequestBody @Validated ZhipuAnalysisInfoEntity requestData) { + public R update(@RequestBody ZhipuAnalysisInfoEntity requestData) { return R.status(analysisInfoService.updateById(requestData)); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java index 4712811..ff583d4 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java @@ -7,7 +7,6 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; -import org.springblade.core.mp.base.BaseEntity; import org.springblade.core.mp.support.QueryField; import org.springblade.core.tenant.mp.TenantEntity; @@ -25,6 +24,10 @@ public class ZhipuAnalysisInfoEntity extends TenantEntity { @TableField("CODE") private String code; + @ApiModelProperty(value = "对应字典表“AI识别类型”的key值") + @TableField("CHECK_TYPE_SON") + private String checkTypeSon; + @ApiModelProperty(value = "策略名称") @TableField("NAME") @QueryField(condition = SqlCondition.LIKE) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/AbstractZhipuAnalysisHandler.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/AbstractZhipuAnalysisHandler.java index 09fa6dd..62a19ec 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/AbstractZhipuAnalysisHandler.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/AbstractZhipuAnalysisHandler.java @@ -1,6 +1,7 @@ package com.hnac.hzims.bigmodel.zhipuai.handler; import com.zhipu.oapi.ClientV4; +import lombok.Data; import javax.annotation.Resource; @@ -8,10 +9,15 @@ import javax.annotation.Resource; * @Author: ypj * @Date: 2024/8/12 8:44 */ +@Data public abstract class AbstractZhipuAnalysisHandler implements ZhipuAnalyser { protected final String requestIdTemplate = "big_model-%d"; @Resource protected ClientV4 client; + private String text; + + private String url; + } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultStrategy.java index 3ae3c7e..b86adea 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultStrategy.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultStrategy.java @@ -36,8 +36,8 @@ public interface ResultStrategy { return originalData; } - default T getResult(ZhipuAnalysisInfoEntity info, String originalData) { - return getResult(info, convertOriginalData(originalData, info.getResultType())); + default T getResult(ZhipuAnalysisInfoEntity info, String originalValue) { + return getResult(info, convertOriginalData(originalValue, info.getResultType())); } T getResult(ZhipuAnalysisInfoEntity info, Object resultData); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalyser.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalyser.java index 9de7349..6b22484 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalyser.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalyser.java @@ -1,32 +1,50 @@ package com.hnac.hzims.bigmodel.zhipuai.handler; -import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; import org.springblade.core.tool.jackson.JsonUtil; import java.util.Map; +import java.util.Optional; /** * @Author: ypj * @Date: 2024/8/8 14:45 */ public interface ZhipuAnalyser { + String QUESTION_PROFILE = "## Profile\n"; + + String QUESTION_CONSTRAINS = "## Constrains\n"; + + String QUESTION_OUTPUT_FORMAT = "## OutputFormat\n"; String getAnalysisStrategy(); String getAnalysisModel(); + String getUrl(); + + void setUrl(String url); + + String getText(); + + void setText(String text); + default boolean isSupport(String strategyCode) { return getAnalysisStrategy().equals(strategyCode); } - Resp sendRequest(ZhipuAnalysisInfoEntity info, String url); + Resp sendRequest(String text, String url); - Req getRequest(ZhipuAnalysisInfoEntity info, String url); + Req getRequest(String text, String url); - String getResult(ZhipuAnalysisInfoEntity info, String url); + String getResult(String text, String url); + + default Map getResultMap(String text, String url) { + String result = getResult(text, url); + return Optional.ofNullable(result).map(str -> JsonUtil.toMap(result)).orElse(null); + } - default Object getResultValue(ZhipuAnalysisInfoEntity info, String url) { - Map resultMap = JsonUtil.toMap(getResult(info, url)); - return resultMap.get(info.getResultKey()); + default Object getResultValue(String text, String key, String url) { + Map resultMap = getResultMap(text, url); + return Optional.ofNullable(resultMap).map(data -> data.get(key)).orElse(null); } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java index 23c7767..e56b0f3 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java @@ -33,19 +33,19 @@ public class ZhipuAnalysisHandlerGlm4v extends AbstractZhipuAnalysisHandler { } @Override - public ModelApiResponse sendRequest(ZhipuAnalysisInfoEntity info, String url) { - ChatCompletionRequest request = getRequest(info, url); + public ModelApiResponse sendRequest(String text, String url) { + ChatCompletionRequest request = getRequest(text, url); log.info("send zhipu ai request :{}", Optional.ofNullable(request).map(req -> JsonUtil.toJson(req)).orElse("null")); return client.invokeModelApi(request); } @Override - public ChatCompletionRequest getRequest(ZhipuAnalysisInfoEntity info, String url) { + public ChatCompletionRequest getRequest(String text, String url) { List messages = new ArrayList<>(); List> contentList = new ArrayList<>(); Map textMap = new HashMap<>(); textMap.put("type", "text"); - textMap.put("text", info.getRequestContent()); + textMap.put("text", text); Map typeMap = new HashMap<>(); typeMap.put("type", "image_url"); Map urlMap = new HashMap<>(); @@ -68,8 +68,8 @@ public class ZhipuAnalysisHandlerGlm4v extends AbstractZhipuAnalysisHandler { } @Override - public String getResult(ZhipuAnalysisInfoEntity info, String url) { - ModelApiResponse response = sendRequest(info, url); + public String getResult(String text, String url) { + ModelApiResponse response = sendRequest(text, url); log.info("get zhi pu ai response : {}", Optional.ofNullable(response).map(resp -> JsonUtil.toJson(resp)).orElse("null")); if (response.isSuccess()) { try { diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/ZhipuAnalysisService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/ZhipuAnalysisService.java index f6649ca..2316cbd 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/ZhipuAnalysisService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/ZhipuAnalysisService.java @@ -1,5 +1,7 @@ package com.hnac.hzims.bigmodel.zhipuai.service; +import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisRequestDTO; +import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisResponseDTO; import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisFileRequest; import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisFileResponse; @@ -13,4 +15,6 @@ public interface ZhipuAnalysisService { ZhipuAnalysisFileResponse analysis(ZhipuAnalysisFileRequest request); ZhipuAnalysisInfoEntity getAnalysisInfo(ZhipuAnalysisFileRequest request); + + BigModelAnalysisResponseDTO multiAnalysis(BigModelAnalysisRequestDTO analysisInfo); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java index 1848f58..a639efa 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java @@ -1,6 +1,8 @@ package com.hnac.hzims.bigmodel.zhipuai.service.impl; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisRequestDTO; +import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisResponseDTO; import com.hnac.hzims.bigmodel.zhipuai.constants.BaseEnum; import com.hnac.hzims.bigmodel.zhipuai.constants.ResultStrategyType; import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; @@ -15,13 +17,15 @@ import com.hnac.hzims.common.utils.FileUtil; import com.hnac.hzinfo.exception.HzServiceException; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.ResultCode; import org.springblade.core.tool.jackson.JsonUtil; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; import org.springframework.util.Assert; -import java.util.Objects; -import java.util.Optional; +import java.util.*; /** * @Author: ypj @@ -36,6 +40,14 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { private final ZhipuAnalysisInfoService infoService; + private final String multiQuestionBrief = "从给出的图片回答以下{}个问题\n"; + + private final String multiQuestionPrefix = "第{}个问题,"; + + private final String multiQuestionConstrains = "- 不要在输出中添加任何注释和思考过程和其他多余的内容,以JSON格式输出简单结果,{}结果只包含'是'或者'否'\n"; + + private final String multiQuestionConstrainsList = "'问题{}'代表第{}个问题,"; + @Override public ZhipuAnalysisFileResponse analysis(ZhipuAnalysisFileRequest request) { Assert.isTrue(StringUtil.isNotBlank(request.getFilePath()) || StringUtil.isNotBlank(request.getUrl()), () -> { @@ -49,7 +61,21 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { }); ZhipuAnalyser analyser = analysisFactory.getAnalysisStrategy(info.getModel()); - Object resultObject = analyser.getResultValue(info, getSendUrl(request)); + Assert.isTrue(StringUtil.isNotBlank(info.getRequestContent()), () -> { + throw new HzServiceException("智谱平台交互内容为空"); + }); + //拼接文字内容 + StringBuilder textBuilder = new StringBuilder(); + textBuilder.append(ZhipuAnalyser.QUESTION_PROFILE).append(info.getRequestContent()); + if (StringUtil.isNotBlank(info.getRequestConstrains())) { + textBuilder.append(ZhipuAnalyser.QUESTION_CONSTRAINS).append(info.getRequestConstrains()); + } + if (StringUtil.isNotBlank(info.getRequestOutputFormat())) { + textBuilder.append(ZhipuAnalyser.QUESTION_OUTPUT_FORMAT).append("{").append(info.getRequestOutputFormat()).append("}"); + } + analyser.setText(textBuilder.toString()); + + Object resultObject = analyser.getResultValue(analyser.getText(), info.getResultKey(), getSendUrl(request)); Assert.isTrue(Objects.nonNull(resultObject), () -> { throw new HzServiceException("智谱平台分析失败"); }); @@ -82,11 +108,12 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { @Override public ZhipuAnalysisInfoEntity getAnalysisInfo(ZhipuAnalysisFileRequest request) { ZhipuAnalysisInfoEntity result = null; - if (StringUtil.isBlank(request.getCode())) { + if (StringUtil.isBlank(request.getCode()) && StringUtil.isBlank(request.getCheckTypeSon())) { result = request.toAnalysisInfo(); } else { result = infoService.getOne(Wrappers.lambdaQuery() - .eq(ZhipuAnalysisInfoEntity::getCode, request.getCode()) + .eq(StringUtil.isNotBlank(request.getCode()), ZhipuAnalysisInfoEntity::getCode, request.getCode()) + .eq(StringUtil.isNotBlank(request.getCheckTypeSon()), ZhipuAnalysisInfoEntity::getCheckTypeSon, request.getCheckTypeSon()) .last("limit 1;")); } log.info("the analysis information is {}", Optional.ofNullable(result).map(r -> JsonUtil.toJson(r)).orElse("null")); @@ -94,4 +121,86 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { } + @Override + public BigModelAnalysisResponseDTO multiAnalysis(BigModelAnalysisRequestDTO request) { + BigModelAnalysisResponseDTO response = new BigModelAnalysisResponseDTO(); + try { + Assert.isTrue(StringUtil.isNotBlank(request.getUrl()), () -> { + throw new HzServiceException("文件为空"); + }); + Assert.isTrue(CollectionUtil.isNotEmpty(request.getCodeList()) || CollectionUtil.isNotEmpty(request.getCheckTypeSonList()), () -> { + throw new HzServiceException("识别类型为空"); + }); + List infoList = infoService.list(Wrappers.lambdaQuery().in(CollectionUtil.isNotEmpty(request.getCodeList()), ZhipuAnalysisInfoEntity::getCode, request.getCodeList()) + .in(CollectionUtil.isNotEmpty(request.getCheckTypeSonList()), ZhipuAnalysisInfoEntity::getCheckTypeSon, request.getCheckTypeSonList())); + Assert.isTrue(CollectionUtil.isNotEmpty(infoList), () -> { + throw new HzServiceException("未知的识别类型"); + }); + ZhipuAnalyser analyser = analysisFactory.getAnalysisStrategy(infoList.get(0).getModel()); + + String text = getMultiAnalyserText(infoList); + Map resultMap = analyser.getResultMap(text, request.getUrl()); + + if (null == resultMap) { + response.setCode(ResultCode.FAILURE.getCode()); + response.setMsg("智谱大模型分析失败"); + return response; + } + + List results = new ArrayList<>(infoList.size()); + for (int index = 1; index <= infoList.size(); index++) { + ZhipuAnalysisInfoEntity infoEntity = infoList.get(index - 1); + BigModelAnalysisResponseDTO.BigModelAnalysisResult result = new BigModelAnalysisResponseDTO.BigModelAnalysisResult(); + results.add(result); + result.setCheckTypeSon(infoEntity.getCheckTypeSon()); + Object resultObj = resultMap.get(infoEntity.getResultKey()); + if (ObjectUtil.isEmpty(resultObj)) { + continue; + } + String resultStr = resultObj.toString(); + result.setResultStr(resultStr); + result.setDescription(infoEntity.getName() + StringUtil.format(",结果为{}", resultStr)); + ResultStrategyType strategyType = BaseEnum.getInstance(infoEntity.getResultStrategy(), ResultStrategyType.class); + if (ObjectUtil.isEmpty(strategyType)) { + continue; + } + result.setResult(strategyType.getStrategy().getResult(infoEntity, resultObj)); + } + response.setData(results); + response.setCode(ResultCode.SUCCESS.getCode()); + response.setMsg(ResultCode.SUCCESS.getMessage()); + } catch (Exception e) { + if (e instanceof HzServiceException) { + response.setCode(ResultCode.FAILURE.getCode()); + response.setMsg(e.getMessage()); + } else { + response.setCode(ResultCode.FAILURE.getCode()); + response.setMsg("智谱大模型分析失败"); + } + log.error("智谱大模型分析失败", e); + } + return response; + } + + String getMultiAnalyserText(List infoList) { + StringBuilder stringBuilder = new StringBuilder(); + StringBuilder titleBuilder = new StringBuilder(); + StringBuilder formatBuilder = new StringBuilder(); + stringBuilder.append(ZhipuAnalyser.QUESTION_PROFILE) + .append(StringUtil.format(multiQuestionBrief, infoList.size())); + formatBuilder.append("{"); + for (int index = 1; index <= infoList.size(); index++) { + ZhipuAnalysisInfoEntity infoEntity = infoList.get(index - 1); + stringBuilder.append(StringUtil.format(multiQuestionPrefix, index)); + titleBuilder.append(StringUtil.format(multiQuestionConstrainsList, infoEntity.getResultKey(), index)); + formatBuilder.append(infoEntity.getRequestOutputFormat()).append(","); + } + formatBuilder.deleteCharAt(formatBuilder.length() - 1); + formatBuilder.append("}"); + stringBuilder.append(ZhipuAnalyser.QUESTION_CONSTRAINS) + .append(StringUtil.format(multiQuestionConstrains, titleBuilder.toString())) + .append(ZhipuAnalyser.QUESTION_OUTPUT_FORMAT).append(formatBuilder); + return stringBuilder.toString(); + } + } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisFileRequest.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisFileRequest.java index 451c4aa..81184a6 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisFileRequest.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisFileRequest.java @@ -1,6 +1,6 @@ package com.hnac.hzims.bigmodel.zhipuai.vo; -import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisDTO; +import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisRequestDTO; import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -16,6 +16,9 @@ public class ZhipuAnalysisFileRequest { @ApiModelProperty("策略编码") private String code; + @ApiModelProperty(value = "检测类型子类") + private String checkTypeSon; + @ApiModelProperty("模型名称") private String model; @@ -39,10 +42,4 @@ public class ZhipuAnalysisFileRequest { return info; } - public static ZhipuAnalysisFileRequest of(BigModelAnalysisDTO analysisDTO) { - ZhipuAnalysisFileRequest request = new ZhipuAnalysisFileRequest(); - request.setCode(analysisDTO.getCode()); - request.setUrl(analysisDTO.getUrl()); - return request; - } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisResult.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisResult.java index e037767..cc67650 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisResult.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisResult.java @@ -21,7 +21,7 @@ public class ZhipuAnalysisResult implements Serializable { private Boolean success = null; @ApiModelProperty(value = "承载数据") - private T result; + private Object result; @ApiModelProperty(value = "结果描述") private String resultStr; diff --git a/hzims-service/inspect/pom.xml b/hzims-service/inspect/pom.xml index 10d46e5..401e4d8 100644 --- a/hzims-service/inspect/pom.xml +++ b/hzims-service/inspect/pom.xml @@ -155,6 +155,10 @@ okhttp 4.9.3 + + com.hnac.hzims + big-model-api + diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java index d4f79be..1519e95 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java @@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; +import com.hnac.hzims.bigmodel.api.feign.IBigModelAnalysisClient; import com.hnac.hzinfo.datasearch.soe.ISoeClient; import com.hnac.hzinfo.datasearch.soe.vo.DeviceSoeVO; import com.hnac.hzinfo.inspect.ai.entity.CameraInfoEntity; @@ -13,6 +14,8 @@ import com.hnac.hzinfo.inspect.ai.service.ICameraInfoService; import com.hnac.hzinfo.inspect.ai.service.IRobotTaskService; import com.hnac.hzinfo.inspect.areamonthly.vo.TaskObjectVO; import com.hnac.hzinfo.inspect.hikVideo.service.IHikApiService; +import com.hnac.hzinfo.inspect.obj.entity.ContentEntity; +import com.hnac.hzinfo.inspect.obj.services.ContentService; import com.hnac.hzinfo.inspect.plan.PlanContants; import com.hnac.hzinfo.inspect.task.TaskContants; import com.hnac.hzinfo.inspect.task.entity.EventEntity; @@ -34,12 +37,14 @@ import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; +import org.springblade.resource.feign.IOssClient; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.stereotype.Component; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; +import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -63,9 +68,13 @@ public class VideoTaskSchedule { private final ISoeClient soeClient; private final DataSourceTransactionManager dataSourceTransactionManager; private final TransactionDefinition transactionDefinition; + private final IOssClient ossClient; + private final ContentService contentService; + private final IBigModelAnalysisClient bigModelClient; /** * 视频巡检任务执行 + * * @param params 任务ID * @return */ @@ -74,15 +83,14 @@ public class VideoTaskSchedule { public ReturnT execute(String params) throws InterruptedException { List taskList = Lists.newArrayList(); // 获取待执行的任务 - if(StringUtil.isBlank(params)) { + if (StringUtil.isBlank(params)) { LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery() .eq(TaskEntity::getStatus, TaskContants.TaskStatusEnum.INIT_STATUS.getStatus()) .le(TaskEntity::getPlanStartTime, LocalDateTime.now()) .ge(TaskEntity::getPlanEndTime, LocalDateTime.now()) .eq(TaskEntity::getAutoVideo, PlanContants.InspectTypeEnum.VIDEO.getVal()); taskList.addAll(taskService.list(queryWrapper)); - } - else { + } else { LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery() .in(TaskEntity::getId, Func.toLongList(",", params)) .eq(TaskEntity::getStatus, TaskContants.TaskStatusEnum.UNDERWAY_STATUS.getStatus()) @@ -95,6 +103,7 @@ public class VideoTaskSchedule { /** * 执行视频巡检任务 + * * @param task 视频巡检任务 */ private void executeVideoTask(TaskEntity task) { @@ -105,16 +114,15 @@ public class VideoTaskSchedule { this.fillEvent(task); // 更新视频巡检任务状态 taskService.update(Wrappers.lambdaUpdate() - .set(TaskEntity::getStatus,TaskContants.TaskStatusEnum.FINISH_STATUS.getStatus()) - .set(TaskEntity::getEndTime,LocalDateTime.now()) - .eq(TaskEntity::getId,task.getId())); - } - catch(Exception e) { + .set(TaskEntity::getStatus, TaskContants.TaskStatusEnum.FINISH_STATUS.getStatus()) + .set(TaskEntity::getEndTime, LocalDateTime.now()) + .eq(TaskEntity::getId, task.getId())); + } catch (Exception e) { e.printStackTrace(); - XxlJobLogger.log("【taskId:"+task.getId()+"】视频巡检任务执行失败,报错信息为:"+e.getMessage()); + XxlJobLogger.log("【taskId:" + task.getId() + "】视频巡检任务执行失败,报错信息为:" + e.getMessage()); } try { - Thread.sleep(3*1000); + Thread.sleep(3 * 1000); } catch (InterruptedException e) { throw new RuntimeException(e); } @@ -122,11 +130,12 @@ public class VideoTaskSchedule { /** * 填充视频巡检执行情况 + * * @param task 视频巡检任务 */ private void fillEvent(TaskEntity task) { List taskObjects = taskService.getTaskById(task.getId()); - List taskObjectList = JSONArray.parseArray(JSON.toJSONString(taskObjects),TaskObjectVO.class); + List taskObjectList = JSONArray.parseArray(JSON.toJSONString(taskObjects), TaskObjectVO.class); taskObjectList.forEach(object -> object.getProjects().forEach(project -> { EventEntity event = new EventEntity(); event.setTaskId(task.getId()); @@ -150,17 +159,17 @@ public class VideoTaskSchedule { record.setUpdateUser(task.getUpdateUser()); record.setCurrentStatus("1"); CameraInfoEntity camera = this.getCameraByProIdAndConId(project.getProjectId(), content.getContentId()); - if(Func.isNotEmpty(camera)) { + if (Func.isNotEmpty(camera)) { // 获取计划时间段内视频的告警信息设置是否异常 - if(Func.isNotEmpty(camera.getEmCode())) { + if (Func.isNotEmpty(camera.getEmCode())) { Result> deviceSoeR = soeClient.getDeviceCodeByTaosSoe(DateUtil.formatDateTime(task.getPlanStartTime()), DateUtil.formatDateTime(task.getPlanEndTime()), camera.getEmCode(), 0, String.valueOf(-1)); - if(deviceSoeR.isSuccess() && CollectionUtil.isNotEmpty(deviceSoeR.getData().getRecords())) { + if (deviceSoeR.isSuccess() && CollectionUtil.isNotEmpty(deviceSoeR.getData().getRecords())) { record.setCurrentStatus("0"); } } // 调用海康威视api实现手动截屏回传至fileUrl - if(Func.isNotEmpty(camera.getPointCode())) { + if (Func.isNotEmpty(camera.getPointCode())) { String picUrl = hikApiService.manualCapture(camera.getPointCode()); record.setFileUrl(picUrl); record.setCurrentValue(picUrl); @@ -169,14 +178,15 @@ public class VideoTaskSchedule { return record; }).collect(Collectors.toList()); eventRecordService.saveBatch(recordList); - if(recordList.stream().anyMatch(r -> TaskContants.CurrentStatusEnum.abnormal.getType().equals(r.getCurrentStatus()))) { - eventService.update(Wrappers.lambdaUpdate().set(EventEntity::getIsProblem,"1").eq(EventEntity::getId,event.getId())); + if (recordList.stream().anyMatch(r -> TaskContants.CurrentStatusEnum.abnormal.getType().equals(r.getCurrentStatus()))) { + eventService.update(Wrappers.lambdaUpdate().set(EventEntity::getIsProblem, "1").eq(EventEntity::getId, event.getId())); } })); } /** * 登记任务 + * * @param task 视频巡检任务 */ private void registration(TaskEntity task) { @@ -188,7 +198,7 @@ public class VideoTaskSchedule { taskUserEntity.setClaimStatus(TaskContants.ClaimStatusEnum.COLLECT.getStatus()); taskUserEntity.setClaimTime(LocalDateTime.now()); taskUserService.updateById(taskUserEntity); - if(PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(task.getMethod())) { + if (PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(task.getMethod())) { taskUserService.removeByIds(taskUserList.stream().map(TaskUserEntity::getId).filter(id -> !taskUserEntity.getId().equals(id)).collect(Collectors.toList())); } // 更改任务状态 @@ -199,19 +209,31 @@ public class VideoTaskSchedule { /** * 根据项目ID以及内容ID获取摄像头编号 + * * @param projectId 项目ID * @param contentId 内容ID * @return 摄像头编号 */ - private CameraInfoEntity getCameraByProIdAndConId(Long projectId,Long contentId) { + private CameraInfoEntity getCameraByProIdAndConId(Long projectId, Long contentId) { RobotTaskEntity robotTaskEntity = robotTaskService.getOne(Wrappers.lambdaQuery() .eq(RobotTaskEntity::getProjectId, projectId) .like(RobotTaskEntity::getContentIds, String.valueOf(contentId)) ); - if(Func.isNotEmpty(robotTaskEntity)) { + if (Func.isNotEmpty(robotTaskEntity)) { return cameraInfoService.getById(robotTaskEntity.getCameraId()); } return null; } + private void pictureHandle(String url, Long contentId) { + + ContentEntity content = contentService.getById(contentId); + if (StringUtil.isBlank(content.getMultiCheckTypeSon())) { + return; + } + String[] typeArray = content.getMultiCheckTypeSon().split(","); + List checkTypeSonList = Arrays.asList(typeArray); + + } + } From 3db26b39e6fd35a1fef83c6d1f676bf4be6c3616 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 20 Aug 2024 08:10:11 +0800 Subject: [PATCH 2/5] =?UTF-8?q?#=E9=A6=96=E9=A1=B5=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../constant/HydroelectricConstant.java | 18 + .../vo/HydroelectricAreaStationVo.java | 48 ++ .../Hydroelectric/vo/HydroelectricAreaVo.java | 70 +++ .../vo/HydroelectricDeviceGenerateVo.java | 2 +- .../vo/HydroelectricDevicePowerVo.java | 2 +- .../vo/HydroelectricGenerateMonVo.java | 6 +- .../vo/HydroelectricGenerateYearVo.java | 21 + .../Hydroelectric/vo/HydroelectricGroupAreaVo.java | 45 ++ .../Hydroelectric/vo/HydroelectricGroupVo.java | 70 +++ .../Hydroelectric/vo/HydroelectricStationVo.java | 2 +- .../hydroelectric/vo/HydroelectricDeviceVo.java | 72 +++ .../hydroelectric/vo/HydroelectricPowerRainVo.java | 22 + .../operational/main/vo/HydropowerStationVo.java | 2 +- .../hzims/emParam/controller/ParamController.java | 1 + .../controller/HydroelectricController.java | 19 +- .../homePage/service/HydroelectricService.java | 8 +- .../service/impl/HydroelectricServiceImpl.java | 529 ++++++++++++++++++++- .../main/service/impl/HydropowerServiceImpl.java | 2 +- 18 files changed, 918 insertions(+), 21 deletions(-) create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/constant/HydroelectricConstant.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricAreaStationVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricAreaVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGenerateYearVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGroupAreaVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGroupVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/constant/HydroelectricConstant.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/constant/HydroelectricConstant.java new file mode 100644 index 0000000..bd008e2 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/constant/HydroelectricConstant.java @@ -0,0 +1,18 @@ +package com.hnac.hzims.operational.homePage.hydroelectric.constant; + +/** + * 水电站首页-常量 + * @author ysj + */ +public interface HydroelectricConstant { + + /** + * 水电站 + */ + Integer HYDROPOWER = 0; + + /** + * 代运维 + */ + Integer PROXY_OPEARIONAL = 2; +} \ No newline at end of file diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricAreaStationVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricAreaStationVo.java new file mode 100644 index 0000000..98cdb14 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricAreaStationVo.java @@ -0,0 +1,48 @@ +package com.hnac.hzims.operational.homePage.hydroelectric.vo; + +import com.hnac.hzims.hzimsweather.response.weather.Daily; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * 集团/区域占比 + * @author ysj + */ +@Data +public class HydroelectricAreaStationVo { + + @ApiModelProperty(value = "站点机构") + private Long deptId; + + @ApiModelProperty(value = "机构ID") + private String stationCode; + + @ApiModelProperty(value = "机构名称") + private String stationName; + + @ApiModelProperty(value = "站点实时温度") + private String temp; + + @ApiModelProperty(value = "七日内天气") + private List weather; + + @ApiModelProperty(value = "年发电量") + private Double generateYear; + + @ApiModelProperty(value = "发电完成率") + private Double generateRate; + + @ApiModelProperty(value = "电站利用率") + private Double deviceUse; + + @ApiModelProperty(value = "容量利用率") + private Double capacityUse; + + @ApiModelProperty(value = "区域/集团发电占比") + private Double areaMakeUp; + + @ApiModelProperty(value = "排序") + private Integer sort; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricAreaVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricAreaVo.java new file mode 100644 index 0000000..14b6f1b --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricAreaVo.java @@ -0,0 +1,70 @@ +package com.hnac.hzims.operational.homePage.hydroelectric.vo; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "水电站首页-区域") +public class HydroelectricAreaVo { + + @ApiModelProperty(value = "机构Id") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Long deptId; + + @ApiModelProperty(value = "机构名称") + private String deptName; + + @ApiModelProperty(value = "站点数量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer count; + + @ApiModelProperty(value = "总装机容量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double capacity; + + @ApiModelProperty(value = "电站总负荷") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double load; + + @ApiModelProperty(value = "容量利用率") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double capacityRate; + + @ApiModelProperty(value = "年发电量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double generateYear; + + @ApiModelProperty(value = "月发电量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double generateMon; + + @ApiModelProperty(value = "日发电量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double generateDay; + + @ApiModelProperty(value = "今年计划发电量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double generatePlanYear; + + @ApiModelProperty(value = "电量完成吕") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double generateRate; + + @ApiModelProperty(value = "近3年发电对比") + private List recentYears; + + @ApiModelProperty(value = "计划完成完成趋势") + private List completes; + + @ApiModelProperty(value = "电站 :利用情况 && 天气 && 排名") + private List stations; + +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDeviceGenerateVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDeviceGenerateVo.java index 8e37237..97f5971 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDeviceGenerateVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDeviceGenerateVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.homePage.Hydroelectric.vo; +package com.hnac.hzims.operational.homePage.hydroelectric.vo; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.NullSerializer; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDevicePowerVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDevicePowerVo.java index c16ea6c..462e92f 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDevicePowerVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDevicePowerVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.homePage.Hydroelectric.vo; +package com.hnac.hzims.operational.homePage.hydroelectric.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGenerateMonVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGenerateMonVo.java index 12266ae..daeba5e 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGenerateMonVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGenerateMonVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.homePage.Hydroelectric.vo; +package com.hnac.hzims.operational.homePage.hydroelectric.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -21,8 +21,8 @@ public class HydroelectricGenerateMonVo { private String strMonth; @ApiModelProperty(value = "月发电量") - private Double power; + private Double generate; @ApiModelProperty(value = "计划发电量") - private Double planPower; + private Double planGenerate; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGenerateYearVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGenerateYearVo.java new file mode 100644 index 0000000..319e88d --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGenerateYearVo.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.operational.homePage.hydroelectric.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "年发电对象") +public class HydroelectricGenerateYearVo { + + @ApiModelProperty(value = "年份") + private Integer year; + + @ApiModelProperty(value = "月发电量集合:由1-12月组合") + private List generateMons; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGroupAreaVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGroupAreaVo.java new file mode 100644 index 0000000..e834cd1 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGroupAreaVo.java @@ -0,0 +1,45 @@ +package com.hnac.hzims.operational.homePage.hydroelectric.vo; + +import com.hnac.hzims.hzimsweather.response.weather.Daily; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * 集团/区域占比 + * @author ysj + */ +@Data +public class HydroelectricGroupAreaVo { + + @ApiModelProperty(value = "站点机构") + private Long deptId; + + @ApiModelProperty(value = "机构名称") + private String deptName; + + @ApiModelProperty(value = "站点实时温度") + private String temp; + + @ApiModelProperty(value = "七日内天气") + private List weather; + + @ApiModelProperty(value = "年发电量") + private Double generateYear; + + @ApiModelProperty(value = "发电完成率") + private Double generateRate; + + @ApiModelProperty(value = "电站利用率") + private Double deviceUse; + + @ApiModelProperty(value = "容量利用率") + private Double capacityUse; + + @ApiModelProperty(value = "区域/集团发电占比") + private Double areaMakeUp; + + @ApiModelProperty(value = "排序") + private Integer sort; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGroupVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGroupVo.java new file mode 100644 index 0000000..66e31e5 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGroupVo.java @@ -0,0 +1,70 @@ +package com.hnac.hzims.operational.homePage.hydroelectric.vo; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "水电站首页-站点") +public class HydroelectricGroupVo { + + @ApiModelProperty(value = "机构Id") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Long deptId; + + @ApiModelProperty(value = "机构名称") + private String deptName; + + @ApiModelProperty(value = "站点数量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer count; + + @ApiModelProperty(value = "总装机容量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double capacity; + + @ApiModelProperty(value = "电站总负荷") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double load; + + @ApiModelProperty(value = "容量利用率") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double capacityRate; + + @ApiModelProperty(value = "年发电量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double generateYear; + + @ApiModelProperty(value = "月发电量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double generateMon; + + @ApiModelProperty(value = "日发电量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double generateDay; + + @ApiModelProperty(value = "今年计划发电量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double generatePlanYear; + + @ApiModelProperty(value = "电量完成吕") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double generateRate; + + @ApiModelProperty(value = "近3年发电对比") + private List recentYears; + + @ApiModelProperty(value = "计划完成完成趋势") + private List completes; + + @ApiModelProperty(value = "电站 :利用情况 && 天气 && 排名") + private List areas; + +} \ No newline at end of file diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricStationVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricStationVo.java index 41bd6ba..ad3b959 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricStationVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricStationVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.homePage.Hydroelectric.vo; +package com.hnac.hzims.operational.homePage.hydroelectric.vo; import com.hnac.hzims.hzimsweather.response.weather.Daily; import io.swagger.annotations.ApiModel; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java new file mode 100644 index 0000000..ec21858 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java @@ -0,0 +1,72 @@ +package com.hnac.hzims.operational.homePage.hydroelectric.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "站点首页-设备信息") +public class HydroelectricDeviceVo { + + @ApiModelProperty(value = "设备编号") + private String deivceCode; + + @ApiModelProperty(value = "设备名称") + private String deivceName; + + @ApiModelProperty(value = "开关机状态: 0 - 关机 1 - 开机") + private Boolean state; + + @ApiModelProperty(value = "总装机容量") + private Double installedCapacity; + + @ApiModelProperty(value = "有功功率") + private Double activePower; + + @ApiModelProperty(value = "容量利用率") + private Double capacityRate; + + @ApiModelProperty(value = "无功功率") + private Double reactivePower; + + @ApiModelProperty(value = "导叶开度") + private Double guideOpen; + + @ApiModelProperty(value = "今日发电量") + private Float powerDay; + + @ApiModelProperty(value = "昨日发电量") + private Float powerYesterDay; + + @ApiModelProperty(value = "当年发电量") + private Float powerYear; + + @ApiModelProperty(value = "去年发电量") + private Float powerYesterYear; + + @ApiModelProperty(value = "当月发电量") + private Float powerMon; + + @ApiModelProperty(value = "本次开机时间") + private String startDownTime; + + @ApiModelProperty(value = "本次开机时长") + private Double startupDownDuration; + + @ApiModelProperty(value = "年停机时长") + private Double shutDownDurationYear; + + @ApiModelProperty(value = "年开机时长") + private Double startupDurationYear; + + @ApiModelProperty(value = "设备近24小时有功功率") + private List powers; + + @ApiModelProperty(value = "设备近30日发电量") + private List generates; +} \ No newline at end of file diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java new file mode 100644 index 0000000..2fcb5e3 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.operational.homePage.hydroelectric.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "站点首页-最近30日发电量/降雨量") +public class HydroelectricPowerRainVo { + + @ApiModelProperty(value = "日期") + private String date; + + @ApiModelProperty(value = "发电量") + private Double generate; + + @ApiModelProperty(value = "降雨") + private Double rain; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerStationVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerStationVo.java index 2bc64a1..680d8c4 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerStationVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerStationVo.java @@ -1,7 +1,7 @@ package com.hnac.hzims.operational.main.vo; import com.hnac.hzims.hzimsweather.response.weather.Daily; -import com.hnac.hzims.operational.homePage.Hydroelectric.vo.HydroelectricPowerRainVo; +import com.hnac.hzims.operational.homePage.hydroelectric.vo.HydroelectricPowerRainVo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/controller/ParamController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/controller/ParamController.java index 28dd424..f2b9040 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/controller/ParamController.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/controller/ParamController.java @@ -30,6 +30,7 @@ public class ParamController extends BladeController { } @PostMapping("/distribute") + @ApiOperation("下发参数") @ApiOperationSupport(order = 2) public Result distribute(@RequestBody ParamDistributeDTO req) { diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/controller/HydroelectricController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/controller/HydroelectricController.java index 6bc6de6..fb32444 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/controller/HydroelectricController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/controller/HydroelectricController.java @@ -1,11 +1,12 @@ package com.hnac.hzims.operational.homePage.controller; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.operational.homePage.Hydroelectric.vo.HydroelectricStationVo; +import com.hnac.hzims.operational.homePage.hydroelectric.vo.HydroelectricAreaVo; +import com.hnac.hzims.operational.homePage.hydroelectric.vo.HydroelectricGroupVo; +import com.hnac.hzims.operational.homePage.hydroelectric.vo.HydroelectricStationVo; import com.hnac.hzims.operational.homePage.service.HydroelectricService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.tool.api.R; @@ -32,4 +33,18 @@ public class HydroelectricController extends BladeController { public R station(@RequestParam("deptId") Long deptId) { return R.data(hydroelectricService.station(deptId)); } + + @ApiOperation("水电站区域指标") + @GetMapping("/area") + @ApiOperationSupport(order = 1) + public R area(@RequestParam(value = "deptId") Long deptId) { + return R.data(hydroelectricService.area(deptId)); + } + + @ApiOperation("水电站集团指标") + @GetMapping("/group") + @ApiOperationSupport(order = 1) + public R group() { + return R.data(hydroelectricService.group()); + } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/HydroelectricService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/HydroelectricService.java index 14bef09..5eabf11 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/HydroelectricService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/HydroelectricService.java @@ -1,6 +1,8 @@ package com.hnac.hzims.operational.homePage.service; -import com.hnac.hzims.operational.homePage.Hydroelectric.vo.HydroelectricStationVo; +import com.hnac.hzims.operational.homePage.hydroelectric.vo.HydroelectricAreaVo; +import com.hnac.hzims.operational.homePage.hydroelectric.vo.HydroelectricGroupVo; +import com.hnac.hzims.operational.homePage.hydroelectric.vo.HydroelectricStationVo; /** * 水电站-首页接口 @@ -9,4 +11,8 @@ import com.hnac.hzims.operational.homePage.Hydroelectric.vo.HydroelectricStation public interface HydroelectricService { HydroelectricStationVo station(Long deptId); + + HydroelectricAreaVo area(Long deptId); + + HydroelectricGroupVo group(); } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java index ed6e432..aef388a 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java @@ -1,14 +1,19 @@ package com.hnac.hzims.operational.homePage.service.impl; + import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.equipment.entity.PlanGenerationEntity; import com.hnac.hzims.equipment.feign.IPlanGenertionClient; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.equipment.vo.PlanPowerYearVo; import com.hnac.hzims.hzimsweather.feign.IRainfallClient; +import com.hnac.hzims.hzimsweather.response.weather.Daily; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse; -import com.hnac.hzims.operational.homePage.Hydroelectric.vo.*; +import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse; +import com.hnac.hzims.operational.homePage.hydroelectric.constant.HydroelectricConstant; +import com.hnac.hzims.operational.homePage.hydroelectric.vo.*; import com.hnac.hzims.operational.homePage.service.HydroelectricService; import com.hnac.hzims.operational.main.service.IWeatherService; import com.hnac.hzims.operational.main.vo.HydropowerUnitRealVo; @@ -23,11 +28,15 @@ import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.system.entity.Dept; +import org.springblade.system.feign.ISysClient; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.math.RoundingMode; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @@ -40,11 +49,12 @@ import java.util.stream.Collectors; @Slf4j public class HydroelectricServiceImpl implements HydroelectricService { - private final IStationService stationService; private final IWeatherService weatherService; + private final ISysClient sysClient; + private final IRainfallClient rainClient; private final IPlanGenertionClient planClient; @@ -97,8 +107,10 @@ public class HydroelectricServiceImpl implements HydroelectricService { } // 设备 if(CollectionUtil.isNotEmpty(devices)){ - result.setDevices(devices.stream().map(iter->{ + result.setDevices(devices.stream().filter(device-> station.getRefDept().equals(device.getCreateDept())).map(iter->{ HydroelectricDeviceVo device = new HydroelectricDeviceVo(); + device.setDeivceCode(iter.getEmCode()); + device.setDeivceName(iter.getName()); Optional real = reals.stream().filter(o-> iter.getEmCode().equals(o.getDeviceCode())).findFirst(); // 实时数据 if(real.isPresent()){ @@ -145,13 +157,18 @@ public class HydroelectricServiceImpl implements HydroelectricService { }else{ result.setCapacityRate(0.0); } - // 月计划发电量、月已发电量 + // 月计划发电量、月已发电量、月完成率 if(CollectionUtil.isNotEmpty(plans)){ - result.setPowerMonPlan(plans.stream().filter(plan -> plan.getMon().contains(DateUtil.format(new Date(),"yyyy-NM"))).mapToDouble(PlanPowerYearVo::getPlanPower).sum()); + result.setPowerMonPlan(plans.stream().filter(plan -> plan.getMon().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(PlanPowerYearVo::getPlanPower).sum()); }else{ result.setPowerMonPlan(0.0); } result.setPowerMon(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerMon).sum()); + if(result.getPowerMonPlan() <= 0 || result.getPowerMon() <= 0){ + result.setPowerRateMon(0.0); + }else{ + result.setPowerRateMon(BigDecimal.valueOf(result.getPowerMon() / result.getPowerMonPlan() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); + } // 年计划发电量、年已发电量 if(CollectionUtil.isNotEmpty(plans)){ @@ -160,6 +177,11 @@ public class HydroelectricServiceImpl implements HydroelectricService { result.setPowerYearPlan(0.0); } result.setPowerYear(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerYear).sum()); + if(result.getPowerYearPlan() <= 0 || result.getPowerYear() <= 0){ + result.setPowerRateYear(0.0); + }else{ + result.setPowerRateYear(BigDecimal.valueOf(result.getPowerYear() / result.getPowerYearPlan() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); + } // 今日发电量、昨日发电量 result.setPowerDay(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerDay).sum()); @@ -174,6 +196,493 @@ public class HydroelectricServiceImpl implements HydroelectricService { } /** + * 水电站区域指标 + * @param deptId + * @return + */ + @Override + public HydroelectricAreaVo area(Long deptId) { + HydroelectricAreaVo area = new HydroelectricAreaVo(); + // 区域下站点 + List stations = this.stationByArea(deptId); + if(CollectionUtil.isEmpty(stations)){ + return area; + } + // 站点计划发电量数据 + List plans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()),null,DateUtil.format(new Date(),"yyyy")); + + // 机构名称 + R dept = sysClient.getDept(deptId); + if(dept.isSuccess() && ObjectUtil.isNotEmpty(dept.getData())){ + area.setDeptId(dept.getData().getId()); + area.setDeptName(dept.getData().getDeptName()); + } + List refDepts = stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()); + // 站点数量 + area.setCount(stations.size()); + // 实时数据 + List reals = (List) redisTemplate.opsForValue().get(LOAD_HYDROPOWER_REAL_KEY); + if (CollectionUtil.isNotEmpty(reals)) { + List stationReals = reals.stream().filter(real -> refDepts.contains(real.getDeptId())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(stationReals)) { + // 容量 + area.setCapacity(stationReals.stream().mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum()); + // 负荷 + area.setLoad(reals.stream().mapToDouble(o->{ + if("MW".equalsIgnoreCase(o.getPowerUnit())){ + return o.getActivePower() * 1000; + } + return o.getActivePower(); + }).sum()); + // 容量利用率 + if (area.getCapacity() <= 0 || area.getLoad() <= 0) { + area.setCapacityRate(0.0); + }else{ + area.setCapacityRate(BigDecimal.valueOf(area.getLoad() / area.getCapacity() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); + } + } + } + // 指标数据 + List targets = (List) redisTemplate.opsForValue().get(LOAD_HYDROPOWER_TARGET_KEY); + if (CollectionUtil.isNotEmpty(targets)) { + List stationTargets = targets.stream().filter(device -> refDepts.contains(device.getDeptId())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(targets)) { + // 年发电量 + area.setGenerateYear(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum()); + // 月发电量 + area.setGenerateMon(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum()); + // 日发电量 + area.setGenerateDay(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerDay).sum()); + // 年计划发电量 + area.setGeneratePlanYear(planClient.getPlanPowerYear(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), DateUtil.format(new Date(),"yyyy"))); + if(area.getGeneratePlanYear() <= 0 || area.getGenerateYear() <= 0){ + area.setGenerateRate(0.0); + }else{ + area.setGenerateRate(BigDecimal.valueOf(area.getGenerateYear() / area.getGeneratePlanYear() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); + } + + } + } + // 站点近年发电数据 key - id value - 月份,发电量 + Map> maps = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); + // 近3年发电量 + area.setRecentYears(this.recentYears(stations,maps)); + // 发电量完成趋势 + area.setCompletes(this.completes(stations,maps,plans)); + // 站点综合信息 + area.setStations(this.comprehensive(stations,plans,reals,targets)); + return area; + } + + /** + * 水电站集团指标 + * @return + */ + @Override + public HydroelectricGroupVo group() { + HydroelectricGroupVo group = new HydroelectricGroupVo(); + + // 查询用户当前权限站点 + List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getServeType,HydroelectricConstant.PROXY_OPEARIONAL) + .eq(StationEntity::getType,HydroelectricConstant.HYDROPOWER) + ); + if(CollectionUtil.isEmpty(stations)){ + return group; + } + + // 查询用户权限机构 + R> currents = sysClient.getDeptByCurrentUser(); + if(!currents.isSuccess() || CollectionUtil.isEmpty(currents.getData())){ + return group; + } + // 区域机构 + List areas = currents.getData().stream().filter(o->o.getDeptCategory().equals(3)).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(areas)){ + return group; + } + + List plans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()),null,DateUtil.format(new Date(),"yyyy")); + + // 机构名称 + Optional dept = currents.getData().stream().min(Comparator.comparing(Dept::getDeptCategory)); + if(dept.isPresent()){ + group.setDeptId(dept.get().getId()); + group.setDeptName(dept.get().getDeptName()); + } + + List refDepts = stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()); + // 站点数量 + group.setCount(stations.size()); + // 实时数据 + List reals = (List) redisTemplate.opsForValue().get(LOAD_HYDROPOWER_REAL_KEY); + if (CollectionUtil.isNotEmpty(reals)) { + List stationReals = reals.stream().filter(real -> refDepts.contains(real.getDeptId())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(stationReals)) { + // 容量 + group.setCapacity(stationReals.stream().mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum()); + // 负荷 + group.setLoad(reals.stream().mapToDouble(o->{ + if("MW".equalsIgnoreCase(o.getPowerUnit())){ + return o.getActivePower() * 1000; + } + return o.getActivePower(); + }).sum()); + // 容量利用率 + if (group.getCapacity() <= 0 || group.getLoad() <= 0) { + group.setCapacityRate(0.0); + }else{ + group.setCapacityRate(BigDecimal.valueOf(group.getLoad() / group.getCapacity() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); + } + } + } + // 指标数据 + List targets = (List) redisTemplate.opsForValue().get(LOAD_HYDROPOWER_TARGET_KEY); + if (CollectionUtil.isNotEmpty(targets)) { + List stationTargets = targets.stream().filter(device -> refDepts.contains(device.getDeptId())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(targets)) { + // 年发电量 + group.setGenerateYear(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum()); + // 月发电量 + group.setGenerateMon(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum()); + // 日发电量 + group.setGenerateDay(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerDay).sum()); + // 年计划发电量 + group.setGeneratePlanYear(planClient.getPlanPowerYear(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), DateUtil.format(new Date(),"yyyy"))); + if(group.getGeneratePlanYear() <= 0 || group.getGenerateYear() <= 0){ + group.setGenerateRate(0.0); + }else{ + group.setGenerateRate(BigDecimal.valueOf(group.getGenerateYear() / group.getGeneratePlanYear() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); + } + + } + } + + // 站点近年发电数据 key - id value - 月份,发电量 + Map> maps = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); + + // 近3年发电量 + group.setRecentYears(this.recentYears(stations,maps)); + + // 发电量完成趋势 + group.setCompletes(this.completes(stations,maps,plans)); + + // 区域综合信息 + Map> groupArea = areas.stream().collect(Collectors.toMap(obj -> obj, obj -> { + List groups = currents.getData().stream().filter(o->o.getParentId().equals(obj.getId())).collect(Collectors.toList()); + return stations.stream().filter(station -> groups.stream().map(Dept::getId).collect(Collectors.toList()).contains(station.getRefDept())).collect(Collectors.toList()); + })); + group.setAreas(this.comprehensiveArea(groupArea,plans,reals,targets)); + return group; + } + + + /** + * 区域综合信息 + * @param areas + * @param plans + * @param reals + * @param targets + * @return + */ + private List comprehensiveArea(Map> areas, List plans, List reals, List targets) { + // 站点 : 利用情况 && 天气 && 排名 + List codes = areas.values().stream().filter(CollectionUtil::isNotEmpty).map(values -> values.get(0).getCode()).collect(Collectors.toList()); + // 获取站点实时天气 + Map nowWeather = this.weatherService.getNowWeather(codes); + // 获取站点7日天气 + Map weekWeather = this.weatherService.getWeekWeather(codes); + // 计划发电量 + List result = areas.entrySet().stream().filter(entry->CollectionUtil.isNotEmpty(entry.getValue())).map(itr->{ + HydroelectricGroupAreaVo groupArea = new HydroelectricGroupAreaVo(); + groupArea.setDeptId(itr.getKey().getId()); + groupArea.setDeptName(itr.getKey().getDeptName()); + // 站点温度、近7日天气 + groupArea.setTemp(this.stationTemp(nowWeather,itr.getValue().get(0).getCode())); + groupArea.setWeather(this.stationWeather(weekWeather,itr.getValue().get(0).getCode())); + List refDepts = itr.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()); + List stationCodes = itr.getValue().stream().map(StationEntity::getCode).collect(Collectors.toList()); + // 指标数据: 发电量完成率 + if(CollectionUtil.isNotEmpty(targets)){ + // 当年发电量 + groupArea.setGenerateYear(targets.stream().filter(target-> refDepts.contains(target.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum()); + if(CollectionUtil.isNotEmpty(plans)){ + // 当年计划发电量 + double generatePlan = plans.stream().filter(plan-> stationCodes.contains(plan.getStationId())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum(); + if(groupArea.getGenerateYear() <= 0 || generatePlan <= 0.0){ + groupArea.setGenerateRate(0.0); + }else{ + groupArea.setGenerateRate(BigDecimal.valueOf(groupArea.getGenerateYear() / generatePlan * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); + } + }else{ + groupArea.setGenerateRate(0.0); + } + + } + // 实时数据: 容量利用率、电站利用率 + if(CollectionUtil.isNotEmpty(reals)){ + // 实时功率 + double use = reals.stream().filter(real-> refDepts.contains(real.getDeptId())).mapToDouble(o->{ + if("MW".equalsIgnoreCase(o.getPowerUnit())){ + return o.getActivePower() * 1000; + } + return o.getActivePower(); + }).sum(); + if(CollectionUtil.isNotEmpty(plans)){ + // 装机容量 + double capacity = reals.stream().filter(real-> refDepts.contains(real.getDeptId())).mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum(); + if(Math.abs(capacity) > 0){ + groupArea.setCapacityUse(BigDecimal.valueOf(use / capacity * 100).setScale(1, RoundingMode.HALF_UP).doubleValue()); + }else{ + groupArea.setCapacityUse(0.0); + } + }else{ + groupArea.setCapacityUse(0.0); + } + // 开机数量 + long on = reals.stream().filter(real -> refDepts.contains(real.getDeptId()) && real.getState()).count(); + long sum = reals.stream().filter(real-> refDepts.contains(real.getDeptId())).count(); + if(sum > 0){ + groupArea.setDeviceUse(BigDecimal.valueOf(on / (double)sum * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); + }else{ + groupArea.setDeviceUse(0.0); + } + } + return groupArea; + }).collect(Collectors.toList()); + + double generateSum = result.stream().mapToDouble(HydroelectricGroupAreaVo::getGenerateYear).sum(); + // 返回结果集 + if(generateSum <= 0){ + return result.stream().peek(scale-> scale.setAreaMakeUp(0.0)).filter(scale-> Math.abs(scale.getCapacityUse()) > 0 || Math.abs(scale.getAreaMakeUp()) > 0 + || Math.abs(scale.getDeviceUse()) > 0 || Math.abs(scale.getGenerateRate()) > 0) + .sorted(Comparator.comparing(HydroelectricGroupAreaVo::getGenerateYear).reversed()).collect(Collectors.toList()); + } + return result.stream().peek(scale-> scale.setAreaMakeUp(BigDecimal.valueOf(scale.getGenerateYear() / generateSum * 100).setScale(1, RoundingMode.HALF_UP).doubleValue())). + filter(scale-> Math.abs(scale.getCapacityUse()) > 0 || Math.abs(scale.getAreaMakeUp()) > 0 + || Math.abs(scale.getDeviceUse()) > 0 || Math.abs(scale.getGenerateRate()) > 0) + .sorted(Comparator.comparing(HydroelectricGroupAreaVo::getGenerateYear).reversed()).collect(Collectors.toList()); + } + + + + /** + * 区域近3年发电量 + * @param stations + * @return + */ + private List recentYears(List stations, Map> maps) { + // 过滤站点发电量数据 + List> generates = maps.entrySet().stream().filter(entry -> stations.stream().map(StationEntity::getCode).collect(Collectors.toList()).contains(entry.getKey())).map(Map.Entry::getValue).collect(Collectors.toList()); + + // 根据月份分组 + List generateMons = new ArrayList<>(); + if(CollectionUtil.isNotEmpty(generates)){ + generates.forEach(item -> item.forEach((key, value) -> { + HydroelectricGenerateMonVo generateMon = new HydroelectricGenerateMonVo(); + generateMon.setStrMonth(key); + generateMon.setGenerate(Double.valueOf(value)); + generateMons.add(generateMon); + })); + } + + // 月份发电量数据整合 + List mons = this.mons(2,12,false); + List integrations = mons.stream().map(mon->{ + HydroelectricGenerateMonVo integration = new HydroelectricGenerateMonVo(); + integration.setStrMonth(mon); + LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), mon), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + integration.setYear(localDate.getYear()); + integration.setMonth(localDate.getMonthValue()); + integration.setGenerate(generateMons.stream().filter(o->o.getStrMonth().equals(mon)).mapToDouble(HydroelectricGenerateMonVo::getGenerate).sum()); + return integration; + }).collect(Collectors.toList()); + + // 根据年份分组 + Map> year = integrations.stream().collect(Collectors.groupingBy(HydroelectricGenerateMonVo::getYear)); + // 返回结果集 + return year.entrySet().stream().map(entry -> { + HydroelectricGenerateYearVo generateYear = new HydroelectricGenerateYearVo(); + generateYear.setYear(entry.getKey()); + List sortValue = entry.getValue().stream().sorted(Comparator.comparing(HydroelectricGenerateMonVo::getMonth)).collect(Collectors.toList()); + generateYear.setGenerateMons(sortValue); + return generateYear; + }).collect(Collectors.toList()); + } + + /** + * 计划完成完成趋势 + * @param stations + * @param maps + * @param plans + * @return + */ + private List completes(List stations, Map> maps, List plans) { + // 获取月份集合 + List monList = this.mons(0,12,false); + return monList.stream().map(o->{ + HydroelectricGenerateMonVo generate = new HydroelectricGenerateMonVo(); + LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), o), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + generate.setStrMonth(o); + generate.setYear(localDate.getYear()); + generate.setMonth(localDate.getMonthValue()); + // 实际发电量 + if(CollectionUtil.isEmpty(maps)){ + generate.setGenerate(0.0); + }else{ + generate.setGenerate(maps.entrySet().stream(). + filter(entry->stations.stream().map(StationEntity::getCode).collect(Collectors.toList()).contains(entry.getKey())). + mapToDouble(valueMap-> valueMap.getValue().entrySet().stream().filter(entry->entry.getKey().equals(o)) + .mapToDouble(Map.Entry::getValue).sum()).sum()); + } + // 计划发电量 + if(CollectionUtil.isEmpty(plans)){ + generate.setPlanGenerate(0.0); + }else{ + String mon = localDate.format(DateTimeFormatter.ofPattern("yyyy-MM")); + generate.setPlanGenerate(plans.stream().filter(plan->mon.equals(plan.getDateTime())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); + } + return generate; + }).collect(Collectors.toList()); + } + + + /** + * 站点综合信息 + * @param reals + * @param targets + * @return + */ + private List comprehensive(List stations, List plans , List reals, List targets) { + // 站点 : 利用情况 && 天气 && 排名 + List codes = stations.stream().map(StationEntity::getCode).collect(Collectors.toList()); + // 获取站点实时天气 + Map nowWeather = this.weatherService.getNowWeather(codes); + // 获取站点7日天气 + Map weekWeather = this.weatherService.getWeekWeather(codes); + // 计划发电量 + List result = stations.stream().map(itr->{ + HydroelectricAreaStationVo station = new HydroelectricAreaStationVo(); + station.setDeptId(itr.getRefDept()); + station.setStationCode(itr.getCode()); + station.setStationName(itr.getName()); + // 站点温度、近7日天气 + station.setTemp(this.stationTemp(nowWeather,itr.getCode())); + station.setWeather(this.stationWeather(weekWeather,itr.getCode())); + // 指标数据: 发电量完成率 + if(CollectionUtil.isNotEmpty(targets)){ + // 当年发电量 + station.setGenerateYear(targets.stream().filter(target-> itr.getRefDept().equals(target.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum()); + if(CollectionUtil.isNotEmpty(plans)){ + // 当年计划发电量 + double generatePlan = plans.stream().filter(plan-> itr.getCode().equals(plan.getStationId())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum(); + if(station.getGenerateYear() <= 0 || generatePlan <= 0.0){ + station.setGenerateRate(0.0); + }else{ + station.setGenerateRate(BigDecimal.valueOf(station.getGenerateYear() / generatePlan * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); + } + }else{ + station.setGenerateRate(0.0); + } + + } + // 实时数据: 容量利用率、电站利用率 + if(CollectionUtil.isNotEmpty(reals)){ + // 实时功率 + double use = reals.stream().filter(real-> itr.getRefDept().equals(real.getDeptId())).mapToDouble(o->{ + if("MW".equalsIgnoreCase(o.getPowerUnit())){ + return o.getActivePower() * 1000; + } + return o.getActivePower(); + }).sum(); + if(CollectionUtil.isNotEmpty(plans)){ + // 装机容量 + double capacity = reals.stream().filter(real-> itr.getRefDept().equals(real.getDeptId())).mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum(); + if(Math.abs(capacity) > 0){ + station.setCapacityUse(BigDecimal.valueOf(use / capacity * 100).setScale(1, RoundingMode.HALF_UP).doubleValue()); + }else{ + station.setCapacityUse(0.0); + } + }else{ + station.setCapacityUse(0.0); + } + // 开机数量 + long on = reals.stream().filter(real -> itr.getRefDept().equals(real.getDeptId()) && real.getState()).count(); + long sum = reals.stream().filter(real-> itr.getRefDept().equals(real.getDeptId())).count(); + if(sum > 0){ + station.setDeviceUse(BigDecimal.valueOf(on / (double)sum * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); + }else{ + station.setDeviceUse(0.0); + } + } + return station; + }).collect(Collectors.toList()); + + double generateSum = result.stream().mapToDouble(HydroelectricAreaStationVo::getGenerateYear).sum(); + // 返回结果集 + if(generateSum <= 0){ + return result.stream().peek(scale-> scale.setAreaMakeUp(0.0)).filter(scale-> Math.abs(scale.getCapacityUse()) > 0 || Math.abs(scale.getAreaMakeUp()) > 0 + || Math.abs(scale.getDeviceUse()) > 0 || Math.abs(scale.getGenerateRate()) > 0) + .sorted(Comparator.comparing(HydroelectricAreaStationVo::getGenerateYear).reversed()).collect(Collectors.toList()); + } + return result.stream().peek(scale-> scale.setAreaMakeUp(BigDecimal.valueOf(scale.getGenerateYear() / generateSum * 100).setScale(1, RoundingMode.HALF_UP).doubleValue())). + filter(scale-> Math.abs(scale.getCapacityUse()) > 0 || Math.abs(scale.getAreaMakeUp()) > 0 + || Math.abs(scale.getDeviceUse()) > 0 || Math.abs(scale.getGenerateRate()) > 0) + .sorted(Comparator.comparing(HydroelectricAreaStationVo::getGenerateYear).reversed()).collect(Collectors.toList()); + } + + + /** + * 温度 + * @param nowWeather + * @param code + */ + private String stationTemp(Map nowWeather, String code) { + // 实时天气 + if(MapUtils.isNotEmpty(nowWeather) && nowWeather.containsKey(code)){ + HeWeatherWeatherNowResponse nowData = nowWeather.get(code); + if(ObjectUtil.isNotEmpty(nowData.getNow())){ + return nowData.getNow().getTemp(); + } + } + return "21"; + } + + + // 站点七日内天气 + private List stationWeather(Map weekWeather, String code) { + // 实时天气 + if(MapUtils.isNotEmpty(weekWeather) && weekWeather.containsKey(code)){ + HeWeatherWeatherDailyResponse weekData = weekWeather.get(code); + return weekData.getDaily(); + } + return new ArrayList<>(); + } + + + /** + * 区域下站点 + * @param deptId + * @return + */ + private List stationByArea(Long deptId) { + // 用户权限机构 + R> depts = sysClient.getDeptByCurrentUser(); + if(!depts.isSuccess() || CollectionUtil.isEmpty(depts.getData())){ + return new ArrayList<>(); + } + List deptIds = depts.getData().stream().filter(dept->dept.getParentId().equals(deptId)).map(Dept::getId).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(deptIds)) { + return new ArrayList<>(); + } + return stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getType, HydroelectricConstant.HYDROPOWER) + .eq(StationEntity::getServeType,HydroelectricConstant.PROXY_OPEARIONAL) + .in(StationEntity::getRefDept,deptIds) + ); + } + + /** * 站点近30天降雨数据 * @param station * @return @@ -209,7 +718,7 @@ public class HydroelectricServiceImpl implements HydroelectricService { * @param devices * @return */ - private List stationPowerRains(List devices,List> rains) { + private List stationPowerRains(List devices, List> rains) { List generates = new ArrayList<>(); devices.forEach(device->{ generates.addAll(device.getGenerates()); @@ -269,15 +778,15 @@ public class HydroelectricServiceImpl implements HydroelectricService { generateMon.setMonth(date.getMonth() + 1); // 计划发电量 if(CollectionUtil.isNotEmpty(plans)){ - generateMon.setPlanPower(plans.stream().filter(plan -> plan.getMon().contains(DateUtil.format(date,"yyyy-MM"))).mapToDouble(PlanPowerYearVo::getPlanPower).sum()); + generateMon.setPlanGenerate(plans.stream().filter(plan -> plan.getMon().contains(DateUtil.format(date,"yyyy-MM"))).mapToDouble(PlanPowerYearVo::getPlanPower).sum()); }else{ - generateMon.setPlanPower(0.0); + generateMon.setPlanGenerate(0.0); } // 实际发电 if(MapUtils.isNotEmpty(map)){ - generateMon.setPower(map.entrySet().stream().filter(entry->entry.getKey().equals(mon)).mapToDouble(Map.Entry::getValue).sum()); + generateMon.setGenerate(map.entrySet().stream().filter(entry->entry.getKey().equals(mon)).mapToDouble(Map.Entry::getValue).sum()); }else{ - generateMon.setPlanPower(0.0); + generateMon.setGenerate(0.0); } return generateMon; }).collect(Collectors.toList()); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java index e6642ea..beebac5 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java @@ -18,7 +18,7 @@ import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; import com.hnac.hzims.operational.defect.service.IOperPhenomenonService; import com.hnac.hzims.operational.duty.service.IImsDutyMainService; import com.hnac.hzims.operational.duty.vo.DutyMainInfoVo; -import com.hnac.hzims.operational.homePage.Hydroelectric.vo.HydroelectricPowerRainVo; +import com.hnac.hzims.operational.homePage.hydroelectric.vo.HydroelectricPowerRainVo; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.entity.UserDeptEntity; import com.hnac.hzims.operational.main.service.*; From e053e44ba43f90560734c332d449d9b737138781 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 20 Aug 2024 08:30:47 +0800 Subject: [PATCH 3/5] =?UTF-8?q?#=E9=A6=96=E9=A1=B5=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java | 2 +- .../operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java index ec21858..f3ce2b7 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.homePage.hydroelectric.vo; +package com.hnac.hzims.operational.homePage.Hydroelectric.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java index 2fcb5e3..a2aae0e 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.homePage.hydroelectric.vo; +package com.hnac.hzims.operational.homePage.Hydroelectric.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; From efd438006b25c6e6e249af71405c761c1a4abedc Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 20 Aug 2024 08:31:22 +0800 Subject: [PATCH 4/5] =?UTF-8?q?#=E9=A6=96=E9=A1=B5=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java | 2 +- .../operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java index f3ce2b7..ec21858 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.homePage.Hydroelectric.vo; +package com.hnac.hzims.operational.homePage.hydroelectric.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java index a2aae0e..2fcb5e3 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.homePage.Hydroelectric.vo; +package com.hnac.hzims.operational.homePage.hydroelectric.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; From 621a0fb3fcd0fc146a5852f44c171882fadb9e36 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 20 Aug 2024 08:34:36 +0800 Subject: [PATCH 5/5] =?UTF-8?q?#=E9=A6=96=E9=A1=B5=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java | 2 +- .../operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java index ec21858..4eb7c5b 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java @@ -19,7 +19,7 @@ public class HydroelectricDeviceVo { @ApiModelProperty(value = "设备名称") private String deivceName; - @ApiModelProperty(value = "开关机状态: 0 - 关机 1 - 开机") + @ApiModelProperty(value = "开关机状态 : 0 - 关机 1 - 开机") private Boolean state; @ApiModelProperty(value = "总装机容量") diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java index 2fcb5e3..22df4ec 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java @@ -8,7 +8,7 @@ import lombok.Data; * @author ysj */ @Data -@ApiModel(value = "站点首页-最近30日发电量/降雨量") +@ApiModel(value = "站点首页 - 最近30日发电量/降雨量") public class HydroelectricPowerRainVo { @ApiModelProperty(value = "日期")