前置机功能开发

This commit is contained in:
hzj
2025-05-06 14:09:21 +08:00
parent a2fcb97a8d
commit fc75a7084d
12 changed files with 254 additions and 58 deletions

View File

@@ -26,8 +26,10 @@ public class DeviceInfo {
private String port; private String port;
//终端端口 //终端端口
private String stationName; private String stationName;
//变电站名 //终端名称
private String name; private String name;
//电站名称
private String subName;
//终端序列号 //终端序列号
private String updateTime; private String updateTime;
//数据更新时间 //数据更新时间
@@ -40,6 +42,8 @@ public class DeviceInfo {
private String devKey; private String devKey;
private Integer processNo; private Integer processNo;
private Integer maxProcessNum;
// //
private List<MonitorInfo> monitorData; private List<MonitorInfo> monitorData;

View File

@@ -0,0 +1,33 @@
package com.njcn.device.pq.pojo.dto;
import com.njcn.device.pq.pojo.param.NodeParam;
import com.njcn.device.pq.pojo.po.Node;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* Description:
* Date: 2024/11/4 21:01【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Data
public class NodeProcessDeviceTree {
private Node node;
private List<ProcessDevice> processDeviceList;
@Data
@EqualsAndHashCode(callSuper = false)
public static class ProcessDevice {
private Integer processNo;
private Integer processState;
private List<DeviceInfo> deviceInfoList;
}
}

View File

@@ -0,0 +1,43 @@
package com.njcn.device.pq.pojo.dto;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author hongawen
* @since 2023-04-12
*/
@Data
public class PqsTerminalPushLogDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 终端运维日志Id
*/
private String id;
private String nodeId;
private Integer processNum;
private String devId;
/**
* 新增,修改,删除
*/
private String operateType;
}

View File

@@ -56,9 +56,9 @@ public class DeviceParam {
@NotNull(message = "前置机索引不能为空") @NotNull(message = "前置机索引不能为空")
private String nodeId; private String nodeId;
@ApiModelProperty(name = "nodeId",value = "所属前置机机进程",required = true) // @ApiModelProperty(name = "nodeId",value = "所属前置机机进程",required = true)
@NotNull(message = "所属前置机机进程不能为空") // @NotNull(message = "所属前置机机进程不能为空")
private Integer processNum; // private Integer processNum;
@ApiModelProperty(name = "series",value = "装置识别码采用3ds加密") @ApiModelProperty(name = "series",value = "装置识别码采用3ds加密")
private String series; private String series;

View File

@@ -50,7 +50,7 @@ public class PqsTerminalLogs extends BaseEntity implements Serializable {
private String logsType; private String logsType;
/** /**
* 是否推送 * 是否推送 0未推送1已推送
*/ */
private Integer isPush; private Integer isPush;

View File

@@ -7,8 +7,10 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.pq.pojo.dto.DeviceInfo; import com.njcn.device.pq.pojo.dto.DeviceInfo;
import com.njcn.device.pq.pojo.dto.NodeProcessDeviceTree;
import com.njcn.device.pq.pojo.param.NodeDeviceParam; import com.njcn.device.pq.pojo.param.NodeDeviceParam;
import com.njcn.device.pq.pojo.po.DeviceProcess;
import com.njcn.device.pq.service.NodeDeviceService; import com.njcn.device.pq.service.NodeDeviceService;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@@ -49,6 +51,15 @@ public class NodeDeviceController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
} }
@ApiOperation("查询前置-进程-设备-设备树")
@OperateInfo(info = LogEnum.BUSINESS_MEDIUM)
@PostMapping("nodeDeviceTree")
public HttpResult<NodeProcessDeviceTree> nodeDeviceTree(@RequestParam("nodeId") String nodeId){
String methodDescribe = getMethodDescribe("nodeDeviceTree");
NodeProcessDeviceTree list = nodeDeviceService.nodeDeviceTree(nodeId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@ApiOperation("一键分配装置所属进程号") @ApiOperation("一键分配装置所属进程号")
@OperateInfo(info = LogEnum.BUSINESS_MEDIUM) @OperateInfo(info = LogEnum.BUSINESS_MEDIUM)
@PostMapping("oneKeyDistribution") @PostMapping("oneKeyDistribution")
@@ -58,7 +69,14 @@ public class NodeDeviceController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} }
@ApiOperation("更新设备进程号")
@OperateInfo(info = LogEnum.BUSINESS_MEDIUM)
@PostMapping("updateDeviceProcess")
public HttpResult<Boolean> updateDeviceProcess(@RequestBody DeviceProcess deviceProcess){
String methodDescribe = getMethodDescribe("nodeDeviceTree");
Boolean flag = nodeDeviceService.updateDeviceProcess(deviceProcess);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
}
} }

View File

@@ -444,23 +444,22 @@ public class TerminalBaseController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} }
@ApiOperation("请求前置设备设备") @ApiOperation("请求前置设备重启")
@PostMapping(value = "askRestartDevice") @PostMapping(value = "askRestartDevice")
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.DELETE) @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.DELETE)
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "devId", value = "设备id", required = true), @ApiImplicitParam(name = "devId", value = "设备id", required = true),
@ApiImplicitParam(name = "deviceRebootType", value = "重启类型", required = true) @ApiImplicitParam(name = "deviceRebootType", value = "重启类型", required = true)
}) })
public HttpResult<Object> askRestartDevice(@RequestParam("devId")String devId,@RequestParam("deviceRebootType")String deviceRebootType) { public HttpResult<Object> askRestartDevice(@RequestParam("devId")List<String> devIds,@RequestParam("deviceRebootType")String deviceRebootType,@RequestParam("processNo")Integer processNo) {
String methodDescribe = getMethodDescribe("askRestartDevice"); String methodDescribe = getMethodDescribe("askRestartDevice");
terminalBaseService.askRestartDevice(devId,deviceRebootType); terminalBaseService.askRestartDevice(devIds,deviceRebootType,processNo);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} }
@ApiOperation("台账变更推送") @ApiOperation("台账变更推送")
@PostMapping(value = "ledgerChangePush") @PostMapping(value = "ledgerChangePush")
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.QUERY) @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.QUERY)
public HttpResult<Object> ledgerChangePush() { public HttpResult<Object> ledgerChangePush() {
String methodDescribe = getMethodDescribe("ledgerChangePush"); String methodDescribe = getMethodDescribe("ledgerChangePush");
terminalBaseService.ledgerChangePush(); terminalBaseService.ledgerChangePush();

View File

@@ -10,16 +10,19 @@
s1.Name devType, s1.Name devType,
pq_device.Port port, pq_device.Port port,
pq_line.Name name, pq_line.Name name,
sub.Name subName,
pq_device.Update_Time updateTime, pq_device.Update_Time updateTime,
s2.Name manufacturer, s2.Name manufacturer,
pq_device.Com_Flag status, pq_device.Com_Flag status,
pq_device.Series series, pq_device.Series series,
pq_device_process.process_no processNo, pq_device_process.process_no processNo,
pq_device.Dev_Key devKey pq_device.Dev_Key devKey,
pq_node.max_Process_Num maxProcessNum
FROM FROM
pq_device pq_device
LEFT JOIN pq_node ON pq_node.Id = pq_device.Node_Id LEFT JOIN pq_node ON pq_node.Id = pq_device.Node_Id
LEFT JOIN pq_line on pq_device.id = pq_line.id LEFT JOIN pq_line on pq_device.id = pq_line.id
LEFT JOIN pq_line sub on pq_line.pid = sub.id
LEFT JOIN pq_device_process on pq_device_process.id = pq_device.id LEFT JOIN pq_device_process on pq_device_process.id = pq_device.id
LEFT JOIN sys_dict_data s1 ON pq_device.Dev_Type = s1.id LEFT JOIN sys_dict_data s1 ON pq_device.Dev_Type = s1.id
LEFT JOIN sys_dict_data s2 ON pq_device.Manufacturer = s2.id LEFT JOIN sys_dict_data s2 ON pq_device.Manufacturer = s2.id

View File

@@ -1,7 +1,9 @@
package com.njcn.device.pq.service; package com.njcn.device.pq.service;
import com.njcn.device.pq.pojo.dto.DeviceInfo; import com.njcn.device.pq.pojo.dto.DeviceInfo;
import com.njcn.device.pq.pojo.dto.NodeProcessDeviceTree;
import com.njcn.device.pq.pojo.param.NodeDeviceParam; import com.njcn.device.pq.pojo.param.NodeDeviceParam;
import com.njcn.device.pq.pojo.po.DeviceProcess;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@@ -18,4 +20,8 @@ public interface NodeDeviceService {
List<DeviceInfo> nodeDeviceList(NodeDeviceParam nodeDeviceParam); List<DeviceInfo> nodeDeviceList(NodeDeviceParam nodeDeviceParam);
void oneKeyDistribution(String nodeId); void oneKeyDistribution(String nodeId);
NodeProcessDeviceTree nodeDeviceTree(String nodeId);
Boolean updateDeviceProcess(DeviceProcess deviceProcess);
} }

View File

@@ -287,7 +287,7 @@ public interface TerminalBaseService {
//通知前置重启设备 //通知前置重启设备
void askRestartProcess(Integer processNo,String processType,String deviceRebootType); void askRestartProcess(Integer processNo,String processType,String deviceRebootType);
void askRestartDevice(String devId, String deviceRebootType); void askRestartDevice(List<String> devId, String deviceRebootType,Integer processNo);
void ledgerChangePush(); void ledgerChangePush();
} }

View File

@@ -7,6 +7,7 @@ import com.njcn.device.pq.mapper.LineMapper;
import com.njcn.device.pq.mapper.NodeMapper; import com.njcn.device.pq.mapper.NodeMapper;
import com.njcn.device.pq.pojo.dto.DeviceInfo; import com.njcn.device.pq.pojo.dto.DeviceInfo;
import com.njcn.device.pq.pojo.dto.MonitorInfo; import com.njcn.device.pq.pojo.dto.MonitorInfo;
import com.njcn.device.pq.pojo.dto.NodeProcessDeviceTree;
import com.njcn.device.pq.pojo.param.NodeDeviceParam; import com.njcn.device.pq.pojo.param.NodeDeviceParam;
import com.njcn.device.pq.pojo.po.Device; import com.njcn.device.pq.pojo.po.Device;
import com.njcn.device.pq.pojo.po.DeviceProcess; import com.njcn.device.pq.pojo.po.DeviceProcess;
@@ -14,13 +15,16 @@ import com.njcn.device.pq.pojo.po.Node;
import com.njcn.device.pq.service.DeviceProcessService; import com.njcn.device.pq.service.DeviceProcessService;
import com.njcn.device.pq.service.IDeviceService; import com.njcn.device.pq.service.IDeviceService;
import com.njcn.device.pq.service.NodeDeviceService; import com.njcn.device.pq.service.NodeDeviceService;
import com.njcn.redis.utils.RedisUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@@ -38,6 +42,8 @@ public class NodeDeviceServiceImpl implements NodeDeviceService {
private final LineMapper lineMapper; private final LineMapper lineMapper;
private final IDeviceService iDeviceService; private final IDeviceService iDeviceService;
private final DeviceProcessService deviceProcessService; private final DeviceProcessService deviceProcessService;
private final RedisUtil redisUtil;
@Override @Override
public List<DeviceInfo> nodeDeviceList(NodeDeviceParam nodeDeviceParam) { public List<DeviceInfo> nodeDeviceList(NodeDeviceParam nodeDeviceParam) {
@@ -82,4 +88,35 @@ public class NodeDeviceServiceImpl implements NodeDeviceService {
deviceProcessService.updateBatchById(collect); deviceProcessService.updateBatchById(collect);
} }
@Override
public NodeProcessDeviceTree nodeDeviceTree(String nodeId) {
Node node = nodeMapper.selectById(nodeId);
NodeProcessDeviceTree nodeProcessDeviceTree = new NodeProcessDeviceTree();
nodeProcessDeviceTree.setNode(node);
NodeDeviceParam nodeDeviceParam = new NodeDeviceParam();
nodeDeviceParam.setIp(node.getIp());
List<DeviceInfo> list = nodeMapper.nodeDeviceList(nodeDeviceParam);
List<NodeProcessDeviceTree.ProcessDevice> processDeviceLis = new ArrayList<>();
for (int i = 1; i <= node.getMaxProcessNum(); i++) {
NodeProcessDeviceTree.ProcessDevice processDevice= new NodeProcessDeviceTree.ProcessDevice();
processDevice.setProcessNo(i);
int finalI = i;
List<DeviceInfo> collect = list.stream().filter(deviceInfo -> Objects.equals(deviceInfo.getProcessNo(), finalI)).collect(Collectors.toList());
processDevice.setDeviceInfoList(collect);
processDeviceLis.add(processDevice);
// redisUtil.getObjectByKey()
}
nodeProcessDeviceTree.setProcessDeviceList(processDeviceLis);
return nodeProcessDeviceTree;
}
@Override
public Boolean updateDeviceProcess(DeviceProcess deviceProcess) {
return deviceProcessService.updateById(deviceProcess);
}
} }

View File

@@ -40,6 +40,7 @@ import com.njcn.device.pq.pojo.bo.excel.OverLimitExcel;
import com.njcn.device.pq.pojo.bo.excel.TerminalBaseExcel; import com.njcn.device.pq.pojo.bo.excel.TerminalBaseExcel;
import com.njcn.device.pq.pojo.dto.DeviceInfo; import com.njcn.device.pq.pojo.dto.DeviceInfo;
import com.njcn.device.pq.pojo.dto.PollutionSubstationDTO; import com.njcn.device.pq.pojo.dto.PollutionSubstationDTO;
import com.njcn.device.pq.pojo.dto.PqsTerminalPushLogDTO;
import com.njcn.device.pq.pojo.param.*; import com.njcn.device.pq.pojo.param.*;
import com.njcn.device.pq.pojo.param.oracle.*; import com.njcn.device.pq.pojo.param.oracle.*;
import com.njcn.device.pq.pojo.po.*; import com.njcn.device.pq.pojo.po.*;
@@ -318,10 +319,10 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
// .stream() // .stream()
// .min(Comparator.comparingInt(e -> e.getValue())) // .min(Comparator.comparingInt(e -> e.getValue()))
// .map(Map.Entry::getKey); // .map(Map.Entry::getKey);
DeviceProcess deviceProcess = new DeviceProcess(); // DeviceProcess deviceProcess = new DeviceProcess();
deviceProcess.setId(device.getId()); // deviceProcess.setId(device.getId());
deviceProcess.setProcessNo(deviceParam.getProcessNum()); // deviceProcess.setProcessNo(deviceParam.getProcessNum());
deviceProcessService.saveOrUpdate(deviceProcess); // deviceProcessService.saveOrUpdate(deviceProcess);
//装置功能 //装置功能
List<DictData> funList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.DEV_FUN.getName()).getData(); List<DictData> funList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.DEV_FUN.getName()).getData();
if (CollectionUtil.isEmpty(funList)) { if (CollectionUtil.isEmpty(funList)) {
@@ -706,9 +707,15 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
BeanUtils.copyProperties(updateDeviceParam, deviceDetail); BeanUtils.copyProperties(updateDeviceParam, deviceDetail);
deviceDetail.setId(updateDeviceParam.getDevIndex()); deviceDetail.setId(updateDeviceParam.getDevIndex());
coderM3d(deviceDetail,true); coderM3d(deviceDetail,true);
this.updateById(device); this.updateById(device);
deviceMapper.updateById(deviceDetail); deviceMapper.updateById(deviceDetail);
// DeviceProcess deviceProcess = new DeviceProcess();
// deviceProcess.setId(updateDeviceParam.getDevIndex());
// deviceProcess.setProcessNo(updateDeviceParam.getProcessNum());
// deviceProcessService.saveOrUpdate(deviceProcess);
} }
//母线 //母线
@@ -1416,7 +1423,9 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
// 2. 查询并删除所有省份 // 2. 查询并删除所有省份
List<Line> provinces = findChildren(project.getId()); List<Line> provinces = findChildren(project.getId());
if (CollectionUtil.isEmpty(provinces)) return; if (CollectionUtil.isEmpty(provinces)) {
return;
}
List<String> provinceIds = provinces.stream() List<String> provinceIds = provinces.stream()
.map(Line::getId) .map(Line::getId)
@@ -1433,7 +1442,9 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
// 1. 查询并删除所有供电公司 // 1. 查询并删除所有供电公司
List<Line> powerCompanies = findChildren(provinceId); List<Line> powerCompanies = findChildren(provinceId);
if (CollectionUtil.isEmpty(powerCompanies)) return; if (CollectionUtil.isEmpty(powerCompanies)) {
return;
}
List<String> companyIds = powerCompanies.stream() List<String> companyIds = powerCompanies.stream()
.map(Line::getId) .map(Line::getId)
@@ -1449,7 +1460,9 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
this.removeById(companyId); this.removeById(companyId);
// 1. 查询并删除所有变电站 // 1. 查询并删除所有变电站
List<Line> substations = findChildren(companyId); List<Line> substations = findChildren(companyId);
if (CollectionUtil.isEmpty(substations)) return; if (CollectionUtil.isEmpty(substations)) {
return;
}
List<String> substationIds = substations.stream() List<String> substationIds = substations.stream()
.map(Line::getId) .map(Line::getId)
@@ -1467,7 +1480,9 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
substationMapper.deleteById(substationId); substationMapper.deleteById(substationId);
// 1. 查询并删除所有装置 // 1. 查询并删除所有装置
List<Line> devices = findChildren(substationId); List<Line> devices = findChildren(substationId);
if (CollectionUtil.isEmpty(devices)) return; if (CollectionUtil.isEmpty(devices)) {
return;
}
logsList.addAll(devices); logsList.addAll(devices);
@@ -1486,10 +1501,12 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
private void deleteDeviceAndChildren(String deviceId,List<Line> logsList) { private void deleteDeviceAndChildren(String deviceId,List<Line> logsList) {
this.removeById(deviceId); this.removeById(deviceId);
deviceMapper.deleteById(deviceId); deviceMapper.deleteById(deviceId);
deviceProcessService.removeById(deviceId);
// 1. 查询并删除所有母线 // 1. 查询并删除所有母线
List<Line> busbars = findChildren(deviceId); List<Line> busbars = findChildren(deviceId);
if (CollectionUtil.isEmpty(busbars)) return; if (CollectionUtil.isEmpty(busbars)) {
return;
}
List<String> busbarIds = busbars.stream() List<String> busbarIds = busbars.stream()
.map(Line::getId) .map(Line::getId)
@@ -1510,7 +1527,9 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
voltageMapper.deleteById(busbarId); voltageMapper.deleteById(busbarId);
// 1. 查询并删除所有监测点 // 1. 查询并删除所有监测点
List<Line> monitoringPoints = findChildren(busbarId); List<Line> monitoringPoints = findChildren(busbarId);
if (CollectionUtil.isEmpty(monitoringPoints)) return; if (CollectionUtil.isEmpty(monitoringPoints)) {
return;
}
logsList.addAll(monitoringPoints); logsList.addAll(monitoringPoints);
@@ -3641,29 +3660,36 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
@Override @Override
@Async // @Async
public void askRestartDevice(String devId, String deviceRebootType) { public void askRestartDevice(List<String> devId, String deviceRebootType,Integer processNum) {
DeviceProcess one = deviceProcessService.lambdaQuery().eq(DeviceProcess::getId, devId).one();
DeviceRebootMessage deviceRebootMessage = new DeviceRebootMessage(); DeviceRebootMessage deviceRebootMessage = new DeviceRebootMessage();
deviceRebootMessage.setCode(deviceRebootType); deviceRebootMessage.setCode(deviceRebootType);
if(Objects.equals(deviceRebootType, DeviceRebootType.DELETE_TERMINAL)){ if(Objects.equals(deviceRebootType, DeviceRebootType.DELETE_TERMINAL)){
DeviceRebootMessage.DeviceInfo deviceInfo = new DeviceRebootMessage.DeviceInfo();
deviceInfo.setId(devId);
List<DeviceRebootMessage.DeviceInfo> list = new ArrayList<>(); List<DeviceRebootMessage.DeviceInfo> list = new ArrayList<>();
devId.forEach(temp->{
DeviceRebootMessage.DeviceInfo deviceInfo = new DeviceRebootMessage.DeviceInfo();
deviceInfo.setId(temp);
list.add(deviceInfo); list.add(deviceInfo);
});
deviceRebootMessage.setData(list); deviceRebootMessage.setData(list);
deviceRebootMessage.setIndex(one.getProcessNo()); deviceRebootMessage.setIndex(processNum);
produceFeignClient.askRestartDevice(deviceRebootMessage); produceFeignClient.askRestartDevice(deviceRebootMessage);
//删除设备进程关系 //删除设备进程关系
deviceProcessService.removeById(devId); deviceProcessService.removeByIds(devId);
}else { }else {
List<DeviceRebootMessage.DeviceInfo> list = new ArrayList<>();
devId.forEach(temp->{
NodeDeviceParam nodeDeviceParam = new NodeDeviceParam(); NodeDeviceParam nodeDeviceParam = new NodeDeviceParam();
nodeDeviceParam.setDevId(devId); nodeDeviceParam.setDevId(temp);
List<DeviceInfo> deviceInfos = nodeDeviceService.nodeDeviceList(nodeDeviceParam); List<DeviceInfo> deviceInfos = nodeDeviceService.nodeDeviceList(nodeDeviceParam);
if (CollectionUtil.isNotEmpty(deviceInfos)) { if (CollectionUtil.isNotEmpty(deviceInfos)) {
deviceRebootMessage.setIndex(one.getProcessNo()); deviceRebootMessage.setIndex(processNum);
DeviceInfo deviceInfo = deviceInfos.get(0); DeviceInfo deviceInfo = deviceInfos.get(0);
DeviceRebootMessage.DeviceInfo deviceInfo1 = new DeviceRebootMessage.DeviceInfo(); DeviceRebootMessage.DeviceInfo deviceInfo1 = new DeviceRebootMessage.DeviceInfo();
BeanUtils.copyProperties(deviceInfo, deviceInfo1); BeanUtils.copyProperties(deviceInfo, deviceInfo1);
@@ -3673,33 +3699,60 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
return m; return m;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
deviceInfo1.setMonitorData(monitorInfoList); deviceInfo1.setMonitorData(monitorInfoList);
List<DeviceRebootMessage.DeviceInfo> list = new ArrayList<>();
list.add(deviceInfo1); list.add(deviceInfo1);
}
});
deviceRebootMessage.setData(list); deviceRebootMessage.setData(list);
produceFeignClient.askRestartDevice(deviceRebootMessage); produceFeignClient.askRestartDevice(deviceRebootMessage);
} }
} }
}
@Override @Override
@Transactional @Transactional
public void ledgerChangePush() { public void ledgerChangePush() {
QueryWrapper<PqsTerminalLogs> queryWrapper= new QueryWrapper<PqsTerminalLogs>(); QueryWrapper<PqsTerminalLogs> queryWrapper= new QueryWrapper<>();
queryWrapper.lambda().eq(PqsTerminalLogs::getState, 1).eq(PqsTerminalLogs::getIsPush, 0).in(PqsTerminalLogs::getTerminalType,Stream.of(4,6).collect(Collectors.toList())); queryWrapper.lambda().eq(PqsTerminalLogs::getState, 1).eq(PqsTerminalLogs::getIsPush, 0).in(PqsTerminalLogs::getTerminalType,Stream.of(4,6).collect(Collectors.toList()));
List<PqsTerminalLogs> list = pqsTerminalLogsMapper.selectList(queryWrapper); List<PqsTerminalLogs> list = pqsTerminalLogsMapper.selectList(queryWrapper);
// list.forEach(temp->{
// PqsTerminalPushLogDTO pqsTerminalPushLogDTO = new PqsTerminalPushLogDTO();
// if(Objects.equals(temp.getTerminalType(),6)){
// pqsTerminalPushLogDTO.setId(temp.getId());
// pqsTerminalPushLogDTO.setNodeId();
// pqsTerminalPushLogDTO.setProcessNum();
// pqsTerminalPushLogDTO.setDevId();
// pqsTerminalPushLogDTO.setOperateType(DeviceRebootType.LEDGER_MODIFY);
//
//
// }
//
// });
if(!CollectionUtils.isEmpty(list)){ if(!CollectionUtils.isEmpty(list)){
//一个是删除操作,其余都算终端设备更新操作 //一个是删除操作,其余都算终端设备更新操作
List<PqsTerminalLogs> delDevice = list.stream().filter(temp -> Objects.equals(temp.getOperateType(), Param.DEL) && Objects.equals(temp.getTerminalType(), 4)).distinct().collect(Collectors.toList()); List<PqsTerminalLogs> delDevice = list.stream().filter(temp -> Objects.equals(temp.getOperateType(), Param.DEL) && Objects.equals(temp.getTerminalType(), 4)).distinct().collect(Collectors.toList());
List<String> delDevIds = new ArrayList<>(); List<String> delDevIds = new ArrayList<>();
if(!CollectionUtils.isEmpty(delDevice)){ if(!CollectionUtils.isEmpty(delDevice)){
delDevice.forEach(temp->{ List<String> collect = delDevice.stream().map(PqsTerminalLogs::getObjIndex).collect(Collectors.toList());
this.askRestartDevice(temp.getObjIndex(), DeviceRebootType.DELETE_TERMINAL); delDevIds.addAll(collect);
delDevIds.add(temp.getObjIndex()); List<DeviceProcess> deviceProcessList = deviceProcessService.lambdaQuery().in(DeviceProcess::getId, collect).list();
//根据进程号分组每个进程发送一条信息给前置如果该进程修改的设备数超过10台则直接重启该进程
Map<Integer, List<DeviceProcess>> collect1 = deviceProcessList.stream().collect(Collectors.groupingBy(DeviceProcess::getProcessNo));
//根据进程号
collect1.forEach((k,v)->{
// this.askRestartDevice(temp.getObjIndex(), DeviceRebootType.DELETE_TERMINAL);
if(v.size()>=10){
// this.askRestartProcess(k,);
}else {
// this.askRestartDevice();
} }
); });
} }
List<String> updateDevIds = new ArrayList<>(); List<String> updateDevIds = new ArrayList<>();
List<String> lineIds = list.stream().filter(temp -> Objects.equals(temp.getTerminalType(), 6)).map(PqsTerminalLogs::getObjIndex).distinct().collect(Collectors.toList()); List<String> lineIds = list.stream().filter(temp -> Objects.equals(temp.getTerminalType(), 6)).map(PqsTerminalLogs::getObjIndex).distinct().collect(Collectors.toList());
@@ -3719,7 +3772,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
updateDevIds.removeAll(delDevIds); updateDevIds.removeAll(delDevIds);
} }
updateDevIds.stream().distinct().forEach(temp->{ updateDevIds.stream().distinct().forEach(temp->{
this.askRestartDevice(temp, DeviceRebootType.LEDGER_MODIFY); // this.askRestartDevice(temp, DeviceRebootType.LEDGER_MODIFY);
} }
); );
list.forEach(temp->{ list.forEach(temp->{