| | |
| | | import com.alibaba.excel.util.StringUtils; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.mes.TransArrivalStation; |
| | | import com.zy.asrs.entity.mes.TransParent; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.*; |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | import java.io.PrintWriter; |
| | | import java.net.ConnectException; |
| | | import java.net.SocketTimeoutException; |
| | | import java.net.URL; |
| | |
| | | // 华晓RCS地址 |
| | | @Value("${hx.url}") |
| | | private String HX_URL; |
| | | // 华晓RCS地址 |
| | | @Value("${hx.taskNo}") |
| | | private String taskNo; |
| | | // 华晓RCS地址 |
| | | @Value("${hx.inOk}") |
| | | private String inOk; |
| | | @Value("${mes.defaultUserId}") |
| | | public long defaultUserId; |
| | | |
| | |
| | | private TaskDetlServiceImpl taskDetlService; |
| | | @Resource |
| | | private WrkMastService wrkMastService; |
| | | |
| | | @Resource |
| | | private ApiLogService apiLogService; |
| | | |
| | | |
| | | // region 封锁区逻辑,目前只有一个大封锁区,任务全部转到滑块库处理,或直接写到滑块库 |
| | |
| | | */ |
| | | public void managerBlock() { |
| | | |
| | | try { |
| | | BlockTask firstTask = blockTaskMapper.findTop(); |
| | | if (firstTask == null) { |
| | | return; |
| | | } |
| | | EntityWrapper<BlockStation> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("block_no", firstTask.getBlockNo()); |
| | | List<BlockStation> stations = blockStationMapper.selectList(wrapper); |
| | | if (!stations.isEmpty()) { |
| | | boolean locked = false; |
| | | for (BlockStation station : stations) { |
| | | // 只允许1个厂家设备进入封锁区,status状态:0 空闲;1 海康封锁中;2 华晓封锁中;-1 异常; |
| | | if (station.getStatus() > 0 && !station.getStatus().equals(firstTask.getAgvFactory())) { |
| | | locked = true; |
| | | break; |
| | | } |
| | | } |
| | | try { |
| | | BlockTask firstTask = blockTaskMapper.findTop(); |
| | | if (firstTask == null) { |
| | | return; |
| | | } |
| | | EntityWrapper<BlockStation> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("block_no", firstTask.getBlockNo()); |
| | | List<BlockStation> stations = blockStationMapper.selectList(wrapper); |
| | | if (!stations.isEmpty()) { |
| | | boolean locked = false; |
| | | for (BlockStation station : stations) { |
| | | // 只允许1个厂家设备进入封锁区,status状态:0 空闲;1 海康封锁中;2 华晓封锁中;-1 异常; |
| | | if (station.getStatus() > 0 && !station.getStatus().equals(firstTask.getAgvFactory())) { |
| | | locked = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (!locked) { |
| | | // 封锁状态 |
| | | int success = blockStationMapper.addByBlockNo(firstTask.getBlockNo(), firstTask.getAgvFactory()); |
| | | if (success > 0) { |
| | | // 通知RCS |
| | | RcsEqptNotify notify = new RcsEqptNotify(); |
| | | notify.setEqptCode(firstTask.getBlockNo()); |
| | | notify.setTaskCode(firstTask.getTaskCode()); |
| | | notify.setActionStatus("1"); |
| | | notifyEqpt(notify, firstTask.getAgvFactory()); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("管理封锁区异常", e); |
| | | } |
| | | if (!locked) { |
| | | // 封锁状态 |
| | | int success = blockStationMapper.addByBlockNo(firstTask.getBlockNo(), firstTask.getAgvFactory()); |
| | | if (success > 0) { |
| | | // 通知RCS |
| | | RcsEqptNotify notify = new RcsEqptNotify(); |
| | | notify.setEqptCode(firstTask.getBlockNo()); |
| | | notify.setTaskCode(firstTask.getTaskCode()); |
| | | notify.setActionStatus("1"); |
| | | notifyEqpt(notify, firstTask.getAgvFactory()); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("管理封锁区异常", e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public int submitTask(RcsTaskSubmit rcsTaskSubmit, int rcsFactory){ |
| | | |
| | | String url = rcsFactory == 2 ? HIK_URL : HX_URL + "api/robot/controller/task/submit"; |
| | | String response = sendPost(url, rcsTaskSubmit.toString()); |
| | | // String response = ""; |
| | | // boolean success = false; |
| | | // Map<String,Object> headers = new HashMap<>(); |
| | | // headers.put("Content-Type","application/json"); |
| | | // headers.put("Content-Length","<calculated when request is sent>"); |
| | | // headers.put("Host","<calculated when request is sent>"); |
| | | //// headers.put("Connection","keep-alive"); |
| | | //// headers.put("Accept","*/*"); |
| | | //// headers.put("Accept-Encoding","gzip, deflate, br"); |
| | | // headers.put("X-lr-request-id","123"); |
| | | // headers.put("X-lr-version","4.3"); |
| | | // try { |
| | | // response = new HttpHandler.Builder() |
| | | // .setUri(HIK_URL) |
| | | // .setPath("api/robot/controller/task/submit") |
| | | // .setHeaders(headers) |
| | | // .setJson(JSON.toJSONString(rcsTaskSubmit)) |
| | | // .build() |
| | | // .doPost(); |
| | | // JSONObject jsonObject = JSON.parseObject(response); |
| | | // if (jsonObject.getBoolean("success")) { |
| | | // success = true; |
| | | // } else { |
| | | // log.error("下发agv任务失败!url:{};request:{};response:{}", HIK_URL + "api/robot/controller/task/submit", JSON.toJSONString(rcsTaskSubmit), response); |
| | | // } |
| | | // } catch (Exception e) { |
| | | // log.error("下发agv任务异常", e); |
| | | // } finally { |
| | | // try { |
| | | // // 保存接口日志 |
| | | // apiLogService.save( |
| | | // "下发agv任务", |
| | | // HIK_URL + "api/robot/controller/task/submit", |
| | | // null, |
| | | // "127.0.0.1", |
| | | // JSON.toJSONString(rcsTaskSubmit), |
| | | // response, |
| | | // success |
| | | // ); |
| | | // } catch (Exception e) { |
| | | // log.error("下发agv任务保存接口日志异常", e); |
| | | // } |
| | | // } |
| | | // return success ? 1 : 0; |
| | | |
| | | String url = rcsFactory == 2 ? HX_URL+taskNo :HIK_URL + "api/robot/controller/task/submit"; |
| | | String response = sendPost(url, JSONObject.toJSONString(rcsTaskSubmit)); |
| | | |
| | | if (!StringUtils.isEmpty(response) && response.contains("code")){ |
| | | RcsReturn rcsReturn = JSONObject.parseObject(response, RcsReturn.class); |
| | | if("SUCCESS".equals(rcsReturn.getCode())) { |
| | | if("SUCCESS".equals(rcsReturn.getCode())||"200".equals(rcsReturn.getCode())) { |
| | | JSONObject data = rcsReturn.getData(); |
| | | String robotTaskCode = data.getString("robotTaskCode"); |
| | | if (robotTaskCode.equals(rcsTaskSubmit.getRobotTaskCode())){ |
| | |
| | | * @param rcsFactory |
| | | * @return |
| | | */ |
| | | public int continueTask(RcsTaskContinue rcsTaskContinue, int rcsFactory){ |
| | | public int continueTask(Object rcsTaskContinue, int rcsFactory){ |
| | | |
| | | String url = rcsFactory == 2 ? HIK_URL : HX_URL + "api/robot/controller/task/extend/continue"; |
| | | String response = sendPost(url, rcsTaskContinue.toString()); |
| | | String url = rcsFactory == 2 ? HX_URL+inOk :HIK_URL + "api/robot/controller/task/extend/continue"; |
| | | String response = sendPost(url, JSONObject.toJSONString(rcsTaskContinue)); |
| | | if (!StringUtils.isEmpty(response) && response.contains("code")){ |
| | | RcsReturn rcsReturn = JSONObject.parseObject(response, RcsReturn.class); |
| | | if("SUCCESS".equals(rcsReturn.getCode())) { |
| | | JSONObject data = rcsReturn.getData(); |
| | | String robotTaskCode = data.getString("robotTaskCode"); |
| | | if (robotTaskCode.equals(rcsTaskContinue.getRobotTaskCode())) { |
| | | return 1; |
| | | } |
| | | if("SUCCESS".equals(rcsReturn.getCode())||"200".equals(rcsReturn.getCode())) { |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | public int cancelTask(RcsTaskCancel rcsTaskCancel, int rcsFactory){ |
| | | |
| | | String url = rcsFactory == 2 ? HIK_URL : HX_URL + "api/robot/controller/task/cancel"; |
| | | String url = rcsFactory == 2 ? HX_URL :HIK_URL + "api/robot/controller/task/cancel"; |
| | | String response = sendPost(url, rcsTaskCancel.toString()); |
| | | if (!StringUtils.isEmpty(response) && response.contains("code")){ |
| | | RcsReturn rcsReturn = JSONObject.parseObject(response, RcsReturn.class); |
| | |
| | | */ |
| | | private int notifyEqpt(RcsEqptNotify rcsEqptNotify, int rcsFactory){ |
| | | |
| | | String url = rcsFactory == 2 ? HIK_URL : HX_URL + "api/wcs/robot/eqpt/notify"; |
| | | String url = rcsFactory == 2 ? HX_URL :HIK_URL + "api/wcs/robot/eqpt/notify"; |
| | | String response = sendPost(url, rcsEqptNotify.toString()); |
| | | if (!StringUtils.isEmpty(response) && response.contains("code")){ |
| | | RcsReturn rcsReturn = JSONObject.parseObject(response, RcsReturn.class); |
| | |
| | | |
| | | String robotTaskCode = rcsReporterTask.getRobotTaskCode(); |
| | | String singleRobotCode = rcsReporterTask.getSingleRobotCode(); |
| | | JSONObject values = rcsReporterTask.getExtra().getJSONObject("values"); |
| | | // start : 任务开始;outbin : 走出储位;end : 任务完成 |
| | | String method = values.getString("method"); |
| | | String carrierType = values.getString("carrierType"); |
| | | String slotCategory = values.getString("slotCategory"); |
| | | String slotCode = values.getString("slotCode"); |
| | | |
| | | try { |
| | | if ("Q3".equals(carrierType) || "Q8".equals(carrierType)) { //AGV |
| | | String[] split = robotTaskCode.split("-"); |
| | | robotTaskCode = split[0]; |
| | | //华晓AGV状态反馈,及申请 |
| | | if(Cools.isEmpty(rcsReporterTask.getExtra())){ |
| | | if(Cools.isEmpty(rcsReporterTask.getMethod())){ |
| | | log.error("华晓AGV上报状态Method为空!"); |
| | | rcsReturn.setCode("Err_Internal"); |
| | | rcsReturn.setMessage("华晓AGV上报状态Method为空"); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("robotTaskCode", robotTaskCode); |
| | | rcsReturn.setData(data); |
| | | }else { |
| | | EntityWrapper<Task> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("task_no", robotTaskCode); |
| | | Task task = taskService.selectOne(wrapper); |
| | | if (task == null || !task.getTaskNo().equals(robotTaskCode)) { |
| | | rcsReturn.setCode("Err_RobotCodeNotMatch"); |
| | | rcsReturn.setMessage(""); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("robotTaskCode", robotTaskCode); |
| | | rcsReturn.setData(data); |
| | | return rcsReturn; |
| | | } |
| | | JSONObject memo = JSONObject.parseObject(task.getMemo()); |
| | | |
| | | switch (Objects.requireNonNull(RcsRetMethodEnum.getEnum(method))) { |
| | | case TASK_START: { |
| | | String method = rcsReporterTask.getMethod(); |
| | | JSONObject memo = Cools.isEmpty(task) ? null : JSONObject.parseObject(task.getMemo()); |
| | | switch (method) { |
| | | case "TASK_START": { |
| | | task.setWrkSts(302L); // 301 任务下发、302 任务执行、303 任务中断、304 任务结束 |
| | | task.setModiTime(new Date()); |
| | | task.setModiUser(defaultUserId); |
| | | taskService.updateById(task); |
| | | } break; |
| | | case TASK_OUT_BIN: { |
| | | case "TASK_OUT_BIN": { |
| | | // TODO:立库出库一托,AGV开始运输后,给MES发送出库完成(一托发一次) |
| | | JSONObject taskMemo = JSONObject.parseObject(task.getMemo()); |
| | | mesService.outFeedbackByTuo(taskMemo.getString("OrderNo"), task); |
| | | // JSONObject taskMemo = JSONObject.parseObject(task.getMemo()); |
| | | // mesService.outFeedbackByTuo(taskMemo.getString("OrderNo"), task); |
| | | } break; |
| | | case TASK_END: { |
| | | case "TASK_END": { |
| | | if(Cools.isEmpty(task)){ |
| | | rcsReturn.setCode("Err_RobotCodeNotMatch"); |
| | | rcsReturn.setMessage(""); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("robotTaskCode", robotTaskCode); |
| | | rcsReturn.setData(data); |
| | | return rcsReturn; |
| | | } |
| | | // 更新任务状态等内部逻辑 |
| | | task.setWrkSts(304L); // 301 任务下发、302 任务执行、303 任务中断、304 任务结束 |
| | | task.setModiTime(new Date()); |
| | | task.setModiUser(defaultUserId); |
| | | taskService.updateById(task); |
| | | // 任务完成 |
| | | // mesService.reporterTask(rcsReporterTask); |
| | | |
| | | // EntityWrapper<TaskDetl> wapper2 = new EntityWrapper<>(); |
| | | // wapper2.eq("wrk_no", task.getWrkNo()) |
| | | // .eq("matnr", memo.getString("ItemNo")) |
| | | // .eq("order_no", memo.getString("OrderNo")); |
| | | // TaskDetl taskDetl = taskDetlService.selectOne(wapper2); |
| | | // taskDetl.setAnfme() |
| | | // taskDetlService.updateById(); |
| | | |
| | | // // 301 任务下发、302 任务执行、303 任务中断、304 任务结束 |
| | | // taskService.completeWrkMast(); |
| | | // taskDetlService. |
| | | |
| | | } break; |
| | | case APPLY_IN_STATION: |
| | | case APPLY_OFF_STATION: |
| | | case ARRIVE_OFF_STATION: { |
| | | case "APPLY_IN_STATION": |
| | | case "APPLY_OFF_STATION": |
| | | case "ARRIVE_OFF_STATION": { |
| | | TransParent apply = new TransParent(); |
| | | apply.setTaskno(robotTaskCode); |
| | | apply.setTaskname(memo.getString("taskName")); |
| | |
| | | String transType = memo.getString("TransType"); |
| | | apply.setTransType(transType); |
| | | apply.setProductLineId(memo.getString("ProductLineId")); |
| | | if(transType.equals("02") || transType.equals("04") || transType.equals("06")) { |
| | | apply.setStationId(task.getSourceStaNo()); |
| | | } else { |
| | | apply.setStationId(task.getStaNo()); |
| | | } |
| | | |
| | | if (RcsRetMethodEnum.APPLY_IN_STATION.getCode().equals(method)) { |
| | | apply.setStationId(task.getSourceStaNo()); |
| | | //agv入站申请 |
| | | if ("APPLY_IN_STATION".equals(method)) { |
| | | mesService.applyInStation(apply); |
| | | } else if (RcsRetMethodEnum.APPLY_OFF_STATION.getCode().equals(method)) { |
| | | //agv离站请求 |
| | | } else if ("APPLY_OFF_STATION".equals(method)) { |
| | | mesService.applyOutStation(apply); |
| | | } else if (RcsRetMethodEnum.ARRIVE_OFF_STATION.getCode().equals(method)) { |
| | | //agv离站完成 |
| | | } else { |
| | | mesService.outStation(apply); |
| | | } |
| | | } break; |
| | | case ARRIVE_ON_STATION: { |
| | | case "ARRIVE_ON_STATION": { |
| | | // TODO: 如果产线是运输起点,则不发送到站完成,暂时调试使用lG,未实现判断 |
| | | if (rcsReporterTask.getCurrentSeq() == 0 && task.getSourceStaNo().startsWith("LG")) { |
| | | break; |
| | |
| | | } break; |
| | | default: {} break; |
| | | } |
| | | } else if ("CTU".equals(carrierType)) { //CTU |
| | | EntityWrapper<WrkMast> wrapper = new EntityWrapper<>(); |
| | | } |
| | | // 返回RCS |
| | | rcsReturn.setCode("SUCCESS"); |
| | | rcsReturn.setMessage(""); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("robotTaskCode", robotTaskCode); |
| | | rcsReturn.setData(data); |
| | | //海康AGV状态反馈,及申请 |
| | | }else { |
| | | JSONObject values = rcsReporterTask.getExtra().getJSONObject("values"); |
| | | // start : 任务开始;outbin : 走出储位;end : 任务完成 |
| | | String method = values.getString("method"); |
| | | String carrierType = values.getString("carrierType"); |
| | | String slotCategory = values.getString("slotCategory"); |
| | | String slotCode = values.getString("slotCode"); |
| | | try { |
| | | // q3,q8=1 |
| | | |
| | | EntityWrapper<Task> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("task_no", robotTaskCode); |
| | | WrkMast task = wrkMastService.selectOne(wrapper); |
| | | Task task = taskService.selectOne(wrapper); |
| | | if (task == null || !task.getTaskNo().equals(robotTaskCode)) { |
| | | rcsReturn.setCode("Err_RobotCodeNotMatch"); |
| | | rcsReturn.setMessage(""); |
| | |
| | | rcsReturn.setData(data); |
| | | return rcsReturn; |
| | | } |
| | | // JSONObject memo = JSONObject.parseObject(task.getMemo()); |
| | | JSONObject memo = JSONObject.parseObject(task.getMemo()); |
| | | |
| | | switch (Objects.requireNonNull(RcsRetMethodEnum.getEnum(method))) { |
| | | case TASK_START: { |
| | | // task.setWrkSts(302L); // 301 任务下发、302 任务执行、303 任务中断、304 任务结束 |
| | | // task.setModiTime(new Date()); |
| | | // task.setModiUser(defaultUserId); |
| | | // taskService.updateById(task); |
| | | } break; |
| | | // case TASK_OUT_BIN: {} break; |
| | | case TASK_END: { |
| | | // 更新任务状态等内部逻辑 |
| | | long wrkSts = task.getWrkSts(); // 1.入库;101.出库; |
| | | if (task.getIoType() == 1) { |
| | | wrkSts = 4L; |
| | | } else if (task.getIoType() == 101) { |
| | | wrkSts = 14L; |
| | | } |
| | | |
| | | task.setWrkSts(wrkSts); // 4.入库完成;14.已出库未确认; |
| | | task.setWrkSts(302L); // 301 任务下发、302 任务执行、303 任务中断、304 任务结束 |
| | | task.setModiTime(new Date()); |
| | | task.setModiUser(defaultUserId); |
| | | wrkMastService.updateById(task); |
| | | taskService.updateById(task); |
| | | } |
| | | break; |
| | | case TASK_OUT_BIN: { |
| | | // TODO:立库出库一托,AGV开始运输后,给MES发送出库完成(一托发一次) |
| | | // JSONObject taskMemo = JSONObject.parseObject(task.getMemo()); |
| | | // mesService.outFeedbackByTuo(taskMemo.getString("OrderNo"), task); |
| | | } |
| | | break; |
| | | case TASK_END: { |
| | | // 更新任务状态等内部逻辑 |
| | | task.setWrkSts(304L); // 301 任务下发、302 任务执行、303 任务中断、304 任务结束 |
| | | task.setModiTime(new Date()); |
| | | task.setModiUser(defaultUserId); |
| | | taskService.updateById(task); |
| | | // 任务完成 |
| | | // mesService.reporterTask(rcsReporterTask); |
| | | |
| | | // TODO:任务完成触发出入库变更操作 |
| | | // EntityWrapper<TaskDetl> wapper2 = new EntityWrapper<>(); |
| | | // wapper2.eq("wrk_no", task.getWrkNo()) |
| | | // .eq("matnr", memo.getString("ItemNo")) |
| | | // .eq("order_no", memo.getString("OrderNo")); |
| | | // TaskDetl taskDetl = taskDetlService.selectOne(wapper2); |
| | | // taskDetl.setAnfme() |
| | | // taskDetlService.updateById(); |
| | | |
| | | // // 301 任务下发、302 任务执行、303 任务中断、304 任务结束 |
| | | // taskService.completeWrkMast(); |
| | | // taskDetlService. |
| | | |
| | | // // 入库完成 |
| | | // mesService.inFeedback(memo.getString("OrderNo")); |
| | | // // 出库完成 |
| | | // mesService.outFeedback(memo.getString("OrderNo")); |
| | | } break; |
| | | default: {} break; |
| | | } |
| | | break; |
| | | case APPLY_IN_STATION: |
| | | case APPLY_OFF_STATION: |
| | | case ARRIVE_OFF_STATION: { |
| | | TransParent apply = new TransParent(); |
| | | apply.setTaskno(robotTaskCode); |
| | | apply.setTaskname(memo.getString("taskName")); |
| | | apply.setAgvCode(singleRobotCode); |
| | | String transType = memo.getString("TransType"); |
| | | apply.setTransType(transType); |
| | | apply.setProductLineId(memo.getString("ProductLineId")); |
| | | if (transType.equals("02") || transType.equals("04") || transType.equals("06")) { |
| | | apply.setStationId(task.getSourceStaNo()); |
| | | } else { |
| | | apply.setStationId(task.getStaNo()); |
| | | } |
| | | |
| | | if (RcsRetMethodEnum.APPLY_IN_STATION.getCode().equals(method)) { |
| | | mesService.applyInStation(apply); |
| | | } else if (RcsRetMethodEnum.APPLY_OFF_STATION.getCode().equals(method)) { |
| | | mesService.applyOutStation(apply); |
| | | } else if (RcsRetMethodEnum.ARRIVE_OFF_STATION.getCode().equals(method)) { |
| | | mesService.outStation(apply); |
| | | } |
| | | } |
| | | break; |
| | | case ARRIVE_ON_STATION: { |
| | | // TODO: 如果产线是运输起点,则不发送到站完成,暂时调试使用lG,未实现判断 |
| | | if (rcsReporterTask.getCurrentSeq() == 0 && task.getSourceStaNo().startsWith("LG")) { |
| | | break; |
| | | } |
| | | |
| | | EntityWrapper<TaskDetl> wapper2 = new EntityWrapper<>(); |
| | | wapper2.eq("wrk_no", task.getWrkNo()) |
| | | .eq("matnr", memo.getString("Itemno")) |
| | | .eq("order_no", memo.getString("OrderNo")); |
| | | TaskDetl taskDetl = taskDetlService.selectOne(wapper2); |
| | | TransArrivalStation arrivalStation = new TransArrivalStation(); |
| | | arrivalStation.setTaskno(robotTaskCode); |
| | | arrivalStation.setTaskname(memo.getString("taskName")); |
| | | arrivalStation.setTuoPanId(taskDetl.getZpallet()); // memo.getString("TuoPanId") |
| | | arrivalStation.setProductLineId(memo.getString("ProductLineId")); |
| | | String transType = memo.getString("TransType"); |
| | | arrivalStation.setDaotype(transType); |
| | | if (transType.equals("02") || transType.equals("04") || transType.equals("06")) { |
| | | arrivalStation.setStationID(task.getSourceStaNo()); |
| | | } else { |
| | | arrivalStation.setStationID(task.getStaNo()); |
| | | } |
| | | arrivalStation.setOrderNo(memo.getString("OrderNo")); |
| | | arrivalStation.setAgvCode(singleRobotCode); |
| | | arrivalStation.setItemno(memo.getString("Itemno")); |
| | | String memo2 = taskDetl.getMemo(); |
| | | List<String> itemBarCode = new ArrayList<>(); |
| | | Matcher matcher = Pattern.compile("\"([^\"]*)\"").matcher(memo2); |
| | | while (matcher.find()) { |
| | | itemBarCode.add(matcher.group(1)); |
| | | } |
| | | arrivalStation.setItemBarcode(itemBarCode); |
| | | mesService.arriveOnStation(arrivalStation); |
| | | } |
| | | break; |
| | | default: { |
| | | } |
| | | break; |
| | | } |
| | | |
| | | // 返回RCS |
| | | rcsReturn.setCode("SUCCESS"); |
| | | rcsReturn.setMessage(""); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("robotTaskCode", robotTaskCode); |
| | | rcsReturn.setData(data); |
| | | } catch (Exception e) { |
| | | log.error("RCS反馈任务进度处理异常 - {}", rcsReporterTask, e); |
| | | rcsReturn.setCode("Err_Internal"); |
| | | rcsReturn.setMessage("内部处理异常"); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("robotTaskCode", robotTaskCode); |
| | | rcsReturn.setData(data); |
| | | } |
| | | |
| | | // 返回RCS |
| | | rcsReturn.setCode("SUCCESS"); |
| | | rcsReturn.setMessage(""); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("robotTaskCode", robotTaskCode); |
| | | rcsReturn.setData(data); |
| | | } catch (Exception e) { |
| | | log.error("RCS反馈任务进度处理异常 - {}", rcsReporterTask, e); |
| | | rcsReturn.setCode("Err_Internal"); |
| | | rcsReturn.setMessage("内部处理异常"); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("robotTaskCode", robotTaskCode); |
| | | rcsReturn.setData(data); |
| | | } |
| | | |
| | | return rcsReturn; |
| | |
| | | * @param apply |
| | | * @return |
| | | */ |
| | | public JSONObject hxApplyInLine(TransParent apply) { |
| | | public RcsReturn hxApplyInLine(TransParent apply) { |
| | | |
| | | String status = mesService.applyInLine(apply); |
| | | JSONObject result = new JSONObject(); |
| | | result.put("Success", 1); |
| | | result.put("Message", status); |
| | | RcsReturn rcsReturn = new RcsReturn(); |
| | | |
| | | String robotTaskCode = apply.getTaskno(); |
| | | String singleRobotCode = apply.getAgvCode(); |
| | | //华晓AGV申请 |
| | | if(Cools.isEmpty(apply.getMethod())){ |
| | | log.error("华晓AGV上报状态Method为空!"); |
| | | rcsReturn.setCode("Err_Internal"); |
| | | rcsReturn.setMessage("华晓AGV上报状态Method为空"); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("robotTaskCode", robotTaskCode); |
| | | rcsReturn.setData(data); |
| | | }else { |
| | | EntityWrapper<Task> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("task_no", robotTaskCode); |
| | | Task task = taskService.selectOne(wrapper); |
| | | String method = apply.getMethod(); |
| | | JSONObject memo = Cools.isEmpty(task) ? null : JSONObject.parseObject(task.getMemo()); |
| | | switch (method) { |
| | | case "APPLY_IN_STATION": |
| | | case "APPLY_OFF_STATION": |
| | | case "ARRIVE_OFF_STATION": { |
| | | //agv入站申请 |
| | | if ("APPLY_IN_STATION".equals(method)) { |
| | | mesService.applyInStation(apply); |
| | | //agv离站请求 |
| | | } else if ("APPLY_OFF_STATION".equals(method)) { |
| | | mesService.applyOutStation(apply); |
| | | //agv离站完成 |
| | | } else { |
| | | mesService.outStation(apply); |
| | | } |
| | | } break; |
| | | default: {} break; |
| | | } |
| | | } |
| | | // 返回RCS |
| | | rcsReturn.setCode("SUCCESS"); |
| | | rcsReturn.setMessage(""); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("status", status); |
| | | result.put("Data", data); |
| | | data.put("robotTaskCode", robotTaskCode); |
| | | rcsReturn.setData(data); |
| | | //海康AGV状态反馈,及申请 |
| | | |
| | | return result; |
| | | return rcsReturn; |
| | | } |
| | | |
| | | // endregion |
| | |
| | | log.info("sendPost - {} - {}", url, param); |
| | | URL realUrl = new URL(url); |
| | | URLConnection conn = realUrl.openConnection(); |
| | | conn.setRequestProperty("accept", "*/*"); |
| | | conn.setRequestProperty("connection", "Keep-Alive"); |
| | | conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); |
| | | conn.setRequestProperty("Accept-Charset", "utf-8"); |
| | | conn.setRequestProperty("Content-Type", "application/json;charset=utf-8"); |
| | | conn.setRequestProperty("Content-Type", "application/json"); |
| | | conn.setRequestProperty("Content-Length", "<calculated when request is sent>"); |
| | | conn.setRequestProperty("Host", "<calculated when request is sent>"); |
| | | conn.setRequestProperty("Accept", "*/*"); |
| | | conn.setRequestProperty("Accept-Encoding", "gzip, deflate, br"); |
| | | conn.setRequestProperty("Connection", "keep-alive"); |
| | | |
| | | 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.setDoOutput(true); |
| | |
| | | { |
| | | result.append(line); |
| | | } |
| | | log.info("recv - {}", result); |
| | | log.info("rec - {}", result); |
| | | } |
| | | catch (ConnectException e) |
| | | { |