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.IsJobTicketPoints;
import com.ktg.iscs.domain.vo.ticketPoints.IsJobTicketPointsVO;
import com.ktg.iscs.mapper.IsJobTicketPointsMapper;
import com.ktg.iscs.service.IIsJobTicketPointsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 作业票隔离点Service业务层处理
 *
 * @author cgj
 * @date 2024-10-18
 */
@Service
public class IsJobTicketPointsServiceImpl extends ServiceImpl<IsJobTicketPointsMapper, IsJobTicketPoints> implements IIsJobTicketPointsService
{
    @Autowired
    private IsJobTicketPointsMapper isJobTicketPointsMapper;

    /**
     * 查询作业票隔离点
     *
     * @param recordId 作业票隔离点主键
     * @return 作业票隔离点
     */
    @Override
    public IsJobTicketPoints selectIsJobTicketPointsByRecordId(Long recordId)
    {
        return isJobTicketPointsMapper.selectIsJobTicketPointsByRecordId(recordId);
    }

    /**
     * 查询作业票隔离点列表
     *
     * @param isJobTicketPoints 作业票隔离点
     * @return 作业票隔离点
     */
    @Override
    public List<IsJobTicketPoints> selectIsJobTicketPointsList(IsJobTicketPoints isJobTicketPoints)
    {
        return isJobTicketPointsMapper.selectIsJobTicketPointsList(isJobTicketPoints);
    }

    /**
     * 新增作业票隔离点
     *
     * @param isJobTicketPoints 作业票隔离点
     * @return 结果
     */
    @Override
    public int insertIsJobTicketPoints(IsJobTicketPoints isJobTicketPoints)
    {
        isJobTicketPoints.setCreateTime(DateUtils.getNowDate());
        return isJobTicketPointsMapper.insertIsJobTicketPoints(isJobTicketPoints);
    }

    /**
     * 修改作业票隔离点
     *
     * @param isJobTicketPoints 作业票隔离点
     * @return 结果
     */
    @Override
    public int updateIsJobTicketPoints(IsJobTicketPoints isJobTicketPoints)
    {
        isJobTicketPoints.setUpdateTime(DateUtils.getNowDate());
        return isJobTicketPointsMapper.updateIsJobTicketPoints(isJobTicketPoints);
    }

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

    /**
     * 删除作业票隔离点信息
     *
     * @param recordId 作业票隔离点主键
     * @return 结果
     */
    @Override
    public int deleteIsJobTicketPointsByRecordId(Long recordId)
    {
        return isJobTicketPointsMapper.deleteIsJobTicketPointsByRecordId(recordId);
    }

    @Override
    public List<IsJobTicketPointsVO> getListByTicketId(Long ticketId) {
        return isJobTicketPointsMapper.getListByTicketId(ticketId);
    }

    @Override
    public List<IsJobTicketPoints> getFinishConflictJob(Long pointId, Long lockId) {
        return isJobTicketPointsMapper.getFinishConflictJob(pointId, lockId);
    }

    @Override
    public List<IsJobTicketPoints> getNotFinishConflictJob(Long pointId, Long lockId) {
        return isJobTicketPointsMapper.getNotFinishConflictJob(pointId, lockId);
    }

    @Override
    public IsJobTicketPoints getLockingData(Long pointId) {
        return isJobTicketPointsMapper.getLockingData(pointId);
    }

    @Override
    public List<IsJobTicketPoints> getVirtualLockConflictPoint(Long pointId, Long lockId, Long ticketId) {
        return isJobTicketPointsMapper.getVirtualLockConflictPoint(pointId, lockId, ticketId);
    }
}
