This commit is contained in:
zhouhuang 2024-12-30 12:44:55 +08:00
commit 1dd47ef259
8 changed files with 64 additions and 17 deletions

View File

@ -12,7 +12,7 @@ import java.util.Map;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/api/logger/")
@RequestMapping("/api/logger")
public class LoggerController {
private static final Logger logger = LogManager.getLogger(LoggerController.class);
@ -49,4 +49,29 @@ public class LoggerController {
return R.fail(String.format("Invalid log level [%s]. Valid levels: TRACE, DEBUG, INFO, WARN, ERROR, FATAL.", level));
}
}
/**
* 删除指定日志配置
*
* @param loggerName 日志名称
* @return 删除结果
*/
@PostMapping("/delete")
public R<String> deleteLogLevel(String loggerName) {
try {
LoggerContext context = (LoggerContext) LogManager.getContext(false);
LoggerConfig loggerConfig = context.getConfiguration().getLoggerConfig(loggerName);
if (loggerConfig.getName().equals(loggerName)) {
context.getConfiguration().removeLogger(loggerName);
context.updateLoggers();
logger.info("Deleted logger [{}]", loggerName);
return R.success(String.format("Logger [%s] configuration deleted, using parent level now.", loggerName));
} else {
return R.fail(String.format("Logger [%s] does not have a specific configuration.", loggerName));
}
} catch (Exception e) {
logger.error("Failed to delete logger [{}]", loggerName, e);
return R.fail(String.format("Failed to delete logger [%s]: %s", loggerName, e.getMessage()));
}
}
}

View File

@ -9,8 +9,12 @@ import com.das.modules.node.domain.bo.TerminalMessage;
import com.fasterxml.jackson.databind.JsonNode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;
import java.util.concurrent.TimeUnit;
@Slf4j
@Service(value = NodeConstant.HEARTBEAT)
public class HeartbeatCommand implements BaseCommand{
@ -18,7 +22,7 @@ public class HeartbeatCommand implements BaseCommand{
public static final long HEARTBEAT_TTL = 12L;
@Autowired
AdminRedisTemplate adminRedisTemplate;
RedisTemplate<String,Object> redisTemplate;
@Autowired
CacheService cacheService;
@ -35,16 +39,28 @@ public class HeartbeatCommand implements BaseCommand{
// 解析心跳报文中的数据信息
JsonNode dataInfo = data.getData();
if (!dataInfo.isEmpty()) {
ValueOperations<String,Object> ops = redisTemplate.opsForValue();
// 处理链路信息
JsonNode links = data.getData().get("links");
if (links != null && links.isArray()) {
for (JsonNode linkNode : links) {
String linkId = linkNode.get("linkId").asText();
boolean online = linkNode.get("online").asBoolean();
JsonNode realNode = linkNode.get("real");
if (realNode != null){
boolean real = realNode.asBoolean();
String key = String.format("link:%s:modbus", linkId);
ops.set(key, real, HEARTBEAT_TTL, TimeUnit.SECONDS);
}
JsonNode ftpNode = linkNode.get("ftp");
if (ftpNode != null){
boolean ftp = ftpNode.asBoolean();
String key = String.format("link:%s:ftp", linkId);
ops.set(key, ftp, HEARTBEAT_TTL, TimeUnit.SECONDS);
}
String key = String.format("link:%s:online", linkId);
// 更新链路在线状态到Redis
adminRedisTemplate.set(key, online ? 1 : 0);
adminRedisTemplate.expire(key, HEARTBEAT_TTL);
ops.set(key, online?1:0, HEARTBEAT_TTL, TimeUnit.SECONDS);
}
}
@ -62,19 +78,18 @@ public class HeartbeatCommand implements BaseCommand{
// 判断是不是风机
String keyDeviceOnline = String.format("device:%d:online", deviceId);
// 更新设备在线状态到Redis
adminRedisTemplate.set(keyDeviceOnline, online ? 1 : 0);
adminRedisTemplate.expire(keyDeviceOnline, HEARTBEAT_TTL);
ops.set(keyDeviceOnline, online ? 1 : 0, HEARTBEAT_TTL, TimeUnit.SECONDS);
String keyPLCDeviceStatus = String.format("RT:%d:iturbineoperationmode", deviceId);
String keyCommFaultState = String.format("RT:%d:commfaultstate",deviceId);
Integer plcDeviceStatus = adminRedisTemplate.get(keyPLCDeviceStatus);
Integer plcDeviceStatus = (Integer) ops.get(keyPLCDeviceStatus);
log.debug("设备ID:{},在线状态:{},通讯状态: {}", deviceId, online, plcDeviceStatus);
// 根据设备在线状态和通讯状态更新通讯故障状态
if (plcDeviceStatus == null){
adminRedisTemplate.set(keyCommFaultState, online ? 0 : 1);
ops.set(keyCommFaultState, online ? 0 : 1);
}
else{
adminRedisTemplate.set(keyCommFaultState, online && (plcDeviceStatus != 0) ? 0 : 1);
ops.set(keyCommFaultState, online && (plcDeviceStatus != 0) ? 0 : 1);
}
}
}

View File

@ -347,11 +347,16 @@ PS: 同一节点只允许建立一条连接。
//通讯链路IRN
"linkId": "3444",
//通讯链路状态
"online": true
"online": true,
//实时数据状态
"real": true,
//Ftp数据状态(在没有启用ftp的链路上不传此状态)
"ftp": true
},
{
"linkId": "123",
"online": false
"online": false,
"modbus": true
}
],
//设备监控信息

Binary file not shown.

Binary file not shown.

View File

@ -10,9 +10,6 @@
<div class="cardBtn">
<el-radio-group v-model="overviewSlotData" @change="changeUpdate">
<el-radio v-for="item in belongprojectList" :value="item.value">{{ item.name }}</el-radio>
<!-- <el-radio value="">全部</el-radio>
<el-radio value="一期">一期</el-radio>
<el-radio value="二期">二期</el-radio>-->
</el-radio-group>
</div>
<div class="headerRight">

View File

@ -71,10 +71,15 @@
<el-tooltip
v-if="item.attributeMap.firsttriggeredcode"
:content="item.attributeMap.firsttriggeredcode">
<span :style="item.attributeMap.locked == 1 ? 'max-width:120px;' : 'max-width:150px;'">
<span class="rightTip" :style="item.attributeMap.locked == 1 ? 'width:120px;' : 'width:150px;'">
{{ item.attributeMap.firsttriggeredcode }}
</span>
</el-tooltip>
<span class="rightTip"
v-if="!item.attributeMap.firsttriggeredcode"
:style="item.attributeMap.locked == 1 ? 'width:120px;' : 'width:150px;'">
{{ item.attributeMap.firsttriggeredcode }}
</span>
<!-- <el-tag class="tag-panel is-danger">已锁定</el-tag>-->
<el-tag v-if="item.attributeMap.locked === 1" class="tag-panel is-danger">已锁定</el-tag>
</div>
@ -607,7 +612,7 @@ const getSafeImagePath = (item, type) => {
display: flex;
justify-content: space-between;
height: 24px;
span{
.rightTip{
display: inline-block;
white-space: nowrap;
overflow: hidden;

View File

@ -441,7 +441,7 @@ const calculateAverages = (data: any) => {
if (count > 0) {
let averagePower = sumPower / count
result.push([windSpeed + interval, 2, getCutDecimalsValue(averagePower, 2)])
result.push([windSpeed + interval, getCutDecimalsValue(averagePower, 2)])
}
}