ChoiceHisServiceImpl.java 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package com.zx.dataservice.service.impl;
  2. import com.jfinal.plugin.activerecord.Db;
  3. import com.jfinal.plugin.activerecord.Record;
  4. import com.zx.dataservice.service.ChoiceHisService;
  5. import com.zx.dataservice.utils.DateUtils;
  6. import com.zx.dataservice.utils.WorkingDayUtil;
  7. import org.apache.commons.lang3.StringUtils;
  8. import org.springframework.stereotype.Service;
  9. import java.util.Date;
  10. import java.util.List;
  11. @Service
  12. public class ChoiceHisServiceImpl implements ChoiceHisService {
  13. @Override
  14. public void analysisHistData() {
  15. List<Record> records = Db.use("gp").find("select id, code, name from t_stock_base_info where is_rest_add = 0 order by id asc ");
  16. for (Record record:records) {
  17. String str = Db.use("gp").queryStr("select dates from " +
  18. " data_hist_" + record.getStr("code").replace(".", "_").toLowerCase() +
  19. " order by realtime+0 desc limit 1 ");
  20. if(StringUtils.isNotBlank(str)){
  21. String newTime = new WorkingDayUtil().getNewTime(str, "yyyy/MM/dd",5);
  22. if(DateUtils.dateTime("yyyy/MM/dd",newTime).before(new Date())){ // 五天内还是 无数据
  23. System.out.println("五天内无数据股票****"+record.getStr("code")+"***"+newTime);
  24. Db.use("gp").update(" update t_stock_base_info set is_rest_add = 2 where id = ? ",record.get("id")+"");
  25. }
  26. }
  27. }
  28. List<Record> record2s = Db.use("zq").find("select id, code, name from t_stock_base_info where is_rest_add = 0 order by id asc ");
  29. for (Record record:record2s) {
  30. String str = Db.use("zq").queryStr("select dates from " +
  31. " data_hist_" + record.getStr("code").replace(".", "_").toLowerCase() +
  32. " order by realtime+0 desc limit 1 ");
  33. if(StringUtils.isNotBlank(str)){
  34. String newTime = new WorkingDayUtil().getNewTime(str, "yyyy/MM/dd",5);
  35. if(DateUtils.dateTime("yyyy/MM/dd",newTime).before(new Date())){ // 五天内还是 无数据
  36. System.out.println("五天内无数据股票****"+record.getStr("code")+"***"+newTime);
  37. Db.use("zq").update(" update t_stock_base_info set is_rest_add = 2 where id = ? ",record.get("id")+"");
  38. }
  39. }
  40. }
  41. }
  42. }