From 2cc7564772cdf80b74b3043037375cca0b3d24c8 Mon Sep 17 00:00:00 2001 From: thesai <1021828630@qq.com> Date: Mon, 29 Jan 2024 14:42:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=A7=E7=94=B5=E5=99=A8?= =?UTF-8?q?=E9=A9=B1=E9=87=87=E8=A1=A8=E7=8A=B6=E6=80=81=EF=BC=9B=E4=BF=AE?= =?UTF-8?q?=E6=94=B9Repo=E6=9E=84=E5=BB=BA=E6=97=B6=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- repository/repo.bin | 657 ------------------------------- repository/repository_check.go | 32 +- repository/repository_manager.go | 6 +- 3 files changed, 27 insertions(+), 668 deletions(-) delete mode 100644 repository/repo.bin diff --git a/repository/repo.bin b/repository/repo.bin deleted file mode 100644 index 2c3b1af..0000000 --- a/repository/repo.bin +++ /dev/null @@ -1,657 +0,0 @@ - -1" -3 -3 -1" -5 -4 -2" -6 -5 -3" -11 -6 -4" -12 -15 -14" -17 -16 -8" -18 -17 -15" -20 -18 -16" -19 -21 -20" -22 -22 -21" -23 -23 -22" -25 -24 -19" -26 -25 -23" -29 -26 -24" -30 -29 -25" -32 -30 -26" -31 -31 -30" -34 -32 -29" -33 -33 -32" -36 -34 -31" -38 -36 -33" -42 -38 -34" -39 -44 -42" -45 -45 -44" -46 -46 -45" -47 -47 -46" -48 -48 -47 -50 -43" -51 -51 -50" -52 -52 -51" -53 -53 -52" -54 -54 -53 -379 -43 -1519 -8" -8 -1521 -19" -19 -1522 -20" -19 -1523 -41" -41 -1524 -42" -41 -39 -38" -40 -40 -39" -41 -2" -4 -1525812 -8" -8! -15261114 -11" -8 -152719 -19" -19 -152820 -20" -19" -15294143 -41" -41 -153042 -42" -41"+ -532 MAIN_LINE" -1" -3"- -533 MAIN_LINE" -2" -4"- -535 MAIN_LINE" -4" -6"+ -534 MAIN_LINE" -3" -5", -536 MAIN_LINE" -5" -11". -537 MAIN_LINE" -6" -12". -578 MAIN_LINE" -8" -11"- -579 MAIN_LINE" -12" -14"- -538 MAIN_LINE" -15" -14". -540 MAIN_LINE" -16" -8"- -539ܭ MAIN_LINE" -15" -17"/ -541ܭ MAIN_LINE" -16" -18"/ -543 MAIN_LINE" -18" -19"- -542 MAIN_LINE" -17" -20"- -580 MAIN_LINE" -19" -20"/ -548ꨅ MAIN_LINE" -24" -19"- -544… MAIN_LINE" -21" -20"- -545䀓 MAIN_LINE" -21" -22"- -546 MAIN_LINE" -22" -23"/ -549 MAIN_LINE" -24" -26"- -547 MAIN_LINE" -23" -25"- -550 MAIN_LINE" -25" -29"/ -551 MAIN_LINE" -26" -30"- -552 MAIN_LINE" -29" -32"- -555 MAIN_LINE" -32" -33"/ -554 MAIN_LINE" -31" -34"- -556 MAIN_LINE" -33" -36"/ -557 MAIN_LINE" -34" -38"/ -560 MAIN_LINE" -39" -40"- -558迤 MAIN_LINE" -36" -42"/ -561 MAIN_LINE" -40" -41"/ -582迤 MAIN_LINE" -41" -42"0 -572 MAIN_LINE" -379" -43"/ -567è MAIN_LINE" -50" -43"/ -568Ų MAIN_LINE" -50" -51"- -563Ų MAIN_LINE" -44" -45"- -562 MAIN_LINE" -44" -42"/ -569 MAIN_LINE" -51" -52"- -564 MAIN_LINE" -45" -46"- -565 MAIN_LINE" -46" -47"/ -570 MAIN_LINE" -52" -53"- -566ܟ MAIN_LINE" -47" -48"/ -571 MAIN_LINE" -53" -54"! -575 MAIN_LINE" -48"# -576 MAIN_LINE" -54" -573 MAIN_LINE" -1"" -574 MAIN_LINE" -2"/ -559 MAIN_LINE" -38" -39"/ -553 MAIN_LINE" -30" -31*7 -8 MAIN_LINE -16" -12* - -1519*5 -11 MAIN_LINE -5" -14* - -1519*6 -14 MAIN_LINE -15" -11* - -1519*8 -19 MAIN_LINE -18" -24* - -1521*6 -20 MAIN_LINE -21" -17* - -1521*: -41Ǡ MAIN_LINE - -1523" -43* - -1523*6 -42è MAIN_LINE -44" -36* - -1523*7 -43Ӣ MAIN_LINE -41" -50* -379*6 -12 MAIN_LINE -6" -8* - -15192 -212 MAIN_LINE12 -217 MAIN_LINE22 -484 MAIN_LINE32 -485DŽ MAIN_LINE22 -491 MAIN_LINE42 -492 MAIN_LINE15262 -493 MAIN_LINE15192# -494 MAIN_LINE" -112 -490ܽ MAIN_LINE32 -495 MAIN_LINE15262 -496 MAIN_LINE152 -497 MAIN_LINE162 -498 MAIN_LINE15222 -499 MAIN_LINE182 -500ش MAIN_LINE15222 -501م MAIN_LINE212 -502 MAIN_LINE15212 -504 MAIN_LINE222 -505 MAIN_LINE252 -506 MAIN_LINE262 -507ȶ MAIN_LINE252 -508ȶ MAIN_LINE302 -509 MAIN_LINE332 -510 MAIN_LINE342 -511馈 MAIN_LINE332 -512馈 MAIN_LINE342 -514 MAIN_LINE402 -515 MAIN_LINE15242 -516 MAIN_LINE15232# -518ۨ MAIN_LINE" -432! -519 MAIN_LINE" -422 -520 MAIN_LINE15232 -521 MAIN_LINE15232 -522ҭ MAIN_LINE442 -523ҭ MAIN_LINE502 -524 MAIN_LINE452 -525 MAIN_LINE512 -526 MAIN_LINE462 -527 MAIN_LINE522 -528 MAIN_LINE472 -529ޚ MAIN_LINE532 -530 MAIN_LINE482 -531 MAIN_LINE54: -1170 MAIN_LINE1: -1171 MAIN_LINE1: -1172 MAIN_LINE1: -1173 MAIN_LINE2: -1174 MAIN_LINE2: -1175 MAIN_LINE2: -1176 MAIN_LINE1: -1177 MAIN_LINE1: -1178 MAIN_LINE1: -1179ߘ MAIN_LINE2: -1180 MAIN_LINE2: -1181 MAIN_LINE2: -1182 MAIN_LINE1: -1183 MAIN_LINE1: -1184 MAIN_LINE2: -1185 MAIN_LINE2: -1186 MAIN_LINE5: -1187 MAIN_LINE5: -1188 MAIN_LINE5: -1189 MAIN_LINE5: -1190 MAIN_LINE6: -1191 MAIN_LINE5: -1192 MAIN_LINE5: -1193 MAIN_LINE5: -1194 MAIN_LINE5: -1195 MAIN_LINE5: -1196 MAIN_LINE5: -1197Ī MAIN_LINE5: -1198 MAIN_LINE5: -1199 MAIN_LINE6: -1200 MAIN_LINE6: -1201 MAIN_LINE6: -1202 MAIN_LINE6: -1203 MAIN_LINE6: -1204 MAIN_LINE6: -1205 MAIN_LINE6: -1206 MAIN_LINE6: -1207 MAIN_LINE6: -1208 MAIN_LINE6: -1209 MAIN_LINE6: -1210 MAIN_LINE15: -1211 MAIN_LINE16: -1212 MAIN_LINE17: -1213 MAIN_LINE17: -1214 MAIN_LINE17: -1215 MAIN_LINE17: -1216 MAIN_LINE17: -1217 MAIN_LINE17: -1218 MAIN_LINE17: -1219 MAIN_LINE17: -1220 MAIN_LINE17: -1221 MAIN_LINE17: -1224 MAIN_LINE18: -1225 MAIN_LINE18: -1226 MAIN_LINE18: -1227 MAIN_LINE18: -1228 MAIN_LINE18: -1229 MAIN_LINE18: -1230̞ MAIN_LINE18: -1231 MAIN_LINE18: -1232 MAIN_LINE18: -1233 MAIN_LINE18: -1234ҿ MAIN_LINE18: -1235ހ MAIN_LINE18: -1236 MAIN_LINE21: -1237 MAIN_LINE21: -1238 MAIN_LINE21: -1239 MAIN_LINE24: -1240 MAIN_LINE24: -1241ŏ MAIN_LINE22: -1242 MAIN_LINE22: -1243 MAIN_LINE22: -1244ض MAIN_LINE24: -1245 MAIN_LINE24: -1246 MAIN_LINE25: -1247آ MAIN_LINE25: -1248 MAIN_LINE25: -1249؟ MAIN_LINE25: -1250 MAIN_LINE25: -1251 MAIN_LINE25: -1252 MAIN_LINE25: -1253 MAIN_LINE25: -1254 MAIN_LINE25: -1255 MAIN_LINE25: -1256 MAIN_LINE26: -1257آ MAIN_LINE26: -1258 MAIN_LINE26: -1259؟ MAIN_LINE26: -1260 MAIN_LINE26: -1261 MAIN_LINE26: -1262 MAIN_LINE26: -1263 MAIN_LINE26: -1264 MAIN_LINE26: -1265 MAIN_LINE26: -1266 MAIN_LINE26: -1267 MAIN_LINE26: -1268 MAIN_LINE30: -1269 MAIN_LINE31: -1270 MAIN_LINE29: -1271 MAIN_LINE29: -1272 MAIN_LINE31: -1273 MAIN_LINE32: -1274 MAIN_LINE33: -1275 MAIN_LINE33: -1276 MAIN_LINE33: -1277 MAIN_LINE33: -1278 MAIN_LINE33: -1279ὄ MAIN_LINE33: -1280 MAIN_LINE33: -1281 MAIN_LINE33: -1282 MAIN_LINE33: -1283 MAIN_LINE33: -1284 MAIN_LINE33: -1285 MAIN_LINE33: -1286 MAIN_LINE34: -1287 MAIN_LINE34: -1288 MAIN_LINE34: -1289 MAIN_LINE34: -1290ȁ MAIN_LINE34: -1291 MAIN_LINE34: -1292 MAIN_LINE34: -1293 MAIN_LINE34: -1294 MAIN_LINE34: -1295 MAIN_LINE34: -1296 MAIN_LINE34: -1297 MAIN_LINE34: -1298 MAIN_LINE36: -1299 MAIN_LINE38: -1300Ԙ MAIN_LINE36: -1301ĥ MAIN_LINE1524: -1302 MAIN_LINE40: -1303ҟ MAIN_LINE40: -1304 MAIN_LINE40:" -1305ܥ MAIN_LINE" -42: -1306ť MAIN_LINE1523: -1307 MAIN_LINE44: -1308 MAIN_LINE44: -1309 MAIN_LINE44: -1310▪ MAIN_LINE44: -1311 MAIN_LINE44: -1312Į MAIN_LINE44: -1313 MAIN_LINE44: -1314⹯ MAIN_LINE44: -1315 MAIN_LINE44: -1316ꨱ MAIN_LINE44: -1317 MAIN_LINE44: -1318 MAIN_LINE44: -1319 MAIN_LINE50: -1320♩ MAIN_LINE50: -1321 MAIN_LINE50: -1322▪ MAIN_LINE50: -1323ϫ MAIN_LINE50: -1324ꅬ MAIN_LINE50: -1325Ĭ MAIN_LINE50: -1326 MAIN_LINE50: -1327 MAIN_LINE50: -1328ꨱ MAIN_LINE50: -1329 MAIN_LINE50: -1330 MAIN_LINE50: -1331õ MAIN_LINE45: -1332õ MAIN_LINE51: -1333ꖷ MAIN_LINE46: -1334 MAIN_LINE46: -1335ڳ MAIN_LINE46: -1336ꖷ MAIN_LINE52: -1337 MAIN_LINE52: -1338 MAIN_LINE52: -1339 MAIN_LINE47: -1340 MAIN_LINE47: -1341 MAIN_LINE47: -1342 MAIN_LINE53: -1343 MAIN_LINE53: -1344 MAIN_LINE53: -1345ɀ MAIN_LINE17: -1346 MAIN_LINE17:" -1347Ɍ MAIN_LINE" -20B1 -1356 MAIN_LINE MAIN_LINEB- -1378 MAIN_LINE MAIN_LINEB5 -1379 MAIN_LINEψ MAIN_LINEB5 -1382 MAIN_LINE MAIN_LINE߱B. -1385 MAIN_LINE MAIN_LINE݋B* -1386 MAIN_LINE MAIN_LINEB5 -1387 MAIN_LINE MAIN_LINEB* -1388 MAIN_LINE MAIN_LINEB- -1389 MAIN_LINEЁ MAIN_LINE.B* -1390Ё MAIN_LINE MAIN_LINEB9 -1391 MAIN_LINEψ MAIN_LINEB2 -1393 MAIN_LINE MAIN_LINEB. -1394 MAIN_LINE MAIN_LINEB9 -1395 MAIN_LINE MAIN_LINEB. -1396 MAIN_LINE MAIN_LINEB1 -1397 MAIN_LINEЁ MAIN_LINE.B. -1398Ё MAIN_LINE MAIN_LINEB5 -1399ψ MAIN_LINE MAIN_LINEB- -1400 MAIN_LINE MAIN_LINEB9 -1401ψ MAIN_LINE MAIN_LINEB9 -1402 MAIN_LINE MAIN_LINEB1 -1403 MAIN_LINE MAIN_LINEJ2 -1406 MAIN_LINE MAIN_LINE9J. -1433 MAIN_LINE MAIN_LINE:J* -1434 MAIN_LINEߓ MAIN_LINEJ* -1437 MAIN_LINE MAIN_LINEJ5 -1438 MAIN_LINE MAIN_LINEJ* -1439 MAIN_LINEȧ MAIN_LINEJ5 -1440ȧ MAIN_LINEȍ MAIN_LINEJ* -1441ȍ MAIN_LINE MAIN_LINEJ. -1442 MAIN_LINE MAIN_LINEJ* -1443 MAIN_LINE MAIN_LINEJ5 -1444 MAIN_LINE MAIN_LINEJ. -1445 MAIN_LINE۪ MAIN_LINEJ2 -1446۪ MAIN_LINEތ MAIN_LINEzJ. -1447ތ MAIN_LINE MAIN_LINEJ9 -1449ƿ MAIN_LINE MAIN_LINEJ. -1450 MAIN_LINE MAIN_LINEJ9 -1451 MAIN_LINE MAIN_LINEJ. -1452 MAIN_LINE MAIN_LINEJ2 -1453 MAIN_LINE MAIN_LINEJ. -1454 MAIN_LINE MAIN_LINEJ9 -1455 MAIN_LINE MAIN_LINEJ. -1456ߓ MAIN_LINE MAIN_LINE6J2 -1457 MAIN_LINE̺ MAIN_LINE3J. -1458̺ MAIN_LINEƿ MAIN_LINER# - MAIN_LINE  MAIN_LINER - MAIN_LINER - MAIN_LINER# - MAIN_LINE  MAIN_LINER - MAIN_LINER# -Ǡ MAIN_LINE  MAIN_LINER -è MAIN_LINER# -Ӣ MAIN_LINE  MAIN_LINER# - MAIN_LINE  MAIN_LINER - MAIN_LINER - MAIN_LINER -ψ MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINER -Ё MAIN_LINER - MAIN_LINER - MAIN_LINER -Ё MAIN_LINER - MAIN_LINER - MAIN_LINER -ψ MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINER -۪ MAIN_LINER -ތ MAIN_LINER - MAIN_LINER -̺ MAIN_LINER -ƿ MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINER -ߓ MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINER -ȧ MAIN_LINER -ȍ MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINER - MAIN_LINE \ No newline at end of file diff --git a/repository/repository_check.go b/repository/repository_check.go index d087c1c..09b1263 100644 --- a/repository/repository_check.go +++ b/repository/repository_check.go @@ -9,18 +9,25 @@ import ( // 对数据做基础检查 func baseCheck(source *proto.Repository) []string { var errMsg []string + uidMap := make(map[string]bool) //区段 - sectionMap := make(map[string]*proto.PhysicalSection) for _, section := range source.PhysicalSections { - sectionMap[section.Id] = section + if uidMap[section.Id] { + errMsg = append(errMsg, fmt.Sprintf("uid[%s]重复", section.Id)) + continue + } + uidMap[section.Id] = true if len(section.TurnoutIds) == 0 && section.ADevicePort == nil && section.BDevicePort == nil { errMsg = append(errMsg, fmt.Sprintf("区段[%s]缺少关联的道岔或区段", section.Id)) } } //道岔 - turnoutMap := make(map[string]*proto.Turnout) for _, turnout := range source.Turnouts { - turnoutMap[turnout.Id] = turnout + if uidMap[turnout.Id] { + errMsg = append(errMsg, fmt.Sprintf("uid[%s]重复", turnout.Id)) + continue + } + uidMap[turnout.Id] = true if turnout.Km == nil { errMsg = append(errMsg, fmt.Sprintf("道岔[%s]缺少公里标", turnout.Id)) } @@ -30,15 +37,23 @@ func baseCheck(source *proto.Repository) []string { } } //检测点 - checkPointMap := make(map[string]*proto.CheckPoint) for _, point := range source.CheckPoints { - checkPointMap[point.Id] = point + if uidMap[point.Id] { + errMsg = append(errMsg, fmt.Sprintf("uid[%s]重复", point.Id)) + continue + } + uidMap[point.Id] = true if point.Km == nil { errMsg = append(errMsg, fmt.Sprintf("检测点[%s]缺少公里标", point.Id)) } } //信号机 for _, signal := range source.Signals { + if uidMap[signal.Id] { + errMsg = append(errMsg, fmt.Sprintf("uid[%s]重复", signal.Id)) + continue + } + uidMap[signal.Id] = true if signal.Km == nil || signal.Km.CoordinateSystem == "" { errMsg = append(errMsg, fmt.Sprintf("信号机[%s]缺少公里标", signal.Id)) } @@ -48,6 +63,11 @@ func baseCheck(source *proto.Repository) []string { } //应答器 for _, transponder := range source.Transponders { + if uidMap[transponder.Id] { + errMsg = append(errMsg, fmt.Sprintf("uid[%s]重复", transponder.Id)) + continue + } + uidMap[transponder.Id] = true if transponder.Km == nil || transponder.Km.CoordinateSystem == "" { errMsg = append(errMsg, fmt.Sprintf("应答器[%s]缺少公里标", transponder.Id)) } diff --git a/repository/repository_manager.go b/repository/repository_manager.go index e18774e..33c56c6 100644 --- a/repository/repository_manager.go +++ b/repository/repository_manager.go @@ -17,11 +17,7 @@ var repositoryMap = make(map[string]*Repository) func BuildRepository(source *proto.Repository) (*Repository, error) { errMsg := baseCheck(source) if len(errMsg) != 0 { - println("-------------------- 数据异常信息 --------------------") - for _, s := range errMsg { - println(s) - } - return nil, errors.New("数据校验未通过") + return nil, errors.New(strings.Join(errMsg, "\n")) } repository := newRepository(source.Id, source.Version) err := buildModels(source, repository)