Browse Source

add:站点数量统计

zhongwei
haungxing 8 months ago
parent
commit
b74c3296c3
  1. 4
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java
  2. 24
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java
  3. 5
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java
  4. 3
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java
  5. 46
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java
  6. 24
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSearchVO.java
  7. 14
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java
  8. 4
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java

4
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 LIST = API_PREFIX + "/list";
String QUERY_EXIST_LGTD_LTTD = API_PREFIX + "/queryExistLgtdAndLttd"; String QUERY_EXIST_LGTD_LTTD = API_PREFIX + "/queryExistLgtdAndLttd";
String GET_ONE = API_PREFIX + "/getOne"; 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"; String QUERY_STATION_BY_CODES = API_PREFIX + "/querySatationByCodes";
@GetMapping(GET_LIST_ALL) @GetMapping(GET_LIST_ALL)
@ -83,5 +83,5 @@ public interface IStationClient {
R<List<StationEntity>> querySatationByCodes(@RequestParam("codes") List<String> codes); R<List<StationEntity>> querySatationByCodes(@RequestParam("codes") List<String> codes);
@GetMapping(GET_STATIONS_BY_TYPE_AND_DURATION) @GetMapping(GET_STATIONS_BY_TYPE_AND_DURATION)
R<List<StationEntity>> getStationByTypeAndDuration(@RequestParam(required = false) String startTime,@RequestParam(required = false) String endTime,@RequestParam String type); R<List<StationEntity>> getStationByTypeAndDuration(@RequestParam(required = false) String startTime,@RequestParam(required = false) String endTime,@RequestParam(required = false) String type);
} }

24
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 @AllArgsConstructor
public enum SearchStationTypeEnum { public enum SearchStationTypeEnum {
TOTAL("站点总数量",null), TOTAL("站点总数量",null,"运维平台目前接入站点总数为:%s"),
HYDROPOWER_TOTAL("水电站总数量","0"), HYDROPOWER_TOTAL("水电站总数量","0","运维平台目前接入水电站总数为:%s"),
WIND_POWER_TOTAL("风电场总数量","1"), WIND_POWER_TOTAL("风电场总数量","1","运维平台目前接入风电场总数为:%s"),
ENERGY_STORAGE_TOTAL("储能站总数量","3"), ENERGY_STORAGE_TOTAL("储能站总数量","3","运维平台目前接入储能站总数为:%s"),
PHOTOVOLTAIC_TOTAL("光伏站总数量","5"), PHOTOVOLTAIC_TOTAL("光伏站总数量","5","运维平台目前接入光伏站总数为:%s"),
CHARGE_TOTAL("充电站总数量","7"), CHARGE_TOTAL("充电站总数量","7","运维平台目前接入充电站总数为:%s"),
HYDROPOWER_NUM("水电站接入量","0"), HYDROPOWER_NUM("水电站接入量","0","运维平台目前接入水电站接入量为:%s"),
WIND_POWER_NUM("风电场接入量","1"), WIND_POWER_NUM("风电场接入量","1","运维平台目前接入风电场接入量为:%s"),
ENERGY_STORAGE_NUM("储能站接入量","3"), ENERGY_STORAGE_NUM("储能站接入量","3","运维平台目前接入储能站接入量为:%s"),
PHOTOVOLTAIC_NUM("光伏站接入量","5"), PHOTOVOLTAIC_NUM("光伏站接入量","5","运维平台目前接入光伏站接入量为:%s"),
CHARGE_NUM("充电站接入量","7"), CHARGE_NUM("充电站接入量","7","运维平台目前接入充电站接入量为:%s"),
; ;
@Getter @Getter
private String searchStationType; private String searchStationType;
@Getter @Getter
private String stationType; private String stationType;
@Getter
private String label;
public static SearchStationTypeEnum getTypeEnum(String searchStationType) { public static SearchStationTypeEnum getTypeEnum(String searchStationType) {
return Arrays.stream(SearchStationTypeEnum.class.getEnumConstants()) return Arrays.stream(SearchStationTypeEnum.class.getEnumConstants())

5
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.BigModelConstants;
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService;
import com.hnac.hzims.bigmodel.interactive.vo.StationSearchVO;
import com.hnac.hzinfo.log.annotation.Business; import com.hnac.hzinfo.log.annotation.Business;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -77,8 +78,8 @@ public class InteractiveController {
@ApiOperation("解析接入站点数量") @ApiOperation("解析接入站点数量")
@ApiOperationSupport(order = 7) @ApiOperationSupport(order = 7)
@PostMapping("/resolveStations") @PostMapping("/resolveStations")
public R resolveStations(String startTime,String endTime,String type,String enumType) { public R resolveStations(@RequestBody StationSearchVO req) {
return R.data(interactiveService.resolveStations(startTime,endTime,type,enumType)); return R.data(interactiveService.resolveStations(req.getStartTime(),req.getEndTime(),req.getType(),req.getEnumType()));
} }
@ApiOperation("站点发电量") @ApiOperation("站点发电量")

3
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); return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class);
} }

46
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java

@ -92,8 +92,6 @@ public class InteractiveServiceImpl implements IInteractiveService {
private final RedisTemplate redisTemplate; private final RedisTemplate redisTemplate;
private final IStationClient stationClient;
private final IAnalyseDataSearchClient analyseDataSearchClient; private final IAnalyseDataSearchClient analyseDataSearchClient;
private final ExtraResolveStrategyService extraResolveStrategyService; private final ExtraResolveStrategyService extraResolveStrategyService;
@ -108,40 +106,23 @@ public class InteractiveServiceImpl implements IInteractiveService {
ExtraVO extraVO = new ExtraVO(); ExtraVO extraVO = new ExtraVO();
extraVO.setType(TypeEnum.PARAMS.getType()); extraVO.setType(TypeEnum.PARAMS.getType());
extraVO.setFuncCode("stations_num"); extraVO.setFuncCode("stations_num");
String stationType = ""; String label;
SearchStationTypeEnum stationTypeEnum = SearchStationTypeEnum.getTypeEnum(enumType); SearchStationTypeEnum stationTypeEnum = SearchStationTypeEnum.getTypeEnum(enumType);
if(SearchTypeEnum.REAL.getSearchType().equals(type)) { if(!startTime.equals(endTime)) {
startTime = null; label = String.format("自%s到%s时间为止,",startTime,endTime);
endTime = null;
} }
else { 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; startTime = null;
break; endTime = null;
case HYDROPOWER_NUM: label = "目前";
case WIND_POWER_NUM:
case ENERGY_STORAGE_NUM:
case PHOTOVOLTAIC_NUM:
case CHARGE_NUM:
stationType = stationTypeEnum.getStationType();
break;
default:
throw new ServiceException("未查询到相关");
}
} }
R<List<StationEntity>> stationListR = stationClient.getStationByTypeAndDuration(startTime, endTime, stationType); R<List<StationEntity>> stationListR = stationClient.getStationByTypeAndDuration(startTime, endTime, stationTypeEnum.getStationType());
Assert.isTrue(stationListR.isSuccess(),() -> { Assert.isTrue(stationListR.isSuccess(),() -> {
throw new ServiceException("获取接入站点数量失败!"); throw new ServiceException("获取接入站点数量失败!");
}); });
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("searchStationType",stationTypeEnum.getSearchStationType()); 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("startTime",startTime);
params.put("endTime",endTime); params.put("endTime",endTime);
extraVO.setParams(params); extraVO.setParams(params);
@ -192,18 +173,7 @@ public class InteractiveServiceImpl implements IInteractiveService {
} }
private void addQuestionSessionId(String sessionId) { private void addQuestionSessionId(String sessionId) {
// 添加redis问题会话 redisTemplate.opsForList().leftPush(HZIMS_BIGMODEL_ASK_KEY,sessionId);
Object json = redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY);
if(ObjectUtil.isEmpty(json)){
List<String> asks = Collections.singletonList(sessionId);
redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,JSONObject.toJSONString(asks));
}else{
List<String> asks = JSONObject.parseArray(json.toString(),String.class);
if(!asks.contains(sessionId)){
asks.add(sessionId);
}
redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,JSONObject.toJSONString(asks));
}
} }
@Override @Override

24
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;
}

14
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 lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil; 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.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil; import org.springblade.core.tool.utils.StringUtil;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
@ -90,12 +91,7 @@ public class InteractiveSchedule {
@XxlJob(GET_INTERACTIVE_RESULT) @XxlJob(GET_INTERACTIVE_RESULT)
public ReturnT getInteractiveResult(String params) { public ReturnT getInteractiveResult(String params) {
Object json = redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); List<String> sessionIds = redisTemplate.opsForList().range(HZIMS_BIGMODEL_ASK_KEY, 0, -1);
if(ObjectUtil.isEmpty(json)){
XxlJobLogger.log("未获取到问题标识,或者用户未进行提问!");
return ReturnT.SUCCESS;
}
List<String> sessionIds = JSONObject.parseArray(json.toString(),String.class);
if(CollectionUtil.isEmpty(sessionIds)){ if(CollectionUtil.isEmpty(sessionIds)){
XxlJobLogger.log("问题都已经回答完毕!"); XxlJobLogger.log("问题都已经回答完毕!");
return ReturnT.SUCCESS; return ReturnT.SUCCESS;
@ -106,13 +102,13 @@ public class InteractiveSchedule {
if(sessionIds.contains(answerVO.getSessionId())){ if(sessionIds.contains(answerVO.getSessionId())){
WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId());
TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO));
if(Func.isNotEmpty(session)) {
wsService.sendMessage(session,message); wsService.sendMessage(session,message);
} }
// 问题回答完成,去除redis问题标记 }
if(answerVO.getRunning() == 0) { if(answerVO.getRunning() == 0) {
sessionIds.remove(answerVO.getSessionId()); redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,answerVO.getSessionId());
} }
redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY, JSONObject.toJSONString(sessionIds));
}, getAnswerPoolExecutor)); }, getAnswerPoolExecutor));
return ReturnT.SUCCESS; return ReturnT.SUCCESS;
} }

4
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; package com.hnac.hzims.bigmodel.schedule;
import com.hnac.hzims.common.constant.CommonConstant;
/** /**
* @Author: huangxing * @Author: huangxing
* @Date: 2024/04/28 16:19 * @Date: 2024/04/28 16:19
@ -18,6 +20,6 @@ public interface XxlJobHandlerConstant {
String INTERACTIVE_RESULT_KEY = "hzllm:interactive:result"; 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";
} }

Loading…
Cancel
Save