package com.cool.store.dao;

import com.cool.store.dto.partner.AdvanceLineDTO;
import com.cool.store.dto.partner.PartnerInterviewInfoDTO;
import com.cool.store.dto.partner.SpecialDateRangeInterviewCountDTO;
import com.cool.store.entity.HyPartnerInterviewPlanDO;
import com.cool.store.mapper.HyPartnerInterviewPlanMapper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * @Author suzhuhong
 * @Date 2023/6/8 14:54
 * @Version 1.0
 */
@Repository
public class HyPartnerInterviewPlanDAO {

    @Resource
    HyPartnerInterviewPlanMapper hyPartnerInterviewPlanMapper;


    /**
     * 查询当前用户当天是否有面试
     * @param userId
     * @param currentDate
     * @return
     */
    public List<AdvanceLineDTO>  getCurrentDateInterviewCount(String userId, String currentDate, String endDate){
        if (StringUtils.isEmpty(userId)){
            return new ArrayList<>();
        }
        return hyPartnerInterviewPlanMapper.getCurrentDateInterviewCount(userId,currentDate,endDate);
    }

    /**
     * 查询指定日期面试数量 与未来7天面试数量
     * @param userId
     * @param currentDate
     * @param startTime
     * @param endTime
     * @return
     */
    public SpecialDateRangeInterviewCountDTO getInterviewCount(String userId, String currentDate, String startTime, String endTime){
        if (StringUtils.isEmpty(userId)){
            return new SpecialDateRangeInterviewCountDTO();
        }
        return hyPartnerInterviewPlanMapper.getInterviewCount(userId,currentDate,startTime,endTime);
    }


    /**
     * 当天还有几场面试
     * @param userId
     * @param currentDate
     * @return
     */
    public List<HyPartnerInterviewPlanDO> getInterviewPlanList(String userId, String currentTime,String currentDay){
        if (StringUtils.isEmpty(userId)){
            return new ArrayList<>();
        }
        return hyPartnerInterviewPlanMapper.getInterviewPlanList(userId,currentTime,currentDay);
    }

    /**
     * 工作台 招商经理 预约面试时间 合格资格面试 列表
     * @param userId
     * @param workflowStage
     * @param workflowStatus
     * @return
     */
    public List<PartnerInterviewInfoDTO> getPartnerInterviewInfoList(String userId, String workflowStage,String workflowStatus,Boolean filter){
        if (StringUtils.isEmpty(userId)){
            return Lists.newArrayList();
        }
        return hyPartnerInterviewPlanMapper.getPartnerInterviewInfoList(userId,workflowStage,workflowStatus,filter);
    }

    public  Long selectInterviewIdByLineId(Long lineId){
        if (lineId==null){
            return 0L;
        }
        return hyPartnerInterviewPlanMapper.selectInterviewIdByLineId(lineId);
    }

    /**
     * 根据线索表ID查询
     * @param lindIds
     * @return
     */
    public List<HyPartnerInterviewPlanDO> getHyPartnerInterviewPlanByLineIds(List<Long> lindIds){
        if (CollectionUtils.isEmpty(lindIds)){
            return Lists.newArrayList();
        }
        return hyPartnerInterviewPlanMapper.getHyPartnerInterviewPlanByLineIds(lindIds);
    }


    public  int updateLineId(String newPartnerId,Long newLineId,Long oldLineId){
        if (newLineId==null || Objects.isNull(oldLineId)){
            return 0;
        }
        return hyPartnerInterviewPlanMapper.updateLineId(newPartnerId,newLineId, oldLineId);
    }
}
