/*
 *    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.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.baomidou.mybatisplus.extension.service.IService;
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.admin.entity.WmTaskContent;
import com.qunzhixinxi.hnqz.admin.entity.dto.CommonEvidenceDTO;
import com.qunzhixinxi.hnqz.common.core.util.R;
import org.apache.ibatis.annotations.Param;

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

/**
 * 任务表
 *
 * @author gaoyanng
 * @date 2020-06-25 23:35:25
 */
public interface WmTaskService extends IService<WmTask> {
	public List<WmTask> listTask(QueryWrapper wrappers);

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

	public Page<WmTask> listTaskPage(Page page, LambdaQueryWrapper<WmTask> wrappers);


	public IPage<WmTask> listTaskByExt(Page page, WmTask wmTask);

	public IPage<WmTask> listTaskByExt1(Page page, WmTask wmTask);

	public List<WmTask> listTaskByExtNoPage(WmTask wmTask);

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

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

	public List<Map<String, Object>> getTaskListByPackageIds(WmTask wmTask);

	public List<Map<String, Object>> getTaskListByPackageIdsForJs(WmTask wmTask);

	public R selectZbCount(WmTask wmTask);

	public List<Map<String, Object>> getTaskListByPackageIdsForJsUser(WmTask wmTask);

	public List<Map<String, Object>> getTaskListByPackageIdsCount(WmTask wmTask);

	public List<Map<String, Object>> getTaskListByPackageIdsAndUser(WmTask wmTask);

	public List<Map<String, Object>> getTaskListByPackageIdsZd(WmTask wmTask);

	public List<WmTask> getTaskListByPackageIdsReturnWmtaskInfo(WmTask wmTask);

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

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

	R selectByWmTask(WmTask wmTask);

	R selectByWmTaskId(WmTask wmTask);

	R saveAndUpdateWmTask(WmTask wmTask, WmReport wmReport);

	R saveAndUpdateWmReport(WmTask wmTask, WmReport wmReport);

	public R selectList(Page page, WmScorePackage wmScorePackage);

	public List<Map<String, Object>> getTaskListByIdsCount(WmTask wmTask);

	List<Map<String, Object>> getTaskListByIds(WmTask wmTask);

	List<Map<String, Object>> getTaskListByIdsOld(WmTask wmTask);

	List<Map<String, Object>> getTaskListByIdsJs(WmTask wmTask);

	public List<WmTask> getTaskListByIdsReturnWmtaskInfo(WmTask wmTask);

	public List<Map<String, Object>> getTaskListByIdsZd(WmTask wmTask);

	public List<Map<String, Object>> getTaskListByIdsZdJs(WmTask wmTask);


	R getWmTaskList(Page page, WmTask wmTask);

	R approvalTask(WmTask wmTask);

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

	R saveTaskSettle(WmTask wmTask);

	/**
	 * 患者教育-处方上传
	 *
	 * @param wmTask 任务对象
	 * @return 是否成功状态
	 */
	R saveTaskPrescription(WmTask wmTask);

	R updateTaskSettle(WmTask wmTask);

	IPage<Map<String, Object>> selectSettleTask(Page page, WmTask wmTask);

	Boolean checkUserTaskSubScore(String userId);

	Boolean newCheckUserTaskSubScore(String userId, LocalDate createDate);

	R getTaskInfo(String taskId);

	/**
	 * 查询调查信息审核数据
	 *
	 * @param taskId 任务id
	 * @return
	 */
	R<?> getSurveryTaskInfo(String taskId);

	/**
	 * 患者教育-处方删除
	 *
	 * @param id 实际为WmTaskContent的id
	 * @return 是否成功状态
	 */
	Boolean deleteTaskPrescription(Integer id);

	/**
	 * 证据链批量上传
	 *
	 * @param commonEvidenceDTOMap 通用证据链DTO map
	 * @param packageName          当前积分包名称
	 * @return 错误证据链编号
	 */
	Map<String, String> taskBatchImport(Map<String, List<CommonEvidenceDTO>> commonEvidenceDTOMap,
										String packageName);

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

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

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