1、多条指令下发用定时器,保持1s间隔
This commit is contained in:
parent
bc1e20c287
commit
4942c23200
@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class APIController extends BasicController {
|
public class APIController extends BasicController {
|
||||||
@ -170,12 +172,21 @@ public class APIController extends BasicController {
|
|||||||
GnssDevice device = deviceMapper.queryByDeviceId(deviceId);
|
GnssDevice device = deviceMapper.queryByDeviceId(deviceId);
|
||||||
if (device == null) return null;
|
if (device == null) return null;
|
||||||
|
|
||||||
|
Timer timerSyn = new Timer();
|
||||||
|
int delay = 500;
|
||||||
|
|
||||||
if (!device.getSyn()) {
|
if (!device.getSyn()) {
|
||||||
GnssGroup gnssGroup = groupMapper.selectById(device.getGroup_id());
|
GnssGroup gnssGroup = groupMapper.selectById(device.getGroup_id());
|
||||||
if (gnssGroup != null) {
|
if (gnssGroup != null) {
|
||||||
String config = gnssGroup.getConfigCmd(device);
|
String config = gnssGroup.getConfigCmd(device);
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
rtcmClient.config(deviceId, config);
|
timerSyn.schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
rtcmClient.config(deviceId, config);
|
||||||
|
}
|
||||||
|
},delay);
|
||||||
|
delay += 1000;
|
||||||
// 保存
|
// 保存
|
||||||
saveMsg(deviceId, tenantId, 0xd311, config, true);
|
saveMsg(deviceId, tenantId, 0xd311, config, true);
|
||||||
}
|
}
|
||||||
@ -183,7 +194,13 @@ public class APIController extends BasicController {
|
|||||||
}
|
}
|
||||||
List<String> deviceCmds = device.getConfigCmd();
|
List<String> deviceCmds = device.getConfigCmd();
|
||||||
for(String deviceCmd:deviceCmds){
|
for(String deviceCmd:deviceCmds){
|
||||||
rtcmClient.config(deviceId, deviceCmd);
|
timerSyn.schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
rtcmClient.config(deviceId, deviceCmd);
|
||||||
|
}
|
||||||
|
},delay);
|
||||||
|
delay += 1000;
|
||||||
// 保存
|
// 保存
|
||||||
saveMsg(deviceId, tenantId, 0xd312, deviceCmd, true);
|
saveMsg(deviceId, tenantId, 0xd312, deviceCmd, true);
|
||||||
|
|
||||||
@ -196,7 +213,13 @@ public class APIController extends BasicController {
|
|||||||
queryWrapper.last("limit 1");
|
queryWrapper.last("limit 1");
|
||||||
DeviceCacheCmd cacheCmd = cacheCmdMapper.selectOne(queryWrapper);
|
DeviceCacheCmd cacheCmd = cacheCmdMapper.selectOne(queryWrapper);
|
||||||
if (cacheCmd != null) {
|
if (cacheCmd != null) {
|
||||||
rtcmClient.config(deviceId, cacheCmd.getCmd());
|
timerSyn.schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
rtcmClient.config(deviceId, cacheCmd.getCmd());
|
||||||
|
}
|
||||||
|
},delay);
|
||||||
|
delay += 1000;
|
||||||
cacheCmd.setSyn(true);
|
cacheCmd.setSyn(true);
|
||||||
cacheCmd.setUpdatetime(LocalDateTime.now());
|
cacheCmd.setUpdatetime(LocalDateTime.now());
|
||||||
cacheCmdMapper.updateById(cacheCmd);
|
cacheCmdMapper.updateById(cacheCmd);
|
||||||
@ -205,7 +228,12 @@ public class APIController extends BasicController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 检查iccid
|
// 检查iccid
|
||||||
checkAndAskICCID(device);
|
timerSyn.schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
checkAndAskICCID(device);
|
||||||
|
}
|
||||||
|
},delay);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -253,6 +253,7 @@ public class GnssDeviceController extends BasicController{
|
|||||||
device.setUpdateuser(getLoginUser(session));
|
device.setUpdateuser(getLoginUser(session));
|
||||||
device.setUpdatetime(old_device.getUpdatetime());
|
device.setUpdatetime(old_device.getUpdatetime());
|
||||||
device.setSyn(old_device.getSyn());
|
device.setSyn(old_device.getSyn());
|
||||||
|
device.setChange_flag(old_device.getChange_flag());
|
||||||
String diff=ObjUtil.compare(old_device,device);
|
String diff=ObjUtil.compare(old_device,device);
|
||||||
if(!diff.isEmpty()) {
|
if(!diff.isEmpty()) {
|
||||||
opLogManager.addLog(getLoginUser(session), getTenantId(session),
|
opLogManager.addLog(getLoginUser(session), getTenantId(session),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user