package com.lz.modules.flow.dao;
/**
* <p>
* 流转记录表 服务类
* </p>
*
* @author quyixiao
* @since 2020-08-18
*/
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lz.modules.flow.entity.FlowRecord;
import com.lz.modules.performance.dto.TaskListDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface FlowRecordMapper extends BaseMapper<FlowRecord> {


	FlowRecord selectFlowRecordById(@Param("id")Long id);


	Long insertFlowRecord(FlowRecord flowRecord);


	int updateFlowRecordById(FlowRecord flowRecord);


	int updateCoverFlowRecordById(FlowRecord flowRecord);


	int deleteFlowRecordById(@Param("id")Long id);


    FlowRecord selectLastFlowRecordByRecordId(@Param("recordId") Long recordId);

    FlowRecord selectNotApprovalStaffIdFlowRecords(@Param("recordId") Long recordId);

	List<FlowRecord> selectFlowRecordByRecordId(@Param("recordId") Long recordId);

	List<FlowRecord> selectFlowRecordByResultRecordIdFlowId(@Param("recordId") Long recordId);

	List<FlowRecord> selectFlowRecordByFlowId(@Param("recordId") Long recordId);

	FlowRecord selectLastFlowNoStatusRecordByRecordId(@Param("recordId") Long recordId);

	List<FlowRecord> selectFlowRecordByResultRecordIdType(@Param("resultRecordId") Long resultRecordId, @Param("type") Integer type);

    List<FlowRecord> selectFlowRecordByResultRecordIdTypeStatus(@Param("recordResultId") Long recordResultId, @Param("type") Integer type, @Param("status") int status);

	Long copyFlowRecord(FlowRecord flowRecord);

	//查看自己要审批的记录 status为1代表流程走到了这里
	List<TaskListDto> selectTodoTasksByApprovalStaffId(@Param("approvalStaffId") Long approvalStaffId, @Param("page") IPage page);

	List<TaskListDto> selectFinishTasksByApprovalStaffId(@Param("approvalStaffId") Long approvalStaffId, @Param("page") IPage page);

    void insertFlowRecords(@Param("flowRecords") List<FlowRecord> flowRecords);


	List<FlowRecord> selectFlowRecordByRecordIdStatus(@Param("resultRecordId") Long resultRecordId, @Param("status") Integer status);

	FlowRecord selectFlowRecordByRecordIdAndFlowId(@Param("resultRecordId") Long resultRecordId, @Param("flowId") Long flowId);

	List<FlowRecord> selectFlowRecordByRecordIdStatusFlowIndex(@Param("resultRecordId") Long resultRecordId, @Param("status") int status, @Param("flowIndex") int flowIndex);


	FlowRecord selectPreFlowRecordByRecordIdMaxIdStatus(@Param("resultRecordId") Long resultRecordId, @Param("id") Long id, @Param("status") int status);

	List<FlowRecord> selectFlowRecordByRecordIdFlowIndex(@Param("resultRecordId") Long resultRecordId, @Param("flowIndex") Integer flowIndex);

	List<FlowRecord> selectFlowRecordByResultRecordId(@Param("resultRecordId") Long resultRecordId);

	FlowRecord selectFlowRecordByRecordIdMinIdStatus(@Param("resultRecordId") Long resultRecordId, @Param("id") Long id, @Param("status") int status);

	int batchUpdateSkip(@Param("recordIds")List<Long> recordIds);

    List<FlowRecord> selectFlowRecordByRecordIdFlowProcess(@Param("id") Long id, @Param("flowProcess") int flowProcess);

	int batchDeleteByRecordIds(@Param("recordIds")List<Long> recordIds);

    List<FlowRecord> selectAndOrFlowRecordsById(@Param("flowRecordId") Long flowRecordId, @Param("recordId") Long recordId);

	List<FlowRecord> selectLastFlowRecordsById(@Param("recordId") Long recordId);

	List<FlowRecord> selectLastFlowRecordsByIdAndFlowIndex(@Param("recordId") Long recordId, @Param("flowIndex") int flowIndex, @Param("status") int status);

    List<FlowRecord> selectSkipFlowRecordsById(@Param("recordId") Long recordId);

	List<FlowRecord> selectFirstFlowRecordsByIdAndFlowIndex(@Param("recordId") Long recordId, @Param("flowIndex") int flowIndex, @Param("status") int status);

    List<FlowRecord> selectFlowRecordsByRecordIdAndStatus(@Param("recordId") Long recordId, @Param("status") int status);

	List<FlowRecord> selectFlowRecordByRecordIdGeFlowIndex(@Param("recordId") Long recordId, @Param("flowIndex") Integer flowIndex);

	List<FlowRecord> selectFlowRecordByRecordIdLeFlowIndex(@Param("recordId") Long recordId, @Param("flowIndex") Integer flowIndex);

	void deleteFlowRecordByRecordId(@Param("recordId") Long recordId);

	void updateFlowRecordIdById(@Param("id") Long id, @Param("newId") Long newId);

	FlowRecord selectPreFlowRecordByRecordIdMinIdStatusList(@Param("recordId") Long recordId, @Param("flowIndex") Integer flowIndex, @Param("statusList") List<Integer> statusList);

	List<FlowRecord> selectFlowRecordByRecordIdFlowIndexStatusList(@Param("recordId") Long recordId, @Param("flowIndex") Integer flowIndex, @Param("statusList") List<Integer> statusList);

    List<FlowRecord> selectFlowRecordByRecordIdsFlowProcess(@Param("recordIds") List<Long> recordIds, @Param("flowProcess") Long flowProcess);

	List<FlowRecord> selectFlowRecordByRecordIdsStatus(@Param("recordIds") List<Long> recordIds, @Param("status") int status);
}