WorkStart.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. using PlcSiemens.Core.Extension;
  2. using ServiceCenter;
  3. using ServiceCenter.SqlSugars;
  4. using WCS.Core;
  5. using WCS.Entity;
  6. using WCS.Entity.Protocol.Protocol.BCR;
  7. using WCS.Entity.Protocol.Protocol.RGV;
  8. using WCS.Entity.Protocol.Protocol.Robot;
  9. using WCS.Entity.Protocol.Protocol.SRM;
  10. using WCS.Entity.Protocol.Protocol.Station;
  11. using WCS.Entity.Protocol.Protocol.Truss;
  12. using WCS.WorkEngineering.Extensions;
  13. using WCS.WorkEngineering.Systems;
  14. using DeviceFlags = WCS.WorkEngineering.Extensions.DeviceFlags;
  15. namespace WCS.WorkEngineering
  16. {
  17. /// <summary>
  18. /// 业务工程配置信息
  19. /// </summary>
  20. public static class WorkStart
  21. {
  22. /// <summary>
  23. /// 初始化 设备信息
  24. /// </summary>
  25. public static void InitializeDeviceInfo()
  26. {
  27. #region 无交互触发设备
  28. var devs = new List<string>() { nameof(分线计算09), nameof(桁架码垛区补空托盘任务生成), "出库AGV", "入库AGV",nameof(NoInteractionSystems) };
  29. foreach (var conv in devs.Select(code => new Device(code)))
  30. {
  31. conv.AddProtocol<IStation520>(0, 520, "1");
  32. }
  33. #endregion 无交互触发设备
  34. #region 设置设备IP集合
  35. ServiceHub.DeviceIPList = new List<string>() { };
  36. #endregion 设置设备IP集合
  37. #region 初始化RGV相关信息
  38. List<RgvSegmentInfo> RgvInfo = new List<RgvSegmentInfo>
  39. {
  40. new RgvSegmentInfo( 1, "10.30.37.113"),
  41. //new RGVSegmentInfo( 2, "10.30.37.118"),
  42. //new RGVSegmentInfo( 3, "10.30.37.123"),
  43. //new RGVSegmentInfo( 4, "10.30.37.128"),
  44. //new RGVSegmentInfo( 5, "10.30.37.133"),
  45. //new RGVSegmentInfo( 6, "10.30.37.138")
  46. };
  47. foreach (var item in RgvInfo)
  48. {
  49. var conv = new Device($"RGV{item.Code}");
  50. conv.AddFlag(DeviceFlags.RGV);
  51. conv.AddProtocol<IRGV520>(0, 520, item.Ip);
  52. conv.AddProtocol<IRGV521>(0, 521, item.Ip);
  53. //conv.AddProtocol<IStation523>(, 523, item.IP);
  54. }
  55. #endregion 初始化RGV相关信息
  56. #region 初始化输送机相关信息
  57. #region 基本信息
  58. #region 托盘线输送线
  59. var tuples = new List<Tuple<string, List<Tuple<int, int>>>>
  60. {
  61. new("10.30.37.89",new List<Tuple<int, int>>()
  62. {
  63. new(1601, 1620),
  64. new(2501, 2540),
  65. new(2701, 2740),
  66. new(1661, 1690),
  67. })
  68. };
  69. foreach (var item in tuples)
  70. {
  71. var db520 = 0;
  72. var db521 = 0;
  73. var db523 = 0;
  74. foreach (var item1 in item.Item2)
  75. {
  76. for (var i = item1.Item1; i <= item1.Item2; i++)
  77. {
  78. var conv = new Device(i.ToString());
  79. conv.AddFlag(DeviceFlags.输送机);
  80. conv.AddProtocol<IStation520>(db520, 520, item.Item1);
  81. conv.AddProtocol<IStation521>(db521, 521, item.Item1);
  82. conv.AddProtocol<IStation523>(db523, 523, item.Item1);
  83. db520 += 14;
  84. db521 += 16;
  85. db523 += 12;
  86. }
  87. }
  88. }
  89. #endregion 托盘线输送线
  90. #region 满轮输送线
  91. #region DB523,所有线体都会有DB523
  92. var mLtuples523 = new List<Tuple<string, List<Tuple<int, int>>>>()
  93. {
  94. new("10.30.37.166",new List<Tuple<int, int>>()
  95. {
  96. new(1, 110),
  97. new(401, 599),
  98. })
  99. };
  100. foreach (var item in mLtuples523)
  101. {
  102. var db523 = 0;
  103. var db524 = 0;
  104. foreach (var item1 in item.Item2)
  105. {
  106. for (var i = item1.Item1; i <= item1.Item2; i++)
  107. {
  108. var conv = new Device(i.ToString());
  109. conv.AddFlag(DeviceFlags.输送机);
  110. conv.AddProtocol<IStation523>(db523, 523, item.Item1);
  111. conv.AddProtocol<IStation524>(db524, 524, item.Item1);
  112. db523 += 12;
  113. db524 += 16;
  114. }
  115. }
  116. }
  117. #endregion DB523,所有线体都会有DB523
  118. #region 520、521 交互线体会有520、521
  119. //Item2表示线体号集合,Item1表示IP
  120. var mLTuples520 = new List<Tuple<string, List<int>>>()
  121. {
  122. new("10.30.37.166",new List<int>(){1,22,41,61,418,426,435,444,455,466,480,494,508,522,536,550,564,578})
  123. };
  124. foreach (var item in mLTuples520)
  125. {
  126. var db520 = 0;
  127. var db521 = 0;
  128. foreach (var device in item.Item2.Select(item1 => Device.All.FirstOrDefault(v => v.Code == item1.ToString())))
  129. {
  130. if (device != null)
  131. {
  132. device.AddProtocol<IStation520>(db520, 520, item.Item1);
  133. device.AddProtocol<IStation521>(db521, 521, item.Item1);
  134. }
  135. db520 += 14;
  136. db521 += 16;
  137. }
  138. }
  139. #endregion 520、521 交互线体会有520、521
  140. #region 满轮扫码器
  141. //Item2表示线体号集合,Item1表示IP
  142. var mLTuples83 = new List<Tuple<string, List<int>>>()
  143. {
  144. new("10.30.37.166",new List<int>(){1,22,41,61,18})
  145. };
  146. foreach (var item in mLTuples83)
  147. {
  148. var db83 = 0;
  149. foreach (var device in item.Item2.Select(item1 => Device.All.FirstOrDefault(v => v.Code == item1.ToString())))
  150. {
  151. device?.AddProtocol<IBCR83>(db83, 83, item.Item1);
  152. db83 += 604;
  153. }
  154. }
  155. #endregion 满轮扫码器
  156. #region 满轮线告诉分拣预分配
  157. //Item2表示线体号集合,Item1表示IP
  158. var mLTuples525 = new List<Tuple<string, List<int>>>()
  159. {
  160. new("10.30.37.166",new List<int>(){18})
  161. };
  162. foreach (var item in mLTuples525)
  163. {
  164. var db525 = 0;
  165. foreach (var device in item.Item2.Select(item1 => Device.All.FirstOrDefault(v => v.Code == item1.ToString())))
  166. {
  167. device?.AddProtocol<IStation525>(db525, 525, item.Item1);
  168. db525 += 3266;
  169. }
  170. }
  171. #endregion 满轮线告诉分拣预分配
  172. #region 外检信息
  173. //Item2表示线体号集合,Item1表示IP
  174. var mLTuples91 = new List<Tuple<string, List<int>>>()
  175. {
  176. new("10.30.37.166",new List<int>(){418})
  177. };
  178. foreach (var item in mLTuples91)
  179. {
  180. var db91 = 0;
  181. foreach (var device in item.Item2.Select(item2 => Device.All.FirstOrDefault(v => v.Code == item2.ToString())))
  182. {
  183. device?.AddProtocol<IStation91>(db91, 91, item.Item1);
  184. db91 += 14;
  185. }
  186. }
  187. #endregion 外检信息
  188. #endregion 满轮输送线
  189. #endregion 基本信息
  190. #region 托盘线扫码器
  191. var bcrInfo = new List<BcrInfo>
  192. {
  193. new(new [] { "2532", "2732" }, "10.30.37.89"),
  194. new(new [] {"RGV1"},"10.30.37.113")
  195. };
  196. foreach (var item in bcrInfo)
  197. {
  198. for (var i = 0; i < item.DeviceNo.Length; i++)
  199. {
  200. var device = Device.All.FirstOrDefault(v => v.Code == item.DeviceNo[i]);
  201. device.AddFlag(DeviceFlags.扫码);
  202. var pos = i * 20;
  203. device.AddProtocol<IBCR81>(pos, 81, item.Ip);
  204. }
  205. }
  206. #endregion 托盘线扫码器
  207. #region 外检信息
  208. List<ShapeInfo> shapeInfo = new List<ShapeInfo>
  209. {
  210. new ShapeInfo(new int[] { 2732,2532 }, "10.30.37.89")
  211. };
  212. foreach (var item in shapeInfo)
  213. {
  214. for (int i = 0; i < item.DeviceNo.Length; i++)
  215. {
  216. var conv = Device.All.FirstOrDefault(x => x.Code == item.DeviceNo[i].ToString());
  217. conv.AddFlag(DeviceFlags.外检);
  218. int pos = i * 14;
  219. conv.AddProtocol<IStation91>(pos, 91, item.Ip);
  220. }
  221. }
  222. #endregion 外检信息
  223. #endregion 初始化输送机相关信息
  224. #region 初始化桁架相关信息
  225. List<TrussSegmentInfo> TrussInfo = new List<TrussSegmentInfo>
  226. {
  227. new TrussSegmentInfo( 1, "10.30.37.211"),
  228. };
  229. foreach (var item in TrussInfo)
  230. {
  231. var conv = new Device($"Truss{item.Code}");
  232. conv.AddFlag(DeviceFlags.桁架);
  233. conv.AddProtocol<ITruss520>(0, 520, item.Ip);
  234. conv.AddProtocol<ITruss521>(0, 521, item.Ip);
  235. conv.AddProtocol<ITruss523>(0, 523, item.Ip);
  236. }
  237. var tuples1 = new List<Tuple<string, List<int>>>
  238. {
  239. //桁架
  240. //new("10.30.37.211",new List<int>(){1662,1663,1664,1665,1670,1671,1672,1673,1674,1675,1677,1678,1679,1680,1685,1686,1687,1688,1689,1690}),
  241. new("10.30.37.211",new List<int>(){1685,1686,1687,1688,1689,1690,1675,1674,1673,1672,1671,1670,1677,1678,1679,1680,1665,1664,1663,1662}),
  242. //机械臂
  243. new("10.30.37.230",new List<int>(){ 1666, 1661}),
  244. };
  245. foreach (var item in tuples1)
  246. {
  247. var db530 = 0;
  248. var db531 = 0;
  249. foreach (var conv in item.Item2.Select(item1 => Device.All.FirstOrDefault(x => x.Code == item1.ToString())))
  250. {
  251. if (item.Item1 == "10.30.37.211")
  252. {
  253. conv!.AddProtocol<ITruss530>(db530, 530, item.Item1);
  254. conv!.AddProtocol<ITruss531>(db531, 531, item.Item1);
  255. db530 += 8;
  256. db531 += 250;
  257. }
  258. else
  259. {
  260. conv!.AddProtocol<IRobot530>(db530, 530, item.Item1);
  261. conv!.AddProtocol<IRobot531>(db531, 531, item.Item1);
  262. db530 += 8;
  263. db531 += 130;
  264. }
  265. }
  266. }
  267. #endregion 初始化桁架相关信息
  268. #region 初始化机械臂相关信息
  269. List<TrussSegmentInfo> TrussInfo1 = new List<TrussSegmentInfo>
  270. {
  271. new TrussSegmentInfo( 1, "10.30.37.230"),
  272. };
  273. foreach (var item in TrussInfo1)
  274. {
  275. var conv = new Device($"Robot{item.Code}");
  276. conv.AddFlag(DeviceFlags.Robot);
  277. conv.AddProtocol<IRobot520>(0, 520, item.Ip);
  278. conv.AddProtocol<IRobot521>(0, 521, item.Ip);
  279. conv.AddProtocol<IRobot522>(0, 522, item.Ip);
  280. //conv.AddProtocol<IRobot530>(0, 521, item.Ip);
  281. //conv.AddProtocol<IRobot531>(0, 522, item.Ip);
  282. }
  283. #endregion 初始化机械臂相关信息
  284. #region 初始化堆垛机相关信息
  285. int ip = 41;
  286. for (int i = 0; i <= 1; i++)
  287. {
  288. var srm = new Device($"SRM{i + 1}");
  289. srm.AddFlag(DeviceFlags.堆垛机);
  290. ip = i == 0 ? ip : ip + 8;
  291. //三台堆垛机IP主机位分别是 41、49、57、65、73、81
  292. srm.AddProtocol<ISRM520>(0, 520, $"10.30.37.{ip}");
  293. srm.AddProtocol<ISRM521>(0, 521, $"10.30.37.{ip}");
  294. srm.AddProtocol<ISRM537>(0, 537, $"10.30.37.{ip}");
  295. //增加巷道
  296. var tunnel = new Device($"TY{i + 1}");
  297. tunnel.AddFlag(DeviceFlags.巷道);
  298. }
  299. #endregion 初始化堆垛机相关信息
  300. #region 配置路径信息
  301. List<RouteInfo> routeInfos = new List<RouteInfo>();
  302. #region 分拣库一
  303. routeInfos.AddRange(new List<RouteInfo>() {
  304. #region 出库路径
  305. //堆垛机--巷道
  306. new RouteInfo("SRM1", new string[] { "TY1" }),
  307. new RouteInfo("SRM2", new string[] { "TY2" }),
  308. //巷道--一楼堆垛机放货口
  309. new RouteInfo("TY1", new string[] { "2532" }), //人工取货口
  310. new RouteInfo("TY2", new string[] { "2732" }),
  311. new RouteInfo("TY1", new string[] { "2534","2533" }),//AGV取货口
  312. new RouteInfo("TY2", new string[] { "2734","2733" }),
  313. //巷道--二楼堆垛机放货口
  314. new RouteInfo("TY1", new string[] { "1601","1605" }),
  315. new RouteInfo("TY2", new string[] { "1611","1615" }),
  316. //二楼堆垛机放货口--二楼拆盘机
  317. new RouteInfo("1601", new string[] { "1602" }),//非09拆盘机
  318. new RouteInfo("1611", new string[] { "1612"}),
  319. new RouteInfo("1605", new string[] { "1606" }),//09拆盘机
  320. new RouteInfo("1615", new string[] { "1616" }),
  321. //二楼拆盘机--RGV
  322. new RouteInfo("1602", new string[] { "RGV1" }),//非09拆盘机
  323. //new RouteInfo("1612", new string[] { "RGV2"}),
  324. new RouteInfo("1606", new string[] { "RGV1" }),//09拆盘机
  325. //new RouteInfo("1616", new string[] { "RGV2" }),
  326. //RGV--码垛区域
  327. new RouteInfo("RGV1", new string[] { "1661","1666" }),//北区机械臂码垛区
  328. //new RouteInfo("RGV2", new string[] { }),//南区机械臂
  329. new RouteInfo("RGV1", new string[] { "1662","1663","1664","1665", "1670","1671","1672","1673","1674","1675"}),//桁架北区码垛站台
  330. //new RouteInfo("RGV2", new string[] { }),//南区桁架
  331. //Robot码垛工位
  332. new RouteInfo("Robot1", new string[] { "1666" }),
  333. #endregion 出库路径
  334. #region 入库
  335. //一楼人工入库口-巷道
  336. new RouteInfo("2532", new string[] { "TY1" }),
  337. new RouteInfo("2732", new string[] { "TY2" }),
  338. //一楼叠盘机(堆垛机入口)--巷道
  339. new RouteInfo("2527", new string[] { "TY1" }),
  340. new RouteInfo("2528", new string[] { "TY1" }),
  341. new RouteInfo("2727", new string[] { "TY2" }),
  342. new RouteInfo("2728", new string[] { "TY2" }),
  343. //一楼AGV入口
  344. //主线入口--预分配点
  345. new RouteInfo("1", new string[] { "18" }),
  346. //预分配点--主线分流点
  347. new RouteInfo("18", new string[] { "22" }),
  348. //主线分流点--环形库分流点
  349. new RouteInfo("22", new string[] { "418" }),
  350. //环形库分流点--环形库取货点
  351. new RouteInfo("418", new string[] { "424","433","442" }),
  352. //环形库分流点--桁架分流点
  353. new RouteInfo("418", new string[] { "455" }),
  354. //桁架分流点--桁架缓存放行点
  355. new RouteInfo("455", new string[] { "466","480","494","508", "522","536","550","564","578"}),
  356. //桁架分流点--异常缓存放行点
  357. new RouteInfo("455", new string[] { "491" }),
  358. //桁架缓存放行点--桁架取货点
  359. new("466", new[] { "461" }),
  360. new("480", new[] { "475" }),
  361. new("494", new[] { "489" }),
  362. new("508", new[] { "503" }),
  363. new("522", new[] { "517" }),
  364. new("536", new[] { "531" }),
  365. new("550", new[] { "545" }),
  366. new("564", new[] { "559" }),
  367. new("578", new[] { "573" }),
  368. //桁架取货点--桁架
  369. new("461", new[] { "Truss1" }),
  370. new("475", new[] { "Truss1" }),
  371. new("489", new[] { "Truss1" }),
  372. new("503", new[] { "Truss1" }),
  373. new("517", new[] { "Truss1" }),
  374. new("531", new[] { "Truss1" }),
  375. new("545", new[] { "Truss1" }),
  376. new("559", new[] { "Truss1" }),
  377. new("573", new[] { "Truss1" }),
  378. //桁架--码垛工位
  379. new("Truss1", new[] { "1662" }),
  380. new("Truss1", new[] { "1663" }),
  381. new("Truss1", new[] { "1664" }),
  382. new("Truss1", new[] { "1665" }),
  383. new("Truss1", new[] { "1670" }),
  384. new("Truss1", new[] { "1671" }),
  385. new("Truss1", new[] { "1672" }),
  386. new("Truss1", new[] { "1673" }),
  387. new("Truss1", new[] { "1674" }),
  388. new("Truss1", new[] { "1675" }),
  389. //码垛工位--RGV
  390. new RouteInfo("1661", new string[] { "RGV1" }),//机械手码垛工位
  391. new RouteInfo("1666", new string[] { "RGV1" }),
  392. new RouteInfo("1662", new string[] { "RGV1" }),//绗架码垛工位
  393. new RouteInfo("1663", new string[] { "RGV1" }),
  394. new RouteInfo("1664", new string[] { "RGV1" }),
  395. new RouteInfo("1665", new string[] { "RGV1" }),
  396. new RouteInfo("1670", new string[] { "RGV1" }),
  397. new RouteInfo("1671", new string[] { "RGV1" }),
  398. new RouteInfo("1672", new string[] { "RGV1" }),
  399. new RouteInfo("1673", new string[] { "RGV1" }),
  400. new RouteInfo("1674", new string[] { "RGV1" }),
  401. new RouteInfo("1675", new string[] { "RGV1" }),
  402. //RGV--RGV放货点
  403. new RouteInfo("RGV1", new string[] { "1604" }),
  404. //RGV放货点--堆垛机取货口
  405. new RouteInfo("1604", new string[] { "1603" }),//北侧
  406. //二楼堆垛机入库--巷道
  407. new RouteInfo("1603", new string[] { "TY1" }),//北侧
  408. new RouteInfo("1613", new string[] { "TY2" }),//南侧
  409. //巷道--堆垛机
  410. new RouteInfo("TY1", new string[] { "SRM1" }),
  411. new RouteInfo("TY2", new string[] { "SRM2" }),
  412. //线体取货位--Robot
  413. new RouteInfo("442", new string[] { "Robot1" }),
  414. new RouteInfo("433", new string[] { "Robot1" }),
  415. new RouteInfo("424", new string[] { "Robot1" }),
  416. #endregion 入库
  417. });
  418. #endregion 分拣库一
  419. foreach (var item in routeInfos)
  420. {
  421. var device = Device.All.FirstOrDefault(x => x.Code == item.DeviceCode);
  422. device.AddTarget(item.NextList);
  423. foreach (var next in item.NextList)
  424. {
  425. var dev = Device.All.FirstOrDefault(x => x.Code == next);
  426. dev.Parent = device;
  427. }
  428. }
  429. #endregion 配置路径信息
  430. #region 添加设备组
  431. var tuples2 = new List<Tuple<string, List<string>>>()
  432. {
  433. //环形库一北侧机械手取货位
  434. new("424",new List<string> {"424","425"}),
  435. new("433",new List<string> {"433","434"}),
  436. new("442",new List<string> {"442","443"})
  437. };
  438. foreach (var item in tuples2)
  439. {
  440. var device = Device.All.FirstOrDefault(x => x.Code == item.Item1);
  441. device.AddDeviceGroup(item.Item2.ToArray());
  442. }
  443. #endregion 添加设备组
  444. #region 标签配置
  445. Dictionary<DeviceFlags, List<string>> devices = new Dictionary<DeviceFlags, List<string>>
  446. {
  447. { DeviceFlags.入库, new List<string>() { "2532", "2533", "2534", "2732", "2733", "2734","1603" } },
  448. { DeviceFlags.出库, new List<string>() { "2532", "2533", "2534", "2732", "2733", "2734" } },
  449. { DeviceFlags.扫码, new List<string>() { "2532", "2732" } },
  450. { DeviceFlags.一列堆垛机, new List<string>() { "SRM1"/*, "SRM3", "SRM5"*/} },
  451. { DeviceFlags.二列堆垛机, new List<string>() { "SRM2"/*, "SRM4", "SRM6"*/ } },
  452. { DeviceFlags.一楼扫码,new List<string>(){ "2532","2732"} },
  453. { DeviceFlags.一楼叠盘机,new List<string>() { "2527","2528","2727","2728"} },
  454. { DeviceFlags.主线分流点,new List<string>() { "22","41","61"} },
  455. { DeviceFlags.满轮主线第一次扫码,new List<string>() { "1"} },
  456. { DeviceFlags.环形库分流点,new List<string>(){ "418"} },
  457. { DeviceFlags.桁架分流点,new List<string>() { "455" } },
  458. { DeviceFlags.桁架缓存放行点, new List<string>(){ "466", "480", "494", "508","522","536" } },
  459. { DeviceFlags.桁架取货点, new List<string>(){ "461", "475", "489", "503","517","531" } },
  460. { DeviceFlags.拆盘机09, new List<string>(){ "1606" } },
  461. { DeviceFlags.拆盘机非09, new List<string>(){ "1602" } },
  462. { DeviceFlags.桁架码垛位, new List<string>(){ "1670", "1671", "1672", "1673", "1674", "1675","1664","1662","1665" } },
  463. { DeviceFlags.环形库码垛工位, new List<string>(){ "1666" } },
  464. { DeviceFlags.AGV取货站台口, new List<string>(){ "2533", "2534", "2734" } },
  465. { DeviceFlags.Robot, new List<string>(){ "Robot1" } },
  466. };
  467. devices.ForEach(item =>
  468. {
  469. item.Value.ForEach(code =>
  470. {
  471. var device = Device.All.FirstOrDefault(v => v.Code == code);
  472. device.AddFlag(item.Key);
  473. });
  474. });
  475. #endregion 标签配置
  476. }
  477. /// <summary>
  478. /// 初始化数据库连接
  479. /// </summary>
  480. /// <param name="datas"></param>
  481. public static void InitDB(this List<DataBaseConnectionString> datas)
  482. {
  483. //初始化数据库
  484. SqlSugarHelper.Do(db =>
  485. {
  486. foreach (var connectionString in datas!)
  487. {
  488. var _db = db.Connect.GetConnectionScope(connectionString.Key);
  489. switch (connectionString.Key)
  490. {
  491. case "WCSDB"://WCS基本数据库
  492. SqlSugarHelper.SetDefault(connectionString.Key);
  493. _db.CodeFirst.InitTables(typeof(WCS_PlcData));
  494. _db.CodeFirst.InitTables(typeof(WCS_TaskInfo));
  495. _db.CodeFirst.InitTables(typeof(WCS_TaskDtl));
  496. _db.CodeFirst.InitTables(typeof(WCS_TaskOld));
  497. _db.CodeFirst.InitTables(typeof(WCS_AgvTaskInfo));
  498. _db.CodeFirst.InitTables(typeof(WCS_Palletizing));
  499. _db.CodeFirst.InitTables(typeof(WCS_PalletizingLayer));
  500. _db.CodeFirst.InitTables(typeof(WCS_PalletizingRow));
  501. _db.CodeFirst.InitTables(typeof(WCS_PalletizingLoc));
  502. _db.CodeFirst.InitTables(typeof(WCS_CacheLine));
  503. _db.CodeFirst.InitTables(typeof(WCS_CacheLineLoc));
  504. break;
  505. case "WCSDlog"://WCS日志数据库
  506. break;
  507. default: //其他库
  508. break;
  509. };
  510. };
  511. });
  512. }
  513. }
  514. }