package digital.laboratory.platform.entrustment.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import digital.laboratory.platform.common.core.util.R;
import digital.laboratory.platform.common.mybatis.security.service.DLPUser;
import digital.laboratory.platform.entrustment.dto.EntrustMaterialCheckoutResultDTO;
import digital.laboratory.platform.entrustment.dto.GenerateQuarterlyReportDTO;
import digital.laboratory.platform.entrustment.dto.ResultExcelDTO;
import digital.laboratory.platform.entrustment.entity.EntrustMaterialCheckoutResult;
import digital.laboratory.platform.entrustment.query.EntrustMaterialCheckoutResultQuery;
import digital.laboratory.platform.entrustment.vo.DetectionRateVO;
import digital.laboratory.platform.entrustment.vo.EntrustMaterialCheckoutResultVO;
import digital.laboratory.platform.entrustment.vo.EntrustmentIdentificationMaterialVO;
import digital.laboratory.platform.entrustment.vo.SuspectDetectionVO;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* @author ChenJiangBao
* @description 针对表【b_entrust_material_checkout_result(委托检材--检出定性定量结果信息)】的数据库操作Service
* @createDate 2024-12-30 16:16:25
*/
public interface EntrustMaterialCheckoutResultService extends IService<EntrustMaterialCheckoutResult> {

    /**
     * 构建委托材料检验结果字符串
     *
     * @param entrustId 委托ID
     * @return 委托材料检验结果字符串
     */
    String buildEntrustMaterialCheckoutResultStr(String entrustId);

    /**
     * 根据DTO保存检材得检出结果信息
     * @param dto 检出DTO
     * @return
     */
    boolean save(EntrustMaterialCheckoutResultDTO dto);

    /**
     * 根据委托id导出检出结果excel文件
     *
     * @param entrustIds 委托id列表，包含需要导出的委托的id
     * @param response HttpServletResponse对象，用于将生成的excel文件写入响应中
     */
    void exportExcel(List<String> entrustIds, HttpServletResponse response) throws IOException;

    /**
     * vo 分页对象
     * @param query
     * @return
     */
    IPage<EntrustMaterialCheckoutResultVO> voiPage(EntrustMaterialCheckoutResultQuery query);

    /**
     * 查询所有检出检材的毒品种类清单，并按名称进行排序
     *
     * @param year
     * @param orgId
     * @return
     */
    List<String> getResultType(Integer year, String orgId);

    IPage<EntrustmentIdentificationMaterialVO> getMaterialByDetection(String drugName, Integer year, Page page);
    /**
     * 查询所有毒品的检出率
     *
     * @param year
     * @param orgId
     * @return
     */
    DetectionRateVO getDetectionRateByMaterial(Integer year, String orgId);


    R getExcelByResult(HttpServletResponse response, ResultExcelDTO excelDTO) throws IOException;

    boolean pushSuspectDetectionResult(String entrustmentId, DLPUser user) throws SQLException;

    R pushSuspectDetectionResultTask(DLPUser dlpUser);

    String generateQuarterlyReportExcel(GenerateQuarterlyReportDTO dto, HttpServletResponse response) throws IOException;
}
