package org.jk.rag.service;


import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jk.common.mybatis.core.page.PageQuery;
import org.jk.rag.domain.dto.*;
import org.jk.rag.domain.entity.*;
import org.jk.rag.domain.vo.KnowledgeSliceVo;
import org.jk.system.domain.vo.SysDictDataVo;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.concurrent.CompletableFuture;

/**
 * 高井 业务层
 *
 * @author Jk
 */
public interface IJkRagService
{

    void initDeepseekInfo();

    SseEmitter sseInvoke(JkSseInfoParams sseParams);

    SseEmitter previewSseInvoke(JkPreviewSeeParams params);

    List<String> asyncCompletions(JkCompletionsParams params);

    List<JkDialogRespDTO> getDialogDetail(String dialogId);

    void saveDialog(JkDialogReqDTO dialogReqDTO);

    List<Object> getDialogList(String appId, String userId);

    void DelDialogDetail(String id);

    void updateDialog(JkDialogReqDTO dialogReqDTO);

    List<JkDialogRespDTO> exportExcel(String dialogId);

    int createKnowledge(JkKnowledgeParams knowledge);

    int updateKnowledge(JkKnowledgeParams knowledge, String knowledgeId);

    JkKnowledge detailKnowledge(String knowledgeId);

    int delKnowledge(String knowledgeId);

    //CompletableFuture<Integer> uploadDocument(MultipartFile[] files, String knowledgeId) throws Exception;

    CompletableFuture<Integer> uploadDocument(JkDocumentParams params,List<JkDocument> documentList,Boolean flg) throws Exception;

    void updateDocumentByPython(JkDocumentPythonParams parms);

    int updateDocument(JkDocumentParams documentParams, String documentId);

    List<JkDocument> documentList(JkDocumentParams documentParams);

    IPage<JkDocument> documentPageList(JkDocumentParams documentParams, PageQuery pageQuery);

    IPage<JkQuoteDocument> quoteDocumentPageList(JkDocumentParams documentParams, PageQuery pageQuery);

    Page<JkSliceDocument> sliceDocumentPageList(JkDocumentParams documentParams, PageQuery pageQuery);

    JkDocument documentDetail(String documentId);

    int delDocument(String documentId);

    int delUnfinishedDocument(String documentId);

    void uploadUrl(JkDocumentObject object);

    int createApplication(JkApplicationParams params, boolean isAdmin);

    int updateApplication(JkApplicationParams params, String appId, boolean isAdmin);

    List<JkApplicationResult> getApplicationList(JkApplication params);

    JSONObject selectApplication(String appId);

    int delApplication(String appId);

    List<JkQuestionDTO> selectQuestionByAppId(String appId);

    List<JkKnowledge> queryKnowledgeList();

    List<JkDialogRespDTO> selectDialogListByAppId(String appId, String userId);

    Page<JkDialogRespDTO> selectDialogPageListByAppId(String appId, String userId,PageQuery pageQuery);

    JkDocumentSettings documentSetting(String dialogId);

    int updateDocumentSetting(JkDocumentParams params, String documentId);

    JSONObject getSliceList(JkSliceParams params);

    int deleteSlice(String sliceId, String knowledgeId, String documentId);

    JSONObject getSliceDetail(String sliceId, String knowledgeId);

    JkMediaReplacement uploadSliceImage(JkSliceImpageParms parms, String knowledgeId, String documentId);

    int updateSliceInfo(JkSliceUpdateParams params,Boolean flg);

    JkMediaReplacement getJkMediaReplacement();

    String addSlice(JkSliceUpdateParams params);

    List<JkSliceInfo> selectByDocumentId(String documentId,String sliceText);

    List<JkSliceInfo> selectOldSliceByDocumentId(String documentId,String sliceText);

    Page<JkSliceInfo> selectPageByDocumentId(String documentId,String sliceText,PageQuery pageQuery);

    JkSliceInfo selectBySliceId(String sliceId);

    List<SliceInfo> slicePageInfoList(List<String> list);

    JSONObject searchSlice(String id);

    List<Object>  searchAppTypeGroupList(List<SysDictDataVo> dictDataList, String userId);

    List<JkApplication> applicationListByApprover(JkApplicationParams documentParams);

    Page<JkApplication> applicationPageListByApprover(JkApplicationParams documentParams,PageQuery pageQuery);

    Page<JkApplication> applicationHistoryPageListByApprover(JkApplicationParams documentParams,PageQuery pageQuery);

    public int startAudit(String appId, String userId);

    int updateAuditApplication(JkApplicationParams appParams, String appId);

    List<JkApplicationResult> selectAppByUserId(String userId);

    List<String> selectAppCollectList(String userId);

    int insertAppCollect(AppCollect appCollect);

    int deleteAppCollect(String userId, String appId);

    List<JkApplicationResult> selectRoleApp();

    List<JkApplicationResult> getChatAppList(List<JkApplicationResult> list, String userId);

    List<Object> setDialogList(List<JkDialogRespDTO> list);

    Page<JkApplicationResult> getApplicationPageList(JkApplication params, PageQuery pageQuery);

    Page<JkApplicationResult> getMyApplicationPageList(JkApplication params, PageQuery pageQuery);

    Page<JkKnowledge> queryKnowledgePageList(JkPageParams params,PageQuery pageQuery);

    List<KnowledgeSliceVo> selectExportKnowledgeSlice(String knowledgeId);

    List<KnowledgeSliceVo> selectExportDocumentSlice(List<String> documentIds);

    void downloadDocument(List<String> documentIds, OutputStream outputStream) throws IOException;

    void downloadFileDocument(List<String> documentIds, OutputStream outputStream) throws IOException;

    void pdfStream(List<String> documentIds, OutputStream outputStream) throws IOException;

    void delByDocId(String docId);

    void importDocumentList(JkDocumentExportParams params);

    void updateSliceInfoList(JkSliceUpdateReq params,Boolean flg);

    void downloadKnowledgeFileDocument(String knowledgeId, OutputStream outputStream) throws IOException;

    void downloadKnowledgeMarkDownFileDocument(String knowledgeId, OutputStream outputStream) throws IOException;

    String checkDocumentFile(DocumentFileDTO params,OssParms ossParms);

    String getMarkDownSliceByDocumentId(String documentId) throws IOException;

    void editMarkDownFile(JkMarkUpdateReq req);

    void updateDocumentKnowledgeSize(String knowlegeId,String documentId);

    void cleanLjData();

    String selQouteDocumentFile(BmDocument params,String knowledgeId);

}
