Merge branch 'master' of https://git.njzscloud.com/lzq/njzscloud
commit
0fce5abc9f
|
|
@ -38,6 +38,18 @@ public class MqttMsgHandlers {
|
||||||
Tuqiang.enableWarn(terminalId, enable);
|
Tuqiang.enableWarn(terminalId, enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启用报警
|
||||||
|
*/
|
||||||
|
@MqttListener(topic = "location/config_ip_port")
|
||||||
|
public void configIpPort(MqttMsg msg) {
|
||||||
|
ConfigIpPortParam configIpPortParam = msg.getMsg(ConfigIpPortParam.class);
|
||||||
|
String terminalId = configIpPortParam.getTerminalId();
|
||||||
|
String ip = configIpPortParam.getIp();
|
||||||
|
int port = configIpPortParam.getPort();
|
||||||
|
Tuqiang.configIpPort(terminalId, ip, port);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置速度阈值
|
* 设置速度阈值
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.njzscloud.common.localizer.mqtt.param;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class ConfigIpPortParam {
|
||||||
|
private String terminalId;
|
||||||
|
private String ip;
|
||||||
|
private int port;
|
||||||
|
}
|
||||||
|
|
@ -80,6 +80,21 @@ public final class Tuqiang {
|
||||||
JT808.sendTxtMessage(terminalId, StrUtil.format("<SPBSJ*P:BSJGPS*CS:{}*H:300>", speed));
|
JT808.sendTxtMessage(terminalId, StrUtil.format("<SPBSJ*P:BSJGPS*CS:{}*H:300>", speed));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改设备的连接地址
|
||||||
|
*
|
||||||
|
* @param terminalId 终端 Id
|
||||||
|
* @param ip 服务器 IP
|
||||||
|
* @param port 服务器端口
|
||||||
|
*/
|
||||||
|
public static void configIpPort(String terminalId, String ip, int port) {
|
||||||
|
Assert.notEmpty(terminalId);
|
||||||
|
Assert.notEmpty(ip);
|
||||||
|
Assert.isTrue(port > 0);
|
||||||
|
JT808.sendTxtMessage(terminalId, StrUtil.format("<SPBSJ*P:BSJGPS*T:{},{}*N:{}>", ip, port, terminalId));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前位置
|
* 获取当前位置
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.njzscloud.common.sichen.support;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.njzscloud.common.core.tuple.Tuple2;
|
import com.njzscloud.common.core.tuple.Tuple2;
|
||||||
import com.njzscloud.common.core.utils.GroupUtil;
|
import com.njzscloud.common.core.utils.GroupUtil;
|
||||||
|
|
@ -12,7 +13,9 @@ import com.njzscloud.common.sichen.contant.ScheduleType;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.event.EventListener;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
@ -20,7 +23,7 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class TaskStore implements BeanPostProcessor {
|
public class TaskStore {
|
||||||
private final Map<String, Tuple2<Object, Method>> fn = new HashMap<>();
|
private final Map<String, Tuple2<Object, Method>> fn = new HashMap<>();
|
||||||
private final List<TaskInfo> tasks = new LinkedList<>();
|
private final List<TaskInfo> tasks = new LinkedList<>();
|
||||||
private final TaskService taskService;
|
private final TaskService taskService;
|
||||||
|
|
@ -67,10 +70,19 @@ public class TaskStore implements BeanPostProcessor {
|
||||||
taskService.updateBatchById(list);
|
taskService.updateBatchById(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventListener(ApplicationReadyEvent.class)
|
||||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
public void onApplicationReadyEvent() {
|
||||||
|
ApplicationContext applicationContext = SpringUtil.getApplicationContext();
|
||||||
|
String[] beanNames = applicationContext.getBeanDefinitionNames();
|
||||||
|
for (String beanName : beanNames) {
|
||||||
|
Object bean = applicationContext.getBean(beanName);
|
||||||
|
process(bean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void process(Object bean) throws BeansException {
|
||||||
Class<?> clazz = bean.getClass();
|
Class<?> clazz = bean.getClass();
|
||||||
for (Method method : clazz.getDeclaredMethods()) {
|
for (Method method : clazz.getMethods()) {
|
||||||
Task task = method.getAnnotation(Task.class);
|
Task task = method.getAnnotation(Task.class);
|
||||||
if (task != null) {
|
if (task != null) {
|
||||||
String value = task.value();
|
String value = task.value();
|
||||||
|
|
@ -102,6 +114,5 @@ public class TaskStore implements BeanPostProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bean;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.njzscloud.common.core.utils.R;
|
||||||
import com.njzscloud.common.mp.support.PageParam;
|
import com.njzscloud.common.mp.support.PageParam;
|
||||||
import com.njzscloud.common.mp.support.PageResult;
|
import com.njzscloud.common.mp.support.PageResult;
|
||||||
import com.njzscloud.supervisory.device.pojo.entity.DeviceLocalizerEntity;
|
import com.njzscloud.supervisory.device.pojo.entity.DeviceLocalizerEntity;
|
||||||
|
import com.njzscloud.supervisory.device.pojo.entity.LocalizerConfig;
|
||||||
import com.njzscloud.supervisory.device.service.DeviceLocalizerService;
|
import com.njzscloud.supervisory.device.service.DeviceLocalizerService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
@ -65,4 +66,14 @@ public class DeviceLocalizerController {
|
||||||
return R.success(deviceLocalizerService.paging(pageParam, deviceLocalizerEntity));
|
return R.success(deviceLocalizerService.paging(pageParam, deviceLocalizerEntity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改设备配置
|
||||||
|
*/
|
||||||
|
@PostMapping("/modify_config")
|
||||||
|
public R<?> modifyConfig(@RequestBody LocalizerConfig config,
|
||||||
|
@RequestParam Long id
|
||||||
|
) {
|
||||||
|
deviceLocalizerService.modifyConfig(id, config);
|
||||||
|
return R.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.njzscloud.supervisory.device.pojo.entity;
|
package com.njzscloud.supervisory.device.pojo.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import com.njzscloud.common.mp.support.handler.j.JsonTypeHandler;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
@ -39,6 +40,9 @@ public class DeviceLocalizerEntity {
|
||||||
*/
|
*/
|
||||||
private LocalDateTime lastTime;
|
private LocalDateTime lastTime;
|
||||||
|
|
||||||
|
@TableField(typeHandler = JsonTypeHandler.class)
|
||||||
|
private LocalizerConfig config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建人 Id; sys_user.id
|
* 创建人 Id; sys_user.id
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.njzscloud.supervisory.device.pojo.entity;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class LocalizerConfig {
|
||||||
|
private String ip;
|
||||||
|
private Integer port;
|
||||||
|
private Integer speedThreshold;
|
||||||
|
private Boolean enableWarn;
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,14 @@
|
||||||
package com.njzscloud.supervisory.device.service;
|
package com.njzscloud.supervisory.device.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njzscloud.common.core.ex.Exceptions;
|
||||||
|
import com.njzscloud.common.localizer.mqtt.param.ConfigIpPortParam;
|
||||||
|
import com.njzscloud.common.localizer.mqtt.param.EnableWarnParam;
|
||||||
|
import com.njzscloud.common.localizer.mqtt.param.SpeedThresholdParam;
|
||||||
import com.njzscloud.common.mp.support.PageParam;
|
import com.njzscloud.common.mp.support.PageParam;
|
||||||
import com.njzscloud.common.mp.support.PageResult;
|
import com.njzscloud.common.mp.support.PageResult;
|
||||||
import com.njzscloud.common.mqtt.support.MqttMsg;
|
import com.njzscloud.common.mqtt.support.MqttMsg;
|
||||||
|
|
@ -10,6 +16,7 @@ import com.njzscloud.common.mqtt.util.Mqtt;
|
||||||
import com.njzscloud.supervisory.biz.service.TruckLocationTrackService;
|
import com.njzscloud.supervisory.biz.service.TruckLocationTrackService;
|
||||||
import com.njzscloud.supervisory.device.mapper.DeviceLocalizerMapper;
|
import com.njzscloud.supervisory.device.mapper.DeviceLocalizerMapper;
|
||||||
import com.njzscloud.supervisory.device.pojo.entity.DeviceLocalizerEntity;
|
import com.njzscloud.supervisory.device.pojo.entity.DeviceLocalizerEntity;
|
||||||
|
import com.njzscloud.supervisory.device.pojo.entity.LocalizerConfig;
|
||||||
import com.njzscloud.supervisory.device.pojo.result.DeviceInfoResult;
|
import com.njzscloud.supervisory.device.pojo.result.DeviceInfoResult;
|
||||||
import com.njzscloud.supervisory.device.pojo.result.HeartbeatResult;
|
import com.njzscloud.supervisory.device.pojo.result.HeartbeatResult;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
@ -95,4 +102,74 @@ public class DeviceLocalizerService extends ServiceImpl<DeviceLocalizerMapper, D
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void modifyConfig(Long id, LocalizerConfig config) {
|
||||||
|
DeviceLocalizerEntity localizerEntity = this.getById(id);
|
||||||
|
Assert.notNull(localizerEntity, () -> Exceptions.exception("定位器不存在"));
|
||||||
|
|
||||||
|
String terminalId = localizerEntity.getTerminalId();
|
||||||
|
LocalizerConfig oldConfig = localizerEntity.getConfig();
|
||||||
|
if (oldConfig == null) oldConfig = new LocalizerConfig();
|
||||||
|
String ip = config.getIp();
|
||||||
|
Integer port = config.getPort();
|
||||||
|
Integer speedThreshold = config.getSpeedThreshold();
|
||||||
|
Boolean enableWarn = config.getEnableWarn();
|
||||||
|
|
||||||
|
if (StrUtil.isEmpty(ip) && port != null && port > 0) {
|
||||||
|
oldConfig.setIp(ip).setPort(port);
|
||||||
|
}
|
||||||
|
if (speedThreshold != null && speedThreshold > 0) {
|
||||||
|
oldConfig.setSpeedThreshold(speedThreshold);
|
||||||
|
}
|
||||||
|
if (enableWarn != null) {
|
||||||
|
oldConfig.setEnableWarn(enableWarn);
|
||||||
|
}
|
||||||
|
this.configDevice(terminalId, config);
|
||||||
|
|
||||||
|
this.updateById(new DeviceLocalizerEntity().setId(id).setConfig(oldConfig));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void configDevice(String terminalId, LocalizerConfig config) {
|
||||||
|
String ip = config.getIp();
|
||||||
|
Integer port = config.getPort();
|
||||||
|
Integer speedThreshold = config.getSpeedThreshold();
|
||||||
|
Boolean enableWarn = config.getEnableWarn();
|
||||||
|
|
||||||
|
if (StrUtil.isEmpty(ip) && port != null && port > 0) {
|
||||||
|
modifyIpPort(terminalId, ip, port);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (speedThreshold != null && speedThreshold > 0) {
|
||||||
|
modifySpeedThreshold(terminalId, speedThreshold);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enableWarn != null) {
|
||||||
|
enableWarn(terminalId, enableWarn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void modifyIpPort(String terminalId, String ip, int port) {
|
||||||
|
if (StrUtil.isEmpty(ip) || port <= 0) return;
|
||||||
|
Mqtt.publish("location/config_ip_port", new ConfigIpPortParam()
|
||||||
|
.setTerminalId(terminalId)
|
||||||
|
.setIp(ip)
|
||||||
|
.setPort(port)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void modifySpeedThreshold(String terminalId, int modifySpeedThreshold) {
|
||||||
|
if (modifySpeedThreshold <= 0) return;
|
||||||
|
Mqtt.publish("location/speed_threshold", new SpeedThresholdParam()
|
||||||
|
.setTerminalId(terminalId)
|
||||||
|
.setSpeed(modifySpeedThreshold)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void enableWarn(String terminalId, boolean enableWarn) {
|
||||||
|
Mqtt.publish("location/speed_threshold", new EnableWarnParam()
|
||||||
|
.setTerminalId(terminalId)
|
||||||
|
.setEnable(enableWarn)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.njzscloud.supervisory.biz.pojo.entity.BizCompanyEntity;
|
import com.njzscloud.supervisory.biz.pojo.entity.BizCompanyEntity;
|
||||||
import com.njzscloud.supervisory.biz.pojo.entity.BizTruckEntity;
|
import com.njzscloud.supervisory.biz.pojo.entity.BizTruckEntity;
|
||||||
|
import com.njzscloud.supervisory.device.pojo.entity.DeviceLocalizerEntity;
|
||||||
import com.njzscloud.supervisory.order.pojo.entity.OrderInfoEntity;
|
import com.njzscloud.supervisory.order.pojo.entity.OrderInfoEntity;
|
||||||
import com.njzscloud.supervisory.order.pojo.result.OrderExportResult;
|
import com.njzscloud.supervisory.order.pojo.result.OrderExportResult;
|
||||||
import com.njzscloud.supervisory.order.pojo.result.OrderPagingResult;
|
import com.njzscloud.supervisory.order.pojo.result.OrderPagingResult;
|
||||||
|
|
@ -41,4 +42,6 @@ public interface OrderInfoMapper extends BaseMapper<OrderInfoEntity> {
|
||||||
BizTruckEntity getTruckInfo(@Param("truckId") Long truckId);
|
BizTruckEntity getTruckInfo(@Param("truckId") Long truckId);
|
||||||
|
|
||||||
BizCompanyEntity getTransInfo(@Param("transCompanyId") Long transCompanyId);
|
BizCompanyEntity getTransInfo(@Param("transCompanyId") Long transCompanyId);
|
||||||
|
|
||||||
|
DeviceLocalizerEntity gpsLastOnlineTime(@Param("gpsId") String gpsId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import com.njzscloud.supervisory.biz.service.BizWarnService;
|
||||||
import com.njzscloud.supervisory.biz.service.TruckLocationTrackService;
|
import com.njzscloud.supervisory.biz.service.TruckLocationTrackService;
|
||||||
import com.njzscloud.supervisory.config.AppProperties;
|
import com.njzscloud.supervisory.config.AppProperties;
|
||||||
import com.njzscloud.supervisory.constant.Constant;
|
import com.njzscloud.supervisory.constant.Constant;
|
||||||
|
import com.njzscloud.supervisory.device.pojo.entity.DeviceLocalizerEntity;
|
||||||
import com.njzscloud.supervisory.expense.contant.ExpenseItemCategory;
|
import com.njzscloud.supervisory.expense.contant.ExpenseItemCategory;
|
||||||
import com.njzscloud.supervisory.expense.contant.Scope;
|
import com.njzscloud.supervisory.expense.contant.Scope;
|
||||||
import com.njzscloud.supervisory.expense.pojo.entity.ExpenseItemsConfigEntity;
|
import com.njzscloud.supervisory.expense.pojo.entity.ExpenseItemsConfigEntity;
|
||||||
|
|
@ -711,7 +712,6 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
||||||
.setOrderStatus(OrderStatus.QingYunZhong)
|
.setOrderStatus(OrderStatus.QingYunZhong)
|
||||||
.setTransTime(LocalDateTime.now())
|
.setTransTime(LocalDateTime.now())
|
||||||
);
|
);
|
||||||
// TODO 获取 GPS
|
|
||||||
Long truckId = orderInfo.getTruckId();
|
Long truckId = orderInfo.getTruckId();
|
||||||
Assert.notNull(truckId, () -> Exceptions.clierr("订单未分配车辆"));
|
Assert.notNull(truckId, () -> Exceptions.clierr("订单未分配车辆"));
|
||||||
BizTruckEntity truckInfo = baseMapper.getTruckInfo(truckId);
|
BizTruckEntity truckInfo = baseMapper.getTruckInfo(truckId);
|
||||||
|
|
@ -732,9 +732,44 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void orderTimeOut() {
|
||||||
|
log.info("检查超时订单");
|
||||||
|
List<OrderInfoEntity> timeOutOrderList = this.list(Wrappers.<OrderInfoEntity>lambdaQuery()
|
||||||
|
.isNotNull(OrderInfoEntity::getAuditTime)
|
||||||
|
.le(OrderInfoEntity::getAuditTime, LocalDateTime.now().minusHours(12))
|
||||||
|
.notIn(OrderInfoEntity::getOrderStatus, OrderStatus.YiJinChang, OrderStatus.YiChuChang, OrderStatus.YiWanCheng)
|
||||||
|
);
|
||||||
|
if (CollUtil.isEmpty(timeOutOrderList)) return;
|
||||||
|
log.info("有超时订单:{} 个", timeOutOrderList.size());
|
||||||
|
for (OrderInfoEntity orderInfoEntity : timeOutOrderList) {
|
||||||
|
Long id = orderInfoEntity.getId();
|
||||||
|
String sn = orderInfoEntity.getSn();
|
||||||
|
boolean exists = bizWarnService.exists(Wrappers.<BizWarnEntity>lambdaQuery().eq(BizWarnEntity::getOrderId, id).eq(BizWarnEntity::getWarnCategory, WarnCategory.SAFETY.getVal()));
|
||||||
|
if (exists) continue;
|
||||||
|
bizWarnService.save(new BizWarnEntity()
|
||||||
|
.setWarnCategory(WarnCategory.SAFETY.getVal())
|
||||||
|
.setWarnContent(StrUtil.format("订单:{},已超时", sn))
|
||||||
|
.setOrderId(id)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void startTuqiangTrack(String gpsId, String licensePlate, Long orderInfoId, Long truckId) {
|
private void startTuqiangTrack(String gpsId, String licensePlate, Long orderInfoId, Long truckId) {
|
||||||
CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
Assert.notEmpty(gpsId, () -> Exceptions.clierr("车辆未绑定GPS"));
|
Assert.notEmpty(gpsId, () -> Exceptions.clierr("车辆未绑定GPS"));
|
||||||
|
DeviceLocalizerEntity deviceLocalizerEntity = baseMapper.gpsLastOnlineTime(gpsId);
|
||||||
|
LocalDateTime lastTime = deviceLocalizerEntity.getLastTime();
|
||||||
|
boolean after = lastTime.isBefore(LocalDateTime.now().minusMinutes(5));
|
||||||
|
if (after) {
|
||||||
|
bizWarnService.save(new BizWarnEntity()
|
||||||
|
.setWarnCategory(WarnCategory.EQUIPMENT.getVal())
|
||||||
|
.setWarnContent(StrUtil.format("{} 绑定的 GPS 设备已离线,设备号:{}", licensePlate, gpsId))
|
||||||
|
.setOrderId(orderInfoId)
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Mqtt.subscribe(gpsId + "/track_location", (msg) -> {
|
Mqtt.subscribe(gpsId + "/track_location", (msg) -> {
|
||||||
RealtimeLocationResult realtimeLocationResult = msg.getMsg(RealtimeLocationResult.class);
|
RealtimeLocationResult realtimeLocationResult = msg.getMsg(RealtimeLocationResult.class);
|
||||||
if (realtimeLocationResult == null) {
|
if (realtimeLocationResult == null) {
|
||||||
|
|
@ -769,7 +804,6 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
||||||
.setOverspeed(realtimeLocationResult.isOverspeed())
|
.setOverspeed(realtimeLocationResult.isOverspeed())
|
||||||
.setCompensate(realtimeLocationResult.getType() == 1);
|
.setCompensate(realtimeLocationResult.getType() == 1);
|
||||||
truckLocationTrackService.save(entity);
|
truckLocationTrackService.save(entity);
|
||||||
// truckLocationTrackService.cache(entity);
|
|
||||||
});
|
});
|
||||||
Mqtt.publish("location/track", MapUtil.builder()
|
Mqtt.publish("location/track", MapUtil.builder()
|
||||||
.put("terminalId", gpsId)
|
.put("terminalId", gpsId)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.njzscloud.supervisory.order.service;
|
||||||
|
|
||||||
|
import com.njzscloud.common.sichen.support.Task;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class OrderInfoServiceTask {
|
||||||
|
private final OrderInfoService orderInfoService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每 30 分钟检查一次
|
||||||
|
*/
|
||||||
|
@Task(cron = "0 0/30 * * * ?")
|
||||||
|
public void orderTimeOut() {
|
||||||
|
orderInfoService.orderTimeOut();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -295,4 +295,11 @@
|
||||||
FROM biz_company
|
FROM biz_company
|
||||||
WHERE id = #{transCompanyId}
|
WHERE id = #{transCompanyId}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="gpsLastOnlineTime"
|
||||||
|
resultType="com.njzscloud.supervisory.device.pojo.entity.DeviceLocalizerEntity">
|
||||||
|
select *
|
||||||
|
from device_localizer
|
||||||
|
where terminal_id = #{gpsId}
|
||||||
|
and deleted = 0
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue