package com.gci.boot.modules.gis.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.gci.boot.common.util.FormatUtil;
import com.gci.boot.modules.gis.entity.TbGisSpeedingAlarm;
import com.gci.boot.modules.gis.entity.TbGisStoppingAlarm;
import com.gci.boot.modules.gis.mapper.TbGisStoppingAlarmMapper;
import com.gci.boot.modules.gis.service.ITbGisStoppingAlarmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 停车超时记录表 服务实现类
 * </p>
 *
 * @author 2464
 * @since 2023-09-01
 */
@Service
public class TbGisStoppingAlarmServiceImpl extends ServiceImpl<TbGisStoppingAlarmMapper, TbGisStoppingAlarm> implements ITbGisStoppingAlarmService {

    @Autowired
    private TbGisStoppingAlarmMapper gisStoppingAlarmMapper;

    @Override
    public IPage<TbGisStoppingAlarm> pageBuild(Page<TbGisStoppingAlarm> page, LambdaQueryWrapper<TbGisStoppingAlarm> lambdaQueryWrapper) {
        Page<TbGisStoppingAlarm> list = gisStoppingAlarmMapper.pageBuild(page, lambdaQueryWrapper);
        for (TbGisStoppingAlarm record : list.getRecords()) {
            String duration = FormatUtil.formattedTimeDifference(record.getStartTime(), record.getEndTime());
            record.setDuration(duration);
        }
        return list;
    }
}
