1、支持常用命令置顶功能
This commit is contained in:
parent
5fce40b221
commit
b25a3a6cde
@ -1,6 +1,7 @@
|
|||||||
package com.imdroid.beidou.controller;
|
package com.imdroid.beidou.controller;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.imdroid.beidou.common.HttpResult;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
@ -41,8 +43,10 @@ public class CmdLineController extends BasicController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/page/table/frequent_cmd")
|
@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);
|
initModel(m, session);
|
||||||
|
m.addAttribute("device_id", device_id);
|
||||||
|
m.addAttribute("send_channel", send_channel);
|
||||||
|
|
||||||
return "/page/table/frequent_cmd";
|
return "/page/table/frequent_cmd";
|
||||||
}
|
}
|
||||||
@ -62,6 +66,10 @@ public class CmdLineController extends BasicController{
|
|||||||
@RequestParam("device_id") String deviceId,
|
@RequestParam("device_id") String deviceId,
|
||||||
@RequestParam("cmd_type") int cmdType,
|
@RequestParam("cmd_type") int cmdType,
|
||||||
@RequestParam("send_channel") int sendChannel) {
|
@RequestParam("send_channel") int sendChannel) {
|
||||||
|
if(!StringUtils.hasText(deviceId)){
|
||||||
|
return HttpResult.fail("设备号不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
String sendCmd = cmd.replaceAll(" +","");
|
String sendCmd = cmd.replaceAll(" +","");
|
||||||
short len = 0;
|
short len = 0;
|
||||||
int msgType = 0xD310 + cmdType;
|
int msgType = 0xD310 + cmdType;
|
||||||
@ -159,7 +167,9 @@ public class CmdLineController extends BasicController{
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public JSONObject listCmd(int page, int limit) {
|
public JSONObject listCmd(int page, int limit) {
|
||||||
Page<DeviceCmd> pageable = new Page<>(page, 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 jsonObject = new JSONObject();
|
||||||
jsonObject.put("code", 0);
|
jsonObject.put("code", 0);
|
||||||
@ -204,6 +214,23 @@ public class CmdLineController extends BasicController{
|
|||||||
return HttpResult.failed();
|
return HttpResult.failed();
|
||||||
} else return HttpResult.ok();
|
} 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")
|
@PostMapping("/gnss/cache_cmd/delete")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
|||||||
@ -37,7 +37,7 @@
|
|||||||
<div class="layui-inline">
|
<div class="layui-inline">
|
||||||
<label class="layui-form-label">设备ID</label>
|
<label class="layui-form-label">设备ID</label>
|
||||||
<div class="layui-input-inline">
|
<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>
|
</div>
|
||||||
<div class="layui-inline">
|
<div class="layui-inline">
|
||||||
@ -151,7 +151,7 @@
|
|||||||
offset: 'rb',
|
offset: 'rb',
|
||||||
anim: 2,
|
anim: 2,
|
||||||
area: ['50%', '100%'],
|
area: ['50%', '100%'],
|
||||||
content: '../page/table/q_cache_cmd',
|
content: '../page/table/q_cache_cmd'
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@ -165,8 +165,9 @@
|
|||||||
shadeClose: true,
|
shadeClose: true,
|
||||||
offset: 'rb',
|
offset: 'rb',
|
||||||
anim: 2,
|
anim: 2,
|
||||||
area: ['70%', '100%'],
|
area: ['50%', '100%'],
|
||||||
content: '../page/table/frequent_cmd',
|
content: '../page/table/frequent_cmd?device_id='+
|
||||||
|
$('#device_id').val()+'&send_channel='+$('#send_channel').val()
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@ -179,6 +180,11 @@
|
|||||||
$('#tx_win').val(content);
|
$('#tx_win').val(content);
|
||||||
form.render();
|
form.render();
|
||||||
}
|
}
|
||||||
|
function setResult(result) {
|
||||||
|
var $ = layui.$;
|
||||||
|
$("#rx_win").val($("#rx_win").val() + result.data + "\r\n");
|
||||||
|
form.render();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- Web socket operations-->
|
<!-- Web socket operations-->
|
||||||
|
|||||||
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
<div class="layui-form layuimini-form">
|
<div class="layui-form layuimini-form">
|
||||||
<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
|
<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 top-panel">
|
||||||
<div class="layui-card-body">
|
<div class="layui-card-body">
|
||||||
@ -63,11 +65,12 @@
|
|||||||
<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
|
<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
|
||||||
|
|
||||||
<script type="text/html" id="currentTableBar">
|
<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>
|
<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script th:inline="none">
|
<script th:inline="javascript">
|
||||||
layui.use(['form', 'table'], function () {
|
layui.use(['form', 'table'], function () {
|
||||||
var $ = layui.$,
|
var $ = layui.$,
|
||||||
form = layui.form,
|
form = layui.form,
|
||||||
@ -81,12 +84,14 @@
|
|||||||
table.render({
|
table.render({
|
||||||
elem: '#currentTableId',
|
elem: '#currentTableId',
|
||||||
url: '/gnss/cmd/list',
|
url: '/gnss/cmd/list',
|
||||||
cols: [[
|
cols: [
|
||||||
{field: 'name', title: '指令名称'},
|
[
|
||||||
|
{field: 'name', title: '指令名称',width:'20%'},
|
||||||
{field: 'type', title: '类型',templet: '#typeTrans'},
|
{field: 'type', title: '类型',templet: '#typeTrans'},
|
||||||
{field: 'content', title: '指令',width:'50%'},
|
{field: 'content', title: '指令',width:'40%'},
|
||||||
{title: '操作', toolbar: '#currentTableBar', align: "center", minWidth: 120}
|
{title: '操作', toolbar: '#currentTableBar', align: "center", minWidth: 180}
|
||||||
]],
|
]
|
||||||
|
],
|
||||||
limits: [10, 15, 20, 25, 50, 100],
|
limits: [10, 15, 20, 25, 50, 100],
|
||||||
limit: 10,
|
limit: 10,
|
||||||
page: true,
|
page: true,
|
||||||
@ -97,7 +102,23 @@
|
|||||||
var data = obj.data;
|
var data = obj.data;
|
||||||
if (obj.event === 'use') {
|
if (obj.event === 'use') {
|
||||||
parent.setCmd(data.type, data.content);
|
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') {
|
else if (obj.event === 'delete') {
|
||||||
layer.confirm('确定删除'+data.name+"?", function(index){
|
layer.confirm('确定删除'+data.name+"?", function(index){
|
||||||
@ -118,6 +139,21 @@
|
|||||||
layer.close(index);
|
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) {
|
form.on('submit(saveBtn)', function (data) {
|
||||||
@ -136,7 +172,6 @@
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" id="typeTrans">
|
<script type="text/html" id="typeTrans">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user