1、支持常用命令置顶功能
This commit is contained in:
parent
5fce40b221
commit
b25a3a6cde
@ -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<DeviceCmd> pageable = new Page<>(page, limit);
|
||||
IPage<DeviceCmd> cs = deviceCmdMapper.selectPage(pageable, null);
|
||||
QueryWrapper<DeviceCmd> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc("id");
|
||||
IPage<DeviceCmd> 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<DeviceCmd> 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
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">设备ID</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="device_id" autocomplete="off" class="layui-input">
|
||||
<input type="text" name="device_id" id="device_id" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
@ -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();
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Web socket operations-->
|
||||
|
||||
@ -18,6 +18,8 @@
|
||||
|
||||
<div class="layui-form layuimini-form">
|
||||
<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
|
||||
<input type="hidden" name="device_id" id="device_id">
|
||||
<input type="hidden" name="send_channel" id="send_channel">
|
||||
|
||||
<div class="layui-card top-panel">
|
||||
<div class="layui-card-body">
|
||||
@ -63,11 +65,12 @@
|
||||
<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
|
||||
|
||||
<script type="text/html" id="currentTableBar">
|
||||
<a class="layui-btn layui-btn-normal layui-btn-xs " lay-event="use">使用</a>
|
||||
<a class="layui-btn layui-btn-normal layui-btn-xs " lay-event="use">发送</a>
|
||||
<a class="layui-btn layui-btn-normal layui-btn-xs " lay-event="go_top">置顶</a>
|
||||
<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
|
||||
</script>
|
||||
|
||||
<script th:inline="none">
|
||||
<script th:inline="javascript">
|
||||
layui.use(['form', 'table'], function () {
|
||||
var $ = layui.$,
|
||||
form = layui.form,
|
||||
@ -81,12 +84,14 @@
|
||||
table.render({
|
||||
elem: '#currentTableId',
|
||||
url: '/gnss/cmd/list',
|
||||
cols: [[
|
||||
{field: 'name', title: '指令名称'},
|
||||
cols: [
|
||||
[
|
||||
{field: 'name', title: '指令名称',width:'20%'},
|
||||
{field: 'type', title: '类型',templet: '#typeTrans'},
|
||||
{field: 'content', title: '指令',width:'50%'},
|
||||
{title: '操作', toolbar: '#currentTableBar', align: "center", minWidth: 120}
|
||||
]],
|
||||
{field: 'content', title: '指令',width:'40%'},
|
||||
{title: '操作', toolbar: '#currentTableBar', align: "center", minWidth: 180}
|
||||
]
|
||||
],
|
||||
limits: [10, 15, 20, 25, 50, 100],
|
||||
limit: 10,
|
||||
page: true,
|
||||
@ -97,7 +102,23 @@
|
||||
var data = obj.data;
|
||||
if (obj.event === 'use') {
|
||||
parent.setCmd(data.type, data.content);
|
||||
parent.layer.close(iframeIndex);
|
||||
$.ajax({
|
||||
type:"POST",
|
||||
url:"/gnss/config_cmd",
|
||||
data: {
|
||||
'device_id':[[${device_id}]],
|
||||
'send_channel':[[${send_channel}]],
|
||||
'cmd_type':data.type,
|
||||
'tx_win':data.content
|
||||
},
|
||||
success: function (result) {
|
||||
if(result.code == 0) parent.setResult(result);
|
||||
else layer.alert(result.msg);
|
||||
},
|
||||
error: function () {
|
||||
console.log("ajax error");
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (obj.event === 'delete') {
|
||||
layer.confirm('确定删除'+data.name+"?", function(index){
|
||||
@ -118,6 +139,21 @@
|
||||
layer.close(index);
|
||||
});
|
||||
}
|
||||
else if (obj.event === 'go_top') {
|
||||
$.ajax({
|
||||
type:"POST",
|
||||
url:"/gnss/cmd/go_top",
|
||||
data:{
|
||||
'id':data.id
|
||||
},
|
||||
success: function (data) {
|
||||
table.reload('currentTableId');
|
||||
},
|
||||
error: function () {
|
||||
console.log("ajax error");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
form.on('submit(saveBtn)', function (data) {
|
||||
@ -136,7 +172,6 @@
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="typeTrans">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user