zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/AutoRunScheduler.java
@@ -150,7 +150,7 @@ String staTaskMemo = "DEMO_STA_" + String.join("-", staPreNos); // 移库 this.runLocToLoc(locGroupList, agvGroupList, staTaskMemo); this.runLocToLoc2(locGroupList, agvGroupList, staTaskMemo); } private void autoOut(List<Integer> locGroupList, List<String> staGroupList, List<String> agvGroupList) { @@ -446,6 +446,71 @@ mainService.generateBusAndTask(param, memo); } private void runLocToLoc2(List<Integer> locGroupList, List<String> agvGroupList, String staTaskMemo) { Integer startRow = Collections.min(locGroupList); Integer endRow = Collections.max(locGroupList); String memo = "DEMO_LOC_" + startRow + "-" + endRow; // -2 是为了服务输送线 int availableAgvCount = this.getAvailableAgvCount(agvGroupList) - 1; // 最多 ? 组bus运行 if (availableAgvCount <= busService.count(new LambdaQueryWrapper<Bus>().in(Bus::getBusSts, BusStsType.RECEIVE.val(), BusStsType.PROGRESS.val()).in(Bus::getMemo, memo, staTaskMemo))) { return; } AgvModel agvModel = agvModelService.getOne(new LambdaQueryWrapper<AgvModel>().eq(AgvModel::getType, AgvModelType.CTU_BOX_TRANSPORT_AGV.toString())); if (null == agvModel) { return; } int maxCapacity = agvModel.getBackpack(); // STOCK LambdaQueryWrapper<Loc> stockWrapper = new LambdaQueryWrapper<Loc>().eq(Loc::getLocSts, LocStsType.STOCK.val()); if (null != startRow) { stockWrapper.ge(Loc::getRow, startRow); } if (null != endRow) { stockWrapper.le(Loc::getRow, endRow); } List<Loc> stockList = locService.list(stockWrapper); if (Cools.isEmpty(stockList) || stockList.size() < agvModel.getBackpack()) { return; } Collections.shuffle(stockList); // IDLE LambdaQueryWrapper<Loc> idleWrapper = new LambdaQueryWrapper<Loc>().eq(Loc::getLocSts, LocStsType.IDLE.val()); if (null != startRow) { idleWrapper.ge(Loc::getRow, startRow); } if (null != endRow) { idleWrapper.le(Loc::getRow, endRow); } List<Loc> idleList = locService.list(idleWrapper); if (Cools.isEmpty(idleList)) { return; } Collections.shuffle(idleList); OpenBusSubmitParam param = new OpenBusSubmitParam(); param.setBatch(String.valueOf(snowflakeIdWorker.nextId()).substring(13, 19)); for (int i = 0; i < Math.min(maxCapacity, Math.min(stockList.size(), idleList.size())); i++) { Loc stockLoc = stockList.get(i); Loc idleLoc = idleList.get(i); TaskDto taskDto = new TaskDto(); taskDto.setOriLoc(stockLoc.getLocNo()); taskDto.setDestLoc(idleLoc.getLocNo()); taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(11, 19)); param.getTaskList().add(taskDto); } mainService.generateBusAndTask(param, memo); } public static List<String> getStaPrefixes(List<String> staGroupList) { Set<String> rowSet = new HashSet<>(); for (String s : staGroupList) { zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java
@@ -1502,11 +1502,11 @@ // } // } List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo); for (Long taskId : taskIds) { Task task = taskService.getById(taskId); report(task, agv_11_up.getQrCode(), TaskReportStsType.END); } // List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo); // for (Long taskId : taskIds) { // Task task = taskService.getById(taskId); // report(task, agv_11_up.getQrCode(), TaskReportStsType.END); // } } // 出库取货 @@ -1540,31 +1540,31 @@ // } // } // } List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo); for (Long taskId : taskIds) { Task task = taskService.getById(taskId); report(task, agv_11_up.getQrCode(), TaskReportStsType.OTBIN); } // List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo); // for (Long taskId : taskIds) { // Task task = taskService.getById(taskId); // report(task, agv_11_up.getQrCode(), TaskReportStsType.OTBIN); // } } //从输送线取货完成 if (agv_11_up.getCompleteType().equals(AgvCompleteType.TAKE_FROM_STA_COMPLETE)) { WebsocketServiceImpl.taskShelfBarcode = agv_11_up.getLocCode(); List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo); for (Long taskId : taskIds) { Task task = taskService.getById(taskId); report(task, agv_11_up.getQrCode(), TaskReportStsType.OTBIN); } } // if (agv_11_up.getCompleteType().equals(AgvCompleteType.TAKE_FROM_STA_COMPLETE)) { // WebsocketServiceImpl.taskShelfBarcode = agv_11_up.getLocCode(); // List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo); // for (Long taskId : taskIds) { // Task task = taskService.getById(taskId); // report(task, agv_11_up.getQrCode(), TaskReportStsType.OTBIN); // } // } //往输送线放货完成 if (agv_11_up.getCompleteType().equals(AgvCompleteType.RELEASE_FROM_STA_COMPLETE)) { WebsocketServiceImpl.taskShelfBarcode = agv_11_up.getLocCode(); List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo); for (Long taskId : taskIds) { Task task = taskService.getById(taskId); report(task, agv_11_up.getQrCode(), TaskReportStsType.END); } } // if (agv_11_up.getCompleteType().equals(AgvCompleteType.RELEASE_FROM_STA_COMPLETE)) { // WebsocketServiceImpl.taskShelfBarcode = agv_11_up.getLocCode(); // List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo); // for (Long taskId : taskIds) { // Task task = taskService.getById(taskId); // report(task, agv_11_up.getQrCode(), TaskReportStsType.END); // } // } // 路径完成 || 充电完成 if (agv_11_up.getCompleteType().equals(AgvCompleteType.ENTIRE_PATH_COMPLETE) @@ -1604,6 +1604,8 @@ // task for (Segment segment : segmentList) { boolean taskComplete = false; boolean otbin = false; Task task = taskService.getById(segment.getTaskId()); assert null != task; @@ -1614,6 +1616,7 @@ switch (Objects.requireNonNull(posType)) { case ORI_STA: case ORI_LOC: otbin = true; break; case DEST_STA: case DEST_LOC: @@ -1634,19 +1637,24 @@ break; } if (otbin) { locService.taskCallBackOtbin(task); report(task, null, TaskReportStsType.OTBIN); } if (taskComplete) { locService.taskCallBack(task); locService.taskCallBackEnd(task); task.setTaskSts(TaskStsType.COMPLETE.val()); task.setEndTime(now); task.setUpdateTime(now); if (!taskService.updateById(task)) { log.error("Task [{}] 更新失败 !!!", task.getSeqNum()); } else { report(task, null, TaskReportStsType.END); if (task.getSeqNum() != null && task.getSeqNum().contains("SSX-CK")) { report(task, "1001", TaskReportStsType.COMPLETED); } } report(task, null, TaskReportStsType.END); if (task.getSeqNum() != null && task.getSeqNum().contains("SSX-CK")) { report(task, "1001", TaskReportStsType.COMPLETED); } } } zy-acs-manager/src/main/java/com/zy/acs/manager/core/third/ReportThirdScheduler.java
@@ -69,6 +69,25 @@ e.printStackTrace(); } taskReportService.updateById(taskReport); } else if (taskReport.getEventType().equalsIgnoreCase(TaskReportStsType.OTBIN.name) && taskReport.getSeqNum().contains("SSX-RK")) { String response = null; try { response = new HttpHandler.Builder() .setUri(wcsUrl) .setPath(wcsPath) .setJson(JSON.toJSONString(taskReport)) .build() .doPost(); log.info("返回参数:{}", response); taskReport.setReportTimes((Cools.isEmpty(taskReport.getReportTimes()) ? 0 : taskReport.getReportTimes()) + 1); taskReport.setUpdateTime(new Date()); taskReport.setCompleted(1); } catch (IOException e) { taskReport.setReportTimes((Cools.isEmpty(taskReport.getReportTimes()) ? 0 : taskReport.getReportTimes()) + 1); taskReport.setUpdateTime(new Date()); e.printStackTrace(); } taskReportService.updateById(taskReport); } else { TaskEvent taskEvent = new TaskEvent(taskReport.getSeqNum(), taskReport.getEventType(), taskReport.getAgvId() + ""); log.info("开始上报:{}", taskEvent); @@ -86,6 +105,10 @@ } } public static void main(String[] args) { System.out.println("SSX-RK122".contains("SSX-RK")); } /** * 删除超过一定天数的上报历史记录 */ zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/LocService.java
@@ -15,5 +15,8 @@ List<Map<String, Object>> selectDigitalLocWhichNeedShow(); void taskCallBack(Task task); void taskCallBackOtbin(Task task); void taskCallBackEnd(Task task); } zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/LocServiceImpl.java
@@ -44,7 +44,7 @@ } @Override public void taskCallBack(Task task) { public void taskCallBackOtbin(Task task) { if (null == task) { return; } @@ -54,9 +54,7 @@ Date now = new Date(); // loc status Loc oriLoc = null; Loc destLoc = null; Sta oriSta = null; Sta destSta = null; switch (Objects.requireNonNull(TaskTypeType.get(task.getTaskTypeEl()))) { case LOC_TO_LOC: oriLoc = this.getById(task.getOriLoc()); @@ -68,14 +66,6 @@ } } destLoc = this.getById(task.getDestLoc()); if (destLoc.getLocSts().equals(LocStsType.PAKIN.val())) { destLoc.setLocSts(LocStsType.STOCK.val()); destLoc.setUpdateTime(now); if (!this.updateById(destLoc)) { log.error("Loc [{}] 库位修改状态失败", task.getDestLoc$()); } } break; case LOC_TO_STA: oriLoc = this.getById(task.getOriLoc()); @@ -87,14 +77,6 @@ } } destSta = staService.getById(task.getDestSta()); if (destSta.getStaSts().equals(StaStsType.READY_RELEASE.val())) { destSta.setStaSts(StaStsType.STOCK.val()); destSta.setUpdateTime(now); if (!staService.updateById(destSta)) { log.error("Sta [{}] 站点修改状态失败", task.getDestSta$()); } } break; case STA_TO_LOC: oriSta = staService.getById(task.getOriSta()); @@ -106,14 +88,6 @@ } } destLoc = this.getById(task.getDestLoc()); if (destLoc.getLocSts().equals(LocStsType.PAKIN.val())) { destLoc.setLocSts(LocStsType.STOCK.val()); destLoc.setUpdateTime(now); if (!this.updateById(destLoc)) { log.error("Loc [{}] 库位修改状态失败", task.getDestLoc$()); } } break; case STA_TO_STA: oriSta = staService.getById(task.getOriSta()); @@ -125,6 +99,61 @@ } } break; case TO_CHARGE: case TO_STANDBY: case MOVE: break; default: break; } } @Override public void taskCallBackEnd(Task task) { if (null == task) { return; } if (!task.getTaskSts().equals(TaskStsType.PROGRESS.val())) { return; } Date now = new Date(); // loc status Loc destLoc = null; Sta destSta = null; switch (Objects.requireNonNull(TaskTypeType.get(task.getTaskTypeEl()))) { case LOC_TO_LOC: destLoc = this.getById(task.getDestLoc()); if (destLoc.getLocSts().equals(LocStsType.PAKIN.val())) { destLoc.setLocSts(LocStsType.STOCK.val()); destLoc.setUpdateTime(now); if (!this.updateById(destLoc)) { log.error("Loc [{}] 库位修改状态失败", task.getDestLoc$()); } } break; case LOC_TO_STA: destSta = staService.getById(task.getDestSta()); if (destSta.getStaSts().equals(StaStsType.READY_RELEASE.val())) { destSta.setStaSts(StaStsType.STOCK.val()); destSta.setUpdateTime(now); if (!staService.updateById(destSta)) { log.error("Sta [{}] 站点修改状态失败", task.getDestSta$()); } } break; case STA_TO_LOC: destLoc = this.getById(task.getDestLoc()); if (destLoc.getLocSts().equals(LocStsType.PAKIN.val())) { destLoc.setLocSts(LocStsType.STOCK.val()); destLoc.setUpdateTime(now); if (!this.updateById(destLoc)) { log.error("Loc [{}] 库位修改状态失败", task.getDestLoc$()); } } break; case STA_TO_STA: destSta = staService.getById(task.getDestSta()); if (destSta.getStaSts().equals(StaStsType.READY_RELEASE.val())) { destSta.setStaSts(StaStsType.STOCK.val());