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 eb07de802..3f702c591 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 @@ -2,6 +2,8 @@ package org.nl.acs.device_driver; import org.nl.acs.opc.Device; +import java.util.List; + public interface DeviceDriver { default String getDeviceCode() { return this.getDevice().getDevice_code(); @@ -17,4 +19,5 @@ public interface DeviceDriver { return this.getDriverDefination().getDriverCode(); } + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/ItemProtocol.java index afe2f4f65..9a50dc38f 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/ItemProtocol.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/ItemProtocol.java @@ -123,5 +123,10 @@ public class ItemProtocol { return list; } + @Override + public String toString() { + return ""; + } + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java index 6caae49ac..57904d43b 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.IdUtil; 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.Data; import lombok.RequiredArgsConstructor; @@ -230,11 +231,11 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme this.setIserror(true); message = "未联机"; //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 +// } else if (error != 0) { +// this.setIsonline(false); +// this.setIserror(true); +// message = "有报警"; +// //无报警 } else { this.setIsonline(true); this.setIserror(false); @@ -421,18 +422,24 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme } } -// public void writing(int type, int command) { -// String to_material_code = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() -// + "." + ItemProtocol.item_to_material_code; -// String opcservcerid = this.getDevice().getOpc_server_id(); -// Server server = ReadUtil.getServer(opcservcerid); -// Map itemMap = new HashMap(); -// if (type == 2) { -// itemMap.put(to_material_code, command); -// } -// ReadUtil.write(itemMap, server); -// -// } + public void writing(List list) { + + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + for (int i = 0; i < list.size(); i++) { + Object ob = list.get(i); + JSONObject json = (JSONObject) JSONObject.toJSON(ob); + if (!StrUtil.isEmpty(json.getString("value"))) { + String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + json.getString("code"); + itemMap.put(to_param, json.getString("value")); + } + } + logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); + ReadUtil.write(itemMap, server); + + } /** @@ -525,12 +532,42 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme taskserver.update(task); requireSucess = true; String next_addr = nextdevice.getExtraValue().get("address").toString(); - this.writing("to_target", next_addr); - this.writing("to_task", instdto.getInstruction_code()); - this.writing("to_command", "1"); - this.writing("to_task", instdto.getInstruction_code()); - this.writing("to_target", next_addr); - this.writing("to_command", "1"); + + List list = new ArrayList(); + Map map = new HashMap(); + map.put("code","to_target"); + map.put("value",next_addr); + list.add(map); + Map map2 = new HashMap(); + map2.put("code","to_task"); + map2.put("value",instdto.getInstruction_code()); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code","to_command"); + map3.put("value","1"); + list.add(map3); + this.writing(list); + + } else { + Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code); + Device nextdevice = deviceAppservice.findDeviceByCode(inst.getNext_device_code()); + String next_addr = nextdevice.getExtraValue().get("address").toString(); + + List list = new ArrayList(); + Map map = new HashMap(); + map.put("code","to_target"); + map.put("value",next_addr); + list.add(map); + Map map2 = new HashMap(); + map2.put("code","to_task"); + map2.put("value",inst.getInstruction_code()); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code","to_command"); + map3.put("value","1"); + list.add(map3); + this.writing(list); + } return true; } @@ -598,4 +635,6 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme } } + + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/ItemProtocol.java index 60d25754f..4242ed5ed 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/ItemProtocol.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/ItemProtocol.java @@ -114,5 +114,11 @@ public class ItemProtocol { } + @Override + public String toString() { + return ""; + } + + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java index 5a3ad75c7..fbc35bfff 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java @@ -21,6 +21,7 @@ import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.log.service.DeviceExecuteLogService; import org.nl.acs.monitor.DeviceStageMonitor; import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; @@ -64,6 +65,8 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe @Autowired AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); + @Autowired + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); String container; protected String barcode = null; @@ -214,12 +217,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe this.setIsonline(false); this.setIserror(true); message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 + } else { this.setIsonline(true); this.setIserror(false); @@ -426,12 +424,50 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe instructionService.create(instdto); //创建指令后修改任务状态 WQLObject taskwo = WQLObject.getWQLObject("acs_task"); - task.setTask_status("1"); //创建指令后修改任务状态 task.setTask_status("1"); taskserver.update(task); +// this.writing("to_command","1"); +// if(StrUtil.isNotEmpty(task.getTo_z())){ +// if(StrUtil.equals(task.getTo_z(),"01")){ +// this.writing("to_target","102"); +// } else if(StrUtil.equals(task.getTo_z(),"02")){ +// this.writing("to_target","201"); +// } else if(StrUtil.equals(task.getTo_z(),"03")){ +// this.writing("to_target","301"); +// } +// } +// this.writing("to_command","1"); +// this.writing("to_task",instdto.getInstruction_code()); + List list = new ArrayList(); + Map map = new HashMap(); + + if(StrUtil.isNotEmpty(task.getTo_z())){ + if(StrUtil.equals(task.getTo_z(),"01")){ + map.put("code","to_target"); + map.put("value","102"); + } else if(StrUtil.equals(task.getTo_z(),"02")){ + map.put("code","to_target"); + map.put("value","201"); + } else if(StrUtil.equals(task.getTo_z(),"03")){ + map.put("code","to_target"); + map.put("value","301"); + } + } + list.add(map); + Map map2 = new HashMap(); + map2.put("code","to_task"); + map2.put("value",instdto.getInstruction_code()); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code","to_command"); + map3.put("value","1"); + list.add(map3); + this.writing(list); + + requireSucess = true; applySucess = true; } else { log.info("未找到载具号{}对应任务", container_code); @@ -531,15 +567,56 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe //创建指令后修改任务状态 task.setTask_status("1"); taskserver.update(task); + + + +// this.writing("to_command","1"); +// if(StrUtil.isNotEmpty(task.getTo_z())){ +// if(StrUtil.equals(task.getTo_z(),"01")){ +// this.writing("to_target","102"); +// } else if(StrUtil.equals(task.getTo_z(),"02")){ +// this.writing("to_target","201"); +// } else if(StrUtil.equals(task.getTo_z(),"03")){ +// this.writing("to_target","301"); +// } +// } +// this.writing("to_command","1"); +// this.writing("to_task",instdto.getInstruction_code()); + + List list = new ArrayList(); + Map map = new HashMap(); + + if(StrUtil.isNotEmpty(task.getTo_z())){ + if(StrUtil.equals(task.getTo_z(),"01")){ + map.put("code","to_target"); + map.put("value","102"); + } else if(StrUtil.equals(task.getTo_z(),"02")){ + map.put("code","to_target"); + map.put("value","201"); + } else if(StrUtil.equals(task.getTo_z(),"03")){ + map.put("code","to_target"); + map.put("value","301"); + } + } + list.add(map); + Map map2 = new HashMap(); + map2.put("code","to_task"); + map2.put("value",instdto.getInstruction_code()); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code","to_command"); + map3.put("value","1"); + list.add(map3); + this.writing(list); + requireSucess = true; applySucess = true; } else { if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { message = "申请任务中..."; JSONObject apply = new JSONObject(); - apply.put("type", "6"); apply.put("vehicle_code", container_code); - apply.put("point_code", device_code); + apply.put("device_code", device_code); String str = acsToWmsService.applyTaskToWms(apply); JSONObject jo = JSON.parseObject(str); if (ObjectUtil.isEmpty(jo)) { @@ -559,6 +636,39 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe } } + + public void writing(String param, String value) { + + String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + param; + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + + itemMap.put(to_param, Integer.parseInt(value)); +// itemMap.put(to_param, Integer.parseInt(value)); + ReadUtil.write(itemMap, server); + + } + + public void writing(List list) { + + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + for (int i = 0; i < list.size(); i++) { + Object ob = list.get(i); + JSONObject json = (JSONObject) JSONObject.toJSON(ob); + if (!StrUtil.isEmpty(json.getString("value"))) { + String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + json.getString("code"); + itemMap.put(to_param, json.getString("value")); + } + } + logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); + ReadUtil.write(itemMap, server); + } + @Override public JSONObject getDeviceStatusName() { JSONObject jo = new JSONObject(); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java index f38d2a1d4..ec7c36f5d 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java @@ -11,12 +11,6 @@ public interface AcsToWmsService { /** * ACS向WMS申请任务 - * type:必填;1共挤线申请空盘、2共挤线满托入库、3油漆线申请空盘、4油漆线申请物料、5油漆线空盘入库、6、一楼空托入库 - * point_code:必填; - * vehicle_num 载具数量 - * vehicle_type 载具类型 - * vehicle_code 载具号 - * qty 物料数量 */ String applyTaskToWms(JSONObject jo); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToLiKuServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToLiKuServiceImpl.java index fdd95590f..0e76e858b 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToLiKuServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToLiKuServiceImpl.java @@ -7,6 +7,7 @@ import org.nl.acs.ext.wms.RespUtil; import org.nl.acs.ext.wms.AcsUtil; import org.nl.acs.ext.wms.liKuData.*; import org.nl.acs.ext.wms.service.AcsToLiKuService; +import org.slf4j.MDC; import org.springframework.stereotype.Service; /** @@ -22,61 +23,131 @@ public class AcsToLiKuServiceImpl implements AcsToLiKuService { private final AddressService addressService; + private String log_file_type="log_file_type"; + private String log_type="ACS请求立库"; + @Override public Resp inStore(InStoreRequest requestParam) { - String api = addressService.findByCode("inStore").getMethods_url(); - String result = AcsUtil.notifyAcs(api, requestParam); - return RespUtil.getResp(result, new InStoreResponse()); + try { + MDC.put(log_file_type, log_type); + String api = addressService.findByCode("inStore").getMethods_url(); + log.info("inStore-----输入参数{}", requestParam); + String result = AcsUtil.notifyAcs(api, requestParam); + log.info("inStore-----输出参数{}", result); + return RespUtil.getResp(result, new InStoreResponse()); + } finally { + MDC.remove(log_file_type); + } + } @Override public Resp outStore(OutStoreRequest requestParam) { - String api = addressService.findByCode("outStore").getMethods_url(); - String result = AcsUtil.notifyAcs(api, requestParam); - return RespUtil.getResp(result, new OutStoreResponse()); + try { + MDC.put(log_file_type, log_type); + log.info("outStore-----输入参数{}", requestParam); + String api = addressService.findByCode("outStore").getMethods_url(); + String result = AcsUtil.notifyAcs(api, requestParam); + log.info("outStore-----输出参数{}", result); + return RespUtil.getResp(result, new OutStoreResponse()); + } finally { + MDC.remove(log_file_type); + } + } @Override public Resp emptyVehicleOutStore(EmptyVehicleOutStoreRequest requestParam) { - String api = addressService.findByCode("emptyVehicleOutStore").getMethods_url(); - String result = AcsUtil.notifyAcs(api, requestParam); - return RespUtil.getResp(result, new EmptyVehicleOutStoreResponse()); + try { + MDC.put(log_file_type, log_type); + log.info("emptyVehicleOutStore-----输入参数{}", requestParam); + String api = addressService.findByCode("emptyVehicleOutStore").getMethods_url(); + String result = AcsUtil.notifyAcs(api, requestParam); + log.info("emptyVehicleOutStore-----输出参数{}", result); + return RespUtil.getResp(result, new EmptyVehicleOutStoreResponse()); + } finally { + MDC.remove(log_file_type); + } + } @Override public Resp moveStore(MoveStoreRequest requestParam) { - String api = addressService.findByCode("moveStore").getMethods_url(); - String result = AcsUtil.notifyAcs(api, requestParam); - return RespUtil.getResp(result, new MoveStoreResponse()); + try { + MDC.put(log_file_type, log_type); + log.info("moveStore-----输入参数{}", requestParam); + String api = addressService.findByCode("moveStore").getMethods_url(); + String result = AcsUtil.notifyAcs(api, requestParam); + log.info("moveStore-----输出参数{}", result); + return RespUtil.getResp(result, new MoveStoreResponse()); + + } finally { + MDC.remove(log_file_type); + } } @Override public Resp inStoreReset(InStoreResetRequest requestParam) { - String api = addressService.findByCode("inStoreReset").getMethods_url(); - String result = AcsUtil.notifyAcs(api, requestParam); - return RespUtil.getResp(result, new InStoreResetResponse()); + try { + MDC.put(log_file_type, log_type); + log.info("inStoreReset-----输入参数{}", requestParam); + String api = addressService.findByCode("inStoreReset").getMethods_url(); + String result = AcsUtil.notifyAcs(api, requestParam); + log.info("inStoreReset-----输出参数{}", result); + return RespUtil.getResp(result, new InStoreResetResponse()); + } finally { + MDC.remove(log_file_type); + } + } @Override public Resp moveStoreReset(MoveStoreResetRequest requestParam) { - String api = addressService.findByCode("moveStoreReset").getMethods_url(); - String result = AcsUtil.notifyAcs(api, requestParam); - return RespUtil.getResp(result, new MoveStoreResetResponse()); + try { + MDC.put(log_file_type, log_type); + log.info("moveStoreReset-----输入参数{}", requestParam); + String api = addressService.findByCode("moveStoreReset").getMethods_url(); + String result = AcsUtil.notifyAcs(api, requestParam); + log.info("moveStoreReset-----输出参数{}", result); + return RespUtil.getResp(result, new MoveStoreResetResponse()); + + } finally { + MDC.remove(log_file_type); + } + } @Override public Resp roadWayIsLock(RoadWayIsLockRequest requestParam) { - String api = addressService.findByCode("roadWayIsLock").getMethods_url(); - String result = AcsUtil.notifyAcs(api, requestParam); - return RespUtil.getResp(result, new RoadWayIsLockResponse()); + try { + MDC.put(log_file_type, log_type); + log.info("roadWayIsLock-----输入参数{}", requestParam); + String api = addressService.findByCode("roadWayIsLock").getMethods_url(); + String result = AcsUtil.notifyAcs(api, requestParam); + log.info("roadWayIsLock-----输出参数{}", result); + return RespUtil.getResp(result, new RoadWayIsLockResponse()); + + } finally { + MDC.remove(log_file_type); + } + } @Override public Resp cancelTask(CancelTaskRequest requestParam) { - String api = addressService.findByCode("cancelTask").getMethods_url(); - String result = AcsUtil.notifyAcs(api, requestParam); - return RespUtil.getResp(result, new CancelTaskResponse()); + try { + MDC.put(log_file_type, log_type); + log.info("cancelTask-----输入参数{}", requestParam); + String api = addressService.findByCode("cancelTask").getMethods_url(); + String result = AcsUtil.notifyAcs(api, requestParam); + log.info("cancelTask-----输出参数{}", result); + return RespUtil.getResp(result, new CancelTaskResponse()); + + } finally { + MDC.remove(log_file_type); + } + } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java index 4e87063ac..23fdfccb5 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java @@ -20,6 +20,7 @@ import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.system.service.ParamService; +import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; @@ -48,72 +49,90 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { /*@Value("${acsTowms.token}")*/ public String token; + + private String log_file_type="log_file_type"; + private String log_type="ACS请求LMS"; + @Override public String applyTaskToWms(JSONObject jo) { - String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue(); - AddressDto addressDto = addressService.findByCode("applyTaskToWms"); - String url = wmsurl + addressDto.getMethods_url(); - log.info("applyTaskToWms-----请求参数{}", jo.toString()); - HttpResponse result2 = null; try { - result2 = HttpRequest.post(url) - .header("Authorization", token) - .body(String.valueOf(jo)) - .execute(); - System.out.println(result2); - } catch (Exception e) { - String msg = e.getMessage(); - //网络不通 - System.out.println(msg); + MDC.put(log_file_type, log_type); + log.info("applyTaskToWms-----输入参数{}", jo); + String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue(); + AddressDto addressDto = addressService.findByCode("applyTaskToWms"); + String url = wmsurl + addressDto.getMethods_url(); + HttpResponse result2 = null; + try { + result2 = HttpRequest.post(url) + .header("Authorization", token) + .body(String.valueOf(jo)) + .execute(); + System.out.println(result2); + } catch (Exception e) { + String msg = e.getMessage(); + //网络不通 + System.out.println(msg); + } + String type = ""; + if (result2.getStatus() == 200) { + type = "info"; + } else { + type = "error"; + } + log.info("applyTaskToWms-----输出参数{}", result2.body()); + return result2.body(); + + } finally { + MDC.remove(log_file_type); } - String type = ""; - if (result2.getStatus() == 200) { - type = "info"; - } else { - type = "error"; - } - log.info("applyTaskToWms-----输出参数{}", result2.body()); - return result2.body(); + } @Override public HttpResponse feedbackTaskStatusToWms(JSONArray data) { - String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue(); - String task_code = ""; - for (int i = 0; i < data.size(); i++) { - JSONObject json = (JSONObject) data.get(i); - task_code = json.getString("task_code"); - } - TaskDto taskDto = taskService.findByCode(task_code); - String vehicle_code = taskDto.getVehicle_code(); - - HttpResponse result2 = null; - log.info("feedbackTaskStatusToWms-----请求参数{}", data.toString()); - - AddressDto addressDto = addressService.findByCode("feedbackTaskStatusToWms"); - String methods_url = addressDto.getMethods_url(); try { - result2 = HttpRequest.post(wmsurl + methods_url) - .header("Authorization", token).body(String.valueOf(data)) - .execute(); - System.out.println(result2); - } catch (Exception e) { - String msg = e.getMessage(); - //网络不通 - System.out.println(msg); + MDC.put(log_file_type, log_type); + String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue(); + + String task_code = ""; + for (int i = 0; i < data.size(); i++) { + JSONObject json = (JSONObject) data.get(i); + task_code = json.getString("task_code"); + } + TaskDto taskDto = taskService.findByCode(task_code); + String vehicle_code = taskDto.getVehicle_code(); + + HttpResponse result2 = null; + log.info("feedbackTaskStatusToWms-----请求参数{}", data.toString()); + + AddressDto addressDto = addressService.findByCode("feedbackTaskStatusToWms"); + String methods_url = addressDto.getMethods_url(); + try { + result2 = HttpRequest.post(wmsurl + methods_url) + .header("Authorization", token).body(String.valueOf(data)) + .execute(); + System.out.println(result2); + } catch (Exception e) { + String msg = e.getMessage(); + //网络不通 + System.out.println(msg); + } + + String type = ""; + if (result2.getStatus() == 200) { + type = "info"; + } else { + type = "error"; + } + + JSONObject jo = JSONObject.parseObject(result2.body()); + log.info("feedbackTaskStatusToWms-----输出参数{}", jo.toString()); + return result2; + } finally { + MDC.remove(log_file_type); } - String type = ""; - if (result2.getStatus() == 200) { - type = "info"; - } else { - type = "error"; - } - - JSONObject jo = JSONObject.parseObject(result2.body()); - log.info("feedbackTaskStatusToWms-----输出参数{}", jo.toString()); - return result2; } @@ -382,82 +401,103 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { @Override public ApplyLabelingAndBindingResponse applyLabelingAndBindingRequest(ApplyLabelingAndBindingRequest param) { - ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = new ApplyLabelingAndBindingResponse(); - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { - String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); - AddressDto addressDto = addressService.findByCode("applyLabelingAndBinding"); - String methods_url = addressDto.getMethods_url(); - String url = wmsUrl + methods_url; - log.info("ApplyLabelingAndBindingRequest----请求参数{}", param); - try { - String result = HttpRequest.post(url) - .body(JSON.toJSONString(param)) - .execute().body(); - JSONObject jsonObject = JSONObject.parseObject(result); - log.info("ApplyLabelingAndBindingResponse----返回参数{}", result); - applyLabelingAndBindingResponse = JSONObject.toJavaObject(jsonObject, ApplyLabelingAndBindingResponse.class); - } catch (Exception e) { - JSONObject map = new JSONObject(); - map.put("status", 400); - map.put("message", e.getMessage()); - return JSONObject.toJavaObject(map, ApplyLabelingAndBindingResponse.class); + try { + MDC.put(log_file_type, log_type); + ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = new ApplyLabelingAndBindingResponse(); + if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { + String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); + AddressDto addressDto = addressService.findByCode("applyLabelingAndBinding"); + String methods_url = addressDto.getMethods_url(); + String url = wmsUrl + methods_url; + log.info("ApplyLabelingAndBindingRequest----请求参数{}", param); + try { + String result = HttpRequest.post(url) + .body(JSON.toJSONString(param)) + .execute().body(); + JSONObject jsonObject = JSONObject.parseObject(result); + log.info("ApplyLabelingAndBindingResponse----返回参数{}", result); + applyLabelingAndBindingResponse = JSONObject.toJavaObject(jsonObject, ApplyLabelingAndBindingResponse.class); + } catch (Exception e) { + JSONObject map = new JSONObject(); + map.put("status", 400); + map.put("message", e.getMessage()); + return JSONObject.toJavaObject(map, ApplyLabelingAndBindingResponse.class); + } } + return applyLabelingAndBindingResponse; + } finally { + MDC.remove(log_file_type); } - return applyLabelingAndBindingResponse; + + } @Override public LiKuApplyTakResponse liKuApplyTaskRequest(LiKuApplyTaskRequest param) { - LiKuApplyTakResponse liKuApplyTakResponse = new LiKuApplyTakResponse(); - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { - String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); - AddressDto addressDto = addressService.findByCode("liKuApplyTask"); - String methods_url = addressDto.getMethods_url(); - String url = wmsUrl + methods_url; - log.info("LiKuApplyTaskRequest----请求参数{}", param); - try { - String result = HttpRequest.post(url) - .body(JSON.toJSONString(param)) - .execute().body(); - JSONObject jsonObject = JSONObject.parseObject(result); - log.info("LiKuApplyTakResponse----返回参数{}", result); - liKuApplyTakResponse = JSONObject.toJavaObject(jsonObject, LiKuApplyTakResponse.class); - } catch (Exception e) { - JSONObject map = new JSONObject(); - map.put("status", 400); - map.put("message", e.getMessage()); - return JSONObject.toJavaObject(map, LiKuApplyTakResponse.class); + try { + MDC.put(log_file_type, log_type); + LiKuApplyTakResponse liKuApplyTakResponse = new LiKuApplyTakResponse(); + if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { + String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); + AddressDto addressDto = addressService.findByCode("liKuApplyTask"); + String methods_url = addressDto.getMethods_url(); + String url = wmsUrl + methods_url; + log.info("LiKuApplyTaskRequest----请求参数{}", param); + try { + String result = HttpRequest.post(url) + .body(JSON.toJSONString(param)) + .execute().body(); + JSONObject jsonObject = JSONObject.parseObject(result); + log.info("LiKuApplyTakResponse----返回参数{}", result); + liKuApplyTakResponse = JSONObject.toJavaObject(jsonObject, LiKuApplyTakResponse.class); + } catch (Exception e) { + JSONObject map = new JSONObject(); + map.put("status", 400); + map.put("message", e.getMessage()); + return JSONObject.toJavaObject(map, LiKuApplyTakResponse.class); + } } + return liKuApplyTakResponse; + } finally { + MDC.remove(log_file_type); } - return liKuApplyTakResponse; + } @Override public UpdateLKTaskResponse updateLKTaskRequest(UpdateLKTaskRequest param) { - UpdateLKTaskResponse updateLKTaskResponse = new UpdateLKTaskResponse(); - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { - String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); - AddressDto addressDto = addressService.findByCode("liKuApplyTask"); - String methods_url = addressDto.getMethods_url(); - String url = wmsUrl + methods_url; - log.info("UpdateLKTaskResponse----请求参数{}", param); - try { - String result = HttpRequest.post(url) - .body(JSON.toJSONString(param)) - .execute().body(); - JSONObject jsonObject = JSONObject.parseObject(result); - log.info("UpdateLKTaskResponse----返回参数{}", result); - updateLKTaskResponse = JSONObject.toJavaObject(jsonObject, UpdateLKTaskResponse.class); - } catch (Exception e) { - JSONObject map = new JSONObject(); - map.put("status", 400); - map.put("message", e.getMessage()); - return JSONObject.toJavaObject(map, UpdateLKTaskResponse.class); + try { + MDC.put(log_file_type, log_type); + log.info("updateLKTaskRequest-----输入参数{}", param); + UpdateLKTaskResponse updateLKTaskResponse = new UpdateLKTaskResponse(); + if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { + String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); + AddressDto addressDto = addressService.findByCode("liKuApplyTask"); + String methods_url = addressDto.getMethods_url(); + String url = wmsUrl + methods_url; + try { + String result = HttpRequest.post(url) + .body(JSON.toJSONString(param)) + .execute().body(); + log.info("UpdateLKTaskResponse----返回参数{}", result); + + JSONObject jsonObject = JSONObject.parseObject(result); + updateLKTaskResponse = JSONObject.toJavaObject(jsonObject, UpdateLKTaskResponse.class); + } catch (Exception e) { + JSONObject map = new JSONObject(); + map.put("status", 400); + map.put("message", e.getMessage()); + return JSONObject.toJavaObject(map, UpdateLKTaskResponse.class); + } } + + return updateLKTaskResponse; + } finally { + MDC.remove(log_file_type); } - return updateLKTaskResponse; + } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java index 7bde5bfc9..5cb3cff2c 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java @@ -17,6 +17,7 @@ import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; +import org.slf4j.MDC; import org.springframework.stereotype.Service; /** @@ -40,117 +41,139 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService { private final AcsToLiKuService acsToLiKuService; + + private String log_file_type="log_file_type"; + private String log_type="立库请求ACS"; + //入库任务状态反馈 @Override public Resp inStoreReport(InStoreReportRequest requestParam) throws Exception { - String inst_code = requestParam.getOrderId(); - String status = requestParam.getState(); - Instruction inst = instructionService.findByCodeFromCache(inst_code); - TaskDto task = taskService.findByCodeFromCache(inst.getTask_code()); - // 1 已接收 2 开始执行 3执行完成 4 阻挡 5 空洞 - if(StrUtil.equals(status,"1") || StrUtil.equals(status,"2") ){ - inst.setInstruction_status("1"); - instructionService.update(inst); - } else if(StrUtil.equals(status,"3")){ - inst.setInstruction_status("2"); - instructionService.finish(inst.getInstruction_id()); - } else if(StrUtil.equals(status,"4")) { - UpdateLKTaskRequest updateLKTaskRequest = new UpdateLKTaskRequest(); - updateLKTaskRequest.setVehicle_code(inst.getVehicle_code()); - updateLKTaskRequest.setExt_task_id(task.getExt_task_id()); - updateLKTaskRequest.setDtl_type(task.getStorage_task_type()); - updateLKTaskRequest.setSrcLocation(inst.getNext_point_code()); - updateLKTaskRequest.setType("1"); - //调用LMS接口申请获取新库位 - UpdateLKTaskResponse updateLKTaskResponse = acsToWmsService.updateLKTaskRequest(updateLKTaskRequest); - if(updateLKTaskResponse.getstatus() == 200){ - String srcLocation = updateLKTaskResponse.getParameters().get("srcLocation"); - String destLocation = updateLKTaskResponse.getParameters().get("destLocation "); - InStoreResetRequest inStoreResetRequest = new InStoreResetRequest(); - inStoreResetRequest.setFloorNo(Integer.parseInt(inst.getTo_z())); - inStoreResetRequest.setSrcLocation(srcLocation); - inStoreResetRequest.setDestLocation(destLocation); - inStoreResetRequest.setPalletCode(inst.getVehicle_code()); - inStoreResetRequest.setOrderId(inst.getInstruction_code()); - acsToLiKuService.inStoreReset(inStoreResetRequest); - } - } else if(StrUtil.equals(status,"5")) { - UpdateLKTaskRequest updateLKTaskRequest = new UpdateLKTaskRequest(); - updateLKTaskRequest.setVehicle_code(inst.getVehicle_code()); - updateLKTaskRequest.setExt_task_id(task.getExt_task_id()); - updateLKTaskRequest.setDtl_type(task.getStorage_task_type()); - updateLKTaskRequest.setSrcLocation(inst.getNext_point_code()); - updateLKTaskRequest.setType("2"); - //调用LMS接口申请获取新库位 - UpdateLKTaskResponse updateLKTaskResponse = acsToWmsService.updateLKTaskRequest(updateLKTaskRequest); - if(updateLKTaskResponse.getstatus() == 200){ - String srcLocation = updateLKTaskResponse.getParameters().get("srcLocation"); - String destLocation = updateLKTaskResponse.getParameters().get("destLocation "); + try { + MDC.put(log_file_type, log_type); + log.info("入库任务状态反馈-----输入参数{}", requestParam.toString()); + String inst_code = requestParam.getOrderId(); + String status = requestParam.getState(); + Instruction inst = instructionService.findByCodeFromCache(inst_code); + TaskDto task = taskService.findByCodeFromCache(inst.getTask_code()); + // 1 已接收 2 开始执行 3执行完成 4 阻挡 5 空洞 + if(StrUtil.equals(status,"1") || StrUtil.equals(status,"2") ){ + inst.setInstruction_status("1"); + instructionService.update(inst); + } else if(StrUtil.equals(status,"3")){ + inst.setInstruction_status("2"); + instructionService.finish(inst.getInstruction_id()); + } else if(StrUtil.equals(status,"4")) { + UpdateLKTaskRequest updateLKTaskRequest = new UpdateLKTaskRequest(); + updateLKTaskRequest.setVehicle_code(inst.getVehicle_code()); + updateLKTaskRequest.setExt_task_id(task.getExt_task_id()); + updateLKTaskRequest.setDtl_type(task.getStorage_task_type()); + updateLKTaskRequest.setSrcLocation(inst.getNext_point_code()); + updateLKTaskRequest.setType("1"); + //调用LMS接口申请获取新库位 + UpdateLKTaskResponse updateLKTaskResponse = acsToWmsService.updateLKTaskRequest(updateLKTaskRequest); + if(updateLKTaskResponse.getstatus() == 200){ + String srcLocation = updateLKTaskResponse.getParameters().get("srcLocation"); + String destLocation = updateLKTaskResponse.getParameters().get("destLocation "); + InStoreResetRequest inStoreResetRequest = new InStoreResetRequest(); + inStoreResetRequest.setFloorNo(Integer.parseInt(inst.getTo_z())); + inStoreResetRequest.setSrcLocation(srcLocation); + inStoreResetRequest.setDestLocation(destLocation); + inStoreResetRequest.setPalletCode(inst.getVehicle_code()); + inStoreResetRequest.setOrderId(inst.getInstruction_code()); + acsToLiKuService.inStoreReset(inStoreResetRequest); + } + } else if(StrUtil.equals(status,"5")) { + UpdateLKTaskRequest updateLKTaskRequest = new UpdateLKTaskRequest(); + updateLKTaskRequest.setVehicle_code(inst.getVehicle_code()); + updateLKTaskRequest.setExt_task_id(task.getExt_task_id()); + updateLKTaskRequest.setDtl_type(task.getStorage_task_type()); + updateLKTaskRequest.setSrcLocation(inst.getNext_point_code()); + updateLKTaskRequest.setType("2"); + //调用LMS接口申请获取新库位 + UpdateLKTaskResponse updateLKTaskResponse = acsToWmsService.updateLKTaskRequest(updateLKTaskRequest); + if(updateLKTaskResponse.getstatus() == 200){ + String srcLocation = updateLKTaskResponse.getParameters().get("srcLocation"); + String destLocation = updateLKTaskResponse.getParameters().get("destLocation "); - InStoreResetRequest inStoreResetRequest = new InStoreResetRequest(); - inStoreResetRequest.setFloorNo(Integer.parseInt(inst.getTo_z())); - inStoreResetRequest.setSrcLocation(srcLocation); - inStoreResetRequest.setDestLocation(destLocation); - inStoreResetRequest.setPalletCode(inst.getVehicle_code()); - inStoreResetRequest.setOrderId(inst.getInstruction_code()); - acsToLiKuService.inStoreReset(inStoreResetRequest); + InStoreResetRequest inStoreResetRequest = new InStoreResetRequest(); + inStoreResetRequest.setFloorNo(Integer.parseInt(inst.getTo_z())); + inStoreResetRequest.setSrcLocation(srcLocation); + inStoreResetRequest.setDestLocation(destLocation); + inStoreResetRequest.setPalletCode(inst.getVehicle_code()); + inStoreResetRequest.setOrderId(inst.getInstruction_code()); + acsToLiKuService.inStoreReset(inStoreResetRequest); + } } + InStoreReportResponse inStoreReportResponse = new InStoreReportResponse(); + inStoreReportResponse.setOrderId(inst_code); + JSONObject result = new JSONObject(); + result.put("result", "true"); + result.put("code", "0"); + result.put("comment", ""); + result.put("data", inStoreReportResponse ); + log.info("入库任务状态反馈-----输出参数{}", result); + return RespUtil.getResp(result.toString(), new InStoreReportResponse()); + } finally { + MDC.remove(log_file_type); } - InStoreReportResponse inStoreReportResponse = new InStoreReportResponse(); - inStoreReportResponse.setOrderId(inst_code); - JSONObject result = new JSONObject(); - result.put("result", "true"); - result.put("code", "0"); - result.put("comment", ""); - result.put("data", inStoreReportResponse ); - return RespUtil.getResp(result.toString(), new InStoreReportResponse()); + } @Override public Resp outStoreReport(OutStoreReportRequest requestParam) throws Exception { - String inst_code = requestParam.getOrderId(); - String status = requestParam.getState(); - Instruction inst = instructionService.findByCodeFromCache(inst_code); - TaskDto task = taskService.findByCodeFromCache(inst.getTask_code()); + try { + MDC.put(log_file_type, log_type); + log.info("出库任务状态反馈-----输入参数{}", requestParam.toString()); + String inst_code = requestParam.getOrderId(); + String status = requestParam.getState(); + Instruction inst = instructionService.findByCodeFromCache(inst_code); + TaskDto task = taskService.findByCodeFromCache(inst.getTask_code()); - // 1 已接收 2 开始执行 3执行完成 4 阻挡 5 空洞 - if(StrUtil.equals(status,"1") || StrUtil.equals(status,"2") ){ - inst.setInstruction_status("1"); - } else if(StrUtil.equals(status,"3")){ - inst.setInstruction_status("2"); - instructionService.finish(inst.getInstruction_id()); - //出库任务起点无货 - } else if(StrUtil.equals(status,"4")){ - UpdateLKTaskRequest updateLKTaskRequest = new UpdateLKTaskRequest(); - updateLKTaskRequest.setVehicle_code(inst.getVehicle_code()); - updateLKTaskRequest.setExt_task_id(task.getExt_task_id()); - updateLKTaskRequest.setDtl_type(task.getStorage_task_type()); - updateLKTaskRequest.setSrcLocation(inst.getStart_point_code()); - updateLKTaskRequest.setType("5"); - //调用LMS接口 - UpdateLKTaskResponse updateLKTaskResponse = acsToWmsService.updateLKTaskRequest(updateLKTaskRequest); + // 1 已接收 2 开始执行 3执行完成 4 阻挡 5 空洞 + if(StrUtil.equals(status,"1") || StrUtil.equals(status,"2") ){ + inst.setInstruction_status("1"); + instructionService.update(inst); + } else if(StrUtil.equals(status,"3")){ + inst.setInstruction_status("2"); + instructionService.finish(inst.getInstruction_id()); + //出库任务起点无货 + } else if(StrUtil.equals(status,"4")){ + UpdateLKTaskRequest updateLKTaskRequest = new UpdateLKTaskRequest(); + updateLKTaskRequest.setVehicle_code(inst.getVehicle_code()); + updateLKTaskRequest.setExt_task_id(task.getExt_task_id()); + updateLKTaskRequest.setDtl_type(task.getStorage_task_type()); + updateLKTaskRequest.setSrcLocation(inst.getStart_point_code()); + updateLKTaskRequest.setType("5"); + //调用LMS接口 + UpdateLKTaskResponse updateLKTaskResponse = acsToWmsService.updateLKTaskRequest(updateLKTaskRequest); - } else if(StrUtil.equals(status,"5")){ - UpdateLKTaskRequest updateLKTaskRequest = new UpdateLKTaskRequest(); - updateLKTaskRequest.setVehicle_code(inst.getVehicle_code()); - updateLKTaskRequest.setExt_task_id(task.getExt_task_id()); - updateLKTaskRequest.setDtl_type(task.getStorage_task_type()); - updateLKTaskRequest.setSrcLocation(inst.getStart_point_code()); - updateLKTaskRequest.setType("6"); - UpdateLKTaskResponse updateLKTaskResponse = acsToWmsService.updateLKTaskRequest(updateLKTaskRequest); + } else if(StrUtil.equals(status,"5")){ + UpdateLKTaskRequest updateLKTaskRequest = new UpdateLKTaskRequest(); + updateLKTaskRequest.setVehicle_code(inst.getVehicle_code()); + updateLKTaskRequest.setExt_task_id(task.getExt_task_id()); + updateLKTaskRequest.setDtl_type(task.getStorage_task_type()); + updateLKTaskRequest.setSrcLocation(inst.getStart_point_code()); + updateLKTaskRequest.setType("6"); + UpdateLKTaskResponse updateLKTaskResponse = acsToWmsService.updateLKTaskRequest(updateLKTaskRequest); + } + OutStoreReportResponse outStoreReportResponse = new OutStoreReportResponse(); + outStoreReportResponse.setOrderId(inst_code); + JSONObject result = new JSONObject(); + result.put("result", "true"); + result.put("code", "0"); + result.put("comment", ""); + result.put("data", outStoreReportResponse ); + log.info("出库任务状态反馈-----输出参数{}", result); + + return RespUtil.getResp(result.toString(), new OutStoreReportResponse()); + } finally { + MDC.remove(log_file_type); } - OutStoreReportResponse outStoreReportResponse = new OutStoreReportResponse(); - outStoreReportResponse.setOrderId(inst_code); - JSONObject result = new JSONObject(); - result.put("result", "true"); - result.put("code", "0"); - result.put("comment", ""); - result.put("data", outStoreReportResponse ); - return RespUtil.getResp(result.toString(), new OutStoreReportResponse()); + } @@ -158,70 +181,80 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService { //移库任务上报 @Override public Resp moveStoreReport(MoveStoreReportRequest requestParam) throws Exception { - String inst_code = requestParam.getOrderId(); - String status = requestParam.getState(); - Instruction inst = instructionService.findByCodeFromCache(inst_code); - TaskDto task = taskService.findByCodeFromCache(inst.getTask_code()); - // 1 已接收 2 开始执行 3执行完成 4 阻挡 5 空洞 - if(StrUtil.equals(status,"1") || StrUtil.equals(status,"2") ){ - inst.setInstruction_status("1"); - } else if(StrUtil.equals(status,"3")){ - inst.setInstruction_status("2"); - instructionService.finish(inst.getInstruction_id()); - } else if(StrUtil.equals(status,"4")){ - UpdateLKTaskRequest updateLKTaskRequest = new UpdateLKTaskRequest(); - updateLKTaskRequest.setVehicle_code(inst.getVehicle_code()); - updateLKTaskRequest.setExt_task_id(task.getExt_task_id()); - updateLKTaskRequest.setDtl_type(task.getStorage_task_type()); - updateLKTaskRequest.setSrcLocation(inst.getStart_point_code()); - updateLKTaskRequest.setType("3"); - //调用LMS接口 - UpdateLKTaskResponse updateLKTaskResponse = acsToWmsService.updateLKTaskRequest(updateLKTaskRequest); - if(updateLKTaskResponse.getstatus() == 200){ - String srcLocation = updateLKTaskResponse.getParameters().get("srcLocation"); - String destLocation = updateLKTaskResponse.getParameters().get("destLocation "); + try { + MDC.put(log_file_type, log_type); + log.info("移库任务上报-----输入参数{}", requestParam.toString()); + String inst_code = requestParam.getOrderId(); + String status = requestParam.getState(); + Instruction inst = instructionService.findByCodeFromCache(inst_code); + TaskDto task = taskService.findByCodeFromCache(inst.getTask_code()); + // 1 已接收 2 开始执行 3执行完成 4 阻挡 5 空洞 + if(StrUtil.equals(status,"1") || StrUtil.equals(status,"2") ){ + inst.setInstruction_status("1"); + instructionService.update(inst); - InStoreResetRequest inStoreResetRequest = new InStoreResetRequest(); - inStoreResetRequest.setFloorNo(Integer.parseInt(inst.getTo_z())); - inStoreResetRequest.setSrcLocation(srcLocation); - inStoreResetRequest.setDestLocation(destLocation); - inStoreResetRequest.setPalletCode(inst.getVehicle_code()); - inStoreResetRequest.setOrderId(inst.getInstruction_code()); - acsToLiKuService.inStoreReset(inStoreResetRequest); + } else if(StrUtil.equals(status,"3")){ + inst.setInstruction_status("2"); + instructionService.finish(inst.getInstruction_id()); + } else if(StrUtil.equals(status,"4")){ + UpdateLKTaskRequest updateLKTaskRequest = new UpdateLKTaskRequest(); + updateLKTaskRequest.setVehicle_code(inst.getVehicle_code()); + updateLKTaskRequest.setExt_task_id(task.getExt_task_id()); + updateLKTaskRequest.setDtl_type(task.getStorage_task_type()); + updateLKTaskRequest.setSrcLocation(inst.getStart_point_code()); + updateLKTaskRequest.setType("3"); + //调用LMS接口 + UpdateLKTaskResponse updateLKTaskResponse = acsToWmsService.updateLKTaskRequest(updateLKTaskRequest); + if(updateLKTaskResponse.getstatus() == 200){ + String srcLocation = updateLKTaskResponse.getParameters().get("srcLocation"); + String destLocation = updateLKTaskResponse.getParameters().get("destLocation "); + InStoreResetRequest inStoreResetRequest = new InStoreResetRequest(); + inStoreResetRequest.setFloorNo(Integer.parseInt(inst.getTo_z())); + inStoreResetRequest.setSrcLocation(srcLocation); + inStoreResetRequest.setDestLocation(destLocation); + inStoreResetRequest.setPalletCode(inst.getVehicle_code()); + inStoreResetRequest.setOrderId(inst.getInstruction_code()); + acsToLiKuService.inStoreReset(inStoreResetRequest); + + } + + } else if(StrUtil.equals(status,"5")){ + UpdateLKTaskRequest updateLKTaskRequest = new UpdateLKTaskRequest(); + updateLKTaskRequest.setVehicle_code(inst.getVehicle_code()); + updateLKTaskRequest.setExt_task_id(task.getExt_task_id()); + updateLKTaskRequest.setDtl_type(task.getStorage_task_type()); + updateLKTaskRequest.setSrcLocation(inst.getNext_point_code()); + updateLKTaskRequest.setType("4"); + UpdateLKTaskResponse updateLKTaskResponse = acsToWmsService.updateLKTaskRequest(updateLKTaskRequest); + if(updateLKTaskResponse.getstatus() == 200){ + String srcLocation = updateLKTaskResponse.getParameters().get("srcLocation"); + String destLocation = updateLKTaskResponse.getParameters().get("destLocation "); + + InStoreResetRequest inStoreResetRequest = new InStoreResetRequest(); + inStoreResetRequest.setFloorNo(Integer.parseInt(inst.getTo_z())); + inStoreResetRequest.setSrcLocation(srcLocation); + inStoreResetRequest.setDestLocation(destLocation); + inStoreResetRequest.setPalletCode(inst.getVehicle_code()); + inStoreResetRequest.setOrderId(inst.getInstruction_code()); + acsToLiKuService.inStoreReset(inStoreResetRequest); + + } } + MoveStoreReportResponse moveStoreReportResponse = new MoveStoreReportResponse(); + moveStoreReportResponse.setOrderId(inst_code); + JSONObject result = new JSONObject(); + result.put("result", "true"); + result.put("code", "0"); + result.put("comment", ""); + result.put("data", moveStoreReportResponse ); + log.info("移库任务上报-----输出参数{}", result); - } else if(StrUtil.equals(status,"5")){ - UpdateLKTaskRequest updateLKTaskRequest = new UpdateLKTaskRequest(); - updateLKTaskRequest.setVehicle_code(inst.getVehicle_code()); - updateLKTaskRequest.setExt_task_id(task.getExt_task_id()); - updateLKTaskRequest.setDtl_type(task.getStorage_task_type()); - updateLKTaskRequest.setSrcLocation(inst.getNext_point_code()); - updateLKTaskRequest.setType("4"); - UpdateLKTaskResponse updateLKTaskResponse = acsToWmsService.updateLKTaskRequest(updateLKTaskRequest); - if(updateLKTaskResponse.getstatus() == 200){ - String srcLocation = updateLKTaskResponse.getParameters().get("srcLocation"); - String destLocation = updateLKTaskResponse.getParameters().get("destLocation "); - - InStoreResetRequest inStoreResetRequest = new InStoreResetRequest(); - inStoreResetRequest.setFloorNo(Integer.parseInt(inst.getTo_z())); - inStoreResetRequest.setSrcLocation(srcLocation); - inStoreResetRequest.setDestLocation(destLocation); - inStoreResetRequest.setPalletCode(inst.getVehicle_code()); - inStoreResetRequest.setOrderId(inst.getInstruction_code()); - acsToLiKuService.inStoreReset(inStoreResetRequest); - - } + return RespUtil.getResp(result.toString(), new MoveStoreReportResponse()); + } finally { + MDC.remove(log_file_type); } - MoveStoreReportResponse moveStoreReportResponse = new MoveStoreReportResponse(); - moveStoreReportResponse.setOrderId(inst_code); - JSONObject result = new JSONObject(); - result.put("result", "true"); - result.put("code", "0"); - result.put("comment", ""); - result.put("data", moveStoreReportResponse ); - return RespUtil.getResp(result.toString(), new MoveStoreReportResponse()); } 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 7345b7676..05a9ca88b 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 @@ -29,6 +29,7 @@ import org.nl.modules.system.service.ParamService; import org.nl.modules.wql.core.bean.WQLObject; import org.nl.modules.wql.exception.WDKException; import org.nl.modules.wql.util.SpringContextHolder; +import org.slf4j.MDC; import org.springframework.context.ApplicationContext; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; @@ -49,6 +50,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { private final DeviceAppService deviceAppService; private final RouteLineService routeLineService; + private String log_file_type="log_file_type"; + private String log_type="LMS请求ACS"; @Override public CancelTaskResponse cancelFromWms(String param) throws Exception { @@ -137,99 +140,113 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { @Override public PutActionResponse putAction(String jsonObject) throws Exception { - log.info("putAction--------------:输出参数" + jsonObject); - JSONArray datas = JSONArray.parseArray(jsonObject); - PutActionResponse response = new PutActionResponse(); - JSONArray errArr = new JSONArray(); - for (int i = 0; i < datas.size(); i++) { - String data = datas.get(i).toString(); - PutActionRequest request = JsonUtl.format(data, PutActionRequest.class); - String device_code = request.getDevice_code(); - String code = request.getCode(); - String value = request.getValue(); - Device device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device)) { - throw new Exception("未找到对应设备:" + device_code); - } - HongXiangStationDeviceDriver hongXiangStationDeviceDriver; - if (device.getDeviceDriver() instanceof HongXiangStationDeviceDriver) { - hongXiangStationDeviceDriver = (HongXiangStationDeviceDriver) device.getDeviceDriver(); - hongXiangStationDeviceDriver.writing(code, value); + try { + MDC.put(log_file_type, log_type); + log.info("putAction--------------:输出参数" + jsonObject); + JSONArray datas = JSONArray.parseArray(jsonObject); + PutActionResponse response = new PutActionResponse(); + JSONArray errArr = new JSONArray(); + for (int i = 0; i < datas.size(); i++) { + String data = datas.get(i).toString(); + PutActionRequest request = JsonUtl.format(data, PutActionRequest.class); + String device_code = request.getDevice_code(); + String code = request.getCode(); + String value = request.getValue(); + Device device = deviceAppService.findDeviceByCode(device_code); + if (ObjectUtil.isEmpty(device)) { + throw new Exception("未找到对应设备:" + device_code); + } + HongXiangStationDeviceDriver hongXiangStationDeviceDriver; + if (device.getDeviceDriver() instanceof HongXiangStationDeviceDriver) { + hongXiangStationDeviceDriver = (HongXiangStationDeviceDriver) device.getDeviceDriver(); + hongXiangStationDeviceDriver.writing(code, value); + } } + response.setStatus(200); + response.setMessage("success"); + log.info("putAction--------------:输出参数:" + response); + return response; + } finally { + MDC.remove(log_file_type); } - response.setStatus(200); - response.setMessage("success"); - log.info("putAction--------------:输出参数:" + response); - return response; + } @Override public Map queryDevice(String jsonObject) throws Exception { - log.info("queryDevice--------------:输入参数" + jsonObject.toString()); - JSONArray backja = new JSONArray(); - JSONArray datas = JSONArray.parseArray(jsonObject); + try { + MDC.put(log_file_type, log_type); + log.info("queryDevice--------------:输入参数" + jsonObject.toString()); + JSONArray backja = new JSONArray(); + JSONArray datas = JSONArray.parseArray(jsonObject); - //AGV烘箱对接位 - HongXiangStationDeviceDriver hongXiangStationDeviceDriver; - //烘箱工位 - HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - //货梯对接线-带扫码器 - StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver; + //AGV烘箱对接位 + HongXiangStationDeviceDriver hongXiangStationDeviceDriver; + //烘箱工位 + HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; + //货梯对接线-带扫码器 + StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver; - if (datas.size() == 0) { - throw new BadRequestException("缺少输入参数!"); + if (datas.size() == 0) { + throw new BadRequestException("缺少输入参数!"); + } + + for (int i = 0; i < datas.size(); i++) { + JSONObject jo = new JSONObject(); + JSONObject data = datas.getJSONObject(i); + String parent_device_code = data.getString("device_code"); + String device_code = ""; + JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + parent_device_code + "'").uniqueResult(0); + if (!ObjectUtil.isEmpty(device_json)) { + device_code = (String) device_json.get("parent_storage_code") == null ? parent_device_code : (String) device_json.get("storage_code"); + } + Device device = deviceAppService.findDeviceByCode(device_code); + if (ObjectUtil.isEmpty(device)) { + throw new Exception("未找到对应设备:" + parent_device_code); + } + + if (device.getDeviceDriver() instanceof HongXiangStationDeviceDriver) { + hongXiangStationDeviceDriver = (HongXiangStationDeviceDriver) device.getDeviceDriver(); + jo.put("device_code", parent_device_code); + jo.put("mode", hongXiangStationDeviceDriver.getMode()); + jo.put("move", hongXiangStationDeviceDriver.getMove()); + + } else if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver(); + jo.put("device_code", parent_device_code); + jo.put("mode", hongXiangConveyorDeviceDriver.getMode()); + jo.put("move", hongXiangConveyorDeviceDriver.getMove()); + jo.put("countdown_house", hongXiangConveyorDeviceDriver.getCountdown_house()); + jo.put("countdown_min", hongXiangConveyorDeviceDriver.getCountdown_min()); + jo.put("countdown_sec", hongXiangConveyorDeviceDriver.getCountdown_sec()); + jo.put("temperature", hongXiangConveyorDeviceDriver.getTemperature()); + jo.put("door", hongXiangConveyorDeviceDriver.getDoor()); + jo.put("finish", hongXiangConveyorDeviceDriver.getFinish()); + jo.put("task", hongXiangConveyorDeviceDriver.getTask()); + jo.put("error", hongXiangConveyorDeviceDriver.getError()); + } else if (device.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) { + standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) device.getDeviceDriver(); + jo.put("device_code", parent_device_code); + jo.put("move", standardCoveyorControlWithScannerDeviceDriver.getMove()); + jo.put("action", standardCoveyorControlWithScannerDeviceDriver.getAction()); + jo.put("error", standardCoveyorControlWithScannerDeviceDriver.getError()); + } else { + jo.put("device_code", parent_device_code); + } + backja.add(jo); + } + JSONObject resultJson = new JSONObject(); + resultJson.put("status", HttpStatus.OK.value()); + resultJson.put("message", "操作成功"); + resultJson.put("data", backja); + log.info("queryDevice--------------:输出参数" + resultJson.toString()); + return resultJson; + + } finally { + MDC.remove(log_file_type); } - for (int i = 0; i < datas.size(); i++) { - JSONObject jo = new JSONObject(); - JSONObject data = datas.getJSONObject(i); - String parent_device_code = data.getString("device_code"); - String device_code = ""; - JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + parent_device_code + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(device_json)) { - device_code = (String) device_json.get("parent_storage_code") == null ? parent_device_code : (String) device_json.get("storage_code"); - } - Device device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device)) { - throw new Exception("未找到对应设备:" + parent_device_code); - } - if (device.getDeviceDriver() instanceof HongXiangStationDeviceDriver) { - hongXiangStationDeviceDriver = (HongXiangStationDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", parent_device_code); - jo.put("mode", hongXiangStationDeviceDriver.getMode()); - jo.put("move", hongXiangStationDeviceDriver.getMove()); - - } else if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", parent_device_code); - jo.put("mode", hongXiangConveyorDeviceDriver.getMode()); - jo.put("move", hongXiangConveyorDeviceDriver.getMove()); - jo.put("countdown_house", hongXiangConveyorDeviceDriver.getCountdown_house()); - jo.put("countdown_min", hongXiangConveyorDeviceDriver.getCountdown_min()); - jo.put("countdown_sec", hongXiangConveyorDeviceDriver.getCountdown_sec()); - jo.put("temperature", hongXiangConveyorDeviceDriver.getTemperature()); - jo.put("door", hongXiangConveyorDeviceDriver.getDoor()); - jo.put("finish", hongXiangConveyorDeviceDriver.getFinish()); - jo.put("task", hongXiangConveyorDeviceDriver.getTask()); - jo.put("error", hongXiangConveyorDeviceDriver.getError()); - } else if (device.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) { - standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", parent_device_code); - jo.put("move", standardCoveyorControlWithScannerDeviceDriver.getMove()); - jo.put("action", standardCoveyorControlWithScannerDeviceDriver.getAction()); - jo.put("error", standardCoveyorControlWithScannerDeviceDriver.getError()); - } else { - jo.put("device_code", parent_device_code); - } - backja.add(jo); - } - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.OK.value()); - resultJson.put("message", "操作成功"); - resultJson.put("data", backja); - log.info("queryDevice--------------:输出参数" + resultJson.toString()); - return resultJson; } @@ -276,193 +293,202 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { @Override public CreateTaskResponse crateTask(String param) { - JSONArray datas = JSONArray.parseArray(param); - CreateTaskResponse response = new CreateTaskResponse(); - JSONArray errArr = new JSONArray(); - for (int i = 0; i < datas.size(); i++) { - String data = datas.get(i).toString(); - CreateTaskRequest request = JsonUtl.format(data, CreateTaskRequest.class); - String ext_task_id = request.getExt_task_id(); - String task_code = request.getTask_code(); - String start_device_code = request.getStart_device_code(); - String start_device_code2 = request.getStart_device_code2(); - String next_device_code = request.getNext_device_code(); - String next_device_code2 = request.getNext_device_code2(); - String put_device_code = request.getPut_device_code(); - String priority = request.getPriority(); - String vehicle_code = request.getVehicle_code(); - String vehicle_type = request.getVehicle_type(); - String route_plan_code = request.getRoute_plan_code(); - String task_type = request.getTask_type(); - String storage_task_type = request.getDtl_type(); - String agv_system_type = request.getAgv_system_type(); - String remark = request.getRemark(); - double oven_time = 0.00d; - if (StrUtil.isNotEmpty(request.getOven_time())) { - oven_time = Double.parseDouble(request.getOven_time()); - } - String temperature = request.getTemperature(); - Map params = request.getParams(); - - String start_point_code = ""; - String start_point_code2 = ""; - String next_point_code = ""; - String next_point_code2 = ""; - String put_point_code = ""; - if (StrUtil.isEmpty(task_code)) { - throw new WDKException("任务号不能为空"); - } - if (StrUtil.isEmpty(start_device_code)) { - throw new WDKException("起点不能为空"); - } - if (StrUtil.isEmpty(next_device_code)) { - throw new WDKException("终点不能为空"); - } - - - JSONObject start_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + start_device_code + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(start_device_json)) { - start_point_code = (String) start_device_json.get("parent_storage_code") == null ? start_device_code : (String) start_device_json.get("storage_code"); - } - JSONObject next_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + next_device_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"); - } - JSONObject start_device_json2 = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + start_device_code2 + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(start_device_json2)) { - start_point_code2 = (String) start_device_json2.get("parent_storage_code") == null ? start_device_code2 : (String) start_device_json.get("storage_code"); - } - JSONObject next_device_json2 = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + next_device_code2 + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(next_device_json2)) { - next_point_code2 = (String) next_device_json2.get("parent_storage_code") == null ? next_device_code2 : (String) next_device_json.get("storage_code"); - } - JSONObject put_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + put_device_code + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(put_device_json)) { - put_point_code = (String) put_device_json.get("parent_storage_code") == null ? put_device_code : (String) next_device_json.get("storage_code"); - } - 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 (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 (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 (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 (StrUtil.isNotEmpty(put_point_code) && put_point_code.indexOf("-") > 0) { - String str[] = put_point_code.split("-"); - put_device_code = str[0]; - } else { - put_device_code = put_point_code; - } - - if (StrUtil.isEmpty(route_plan_code)) { - route_plan_code = "normal"; - } - - 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("已存在该载具号的任务!"); + try { + MDC.put(log_file_type, log_type); + log.info("crateTask-----输入参数{}", param); + JSONArray datas = JSONArray.parseArray(param); + CreateTaskResponse response = new CreateTaskResponse(); + JSONArray errArr = new JSONArray(); + for (int i = 0; i < datas.size(); i++) { + String data = datas.get(i).toString(); + CreateTaskRequest request = JsonUtl.format(data, CreateTaskRequest.class); + String ext_task_id = request.getExt_task_id(); + String task_code = request.getTask_code(); + String start_device_code = request.getStart_device_code(); + String start_device_code2 = request.getStart_device_code2(); + String next_device_code = request.getNext_device_code(); + String next_device_code2 = request.getNext_device_code2(); + String put_device_code = request.getPut_device_code(); + String priority = request.getPriority(); + String vehicle_code = request.getVehicle_code(); + String vehicle_type = request.getVehicle_type(); + String route_plan_code = request.getRoute_plan_code(); + String task_type = request.getTask_type(); + String storage_task_type = request.getDtl_type(); + String agv_system_type = request.getAgv_system_type(); + String remark = request.getRemark(); + double oven_time = 0.00d; + if (StrUtil.isNotEmpty(request.getOven_time())) { + oven_time = Double.parseDouble(request.getOven_time()); } - } + String temperature = request.getTemperature(); + Map params = request.getParams(); - if (StrUtil.isEmpty(start_point_code)) { - JSONObject json = new JSONObject(); - json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); - json.put("message", request.getStart_device_code() + " 该设备号未找到对应点位"); - 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_id); - json.put("message", request.getNext_device_code() + " 该设备号未找到对应点位"); - errArr.add(json); - continue; - } + String start_point_code = ""; + String start_point_code2 = ""; + String next_point_code = ""; + String next_point_code2 = ""; + String put_point_code = ""; + if (StrUtil.isEmpty(task_code)) { + throw new WDKException("任务号不能为空"); + } + if (StrUtil.isEmpty(start_device_code)) { + throw new WDKException("起点不能为空"); + } + if (StrUtil.isEmpty(next_device_code)) { + 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_point_code2", start_point_code2); - jo.put("next_point_code2", next_point_code2); - jo.put("put_point_code", put_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("start_device_code2", start_device_code2); - jo.put("next_device_code2", next_device_code2); - jo.put("put_device_code", put_device_code); - jo.put("priority", priority); - jo.put("vehicle_code", vehicle_code); - jo.put("vehicle_type", vehicle_type); - jo.put("storage_task_type", storage_task_type); - jo.put("agv_system_type", agv_system_type); - jo.put("oven_time", (int) Math.ceil(oven_time)); - 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 { - // task_type=7 则是立库任务需要下刻下发 - if (StrUtil.equals(task_dto.getTask_type(), "7")) { - taskService.create(task_dto); + JSONObject start_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + start_device_code + "'").uniqueResult(0); + if (!ObjectUtil.isEmpty(start_device_json)) { + start_point_code = (String) start_device_json.get("parent_storage_code") == null ? start_device_code : (String) start_device_json.get("storage_code"); + } + JSONObject next_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + next_device_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"); + } + JSONObject start_device_json2 = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + start_device_code2 + "'").uniqueResult(0); + if (!ObjectUtil.isEmpty(start_device_json2)) { + start_point_code2 = (String) start_device_json2.get("parent_storage_code") == null ? start_device_code2 : (String) start_device_json.get("storage_code"); + } + JSONObject next_device_json2 = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + next_device_code2 + "'").uniqueResult(0); + if (!ObjectUtil.isEmpty(next_device_json2)) { + next_point_code2 = (String) next_device_json2.get("parent_storage_code") == null ? next_device_code2 : (String) next_device_json.get("storage_code"); + } + JSONObject put_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + put_device_code + "'").uniqueResult(0); + if (!ObjectUtil.isEmpty(put_device_json)) { + put_point_code = (String) put_device_json.get("parent_storage_code") == null ? put_device_code : (String) next_device_json.get("storage_code"); + } + if (StrUtil.isNotEmpty(start_point_code) && start_point_code.indexOf("-") > 0) { + String str[] = start_point_code.split("-"); + start_device_code = str[0]; } else { - taskService.create(task_dto); + start_device_code = start_point_code; } - } 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)) { - response.setStatus(200); - } else { - response.setStatus(400); - } - response.setMessage("success"); - response.setErrArr(errArr); - log.info("createFromWms--------------:输出参数:" + response); - return response; + 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 (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 (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 (StrUtil.isNotEmpty(put_point_code) && put_point_code.indexOf("-") > 0) { + String str[] = put_point_code.split("-"); + put_device_code = str[0]; + } else { + put_device_code = put_point_code; + } + + if (StrUtil.isEmpty(route_plan_code)) { + route_plan_code = "normal"; + } + + 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("已存在该载具号的任务!"); + } + } + + if (StrUtil.isEmpty(start_point_code)) { + JSONObject json = new JSONObject(); + json.put("task_code", task_code); + json.put("ext_task_id", ext_task_id); + json.put("message", request.getStart_device_code() + " 该设备号未找到对应点位"); + 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_id); + json.put("message", request.getNext_device_code() + " 该设备号未找到对应点位"); + errArr.add(json); + continue; + } + + 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_point_code2", start_point_code2); + jo.put("next_point_code2", next_point_code2); + jo.put("put_point_code", put_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("start_device_code2", start_device_code2); + jo.put("next_device_code2", next_device_code2); + jo.put("put_device_code", put_device_code); + jo.put("priority", priority); + jo.put("vehicle_code", vehicle_code); + jo.put("vehicle_type", vehicle_type); + jo.put("storage_task_type", storage_task_type); + jo.put("agv_system_type", agv_system_type); + jo.put("oven_time", (int) Math.ceil(oven_time)); + 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 { + // task_type=7 则是立库任务需要下刻下发 + if (StrUtil.equals(task_dto.getTask_type(), "7")) { + taskService.create(task_dto); + } else { + 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)) { + response.setStatus(200); + } else { + response.setStatus(400); + } + response.setMessage("success"); + response.setErrArr(errArr); + log.info("createFromWms--------------:输出参数:" + response); + + return response; + } finally { + MDC.remove(log_file_type); + } + + + } diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java index 02eca6a5d..6af6f7273 100644 --- a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java +++ b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java @@ -43,6 +43,7 @@ public class AutoCreateInst { String taskcode = acsTask.getTask_code(); String task_type = acsTask.getTask_type(); String vehiclecode = acsTask.getVehicle_code(); + String storage_task_type = acsTask.getStorage_task_type(); String priority = acsTask.getPriority(); String is_send = acsTask.getIs_send(); @@ -70,6 +71,9 @@ public class AutoCreateInst { if (StrUtil.equals(is_send, "0")) { continue; } + if(StrUtil.equals(storage_task_type,"1") || StrUtil.equals(storage_task_type,"2") ){ + continue; + } //校验路由关系 List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); if (ObjectUtils.isEmpty(shortPathsList)) { diff --git a/acs/nladmin-system/src/main/resources/config/application.yml b/acs/nladmin-system/src/main/resources/config/application.yml index 7e3fbea7d..8e1be364d 100644 --- a/acs/nladmin-system/src/main/resources/config/application.yml +++ b/acs/nladmin-system/src/main/resources/config/application.yml @@ -2,14 +2,13 @@ spring: freemarker: check-template-location: false profiles: - active: dev + active: prod jackson: time-zone: GMT+8 data: redis: repositories: enabled: false - #配置 Jpa jpa: hibernate: @@ -18,7 +17,7 @@ spring: properties: hibernate: dialect: org.hibernate.dialect.MySQL5InnoDBDialect - enable_lazy_load_no_trans: true + task: pool: # 核心线程池大小 @@ -44,37 +43,13 @@ rsa: private_key: MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A== logging: file: - path: C:\log\wms - config: classpath:logback-spring.xml -# sa-token白名单配置 -security: - # 排除路径 - excludes: - # 认证 - - /auth/login - - /auth/code - - /auth/logout - # swagger - - /swagger-ui.html - - /swagger-resources/** - - /webjars/** - - /file/** - - /webSocket/** - # 静态资源 - - /*.html - - /**/*.html - - /**/*.css - - /**/*.js - # swagger 文档配置 - - /favicon.ico - - /*/api-docs - - /*/api-docs/** - # druid 监控配置 - - /druid/** - # actuator 监控配置 - - /actuator - - /actuator/** - # 上传 - - /api/localStorage/pictures - # 参数 - - /api/param/getValueByCode + path: C:\logs\nlacs\ +demo: + monitor: + server-url: https://www.demo-monitor.com + username: MessiLoveRidingBike + password: 123456 + +acsTowms: + token: Bearer eyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiI2ZjI2OGMxZjAyOTE0MTNiOWU3YThmMTM2ZTc2MWJkYSIsImF1dGgiOiJhZG1pbiIsInN1YiI6ImFkbWluIn0.lKxY3Wc_efzmBXXAS_dDC_Sfh32kZInxYmaxBzg83e5gviSJPPKolNt4IlCCaGM8HOc_yKByiIu8YFlgQif01Q +