Merge branch 'main' of https://git.jsspisoft.com/ry-das
This commit is contained in:
commit
81d46ccda5
@ -2817,11 +2817,11 @@ void CRYDevice::heart_beat(int status)
|
|||||||
if (status == 1) {
|
if (status == 1) {
|
||||||
Json::Value jsonLink;
|
Json::Value jsonLink;
|
||||||
Json::Value jsonDevice;
|
Json::Value jsonDevice;
|
||||||
Json::Value jsonValue;
|
|
||||||
for (int i = 0; i < PROCESSES_NUM; i++) {
|
for (int i = 0; i < PROCESSES_NUM; i++) {
|
||||||
if ((config.processes[i].state & 0x01) == TRUE) {
|
if ((config.processes[i].state & 0x01) == TRUE) {
|
||||||
char linkId[32];
|
char linkId[32];
|
||||||
if (config.processes[i].irn == 0) continue;
|
if (config.processes[i].irn == 0) continue;
|
||||||
|
Json::Value jsonValue;
|
||||||
#ifdef NOPOLL_64BIT_PLATFORM
|
#ifdef NOPOLL_64BIT_PLATFORM
|
||||||
snprintf(linkId, sizeof(linkId), "%ld", config.processes[i].irn);
|
snprintf(linkId, sizeof(linkId), "%ld", config.processes[i].irn);
|
||||||
#else
|
#else
|
||||||
@ -2830,7 +2830,7 @@ void CRYDevice::heart_beat(int status)
|
|||||||
jsonValue["linkId"] = linkId;
|
jsonValue["linkId"] = linkId;
|
||||||
jsonValue["online"] = (config.processes[i].real_softdog >= PROCESS_WATCHDOG_TIME) ? false : true;
|
jsonValue["online"] = (config.processes[i].real_softdog >= PROCESS_WATCHDOG_TIME) ? false : true;
|
||||||
jsonValue["real"] = (config.processes[i].real_softdog >= PROCESS_WATCHDOG_TIME) ? false : true;
|
jsonValue["real"] = (config.processes[i].real_softdog >= PROCESS_WATCHDOG_TIME) ? false : true;
|
||||||
if (config.processes[i].state & 0x20) {
|
if ((config.processes[i].state & 0x20) == 0x20) {
|
||||||
jsonValue["ftp"] = (config.processes[i].real_softdog >= PROCESS_WATCHDOG_TIME) ? false : true;
|
jsonValue["ftp"] = (config.processes[i].real_softdog >= PROCESS_WATCHDOG_TIME) ? false : true;
|
||||||
}
|
}
|
||||||
jsonLink.append(jsonValue);
|
jsonLink.append(jsonValue);
|
||||||
@ -2845,6 +2845,7 @@ void CRYDevice::heart_beat(int status)
|
|||||||
if ((config.units[i].state & 0x01) == TRUE) {
|
if ((config.units[i].state & 0x01) == TRUE) {
|
||||||
char deviceId[32];
|
char deviceId[32];
|
||||||
if (config.units[i].irn == 0) continue;
|
if (config.units[i].irn == 0) continue;
|
||||||
|
Json::Value jsonValue;
|
||||||
#ifdef NOPOLL_64BIT_PLATFORM
|
#ifdef NOPOLL_64BIT_PLATFORM
|
||||||
snprintf(deviceId, sizeof(deviceId), "%ld", config.units[i].irn);
|
snprintf(deviceId, sizeof(deviceId), "%ld", config.units[i].irn);
|
||||||
#else
|
#else
|
||||||
|
@ -523,7 +523,7 @@ static void* ryftp_process(void* param)
|
|||||||
vLog(LOG_DEBUG, "%s get %s to local memory, with name: %s, and password: %s okay, and file length is: %d.\n", processName, remote, user, password, chunk.size);
|
vLog(LOG_DEBUG, "%s get %s to local memory, with name: %s, and password: %s okay, and file length is: %d.\n", processName, remote, user, password, chunk.size);
|
||||||
config.units[uid].value &= ~0x02;
|
config.units[uid].value &= ~0x02;
|
||||||
ftpget_retry_count = 0;
|
ftpget_retry_count = 0;
|
||||||
if (chunk.size <= (int)(sizeof(struRYDeviceData) << 5)) {
|
if (chunk.size <= (int)(sizeof(struRYDeviceData) * 248)) {
|
||||||
vLog(LOG_DEBUG, "%s PLC文件生成未完成!\n", processName);
|
vLog(LOG_DEBUG, "%s PLC文件生成未完成!\n", processName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -531,7 +531,8 @@ static void* ryftp_process(void* param)
|
|||||||
struRYDeviceData *data = (struRYDeviceData *)chunk.response;
|
struRYDeviceData *data = (struRYDeviceData *)chunk.response;
|
||||||
int uid = mbt->GetCurUnitID();
|
int uid = mbt->GetCurUnitID();
|
||||||
mbt->UnitFeedFTPDog(uid);
|
mbt->UnitFeedFTPDog(uid);
|
||||||
for (int i = 0; i < 250; i++, data++) { //每个文件有250个数据块
|
int data_count = (chunk.size / sizeof(struRYDeviceData));
|
||||||
|
for (int i = 0; i < data_count; i++, data++) { //每个文件有250个数据块
|
||||||
QLONG unix_time = filetime_to_unix(data->localtime);
|
QLONG unix_time = filetime_to_unix(data->localtime);
|
||||||
DWORD localtime = ((unix_time / 1000) - 28800L);
|
DWORD localtime = ((unix_time / 1000) - 28800L);
|
||||||
|
|
||||||
@ -539,14 +540,17 @@ static void* ryftp_process(void* param)
|
|||||||
unix_time = localtime; unix_time *= 1000;
|
unix_time = localtime; unix_time *= 1000;
|
||||||
unix_time += millisec;
|
unix_time += millisec;
|
||||||
#if 0
|
#if 0
|
||||||
unionCP56Time st;
|
if (unix_time < 1735488000000 || unix_time >= 1735660800000)
|
||||||
st = Time_ttounionCP56Time(localtime);
|
{
|
||||||
vLog(LOG_DEBUG, "data<%d> time is: %04d/%02d/%02d %02d:%02d:%02d.%03d\n", \
|
unionCP56Time st;
|
||||||
i, \
|
st = Time_ttounionCP56Time(localtime);
|
||||||
st.year + 2000, st.month, st.dayofmonth, \
|
vLog(LOG_DEBUG, "unix_time is: %ld, localtime is: %d, and data<%d> time is: %04d/%02d/%02d %02d:%02d:%02d.%03d\n", \
|
||||||
st.hour, st.minute, st.millisecond/1000, st.millisecond%1000);
|
unix_time, localtime,
|
||||||
|
i, \
|
||||||
|
st.year + 2000, st.month, st.dayofmonth, \
|
||||||
|
st.hour, st.minute, st.millisecond/1000, millisec);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
//vLog(LOG_DEBUG, "data.iPitchAngle1 is: %d, data.iPitchAngle2 is: %d, and data.iPitchAngle3 is: %d\n", data->iPitchAngle1, data->iPitchAngle2, data->iPitchAngle3);
|
|
||||||
//如何将结构化数据传入,且快速获取
|
//如何将结构化数据传入,且快速获取
|
||||||
Json::Value highspeedvalues;
|
Json::Value highspeedvalues;
|
||||||
for (datatypemap::iterator it = highspeedmap.begin(); it != highspeedmap.end(); it++) {
|
for (datatypemap::iterator it = highspeedmap.begin(); it != highspeedmap.end(); it++) {
|
||||||
@ -556,7 +560,6 @@ static void* ryftp_process(void* param)
|
|||||||
int point = it->second;
|
int point = it->second;
|
||||||
if (GetYCValue(point, fields, (const char *)data, dvalue)) {
|
if (GetYCValue(point, fields, (const char *)data, dvalue)) {
|
||||||
if (adsGetUnitYCIsFloat(uid, point)) {
|
if (adsGetUnitYCIsFloat(uid, point)) {
|
||||||
//fprintf(stderr, "%s, ", config.units[uid].ycs[order].name);
|
|
||||||
highspeedvalues[(const char *)config.units[uid].ycs[order].name] = adsGetUnitYCRealFromValue(uid, point, dvalue);
|
highspeedvalues[(const char *)config.units[uid].ycs[order].name] = adsGetUnitYCRealFromValue(uid, point, dvalue);
|
||||||
} else {
|
} else {
|
||||||
highspeedvalues[(const char *)config.units[uid].ycs[order].name] = dvalue;
|
highspeedvalues[(const char *)config.units[uid].ycs[order].name] = dvalue;
|
||||||
@ -579,9 +582,7 @@ static void* ryftp_process(void* param)
|
|||||||
int order = it->first;
|
int order = it->first;
|
||||||
int point = it->second;
|
int point = it->second;
|
||||||
if (GetYCValue(point, fields, (const char *)data, dvalue)) {
|
if (GetYCValue(point, fields, (const char *)data, dvalue)) {
|
||||||
//fprintf(stderr, "get<%d> value is: %d.\n", point, dvalue);
|
|
||||||
if (adsGetUnitYCIsFloat(uid, point)) {
|
if (adsGetUnitYCIsFloat(uid, point)) {
|
||||||
//fprintf(stderr, "%s, ", config.units[uid].ycs[order].name);
|
|
||||||
lowspeedvalues[(const char *)config.units[uid].ycs[order].name] = adsGetUnitYCRealFromValue(uid, point, dvalue);
|
lowspeedvalues[(const char *)config.units[uid].ycs[order].name] = adsGetUnitYCRealFromValue(uid, point, dvalue);
|
||||||
} else {
|
} else {
|
||||||
lowspeedvalues[(const char *)config.units[uid].ycs[order].name] = dvalue;
|
lowspeedvalues[(const char *)config.units[uid].ycs[order].name] = dvalue;
|
||||||
@ -595,7 +596,6 @@ static void* ryftp_process(void* param)
|
|||||||
int order = it->first;
|
int order = it->first;
|
||||||
int point = it->second.point;
|
int point = it->second.point;
|
||||||
int pos = it->second.pos;
|
int pos = it->second.pos;
|
||||||
//vLog(LOG_DEBUG, "start to get point is: %d, pos is: %d\n", point, pos);
|
|
||||||
if (GetYXValue(point, fields, (const char *)data, pos, bvalue)) {
|
if (GetYXValue(point, fields, (const char *)data, pos, bvalue)) {
|
||||||
lowspeedvalues[(const char *)config.units[uid].yxs[order].name] = (int)bvalue;
|
lowspeedvalues[(const char *)config.units[uid].yxs[order].name] = (int)bvalue;
|
||||||
} else {
|
} else {
|
||||||
|
@ -528,7 +528,7 @@ static void* ryftp_process(void* param)
|
|||||||
vLog(LOG_DEBUG, "%s get %s to local memory, with name: %s, and password: %s okay, and file length is: %d.\n", processName, remote, user, password, chunk.size);
|
vLog(LOG_DEBUG, "%s get %s to local memory, with name: %s, and password: %s okay, and file length is: %d.\n", processName, remote, user, password, chunk.size);
|
||||||
config.units[uid].value &= ~0x02;
|
config.units[uid].value &= ~0x02;
|
||||||
ftpget_retry_count = 0;
|
ftpget_retry_count = 0;
|
||||||
if (chunk.size <= (int)(sizeof(struRYDeviceData) << 5)) {
|
if (chunk.size <= (int)(sizeof(struRYDeviceData) * 248)) {
|
||||||
vLog(LOG_DEBUG, "%s PLC文件生成未完成!\n", processName);
|
vLog(LOG_DEBUG, "%s PLC文件生成未完成!\n", processName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -536,7 +536,8 @@ static void* ryftp_process(void* param)
|
|||||||
struRYDeviceData *data = (struRYDeviceData *)chunk.response;
|
struRYDeviceData *data = (struRYDeviceData *)chunk.response;
|
||||||
int uid = mbt->GetCurUnitID();
|
int uid = mbt->GetCurUnitID();
|
||||||
mbt->UnitFeedFTPDog(uid);
|
mbt->UnitFeedFTPDog(uid);
|
||||||
for (int i = 0; i < 250; i++, data++) { //每个文件有250个数据块
|
int data_count = (chunk.size / sizeof(struRYDeviceData));
|
||||||
|
for (int i = 0; i < data_count; i++, data++) { //每个文件有250个数据块
|
||||||
QLONG unix_time = filetime_to_unix(data->localtime);
|
QLONG unix_time = filetime_to_unix(data->localtime);
|
||||||
DWORD localtime = ((unix_time / 1000) - 28800L);
|
DWORD localtime = ((unix_time / 1000) - 28800L);
|
||||||
|
|
||||||
|
@ -49,14 +49,14 @@ public class HeartbeatCommand implements BaseCommand{
|
|||||||
JsonNode realNode = linkNode.get("real");
|
JsonNode realNode = linkNode.get("real");
|
||||||
if (realNode != null){
|
if (realNode != null){
|
||||||
boolean real = realNode.asBoolean();
|
boolean real = realNode.asBoolean();
|
||||||
String key = String.format("link:%s:modbus", linkId);
|
String key = String.format("link:%s:real", linkId);
|
||||||
ops.set(key, real, HEARTBEAT_TTL, TimeUnit.SECONDS);
|
ops.set(key, real?1:0, HEARTBEAT_TTL, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
JsonNode ftpNode = linkNode.get("ftp");
|
JsonNode ftpNode = linkNode.get("ftp");
|
||||||
if (ftpNode != null){
|
if (ftpNode != null){
|
||||||
boolean ftp = ftpNode.asBoolean();
|
boolean ftp = ftpNode.asBoolean();
|
||||||
String key = String.format("link:%s:ftp", linkId);
|
String key = String.format("link:%s:ftp", linkId);
|
||||||
ops.set(key, ftp, HEARTBEAT_TTL, TimeUnit.SECONDS);
|
ops.set(key, ftp?1:0, HEARTBEAT_TTL, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
String key = String.format("link:%s:online", linkId);
|
String key = String.format("link:%s:online", linkId);
|
||||||
// 更新链路在线状态到Redis
|
// 更新链路在线状态到Redis
|
||||||
|
@ -38,9 +38,23 @@ public class SysCommunicationLinkVo {
|
|||||||
private String nodeName;
|
private String nodeName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态 0 - 正常 1 - 通讯中断
|
* 链路状态 0 - 离线, 1 - 正常
|
||||||
|
*/
|
||||||
|
private Integer onlineStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ftp状态 0 - 异常 1 - 正常
|
||||||
|
*/
|
||||||
|
private Integer ftpStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实时数据状态 0 - 异常 1 - 正常
|
||||||
|
*/
|
||||||
|
private Integer realStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实时数据状态
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 所属系统节点id
|
* 所属系统节点id
|
||||||
|
@ -39,6 +39,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.core.ValueOperations;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
@ -81,7 +82,7 @@ public class SysNodeServiceImpl implements SysNodeService {
|
|||||||
SysIotModelServiceMapper iotModelServiceMapper;
|
SysIotModelServiceMapper iotModelServiceMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
AdminRedisTemplate adminRedisTemplate;
|
RedisTemplate<String,Object> redisTemplate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SysNodeVo> querySysNodeList() {
|
public List<SysNodeVo> querySysNodeList() {
|
||||||
@ -144,6 +145,7 @@ public class SysNodeServiceImpl implements SysNodeService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PageDataInfo<SysCommunicationLinkVo> querySysCommunicationLinkList(SysCommunicationLinkDto sysCommunicationLinkDto) {
|
public PageDataInfo<SysCommunicationLinkVo> querySysCommunicationLinkList(SysCommunicationLinkDto sysCommunicationLinkDto) {
|
||||||
|
ValueOperations<String,Object> ops = redisTemplate.opsForValue();
|
||||||
// 初始化分页查询对象
|
// 初始化分页查询对象
|
||||||
PageQuery pageQuery = new PageQuery();
|
PageQuery pageQuery = new PageQuery();
|
||||||
pageQuery.setPageNum(sysCommunicationLinkDto.getPageNum());
|
pageQuery.setPageNum(sysCommunicationLinkDto.getPageNum());
|
||||||
@ -158,32 +160,37 @@ public class SysNodeServiceImpl implements SysNodeService {
|
|||||||
// 根据条件判断是否需要查询在线状态
|
// 根据条件判断是否需要查询在线状态
|
||||||
if (sysCommunicationLinkDto.getWithStatus() != null && sysCommunicationLinkDto.getWithStatus() == 1) {
|
if (sysCommunicationLinkDto.getWithStatus() != null && sysCommunicationLinkDto.getWithStatus() == 1) {
|
||||||
// 初始化用于存储在线状态键的列表
|
// 初始化用于存储在线状态键的列表
|
||||||
List<String> keys = new ArrayList<>(records.size());
|
List<String> onlines = new ArrayList<>(records.size());
|
||||||
|
List<String> ftps = new ArrayList<>(records.size());
|
||||||
|
List<String> reals = new ArrayList<>(records.size());
|
||||||
// 遍历查询结果,构造每个通信链路的在线状态键
|
// 遍历查询结果,构造每个通信链路的在线状态键
|
||||||
for (int i = 0; i < records.size(); i++) {
|
for (int i = 0; i < records.size(); i++) {
|
||||||
SysCommunicationLinkVo sysCommunicationLinkVo = records.get(i);
|
SysCommunicationLinkVo sysCommunicationLinkVo = records.get(i);
|
||||||
String onlineKey = String.format("link:%d:online", sysCommunicationLinkVo.getId());
|
onlines.add(String.format("link:%d:online", sysCommunicationLinkVo.getId()));
|
||||||
keys.add(onlineKey);
|
ftps.add(String.format("link:%d:ftp", sysCommunicationLinkVo.getId()));
|
||||||
|
reals.add(String.format("link:%d:real", sysCommunicationLinkVo.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 批量获取在线状态值
|
// 批量获取在线状态值
|
||||||
List<Object> values = adminRedisTemplate.mGet(keys);
|
List<Object> onlinesStatus = ops.multiGet(onlines);
|
||||||
|
List<Object> ftpsStatus = ops.multiGet(ftps);
|
||||||
|
List<Object> realsStatus = ops.multiGet(reals);
|
||||||
|
|
||||||
// 遍历在线状态值,更新通信链路的在线状态
|
// 遍历在线状态值,更新通信链路的在线状态
|
||||||
for (int i = 0; i < values.size(); i++) {
|
for (int i = 0; i < records.size(); i++) {
|
||||||
Object val = values.get(i);
|
SysCommunicationLinkVo sysCommunicationLinkVo = records.get(i);
|
||||||
if (val == null) {
|
Integer ostatus = (Integer) onlinesStatus.get(i);
|
||||||
records.get(i).setStatus(1);
|
Integer fstatus = (Integer) ftpsStatus.get(i);
|
||||||
|
Integer rstatus = (Integer) realsStatus.get(i);
|
||||||
|
if (ostatus == null) {
|
||||||
|
ostatus = 0;
|
||||||
}
|
}
|
||||||
else{
|
sysCommunicationLinkVo.setOnlineStatus(ostatus);
|
||||||
Integer status = NumberUtil.parseInt(val.toString(), null);
|
if (fstatus != null){
|
||||||
if (status == null || status == 0) {
|
sysCommunicationLinkVo.setFtpStatus(fstatus);
|
||||||
records.get(i).setStatus(1);
|
}
|
||||||
}
|
if (rstatus != null ){
|
||||||
else{
|
sysCommunicationLinkVo.setRealStatus(rstatus);
|
||||||
records.get(i).setStatus(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user