新增装置状态判断 修改log日志路径 装置在线判断
parent
5e3982efd6
commit
e34e1f1474
@ -0,0 +1,19 @@
|
||||
package com.shxy.xymanager_common.model;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 装置在线状态
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "装置在线状态对象", description = "装置在线状态对象")
|
||||
public class TermStatusModel implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "是否在线", example = "123456")
|
||||
private Boolean isonline;
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.shxy.xymanager_common.util;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import com.shxy.xymanager_common.entity.TerminalStatus;
|
||||
import com.shxy.xymanager_common.entity.Terminals;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 执行指令
|
||||
*
|
||||
* @author cy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class TerminalUtils {
|
||||
|
||||
private static Integer hearttime;
|
||||
|
||||
|
||||
@Value("${heart.time}")
|
||||
public void setHearttime(Integer time) {
|
||||
TerminalUtils.hearttime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断装置是否在线
|
||||
*
|
||||
* @param lastHeartbeat
|
||||
*/
|
||||
public static boolean judgeTerminalStatus(BigInteger lastHeartbeat) {
|
||||
long time = MyDateUtils.TimeSecond2MillSecond(lastHeartbeat.longValue());
|
||||
DateTime date = MyDateUtils.date(time);
|
||||
long between = MyDateUtils.between(MyDateUtils.getNowDate(), date, DateUnit.MINUTE);
|
||||
if (between > hearttime) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue