| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -12,6 +12,7 @@ import com.hnac.gglm.bigmodel.interactive.service.IHznlmInvokeService; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import com.hnac.gglm.bigmodel.interactive.vo.AnswerVO; | 
					 | 
					 | 
					 | 
					import com.hnac.gglm.bigmodel.interactive.vo.AnswerVO; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import com.hnac.gglm.bigmodel.manager.SessionRedisManager; | 
					 | 
					 | 
					 | 
					import com.hnac.gglm.bigmodel.manager.SessionRedisManager; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import com.hnac.gglm.bigmodel.question.dto.QuestionDTO; | 
					 | 
					 | 
					 | 
					import com.hnac.gglm.bigmodel.question.dto.QuestionDTO; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.hnac.gglm.bigmodel.utils.MultipartFileToBase64Converter; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import com.hnac.gglm.bigmodel.utils.RequestClientUtil; | 
					 | 
					 | 
					 | 
					import com.hnac.gglm.bigmodel.utils.RequestClientUtil; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import com.hnac.gglm.bigmodel.websocket.constants.RedisKeyConstants; | 
					 | 
					 | 
					 | 
					import com.hnac.gglm.bigmodel.websocket.constants.RedisKeyConstants; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import com.hnac.gglm.bigmodel.websocket.sessionManager.InteractiveSessionManager; | 
					 | 
					 | 
					 | 
					import com.hnac.gglm.bigmodel.websocket.sessionManager.InteractiveSessionManager; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -19,12 +20,15 @@ import com.hnac.hzims.common.constant.CommonConstant; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import com.hnac.hzinfo.exception.HzServiceException; | 
					 | 
					 | 
					 | 
					import com.hnac.hzinfo.exception.HzServiceException; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import lombok.RequiredArgsConstructor; | 
					 | 
					 | 
					 | 
					import lombok.RequiredArgsConstructor; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import lombok.extern.slf4j.Slf4j; | 
					 | 
					 | 
					 | 
					import lombok.extern.slf4j.Slf4j; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import org.springblade.core.oss.model.BladeFile; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import org.springblade.core.tool.api.R; | 
					 | 
					 | 
					 | 
					import org.springblade.core.tool.api.R; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import org.springblade.core.tool.jackson.JsonUtil; | 
					 | 
					 | 
					 | 
					import org.springblade.core.tool.jackson.JsonUtil; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import org.springblade.core.tool.utils.Func; | 
					 | 
					 | 
					 | 
					import org.springblade.core.tool.utils.Func; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import org.springblade.resource.feign.IOssClient; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import org.springframework.beans.factory.annotation.Value; | 
					 | 
					 | 
					 | 
					import org.springframework.beans.factory.annotation.Value; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import org.springframework.data.redis.core.RedisTemplate; | 
					 | 
					 | 
					 | 
					import org.springframework.data.redis.core.RedisTemplate; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import org.springframework.stereotype.Service; | 
					 | 
					 | 
					 | 
					import org.springframework.stereotype.Service; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import org.springframework.web.multipart.MultipartFile; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import java.util.HashMap; | 
					 | 
					 | 
					 | 
					import java.util.HashMap; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import java.util.List; | 
					 | 
					 | 
					 | 
					import java.util.List; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -46,17 +50,18 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private final SessionRedisManager sessionRedisManager; | 
					 | 
					 | 
					 | 
					    private final SessionRedisManager sessionRedisManager; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private final IAuthClient authClient; | 
					 | 
					 | 
					 | 
					    private final IAuthClient authClient; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private final RedisTemplate redisTemplate; | 
					 | 
					 | 
					 | 
					    private final RedisTemplate redisTemplate; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    private final IOssClient ossClient; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Value("${gglm.url}") | 
					 | 
					 | 
					 | 
					    @Value("${gglm.url}") | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private String gglmUrl; | 
					 | 
					 | 
					 | 
					    private String gglmUrl; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Override | 
					 | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public void ask(String question, String sessionId, String userId) { | 
					 | 
					 | 
					 | 
					    public void ask(String question, String sessionId, String userId) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Map<String, Object> params = new HashMap<>(); | 
					 | 
					 | 
					 | 
					        Map<String,Object> params = new HashMap<>(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.put("chat_id", sessionId); | 
					 | 
					 | 
					 | 
					        params.put("chat_id",sessionId); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.put("user_id", userId); | 
					 | 
					 | 
					 | 
					        params.put("user_id", userId); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.put("query", question); | 
					 | 
					 | 
					 | 
					        params.put("q_id", UUID.randomUUID().toString()); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.put("q_id", UUID.randomUUID()); | 
					 | 
					 | 
					 | 
					        params.put("query",question); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Map<String, String[]> authDataIds = this.getAuthDataIds(userId); | 
					 | 
					 | 
					 | 
					        Map<String, String[]> authDataIds = this.getAuthDataIds(userId); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.putAll(authDataIds); | 
					 | 
					 | 
					 | 
					        params.putAll(authDataIds); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAsk(), params); | 
					 | 
					 | 
					 | 
					        RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAsk(), params); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -65,40 +70,42 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Override | 
					 | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public void ask(QuestionDTO question) { | 
					 | 
					 | 
					 | 
					    public void ask(QuestionDTO question) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAsk(), JSON.toJSONString(question)); | 
					 | 
					 | 
					 | 
					        Map<String, Object> params = Func.toMap(question); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        params.put("q_id", UUID.randomUUID().toString()); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAsk(), params); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        sessionRedisManager.addSessionId(question.getChatId()); | 
					 | 
					 | 
					 | 
					        sessionRedisManager.addSessionId(question.getChatId()); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Override | 
					 | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public void specialAsk(String sessionId, String userId, Map<String, Object> extra) { | 
					 | 
					 | 
					 | 
					    public void specialAsk(String sessionId, String userId, Map<String, Object> extra) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Map<String, Object> params = new HashMap<>(); | 
					 | 
					 | 
					 | 
					        Map<String,Object> params = new HashMap<>(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.put("chat_id", sessionId); | 
					 | 
					 | 
					 | 
					        params.put("chat_id",sessionId); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.put("user_id", userId); | 
					 | 
					 | 
					 | 
					        params.put("user_id", userId); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.put("extra", extra); | 
					 | 
					 | 
					 | 
					        params.put("q_id", UUID.randomUUID().toString()); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.put("q_id", UUID.randomUUID()); | 
					 | 
					 | 
					 | 
					        params.put("extra",extra); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Map<String, String[]> authDataIds = this.getAuthDataIds(userId); | 
					 | 
					 | 
					 | 
					        Map<String, String[]> authDataIds = this.getAuthDataIds(userId); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.putAll(authDataIds); | 
					 | 
					 | 
					 | 
					        params.putAll(authDataIds); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        log.info("调用大模型接口:{},传参为:{}", gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), JSON.toJSONString(params)); | 
					 | 
					 | 
					 | 
					        log.info("调用大模型接口:{},传参为:{}",gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(),JSON.toJSONString(params)); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), params); | 
					 | 
					 | 
					 | 
					        RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), params); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        sessionRedisManager.addSessionId(sessionId); | 
					 | 
					 | 
					 | 
					        sessionRedisManager.addSessionId(sessionId); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Override | 
					 | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public void specialAsk(QuestionDTO question) { | 
					 | 
					 | 
					 | 
					    public void specialAsk(QuestionDTO question) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Map<String, Object> questionMap = JsonUtil.toMap(JSON.toJSONString(question)); | 
					 | 
					 | 
					 | 
					        Map<String, Object> params = Func.toMap(question); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        questionMap.put("q_id", UUID.randomUUID()); | 
					 | 
					 | 
					 | 
					        params.put("q_id", UUID.randomUUID().toString()); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), JSON.toJSONString(questionMap)); | 
					 | 
					 | 
					 | 
					        RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), params); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        sessionRedisManager.addSessionId(question.getChatId()); | 
					 | 
					 | 
					 | 
					        sessionRedisManager.addSessionId(question.getChatId()); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Override | 
					 | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public void knowledgeAsk(String question, String sessionId, String userId, String knowledge) { | 
					 | 
					 | 
					 | 
					    public void knowledgeAsk(String question, String sessionId, String userId, String knowledge) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Map<String, Object> params = new HashMap<>(); | 
					 | 
					 | 
					 | 
					        Map<String,Object> params = new HashMap<>(); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.put("chat_id", sessionId); | 
					 | 
					 | 
					 | 
					        params.put("chat_id", sessionId); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.put("user_id", userId); | 
					 | 
					 | 
					 | 
					        params.put("user_id", userId); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.put("query", question); | 
					 | 
					 | 
					 | 
					        params.put("query", question); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        params.put("q_id", UUID.randomUUID().toString()); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.put("knowledge", knowledge); | 
					 | 
					 | 
					 | 
					        params.put("knowledge", knowledge); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.put("q_id", UUID.randomUUID()); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Map<String, String[]> authDataIds = this.getAuthDataIds(userId); | 
					 | 
					 | 
					 | 
					        Map<String, String[]> authDataIds = this.getAuthDataIds(userId); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.putAll(authDataIds); | 
					 | 
					 | 
					 | 
					        params.putAll(authDataIds); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), params); | 
					 | 
					 | 
					 | 
					        RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), params); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -107,17 +114,17 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Override | 
					 | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public void knowledgeAsk(QuestionDTO question) { | 
					 | 
					 | 
					 | 
					    public void knowledgeAsk(QuestionDTO question) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Map<String, Object> questionMap = JsonUtil.toMap(JSON.toJSONString(question)); | 
					 | 
					 | 
					 | 
					        Map<String, Object> params = Func.toMap(question); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        questionMap.put("q_id", UUID.randomUUID()); | 
					 | 
					 | 
					 | 
					        params.put("q_id", UUID.randomUUID().toString()); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), JSON.toJSONString(questionMap)); | 
					 | 
					 | 
					 | 
					        RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), params); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        sessionRedisManager.addSessionId(question.getChatId()); | 
					 | 
					 | 
					 | 
					        sessionRedisManager.addSessionId(question.getChatId()); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Override | 
					 | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public void analyseAsk(QuestionDTO question) { | 
					 | 
					 | 
					 | 
					    public void analyseAsk(QuestionDTO question) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Map<String, Object> questionMap = JsonUtil.toMap(JSON.toJSONString(question)); | 
					 | 
					 | 
					 | 
					        Map<String, Object> params = Func.toMap(question); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        questionMap.put("q_id", UUID.randomUUID()); | 
					 | 
					 | 
					 | 
					        params.put("q_id", UUID.randomUUID().toString()); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAnalyseAsk(), JSON.toJSONString(questionMap)); | 
					 | 
					 | 
					 | 
					        RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAnalyseAsk(), params); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        sessionRedisManager.addSessionId(question.getChatId()); | 
					 | 
					 | 
					 | 
					        sessionRedisManager.addSessionId(question.getChatId()); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -131,8 +138,8 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Override | 
					 | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public void askAbort(String sessionId) { | 
					 | 
					 | 
					 | 
					    public void askAbort(String sessionId) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Map<String, Object> params = new HashMap<>(); | 
					 | 
					 | 
					 | 
					        Map<String,Object> params = new HashMap<>(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.put("chat_id", sessionId); | 
					 | 
					 | 
					 | 
					        params.put("chat_id",sessionId); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAskAbort(), params); | 
					 | 
					 | 
					 | 
					        RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAskAbort(), params); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        sessionRedisManager.removeSessionId(sessionId); | 
					 | 
					 | 
					 | 
					        sessionRedisManager.removeSessionId(sessionId); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -141,74 +148,94 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        this.askAbort(sessionId); | 
					 | 
					 | 
					 | 
					        this.askAbort(sessionId); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        // 循环获取该会话ID中断状态,当状态等于-2或重连超6次则中断返回结果
 | 
					 | 
					 | 
					 | 
					        // 循环获取该会话ID中断状态,当状态等于-2或重连超6次则中断返回结果
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        int status = 999; | 
					 | 
					 | 
					 | 
					        int status = 999; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        int attempts = 0; | 
					 | 
					 | 
					 | 
					        int attempts  = 0; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        while (status > 0) { | 
					 | 
					 | 
					 | 
					        while (status > 0) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            // 若重连超过10次 则抛出错误
 | 
					 | 
					 | 
					 | 
					            // 若重连超过10次 则抛出错误
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (attempts >= 8) { | 
					 | 
					 | 
					 | 
					            if(attempts  >= 8) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                throw new HzServiceException("中断失败!长时间未获取到中断状态"); | 
					 | 
					 | 
					 | 
					                throw new HzServiceException("中断失败!长时间未获取到中断状态"); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            List<AnswerVO> answers = this.getAnswerBySessionIds(sessionId); | 
					 | 
					 | 
					 | 
					            List<AnswerVO> answers = this.getAnswerBySessionIds(sessionId); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (Func.isNotEmpty(answers)) { | 
					 | 
					 | 
					 | 
					            if(Func.isNotEmpty(answers)) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                log.info(answers.get(0).getStatus() + ""); | 
					 | 
					 | 
					 | 
					                log.info(answers.get(0).getStatus()+""); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                status = answers.get(0).getStatus(); | 
					 | 
					 | 
					 | 
					                status = answers.get(0).getStatus(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            // 若获取到的状态不等于2 则延时0.5秒
 | 
					 | 
					 | 
					 | 
					            // 若获取到的状态不等于2 则延时0.5秒
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (status > 0) { | 
					 | 
					 | 
					 | 
					            if(status > 0) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                try { | 
					 | 
					 | 
					 | 
					                try { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    Thread.sleep(500); | 
					 | 
					 | 
					 | 
					                    Thread.sleep(500); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                } catch (InterruptedException e) { | 
					 | 
					 | 
					 | 
					                } catch (InterruptedException e) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    throw new RuntimeException(e); | 
					 | 
					 | 
					 | 
					                    throw new RuntimeException(e); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                } | 
					 | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            attempts++; | 
					 | 
					 | 
					 | 
					            attempts ++; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Override | 
					 | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public void smartReportGeneratePower(RunReportAnalyseRequest req) { | 
					 | 
					 | 
					 | 
					    public void smartReportGeneratePower(RunReportAnalyseRequest req) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Map<String, Object> params = new HashMap<>(); | 
					 | 
					 | 
					 | 
					        Map<String,Object> params = new HashMap<>(); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        String sessionId = IdWorker.get32UUID(); | 
					 | 
					 | 
					 | 
					        String sessionId = IdWorker.get32UUID(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.put("chat_id", sessionId); | 
					 | 
					 | 
					 | 
					        params.put("chat_id",sessionId); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.put("user_id", CommonConstant.SYSTEM_USER.toString()); | 
					 | 
					 | 
					 | 
					        params.put("user_id", CommonConstant.SYSTEM_USER.toString()); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.put("data", req.getAnalyseDTOS()); | 
					 | 
					 | 
					 | 
					        params.put("data", req.getAnalyseDTOS()); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.put("query", ""); | 
					 | 
					 | 
					 | 
					        params.put("query", ""); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        params.put("q_id", UUID.randomUUID().toString()); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getSmartReportGeneratePower(), params); | 
					 | 
					 | 
					 | 
					        RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getSmartReportGeneratePower(), params); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        // 将sessionId存入redis,拿到数据之后输入月报中
 | 
					 | 
					 | 
					 | 
					        // 将sessionId存入redis,拿到数据之后输入月报中
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        JSONObject report = new JSONObject(); | 
					 | 
					 | 
					 | 
					        JSONObject report = new JSONObject(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        report.put("stationCode", req.getStationCode()); | 
					 | 
					 | 
					 | 
					        report.put("stationCode",req.getStationCode()); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        report.put("month", req.getMonth()); | 
					 | 
					 | 
					 | 
					        report.put("month",req.getMonth()); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        report.put("sessionId", sessionId); | 
					 | 
					 | 
					 | 
					        report.put("sessionId",sessionId); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        redisTemplate.opsForList().leftPush(RedisKeyConstants.RUN_REPORT_SESSION_ID, JSON.toJSONString(report)); | 
					 | 
					 | 
					 | 
					        redisTemplate.opsForList().leftPush(RedisKeyConstants.RUN_REPORT_SESSION_ID,JSON.toJSONString(report)); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        redisTemplate.expire(RedisKeyConstants.RUN_REPORT_SESSION_ID, 5, TimeUnit.MINUTES); | 
					 | 
					 | 
					 | 
					        redisTemplate.expire(RedisKeyConstants.RUN_REPORT_SESSION_ID,5, TimeUnit.MINUTES); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Override | 
					 | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public void updateKnowledge(String name) { | 
					 | 
					 | 
					 | 
					    public void updateKnowledge(String name) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Map<String, Object> params = new HashMap<>(); | 
					 | 
					 | 
					 | 
					        Map<String,Object> params = new HashMap<>(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.put("name", name); | 
					 | 
					 | 
					 | 
					        params.put("name",name); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getUpdateKnowledge(), params); | 
					 | 
					 | 
					 | 
					        RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getUpdateKnowledge(), params); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Override | 
					 | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    public void identifyForm(String formStructure, MultipartFile file, String content, String chatId, Long userId) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        // 若 file 不为空,则转换为base64编码格式字符串传给大模型
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        String pic = null; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if(Func.isNotEmpty(file)) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            pic = MultipartFileToBase64Converter.convertToBase64(file); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        Map<String,Object> param = new HashMap<>(5); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        Map<String,Object> data = new HashMap<>(3); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        data.put("form",JSONObject.parseObject(formStructure)); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        data.put("pic", pic); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        data.put("content", content); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        param.put("chat_id", chatId); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        param.put("user_id", userId.toString()); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        param.put("query", ""); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        param.put("data",data); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        param.put("q_id", UUID.randomUUID().toString()); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getIdentifyForm(), param, new TypeReference<JSONObject>(){}); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public List hotQuestions() { | 
					 | 
					 | 
					 | 
					    public List hotQuestions() { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        try { | 
					 | 
					 | 
					 | 
					        try { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getHotQuestion(), null, new TypeReference<List<String>>() { | 
					 | 
					 | 
					 | 
					            return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getHotQuestion(), null, new TypeReference<List<String>>(){}); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            }); | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } catch (Exception e) { | 
					 | 
					 | 
					 | 
					        catch (Exception e) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            log.error("An error occurred", e); | 
					 | 
					 | 
					 | 
					            log.error("An error occurred",e); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            return Lists.newArrayList(); | 
					 | 
					 | 
					 | 
					            return Lists.newArrayList(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Override | 
					 | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public List<AnswerVO> getAnswerBySessionIds(String sessionIds) { | 
					 | 
					 | 
					 | 
					    public List<AnswerVO> getAnswerBySessionIds(String sessionIds) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Map<String, Object> params = new HashMap<>(); | 
					 | 
					 | 
					 | 
					        Map<String,Object> params = new HashMap<>(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        params.put("chat_ids", Func.toStrList(",", sessionIds).toArray()); | 
					 | 
					 | 
					 | 
					        params.put("chat_ids",Func.toStrList(",",sessionIds).toArray()); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantStatus(), params, new TypeReference<List<AnswerVO>>() { | 
					 | 
					 | 
					 | 
					        return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantStatus(), params, new TypeReference<List<AnswerVO>>(){}); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private Map<String, String[]> getAuthDataIds(String userId) { | 
					 | 
					 | 
					 | 
					    private Map<String,String[]> getAuthDataIds(String userId) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Map<String, String[]> result = new HashMap<>(2); | 
					 | 
					 | 
					 | 
					        Map<String, String[]> result = new HashMap<>(2); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        R<Map<String, String[]>> authDataR = authClient.getAuthData(userId); | 
					 | 
					 | 
					 | 
					        R<Map<String, String[]>> authDataR = authClient.getAuthData(userId); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        result.putAll(authDataR.getData()); | 
					 | 
					 | 
					 | 
					        result.putAll(authDataR.getData()); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |