package com.trs.ggzyexchange.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.trs.ggzyexchange.entity.*;
import com.trs.ggzyexchange.mapper.GcBidExceptioNoticeMapper;
import com.trs.ggzyexchange.service.GcBidExceptioNoticeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 招标异常公告 服务实现类
 * </p>
 *
 * @author trs
 * @since 2023-02-16
 */
@Service
public class GcBidExceptioNoticeServiceImpl extends ServiceImpl<GcBidExceptioNoticeMapper, GcBidExceptioNotice> implements GcBidExceptioNoticeService {

    @Autowired
    private GcBidExceptioNoticeMapper gcBidExceptioNoticeMapper;

    public IPage<GcBidExceptioNoticeVo> queryGcBidExceptioNoticeList(Page<GcBidExceptioNotice> page,GcBidExceptioNotice gcBidExceptioNotice){

        IPage<GcBidExceptioNoticeVo> gcBidExceptioNoticeVoIPage = gcBidExceptioNoticeMapper.queryGcBidExceptioNoticeList(
                page,
                gcBidExceptioNotice.getRegionCode(),
                gcBidExceptioNotice.getIndustriesType(),
                gcBidExceptioNotice.getNoticeName(),
                gcBidExceptioNotice.getPlatformCode(),
                gcBidExceptioNotice.getNoticeSendTimeStart(),
                gcBidExceptioNotice.getNoticeSendTimeEnd()
        );
        return gcBidExceptioNoticeVoIPage;

    }

    @Override
    public IPage<TenderDetailsVo> queryGcBidExceptioNoticeAllList(Page<GcBidExceptioNotice> page) {
        return gcBidExceptioNoticeMapper.queryGcBidExceptioNoticeAllList(page);
    }

    @Override
    public IPage<TenderDetailsVo> queryGcBidExceptioNoticeAllListByTime(Page<GcBidExceptioNotice> page, Long time) {
        return gcBidExceptioNoticeMapper.queryGcBidExceptioNoticeAllListByTime(page,time);
    }

    @Override
    public Long maxDataTimeStamp() {
        Long aLong = gcBidExceptioNoticeMapper.maxDataTimeStamp();
        try{
            if(!ObjectUtils.isEmpty(aLong)){
                if(aLong != 0){
                    String sLong = ((aLong+"").substring(0,8)) + "000000";
                    aLong = Long.parseLong(sLong);
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return aLong;
    }
}
