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