From 04b47b5e1682883b6cdba21d45d6e4af3cac19bf Mon Sep 17 00:00:00 2001 From: weizhihong Date: Fri, 21 Jul 2023 11:08:42 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E6=8A=A5=E9=94=99?= =?UTF-8?q?=EF=BC=8C=E5=8E=BB=E9=99=A4=E6=97=A0=E6=95=88=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=89=93=E5=8D=B0=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ats/cache/LineGraphicDataRepository.java | 50 +++++++++---------- .../xiannccda/GenerateProtoBufUtil.java | 38 ++++++++------ xian-ncc-da-message | 2 +- 3 files changed, 47 insertions(+), 43 deletions(-) diff --git a/src/main/java/club/joylink/xiannccda/ats/cache/LineGraphicDataRepository.java b/src/main/java/club/joylink/xiannccda/ats/cache/LineGraphicDataRepository.java index ef70163..3572c1d 100644 --- a/src/main/java/club/joylink/xiannccda/ats/cache/LineGraphicDataRepository.java +++ b/src/main/java/club/joylink/xiannccda/ats/cache/LineGraphicDataRepository.java @@ -36,13 +36,10 @@ public class LineGraphicDataRepository { private static final Map> lineCoordinateMain = new HashMap<>(); - /** - * 线路-设备code-设备 - */ - private static final HashBasedTable line_code_table = HashBasedTable.create(); - /** - * 线路-设备。由于现在许多设备code都是"",使用line_code_table会覆盖,临时加此map,后续删除 - */ + /** 线路-设备code-设备 */ + private static final HashBasedTable line_code_table = + HashBasedTable.create(); + /** 线路-设备。由于现在许多设备code都是"",使用line_code_table会覆盖,临时加此map,后续删除 */ private static final HashMap> line_map = new HashMap<>(); /** @@ -117,28 +114,30 @@ public class LineGraphicDataRepository { return line_map.get(lineId).stream() .filter(builder -> cls.isAssignableFrom(builder.getClass())) .map(builder -> (T) builder); -// return line_code_table.row(lineId).values().stream() -// .filter(builder -> cls.isAssignableFrom(builder.getClass())) -// .map(builder -> (T) builder); + // return line_code_table.row(lineId).values().stream() + // .filter(builder -> cls.isAssignableFrom(builder.getClass())) + // .map(builder -> (T) builder); } private static void fillLineCodeTable(Integer lineId, RtssGraphicStorage storage) { Short shortLineId = lineId.shortValue(); - List list = storage.getAllFields().entrySet().stream() - .filter(entry -> entry.getKey().isRepeated()) - .flatMap(entry -> ((List) entry.getValue()).stream()) - .collect(Collectors.toList()); + List list = + storage.getAllFields().entrySet().stream() + .filter(entry -> entry.getKey().isRepeated()) + .flatMap(entry -> ((List) entry.getValue()).stream()) + .collect(Collectors.toList()); line_map.put(shortLineId, list); -// storage.getAllFields().forEach((fd, value) -> { -// if (fd.isRepeated()) { -// List list = (List) value; -// for (MessageOrBuilder builder : list) { -// FieldDescriptor fieldDescriptor = builder.getDescriptorForType().findFieldByName("code"); -// String code = (String) builder.getField(fieldDescriptor); -// line_code_table.put(shortLineId, code, builder); -// } -// } -// }); + // storage.getAllFields().forEach((fd, value) -> { + // if (fd.isRepeated()) { + // List list = (List) value; + // for (MessageOrBuilder builder : list) { + // FieldDescriptor fieldDescriptor = + // builder.getDescriptorForType().findFieldByName("code"); + // String code = (String) builder.getField(fieldDescriptor); + // line_code_table.put(shortLineId, code, builder); + // } + // } + // }); } /** @@ -404,9 +403,6 @@ public class LineGraphicDataRepository { if (sectionMap.containsKey(sid)) { DeviceInfoProto.Section.Builder sectionBuilder = (DeviceInfoProto.Section.Builder) sectionMap.get(sid); - if (sectionBuilder.getPhysicalSectionId().equals("118")) { - log.info(""); - } sectionBuilder.setCode(section.getCode()); // 获取到物理区段信息 DeviceInfoProto.Section.Builder physicalSection = diff --git a/src/test/java/club/joylink/xiannccda/GenerateProtoBufUtil.java b/src/test/java/club/joylink/xiannccda/GenerateProtoBufUtil.java index 5aa4e16..da218a7 100644 --- a/src/test/java/club/joylink/xiannccda/GenerateProtoBufUtil.java +++ b/src/test/java/club/joylink/xiannccda/GenerateProtoBufUtil.java @@ -10,22 +10,25 @@ import org.assertj.core.util.Lists; public class GenerateProtoBufUtil { - private final static String EXE_BIN_FILE = String.join(File.separator, - System.getProperty("user.dir"), "xian-ncc-da-message", - "protoc-23.1", "bin", "win64", - "protoc"); + private static final String EXE_BIN_FILE = + String.join( + File.separator, + System.getProperty("user.dir"), + "xian-ncc-da-message", + "protoc-23.1", + "bin", + "win64", + "protoc"); private File protoFilePath; private String outPath; private boolean pullMessage; -// private String gitPullPath; + // private String gitPullPath; public GenerateProtoBufUtil(String rootPath, boolean pullMessage) { this.pullMessage = pullMessage; - String sourcePath = String.join(File.separator, rootPath, - "xian-ncc-da-message", "protos"); + String sourcePath = String.join(File.separator, rootPath, "xian-ncc-da-message", "protos"); - this.outPath = String.join(File.separator, rootPath, - "src", "main", "java"); + this.outPath = String.join(File.separator, rootPath, "src", "main", "java"); this.protoFilePath = new File(sourcePath); if (!protoFilePath.exists() || !protoFilePath.isDirectory()) { throw new RuntimeException("proto不是目录或目录不存在"); @@ -41,9 +44,14 @@ public class GenerateProtoBufUtil { this.PullTmmsMessage(); } for (File file : this.findFiles()) { - String command = String.format("%s --proto_path=%s -I=%s --java_out=%s %s", EXE_BIN_FILE, - this.protoFilePath.getPath(), file.getParentFile().getAbsolutePath(), this.outPath, - file.getName()); + String command = + String.format( + "%s --proto_path=%s -I=%s --java_out=%s %s", + EXE_BIN_FILE, + this.protoFilePath.getPath(), + file.getParentFile().getAbsolutePath(), + this.outPath, + file.getName()); this.genertateFile(command); } } @@ -74,8 +82,8 @@ public class GenerateProtoBufUtil { } private void PullTmmsMessage() throws IOException { - InputStream inputStream = Runtime.getRuntime() - .exec("git pull", null, protoFilePath).getInputStream(); + InputStream inputStream = + Runtime.getRuntime().exec("git pull", null, protoFilePath).getInputStream(); byte[] ebs = new byte[512]; StringBuilder sb = new StringBuilder(); int size; @@ -87,7 +95,7 @@ public class GenerateProtoBufUtil { } public static void main(String[] args) throws IOException { - GenertateProtoBufUtil gu = new GenertateProtoBufUtil(System.getProperty("user.dir"), true); + GenerateProtoBufUtil gu = new GenerateProtoBufUtil(System.getProperty("user.dir"), true); gu.execCommand(); } } diff --git a/xian-ncc-da-message b/xian-ncc-da-message index e521fa9..edc9973 160000 --- a/xian-ncc-da-message +++ b/xian-ncc-da-message @@ -1 +1 @@ -Subproject commit e521fa9d3372987b45a4d9bdb63544cf4e1f088f +Subproject commit edc9973662bc4f02198f72919de9408fa9ea9043