haungxing
7 months ago
31 changed files with 780 additions and 97 deletions
@ -0,0 +1,11 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.constants; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/06/21 16:35 |
||||
*/ |
||||
public interface InfoMessageConstant { |
||||
|
||||
String ERROR_MESSAGE = "非常抱歉,系统在处理您的请求时遇到了问题。请稍后再试或联系我们的客服团队。"; |
||||
|
||||
} |
@ -0,0 +1,46 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.factory; |
||||
|
||||
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; |
||||
import com.hnac.hzims.bigmodel.interactive.service.IResolveService; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.log.logger.BladeLogger; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.core.tool.utils.SpringUtil; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/06/21 18:44 |
||||
*/ |
||||
public class AnswerResolveFactory { |
||||
|
||||
public static final String DIAGNOSE_ANSWER_SERVICE = "diagnoseAnswerResolveService"; |
||||
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 IResolveService getResolveService(String funcCode) { |
||||
FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(funcCode); |
||||
if(Func.isNotEmpty(funcRouteEnum)) { |
||||
switch (funcRouteEnum) { |
||||
case DIAGNOSE: |
||||
return SpringUtil.getBean(DIAGNOSE_ANSWER_SERVICE); |
||||
case CHOOSE_VIDEO: |
||||
case CHOOSE_CANVAS: |
||||
case CHOOSE_STATION: |
||||
case CHOOSE_FAULT: |
||||
case CHOOSE_YC: |
||||
case CHOOSE_YK: |
||||
return SpringUtil.getBean(CHOICE_ANSWER_SERVICE); |
||||
case CONFIRM_YK: |
||||
return SpringUtil.getBean(REMOTE_ANSWER_SERVICE); |
||||
case SHOW_PARAM: |
||||
return SpringUtil.getBean(PARAM_ANSWER_SERVICE); |
||||
default: |
||||
throw new ServiceException("service解析失败!"); |
||||
} |
||||
} |
||||
throw new ServiceException("service解析失败!"); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,44 @@
|
||||
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.FunctionConstants; |
||||
import com.hnac.hzims.bigmodel.interactive.service.IResolveService; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.log.logger.BladeLogger; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.core.tool.utils.SpringUtil; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/06/21 15:53 |
||||
*/ |
||||
public class ResolveFactory { |
||||
|
||||
public static final String CANVAS_RESOLVE_SERVICE = "canvasResolveService"; |
||||
public static final String VIDEO_RESOLVE_SERVICE = "videoResolveService"; |
||||
|
||||
/** |
||||
* 获取解析函数需要的service |
||||
* @param funcCode 函数编号 |
||||
* @return 解析函数所需service |
||||
*/ |
||||
public static IResolveService getResolveService(String funcCode) { |
||||
BladeLogger logger = SpringUtil.getBean(BladeLogger.class); |
||||
FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(funcCode); |
||||
if(Func.isNotEmpty(funcRouteEnum)) { |
||||
switch(funcRouteEnum) { |
||||
case OPEN_CANVAS: |
||||
return SpringUtil.getBean("canvasResolveService"); |
||||
case OPEN_VIDEO: |
||||
return SpringUtil.getBean("videoResolveService"); |
||||
default: |
||||
logger.error("hzims:bigModel:getResolveService","函数解析失败,函数编号为:" + funcCode); |
||||
throw new ServiceException("service解析失败"); |
||||
} |
||||
} |
||||
throw new ServiceException("service解析失败"); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,22 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.service; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.stream.Stream; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/06/21 18:39 |
||||
*/ |
||||
public interface IAnswerResolveService { |
||||
|
||||
AnswerVO resolve(AnswerVO answer); |
||||
|
||||
default Stream<JSONObject> extraStream(AnswerVO answer) { |
||||
return Arrays.stream(answer.getExtras()).map(JSON::toJSONString).map(JSONObject::parseObject); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,63 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.service; |
||||
|
||||
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; |
||||
import org.springblade.core.tool.api.R; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/06/21 17:20 |
||||
*/ |
||||
public interface IHznlmInvokeService { |
||||
|
||||
/** |
||||
* 基础问题 |
||||
* @param question 提问问题 |
||||
* @param sessionId 会话ID |
||||
* @param userId 提问人ID |
||||
* @return 提问结果 |
||||
*/ |
||||
void ask(String question, String sessionId, String userId); |
||||
|
||||
/** |
||||
* 特殊问题 |
||||
* @param sessionId 会话ID |
||||
* @param userId 提问人ID |
||||
* @param extra 特殊问题内容 |
||||
* @return 提问结果 |
||||
*/ |
||||
void specialAsk(String sessionId, String userId, Map<String,Object> extra); |
||||
|
||||
/** |
||||
* 知识库问题 |
||||
* @param question 问题名称 |
||||
* @param sessionId 会话ID |
||||
* @param userId 提问人ID |
||||
* @param knowledge 知识库名称 |
||||
*/ |
||||
void knowledgeAsk(String question, String sessionId, String userId, String knowledge); |
||||
|
||||
/** |
||||
* 删除对话记录 |
||||
* @param sessionId 会话ID |
||||
*/ |
||||
void removeSessionId(String sessionId); |
||||
|
||||
/** |
||||
* 获取热点问题 |
||||
* @return 热点问题 |
||||
*/ |
||||
List hotQuestions(); |
||||
|
||||
/** |
||||
* 查询问答状态 |
||||
* @param sessionIds 会话ID,按逗号分隔 |
||||
* @return 答案列表 |
||||
*/ |
||||
List<AnswerVO> getAnswerBySessionIds(String sessionIds); |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,17 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.service; |
||||
|
||||
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/06/21 15:39 |
||||
*/ |
||||
public interface IResolveService { |
||||
|
||||
ExtraVO resolve(Long id); |
||||
|
||||
ResolveResultVO resolve(ModelFunctionReq req); |
||||
|
||||
} |
@ -0,0 +1,33 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.service.impl; |
||||
|
||||
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.hzinfo.sdk.v5.scada.ScadaClient; |
||||
import groovy.util.logging.Slf4j; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/06/21 15:39 |
||||
*/ |
||||
@Service(ResolveFactory.CANVAS_RESOLVE_SERVICE) |
||||
@AllArgsConstructor |
||||
@Slf4j |
||||
public class CanvasResolveServiceImpl implements IResolveService { |
||||
|
||||
private final ScadaClient scadaClient; |
||||
|
||||
@Override |
||||
public ResolveResultVO resolve(ModelFunctionReq req) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public ExtraVO resolve(Long id) { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,47 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.service.impl; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; |
||||
import com.hnac.hzims.bigmodel.interactive.factory.AnswerResolveFactory; |
||||
import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; |
||||
import groovy.util.logging.Slf4j; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/06/21 19:02 |
||||
* @Describe 选项答案解析服务层 |
||||
*/ |
||||
@AllArgsConstructor |
||||
@Service(AnswerResolveFactory.CHOICE_ANSWER_SERVICE) |
||||
@Slf4j |
||||
public class ChoiceAnswerResolveServiceImpl implements IAnswerResolveService { |
||||
|
||||
@Override |
||||
public AnswerVO resolve(AnswerVO answer) { |
||||
List<ExtraVO> extraList = this.extraStream(answer).map(this::getExtra).collect(Collectors.toList()); |
||||
answer.setExtras(extraList.toArray()); |
||||
|
||||
return answer; |
||||
} |
||||
|
||||
private ExtraVO getExtra(JSONObject originExtra) { |
||||
ExtraVO result = new ExtraVO(); |
||||
JSONArray selections = JSONArray.parseArray(JSON.toJSONString(originExtra.get("data"))); |
||||
result.setSelection(selections); |
||||
result.setSpecial(true); |
||||
String funcCode = originExtra.getString("func"); |
||||
result.setFuncCode(funcCode); |
||||
result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType()); |
||||
return result; |
||||
} |
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.service.impl; |
||||
|
||||
import com.hnac.hzims.bigmodel.interactive.factory.AnswerResolveFactory; |
||||
import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; |
||||
import groovy.util.logging.Slf4j; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/06/21 18:59 |
||||
*/ |
||||
@Service(AnswerResolveFactory.DIAGNOSE_ANSWER_SERVICE) |
||||
@Slf4j |
||||
@AllArgsConstructor |
||||
public class DiagnoseAnswerResolveServiceImpl implements IAnswerResolveService { |
||||
|
||||
@Override |
||||
public AnswerVO resolve(AnswerVO answer) { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,120 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.service.impl; |
||||
|
||||
import cn.hutool.http.HttpRequest; |
||||
import cn.hutool.http.HttpResponse; |
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.hnac.hzims.bigmodel.configuration.BigModelInvokeUrl; |
||||
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.xxl.job.core.log.XxlJobLogger; |
||||
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.CollectionUtil; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.core.tool.utils.StringUtil; |
||||
import org.springblade.system.dto.DeptStationDTO; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.util.Assert; |
||||
|
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/06/21 17:20 |
||||
* @Describe HZN_LM大模型接口调用服务层 |
||||
*/ |
||||
@Service |
||||
@RequiredArgsConstructor |
||||
@Slf4j |
||||
public class HznlmInvokeServiceImpl implements IHznlmInvokeService { |
||||
|
||||
private final AuthenticationService authenticationService; |
||||
private final BigModelInvokeUrl bigModelInvokeUrl; |
||||
private final BladeLogger logger; |
||||
private final SessionRedisManager sessionRedisManager; |
||||
|
||||
@Value("${fdp.host}") |
||||
private String fdpHost; |
||||
|
||||
@Override |
||||
public void ask(String question, String sessionId, String userId) { |
||||
Map<String,Object> params = new HashMap<>(); |
||||
params.put("id",sessionId); |
||||
params.put("userid", userId); |
||||
params.put("query",question); |
||||
Map<String, String[]> authDataIds = this.getAuthDataIds(userId); |
||||
params.putAll(authDataIds); |
||||
RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantAsk(), params); |
||||
sessionRedisManager.addSessionId(sessionId); |
||||
} |
||||
|
||||
@Override |
||||
public void specialAsk(String sessionId, String userId, Map<String, Object> extra) { |
||||
Map<String,Object> params = new HashMap<>(); |
||||
params.put("id",sessionId); |
||||
params.put("userid", userId); |
||||
params.put("extra",extra); |
||||
Map<String, String[]> authDataIds = this.getAuthDataIds(userId); |
||||
params.putAll(authDataIds); |
||||
RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantSpecialAsk(), params); |
||||
sessionRedisManager.addSessionId(sessionId); |
||||
} |
||||
|
||||
@Override |
||||
public void knowledgeAsk(String question, String sessionId, String userId, String knowledge) { |
||||
Map<String,Object> params = new HashMap<>(); |
||||
params.put("id", sessionId); |
||||
params.put("userid", userId); |
||||
params.put("query", question); |
||||
params.put("knowledge", knowledge); |
||||
Map<String, String[]> authDataIds = this.getAuthDataIds(userId); |
||||
params.putAll(authDataIds); |
||||
RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantKnowledgeAsk(), params); |
||||
sessionRedisManager.addSessionId(sessionId); |
||||
} |
||||
|
||||
@Override |
||||
public void removeSessionId(String sessionId) { |
||||
Map<String,Object> params = new HashMap<>(); |
||||
params.put("id",sessionId); |
||||
RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAskAbort(), params); |
||||
sessionRedisManager.removeSessionId(sessionId); |
||||
} |
||||
|
||||
@Override |
||||
public List hotQuestions() { |
||||
return RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getHotQuestion(), null, List.class); |
||||
} |
||||
|
||||
@Override |
||||
public List<AnswerVO> getAnswerBySessionIds(String sessionIds) { |
||||
Map<String,Object> params = new HashMap<>(); |
||||
params.put("ids",Func.toStrList(",",sessionIds).toArray()); |
||||
List<AnswerVO> answerVOList = RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantStatus(), params, List.class); |
||||
//TODO 解析答案
|
||||
return answerVOList; |
||||
} |
||||
|
||||
private Map<String,String[]> getAuthDataIds(String userId) { |
||||
List<DeptStationDTO> authDatas = authenticationService.getStationPermissionsById(userId); |
||||
Map<String, String[]> result = new HashMap<>(2); |
||||
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); |
||||
result.put("stationids", stationIds); |
||||
result.put("projectids", projectIds); |
||||
return result; |
||||
} |
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.service.impl; |
||||
|
||||
import com.hnac.hzims.bigmodel.interactive.factory.AnswerResolveFactory; |
||||
import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; |
||||
import groovy.util.logging.Slf4j; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/06/21 19:02 |
||||
*/ |
||||
@Service(AnswerResolveFactory.PARAM_ANSWER_SERVICE) |
||||
@Slf4j |
||||
@AllArgsConstructor |
||||
public class ParamAnswerResolveServiceImpl implements IAnswerResolveService { |
||||
|
||||
@Override |
||||
public AnswerVO resolve(AnswerVO answer) { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.service.impl; |
||||
|
||||
import com.hnac.hzims.bigmodel.interactive.factory.AnswerResolveFactory; |
||||
import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; |
||||
import groovy.util.logging.Slf4j; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/06/21 19:02 |
||||
*/ |
||||
@Service(AnswerResolveFactory.REMOTE_ANSWER_SERVICE) |
||||
@Slf4j |
||||
@AllArgsConstructor |
||||
public class RemoteAnswerResolveServiceImpl implements IAnswerResolveService { |
||||
|
||||
@Override |
||||
public AnswerVO resolve(AnswerVO answer) { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,73 @@
|
||||
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.FunctionConstants; |
||||
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.StationVideoTypeEntity; |
||||
import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; |
||||
import groovy.util.logging.Slf4j; |
||||
import lombok.AllArgsConstructor; |
||||
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.springframework.stereotype.Service; |
||||
import org.springframework.util.Assert; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/06/21 16:17 |
||||
*/ |
||||
@Service(ResolveFactory.VIDEO_RESOLVE_SERVICE) |
||||
@AllArgsConstructor |
||||
@Slf4j |
||||
public class VideoResolveServiceImpl implements IResolveService { |
||||
|
||||
private final IStationVideoTypeClient videoClient; |
||||
private final BladeLogger logger; |
||||
|
||||
@Override |
||||
public ResolveResultVO 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"); |
||||
}); |
||||
ExtraVO extra = this.resolve(Long.valueOf(id)); |
||||
String message = "已成功打开" + name + ";"; |
||||
return new ResolveResultVO(message,extra); |
||||
} |
||||
|
||||
@Override |
||||
public ExtraVO resolve(Long id) { |
||||
// 跳转页面逻辑
|
||||
ExtraVO extraVO = new ExtraVO(); |
||||
R<StationVideoTypeEntity> videoR = videoClient.getById(Long.valueOf(id)); |
||||
if(videoR.isSuccess()) { |
||||
StationVideoTypeEntity video = videoR.getData(); |
||||
extraVO.setType(FunctionConstants.TypeEnum.PARAMS.getType()); |
||||
extraVO.setImmediatelyJump(true); |
||||
extraVO.setFuncCode(FuncRouteEnum.OPEN_VIDEO.getFuncCode()); |
||||
Map<String,Object> params = new HashMap<>(); |
||||
params.put("name", video.getName()); |
||||
params.put("videoHost", video.getVideoHost()); |
||||
params.put("pointCode", video.getPointCode()); |
||||
params.put("appKey", video.getAppKey()); |
||||
params.put("appSecret", video.getAppSecret()); |
||||
params.put("liveSourceAddress",video.getLiveSourceAddress()); |
||||
extraVO.setParams(params); |
||||
} |
||||
return extraVO; |
||||
} |
||||
} |
@ -0,0 +1,29 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.vo; |
||||
|
||||
import com.hnac.hzims.bigmodel.interactive.constants.InfoMessageConstant; |
||||
import io.swagger.annotations.ApiModel; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/06/21 16:31 |
||||
*/ |
||||
@EqualsAndHashCode |
||||
@Data |
||||
@AllArgsConstructor |
||||
@ApiModel(value = "解析结果",description = "解析结果") |
||||
public class ResolveResultVO implements Serializable { |
||||
|
||||
private String content; |
||||
|
||||
private ExtraVO extraVO; |
||||
|
||||
public static ResolveResultVO error() { |
||||
return new ResolveResultVO(InfoMessageConstant.ERROR_MESSAGE,null); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,28 @@
|
||||
package com.hnac.hzims.bigmodel.manager; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.data.redis.core.RedisTemplate; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.HZIMS_BIGMODEL_ASK_KEY; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/06/21 18:23 |
||||
*/ |
||||
@Component |
||||
public class SessionRedisManager { |
||||
|
||||
@Autowired |
||||
private RedisTemplate redisTemplate; |
||||
|
||||
public void addSessionId(String sessionId) { |
||||
redisTemplate.opsForList().leftPush(HZIMS_BIGMODEL_ASK_KEY,sessionId); |
||||
} |
||||
|
||||
public void removeSessionId(String sessionId) { |
||||
redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,sessionId); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,48 @@
|
||||
package com.hnac.hzims.bigmodel.utils; |
||||
|
||||
import cn.hutool.http.HttpRequest; |
||||
import cn.hutool.http.HttpResponse; |
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import groovy.util.logging.Slf4j; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springframework.util.Assert; |
||||
|
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/06/21 17:12 |
||||
*/ |
||||
public class RequestClientUtil { |
||||
|
||||
/** |
||||
* 无返回结果远程调用http接口 |
||||
* @param url 接口url |
||||
* @param body 传参body |
||||
*/ |
||||
public static void postCall(String url, Map body) { |
||||
HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute(); |
||||
Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { |
||||
throw new ServiceException("远程调用大模型接口" + url + "失败!"); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 远程调用http接口 |
||||
* @param url 接口url |
||||
* @param body 传参 |
||||
* @param resultT 结果解析对象 |
||||
* @return 结果 |
||||
* @param <T> 结果解析对象类型 |
||||
*/ |
||||
public static <T> T postCall(String url, Map body, Class<T> resultT) { |
||||
HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute(); |
||||
Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { |
||||
throw new ServiceException("远程调用大模型接口" + url + "失败!"); |
||||
}); |
||||
return JSONObject.parseObject(response.body(), resultT); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue