
package org.sky.scientific.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.sky.core.tenant.annotation.TenantIgnore;
import org.sky.scientific.pojo.dto.TechnicianDTO;
import org.sky.scientific.pojo.entity.TechnicianEntity;
import org.sky.scientific.pojo.vo.TechnicianVO;

import java.util.HashMap;
import java.util.List;

/**
 * 技术人员花名册 Mapper 接口
 *
 * @author Kd
 * @since 2025-06-11
 */
public interface TechnicianMapper extends BaseMapper<TechnicianEntity> {

	/**
	 * 分页-按月
	 *
	 * @param page       分页参数
	 * @param technician 查询参数
	 * @return List<TechnicianVO>
	 */
	List<TechnicianVO> selectTechnicianPage(IPage<TechnicianVO> page, @Param("ew") TechnicianDTO technician);

	/**
	 * 分页-按年
	 * @param page
	 * @param technician
	 * @return
	 */
	List<TechnicianVO> selectByYear(IPage<TechnicianVO> page,@Param("ew") TechnicianDTO technician);

	TechnicianEntity selectByUnicodeAndYearAndMonth(@Param("unicode") String unicode, @Param("yearAndMonth") String yearAndMonth);

	String getUnicodeByNumberAndIdentityCard(@Param("number") String number, @Param("idCard") String idCard);

	Long getIdByNumberAndIdentityCard(@Param("number") String number, @Param("idCard") String idCard, @Param("yearAndMonth") String yearAndMonth);

	List<TechnicianEntity> selectByDateInterval(IPage page, @Param("param") HashMap<String,String> param);

	String getNameById(@Param("technicianId") Long technicianId);

	/**
	 * 批量删除
	 * @param list
	 * @return
	 */
	int batchDelete(@Param("unicodeList") List<String> unicodeList, @Param("yearAndMonth") String yearAndMonth);

	/**
	 * 年度科技人员汇总表
	 */
	@TenantIgnore
	List<TechnicianVO> niandugaokejirenyuanhuizongbiao(@Param("page") IPage<TechnicianVO> page, @Param("ew") TechnicianDTO dto);

	@TenantIgnore
	String getMaxUnicode();

	@Update("update kd_technician set department = #{departmentName} where department_id = #{departmentId}")
	int updateDepartment(@Param("departmentId") Long departmentId, @Param("departmentName") String departmentName);

	@Select("select name from kd_technician where unicode = #{unicode} and year_and_month = #{yearAndMonth} ")
	String getNameByUnicodeAndMonth(@Param("unicode") String unicode, @Param("yearAndMonth") String yearAndMonth);
}
