| | |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.domain.enums.TaskStatusType; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.web.BaseController; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | @Autowired |
| | | private BasCrnErrorService basCrnErrorService; |
| | | |
| | | @Value("${agv.url}") |
| | | private String agvUrl; |
| | | @Value("${agv.bindPodAndBerth}") |
| | | private String bindPodAndBerth; |
| | | |
| | | private static final boolean auth = true; |
| | | |
| | | public static final ArrayList<String> APP_KEY_LIST = new ArrayList<String>() {{ |
| | | add("ea1f0459efc02a79f046f982767939ae"); |
| | | }}; |
| | | |
| | | //agv上报 |
| | | //AGV上报 |
| | | @PostMapping("/agvReport") |
| | | public R agvReport(@RequestBody HashMap<String, Object> param) { |
| | | String taskCode = param.get("taskCode").toString(); |
| | | System.out.println(JSON.toJSONString(param)); |
| | | |
| | | TaskWrk taskWrk = taskWrkService.selectByTaskNo(taskCode); |
| | | if(taskWrk == null) { |
| | | return R.error("任务不存在"); |
| | | } |
| | | |
| | | if (taskWrk.getTargetPoint().equals("0900601")) { |
| | | HashMap<String, Object> requestParam = new HashMap<>(); |
| | | |
| | | int nextInt = new Random().nextInt(100); |
| | | requestParam.put("reqCode", taskWrk.getTaskNo() + "-" + nextInt); |
| | | requestParam.put("podCode", param.get("podCode")); |
| | | requestParam.put("positionCode", taskWrk.getTargetPoint()); |
| | | requestParam.put("indBind", 0); |
| | | |
| | | String response = null; |
| | | boolean requestStatus = false; |
| | | try { |
| | | log.info("WCS解绑AGV货架={}", taskWrk); |
| | | response = new HttpHandler.Builder() |
| | | .setUri(agvUrl) |
| | | .setPath(bindPodAndBerth) |
| | | .setJson(JSON.toJSONString(requestParam)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.get("code").equals("0")) { |
| | | requestStatus = true; |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("WCS派发任务给AGV失败{},返回值={}", taskWrk, response); |
| | | } finally { |
| | | apiLogService.save("WCS派发任务给AGV" |
| | | , agvUrl + bindPodAndBerth |
| | | , null |
| | | , "127.0.0.1" |
| | | , JSON.toJSONString(requestParam) |
| | | , response |
| | | , requestStatus |
| | | ); |
| | | } |
| | | } |
| | | |
| | | taskWrk.setStatus(TaskStatusType.COMPLETE.id); |
| | | taskWrk.setModiTime(new Date()); |
| | | taskWrk.setBarcode(param.get("podCode").toString()); |
| | | taskWrkService.updateById(taskWrk); |
| | | return R.ok(); |
| | | } |
| | | |
| | | //生成AGV任务 |
| | | @PostMapping("/generateAgvTask") |
| | | public R generateAgvTask(@RequestBody GenerateAgvTaskParam param) { |
| | | boolean generated = openService.generateAgvTask(param); |
| | | if(generated) { |
| | | return R.ok(); |
| | | } |
| | | return R.error(); |
| | | } |
| | | |
| | | //创建任务 |
| | | @PostMapping("/taskCreate") |
| | | @Transactional |