| | |
| | | import com.zy.asrs.entity.mes.TransParent; |
| | | import com.zy.asrs.entity.rcs.*; |
| | | import com.zy.asrs.enums.RcsRetMethodEnum; |
| | | import com.zy.asrs.mapper.BasDevpMapper; |
| | | import com.zy.asrs.mapper.BlockStationMapper; |
| | | import com.zy.asrs.mapper.BlockTaskMapper; |
| | | import com.zy.asrs.service.*; |
| | |
| | | return 0; |
| | | } |
| | | |
| | | @Resource |
| | | private BasDevpMapper basDevpMapper; |
| | | |
| | | /** |
| | | * 2.2.1任务执行回馈 |
| | | * 厂家:海量、华晓 |
| | |
| | | // JSONObject taskMemo = JSONObject.parseObject(task.getMemo()); |
| | | // mesService.outFeedbackByTuo(taskMemo.getString("OrderNo"), task); |
| | | } break; |
| | | case APPLY_PUT: { // 放货申请 |
| | | String staNo = task.getStaNo(); |
| | | BasDevp basDevp = basDevpMapper.selectById(staNo); |
| | | if(basDevp.getAutoing().equals("Y") && basDevp.getLoading().equals("N") && basDevp.getWrkNo() == 0) { |
| | | |
| | | // 205 触发条码扫描 |
| | | if (staNo.equals("205")) { |
| | | Map<String,Object> params = new HashMap<>(); |
| | | params.put("siteId",staNo); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(WCS_URL) |
| | | .setPath("/site/startScan") |
| | | .setParams(params) |
| | | .build() |
| | | .doPost(); |
| | | log.info("{}放货申请给wcs下发条码扫描原始返回:{}",staNo,response); |
| | | } |
| | | |
| | | // 满足放货条件,调用RCS任务继续执行 |
| | | RcsTaskContinue rcsTaskContinue = new RcsTaskContinue(); |
| | | rcsTaskContinue.setRobotTaskCode(robotTaskCode); |
| | | rcsTaskContinue.setTriggerType("TASK"); |
| | | rcsTaskContinue.setTriggerCode(robotTaskCode); |
| | | int success = continueTask(rcsTaskContinue, 1); |
| | | if(success != 1) { |
| | | rcsReturn.setCode("Err_RobotCodeNotMatch"); |
| | | rcsReturn.setMessage("继续执行失败"); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("robotTaskCode", robotTaskCode); |
| | | rcsReturn.setData(data); |
| | | return rcsReturn; |
| | | } |
| | | }else { |
| | | log.warn("站点:{},不满足放货条件,自动:{},无物:{},任务号:{}",staNo,basDevp.getAutoing(),basDevp.getLoading(),basDevp.getWrkNo()); |
| | | rcsReturn.setCode("Err_RobotCodeNotMatch"); |
| | | rcsReturn.setMessage("站点不满足放货条件"); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("robotTaskCode", robotTaskCode); |
| | | rcsReturn.setData(data); |
| | | return rcsReturn; |
| | | } |
| | | } break; |
| | | case APPLY_PICK: { // 取货申请 |
| | | String staNo = task.getSourceStaNo(); |
| | | BasDevp basDevp = basDevpMapper.selectById(staNo); |
| | | if(basDevp.getAutoing().equals("Y") && basDevp.getLoading().equals("Y") |
| | | && basDevp.getWrkNo() > 0 && basDevp.getWrkNo() <= 9990) { |
| | | // 满足放货条件,调用RCS任务继续执行 |
| | | RcsTaskContinue rcsTaskContinue = new RcsTaskContinue(); |
| | | rcsTaskContinue.setRobotTaskCode(robotTaskCode); |
| | | rcsTaskContinue.setTriggerType("TASK"); |
| | | rcsTaskContinue.setTriggerCode(robotTaskCode); |
| | | int success = continueTask(rcsTaskContinue, 1); |
| | | if(success != 1) { |
| | | rcsReturn.setCode("Err_RobotCodeNotMatch"); |
| | | rcsReturn.setMessage("继续执行失败"); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("robotTaskCode", robotTaskCode); |
| | | rcsReturn.setData(data); |
| | | return rcsReturn; |
| | | } |
| | | }else { |
| | | log.warn("站点:{},不满足取货条件,自动:{},无物:{},任务号:{}",staNo,basDevp.getAutoing(),basDevp.getLoading(),basDevp.getWrkNo()); |
| | | rcsReturn.setCode("Err_RobotCodeNotMatch"); |
| | | rcsReturn.setMessage("站点不满足放货条件"); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("robotTaskCode", robotTaskCode); |
| | | rcsReturn.setData(data); |
| | | return rcsReturn; |
| | | } |
| | | } break; |
| | | case PICK_COMPLETE: { // 取货完成 |
| | | String staNo = task.getSourceStaNo(); |
| | | |
| | | // 清除输送线任务号 |
| | | Map<String,Object> params = new HashMap<>(); |
| | | params.put("siteId",staNo); |
| | | params.put("workNo",0); |
| | | params.put("staNo", 0); |
| | | params.put("pakMk","Y"); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(WCS_URL) |
| | | .setPath("/site/detl/update") |
| | | .setParams(params) |
| | | .build() |
| | | .doPost(); |
| | | log.info("agv反馈pickComplete给wcs发命令:{},返回:{}",JSONObject.toJSONString(params),response); |
| | | // agv继续执行 |
| | | // TransInOutStationAllow inOutStationAllow = new TransInOutStationAllow(); |
| | | // inOutStationAllow.setTaskno(robotTaskCode); |
| | | // inOutStationAllow.setStatus("Y"); |
| | | // inOutStationAllow.setAgvCode("agv001"); |
| | | // mesService.allowOutStation(inOutStationAllow); |
| | | } break; |
| | | case TASK_END: { |
| | | // 更新任务状态等内部逻辑 |
| | | task.setWrkSts(304L); // 301 任务下发、302 任务执行、303 任务中断、304 任务结束 |
| | |
| | | task.setModiUser(defaultUserId); |
| | | taskService.updateById(task); |
| | | // 任务完成 |
| | | mesService.reporterTask(rcsReporterTask); |
| | | // mesService.reporterTask(rcsReporterTask); |
| | | |
| | | // 入立库时,区分是空托还是满托,给输送线下发命令9990 空,9995满 |
| | | // 侧面205 9996空,9997满 |
| | | String transType = memo.getString("TransType"); |
| | | if("02".equals(transType) || "04".equals(transType)) { |
| | | int wrkNo = 9995; |
| | |
| | | } |
| | | } |
| | | int staNo = Integer.parseInt(task.getStaNo()); |
| | | if(staNo == 205) { // 侧面任务号转换 |
| | | wrkNo = wrkNo == 9990 ? 9996 : 9997; |
| | | } |
| | | Map<String,Object> params = new HashMap<>(); |
| | | params.put("siteId",staNo); |
| | | params.put("workNo",wrkNo); |
| | | params.put("staNo", staNo == 205 ? 205 : (staNo-1) ); |
| | | params.put("String","Y"); |
| | | params.put("pakMk","Y"); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(WCS_URL) |
| | | .setPath("/site/detl/update") |
| | |
| | | mesService.outStation(apply); |
| | | // agv继续执行 |
| | | |
| | | TransInOutStationAllow inOutStationAllow = new TransInOutStationAllow(); |
| | | inOutStationAllow.setTaskno(robotTaskCode); |
| | | inOutStationAllow.setStatus("Y"); |
| | | inOutStationAllow.setAgvCode("agv001"); |
| | | mesService.allowOutStation(inOutStationAllow); |
| | | // TransInOutStationAllow inOutStationAllow = new TransInOutStationAllow(); |
| | | // inOutStationAllow.setTaskno(robotTaskCode); |
| | | // inOutStationAllow.setStatus("Y"); |
| | | // inOutStationAllow.setAgvCode("agv001"); |
| | | // mesService.allowOutStation(inOutStationAllow); |
| | | } |
| | | } break; |
| | | case ARRIVE_ON_STATION: { |
| | |
| | | TransArrivalStation arrivalStation = new TransArrivalStation(); |
| | | arrivalStation.setTaskno(robotTaskCode); |
| | | arrivalStation.setTaskname(memo.getString("taskName")); |
| | | arrivalStation.setTuoPanId(taskDetl == null ? "":taskDetl.getZpallet()); // memo.getString("TuoPanId") |
| | | arrivalStation.setTuoPanId(task.getBarcode()); // memo.getString("TuoPanId") |
| | | arrivalStation.setProductLineId(memo.getString("ProductLineId")); |
| | | String transType = memo.getString("TransType"); |
| | | arrivalStation.setDaotype(transType); |
| | |
| | | return result.toString(); |
| | | } |
| | | |
| | | @Override |
| | | public RcsReturn siteBind(SiteBind siteBind) { |
| | | RcsReturn rcsReturn = new RcsReturn(); |
| | | String url = HIK_URL + "api/robot/controller/site/bind"; |
| | | String response = sendPost(url, JSONObject.toJSONString(siteBind)); |
| | | if (!StringUtils.isEmpty(response) && response.contains("code")){ |
| | | rcsReturn = JSONObject.parseObject(response, RcsReturn.class); |
| | | } else { |
| | | rcsReturn.setCode("ERROR"); |
| | | rcsReturn.setMessage("调用绑定接口RCS无返回"); |
| | | } |
| | | return rcsReturn; |
| | | } |
| | | |
| | | // endregion |
| | | } |