AiSqlErrorHistoryThread.java 2.46 KB
package com.xly.thread;


import cn.hutool.core.util.StrUtil;
import com.xly.config.SpringContextHolder;
import com.xly.entity.UserSceneSession;
import com.xly.service.DynamicExeDbService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class AiSqlErrorHistoryThread implements Runnable {
    private UserSceneSession session;
    private String sSqlContent;
    private String sError_sql;
    private String sError_mes;
    private String sQuestion;
    public final String sProName="Sp_Ai_AiSqlErrorHistoryThread";

    public AiSqlErrorHistoryThread(UserSceneSession session, String sSqlContent, String sError_sql,String sError_mes,String sQuestion) {
        this.session = session;
        this.sSqlContent = sSqlContent;
        this.sError_sql = sError_sql;
        this.sError_mes = sError_mes;
        this.sQuestion = sQuestion;
    }
    @Override
    public void run() {
        String sSceneId = session.getCurrentScene().getSId();
        String sMethodId = session.getCurrentTool().getSId();
        DynamicExeDbService dynamicExeDbService = SpringContextHolder.getBean(DynamicExeDbService.class);
        Map<String, Object> data = getMap(sSceneId, sMethodId);
        data.put("sQuestion",getsQuestion(session.getSUserQuestionList()));
        Map<String, Object> searMap = dynamicExeDbService.getDoProMap(sProName, data);
        dynamicExeDbService.getCallPro(searMap, sProName);
    }
    private String getsQuestion(List<String> sUserQuestionList){
        return String.join(",", sUserQuestionList);
    }
    /***
     * @Author 钱豹
     * @Date 4:22 2026/3/15
     * @Param [sSceneId, sMethodId]
     * @return java.util.Map<java.lang.String,java.lang.Object>
     * @Description 获取执行的动态Map
     **/
    private Map<String, Object> getMap(String sSceneId, String sMethodId) {
        Map<String,Object> data = new HashMap<>(16);
        data.put("sSceneId", sSceneId);
        data.put("sMethodId", sMethodId);
        data.put("sSqlContent",sSqlContent);
        data.put("sError_sql",sError_sql);
        data.put("sError_mes",sError_mes);
        data.put("sBrId",session.getSBrandsId());
        data.put("sBrandsId",session.getSBrandsId());
        data.put("sSuId",session.getSSubsidiaryId());
        data.put("sSubsidiaryId",session.getSSubsidiaryId());
        data.put("sLoginId",session.getUserName());
        data.put("sUserName",session.getUserName());
        data.put("sUserId",session.getUserId());
        return data;
    }
}