package cn.cslg.pas.mapper;

import cn.cslg.pas.common.model.QueryPatentVO;
import cn.cslg.pas.common.model.dto.PatentQueryFieldSourceDTO;
import cn.cslg.pas.common.model.vo.PatentQueryFieldSourceVO;
import cn.cslg.pas.common.model.vo.PatentVO;
import cn.cslg.pas.domain.Patent;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

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

/**
 * <p>
 * 专利信息表 Mapper 接口
 * </p>
 *
 * @author 王岩
 * @since 2021-12-26
 */
public interface PatentMapper extends BaseMapper<Patent> {

    Integer getDateTime(String ids, String column, String type);

    Integer getDateTime2(String ids, Integer field, String type);

    List<Integer> getCustomFieldCount(@Param("ids") List<Integer> ids, @Param("field") Integer field, @Param("mino") String mino, @Param("maxo") String maxo, @Param("minv") Integer minv, @Param("maxv") Integer maxv);

    List<Integer> getCustomFieldTime(@Param("ids") List<Integer> ids, @Param("field") Integer field, @Param("startDate") Long startDate, @Param("endDate") Long endDate);

    @MapKey("id")
    Map<String, Object> getPatentListByIdAndColumn(Integer id, String column);

    IPage<Patent> getPageList(Page<Patent> page, @Param("params") PatentVO params);
    IPage<Patent> getPageListForRMS2(Page<Patent> page, @Param("params") QueryPatentVO params);
    List<String> getListForRMS( @Param("params")QueryPatentVO params);
    List<Patent> getPageList(@Param("params") PatentVO params);

    IPage<PatentQueryFieldSourceDTO> getPatentQuerySourcePageList(Page<Patent> page, @Param("params") PatentQueryFieldSourceVO params, @Param("ids") List<Integer> patentIds);

    List<PatentQueryFieldSourceDTO> getPatentQuerySourcePageList(@Param("params") PatentQueryFieldSourceVO params, @Param("ids") List<Integer> patentIds);

    @Select(" SELECT count(status) as count, status as label" +
            " FROM os_patent_affair A\n" +
            " where A.pid IN (SELECT op.id\n" +
            "                FROM os_patent op\n" +
            "                         LEFT JOIN os_thematic_pid c on c.pid = op.id\n" +
            "                where c.zid = #{projectId})\n" +
            " group by status ")
    List<PatentQueryFieldSourceDTO> getCountStatus(@Param("projectId") Integer projectId);
    List<Patent> getPatent(@Param("patentNo")List<String> patentNo,@Param("n")int n,@Param("p")int p);
    int getPatentNumber(@Param("patentNo")List<String> patentNo);
    List<String> getConPantentNos(@Param("params") QueryPatentVO params);
    List<Patent> getConPantents(@Param("params") QueryPatentVO params);

}

