java之定时任务

时间:2023-03-09 07:29:40
java之定时任务
 package com.financial.server.util;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import com.financial.server.service.impl.GSXQ_K_LineOfDayService;
import com.financial.server.service.impl.GSYJReportService;
import com.financial.server.service.impl.HGYJReportService;
import com.financial.server.service.impl.HYYYReportService;
import com.financial.server.service.impl.JuChaoServiceImpl;
import com.financial.server.service.impl.LongHuBangDetailsService;
import com.financial.server.service.impl.QSCHReportService;
import com.financial.server.service.impl.SHZQService;
import com.financial.server.service.impl.SZZQService;
import com.financial.server.service.impl.TZCLReportService;
import com.financial.server.service.impl.TaoGuBaService;
import com.financial.server.service.impl.XGYBReportService;
import com.financial.server.thread.GSYJThread;
import com.financial.server.thread.HGYJThread;
import com.financial.server.thread.HYYYThread;
import com.financial.server.thread.JuChaoDownloadThread;
import com.financial.server.thread.KOfDayThread;
import com.financial.server.thread.LongHuBangDetailsThread;
import com.financial.server.thread.QSCHThread;
import com.financial.server.thread.SHZQThread;
import com.financial.server.thread.SZZQThread;
import com.financial.server.thread.TGBThread;
import com.financial.server.thread.TZCLThread;
import com.financial.server.thread.XGYBThread; @Component
public class TimerTask {
@Autowired
private GSXQ_K_LineOfDayService kOfDayService; @Autowired
private JuChaoServiceImpl juChaoServiceImpl; @Autowired
private TaoGuBaService taoGuBaService; @Autowired
private GSYJReportService gsyjReportService;
@Autowired
private XGYBReportService xgybReportService;
@Autowired
private HYYYReportService hyyyReportService;
/*@Autowired
private GNYBReportService gnybReportService;*/
@Autowired
private TZCLReportService tzclReportService;
@Autowired
private QSCHReportService qschReportService;
@Autowired
private HGYJReportService hgyjReportService; @Autowired
private LongHuBangDetailsService longHuBangDetailsService; @Autowired
private JuChaoServiceImpl juchChaoServiceImpl;
@Autowired
private GSXQ_K_LineOfDayService gsxq_K_LineOfDayService; String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());//
//String date = "2018-07-12";
String typeFile = "F:/巨潮网/巨潮网公告类别.txt";
@Scheduled(cron = "0 59 13 ? * *")//每天15:04执行一次
public void doSomethingWithCron() {
try { //插入跟帖
/*Map<String, String> map = TaoGuBa.webParseHtmls("https://www.taoguba.com.cn/index?blockID=1");
String JessionID = map.get("JSESSIONID").toString();
String cookie = TaoGuBa.SubmitPost(JessionID);
new Thread(new TGBThread(taoGuBaService, date, date,true)).start();//淘股吧
*/
new Thread(new GSYJThread(gsyjReportService, date, date,true)).start();//公司研究 new Thread(new XGYBThread(xgybReportService, date, date,true)).start();//新股研报 new Thread(new HYYYThread(hyyyReportService, date, date,true)).start();//行业研究 new Thread(new TZCLThread(tzclReportService, date, date,true)).start();//投资策略 new Thread(new QSCHThread(qschReportService, date, date,true)).start();//券商晨会 new Thread(new HGYJThread(hgyjReportService, date, date,true)).start();//宏观研究 new Thread(new LongHuBangDetailsThread(longHuBangDetailsService, date, date,true)).start();//龙虎榜详情 new Thread(new JuChaoThread(juchChaoServiceImpl,typeFile,date, date,true)).start();//巨潮网公告 new Thread(new KOfDayThread(gsxq_K_LineOfDayService,date,true)).start();//日k线数据 } catch (Exception e) {
e.printStackTrace();
}
} }