模拟设备状态变更接口调整
This commit is contained in:
parent
b706a19245
commit
bea73f80fb
@ -84,7 +84,7 @@ public class TrainIndicationInitResponse extends MessageResponse {
|
|||||||
}
|
}
|
||||||
builder.setRollingStock(trainCell.getRollingStock());
|
builder.setRollingStock(trainCell.getRollingStock());
|
||||||
builder.setDriverId(StringUtils.defaultString(trainCell.getDriverId(), ""));
|
builder.setDriverId(StringUtils.defaultString(trainCell.getDriverId(), ""));
|
||||||
|
|
||||||
if (trainCell.getOtpTime() != null) {
|
if (trainCell.getOtpTime() != null) {
|
||||||
builder.setOtpTime(trainCell.getOtpTime());
|
builder.setOtpTime(trainCell.getOtpTime());
|
||||||
}
|
}
|
||||||
@ -151,7 +151,7 @@ public class TrainIndicationInitResponse extends MessageResponse {
|
|||||||
/**
|
/**
|
||||||
* 目的地号(4)
|
* 目的地号(4)
|
||||||
*/
|
*/
|
||||||
private Integer destinationId;
|
private String destinationId;
|
||||||
/**
|
/**
|
||||||
* 编组数量(1)
|
* 编组数量(1)
|
||||||
*/
|
*/
|
||||||
@ -209,7 +209,8 @@ public class TrainIndicationInitResponse extends MessageResponse {
|
|||||||
buf.readBytes(groupId);
|
buf.readBytes(groupId);
|
||||||
buf.readBytes(trainId);
|
buf.readBytes(trainId);
|
||||||
buf.readBytes(globalId);
|
buf.readBytes(globalId);
|
||||||
this.destinationId = buf.readInt();
|
this.destinationId = EntityParseUtil.convertStr(buf, 4);
|
||||||
|
|
||||||
this.rollingStock = buf.readByte();
|
this.rollingStock = buf.readByte();
|
||||||
buf.readBytes(driverId);
|
buf.readBytes(driverId);
|
||||||
this.otpTime = buf.readInt();
|
this.otpTime = buf.readInt();
|
||||||
|
@ -87,7 +87,7 @@ public class GenertateProtoBufUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
GenertateProtoBufUtil gu = new GenertateProtoBufUtil(System.getProperty("user.dir"), false);
|
GenertateProtoBufUtil gu = new GenertateProtoBufUtil(System.getProperty("user.dir"), true);
|
||||||
gu.execCommand();
|
gu.execCommand();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ public class TrainDataTest {
|
|||||||
/**
|
/**
|
||||||
* 目的地号(4)
|
* 目的地号(4)
|
||||||
*/
|
*/
|
||||||
updateResponse.setDestinationId(1);
|
// updateResponse.setDestinationId(1);
|
||||||
/**
|
/**
|
||||||
* 编组数量(1)
|
* 编组数量(1)
|
||||||
*/
|
*/
|
||||||
|
151
src/test/java/club/joylink/xiannccda/util/CollectorData.java
Normal file
151
src/test/java/club/joylink/xiannccda/util/CollectorData.java
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
package club.joylink.xiannccda.util;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.ats.message.MessageResponse;
|
||||||
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||||
|
import club.joylink.xiannccda.ats.message.line3.rep.DeviceStatusBitmapResponse;
|
||||||
|
import club.joylink.xiannccda.ats.message.line3.rep.DeviceStatusBitmapResponse.DeviceEntity;
|
||||||
|
import club.joylink.xiannccda.ats.message.line3.rep.DeviceStatusBitmapResponse.DeviceTypeEntity;
|
||||||
|
import club.joylink.xiannccda.ats.message.line3.rep.TrainIndicationUpdateResponse;
|
||||||
|
import club.joylink.xiannccda.mock.message.NccMockData;
|
||||||
|
import club.joylink.xiannccda.mock.message.NccMockDataService;
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.google.common.collect.HashBasedTable;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Table;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.Unpooled;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
public class CollectorData {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
NccMockDataService nccMockDataService;
|
||||||
|
|
||||||
|
/* @Test
|
||||||
|
public void dd() throws UnsupportedEncodingException {
|
||||||
|
|
||||||
|
LambdaQueryWrapper<NccMockData> queryWrapper = Wrappers.<NccMockData>lambdaQuery();
|
||||||
|
queryWrapper.eq(NccMockData::getMsgId, "TRAIN_INDICATION_UPDATE");
|
||||||
|
List<MessageResponse> datas = this.nccMockDataService.loadALLData(queryWrapper);
|
||||||
|
List<TrainIndicationUpdateResponse> bitmapResponses = datas.stream().map(d -> (TrainIndicationUpdateResponse) d).collect(Collectors.toList());
|
||||||
|
Set<String> sets = new HashSet<>();
|
||||||
|
|
||||||
|
for (TrainIndicationUpdateResponse bitmapRespons : bitmapResponses) {
|
||||||
|
ByteBuf buf = Unpooled.buffer();
|
||||||
|
|
||||||
|
// buf.writeInt(842413824);
|
||||||
|
buf.writeInt(bitmapRespons.getDestinationId());
|
||||||
|
byte[] dd = new byte[4];
|
||||||
|
buf.readBytes(dd);
|
||||||
|
String s = new String(dd, "utf-8");
|
||||||
|
if (StringUtils.isEmpty(s.trim())) {
|
||||||
|
System.out.println(bitmapRespons);
|
||||||
|
}
|
||||||
|
sets.add(s);
|
||||||
|
}
|
||||||
|
System.out.println(sets);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void collector() {
|
||||||
|
|
||||||
|
Table<DeviceType, String, List<String>> dataTable = this.loadData();
|
||||||
|
|
||||||
|
JSONObject jo = this.readData();
|
||||||
|
for (DeviceType deviceType : dataTable.rowKeySet()) {
|
||||||
|
Map<String, List<String>> maps = dataTable.row(deviceType);
|
||||||
|
File file = new File("d:\\usr\\" + deviceType.name());
|
||||||
|
if (file.exists()) {
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
maps.forEach((k, v) -> {
|
||||||
|
|
||||||
|
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true)))) {
|
||||||
|
Map<Boolean, List<String>> findMaper = Device.match(v, deviceType, jo);
|
||||||
|
writer.write(String.format("集中站:%s \n", k));
|
||||||
|
for (Boolean aBoolean : findMaper.keySet()) {
|
||||||
|
writer.write("\t\t" + aBoolean + "\n");
|
||||||
|
writer.write("\t\t" + JSON.toJSONString(findMaper.get(aBoolean)) + "\n");
|
||||||
|
}
|
||||||
|
writer.write("-----------------------------------\n");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Table<DeviceType, String, List<String>> loadData() {
|
||||||
|
LambdaQueryWrapper<NccMockData> queryWrapper = Wrappers.<NccMockData>lambdaQuery();
|
||||||
|
queryWrapper.eq(NccMockData::getMsgId, "DEVICE_STATUS_BITMAP");
|
||||||
|
|
||||||
|
List<MessageResponse> datas = this.nccMockDataService.loadALLData(queryWrapper);
|
||||||
|
List<DeviceStatusBitmapResponse> bitmapResponses = datas.stream().map(d -> (DeviceStatusBitmapResponse) d).collect(Collectors.toList());
|
||||||
|
Table<DeviceType, String, List<String>> dataTable = HashBasedTable.create();
|
||||||
|
List<String> dd = Lists.newArrayList();
|
||||||
|
for (DeviceStatusBitmapResponse bitmapRespons : bitmapResponses) {
|
||||||
|
String rtuId = bitmapRespons.getRtuId().toString();
|
||||||
|
for (DeviceTypeEntity deviceTypeEntity : bitmapRespons.getEntityList()) {
|
||||||
|
DeviceType dt = deviceTypeEntity.getType();
|
||||||
|
if (!dd.contains(dt.name())) {
|
||||||
|
dd.add(dt.name());
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isNotEmpty(deviceTypeEntity.getDeviceList())) {
|
||||||
|
for (DeviceEntity deviceEntity : deviceTypeEntity.getDeviceList()) {
|
||||||
|
String deviceName = deviceEntity.getDevName();
|
||||||
|
List<String> deviceList = dataTable.get(dt, rtuId);
|
||||||
|
if (Objects.isNull(deviceList)) {
|
||||||
|
deviceList = Lists.newArrayList();
|
||||||
|
}
|
||||||
|
if (!deviceList.contains(deviceName)) {
|
||||||
|
deviceList.add(deviceName);
|
||||||
|
}
|
||||||
|
dataTable.put(dt, rtuId, deviceList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dataTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private JSONObject readData() {
|
||||||
|
|
||||||
|
try (BufferedReader reader = new BufferedReader(new FileReader("G:\\map.txt"))) {
|
||||||
|
String content = null;
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
while ((content = reader.readLine()) != null) {
|
||||||
|
sb.append(content);
|
||||||
|
}
|
||||||
|
return JSON.parseObject(sb.toString());
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1 +1 @@
|
|||||||
Subproject commit 2b1cf46a4bece01bce4b3269e4fcf094f8117492
|
Subproject commit f86b35768560ddd4e2a3bef70c9b8dfe42510d8f
|
Loading…
Reference in New Issue
Block a user