feat: 优化事务管理命令行控制
This commit is contained in:
parent
12eb4471f9
commit
9d41de8d70
@ -530,6 +530,9 @@ public class GnssDeviceController extends BasicController{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备现场安装
|
* 设备现场安装
|
||||||
*
|
*
|
||||||
|
|||||||
@ -6,6 +6,7 @@ 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.secapi.dto.RtkTransaction;
|
import com.imdroid.secapi.dto.RtkTransaction;
|
||||||
import com.imdroid.secapi.dto.RtkTransactionMapper;
|
import com.imdroid.secapi.dto.RtkTransactionMapper;
|
||||||
|
import com.imdroid.secapi.dto.GnssDevice;
|
||||||
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;
|
||||||
@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class RtkTransactionController extends BasicController {
|
public class RtkTransactionController extends BasicController {
|
||||||
@ -46,13 +48,25 @@ public class RtkTransactionController extends BasicController {
|
|||||||
|
|
||||||
@RequestMapping("/rtk/transaction/check")
|
@RequestMapping("/rtk/transaction/check")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String check(Integer id, Boolean apply){
|
public String check(HttpSession session, Integer id, Boolean apply){
|
||||||
RtkTransaction t = mapper.selectById(id);
|
RtkTransaction t = mapper.selectById(id);
|
||||||
if(t==null) return com.imdroid.beidou.common.HttpResult.failed();
|
if(t==null) return com.imdroid.beidou.common.HttpResult.failed();
|
||||||
t.setChecked((short)1);
|
t.setChecked((short)1);
|
||||||
mapper.updateById(t);
|
mapper.updateById(t);
|
||||||
if(Boolean.TRUE.equals(apply)){
|
if(Boolean.TRUE.equals(apply)){
|
||||||
try{ gnssDeviceMapper.updateEcefByDeviceId(t.getDevice_id(), t.getEcef_x(), t.getEcef_y(), t.getEcef_z()); }catch(Exception ignored){}
|
try{
|
||||||
|
GnssDevice exist = gnssDeviceMapper.queryByDeviceId(t.getDevice_id());
|
||||||
|
if(exist != null){
|
||||||
|
GnssDevice upd = new GnssDevice();
|
||||||
|
upd.setId(exist.getId());
|
||||||
|
upd.setEcefx(t.getEcef_x());
|
||||||
|
upd.setEcefy(t.getEcef_y());
|
||||||
|
upd.setEcefz(t.getEcef_z());
|
||||||
|
upd.setUpdatetime(LocalDateTime.now());
|
||||||
|
upd.setUpdateuser(getLoginUser(session));
|
||||||
|
gnssDeviceMapper.updateById(upd);
|
||||||
|
}
|
||||||
|
}catch(Exception ignored){}
|
||||||
}
|
}
|
||||||
return com.imdroid.beidou.common.HttpResult.ok();
|
return com.imdroid.beidou.common.HttpResult.ok();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,6 +37,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<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>
|
||||||
|
<style>
|
||||||
|
#tx-btn-bar .layui-btn{ margin-right:8px; }
|
||||||
|
#tx-btn-bar{ margin-bottom:8px; }
|
||||||
|
</style>
|
||||||
<script>
|
<script>
|
||||||
layui.use(['form','table'], function(){
|
layui.use(['form','table'], function(){
|
||||||
var $=layui.$, form=layui.form, table=layui.table;
|
var $=layui.$, form=layui.form, table=layui.table;
|
||||||
@ -51,6 +55,7 @@ layui.use(['form','table'], function(){
|
|||||||
cmdWs.onerror=function(){ if(onmsg) onmsg('通讯通道连接失败'); };
|
cmdWs.onerror=function(){ if(onmsg) onmsg('通讯通道连接失败'); };
|
||||||
}
|
}
|
||||||
function sendDebugCmd(dev, content, onres){ if(!dev){layer.msg('无设备号');return;} $.ajax({ type:'POST', url:'/gnss/config_cmd', data:{ tx_win: content, device_id: dev, cmd_type: 3, send_channel: 0 }, success:function(res){ if(onres) onres(res); }, error:function(){ layer.alert('请求失败'); } }); }
|
function sendDebugCmd(dev, content, onres){ if(!dev){layer.msg('无设备号');return;} $.ajax({ type:'POST', url:'/gnss/config_cmd', data:{ tx_win: content, device_id: dev, cmd_type: 3, send_channel: 0 }, success:function(res){ if(onres) onres(res); }, error:function(){ layer.alert('请求失败'); } }); }
|
||||||
|
function sendGnssHex(dev, hex, onres){ if(!dev){layer.msg('无设备号');return;} $.ajax({ type:'POST', url:'/gnss/config_cmd', data:{ tx_win: hex, device_id: dev, cmd_type: 0, send_channel: 0 }, success:function(res){ if(onres) onres(res); }, error:function(){ layer.alert('请求失败'); } }); }
|
||||||
function toHexSp(str){
|
function toHexSp(str){
|
||||||
var s=''; for(var i=0;i<str.length;i++){ var h=str.charCodeAt(i).toString(16).toUpperCase(); if(h.length<2) h='0'+h; s+=h+(i<str.length-1?' ':''); } return s;
|
var s=''; for(var i=0;i<str.length;i++){ var h=str.charCodeAt(i).toString(16).toUpperCase(); if(h.length<2) h='0'+h; s+=h+(i<str.length-1?' ':''); } return s;
|
||||||
}
|
}
|
||||||
@ -84,10 +89,11 @@ layui.use(['form','table'], function(){
|
|||||||
'<div class="layui-row">'+
|
'<div class="layui-row">'+
|
||||||
'<div class="layui-col-md12">'+
|
'<div class="layui-col-md12">'+
|
||||||
'<div class="layui-text">设备号:<b>'+ (d.device_id||'') +'</b></div><hr/>'+
|
'<div class="layui-text">设备号:<b>'+ (d.device_id||'') +'</b></div><hr/>'+
|
||||||
'<div class="layui-btn-group" style="margin-bottom:8px;">'+
|
'<div class="layui-form-item" id="tx-btn-bar">'+
|
||||||
'<button class="layui-btn layui-btn-primary" id="btn-tx-connect">连接通道</button>'+
|
'<button class="layui-btn layui-btn-warm" type="button" id="btn-tx-connect">连接设备通讯通道</button>'+
|
||||||
'<button class="layui-btn" id="btn-tx-0100">发送 0100</button>'+
|
'<button class="layui-btn" type="button" id="btn-tx-0102">发送 0102</button>'+
|
||||||
'<button class="layui-btn" id="btn-tx-0102">发送 0102</button>'+
|
'<button class="layui-btn layui-btn-normal" type="button" id="btn-tx-1005">配置1005</button>'+
|
||||||
|
'<button class="layui-btn" type="button" id="btn-tx-0100">发送 0100</button>'+
|
||||||
'</div>'+
|
'</div>'+
|
||||||
'<div class="layui-text">生效命令</div><pre class="layui-code">'+cmd.replace(/</g,'<')+'</pre>'+
|
'<div class="layui-text">生效命令</div><pre class="layui-code">'+cmd.replace(/</g,'<')+'</pre>'+
|
||||||
'<div class="layui-text">十六进制</div><pre class="layui-code">'+hex+'</pre>'+
|
'<div class="layui-text">十六进制</div><pre class="layui-code">'+hex+'</pre>'+
|
||||||
@ -95,21 +101,36 @@ layui.use(['form','table'], function(){
|
|||||||
'</div>'+
|
'</div>'+
|
||||||
'</div>'+
|
'</div>'+
|
||||||
'</div>';
|
'</div>';
|
||||||
var idx = layer.open({ title:'检查', type:1, area:['680px','560px'], content: html, btn:['生效','取消'],
|
var idx = layer.open({ title:'检查', type:1, area:['680px','560px'], content: html, btn:['写入ECEF坐标到数据库','检查','取消'],
|
||||||
success:function(){
|
success:function(){
|
||||||
var info = layui.$('#tx-cmd-info');
|
var info = layui.$('#tx-cmd-info');
|
||||||
var deviceId = d.device_id;
|
var deviceId = d.device_id;
|
||||||
layui.$('#btn-tx-connect').on('click', function(){ connectCmdWs(function(m){ info.text(info.text()+m+'\n'); var el=info.get(0); el.scrollTop=el.scrollHeight; }); });
|
|
||||||
layui.$('#btn-tx-0100').on('click', function(){ sendDebugCmd(deviceId,'0100', function(res){ var s=(res&&res.data)||''; info.text(info.text()+s+'\n'); var el=info.get(0); el.scrollTop=el.scrollHeight; }); });
|
function appendMsg(s){ info.text(info.text()+s+'\n'); var el=info.get(0); el.scrollTop=el.scrollHeight; }
|
||||||
layui.$('#btn-tx-0102').on('click', function(){ sendDebugCmd(deviceId,'0102', function(res){ var s=(res&&res.data)||''; info.text(info.text()+s+'\n'); var el=info.get(0); el.scrollTop=el.scrollHeight; }); });
|
function updateConnectBtn(){ var b=layui.$('#btn-tx-connect'); if(cmdConnected){ b.text('关闭设备通讯通道'); } else { b.text('连接设备通讯通道'); } }
|
||||||
|
layui.$('#btn-tx-connect').on('click', function(){
|
||||||
|
if(!cmdConnected){
|
||||||
|
connectCmdWs(function(m){ appendMsg(m); updateConnectBtn(); });
|
||||||
|
try{
|
||||||
|
if(cmdWs){ cmdWs.onmessage=function(e){ var msg=e.data||''; var parts=msg.trim().split(/\s+/); if(parts[0]==='RX' && parts.length>3){ if(deviceId && parts[3]!==deviceId) return; } appendMsg(msg); }; }
|
||||||
|
}catch(e){}
|
||||||
|
} else {
|
||||||
|
try{ if(cmdWs){ cmdWs.close(); cmdWs=null; } }catch(e){}
|
||||||
|
updateConnectBtn();
|
||||||
|
}
|
||||||
|
}); updateConnectBtn();
|
||||||
|
layui.$('#btn-tx-0100').on('click', function(){ sendDebugCmd(deviceId,'0100', function(res){ var s=(res&&res.data)||''; appendMsg(s); }); });
|
||||||
|
layui.$('#btn-tx-0102').on('click', function(){ sendDebugCmd(deviceId,'0102', function(res){ var s=(res&&res.data)||''; appendMsg(s); }); });
|
||||||
|
layui.$('#btn-tx-1005').on('click', function(){ sendGnssHex(deviceId, hex, function(res){ var s=(res&&res.data)||''; appendMsg(s); }); });
|
||||||
// 监听 WebSocket 输出
|
// 监听 WebSocket 输出
|
||||||
try{
|
try{
|
||||||
connectCmdWs(function(){});
|
connectCmdWs(function(){});
|
||||||
if(cmdWs){ cmdWs.onmessage=function(e){ var msg=e.data||''; var parts=msg.trim().split(/\s+/); if(parts[0]==='RX' && parts.length>3){ if(deviceId && parts[3]!==deviceId) return; } info.text(info.text()+msg+'\n'); var el=info.get(0); el.scrollTop=el.scrollHeight; }; }
|
if(cmdWs){ cmdWs.onmessage=function(e){ var msg=e.data||''; var parts=msg.trim().split(/\s+/); if(parts[0]==='RX' && parts.length>3){ if(deviceId && parts[3]!==deviceId) return; } appendMsg(msg); }; }
|
||||||
}catch(e){}
|
}catch(e){}
|
||||||
},
|
},
|
||||||
yes: function(index){ $.post('/rtk/transaction/check',{id:d.id, apply:true}, function(){ layer.close(index); table.reload('txTable'); }); },
|
yes: function(index){ $.post('/rtk/transaction/check',{id:d.id, apply:true}, function(){ layer.close(index); table.reload('txTable'); }); },
|
||||||
btn2: function(index){ $.post('/rtk/transaction/check',{id:d.id, apply:false}, function(){ layer.close(index); table.reload('txTable'); }); return false; },
|
btn2: function(index){ $.post('/rtk/transaction/check',{id:d.id, apply:false}, function(){ layer.close(index); table.reload('txTable'); }); return false; },
|
||||||
|
btn3: function(index){ layer.close(index); },
|
||||||
end:function(){ try{ if(cmdWs){ cmdWs.close(); cmdWs=null; } }catch(e){} }
|
end:function(){ try{ if(cmdWs){ cmdWs.close(); cmdWs=null; } }catch(e){} }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user