| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.alibaba.excel.util.StringUtils; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.mes.TransArrivalStation; |
| | | import com.zy.asrs.entity.mes.TransInOutStationAllow; |
| | | import com.zy.asrs.entity.mes.TransParent; |
| | | import com.zy.asrs.entity.rcs.*; |
| | | import com.zy.asrs.enums.RcsRetMethodEnum; |
| | |
| | | import java.net.URL; |
| | | import java.net.URLConnection; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | |
| | | @Resource |
| | | private BlockTaskMapper blockTaskMapper; |
| | | @Resource |
| | | private TaskDetlServiceImpl taskDetlService; |
| | | private TaskDetlService taskDetlService; |
| | | @Resource |
| | | private WrkMastService wrkMastService; |
| | | |
| | |
| | | * @param rcsFactory 1 海康;2 华晓; |
| | | * @return |
| | | */ |
| | | public int submitTask(RcsTaskSubmit rcsTaskSubmit, int rcsFactory){ |
| | | public RcsReturn submitTask(RcsTaskSubmit rcsTaskSubmit, int rcsFactory){ |
| | | |
| | | // String response = ""; |
| | | // boolean success = false; |
| | |
| | | // } |
| | | // } |
| | | // return success ? 1 : 0; |
| | | RcsReturn rcsReturn = new RcsReturn(); |
| | | boolean success = false; |
| | | String url = rcsFactory == 2 ? HX_URL : HIK_URL + "api/robot/controller/task/submit"; |
| | | String response = ""; |
| | | try { |
| | | 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; |
| | | |
| | | String url = rcsFactory == 2 ? HX_URL :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())) { |
| | | JSONObject data = rcsReturn.getData(); |
| | | String robotTaskCode = data.getString("robotTaskCode"); |
| | | if (robotTaskCode.equals(rcsTaskSubmit.getRobotTaskCode())){ |
| | | return 1; |
| | | log.info("呼叫agv搬运成功!url:{};request:{};response:{}", url, JSON.toJSONString(rcsTaskSubmit), response); |
| | | } else { |
| | | log.error("呼叫agv搬运失败!url:{};request:{};response:{}", url, JSON.toJSONString(rcsTaskSubmit), response); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("呼叫agv搬运异常", e); |
| | | } finally { |
| | | try { |
| | | // 保存接口日志 |
| | | apiLogService.save( |
| | | "呼叫agv搬运", |
| | | url, |
| | | null, |
| | | "127.0.0.1", |
| | | JSON.toJSONString(rcsTaskSubmit), |
| | | response, |
| | | success |
| | | ); |
| | | } catch (Exception e) { |
| | | log.error("呼叫agv搬运保存接口日志异常", e); |
| | | } |
| | | } |
| | | |
| | | return 0; |
| | | return rcsReturn; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | try { |
| | | // q3,q8=1 |
| | | if ("1".equals(carrierType)) { //AGV |
| | | // if ("1".equals(carrierType)) { //AGV |
| | | EntityWrapper<Task> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("task_no", robotTaskCode); |
| | | Task task = taskService.selectOne(wrapper); |
| | |
| | | mesService.applyOutStation(apply); |
| | | } else if (RcsRetMethodEnum.ARRIVE_OFF_STATION.getCode().equals(method)) { |
| | | mesService.outStation(apply); |
| | | // agv继续执行 |
| | | |
| | | TransInOutStationAllow inOutStationAllow = new TransInOutStationAllow(); |
| | | inOutStationAllow.setTaskno(robotTaskCode); |
| | | inOutStationAllow.setStatus("Y"); |
| | | inOutStationAllow.setAgvCode("agv001"); |
| | | mesService.allowOutStation(inOutStationAllow); |
| | | } |
| | | } break; |
| | | case ARRIVE_ON_STATION: { |
| | | // TODO: 如果产线是运输起点,则不发送到站完成,暂时调试使用lG,未实现判断 |
| | | if (rcsReporterTask.getCurrentSeq() == 0 && task.getSourceStaNo().startsWith("LG")) { |
| | | break; |
| | | } |
| | | // if (rcsReporterTask.getCurrentSeq() == 0 && task.getSourceStaNo().startsWith("LG") || task.getSourceStaNo().startsWith("LL")) { |
| | | // break; |
| | | // } |
| | | |
| | | EntityWrapper<TaskDetl> wapper2 = new EntityWrapper<>(); |
| | | wapper2.eq("wrk_no", task.getWrkNo()) |
| | |
| | | TransArrivalStation arrivalStation = new TransArrivalStation(); |
| | | arrivalStation.setTaskno(robotTaskCode); |
| | | arrivalStation.setTaskname(memo.getString("taskName")); |
| | | arrivalStation.setTuoPanId(taskDetl.getZpallet()); // memo.getString("TuoPanId") |
| | | arrivalStation.setTuoPanId(taskDetl == null ? "":taskDetl.getZpallet()); // memo.getString("TuoPanId") |
| | | arrivalStation.setProductLineId(memo.getString("ProductLineId")); |
| | | String transType = memo.getString("TransType"); |
| | | arrivalStation.setDaotype(transType); |
| | |
| | | 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); |
| | | String memo2 = taskDetl == null ? "":taskDetl.getMemo(); |
| | | String[] array = memo2.split(","); |
| | | // List<String> itemBarCode = new ArrayList<>(); |
| | | // Matcher matcher = Pattern.compile("\"([^\"]*)\"").matcher(memo2); |
| | | // while (matcher.find()) { |
| | | // itemBarCode.add(matcher.group(1)); |
| | | // } |
| | | arrivalStation.setItemBarcode(Arrays.asList(array)); |
| | | mesService.arriveOnStation(arrivalStation); |
| | | } break; |
| | | default: {} break; |
| | | } |
| | | } |
| | | // } |
| | | // else if ("CTU".equals(carrierType)) { //CTU |
| | | // EntityWrapper<WrkMast> wrapper = new EntityWrapper<>(); |
| | | // wrapper.eq("task_no", robotTaskCode); |