更新接口
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
package org.nl.acs.ext.wms.data;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CancelTaskRequest extends BaseRequest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务标识
|
||||||
|
*/
|
||||||
|
private String ext_task_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务编号
|
||||||
|
*/
|
||||||
|
private String task_code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 载具号
|
||||||
|
*/
|
||||||
|
String vehicle_code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 扩展属性
|
||||||
|
*/
|
||||||
|
Map<String,String> params;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package org.nl.acs.ext.wms.data;
|
||||||
|
|
||||||
|
public class CancelTaskResponse extends BaseResponse {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -35,7 +35,7 @@ public class WmsToAcsController {
|
|||||||
@ApiOperation("接收WMS任务")
|
@ApiOperation("接收WMS任务")
|
||||||
@SaIgnore
|
@SaIgnore
|
||||||
public ResponseEntity<Object> createFromWms(@RequestBody String whereJson) {
|
public ResponseEntity<Object> createFromWms(@RequestBody String whereJson) {
|
||||||
return new ResponseEntity<>(wmstoacsService.createFromWms(whereJson), HttpStatus.OK);
|
return new ResponseEntity<>(wmstoacsService.crateTask(whereJson), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/cancelTask")
|
@PostMapping("/cancelTask")
|
||||||
@@ -80,13 +80,5 @@ public class WmsToAcsController {
|
|||||||
return new ResponseEntity<>(wmstoacsService.queryDeviceDBValue(whereJson), HttpStatus.OK);
|
return new ResponseEntity<>(wmstoacsService.queryDeviceDBValue(whereJson), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SaIgnore
|
|
||||||
@PostMapping("/createtask")
|
|
||||||
@Log("11")
|
|
||||||
@ApiOperation("11")
|
|
||||||
public ResponseEntity<Object> task(@RequestBody String whereJson){
|
|
||||||
return new ResponseEntity<>(wmstoacsService.crateTask(whereJson), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,26 +3,27 @@ package org.nl.acs.ext.wms.service;
|
|||||||
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.nl.acs.ext.wms.data.CancelTaskResponse;
|
||||||
import org.nl.acs.ext.wms.data.CreateTaskResponse;
|
import org.nl.acs.ext.wms.data.CreateTaskResponse;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface WmsToAcsService {
|
public interface WmsToAcsService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建任务
|
* 创建任务
|
||||||
*
|
* @param whereJson
|
||||||
* @param jsonObject 条件
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Map<String, Object> createFromWms(String jsonObject);
|
CreateTaskResponse crateTask(String whereJson);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取消任务
|
* 取消任务
|
||||||
*
|
*
|
||||||
* @param jsonObject 条件
|
* @param jsonObject 条件
|
||||||
* @return Map<String, Object>
|
|
||||||
*/
|
*/
|
||||||
Map<String, Object> cancelFromWms(String jsonObject) throws Exception;
|
CancelTaskResponse cancelFromWms(String jsonObject) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改设置有无货属性
|
* 修改设置有无货属性
|
||||||
@@ -63,11 +64,8 @@ public interface WmsToAcsService {
|
|||||||
*/
|
*/
|
||||||
Map<String, Object> queryDeviceDBValue(String whereJson);
|
Map<String, Object> queryDeviceDBValue(String whereJson);
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建任务
|
|
||||||
* @param whereJson
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
CreateTaskResponse crateTask(String whereJson);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,7 @@ import org.nl.acs.device.service.DeviceService;
|
|||||||
import org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.CargoLiftConveyorDeviceDriver;
|
import org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.CargoLiftConveyorDeviceDriver;
|
||||||
import org.nl.acs.device_driver.basedriver.empty_vehicle_stacking_position.EmptyVehicleStackingPositionDeviceDriver;
|
import org.nl.acs.device_driver.basedriver.empty_vehicle_stacking_position.EmptyVehicleStackingPositionDeviceDriver;
|
||||||
import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver;
|
import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver;
|
||||||
import org.nl.acs.ext.wms.data.CreateTaskRequest;
|
import org.nl.acs.ext.wms.data.*;
|
||||||
import org.nl.acs.ext.wms.data.CreateTaskResponse;
|
|
||||||
import org.nl.acs.ext.wms.data.JsonUtl;
|
|
||||||
import org.nl.acs.ext.wms.service.WmsToAcsService;
|
import org.nl.acs.ext.wms.service.WmsToAcsService;
|
||||||
import org.nl.acs.instruction.service.InstructionService;
|
import org.nl.acs.instruction.service.InstructionService;
|
||||||
import org.nl.acs.instruction.service.dto.Instruction;
|
import org.nl.acs.instruction.service.dto.Instruction;
|
||||||
@@ -49,151 +47,21 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
private final DeviceAppService deviceAppService;
|
private final DeviceAppService deviceAppService;
|
||||||
private final RouteLineService routeLineService;
|
private final RouteLineService routeLineService;
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Object> createFromWms(String param) {
|
|
||||||
JSONArray tasks = JSONArray.parseArray(param);
|
|
||||||
JSONObject resultJson = new JSONObject();
|
|
||||||
log.info("createFromWms--------------:输入参数:" + tasks.toString());
|
|
||||||
try {
|
|
||||||
JSONArray errArr = new JSONArray();
|
|
||||||
for (int i = 0; i < tasks.size(); i++) {
|
|
||||||
JSONObject task = tasks.getJSONObject(i);
|
|
||||||
String ext_task_id = 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");
|
|
||||||
String start_point_code2 = task.getString("start_device_code2");
|
|
||||||
String next_point_code2 = task.getString("next_device_code2");
|
|
||||||
String put_point_code = task.getString("put_device_code");
|
|
||||||
String start_device_code = "";
|
|
||||||
String next_device_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)) {
|
|
||||||
start_point_code = (String) start_device_json.get("parent_storage_code") == null ? start_point_code : (String) start_device_json.get("storage_code");
|
|
||||||
}
|
|
||||||
JSONObject next_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + next_point_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");
|
|
||||||
}
|
|
||||||
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");
|
|
||||||
|
|
||||||
if (start_point_code.indexOf("-") > 0) {
|
|
||||||
String str[] = start_point_code.split("-");
|
|
||||||
start_device_code = str[0];
|
|
||||||
} else {
|
|
||||||
start_device_code = start_point_code;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (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.isEmpty(route_plan_code)) {
|
|
||||||
route_plan_code = "normal";
|
|
||||||
}
|
|
||||||
// List<RouteLineDto> list = RouteLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
|
|
||||||
//
|
|
||||||
// if (ObjectUtil.isEmpty(list)) {
|
|
||||||
// throw new WDKException("路由不通!");
|
|
||||||
// }
|
|
||||||
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("已存在该载具号的任务!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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_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("priority", priority);
|
|
||||||
jo.put("vehicle_code", vehicle_code);
|
|
||||||
jo.put("vehicle_type", vehicle_type);
|
|
||||||
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 {
|
|
||||||
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)) {
|
|
||||||
resultJson.put("status", 200);
|
|
||||||
resultJson.put("message", "操作成功");
|
|
||||||
} else {
|
|
||||||
resultJson.put("status", 400);
|
|
||||||
resultJson.put("message", "操作失败");
|
|
||||||
}
|
|
||||||
resultJson.put("errArr", errArr);
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return resultJson;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> cancelFromWms(String param) throws Exception {
|
public CancelTaskResponse cancelFromWms(String param) throws Exception {
|
||||||
JSONArray tasks = JSONArray.parseArray(param);
|
|
||||||
ParamService paramService = SpringContextHolder.getBean(ParamService.class);
|
ParamService paramService = SpringContextHolder.getBean(ParamService.class);
|
||||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
||||||
log.debug(tasks.toString());
|
JSONArray datas = JSONArray.parseArray(param);
|
||||||
log.info("cancelFromWms--------------:输入参数" + tasks.toString());
|
CancelTaskResponse response = new CancelTaskResponse();
|
||||||
for (int i = 0; i < tasks.size(); i++) {
|
JSONArray errArr = new JSONArray();
|
||||||
JSONObject task = tasks.getJSONObject(i);
|
for (int i = 0; i < datas.size(); i++) {
|
||||||
String task_uuid = task.getString("task_id");
|
String data = datas.get(i).toString();
|
||||||
String task_code = task.getString("task_code");
|
CancelTaskRequest request = JsonUtl.format(param, CancelTaskRequest.class);
|
||||||
String vehicle_code = task.getString("vehicle_code");
|
|
||||||
String params = task.getString("params");
|
String task_uuid = request.getExt_task_id();
|
||||||
|
String task_code = request.getTask_code();
|
||||||
|
String vehicle_code = request.getVehicle_code();
|
||||||
|
|
||||||
if (StrUtil.isEmpty(task_uuid)) {
|
if (StrUtil.isEmpty(task_uuid)) {
|
||||||
throw new WDKException("任务标识不能为空");
|
throw new WDKException("任务标识不能为空");
|
||||||
@@ -214,12 +82,17 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
JSONObject resultJson = new JSONObject();
|
|
||||||
resultJson.put("status", HttpStatus.OK);
|
if (ObjectUtil.isEmpty(errArr)) {
|
||||||
resultJson.put("message", "操作成功");
|
response.setStatus(200);
|
||||||
resultJson.put("data", new JSONObject());
|
} else {
|
||||||
log.info("cancelFromWms--------------:输出参数" + resultJson.toString());
|
response.setStatus(400);
|
||||||
return resultJson;
|
}
|
||||||
|
response.setMessage("success");
|
||||||
|
response.setErrArr(errArr);
|
||||||
|
log.info("createFromWms--------------:输出参数:" + response);
|
||||||
|
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -395,7 +268,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
String route_plan_code = request.getRoute_plan_code();
|
String route_plan_code = request.getRoute_plan_code();
|
||||||
String task_type = request.getTask_type();
|
String task_type = request.getTask_type();
|
||||||
String remark = request.getRemark();
|
String remark = request.getRemark();
|
||||||
String params = request.getParams().toString();
|
Map<String,String> params = request.getParams();
|
||||||
|
|
||||||
String start_device_code = "";
|
String start_device_code = "";
|
||||||
String start_device_code2 = "";
|
String start_device_code2 = "";
|
||||||
@@ -426,42 +299,42 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
start_point_code2 = (String) start_device_json2.get("parent_storage_code") == null ? start_point_code2 : (String) start_device_json.get("storage_code");
|
start_point_code2 = (String) start_device_json2.get("parent_storage_code") == null ? start_point_code2 : (String) start_device_json.get("storage_code");
|
||||||
}
|
}
|
||||||
JSONObject next_device_json2 = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + next_point_code2 + "'").uniqueResult(0);
|
JSONObject next_device_json2 = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + next_point_code2 + "'").uniqueResult(0);
|
||||||
if (!ObjectUtil.isEmpty(next_device_json)) {
|
if (!ObjectUtil.isEmpty(next_device_json2)) {
|
||||||
next_point_code2 = (String) next_device_json2.get("parent_storage_code") == null ? next_point_code2 : (String) next_device_json.get("storage_code");
|
next_point_code2 = (String) next_device_json2.get("parent_storage_code") == null ? next_point_code2 : (String) next_device_json.get("storage_code");
|
||||||
}
|
}
|
||||||
JSONObject put_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + put_point_code + "'").uniqueResult(0);
|
JSONObject put_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + put_point_code + "'").uniqueResult(0);
|
||||||
if (!ObjectUtil.isEmpty(put_device_json)) {
|
if (!ObjectUtil.isEmpty(put_device_json)) {
|
||||||
put_point_code = (String) put_device_json.get("parent_storage_code") == null ? put_point_code : (String) next_device_json.get("storage_code");
|
put_point_code = (String) put_device_json.get("parent_storage_code") == null ? put_point_code : (String) next_device_json.get("storage_code");
|
||||||
}
|
}
|
||||||
if (start_point_code.indexOf("-") > 0) {
|
if (StrUtil.isNotEmpty(start_point_code) && start_point_code.indexOf("-") > 0) {
|
||||||
String str[] = start_point_code.split("-");
|
String str[] = start_point_code.split("-");
|
||||||
start_device_code = str[0];
|
start_device_code = str[0];
|
||||||
} else {
|
} else {
|
||||||
start_device_code = start_point_code;
|
start_device_code = start_point_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next_point_code.indexOf("-") > 0) {
|
if (StrUtil.isNotEmpty(next_point_code) && next_point_code.indexOf("-") > 0) {
|
||||||
String str[] = next_point_code.split("-");
|
String str[] = next_point_code.split("-");
|
||||||
next_device_code = str[0];
|
next_device_code = str[0];
|
||||||
} else {
|
} else {
|
||||||
next_device_code = next_point_code;
|
next_device_code = next_point_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start_point_code2.indexOf("-") > 0) {
|
if (StrUtil.isNotEmpty(start_point_code2) && start_point_code2.indexOf("-") > 0) {
|
||||||
String str[] = start_point_code2.split("-");
|
String str[] = start_point_code2.split("-");
|
||||||
start_device_code2 = str[0];
|
start_device_code2 = str[0];
|
||||||
} else {
|
} else {
|
||||||
start_device_code2 = start_point_code2;
|
start_device_code2 = start_point_code2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next_point_code2.indexOf("-") > 0) {
|
if (StrUtil.isNotEmpty(next_point_code2) && next_point_code2.indexOf("-") > 0) {
|
||||||
String str[] = next_point_code2.split("-");
|
String str[] = next_point_code2.split("-");
|
||||||
next_device_code2 = str[0];
|
next_device_code2 = str[0];
|
||||||
} else {
|
} else {
|
||||||
next_device_code2 = next_point_code2;
|
next_device_code2 = next_point_code2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (put_point_code.indexOf("-") > 0) {
|
if (StrUtil.isNotEmpty(put_point_code) && put_point_code.indexOf("-") > 0) {
|
||||||
String str[] = put_point_code.split("-");
|
String str[] = put_point_code.split("-");
|
||||||
put_device_code = str[0];
|
put_device_code = str[0];
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user