|
|
@ -2,14 +2,17 @@ package org.nl.acs.ext.wms.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.nl.acs.agv.AgvUtil; |
|
|
|
import org.nl.acs.config.AcsConfig; |
|
|
|
import org.nl.acs.device.service.DeviceService; |
|
|
|
import org.nl.acs.device_driver.DeviceDriver; |
|
|
|
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; |
|
|
|
import org.nl.acs.device_driver.lnsh.lnsh_Laminating_machine.ItemProtocol; |
|
|
|
import org.nl.acs.device_driver.lnsh.lnsh_Laminating_machine.LnshLaminatingMachineDeviceDriver; |
|
|
|
import org.nl.acs.device_driver.lnsh.lnsh_fold_disc_site.LnshFoldDiscSiteDeviceDriver; |
|
|
|
import org.nl.acs.device_driver.lnsh.lnsh_kiln_lane.LnshKilnLaneDeviceDriver; |
|
|
@ -27,6 +30,12 @@ import org.nl.acs.device_driver.lnsh.lnsh_rgv.LnshRGVDeviceDriver; |
|
|
|
import org.nl.acs.device_driver.lnsh.lnsh_split_manipulator.LnshSplitManipulatorDeviceDriver; |
|
|
|
import org.nl.acs.device_driver.lnsh.lnsh_station.LnshStationDeviceDriver; |
|
|
|
import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver; |
|
|
|
import org.nl.acs.ext.wms.data.AcsToWmsData.grab_place_station.GrabPlaceStationResponse; |
|
|
|
import org.nl.acs.ext.wms.data.WmstoAcsData.createTask.CreateTaskRequest; |
|
|
|
import org.nl.acs.ext.wms.data.WmstoAcsData.createTask.CreateTaskResponse; |
|
|
|
import org.nl.acs.ext.wms.data.WmstoAcsData.putAction.PutActionRequest; |
|
|
|
import org.nl.acs.ext.wms.data.WmstoAcsData.putAction.PutActionResponse; |
|
|
|
import org.nl.acs.ext.wms.data.WmstoAcsData.putAction.SignalData; |
|
|
|
import org.nl.acs.ext.wms.service.WmsToAcsService; |
|
|
|
import org.nl.acs.instruction.service.InstructionService; |
|
|
|
import org.nl.acs.instruction.service.dto.Instruction; |
|
|
@ -67,33 +76,39 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
private String log_type = "WMS下发ACS"; |
|
|
|
|
|
|
|
@Override |
|
|
|
public Map<String, Object> createFromWms(String param) { |
|
|
|
public JSONObject createFromWms(JSONObject req) { |
|
|
|
try { |
|
|
|
MDC.put(log_file_type, log_type); |
|
|
|
JSONArray tasks = JSONArray.parseArray(param); |
|
|
|
CreateTaskRequest tasks = JSON.toJavaObject(req, CreateTaskRequest.class); |
|
|
|
JSONObject resultJson = new JSONObject(); |
|
|
|
CreateTaskResponse resp = new CreateTaskResponse(); |
|
|
|
log.info("createFromWms - 请求参数 {}", tasks.toString()); |
|
|
|
String request_no = tasks.getRequestNo(); |
|
|
|
JSONArray errArr = new JSONArray(); |
|
|
|
try { |
|
|
|
JSONArray errArr = new JSONArray(); |
|
|
|
for (int i = 0; i < tasks.size(); i++) { |
|
|
|
JSONObject task = tasks.getJSONObject(i); |
|
|
|
String ext_task_uuid = task.getString("task_id"); |
|
|
|
String task_code = task.getString("task_code"); |
|
|
|
String start_point_code = task.getString("start_device_code"); |
|
|
|
String next_point_code = task.getString("next_device_code"); |
|
|
|
for (int i = 0; i < tasks.getList().size(); i++) { |
|
|
|
TaskDto task = tasks.getList().get(i); |
|
|
|
String ext_task_uuid = task.getExt_task_uuid(); |
|
|
|
String task_code = task.getTask_code(); |
|
|
|
String start_point_code = task.getStart_device_code(); |
|
|
|
String next_point_code = task.getNext_device_code(); |
|
|
|
String priority = task.getPriority(); |
|
|
|
String vehicle_code = task.getVehicle_code(); |
|
|
|
String vehicle_type = task.getVehicle_type(); |
|
|
|
String route_plan_code = task.getRoute_plan_code(); |
|
|
|
String task_type = task.getTask_type(); |
|
|
|
String remark = task.getRemark(); |
|
|
|
String params = task.getParams(); |
|
|
|
// 双工RGV任务 后工位任务
|
|
|
|
String start_point_code2 = task.getStart_device_code2(); |
|
|
|
String next_point_code2 = task.getNext_device_code2(); |
|
|
|
String start_device_code2 = task.getStart_device_code2(); |
|
|
|
String next_device_code2 = task.getNext_device_code2(); |
|
|
|
String start_device_code = ""; |
|
|
|
String next_device_code = ""; |
|
|
|
String start_parent_code = ""; |
|
|
|
String next_parent_code = ""; |
|
|
|
if (StrUtil.isEmpty(task_code)) { |
|
|
|
throw new WDKException("任务号不能为空"); |
|
|
|
} |
|
|
|
if (StrUtil.isEmpty(start_point_code)) { |
|
|
|
throw new WDKException("起点不能为空"); |
|
|
|
} |
|
|
|
if (StrUtil.isEmpty(next_point_code)) { |
|
|
|
throw new WDKException("终点不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
JSONObject start_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + start_point_code + "'").uniqueResult(0); |
|
|
|
if (!ObjectUtil.isEmpty(start_device_json)) { |
|
|
@ -111,18 +126,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
} |
|
|
|
next_parent_code = next_device_json.get("parent_storage_code") == null ? next_point_code : (String) next_device_json.get("parent_storage_code"); |
|
|
|
} |
|
|
|
String priority = task.getString("priority"); |
|
|
|
String vehicle_code = task.getString("vehicle_code"); |
|
|
|
String vehicle_type = task.getString("vehicle_type"); |
|
|
|
String route_plan_code = task.getString("route_plan_code"); |
|
|
|
String task_type = task.getString("task_type"); |
|
|
|
String remark = task.getString("remark"); |
|
|
|
String params = task.getString("params"); |
|
|
|
// 双工RGV任务 后工位任务
|
|
|
|
String start_point_code2 = task.getString("start_device_code2"); |
|
|
|
String next_point_code2 = task.getString("next_device_code2"); |
|
|
|
String start_device_code2 = task.getString("start_device_code2"); |
|
|
|
String next_device_code2 = task.getString("next_device_code2"); |
|
|
|
|
|
|
|
if (start_point_code.indexOf("-") > 0) { |
|
|
|
String str[] = start_point_code.split("-"); |
|
|
|
start_device_code = str[0]; |
|
|
@ -143,12 +147,50 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
List<RouteLineDto> list = RouteLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); |
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(list)) { |
|
|
|
throw new WDKException("路由不通!"); |
|
|
|
//throw new WDKException("路由不通!");
|
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("task_code", task_code); |
|
|
|
json.put("ext_task_id", ext_task_uuid); |
|
|
|
json.put("message", "路由不通!"); |
|
|
|
errArr.add(json); |
|
|
|
continue; |
|
|
|
} |
|
|
|
TaskDto taskDto = TaskService.findByCodeFromCache(task_code); |
|
|
|
if (taskDto != null) { |
|
|
|
throw new WDKException("不能存在相同的任务号!"); |
|
|
|
//throw new WDKException("不能存在相同的任务号!");
|
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("task_code", task_code); |
|
|
|
json.put("ext_task_id", ext_task_uuid); |
|
|
|
json.put("message", "不能存在相同的任务号!"); |
|
|
|
errArr.add(json); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if (StrUtil.isEmpty(task_code)) { |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("task_code", task_code); |
|
|
|
json.put("ext_task_id", ext_task_uuid); |
|
|
|
json.put("message", "任务号不能为空"); |
|
|
|
errArr.add(json); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (StrUtil.isEmpty(start_point_code)) { |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("task_code", task_code); |
|
|
|
json.put("ext_task_id", ext_task_uuid); |
|
|
|
json.put("message", "起点不能为空"); |
|
|
|
errArr.add(json); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (StrUtil.isEmpty(next_point_code)) { |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("task_code", task_code); |
|
|
|
json.put("ext_task_id", ext_task_uuid); |
|
|
|
json.put("message", "终点不能为空"); |
|
|
|
errArr.add(json); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
// if (!StrUtil.isEmpty(vehicle_code) && !"0000".equals(vehicle_code)) {
|
|
|
|
// TaskDto vehicle_dto = TaskService.findByContainer(vehicle_code);
|
|
|
|
// if (vehicle_dto != null) {
|
|
|
@ -164,8 +206,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
jo.put("next_parent_code", next_parent_code); |
|
|
|
jo.put("start_device_code", start_device_code); |
|
|
|
jo.put("next_device_code", next_device_code); |
|
|
|
jo.put("start_point_code2", start_point_code2); |
|
|
|
jo.put("next_point_code2", next_point_code2); |
|
|
|
jo.put("start_point_code2", start_device_code2); |
|
|
|
jo.put("next_point_code2", next_device_code2); |
|
|
|
jo.put("start_device_code2", start_device_code2); |
|
|
|
jo.put("next_device_code2", next_device_code2); |
|
|
|
jo.put("priority", priority); |
|
|
@ -200,26 +242,26 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
json.put("ext_task_uuid", ext_task_uuid); |
|
|
|
json.put("message", e.getMessage()); |
|
|
|
errArr.add(json); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
if (ObjectUtil.isEmpty(errArr)) { |
|
|
|
resultJson.put("status", 200); |
|
|
|
resp.setCode(200); |
|
|
|
} else { |
|
|
|
resultJson.put("status", 400); |
|
|
|
resp.setCode(400); |
|
|
|
} |
|
|
|
resultJson.put("errArr", errArr); |
|
|
|
resultJson.put("message", "操作成功"); |
|
|
|
resultJson.put("data", new JSONObject()); |
|
|
|
|
|
|
|
log.info("createFromWms - 返回参数 {}", resultJson.toString()); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
resultJson.put("status", 400); |
|
|
|
resultJson.put("errArr", e.getMessage()); |
|
|
|
resultJson.put("message", e.getMessage()); |
|
|
|
resultJson.put("data", new JSONObject()); |
|
|
|
log.info("createFromWms - 返回参数 {}", resultJson.toString()); |
|
|
|
resp.setCode(400); |
|
|
|
resp.setMessage(e.getMessage()); |
|
|
|
} |
|
|
|
return resultJson; |
|
|
|
resp.setRequestNo(request_no); |
|
|
|
resp.setResponseDate(AgvUtil.getDate()); |
|
|
|
resp.setMessage("请求成功"); |
|
|
|
log.info("createFromWms - 返回参数 {}", JSON.toJSON(resp)); |
|
|
|
return (JSONObject) JSON.toJSON(resp); |
|
|
|
} finally { |
|
|
|
MDC.remove(log_file_type); |
|
|
|
} |
|
|
@ -494,16 +536,20 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Map<String, Object> putAction(String jsonObject) throws Exception { |
|
|
|
public JSONObject putAction(String req) throws Exception { |
|
|
|
try { |
|
|
|
MDC.put(log_file_type, log_type); |
|
|
|
JSONArray datas = JSONArray.parseArray(jsonObject); |
|
|
|
PutActionRequest actions = JSON.toJavaObject(JSONObject.parseObject(req), PutActionRequest.class); |
|
|
|
PutActionResponse resp = new PutActionResponse(); |
|
|
|
String request_no = actions.getRequestNo(); |
|
|
|
String device_code = actions.getDevice_code(); |
|
|
|
JSONArray errArr = new JSONArray(); |
|
|
|
JSONArray datas = JSONArray.parseArray(actions.getList().toString()); |
|
|
|
log.info("putAction - 请求参数 {}", datas.toString()); |
|
|
|
for (int i = 0; i < datas.size(); i++) { |
|
|
|
JSONObject data = datas.getJSONObject(i); |
|
|
|
String device_code = data.getString("device_code"); |
|
|
|
String code = data.getString("code"); |
|
|
|
String value = data.getString("value"); |
|
|
|
SignalData data = JSON.toJavaObject(JSONObject.parseObject(datas.get(i).toString()), SignalData.class); |
|
|
|
String code = data.getCode(); |
|
|
|
String value = data.getValue(); |
|
|
|
Device device = DeviceAppService.findDeviceByCode(device_code); |
|
|
|
if (ObjectUtil.isEmpty(device)) { |
|
|
|
throw new Exception("未找到对应设备:" + device_code); |
|
|
@ -512,19 +558,28 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
//晟华覆膜机
|
|
|
|
if (device.getDeviceDriver() instanceof LnshLaminatingMachineDeviceDriver) { |
|
|
|
lnshLaminatingMachineDeviceDriver = (LnshLaminatingMachineDeviceDriver) device.getDeviceDriver(); |
|
|
|
org.nl.acs.device_driver.lnsh.lnsh_Laminating_machine.ItemProtocol itemProtocol = new org.nl.acs.device_driver.lnsh.lnsh_Laminating_machine.ItemProtocol(lnshLaminatingMachineDeviceDriver); |
|
|
|
ItemProtocol itemProtocol = new ItemProtocol(lnshLaminatingMachineDeviceDriver); |
|
|
|
if (!lnshLaminatingMachineDeviceDriver.isExistFieldName(code, itemProtocol)) { |
|
|
|
throw new Exception("设备:" + device_code + "未找到对应信号:" + code); |
|
|
|
//throw new Exception("设备:" + device_code + "未找到对应信号:" + code);
|
|
|
|
JSONObject back = new JSONObject(); |
|
|
|
back.put("code", code); |
|
|
|
back.put("value", value); |
|
|
|
back.put("message", "设备:" + device_code + "未找到对应信号:" + code); |
|
|
|
errArr.add(back); |
|
|
|
continue; |
|
|
|
} |
|
|
|
lnshLaminatingMachineDeviceDriver.writing(code, value); |
|
|
|
} |
|
|
|
} |
|
|
|
JSONObject resultJson = new JSONObject(); |
|
|
|
resultJson.put("status", HttpStatus.OK); |
|
|
|
resultJson.put("message", "操作成功"); |
|
|
|
resultJson.put("data", new JSONObject()); |
|
|
|
log.info("putAction - 返回参数 {}", resultJson.toString()); |
|
|
|
return resultJson; |
|
|
|
if (ObjectUtil.isEmpty(errArr)) { |
|
|
|
resp.setCode(200); |
|
|
|
} else { |
|
|
|
resp.setCode(400); |
|
|
|
resp.setErrArr(errArr); |
|
|
|
} |
|
|
|
resp.setRequestNo(request_no); |
|
|
|
log.info("putAction - 返回参数 {}", JSON.toJSON(resp)); |
|
|
|
return (JSONObject) JSON.toJSON(resp); |
|
|
|
} finally { |
|
|
|
MDC.remove(log_file_type); |
|
|
|
} |
|
|
|