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.ZrzyTdBidwinnotice;
import com.trs.ggzyexchange.entity.ZrzyTdBidwinnoticeVo;
import com.trs.ggzyexchange.mapper.ZrzyTdBidwinnoticeMapper;
import com.trs.ggzyexchange.service.ZrzyTdBidwinnoticeService;
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-24
 */
@Service
public class ZrzyTdBidwinnoticeServiceImpl extends ServiceImpl<ZrzyTdBidwinnoticeMapper, ZrzyTdBidwinnotice> implements ZrzyTdBidwinnoticeService {


    @Autowired
    private ZrzyTdBidwinnoticeMapper zrzyTdBidwinnoticeMapper;

    @Override
    public IPage<ZrzyTdBidwinnoticeVo> queryZrzyTdBidwinnoticeList(Page<ZrzyTdBidwinnotice> page, ZrzyTdBidwinnotice zrzyTdCedeNotice) {
        IPage<ZrzyTdBidwinnoticeVo> zrzyTdBidwinnoticeList =  zrzyTdBidwinnoticeMapper.queryZrzyTdBidwinnoticeList(
                page,
                zrzyTdCedeNotice.getRegionCode(),
                zrzyTdCedeNotice.getLandUsage(),
                zrzyTdCedeNotice.getAnnouncementTitle(),
                zrzyTdCedeNotice.getPublishingTimeStart(),
                zrzyTdCedeNotice.getPublishingTimeEnd()
        );
        return zrzyTdBidwinnoticeList;
    }

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

}
