package com.ozs.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ozs.entity.MsgHeartbeatAlarmMessage;
import com.ozs.entity.VehiclePosition;
import com.ozs.entity.vo.MsgAlarmVo;
import com.ozs.mapper.MsgHeartbeatAlarmMessageMapper;
import com.ozs.service.MsgHeartbeatAlarmMessageService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


@Service
public class MsgHeartbeatAlarmMessageServiceImpl extends ServiceImpl<MsgHeartbeatAlarmMessageMapper, MsgHeartbeatAlarmMessage> implements MsgHeartbeatAlarmMessageService {
    @Override
    public IPage listToPage(List<MsgHeartbeatAlarmMessage> list, Integer pageNum, Integer pageSize) {
        List pageList = new ArrayList<>();
        int curIdx = pageNum > 1 ? (pageNum - 1) * pageSize : 0;
        for (int i = 0; i < pageSize && curIdx + i < list.size(); i++) {
            pageList.add(list.get(curIdx + i));
        }
        IPage page = new Page<>(pageNum, pageSize);
        page.setRecords(pageList);
        page.setTotal(list.size());
        return page;
    }

    @Override
    public List<MsgHeartbeatAlarmMessage> selectBaseLineManagement(String alarmId) {
        return baseMapper.selectBaseLineManagement(alarmId);
    }
}
