From b25a3a6cded018dde19d74dbdc25ac7ca2d22b38 Mon Sep 17 00:00:00 2001 From: weidong Date: Wed, 18 Dec 2024 16:21:07 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=94=AF=E6=8C=81=E5=B8=B8=E7=94=A8?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E7=BD=AE=E9=A1=B6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../beidou/controller/CmdLineController.java | 31 ++++++++++- .../resources/templates/page/cmd_line.html | 14 +++-- .../templates/page/table/frequent_cmd.html | 53 +++++++++++++++---- 3 files changed, 83 insertions(+), 15 deletions(-) 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 35c97520..2c9cebd3 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,6 +1,7 @@ package com.imdroid.beidou.controller; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.imdroid.beidou.common.HttpResult; @@ -11,6 +12,7 @@ import com.imdroid.secapi.dto.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; +import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpSession; @@ -41,8 +43,10 @@ public class CmdLineController extends BasicController{ } @RequestMapping("/page/table/frequent_cmd") - public String frequentCmd(Model m, HttpSession session) { + public String frequentCmd(Model m, HttpSession session, String device_id, Integer send_channel) { initModel(m, session); + m.addAttribute("device_id", device_id); + m.addAttribute("send_channel", send_channel); return "/page/table/frequent_cmd"; } @@ -62,6 +66,10 @@ public class CmdLineController extends BasicController{ @RequestParam("device_id") String deviceId, @RequestParam("cmd_type") int cmdType, @RequestParam("send_channel") int sendChannel) { + if(!StringUtils.hasText(deviceId)){ + return HttpResult.fail("设备号不能为空"); + } + String sendCmd = cmd.replaceAll(" +",""); short len = 0; int msgType = 0xD310 + cmdType; @@ -159,7 +167,9 @@ public class CmdLineController extends BasicController{ @ResponseBody public JSONObject listCmd(int page, int limit) { Page pageable = new Page<>(page, limit); - IPage cs = deviceCmdMapper.selectPage(pageable, null); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.orderByDesc("id"); + IPage cs = deviceCmdMapper.selectPage(pageable, queryWrapper); JSONObject jsonObject = new JSONObject(); jsonObject.put("code", 0); @@ -204,6 +214,23 @@ public class CmdLineController extends BasicController{ return HttpResult.failed(); } else return HttpResult.ok(); } + @PostMapping("/gnss/cmd/go_top") + @ResponseBody + public String topCmd(@RequestParam int id) throws Exception { + DeviceCmd cmd = deviceCmdMapper.selectById(id); + if(cmd == null) return HttpResult.failed(); + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.orderByDesc("id"); + queryWrapper.last("limit 1"); + DeviceCmd cmdMaxId = deviceCmdMapper.selectOne(queryWrapper); + if(!cmdMaxId.getId().equals(cmd.getId())){ + deviceCmdMapper.deleteById(cmd.getId()); + cmd.setId(cmdMaxId.getId()+1); + deviceCmdMapper.insert(cmd); + } + return HttpResult.ok(); + } @PostMapping("/gnss/cache_cmd/delete") @ResponseBody 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 95c25382..4efadb7a 100644 --- a/sec-beidou/src/main/resources/templates/page/cmd_line.html +++ b/sec-beidou/src/main/resources/templates/page/cmd_line.html @@ -37,7 +37,7 @@
- +
@@ -151,7 +151,7 @@ offset: 'rb', anim: 2, area: ['50%', '100%'], - content: '../page/table/q_cache_cmd', + content: '../page/table/q_cache_cmd' }); return false; }); @@ -165,8 +165,9 @@ shadeClose: true, offset: 'rb', anim: 2, - area: ['70%', '100%'], - content: '../page/table/frequent_cmd', + area: ['50%', '100%'], + content: '../page/table/frequent_cmd?device_id='+ + $('#device_id').val()+'&send_channel='+$('#send_channel').val() }); return false; }); @@ -179,6 +180,11 @@ $('#tx_win').val(content); form.render(); } + function setResult(result) { + var $ = layui.$; + $("#rx_win").val($("#rx_win").val() + result.data + "\r\n"); + form.render(); + } diff --git a/sec-beidou/src/main/resources/templates/page/table/frequent_cmd.html b/sec-beidou/src/main/resources/templates/page/table/frequent_cmd.html index 95d02a5e..bf7fd308 100644 --- a/sec-beidou/src/main/resources/templates/page/table/frequent_cmd.html +++ b/sec-beidou/src/main/resources/templates/page/table/frequent_cmd.html @@ -18,6 +18,8 @@
+ +
@@ -63,11 +65,12 @@ -