package com.jeeplus.test.cw.projectReport.mapper;

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.sys.service.dto.UserDTO;
import com.jeeplus.test.cw.projectRecords.domain.CwProjectRecords;
import com.jeeplus.test.cw.projectRecords.service.dto.CwProjectRecordsDTO;
import com.jeeplus.test.cw.projectReport.domain.*;
import com.jeeplus.test.cw.workClientInfo.domain.CwWorkClientBase;
import com.jeeplus.test.cw.workClientInfo.service.dto.CwWorkClientBaseDTO;
import com.jeeplus.test.oss.domain.WorkAttachment;
import com.jeeplus.test.workContract.service.dto.WorkAttachmentDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

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

    /**
     * 查询报告数据集合
     * @param page
     * @param queryWrapper
     * @return
     */
    IPage<CwProjectReportData> findList(Page<CwProjectReportData> page, @Param("currentUser") UserDTO currentUser, @Param("isBmzr") String isBmzr, @Param("officeIds") String officeIds, @Param(Constants.WRAPPER) QueryWrapper<CwProjectReportData> queryWrapper);

    List<WorkAttachment> findFileList(@Param("id") String id);

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

    Integer deleteAttachement(@Param("id") String id,@Param("attachmentFlag") String attachmentFlag);

    CwProjectReportData queryById(@Param("id") String id);

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

    String getUserNameById(String id);

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

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

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

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

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

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

    List<CwProjectReportData> getContainDelByProjectId(String projectId);

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

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

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

    /**
     * 新增签章附件信息
     * @param cwProjectReportFile
     */
    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
     * @param officeId
     * @return
     */
    List<ReviewUser> getReviewByPost(@Param("postName") String postName);

    List<WorkAttachmentDto> findDtos(@Param("id") String id);

    CwProjectReport getByNewLineId(String reportId);

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

    String getOfficeId(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);
}
