From a8f4077ff4c7a52f11990b496a8fbf6d6e3c96a0 Mon Sep 17 00:00:00 2001 From: "USER-20220102CG\\noblelift" <546428999@qq.com> Date: Wed, 23 Nov 2022 19:17:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../acs/ext/wms/data/CancelTaskRequest.java | 30 +++ .../acs/ext/wms/data/CancelTaskResponse.java | 7 + .../acs/ext/wms/rest/WmsToAcsController.java | 10 +- .../acs/ext/wms/service/WmsToAcsService.java | 20 +- .../wms/service/impl/WmsToAcsServiceImpl.java | 187 +++--------------- 5 files changed, 77 insertions(+), 177 deletions(-) create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CancelTaskRequest.java create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CancelTaskResponse.java diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CancelTaskRequest.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CancelTaskRequest.java new file mode 100644 index 000000000..e2aea4c88 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CancelTaskRequest.java @@ -0,0 +1,30 @@ +package org.nl.acs.ext.wms.data; + +import lombok.Data; + +import java.util.Map; + +@Data +public class CancelTaskRequest extends BaseRequest { + + /** + * 任务标识 + */ + private String ext_task_id; + + /** + * 任务编号 + */ + private String task_code; + + /** + * 载具号 + */ + String vehicle_code; + + /** + * 扩展属性 + */ + Map params; + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CancelTaskResponse.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CancelTaskResponse.java new file mode 100644 index 000000000..7a24424d2 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CancelTaskResponse.java @@ -0,0 +1,7 @@ +package org.nl.acs.ext.wms.data; + +public class CancelTaskResponse extends BaseResponse { + + + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java index b9680bd19..fb5506ee8 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java @@ -35,7 +35,7 @@ public class WmsToAcsController { @ApiOperation("接收WMS任务") @SaIgnore public ResponseEntity createFromWms(@RequestBody String whereJson) { - return new ResponseEntity<>(wmstoacsService.createFromWms(whereJson), HttpStatus.OK); + return new ResponseEntity<>(wmstoacsService.crateTask(whereJson), HttpStatus.OK); } @PostMapping("/cancelTask") @@ -80,13 +80,5 @@ public class WmsToAcsController { return new ResponseEntity<>(wmstoacsService.queryDeviceDBValue(whereJson), HttpStatus.OK); } - @SaIgnore - @PostMapping("/createtask") - @Log("11") - @ApiOperation("11") - public ResponseEntity task(@RequestBody String whereJson){ - return new ResponseEntity<>(wmstoacsService.crateTask(whereJson), HttpStatus.OK); - } - } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java index cc41771b6..bffafd9b7 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java @@ -3,26 +3,27 @@ package org.nl.acs.ext.wms.service; import com.alibaba.fastjson.JSONObject; +import org.nl.acs.ext.wms.data.CancelTaskResponse; import org.nl.acs.ext.wms.data.CreateTaskResponse; import java.util.Map; public interface WmsToAcsService { + /** * 创建任务 - * - * @param jsonObject 条件 + * @param whereJson * @return */ - Map createFromWms(String jsonObject); + CreateTaskResponse crateTask(String whereJson); + /** * 取消任务 * * @param jsonObject 条件 - * @return Map */ - Map cancelFromWms(String jsonObject) throws Exception; + CancelTaskResponse cancelFromWms(String jsonObject) throws Exception; /** * 修改设置有无货属性 @@ -63,11 +64,8 @@ public interface WmsToAcsService { */ Map queryDeviceDBValue(String whereJson); - /** - * 创建任务 - * @param whereJson - * @return - */ - CreateTaskResponse crateTask(String whereJson); + + + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index f42903da8..e5efa1774 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -12,9 +12,7 @@ import org.nl.acs.device.service.DeviceService; import org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.CargoLiftConveyorDeviceDriver; import org.nl.acs.device_driver.basedriver.empty_vehicle_stacking_position.EmptyVehicleStackingPositionDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; -import org.nl.acs.ext.wms.data.CreateTaskRequest; -import org.nl.acs.ext.wms.data.CreateTaskResponse; -import org.nl.acs.ext.wms.data.JsonUtl; +import org.nl.acs.ext.wms.data.*; import org.nl.acs.ext.wms.service.WmsToAcsService; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; @@ -49,151 +47,21 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { private final DeviceAppService deviceAppService; private final RouteLineService routeLineService; - @Override - public Map createFromWms(String param) { - JSONArray tasks = JSONArray.parseArray(param); - JSONObject resultJson = new JSONObject(); - log.info("createFromWms--------------:输入参数:" + tasks.toString()); - try { - JSONArray errArr = new JSONArray(); - for (int i = 0; i < tasks.size(); i++) { - JSONObject task = tasks.getJSONObject(i); - String ext_task_id = task.getString("task_id"); - String task_code = task.getString("task_code"); - String start_point_code = task.getString("start_device_code"); - String next_point_code = task.getString("next_device_code"); - String start_point_code2 = task.getString("start_device_code2"); - String next_point_code2 = task.getString("next_device_code2"); - String put_point_code = task.getString("put_device_code"); - String start_device_code = ""; - String next_device_code = ""; - if (StrUtil.isEmpty(task_code)) { - throw new WDKException("任务号不能为空"); - } - if (StrUtil.isEmpty(start_point_code)) { - throw new WDKException("起点不能为空"); - } - if (StrUtil.isEmpty(next_point_code)) { - throw new WDKException("终点不能为空"); - } - - JSONObject start_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + start_point_code + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(start_device_json)) { - start_point_code = (String) start_device_json.get("parent_storage_code") == null ? start_point_code : (String) start_device_json.get("storage_code"); - } - JSONObject next_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + next_point_code + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(next_device_json)) { - next_point_code = (String) next_device_json.get("parent_storage_code") == null ? next_point_code : (String) next_device_json.get("storage_code"); - } - String priority = task.getString("priority"); - String vehicle_code = task.getString("vehicle_code"); - String vehicle_type = task.getString("vehicle_type"); - String route_plan_code = task.getString("route_plan_code"); - String task_type = task.getString("task_type"); - String remark = task.getString("remark"); - String params = task.getString("params"); - - if (start_point_code.indexOf("-") > 0) { - String str[] = start_point_code.split("-"); - start_device_code = str[0]; - } else { - start_device_code = start_point_code; - } - - if (next_point_code.indexOf("-") > 0) { - String str[] = next_point_code.split("-"); - next_device_code = str[0]; - } else { - next_device_code = next_point_code; - } - - if (StrUtil.isEmpty(route_plan_code)) { - route_plan_code = "normal"; - } -// List list = RouteLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); -// -// if (ObjectUtil.isEmpty(list)) { -// throw new WDKException("路由不通!"); -// } - TaskDto taskDto = taskService.findByCodeFromCache(task_code); - if (taskDto != null) { - throw new WDKException("不能存在相同的任务号!"); - } - if (!StrUtil.isEmpty(vehicle_code)) { - TaskDto vehicle_dto = taskService.findByContainer(vehicle_code); - if (vehicle_dto != null) { - throw new WDKException("已存在该载具号的任务!"); - } - } - JSONObject jo = new JSONObject(); - jo.put("task_code", task_code); - jo.put("task_id", ext_task_id); - jo.put("start_point_code", start_point_code); - jo.put("next_point_code", next_point_code); - jo.put("start_parent_code", start_point_code); - jo.put("next_parent_code", next_point_code); - jo.put("start_device_code", start_device_code); - jo.put("next_device_code", next_device_code); - jo.put("priority", priority); - jo.put("vehicle_code", vehicle_code); - jo.put("vehicle_type", vehicle_type); - jo.put("remark", remark); - jo.put("params", params); - jo.put("task_type", StrUtil.isEmpty(task_type) ? 1 : Integer.parseInt(task_type)); - - if (!StrUtil.isEmpty(ext_task_id)) { - jo.put("ext_task_id", ext_task_id); - } - - TaskDto task_dto = jo.toJavaObject(TaskDto.class); - try { - taskService.create(task_dto); - } catch (Exception e) { - e.printStackTrace(); - JSONObject json = new JSONObject(); - json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); - json.put("message", e.getMessage()); - errArr.add(json); - } - } - if (ObjectUtil.isEmpty(errArr)) { - resultJson.put("status", 200); - resultJson.put("message", "操作成功"); - } else { - resultJson.put("status", 400); - resultJson.put("message", "操作失败"); - } - resultJson.put("errArr", errArr); - resultJson.put("data", new JSONObject()); - log.info("createFromWms--------------:输出参数:" + resultJson.toString()); - - } catch (Exception e) { - resultJson.put("status", 400); - resultJson.put("errArr", e.getMessage()); - resultJson.put("message", e.getMessage()); - resultJson.put("data", new JSONObject()); - log.info("createFromWms--------------:输出参数:" + resultJson.toString()); - } - - - return resultJson; - } - @Override - public Map cancelFromWms(String param) throws Exception { - JSONArray tasks = JSONArray.parseArray(param); + public CancelTaskResponse cancelFromWms(String param) throws Exception { ParamService paramService = SpringContextHolder.getBean(ParamService.class); InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - log.debug(tasks.toString()); - log.info("cancelFromWms--------------:输入参数" + tasks.toString()); - for (int i = 0; i < tasks.size(); i++) { - JSONObject task = tasks.getJSONObject(i); - String task_uuid = task.getString("task_id"); - String task_code = task.getString("task_code"); - String vehicle_code = task.getString("vehicle_code"); - String params = task.getString("params"); + JSONArray datas = JSONArray.parseArray(param); + CancelTaskResponse response = new CancelTaskResponse(); + JSONArray errArr = new JSONArray(); + for (int i = 0; i < datas.size(); i++) { + String data = datas.get(i).toString(); + CancelTaskRequest request = JsonUtl.format(param, CancelTaskRequest.class); + + String task_uuid = request.getExt_task_id(); + String task_code = request.getTask_code(); + String vehicle_code = request.getVehicle_code(); if (StrUtil.isEmpty(task_uuid)) { throw new WDKException("任务标识不能为空"); @@ -214,12 +82,17 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { } } - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.OK); - resultJson.put("message", "操作成功"); - resultJson.put("data", new JSONObject()); - log.info("cancelFromWms--------------:输出参数" + resultJson.toString()); - return resultJson; + + if (ObjectUtil.isEmpty(errArr)) { + response.setStatus(200); + } else { + response.setStatus(400); + } + response.setMessage("success"); + response.setErrArr(errArr); + log.info("createFromWms--------------:输出参数:" + response); + + return response; } @Override @@ -395,7 +268,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { String route_plan_code = request.getRoute_plan_code(); String task_type = request.getTask_type(); String remark = request.getRemark(); - String params = request.getParams().toString(); + Map params = request.getParams(); String start_device_code = ""; String start_device_code2 = ""; @@ -426,42 +299,42 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { start_point_code2 = (String) start_device_json2.get("parent_storage_code") == null ? start_point_code2 : (String) start_device_json.get("storage_code"); } JSONObject next_device_json2 = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + next_point_code2 + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(next_device_json)) { + if (!ObjectUtil.isEmpty(next_device_json2)) { next_point_code2 = (String) next_device_json2.get("parent_storage_code") == null ? next_point_code2 : (String) next_device_json.get("storage_code"); } JSONObject put_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + put_point_code + "'").uniqueResult(0); if (!ObjectUtil.isEmpty(put_device_json)) { put_point_code = (String) put_device_json.get("parent_storage_code") == null ? put_point_code : (String) next_device_json.get("storage_code"); } - if (start_point_code.indexOf("-") > 0) { + if (StrUtil.isNotEmpty(start_point_code) && start_point_code.indexOf("-") > 0) { String str[] = start_point_code.split("-"); start_device_code = str[0]; } else { start_device_code = start_point_code; } - if (next_point_code.indexOf("-") > 0) { + if (StrUtil.isNotEmpty(next_point_code) && next_point_code.indexOf("-") > 0) { String str[] = next_point_code.split("-"); next_device_code = str[0]; } else { next_device_code = next_point_code; } - if (start_point_code2.indexOf("-") > 0) { + if (StrUtil.isNotEmpty(start_point_code2) && start_point_code2.indexOf("-") > 0) { String str[] = start_point_code2.split("-"); start_device_code2 = str[0]; } else { start_device_code2 = start_point_code2; } - if (next_point_code2.indexOf("-") > 0) { + if (StrUtil.isNotEmpty(next_point_code2) && next_point_code2.indexOf("-") > 0) { String str[] = next_point_code2.split("-"); next_device_code2 = str[0]; } else { next_device_code2 = next_point_code2; } - if (put_point_code.indexOf("-") > 0) { + if (StrUtil.isNotEmpty(put_point_code) && put_point_code.indexOf("-") > 0) { String str[] = put_point_code.split("-"); put_device_code = str[0]; } else {