1. 异步更新在线状态

This commit is contained in:
邱贞招 2024-06-18 17:11:55 +08:00
parent 8fe5ebda0a
commit 36dabe0e30
2 changed files with 20 additions and 0 deletions

View File

@ -129,6 +129,9 @@ public class ReceiveController {
String msg = (String) obj.getMsg();
log.info("receive方法-获取到消息体: msg---" +msg);
JSONObject jsonObject = JSONObject.parseObject(msg, JSONObject.class);
String devName = (String)jsonObject.get("dev_name");
/*异步更新在线状态*/
asynchronousUpdateOnlineStatus(devName);
if(IotConstants.ONENET_LOCATION.equals(jsonObject.get("ds_id")) && ObjectUtil.isNotNull(jsonObject.get("value"))){
LogEntry logEntry = JSONObject.parseObject(msg, LogEntry.class);
log.info("logEntry转换后的对象: logEntry---【{}】" , JSON.toJSONString(logEntry));
@ -314,6 +317,22 @@ public class ReceiveController {
}
}
/**
* 异步更新在线状态
*/
private void asynchronousUpdateOnlineStatus(String mac) {
AsDevice device = asDeviceService.selectAsDeviceByMac(mac);
//开异步线程保存回调参数
scheduledExecutorService.schedule(() -> {
log.info("【接收onenet推送】异步更新在线状态"+JSON.toJSONString(device));
device.setOnlineStatus(ServiceConstants.VEHICLE_STATUS_ONLINE);
int i = asDeviceService.updateAsDevice(device);
if(i>0){
log.info("【接收onenet推送】异步保存在线状态成功");
}
}, 0, TimeUnit.SECONDS);
}
private boolean isLastPointSame(JSONArray jsonArray, BigDecimal lon, BigDecimal lat) {
if (jsonArray.size() > 0) {
JSONArray lastPoint = (JSONArray) jsonArray.get(jsonArray.size() - 1);

View File

@ -102,6 +102,7 @@ public class EtTask {
* 根据用户查询最后一次押金充值记录
*/
List<EtOrder> orders = etOrderMapper.selectUserListFinishOrder();
log.info("已完成的订单未退还押金的的订单 = " + JSON.toJSONString(orders));
for(EtOrder order:orders){
EtFeeRule rule = etFeeRuleService.selectEtFeeRuleByRuleId(order.getRuleId());
if(ObjectUtil.isNull(rule)){