#update
This commit is contained in:
@@ -15,16 +15,20 @@ import com.maibu.mapper.WorkRecordMapper;
|
|||||||
import com.maibu.memory.GlobalMemory;
|
import com.maibu.memory.GlobalMemory;
|
||||||
import com.maibu.memory.SiteMemory;
|
import com.maibu.memory.SiteMemory;
|
||||||
import com.maibu.utils.spring.SpringUtils;
|
import com.maibu.utils.spring.SpringUtils;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
|
import io.netty.util.CharsetUtil;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import com.maibu.core.business.path.LatAndLngEntity;
|
import com.maibu.core.business.path.LatAndLngEntity;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
public class NettyDevice extends Connector {
|
public class NettyDevice extends Connector {
|
||||||
@@ -65,6 +69,24 @@ public class NettyDevice extends Connector {
|
|||||||
this.deviceType = deviceType;
|
this.deviceType = deviceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// abaa 00 18 06 18 06 00 00 00 00 00 00 aaab
|
||||||
|
//
|
||||||
|
// ab aa 01 01 00 3c 88
|
||||||
|
// 2d e0 48 05 40 40
|
||||||
|
// 22 07 d0 42 c6 33
|
||||||
|
// 5e 40 e8 03 00 00 aa ab
|
||||||
|
private static final byte[] PACKET = {(byte) 0xAB, (byte) 0xAA,
|
||||||
|
(byte) 0x00, (byte) 0x18,(byte) 0x06,(byte) 0x18,(byte) 0x06,
|
||||||
|
(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x00,(byte) 0x00,
|
||||||
|
(byte) 0xAA, (byte) 0xAB};
|
||||||
|
|
||||||
|
private static final byte[] route = {(byte) 0xab, (byte) 0xaa,
|
||||||
|
(byte) 0x01, (byte) 0x01,(byte) 0x00,(byte) 0x3c,(byte) 0x88,
|
||||||
|
(byte) 0x2d, (byte) 0xe0,(byte) 0x48,(byte) 0x05,(byte) 0x40,(byte) 0x40,
|
||||||
|
(byte) 0x22, (byte) 0x07,(byte) 0xd0,(byte) 0x42,(byte) 0xc6,(byte) 0x33,
|
||||||
|
(byte) 0x5e,(byte) 0x40,(byte) 0xe8,(byte) 0x03,(byte) 0x00,(byte) 0x00,
|
||||||
|
(byte) 0xaa, (byte) 0xab};
|
||||||
|
//todo 重发
|
||||||
public void sendNextPoint() {
|
public void sendNextPoint() {
|
||||||
if (task.getTaskStaus().equals(DeviceTaskStaus.PAUSE)) return;
|
if (task.getTaskStaus().equals(DeviceTaskStaus.PAUSE)) return;
|
||||||
if (!locationQueue.isEmpty()) {
|
if (!locationQueue.isEmpty()) {
|
||||||
@@ -77,8 +99,7 @@ public class NettyDevice extends Connector {
|
|||||||
routePlanSendEntity.setTargetLongitude(entity.getLng());
|
routePlanSendEntity.setTargetLongitude(entity.getLng());
|
||||||
routePlanSendEntity.setSpeed((short) 1000);
|
routePlanSendEntity.setSpeed((short) 1000);
|
||||||
byte[] bytes = routePlanSendEntity.toBytes();
|
byte[] bytes = routePlanSendEntity.toBytes();
|
||||||
System.out.println("====Lat:" + entity.getLat() + " ====Lng:" + entity.getLng());
|
log.debug("下发路径的报文:{}", toHexString(bytes));
|
||||||
|
|
||||||
currentPoint = entity;
|
currentPoint = entity;
|
||||||
if (this.getChannel() != null && this.getChannel().isActive()) {
|
if (this.getChannel() != null && this.getChannel().isActive()) {
|
||||||
this.getChannel().writeAndFlush(Unpooled.wrappedBuffer(bytes));
|
this.getChannel().writeAndFlush(Unpooled.wrappedBuffer(bytes));
|
||||||
@@ -87,6 +108,14 @@ public class NettyDevice extends Connector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String toHexString(byte[] bytes) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (byte b : bytes) {
|
||||||
|
sb.append(String.format("%02X ", b));
|
||||||
|
}
|
||||||
|
return sb.toString().trim();
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void finishTask() {
|
public synchronized void finishTask() {
|
||||||
if (executingTask) {
|
if (executingTask) {
|
||||||
task.setTaskStaus(DeviceTaskStaus.FINISH);
|
task.setTaskStaus(DeviceTaskStaus.FINISH);
|
||||||
@@ -106,6 +135,7 @@ public class NettyDevice extends Connector {
|
|||||||
task.setUpdateTime(LocalDateTime.now());
|
task.setUpdateTime(LocalDateTime.now());
|
||||||
devicePlanTaskMapper.saveOrUpdate(task);
|
devicePlanTaskMapper.saveOrUpdate(task);
|
||||||
SiteMemory siteMemory = GlobalMemory.getSiteMemory(task.getOrgId(), task.getSiteId());
|
SiteMemory siteMemory = GlobalMemory.getSiteMemory(task.getOrgId(), task.getSiteId());
|
||||||
|
siteMemory.removeDevicePlanPrepare(task);
|
||||||
siteMemory.removeDevicePlanExecute(task.getDeviceId());
|
siteMemory.removeDevicePlanExecute(task.getDeviceId());
|
||||||
task = null;
|
task = null;
|
||||||
currentTaskId = null;
|
currentTaskId = null;
|
||||||
@@ -136,7 +166,7 @@ public class NettyDevice extends Connector {
|
|||||||
executingTask = true;
|
executingTask = true;
|
||||||
sendNextPoint();
|
sendNextPoint();
|
||||||
return true;
|
return true;
|
||||||
}else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -443,17 +443,14 @@ public class DeviceTaskService {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Long taskId = dto.getTaskId();
|
Long taskId = dto.getTaskId();
|
||||||
Long siteId = dto.getSiteId();
|
// Long siteId = dto.getSiteId();
|
||||||
Long orgId = dto.getOrgId();
|
// Long orgId = dto.getOrgId();
|
||||||
DevicePlanTask devicePlanTask = devicePlanTaskMapper.selectById(taskId);
|
DevicePlanTask devicePlanTask = devicePlanTaskMapper.selectById(taskId);
|
||||||
if (devicePlanTask != null) {
|
if (devicePlanTask != null) {
|
||||||
devicePlanTask.setUpdateTime(LocalDateTime.now());
|
NettyDevice device = deviceSessionManager.getDevice(devicePlanTask.getDeviceId());
|
||||||
devicePlanTask.setTaskStaus(DeviceTaskStaus.CANCELED);
|
if (device != null) {
|
||||||
devicePlanTask.setUpdateBy(username);
|
return device.cancelTask();
|
||||||
devicePlanTaskMapper.saveOrUpdate(devicePlanTask);
|
}
|
||||||
SiteMemory siteMemory = GlobalMemory.getSiteMemory(orgId, siteId);
|
|
||||||
siteMemory.removeDevicePlanPrepare(devicePlanTask);
|
|
||||||
siteMemory.removeDevicePlanExecute(devicePlanTask.getDeviceId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -23,4 +23,5 @@ public class CommandUtils {
|
|||||||
buf.writeByte(0x00);
|
buf.writeByte(0x00);
|
||||||
buf.writeShort(0xAAAB);
|
buf.writeShort(0xAAAB);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -266,7 +266,7 @@ public class ClientHandler extends ChannelInboundHandlerAdapter {
|
|||||||
transferData.add(detail13);
|
transferData.add(detail13);
|
||||||
|
|
||||||
DeviceStatusDetail detail14 = new DeviceStatusDetail();
|
DeviceStatusDetail detail14 = new DeviceStatusDetail();
|
||||||
detail14.setName("headingStatus");
|
detail14.setName("qual");
|
||||||
detail14.setValue(split[14]);
|
detail14.setValue(split[14]);
|
||||||
detail14.setUnit("");
|
detail14.setUnit("");
|
||||||
transferData.add(detail14);
|
transferData.add(detail14);
|
||||||
|
|||||||
Reference in New Issue
Block a user