Browse Source

add:站点数量统计

zhongwei
haungxing 8 months ago
parent
commit
1c0aec87e2
  1. 14
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AttrSelectionVO.java
  2. 0
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java
  3. 0
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java
  4. 0
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java
  5. 5
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java
  6. 5
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java
  7. 1
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java
  8. 39
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java
  9. 28
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchTypeEnum.java
  10. 7
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java
  11. 3
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java
  12. 49
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java
  13. 53
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java
  14. 13
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java

14
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AttrSelectionVO.java

@ -0,0 +1,14 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import lombok.Data;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/05/24 15:55
*/
@Data
public class AttrSelectionVO extends SelectionVO implements Serializable {
private DataItemVO item;
}

0
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java → hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java

0
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java → hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java

0
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java → hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java

5
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 QUERY_STATION_BY_CODES = API_PREFIX + "/querySatationByCodes";
@GetMapping(GET_LIST_ALL)
@ -81,4 +81,7 @@ public interface IStationClient {
*/
@PostMapping(QUERY_STATION_BY_CODES)
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);
}

5
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java

@ -76,4 +76,9 @@ public class IStationClientFallBack implements IStationClient {
public R<List<StationEntity>> querySatationByCodes(List<String> codes) {
return R.data(new ArrayList<>());
}
@Override
public R<List<StationEntity>> getStationByTypeAndDuration(String startTime, String endTime, String type) {
return R.fail("远程调用失败!");
}
}

1
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java

@ -21,6 +21,7 @@ public enum FuncRouteEnum {
CHOOSE_FAULT("choose_fault","选择故障",null),
CONFIRM_YK("confirm_yk","遥控确认", FunctionConstants.TypeEnum.PARAMS),
SHOW_PARAM("show_param","设备参数查询", FunctionConstants.TypeEnum.PARAMS),
CHOOSE_YC("choose_yc","选择遥测数据",FunctionConstants.TypeEnum.CHOOSE)
;
@Getter
private String funcCode;

39
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java

@ -0,0 +1,39 @@
package com.hnac.hzims.bigmodel.interactive.constants;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
/**
* @Author: huangxing
* @Date: 2024/05/24 17:14
*/
@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"),
;
@Getter
private String searchStationType;
@Getter
private String stationType;
public static SearchStationTypeEnum getTypeEnum(String searchStationType) {
return Arrays.stream(SearchStationTypeEnum.class.getEnumConstants())
.filter(e -> e.getSearchStationType().equals(searchStationType))
.findFirst()
.orElse(null);
}
}

28
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchTypeEnum.java

@ -0,0 +1,28 @@
package com.hnac.hzims.bigmodel.interactive.constants;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import java.util.Arrays;
/**
* @Author: huangxing
* @Date: 2024/05/24 17:13
*/
@AllArgsConstructor
public enum SearchTypeEnum {
REAL("实时"),
HISTORY("历史")
;
@Getter
private String searchType;
public static SearchTypeEnum getSearchType(String searchType) {
return Arrays.stream(SearchTypeEnum.class.getEnumConstants())
.filter(e -> e.getSearchType().equals(searchType))
.findFirst()
.orElse(null);
}
}

7
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java

@ -77,4 +77,11 @@ public class InteractiveController {
public R sendRemoteControl(@RequestBody ControlDTO operate) {
return interactiveService.sendRemoteControl(operate);
}
@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));
}
}

3
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java

@ -2,6 +2,7 @@ package com.hnac.hzims.bigmodel.interactive.service;
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import org.springblade.core.tool.api.R;
import org.springblade.system.dto.ControlDTO;
@ -14,6 +15,8 @@ import java.util.Map;
*/
public interface IInteractiveService {
ExtraVO resolveStations(String startTime, String endTime, String type, String enumType);
R resolve(ModelFunctionReq req);
R ask(String question,String sessionId,String userId);

49
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java

@ -12,15 +12,14 @@ import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient;
import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceFuncVO;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger;
import lombok.AllArgsConstructor;
import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.core.tool.utils.*;
import org.springblade.system.dto.ControlDTO;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
@ -45,6 +44,7 @@ public class ExtraResolveStrategyService {
private final IStationVideoTypeClient videoTypeClient;
private final JumpRouteJoinStrategy jumpRouteJoinStrategy;
private final DeviceClient deviceClient;
private final BladeLogger logger;
private final RedisTemplate redisTemplate;
/**
@ -74,6 +74,8 @@ public class ExtraResolveStrategyService {
return this.resolveConfirmRemote(extra);
case SHOW_PARAM:
return this.resolveShowParam(extra);
case CHOOSE_YC:
return this.resolveChooseYc(extra);
default:
break;
}
@ -82,16 +84,47 @@ public class ExtraResolveStrategyService {
return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class);
}
private ExtraVO resolveChooseYc(JSONObject extra) {
ExtraVO result = new ExtraVO();
JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")));
if(data.containsKey("ycs")) {
List<AttrSelectionVO> attrs = JSONArray.parseArray(JSON.toJSONString(data.get("ycs")), AttrSelectionVO.class);
result.setSelection(attrs);
}
result.setFuncCode(FuncRouteEnum.CHOOSE_YC.getFuncCode());
result.setSpecial(true);
result.setType(FuncRouteEnum.CHOOSE_YC.getType().getType());
return result;
}
private ExtraVO resolveShowParam(Map<String,Object> extra) {
ExtraVO result = new ExtraVO();
result.setFuncCode(FuncRouteEnum.SHOW_PARAM.getFuncCode());
result.setType(FuncRouteEnum.SHOW_PARAM.getType().getType());
Map<String,Object> param = new HashMap(1);
DataVO data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")),DataVO.class);
if(Func.isNotEmpty(data) && Func.isNotEmpty(data.getReal()) && Func.isNotEmpty(data.getReal().getTime()) && StringUtil.isNotBlank(data.getReal().getTime())) {
RealDataVO real = data.getReal();
Date date = DateUtil.parse(real.getTime(), PATTERN_DATETIME);
real.setTime(DateUtil.format(date,DateUtil.PATTERN_DATETIME));
if(Func.isNotEmpty(data)) {
if(Func.isNotEmpty(data.getReal())) {
if(Func.isNotEmpty(data.getReal().getTime()) && StringUtil.isNotBlank(data.getReal().getTime())) {
RealDataVO real = data.getReal();
Date date = DateUtil.parse(real.getTime(), PATTERN_DATETIME);
real.setTime(DateUtil.format(date,DateUtil.PATTERN_DATETIME));
}
}
if(Func.isNotEmpty(data.getItem())) {
if("历史".equals(data.getType())) {
// 历史数据需要手动查询功能ID供前端使用
DataItemVO item = data.getItem();
R<List<DeviceInstanceAttrVO>> attrR = deviceClient.getOnlineAttr(item.getDeviceId());
if(attrR.isSuccess() && CollectionUtil.isNotEmpty(attrR.getData())) {
List<DeviceInstanceAttrVO> attrList = attrR.getData();
Optional<String> facDeviceIdOptional = attrList.stream().parallel().filter(f -> item.getSignage().equals(f.getSignage()))
.map(DeviceInstanceAttrVO::getFacDeviceAttrId).findFirst();
logger.info("hzims-big-model:resolveShowParam:facDeviceId",facDeviceIdOptional.orElse(""));
item.setAttrId(facDeviceIdOptional.orElse(null));
}
}
}
}
param.put("data", data);
result.setParams(param);

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

@ -9,11 +9,17 @@ import com.hnac.hzims.bigmodel.configuration.BigModelInvokeUrl;
import com.hnac.hzims.bigmodel.entity.FunctionEntity;
import com.hnac.hzims.bigmodel.function.service.IFunctionService;
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum;
import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants;
import com.hnac.hzims.bigmodel.interactive.constants.SearchStationTypeEnum;
import com.hnac.hzims.bigmodel.interactive.constants.SearchTypeEnum;
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService;
import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService;
import com.hnac.hzims.bigmodel.interactive.service.IParamsService;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
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.xxl.job.core.log.XxlJobLogger;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -66,12 +72,59 @@ public class InteractiveServiceImpl implements IInteractiveService {
private final RedisTemplate redisTemplate;
private final IStationClient stationClient;
private final ExtraResolveStrategyService extraResolveStrategyService;
@Value("${fdp.host}")
private String fdpHost;
@Override
public ExtraVO resolveStations(String startTime, String endTime, String type, String enumType) {
ExtraVO extraVO = new ExtraVO();
extraVO.setType(TypeEnum.PARAMS.getType());
extraVO.setFuncCode("stations_num");
String stationType = "";
SearchStationTypeEnum stationTypeEnum = SearchStationTypeEnum.getTypeEnum(enumType);
if(SearchTypeEnum.REAL.getSearchType().equals(type)) {
startTime = null;
endTime = null;
}
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("未查询到相关");
}
}
R<List<StationEntity>> stationListR = stationClient.getStationByTypeAndDuration(startTime, endTime, stationType);
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("startTime",startTime);
params.put("endTime",endTime);
extraVO.setParams(params);
return extraVO;
}
@Override
public R resolve(ModelFunctionReq req) {
logger.info("interactive:resolve","开始解析大模型函数,函数内容为:" + JSON.toJSONString(req));
FunctionEntity function = functionService.getFunctionByCode(req.getFunctionName());

13
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java

@ -14,6 +14,7 @@ import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.user.entity.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
@ -137,6 +138,18 @@ public class StationClient implements IStationClient {
.in(StationEntity::getCode,codes)));
}
@Override
@GetMapping("/getStationByTypeAndDuration")
public R<List<StationEntity>> getStationByTypeAndDuration(@RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime,
@RequestParam(required = false) String type) {
LambdaQueryWrapper<StationEntity> wrapper = Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getType, type)
.le(StringUtil.isNotBlank(endTime) && Func.isNotEmpty(endTime),StationEntity::getCreateTime, endTime)
.ge(StringUtil.isNotBlank(startTime) && Func.isNotEmpty(startTime),StationEntity::getCreateTime, startTime);
return R.data(stationService.list(wrapper));
}
@Override
@PostMapping("/getStationByCodeOrRedDept")

Loading…
Cancel
Save