From f0a28e62263008be12670dacd7cd26b6a059943d Mon Sep 17 00:00:00 2001 From: LiLongLong <13717757313@163.com> Date: Fri, 7 Mar 2025 11:56:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=8B=E9=87=8F=E8=AE=B0?= =?UTF-8?q?=E5=BD=95MOCK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.ts | 3 ++- src/routes/measureData.ts | 67 +++++++++++++++++++++++++++++++++++++++++++++++ src/types/wsTypes.ts | 13 ++++++++- 3 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 src/routes/measureData.ts diff --git a/src/index.ts b/src/index.ts index 080ca1c..a1978a1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,6 +8,7 @@ import cmdRouter from "./routes/cmd"; import debugRouter from "./routes/debug"; import authRouter from "./routes/auth"; import measureRouter from "./routes/measure"; +import measureDataRouter from "./routes/measureData" // import { defaultStatus, StatusDatagram } from "./types/wsTypes"; import { wsSend } from "./utils/wss"; @@ -59,7 +60,7 @@ app.use("/api/debug", debugRouter); app.use("/api/cmd", cmdRouter); app.use("/auth", authRouter); app.use("/measurement-task", measureRouter); - +app.use("/measurement-data", measureDataRouter); //@ts-ignore app.use((err, req, res, next) => { console.error(err.stack); diff --git a/src/routes/measureData.ts b/src/routes/measureData.ts new file mode 100644 index 0000000..37eb34b --- /dev/null +++ b/src/routes/measureData.ts @@ -0,0 +1,67 @@ +import express from "express"; +import { delay } from "../utils/helper"; +import { wsSend } from "../utils/wss"; +const router = express.Router(); + +router.post("/list", async (req, res) => { + await delay(100); + wsSend(req.app.locals["wss"], { + messageType: "STATE", + data: { + isConnect: true, + "connectPort": "COM4",//串口名 + "sn": "",//连接的设备ID + "descriptivePortName": "COM4 serial ch340" //用于详细系 + }, + path: "/subdevice/uartchanel/get-channel-state", + }); + + res.json({ + status: 0 , + data:{ + list:[{ + "id": 27033,//数据主键id + "createTime": "2025-03-03 17:05:34",//数据创建时间 + "updateTime": "2025-03-03 17:05:34",//数据修改时间 + "uuid": "650fc0a3-8bb2-4223-973e-72846fd31b82",//数据uuid + "operatorName": "张三",//操作员姓名 + "trackShapeCode": "001",//轨型code + "verificationMethodCode": "aaa",//核校方式code + "name": "京沪铁路12",//测量名称 + "lineName": "河北段",//线路名称 + "location": "100米处",//位置 + "direction": "左"///方向 + },{ + "id": 27044,//数据主键id + "createTime": "2025-03-03 17:05:34",//数据创建时间 + "updateTime": "2025-03-03 17:05:34",//数据修改时间 + "uuid": "650fc0a3-8bb2-4223-973e-72846fd31b83",//数据uuid + "operatorName": "李四",//操作员姓名 + "trackShapeCode": "002",//轨型code + "verificationMethodCode": "bbb",//核校方式code + "name": "京昆铁路",//测量名称 + "lineName": "河北段",//线路名称 + "location": "5100米处",//位置 + "direction": "右"///方向 + }] + } + }); +}); + +router.post("/getDevice", async (req, res) => { + res.json({ + status: 0 , + data:{ + list:[{ + name:'Kdkow_1', + id:'1', + },{ + name:'llwoa_2', + id:'2', + }] + } + }) +}) + + +export default router \ No newline at end of file diff --git a/src/types/wsTypes.ts b/src/types/wsTypes.ts index b8aec4b..56c656a 100644 --- a/src/types/wsTypes.ts +++ b/src/types/wsTypes.ts @@ -38,4 +38,15 @@ export type ContextMessage = { path: "/deviceContext"; }; -export type Datagram = TrackRecordSig | TaskState | ContextMessage; +export type ChannelMessage = { + messageType: "STATE"; + data: { + isConnect: boolean; + connectPort: string; + sn: string; + descriptivePortName:string; + }; + path: "/subdevice/uartchanel/get-channel-state"; +}; + +export type Datagram = TrackRecordSig | TaskState | ContextMessage | ChannelMessage;