终端删除后,终端日志记录名称修改

This commit is contained in:
hzj
2026-01-21 15:02:47 +08:00
parent fd6ec7bdf2
commit ed166cf1e0

View File

@@ -96,6 +96,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@@ -3698,9 +3699,13 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList = new ArrayList<>(); List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList = new ArrayList<>();
List<String> addAndDelteId = new ArrayList<>(); List<String> addAndDelteId = new ArrayList<>();
//异常标志
Boolean exFlag= false;
if (!CollectionUtils.isEmpty(list)) { if (!CollectionUtils.isEmpty(list)) {
List<PqsTerminalLogs> list1 = new ArrayList<>();
try {
//前置层修改 //前置层修改
List<PqsTerminalLogs> list1 = list.stream().filter(temp -> temp.getTerminalDescribe().contains("终端所属前置机由")).collect(Collectors.toList()); list1 = list.stream().filter(temp -> temp.getTerminalDescribe().contains("终端所属前置机由")).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(list1)) { if (!CollectionUtils.isEmpty(list1)) {
for (PqsTerminalLogs temp : list1) { for (PqsTerminalLogs temp : list1) {
String temLos = "%s终端所属前置机由 %s 改为> %s;"; String temLos = "%s终端所属前置机由 %s 改为> %s;";
@@ -3781,6 +3786,23 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO); pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO);
} else if (Objects.equals(temp.getTerminalType(), 4)) { } else if (Objects.equals(temp.getTerminalType(), 4)) {
String deviceId = temp.getObjIndex();
if(!deviceMap.containsKey(deviceId)){
//说明设备被删除
String temLos = "%s名称:%s;前置信息:%s";
List<String> strings = this.parseTemplateValues(temLos, temp.getTerminalDescribe());
String devName = strings.get(1); // 设备名称
String nodeName = strings.get(2); // 进程名称
pqsTerminalPushLogDTO.setDevName(devName);
//如果前置删了直接返回
if(!nodeNameMap.containsKey(nodeName)){
return;
}
String nodeId = nodeNameMap.get(nodeName).getId();
pqsTerminalPushLogDTO.setNodeId(nodeId);
pqsTerminalPushLogDTO.setNodeName(nodeName);
}
//如果是修改进程操作记录2个进程日志; //如果是修改进程操作记录2个进程日志;
if (temp.getLogsType().equals(dataDic.getId())) { if (temp.getLogsType().equals(dataDic.getId())) {
String temLos = "%s进行更新终端进程操作;终端名称 %s,由进程%s修改成进程%s"; String temLos = "%s进行更新终端进程操作;终端名称 %s,由进程%s修改成进程%s";
@@ -3790,7 +3812,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
int processId1 = Integer.parseInt(num1); int processId1 = Integer.parseInt(num1);
int processId2 = Integer.parseInt(num2); int processId2 = Integer.parseInt(num2);
pqsTerminalPushLogDTO.setId(temp.getId()); pqsTerminalPushLogDTO.setId(temp.getId());
String deviceId = temp.getObjIndex(); // String deviceId = temp.getObjIndex();
pqsTerminalPushLogDTO.setDevId(deviceId); pqsTerminalPushLogDTO.setDevId(deviceId);
pqsTerminalPushLogDTO.setDevName(lineMap.containsKey(deviceId) ? lineMap.get(deviceId).getName() : "删除设备"); pqsTerminalPushLogDTO.setDevName(lineMap.containsKey(deviceId) ? lineMap.get(deviceId).getName() : "删除设备");
String nodeId = deviceMap.get(deviceId).getNodeId(); String nodeId = deviceMap.get(deviceId).getNodeId();
@@ -3812,7 +3834,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
} else { } else {
pqsTerminalPushLogDTO.setId(temp.getId()); pqsTerminalPushLogDTO.setId(temp.getId());
String deviceId = temp.getObjIndex(); // String deviceId = temp.getObjIndex();
pqsTerminalPushLogDTO.setDevId(deviceId); pqsTerminalPushLogDTO.setDevId(deviceId);
//区分删除操作,新增和其他操作 //区分删除操作,新增和其他操作
String operate = DeviceRebootType.LEDGER_MODIFY; String operate = DeviceRebootType.LEDGER_MODIFY;
@@ -3847,7 +3869,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
if (deviceMap.containsKey(deviceId)) { if (deviceMap.containsKey(deviceId)) {
String nodeId = deviceMap.get(deviceId).getNodeId(); String nodeId = deviceMap.get(deviceId).getNodeId();
pqsTerminalPushLogDTO.setNodeId(nodeId); pqsTerminalPushLogDTO.setNodeId(nodeId);
pqsTerminalPushLogDTO.setNodeName(nodeMap.get(nodeId).getName()); pqsTerminalPushLogDTO.setNodeName(nodeMap.containsKey(nodeId)?nodeMap.get(nodeId).getName():"删除前置");
} else { } else {
addAndDelteId.add(deviceId); addAndDelteId.add(deviceId);
return; return;
@@ -3997,6 +4019,19 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
}); });
}); });
} catch (Exception e) {
//出现异常,直接重启整个前置
exFlag=true;
for (Node node : nodes) {
RestartParam restartParam = new RestartParam();
restartParam.setDeviceRebootType("1");
restartParam.setNodeId(node.getId());
askRestartProcess(restartParam);
}
}
if (!CollectionUtils.isEmpty(list1)) { if (!CollectionUtils.isEmpty(list1)) {
list1.forEach(temp -> { list1.forEach(temp -> {
temp.setIsPush(1); temp.setIsPush(1);
@@ -4016,6 +4051,10 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
} else { } else {
throw new BusinessException("暂无变动的装置测点推送"); throw new BusinessException("暂无变动的装置测点推送");
} }
if(exFlag){
throw new BusinessException("存在未知错误,重启前置");
}
if (CollectionUtils.isEmpty(preCommandDTOList)) { if (CollectionUtils.isEmpty(preCommandDTOList)) {
throw new BusinessException("暂无变动的装置测点推送"); throw new BusinessException("暂无变动的装置测点推送");
} }
@@ -4166,7 +4205,21 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
subName = subMap.get(line.getPids().split(StrUtil.COMMA)[SUB_LEVEL.getCode()]).getName(); subName = subMap.get(line.getPids().split(StrUtil.COMMA)[SUB_LEVEL.getCode()]).getName();
String temLos = "%s进行%s%s操作;详细信息: %s名称: %s"; String temLos = "%s进行%s%s操作;详细信息: %s名称: %s";
if (line.getLevel().equals(LINE_LEVEL.getCode())) { if (line.getLevel().equals(LINE_LEVEL.getCode())) {
String devName = this.getById(line.getPids().split(StrUtil.COMMA)[DEVICE_LEVEL.getCode()]).getName(); String devId=line.getPids().split(StrUtil.COMMA)[DEVICE_LEVEL.getCode()];
Line byId = this.getById(devId);
String devName="";
//设备已删除
if(Objects.nonNull(byId)){
devName= byId.getName();
}else{
List<Line> device = logsList.stream().filter(temp -> Objects.equals(temp.getId(), devId)).collect(Collectors.toList());
if(!CollectionUtils.isEmpty(device)){
devName =device.get(0).getName();
}else {
devName = "已删除设备";
}
}
tem = String.format(temLos, name, op, levelOperate, levelOperate, subName + "->" + devName + "->" + line.getName() + nodeName); tem = String.format(temLos, name, op, levelOperate, levelOperate, subName + "->" + devName + "->" + line.getName() + nodeName);
} else { } else {
tem = String.format(temLos, name, op, levelOperate, levelOperate, subName + "->" + line.getName() + nodeName); tem = String.format(temLos, name, op, levelOperate, levelOperate, subName + "->" + line.getName() + nodeName);