package com.yida.data.user.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yida.data.common.core.entity.CurrentUser;
import com.yida.data.common.core.entity.constant.FebsConstant;
import com.yida.data.common.core.entity.user.EduStudent;
import com.yida.data.common.core.entity.user.EduTeacherDept;
import com.yida.data.school.dto.transaction.ListBuyStudentDTO;
import com.yida.data.user.dto.ListStudentDTO;
import com.yida.data.user.dto.OutPageStudentDTO;
import com.yida.data.user.dto.PageStudentDTO;
import com.yida.data.user.dto.h5.BindStudentDTO;
import com.yida.data.user.excel.SelectStudentDormExportData;
import com.yida.data.user.vo.*;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

public interface EduStudentService extends IService<EduStudent> {

    /**
     * 查询学生列表数据
     */
    IPage<EduStudent> findStudentPage(PageStudentDTO dto);

    /**
     * 保存学生信息
     */
    EduStudent saveStudent(EduStudent EduStudent, CurrentUser currentUser, Boolean isWx);

    /**
     * 批量删除学生信息
     */
    void delStudentBatchIds(List<Long> studentIds, Boolean isWx);

    /**
     * 查询学生
     */
    EduStudent getStudent(Long studentId);

    /**
     * 查询学生
     */
    List<EduStudent> getStudentDeptByIds(List<Long> studentIdList);

    /**
     * 批量导入学生
     *
     * @param currentUser
     * @return
     */
    @Async(FebsConstant.ASYNC_POOL)
    void importStudent(String path, CurrentUser currentUser, Long schoolId, Long key, String filename);

    @Async(FebsConstant.ASYNC_POOL)
    void importCard(String path, CurrentUser currentUser, Long schoolId, Long key, String filename);

    Integer importStaffHeartbeat(String username, Long key);

    void importStudentUpdateType(MultipartFile file, Long schoolId);

    List<Map<String, String>> listImportKey(String username);

    List<EduStudent> listStudentByParent(Long parentId, String applyCode);

    /**
     * 初始化学生信息
     */
    void initStudent(List<EduStudent> studentList);

    StudentClassInfoVO getClassInfoByStudent(Long studentId, String parentMobile);

    void downloadTemplate(HttpServletResponse response, CurrentUser currentUser);

    void downloadCardTemplate(HttpServletResponse response, CurrentUser currentUser);

    List<String> getParentByPhoneAndSchoolId(List<String> phone, Long schoolId);

    /**
     * 查询未购买商品的学生
     *
     * @param dto
     * @return
     */
    Page<EduStudent> listNotBuyStudent(ListBuyStudentDTO dto);

    /**
     * 通过学生id 查询家长wxid
     *
     * @param studentId
     * @return
     */
    List<String> findParentWxId(List<Long> studentId);

    /**
     * 查询全部未购买学生
     *
     * @param listBuyStudentDTO
     * @return
     */
    List<EduStudent> listAllNotBuyStudent(ListBuyStudentDTO listBuyStudentDTO);

    /**
     * 通过学生们查询学生和家长信息
     *
     * @param studentIds
     * @return
     */
    List<ListParentByStudentIdsVO> listParentByStudentIds(List<Long> studentIds);

    /**
     * 同步企业微信学生数据
     */
    @Async(FebsConstant.ASYNC_POOL)
    void syncQywxStudent();

    /**
     * 查询学生列表
     */
    List<EduStudent> listStudent(ListStudentDTO dto);

    List<EduStudent> listStudentByClassId(ListStudentDTO dto);

    @Async
    void exportStudent(PageStudentDTO dto, String key);

    /**
     * 查询导出进度
     *
     * @param key 导出唯一标识
     * @return java.lang.Object
     * @author ZYJ
     * @date 2023/12/13 14:42
     */
    Object getStudentExportInfo(String key);

    DownLoadPicVO exportStudentPic(PageStudentDTO dto);

    /**
     * 查询学生关联的教师
     *
     * @param classId
     * @return
     */
    List<EduTeacherDept> listTeacherByStudentId(Long classId);

    /**
     * 学生分布情况
     *
     * @return
     */
    StaStudentVO staStudentDistribu(List<Long> schoolIds);

    /**
     * 根据学生表字段查询学生id信息
     *
     * @param eduStudent 查询条件
     * @return java.util.List<java.lang.Long>
     * @author ZYJ
     * @date 2022/3/29 9:31
     */
    List<Long> listBaseStudentIds(EduStudent eduStudent);

    /**
     * 根据学生表字段查询学生列表信息
     *
     * @param eduStudent 查询条件
     * @return java.util.List<com.yida.data.common.core.entity.user.EduStudent>
     * @author ZYJ
     * @date 2022/3/29 13:58
     */
    List<EduStudent> listBaseStudent(EduStudent eduStudent);

    /**
     * 易达app绑定学生
     *
     * @param dto h5绑定学生信息请求类
     * @author ZYJ
     * @date 2022/4/21 14:42
     */
    List<EduStudent> bindStudent(BindStudentDTO dto);


    List<Long> listDormIdsByDeptId(ListStudentDTO dto);


    /**
     * 单表查询学生信息
     *
     * @param eduStudent
     * @return
     */
    List<EduStudent> listBaseStudentNoJoin(EduStudent eduStudent);

    /**
     * 分页查询学生列表数据
     *
     * @param dto     分页查询学生列表数据请求类
     * @param request request
     * @return com.baomidou.mybatisplus.core.metadata.IPage<com.yida.data.user.vo.OutPageStudentVO>
     * @author ZYJ
     * @date 2023/2/20 16:41
     */
    IPage<OutPageStudentVO> listStudentOutPage(OutPageStudentDTO dto, HttpServletRequest request);

    /**
     * 更新学生缓存信息
     */
    @Async
    void updateStudentCache();

    List<EduStudent> selectStudent(PageStudentDTO dto);

    /**
     * 查询学生宿舍信息
     *
     * @param dormRoomIds                 宿舍id集合
     * @param selectStudentDormExportData 查询条件
     * @return java.util.List<com.yida.data.common.core.entity.user.EduStudent>
     * @author ZYJ
     * @date 2023/12/13 18:17
     */
    List<EduStudent> listStudentDorm(List<Long> dormRoomIds, SelectStudentDormExportData selectStudentDormExportData);
}
