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.GcBidopenrecord;
import com.trs.ggzyexchange.entity.GcBidopenrecordVo;
import com.trs.ggzyexchange.entity.GcBidpublicity;
import com.trs.ggzyexchange.entity.TenderDetailsVo;
import com.trs.ggzyexchange.mapper.GcBidopenrecordMapper;
import com.trs.ggzyexchange.service.GcBidopenrecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 开标记录 服务实现类
 * </p>
 *
 * @author trs
 * @since 2023-02-16
 */
@Service
public class GcBidopenrecordServiceImpl extends ServiceImpl<GcBidopenrecordMapper, GcBidopenrecord> implements GcBidopenrecordService {


    @Autowired
    private GcBidopenrecordMapper gcBidopenrecordMapper;

    @Override
    public IPage<GcBidopenrecordVo> queryGcBidopenrecordServiceList(Page<GcBidopenrecord> page, GcBidopenrecord gcBidopenrecord) {
        return gcBidopenrecordMapper.queryGcBidopenrecordServiceList(page,
                gcBidopenrecord.getRegionCode(),
                gcBidopenrecord.getIndustriesType(),
                gcBidopenrecord.getNoticeName(),
                gcBidopenrecord.getPlatformCode(),
                gcBidopenrecord.getBidOpeningTimeStart(),
                gcBidopenrecord.getBidOpeningTimeEnd(),
                gcBidopenrecord.getBidFinishTimeStart(),
                gcBidopenrecord.getBidFinishTimeEnd()
        );
    }

    public IPage<TenderDetailsVo> queryGcBidopenrecordAllList(Page<GcBidopenrecord> page){
        return gcBidopenrecordMapper.queryGcBidopenrecordAllList(page);
    }

    @Override
    public Long maxDataTimeStamp() {
        Long aLong = gcBidopenrecordMapper.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;
    }

    @Override
    public IPage<TenderDetailsVo> queryGcBidopenrecordAllListByTime(Page<GcBidopenrecord> page, Long time) {
        return gcBidopenrecordMapper.queryGcBidopenrecordAllListByTime(page,time);
    }
}
