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 | 496 +++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 443 insertions(+), 53 deletions(-)
diff --git a/api/vehicle.js b/api/vehicle.js
index 47f4d43..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,7 +394,7 @@
method: "GET",
url,
header,
-
+
})
@@ -111,7 +416,7 @@
url,
header,
timeout: 5000,
-
+
})
}
@@ -209,7 +514,7 @@
data: {
stationID,
name,
- x:Number(x),
+ x: Number(x),
y: Number(y),
angle
}
@@ -702,7 +1007,7 @@
* @returns
*/
export const updateSplitTeachingData = (ip, param) => {
-
+
const {
edge_name,
name,
@@ -734,8 +1039,8 @@
* name # 蹇呬紶
* @returns
*/
-export const deleteSplitTeachingData = (ip, edge_name,name) => {
-
+export const deleteSplitTeachingData = (ip, edge_name, name) => {
+
var header = {
"Content-Type": "application/json;charset=UTF-8"
};
@@ -810,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"
};
@@ -858,7 +1163,7 @@
* @returns
*/
-export const getMapLaserData = (ip,mapId) => {
+export const getMapLaserData = (ip, mapId) => {
var header = {
"Content-Type": "application/json;charset=UTF-8"
};
@@ -1000,10 +1305,50 @@
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,
+ })
+}
+
/**
@@ -1041,47 +1386,92 @@
method: "POST",
url,
header,
- data: {status}
+ 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/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