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.GcBidcandidatePost;
import com.trs.ggzyexchange.entity.GcBidcandidatePostVo;
import com.trs.ggzyexchange.entity.TenderDetailsVo;
import com.trs.ggzyexchange.mapper.GcBidcandidatePostMapper;
import com.trs.ggzyexchange.service.GcBidcandidatePostService;
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 GcBidcandidatePostServiceImpl extends ServiceImpl<GcBidcandidatePostMapper, GcBidcandidatePost> implements GcBidcandidatePostService {


    @Autowired
    private GcBidcandidatePostMapper gcBidcandidatePostMapper;

    public IPage<GcBidcandidatePostVo> queryGcBidcandidatePostList(Page<GcBidcandidatePost> page,GcBidcandidatePost gcBidcandidatePost){
        IPage<GcBidcandidatePostVo> gcBidcandidatePostVoIPage = gcBidcandidatePostMapper.queryGcBidcandidatePostList(
                page,
                gcBidcandidatePost.getRegionCode(),
                gcBidcandidatePost.getIndustriesType(),
                gcBidcandidatePost.getPublicityName(),
                gcBidcandidatePost.getPlatformCode(),
                gcBidcandidatePost.getPublicityReferTimeStart(),
                gcBidcandidatePost.getPublicityReferTimeEnd()
        );
        return gcBidcandidatePostVoIPage;
    }
    @Override
    public IPage<TenderDetailsVo> queryGcBidcandidatePostAllList(Page<GcBidcandidatePost> page) {
        return gcBidcandidatePostMapper.queryGcBidcandidatePostAllList(page);
    }

    @Override
    public IPage<TenderDetailsVo> queryGcBidcandidatePostAllListByTime(Page<GcBidcandidatePost> page, Long time) {
        return gcBidcandidatePostMapper.queryGcBidcandidatePostAllListByTime(page,time);
    }

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