fwq
2024-09-27 eece99c5fea3095a64485833c32b07b6f05e31ad
提交 | 用户 | age
739bf5 1 package com.hx.phip.his.task;
C 2
3 import com.hx.phip.model.SyncExecutionRecord;
4 import com.hx.phip.his.service.SyncExecutionRecordService;
5 import com.hx.util.DateUtil;
6 import net.sf.json.JSONObject;
7 import org.slf4j.Logger;
8 import org.slf4j.LoggerFactory;
9 import org.springframework.scheduling.annotation.Scheduled;
10 import org.springframework.stereotype.Component;
11
12 import javax.annotation.Resource;
13 import java.util.Calendar;
14 import java.util.Date;
15
16 /**
17  * his 同步可划扣数据定时器
18  */
19 //@Component
20 public class HisExecutableRecordSyncTask {
21
22     private static Logger logger = LoggerFactory.getLogger(HisExecutableRecordSyncTask.class);
23
24     @Resource
25     private SyncExecutionRecordService syncExecutionRecordService;
26
27     /**
28      * 两分钟同步一次当前时间和前一天的可划扣信息
29      */
30     @Scheduled(fixedDelay = 300000)
31     public void syncExecutableByTimeTask() {
32         Calendar c = Calendar.getInstance();
33         c.setTime(new Date());
34         Date end = c.getTime();
35         String endTime=DateUtil.formatDate_3(end);//当前日期
36
37         logger.info("开始执行同步可划扣定时器,开始时间:{},结束时间:{}",endTime,endTime);
38         JSONObject jsonObject=new JSONObject();
39         jsonObject.put("startTime",endTime);
40         jsonObject.put("endTime",endTime);
41         SyncExecutionRecord syncExecutionRecord=new SyncExecutionRecord(jsonObject.toString(),null,2,2,0,0,new Date());
42         syncExecutionRecordService.executable(jsonObject,syncExecutionRecord);
43         logger.info("定时器同步可划扣执行完成");
44     }
45
46     /**
47      * 晚上初始化同步所有可划扣信息
48      */
49    // @Scheduled(cron="01 01 22 20 * ?")
50     /*public void syncExecutableTask() {
51         JSONObject jsonObject=new JSONObject();
52         logger.info("开始执行同步库存定时器,");
53         syncExecutionRecordService.executable(jsonObject);
54         logger.info("定时器同步库存定时器完成");
55
56     }*/
57
58 }