package com.ktg.iscs.service.impl;

import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ktg.common.core.text.Convert;
import com.ktg.common.utils.DateUtils;
import com.ktg.iscs.domain.IsJobTicketLock;
import com.ktg.iscs.domain.vo.hardwareApi.JobTicketLockVO;
import com.ktg.iscs.mapper.IsJobTicketLockMapper;
import com.ktg.iscs.service.IIsJobTicketLockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 作业票关联锁Service业务层处理
 *
 * @author cgj
 * @date 2024-11-18
 */
@Service
public class IsJobTicketLockServiceImpl extends ServiceImpl<IsJobTicketLockMapper, IsJobTicketLock> implements IIsJobTicketLockService
{
    @Autowired
    private IsJobTicketLockMapper isJobTicketLockMapper;

    /**
     * 查询作业票关联锁
     *
     * @param recordId 作业票关联锁主键
     * @return 作业票关联锁
     */
    @Override
    public IsJobTicketLock selectIsJobTicketLockByRecordId(Long recordId)
    {
        return isJobTicketLockMapper.selectIsJobTicketLockByRecordId(recordId);
    }

    /**
     * 查询作业票关联锁列表
     *
     * @param isJobTicketLock 作业票关联锁
     * @return 作业票关联锁
     */
    @Override
    public List<IsJobTicketLock> selectIsJobTicketLockList(IsJobTicketLock isJobTicketLock)
    {
        return isJobTicketLockMapper.selectIsJobTicketLockList(isJobTicketLock);
    }

    /**
     * 新增作业票关联锁
     *
     * @param isJobTicketLock 作业票关联锁
     * @return 结果
     */
    @Override
    public int insertIsJobTicketLock(IsJobTicketLock isJobTicketLock)
    {
        isJobTicketLock.setCreateTime(DateUtils.getNowDate());
        return isJobTicketLockMapper.insertIsJobTicketLock(isJobTicketLock);
    }

    /**
     * 修改作业票关联锁
     *
     * @param isJobTicketLock 作业票关联锁
     * @return 结果
     */
    @Override
    public int updateIsJobTicketLock(IsJobTicketLock isJobTicketLock)
    {
        isJobTicketLock.setUpdateTime(DateUtils.getNowDate());
        return isJobTicketLockMapper.updateIsJobTicketLock(isJobTicketLock);
    }

    /**
     * 批量删除作业票关联锁
     *
     * @param recordIds 需要删除的作业票关联锁主键
     * @return 结果
     */
    @Override
    public int deleteIsJobTicketLockByRecordIds(String recordIds)
    {
        Assert.notBlank(recordIds, "请选择需要删除的数据!");
        Long[] longIds = Convert.toLongArray(recordIds);
        return isJobTicketLockMapper.deleteIsJobTicketLockByRecordIds(longIds);
    }

    /**
     * 删除作业票关联锁信息
     *
     * @param recordId 作业票关联锁主键
     * @return 结果
     */
    @Override
    public int deleteIsJobTicketLockByRecordId(Long recordId)
    {
        return isJobTicketLockMapper.deleteIsJobTicketLockByRecordId(recordId);
    }

    @Override
    public List<IsJobTicketLock> selectByTicketId(Long ticketId) {
        return isJobTicketLockMapper.selectList(IsJobTicketLock::getTicketId, ticketId);
    }

    @Override
    public List<JobTicketLockVO> getTicketLockByTicketId(Long ticketId) {
        return isJobTicketLockMapper.getTicketLockByTicketId(ticketId);
    }

    @Override
    public IsJobTicketLock getLockJobByBfc(String nfc, Long ticketId) {
        return isJobTicketLockMapper.getLockJobByBfc(nfc, ticketId);
    }

    @Override
    public List<IsJobTicketLock> getLockJob(Long lockId) {
        return isJobTicketLockMapper.getLockJob(lockId);
    }
}
