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.GcBidpublicity;
import com.trs.ggzyexchange.entity.GcBidpublicityVo;
import com.trs.ggzyexchange.entity.TenderDetailsVo;
import com.trs.ggzyexchange.mapper.GcBidopenrecordMapper;
import com.trs.ggzyexchange.mapper.GcBidpublicityMapper;
import com.trs.ggzyexchange.service.GcBidpublicityService;
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 GcBidpublicityServiceImpl extends ServiceImpl<GcBidpublicityMapper, GcBidpublicity> implements GcBidpublicityService {

    @Autowired
    private GcBidpublicityMapper gcBidpublicityMapper;

    @Override
    public IPage<GcBidpublicityVo> queryGcBidpublicityList(Page<GcBidpublicity> page, GcBidpublicity gcBidpublicity) {
        return gcBidpublicityMapper.queryGcBidpublicityList(
                page,
                gcBidpublicity.getRegionCode(),
                gcBidpublicity.getIndustriesType(),
                gcBidpublicity.getNoticeName(),
                gcBidpublicity.getPlatformCode(),
                gcBidpublicity.getNoticeSendTimeStart(),
                gcBidpublicity.getNoticeSendTimeEnd()
        );
    }
    @Override
    public IPage<TenderDetailsVo> queryGcBidpublicityAllList(Page<GcBidpublicity> page) {
        return gcBidpublicityMapper.queryGcBidpublicityAllList(page);
    }

    @Override
    public IPage<TenderDetailsVo> queryGcBidpublicityAllListByTime(Page<GcBidpublicity> page, Long time) {
        return gcBidpublicityMapper.queryGcBidpublicityAllListByTime(page,time);
    }

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