Browse Source

fix:大模型结构调整

zhongwei
haungxing 5 months ago
parent
commit
9a87d6550c
  1. 2
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java
  2. 3
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/ResolveFactory.java
  3. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java
  4. 6
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java
  5. 11
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/DataSourceController.java
  6. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TablePropertyController.java
  7. 6
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java
  8. 5
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/MessageDTO.java
  9. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/QuestionDTO.java
  10. 5
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/service/QuestionHandlerService.java
  11. 3
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java

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

@ -45,7 +45,7 @@ public class ExtraVO implements Serializable {
@ApiModelProperty("选项") @ApiModelProperty("选项")
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
private List selection; private List data;
@JSONField(name = "agent_name") @JSONField(name = "agent_name")
private String agentName; private String agentName;

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

@ -1,9 +1,6 @@
package com.hnac.hzims.bigmodel.interactive.factory; package com.hnac.hzims.bigmodel.interactive.factory;
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.FuncRouteEnum;
import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants;
import com.hnac.hzims.bigmodel.interactive.service.IResolveService; import com.hnac.hzims.bigmodel.interactive.service.IResolveService;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.log.logger.BladeLogger;

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

@ -52,7 +52,7 @@ public class CanvasResolveServiceImpl implements IResolveService {
ExtraVO extraVO = new ExtraVO(); ExtraVO extraVO = new ExtraVO();
extraVO.setImmediatelyJump(true); extraVO.setImmediatelyJump(true);
extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFunc()); extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFunc());
final String[] SCADA_PARAMS_SOLVE = new String[]{"picResource","context","stationNum","projectId","taskId","name","itemId"}; final String[] SCADA_PARAMS_SOLVE = new String[]{"picResource","context","stationNum","projectId","taskId","name","id"};
String canvasHost = ParamCache.getValue(ParamKeyConstants.CANVAS_HOST); String canvasHost = ParamCache.getValue(ParamKeyConstants.CANVAS_HOST);
// 将ID解析为 // 将ID解析为
Map<String, String> resolveMap = this.resolve(id, SCADA_PARAMS_SOLVE); Map<String, String> resolveMap = this.resolve(id, SCADA_PARAMS_SOLVE);

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

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

11
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/DataSourceController.java

@ -16,6 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
/** /**
* @Author: huangxing * @Author: huangxing
* @Date: 2024/07/05 16:55 * @Date: 2024/07/05 16:55
@ -37,7 +39,7 @@ public class DataSourceController {
} }
@GetMapping("/detail") @GetMapping("/detail")
@ApiOperation(value = "分页查询") @ApiOperation(value = "查看详情")
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
public R<DatasourceEntity> detail(@RequestParam @ApiParam("主键ID") Long id) { public R<DatasourceEntity> detail(@RequestParam @ApiParam("主键ID") Long id) {
return R.data(dataSourceService.getById(id)); return R.data(dataSourceService.getById(id));
@ -64,4 +66,11 @@ public class DataSourceController {
return R.status(dataSourceService.updateById(req)); return R.status(dataSourceService.updateById(req));
} }
@GetMapping("/list")
@ApiOperation(value = "列表查询")
@ApiOperationSupport(order = 1)
public R<List<DatasourceEntity>> list(DatasourceEntity req) {
return R.data(dataSourceService.list(Condition.getQueryWrapper(req).lambda()));
}
} }

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TablePropertyController.java

@ -36,7 +36,7 @@ public class TablePropertyController {
} }
@GetMapping("/detail") @GetMapping("/detail")
@ApiOperation(value = "分页查询") @ApiOperation(value = "查看详情")
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
public R<TablePropertyEntity> detail(@RequestParam @ApiParam("主键ID") Long id) { public R<TablePropertyEntity> detail(@RequestParam @ApiParam("主键ID") Long id) {
return R.data(tablePropertyService.getById(id)); return R.data(tablePropertyService.getById(id));

6
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java

@ -20,17 +20,17 @@ public class TableColumnService {
private final DataSourceService dataSourceService; private final DataSourceService dataSourceService;
public List<Map<String,Object>> getDatabase(String datasource) { public List<Map<String,Object>> getDatabase(String datasource) {
String sql = "select distinct `table_schema` from `information_schema`.`tables` where `table_schema` <> 'information_schema';"; String sql = "select distinct `table_schema` as tableName from `information_schema`.`tables` where `table_schema` <> 'information_schema';";
return dataSourceService.queryListOnSpecificDataSource(sql,datasource); return dataSourceService.queryListOnSpecificDataSource(sql,datasource);
} }
public List<Map<String, Object>> getTables(String datasource,String database) { public List<Map<String, Object>> getTables(String datasource,String database) {
String sql = "select distinct `table_name` from `information_schema`.`tables` where `table_schema` = '" + database + "';"; String sql = "select distinct `table_name` as tableName from `information_schema`.`tables` where `table_schema` = '" + database + "';";
return dataSourceService.queryListOnSpecificDataSource(sql,datasource); return dataSourceService.queryListOnSpecificDataSource(sql,datasource);
} }
public List<Map<String, Object>> getColumns(String datasource,String database,String tableName) { public List<Map<String, Object>> getColumns(String datasource,String database,String tableName) {
String sql = "select distinct `column_name`,`column_comment` from `information_schema`.`COLUMNS` where `TABLE_SCHEMA` = '" + database + "' and `TABLE_NAME` = '" + tableName + "';"; String sql = "select distinct `column_name` as columnName,`column_comment` as columnComment from `information_schema`.`COLUMNS` where `TABLE_SCHEMA` = '" + database + "' and `TABLE_NAME` = '" + tableName + "';";
return dataSourceService.queryListOnSpecificDataSource(sql,datasource); return dataSourceService.queryListOnSpecificDataSource(sql,datasource);
} }

5
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/MessageDTO.java

@ -53,11 +53,6 @@ public class MessageDTO implements Serializable {
private String chatId; private String chatId;
/** /**
* 选项
*/
private Object selection;
/**
* 大模型函数 * 大模型函数
*/ */
private String func; private String func;

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/QuestionDTO.java

@ -37,8 +37,6 @@ public class QuestionDTO implements Serializable {
*/ */
private Map<String, Object> extra; private Map<String, Object> extra;
private Object data;
/** /**
* 是否允许大模型查询数据,默认为 1 * 是否允许大模型查询数据,默认为 1
*/ */

5
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/service/QuestionHandlerService.java

@ -53,7 +53,6 @@ public class QuestionHandlerService {
case CHOOSE_YC: case CHOOSE_YC:
case CHOOSE_FAULT: case CHOOSE_FAULT:
case CHOOSE_YK: case CHOOSE_YK:
question.setData(messageDTO.getSelection());
hznlmInvokeService.specialAsk(question); hznlmInvokeService.specialAsk(question);
break; break;
case CHOOSE_VIDEO: case CHOOSE_VIDEO:
@ -71,7 +70,7 @@ public class QuestionHandlerService {
private void handleVideoChoose(MessageDTO messageDTO) { private void handleVideoChoose(MessageDTO messageDTO) {
InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class); InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class);
try { try {
VideoSelectionVO selection = (VideoSelectionVO) messageDTO.getSelection(); VideoSelectionVO selection = (VideoSelectionVO) messageDTO.getExtra().get("data");
IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_VIDEO.getFunc()); IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_VIDEO.getFunc());
String videoId = selection.getItemId(); String videoId = selection.getItemId();
ExtraVO videoExtras = resolveService.resolve(videoId); ExtraVO videoExtras = resolveService.resolve(videoId);
@ -98,7 +97,7 @@ public class QuestionHandlerService {
private void handleScadaChoose(MessageDTO messageDTO) { private void handleScadaChoose(MessageDTO messageDTO) {
InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class); InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class);
try { try {
ScadaSelectionVO selection = (ScadaSelectionVO) messageDTO.getSelection(); ScadaSelectionVO selection = (ScadaSelectionVO) messageDTO.getExtra().get("data");
IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_CANVAS.getFunc()); IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_CANVAS.getFunc());
ExtraVO scadaExtra = resolveService.resolve(selection.getItemId()); ExtraVO scadaExtra = resolveService.resolve(selection.getItemId());
AnswerVO answerVO = new AnswerVO(); AnswerVO answerVO = new AnswerVO();

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

@ -41,7 +41,8 @@ public class RequestClientUtil {
*/ */
public static void postCall(String url, Map body) { public static void postCall(String url, Map body) {
log.info("开始远程调用{}接口",url); log.info("开始远程调用{}接口",url);
HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute();log.info("远程调用{}接口结束",url); HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute();
log.info("远程调用{}接口结束",url);
Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> {
throw new ServiceException("远程调用接口" + url + "失败!"); throw new ServiceException("远程调用接口" + url + "失败!");
}); });

Loading…
Cancel
Save