package com.jeeplus.finance.projectReport.mapper;

import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeeplus.finance.projectReport.domain.*;
import com.jeeplus.finance.projectReport.service.dto.ProjectContactInfo;
import com.jeeplus.finance.projectReport.service.dto.ProjectReportInfo;
import com.jeeplus.finance.workClientInfo.domain.CwWorkClientBase;
import com.jeeplus.finance.workClientInfo.service.dto.CwWorkClientBaseDTO;
import com.jeeplus.sys.domain.WorkAttachmentInfo;
import com.jeeplus.sys.service.dto.UserDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 财务-报告管理
 * @author: 王强
 * @create: 2022-11-16 14:17
 **/
@Mapper
//@InterceptorIgnore(tenantLine = "true")
public interface CwProjectReportMapper extends BaseMapper<CwProjectReport> {

    String getTotal();

    /**
     * 查询报告数据集合
     * @param page
     * @param queryWrapper
     * @return
     */
    //@InterceptorIgnore(tenantLine = "true")
    IPage<CwProjectReportData> findList(Page<CwProjectReportData> page, @Param("isBmzr") String isBmzr, @Param("officeIds") String officeIds, @Param(Constants.WRAPPER) QueryWrapper<CwProjectReportData> queryWrapper);
    //获取所有的项目信息
    List<CwProjectReportData> findAllList();

    @InterceptorIgnore(tenantLine = "true")
    List<WorkAttachmentInfo> findFileList(@Param("id") String id);
    @InterceptorIgnore(tenantLine = "true")
    List<WorkAttachmentInfo> findFileListOnAttachmentFlag(@Param("id") String id,@Param("attachmentFlag") String attachmentFlag);

    Integer findIsExit(@Param("id") String id, @Param("name")String name);

    @InterceptorIgnore(tenantLine = "true")
    Integer deleteAttachement(@Param("id") String id,@Param("attachmentFlag") String attachmentFlag);

    @InterceptorIgnore(tenantLine = "true")
    CwProjectReportData queryById(@Param("id") String id);

    @InterceptorIgnore(tenantLine = "true")
    CwProjectReportData queryByIdNew(@Param("id") String id);

    /**
     * 查询被服务单位
     * @param page
     * @param queryWrapper
     * @return
     */
    //@InterceptorIgnore(tenantLine = "true")
    public IPage<CwWorkClientBaseDTO> findClineList(Page<CwWorkClientBaseDTO> page, @Param(Constants.WRAPPER) QueryWrapper<CwWorkClientBase> queryWrapper);

    @InterceptorIgnore(tenantLine = "true")
    String getUserNameById(String id);

    /**
     * 更改报告号签章id信息
     * @param cwProjectReportData
     */
    void updateSignatureInfo(CwProjectReportData cwProjectReportData);

    /**
     * 更改报告号签章id信息
     * @param cwProjectReportData
     */
    @InterceptorIgnore(tenantLine = "true")
    void updateSignatureUrl(CwProjectReportData cwProjectReportData);

    /**
     * 根据id修改del_flag状态
     * @param id
     */
    void updateDelFlag(@Param("flag")int flag,@Param("id") String id);

    /**
     * 根据签章id查询报告信息
     * @param contractId
     * @return
     */
    @InterceptorIgnore(tenantLine = "true")
    CwProjectReportData queryByContractId(@Param("contractId") String contractId);

    /**
     * 修改盖章状态
     * @param cwProjectReportData
     */
    void updateReportSealType(CwProjectReportData cwProjectReportData);

    /**
     * 根据项目id查出所有的reportID
     * @param projectId
     * @return
     */
    @InterceptorIgnore(tenantLine = "true")
    List<CwProjectReportData> getByProjectId(String projectId);

    List<CwProjectReportData> getContainDelByProjectId(String projectId);

    /**
     * 根据报告签章id查询流程id
     * @param id
     * @return
     */
    @InterceptorIgnore(tenantLine = "true")
    String getProcessInstanceIdById(String id);

    /**
     * 修改签章流程节点状态
     * @param repportSignature
     */
    @InterceptorIgnore(tenantLine = "true")
    void updateSignatureType(CwProjectReportSignature repportSignature);

    /**
     * 根据id查询报告签章数据信息
     * @param id
     * @return
     */
    @InterceptorIgnore(tenantLine = "true")
    CwProjectReportSignature getReportSignatureById(String id);

    /**
     * 新增签章附件信息
     * @param cwProjectReportFile
     */
    @InterceptorIgnore(tenantLine = "true")
    void insertProjectReportFile(CwProjectReportFile cwProjectReportFile);

    List<String> getIdByProjectId(@Param("id") String id);

    List<String> getIdByClientId(@Param("id") String id);

    List<String> getIdByContractId(@Param("id") String id);

    List<CwProjectReport> getByIds(@Param(Constants.WRAPPER) QueryWrapper<CwProjectReport> queryWrapper);

    /**
     * 根据报告类型查询指定下一个审核人信息
     * @param name 类型值
     * @return
     */
    List<ReviewUser> getReviewByS(String name);

    /**
     * 根据报部门id和岗位名称查询用户信息
     * @param postName
     * @return
     */
    @InterceptorIgnore(tenantLine = "true")
    List<ReviewUser> getReviewByPost(@Param("postName") String postName);

    @InterceptorIgnore(tenantLine = "true")
    List<WorkAttachmentInfo> findDtos(@Param("id") String id);

    @InterceptorIgnore(tenantLine = "true")
    CwProjectReport getByNewLineId(String reportId);

    /**
     * 根据项目id查询委托方名称
     * @param id
     * @return
     */
    String getServedUnitName(String id);

    String getOfficeId(String name);

    /**
     * 根据部门名称查询和部门相关的部门id
     * （该部门和该部门子部门id）
     * @param name
     * @return
     */
    String getCorrelationOfficeIdByName(String name);

    /**
     * 根据id修改报告的盖章类型
     * @param cwProjectReportData
     */
    void updateSignatureTypeById(CwProjectReportData cwProjectReportData);

    /**
     * 删除已盖章的附件(报告签章附件关联表  cw_project_report_file)
     * @param id work_attachment表的id
     */
    void deleteIsSign(@Param("id")String id);

    /**
     * 根据附件id查询附件是否已盖章
     * @param id
     * @return
     */
    int checkIsSign(@Param("id")String id);

    /**
     * 根据报告id修改签字注师1、2,所属行业以及业务对象的值
     * @param cwProjectReport
     */
    void updateAnnotatorById(@Param("report")CwProjectReport cwProjectReport);

    void saveById(@Param("id")String id);

    @InterceptorIgnore(tenantLine = "true")
    void updateCwProjectReportDataById(CwProjectReport cwProjectReportData);

    @InterceptorIgnore(tenantLine = "true")
    CwProjectReport getById(@Param("id") String id);

    /**
     * 数据导入(临时)
     * @param reportNo
     * @return
     */
    @InterceptorIgnore(tenantLine = "true")
    CwProjectReport getReportByReportNo(@Param("reportNo") String reportNo);

    /**
     * 数据导入(临时)
     * @param reportNoList
     * @return
     */
    @InterceptorIgnore(tenantLine = "true")
    List<CwProjectReport> getReportInfoByNoList(@Param("reportNoList") List<String> reportNoList);

    void updatesigStatusById(CwProjectReport report);

    /**
     * 根据项目id获取委托方联系人信息
     * @param projectId
     * @return
     */
    List<ProjectContactInfo> getContactInfos(@Param("projectId") String projectId);

    /**
     * 将复核超期的数据状态改为超期未复核
     */
    void updateQualityOverdueStatus();

    /**
     * 将在线归档超期的数据状态改为超期未归档
     */
    void updateOnlineArchiveStatus();

    /**
     * 将纸质归档超期的数据状态改为超期未归档
     */
    void updatePaperArchiveStatus();

    List<String> getAllInfo();

    List<ProjectReportInfo> getProjectReportInfo(@Param("id") String id);

    /**
     * 归档信息导出数据查询
     * @return
     */
    List<ArchivedReportInfo> archivedInfoExport(@Param(Constants.WRAPPER) QueryWrapper<ArchivedReportInfo> queryWrapper);

    String getIdByNo(@Param("reportNo")String reportNo);
    //根据租户删除记录,仅用于删除ccpm系统中的数据
    void deleteByTenantId();

    void deleteByProjectId(@Param("id") String id);
}
