| | |
| | | import com.zy.asrs.mapper.BlockStationMapper; |
| | | import com.zy.asrs.mapper.BlockTaskMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private String HX_URL; |
| | | @Value("${mes.defaultUserId}") |
| | | public long defaultUserId; |
| | | |
| | | // wcs地址 |
| | | @Value("${wcs.url}") |
| | | private String WCS_URL; |
| | | |
| | | |
| | | @Resource |
| | |
| | | String url = rcsFactory == 2 ? HX_URL : HIK_URL + "api/robot/controller/task/submit"; |
| | | String response = ""; |
| | | try { |
| | | // 模拟返回 |
| | | // rcsReturn.setCode("SUCCESS"); |
| | | // log.info("呼叫agv搬运成功!url:{};request:{};response:{}", url, JSON.toJSONString(rcsTaskSubmit), response); |
| | | // success = true; |
| | | |
| | | response = sendPost(url, JSONObject.toJSONString(rcsTaskSubmit)); |
| | | if (!StringUtils.isEmpty(response) && response.contains("code")) { |
| | | rcsReturn = JSONObject.parseObject(response, RcsReturn.class); |
| | | if ("SUCCESS".equals(rcsReturn.getCode())) { |
| | | // 模拟返回 |
| | | // rcsReturn.setCode("SUCCESS"); |
| | | // JSONObject jsonObject = new JSONObject(); |
| | | // jsonObject.put("robotTaskCode",4); |
| | | // rcsReturn.setData(jsonObject); |
| | | success = true; |
| | | |
| | | log.info("呼叫agv搬运成功!url:{};request:{};response:{}", url, JSON.toJSONString(rcsTaskSubmit), response); |
| | | } else { |
| | | log.error("呼叫agv搬运失败!url:{};request:{};response:{}", url, JSON.toJSONString(rcsTaskSubmit), response); |
| | |
| | | public int cancelTask(RcsTaskCancel rcsTaskCancel, int rcsFactory){ |
| | | |
| | | String url = rcsFactory == 2 ? HX_URL :HIK_URL + "api/robot/controller/task/cancel"; |
| | | String response = sendPost(url, rcsTaskCancel.toString()); |
| | | String response = sendPost(url, JSONObject.toJSONString(rcsTaskCancel)); |
| | | if (!StringUtils.isEmpty(response) && response.contains("code")){ |
| | | RcsReturn rcsReturn = JSONObject.parseObject(response, RcsReturn.class); |
| | | if("SUCCESS".equals(rcsReturn.getCode())) { |
| | |
| | | private int notifyEqpt(RcsEqptNotify rcsEqptNotify, int rcsFactory){ |
| | | |
| | | String url = rcsFactory == 2 ? HX_URL :HIK_URL + "api/wcs/robot/eqpt/notify"; |
| | | String response = sendPost(url, rcsEqptNotify.toString()); |
| | | String response = sendPost(url, JSONObject.toJSONString(rcsEqptNotify)); |
| | | if (!StringUtils.isEmpty(response) && response.contains("code")){ |
| | | RcsReturn rcsReturn = JSONObject.parseObject(response, RcsReturn.class); |
| | | if("SUCCESS".equals(rcsReturn.getCode())) { |
| | |
| | | task.setModiUser(defaultUserId); |
| | | taskService.updateById(task); |
| | | // 任务完成 |
| | | // mesService.reporterTask(rcsReporterTask); |
| | | mesService.reporterTask(rcsReporterTask); |
| | | |
| | | // 入立库时,区分是空托还是满托,给输送线下发命令9990 空,9995满 |
| | | String transType = memo.getString("TransType"); |
| | | if("02".equals(transType) || "04".equals(transType)) { |
| | | int wrkNo = 9995; |
| | | if("02".equals(transType)) { |
| | | TaskDetl taskDetl = taskDetlService.selectOne(new EntityWrapper<TaskDetl>().eq("wrk_no", task.getWrkNo())); |
| | | if (taskDetl != null) { |
| | | if("tuopan".equals(taskDetl.getMatnr())){ |
| | | wrkNo = 9990; |
| | | } |
| | | } |
| | | } |
| | | int staNo = Integer.parseInt(task.getStaNo()); |
| | | 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"); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(WCS_URL) |
| | | .setPath("/site/detl/update") |
| | | .setParams(params) |
| | | .build() |
| | | .doPost(); |
| | | log.info("agv反馈end给wcs发命令:{},返回:{}",JSONObject.toJSONString(params),response); |
| | | } |
| | | |
| | | // EntityWrapper<TaskDetl> wapper2 = new EntityWrapper<>(); |
| | | // wapper2.eq("wrk_no", task.getWrkNo()) |
| | |
| | | } |
| | | } break; |
| | | case ARRIVE_ON_STATION: { |
| | | // TODO: 如果产线是运输起点,则不发送到站完成,暂时调试使用lG,未实现判断 |
| | | // if (rcsReporterTask.getCurrentSeq() == 0 && task.getSourceStaNo().startsWith("LG") || task.getSourceStaNo().startsWith("LL")) { |
| | | // break; |
| | | // } |
| | | |
| | | EntityWrapper<TaskDetl> wapper2 = new EntityWrapper<>(); |
| | | wapper2.eq("wrk_no", task.getWrkNo()) |
| | | .eq("matnr", memo.getString("Itemno")) |