From c414f102271b4be7851c1e409ef828561f2da8ee Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 30 May 2024 11:33:49 +0800 Subject: [PATCH] =?UTF-8?q?add:=E5=8E=86=E5=8F=B2=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/interactive/constants/DateEnum.java | 12 ++++++------ .../service/impl/AnalyseDataServiceImpl.java | 20 +++++++++++++++++--- .../service/impl/InteractiveServiceImpl.java | 5 ++++- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java index 82f5cba..019f2ef 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java @@ -11,12 +11,12 @@ import java.util.Arrays; */ @AllArgsConstructor public enum DateEnum { - YEAR("year","年","按年",5,6), - MONTH("month","月","按月",4,5), - DAY("day","日","按日",3,3), - HOUR("hour","时","按时",2,2), - MINUTE("minute","分","按分",1,1), - SECOND("second","秒","按秒",0,0), + YEAR("year","每年","按年",5,6), + MONTH("month","每月","按月",4,5), + DAY("day","每天","按天",3,3), + HOUR("hour","每小时","按小时",2,2), + MINUTE("minute","每分钟","按分钟",1,1), + SECOND("second","每秒","按秒",0,0), ; @Getter private String code; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java index 9cfc479..2385bca 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java @@ -1,5 +1,6 @@ package com.hnac.hzims.bigmodel.interactive.service.impl; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.google.common.collect.Lists; import com.hnac.hzims.bigmodel.interactive.constants.DataMethodEnum; @@ -17,8 +18,10 @@ import com.hnac.hzinfo.sdk.v5.device.dto.ReductionDataDTO; import com.hnac.hzinfo.sdk.v5.device.vo.ReductionDataVO; import lombok.AllArgsConstructor; import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; import org.springframework.util.Assert; @@ -40,11 +43,13 @@ import java.util.stream.Collectors; public class AnalyseDataServiceImpl implements IAnalyseDataService { private final DeviceDataClient deviceDataClient; + private final BladeLogger logger; public static final int DATA_COUNT_MAX = 8000; @Override public ExtraVO getHistoryData(HistoryDataSearchVO searchVO) { - if(DataMethodEnum.USUAL.getMethod().equals(searchVO.getMethod())) { + if(Func.isEmpty(searchVO.getDataType()) || StringUtil.isBlank(searchVO.getDataType()) + || DataMethodEnum.USUAL.getMethod().equals(searchVO.getMethod())) { searchVO.setDataType(DateEnum.SECOND.getDateType()); } // 聚合数据方式处理 @@ -52,12 +57,11 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService { searchVO.setDataType(dateEnum.getDateType()); // 获取最适配时间段 DateEnum adapterDate = this.getDateEnumByDuration(searchVO.getStartTime(), searchVO.getEndTime(), dateEnum); + String note = adapterDate.getDateType().equals(searchVO.getDataType()) ? "" : "(由于数据量过大,只能帮您" + adapterDate.getDateType() + "查询)"; searchVO.setDataType(adapterDate.getDateType()); - String label = "根据数据量匹配到的取数规则为:" + adapterDate.getDateType() + "查询,查询结果如下:"; ExtraVO extraVO = new ExtraVO(); extraVO.setType(FuncRouteEnum.HISTORY_DATA.getType().getType()); extraVO.setFuncCode(FuncRouteEnum.HISTORY_DATA.getFuncCode()); - extraVO.setLabel(label); Map params = new HashMap<>(1); ReductionDataVO dataVO = this.getPolymerizationData(searchVO); List datalist = dataVO.getDataList().stream().map(m -> { @@ -65,6 +69,15 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService { m.remove(searchVO.getSignage()); return m; }).collect(Collectors.toList()); + DataMethodEnum enumByMethod = DataMethodEnum.getEnumByMethod(searchVO.getMethod()); + String label = searchVO.getStationName() + "_" + + searchVO.getDeviceName() + "_" + + dataVO.getFieldMap().get(searchVO.getSignage()) + "_" + + adapterDate.getName() + + enumByMethod.getMethod() + + note + + ":"; + extraVO.setLabel(label); params.put("data",datalist); params.put("deviceName",searchVO.getDeviceName()); params.put("attrName",dataVO.getFieldMap().get(searchVO.getSignage())); @@ -92,6 +105,7 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService { dataDTO.setSaveTimeType(dateEnum.getSaveTimeType()); dataDTO.setTimeInterval(1); dataDTO.setDtos(Lists.newArrayList(reductionAttrData)); + logger.info("interactive:getPolymerizationData","config传参为:" + JSON.toJSONString(dataDTO)); Result dataVO = deviceDataClient.pageDeviceCodeAndSignages(dataDTO); Assert.isTrue(dataVO.isSuccess(),() -> { throw new ServiceException("聚合历史数据查询失败!"); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java index 317f17d..1531362 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java @@ -50,6 +50,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.util.Assert; +import org.springframework.util.StringUtils; import javax.servlet.http.HttpServletResponse; import java.time.LocalDateTime; @@ -229,12 +230,14 @@ public class InteractiveServiceImpl implements IInteractiveService { params.put("ids",Func.toStrList(",",sessionIds).toArray()); HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantStatus()) .body(JSON.toJSONString(params)).execute(); - logger.info("interactive:getAnswerBySessionIds","获取答案:" + response.body()); Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { throw new ServiceException("远程调用大模型【获取问题答案】接口失败!"); }); XxlJobLogger.log("接收到答案:"+JSON.toJSONString(response.body())); List result = JSONArray.parseArray(response.body(), AnswerVO.class); + if(CollectionUtil.isNotEmpty(result)) { + logger.info("interactive:getAnswerBySessionIds","获取答案:" + response.body()); + } result.stream().filter(answerVO -> answerVO.getRunning() == 0).forEach(answerVO -> { Object[] extras = answerVO.getExtras(); if(ObjectUtil.isEmpty(answerVO.getExtras()) || extras.length == 0){