diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/createTask/CreateTaskRequest.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/createTask/CreateTaskRequest.java index ceebb3e..1e2dabf 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/createTask/CreateTaskRequest.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/createTask/CreateTaskRequest.java @@ -2,120 +2,17 @@ package org.nl.acs.ext.wms.data.WmstoAcsData.createTask; import lombok.Data; import org.nl.acs.ext.wms.data.BaseRequest; +import org.nl.acs.task.service.dto.TaskDto; +import java.util.List; import java.util.Map; @Data public class CreateTaskRequest extends BaseRequest { /** - * 任务标识 - */ - private String ext_task_id; - - /** - * 任务编号 - */ - private String task_code; - - - /** - * 取货点1 - */ - String start_device_code; - - /** - * 放货点1 - */ - String next_device_code; - - /** - * 取货点2 - */ - String start_device_code2; - - /** - * 放货点2 - */ - String next_device_code2; - - /** - * 对接位 - */ - String put_device_code; - - /** - * 优先级 - */ - String priority; - - /** - * 载具号 - */ - String vehicle_code; - - /** - * 载具类型 - */ - String vehicle_type; - - /** - * 路由方案 - */ - String route_plan_code; - - /** - * 任务类型 - */ - String task_type; - - /** - * 立库任务类型 - * - */ - String dtl_type; - - /** - * Agv系统类型 - * 1:1楼叉车系统 - * 2:2楼1区域AGV系统 - * 3:2楼2区域AGV系统 - */ - String agv_system_type; - - /** - * 备注 - */ - String remark; - - /** - * 烘箱时间 - */ - String oven_time; - - /** - * 烘箱温度 - */ - String temperature; - - /** - * agv取货高度 - */ - private String start_height; - - /** - * agv放货高度 - */ - private String next_height; - - /** - * 方向 1往左 2往右 - */ - private String direction; - - /** - * 扩展属性 - */ - Map params; + * 任务数组 + */ + private List list = null; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/createTask/CreateTaskResponse.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/createTask/CreateTaskResponse.java index 57c135e..071b991 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/createTask/CreateTaskResponse.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/createTask/CreateTaskResponse.java @@ -1,8 +1,12 @@ package org.nl.acs.ext.wms.data.WmstoAcsData.createTask; +import com.alibaba.fastjson.JSONArray; +import lombok.Data; import org.nl.acs.ext.wms.data.BaseResponse; +@Data public class CreateTaskResponse extends BaseResponse { + private JSONArray errArr = new JSONArray(); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/putAction/PutActionRequest.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/putAction/PutActionRequest.java index 16d45cc..83a8681 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/putAction/PutActionRequest.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/putAction/PutActionRequest.java @@ -9,11 +9,6 @@ import java.util.Map; @Data public class PutActionRequest extends BaseRequest { - /** - * 设备号 - */ - private String device_code; - private List list ; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/putAction/PutActionResponse.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/putAction/PutActionResponse.java index 48b8289..6de164f 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/putAction/PutActionResponse.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/putAction/PutActionResponse.java @@ -1,9 +1,12 @@ package org.nl.acs.ext.wms.data.WmstoAcsData.putAction; +import com.alibaba.fastjson.JSONArray; +import lombok.Data; import org.nl.acs.ext.wms.data.BaseResponse; +@Data public class PutActionResponse extends BaseResponse { - + private JSONArray errArr = new JSONArray(); } 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 b24848c..914c749 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 @@ -9,6 +9,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.nl.acs.ext.wms.data.WmstoAcsData.createTask.CreateTaskRequest; import org.nl.acs.ext.wms.service.WmsToAcsService; import org.nl.modules.logging.annotation.Log; import org.springframework.http.HttpStatus; @@ -34,7 +35,7 @@ public class WmsToAcsController { @PostMapping("/task") @Log("接收WMS任务") @ApiOperation("接收WMS任务") - public ResponseEntity createFromWms(@RequestBody String whereJson) { + public ResponseEntity createFromWms(@RequestBody JSONObject whereJson) { return new ResponseEntity<>(wmstoacsService.createFromWms(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 73f28a9..7428d38 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 @@ -14,7 +14,7 @@ public interface WmsToAcsService { * @param jsonObject 条件 * @return */ - Map createFromWms(String jsonObject); + JSONObject createFromWms(JSONObject jsonObject); /** * 取消任务 @@ -54,7 +54,7 @@ public interface WmsToAcsService { * @param jsonObject 条件 * @return Map */ - Map putAction(String jsonObject) throws Exception; + JSONObject putAction(String jsonObject) throws Exception; /** * 查询设备状态 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 7623dd8..70bc42c 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 @@ -2,14 +2,17 @@ package org.nl.acs.ext.wms.service.impl; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.nl.acs.agv.AgvUtil; import org.nl.acs.config.AcsConfig; import org.nl.acs.device.service.DeviceService; import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; +import org.nl.acs.device_driver.lnsh.lnsh_Laminating_machine.ItemProtocol; import org.nl.acs.device_driver.lnsh.lnsh_Laminating_machine.LnshLaminatingMachineDeviceDriver; import org.nl.acs.device_driver.lnsh.lnsh_fold_disc_site.LnshFoldDiscSiteDeviceDriver; import org.nl.acs.device_driver.lnsh.lnsh_kiln_lane.LnshKilnLaneDeviceDriver; @@ -27,6 +30,12 @@ import org.nl.acs.device_driver.lnsh.lnsh_rgv.LnshRGVDeviceDriver; import org.nl.acs.device_driver.lnsh.lnsh_split_manipulator.LnshSplitManipulatorDeviceDriver; import org.nl.acs.device_driver.lnsh.lnsh_station.LnshStationDeviceDriver; import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver; +import org.nl.acs.ext.wms.data.AcsToWmsData.grab_place_station.GrabPlaceStationResponse; +import org.nl.acs.ext.wms.data.WmstoAcsData.createTask.CreateTaskRequest; +import org.nl.acs.ext.wms.data.WmstoAcsData.createTask.CreateTaskResponse; +import org.nl.acs.ext.wms.data.WmstoAcsData.putAction.PutActionRequest; +import org.nl.acs.ext.wms.data.WmstoAcsData.putAction.PutActionResponse; +import org.nl.acs.ext.wms.data.WmstoAcsData.putAction.SignalData; import org.nl.acs.ext.wms.service.WmsToAcsService; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; @@ -67,33 +76,39 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { private String log_type = "WMS下发ACS"; @Override - public Map createFromWms(String param) { + public JSONObject createFromWms(JSONObject req) { try { MDC.put(log_file_type, log_type); - JSONArray tasks = JSONArray.parseArray(param); + CreateTaskRequest tasks = JSON.toJavaObject(req, CreateTaskRequest.class); JSONObject resultJson = new JSONObject(); + CreateTaskResponse resp = new CreateTaskResponse(); log.info("createFromWms - 请求参数 {}", tasks.toString()); + String request_no = tasks.getRequestNo(); + JSONArray errArr = new JSONArray(); try { - JSONArray errArr = new JSONArray(); - for (int i = 0; i < tasks.size(); i++) { - JSONObject task = tasks.getJSONObject(i); - String ext_task_uuid = 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"); + for (int i = 0; i < tasks.getList().size(); i++) { + TaskDto task = tasks.getList().get(i); + String ext_task_uuid = task.getExt_task_uuid(); + String task_code = task.getTask_code(); + String start_point_code = task.getStart_device_code(); + String next_point_code = task.getNext_device_code(); + String priority = task.getPriority(); + String vehicle_code = task.getVehicle_code(); + String vehicle_type = task.getVehicle_type(); + String route_plan_code = task.getRoute_plan_code(); + String task_type = task.getTask_type(); + String remark = task.getRemark(); + String params = task.getParams(); + // 双工RGV任务 后工位任务 + String start_point_code2 = task.getStart_device_code2(); + String next_point_code2 = task.getNext_device_code2(); + String start_device_code2 = task.getStart_device_code2(); + String next_device_code2 = task.getNext_device_code2(); String start_device_code = ""; String next_device_code = ""; String start_parent_code = ""; String next_parent_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)) { @@ -111,18 +126,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { } next_parent_code = next_device_json.get("parent_storage_code") == null ? next_point_code : (String) next_device_json.get("parent_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"); - // 双工RGV任务 后工位任务 - String start_point_code2 = task.getString("start_device_code2"); - String next_point_code2 = task.getString("next_device_code2"); - String start_device_code2 = task.getString("start_device_code2"); - String next_device_code2 = task.getString("next_device_code2"); + if (start_point_code.indexOf("-") > 0) { String str[] = start_point_code.split("-"); start_device_code = str[0]; @@ -143,12 +147,50 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { List list = RouteLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); if (ObjectUtil.isEmpty(list)) { - throw new WDKException("路由不通!"); + //throw new WDKException("路由不通!"); + JSONObject json = new JSONObject(); + json.put("task_code", task_code); + json.put("ext_task_id", ext_task_uuid); + json.put("message", "路由不通!"); + errArr.add(json); + continue; } TaskDto taskDto = TaskService.findByCodeFromCache(task_code); if (taskDto != null) { - throw new WDKException("不能存在相同的任务号!"); + //throw new WDKException("不能存在相同的任务号!"); + JSONObject json = new JSONObject(); + json.put("task_code", task_code); + json.put("ext_task_id", ext_task_uuid); + json.put("message", "不能存在相同的任务号!"); + errArr.add(json); + continue; } + + if (StrUtil.isEmpty(task_code)) { + JSONObject json = new JSONObject(); + json.put("task_code", task_code); + json.put("ext_task_id", ext_task_uuid); + json.put("message", "任务号不能为空"); + errArr.add(json); + continue; + } + if (StrUtil.isEmpty(start_point_code)) { + JSONObject json = new JSONObject(); + json.put("task_code", task_code); + json.put("ext_task_id", ext_task_uuid); + json.put("message", "起点不能为空"); + errArr.add(json); + continue; + } + if (StrUtil.isEmpty(next_point_code)) { + JSONObject json = new JSONObject(); + json.put("task_code", task_code); + json.put("ext_task_id", ext_task_uuid); + json.put("message", "终点不能为空"); + errArr.add(json); + continue; + } + // if (!StrUtil.isEmpty(vehicle_code) && !"0000".equals(vehicle_code)) { // TaskDto vehicle_dto = TaskService.findByContainer(vehicle_code); // if (vehicle_dto != null) { @@ -164,8 +206,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { jo.put("next_parent_code", next_parent_code); jo.put("start_device_code", start_device_code); jo.put("next_device_code", next_device_code); - jo.put("start_point_code2", start_point_code2); - jo.put("next_point_code2", next_point_code2); + jo.put("start_point_code2", start_device_code2); + jo.put("next_point_code2", next_device_code2); jo.put("start_device_code2", start_device_code2); jo.put("next_device_code2", next_device_code2); jo.put("priority", priority); @@ -200,26 +242,26 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { json.put("ext_task_uuid", ext_task_uuid); json.put("message", e.getMessage()); errArr.add(json); + continue; } } if (ObjectUtil.isEmpty(errArr)) { - resultJson.put("status", 200); + resp.setCode(200); } else { - resultJson.put("status", 400); + resp.setCode(400); } - resultJson.put("errArr", errArr); - resultJson.put("message", "操作成功"); - 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()); + resp.setCode(400); + resp.setMessage(e.getMessage()); } - return resultJson; + resp.setRequestNo(request_no); + resp.setResponseDate(AgvUtil.getDate()); + resp.setMessage("请求成功"); + log.info("createFromWms - 返回参数 {}", JSON.toJSON(resp)); + return (JSONObject) JSON.toJSON(resp); } finally { MDC.remove(log_file_type); } @@ -494,16 +536,20 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { } @Override - public Map putAction(String jsonObject) throws Exception { + public JSONObject putAction(String req) throws Exception { try { MDC.put(log_file_type, log_type); - JSONArray datas = JSONArray.parseArray(jsonObject); + PutActionRequest actions = JSON.toJavaObject(JSONObject.parseObject(req), PutActionRequest.class); + PutActionResponse resp = new PutActionResponse(); + String request_no = actions.getRequestNo(); + String device_code = actions.getDevice_code(); + JSONArray errArr = new JSONArray(); + JSONArray datas = JSONArray.parseArray(actions.getList().toString()); log.info("putAction - 请求参数 {}", datas.toString()); for (int i = 0; i < datas.size(); i++) { - JSONObject data = datas.getJSONObject(i); - String device_code = data.getString("device_code"); - String code = data.getString("code"); - String value = data.getString("value"); + SignalData data = JSON.toJavaObject(JSONObject.parseObject(datas.get(i).toString()), SignalData.class); + String code = data.getCode(); + String value = data.getValue(); Device device = DeviceAppService.findDeviceByCode(device_code); if (ObjectUtil.isEmpty(device)) { throw new Exception("未找到对应设备:" + device_code); @@ -512,19 +558,28 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { //晟华覆膜机 if (device.getDeviceDriver() instanceof LnshLaminatingMachineDeviceDriver) { lnshLaminatingMachineDeviceDriver = (LnshLaminatingMachineDeviceDriver) device.getDeviceDriver(); - org.nl.acs.device_driver.lnsh.lnsh_Laminating_machine.ItemProtocol itemProtocol = new org.nl.acs.device_driver.lnsh.lnsh_Laminating_machine.ItemProtocol(lnshLaminatingMachineDeviceDriver); + ItemProtocol itemProtocol = new ItemProtocol(lnshLaminatingMachineDeviceDriver); if (!lnshLaminatingMachineDeviceDriver.isExistFieldName(code, itemProtocol)) { - throw new Exception("设备:" + device_code + "未找到对应信号:" + code); + //throw new Exception("设备:" + device_code + "未找到对应信号:" + code); + JSONObject back = new JSONObject(); + back.put("code", code); + back.put("value", value); + back.put("message", "设备:" + device_code + "未找到对应信号:" + code); + errArr.add(back); + continue; } lnshLaminatingMachineDeviceDriver.writing(code, value); } } - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.OK); - resultJson.put("message", "操作成功"); - resultJson.put("data", new JSONObject()); - log.info("putAction - 返回参数 {}", resultJson.toString()); - return resultJson; + if (ObjectUtil.isEmpty(errArr)) { + resp.setCode(200); + } else { + resp.setCode(400); + resp.setErrArr(errArr); + } + resp.setRequestNo(request_no); + log.info("putAction - 返回参数 {}", JSON.toJSON(resp)); + return (JSONObject) JSON.toJSON(resp); } finally { MDC.remove(log_file_type); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/InstructionDto.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/InstructionDto.java index 5bc0624..4405618 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/InstructionDto.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/InstructionDto.java @@ -104,6 +104,26 @@ public class InstructionDto implements Serializable { */ private String next_device_code; + /** + * 起始点位编码2 + */ + private String start_point_code2; + + /** + * 起始设备编码2 + */ + private String start_device_code2; + + /** + * 目标点位编码2 + */ + private String next_point_code2; + + /** + * 目标设备编码 + */ + private String next_device_code2; + /** * 排 */ diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java index 4a54fb8..ee860d1 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java @@ -505,6 +505,9 @@ public class RouteLineServiceImpl implements RouteLineService, ApplicationAutoIn public List getShortPathLines(String device_code, String next_device_code, String plan_code) { List list = this.routeLines.get(plan_code); + if(ObjectUtil.isEmpty(list)){ + return null; + } List result = new ArrayList(); Iterator iterator = list.iterator(); while (iterator.hasNext()) { diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java index 4317371..5edf3fa 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java @@ -78,6 +78,16 @@ public class TaskDto implements Serializable { */ private String start_device_code; + /** + * 起始点位编码2 + */ + private String start_point_code2; + + /** + * 起始设备编码2 + */ + private String start_device_code2; + /** * 目标点位编码 */ @@ -88,6 +98,17 @@ public class TaskDto implements Serializable { */ private String next_device_code; + /** + * 目标点位编码2 + */ + private String next_point_code2; + + /** + * 目标设备编码2 + */ + private String next_device_code2; + + /** * 排 */ @@ -217,4 +238,9 @@ public class TaskDto implements Serializable { * 外部系统标识 */ private String ext_task_uuid; + + /** + * 扩展参数 + */ + private String params; }