From 20042552756da80f036c37ece360cbe8baca1844 Mon Sep 17 00:00:00 2001 From: weidong Date: Sun, 14 Jan 2024 15:47:19 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=91=BD=E4=BB=A4=E8=A1=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=B8=B8=E7=94=A8=E6=8C=87=E4=BB=A4=202=E3=80=81?= =?UTF-8?q?=E9=83=A8=E5=88=86=E7=95=8C=E9=9D=A2=E5=81=9A=E4=BA=86=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/imdroid/secapi/dto/DeviceCmd.java | 29 ++++ .../imdroid/secapi/dto/DeviceCmdMapper.java | 10 ++ .../beidou/controller/CmdLineController.java | 56 ++++++- .../beidou/controller/WebSocketServer.java | 12 ++ sec-beidou/src/main/resources/db/schema.sql | 11 ++ .../resources/templates/page/cmd_line.html | 31 +++- .../resources/templates/page/fwd_agents.html | 8 +- .../resources/templates/page/fwd_records.html | 7 +- .../templates/page/gnss_data_calc.html | 5 - .../templates/page/gnss_dev_cfg.html | 1 - .../templates/page/table/frequent_cmd.html | 152 ++++++++++++++++++ .../templates/page/table/gnss_add_dev.html | 2 - .../templates/page/table/warning_add.html | 2 - 13 files changed, 294 insertions(+), 32 deletions(-) create mode 100644 sec-api/src/main/java/com/imdroid/secapi/dto/DeviceCmd.java create mode 100644 sec-api/src/main/java/com/imdroid/secapi/dto/DeviceCmdMapper.java create mode 100644 sec-beidou/src/main/resources/templates/page/table/frequent_cmd.html diff --git a/sec-api/src/main/java/com/imdroid/secapi/dto/DeviceCmd.java b/sec-api/src/main/java/com/imdroid/secapi/dto/DeviceCmd.java new file mode 100644 index 00000000..fd54a627 --- /dev/null +++ b/sec-api/src/main/java/com/imdroid/secapi/dto/DeviceCmd.java @@ -0,0 +1,29 @@ +package com.imdroid.secapi.dto; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +/** + * GNSS收发统计消息,每个工作周期结束的时候统计一次 + * + * @author LiGang + */ +@Data +@TableName(value = "devicecmd") +public class DeviceCmd { + // device type definition + public static final short TYPE_GNSS = 0; + public static final short TYPE_DTU = 1; + public static final short TYPE_MPU = 2; + public static final short TYPE_DEBUG = 3; + + public static final short MAX_CMD_LEN = 800; + + @TableId(value = "id", type = IdType.AUTO) + Long id; + String name; + Short type; + String content; +} diff --git a/sec-api/src/main/java/com/imdroid/secapi/dto/DeviceCmdMapper.java b/sec-api/src/main/java/com/imdroid/secapi/dto/DeviceCmdMapper.java new file mode 100644 index 00000000..36dbcdb0 --- /dev/null +++ b/sec-api/src/main/java/com/imdroid/secapi/dto/DeviceCmdMapper.java @@ -0,0 +1,10 @@ +package com.imdroid.secapi.dto; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + + +@Mapper +public interface DeviceCmdMapper extends BaseMapper { + +} diff --git a/sec-beidou/src/main/java/com/imdroid/beidou/controller/CmdLineController.java b/sec-beidou/src/main/java/com/imdroid/beidou/controller/CmdLineController.java index ddfae5c5..d28d0424 100644 --- a/sec-beidou/src/main/java/com/imdroid/beidou/controller/CmdLineController.java +++ b/sec-beidou/src/main/java/com/imdroid/beidou/controller/CmdLineController.java @@ -1,18 +1,17 @@ package com.imdroid.beidou.controller; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.imdroid.beidou.common.HttpResult; import com.imdroid.secapi.client.HttpResp; import com.imdroid.secapi.client.RtcmClient; -import com.imdroid.secapi.dto.GnssMsg; -import com.imdroid.secapi.dto.GnssMsgMapper; +import com.imdroid.secapi.dto.*; import com.imdroid.secapi.utils.HexUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpSession; import java.text.SimpleDateFormat; @@ -26,6 +25,8 @@ public class CmdLineController extends BasicController{ RtcmClient rtcmClient; @Autowired GnssMsgMapper msgMapper; + @Autowired + DeviceCmdMapper deviceCmdMapper; /**** 推送页面 *****/ @RequestMapping("/page/cmd_line") @@ -35,6 +36,13 @@ public class CmdLineController extends BasicController{ return "/page/cmd_line"; } + @RequestMapping("/page/table/frequent_cmd") + public String frequentCmd(Model m, HttpSession session) { + initModel(m, session); + + return "/page/table/frequent_cmd"; + } + /****** 发送指令 *******/ @PostMapping(value = "/gnss/config_cmd") @ResponseBody @@ -83,4 +91,40 @@ public class CmdLineController extends BasicController{ return HttpResult.success(txInfo); } + + @RequestMapping("/gnss/cmd/list") + @ResponseBody + public JSONObject list(int page, int limit) { + Page pageable = new Page<>(page, limit); + IPage cs = deviceCmdMapper.selectPage(pageable, null); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("code", 0); + jsonObject.put("msg", ""); + jsonObject.put("count", cs.getTotal()); + jsonObject.put("data", cs.getRecords()); + return jsonObject; + } + + @PostMapping("/gnss/cmd/add") + @ResponseBody + public String add(@RequestBody JSONObject object) throws Exception { + DeviceCmd deviceCmd = JSONObject.toJavaObject(object,DeviceCmd.class); + int num = deviceCmdMapper.insert(deviceCmd); + + if (num == 0) { + return HttpResult.failed(); + } else{ + return HttpResult.ok(); + } + } + + @PostMapping("/gnss/cmd/delete") + @ResponseBody + public String delete(@RequestParam int del_id) throws Exception { + int num = deviceCmdMapper.deleteById(del_id); + if (num == 0) { + return HttpResult.failed(); + } else return HttpResult.ok(); + } } diff --git a/sec-beidou/src/main/java/com/imdroid/beidou/controller/WebSocketServer.java b/sec-beidou/src/main/java/com/imdroid/beidou/controller/WebSocketServer.java index 4ab63d12..81bd171f 100644 --- a/sec-beidou/src/main/java/com/imdroid/beidou/controller/WebSocketServer.java +++ b/sec-beidou/src/main/java/com/imdroid/beidou/controller/WebSocketServer.java @@ -57,4 +57,16 @@ public class WebSocketServer { } } + public static void sendMessage(HttpSession httpSession, String msg) { + Session session = webSocketSet.get(httpSession.getId()); + if(session != null){ + try { + session.getBasicRemote().sendText(msg); + } + catch (Exception e){ + log.error("websocket send msg error:", e); + } + } + } + } diff --git a/sec-beidou/src/main/resources/db/schema.sql b/sec-beidou/src/main/resources/db/schema.sql index 875c7996..a67051b2 100644 --- a/sec-beidou/src/main/resources/db/schema.sql +++ b/sec-beidou/src/main/resources/db/schema.sql @@ -246,3 +246,14 @@ CREATE TABLE IF NOT EXISTS `fwdrecords` ( `fwd_group_id` varchar(64) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +/*** + 常用指令 + */ +CREATE TABLE IF NOT EXISTS `devicecmd` ( + `id` bigint AUTO_INCREMENT, + `name` varchar(80) NOT NULL, + `type` smallint NOT NULL, + `content` varchar(800) NOT NULL, + PRIMARY KEY (`id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; \ No newline at end of file diff --git a/sec-beidou/src/main/resources/templates/page/cmd_line.html b/sec-beidou/src/main/resources/templates/page/cmd_line.html index 442368b0..16faa33a 100644 --- a/sec-beidou/src/main/resources/templates/page/cmd_line.html +++ b/sec-beidou/src/main/resources/templates/page/cmd_line.html @@ -43,7 +43,7 @@
- @@ -56,6 +56,7 @@
+
@@ -63,7 +64,6 @@ - @@ -111,7 +111,31 @@ rxWin.val(""); return false; }); + + form.on('submit(frequent_btn)', function (data) { + var index = layer.open({ + title: '常用指令', + type: 2, + shade: 0.2, + maxmin:true, + shadeClose: true, + offset: 'rb', + anim: 2, + area: ['70%', '100%'], + content: '../page/table/frequent_cmd', + }); + return false; + }); }); + + function setCmd(type, content){ + var form = layui.form + , $ = layui.$; + console.log(type); + $('#cmd_type').val(type); + $('#tx_win').val(content); + form.render(); + } @@ -160,12 +184,13 @@ layui.layer.alert("Open web socket failed!"); } websocket.onclose = function (){ + console.log("Socket close"); rxWin.val(rxWin.val()+"websocket closed!"); clearInterval(intervalId); } //接收信息 websocket.onmessage = function (event) { - console.log(event.data); + //console.log(event.data); rxWin.val(rxWin.val()+event.data + "\r\n"); rxWin.scrollTop = rxWin.scrollHeight; } diff --git a/sec-beidou/src/main/resources/templates/page/fwd_agents.html b/sec-beidou/src/main/resources/templates/page/fwd_agents.html index 2a8e199b..877f173a 100644 --- a/sec-beidou/src/main/resources/templates/page/fwd_agents.html +++ b/sec-beidou/src/main/resources/templates/page/fwd_agents.html @@ -12,12 +12,7 @@
-
-
代理信息
-
-
-
-
+
@@ -34,7 +29,6 @@ table.render({ elem: '#forwardParaTableId', url: '/fwd/agents', - toolbar: '#toolbarTable', cols: [[ {field: 'name', title: '名称'}, {field: 'description', title: '描述'}, diff --git a/sec-beidou/src/main/resources/templates/page/fwd_records.html b/sec-beidou/src/main/resources/templates/page/fwd_records.html index 862a69e3..c637f9f3 100644 --- a/sec-beidou/src/main/resources/templates/page/fwd_records.html +++ b/sec-beidou/src/main/resources/templates/page/fwd_records.html @@ -12,12 +12,7 @@
-
-
推送记录
-
-
-
-
+
diff --git a/sec-beidou/src/main/resources/templates/page/gnss_data_calc.html b/sec-beidou/src/main/resources/templates/page/gnss_data_calc.html index ab80404c..b6cb3e03 100644 --- a/sec-beidou/src/main/resources/templates/page/gnss_data_calc.html +++ b/sec-beidou/src/main/resources/templates/page/gnss_data_calc.html @@ -82,11 +82,6 @@ table.render({ elem: '#currentTableId', url: '/gnss/data/list_calc', - defaultToolbar: ['filter', 'exports', 'print', { - title: '提示', - layEvent: 'LAYTABLE_TIPS', - icon: 'layui-icon-tips' - }], cols: [[ {field: 'deviceid', title: '设备号'}, {field: 'createtime', title: '上报时间', width:'18%', templet: "
{{layui.util.toDateString(d.createtime, 'yyyy-MM-dd HH:mm:ss')}}
"}, diff --git a/sec-beidou/src/main/resources/templates/page/gnss_dev_cfg.html b/sec-beidou/src/main/resources/templates/page/gnss_dev_cfg.html index 20710964..d035a017 100644 --- a/sec-beidou/src/main/resources/templates/page/gnss_dev_cfg.html +++ b/sec-beidou/src/main/resources/templates/page/gnss_dev_cfg.html @@ -39,7 +39,6 @@
- + +
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+ +
+
+ +
+
+
+
+ + + + + + + + + + + \ No newline at end of file diff --git a/sec-beidou/src/main/resources/templates/page/table/gnss_add_dev.html b/sec-beidou/src/main/resources/templates/page/table/gnss_add_dev.html index 8624b397..558c4375 100644 --- a/sec-beidou/src/main/resources/templates/page/table/gnss_add_dev.html +++ b/sec-beidou/src/main/resources/templates/page/table/gnss_add_dev.html @@ -47,7 +47,6 @@
- @@ -62,7 +61,6 @@
- diff --git a/sec-beidou/src/main/resources/templates/page/table/warning_add.html b/sec-beidou/src/main/resources/templates/page/table/warning_add.html index 5a157457..e1574a59 100644 --- a/sec-beidou/src/main/resources/templates/page/table/warning_add.html +++ b/sec-beidou/src/main/resources/templates/page/table/warning_add.html @@ -30,7 +30,6 @@
- @@ -59,7 +58,6 @@
-