|
|
@ -38,20 +38,20 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
@Autowired |
|
|
|
private DeviceAppService deviceAppService; |
|
|
|
@Autowired |
|
|
|
private TaskService taskserver; |
|
|
|
private TaskService taskService; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public JSONObject crateTask(JSONObject req) { |
|
|
|
log.info("createFromWms--------------:输入参数:" + JSON.toJSONString(req)); |
|
|
|
public JSONObject crateTask(JSONArray req) { |
|
|
|
log.info("crateTask--------------:输入参数:" + JSON.toJSONString(req)); |
|
|
|
try { |
|
|
|
JSONArray datas = req.getJSONArray("tasks"); |
|
|
|
JSONArray errArr = new JSONArray(); |
|
|
|
for (int i = 0; i < datas.size(); i++) { |
|
|
|
JSONObject task = datas.getJSONObject(i); |
|
|
|
String ext_task_id = task.getString("ext_task_id"); |
|
|
|
for (int i = 0; i < req.size(); i++) { |
|
|
|
JSONObject task = req.getJSONObject(i); |
|
|
|
String ext_task_id = task.getString("id"); |
|
|
|
String task_code = task.getString("task_code"); |
|
|
|
String start_device_code = task.getString("start_device_code"); |
|
|
|
String next_device_code = task.getString("next_device_code"); |
|
|
|
String start_device_code = task.getString("point_code1"); |
|
|
|
String next_device_code = task.getString("point_code2"); |
|
|
|
String put_device_code = task.getString("put_device_code"); |
|
|
|
String priority = task.getString("priority"); |
|
|
|
String vehicle_code = task.getString("vehicle_code"); |
|
|
@ -61,7 +61,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
String remark = task.getString("remark"); |
|
|
|
String storage_task_type = task.getString("storage_task_type"); |
|
|
|
String agv_system_type = task.getString("agv_system_type"); |
|
|
|
JSONObject param = task.getJSONObject("param"); |
|
|
|
JSONObject params = task.getJSONObject("params"); |
|
|
|
String start_point_code = ""; |
|
|
|
String next_point_code = ""; |
|
|
|
String put_point_code = ""; |
|
|
@ -136,7 +136,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
route_plan_code = "normal"; |
|
|
|
} |
|
|
|
|
|
|
|
TaskDto taskDto = taskserver.findByCodeFromCache(task_code); |
|
|
|
TaskDto taskDto = taskService.findByCodeFromCache(task_code); |
|
|
|
if (taskDto != null) { |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("task_code", task_code); |
|
|
@ -146,7 +146,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (!StrUtil.isEmpty(vehicle_code)) { |
|
|
|
TaskDto vehicle_dto = taskserver.findByContainer(vehicle_code); |
|
|
|
TaskDto vehicle_dto = taskService.findByContainer(vehicle_code); |
|
|
|
if (vehicle_dto != null) { |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("task_code", task_code); |
|
|
@ -191,7 +191,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
jo.put("agv_system_type", agv_system_type); |
|
|
|
jo.put("storage_task_type", storage_task_type); |
|
|
|
jo.put("remark", remark); |
|
|
|
jo.put("params", param); |
|
|
|
jo.put("params", params); |
|
|
|
jo.put("task_type", StrUtil.isEmpty(task_type) ? 1 : Integer.parseInt(task_type)); |
|
|
|
|
|
|
|
|
|
|
@ -201,7 +201,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
|
|
|
|
TaskDto task_dto = jo.toJavaObject(TaskDto.class); |
|
|
|
try { |
|
|
|
taskserver.create(task_dto); |
|
|
|
taskService.create(task_dto); |
|
|
|
} catch (Exception e) { |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("task_code", task_code); |
|
|
@ -224,7 +224,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
} |
|
|
|
resp.put("errArr", errArr); |
|
|
|
} |
|
|
|
log.info("createFromWms--------------:输出参数:" + JSON.toJSONString(resp)); |
|
|
|
log.info("crateTask--------------:输出参数:" + JSON.toJSONString(resp)); |
|
|
|
return resp; |
|
|
|
} finally { |
|
|
|
} |
|
|
@ -232,6 +232,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public JSONObject switchInOut(JSONObject reqs) { |
|
|
|
log.info("switchInOut--------------:输入参数:" + JSON.toJSONString(reqs)); |
|
|
|
Assert.notNull(reqs); |
|
|
|
String device_code = reqs.getString("device_code"); |
|
|
|
if (StrUtil.isBlank(device_code)) { |
|
|
@ -247,13 +248,13 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
if (belongToConveyorDevice != null && belongToConveyorDevice.getDeviceDriver() instanceof StripConveyorDeviceDriver) { |
|
|
|
StripConveyorDeviceDriver stripConveyorDeviceDriver = (StripConveyorDeviceDriver) belongToConveyorDevice.getDeviceDriver(); |
|
|
|
//切换为入库
|
|
|
|
if ("1".equals(type)) { |
|
|
|
if ("0".equals(type)) { |
|
|
|
String samePoint = Optional.ofNullable(device.getExtraValue().get("samePoint")).map(Object::toString).orElse(null); |
|
|
|
TaskDto taskDto; |
|
|
|
if (StrUtil.isNotEmpty(samePoint)) { |
|
|
|
taskDto = taskserver.findByNextCode(samePoint); |
|
|
|
taskDto = taskService.findByNextCode(samePoint); |
|
|
|
} else { |
|
|
|
taskDto = taskserver.findByNextCode(device_code); |
|
|
|
taskDto = taskService.findByNextCode(device_code); |
|
|
|
} |
|
|
|
if (ObjectUtil.isNotEmpty(taskDto)) { |
|
|
|
throw new BadRequestException("ACS存在出库任务,无法切换为入库模式"); |
|
|
@ -268,13 +269,13 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
stripConveyorDeviceDriver.writing("toCommand", 0); |
|
|
|
} |
|
|
|
//切换为出库
|
|
|
|
else if ("2".equals(type)) { |
|
|
|
else if ("1".equals(type)) { |
|
|
|
String samePoint = Optional.ofNullable(device.getExtraValue().get("samePoint")).map(Object::toString).orElse(null); |
|
|
|
TaskDto taskDto; |
|
|
|
if (StrUtil.isNotEmpty(samePoint)) { |
|
|
|
taskDto = taskserver.findByStartCode(samePoint); |
|
|
|
taskDto = taskService.findByStartCode(samePoint); |
|
|
|
} else { |
|
|
|
taskDto = taskserver.findByStartCode(device_code); |
|
|
|
taskDto = taskService.findByStartCode(device_code); |
|
|
|
} |
|
|
|
if (ObjectUtil.isNotEmpty(taskDto)) { |
|
|
|
throw new BadRequestException("ACS存在入库任务,无法切换为出库模式"); |
|
|
@ -290,22 +291,24 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
} |
|
|
|
} |
|
|
|
JSONObject resp = new JSONObject(); |
|
|
|
resp.put("status", 200); |
|
|
|
resp.put("message", "切换出入库模式成功"); |
|
|
|
resp.put("code", "200"); |
|
|
|
resp.put("msg", "切换出入库模式成功"); |
|
|
|
log.info("switchInOut--------------:输出参数:" + JSON.toJSONString(resp)); |
|
|
|
return resp; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public JSONObject pinkStartStop(JSONObject reqs) { |
|
|
|
log.info("pinkStartStop--------------:输入参数:" + JSON.toJSONString(reqs)); |
|
|
|
Assert.notNull(reqs); |
|
|
|
JSONObject resp = new JSONObject(); |
|
|
|
String device_code = reqs.getString("device_code"); |
|
|
|
if (StrUtil.isBlank(device_code)) { |
|
|
|
throw new BadRequestException("设备号不能为空!"); |
|
|
|
} |
|
|
|
String type = reqs.getString("type"); |
|
|
|
String type = reqs.getString("status"); |
|
|
|
if (StrUtil.isEmpty(type)) { |
|
|
|
throw new BadRequestException("启停类型不能为空!"); |
|
|
|
throw new BadRequestException("启停状态不能为空!"); |
|
|
|
} |
|
|
|
Device device = deviceAppService.findDeviceByCode(device_code); |
|
|
|
if (device != null && device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) { |
|
|
@ -318,8 +321,34 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
} else { |
|
|
|
throw new BadRequestException("设备不存在"); |
|
|
|
} |
|
|
|
resp.put("status", 200); |
|
|
|
resp.put("message", "切换成功"); |
|
|
|
resp.put("code", "200"); |
|
|
|
resp.put("msg", "切换成功"); |
|
|
|
log.info("pinkStartStop--------------:输出参数:" + JSON.toJSONString(resp)); |
|
|
|
return resp; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public JSONObject toCommand(JSONObject req) { |
|
|
|
log.info("toCommand--------------:输入参数:" + JSON.toJSONString(req)); |
|
|
|
Assert.notNull(req); |
|
|
|
String device_code = req.getString("device_code"); |
|
|
|
if (StrUtil.isEmpty(device_code)) { |
|
|
|
throw new BadRequestException("设备号不能为空"); |
|
|
|
} |
|
|
|
Integer toCommand = req.getInteger("toCommand"); |
|
|
|
if (toCommand == null) { |
|
|
|
throw new BadRequestException("下发参数不能为空"); |
|
|
|
} |
|
|
|
Device device = deviceAppService.findDeviceByCode(device_code); |
|
|
|
|
|
|
|
if (device != null && device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) { |
|
|
|
AppearanceInspectionScannerConveyorDeviceDriver appearanceInspectionScannerConveyorDeviceDriver = (AppearanceInspectionScannerConveyorDeviceDriver) device.getDeviceDriver(); |
|
|
|
appearanceInspectionScannerConveyorDeviceDriver.writing("toCommand", toCommand); |
|
|
|
} |
|
|
|
JSONObject resp = new JSONObject(); |
|
|
|
resp.put("code", "200"); |
|
|
|
resp.put("msg", "下发成功"); |
|
|
|
log.info("toCommand--------------:输出参数:" + JSON.toJSONString(resp)); |
|
|
|
return resp; |
|
|
|
} |
|
|
|
|
|
|
|