package com.yeejoin.amos.patrol.business.dao.mapper;

import com.yeejoin.amos.patrol.business.dto.PlanTaskStaticDto;
import com.yeejoin.amos.patrol.business.dto.StaticTableUpdateDto;
import com.yeejoin.amos.patrol.business.entity.mybatis.CheckChkExListBo;
import com.yeejoin.amos.patrol.business.entity.mybatis.PlanTaskPointInputItemBo;
import com.yeejoin.amos.patrol.business.entity.mybatis.PointCheckDetailBo;
import com.yeejoin.amos.patrol.business.param.CheckPtListPageParam;
import com.yeejoin.amos.patrol.business.param.PlanTaskPageParam;
import com.yeejoin.amos.patrol.business.vo.CodeOrderVo;
import com.yeejoin.amos.patrol.business.vo.LeavePlanTaskVo;
import com.yeejoin.amos.patrol.business.vo.PlanTaskVo;
import com.yeejoin.amos.patrol.core.common.response.AppCheckInputRespone;
import com.yeejoin.amos.patrol.dao.entity.*;
import org.apache.ibatis.annotations.Param;

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

public interface PlanTaskMapper extends BaseMapper {
	/**
	 * 统计-计划执行
	 *
	 * @param params
	 * @return
	 */
	long countPlanTask(PlanTaskPageParam params);

	/**
	 * 计划执行查询
	 *
	 * @param params
	 * @return
	 */
	List<HashMap<String, Object>> getPlanTaskInfo(PlanTaskPageParam params);

	/**
	 * 批量删除
	 *
	 * @param strArry
	 */
	void planTaskDet(String[] strArry);

	/**
	 * 更新任务表
	 *
	 * @param param
	 */
	void updatePlanTaskPtInfo(HashMap<String, Object> param);

	/**
	 * 查询需删除的任务信息列表
	 *
	 * @param param
	 * @return
	 */
	List<String> getGenPlanTask(HashMap<String, Object> param);

	void deleteAllById(@Param("ids") List<String> ids);
	/**
	 * 根据路线id获取关联的计划任务
	 *
	 * @param routeId
	 * @return
	 */
	List<PlanTask> getPlanTaskByRouteId(@Param(value = "routeId") Long routeId);

	/**
	 * 根据巡检点id获取关联的计划任务
	 *
	 * @param routeId
	 * @return
	 */
	List<HashMap<String, Object>> getPlanTaskByPointId(HashMap<String, Object> param);

	/**
	 * 根据条件查询计划任务列表
	 *
	 * @param params
	 * @return
	 */
	List<Map<String, Object>> getPlanTasks(HashMap<String, Object> params);

	/**
	 * 通过计划任务Id获得计划任务信息
	 *
	 * @param planTaskId
	 * @return
	 */
	Map queryPlanTaskById(@Param(value = "planTaskId") Long planTaskId);

	/**
	 * 通过计划任务Id获取任务所有点信息
	 *
	 * @param planTaskId
	 * @return
	 */
	List getPlanTaskPoints(@Param(value = "planTaskId") Long planTaskId);

	/**
	 * 获取用户当前所有可以做的任务个数
	 *
	 * @param userId
	 * @return
	 */
	int getCurrentPlanTaskCount(@Param(value = "userId") String userId);

	/**
	 * 根据计划任务id获取所有巡检项信息
	 *
	 * @param planTaskId
	 * @return
	 */
	List<PlanTaskPointInputItemBo> getPlanTaskPointInputItemByPlanTaskId(@Param(value = "planTaskId") Long planTaskId,
																		 @Param(value = "planTaskDetailStatus") String planTaskDetailStatus,
																		 @Param(value = "planTaskDetailIsFinish") String planTaskDetailIsFinish);

	/**
	 * 条件查询数据
	 *
	 * @param param
	 * @return
	 */
	List<PlanTaskVo> getPlanTaskInfoList(PlanTaskPageParam param);

	/**
	 * 根据ids获取执行计划
	 *
	 * @param ids
	 * @return
	 */
	List<PlanTaskVo> getPlanTaskListByIds(@Param("ids") Long[] ids);

	/**
	 * 分页统计
	 *
	 * @param param
	 * @return
	 */
	long countChkExListData(CheckPtListPageParam param);

	long countChkExListDataNew(CheckPtListPageParam param);

	/**
	 * 今日执行情况，业务信息查询
	 *
	 * @param param
	 * @return
	 */
	List<CheckChkExListBo> getChkExList(CheckPtListPageParam param);

	List<CheckChkExListBo> getChkExListNew(CheckPtListPageParam param);

	/**
	 * 任务分页查询数量
	 *
	 * @param params 参数
	 * @return long
	 */
	long getPlanTasksCount(HashMap<String, Object> params);

	Map<String, Object> getPlanTaskStatisticsForApp(HashMap<String, Object> params);


	/**
	 * 根据计划id和点id获取点详情
	 *
	 * @param planTaskId
	 * @param pointId
	 * @return
	 */
	PointCheckDetailBo getPointPlanTaskInfo(@Param("planTaskId") Long planTaskId, @Param("pointId") Long pointId);

	/**
	 * 根据路线id和点id获取该点的检查项
	 *
	 * @param routeId
	 * @param pointId
	 * @return
	 */
	List<PointCheckDetailBo> getPointInputByRouteIdAndPointId(@Param("routeId") Long routeId, @Param("pointId") Long pointId);

	/**
	 * 统计当日任务累计完成情况
	 *
	 * @param loginOrgCode
	 * @return
	 */
	String getCumulativePlanCountByOrgCode(@Param("orgCode") String loginOrgCode);

	/**
	 * 获取用户离线巡检计划任务信息
	 *
	 * @param params
	 * @return
	 */
	List<LeavePlanTaskVo> queryLeavePlanTask(HashMap<String, Object> params);

	/**
	 * 根据路线id与点id，获取路线点项
	 *
	 * @param routeId
	 * @param pointId
	 * @return
	 */
	List<PointInputItem> getRoutePointInputItem(@Param(value = "routeId") long routeId, @Param(value = "pointId") long pointId);


	List<CodeOrderVo> queryCodeOrderVo(HashMap<String, Object> params);

	/**
	 * 重新统计用户重做日期段内计划任务
	 *
	 * @param userId
	 * @param refDate
	 * @param orgCode
	 */
	void reformStatistics(@Param(value = "userId") String userId, @Param(value = "refDate") String refDate, @Param(value = "orgCode") String orgCode);

	List<Map<String, Object>> countFinishByPlanIds(List<Long> planIds);

	List<Map<String, Object>> queryPlanTaskTimeAxis(HashMap<String, Object> params);

	List<Map<String, Object>> queryTimeAxis(HashMap<String, Object> params);

	List<Plan> getPlanIdsByDate(@Param("date") Date date);

	List<PlanTask> getPlanTaskList(@Param("date") Date date);

	/**
	 * 消防巡检信息统计
	 *
	 * @param bizOrgCode 业务公司编码
	 * @return 消防巡检信息统计
	 */
    List<Map<String, Object>> firePatrolStatics(@Param("bizOrgCode") String bizOrgCode);

	long countData(@Param(value = "param") PlanTaskPageParam param);

	List<HashMap<String, Object>> planTaskPage(@Param(value = "param") PlanTaskPageParam param);

	Map<String, Object> getPlanTaskBasicInfo(@Param(value = "taskDetailId") String taskDetailId);

	Map<String, Object> getPlanTaskExecuteInfo(@Param(value = "taskDetailId") String taskDetailId);

	List<String> getDefinitionObjCode(@Param(value = "taskDetailId") String taskDetailId);

	Map<String, Object> getDefectEquipInfo(@Param(value = "id") String id);

	List<Map<String, Object>> getCheckMissedEquipInfo(@Param(value = "taskDetailId") String taskDetailId);

	List<Map<String, Object>> getCheckQualifiedEquipInfo(@Param(value = "taskDetailId") String taskDetailId);

	List<Map<String, Object>> getCheckNotQualifiedEquipInfo(@Param(value = "taskDetailId") String taskDetailId);

	String getCheckIdByDetailId(@Param(value = "taskDetailId") String taskDetailId);

	String queryByCompanyCode(@Param("companyCode") String companyCode);

	List<Map<String, Object>> getStatics(@Param("bizOrgCode") String bizOrgCode);

	Map<String, Object> queryPatrolInfoList(@Param(value = "bizOrgCode") String bizOrgCode, @Param(value = "startDate") Date startDate, @Param(value = "endDate") Date endDate);

	Map<String, Object> queryPatrolEquipInfo(@Param(value = "bizOrgCode") String bizOrgCode, @Param(value = "startDate") Date startDate, @Param(value = "endDate") Date endDate);

	List<Long> getPlanTaskListByPlanId(long planId, int finishStatus);

	List<PlanTask> getPlanTaskTListByPlanId(long planId, int finishStatus);

	void updatePlanTaskByPlanId(@Param(value = "ids") List<Long> ids, int finishStatus);

	void updatePlanTaskDetailsByPlanId(@Param(value = "ids") List<Long> ids);

    List<PlanTask> getInitPlanTaskList();

	void updatePlanTaskList(List<String> ids, int newStatus);

	List<String> selectPlanTaskIdList(long planId, int oldStatus);

	List<PlanTaskDetail> selectTaskDetails(String ids);

	Map<String, Object> selectTaskStatus(Long planTaskId);

	void updatePlanTaskList(long planId, int oldStatus, int newStatus);

	List<PlanTask> findPlanTask();

	List<PlanTaskDetail> findPlanTaskDetail();

	List<Check> findCheck();

	List<CheckInput> findCheckInput();

	List<CheckShot> findCheckShot();

	List<StaticDay> findStaticDay();

	List<StaticDay> findStaticWeek();

	void insertAll(String table, StaticDay item);

	void updateData(String table, @Param(value = "list") List<StaticDay> list);

	void updateSingle(String table, int riskEnd, int noRiskEnd, String orgCode, String checkTime);


	int deleteDate(String table);

	int deleteOne(String table, String checkDate);

	Long selectRoutId(String id);

	List<String> selectPlanTaskIdLists(long planId, int status, int status1);

	List<PlanTask> selectTaskList(@Param(value = "ids") List<String> ids);

	List<PlanTaskStaticDto> queryPlanTaskStaticById(@Param(value = "planTaskIds") String planTaskIds);

	List<ESTaskDetailDto> selectTaskDetailList(@Param(value = "ids") String ids);

	List<ESTaskDetailDto> selectTaskInfoList(@Param(value = "id") long id);

	List<AppCheckInputRespone> selectPointInputs(@Param(value = "routeId") Long routeId);

	List<String> getPlanTaskIds(@Param(value = "id") long id);

	List<Map<String, String>> selectExcludeItemsByRoutId(long routeId);

	void updateStaticTableBatch(@Param("list") List<StaticTableUpdateDto> staticTableUpdateDtos);

}
