package com.jeeplus.finance.projectRecords.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.projectRecords.domain.CwProjectPlanDetails;
import com.jeeplus.finance.projectRecords.domain.CwProjectRecords;
import com.jeeplus.finance.projectRecords.domain.PartialCustomerInfo;
import com.jeeplus.finance.projectRecords.service.dto.CwProjectClientInfoDTO;
import com.jeeplus.finance.projectRecords.service.dto.CwProjectRecordsDTO;
import com.jeeplus.finance.projectRecords.service.dto.CwTreeUserDto;
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;

/**
 * 财务项目登记mapper
 * @author: 徐滕
 * @version: 2022-11-10 14:56
 */
@Mapper
public interface CwProjectRecordsMapper extends BaseMapper<CwProjectRecords> {
    /**
     * 查询项目数据集合
     * @param page
     * @param queryWrapper
     * @return
     */
    // @InterceptorIgnore(tenantLine = "true")
    IPage<CwProjectRecordsDTO> findList(Page<CwProjectRecordsDTO> page, @Param(Constants.WRAPPER) QueryWrapper<CwProjectRecords> queryWrapper);
    //获取所有的项目
    @InterceptorIgnore(tenantLine = "true")
    IPage<CwProjectRecordsDTO> getAllList(Page<CwProjectRecordsDTO> page, @Param(Constants.WRAPPER) QueryWrapper<CwProjectRecords> queryWrapper);

    IPage<PartialCustomerInfo> partialCustomerInfoList(Page<PartialCustomerInfo> page, @Param(Constants.WRAPPER) QueryWrapper<PartialCustomerInfo> queryWrapper);
    /**
     * 查询项目数据集合,和上面findList是一样的，目的是跳过findList接口的数据规则（比如仅部门可见、仅自己可见之类的）
     */
    IPage<CwProjectRecordsDTO> findList2(Page<CwProjectRecordsDTO> page, @Param(Constants.WRAPPER) QueryWrapper<CwProjectRecords> queryWrapper);
    /**
     * 根据id查询项目详情
     * @param id
     * @return
     */
    CwProjectRecordsDTO queryById(@Param("id") String id);

    /**
     * 根据项目id删除项目相关的所有被服务单位
     * @param projectId
     * @return
     */
    Integer deleteProjectClientInfoByProjectId(@Param("projectId") String projectId);

    /**
     * 保存被服务单位信息
     * @param cwProjectClientInfoList
     * @return
     */
    Integer insertProjectClientInfoList(@Param("cwProjectClientInfoList") List<CwProjectClientInfoDTO> cwProjectClientInfoList);

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

    List<CwProjectRecordsDTO> getProjectByIdList(@Param(Constants.WRAPPER) QueryWrapper<CwProjectRecords> queryWrapper);

    List<CwProjectRecordsDTO> getByContractId(@Param(Constants.WRAPPER) QueryWrapper<CwProjectRecords> queryWrapper);

    List<String> getHaveProjectIds(@Param("currentUser") UserDTO currentUser);

    List<String> isUseByReport(@Param("idArray")List<String> idArray);

    List<String> isUseByReim(@Param("idArray")List<String> idArray);

    List<String> isUseByFinance(@Param("idArray")List<String> idArray);

    @InterceptorIgnore(tenantLine = "true")
    void updatereportReviewById(CwProjectRecords records);

    @InterceptorIgnore(tenantLine = "true")
    List<CwProjectRecords> getListByIds(@Param("ids") List<String> ids);



    List<CwProjectRecordsDTO> getReportById(@Param("id") String id, @Param("cwProjectRecordsDTO") CwProjectRecordsDTO cwProjectRecordsDTO);

    List<CwProjectRecordsDTO> getReportByProjectId(@Param("id") String id,@Param("projectId")String projectId);

    /**
     * 查询所有的项目组成员id
     * @param id
     * @return
     */
    List<String> getMembersId(@Param("id") String id);

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

    CwProjectRecordsDTO queryPlanById(@Param("id")String id);

    List<CwProjectPlanDetails> findPlanList(@Param("id") String id);

    List<CwTreeUserDto> findOfficeList();

    List<CwTreeUserDto> findUserList(@Param("name") String name, @Param("s") String s);

    /**
     * 查询项目组成员id
     * @param id
     * @return
     */
    List<String> getMemberId(@Param("id") String id);

    List<CwProjectPlanDetails> getListByPlanId(@Param("planId") String planId);

    List<WorkAttachmentInfo> getFileList(@Param("id") String id);

    //获取任务阶段
    List<String> getTaskPhase();
    @InterceptorIgnore(tenantLine = "true")
    List<CwProjectPlanDetails> getPlanDetails();

    /**
     * 根据id修改项目等级
     * @param id
     * @return
     */
    void projectUpgrade( @Param("id") String id,@Param("level") String level);

    CwProjectRecordsDTO getInfoById(@Param("id") String id);

    //根据租户删除记录,仅用于删除ccpm系统中的数据
    void deleteByTenantId();
    //根据项目id删除项目信息
    void deleteInfoById(@Param("id")String id);
}
