Browse Source

fix:大模型结构调整

zhongwei
haungxing 5 months ago
parent
commit
85384b11b3
  1. 7
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java
  2. 4
      hzims-service/hzims-big-model/pom.xml
  3. 3
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/HzimsBigModelApplication.java
  4. 26
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/controller/DataSourceExecuteController.java
  5. 51
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java
  6. 14
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/IDataSourceService.java
  7. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionController.java
  8. 19
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ParamKeyConstants.java
  9. 1
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/AnalyseDataController.java
  10. 8
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java
  11. 3
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java
  12. 1
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java
  13. 3
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java
  14. 3
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java
  15. 4
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IResolveService.java
  16. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java
  17. 112
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java
  18. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java
  19. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java
  20. 12
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java
  21. 9
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java
  22. 6
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java
  23. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java
  24. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java
  25. 4
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java
  26. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java
  27. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java
  28. 14
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java
  29. 7
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java
  30. 5
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java
  31. 9
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java
  32. 5
      pom.xml

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

@ -1,5 +1,6 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -26,7 +27,7 @@ public class ExtraVO implements Serializable {
private String label;
@ApiModelProperty("函数编号")
private String funcCode;
private String func;
@ApiModelProperty("是否立即跳转")
private boolean isImmediatelyJump = false;
@ -40,10 +41,10 @@ public class ExtraVO implements Serializable {
@ApiModelProperty("选项")
private List selection;
@ApiModelProperty("")
@JSONField(name = "agent_name")
private String agentName;
@ApiModelProperty("")
@JSONField(name = "agent_data")
private Map<String,Object> agentData;
}

4
hzims-service/hzims-big-model/pom.xml

@ -79,6 +79,10 @@
<groupId>com.hnac.hzims</groupId>
<artifactId>equipment-api</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
</dependency>
</dependencies>
<build>

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

@ -18,9 +18,8 @@ import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.HZIMS_BIGMO
@EnableBladeFeign(basePackages = {"org.springblade","com.hnac"})
@SpringCloudApplication
@MapperScan("com.hnac.hzims.**.mapper.**")
@ComponentScan(basePackages = {"com.hnac.hzims.bigmodel.*"})
@Resource
@ComponentScan(basePackages = {"com.hnac.hzims.*"})
@ComponentScan(basePackages = {"com.hnac.hzims.**"})
@Slf4j
public class HzimsBigModelApplication extends SpringBootServletInitializer {

26
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/controller/DataSourceExecuteController.java

@ -0,0 +1,26 @@
package com.hnac.hzims.bigmodel.datasource.controller;
import com.hnac.hzims.bigmodel.datasource.service.DataSourceService;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author: huangxing
* @Date: 2024/06/28 14:07
*/
@RestController
@RequestMapping("/dataSource/execute")
@AllArgsConstructor
public class DataSourceExecuteController {
private final DataSourceService dataSourceService;
@GetMapping("/executeQuery")
public R executeQuery(String sql,String dataSourceName) {
return R.data(dataSourceService.queryListOnSpecificDataSource(sql,dataSourceName));
}
}

51
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java

@ -0,0 +1,51 @@
package com.hnac.hzims.bigmodel.datasource.service;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* @Author: huangxing
* @Date: 2024/06/28 15:24
*/
@Service
@AllArgsConstructor
@Slf4j
public class DataSourceService {
private final JdbcTemplate jdbcTemplate;
/**
* 指定
* @param sql
* @param dataSourceName
* @return
*/
public List<Map<String, Object>> queryListOnSpecificDataSource(String sql,String dataSourceName) {
// 切换到指定的数据源
DynamicDataSourceContextHolder.push(dataSourceName);
try {
return jdbcTemplate.queryForList(sql);
} finally {
// 清除,恢复默认数据源
DynamicDataSourceContextHolder.clear();
}
}
public Integer updateOnSpecificDataSource(String sql,String dataSourceName) {
// 切换到指定的数据源
DynamicDataSourceContextHolder.push(dataSourceName);
try {
return jdbcTemplate.update(sql);
} finally {
// 清除,恢复默认数据源
DynamicDataSourceContextHolder.clear();
}
}
}

14
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/IDataSourceService.java

@ -0,0 +1,14 @@
package com.hnac.hzims.bigmodel.datasource.service;
import java.util.List;
import java.util.Map;
/**
* @Author: huangxing
* @Date: 2024/06/28 14:22
*/
public interface IDataSourceService {
List<Map<String,Object>> queryList(String sql);
}

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionController.java

@ -41,7 +41,7 @@ public class FunctionController {
return R.status(functionService.save(req));
}
@PutMapping("/save")
@PutMapping("/updateById")
@ApiOperation("编辑函数")
@ApiOperationSupport(order = 2)
public R updateById(@RequestBody FunctionEntity req) {

19
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ParamKeyConstants.java

@ -0,0 +1,19 @@
package com.hnac.hzims.bigmodel.interactive.constants;
/**
* @Author: huangxing
* @Date: 2024/07/01 14:26
* @Describe: 参数key管理
*/
public interface ParamKeyConstants {
/**实时画面host**/
String CANVAS_HOST = "hzims:bigModel:canvas:host";
/**实时画面v3路径 {context}&stationNum={stationNum}&projectId={projectId}**/
String CANVAS_V3_PATH = "hzims:bigModel:canvas:v3:path";
/**实时画面v4路径 other/v4/canvas/index.html?hzinfowebkit=true&taskId={taskId}&stationNum={stationNum}&projectId={projectId}&source=app&picName={context}&name={name}**/
String CANVAS_V4_PATH = "hzims:bigModel:canvas:v4:path";
/**实时画面云组态路径 hzinfo-data-scada/view/{projectId}/{id}?source=app**/
String CANVAS_YZT_PATH = "hzims:bigModel:canvas:yzt:path";
}

1
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/AnalyseDataController.java

@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
@AllArgsConstructor
@Api(value = "数据查询管理",tags = "数据查询管理")
@RestController
@Deprecated
public class AnalyseDataController {
private final IAnalyseDataService analyseDataService;

8
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java

@ -1,5 +1,6 @@
package com.hnac.hzims.bigmodel.interactive.controller;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.google.common.collect.Lists;
import com.hnac.hzims.bigmodel.BigModelConstants;
@ -52,4 +53,11 @@ public class FontEndInteractiveController {
public R<List<String>> hotQuestions() {
return R.data(hznlmInvokeService.hotQuestions());
}
@ApiOperation("获取问答sessionId")
@ApiOperationSupport(order = 4)
@GetMapping("/getSessionId")
public R<String> getSessionId() {
return R.data(IdWorker.get32UUID());
}
}

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

@ -6,6 +6,7 @@ import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO;
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.service.IHznlmInteractiveService;
import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO;
import com.hnac.hzinfo.log.annotation.Business;
import io.swagger.annotations.Api;
@ -40,7 +41,7 @@ public class HznlmInteractiveController {
@ApiOperation("解析大模型函数")
@ApiOperationSupport(order = 2)
@PostMapping("/resolve")
public R<ResolveResultVO> resolve(@RequestBody @Valid ModelFunctionReq req) {
public R<ExtraVO> resolve(@RequestBody @Valid ModelFunctionReq req) {
return R.data(interactiveService.resolve(req));
}
}

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

@ -28,6 +28,7 @@ import java.util.List;
@Api(value = "FDP大模型交互层",tags = "FDP大模型交互层")
@RequestMapping("/interactive")
@Business(module = BigModelConstants.MODULE_NAME,value = "FDP大模型交互层")
@Deprecated
public class InteractiveController {
private final IInteractiveService interactiveService;

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

@ -21,6 +21,7 @@ public class AnswerResolveFactory {
public static final String CHOICE_ANSWER_SERVICE = "choiceAnswerResolveService";
public static final String REMOTE_ANSWER_SERVICE = "remoteAnswerResolveService";
public static final String PARAM_ANSWER_SERVICE = "paramAnswerResolveService";
public static final String PRE_ANSWER_SERVICE = "preAnswerResolveService";
public static IAnswerResolveService getResolveService(Object extra) {
String funcCode = JSONObject.parseObject(JSON.toJSONString(extra)).getString("func");
@ -45,7 +46,7 @@ public class AnswerResolveFactory {
case SHOW_PARAM:
return SpringUtil.getBean(PARAM_ANSWER_SERVICE);
default:
throw new ServiceException("service解析失败!");
return null;
}
}
throw new ServiceException("service解析失败!");

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

@ -3,6 +3,7 @@ package com.hnac.hzims.bigmodel.interactive.service;
import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO;
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO;
import org.springframework.web.bind.annotation.RequestBody;
@ -17,5 +18,5 @@ public interface IHznlmInteractiveService {
List<AuthDataVO> getAuthData(@RequestBody @Valid AuthDataDTO req);
ResolveResultVO resolve(ModelFunctionReq req);
ExtraVO resolve(ModelFunctionReq req);
}

4
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IResolveService.java

@ -10,8 +10,8 @@ import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO;
*/
public interface IResolveService {
ExtraVO resolve(Long id);
ExtraVO resolve(String id);
ResolveResultVO resolve(ModelFunctionReq req);
ExtraVO resolve(ModelFunctionReq req);
}

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java

@ -57,7 +57,7 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService {
searchVO.setDataType(adapterDate.getDateType());
ExtraVO extraVO = new ExtraVO();
extraVO.setType(FuncRouteEnum.HISTORY_DATA.getType().getType());
extraVO.setFuncCode(FuncRouteEnum.HISTORY_DATA.getFuncCode());
extraVO.setFunc(FuncRouteEnum.HISTORY_DATA.getFuncCode());
Map<String,Object> params = new HashMap<>(1);
Result<ReductionDataVO> reductionDataVOR = historyDataService.getPolymerizationData(searchVO);
String label;

112
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java

@ -1,14 +1,30 @@
package com.hnac.hzims.bigmodel.interactive.service.impl;
import com.alibaba.fastjson.JSON;
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum;
import com.hnac.hzims.bigmodel.interactive.constants.ParamKeyConstants;
import com.hnac.hzims.bigmodel.interactive.factory.ResolveFactory;
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.service.IResolveService;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import com.hnac.hzinfo.sdk.v5.scada.ScadaClient;
import groovy.util.logging.Slf4j;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.cache.ParamCache;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.util.*;
import java.util.stream.IntStream;
/**
* @Author: huangxing
@ -19,15 +35,101 @@ import org.springframework.stereotype.Service;
@Slf4j
public class CanvasResolveServiceImpl implements IResolveService {
private final ScadaClient scadaClient;
private final IStationClient stationClient;
private final BladeLogger logger;
@Override
public ResolveResultVO resolve(ModelFunctionReq req) {
return null;
public ExtraVO resolve(ModelFunctionReq req) {
Map<String, String> args = req.getFunctionArgs();
String id = args.get("id");
String name = args.get("name");
Assert.isTrue(StringUtil.isNotBlank(id) && StringUtil.isNotBlank(name),() -> {
logger.error("hzims:video:resolve","解析传参错误,缺少必要参数video_id,传参内容为:" + JSON.toJSONString(req));
throw new ServiceException("解析传参错误,缺少必要参数video_id");
});
return this.resolve(id);
// ExtraVO extra = this.resolve(id);
// String message = "已成功打开" + name + ";";
// return new ResolveResultVO(message,extra);
}
@Override
public ExtraVO resolve(Long id) {
return null;
public ExtraVO resolve(String id) {
ExtraVO extraVO = new ExtraVO();
extraVO.setImmediatelyJump(true);
extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFuncCode());
final String[] SCADA_PARAMS_SOLVE = new String[]{"picResource","context","stationNum","projectId","taskId","name","id"};
String canvasHost = ParamCache.getValue(ParamKeyConstants.CANVAS_HOST);
// 将ID解析为
Map<String, String> resolveMap = this.resolve(id, SCADA_PARAMS_SOLVE);
R<StationEntity> stationR = stationClient.getStationByCode(resolveMap.get("projectId"));
extraVO.setLabel(Optional.ofNullable(stationR).filter(r -> r.isSuccess()).map(R::getData).map(StationEntity::getName).orElse("") + "_" + resolveMap.get("name"));
Integer picResource = Integer.valueOf(resolveMap.get("picResource"));
Map<String,Object> extraParams = new HashMap<>(1);
extraParams.put("picResource",picResource);
extraVO.setParams(extraParams);
// 云组态
if(picResource == 0) {
String path = this.replacePath(ParamCache.getValue(ParamKeyConstants.CANVAS_YZT_PATH), resolveMap);
extraVO.setRoute(canvasHost + path);
}
// v3.0
else if(picResource == 1) {
String path = this.replacePath(ParamCache.getValue(ParamKeyConstants.CANVAS_V3_PATH), resolveMap);
extraVO.setRoute(canvasHost + path);
}
// v4.0
else if (picResource == 2) {
// pic_name 去掉头部的/ 以及尾部的.js
String context = resolveMap.get("context");
context = this.removeHeadChars(context,"/");
context = this.removeTailChars(context,".js");
resolveMap.put("context",context);
extraVO.setRoute(this.replacePath("other/v4/canvas/index.html?hzinfowebkit=true&taskId={taskId}&stationNum={stationNum}&projectId={projectId}&source=app&picName={context}&name={name}", resolveMap));
}
else {
throw new ServiceException("解析出来的画面类型在云组态、v3、v4类型之外,无法解析路由");
}
return extraVO;
}
public Map<String,String> resolve(String paramsStr, String... keys) {
Map<String,String> result = new HashMap<>();
List<String> params = Func.toStrList("\\^", paramsStr);
Assert.isTrue(params.size() == keys.length, () -> {
throw new ServiceException("大模型传参params长度错误,传参为:" + paramsStr);
});
IntStream.iterate(0, index -> index + 1).limit(params.size()).forEach(index -> result.put(keys[index],params.get(index)));
return result;
}
private String replacePath(String path,Map<String,String> params) {
Set<Map.Entry<String, String>> entries = params.entrySet();
// 替换path中变量
for (Map.Entry<String, String> entry : entries) {
String replaceVariables = "{" + entry.getKey() + "}";
path = StringUtil.replace(path,replaceVariables,entry.getValue());
}
return path;
}
public String removeHeadChars(String str, String charsToRemove) {
if (str == null || charsToRemove == null || charsToRemove.isEmpty()) {
return str;
}
while (str.startsWith(charsToRemove)) {
str = str.substring(charsToRemove.length());
}
return str;
}
public String removeTailChars(String str, String charsToRemove) {
if (str == null || charsToRemove == null || charsToRemove.isEmpty()) {
return str;
}
while (str.endsWith(charsToRemove)) {
str = str.substring(0, str.length() - charsToRemove.length());
}
return str;
}
}

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java

@ -38,7 +38,7 @@ public class ChoiceAnswerResolveServiceImpl implements IAnswerResolveService {
ExtraVO result = JSONObject.parseObject(JSON.toJSONString(originExtra),ExtraVO.class);
result.setSpecial(true);
String funcCode = originExtra.getString("func");
result.setFuncCode(funcCode);
result.setFunc(funcCode);
result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType());
JSONArray selections = JSONArray.parseArray(JSON.toJSONString(originExtra.get("data")));
result.setSelection(selections);

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java

@ -43,7 +43,7 @@ public class DiagnoseAnswerResolveServiceImpl implements IAnswerResolveService {
params.put("fdpOrd",data.getString("ord"));
result.setParams(params);
String funcCode = originExtra.getString("func");
result.setFuncCode(funcCode);
result.setFunc(funcCode);
result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType());
return result;
}

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

@ -82,7 +82,7 @@ public class ExtraResolveStrategyService {
private ExtraVO resolveChooseSelection(JSONObject extra,FuncRouteEnum funcRouteEnum) {
ExtraVO result = new ExtraVO();
JSONArray selections = JSONArray.parseArray(JSON.toJSONString(extra.get("data")));
result.setFuncCode(funcRouteEnum.getFuncCode());
result.setFunc(funcRouteEnum.getFuncCode());
result.setSpecial(true);
result.setSelection(selections);
result.setType(funcRouteEnum.getType().getType());
@ -132,7 +132,7 @@ public class ExtraResolveStrategyService {
}
}
ExtraVO result = new ExtraVO();
result.setFuncCode(FuncRouteEnum.SHOW_PARAM.getFuncCode());
result.setFunc(FuncRouteEnum.SHOW_PARAM.getFuncCode());
result.setType(FuncRouteEnum.SHOW_PARAM.getType().getType());
Map<String,Object> param = new HashMap(1);
param.put("data", data);
@ -144,7 +144,7 @@ public class ExtraResolveStrategyService {
private ExtraVO resolveConfirmRemote(Map<String,Object> extra) {
ExtraVO result = new ExtraVO();
RemoteParamVO remoteParam = JSONObject.parseObject(JSON.toJSONString(extra.get("data")), RemoteParamVO.class);
result.setFuncCode(FuncRouteEnum.CONFIRM_YK.getFuncCode());
result.setFunc(FuncRouteEnum.CONFIRM_YK.getFuncCode());
result.setType(FuncRouteEnum.CONFIRM_YK.getType().getType());
R<DeviceInstanceFuncVO> funcVOR = deviceClient.getFuncById(remoteParam.getFuncId());
if(funcVOR.isSuccess()) {
@ -182,7 +182,7 @@ public class ExtraResolveStrategyService {
params.put("fdpDeviceName",data.getString("device_name"));
params.put("fdpOrd",data.getString("ord"));
result.setParams(params);
result.setFuncCode(FuncRouteEnum.DIAGNOSE.getFuncCode());
result.setFunc(FuncRouteEnum.DIAGNOSE.getFuncCode());
result.setType(FunctionConstants.TypeEnum.PARAMS.getType());
return result;
}
@ -229,7 +229,7 @@ public class ExtraResolveStrategyService {
}
return selectionVO;
}).collect(Collectors.toList());
result.setFuncCode(FuncRouteEnum.CHOOSE_VIDEO.getFuncCode());
result.setFunc(FuncRouteEnum.CHOOSE_VIDEO.getFuncCode());
result.setSpecial(true);
result.setSelection(selections);
}
@ -249,7 +249,7 @@ public class ExtraResolveStrategyService {
selectionVO.setName(resolve.get("name"));
return selectionVO;
}).collect(Collectors.toList());
result.setFuncCode(FuncRouteEnum.CHOOSE_CANVAS.getFuncCode());
result.setFunc(FuncRouteEnum.CHOOSE_CANVAS.getFuncCode());
result.setSpecial(true);
result.setSelection(selections);
}

9
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java

@ -7,6 +7,7 @@ import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.service.IHznlmInteractiveService;
import com.hnac.hzims.bigmodel.interactive.service.IResolveService;
import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO;
import groovy.util.logging.Slf4j;
import lombok.AllArgsConstructor;
@ -43,13 +44,9 @@ public class HznlmInteractiveServiceImpl implements IHznlmInteractiveService {
}
@Override
public ResolveResultVO resolve(ModelFunctionReq req) {
public ExtraVO resolve(ModelFunctionReq req) {
IResolveService resolveService = ResolveFactory.getResolveService(req.getFunctionName());
try {
return resolveService.resolve(req);
} catch (Exception e) {
return ResolveResultVO.error();
}
return resolveService.resolve(req);
}
public List<AuthDataVO> getDeptAuthData(String userId) {

6
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java

@ -11,6 +11,7 @@ import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
import com.hnac.hzims.bigmodel.manager.SessionRedisManager;
import com.hnac.hzims.bigmodel.utils.RequestClientUtil;
import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager;
import com.xxl.job.core.log.XxlJobLogger;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
@ -69,6 +70,7 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
params.put("extra",extra);
Map<String, String[]> authDataIds = this.getAuthDataIds(userId);
params.putAll(authDataIds);
log.info("调用大模型接口:{},传参为:{}",fdpHost + bigModelInvokeUrl.getAssistantSpecialAsk(),JSON.toJSONString(params));
RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantSpecialAsk(), params);
sessionRedisManager.addSessionId(sessionId);
}
@ -91,6 +93,8 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
Map<String,Object> params = new HashMap<>();
params.put("id",sessionId);
RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAskAbort(), params);
// 移除内存sessionId
InteractiveSessionManager.SESSION_POOL.remove(sessionId);
sessionRedisManager.removeSessionId(sessionId);
}
@ -119,7 +123,7 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
String[] stationIds = authDatas.stream().map(DeptStationDTO::getStationId)
.filter(StringUtil::isNotBlank).toArray(String[]::new);
String[] projectIds = authDatas.stream().map(DeptStationDTO::getDeptId)
.filter(Func::isNotEmpty).toArray(String[]::new);
.filter(Func::isNotEmpty).map(String::valueOf).toArray(String[]::new);
result.put("stationids", stationIds);
result.put("projectids", projectIds);
return result;

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

@ -108,7 +108,7 @@ public class InteractiveServiceImpl implements IInteractiveService {
public ExtraVO resolveStations(String startTime, String endTime, String type, String enumType) {
ExtraVO extraVO = new ExtraVO();
extraVO.setType(TypeEnum.PARAMS.getType());
extraVO.setFuncCode("stations_num");
extraVO.setFunc("stations_num");
String label;
SearchStationTypeEnum stationTypeEnum = SearchStationTypeEnum.getTypeEnum(enumType);
if(!startTime.equals(endTime) && SearchTypeEnum.HISTORY.getSearchType().equals(type)) {

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java

@ -54,7 +54,7 @@ public class JumpRouteJoinStrategy {
// 跳转页面逻辑
ExtraVO extraVO = new ExtraVO();
extraVO.setImmediatelyJump(true);
extraVO.setFuncCode(FuncRouteEnum.OPEN_CANVAS.getFuncCode());
extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFuncCode());
Map<String, String> params = this.scadaResolve(args);
// 根据hz3000画面版本获取path
Integer picResource = Integer.valueOf(params.get("picResource"));

4
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java

@ -57,11 +57,11 @@ public class ParamAnswerResolveServiceImpl implements IAnswerResolveService {
}
else if(StringUtil.isNotBlank(data.getType()) && SearchTypeEnum.HISTORY.getSearchType().equals(data.getType())) {
// 处理查询历史数据
this.getHistoryData(data);
return this.getHistoryData(data);
}
String funcCode = originExtra.getString("func");
ExtraVO result = new ExtraVO();
result.setFuncCode(funcCode);
result.setFunc(funcCode);
result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType());
Map<String,Object> param = new HashMap(1);
param.put("data", data);

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java

@ -57,7 +57,7 @@ public class ParamStrategy {
StationVideoTypeEntity video = videoR.getData();
extraVO.setType(FunctionConstants.TypeEnum.PARAMS.getType());
extraVO.setImmediatelyJump(true);
extraVO.setFuncCode(FuncRouteEnum.OPEN_VIDEO.getFuncCode());
extraVO.setFunc(FuncRouteEnum.OPEN_VIDEO.getFuncCode());
Map<String,Object> params = new HashMap<>();
params.put("name", video.getName());
params.put("videoHost", video.getVideoHost());

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java

@ -42,7 +42,7 @@ public class RemoteAnswerResolveServiceImpl implements IAnswerResolveService {
ExtraVO result = new ExtraVO();
RemoteParamVO remoteParam = JSONObject.parseObject(JSON.toJSONString(originExtra.get("data")), RemoteParamVO.class);
String funcCode = originExtra.getString("func");
result.setFuncCode(funcCode);
result.setFunc(funcCode);
result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType());
R<DeviceInstanceFuncVO> funcVOR = deviceClient.getFuncById(remoteParam.getFuncId());
if(funcVOR.isSuccess()) {

14
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java

@ -36,7 +36,7 @@ public class VideoResolveServiceImpl implements IResolveService {
private final BladeLogger logger;
@Override
public ResolveResultVO resolve(ModelFunctionReq req) {
public ExtraVO resolve(ModelFunctionReq req) {
Map<String, String> args = req.getFunctionArgs();
String id = args.get("id");
String name = args.get("name");
@ -44,13 +44,15 @@ public class VideoResolveServiceImpl implements IResolveService {
logger.error("hzims:video:resolve","解析传参错误,缺少必要参数video_id,传参内容为:" + JSON.toJSONString(req));
throw new ServiceException("解析传参错误,缺少必要参数video_id");
});
ExtraVO extra = this.resolve(Long.valueOf(id));
String message = "已成功打开" + name + ";";
return new ResolveResultVO(message,extra);
return this.resolve(id);
// ExtraVO extra = this.resolve(id);
// String message = "已成功打开" + name + ";";
// return new ResolveResultVO(message,extra);
}
@Override
public ExtraVO resolve(Long id) {
public ExtraVO resolve(String idStr) {
Long id = Long.valueOf(idStr);
// 跳转页面逻辑
ExtraVO extraVO = new ExtraVO();
R<StationVideoTypeEntity> videoR = videoClient.getById(Long.valueOf(id));
@ -58,7 +60,7 @@ public class VideoResolveServiceImpl implements IResolveService {
StationVideoTypeEntity video = videoR.getData();
extraVO.setType(FunctionConstants.TypeEnum.PARAMS.getType());
extraVO.setImmediatelyJump(true);
extraVO.setFuncCode(FuncRouteEnum.OPEN_VIDEO.getFuncCode());
extraVO.setFunc(FuncRouteEnum.OPEN_VIDEO.getFuncCode());
Map<String,Object> params = new HashMap<>();
params.put("name", video.getName());
params.put("videoHost", video.getVideoHost());

7
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java

@ -67,8 +67,11 @@ public class FrontEndInteractiveSchedule {
// 解析答案
Object[] resolveExtras = Arrays.stream(extras).map(extra -> {
IAnswerResolveService answerResolveService = AnswerResolveFactory.getResolveService(extra);
JSONObject extraObject = JSONObject.parseObject(JSON.toJSONString(extra));
return answerResolveService.getExtra(extraObject);
if(Func.isNotEmpty(answerResolveService)) {
JSONObject extraObject = JSONObject.parseObject(JSON.toJSONString(extra));
return answerResolveService.getExtra(extraObject);
}
return extra;
}).map(JSON::toJSONString).toArray();
answerVO.setExtras(resolveExtras);
}

5
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java

@ -5,7 +5,7 @@ import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import groovy.util.logging.Slf4j;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springframework.util.Assert;
@ -16,6 +16,7 @@ import java.util.Map;
* @Author: huangxing
* @Date: 2024/06/21 17:12
*/
@Slf4j
public class RequestClientUtil {
/**
@ -34,7 +35,7 @@ public class RequestClientUtil {
* 远程调用http接口
* @param url 接口url
* @param body 传参
* @param resultT 结果解析对象
* @param typeRef 结果解析对象
* @return 结果
* @param <T> 结果解析对象类型
*/

9
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
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.service.IHznlmInvokeService;
import com.hnac.hzims.bigmodel.interactive.service.impl.JumpRouteJoinStrategy;
import com.hnac.hzims.bigmodel.interactive.service.impl.ParamStrategy;
import com.hnac.hzims.bigmodel.interactive.vo.*;
@ -103,7 +104,7 @@ public class InteractiveHandler extends TextWebSocketHandler {
}
}
else {
String funcCode = messageContext.getString("funcCode");
String funcCode = messageContext.getString("func");
FuncRouteEnum funcEnum = FuncRouteEnum.getEnumByFuncCode(funcCode);
switch (funcEnum) {
case CHOOSE_STATION:
@ -125,11 +126,11 @@ public class InteractiveHandler extends TextWebSocketHandler {
}
private void handleDefaultChoose(JSONObject messageContext,String sessionId) {
IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class);
IHznlmInvokeService invokeService = SpringUtil.getBean(IHznlmInvokeService.class);
Map<String, Object> extra = messageContext.toJavaObject(Map.class);
extra.put("func",extra.get("funcCode"));
extra.put("func",extra.get("func"));
extra.put("data",messageContext.getObject("selection", JSONObject.class));
interactiveService.specialAsk(sessionId, (String) extra.get("userId"),extra);
invokeService.specialAsk(sessionId, (String) extra.get("userId"),extra);
}
private void handleVideoChoose(JSONObject messageContext,String sessionId) {

5
pom.xml

@ -212,6 +212,11 @@
<artifactId>easypoi-spring-boot-starter</artifactId>
<version>${easpoi.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>2.5.6</version>
</dependency>
</dependencies>
</dependencyManagement>

Loading…
Cancel
Save