| | |
| | | String slotCategory = values.getString("slotCategory"); |
| | | String slotCode = values.getString("slotCode"); |
| | | EntityWrapper<AgvTask> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("task_no", robotTaskCode); |
| | | wrapper.eq("task_no", rcsReporterTask.getRobotTaskCode().substring(0, rcsReporterTask.getRobotTaskCode().length() - 2)); |
| | | AgvTask task = agvTaskService.selectOne(wrapper); |
| | | if (!Cools.isEmpty(task)) { |
| | | try { |
| | |
| | | transParent.setTaskname(task.getTaskNo()+"-"+(task.getCtnType()-1)); |
| | | transParent.setStationId(task.getStaNo()); |
| | | transParent.setAgvCode("2");//连接器库 |
| | | //08-1是空托盘转序任务 |
| | | //08-2是物料转序任务 |
| | | if (task.getTaskType().equals("ZX-AGV-08-1")) { |
| | | transParent.setTransType("08-1"); |
| | | } else if (task.getTaskType().equals("ZX-AGV-08-2")) { |
| | | transParent.setTransType("08-2"); |
| | | } else if (task.getTaskType().equals("PP-AGV")) { |
| | | transParent.setTransType("10"); |
| | | } else if (task.getTaskType().equals("ZP-AGV")) { |
| | | transParent.setTransType("11"); |
| | | } |
| | | int i = applyInStation(transParent); |
| | | if (i == 1) { |
| | | rcsReturn.setCode("SUCCESS"); |
| | |
| | | if (task.getTaskType().equals("AGV补空料架") && staProtocol != null && !staProtocol.isLoading() && staProtocol.isEmptyOutType() && staProtocol.getWorkNo() == 0) { |
| | | boo = true; |
| | | wrkNo = 9998; |
| | | } else if (!task.getTaskType().equals("AGV补空料架") && staProtocol != null && staProtocol.isLoading() && staProtocol.isEmptyOutType() && staProtocol.getWorkNo() == 0) { |
| | | } else if (!task.getTaskType().equals("AGV补空料架") && staProtocol != null && staProtocol.isLoading() && staProtocol.isEmptyOutType()) { |
| | | boo = true; |
| | | } |
| | | if (boo) { |
| | |
| | | rcsReturn.setData(data); |
| | | } |
| | | }else { |
| | | TransParent transParent = new TransParent(); |
| | | transParent.setTaskno(task.getTaskNo() + "-" + (task.getCtnType() - 1)); |
| | | transParent.setTaskname(task.getTaskNo() + "-" + (task.getCtnType() - 1)); |
| | | transParent.setStationId(task.getStaNo()); |
| | | transParent.setAgvCode("2");//连接器库 |
| | | //08-1是空托盘转序任务 |
| | | //08-2是物料转序任务 |
| | | if (task.getTaskType().equals("ZX-AGV-08-1")) { |
| | | transParent.setTransType("08-1"); |
| | | } else if (task.getTaskType().equals("ZX-AGV-08-2")) { |
| | | transParent.setTransType("08-2"); |
| | | } else if (task.getTaskType().equals("PP-AGV")) { |
| | | transParent.setTransType("10"); |
| | | } else if (task.getTaskType().equals("ZP-AGV")) { |
| | | transParent.setTransType("11"); |
| | | } |
| | | //放货离开站点 |
| | | int i = AGVDepartureCompleted(transParent); |
| | | if (i == 1) { |
| | | // 更新任务状态等内部逻辑 |
| | | task.setWrkSts(304L); // 301 任务下发、302 任务执行、303 任务中断、304 任务结束 |
| | | task.setModiTime(new Date()); |
| | | agvTaskService.updateById(task); |
| | | // 返回RCS |
| | | rcsReturn.setCode("SUCCESS"); |
| | | rcsReturn.setMessage(""); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("robotTaskCode", robotTaskCode); |
| | | rcsReturn.setData(data); |
| | | } else { |
| | | // 返回RCS |
| | | rcsReturn.setCode("Err_Internal"); |
| | | rcsReturn.setMessage(""); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("robotTaskCode", robotTaskCode); |
| | | rcsReturn.setData(data); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | |
| | | String response = sendPost(url, JSONObject.toJSONString(rcsTaskContinue)); |
| | | if (!StringUtils.isEmpty(response) && response.contains("code")) { |
| | | RcsReturn rcsReturn1 = JSONObject.parseObject(response, RcsReturn.class); |
| | | if ("200".equals(rcsReturn1.getCode())) { |
| | | if ("SUCCESS".equals(rcsReturn1.getCode())) { |
| | | // 返回RCS |
| | | rcsReturn.setCode("SUCCESS"); |
| | | rcsReturn.setMessage(""); |
| | |
| | | transParent.setTaskname(task.getTaskNo()+"-"+(task.getCtnType()-1)); |
| | | transParent.setStationId(task.getStaNo()); |
| | | transParent.setAgvCode("2");//连接器库 |
| | | //08-1是空托盘转序任务 |
| | | //08-2是物料转序任务 |
| | | if (task.getTaskType().equals("ZX-AGV-08-1")) { |
| | | transParent.setTransType("08-1"); |
| | | } else if (task.getTaskType().equals("ZX-AGV-08-2")) { |
| | | transParent.setTransType("08-2"); |
| | | } else if (task.getTaskType().equals("PP-AGV")) { |
| | | transParent.setTransType("10"); |
| | | } else if (task.getTaskType().equals("ZP-AGV")) { |
| | | transParent.setTransType("11"); |
| | | } |
| | | int i = applyInStation(transParent); |
| | | if (i == 1) { |
| | | rcsReturn.setCode("SUCCESS"); |
| | |
| | | break; |
| | | //rcs取货完成,已退出输送线 |
| | | case PICK_COMPLETE: { |
| | | if (task.getSourceStaNo().equals("401") || task.getSourceStaNo().equals("402") || task.getSourceStaNo().equals("307")) { |
| | | Integer sourceStaNo = Integer.valueOf(task.getSourceStaNo()); |
| | | SiemensDevpThread siemensDevpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, 1); |
| | | StaProtocol staProtocol = siemensDevpThread.getStation().get(sourceStaNo).clone(); |
| | |
| | | } |
| | | |
| | | } |
| | | } else { |
| | | |
| | | TransParent transParent = new TransParent(); |
| | | transParent.setTaskno(task.getTaskNo() + "-" + (task.getCtnType() - 1)); |
| | | transParent.setTaskname(task.getTaskNo() + "-" + (task.getCtnType() - 1)); |
| | | transParent.setStationId(task.getStaNo()); |
| | | transParent.setAgvCode("2");//连接器库 |
| | | //08-1是空托盘转序任务 |
| | | //08-2是物料转序任务 |
| | | if (task.getTaskType().equals("ZX-AGV-08-1")) { |
| | | transParent.setTransType("08-1"); |
| | | } else if (task.getTaskType().equals("ZX-AGV-08-2")) { |
| | | transParent.setTransType("08-2"); |
| | | } else if (task.getTaskType().equals("PP-AGV")) { |
| | | transParent.setTransType("10"); |
| | | } else if (task.getTaskType().equals("ZP-AGV")) { |
| | | transParent.setTransType("11"); |
| | | } |
| | | //取货离开站点 |
| | | int i = AGVDepartureCompleted(transParent); |
| | | if (i == 1) { |
| | | // 更新任务状态等内部逻辑 |
| | | task.setWrkSts(304L); // 301 任务下发、302 任务执行、303 任务中断、304 任务结束 |
| | | task.setModiTime(new Date()); |
| | | agvTaskService.updateById(task); |
| | | rcsReturn.setCode("SUCCESS"); |
| | | rcsReturn.setMessage(""); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("robotTaskCode", robotTaskCode); |
| | | rcsReturn.setData(data); |
| | | } else { |
| | | // 返回RCS |
| | | rcsReturn.setCode("Err_Internal"); |
| | | rcsReturn.setMessage(""); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("robotTaskCode", robotTaskCode); |
| | | rcsReturn.setData(data); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | //AGV取货离站请求 |
| | |
| | | String response = sendPost(url, JSONObject.toJSONString(rcsTaskContinue)); |
| | | if (!StringUtils.isEmpty(response) && response.contains("code")) { |
| | | RcsReturn rcsReturn1 = JSONObject.parseObject(response, RcsReturn.class); |
| | | if ("200".equals(rcsReturn1.getCode())) { |
| | | if ("SUCCESS".equals(rcsReturn1.getCode())) { |
| | | // 返回RCS |
| | | rcsReturn.setCode("SUCCESS"); |
| | | rcsReturn.setMessage(""); |
| | |
| | | transParent.setTaskname(task.getTaskNo()+"-"+(task.getCtnType()-1)); |
| | | transParent.setStationId(task.getStaNo()); |
| | | transParent.setAgvCode("2");//连接器库 |
| | | //08-1是空托盘转序任务 |
| | | //08-2是物料转序任务 |
| | | if (task.getTaskType().equals("ZX-AGV-08-1")) { |
| | | transParent.setTransType("08-1"); |
| | | } else if (task.getTaskType().equals("ZX-AGV-08-2")) { |
| | | transParent.setTransType("08-2"); |
| | | } else if (task.getTaskType().equals("PP-AGV")) { |
| | | transParent.setTransType("10"); |
| | | } else if (task.getTaskType().equals("ZP-AGV")) { |
| | | transParent.setTransType("11"); |
| | | } |
| | | int i = applyOutStation(transParent); |
| | | if (i == 1) { |
| | | rcsReturn.setCode("SUCCESS"); |
| | |
| | | String response = sendPost(url, JSONObject.toJSONString(rcsTaskContinue)); |
| | | if (!StringUtils.isEmpty(response) && response.contains("code")) { |
| | | RcsReturn rcsReturn1 = JSONObject.parseObject(response, RcsReturn.class); |
| | | if ("200".equals(rcsReturn1.getCode())) { |
| | | if ("SUCCESS".equals(rcsReturn1.getCode())) { |
| | | // 返回RCS |
| | | rcsReturn.setCode("SUCCESS"); |
| | | rcsReturn.setMessage(""); |
| | |
| | | transParent.setTaskname(task.getTaskNo()+"-"+(task.getCtnType()-1)); |
| | | transParent.setStationId(task.getStaNo()); |
| | | transParent.setAgvCode("2");//连接器库 |
| | | //08-1是空托盘转序任务 |
| | | //08-2是物料转序任务 |
| | | if (task.getTaskType().equals("ZX-AGV-08-1")) { |
| | | transParent.setTransType("08-1"); |
| | | } else if (task.getTaskType().equals("ZX-AGV-08-2")) { |
| | | transParent.setTransType("08-2"); |
| | | } else if (task.getTaskType().equals("PP-AGV")) { |
| | | transParent.setTransType("10"); |
| | | } else if (task.getTaskType().equals("ZP-AGV")) { |
| | | transParent.setTransType("11"); |
| | | } |
| | | int i = applyOutStation(transParent); |
| | | if (i == 1) { |
| | | rcsReturn.setCode("SUCCESS"); |
| | |
| | | } |
| | | } |
| | | |
| | | break; |
| | | } |
| | | //到站完成 |
| | | case ARRIVE_ON_STATION: { |
| | | if (task.getStaNo().equals("401") || task.getStaNo().equals("402") || task.getStaNo().equals("307")) { |
| | | // 返回RCS |
| | | rcsReturn.setCode("SUCCESS"); |
| | | rcsReturn.setMessage(""); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("robotTaskCode", robotTaskCode); |
| | | rcsReturn.setData(data); |
| | | } else { |
| | | TransParent transParent = new TransParent(); |
| | | transParent.setTaskno(task.getTaskNo() + "-" + (task.getCtnType() - 1)); |
| | | transParent.setTaskname(task.getTaskNo() + "-" + (task.getCtnType() - 1)); |
| | | transParent.setStationId(task.getStaNo()); |
| | | transParent.setAgvCode("2");//连接器库 |
| | | //08-1是空托盘转序任务 |
| | | //08-2是物料转序任务 |
| | | if (task.getTaskType().equals("ZX-AGV-08-1")) { |
| | | transParent.setTransType("08-1"); |
| | | } else if (task.getTaskType().equals("ZX-AGV-08-2")) { |
| | | transParent.setTransType("08-2"); |
| | | } else if (task.getTaskType().equals("PP-AGV")) { |
| | | transParent.setTransType("10"); |
| | | } else if (task.getTaskType().equals("ZP-AGV")) { |
| | | transParent.setTransType("11"); |
| | | } |
| | | int i = AGVArrivalCompletedFit(transParent); |
| | | if (i == 1) { |
| | | rcsReturn.setCode("SUCCESS"); |
| | | rcsReturn.setMessage(""); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("robotTaskCode", robotTaskCode); |
| | | rcsReturn.setData(data); |
| | | } else { |
| | | // 返回RCS |
| | | rcsReturn.setCode("Err_Internal"); |
| | | rcsReturn.setMessage(""); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("robotTaskCode", robotTaskCode); |
| | | rcsReturn.setData(data); |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | |
| | |
| | | conn.setRequestProperty("X-lr-request-id", String.valueOf(new Date().getTime())); |
| | | conn.setRequestProperty("X-lr-version", "4.3"); |
| | | |
| | | conn.setConnectTimeout(5000); |
| | | conn.setReadTimeout(5000); |
| | | conn.setConnectTimeout(10000); |
| | | conn.setReadTimeout(10000); |
| | | conn.setDoOutput(true); |
| | | conn.setDoInput(true); |
| | | out = new PrintWriter(conn.getOutputStream()); |
| | |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | | * 离站完成:wms->mes |
| | | * AGV离开接驳位后发送离开状态给MES |
| | | * |
| | | * @param apply |
| | | * @return |
| | | */ |
| | | public int AGVDepartureCompleted(TransParent apply) { |
| | | |
| | | String url = MES_URL + "AGVDepartureCompleted"; |
| | | String response = RcsServiceImpl.sendPost(url, JSONObject.toJSONString(apply)); |
| | | if (!StringUtils.isEmpty(response) && response.contains("Success")) { |
| | | MesReturn mesReturn = JSONObject.parseObject(response, MesReturn.class); |
| | | if ("1".equals(mesReturn.getSuccess())) { |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | | * 到站完成:AGV到达工位里面--》mes到位完成 |
| | | * |
| | | * @param apply |
| | | * @return |
| | | */ |
| | | public int AGVArrivalCompletedFit(TransParent apply) { |
| | | |
| | | String url = MES_URL + "AGVArrivalCompletedFit"; |
| | | String response = RcsServiceImpl.sendPost(url, JSONObject.toJSONString(apply)); |
| | | if (!StringUtils.isEmpty(response) && response.contains("Success")) { |
| | | MesReturn mesReturn = JSONObject.parseObject(response, MesReturn.class); |
| | | if ("1".equals(mesReturn.getSuccess())) { |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | } |