• canvas 轮询http接口让小车实时运动


    需求:项目中的canvas图要对应线下的实体仓库,但线上图是线下的迷你版所以并不能真正的按线下的XY走;只能线上按好线和图,把XY对应的所有点告诉后台,后台传给我startNode,endNode做为起点和结束然后根据这个点位绘制出一条路径线

     

     

     

     父组件获取接口

    1. methods: {
    2. // 获取小车路径
    3. getAgvLine() {
    4. this.setIntervalVal = setInterval(() => {
    5. api.getAgvLine().then(res => {
    6. this.forkliftDataInit = res.map(item => {
    7. console.log("获取小车成功", item.carId, item);
    8. return {
    9. ...item,
    10. position: this.setAnimation(item)
    11. };
    12. });
    13. });
    14. }, 1000);
    15. },}

    setAnimation方法写在了mixin文件中;

    carAnimation.js

    1. /*
    2. * @Author: 周云芳 164591357@qq.com
    3. * @Date: 2022-09-19 08:57:02
    4. * @LastEditors: 周云芳 164591357@qq.com
    5. * @LastEditTime: 2022-09-19 10:47:20
    6. * @FilePath: \idps-detection-city\src\views\condition\mixins\carAnimation.js
    7. * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
    8. */
    9. const CarAnimationMixin = {
    10. methods: {
    11. setAnimation(item) {
    12. let directionX = null,
    13. directionY = null,
    14. rotateX = 0,
    15. rotateY = 0,
    16. currentY = item.currentPosition.top,
    17. currentX = item.currentPosition.left, //当前坐标
    18. lastY = item.lastPosition.top, //上一步的坐标
    19. lastX = item.lastPosition.left;
    20. if (Number(currentY) != Number(lastY)) {
    21. //判断Y轴方向当前xy是否和上一步的xy坐标相等
    22. directionX = Number(currentY) > Number(lastY) ? "bottom" : "top"; //判断转向
    23. console.log("走Y", directionX);
    24. if (directionX == "top") {
    25. rotateX = "180";
    26. currentY = Number(currentY);
    27. } else if (directionX == "bottom") {
    28. rotateX = "0";
    29. currentY = Number(currentY);
    30. }
    31. let position = {
    32. transform: `rotate(${rotateX}deg)`,
    33. top: currentY + "px",
    34. left: currentX + "px"
    35. };
    36. return position;
    37. } else if (Number(currentX) != Number(lastX)) {
    38. directionY = Number(currentX) > Number(lastX) ? "right" : "left";
    39. console.log("directionY--X->", directionY);
    40. if (directionY == "left") {
    41. rotateY = "90";
    42. currentX = Number(currentX);
    43. } else if (directionY == "right") {
    44. rotateY = "270";
    45. currentX = Number(currentX);
    46. }
    47. let position = {
    48. transform: `rotate(${rotateY}deg)`,
    49. top: currentY + "px",
    50. left: currentX + "px"
    51. };
    52. return position;
    53. }
    54. //针对停止车辆的位置摆放
    55. if (currentY == lastY && currentX == lastX) {
    56. let position = {
    57. transform: `rotate(${rotateY}deg)`,
    58. top: currentY + "px",
    59. left: currentX + "px"
    60. };
    61. return position;
    62. }
    63. }
    64. }
    65. };
    66. export default CarAnimationMixin;

    对应的线路图

     

     

    子组件引入并获取传入的值进行绘制小车要走的线路

    1. watch: {
    2. forkliftDataInit: {
    3. handler(params) {
    4. // if (!params) return;
    5. if (params && params.length > 0) {
    6. this.forkliftData = JSON.parse(JSON.stringify(params));
    7. setTimeout(() => {
    8. this.canvasMain();
    9. }, 0);
    10. }
    11. },
    12. immediate: true,
    13. deep: true
    14. }
    15. },
    16. methods: {
    17. // 叉车线路图
    18. canvasMain() {
    19. if (this.ctxMain) {
    20. this.ctxMain.clearRect(0, 0, this.canvasWidth, 467); //清除画布
    21. }
    22. var c = document.getElementById("main_canvas");
    23. this.ctxMain = c.getContext("2d");
    24. this.ctxMain.strokeStyle = "#666";
    25. this.ctxMain.lineWidth = 2;
    26. //1. 使用`font`设置字体。
    27. // this.ctxMain.font = "20px serif";
    28. //2. 使用`fillStyle`设置字体颜色。
    29. // this.ctxMain.fillStyle = "red";
    30. // 货区A0
    31. this.ctxMain.beginPath();
    32. this.ctxMain.lineTo(307, 50);
    33. this.ctxMain.lineTo(307, 150);
    34. this.ctxMain.strokeStyle = this.getColor("J0");
    35. // this.ctxMain.fillText("J0", 310, 100);
    36. this.ctxMain.stroke();
    37. // 箭头
    38. if (this.getArrow("J0")) {
    39. this.ctxMain.beginPath();
    40. this.ctxMain.moveTo(300, 55);
    41. this.ctxMain.lineTo(307, 45);
    42. this.ctxMain.lineTo(314, 55);
    43. this.ctxMain.strokeStyle = this.getArrow("J0");
    44. this.ctxMain.lineWidth = 4;
    45. this.ctxMain.stroke();
    46. this.ctxMain.lineWidth = 2;
    47. }
    48. // 货区1和货区2的中间线
    49. this.ctxMain.beginPath();
    50. this.ctxMain.moveTo(307, 150);
    51. this.ctxMain.lineTo(364, 150);
    52. this.ctxMain.strokeStyle = this.getColor("main-hq");
    53. this.ctxMain.font = "16px serif";
    54. // this.ctxMain.fillText("main-hq", 310, 140);
    55. this.ctxMain.stroke();
    56. //中间主线-1
    57. this.ctxMain.beginPath();
    58. this.ctxMain.moveTo(364, 150);
    59. this.ctxMain.lineTo(420, 150);
    60. this.ctxMain.strokeStyle = this.getColor("main-z1");
    61. // this.ctxMain.fillText("main-z1", 364, 165);
    62. this.ctxMain.stroke();
    63. //中间主线-2
    64. this.ctxMain.beginPath();
    65. this.ctxMain.moveTo(420, 150);
    66. this.ctxMain.lineTo(448, 150);
    67. this.ctxMain.strokeStyle = this.getColor("main-z2");
    68. // this.ctxMain.fillText("main-z2", 420, 165);
    69. this.ctxMain.stroke();
    70. //中间主线-2-1
    71. this.ctxMain.beginPath();
    72. this.ctxMain.moveTo(448, 150);
    73. this.ctxMain.lineTo(478, 150);
    74. this.ctxMain.strokeStyle = this.getColor("main-z2-1");
    75. // this.ctxMain.fillText("main-z2-1", 448, 145);
    76. this.ctxMain.stroke();
    77. //中间主线-3
    78. this.ctxMain.beginPath();
    79. this.ctxMain.moveTo(478, 150);
    80. this.ctxMain.lineTo(557, 150);
    81. this.ctxMain.strokeStyle = this.getColor("main-z3");
    82. // this.ctxMain.fillText("main-z3", 478, 165);
    83. this.ctxMain.stroke();
    84. //中间主线-4
    85. this.ctxMain.beginPath();
    86. this.ctxMain.moveTo(557, 150);
    87. this.ctxMain.lineTo(628, 150);
    88. this.ctxMain.strokeStyle = this.getColor("main-z4");
    89. // this.ctxMain.fillText("main-z4", 557, 140);
    90. this.ctxMain.stroke();
    91. //中间主线-5
    92. this.ctxMain.beginPath();
    93. this.ctxMain.moveTo(628, 150);
    94. this.ctxMain.lineTo(720, 150);
    95. this.ctxMain.strokeStyle = this.getColor("main-z5");
    96. // this.ctxMain.fillText("main-z5", 628, 140);
    97. this.ctxMain.stroke();
    98. //中间主线-6
    99. this.ctxMain.beginPath();
    100. this.ctxMain.moveTo(720, 150);
    101. // this.ctxMain.lineTo(this.canvasWidth - 450, 150);
    102. this.ctxMain.lineTo(764, 150);
    103. this.ctxMain.strokeStyle = this.getColor("main-z6");
    104. // this.ctxMain.fillText("main-z6", 720, 140);
    105. this.ctxMain.stroke();
    106. //中间主线-7
    107. this.ctxMain.beginPath();
    108. // this.ctxMain.moveTo(this.canvasWidth - 450, 150);
    109. // this.ctxMain.lineTo(this.canvasWidth - 390, 150);
    110. this.ctxMain.moveTo(764, 150);
    111. this.ctxMain.lineTo(842, 150);
    112. this.ctxMain.strokeStyle = this.getColor("main-z7");
    113. // this.ctxMain.fillText("main-z7", 760, 165);
    114. this.ctxMain.stroke();
    115. // 中间主线-8
    116. this.ctxMain.beginPath();
    117. // this.ctxMain.moveTo(this.canvasWidth - 390, 150);
    118. // this.ctxMain.lineTo(this.canvasWidth - 340, 150);
    119. this.ctxMain.moveTo(this.canvasWidth - 390, 150);
    120. this.ctxMain.lineTo(this.canvasWidth - 340, 150);
    121. this.ctxMain.strokeStyle = this.getColor("main-z8");
    122. // this.ctxMain.fillText("main-z8", this.canvasWidth - 390, 165);
    123. this.ctxMain.stroke();
    124. //中间主线-9
    125. this.ctxMain.beginPath();
    126. this.ctxMain.moveTo(this.canvasWidth - 340, 150);
    127. this.ctxMain.lineTo(this.canvasWidth - 291, 150);
    128. this.ctxMain.font = "14px serif";
    129. this.ctxMain.strokeStyle = this.getColor("main-z9");
    130. // this.ctxMain.fillText("main-z9", this.canvasWidth - 340, 145);
    131. this.ctxMain.stroke();
    132. //中间主线-10
    133. this.ctxMain.beginPath();
    134. this.ctxMain.moveTo(this.canvasWidth - 291, 150);
    135. this.ctxMain.lineTo(this.canvasWidth - 270, 150);
    136. this.ctxMain.strokeStyle = this.getColor("main-z10");
    137. // this.ctxMain.fillText("mainz10", this.canvasWidth - 291, 145);
    138. this.ctxMain.stroke();
    139. //A4-4
    140. this.ctxMain.beginPath();
    141. this.ctxMain.moveTo(307, 150);
    142. this.ctxMain.lineTo(307, 226);
    143. this.ctxMain.strokeStyle = this.getColor("A4-4");
    144. // this.ctxMain.fillText("A4-4", 290, 226);
    145. this.ctxMain.stroke();
    146. // 箭头
    147. if (this.getArrow("A4-4")) {
    148. this.ctxMain.beginPath();
    149. this.ctxMain.moveTo(302, 216);
    150. this.ctxMain.lineTo(307, 226);
    151. this.ctxMain.lineTo(312, 216);
    152. this.ctxMain.strokeStyle = this.getArrow("A4-4");
    153. this.ctxMain.lineWidth = 4;
    154. this.ctxMain.stroke();
    155. this.ctxMain.lineWidth = 2;
    156. }
    157. //A4-3
    158. this.ctxMain.beginPath();
    159. this.ctxMain.moveTo(364, 150);
    160. this.ctxMain.lineTo(364, 226);
    161. this.ctxMain.strokeStyle = this.getColor("A4-3");
    162. // this.ctxMain.fillText("A4-3", 356, 226);
    163. this.ctxMain.stroke();
    164. // 箭头
    165. if (this.getArrow("A4-3")) {
    166. this.ctxMain.beginPath();
    167. this.ctxMain.moveTo(359, 216);
    168. this.ctxMain.lineTo(364, 226);
    169. this.ctxMain.lineTo(369, 216);
    170. this.ctxMain.strokeStyle = this.getArrow("A4-3");
    171. this.ctxMain.lineWidth = 4;
    172. this.ctxMain.stroke();
    173. this.ctxMain.lineWidth = 2;
    174. }
    175. //A4-2
    176. this.ctxMain.beginPath();
    177. this.ctxMain.moveTo(420, 150);
    178. this.ctxMain.lineTo(420, 226);
    179. this.ctxMain.strokeStyle = this.getColor("A4-2");
    180. // this.ctxMain.fillText("A4-2", 410, 230);
    181. this.ctxMain.stroke();
    182. // 箭头
    183. if (this.getArrow("A4-2")) {
    184. this.ctxMain.beginPath();
    185. this.ctxMain.moveTo(415, 216);
    186. this.ctxMain.lineTo(420, 226);
    187. this.ctxMain.lineTo(425, 216);
    188. this.ctxMain.strokeStyle = this.getArrow("A4-2");
    189. this.ctxMain.lineWidth = 4;
    190. this.ctxMain.stroke();
    191. this.ctxMain.lineWidth = 2;
    192. }
    193. //A4-1
    194. this.ctxMain.beginPath();
    195. this.ctxMain.moveTo(478, 150);
    196. this.ctxMain.lineTo(478, 226);
    197. this.ctxMain.strokeStyle = this.getColor("A4-1");
    198. // this.ctxMain.fillText("A4-1", 478, 260);
    199. this.ctxMain.stroke();
    200. // 箭头
    201. if (this.getArrow("A4-1")) {
    202. this.ctxMain.beginPath();
    203. this.ctxMain.moveTo(473, 216);
    204. this.ctxMain.lineTo(478, 226);
    205. this.ctxMain.lineTo(483, 216);
    206. this.ctxMain.strokeStyle = this.getArrow("A4-1");
    207. this.ctxMain.lineWidth = 4;
    208. this.ctxMain.stroke();
    209. this.ctxMain.lineWidth = 2;
    210. }
    211. //A5-2
    212. this.ctxMain.beginPath();
    213. this.ctxMain.moveTo(557, 150);
    214. this.ctxMain.lineTo(557, 230);
    215. // this.ctxMain.lineTo(560, 230);
    216. // this.ctxMain.lineTo(560, 230);
    217. this.ctxMain.strokeStyle = this.getColor("A5-2");
    218. // this.ctxMain.fillText("A5-2", 557, 230);
    219. this.ctxMain.stroke();
    220. // 箭头
    221. if (this.getArrow("A5-2")) {
    222. this.ctxMain.beginPath();
    223. this.ctxMain.moveTo(552, 220);
    224. this.ctxMain.lineTo(557, 230);
    225. this.ctxMain.lineTo(562, 220);
    226. this.ctxMain.strokeStyle = this.getArrow("A5-2");
    227. this.ctxMain.lineWidth = 4;
    228. this.ctxMain.stroke();
    229. this.ctxMain.lineWidth = 2;
    230. }
    231. //A5-1
    232. this.ctxMain.beginPath();
    233. this.ctxMain.moveTo(628, 150);
    234. this.ctxMain.lineTo(628, 230);
    235. this.ctxMain.strokeStyle = this.getColor("A5-1");
    236. // this.ctxMain.fillText("A5-1", 628, 230);
    237. this.ctxMain.stroke();
    238. // 箭头
    239. if (this.getArrow("A5-1")) {
    240. this.ctxMain.beginPath();
    241. this.ctxMain.moveTo(623, 220);
    242. this.ctxMain.lineTo(628, 230);
    243. this.ctxMain.lineTo(633, 220);
    244. this.ctxMain.strokeStyle = this.getArrow("A5-1");
    245. this.ctxMain.lineWidth = 4;
    246. this.ctxMain.stroke();
    247. this.ctxMain.lineWidth = 2;
    248. }
    249. //A1
    250. this.ctxMain.beginPath();
    251. this.ctxMain.moveTo(448, 150);
    252. this.ctxMain.lineTo(448, 86);
    253. this.ctxMain.strokeStyle = this.getColor("A1");
    254. // this.ctxMain.fillText("A1", 448, 86);
    255. this.ctxMain.stroke();
    256. // 箭头
    257. if (this.getArrow("A1")) {
    258. this.ctxMain.beginPath();
    259. this.ctxMain.moveTo(438, 100);
    260. this.ctxMain.lineTo(448, 80);
    261. this.ctxMain.lineTo(458, 100);
    262. this.ctxMain.strokeStyle = this.getArrow("A1");
    263. this.ctxMain.lineWidth = 4;
    264. this.ctxMain.stroke();
    265. this.ctxMain.lineWidth = 2;
    266. }
    267. //A2
    268. this.ctxMain.beginPath();
    269. this.ctxMain.moveTo(628, 150);
    270. this.ctxMain.lineTo(628, 92);
    271. this.ctxMain.strokeStyle = this.getColor("A2");
    272. // this.ctxMain.fillText("A2", 628, 92);
    273. this.ctxMain.stroke();
    274. // 箭头
    275. if (this.getArrow("A2")) {
    276. this.ctxMain.beginPath();
    277. this.ctxMain.moveTo(622, 100);
    278. this.ctxMain.lineTo(628, 90);
    279. this.ctxMain.lineTo(634, 100);
    280. this.ctxMain.strokeStyle = this.getArrow("A2");
    281. this.ctxMain.lineWidth = 4;
    282. this.ctxMain.stroke();
    283. this.ctxMain.lineWidth = 2;
    284. }
    285. //A3
    286. this.ctxMain.beginPath();
    287. this.ctxMain.moveTo(this.canvasWidth - 270, 150);
    288. this.ctxMain.lineTo(this.canvasWidth - 210, 150);
    289. this.ctxMain.strokeStyle = this.getColor("A3");
    290. // this.ctxMain.fillText("A3", this.canvasWidth - 230, 165);
    291. this.ctxMain.stroke();
    292. // 箭头
    293. if (this.getArrow("A3")) {
    294. this.ctxMain.beginPath();
    295. this.ctxMain.moveTo(this.canvasWidth - 215, 144);
    296. this.ctxMain.lineTo(this.canvasWidth - 205, 150);
    297. this.ctxMain.lineTo(this.canvasWidth - 215, 156);
    298. this.ctxMain.strokeStyle = this.getArrow("A3");
    299. this.ctxMain.lineWidth = 4;
    300. this.ctxMain.stroke();
    301. this.ctxMain.lineWidth = 2;
    302. }
    303. //A6
    304. this.ctxMain.beginPath();
    305. this.ctxMain.moveTo(this.canvasWidth - 270, 150);
    306. this.ctxMain.lineTo(this.canvasWidth - 270, 246);
    307. this.ctxMain.lineTo(this.canvasWidth - 210, 246);
    308. this.ctxMain.strokeStyle = this.getColor("A6");
    309. this.ctxMain.font = "30px serif";
    310. // this.ctxMain.fillText("A6", this.canvasWidth - 285, 240);
    311. this.ctxMain.stroke();
    312. // 箭头
    313. if (this.getArrow("A6")) {
    314. this.ctxMain.beginPath();
    315. this.ctxMain.moveTo(this.canvasWidth - 215, 240);
    316. this.ctxMain.lineTo(this.canvasWidth - 205, 246);
    317. this.ctxMain.lineTo(this.canvasWidth - 215, 252);
    318. this.ctxMain.strokeStyle = this.getArrow("A6");
    319. this.ctxMain.lineWidth = 4;
    320. this.ctxMain.stroke();
    321. this.ctxMain.lineWidth = 2;
    322. }
    323. // 叉车3
    324. this.ctxMain.beginPath();
    325. this.ctxMain.moveTo(this.canvasWidth - 288, 95);
    326. this.ctxMain.lineTo(this.canvasWidth - 294, 95);
    327. this.ctxMain.lineTo(this.canvasWidth - 291, 95);
    328. this.ctxMain.lineTo(this.canvasWidth - 291, 150);
    329. this.ctxMain.strokeStyle = this.getColor("C3");
    330. this.ctxMain.stroke();
    331. // 箭头
    332. if (this.getArrow("C3")) {
    333. this.ctxMain.beginPath();
    334. this.ctxMain.moveTo(this.canvasWidth - 299, 103);
    335. this.ctxMain.lineTo(this.canvasWidth - 291, 93);
    336. this.ctxMain.lineTo(this.canvasWidth - 284, 103);
    337. this.ctxMain.strokeStyle = this.getArrow("C3");
    338. this.ctxMain.lineWidth = 4;
    339. this.ctxMain.stroke();
    340. this.ctxMain.lineWidth = 2;
    341. }
    342. // 叉车2
    343. this.ctxMain.beginPath();
    344. this.ctxMain.moveTo(this.canvasWidth - 337, 95);
    345. this.ctxMain.lineTo(this.canvasWidth - 343, 95);
    346. this.ctxMain.lineTo(this.canvasWidth - 340, 95);
    347. this.ctxMain.lineTo(this.canvasWidth - 340, 150);
    348. this.ctxMain.strokeStyle = this.getColor("C2");
    349. this.ctxMain.stroke();
    350. // 箭头
    351. if (this.getArrow("C2")) {
    352. this.ctxMain.beginPath();
    353. this.ctxMain.moveTo(this.canvasWidth - 348, 103);
    354. this.ctxMain.lineTo(this.canvasWidth - 340, 93);
    355. this.ctxMain.lineTo(this.canvasWidth - 332, 103);
    356. this.ctxMain.strokeStyle = this.getArrow("C2");
    357. this.ctxMain.lineWidth = 4;
    358. this.ctxMain.stroke();
    359. this.ctxMain.lineWidth = 2;
    360. }
    361. // 叉车1
    362. this.ctxMain.beginPath();
    363. this.ctxMain.moveTo(this.canvasWidth - 387, 95);
    364. this.ctxMain.lineTo(this.canvasWidth - 393, 95);
    365. this.ctxMain.lineTo(this.canvasWidth - 390, 95);
    366. this.ctxMain.lineTo(this.canvasWidth - 390, 150);
    367. this.ctxMain.strokeStyle = this.getColor("C1");
    368. this.ctxMain.stroke();
    369. // 箭头
    370. if (this.getArrow("C1")) {
    371. this.ctxMain.beginPath();
    372. this.ctxMain.moveTo(this.canvasWidth - 398, 103);
    373. this.ctxMain.lineTo(this.canvasWidth - 390, 93);
    374. this.ctxMain.lineTo(this.canvasWidth - 382, 103);
    375. this.ctxMain.strokeStyle = this.getArrow("C1");
    376. this.ctxMain.lineWidth = 4;
    377. this.ctxMain.stroke();
    378. this.ctxMain.lineWidth = 2;
    379. }
    380. },
    381. //获取箭头的状态和颜色
    382. getArrow(type) {
    383. if (!this.forkliftData) return;
    384. let color = "";
    385. let ccData = {
    386. endNode1: "",
    387. endNode2: "",
    388. endNode3: ""
    389. };
    390. this.forkliftData.forEach(item => {
    391. if (item.carId == "1") {
    392. ccData.endNode1 = item.endNode;
    393. } else if (item.carId == "2") {
    394. ccData.endNode2 = item.endNode;
    395. } else if (item.carId == "3") {
    396. ccData.endNode3 = item.endNode;
    397. }
    398. });
    399. if (ccData.endNode1 == type) {
    400. color = "#00FF00";
    401. } else if (ccData.endNode2 == type) {
    402. color = "#00ffff";
    403. } else if (ccData.endNode3 == type) {
    404. color = "#FFE13B";
    405. } else {
    406. color = false;
    407. }
    408. return color;
    409. },
    410. //获取线条的颜色
    411. getColor(type) {
    412. //type为AO,A1...
    413. if (!this.forkliftData) return;
    414. let color = "";
    415. let C1 = {},
    416. C2 = {},
    417. C3 = {};
    418. // 车子开开始的位置和结束的位置
    419. this.forkliftData.forEach(item => {
    420. if (item.carId == "1") {
    421. C1.startNode = item.startNode;
    422. C1.endNode = item.endNode;
    423. } else if (item.carId == "2") {
    424. C2.startNode = item.startNode;
    425. C2.endNode = item.endNode;
    426. } else if (item.carId == "3") {
    427. C3.startNode = item.startNode;
    428. C3.endNode = item.endNode;
    429. }
    430. });
    431. if (this.ccType(type, C1)) {
    432. //判断小车类型和开始或类型和结束位置相同
    433. color = "#00FF00";
    434. } else if (this.ccType(type, C2)) {
    435. //计算线条的数据返回True
    436. color = "#00ffff";
    437. } else if (this.ccType(type, C3)) {
    438. color = "#FFE13B";
    439. } else {
    440. color = "#666";
    441. }
    442. // if (this.ccType(type, C1)) {
    443. // this.trolley1.push(type);
    444. // }
    445. // if (this.ccType(type, C2)) {
    446. // this.trolley2.push(type);
    447. // }
    448. // if (this.ccType(type, C3)) {
    449. // this.trolley3.push(type);
    450. // }
    451. return color;
    452. },
    453. //计算线条的数据
    454. ccType(type, cc) {
    455. //type为AO,A1...,cc=叉车开始及结束位置 {startNode: 'C2', endNode: 'A4-1'}
    456. let status = false;
    457. if (type.indexOf("main") < 0) {
    458. if (cc.startNode == type || cc.endNode == type) {
    459. status = true;
    460. }
    461. } else {
    462. if (type == "main-hq" && this.mainHq(cc)) {
    463. status = true;
    464. }
    465. if (type == "main-z1" && this.mainZ1(cc)) {
    466. status = true;
    467. }
    468. if (type == "main-z2" && this.mainZ2(cc)) {
    469. status = true;
    470. }
    471. if (type == "main-z2-1" && this.mainZ21(cc)) {
    472. status = true;
    473. }
    474. if (type == "main-z3" && this.mainZ3(cc)) {
    475. status = true;
    476. }
    477. if (type == "main-z4" && this.mainZ4(cc)) {
    478. status = true;
    479. }
    480. if (type == "main-z5" && this.mainZ5(cc)) {
    481. status = true;
    482. }
    483. if (type == "main-z6" && this.mainZ6(cc)) {
    484. status = true;
    485. }
    486. if (type == "main-z7" && this.mainZ7(cc)) {
    487. status = true;
    488. }
    489. if (type == "main-z8" && this.mainZ8(cc)) {
    490. status = true;
    491. }
    492. if (type == "main-z9" && this.mainZ9(cc)) {
    493. status = true;
    494. }
    495. if (type == "main-z10" && this.mainZ10(cc)) {
    496. status = true;
    497. }
    498. if (type == "main-A7" && this.mainA7(cc)) {
    499. status = true;
    500. }
    501. }
    502. return status;
    503. },
    504. mainHq(cc) {
    505. let status = false;
    506. let left = ["J0", "A4-4"];
    507. let right = [
    508. "AAA",
    509. "A4-3",
    510. "A4-2",
    511. "A4-1",
    512. "A1",
    513. "A2",
    514. "A3",
    515. "A5-2",
    516. "A5-1",
    517. "A6",
    518. "A7",
    519. "C1",
    520. "C2",
    521. "C3",
    522. "cc4",
    523. "A8"
    524. ];
    525. if (
    526. (left.indexOf(cc.startNode) >= 0 && right.indexOf(cc.endNode) >= 0) ||
    527. (left.indexOf(cc.endNode) >= 0 && right.indexOf(cc.startNode) >= 0)
    528. ) {
    529. status = true;
    530. }
    531. return status;
    532. },
    533. mainZ1(cc) {
    534. let status = false;
    535. let left = ["J0", "AAA", "A4-4", "A4-3"];
    536. let right = [
    537. "A4-2",
    538. "A4-1",
    539. "A1",
    540. "A2",
    541. "A3",
    542. "A5-2",
    543. "A5-1",
    544. "A6",
    545. "A7",
    546. "C1",
    547. "C2",
    548. "C3",
    549. "cc4",
    550. "A8"
    551. ];
    552. if (
    553. (left.indexOf(cc.startNode) >= 0 && right.indexOf(cc.endNode) >= 0) ||
    554. (left.indexOf(cc.endNode) >= 0 && right.indexOf(cc.startNode) >= 0)
    555. ) {
    556. status = true;
    557. }
    558. return status;
    559. },
    560. mainZ2(cc) {
    561. let status = false;
    562. let left = ["J0", "AAA", "A4-4", "A4-3", "A4-2"];
    563. let right = [
    564. "A4-1",
    565. "A1",
    566. "A2",
    567. "A3",
    568. "A5-2",
    569. "A5-1",
    570. "A6",
    571. "A7",
    572. "C1",
    573. "C2",
    574. "C3",
    575. "cc4",
    576. "A8"
    577. ];
    578. if (
    579. (left.indexOf(cc.startNode) >= 0 && right.indexOf(cc.endNode) >= 0) ||
    580. (left.indexOf(cc.endNode) >= 0 && right.indexOf(cc.startNode) >= 0)
    581. ) {
    582. status = true;
    583. }
    584. return status;
    585. },
    586. mainZ21(cc) {
    587. let status = false;
    588. let left = ["J0", "AAA", "A1", "A4-4", "A4-3", "A4-2"];
    589. let right = [
    590. "A4-1",
    591. "A2",
    592. "A3",
    593. "A5-2",
    594. "A5-1",
    595. "A6",
    596. "A7",
    597. "C1",
    598. "C2",
    599. "C3",
    600. "cc4",
    601. "A8"
    602. ];
    603. if (
    604. (left.indexOf(cc.startNode) >= 0 && right.indexOf(cc.endNode) >= 0) ||
    605. (left.indexOf(cc.endNode) >= 0 && right.indexOf(cc.startNode) >= 0)
    606. ) {
    607. status = true;
    608. }
    609. return status;
    610. },
    611. mainZ3(cc) {
    612. let status = false;
    613. let left = ["J0", "AAA", "A4-4", "A4-3", "A4-2", "A4-1", "A1"];
    614. let right = [
    615. "A2",
    616. "A3",
    617. "A5-2",
    618. "A5-1",
    619. "A6",
    620. "A7",
    621. "C1",
    622. "C2",
    623. "C3",
    624. "cc4",
    625. "A8"
    626. ];
    627. if (
    628. (left.indexOf(cc.startNode) >= 0 && right.indexOf(cc.endNode) >= 0) ||
    629. (left.indexOf(cc.endNode) >= 0 && right.indexOf(cc.startNode) >= 0)
    630. ) {
    631. status = true;
    632. }
    633. return status;
    634. },
    635. mainZ4(cc) {
    636. let status = false;
    637. let left = ["J0", "AAA", "A4-4", "A4-3", "A4-2", "A4-1", "A1", "A5-2"];
    638. let right = [
    639. "A2",
    640. "A3",
    641. "A5-1",
    642. "A6",
    643. "A7",
    644. "C1",
    645. "C2",
    646. "C3",
    647. "cc4",
    648. "A8"
    649. ];
    650. if (
    651. (left.indexOf(cc.startNode) >= 0 && right.indexOf(cc.endNode) >= 0) ||
    652. (left.indexOf(cc.endNode) >= 0 && right.indexOf(cc.startNode) >= 0)
    653. ) {
    654. status = true;
    655. }
    656. return status;
    657. },
    658. mainZ5(cc) {
    659. let status = false;
    660. let left = [
    661. "J0",
    662. "AAA",
    663. "A4-4",
    664. "A4-3",
    665. "A4-2",
    666. "A4-1",
    667. "A1",
    668. "A5-2",
    669. "A5-1",
    670. "A2"
    671. ];
    672. let right = ["A3", "A6", "A7", "C1", "C2", "C3", "cc4", "A8"];
    673. if (
    674. (left.indexOf(cc.startNode) >= 0 && right.indexOf(cc.endNode) >= 0) ||
    675. (left.indexOf(cc.endNode) >= 0 && right.indexOf(cc.startNode) >= 0)
    676. ) {
    677. status = true;
    678. }
    679. return status;
    680. },
    681. mainZ6(cc) {
    682. let status = false;
    683. let left = [
    684. "J0",
    685. "AAA",
    686. "A4-4",
    687. "A4-3",
    688. "A4-2",
    689. "A4-1",
    690. "A1",
    691. "A5-2",
    692. "A5-1",
    693. "A2",
    694. "A7",
    695. "A8"
    696. ];
    697. let right = ["A3", "A6", "C1", "C2", "C3", "cc4"];
    698. if (
    699. (left.indexOf(cc.startNode) >= 0 && right.indexOf(cc.endNode) >= 0) ||
    700. (left.indexOf(cc.endNode) >= 0 && right.indexOf(cc.startNode) >= 0)
    701. ) {
    702. status = true;
    703. }
    704. return status;
    705. },
    706. mainZ7(cc) {
    707. let status = false;
    708. let left = [
    709. "J0",
    710. "AAA",
    711. "A4-4",
    712. "A4-3",
    713. "A4-2",
    714. "A4-1",
    715. "A1",
    716. "A5-2",
    717. "A5-1",
    718. "A2",
    719. "A7",
    720. "A8"
    721. ];
    722. let right = ["A3", "A6", "C2", "C3", "C1"];
    723. if (
    724. (left.indexOf(cc.startNode) >= 0 && right.indexOf(cc.endNode) >= 0) ||
    725. (left.indexOf(cc.endNode) >= 0 && right.indexOf(cc.startNode) >= 0)
    726. ) {
    727. status = true;
    728. }
    729. return status;
    730. },
    731. mainZ8(cc) {
    732. let status = false;
    733. let left = [
    734. "J0",
    735. "AAA",
    736. "A4-4",
    737. "A4-3",
    738. "A4-2",
    739. "A4-1",
    740. "A1",
    741. "A5-2",
    742. "A5-1",
    743. "A2",
    744. "A7",
    745. "A8",
    746. "C1"
    747. ];
    748. let right = ["A3", "A6", "C3", "C2"];
    749. if (
    750. (left.indexOf(cc.startNode) >= 0 && right.indexOf(cc.endNode) >= 0) ||
    751. (left.indexOf(cc.endNode) >= 0 && right.indexOf(cc.startNode) >= 0)
    752. ) {
    753. status = true;
    754. }
    755. return status;
    756. },
    757. mainZ9(cc) {
    758. let status = false;
    759. let left = [
    760. "J0",
    761. "AAA",
    762. "A4-4",
    763. "A4-3",
    764. "A4-2",
    765. "A4-1",
    766. "A1",
    767. "A5-2",
    768. "A5-1",
    769. "A2",
    770. "A7",
    771. "A8",
    772. "C1",
    773. "C2"
    774. ];
    775. let right = ["A3", "A6", "C3"];
    776. if (
    777. (left.indexOf(cc.startNode) >= 0 && right.indexOf(cc.endNode) >= 0) ||
    778. (left.indexOf(cc.endNode) >= 0 && right.indexOf(cc.startNode) >= 0)
    779. ) {
    780. status = true;
    781. }
    782. return status;
    783. },
    784. mainZ10(cc) {
    785. let status = false;
    786. let left = [
    787. "J0",
    788. "AAA",
    789. "A4-4",
    790. "A4-3",
    791. "A4-2",
    792. "A4-1",
    793. "A1",
    794. "A5-2",
    795. "A5-1",
    796. "A2",
    797. "A7",
    798. "A8",
    799. "C1",
    800. "C2",
    801. "C3",
    802. "cc4"
    803. ];
    804. let right = ["A3", "A6"];
    805. if (
    806. (left.indexOf(cc.startNode) >= 0 && right.indexOf(cc.endNode) >= 0) ||
    807. (left.indexOf(cc.endNode) >= 0 && right.indexOf(cc.startNode) >= 0)
    808. ) {
    809. status = true;
    810. }
    811. return status;
    812. },
    813. mainA7(cc) {
    814. let status = false;
    815. let left = [
    816. "J0",
    817. "AAA",
    818. "A4-4",
    819. "A4-3",
    820. "A4-2",
    821. "A4-1",
    822. "A1",
    823. "A5-2",
    824. "A5-1",
    825. "A2",
    826. "C1",
    827. "C2",
    828. "C3",
    829. "cc4",
    830. "A3",
    831. "A6"
    832. ];
    833. let right = ["A7", "A8"];
    834. if (
    835. (left.indexOf(cc.startNode) >= 0 && right.indexOf(cc.endNode) >= 0) ||
    836. (left.indexOf(cc.endNode) >= 0 && right.indexOf(cc.startNode) >= 0)
    837. ) {
    838. status = true;
    839. }
    840. return status;
    841. },
    842. }

  • 相关阅读:
    Mysql(Mariadb) 数据库安装在ArchLinux
    国家网络安全周 | 金融日,一起 get金融行业数据安全
    【Pycharm 安装Django报错显示:ERROR: Failed building wheel for backports.zoneinfo】
    【Linux】--make/makefile--gcc/g++/gdb
    虚拟机构建单体项目及前后端分离项目
    2023年全球市场氮化铝外延片总体规模、主要生产商、主要地区、产品和应用细分研究报告
    18-JSON和浏览器数据存储
    发送短信验证码执行登录操作
    一日一技:用Python做游戏有多简单
    java代码审计(入门级)—基础漏洞合集
  • 原文地址:https://blog.csdn.net/qq_40190624/article/details/126929359