| | |
| | | import com.yssh.entity.DictRecord; |
| | | import com.yssh.entity.SuYuan; |
| | | import com.yssh.entity.VocVals; |
| | | import com.yssh.service.DictRecordService; |
| | | import com.yssh.service.SuYuanService; |
| | | import com.yssh.service.VocValsService; |
| | | import com.yssh.service.WarningAnalyseService; |
| | | import com.yssh.service.*; |
| | | import com.yssh.utils.*; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | protected final Logger logger = LoggerFactory.getLogger(this.getClass()); |
| | | |
| | | @Resource |
| | | private VocValsService vocValsService; |
| | | VocValsService vocValsService; |
| | | |
| | | @Resource |
| | | private SuYuanService suYuanService; |
| | | SuYuanService suYuanService; |
| | | |
| | | @Resource |
| | | private CsvFilePathConfig csvFilePathConfig; |
| | | CsvFilePathConfig csvFilePathConfig; |
| | | |
| | | @Resource |
| | | private DictRecordService dictRecordService; |
| | | DictRecordService dictRecordService; |
| | | |
| | | @Resource |
| | | private WarningAnalyseService warningAnalyseService; |
| | | WarningAnalyseService warningAnalyseService; |
| | | |
| | | @Resource |
| | | XlsReportService xlsReportService; |
| | | |
| | | @Resource |
| | | EmailService emailService; |
| | | |
| | | @Value("${csv.voc_max}") |
| | | private int vocMax = 96; |
| | |
| | | @Value("${csv.cron_max}") |
| | | private int cronMax = 48; |
| | | |
| | | private static boolean isBusy = false; |
| | | @Value("${email.enable}") |
| | | private Boolean enableEmail; |
| | | |
| | | private final static List<String> md5List = new ArrayList<>(); |
| | | |
| | |
| | | |
| | | @Scheduled(cron = "${csv.cron}") |
| | | private void loadCsvSync() { |
| | | if (isBusy) return; |
| | | |
| | | isBusy = true; |
| | | logger.info("***************** 开始执行CSV入库 *****************" + "\n"); |
| | | Calendar calendar = getCalendar(1); |
| | | for (int i = 0; i < cronMax; i++) { |
| | |
| | | } |
| | | } |
| | | logger.info("***************** CSV入库执行完成 *****************" + "\n"); |
| | | isBusy = false; |
| | | } |
| | | |
| | | public Calendar getCalendar(int start) { |
| | |
| | | } |
| | | warningAnalyseService.warningOperationStorage(date); |
| | | } |
| | | |
| | | /** |
| | | * 创建日报:每日0时1分 |
| | | */ |
| | | @Scheduled(cron = "0 1 0 * * ?") |
| | | public void createDayReport() { |
| | | Calendar calendar = getCalendar(1); |
| | | for (int i = 0; i < 31; i++) { |
| | | try { |
| | | calendar.add(Calendar.DATE, -1); |
| | | xlsReportService.createDayReport(calendar.getTime()); |
| | | // System.out.println(DateUtils.getYyyyMmDd(calendar.getTime())); |
| | | } catch (Exception ex) { |
| | | logger.error(ex.getMessage(), ex); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建周报:每周一0时5分 |
| | | */ |
| | | @Scheduled(cron = "0 5 0 ? * MON") |
| | | public void createWeekReport() { |
| | | Calendar calendar = getCalendar(7 * 24); |
| | | for (int i = 1; i < 8; i++) { |
| | | try { |
| | | calendar.add(Calendar.DATE, -7); |
| | | xlsReportService.createWeekReport(calendar.getTime()); |
| | | // System.out.println(DateUtils.getYyyyMmDd(calendar.getTime())); |
| | | } catch (Exception ex) { |
| | | logger.error(ex.getMessage(), ex); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建月报:每月1日0时9分 |
| | | */ |
| | | @Scheduled(cron = "0 9 0 1 * ?") |
| | | public void createMonthReport() { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(new Date()); |
| | | calendar.add(Calendar.MONTH, 1); |
| | | for (int i = 0; i < 6; i++) { |
| | | try { |
| | | calendar.add(Calendar.MONTH, -1); |
| | | xlsReportService.createMonthReport(calendar.getTime()); |
| | | // System.out.println(DateUtils.getYyyyMmDd(calendar.getTime())); |
| | | } catch (Exception ex) { |
| | | logger.error(ex.getMessage(), ex); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Scheduled(cron = "${email.times}") |
| | | public void autoCalcData() { |
| | | if (enableEmail) { |
| | | //System.out.println("${email.times}"); |
| | | emailService.calcData(); |
| | | } |
| | | } |
| | | } |