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.

131 lines
4.3 KiB
Java

4 years ago
package com.docus.bgts.config;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.docus.bgts.entity.TableJsonRead;
import com.docus.bgts.enums.Codes;
import com.docus.bgts.facade.IBgtsService;
import com.docus.bgts.service.CheckIntegrityService;
4 years ago
import com.docus.bgts.utils.FileUtils;
import com.docus.bgts.utils.HttpUtils;
import org.apache.commons.lang3.StringUtils;
4 years ago
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;
import java.util.Date;
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;
private final String tempfilePrefix="dataConfig\\temp";
private final String tempDataFileName="collectTimeTemp";
private final String lastTimeStr="lastTime";
// static {
// syncFlag=FileUtils.getJsonByName("syncFlag").toString();
// }
@Autowired
IBgtsService bgtsService;
@Autowired
CheckIntegrityService checkIntegrityService;
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")));
try {
HttpUtils.get(beatUrl, params);
} catch (Exception e) {
e.printStackTrace();
logger.info("心跳推送出错,可能是住院服务没有开启");
}
}
4 years ago
/**
* /
* 10
*/
// @Scheduled(fixedRate = 1000 * 60 * 10)
// public void collect() {
// String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
// if ((!collectorid.equals(Codes.SMCODE.getCode())) && (!collectorid.equals(Codes.ZZCODE.getCode()))) {
// return;
// }
// bgtsService.timerCollect();
// }
/**
*
* 10
*/
@Scheduled(fixedRate = 1000 * 60 *10 )
public void collectByExamNo(){
String collectOpen = String.valueOf(FileUtils.getJsonByName("collectOpen"));
if (collectOpen.equals("1")){
logger.info("按需采集开始----------");
String collectStartDate = String.valueOf(FileUtils.getJsonByName("collectStartDate"));
String collectEndDate = String.valueOf(FileUtils.getJsonByName("collectEndDate"));
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
bgtsService.collectByDate(collectStartDate,collectEndDate,collectorid);
}
}
/**
*
*/
// @Scheduled(fixedRate = 1000 * 5 * 60)
// public void syncIntegrality() {
// if (null == syncFlag || "0".equals(syncFlag)) {
//
// } else {
// //获取最后时间
// String lastDate = getLastDate();
// if(StringUtils.isNotBlank(lastDate)) {
// Date date = new Date();
// boolean flag = checkIntegrityService.addSyncIntegrality(lastDate, null);
// if(flag) {
// refreshLastDate(date);
// }
// }else{
// logger.info("采集时间为空");
// }
// }
// }
/**
*
* @return
*/
// private String getLastDate(){
// TableJsonRead tableJsonRead = new TableJsonRead();
// Map<String,String> map = tableJsonRead.Read(tempfilePrefix, tempDataFileName,Map.class);
// return map.get(lastTimeStr);
// }
/**
*
*/
// private void refreshLastDate(Date lastDate){
// String lastTime = DateUtil.format(lastDate, "yyyy-MM-dd HH:mm:ss");
// TableJsonRead tableJsonRead = new TableJsonRead();
// Map<String, String> map = new HashMap<>();
// map.put(lastTimeStr, lastTime);
// tableJsonRead.Save(tempfilePrefix, tempDataFileName, JSON.toJSONString(map));
// }
4 years ago
}