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("定时器同步库存定时器完成");
|
|
}*/
|
|
}
|