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. 48
      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. 16
      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 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<List<StationEntity>> querySatationByCodes(@RequestParam("codes") List<String> codes);
@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
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())

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.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("站点发电量")

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

48
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("未查询到相关");
}
endTime = null;
label = "目前";
}
R<List<StationEntity>> stationListR = stationClient.getStationByTypeAndDuration(startTime, endTime, stationType);
R<List<StationEntity>> stationListR = stationClient.getStationByTypeAndDuration(startTime, endTime, stationTypeEnum.getStationType());
Assert.isTrue(stationListR.isSuccess(),() -> {
throw new ServiceException("获取接入站点数量失败!");
});
Map<String, Object> 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<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));
}
redisTemplate.opsForList().leftPush(HZIMS_BIGMODEL_ASK_KEY,sessionId);
}
@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;
}

16
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<String> sessionIds = JSONObject.parseArray(json.toString(),String.class);
List<String> 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));
if(Func.isNotEmpty(session)) {
wsService.sendMessage(session,message);
}
// 问题回答完成,去除redis问题标记
if(answerVO.getRunning() == 0){
sessionIds.remove(answerVO.getSessionId());
}
redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY, JSONObject.toJSONString(sessionIds));
if(answerVO.getRunning() == 0) {
redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,answerVO.getSessionId());
}
}, getAnswerPoolExecutor));
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;
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";
}

Loading…
Cancel
Save