|
|
@ -60,47 +60,38 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
private String log_type = "LMS请求ACS"; |
|
|
|
|
|
|
|
@Override |
|
|
|
public CancelTaskResponse cancelFromWms(String param) throws Exception { |
|
|
|
public CancelTaskResponse cancelFromWms(String param) { |
|
|
|
ParamService paramService = SpringContextHolder.getBean(ParamService.class); |
|
|
|
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); |
|
|
|
JSONArray datas = JSONArray.parseArray(param); |
|
|
|
// JSONArray datas = JSONArray.parseArray(param);
|
|
|
|
CancelTaskResponse response = new CancelTaskResponse(); |
|
|
|
JSONArray errArr = new JSONArray(); |
|
|
|
for (int i = 0; i < datas.size(); i++) { |
|
|
|
String data = datas.get(i).toString(); |
|
|
|
CancelTaskRequest request = JsonUtl.format(param, CancelTaskRequest.class); |
|
|
|
|
|
|
|
String task_uuid = request.getExt_task_id(); |
|
|
|
String task_code = request.getTask_code(); |
|
|
|
// String task_uuid = request.getExt_task_id();
|
|
|
|
String task_code = request.getTASKCODE(); |
|
|
|
String vehicle_code = request.getVehicle_code(); |
|
|
|
|
|
|
|
if (StrUtil.isEmpty(task_uuid)) { |
|
|
|
throw new WDKException("任务标识不能为空"); |
|
|
|
} |
|
|
|
// if (StrUtil.isEmpty(task_uuid)) {
|
|
|
|
// throw new WDKException("任务标识不能为空");
|
|
|
|
// }
|
|
|
|
if (StrUtil.isEmpty(task_code)) { |
|
|
|
throw new WDKException("任务号不能为空"); |
|
|
|
throw new WDKException("任务号不能为空!"); |
|
|
|
} |
|
|
|
String cancelTaskCheck = paramService.findByCode(AcsConfig.CANCELTASKCHECK).getValue(); |
|
|
|
if (StrUtil.equals(cancelTaskCheck, "1")) { |
|
|
|
taskService.cancel(task_uuid); |
|
|
|
taskService.cancelFromCode(task_code); |
|
|
|
} else if (StrUtil.equals(cancelTaskCheck, "0")) { |
|
|
|
Instruction inst = instructionService.findByTaskcode(task_code); |
|
|
|
if (inst == null) { |
|
|
|
taskService.cancel(task_uuid); |
|
|
|
taskService.cancelFromCode(task_code); |
|
|
|
} else { |
|
|
|
throw new RuntimeException("指令正在执行中,操作失败!"); |
|
|
|
throw new RuntimeException("指令正在执行中,操作失败!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(errArr)) { |
|
|
|
response.setStatus(200); |
|
|
|
} else { |
|
|
|
response.setStatus(400); |
|
|
|
} |
|
|
|
response.setStatus(HttpStatus.OK.value()); |
|
|
|
response.setMessage("success"); |
|
|
|
response.setErrArr(errArr); |
|
|
|
log.info("cancelFromWms--------------:输出参数:" + response); |
|
|
|
|
|
|
|
return response; |
|
|
@ -458,12 +449,9 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
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); |
|
|
|
CreateTaskRequest request = JsonUtl.format(param, CreateTaskRequest.class); |
|
|
|
// String ext_task_id = request.getREQCODE();
|
|
|
|
String task_code = request.getTASKCODE(); |
|
|
|
String start_device_code = request.getSTARTPOSITION(); |
|
|
@ -494,21 +482,21 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
if (StrUtil.isEmpty(task_code)) { |
|
|
|
response.setREQCODE(task_code); |
|
|
|
response.setREPLYTIME(DateUtil.now()); |
|
|
|
response.setREQCODE("1"); |
|
|
|
response.setRTCODE("1"); |
|
|
|
response.setRTMSG("任务号不能为空!"); |
|
|
|
return response; |
|
|
|
} |
|
|
|
if (StrUtil.isEmpty(start_device_code)) { |
|
|
|
response.setREQCODE(task_code); |
|
|
|
response.setREPLYTIME(DateUtil.now()); |
|
|
|
response.setREQCODE("1"); |
|
|
|
response.setRTCODE("1"); |
|
|
|
response.setRTMSG("起点不能为空!"); |
|
|
|
return response; |
|
|
|
} |
|
|
|
if (StrUtil.isEmpty(next_device_code)) { |
|
|
|
response.setREQCODE(task_code); |
|
|
|
response.setREPLYTIME(DateUtil.now()); |
|
|
|
response.setREQCODE("1"); |
|
|
|
response.setRTCODE("1"); |
|
|
|
response.setRTMSG("终点不能为空!"); |
|
|
|
return response; |
|
|
|
} |
|
|
@ -585,7 +573,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
if (taskDto != null) { |
|
|
|
response.setREQCODE(task_code); |
|
|
|
response.setREPLYTIME(DateUtil.now()); |
|
|
|
response.setREQCODE("1"); |
|
|
|
response.setRTCODE("1"); |
|
|
|
response.setRTMSG("不能存在相同的任务号!"); |
|
|
|
return response; |
|
|
|
} |
|
|
@ -594,7 +582,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
if (vehicle_dto != null) { |
|
|
|
response.setREQCODE(task_code); |
|
|
|
response.setREPLYTIME(DateUtil.now()); |
|
|
|
response.setREQCODE("1"); |
|
|
|
response.setRTCODE("1"); |
|
|
|
response.setRTMSG("不能存在相同的料车号!"); |
|
|
|
return response; |
|
|
|
} |
|
|
@ -603,14 +591,14 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
if (StrUtil.isEmpty(start_point_code)) { |
|
|
|
response.setREQCODE(task_code); |
|
|
|
response.setREPLYTIME(DateUtil.now()); |
|
|
|
response.setREQCODE("1"); |
|
|
|
response.setRTCODE("1"); |
|
|
|
response.setRTMSG(start_device_code + "未找到对应点位!"); |
|
|
|
return response; |
|
|
|
} |
|
|
|
if (StrUtil.isEmpty(next_point_code)) { |
|
|
|
response.setREQCODE(task_code); |
|
|
|
response.setREPLYTIME(DateUtil.now()); |
|
|
|
response.setREQCODE("1"); |
|
|
|
response.setRTCODE("1"); |
|
|
|
response.setRTMSG(next_device_code + "未找到对应点位!"); |
|
|
|
return response; |
|
|
|
} |
|
|
@ -677,9 +665,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
// json.put("ext_task_id", ext_task_id);
|
|
|
|
json.put("message", resp.getComment()); |
|
|
|
json.put("code", resp.code); |
|
|
|
json.put("data", data); |
|
|
|
json.put("data", param); |
|
|
|
errArr.add(json); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
@ -689,24 +676,15 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
// e.printStackTrace();
|
|
|
|
response.setREQCODE(task_code); |
|
|
|
response.setREPLYTIME(DateUtil.now()); |
|
|
|
response.setREQCODE("1"); |
|
|
|
response.setRTCODE("1"); |
|
|
|
response.setRTMSG(e.getMessage()); |
|
|
|
return response; |
|
|
|
} |
|
|
|
} |
|
|
|
if (ObjectUtil.isEmpty(errArr)) { |
|
|
|
|
|
|
|
response.setREQCODE(task_code); |
|
|
|
response.setREPLYTIME(DateUtil.now()); |
|
|
|
response.setREQCODE("0"); |
|
|
|
response.setRTCODE("0"); |
|
|
|
response.setRTMSG("success"); |
|
|
|
} else { |
|
|
|
response.setStatus(400); |
|
|
|
if (ObjectUtil.isNotEmpty(errArr)) { |
|
|
|
response.setMessage(errArr.getJSONObject(0).getString("message")); |
|
|
|
} else { |
|
|
|
response.setMessage("false"); |
|
|
|
} |
|
|
|
response.setErrArr(errArr); |
|
|
|
} |
|
|
|
log.info("createFromWms--------------:输出参数:" + JSON.toJSONString(response)); |
|
|
|
|
|
|
|
return response; |
|
|
|