diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java index 7b7efd2..a05597f 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java @@ -933,6 +933,10 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial wo.insert(param); } } + + deviceAppService.removeDevice(device_code); + + deviceAppService.addDevice(device_code); } @Override diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/DeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/DeviceDriver.java index 5fad4da..fd75845 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/DeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/DeviceDriver.java @@ -1,5 +1,6 @@ package org.nl.acs.device_driver; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import org.nl.acs.opc.Device; @@ -37,4 +38,15 @@ public interface DeviceDriver { return devicesList; } + default String getModeName(String mode){ + if(StrUtil.equals("0",mode)){ + mode = "脱机"; + } else if (StrUtil.equals("2",mode)) { + mode = "联机"; + } else { + mode = RequestMethodEnum.getName(mode); + } + return ObjectUtil.isEmpty(mode)? "未定义":mode; + } + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/RequestMethodEnum.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/RequestMethodEnum.java index 6a8bf3d..33260ca 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/RequestMethodEnum.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/RequestMethodEnum.java @@ -118,7 +118,7 @@ public enum RequestMethodEnum { public static String getName(String code) { for (RequestMethodEnum c : RequestMethodEnum.values()) { - if (c.code == code) { + if ( StrUtil.equals(c.code,code)) { return c.name; } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDeviceDriver.java index bc231c5..5a72cf0 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDeviceDriver.java @@ -485,7 +485,7 @@ public class LnshStationDeviceDriver extends AbstractOpcDeviceDriver implements JSONObject jo = new JSONObject(); jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("mode", mode); + jo.put("mode", getModeName(this.getDevice().getExtraValue().get(mode).toString())); jo.put("move", move); jo.put("action", action); jo.put("io_action", io_action); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/createOrder/CreateOrderRequest.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/createOrder/CreateOrderRequest.java new file mode 100644 index 0000000..609f331 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/createOrder/CreateOrderRequest.java @@ -0,0 +1,16 @@ +package org.nl.acs.ext.wms.data.WmstoAcsData.createOrder; + +import lombok.Data; +import org.nl.acs.ext.wms.data.BaseRequest; + +import java.util.List; + +@Data +public class CreateOrderRequest extends BaseRequest { + + /** + * 任务数组 + */ + private List list = null; + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/createOrder/CreateOrderResponse.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/createOrder/CreateOrderResponse.java new file mode 100644 index 0000000..168ea30 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/createOrder/CreateOrderResponse.java @@ -0,0 +1,12 @@ +package org.nl.acs.ext.wms.data.WmstoAcsData.createOrder; + +import com.alibaba.fastjson.JSONArray; +import lombok.Data; +import org.nl.acs.ext.wms.data.BaseResponse; + +@Data +public class CreateOrderResponse extends BaseResponse { + + private JSONArray errArr = new JSONArray(); + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/createOrder/OrderDto.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/createOrder/OrderDto.java new file mode 100644 index 0000000..d8177ba --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/WmstoAcsData/createOrder/OrderDto.java @@ -0,0 +1,31 @@ +package org.nl.acs.ext.wms.data.WmstoAcsData.createOrder; + +import lombok.Data; + +@Data +public class OrderDto { + + private String workorder_code; // 工单编码 + private String device_code; // 设备编码 + private String material_code; // 半成品物料编码 - 工单物料编码 + private String product_code; // 产品代号 - 成品 + private String formula; // 配方-泥料 + private String brick_code; // 砖型编码 + private String plan_qty; // 计划数量 + private String a; // a边 + private String b; // + private String h; + private String w; + private String size_error; // 尺寸允许误差 + private String single_weight; // 单重允许误差 + private String drawing_address; // 图纸地址 + private String standard_size_height1; // 标准尺寸1 + private String standard_size_height2; // 标准尺寸2 + private String standard_size_height3; // 标准尺寸3 + private String standard_size_height4; // 标准尺寸4 + private String standard_weight; // 标准重量 + private String detection_error; // 检测误差值 + + + +} 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 914c749..4cb72bc 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 @@ -49,7 +49,7 @@ public class WmsToAcsController { @PostMapping("/order") @Log("接收WMS排产单") @ApiOperation("接收WMS排产单") - public ResponseEntity createOrder(@RequestBody String whereJson) throws Exception { + public ResponseEntity createOrder(@RequestBody JSONObject whereJson) throws Exception { return new ResponseEntity<>(wmstoacsService.createOrder(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 7428d38..45e0bc9 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 @@ -30,7 +30,7 @@ public interface WmsToAcsService { * @param jsonObject 条件 * @return Map */ - Map createOrder(String jsonObject) throws Exception; + JSONObject createOrder(JSONObject 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 70bc42c..52bfa2a 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 @@ -31,6 +31,9 @@ import org.nl.acs.device_driver.lnsh.lnsh_split_manipulator.LnshSplitManipulator 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.createOrder.CreateOrderRequest; +import org.nl.acs.ext.wms.data.WmstoAcsData.createOrder.CreateOrderResponse; +import org.nl.acs.ext.wms.data.WmstoAcsData.createOrder.OrderDto; 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; @@ -191,12 +194,17 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { continue; } -// if (!StrUtil.isEmpty(vehicle_code) && !"0000".equals(vehicle_code)) { -// TaskDto vehicle_dto = TaskService.findByContainer(vehicle_code); -// if (vehicle_dto != null) { -// throw new WDKException("已存在该载具号的任务!"); -// } -// } + if (!StrUtil.isEmpty(vehicle_code)) { + TaskDto vehicle_dto = TaskService.findByContainer(vehicle_code); + if (vehicle_dto != null) { + 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; + } + } JSONObject jo = new JSONObject(); jo.put("task_code", task_code); jo.put("ext_task_uuid", ext_task_uuid); @@ -316,150 +324,218 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { } @Override - public Map createOrder(String param) throws Exception { - JSONArray orders = JSONArray.parseArray(param); - log.info("createOrder - 请求参数 {}", orders.toString()); - - for (int i = 0; i < orders.size(); i++) { - Boolean is_flag = false; - - JSONObject json = orders.getJSONObject(i); - String producetask_code = json.getString("workorder_code"); - String device_code = json.getString("device_code"); - String material_code = json.getString("material_code"); - String qty = json.getString("plan_qty"); - String product_code = json.getString("product_code"); - String AlongSide = json.getString("a"); - String BshortSide = json.getString("b"); - String Htrapezoidal = json.getString("h"); - String Wthickness = json.getString("w"); - - if (StrUtil.isEmpty(producetask_code)) { - throw new BadRequestException("工单编码不能为空!"); - } - - Device device = DeviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device)) { - throw new Exception("未找到对应设备:" + device_code); - } - - LnshMixingMillDeviceDriver lnshMixingMillDeviceDriver; - LnshPressDeviceDriver lnshPressDeviceDriver; - LnshPackagePalletManipulatorDeviceDriver lnshPackagePalletManipulatorDeviceDriver; - LnshSplitManipulatorDeviceDriver lnshSplitManipulatorDeviceDriver; - if (device.getDeviceDriver() instanceof LnshMixingMillDeviceDriver) { - lnshMixingMillDeviceDriver = (LnshMixingMillDeviceDriver) device.getDeviceDriver(); - if (lnshMixingMillDeviceDriver.getMode() == 0) { - throw new BadRequestException("设备未联机,下发失败!"); - } - if (StrUtil.isEmpty(qty)) { - throw new BadRequestException("重量不能为空!"); - } - if (StrUtil.isEmpty(material_code)) { - throw new BadRequestException("物料编码不能为空!"); - } - lnshMixingMillDeviceDriver.writing("to_order_No", producetask_code); - lnshMixingMillDeviceDriver.writing("to_weight", qty); - lnshMixingMillDeviceDriver.writing("to_material_code", material_code); - lnshMixingMillDeviceDriver.writing("to_order_No", producetask_code); - lnshMixingMillDeviceDriver.writing("to_weight", qty); - lnshMixingMillDeviceDriver.writing("to_material_code", material_code); - lnshMixingMillDeviceDriver.writing(100); - lnshMixingMillDeviceDriver.writing(100); - is_flag = true; - } - if (device.getDeviceDriver() instanceof LnshPressDeviceDriver) { - lnshPressDeviceDriver = (LnshPressDeviceDriver) device.getDeviceDriver(); - if (lnshPressDeviceDriver.getMode() == 0) { - throw new BadRequestException("设备未联机,下发失败!"); - } - if (StrUtil.isEmpty(qty)) { - throw new BadRequestException("数量不能为空!"); - } - if (StrUtil.isEmpty(material_code)) { - throw new BadRequestException("物料编码不能为空!"); - } - lnshPressDeviceDriver.writing("to_order_No", producetask_code); - lnshPressDeviceDriver.writing("to_qty", qty); - lnshPressDeviceDriver.writing("to_material_code", material_code); - lnshPressDeviceDriver.writing("to_product_code", product_code); - lnshPressDeviceDriver.writing("to_AlongSide", AlongSide); - lnshPressDeviceDriver.writing("to_BshortSide", BshortSide); - lnshPressDeviceDriver.writing("to_Htrapezoidal", Htrapezoidal); - lnshPressDeviceDriver.writing("to_Wthickness", Wthickness); - lnshPressDeviceDriver.writing("to_order_No", producetask_code); - lnshPressDeviceDriver.writing("to_qty", qty); - lnshPressDeviceDriver.writing("to_material_code", material_code); - lnshPressDeviceDriver.writing("to_product_code", product_code); - lnshPressDeviceDriver.writing("to_AlongSide", AlongSide); - lnshPressDeviceDriver.writing("to_BshortSide", BshortSide); - lnshPressDeviceDriver.writing("to_Htrapezoidal", Htrapezoidal); - lnshPressDeviceDriver.writing("to_Wthickness", Wthickness); - lnshPressDeviceDriver.writing(100); - lnshPressDeviceDriver.writing(100); - is_flag = true; - } - if (device.getDeviceDriver() instanceof LnshPackagePalletManipulatorDeviceDriver) { - lnshPackagePalletManipulatorDeviceDriver = (LnshPackagePalletManipulatorDeviceDriver) device.getDeviceDriver(); - if (lnshPackagePalletManipulatorDeviceDriver.getMode() == 0) { - throw new BadRequestException("设备未联机,下发失败!"); + public JSONObject createOrder(JSONObject param) throws Exception { + try{ + MDC.put(log_file_type, log_type); + CreateOrderRequest orders = JSON.toJavaObject(param, CreateOrderRequest.class); + CreateOrderResponse resp = new CreateOrderResponse(); + String request_no = orders.getRequestNo(); + JSONArray errArr = new JSONArray(); + log.info("CreateOrderRequest - 请求参数 {}", orders.toString()); + + for (int i = 0; i < orders.getList().size(); i++) { + Boolean is_flag = false; + + OrderDto orderDto = orders.getList().get(i); + String produce_code = orderDto.getProduct_code(); + String device_code = orderDto.getDevice_code(); + String material_code = orderDto.getMaterial_code(); + String qty = orderDto.getPlan_qty(); + String product_code = orderDto.getProduct_code(); + String AlongSide = orderDto.getA(); + String BshortSide = orderDto.getB(); + String Htrapezoidal = orderDto.getH(); + String Wthickness = orderDto.getW(); + String formula = orderDto.getFormula(); + String brick_code = orderDto.getBrick_code(); + String size_error = orderDto.getSize_error(); + String single_weight = orderDto.getSingle_weight(); + String drawing_address = orderDto.getDrawing_address(); + String standard_size_height1 = orderDto.getStandard_size_height1(); + String standard_size_height2 = orderDto.getStandard_size_height2(); + String standard_size_height3 = orderDto.getStandard_size_height3(); + String standard_size_height4 = orderDto.getStandard_size_height4(); + String standard_weight = orderDto.getStandard_weight(); + String detection_error = orderDto.getDetection_error(); + + + if (StrUtil.isEmpty(produce_code)) { + JSONObject json = new JSONObject(); + json.put("produce_code", produce_code); + json.put("devicie_code", device_code); + json.put("message","工单编码不能为空"); + errArr.add(json); + continue; } - if (StrUtil.isEmpty(qty)) { - throw new BadRequestException("数量不能为空"); + + Device device = DeviceAppService.findDeviceByCode(device_code); + if (ObjectUtil.isEmpty(device)) { + JSONObject json = new JSONObject(); + json.put("produce_code", produce_code); + json.put("devicie_code", device_code); + json.put("message","未找到对应设备"); + errArr.add(json); + continue; } - if (StrUtil.isEmpty(material_code)) { - throw new BadRequestException("物料编号不能为空!"); + + LnshMixingMillDeviceDriver lnshMixingMillDeviceDriver; + LnshPressDeviceDriver lnshPressDeviceDriver; + LnshPackagePalletManipulatorDeviceDriver lnshPackagePalletManipulatorDeviceDriver; + LnshSplitManipulatorDeviceDriver lnshSplitManipulatorDeviceDriver; + if (device.getDeviceDriver() instanceof LnshMixingMillDeviceDriver) { + lnshMixingMillDeviceDriver = (LnshMixingMillDeviceDriver) device.getDeviceDriver(); + if (lnshMixingMillDeviceDriver.getMode() == 0) { + JSONObject json = new JSONObject(); + json.put("produce_code", produce_code); + json.put("devicie_code", device_code); + json.put("message","设备未联机"); + errArr.add(json); + continue; + } + if (StrUtil.isEmpty(qty)) { + JSONObject json = new JSONObject(); + json.put("produce_code", produce_code); + json.put("devicie_code", device_code); + json.put("message","重量不能为空"); + errArr.add(json); + continue; + } + if (StrUtil.isEmpty(material_code)) { + JSONObject json = new JSONObject(); + json.put("produce_code", produce_code); + json.put("devicie_code", device_code); + json.put("message","物料编号不能为空"); + errArr.add(json); + continue; + } + lnshMixingMillDeviceDriver.writing("to_order_No", produce_code); + lnshMixingMillDeviceDriver.writing("to_weight", qty); + lnshMixingMillDeviceDriver.writing("to_material_code", material_code); + lnshMixingMillDeviceDriver.writing(100); + is_flag = true; } - lnshPackagePalletManipulatorDeviceDriver.writing("to_order_No", producetask_code); - lnshPackagePalletManipulatorDeviceDriver.writing("to_material", material_code); - lnshPackagePalletManipulatorDeviceDriver.writing("to_product_code", product_code); - lnshPackagePalletManipulatorDeviceDriver.writing("to_AlongSide", AlongSide); - lnshPackagePalletManipulatorDeviceDriver.writing("to_BshortSide", BshortSide); - lnshPackagePalletManipulatorDeviceDriver.writing("to_Htrapezoidal", Htrapezoidal); - lnshPackagePalletManipulatorDeviceDriver.writing("to_Wthickness", Wthickness); - lnshPackagePalletManipulatorDeviceDriver.writing("to_order_No", producetask_code); - lnshPackagePalletManipulatorDeviceDriver.writing("to_material", material_code); - lnshPackagePalletManipulatorDeviceDriver.writing("to_product_code", product_code); - lnshPackagePalletManipulatorDeviceDriver.writing("to_AlongSide", AlongSide); - lnshPackagePalletManipulatorDeviceDriver.writing("to_BshortSide", BshortSide); - lnshPackagePalletManipulatorDeviceDriver.writing("to_Htrapezoidal", Htrapezoidal); - lnshPackagePalletManipulatorDeviceDriver.writing("to_Wthickness", Wthickness); - lnshPackagePalletManipulatorDeviceDriver.writing(100); - lnshPackagePalletManipulatorDeviceDriver.writing(100); - is_flag = true; - } - if (device.getDeviceDriver() instanceof LnshSplitManipulatorDeviceDriver) { - lnshSplitManipulatorDeviceDriver = (LnshSplitManipulatorDeviceDriver) device.getDeviceDriver(); - if (lnshSplitManipulatorDeviceDriver.getMode() == 0) { - throw new BadRequestException("设备未联机,下发失败!"); + if (device.getDeviceDriver() instanceof LnshPressDeviceDriver) { + lnshPressDeviceDriver = (LnshPressDeviceDriver) device.getDeviceDriver(); + if (lnshPressDeviceDriver.getMode() == 0) { + JSONObject json = new JSONObject(); + json.put("produce_code", produce_code); + json.put("devicie_code", device_code); + json.put("message","设备未联机"); + errArr.add(json); + continue; + } + if (StrUtil.isEmpty(qty)) { + JSONObject json = new JSONObject(); + json.put("produce_code", produce_code); + json.put("devicie_code", device_code); + json.put("message","重量不能为空"); + errArr.add(json); + continue; + } + if (StrUtil.isEmpty(material_code)) { + JSONObject json = new JSONObject(); + json.put("produce_code", produce_code); + json.put("devicie_code", device_code); + json.put("message","物料编号不能为空"); + errArr.add(json); + continue; + } + lnshPressDeviceDriver.writing("to_order_No", produce_code); + lnshPressDeviceDriver.writing("to_qty", qty); + lnshPressDeviceDriver.writing("to_material_code", material_code); + lnshPressDeviceDriver.writing("to_product_code", product_code); + lnshPressDeviceDriver.writing("to_AlongSide", AlongSide); + lnshPressDeviceDriver.writing("to_BshortSide", BshortSide); + lnshPressDeviceDriver.writing("to_Htrapezoidal", Htrapezoidal); + lnshPressDeviceDriver.writing("to_Wthickness", Wthickness); + lnshPressDeviceDriver.writing("to_brick_code", brick_code); + lnshPressDeviceDriver.writing("to_formula", formula); + lnshPressDeviceDriver.writing("to_size_error", size_error); + lnshPressDeviceDriver.writing("to_single_weight", single_weight); + lnshPressDeviceDriver.writing("to_drawing_address", drawing_address); + lnshPressDeviceDriver.writing("to_standard_weight", standard_weight); + lnshPressDeviceDriver.writing("to_detection_error", detection_error); + lnshPressDeviceDriver.writing("to_standard_size_height1", standard_size_height1); + lnshPressDeviceDriver.writing("to_standard_size_height2", standard_size_height2); + lnshPressDeviceDriver.writing("to_standard_size_height3", standard_size_height3); + lnshPressDeviceDriver.writing("to_standard_size_height4", standard_size_height4); + lnshPressDeviceDriver.writing(100); + is_flag = true; } - if (StrUtil.isEmpty(qty)) { - throw new BadRequestException("数量不能为空"); + if (device.getDeviceDriver() instanceof LnshPackagePalletManipulatorDeviceDriver) { + lnshPackagePalletManipulatorDeviceDriver = (LnshPackagePalletManipulatorDeviceDriver) device.getDeviceDriver(); + if (lnshPackagePalletManipulatorDeviceDriver.getMode() == 0) { + JSONObject json = new JSONObject(); + json.put("produce_code", produce_code); + json.put("devicie_code", device_code); + json.put("message","设备未联机"); + errArr.add(json); + continue; + } + if (StrUtil.isEmpty(qty)) { + JSONObject json = new JSONObject(); + json.put("produce_code", produce_code); + json.put("devicie_code", device_code); + json.put("message","重量不能为空"); + errArr.add(json); + continue; + } + if (StrUtil.isEmpty(material_code)) { + JSONObject json = new JSONObject(); + json.put("produce_code", produce_code); + json.put("devicie_code", device_code); + json.put("message","物料编号不能为空"); + errArr.add(json); + continue; + } + lnshPackagePalletManipulatorDeviceDriver.writing("to_order_No", produce_code); + lnshPackagePalletManipulatorDeviceDriver.writing("to_material", material_code); + lnshPackagePalletManipulatorDeviceDriver.writing("to_product_code", product_code); + lnshPackagePalletManipulatorDeviceDriver.writing("to_AlongSide", AlongSide); + lnshPackagePalletManipulatorDeviceDriver.writing("to_BshortSide", BshortSide); + lnshPackagePalletManipulatorDeviceDriver.writing("to_Htrapezoidal", Htrapezoidal); + lnshPackagePalletManipulatorDeviceDriver.writing("to_Wthickness", Wthickness); + lnshPackagePalletManipulatorDeviceDriver.writing(100); + is_flag = true; } - if (StrUtil.isEmpty(material_code)) { - throw new BadRequestException("物料编号不能为空!"); + if (device.getDeviceDriver() instanceof LnshSplitManipulatorDeviceDriver) { + lnshSplitManipulatorDeviceDriver = (LnshSplitManipulatorDeviceDriver) device.getDeviceDriver(); + if (lnshSplitManipulatorDeviceDriver.getMode() == 0) { + JSONObject json = new JSONObject(); + json.put("produce_code", produce_code); + json.put("devicie_code", device_code); + json.put("message","设备未联机"); + errArr.add(json); + continue; + } + if (StrUtil.isEmpty(qty)) { + JSONObject json = new JSONObject(); + json.put("produce_code", produce_code); + json.put("devicie_code", device_code); + json.put("message","重量不能为空"); + errArr.add(json); + continue; + } + if (StrUtil.isEmpty(material_code)) { + JSONObject json = new JSONObject(); + json.put("produce_code", produce_code); + json.put("devicie_code", device_code); + json.put("message","物料编号不能为空"); + errArr.add(json); + continue; + } + lnshSplitManipulatorDeviceDriver.writing("to_order_No", produce_code); + lnshSplitManipulatorDeviceDriver.writing("to_material_qty", qty); + lnshSplitManipulatorDeviceDriver.writing("to_material_code", material_code); + lnshSplitManipulatorDeviceDriver.writing("to_product_code", product_code); + lnshSplitManipulatorDeviceDriver.writing("to_AlongSide", AlongSide); + lnshSplitManipulatorDeviceDriver.writing("to_BshortSide", BshortSide); + lnshSplitManipulatorDeviceDriver.writing("to_Htrapezoidal", Htrapezoidal); + lnshSplitManipulatorDeviceDriver.writing("to_Wthickness", Wthickness); + lnshSplitManipulatorDeviceDriver.writing(100); + is_flag = true; } - lnshSplitManipulatorDeviceDriver.writing("to_order_No", producetask_code); - lnshSplitManipulatorDeviceDriver.writing("to_material_qty", qty); - lnshSplitManipulatorDeviceDriver.writing("to_material_code", material_code); - lnshSplitManipulatorDeviceDriver.writing("to_product_code", product_code); - lnshSplitManipulatorDeviceDriver.writing("to_AlongSide", AlongSide); - lnshSplitManipulatorDeviceDriver.writing("to_BshortSide", BshortSide); - lnshSplitManipulatorDeviceDriver.writing("to_Htrapezoidal", Htrapezoidal); - lnshSplitManipulatorDeviceDriver.writing("to_Wthickness", Wthickness); - lnshSplitManipulatorDeviceDriver.writing("to_order_No", producetask_code); - lnshSplitManipulatorDeviceDriver.writing("to_material_qty", qty); - lnshSplitManipulatorDeviceDriver.writing("to_material_code", material_code); - lnshSplitManipulatorDeviceDriver.writing("to_product_code", product_code); - lnshSplitManipulatorDeviceDriver.writing("to_AlongSide", AlongSide); - lnshSplitManipulatorDeviceDriver.writing("to_BshortSide", BshortSide); - lnshSplitManipulatorDeviceDriver.writing("to_Htrapezoidal", Htrapezoidal); - lnshSplitManipulatorDeviceDriver.writing("to_Wthickness", Wthickness); - lnshSplitManipulatorDeviceDriver.writing(100); - lnshSplitManipulatorDeviceDriver.writing(100); - is_flag = true; - } - //下发成功后,写入工单信息表记录 + //下发成功后,写入工单信息表记录 // ProduceshiftorderDto dto = new ProduceshiftorderDto(); // dto.setDevice_code(device_code); @@ -476,14 +552,23 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { // dto.setProduct_code(product_code); // produceshiftorderService.create(dto); - } + } - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.OK.value()); - resultJson.put("message", "操作成功"); - resultJson.put("data", new JSONObject()); - log.info("createOrder - 返回参数 {}", resultJson.toString()); - return resultJson; + if(errArr.size()>0){ + resp.setErrArr(errArr); + resp.setCode(HttpStatus.BAD_REQUEST.value()); + } else { + resp.setCode(HttpStatus.OK.value()); + } + resp.setRequestNo(request_no); + resp.setResponseDate(AgvUtil.getDate()); + resp.setMessage("请求成功"); + log.info("createOrder - 返回参数 {}", JSON.toJSON(resp)); + return (JSONObject) JSON.toJSON(resp); + + } finally { + MDC.remove(log_file_type); + } }