|
|
|
|
@@ -288,7 +288,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
|
|
|
|
applyIn(StorageTypeEnum.BOX_IN.getType());
|
|
|
|
|
List list1 = new ArrayList();
|
|
|
|
|
Map map = new HashMap();
|
|
|
|
|
map.put("code", "mode");
|
|
|
|
|
map.put("code", "to_command");
|
|
|
|
|
map.put("value", 6);
|
|
|
|
|
list1.add(map);
|
|
|
|
|
this.writing(list1);
|
|
|
|
|
@@ -299,7 +299,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
|
|
|
|
applyIn(StorageTypeEnum.STORAGE.getType());
|
|
|
|
|
List list1 = new ArrayList();
|
|
|
|
|
Map map = new HashMap();
|
|
|
|
|
map.put("code", "mode");
|
|
|
|
|
map.put("code", "to_command");
|
|
|
|
|
map.put("value", 7);
|
|
|
|
|
list1.add(map);
|
|
|
|
|
this.writing(list1);
|
|
|
|
|
@@ -476,115 +476,18 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
this.instruction_require_time = date;
|
|
|
|
|
//判断是否存在起点相同 任务状态就绪的任务
|
|
|
|
|
TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code);
|
|
|
|
|
if (!ObjectUtil.isEmpty(taskdto)) {
|
|
|
|
|
|
|
|
|
|
String taskid = taskdto.getTask_id();
|
|
|
|
|
String taskcode = taskdto.getTask_code();
|
|
|
|
|
String vehiclecode = taskdto.getVehicle_code();
|
|
|
|
|
String priority = taskdto.getPriority();
|
|
|
|
|
Instruction instdto = new Instruction();
|
|
|
|
|
String interactionJson = taskdto.getInteraction_json();
|
|
|
|
|
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
|
|
|
|
String containerType = "";
|
|
|
|
|
if (ObjectUtil.isNotEmpty(interactionJsonDTO)) {
|
|
|
|
|
containerType = interactionJsonDTO.getContainerType();
|
|
|
|
|
//根据补码查找任务
|
|
|
|
|
if (StrUtil.isNotBlank(hand_barcode)) {
|
|
|
|
|
TaskDto taskdto = taskserver.findByVehicleCodeCodeAndReady(hand_barcode);
|
|
|
|
|
if (!ObjectUtil.isEmpty(taskdto)) {
|
|
|
|
|
if (creatInstruction(taskdto)) return false;
|
|
|
|
|
}
|
|
|
|
|
if (TaskTypeEnum.AGV_Task.getIndex().equals(taskdto.getTask_type())){
|
|
|
|
|
String route_plan_code = taskdto.getRoute_plan_code();
|
|
|
|
|
|
|
|
|
|
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(taskdto.getStart_device_code(), taskdto.getNext_device_code(), route_plan_code);
|
|
|
|
|
if (CollectionUtil.isEmpty(shortPathsList)){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
RouteLineDto routeLineDto = shortPathsList.get(0);
|
|
|
|
|
String path = routeLineDto.getPath();
|
|
|
|
|
String[] str = path.split("->");
|
|
|
|
|
List<String> pathlist = Arrays.asList(str);
|
|
|
|
|
Integer start = 0;
|
|
|
|
|
String start_device_code = pathlist.get(start);
|
|
|
|
|
String next_device_code = pathlist.get(start+1);
|
|
|
|
|
|
|
|
|
|
//判断有无出入库任务是相同路线
|
|
|
|
|
TaskDto dto = taskserver.findByCodeAndExcute(taskdto.getNext_device_code(), taskdto.getStart_device_code());
|
|
|
|
|
if (ObjectUtil.isNotEmpty(dto)){
|
|
|
|
|
requireSucess = false;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
packageInstrcutData(instdto, taskdto, taskid, taskcode, vehiclecode, priority,start_device_code,next_device_code,containerType);
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
packageInstrcutData(instdto, taskdto, taskid, taskcode, vehiclecode, priority,taskdto.getStart_device_code(),taskdto.getNext_device_code(),containerType);
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
instructionService.create(instdto);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
log.error("指令创建失败!", e.getMessage());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
Device nextdevice = deviceAppservice.findDeviceByCode(instdto.getNext_device_code());
|
|
|
|
|
|
|
|
|
|
//创建指令后修改任务状态
|
|
|
|
|
taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
|
|
|
|
taskserver.update(taskdto);
|
|
|
|
|
String next_addr = nextdevice.getExtraValue().get("address").toString();
|
|
|
|
|
|
|
|
|
|
List list = new ArrayList();
|
|
|
|
|
Map map = new HashMap();
|
|
|
|
|
map.put("code", "to_target");
|
|
|
|
|
map.put("value", next_addr);
|
|
|
|
|
list.add(map);
|
|
|
|
|
Map map2 = new HashMap();
|
|
|
|
|
map2.put("code", "to_task");
|
|
|
|
|
map2.put("value", instdto.getInstruction_code());
|
|
|
|
|
list.add(map2);
|
|
|
|
|
Map map3 = new HashMap();
|
|
|
|
|
map3.put("code", "to_container_type");
|
|
|
|
|
map3.put("value", instdto.getVehicle_type());
|
|
|
|
|
list.add(map3);
|
|
|
|
|
Map map4 = new HashMap();
|
|
|
|
|
map3.put("code", "to_command");
|
|
|
|
|
map3.put("value", "1");
|
|
|
|
|
list.add(map4);
|
|
|
|
|
|
|
|
|
|
this.writing(list);
|
|
|
|
|
led_message = getLedMessage(instdto);
|
|
|
|
|
List<String> deviceCodes = this.getExtraDeviceCodes("link_device_code");
|
|
|
|
|
String device = null;
|
|
|
|
|
if (ObjectUtil.isNotEmpty(deviceCodes)) {
|
|
|
|
|
for (String deviceCode : deviceCodes) {
|
|
|
|
|
Device linkDevice = deviceAppService.findDeviceByCode(deviceCode);
|
|
|
|
|
if (ObjectUtil.isEmpty(linkDevice)) {
|
|
|
|
|
throw new BadRequestException("设备:" + device_code + "关联设备->" + deviceCode + "为空!");
|
|
|
|
|
}
|
|
|
|
|
if (linkDevice.getDeviceDriver() instanceof LedScreenDeviceDriver){
|
|
|
|
|
device = deviceCode;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
taskScreenService.getLedMessage(device);
|
|
|
|
|
requireSucess = true;
|
|
|
|
|
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
|
|
|
|
|
, instdto.getInstruction_code())) {
|
|
|
|
|
this.writing(list);
|
|
|
|
|
LuceneLogDto logDto = LuceneLogDto.builder()
|
|
|
|
|
.device_code(device_code)
|
|
|
|
|
.content(device_code + inst.getInstruction_code() + "再次下发电气信号")
|
|
|
|
|
.build();
|
|
|
|
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(1000);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
if (ObjectUtil.isEmpty(taskserver.findByCode(taskdto.getTask_code()))) {
|
|
|
|
|
requireSucess = false;
|
|
|
|
|
return false;
|
|
|
|
|
}else {
|
|
|
|
|
if (StrUtil.isNotBlank(barcode)) {
|
|
|
|
|
//根据载具号查找任务
|
|
|
|
|
TaskDto taskdto = taskserver.findByVehicleCodeCodeAndReady(barcode);
|
|
|
|
|
if (!ObjectUtil.isEmpty(taskdto)) {
|
|
|
|
|
if (creatInstruction(taskdto)) return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -592,6 +495,117 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean creatInstruction(TaskDto taskdto) {
|
|
|
|
|
String taskid = taskdto.getTask_id();
|
|
|
|
|
String taskcode = taskdto.getTask_code();
|
|
|
|
|
String vehiclecode = taskdto.getVehicle_code();
|
|
|
|
|
String priority = taskdto.getPriority();
|
|
|
|
|
Instruction instdto = new Instruction();
|
|
|
|
|
String interactionJson = taskdto.getInteraction_json();
|
|
|
|
|
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
|
|
|
|
String containerType = "";
|
|
|
|
|
if (ObjectUtil.isNotEmpty(interactionJsonDTO)) {
|
|
|
|
|
containerType = interactionJsonDTO.getContainerType();
|
|
|
|
|
}
|
|
|
|
|
if (TaskTypeEnum.AGV_Task.getIndex().equals(taskdto.getTask_type())){
|
|
|
|
|
String route_plan_code = taskdto.getRoute_plan_code();
|
|
|
|
|
|
|
|
|
|
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(taskdto.getStart_device_code(), taskdto.getNext_device_code(), route_plan_code);
|
|
|
|
|
if (CollectionUtil.isEmpty(shortPathsList)){
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
RouteLineDto routeLineDto = shortPathsList.get(0);
|
|
|
|
|
String path = routeLineDto.getPath();
|
|
|
|
|
String[] str = path.split("->");
|
|
|
|
|
List<String> pathlist = Arrays.asList(str);
|
|
|
|
|
Integer start = 0;
|
|
|
|
|
String start_device_code = pathlist.get(start);
|
|
|
|
|
String next_device_code = pathlist.get(start+1);
|
|
|
|
|
|
|
|
|
|
//判断有无出入库任务是相同路线
|
|
|
|
|
TaskDto dto = taskserver.findByCodeAndExcute(taskdto.getNext_device_code(), taskdto.getStart_device_code());
|
|
|
|
|
if (ObjectUtil.isNotEmpty(dto)){
|
|
|
|
|
requireSucess = false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
packageInstrcutData(instdto, taskdto, taskid, taskcode, vehiclecode, priority,start_device_code,next_device_code,containerType);
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
packageInstrcutData(instdto, taskdto, taskid, taskcode, vehiclecode, priority, taskdto.getStart_device_code(), taskdto.getNext_device_code(),containerType);
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
instructionService.create(instdto);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
log.error("指令创建失败!", e.getMessage());
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
Device nextdevice = deviceAppservice.findDeviceByCode(instdto.getNext_device_code());
|
|
|
|
|
|
|
|
|
|
//创建指令后修改任务状态
|
|
|
|
|
taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
|
|
|
|
taskserver.update(taskdto);
|
|
|
|
|
String next_addr = nextdevice.getExtraValue().get("address").toString();
|
|
|
|
|
|
|
|
|
|
List list = new ArrayList();
|
|
|
|
|
Map map = new HashMap();
|
|
|
|
|
map.put("code", "to_target");
|
|
|
|
|
map.put("value", next_addr);
|
|
|
|
|
list.add(map);
|
|
|
|
|
Map map2 = new HashMap();
|
|
|
|
|
map2.put("code", "to_task");
|
|
|
|
|
map2.put("value", instdto.getInstruction_code());
|
|
|
|
|
list.add(map2);
|
|
|
|
|
Map map3 = new HashMap();
|
|
|
|
|
map3.put("code", "to_container_type");
|
|
|
|
|
map3.put("value", instdto.getVehicle_type());
|
|
|
|
|
list.add(map3);
|
|
|
|
|
Map map4 = new HashMap();
|
|
|
|
|
map3.put("code", "to_command");
|
|
|
|
|
map3.put("value", "1");
|
|
|
|
|
list.add(map4);
|
|
|
|
|
|
|
|
|
|
this.writing(list);
|
|
|
|
|
led_message = getLedMessage(instdto);
|
|
|
|
|
List<String> deviceCodes = this.getExtraDeviceCodes("link_device_code");
|
|
|
|
|
String device = null;
|
|
|
|
|
if (ObjectUtil.isNotEmpty(deviceCodes)) {
|
|
|
|
|
for (String deviceCode : deviceCodes) {
|
|
|
|
|
Device linkDevice = deviceAppService.findDeviceByCode(deviceCode);
|
|
|
|
|
if (ObjectUtil.isEmpty(linkDevice)) {
|
|
|
|
|
throw new BadRequestException("设备:" + device_code + "关联设备->" + deviceCode + "为空!");
|
|
|
|
|
}
|
|
|
|
|
if (linkDevice.getDeviceDriver() instanceof LedScreenDeviceDriver){
|
|
|
|
|
device = deviceCode;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
taskScreenService.getLedMessage(device);
|
|
|
|
|
requireSucess = true;
|
|
|
|
|
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
|
|
|
|
|
, instdto.getInstruction_code())) {
|
|
|
|
|
this.writing(list);
|
|
|
|
|
LuceneLogDto logDto = LuceneLogDto.builder()
|
|
|
|
|
.device_code(device_code)
|
|
|
|
|
.content(device_code + inst.getInstruction_code() + "再次下发电气信号")
|
|
|
|
|
.build();
|
|
|
|
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(1000);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
if (ObjectUtil.isEmpty(taskserver.findByCode(taskdto.getTask_code()))) {
|
|
|
|
|
requireSucess = false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取任务信息
|
|
|
|
|
*/
|
|
|
|
|
|