diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java index 8574363..28019bd 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java @@ -30,7 +30,7 @@ public interface IStationClient { String LIST = API_PREFIX + "/list"; String QUERY_EXIST_LGTD_LTTD = API_PREFIX + "/queryExistLgtdAndLttd"; String GET_ONE = API_PREFIX + "/getOne"; - String GET_STATIONS_BY_TYPE_AND_DURATION = "/getStationByTypeAndDuration"; + String GET_STATIONS_BY_TYPE_AND_DURATION = API_PREFIX + "/getStationByTypeAndDuration"; String QUERY_STATION_BY_CODES = API_PREFIX + "/querySatationByCodes"; @GetMapping(GET_LIST_ALL) @@ -83,5 +83,5 @@ public interface IStationClient { R> querySatationByCodes(@RequestParam("codes") List codes); @GetMapping(GET_STATIONS_BY_TYPE_AND_DURATION) - R> getStationByTypeAndDuration(@RequestParam(required = false) String startTime,@RequestParam(required = false) String endTime,@RequestParam String type); + R> getStationByTypeAndDuration(@RequestParam(required = false) String startTime,@RequestParam(required = false) String endTime,@RequestParam(required = false) String type); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java index 15be73a..51ce3a1 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java @@ -11,23 +11,25 @@ import java.util.Arrays; */ @AllArgsConstructor public enum SearchStationTypeEnum { - TOTAL("站点总数量",null), - HYDROPOWER_TOTAL("水电站总数量","0"), - WIND_POWER_TOTAL("风电场总数量","1"), - ENERGY_STORAGE_TOTAL("储能站总数量","3"), - PHOTOVOLTAIC_TOTAL("光伏站总数量","5"), - CHARGE_TOTAL("充电站总数量","7"), - HYDROPOWER_NUM("水电站接入量","0"), - WIND_POWER_NUM("风电场接入量","1"), - ENERGY_STORAGE_NUM("储能站接入量","3"), - PHOTOVOLTAIC_NUM("光伏站接入量","5"), - CHARGE_NUM("充电站接入量","7"), + TOTAL("站点总数量",null,"运维平台目前接入站点总数为:%s"), + HYDROPOWER_TOTAL("水电站总数量","0","运维平台目前接入水电站总数为:%s"), + WIND_POWER_TOTAL("风电场总数量","1","运维平台目前接入风电场总数为:%s"), + ENERGY_STORAGE_TOTAL("储能站总数量","3","运维平台目前接入储能站总数为:%s"), + PHOTOVOLTAIC_TOTAL("光伏站总数量","5","运维平台目前接入光伏站总数为:%s"), + CHARGE_TOTAL("充电站总数量","7","运维平台目前接入充电站总数为:%s"), + HYDROPOWER_NUM("水电站接入量","0","运维平台目前接入水电站接入量为:%s"), + WIND_POWER_NUM("风电场接入量","1","运维平台目前接入风电场接入量为:%s"), + ENERGY_STORAGE_NUM("储能站接入量","3","运维平台目前接入储能站接入量为:%s"), + PHOTOVOLTAIC_NUM("光伏站接入量","5","运维平台目前接入光伏站接入量为:%s"), + CHARGE_NUM("充电站接入量","7","运维平台目前接入充电站接入量为:%s"), ; @Getter private String searchStationType; @Getter private String stationType; + @Getter + private String label; public static SearchStationTypeEnum getTypeEnum(String searchStationType) { return Arrays.stream(SearchStationTypeEnum.class.getEnumConstants()) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java index 03dd26e..0771fba 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java @@ -5,6 +5,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.bigmodel.BigModelConstants; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; +import com.hnac.hzims.bigmodel.interactive.vo.StationSearchVO; import com.hnac.hzinfo.log.annotation.Business; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -77,8 +78,8 @@ public class InteractiveController { @ApiOperation("解析接入站点数量") @ApiOperationSupport(order = 7) @PostMapping("/resolveStations") - public R resolveStations(String startTime,String endTime,String type,String enumType) { - return R.data(interactiveService.resolveStations(startTime,endTime,type,enumType)); + public R resolveStations(@RequestBody StationSearchVO req) { + return R.data(interactiveService.resolveStations(req.getStartTime(),req.getEndTime(),req.getType(),req.getEnumType())); } @ApiOperation("站点发电量") diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index 4143a10..ed8ffff 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -81,6 +81,9 @@ public class ExtraResolveStrategyService { } } } + else if(extra.containsKey("extra")){ + return extra.getObject("extra",ExtraVO.class); + } return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class); } 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 516c5ea..bfe3f2d 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 @@ -22,7 +22,7 @@ import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzims.equipment.feign.IEmInfoClient; -import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; + import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.equipment.vo.RideDeviceVo; import com.hnac.hzims.operational.fill.feign.IGenerateClient; import com.hnac.hzims.operational.main.constant.HomePageConstant; @@ -92,8 +92,6 @@ public class InteractiveServiceImpl implements IInteractiveService { private final RedisTemplate redisTemplate; - private final IStationClient stationClient; - private final IAnalyseDataSearchClient analyseDataSearchClient; private final ExtraResolveStrategyService extraResolveStrategyService; @@ -108,40 +106,23 @@ public class InteractiveServiceImpl implements IInteractiveService { ExtraVO extraVO = new ExtraVO(); extraVO.setType(TypeEnum.PARAMS.getType()); extraVO.setFuncCode("stations_num"); - String stationType = ""; + String label; SearchStationTypeEnum stationTypeEnum = SearchStationTypeEnum.getTypeEnum(enumType); - if(SearchTypeEnum.REAL.getSearchType().equals(type)) { - startTime = null; - endTime = null; + if(!startTime.equals(endTime)) { + label = String.format("自%s到%s时间为止,",startTime,endTime); } else { - switch(stationTypeEnum) { - case HYDROPOWER_TOTAL: - case WIND_POWER_TOTAL: - case ENERGY_STORAGE_TOTAL: - case PHOTOVOLTAIC_TOTAL: - case CHARGE_TOTAL: - stationType = stationTypeEnum.getStationType(); - startTime = null; - break; - case HYDROPOWER_NUM: - case WIND_POWER_NUM: - case ENERGY_STORAGE_NUM: - case PHOTOVOLTAIC_NUM: - case CHARGE_NUM: - stationType = stationTypeEnum.getStationType(); - break; - default: - throw new ServiceException("未查询到相关"); - } + startTime = null; + endTime = null; + label = "目前"; } - R> stationListR = stationClient.getStationByTypeAndDuration(startTime, endTime, stationType); + R> stationListR = stationClient.getStationByTypeAndDuration(startTime, endTime, stationTypeEnum.getStationType()); Assert.isTrue(stationListR.isSuccess(),() -> { throw new ServiceException("获取接入站点数量失败!"); }); Map params = new HashMap<>(); params.put("searchStationType",stationTypeEnum.getSearchStationType()); - params.put("num",stationTypeEnum.getSearchStationType()); + params.put("label",label + String.format(stationTypeEnum.getLabel(),stationListR.getData().size())); params.put("startTime",startTime); params.put("endTime",endTime); extraVO.setParams(params); @@ -192,18 +173,7 @@ public class InteractiveServiceImpl implements IInteractiveService { } private void addQuestionSessionId(String sessionId) { - // 添加redis问题会话 - Object json = redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); - if(ObjectUtil.isEmpty(json)){ - List asks = Collections.singletonList(sessionId); - redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,JSONObject.toJSONString(asks)); - }else{ - List asks = JSONObject.parseArray(json.toString(),String.class); - if(!asks.contains(sessionId)){ - asks.add(sessionId); - } - redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,JSONObject.toJSONString(asks)); - } + redisTemplate.opsForList().leftPush(HZIMS_BIGMODEL_ASK_KEY,sessionId); } @Override diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSearchVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSearchVO.java new file mode 100644 index 0000000..d111b70 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSearchVO.java @@ -0,0 +1,24 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/25 14:03 + */ +@Data +public class StationSearchVO implements Serializable { + + private String startTime; + + private String endTime; + + @NotBlank(message = "查询类型不能为空") + private String type; + + private String enumType; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java index 85affae..e145733 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java @@ -23,6 +23,7 @@ import com.xxl.job.core.log.XxlJobLogger; import lombok.AllArgsConstructor; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springframework.data.redis.core.RedisTemplate; @@ -90,12 +91,7 @@ public class InteractiveSchedule { @XxlJob(GET_INTERACTIVE_RESULT) public ReturnT getInteractiveResult(String params) { - Object json = redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); - if(ObjectUtil.isEmpty(json)){ - XxlJobLogger.log("未获取到问题标识,或者用户未进行提问!"); - return ReturnT.SUCCESS; - } - List sessionIds = JSONObject.parseArray(json.toString(),String.class); + List sessionIds = redisTemplate.opsForList().range(HZIMS_BIGMODEL_ASK_KEY, 0, -1); if(CollectionUtil.isEmpty(sessionIds)){ XxlJobLogger.log("问题都已经回答完毕!"); return ReturnT.SUCCESS; @@ -106,13 +102,13 @@ public class InteractiveSchedule { if(sessionIds.contains(answerVO.getSessionId())){ WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); - wsService.sendMessage(session,message); + if(Func.isNotEmpty(session)) { + wsService.sendMessage(session,message); + } } - // 问题回答完成,去除redis问题标记 - if(answerVO.getRunning() == 0){ - sessionIds.remove(answerVO.getSessionId()); + if(answerVO.getRunning() == 0) { + redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,answerVO.getSessionId()); } - redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY, JSONObject.toJSONString(sessionIds)); }, getAnswerPoolExecutor)); return ReturnT.SUCCESS; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java index 7317f54..0f210b7 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java @@ -1,5 +1,7 @@ package com.hnac.hzims.bigmodel.schedule; +import com.hnac.hzims.common.constant.CommonConstant; + /** * @Author: huangxing * @Date: 2024/04/28 16:19 @@ -18,6 +20,6 @@ public interface XxlJobHandlerConstant { String INTERACTIVE_RESULT_KEY = "hzllm:interactive:result"; - String HZIMS_BIGMODEL_ASK_KEY = "hzims:bigmodel:ask:key"; + String HZIMS_BIGMODEL_ASK_KEY = CommonConstant.TENANT_ID + ":hzims:bigmodel:ask:key"; }