fix: 堆垛机对接位通过补码生成到货架的任务
This commit is contained in:
@@ -80,7 +80,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
@Autowired
|
||||
DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
|
||||
|
||||
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl");
|
||||
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl");
|
||||
|
||||
ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
|
||||
|
||||
@@ -92,47 +92,47 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
private Date instruction_apply_time = new Date();
|
||||
private int instruction_require_time_out = 3000;
|
||||
|
||||
/**
|
||||
/**
|
||||
* 心跳
|
||||
*/
|
||||
int heartbeat = 0;
|
||||
int last_heartbeat = 0;
|
||||
/**
|
||||
/**
|
||||
* 工作模式
|
||||
*/
|
||||
int mode = 0;
|
||||
int last_mode = 0;
|
||||
/**
|
||||
/**
|
||||
* 光电信号
|
||||
*/
|
||||
int move = 0;
|
||||
int last_move = 0;
|
||||
/**
|
||||
/**
|
||||
* 托盘方向
|
||||
*/
|
||||
int container_direction = 0;
|
||||
int last_container_direction = 0;
|
||||
/**
|
||||
/**
|
||||
* 报警
|
||||
*/
|
||||
int error = 0;
|
||||
int last_error = 0;
|
||||
/**
|
||||
/**
|
||||
* 动作信号
|
||||
*/
|
||||
int action = 0;
|
||||
int last_action = 0;
|
||||
/**
|
||||
/**
|
||||
* 任务号
|
||||
*/
|
||||
int task = 0;
|
||||
int last_task = 0;
|
||||
/**
|
||||
/**
|
||||
* 托盘类型
|
||||
*/
|
||||
int container_type = 0;
|
||||
int last_container_type = 0;
|
||||
/**
|
||||
/**
|
||||
* 纯数字托盘号
|
||||
*/
|
||||
int container_no = 0;
|
||||
@@ -199,6 +199,8 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
String vehicle_code;
|
||||
String inst_message;
|
||||
|
||||
String hand_barcode = null;
|
||||
|
||||
/**
|
||||
* led点阵屏信息
|
||||
*/
|
||||
@@ -235,7 +237,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
|
||||
if (mode != last_mode) {
|
||||
requireSucess = false;
|
||||
if(mode == 2){
|
||||
if (mode == 2) {
|
||||
clearWrite();
|
||||
}
|
||||
}
|
||||
@@ -314,9 +316,6 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void writing(int command) {
|
||||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + org.nl.acs.device_driver.conveyor.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command;
|
||||
@@ -424,8 +423,6 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 申请任务
|
||||
*/
|
||||
@@ -469,6 +466,53 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
//判断是否有相同起点的,任务状态就绪的任务
|
||||
TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code);
|
||||
if (ObjectUtil.isNull(taskdto)) {
|
||||
//补码生成堆垛机对接位到货架的指令
|
||||
if (StrUtil.isNotEmpty(hand_barcode)) {
|
||||
TaskDto taskDtoHandCode = taskserver.findByVehicleCodeCodeAndReady(hand_barcode);
|
||||
if (Objects.nonNull(taskDtoHandCode)) {
|
||||
String taskid = taskDtoHandCode.getTask_id();
|
||||
String taskcode = taskDtoHandCode.getTask_code();
|
||||
String priority = taskDtoHandCode.getPriority();
|
||||
String start_point_code = taskDtoHandCode.getStart_point_code();
|
||||
String start_device_code = "";
|
||||
String route_plan_code = taskDtoHandCode.getRoute_plan_code();
|
||||
String next_device_code = taskDtoHandCode.getNext_device_code();
|
||||
String interactionJson = taskDtoHandCode.getInteraction_json();
|
||||
String containerType = "";
|
||||
if (StrUtil.isNotEmpty(interactionJson)) {
|
||||
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
||||
containerType = interactionJsonDTO.getContainerType();
|
||||
}
|
||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(taskDtoHandCode.getStart_device_code(), next_device_code, route_plan_code);
|
||||
RouteLineDto routeLineDto = shortPathsList.get(0);
|
||||
String path = routeLineDto.getPath();
|
||||
String[] str = path.split("->");
|
||||
List<String> pathlist = Arrays.asList(str);
|
||||
int index = 0;
|
||||
for (int m = 0; m < pathlist.size(); m++) {
|
||||
if (pathlist.get(m).equals(next_device_code)) {
|
||||
index = m - 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
start_device_code = pathlist.get(index);
|
||||
//校验路由关系
|
||||
List<RouteLineDto> shortPathsList2 = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
|
||||
if (ObjectUtils.isEmpty(shortPathsList2) || shortPathsList2.size() < 1) {
|
||||
throw new RuntimeException("路由不通!");
|
||||
}
|
||||
Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code);
|
||||
String next_point_code;
|
||||
if (StrUtil.equals(deviceAppservice.findDeviceTypeByCode(next_device_code), "storage")) {
|
||||
next_point_code = taskDtoHandCode.getTo_x() + "-" + taskDtoHandCode.getTo_y() + "-" + taskDtoHandCode.getTo_z();
|
||||
Instruction instdto = new Instruction();
|
||||
packageData(instdto, route_plan_code, taskDtoHandCode, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code, priority, containerType);
|
||||
return updateTask(taskDtoHandCode, nextdevice, instdto);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (ObjectUtil.isNotNull(taskdto)) {
|
||||
@@ -484,9 +528,12 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
String start_device_code = taskdto.getStart_device_code();
|
||||
String route_plan_code = taskdto.getRoute_plan_code();
|
||||
String next_device_code = "";
|
||||
String containerType = "";
|
||||
String interactionJson = taskdto.getInteraction_json();
|
||||
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
||||
String containerType = interactionJsonDTO.getContainerType();
|
||||
if (StrUtil.isNotEmpty(interactionJson)) {
|
||||
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
||||
containerType = interactionJsonDTO.getContainerType();
|
||||
}
|
||||
/**
|
||||
* 开始平均分配
|
||||
*/
|
||||
@@ -525,7 +572,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
next_point_code = next_device_code;
|
||||
}
|
||||
Instruction instdto = new Instruction();
|
||||
packageData(instdto, route_plan_code, taskdto, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code, priority,containerType);
|
||||
packageData(instdto, route_plan_code, taskdto, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code, priority, containerType);
|
||||
log.error("=================================,{}", instdto.getCreate_by());
|
||||
try {
|
||||
instructionService.create(instdto);
|
||||
@@ -534,21 +581,26 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
log.error("指令创建失败!,{}", e.getMessage());
|
||||
return false;
|
||||
}
|
||||
taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
taskserver.update(taskdto);
|
||||
requireSucess = true;
|
||||
String next_addr = nextdevice.getExtraValue().get("address").toString();
|
||||
List list = new ArrayList();
|
||||
writeData(next_addr, list, instdto);
|
||||
// led_message = getLedMessage(instdto);
|
||||
requireSucess = true;
|
||||
return true;
|
||||
return updateTask(taskdto, nextdevice, instdto);
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean updateTask(TaskDto taskdto, Device nextdevice, Instruction instdto) {
|
||||
taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
taskserver.update(taskdto);
|
||||
requireSucess = true;
|
||||
String next_addr = nextdevice.getExtraValue().get("address").toString();
|
||||
List list = new ArrayList();
|
||||
writeData(next_addr, list, instdto);
|
||||
// led_message = getLedMessage(instdto);
|
||||
requireSucess = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void writeData(String next_addr, List list, Instruction inst) {
|
||||
List list1 = new ArrayList();
|
||||
Map map = new HashMap();
|
||||
@@ -576,7 +628,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
this.writing(list3);
|
||||
}
|
||||
|
||||
private static void packageData(Instruction instdto, String route_plan_code, TaskDto taskdto, String taskid, String taskcode, String start_device_code, String next_device_code, String start_point_code, String next_point_code, String priority,String containerType) {
|
||||
private static void packageData(Instruction instdto, String route_plan_code, TaskDto taskdto, String taskid, String taskcode, String start_device_code, String next_device_code, String start_point_code, String next_point_code, String priority, String containerType) {
|
||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||
instdto.setRoute_plan_code(route_plan_code);
|
||||
instdto.setRemark(taskdto.getRemark());
|
||||
@@ -676,7 +728,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
mode = LangProcess.msg("universal_standby");
|
||||
} else if (this.getMode() == 3) {
|
||||
mode = LangProcess.msg("universal_operation");
|
||||
}else if (this.getMode() == 5) {
|
||||
} else if (this.getMode() == 5) {
|
||||
mode = LangProcess.msg("one_mode3");
|
||||
}
|
||||
|
||||
@@ -685,7 +737,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
jo.put("message", LangProcess.msg(message));
|
||||
jo.put("error", this.getError());
|
||||
String move = "无货";
|
||||
if(this.move == 1){
|
||||
if (this.move == 1) {
|
||||
move = "有货";
|
||||
}
|
||||
jo.put("move", move);
|
||||
@@ -694,6 +746,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
jo.put("is_click", true);
|
||||
jo.put("isOnline", this.getIsonline());
|
||||
jo.put("requireSucess", requireSucess);
|
||||
jo.put("hand_barcode", hand_barcode);
|
||||
return jo;
|
||||
}
|
||||
|
||||
@@ -755,6 +808,8 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
} else if (StrUtil.equals(requestSucess, "1")) {
|
||||
this.requireSucess = true;
|
||||
}
|
||||
String hand_barcode = data.getString("hand_barcode");
|
||||
this.setHand_barcode(hand_barcode);
|
||||
}
|
||||
|
||||
public static boolean arrayEquals(int[] a, int[] b) {
|
||||
|
||||
@@ -389,6 +389,15 @@ public interface TaskService extends CommonService<Task> {
|
||||
*/
|
||||
TaskDto findByStartCodeAndReady(String device_code);
|
||||
|
||||
|
||||
/**
|
||||
* 根据起载具号查询就绪任务
|
||||
*
|
||||
* @param device_code
|
||||
* @return
|
||||
*/
|
||||
TaskDto findByVehicleCodeCodeAndReady(String device_code);
|
||||
|
||||
/**
|
||||
* 根据起点设备编号查询当前是否有执行中任务
|
||||
*
|
||||
|
||||
@@ -1076,6 +1076,15 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
return optionalTask.orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskDto findByVehicleCodeCodeAndReady(String vehicleCode) {
|
||||
Optional<TaskDto> optionalTask = tasks.stream()
|
||||
.filter(task -> StrUtil.equals(task.getVehicle_code(), vehicleCode)
|
||||
&& StrUtil.equals(task.getTask_status(), TaskStatusEnum.READY.getIndex()))
|
||||
.findFirst();
|
||||
return optionalTask.orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskDto findByCodeAndExcute(String start_code, String next_code) {
|
||||
Task task = this.lambdaQuery()
|
||||
|
||||
@@ -58,7 +58,7 @@ public class CreateDDJInst {
|
||||
Device nextDevice = appService.findDeviceByCode(next_device_code);
|
||||
//判断有无出入库任务是相同路线
|
||||
TaskDto dto = taskserver.findByCodeAndExcute(next_device_code, start_device_code);
|
||||
if (ObjectUtil.isNotEmpty(dto)){
|
||||
if (ObjectUtil.isNotEmpty(dto)) {
|
||||
return;
|
||||
}
|
||||
if (startDevice.getDevice_type().equals(DeviceType.storage.name()) &&
|
||||
@@ -90,21 +90,21 @@ public class CreateDDJInst {
|
||||
StandardStackerDeviceDriver standardStackerDeviceDriver;
|
||||
if (deviceByCode.getDeviceDriver() instanceof StandardStackerDeviceDriver) {
|
||||
standardStackerDeviceDriver = (StandardStackerDeviceDriver) deviceByCode.getDeviceDriver();
|
||||
if (standardStackerDeviceDriver.getMode() != 3 || standardStackerDeviceDriver.getMove() == 1 || standardStackerDeviceDriver.getCommand() != 0) {
|
||||
log.error("堆垛机,{}未联机或者在执行中", deviceByCode.getDevice_code());
|
||||
return;
|
||||
}
|
||||
// if (standardStackerDeviceDriver.getMode() != 3 || standardStackerDeviceDriver.getMove() == 1 || standardStackerDeviceDriver.getCommand() != 0) {
|
||||
// log.error("堆垛机,{}未联机或者在执行中", deviceByCode.getDevice_code());
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
String next_device_code = taskDto.getNext_device_code();
|
||||
Device nextDevice = appService.findDeviceByCode(next_device_code);
|
||||
BeltConveyorDeviceDriver beltConveyorDeviceDriver;
|
||||
if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
|
||||
beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver();
|
||||
if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 1) {
|
||||
log.error("输送机,{}未联机或执行中", next_device_code);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
|
||||
// beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver();
|
||||
// if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 1) {
|
||||
// log.error("输送机,{}未联机或执行中", next_device_code);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
String taskid = taskDto.getTask_id();
|
||||
String taskcode = taskDto.getTask_code();
|
||||
String task_type = taskDto.getTask_type();
|
||||
@@ -149,7 +149,7 @@ public class CreateDDJInst {
|
||||
int index = 0;
|
||||
for (int m = 0; m < pathlist1.size(); m++) {
|
||||
String deviceType1 = appService.findDeviceByCode(pathlist1.get(m)).getDevice_type();
|
||||
if(deviceType1.equals(DeviceType.stacker.name())){
|
||||
if (deviceType1.equals(DeviceType.stacker.name())) {
|
||||
index = m + 1;
|
||||
break;
|
||||
}
|
||||
@@ -287,8 +287,8 @@ public class CreateDDJInst {
|
||||
}
|
||||
/*List<DeviceExtra> deviceExtras = deviceExtra.list(Wrappers.lambdaQuery(DeviceExtra.class).
|
||||
eq(DeviceExtra::getDevice_code, pathlist.get(1)).orderByDesc(DeviceExtra::getCreate_time));*/
|
||||
String count = deviceByCode.getExtraValue().get("count").toString();
|
||||
if (StrUtil.isNotEmpty(count) ) {
|
||||
String count = deviceByCode.getExtraValue().get("count").toString();
|
||||
if (StrUtil.isNotEmpty(count)) {
|
||||
if (max <= Integer.parseInt(count)) {
|
||||
instdto.setInstruction_type(task_type);
|
||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||
|
||||
Reference in New Issue
Block a user