package com.ruoyi.quartz.task;

import com.ruoyi.bid.domain.BidInfo;
import com.ruoyi.bid.service.IBidInfoService;
import com.ruoyi.bid.util.BidSystemMVP;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

import static com.ruoyi.common.utils.SecurityUtils.getUsername;

@Component("bidTask")
public class BidTask {
    @Autowired
    private IBidInfoService bidInfoService;

    public void getBidInfo()
    {
        System.out.println("进入获取招标信息任务-------------------------------------------------------");
        List<BidInfo> bidInfos = BidSystemMVP.getBidInfos("http://www.ccgp.gov.cn/cggg/zygg/gkzb/index%s.htm", ".c_list_bid a",null);
        try {
            for (BidInfo bidInfo : bidInfos) {
                bidInfo.setCreateTime(new Date());
                bidInfoService.insertBidInfo(bidInfo);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("获取招标数据完毕----------------------------------------------------------" );
    }
}
