From 2af5f043b60c1f7ac38ecccc8f5bf44743134325 Mon Sep 17 00:00:00 2001
From: cuiqian2004 <cuiqian2004@163.com>
Date: 星期五, 12 十二月 2025 18:08:00 +0800
Subject: [PATCH] test
---
api/vehicle.js | 599 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 590 insertions(+), 9 deletions(-)
diff --git a/api/vehicle.js b/api/vehicle.js
index f98fa91..b40c756 100644
--- a/api/vehicle.js
+++ b/api/vehicle.js
@@ -4,10 +4,11 @@
} from "@/comm/utils.js"
const addLog = (item) => {
- const list = session.getValue("request_log") || []
- list.unshift(item)
- session.setValue("request_log", list)
+ http.addLog(item)
}
+
+
+
// 鍒ゆ柇ip鏄惁鍙互杩炴帴涓� export const checkIpLinkSuccess = (ip) => {
var url = `http://${ip}:4405/api/mt/battery`;
@@ -75,6 +76,310 @@
}
/**
+ * GET 4405/api/shell/version
+ * 鑾峰彇杞欢鐗堟湰淇℃伅锛�+ * @param
+ * @returns
+ */
+export const getShellVersion = (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 4405/api/shell/version
+ * 鏇存柊杞欢鐗堟湰
+ * @param
+ * @returns
+ */
+
+export const uploadShellVersion = async (ip, path) => {
+
+ var header = {
+ 'Content-Type': 'application/octet-stream'
+ };
+
+ var url = `http://${ip}:4405/api/shell/version`;
+ const buf = await FilePath.readArrayBuffer({
+ path: filePath
+ });
+ const flag = 3
+ const flagBuf = new ArrayBuffer(4);
+ const view = new DataView(flagBuf);
+ view.setUint32(0, flag, false); // 澶х
+ // 2.3 鎷兼帴 POST 浣擄細flag(4B) + 鍘嬬缉鍖�+ const body = new ArrayBuffer(4 + buf.byteLength);
+ const whole = new Uint8Array(body);
+ whole.set(new Uint8Array(flagBuf), 0);
+ whole.set(new Uint8Array(buf), 4);
+ return http.request({
+ method: "POST",
+ url,
+ header,
+ dataType: 'arraybuffer', // 鍏抽敭锛氳 data 鎸変簩杩涘埗璧�+ data: body,
+ })
+}
+export const shellUpgrade = async (ip, filePath, cbSuccess, cbProgress, cbFail) => {
+
+ var url = `http://${ip}:4405/api/shell/upgrade`;
+ const uploadTask = uni.uploadFile({
+ url,
+ name: "upload",
+ filePath: filePath,
+ formData: {
+ 'upgrade_flag': 3
+ },
+ success: (result) => {
+ console.log(result)
+ const now = new Date()
+ const date = `${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`
+ if (result.statusCode != 200) {
+ http.addLog({
+ date,
+ method: "POST",
+ url,
+ param: {
+ upload: filePath,
+ upgrade_flag: 3
+ },
+ statusCode: result.statusCode,
+ data: ""
+ })
+ if (result.statusCode == 404) {
+ cbFail("鍦板潃涓嶅锛岃妫�煡璇ュ湴鍧�細" + url);
+ } else
+ cbFail("璁块棶澶辫触锛岀姸鎬佺爜锛� + result.statusCode);
+ } else {
+ 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) {
+ cbFail('灏嗐�json string銆戣浆鎹负銆恓son object銆戝け璐�);
+ }
+ }
+ http.addLog({
+ date,
+ method: "POST",
+ url,
+ param: {
+ upload: filePath,
+ upgrade_flag: 3
+ },
+ statusCode: result.statusCode,
+ data: JSON.stringify(ret)
+ })
+ if (ret.code == 0) {
+
+ cbSuccess(ret.data);
+ } else {
+ cbFail(ret.msg || ret.message || "");
+ }
+
+ }
+ },
+ fail: (result) => {
+ console.log(result)
+ cbFail(result);
+ },
+ })
+ uploadTask.onProgressUpdate((res) => {
+ cbProgress(res, uploadTask)
+ });
+}
+
+/**
+ * GET 4405/api/error/list
+ * 鑾峰彇瀹炴椂閿欒
+ * @param
+ * @returns
+ */
+
+export const getErrorList = (ip) => {
+ var header = {
+ "Content-Type": "application/json;charset=UTF-8"
+ };
+ var url = `http://${ip}:4405/api/error/list?_timestamp=${new Date().getTime()}`;
+ return http.request({
+ method: "GET",
+ url,
+ header,
+ })
+}
+
+
+/**
+ * POST 4405/api/mt/clear_fault
+ * 娓呴櫎瀹炴椂閿欒
+ * @param
+ * @returns
+ */
+
+export const clearFault = (ip) => {
+ var header = {
+ "Content-Type": "application/json;charset=UTF-8"
+ };
+ var url = `http://${ip}:4405/api/mt/clear_fault`;
+ return http.request({
+ method: "POST",
+ url,
+ header,
+ })
+}
+
+/**
+ * GET 4405/api/error/history
+ * 鑾峰彇鍘嗗彶閿欒
+ * @param
+ * @returns
+ */
+
+export const getErrorHistory = (ip) => {
+ var header = {
+ "Content-Type": "application/json;charset=UTF-8"
+ };
+ var url = `http://${ip}:4405/api/error/history?_timestamp=${new Date().getTime()}`;
+ return http.request({
+ method: "GET",
+ url,
+ header,
+ })
+}
+/**
+ * GET 4405/api/error/download_error
+ * 涓嬭浇鍘嗗彶閿欒鏃ュ織锛�+ * @param
+ * @returns
+ */
+
+
+export const downloadError = (ip, path, cbSuccess, cbProgress, cbFail) => {
+ var url = `http://${ip}:4405/api/error/download_error?path=${encodeURI(path)}`;
+ console.log(url)
+ // var header = {
+ // "Content-Type": "application/json;charset=UTF-8"
+ // };
+ // return http.request({
+ // method: "GET",
+ // url,
+ // header,
+ // })
+ // return
+ const downloadTask = uni.downloadFile({
+ url: url,
+ header: {
+ 'content-type': 'application/octet-stream',
+ },
+ success: (result) => {
+ console.log("downloadFile", result)
+ const now = new Date()
+ const date = `${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`
+ if (result.statusCode === 200) {
+ http.addLog({
+ date,
+ method: `GET`,
+ url: url,
+ param: {},
+ statusCode: result.statusCode,
+ data: result
+ })
+ cbSuccess(result.tempFilePath)
+ } else {
+
+ http.addLog({
+ date,
+ method: `GET`,
+ url: url,
+ param: {},
+ statusCode: result.statusCode,
+ data: result.data
+ })
+ cbFail(result.data || '涓嬭浇鏈煡閿欒!');
+ }
+ },
+ fail: (result) => {
+ console.log("downloadTaskFile fail", result)
+ const now = new Date()
+ const date = `${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`
+ http.addLog({
+ date,
+ method: `GET`,
+ url: url,
+ param: {},
+ statusCode: -1,
+ data: result
+ })
+ cbFail('涓嬭浇鏂囦欢澶辫触!');
+ }
+ })
+ downloadTask.onProgressUpdate((res) => {
+
+ cbProgress(res, downloadTask)
+ });
+ return downloadTask
+}
+
+/**
+ * POST 4405/api/mt/error/tar_log
+ * 鎵撳寘涓嬭浇鏃ュ織
+ * @param
+ * @returns
+ */
+
+export const tarErrorLog = (ip, start_time, end_time) => {
+ var header = {
+ "Content-Type": "application/json;charset=UTF-8"
+ };
+ var url = `http://${ip}:4405/api/error/tar_log`;
+ return http.request({
+ method: "POST",
+ url,
+ header,
+ data: {
+ start_time,
+ end_time
+ }
+ })
+}
+
+/**
+ * GET 4405/api/error/query_task_status
+ * 鏌ヨ鎵撳寘鍚庣殑鏃ュ織鐩綍(鏌ュ埌鍚庝娇鐢�405/api/error/download_error鎺ュ彛涓嬭浇)
+ * @param
+ * @returns
+ */
+
+export const queryErrorTaskStatus = (ip, task_list) => {
+ var header = {
+ "Content-Type": "application/json;charset=UTF-8"
+ };
+ var url =
+ `http://${ip}:4405/api/error/query_task_status?_timestamp=${new Date().getTime()}&task_list=${encodeURI(JSON.stringify(task_list))}`;
+ return http.request({
+ method: "GET",
+ url,
+ header,
+ })
+}
+/**
* GET 5000/api/get_agv_state
* 鏌ヨ杞﹁締淇℃伅
* @param
@@ -89,6 +394,7 @@
method: "GET",
url,
header,
+
})
@@ -109,6 +415,8 @@
method: "GET",
url,
header,
+ timeout: 5000,
+
})
}
@@ -206,7 +514,7 @@
data: {
stationID,
name,
- x:Number(x),
+ x: Number(x),
y: Number(y),
angle
}
@@ -553,6 +861,27 @@
}
/**
+ * GET 5000/api/split_teaching_mode
+ * 鍒囧垎鍚庣殑绀烘暀鏌ヨ
+ * @param
+ * @returns
+ */
+export const splitTeachingMode = (ip) => {
+ var header = {
+ "Content-Type": "application/json;charset=UTF-8"
+ };
+
+ var url = `http://${ip}:5000/api/split_teaching_mode/`;
+ return http.request({
+ method: "GET",
+ url,
+ header,
+
+ })
+}
+
+
+/**
* GET 5000/api/get_current_teaching_data
* 鑾峰彇璁板綍鐨勭ず鏁欐暟鎹� * @param
@@ -582,6 +911,7 @@
* teaching_flag # 1 寮�绀烘暀锛�0 鍋滄绀烘暀
* main_road 1,# 1涓昏矾锛�鏀矾
* "bidirection": "1", # 1涓哄弻鍚戯紝0涓哄崟鍚戯紝鍋滄绀烘暀鐨勬椂鍊欎紶鍊煎嵆鍙紙 鍗�teaching_flag": 0锛�+ * mode_type # 0榛樿1鍙屽悜2鏅鸿兘
* @returns
*/
export const teachingModeFlag = (ip, param) => {
@@ -594,7 +924,8 @@
name,
teaching_flag,
main_road,
- bidirection
+ bidirection,
+ mode_type
} = param
var url = `http://${ip}:5000/api/teaching_mode_flag/`;
@@ -608,7 +939,8 @@
name,
teaching_flag,
main_road,
- bidirection
+ bidirection,
+ mode_type
}
})
@@ -640,6 +972,7 @@
})
}
+
/**
* POST 5000/api/delete_teaching_mode_data
* 鍒犻櫎绀烘暀鏁版嵁
@@ -658,6 +991,67 @@
header,
data: {
polygon_points: polygonPoints
+ }
+
+ })
+}
+
+/**
+ * POST 5000/api/update_split_teaching_data
+ * 淇敼鍒囧垎绀烘暀鏁版嵁灞炴�
+ * @param
+ * edge_name # 蹇呬紶id
+ * bidirection # 闈炲繀浼狅紝淇敼鍗曞弻鍚戜紶閫�+ * main_road # 闈炲繀浼狅紝淇敼涓昏矾鏀矾浼犻�
+ * name # 蹇呬紶
+ * @returns
+ */
+export const updateSplitTeachingData = (ip, param) => {
+
+ const {
+ edge_name,
+ name,
+ main_road,
+ bidirection
+ } = param
+ var header = {
+ "Content-Type": "application/json;charset=UTF-8"
+ };
+ var url = `http://${ip}:5000/api/update_split_teaching_data/`;
+ return http.request({
+ method: "POST",
+ url,
+ header,
+ data: {
+ edge_name,
+ name,
+ main_road,
+ bidirection
+ }
+
+ })
+}
+/**
+ * POST 5000/api/delete_split_teaching_data
+ * 鍒犻櫎鍒囧垎绀烘暀鏁版嵁
+ * @param
+ * edge_name # 蹇呬紶id
+ * name # 蹇呬紶
+ * @returns
+ */
+export const deleteSplitTeachingData = (ip, edge_name, name) => {
+
+ var header = {
+ "Content-Type": "application/json;charset=UTF-8"
+ };
+ var url = `http://${ip}:5000/api/delete_split_teaching_data/`;
+ return http.request({
+ method: "POST",
+ url,
+ header,
+ data: {
+ edge_name,
+ name,
}
})
@@ -721,7 +1115,7 @@
* @returns
*/
-export const addMap = (ip, scene_id, map_type="create") => {
+export const addMap = (ip, scene_id, map_type = "create") => {
var header = {
"Content-Type": "application/json;charset=UTF-8"
};
@@ -769,7 +1163,7 @@
* @returns
*/
-export const getMapLaserData = (ip,mapId) => {
+export const getMapLaserData = (ip, mapId) => {
var header = {
"Content-Type": "application/json;charset=UTF-8"
};
@@ -780,6 +1174,27 @@
header,
})
}
+
+/**
+ * GET 6000/api/get_map_server_phase
+ * 鑾峰彇鏋勫浘绋嬪簭闃舵
+ * @param
+ * @returns
+ * "data": 1, # 1锛氭湭鍚姩2锛氬惎鍔ㄤ腑3锛氬惎鍔ㄥ畬鎴�锛氭瀯鍥句繚瀛樹腑5锛氭瀯鍥句繚瀛樺畬鎴�锛氭瀯鍥句繚瀛樺け璐�+ */
+
+export const getMapServerPhase = (ip) => {
+ var header = {
+ "Content-Type": "application/json;charset=UTF-8"
+ };
+ var url = `http://${ip}:5000/api/get_map_server_phase/`;
+ return http.request({
+ method: "GET",
+ url,
+ header,
+ })
+}
+
/**
* POST 5000/api/update_scene_id
@@ -890,7 +1305,173 @@
method: "POST",
url,
header,
- data: {data}
+ data: {
+ data
+ }
+
+ })
+}
+
+/**
+ * GET 5000/api/save_db_data_status
+ * 鑾峰彇DB鏁版嵁淇濆瓨鐘舵�锛�+ * @param
+ * @returns 1淇濆瓨涓�2淇濆瓨鎴愬姛 3淇濆瓨澶辫触
+ */
+
+export const getSaveDBDataStatus = (ip) => {
+ var header = {
+ "Content-Type": "application/json;charset=UTF-8"
+ };
+ var url = `http://${ip}:5000/api/save_db_data_status/`;
+ return http.request({
+ method: "GET",
+ url,
+ header,
+ })
+}
+/**
+ * GET 5000/api/cancel_save_db_data
+ * 鍙栨秷淇濆瓨DB鏁版嵁锛�+ * @param
+ * @returns
+ */
+
+export const cancelSaveDBData = (ip) => {
+ var header = {
+ "Content-Type": "application/json;charset=UTF-8"
+ };
+ var url = `http://${ip}:5000/api/cancel_save_db_data/`;
+ return http.request({
+ method: "GET",
+ url,
+ header,
+ })
+}
+
+
+
+/**
+ * GET 5000/api/check_mapserver_is_start
+ * 鍒ゆ柇鏋勫浘绋嬪簭鏄惁鍚姩
+ * @param
+ * @returns
+ */
+
+export const checkMapServerIsStart = (ip) => {
+ var header = {
+ "Content-Type": "application/json;charset=UTF-8"
+ };
+ var url = `http://${ip}:5000/api/check_mapserver_is_start/`;
+ return http.request({
+ method: "GET",
+ url,
+ header,
+ })
+}
+
+/**
+ * POST 5000/api/start_or_stop_mapserver
+ * 寮�惎鎴栬�鍏抽棴鏋勫浘绋嬪簭锛�1寮�惎2鍏抽棴
+ * @param status 1寮�惎2鍏抽棴
+ * @returns
+ */
+
+export const startOrStopMapServer = (ip, status) => {
+ var header = {
+ "Content-Type": "application/json;charset=UTF-8"
+ };
+ var url = `http://${ip}:5000/api/start_or_stop_mapserver/`;
+ return http.request({
+ method: "POST",
+ url,
+ header,
+ data: {
+ status
+ }
+
+ })
+}
+
+
+/**
+ * GET 5000/api/check_mapserver_is_ok
+ * 鏋勫浘绋嬪簭鏄惁鍑嗗鍒颁綅
+ * @param
+ * @returns
+ */
+
+export const checkMapServerIsOk = (ip) => {
+ var header = {
+ "Content-Type": "application/json;charset=UTF-8"
+ };
+ var url = `http://${ip}:5000/api/check_mapserver_is_ok/`;
+ return http.request({
+ method: "GET",
+ url,
+ header,
+ })
+}
+
+/**
+ * GET 5000/api/check_save_map_is_ok
+ * 缁撴潫鏋勫浘鏄惁淇濆瓨瀹屾垚
+ * @param
+ * @returns
+ */
+
+export const checkSaveMapIsOk = (ip) => {
+ var header = {
+ "Content-Type": "application/json;charset=UTF-8"
+ };
+ var url = `http://${ip}:5000/api/check_save_map_is_ok/`;
+ return http.request({
+ method: "GET",
+ url,
+ header,
+ })
+}
+
+/**
+ * GET 5000/api/get_pallet_size/
+ * 鑾峰彇鎵樼洏灏哄锛�+ * @param
+ * @returns
+ */
+
+export const getPalletSize = (ip) => {
+ var header = {
+ "Content-Type": "application/json;charset=UTF-8"
+ };
+ var url = `http://${ip}:5000/api/get_pallet_size/`;
+ return http.request({
+ method: "GET",
+ url,
+ header,
+ })
+}
+
+
+/**
+ * POST 5000/api/save_pallet_size/
+ * 璁剧疆鎵樼洏灏哄锛�
+ * @param length 2,#闀垮害/鍗曚綅m
+ * @param width 2,#闀垮害/鍗曚綅m
+ * @returns
+ */
+export const savePalletSize = (ip, length, width) => {
+ var header = {
+ "Content-Type": "application/json;charset=UTF-8"
+ };
+ var url = `http://${ip}:5000/api/save_pallet_size/`;
+ return http.request({
+ method: "POST",
+ url,
+ header,
+ data: {
+ length,
+ width
+ }
})
}
\ No newline at end of file
--
Gitblit v1.9.1