package com.chinaweal.aiccs.aiccs.abnormal.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
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.chinaweal.aiccs.aiccs.abnormal.entity.vo.DissentListVo;
import com.chinaweal.aiccs.aiccs.abnormal.entity.TSAbnList;
import com.chinaweal.aiccs.aiccs.abnormal.entity.dto.AbnormalTaskCountDto;
import com.chinaweal.aiccs.aiccs.abnormal.entity.dto.ReasonEntTypeDto;
import com.chinaweal.aiccs.common.base.entity.dto.task.UniTaskListDto;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 经营异常名录表 Mapper 接口
 * </p>
 *
 * @author <a href="https://blog.lroyia.top">lroyia</a>
 * @since 2021-01-19
 */
public interface TSAbnListMapper extends BaseMapper<TSAbnList> {

    /**
     * 个体工商户分页
     * @param page
     * @param tsAbnListModel
     * @return
     */
    IPage<TSAbnList> selectIndividualByPageList(IPage<TSAbnList> page, @Param("tsAbnListModel") TSAbnList tsAbnListModel);

    /**
     * 农合异常名录分页
     * @param page
     * @param tsAbnListModel
     * @return
     */
    IPage<TSAbnList> selectFarmerByPageList(IPage<TSAbnList> page, @Param("tsAbnListModel") TSAbnList tsAbnListModel);

    /**
     * 企业异常名录统计查询
     * @param page
     * @param tsAbnListModel
     * @return
     */
    IPage<TSAbnList> selectTSAbnByPageList(IPage<TSAbnList> page, @Param("tsAbnListModel") TSAbnList tsAbnListModel);

    //企业异常名录
    IPage<TSAbnList> removeselectByPagebnlist(IPage<TSAbnList> page, @Param("tsAbnListModel") TSAbnList tsAbnListModel, @Param("decorgArr")String[] decorgArr);

    //企业异常名录统计查询
    IPage<TSAbnList> removeIndividualByPagebnlist(IPage<TSAbnList> page, @Param("tsAbnListModel") TSAbnList tsAbnListModel, @Param("decorgArr")String[] decorgArr);

    //农合统计查询
    IPage<TSAbnList> removeFarmerByPagebnlist(IPage<TSAbnList> page, @Param("tsAbnListModel") TSAbnList tsAbnListModel, @Param("decorgArr")String[] decorgArr);

    TSAbnList selectPrpid( @Param("pripid")String pripid);

    //查询异常名录表里同一家企业所有记录
    List<TSAbnList> selectEntList(@Param("pripid") String pripid);


    //异常名录中 期限届满列入 查询
    IPage<TSAbnList> selectTSAbnByTimeoutByPage(IPage<TSAbnList> page,
                                                                  @Param("tsAbnListModel") TSAbnList tsAbnListModel,
                                                                  @Param("currentDate") Date currentDate);


    TSAbnList getTSAbnList(@Param("tsAbnListModel")TSAbnList tsAbnListModel,
                                     @Param("currentDate") Date currentDate);

    IPage<TSAbnList> selectAbnListByPage(IPage<TSAbnList> page, @Param("tsAbnListModel") TSAbnList tsAbnListModel);

    List<TSAbnList> selectLimitInfoByPripid(@Param("pripid")String pripid);

    //获取异常主体列表分页
    IPage<DissentListVo> getDissentListPage(Page<DissentListVo> page, @Param("customParamMap") Map<String,Object> customParamMap);

    //获取移出异议主体列表分页
    IPage<DissentListVo> getRemDissentListPage(Page<DissentListVo> page, @Param("customParamMap") Map<String,Object> customParamMap);

    /**
     * 统计移出名录的数据pripid
     * @param beginDate 统计开始范围日期
     * @return 统计结果
     * @author lroyia
     * @since 2021年3月17日 15:03:53
     */
    List<String> listRemovedPripid(@Param("beginDate") String beginDate);

    /**
     * 查询第一个异常经营名录
     * @param ew   查询参数包装
     * @return  查询结果
     * @author lroyia
     * @since 2021年3月23日 15:26:23
     */
    TSAbnList selectFirstAbnormalList(@Param(Constants.WRAPPER) Wrapper<TSAbnList> ew);

    /**
     * 列入异常名录原因与主体类型分类统计
     * @param params    查询参数
     * @return  统计结果
     * @author lroyia
     * @since  2021年4月20日 09:57:45
     */
    List<ReasonEntTypeDto> statisticSpeCauseAndEntType(@Param("params") Map<String, Object> params);

    /**
     * 异常名录待办统计
     * @param params    查询参数
     * @return  统计结果
     * @author lroyia
     * @since  2021年4月20日 09:57:45
     */
    List<AbnormalTaskCountDto> statisticAbnormalTaskCount(@Param("params") Map<String, Object> params);

    /**
     * 查询异常名录待办列表分页
     * @param page  分页参数
     * @param params    查询参数
     * @return  查询结果
     * @author lroyia
     * @since  2021年4月20日 10:28:14
     */
    IPage<UniTaskListDto> selectAbnormalTaskListPage(IPage<UniTaskListDto> page, @Param("params") Map<String, Object> params);

    /**
     * 查询一年内有因实地查无移出记录的企业
     * @param pripid
     * @return
     */
    List<TSAbnList> queryTSAbnByREMDATE(@Param("pripid") String pripid);

    TSAbnList queryOneByPripid(String pripid);

    List<TSAbnList> getTSAbnListByMap(@Param("params")Map<String, Object> parm);

    TSAbnList selectTsAbnbyMap(@Param("params")Map<String, Object> paramAbn);

    TSAbnList queryByAbnlistid(@Param("abnlistid")String abnlistid);

    IPage<TSAbnList> selectTSAbnListByPageList(IPage<TSAbnList> page, @Param("params")Map<String, Object> pram);

    List<TSAbnList> selectAbnListByPripid(@Param("pripid")String pripid,@Param("newAbnTime")String newAbnTime,@Param("abnTime")String abnTime);

    List<TSAbnList> selectCancelEntList();

    List<TSAbnList> selectDeregEntList();

    IPage<String> selectByRemDate(IPage<String> page, @Param("params")Map<String, Object> params);

    List<String> selectByRemDate(@Param("params")Map<String, Object> params);

    TSAbnList queryByPripidAndDate(String pripid, String date);

    List<Map<String, String>> statistics(@Param("bizseqs")List<String> bizseqs);

    Boolean saveAbnBatch(List<TSAbnList> list);

    int checknb(@Param("entityno")String entityno, @Param("reportYear") String reportYear);
}
