You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.3 KiB
Java

4 years ago
package com.docus.bgts.config;
4 years ago
import com.docus.bgts.enums.Codes;
import com.docus.bgts.facade.IBgtsService;
import com.docus.bgts.facade.IMzSyncService;
import com.docus.bgts.service.MzSyncService;
4 years ago
import com.docus.bgts.utils.FileUtils;
import com.docus.bgts.utils.HttpUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
4 years ago
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
4 years ago
import java.util.HashMap;
import java.util.Map;
@Component
public class MyScheduling {
@Value("${beat.url}")
private String beatUrl;
public static String syncFlag;
static {
syncFlag=FileUtils.getJsonByName("syncFlag").toString();
}
@Autowired
IBgtsService bgtsService;
@Autowired
IMzSyncService mzSyncService;
private Logger logger = LogManager.getLogger(MyScheduling.class);
4 years ago
//5分钟执行一次
@Scheduled(fixedRate = 1000 * 60 * 5)
public void beat() {
Map<String, String> params = new HashMap<>();
params.put("code", String.valueOf(FileUtils.getJsonByName("collectorid")));
4 years ago
try {
HttpUtils.get(beatUrl, params);
} catch (Exception e) {
4 years ago
e.printStackTrace();
logger.info("心跳推送出错,可能是住院服务没有开启");
}
}
/**
*
* 10
*/
@Scheduled(fixedRate = 1000 * 60 * 10)
public void collect() {
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
4 years ago
String isStartCollect = String.valueOf(FileUtils.getJsonByName("isStartCollect"));
if (isStartCollect.equals("0")) {
4 years ago
return;
}
if ((!collectorid.equals(Codes.SMCODE.getCode())) && (!collectorid.equals(Codes.ZZCODE.getCode()))) {
return;
}
bgtsService.timerCollect();
}
/**
*
*/
@Scheduled(fixedRate = 1000 * 60 * 30)
public void syncIntegrality() {
if (null == syncFlag || "0".equals(syncFlag)) {
} else {
mzSyncService.addSyncIntegrality();
}
}
4 years ago
}