package com.inspect.exec.service.impl;

import com.inspect.exec.domain.PatrolTaskExecRecord;
import com.inspect.exec.mapper.PatrolTaskExecRecordMapper;
import com.inspect.exec.service.IPatrolTaskExecRecordService;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PatrolTaskExecRecordServiceImpl implements IPatrolTaskExecRecordService {
    private final PatrolTaskExecRecordMapper patrolTaskExecRecordMapper;

    @Autowired
    public PatrolTaskExecRecordServiceImpl(PatrolTaskExecRecordMapper patrolTaskExecRecordMapper) {
        this.patrolTaskExecRecordMapper = patrolTaskExecRecordMapper;
    }

    public PatrolTaskExecRecord selectPatrolTaskExecRecordByTaskPatrolId(String taskPatrolId) {
        return patrolTaskExecRecordMapper.selectPatrolTaskExecRecordByTaskPatrolId(taskPatrolId);
    }

    public List<PatrolTaskExecRecord> selectPatrolTaskExecRecordList(PatrolTaskExecRecord patrolTaskExecRecord) {
        return patrolTaskExecRecordMapper.selectPatrolTaskExecRecordList(patrolTaskExecRecord);
    }

    public int insertPatrolTaskExecRecord(PatrolTaskExecRecord patrolTaskExecRecord) {
        PatrolTaskExecRecord taskExecRecord =
                patrolTaskExecRecordMapper.selectPatrolTaskExecRecordByTaskPatrolId(patrolTaskExecRecord.getTaskPatrolId());
        return taskExecRecord != null ? 0 :
                patrolTaskExecRecordMapper.insertPatrolTaskExecRecord(patrolTaskExecRecord);
    }

    public int updatePatrolTaskExecRecord(PatrolTaskExecRecord patrolTaskExecRecord) {
        return patrolTaskExecRecordMapper.updatePatrolTaskExecRecord(patrolTaskExecRecord);
    }

    public int deletePatrolTaskExecRecordByTaskPatrolIds(String[] taskPatrolledIds) {
        return patrolTaskExecRecordMapper.deletePatrolTaskExecRecordByTaskPatrolIds(taskPatrolledIds);
    }

    public int deletePatrolTaskExecRecordByTaskPatrolId(String taskPatrolledId) {
        return patrolTaskExecRecordMapper.deletePatrolTaskExecRecordByTaskPatrolId(taskPatrolledId);
    }

    public List<PatrolTaskExecRecord> selectCameraPatrolTaskExecRecordList(String taskCode, String devNo, List<String> taskStates) {
        return patrolTaskExecRecordMapper.selectCameraPatrolTaskExecRecordList(taskCode, devNo, taskStates);
    }

    public List<PatrolTaskExecRecord> selectAbeyancePatrolTaskExecRecordList(PatrolTaskExecRecord patrolTaskExecRecord) {
        return patrolTaskExecRecordMapper.selectAbeyancePatrolTaskExecRecordList(patrolTaskExecRecord);
    }

    public int deletePatrolTaskExecRecordByTaskState(String taskState) {
        return patrolTaskExecRecordMapper.deletePatrolTaskExecRecordByTaskState(taskState);
    }
}
