/*
 *    Copyright (c) 2018-2025, hnqz All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: hnqz
 */

package com.qunzhixinxi.hnqz.admin.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qunzhixinxi.hnqz.admin.entity.WmReport;
import com.qunzhixinxi.hnqz.admin.entity.WmScorePackage;
import com.qunzhixinxi.hnqz.admin.entity.WmTask;
import com.qunzhixinxi.hnqz.common.data.datascope.DataScopeMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * 任务表
 *
 * @author gaoyanng
 * @date 2020-06-25 23:35:25
 */
@Mapper
public interface WmTaskMapper extends DataScopeMapper<WmTask> {
	public IPage<WmTask> selectListByExtEnt(Page page, @Param("query") WmTask wmTask);

	public IPage<WmTask> selectListByRelationScoreId(Page page, @Param("query") WmTask wmTask);

	public List<WmTask> selectListByExtEntNoPage(@Param("query") WmTask wmTask);

	public List<Map<String, Object>> selectZbCount(@Param("query") WmTask wmTask);

	public List<Map<String,Object>> getTaskListByPackageIds(@Param("query") WmTask wmTask);

	public List<Map<String,Object>> getTaskListByPackageIdsForJs(@Param("query") WmTask wmTask);

	public List<Map<String,Object>> getTaskListByPackageIdsForJsUser(@Param("query") WmTask wmTask);

	public List<Map<String,Object>> getTaskListByPackageIdsCount(@Param("query") WmTask wmTask);

	public List<Map<String,Object>> getTaskListByPackageIdsAndUser(@Param("query") WmTask wmTask);

	public List<Map<String,Object>> getTaskListByPackageIdsZd(@Param("query") WmTask wmTask);

	public List<WmTask> getTaskListByPackageIdsReturnWmtaskInfo(@Param("query") WmTask wmTask);

	public List<WmTask> selectListByWmTask(@Param("query")WmScorePackage wmScorePackage);

	public IPage<Map<String,Object>> getH5PackageList(Page page, @Param("query") WmTask wmTask);

	public IPage<Map<String,Object>> getH5TaskList(Page page, @Param("query") WmTask wmTask);

	List<Map<String, Object>> selectByWmTaskOne(@Param("query") WmTask wmTask);
	List<Map<String, Object>> selectByWmTaskSecond(@Param("query") WmTask wmTask);
	List<Map<String, Object>> selectByWmTaskDrug(@Param("query") WmTask wmTask);
	List<Map<String, Object>> selectByReportOneApprovalStatus(@Param("query") WmTask wmTask);
	List<Map<String, Object>> selectByReportSecondApprovalStatus(@Param("query") WmTask wmTask);
	List<Map<String, Object>> selectByReportDrugApprovalStatus(@Param("query") WmTask wmTask);

	List<WmTask> selectByWmTaskId(@Param("query") WmTask wmTask);

	int selectById(@Param("query") Long id);

	WmTask selectByRealFlag(Integer id);

	WmTask selectWmTaskById(@Param("query") WmTask wmTask);
	List<Map<String, Object>> saveAndUpdateWmTask(@Param("query") WmTask wmTask, WmReport wmReport);

	List<WmTask> selectListByIds(@Param("query") WmTask wmTask);

	List<WmTask> selectListByScorePackageId(@Param("query") WmTask wmTask);

	public Page<WmTask> selectList(Page page, QueryWrapper wrappers);

	 List<WmTask> selectByTask(@Param("query") WmTask wmTask);


	 List<Map<String,Object>> getTaskListByIdsCount(@Param("query") WmTask wmTask);

	 List<Map<String,Object>> getTaskListByIds(@Param("query") WmTask wmTask);

	List<Map<String,Object>> getTaskListByIdsOld(@Param("query") WmTask wmTask);


	List<Map<String,Object>> getTaskListByIdsJs(@Param("query") WmTask wmTask);

	 List<WmTask> getTaskListByIdsReturnWmtaskInfo(@Param("query") WmTask wmTask);

	 List<Map<String,Object>> getTaskListByIdsZd(@Param("query") WmTask wmTask);

	List<Map<String,Object>> getTaskListByIdsZdJs(@Param("query") WmTask wmTask);

	 IPage<WmTask> getWmTaskList(Page page, @Param("query") WmTask wmTask);

	List<Map<String,String>> PackageIsFinishByTask(@Param("query") WmTask wmTask);

	Map<String, Timestamp> getMaxCreateTime(@Param("query") WmTask wmTask);

	IPage<Map<String,Object>> selectSettleTask(Page page, @Param("query") WmTask wmTask);

	/**
	 * 查询用户审核中和审核通过的积分
	 * @param userId 用户id
	 * @param startTime 开始时间
	 * @param endTime 截止时间
	 * @return 任务积分值和
	 */
	int getUserTaskSubScore(@Param("userId")String userId, @Param("startTime")LocalDateTime startTime, @Param("endTime")LocalDateTime endTime);

	/**
	 * 发包方审核时候只校验审核通过的分数
	 * @param userId 用户id
	 * @param startTime 开始时间
	 * @param endTime 截止时间
	 * @return 任务积分值和
	 */
	int newGetUserTaskSubScore(@Param("userId")String userId, @Param("startTime")LocalDateTime startTime, @Param("endTime")LocalDateTime endTime);

	/**
	 * 患者教育-处方列表
	 *
	 * @param page 分页条件
	 * @param scorePackageId 积分包id
	 * @param prescriptionNo 处方单编号
	 * @return 处方列表分页
	 */
	IPage<WmTask> listTaskPrescriptionPage(Page page, @Param("scorePackageId") String scorePackageId, @Param("prescriptionNo") String prescriptionNo);

	/**
	 * 患者教育-处方列表
	 *
	 * @param scorePackageId 积分包id
	 * @param prescriptionNo 处方单编号
	 * @return 处方列表
	 */
	List<WmTask> listTaskPrescription(@Param("scorePackageId") String scorePackageId, @Param("prescriptionNo") String prescriptionNo);

	/**
	 * 查询调查信息审核列表
	 *
	 * @param wmTask
	 * @param startDate
	 * @param endDate
	 * @return
	 */
	IPage<WmTask> listInfoAudit(Page page, @Param("query") WmTask wmTask, @Param("startDate") LocalDateTime startDate, @Param("endDate") LocalDateTime endDate);

	/**
	 * 查询同一家医院一个月做的任务
	 *
	 * @param hospitalId
	 * @return
	 */
	List<WmTask> listCurrentMonthHospitalTask(@Param("hospitalId") String hospitalId);

	/**
	 * 查询会议任务个数
	 *
	 * @param taskTypeList 任务类型列表
	 * @param taskUserId 用户id
	 * @param startTime 会议时间范围-开始
	 * @param endTime 会议时间范围-结束
	 * @return 会议任务个数
	 */
	Long countMeetingTask(@Param("taskTypeList") List<String> taskTypeList, @Param("taskUserId") String taskUserId,
						  @Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
}
