|
|
@ -16,7 +16,6 @@ import org.nl.acs.device.driver.conveyor.appearance_inspection_scannner_conveyor |
|
|
|
import org.nl.acs.device.driver.conveyor.strip_conveyor.StripConveyorDeviceDriver; |
|
|
|
import org.nl.acs.ext.wms.data.*; |
|
|
|
|
|
|
|
import org.nl.acs.ext.wms.service.AcsToLiKuService; |
|
|
|
import org.nl.acs.ext.wms.service.WmsToAcsService; |
|
|
|
|
|
|
|
import org.nl.acs.device.device.service.DeviceAppService; |
|
|
@ -41,416 +40,416 @@ import java.util.Optional; |
|
|
|
@Slf4j |
|
|
|
public class WmsToAcsServiceImpl implements WmsToAcsService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private StorageCellMapper storageCellMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private DeviceAppService deviceAppService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private LuceneExecuteLogService luceneExecuteLogService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private AcsToLiKuService acsToLiKuService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private TaskService taskserver; |
|
|
|
|
|
|
|
|
|
|
|
private String log_file_type = "log_file_type"; |
|
|
|
private String log_type = "LMS请求ACS"; |
|
|
|
|
|
|
|
@Override |
|
|
|
public CreateTaskResponse crateTask(String param) { |
|
|
|
try { |
|
|
|
MDC.put(log_file_type, log_type); |
|
|
|
log.info("crateTask-----输入参数{}", param); |
|
|
|
JSONArray datas = JSONArray.parseArray(param); |
|
|
|
CreateTaskResponse response = new CreateTaskResponse(); |
|
|
|
// ParamService paramService = SpringContextHolder.getBean(ParamService.class);
|
|
|
|
ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); |
|
|
|
// String cancelTaskCheck = paramService.findByCode(AcsConfig.ISALLOWTASK).getValue();
|
|
|
|
JSONArray errArr = new JSONArray(); |
|
|
|
// if (StrUtil.equals(cancelTaskCheck, "0")) {
|
|
|
|
// @Autowired
|
|
|
|
// private StorageCellMapper storageCellMapper;
|
|
|
|
//
|
|
|
|
// @Autowired
|
|
|
|
// private DeviceAppService deviceAppService;
|
|
|
|
//
|
|
|
|
// @Autowired
|
|
|
|
// private LuceneExecuteLogService luceneExecuteLogService;
|
|
|
|
//
|
|
|
|
// @Autowired
|
|
|
|
// private AcsToLiKuService acsToLiKuService;
|
|
|
|
//
|
|
|
|
// @Autowired
|
|
|
|
// private TaskService taskserver;
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// private String log_file_type = "log_file_type";
|
|
|
|
// private String log_type = "LMS请求ACS";
|
|
|
|
//
|
|
|
|
// @Override
|
|
|
|
// public CreateTaskResponse crateTask(String param) {
|
|
|
|
// try {
|
|
|
|
// MDC.put(log_file_type, log_type);
|
|
|
|
// log.info("crateTask-----输入参数{}", param);
|
|
|
|
// JSONArray datas = JSONArray.parseArray(param);
|
|
|
|
// CreateTaskResponse response = new CreateTaskResponse();
|
|
|
|
//// ParamService paramService = SpringContextHolder.getBean(ParamService.class);
|
|
|
|
// ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
|
|
|
|
//// String cancelTaskCheck = paramService.findByCode(AcsConfig.ISALLOWTASK).getValue();
|
|
|
|
// JSONArray errArr = new JSONArray();
|
|
|
|
//// if (StrUtil.equals(cancelTaskCheck, "0")) {
|
|
|
|
//// response.setStatus(400);
|
|
|
|
//// response.setMessage("ACS系统需要更新,请稍等");
|
|
|
|
//// response.setErrArr(datas);
|
|
|
|
//// return response;
|
|
|
|
//// }
|
|
|
|
// for (int i = 0; i < datas.size(); i++) {
|
|
|
|
// String data = datas.get(i).toString();
|
|
|
|
// CreateTaskRequest request = JSON.parseObject(data, CreateTaskRequest.class);
|
|
|
|
// String paper_array = request.getPaper_array();
|
|
|
|
// 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 truss_type = request.getTruss_type();
|
|
|
|
// String empty_site = request.getEmpty_site();
|
|
|
|
// String is_bushing = request.getIs_bushing();
|
|
|
|
// String is_pulling = request.getIs_pulling();
|
|
|
|
// String size = request.getSize();
|
|
|
|
// String version = request.getVersion();
|
|
|
|
// String bushing_num = request.getBushing_num();
|
|
|
|
// 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();
|
|
|
|
// String start_height = request.getStart_height();
|
|
|
|
// String next_height = request.getNext_height();
|
|
|
|
// String params2 = request.getParams2();
|
|
|
|
// Map<String, String> 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)) {
|
|
|
|
// JSONObject json = new JSONObject();
|
|
|
|
// json.put("task_code", task_code);
|
|
|
|
// json.put("ext_task_id", ext_task_id);
|
|
|
|
// json.put("message", "任务号不能为空");
|
|
|
|
// errArr.add(json);
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
// if (StrUtil.isEmpty(start_device_code)) {
|
|
|
|
// JSONObject json = new JSONObject();
|
|
|
|
// json.put("task_code", task_code);
|
|
|
|
// json.put("ext_task_id", ext_task_id);
|
|
|
|
// json.put("message", "起点不能为空");
|
|
|
|
// errArr.add(json);
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
// if (StrUtil.isEmpty(next_device_code)) {
|
|
|
|
// JSONObject json = new JSONObject();
|
|
|
|
// json.put("task_code", task_code);
|
|
|
|
// json.put("ext_task_id", ext_task_id);
|
|
|
|
// json.put("message", "终点不能为空");
|
|
|
|
// errArr.add(json);
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (StrUtil.equals(task_type, "8")) {
|
|
|
|
// next_device_code = request.getPut_device_code();
|
|
|
|
// put_device_code = request.getNext_device_code();
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// StorageCell start_storageCell = new LambdaQueryChainWrapper<>(storageCellMapper)
|
|
|
|
// .eq(StorageCell::getStorage_code, start_device_code)
|
|
|
|
// .one();
|
|
|
|
// StorageCell next_storageCell = new LambdaQueryChainWrapper<>(storageCellMapper)
|
|
|
|
// .eq(StorageCell::getStorage_code, next_device_code)
|
|
|
|
// .one();
|
|
|
|
// StorageCell start2_storageCell = new LambdaQueryChainWrapper<>(storageCellMapper)
|
|
|
|
// .eq(StorageCell::getStorage_code, start_device_code2)
|
|
|
|
// .one();
|
|
|
|
// StorageCell next2_storageCell = new LambdaQueryChainWrapper<>(storageCellMapper)
|
|
|
|
// .eq(StorageCell::getStorage_code, next_device_code2)
|
|
|
|
// .one();
|
|
|
|
// StorageCell put_storageCell = new LambdaQueryChainWrapper<>(storageCellMapper)
|
|
|
|
// .eq(StorageCell::getStorage_code, put_device_code)
|
|
|
|
// .one();
|
|
|
|
//
|
|
|
|
// JSONObject start_device_json = (JSONObject) JSONObject.toJSON(start_storageCell);
|
|
|
|
// 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 = (JSONObject) JSONObject.toJSON(next_storageCell);
|
|
|
|
// 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 = (JSONObject) JSONObject.toJSON(start2_storageCell);
|
|
|
|
// if (!ObjectUtil.isEmpty(start_device_json2)) {
|
|
|
|
// start_point_code2 = (String) start_device_json2.get("parent_storage_code") == null ? start_device_code2 : (String) start_device_json2.get("storage_code");
|
|
|
|
// }
|
|
|
|
// JSONObject next_device_json2 = (JSONObject) JSONObject.toJSON(next2_storageCell);
|
|
|
|
// if (!ObjectUtil.isEmpty(next_device_json2)) {
|
|
|
|
// next_point_code2 = (String) next_device_json2.get("parent_storage_code") == null ? next_device_code2 : (String) next_device_json2.get("storage_code");
|
|
|
|
// }
|
|
|
|
// JSONObject put_device_json = (JSONObject) JSONObject.toJSON(put_storageCell);
|
|
|
|
// if (!ObjectUtil.isEmpty(put_device_json)) {
|
|
|
|
// put_point_code = (String) put_device_json.get("parent_storage_code") == null ? put_device_code : (String) put_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";
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (StrUtil.equals(task_type, "5")) {
|
|
|
|
// if (taskserver.querySameDeviceReadyTask(start_device_code, next_device_code, "0") > 1) {
|
|
|
|
// JSONObject json = new JSONObject();
|
|
|
|
// json.put("task_code", task_code);
|
|
|
|
// json.put("ext_task_id", ext_task_id);
|
|
|
|
// json.put("message", "已存在相同的起点:" + start_device_code + "终点:" + next_device_code + "未执行的输送任务");
|
|
|
|
// errArr.add(json);
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// TaskDto taskDto = taskserver.findByCodeFromCache(task_code);
|
|
|
|
// if (taskDto != null) {
|
|
|
|
// JSONObject json = new JSONObject();
|
|
|
|
// json.put("task_code", task_code);
|
|
|
|
// json.put("ext_task_id", ext_task_id);
|
|
|
|
// json.put("message", "存在相同的任务号:" + task_code);
|
|
|
|
// errArr.add(json);
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
// if (!StrUtil.isEmpty(vehicle_code)) {
|
|
|
|
// TaskDto vehicle_dto = taskserver.findByContainer(vehicle_code);
|
|
|
|
// if (vehicle_dto != null) {
|
|
|
|
// JSONObject json = new JSONObject();
|
|
|
|
// json.put("task_code", task_code);
|
|
|
|
// json.put("ext_task_id", ext_task_id);
|
|
|
|
// json.put("message", "已存在任务编号为" + vehicle_dto.getTask_code() + "托盘号:" + vehicle_code);
|
|
|
|
// 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_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_id", IdUtil.simpleUUID());
|
|
|
|
// jo.put("task_code", task_code);
|
|
|
|
// 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("start_height", start_height);
|
|
|
|
// jo.put("next_height", next_height);
|
|
|
|
// jo.put("oven_time", (int) Math.ceil(oven_time));
|
|
|
|
// jo.put("remark", remark);
|
|
|
|
// jo.put("params", params);
|
|
|
|
// jo.put("params2", params2);
|
|
|
|
// jo.put("task_type", StrUtil.isEmpty(task_type) ? 1 : Integer.parseInt(task_type));
|
|
|
|
// jo.put("paper_array", JSONUtil.toJsonStr(paper_array));
|
|
|
|
// jo.put("truss_type", JSONUtil.toJsonStr(truss_type));
|
|
|
|
// jo.put("empty_site", JSONUtil.toJsonStr(empty_site));
|
|
|
|
// jo.put("is_bushing", JSONUtil.toJsonStr(is_bushing));
|
|
|
|
// jo.put("is_pulling", JSONUtil.toJsonStr(is_pulling));
|
|
|
|
// jo.put("size", JSONUtil.toJsonStr(size));
|
|
|
|
// jo.put("version", JSONUtil.toJsonStr(version));
|
|
|
|
// jo.put("bushing_num", JSONUtil.toJsonStr(bushing_num));
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// if (!StrUtil.isEmpty(ext_task_id)) {
|
|
|
|
// jo.put("ext_task_id", ext_task_id);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// TaskDto task_dto = jo.toJavaObject(TaskDto.class);
|
|
|
|
// try {
|
|
|
|
// if (ObjectUtil.isNotEmpty(request.getInteraction_json())) {
|
|
|
|
// task_dto.setInteractionJson(request.getInteraction_json());
|
|
|
|
// }
|
|
|
|
// taskserver.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);
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// if (ObjectUtil.isEmpty(errArr)) {
|
|
|
|
// response.setStatus(200);
|
|
|
|
// response.setMessage("success");
|
|
|
|
// } else {
|
|
|
|
// response.setStatus(400);
|
|
|
|
// response.setMessage("ACS系统需要更新,请稍等");
|
|
|
|
// response.setErrArr(datas);
|
|
|
|
// return response;
|
|
|
|
// if (ObjectUtil.isNotEmpty(errArr)) {
|
|
|
|
// response.setMessage(errArr.getJSONObject(0).getString("message"));
|
|
|
|
// } else {
|
|
|
|
// response.setMessage("false");
|
|
|
|
// }
|
|
|
|
// response.setErrArr(errArr);
|
|
|
|
// }
|
|
|
|
for (int i = 0; i < datas.size(); i++) { |
|
|
|
String data = datas.get(i).toString(); |
|
|
|
CreateTaskRequest request = JSON.parseObject(data, CreateTaskRequest.class); |
|
|
|
String paper_array = request.getPaper_array(); |
|
|
|
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 truss_type = request.getTruss_type(); |
|
|
|
String empty_site = request.getEmpty_site(); |
|
|
|
String is_bushing = request.getIs_bushing(); |
|
|
|
String is_pulling = request.getIs_pulling(); |
|
|
|
String size = request.getSize(); |
|
|
|
String version = request.getVersion(); |
|
|
|
String bushing_num = request.getBushing_num(); |
|
|
|
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(); |
|
|
|
String start_height = request.getStart_height(); |
|
|
|
String next_height = request.getNext_height(); |
|
|
|
String params2 = request.getParams2(); |
|
|
|
Map<String, String> 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)) { |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("task_code", task_code); |
|
|
|
json.put("ext_task_id", ext_task_id); |
|
|
|
json.put("message", "任务号不能为空"); |
|
|
|
errArr.add(json); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (StrUtil.isEmpty(start_device_code)) { |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("task_code", task_code); |
|
|
|
json.put("ext_task_id", ext_task_id); |
|
|
|
json.put("message", "起点不能为空"); |
|
|
|
errArr.add(json); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (StrUtil.isEmpty(next_device_code)) { |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("task_code", task_code); |
|
|
|
json.put("ext_task_id", ext_task_id); |
|
|
|
json.put("message", "终点不能为空"); |
|
|
|
errArr.add(json); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if (StrUtil.equals(task_type, "8")) { |
|
|
|
next_device_code = request.getPut_device_code(); |
|
|
|
put_device_code = request.getNext_device_code(); |
|
|
|
} |
|
|
|
|
|
|
|
StorageCell start_storageCell = new LambdaQueryChainWrapper<>(storageCellMapper) |
|
|
|
.eq(StorageCell::getStorage_code, start_device_code) |
|
|
|
.one(); |
|
|
|
StorageCell next_storageCell = new LambdaQueryChainWrapper<>(storageCellMapper) |
|
|
|
.eq(StorageCell::getStorage_code, next_device_code) |
|
|
|
.one(); |
|
|
|
StorageCell start2_storageCell = new LambdaQueryChainWrapper<>(storageCellMapper) |
|
|
|
.eq(StorageCell::getStorage_code, start_device_code2) |
|
|
|
.one(); |
|
|
|
StorageCell next2_storageCell = new LambdaQueryChainWrapper<>(storageCellMapper) |
|
|
|
.eq(StorageCell::getStorage_code, next_device_code2) |
|
|
|
.one(); |
|
|
|
StorageCell put_storageCell = new LambdaQueryChainWrapper<>(storageCellMapper) |
|
|
|
.eq(StorageCell::getStorage_code, put_device_code) |
|
|
|
.one(); |
|
|
|
|
|
|
|
JSONObject start_device_json = (JSONObject) JSONObject.toJSON(start_storageCell); |
|
|
|
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 = (JSONObject) JSONObject.toJSON(next_storageCell); |
|
|
|
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 = (JSONObject) JSONObject.toJSON(start2_storageCell); |
|
|
|
if (!ObjectUtil.isEmpty(start_device_json2)) { |
|
|
|
start_point_code2 = (String) start_device_json2.get("parent_storage_code") == null ? start_device_code2 : (String) start_device_json2.get("storage_code"); |
|
|
|
} |
|
|
|
JSONObject next_device_json2 = (JSONObject) JSONObject.toJSON(next2_storageCell); |
|
|
|
if (!ObjectUtil.isEmpty(next_device_json2)) { |
|
|
|
next_point_code2 = (String) next_device_json2.get("parent_storage_code") == null ? next_device_code2 : (String) next_device_json2.get("storage_code"); |
|
|
|
} |
|
|
|
JSONObject put_device_json = (JSONObject) JSONObject.toJSON(put_storageCell); |
|
|
|
if (!ObjectUtil.isEmpty(put_device_json)) { |
|
|
|
put_point_code = (String) put_device_json.get("parent_storage_code") == null ? put_device_code : (String) put_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"; |
|
|
|
} |
|
|
|
|
|
|
|
if (StrUtil.equals(task_type, "5")) { |
|
|
|
if (taskserver.querySameDeviceReadyTask(start_device_code, next_device_code, "0") > 1) { |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("task_code", task_code); |
|
|
|
json.put("ext_task_id", ext_task_id); |
|
|
|
json.put("message", "已存在相同的起点:" + start_device_code + "终点:" + next_device_code + "未执行的输送任务"); |
|
|
|
errArr.add(json); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
TaskDto taskDto = taskserver.findByCodeFromCache(task_code); |
|
|
|
if (taskDto != null) { |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("task_code", task_code); |
|
|
|
json.put("ext_task_id", ext_task_id); |
|
|
|
json.put("message", "存在相同的任务号:" + task_code); |
|
|
|
errArr.add(json); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (!StrUtil.isEmpty(vehicle_code)) { |
|
|
|
TaskDto vehicle_dto = taskserver.findByContainer(vehicle_code); |
|
|
|
if (vehicle_dto != null) { |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("task_code", task_code); |
|
|
|
json.put("ext_task_id", ext_task_id); |
|
|
|
json.put("message", "已存在任务编号为" + vehicle_dto.getTask_code() + "托盘号:" + vehicle_code); |
|
|
|
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_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_id", IdUtil.simpleUUID()); |
|
|
|
jo.put("task_code", task_code); |
|
|
|
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("start_height", start_height); |
|
|
|
jo.put("next_height", next_height); |
|
|
|
jo.put("oven_time", (int) Math.ceil(oven_time)); |
|
|
|
jo.put("remark", remark); |
|
|
|
jo.put("params", params); |
|
|
|
jo.put("params2", params2); |
|
|
|
jo.put("task_type", StrUtil.isEmpty(task_type) ? 1 : Integer.parseInt(task_type)); |
|
|
|
jo.put("paper_array", JSONUtil.toJsonStr(paper_array)); |
|
|
|
jo.put("truss_type", JSONUtil.toJsonStr(truss_type)); |
|
|
|
jo.put("empty_site", JSONUtil.toJsonStr(empty_site)); |
|
|
|
jo.put("is_bushing", JSONUtil.toJsonStr(is_bushing)); |
|
|
|
jo.put("is_pulling", JSONUtil.toJsonStr(is_pulling)); |
|
|
|
jo.put("size", JSONUtil.toJsonStr(size)); |
|
|
|
jo.put("version", JSONUtil.toJsonStr(version)); |
|
|
|
jo.put("bushing_num", JSONUtil.toJsonStr(bushing_num)); |
|
|
|
|
|
|
|
|
|
|
|
if (!StrUtil.isEmpty(ext_task_id)) { |
|
|
|
jo.put("ext_task_id", ext_task_id); |
|
|
|
} |
|
|
|
|
|
|
|
TaskDto task_dto = jo.toJavaObject(TaskDto.class); |
|
|
|
try { |
|
|
|
if (ObjectUtil.isNotEmpty(request.getInteraction_json())) { |
|
|
|
task_dto.setInteractionJson(request.getInteraction_json()); |
|
|
|
} |
|
|
|
taskserver.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); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
if (ObjectUtil.isEmpty(errArr)) { |
|
|
|
response.setStatus(200); |
|
|
|
response.setMessage("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; |
|
|
|
} finally { |
|
|
|
MDC.remove(log_file_type); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public org.nl.acs.ext.wms.data.one.CreateTaskResponse crateTask(List<org.nl.acs.ext.wms.data.one.CreateTaskRequest> reqs) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public org.nl.acs.ext.wms.data.one.CancelTaskResponse cancelFromWms(List<org.nl.acs.ext.wms.data.one.CancelTaskRequest> reqs) throws Exception { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public JSONObject switchInOut(JSONObject reqs) { |
|
|
|
Assert.notNull(reqs); |
|
|
|
String device_code = reqs.getString("device_code"); |
|
|
|
if (StrUtil.isBlank(device_code)) { |
|
|
|
throw new BadRequestException("设备号不能为空!"); |
|
|
|
} |
|
|
|
String type = reqs.getString("type"); |
|
|
|
if (StrUtil.isBlank(type)) { |
|
|
|
throw new BadRequestException("出入库类型不能为空!"); |
|
|
|
} |
|
|
|
Device device = deviceAppService.findDeviceByCode(device_code); |
|
|
|
String belongToConveyorDeviceCode = Optional.ofNullable(device.getExtraValue().get("belongToConveyor")).map(Object::toString).orElse(null); |
|
|
|
Device belongToConveyorDevice = deviceAppService.findDeviceByCode(belongToConveyorDeviceCode); |
|
|
|
if (belongToConveyorDevice != null && belongToConveyorDevice.getDeviceDriver() instanceof StripConveyorDeviceDriver) { |
|
|
|
StripConveyorDeviceDriver stripConveyorDeviceDriver = (StripConveyorDeviceDriver) belongToConveyorDevice.getDeviceDriver(); |
|
|
|
//切换为入库
|
|
|
|
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.findByNextCode(samePoint); |
|
|
|
} else { |
|
|
|
taskDto = taskserver.findByNextCode(device_code); |
|
|
|
} |
|
|
|
if (ObjectUtil.isNotEmpty(taskDto)) { |
|
|
|
throw new BadRequestException("ACS存在出库任务,无法切换为入库模式"); |
|
|
|
} |
|
|
|
if (stripConveyorDeviceDriver.getInOutMode() == 0) { |
|
|
|
throw new BadRequestException("已经是入库模式,无法再次切换为入库模式"); |
|
|
|
} else { |
|
|
|
if (stripConveyorDeviceDriver.getSwitchInOut() == 0) { |
|
|
|
throw new BadRequestException("输送线不允许切换为入库模式"); |
|
|
|
} |
|
|
|
} |
|
|
|
stripConveyorDeviceDriver.writing("toCommand", 0); |
|
|
|
} |
|
|
|
//切换为出库
|
|
|
|
else if ("2".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); |
|
|
|
} else { |
|
|
|
taskDto = taskserver.findByStartCode(device_code); |
|
|
|
} |
|
|
|
if (ObjectUtil.isNotEmpty(taskDto)) { |
|
|
|
throw new BadRequestException("ACS存在入库任务,无法切换为出库模式"); |
|
|
|
} |
|
|
|
if (stripConveyorDeviceDriver.getInOutMode() == 1) { |
|
|
|
throw new BadRequestException("已经是出库模式,无法再次切换为出库模式"); |
|
|
|
} else { |
|
|
|
if (stripConveyorDeviceDriver.getSwitchInOut() == 0) { |
|
|
|
throw new BadRequestException("输送线不允许切换为出库模式"); |
|
|
|
} |
|
|
|
} |
|
|
|
stripConveyorDeviceDriver.writing("toCommand", 1); |
|
|
|
} |
|
|
|
} |
|
|
|
JSONObject resp = new JSONObject(); |
|
|
|
resp.put("status", 200); |
|
|
|
resp.put("message", "切换出入库模式成功"); |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public JSONObject pinkStartStop(JSONObject 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"); |
|
|
|
if (StrUtil.isEmpty(type)) { |
|
|
|
throw new BadRequestException("启停类型不能为空!"); |
|
|
|
} |
|
|
|
Device device = deviceAppService.findDeviceByCode(device_code); |
|
|
|
if (device != null && device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) { |
|
|
|
AppearanceInspectionScannerConveyorDeviceDriver appearanceInspectionScannerConveyorDeviceDriver = (AppearanceInspectionScannerConveyorDeviceDriver) device.getDeviceDriver(); |
|
|
|
if ("1".equals(type)) { |
|
|
|
appearanceInspectionScannerConveyorDeviceDriver.writing("mode", 2); |
|
|
|
} else { |
|
|
|
appearanceInspectionScannerConveyorDeviceDriver.writing("mode", 0); |
|
|
|
} |
|
|
|
} else { |
|
|
|
throw new BadRequestException("设备不存在"); |
|
|
|
} |
|
|
|
resp.put("status", 200); |
|
|
|
resp.put("message", "切换成功"); |
|
|
|
return resp; |
|
|
|
} |
|
|
|
// log.info("createFromWms--------------:输出参数:" + JSON.toJSONString(response));
|
|
|
|
//
|
|
|
|
// return response;
|
|
|
|
// } finally {
|
|
|
|
// MDC.remove(log_file_type);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// @Override
|
|
|
|
// public org.nl.acs.ext.wms.data.one.CreateTaskResponse crateTask(List<org.nl.acs.ext.wms.data.one.CreateTaskRequest> reqs) {
|
|
|
|
// return null;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// @Override
|
|
|
|
// public org.nl.acs.ext.wms.data.one.CancelTaskResponse cancelFromWms(List<org.nl.acs.ext.wms.data.one.CancelTaskRequest> reqs) throws Exception {
|
|
|
|
// return null;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// @Override
|
|
|
|
// public JSONObject switchInOut(JSONObject reqs) {
|
|
|
|
// Assert.notNull(reqs);
|
|
|
|
// String device_code = reqs.getString("device_code");
|
|
|
|
// if (StrUtil.isBlank(device_code)) {
|
|
|
|
// throw new BadRequestException("设备号不能为空!");
|
|
|
|
// }
|
|
|
|
// String type = reqs.getString("type");
|
|
|
|
// if (StrUtil.isBlank(type)) {
|
|
|
|
// throw new BadRequestException("出入库类型不能为空!");
|
|
|
|
// }
|
|
|
|
// Device device = deviceAppService.findDeviceByCode(device_code);
|
|
|
|
// String belongToConveyorDeviceCode = Optional.ofNullable(device.getExtraValue().get("belongToConveyor")).map(Object::toString).orElse(null);
|
|
|
|
// Device belongToConveyorDevice = deviceAppService.findDeviceByCode(belongToConveyorDeviceCode);
|
|
|
|
// if (belongToConveyorDevice != null && belongToConveyorDevice.getDeviceDriver() instanceof StripConveyorDeviceDriver) {
|
|
|
|
// StripConveyorDeviceDriver stripConveyorDeviceDriver = (StripConveyorDeviceDriver) belongToConveyorDevice.getDeviceDriver();
|
|
|
|
// //切换为入库
|
|
|
|
// 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.findByNextCode(samePoint);
|
|
|
|
// } else {
|
|
|
|
// taskDto = taskserver.findByNextCode(device_code);
|
|
|
|
// }
|
|
|
|
// if (ObjectUtil.isNotEmpty(taskDto)) {
|
|
|
|
// throw new BadRequestException("ACS存在出库任务,无法切换为入库模式");
|
|
|
|
// }
|
|
|
|
// if (stripConveyorDeviceDriver.getInOutMode() == 0) {
|
|
|
|
// throw new BadRequestException("已经是入库模式,无法再次切换为入库模式");
|
|
|
|
// } else {
|
|
|
|
// if (stripConveyorDeviceDriver.getSwitchInOut() == 0) {
|
|
|
|
// throw new BadRequestException("输送线不允许切换为入库模式");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// stripConveyorDeviceDriver.writing("toCommand", 0);
|
|
|
|
// }
|
|
|
|
// //切换为出库
|
|
|
|
// else if ("2".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);
|
|
|
|
// } else {
|
|
|
|
// taskDto = taskserver.findByStartCode(device_code);
|
|
|
|
// }
|
|
|
|
// if (ObjectUtil.isNotEmpty(taskDto)) {
|
|
|
|
// throw new BadRequestException("ACS存在入库任务,无法切换为出库模式");
|
|
|
|
// }
|
|
|
|
// if (stripConveyorDeviceDriver.getInOutMode() == 1) {
|
|
|
|
// throw new BadRequestException("已经是出库模式,无法再次切换为出库模式");
|
|
|
|
// } else {
|
|
|
|
// if (stripConveyorDeviceDriver.getSwitchInOut() == 0) {
|
|
|
|
// throw new BadRequestException("输送线不允许切换为出库模式");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// stripConveyorDeviceDriver.writing("toCommand", 1);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// JSONObject resp = new JSONObject();
|
|
|
|
// resp.put("status", 200);
|
|
|
|
// resp.put("message", "切换出入库模式成功");
|
|
|
|
// return null;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// @Override
|
|
|
|
// public JSONObject pinkStartStop(JSONObject 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");
|
|
|
|
// if (StrUtil.isEmpty(type)) {
|
|
|
|
// throw new BadRequestException("启停类型不能为空!");
|
|
|
|
// }
|
|
|
|
// Device device = deviceAppService.findDeviceByCode(device_code);
|
|
|
|
// if (device != null && device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
|
|
|
|
// AppearanceInspectionScannerConveyorDeviceDriver appearanceInspectionScannerConveyorDeviceDriver = (AppearanceInspectionScannerConveyorDeviceDriver) device.getDeviceDriver();
|
|
|
|
// if ("1".equals(type)) {
|
|
|
|
// appearanceInspectionScannerConveyorDeviceDriver.writing("mode", 2);
|
|
|
|
// } else {
|
|
|
|
// appearanceInspectionScannerConveyorDeviceDriver.writing("mode", 0);
|
|
|
|
// }
|
|
|
|
// } else {
|
|
|
|
// throw new BadRequestException("设备不存在");
|
|
|
|
// }
|
|
|
|
// resp.put("status", 200);
|
|
|
|
// resp.put("message", "切换成功");
|
|
|
|
// return resp;
|
|
|
|
// }
|
|
|
|
|
|
|
|
} |
|
|
|