diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/task/rest/TaskController.java b/hd/nladmin-system/src/main/java/org/nl/acs/task/rest/TaskController.java index 4fb486b..9b83a18 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/task/rest/TaskController.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/task/rest/TaskController.java @@ -166,4 +166,12 @@ public class TaskController { String s = acsToWmsService.applyTaskToWms(device_code, container_code, height, weight); return new ResponseEntity<>(s, HttpStatus.CREATED); } + + @Log("请求充电任务") + @ApiOperation("请求充电任务") + @PostMapping("/chargingTask") + //@PreAuthorize("@el.check('task:add')") + public ResponseEntity chargingQuest(@RequestBody String agv_code) { + return new ResponseEntity<>(taskService.chargingQuest(agv_code), HttpStatus.OK); + } } diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java b/hd/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java index cb20fd5..0c70968 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java @@ -1,6 +1,7 @@ package org.nl.acs.task.service; +import cn.hutool.http.HttpResponse; import net.sf.json.JSONObject; import org.nl.acs.task.service.dto.TaskDto; import org.springframework.data.domain.Pageable; @@ -269,4 +270,5 @@ public interface TaskService { */ Integer querySameOriginTask(String code); + HttpResponse chargingQuest(String agv_code); } diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index 949e14c..3e8e775 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -7,6 +7,7 @@ import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSON; import lombok.RequiredArgsConstructor; @@ -1627,4 +1628,46 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { return num; } + @Override + public HttpResponse chargingQuest(String agvCode) { + String inst_no = CodeUtil.getNewCode("INSTRUCT_NO"); + if (StrUtil.isEmpty(agvCode)){ + throw new BadRequestException("agv编码为空!"); + } + JSONArray ja = new JSONArray(); + JSONObject orderjo = new JSONObject(); + //指定agv车号 + orderjo.put("intendedVehicle", agvCode); + JSONObject jo = new JSONObject(); + //指定agv充电位置 + jo.put("locationName", "100"); + //指定agv操作码 + jo.put("operation", "Charge"); + ja.add(jo); + orderjo.put("destinations",ja); + HttpResponse result = null; + if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { + String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); + String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); + + agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + inst_no; + + log.info("下发agv指令参数:{}", orderjo.toString()); + + try { + result = HttpRequest.post(agvurl) + .body(String.valueOf(orderjo))//表单内容 + .timeout(20000)//超时,毫秒 + .execute(); + System.out.println(result); + log.info("chargingQuest----返回参数{}", result); + } catch (Exception e) { + throw new RuntimeException("下发agv失败!"); + } + } else { + throw new RuntimeException("系统参数未配置!"); + } + return result; + } + }