diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java index 524dbc068..efd0adc43 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java @@ -518,6 +518,14 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl //按照优先级排序 优先级相等按照创建时间排序 taskDtos = this.sortTask(taskDtos); taskDto = taskDtos.get(0); + if(getDeviceCode.endsWith("X")){ + Boolean result = this.checkIsSafe(getDeviceCode,taskDto); + if(!result){ + taskDto = null; + notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!"; + continue; + } + } break; } } @@ -532,6 +540,14 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl //按照优先级排序 优先级相等按照创建时间排序 taskDtos = this.sortTask(taskDtos); taskDto = taskDtos.get(0); + if(backGetDeviceCode.endsWith("X")){ + Boolean result = this.checkIsSafe(backGetDeviceCode,taskDto); + if(!result){ + taskDto = null; + notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!"; + continue; + } + } flag = this.executeBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList); return flag; } else { @@ -541,6 +557,14 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl //按照优先级排序 优先级相等按照创建时间排序 taskDtos = this.sortTask(taskDtos); taskDto = taskDtos.get(0); + if(backGetDeviceCode.endsWith("X")){ + Boolean result = this.checkIsSafe(backGetDeviceCode,taskDto); + if(!result){ + taskDto = null; + notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!"; + continue; + } + } break; } } @@ -582,6 +606,14 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl //按照优先级排序 优先级相等按照创建时间排序 taskDtos = this.sortTask(taskDtos); taskDto = taskDtos.get(0); + if(getDeviceCode.endsWith("X")){ + Boolean result = this.checkIsSafe(getDeviceCode,taskDto); + if(!result){ + taskDto = null; + notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!"; + continue; + } + } flag = this.executeBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList); return flag; } else { @@ -591,6 +623,14 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl //按照优先级排序 优先级相等按照创建时间排序 taskDtos = this.sortTask(taskDtos); taskDto = taskDtos.get(0); + if(getDeviceCode.endsWith("X")){ + Boolean result = this.checkIsSafe(getDeviceCode,taskDto); + if(!result){ + taskDto = null; + notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!"; + continue; + } + } break; } } @@ -605,6 +645,14 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl //按照优先级排序 优先级相等按照创建时间排序 taskDtos = this.sortTask(taskDtos); taskDto = taskDtos.get(0); + if(backGetDeviceCode.endsWith("X")){ + Boolean result = this.checkIsSafe(backGetDeviceCode,taskDto); + if(!result){ + taskDto = null; + notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!"; + continue; + } + } flag = this.executeBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList); return flag; } else { @@ -614,6 +662,14 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl //按照优先级排序 优先级相等按照创建时间排序 taskDtos = this.sortTask(taskDtos); taskDto = taskDtos.get(0); + if(backGetDeviceCode.endsWith("X")){ + Boolean result = this.checkIsSafe(backGetDeviceCode,taskDto); + if(!result){ + taskDto = null; + notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!"; + continue; + } + } break; } } @@ -1675,4 +1731,22 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl } } } + + public boolean checkIsSafe(String device_code,TaskDto dto){ + String newDevice_code = forametDevice_code(device_code); + List list = taskserver.queryTaskByDeviceCode(newDevice_code); + if(list.size()>0){ + return false; + } + return true; + } + + public String forametDevice_code(String device_code){ + if (device_code.endsWith("X")) { + return device_code.substring(0, device_code.length() - 1) + "S"; + } + return device_code; + } + + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java index 5681fb899..bfcb31921 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java @@ -117,6 +117,8 @@ public interface InstructionService { */ void createAgain(Instruction dto) throws Exception ; + Boolean createInstCheck(Instruction dto); + /** * 编辑 * diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 19d523253..294b15350 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -37,6 +37,7 @@ import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.common.utils.FileUtil; +import org.nl.modules.common.utils.RedisUtils; import org.nl.modules.common.utils.SecurityUtils; import org.nl.modules.system.service.ParamService; import org.nl.modules.system.util.CodeUtil; @@ -82,6 +83,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu @Autowired AcsToLiKuService acsToLiKuService; + private final RedisUtils redisUtils; + @Override public void autoInitial() { this.reload(); @@ -91,6 +94,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu public synchronized void reload() { List list = this.queryAll("instruction_status <2 and is_delete =0"); this.instructions = new CopyOnWriteArrayList<>(list); + //redisUtils.set("insts", this.instructions); } @Override @@ -329,14 +333,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu dto.setInstruction_type("3"); } - // 查询是否存在相同指令号 - // if (!StrUtil.isEmpty(dto.getVehicle_code() )) { - // Instruction inst_dto = findByContainer(dto.getVehicle_code()); - // if (inst_dto != null) { - // log.error("存在相同载具号任务,载具号"+dto.getVehicle_code()); - // throw new BadRequestException("存在相同载具号任务!"); - // } - // } + // 查询是否存在相同任务号、起点终点相同 + if (!createInstCheck(dto)) { + log.info("存在相同任务号且起点终点相同的指令"); + return; + } + // 起点设备与终点设备相同则为初始指令 if (StrUtil.equals(task.getStart_device_code(), dto.getStart_device_code())) { if (!StrUtil.equals(dto.getCompound_inst(), "0") @@ -429,7 +431,10 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu dto = foramte(dto); String task_code = dto.getTask_code(); TaskDto task = taskService.findByCodeFromCache(task_code); - + if (!createInstCheck(dto)) { + log.info("存在相同任务号且起点终点相同的指令"); + return; + } WQLObject instwo = WQLObject.getWQLObject("acs_instruction"); String currentUsername = SecurityUtils.getCurrentUsername(); String now = DateUtil.now(); @@ -663,7 +668,19 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu } } - + @Override + public Boolean createInstCheck(Instruction inst){ + Iterator var3 = instructions.iterator(); + while (var3.hasNext()) { + Instruction instruction = (Instruction) var3.next(); + if (StrUtil.equals(instruction.getTask_code(), inst.getTask_code()) + && StrUtil.equals(instruction.getStart_point_code(), inst.getStart_point_code()) + && StrUtil.equals(instruction.getNext_point_code(), inst.getNext_point_code())) { + return false; + } + } + return true; + } @Override public void createAgain(Instruction dto) throws Exception { String task_code = dto.getTask_code(); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index c3d2b3405..e23b40625 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -37,6 +37,7 @@ import org.nl.acs.task.service.dto.TaskDto; import org.nl.acs.task.service.dto.TaskFeedbackDto; import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.common.utils.FileUtil; +import org.nl.modules.common.utils.RedisUtils; import org.nl.modules.common.utils.SecurityUtils; import org.nl.modules.system.service.ParamService; import org.nl.modules.system.util.CodeUtil; @@ -91,6 +92,9 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { @Autowired StorageCellService storageCellService; + private final RedisUtils redisUtils; + + @Override public void autoInitial() throws Exception { Class var1 = TaskInstructionLock.class; @@ -101,7 +105,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { public synchronized void reload() { List list = this.queryAll("task_status <2 and is_delete =0 order by create_time"); - tasks = new CopyOnWriteArrayList<>(list); } @@ -149,7 +152,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { @Override public Map queryAllByCache(Map whereJson, Pageable page) { - this.reload(); + //this.reload(); String task_code = (String) whereJson.get("task_code"); String vehicle_code = (String) whereJson.get("vehicle_code"); String material_type = (String) whereJson.get("material_type"); @@ -160,6 +163,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { List taskList = new ArrayList(); synchronized (TaskServiceImpl.class) { + //redisUtils.get("task"); Iterator it = tasks.iterator(); while (it.hasNext()) { TaskDto task = it.next(); @@ -690,7 +694,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { // 判断是否为WMS下发的任务,如果是反馈任务状态给WMS String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue(); if (!StrUtil.startWith(dto.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { - TaskFeedbackDto feefbackdto = taskFeedbackService.findByCode(entity.getTask_code()); JSONObject feed_jo = new JSONObject(); feed_jo.put("task_id", entity.getExt_task_id()); feed_jo.put("task_code", dto.getTask_code()); @@ -712,73 +715,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { flag = true; message = e.getMessage(); e.printStackTrace(); - } finally { - - } - if (flag) { - if (ObjectUtil.isEmpty(feefbackdto)) { - feefbackdto = new TaskFeedbackDto(); - feefbackdto.setTask_id(entity.getTask_id()); - feefbackdto.setTask_code(entity.getTask_code()); - feefbackdto.setTask_status(entity.getTask_status()); - feefbackdto.setVehicle_type(entity.getVehicle_type()); - feefbackdto.setVehicle_code(entity.getVehicle_code()); - feefbackdto.setStart_device_code(entity.getStart_device_code()); - feefbackdto.setStart_point_code(entity.getStart_point_code()); - feefbackdto.setNext_device_code(entity.getNext_device_code()); - feefbackdto.setNext_point_code(entity.getNext_point_code()); - feefbackdto.setError_code("400"); - feefbackdto.setIs_finished("0"); - feefbackdto.setRemark(message); - taskFeedbackService.create(feefbackdto); - } else { - feefbackdto.setTask_status(entity.getTask_status()); - feefbackdto.setStart_device_code(entity.getStart_device_code()); - feefbackdto.setStart_point_code(entity.getStart_point_code()); - feefbackdto.setNext_device_code(entity.getNext_device_code()); - feefbackdto.setNext_point_code(entity.getNext_point_code()); - feefbackdto.setError_code("400"); - feefbackdto.setRemark(message); - taskFeedbackService.update(feefbackdto); - } - } else { - int status = body.getStatus(); - JSONObject jo = JSONObject.parseObject(body.body()); - if (ObjectUtil.isEmpty(feefbackdto)) { - feefbackdto = new TaskFeedbackDto(); - feefbackdto.setTask_id(entity.getTask_id()); - feefbackdto.setTask_code(entity.getTask_code()); - feefbackdto.setTask_status(entity.getTask_status()); - feefbackdto.setVehicle_type(entity.getVehicle_type()); - feefbackdto.setVehicle_code(entity.getVehicle_code()); - feefbackdto.setError_code(String.valueOf(body.getStatus())); - feefbackdto.setStart_device_code(entity.getStart_device_code()); - feefbackdto.setStart_point_code(entity.getNext_point_code()); - feefbackdto.setNext_device_code(entity.getNext_device_code()); - feefbackdto.setNext_point_code(entity.getNext_point_code()); - if (status == 200) { - if (StrUtil.equals(entity.getTask_status(), "2")) { - feefbackdto.setIs_finished("1"); - } else { - feefbackdto.setIs_finished("0"); - } - } else { - feefbackdto.setIs_finished("0"); - feefbackdto.setRemark(jo.getString("message")); - } - taskFeedbackService.create(feefbackdto); - } else { - feefbackdto.setTask_status(entity.getTask_status()); - if (status == 200) { - } else { - if (StrUtil.equals(entity.getTask_status(), "2")) { - feefbackdto.setIs_finished("1"); - } else { - feefbackdto.setIs_finished("0"); - } - } - taskFeedbackService.update(feefbackdto); - } } } @@ -812,8 +748,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { // 判断是否为WMS下发的任务,如果是反馈任务状态给WMS String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue(); if (!StrUtil.startWith(entity.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { - TaskFeedbackDto feefbackdto = taskFeedbackService.findByCode(entity.getTask_code()); - System.out.println(feefbackdto == null); JSONObject feed_jo = new JSONObject(); feed_jo.put("task_id", entity.getExt_task_id()); feed_jo.put("task_code", entity.getTask_code()); @@ -829,83 +763,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { flag = true; message = e.getMessage(); e.printStackTrace(); - } finally { - - } - if (flag) { - if (ObjectUtil.isEmpty(feefbackdto)) { - feefbackdto = new TaskFeedbackDto(); - feefbackdto.setTask_id(entity.getTask_id()); - feefbackdto.setTask_code(entity.getTask_code()); - feefbackdto.setTask_status(entity.getTask_status()); - feefbackdto.setVehicle_type(entity.getVehicle_type()); - feefbackdto.setVehicle_code(entity.getVehicle_code()); - feefbackdto.setStart_device_code(entity.getStart_device_code()); - feefbackdto.setStart_point_code(entity.getStart_point_code()); - feefbackdto.setNext_device_code(entity.getNext_device_code()); - feefbackdto.setNext_point_code(entity.getNext_point_code()); - feefbackdto.setError_code("400"); - feefbackdto.setIs_finished("0"); - feefbackdto.setRemark(message); - taskFeedbackService.create(feefbackdto); - } else { - feefbackdto.setTask_status(entity.getTask_status()); - feefbackdto.setStart_device_code(entity.getStart_device_code()); - feefbackdto.setStart_point_code(entity.getStart_point_code()); - feefbackdto.setNext_device_code(entity.getNext_device_code()); - feefbackdto.setNext_point_code(entity.getNext_point_code()); - feefbackdto.setError_code("400"); - feefbackdto.setRemark(message); - taskFeedbackService.update(feefbackdto); - } - } else { - int status = body.getStatus(); - JSONObject jo = JSONObject.parseObject(body.body()); - if (ObjectUtil.isEmpty(feefbackdto)) { - feefbackdto = new TaskFeedbackDto(); - feefbackdto.setTask_id(entity.getTask_id()); - feefbackdto.setTask_code(entity.getTask_code()); - feefbackdto.setTask_status(entity.getTask_status()); - feefbackdto.setVehicle_type(entity.getVehicle_type()); - feefbackdto.setVehicle_code(entity.getVehicle_code()); - feefbackdto.setError_code(String.valueOf(body.getStatus())); - feefbackdto.setStart_device_code(entity.getStart_device_code()); - feefbackdto.setStart_point_code(entity.getStart_point_code()); - feefbackdto.setNext_device_code(entity.getNext_device_code()); - feefbackdto.setNext_point_code(entity.getNext_point_code()); - if (status == 200) { - if (StrUtil.equals(entity.getTask_status(), "2")) { - feefbackdto.setIs_finished("1"); - } else { - feefbackdto.setIs_finished("0"); - } - } else { - feefbackdto.setIs_finished("0"); - feefbackdto.setRemark(jo.getString("message")); - } - taskFeedbackService.create(feefbackdto); - } else { - feefbackdto.setTask_status(entity.getTask_status()); - if (status == 200) { - if (StrUtil.equals(entity.getTask_status(), "2")) { - feefbackdto.setIs_finished("1"); - } else { - feefbackdto.setIs_finished("0"); - } - } else { - feefbackdto.setIs_finished("0"); - feefbackdto.setRemark(jo.getString("message")); - } - taskFeedbackService.update(feefbackdto); - } - } - } - // 如果属于先知AGV,关闭运单序列 - if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) { - try { - agvService.markComplete(entity.getTask_code()); - } catch (Exception e) { - e.printStackTrace(); } } } @@ -954,18 +811,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { ja.add(feed_jo); acstowmsService.feedbackTaskStatusToWms(ja); } - List shortPathsList = - routeLineService.getShortPathLines( - entity.getStart_device_code(), - entity.getNext_device_code(), - entity.getRoute_plan_code()); - String type = shortPathsList.get(0).getType(); - // != 0 为agv任务 - if (!StrUtil.equals(type, "0")) { - if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) { - agvService.markComplete(entity.getTask_code()); - } - } } @Override diff --git a/acs/nladmin-ui/src/views/acs/instruction/index.vue b/acs/nladmin-ui/src/views/acs/instruction/index.vue index a1d4f6f34..406e28684 100644 --- a/acs/nladmin-ui/src/views/acs/instruction/index.vue +++ b/acs/nladmin-ui/src/views/acs/instruction/index.vue @@ -71,16 +71,16 @@ - - 同步 - + + + + + + + + + + { - this.crud.toQuery() - }).catch(err => { - console.log(err.response.data.message) - }) - }, + // reload() { + // crudInstruction.reload().then(res => { + // this.crud.toQuery() + // }).catch(err => { + // console.log(err.response.data.message) + // }) + // }, beforeHandleCommand(index, row, command) { return { diff --git a/acs/nladmin-ui/src/views/acs/task/index.vue b/acs/nladmin-ui/src/views/acs/task/index.vue index 59cf49fb1..c7759456e 100644 --- a/acs/nladmin-ui/src/views/acs/task/index.vue +++ b/acs/nladmin-ui/src/views/acs/task/index.vue @@ -68,16 +68,16 @@ > 新增 - - 同步 - + + + + + + + + + + @@ -586,13 +586,13 @@ export default { console.log(err.response.data.message) }) }, - reload() { - crudTask.reload().then(res => { - this.crud.toQuery() - }).catch(err => { - console.log(err.response.data.message) - }) - }, + // reload() { + // crudTask.reload().then(res => { + // this.crud.toQuery() + // }).catch(err => { + // console.log(err.response.data.message) + // }) + // }, beforeHandleCommand(index, row, command) { return {