
14 changed files with 1378 additions and 37 deletions
File diff suppressed because it is too large
@ -1,4 +1,38 @@ |
|||||
package com.yxt.supervise.dbcenter.zhj.crawl; |
package com.yxt.supervise.dbcenter.zhj.crawl; |
||||
|
|
||||
|
import cn.hutool.core.date.DateUtil; |
||||
|
import cn.hutool.core.thread.ThreadUtil; |
||||
|
import com.yxt.supervise.dbcenter.zhj.crawl.biz.crawlSalesAmount.CrawlSalesAmount; |
||||
|
import com.yxt.supervise.dbcenter.zhj.crawl.biz.crawlSalesAmount.CrawlSalesAmountService; |
||||
|
import com.yxt.supervise.dbcenter.zhj.crawl.biz.crawlSalesDishes.CrawlSalesDishesService; |
||||
|
import com.yxt.supervise.dbcenter.zhj.crawl.biz.crawlpurchase.CrawlPurchaseService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.scheduling.annotation.Scheduled; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
@Component |
||||
public class CrawlTask { |
public class CrawlTask { |
||||
|
|
||||
|
@Autowired |
||||
|
private CrawlSalesAmountService crawlSalesAmountService; |
||||
|
@Autowired |
||||
|
private CrawlSalesDishesService crawlSalesDishesService; |
||||
|
@Autowired |
||||
|
private CrawlPurchaseService crawlPurchaseService; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 描述 : 每天上午10点30分抓取数据并保存到数据库. <br/> |
||||
|
* <p> |
||||
|
*/ |
||||
|
@Scheduled(cron = "0 30 10 * * ?") |
||||
|
public void pullZhjData() { |
||||
|
String currDay = DateUtil.format(new Date(), "yyyy-MM-dd"); |
||||
|
ThreadUtil.execute(() -> crawlSalesAmountService.pullData(currDay)); |
||||
|
ThreadUtil.execute(() -> crawlSalesDishesService.pullData(currDay)); |
||||
|
ThreadUtil.execute(() -> crawlPurchaseService.pullData(currDay)); |
||||
|
} |
||||
|
|
||||
} |
} |
||||
|
@ -0,0 +1,35 @@ |
|||||
|
package com.yxt.supervise.dbcenter; |
||||
|
|
||||
|
import cn.hutool.core.date.DateUtil; |
||||
|
import cn.hutool.core.thread.ThreadUtil; |
||||
|
import com.yxt.supervise.dbcenter.zhj.crawl.biz.crawlSalesAmount.CrawlSalesAmountService; |
||||
|
import com.yxt.supervise.dbcenter.zhj.crawl.biz.crawlSalesDishes.CrawlSalesDishesService; |
||||
|
import com.yxt.supervise.dbcenter.zhj.crawl.biz.crawlpurchase.CrawlPurchaseService; |
||||
|
import org.junit.jupiter.api.Test; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.boot.test.context.SpringBootTest; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
@SpringBootTest |
||||
|
class YxtSuperviseDbcenterApplicationTests { |
||||
|
|
||||
|
|
||||
|
@Autowired |
||||
|
private CrawlSalesAmountService crawlSalesAmountService; |
||||
|
@Autowired |
||||
|
private CrawlSalesDishesService crawlSalesDishesService; |
||||
|
@Autowired |
||||
|
private CrawlPurchaseService crawlPurchaseService; |
||||
|
|
||||
|
@Test |
||||
|
void contextLoads() { |
||||
|
String currDay = "2023-05-05"; |
||||
|
|
||||
|
crawlSalesAmountService.pullData(currDay); |
||||
|
crawlSalesDishesService.pullData(currDay); |
||||
|
crawlPurchaseService.pullData(currDay); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
Loading…
Reference in new issue