cuiqian2004
2025-07-10 30311cd24ee3b1567ffafac002494bb67feda657
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
import http from './request.js';
import {
    session,
} from "@/comm/utils.js"
 
const addLog = (item) => {
    const list = session.getValue("request_log") || []
    list.unshift(item)
    session.setValue("request_log", list)
}
// 判断ip是否可以连接上
export const checkIpLinkSuccess = (ip) => {
    var url = `http://${ip}:4405/api/mt/battery`;
    console.log("url", url)
    return new Promise((resolve, reject) => {
        uni.request({
            url: url,
            method: "GET",
            header: {
                "Content-Type": "application/json;charset=UTF-8"
            },
            timeout: 5000,
            success: (result) => {
                //console.log("result",  result)
                if (result.statusCode != 200) {
                    if (result.statusCode == 404) {
                        return reject({
                            errMsg: "地址不对,请检查该地址:" + url
                        });
                    }
                    resolve({
                        code: -1,
                        msg: "访问失败,状态码:" + result.statusCode
                    });
                }
                var ret = result.data
                if (typeof ret == 'string') {
                    try {
                        try {
                            try {
                                ret = JSON.parse(ret.replace(/\\"/g, '"'));
                            } catch (ex) {
                                ret = JSON.parse(ret.replace(/\\/g, '\\\\'))
                            }
                        } catch (ex) {
                            ret = JSON.parse(ret.replace(/\\"/g, "'").replace(
                                /[\r\n]/g,
                                '<br>').replace(/[\t]/g, '    '));
                        }
                    } catch (ex) {
                        resolve({
                            code: -1,
                            msg: '将【json string】转换为【json object】失败'
                        });
                    }
                }
                if (ret.code == 0) {
                    resolve({
                        code: 0,
                        data: ret.data
                    });
                } else {
                    resolve({
                        code: ret.code,
                        msg: ret.msg || ""
                    });
                }
            },
            fail: (err) => {
                console.log("err", err)
                return reject(err);
            }
        })
    })
 
}
/**
 * GET 5000/api/get_agv_state
 * 查询车辆信息
 * @param 
 * @returns 
 */
export const getAgvState = (ip) => {
    var header = {
        "Content-Type": "application/json;charset=UTF-8"
    };
    var url = `http://${ip}:5000/api/get_agv_state`;
    return http.request({
        method: "GET",
        url,
        header,
    })
 
 
 
}
/**
 * GET 4405/api/mt/batter
 * // 查询车辆信息
 * @param 
 * @returns 
 */
export const mtBattery = (ip) => {
    var header = {
        "Content-Type": "application/json;charset=UTF-8"
    };
    var url = `http://${ip}:4405/api/mt/battery`;
    return http.request({
        method: "GET",
        url,
        header,
    })
 
}
/**
 * GET 4405/api/shell/version
 * 查询shell版本
 * @param 
 * @returns 
 */
export const shellVersion = (ip) => {
    var header = {
        "Content-Type": "application/json;charset=UTF-8"
    };
    var url = `http://${ip}:4405/api/shell/version`;
    return http.request({
        method: "GET",
        url,
        header,
    })
 
}
/**
 * POST 5000/api/add_station
 * 获取车辆地图列表
 * @param 
 *  stationID, //站台ID
 *    name, //站台名
 * @returns 
 */
 
export const mapInfo = (ip) => {
    // var header = {
    //     "Content-Type": "application/json;charset=UTF-8"
    // };
    // var url = `http://${ip}:4405/api/shell/version`;
    // return http.request({
    //     method: "GET",
    //     url,
    //     header,
    // })
    return new Promise((resolve, reject) => {
        return resolve(
            [{
                name: "地图1",
                img: 'static/map.png',
            }]
        )
    })
 
 
}
 
/**
 * POST 5000/api/add_station
 * 添加站台
 * @param 
 *  stationID, //站台ID
 *    name, //站台名
 * @returns 
 */
export const addStation = (ip, param) => {
    var header = {
        "Content-Type": "application/json;charset=UTF-8"
    };
    const {
        stationID,
        name
 
    } = param
    var url = `http://${ip}:5000/api/add_station/`;
    return http.request({
        method: "POST",
        url,
        header,
        data: {
            stationID,
            name,
        },
    })
 
}
 
/**
 * GET 5000/api/update_station
 * 查询站点
 * @param 
 * @returns 
 */
export const stations = (ip) => {
    var header = {
        "Content-Type": "application/json;charset=UTF-8"
    };
    var url = `http://${ip}:5000/api/stations`;
    return http.request({
        method: "GET",
        url,
        header,
 
    })
}
 
/**
 * POST 5000/api/update_station
 * 修改站点信息
 * @param 
 * @returns 
 */
export const updateStation = (ip, param) => {
    var header = {
        "Content-Type": "application/json;charset=UTF-8"
    };
    const {
        stationID,
        name,
        x,
        y,
        angle
    } = param
 
    var url = `http://${ip}:5000/api/update_station/`;
    return http.request({
        method: "POST",
        url,
        header,
        data: {
            stationID,
            name,
            x: Number(x),
            y: Number(y),
            angle
        }
 
    })
 
}
 
/**
 * POST 5000/api/delete_station
 * 删除站点信息
 * @param 
 * stationID 站点id集合
 * @returns 
 */
export const delStation = (ip, stationID = []) => {
    var header = {
        "Content-Type": "application/json;charset=UTF-8"
    };
 
    var url = `http://${ip}:5000/api/delete_station/`;
    return http.request({
        method: "POST",
        url,
        header,
        data: {
            stationID
        }
    })
 
}
 
/**
 * POST 5000/api/add_task
 * 添加任务
 * @param 
 * taskGroupID #任务组ID
 * taskGroupName #任务组名
 * cycleTime #循环次数
 * taskButton #绑定按钮
 * taskList [{
     * stationID
     * actionType 任务状态1取货,2卸货,3导航
     * wait 等待时间
  }]
 * taskGroupNameID #任务组名
 * @returns 
 */
 
export const addTask = (ip, param) => {
    var header = {
        "Content-Type": "application/json;charset=UTF-8"
    };
    const {
        taskGroupID,
        taskGroupName,
        cycleTime,
        taskButton,
        tasktype,
        taskList
    } = param
 
    var url = `http://${ip}:5000/api/add_task/`;
    return http.request({
        method: "POST",
        url,
        data: {
            taskGroupID,
            taskGroupName,
            cycleTime,
            taskButton,
            tasktype,
            taskList
        }
 
    })
 
}
 
/**
 * GET 5000/api/tasks
 * 查询任务
 * @param 
 * @returns 
 */
export const tasks = (ip) => {
    var header = {
        "Content-Type": "application/json;charset=UTF-8"
    };
    var url = `http://${ip}:5000/api/tasks`;
    return http.request({
        method: "GET",
        url,
        header,
 
    })
 
}
 
/**
 * POST 5000/api/update_task
 * 修改任务
 * @param 
 * taskGroupID #任务组ID
 * taskGroupName #任务组名
 * cycleTime #循环次数
 * taskButton #绑定按钮
 * taskList [{
     * actionType 任务状态1取货,2卸货,3导航
     "dest": {
            "angle": 1,
            "name": "Work1212",
            "stationID": 6,
            "x": 2,
            "y": 2,   
            "_checked": false
    },
    "taskID": 1,
    "wait": 10
  }]
 * taskGroupNameID #任务组名
 * @returns 
 */
 
export const updateTask = (ip, param) => {
    var header = {
        "Content-Type": "application/json;charset=UTF-8"
    };
    const {
        taskGroupID,
        taskGroupName,
        cycleTime,
        taskButton,
        tasktype,
        taskList
    } = param
 
    var url = `http://${ip}:5000/api/update_task/`;
    return http.request({
        method: "POST",
        url,
        header,
        data: {
            taskGroupID,
            taskGroupName,
            cycleTime,
            tasktype,
            taskButton,
            taskList
        }
 
    })
 
}
 
/**
 * POST 5000/api/delete_station
 * 删除任务
 * @param 
 * [{
     * taskGroupID  任务组ID
     * taskID 任务ID
 }]
 * @returns 
 */
export const delTask = (ip, list = []) => {
    var header = {
        "Content-Type": "application/json;charset=UTF-8"
    };
 
    var url = `http://${ip}:5000/api/delete_task/`;
    return http.request({
        method: "POST",
        url,
        header,
        data: {
            data: list
        }
    })
 
}
 
/**
 * POST 5000/api/add_taskGroupCmd
 * 开始任务
 * @param 
 *  taskGroupID 
 * taskGroupCmdID由于前端生成uuid,创建后需要存储起来,后续在查询当前任务时候做判断使用
 * taskGroupCmd 1 # 1.开始任务 2.结束任务
 * @returns 
 */
 
export const addTaskGroupCmd = (ip, taskGroupID, taskGroupCmdID, taskGroupCmd = 1) => {
    var header = {
        "Content-Type": "application/json;charset=UTF-8"
    };
    var url = `http://${ip}:5000/api/add_taskGroupCmd/`;
    return http.request({
        method: "POST",
        url,
        header,
        data: {
            taskGroupID,
            taskGroupCmd,
            taskGroupCmdID,
        }
    })
 
}
 
/**
 * POST 5000/api/cancel_task
 * 取消任务
 * @param 
 *  taskGroupID 
 * taskGroupCmdID 正在执行任务的cmdId
 * taskList[{
     * taskID,
     * is_cancel
 }]
 * @returns 
 */
export const cancelTask = (ip, taskGroupID, taskGroupCmdID, taskList = []) => {
    var header = {
        "Content-Type": "application/json;charset=UTF-8"
    };
 
    var url = `http://${ip}:5000/api/cancel_task/`;
    return http.request({
        method: "POST",
        url,
        header,
        data: {
            taskGroupID,
            taskGroupCmdID,
            taskList
        }
    })
 
}
 
/**
 * GET 5000/api/taskGroupStatus
 * 查询任务状态
 * @param 
 * @returns 
 */
export const taskGroupStatus = (ip) => {
    var header = {
        "Content-Type": "application/json;charset=UTF-8"
    };
    var url = `http://${ip}:5000/api/taskGroupStatus/`;
    return http.request({
        method: "GET",
        url,
        header,
 
    })
 
}
 
/**
 * GET 5000/api/getAllScene
 * 获取场景列表
 * @param 
 * @returns 
 */
export const getAllScene = (ip) => {
    var header = {
        "Content-Type": "application/json;charset=UTF-8"
    };
    var url = `http://${ip}:5000/api/getAllScene/`;
    return http.request({
        method: "GET",
        url,
        header,
 
    })
}
 
/**
 * POST 5000/api/getMapUrl
 * 通过场景获取地图文件地址
 * @param 
 * @returns 
 */
export const getMapUrl = (ip, id) => {
    var header = {
        "Content-Type": "application/json;charset=UTF-8"
    };
    var url = `http://${ip}:5000/api/getMapUrl/`;
    return http.request({
        method: "POST",
        url,
        header,
        data: {
            sceneId: id,
        },
    })
}
/**
 * POST 5000/api/get_task_log
 * 获取任务记录
 * @param 
 * start_time  #开始时间时间戳
 * end_time #结束时间时间戳
 * @returns 
 */
export const getTaskLog = (ip, start_time = "", end_time = "") => {
    var header = {
        "Content-Type": "application/json;charset=UTF-8"
    };
    var url = `http://${ip}:5000/api/get_task_log/`;
    return http.request({
        method: "POST",
        url,
        header,
        data: {
            start_time,
            end_time
        }
 
    })
}
 
/**
 * GET 5000/api/teaching_mode
 * 示教查询
 * @param 
 * @returns 
 */
export const getTeachingMode = (ip) => {
    var header = {
        "Content-Type": "application/json;charset=UTF-8"
    };
 
    var url = `http://${ip}:5000/api/teaching_mode/`;
    return http.request({
        method: "GET",
        url,
        header,
 
    })
}
 
/**
 * POST 5000/api/teaching_mode_flag
 * 开始/停止示教
 * @param 
 * mode # 公共示教类型: Public, 站台示教类型Stations
 * src_dst  如果mode为站台示教才有值否则为空字符串, 传入起点 + _ + 终点的格式 例如 "loc1_loc2"
 * name 示教名称
 * teaching_flag # 1 开始示教, 0 停止示教
 * main_road 1,# 1主路,0支路
 * @returns 
 */
export const teachingModeFlag = (ip, param) => {
    var header = {
        "Content-Type": "application/json;charset=UTF-8"
    };
    const {
        mode,
        src_dst,
        name,
        teaching_flag,
        main_road,
    } = param
 
    var url = `http://${ip}:5000/api/teaching_mode_flag/`;
    return http.request({
        method: "POST",
        url,
        header,
        data: {
            mode,
            src_dst,
            name,
            teaching_flag,
            main_road
        }
 
    })
}
 
/**
 * POST 5000/api/delete_teaching_mode
 * 删除示教
 * @param 
 * 数组[]
 * mode: 公共示教类型: Public, 站台示教类型Stations    
 *name: #示教名称, 
 * src_dst: #起点终点,
 * @returns 
 */
export const delTeachingMode = (ip, list) => {
    var header = {
        "Content-Type": "application/json;charset=UTF-8"
    };
    var url = `http://${ip}:5000/api/delete_teaching_mode/`;
    return http.request({
        method: "POST",
        url,
        header,
        data: {
            data: list
        }
 
    })
}
 
/**
 * POST 5000/api/check_agv_location_distance_error
 * 判断库位和车距离是否过大
 * @param 
 * location_name  库位
 * @returns 
 */
export const checkAgvLocationDistanceError = (ip, location_name) => {
    var header = {
        "Content-Type": "application/json;charset=UTF-8"
    };
    var url = `http://${ip}:5000/api/check_agv_location_distance_error/`;
    return http.request({
        method: "POST",
        url,
        header,
        data: {
            location_name
        }
 
    })
}