rev:上位系统接口

This commit is contained in:
2024-06-26 14:56:38 +08:00
parent b551d82f21
commit 6579c025ba
13 changed files with 588 additions and 560 deletions

View File

@@ -2,7 +2,6 @@ package org.nl.acs.ext;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.nl.config.SpringContextHolder; import org.nl.config.SpringContextHolder;
import org.nl.config.lucene.service.LuceneExecuteLogService; import org.nl.config.lucene.service.LuceneExecuteLogService;
import org.nl.config.lucene.service.dto.LuceneLogDto; import org.nl.config.lucene.service.dto.LuceneLogDto;
@@ -27,7 +26,7 @@ public class LmsHttpUtil {
.body(JSON.toJSONString(requestParam)) .body(JSON.toJSONString(requestParam))
.execute() .execute()
.body(); .body();
LuceneLogDto luceneLogDto = new LuceneLogDto(url, requestParam.toString(), body, JSONObject.parseObject(body).getString("status"), body); LuceneLogDto luceneLogDto = new LuceneLogDto(url, requestParam.toString(), body, "200", body);
logService.interfaceExecuteLog(luceneLogDto); logService.interfaceExecuteLog(luceneLogDto);
return LMS_RESPONSE_ADAPTER.adapt(body, type); return LMS_RESPONSE_ADAPTER.adapt(body, type);
} catch (Exception e) { } catch (Exception e) {
@@ -48,7 +47,7 @@ public class LmsHttpUtil {
.body(JSON.toJSONString(requestParam)) .body(JSON.toJSONString(requestParam))
.execute() .execute()
.body(); .body();
LuceneLogDto luceneLogDto = new LuceneLogDto(url, requestParam.toString(), body, JSONObject.parseObject(body).getString("status"), body); LuceneLogDto luceneLogDto = new LuceneLogDto(url, requestParam.toString(), body, "200", body);
logService.interfaceExecuteLog(luceneLogDto); logService.interfaceExecuteLog(luceneLogDto);
return LMS_RESPONSE_ADAPTER.adapt(body, type); return LMS_RESPONSE_ADAPTER.adapt(body, type);
} catch (Exception e) { } catch (Exception e) {

View File

@@ -1,6 +1,5 @@
package org.nl.acs.ext; package org.nl.acs.ext;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
/** /**
@@ -8,15 +7,21 @@ import com.alibaba.fastjson.JSONObject;
* @Author Gengby * @Author Gengby
* @Date 2024/4/22 * @Date 2024/4/22
*/ */
public class LmsResponseAdapter<T> implements ResponseAdapter<T> { public class LmsResponseAdapter implements ResponseAdapter {
@Override @Override
public UnifiedResponse<T> adapt(String responseBody, Class<T> type) { public <T> UnifiedResponse<T> adapt(String responseBody, Class<T> type) {
JSONObject jsonResponse = JSONObject.parseObject(responseBody); JSONObject jsonResponse = JSONObject.parseObject(responseBody);
boolean isSuccess = jsonResponse.getInteger("status") == 200; boolean isSuccess = jsonResponse.getInteger("code") == 200;
String message = jsonResponse.getString("message"); String message = jsonResponse.getString("msg");
if (type != null) { if (type != null) {
T data = JSONObject.toJavaObject(jsonResponse.getJSONObject("data"), type); if (type.isArray()) {
return new UnifiedResponse<>(isSuccess, message, data); T data = JSONObject.toJavaObject(jsonResponse.getJSONArray("content"), type);
return new UnifiedResponse<>(isSuccess, message, data);
} else {
T data = JSONObject.toJavaObject(jsonResponse.getJSONObject("data"), type);
return new UnifiedResponse<>(isSuccess, message, data);
}
} }
return new UnifiedResponse<>(isSuccess, message); return new UnifiedResponse<>(isSuccess, message);
} }

View File

@@ -8,9 +8,10 @@ import com.alibaba.fastjson.JSONObject;
* @Author Gengby * @Author Gengby
* @Date 2024/4/22 * @Date 2024/4/22
*/ */
public class MesResponseAdapter<T> implements ResponseAdapter<T> { public class MesResponseAdapter implements ResponseAdapter {
@Override @Override
public UnifiedResponse<T> adapt(String responseBody, Class<T> type) { public <T> UnifiedResponse<T> adapt(String responseBody, Class<T> type) {
JSONObject jsonResponse = JSONObject.parseObject(responseBody); JSONObject jsonResponse = JSONObject.parseObject(responseBody);
boolean isSuccess = jsonResponse.getInteger("code") == 0; boolean isSuccess = jsonResponse.getInteger("code") == 0;
String message = jsonResponse.getString("msg"); String message = jsonResponse.getString("msg");

View File

@@ -1,11 +1,12 @@
package org.nl.acs.ext; package org.nl.acs.ext;
/** /**
* @Description TODO * @Description TODO
* @Author Gengby * @Author Gengby
* @Date 2024/4/22 * @Date 2024/4/22
*/ */
public interface ResponseAdapter<T> { public interface ResponseAdapter {
UnifiedResponse<T> adapt(String responseBody, Class<T> type); public <T> UnifiedResponse<T> adapt(String responseBody, Class<T> type);
} }

View File

@@ -0,0 +1,35 @@
package org.nl.acs.ext.wms;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
/**
* @Description TODO
* @Author Gengby
* @Date 2024/6/25
*/
public class IpUtil {
public static final String LOCAL_IP = localIP();
public static String localIP() {
try {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
NetworkInterface networkInterface = networkInterfaces.nextElement();
Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
while (inetAddresses.hasMoreElements()) {
InetAddress inetAddress = inetAddresses.nextElement();
if (!inetAddress.isLoopbackAddress() && inetAddress instanceof java.net.Inet4Address) {
return inetAddress.getHostAddress();
}
}
}
} catch (SocketException e) {
e.printStackTrace();
}
return "";
}
}

View File

@@ -0,0 +1,32 @@
package org.nl.acs.ext.wms.data.req;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.Builder;
import lombok.Data;
import org.nl.acs.ext.wms.IpUtil;
import org.nl.config.IdUtil;
/**
* @Description TODO
* @Author Gengby
* @Date 2024/6/25
*/
@Data
@Builder
public class CommonRequest {
private String service;
private String type;
private String ip = IpUtil.LOCAL_IP;
@Builder.Default
private String request_time = DateUtil.now();
@Builder.Default
private String trace_id = "trace_id_" + IdUtil.getStringId();
private JSONObject data;
}

View File

@@ -0,0 +1,18 @@
package org.nl.acs.ext.wms.data.resp;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
/**
* @Description TODO
* @Author Gengby
* @Date 2024/6/25
*/
@Data
public class CommonResponse {
private String code;
private String msg;
private JSONObject data;
}

View File

@@ -2,11 +2,9 @@
package org.nl.acs.ext.wms.rest; package org.nl.acs.ext.wms.rest;
import com.alibaba.fastjson.JSONArray;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.acs.ext.wms.data.req.CommonRequest;
import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@@ -16,7 +14,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/** /**
* @author ludj * @author ludj
@@ -24,27 +21,15 @@ import java.util.Map;
**/ **/
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/api/wms") @RequestMapping("/api/acsToWms")
@Slf4j @Slf4j
public class AcsToWmsController { public class AcsToWmsController {
private final AcsToWmsService acstowmsService; private final AcsToWmsService acstowmsService;
// @PostMapping("/applyTask") @PostMapping("/apply")
// @Log("向WMS申请任务") @Log("向WMS申请")
// public ResponseEntity<Object> applyTaskToWms(@RequestBody CommonRequest request) {
// public ResponseEntity<Object> applyTaskToWms(@RequestBody String device_code, String container_code, int height, int weight) { return new ResponseEntity<>(acstowmsService.apply(request), HttpStatus.OK);
// return new ResponseEntity<>(acstowmsService.applyTaskToWms(device_code, container_code, height, weight), HttpStatus.OK);
// }
@PostMapping("/taskStatusFeedback")
@Log("向WMS反馈任务状态")
public ResponseEntity<Object> feedbackTaskStatusToWms(@RequestBody Map whereJson) {
JSONArray data = JSONArray.parseArray(String.valueOf(whereJson));
return new ResponseEntity<>(acstowmsService.feedbackTaskStatusToWms(data), HttpStatus.OK);
} }
} }

View File

@@ -2,24 +2,11 @@
package org.nl.acs.ext.wms.rest; package org.nl.acs.ext.wms.rest;
import cn.dev33.satoken.annotation.SaIgnore;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.acs.ext.wms.data.one.CancelTaskRequest;
import org.nl.acs.ext.wms.service.WmsToAcsService;
//import org.nl.modules.logging.InterfaceLogType;
import org.nl.common.logging.annotation.Log;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/** /**
* @author ludj * @author ludj
@@ -30,39 +17,39 @@ import java.util.List;
@RequestMapping("/api/wms") @RequestMapping("/api/wms")
@Slf4j @Slf4j
public class WmsToAcsController { public class WmsToAcsController {
private final WmsToAcsService wmstoacsService; // private final WmsToAcsService wmstoacsService;
//
@PostMapping("/task") // @PostMapping("/task")
@Log(value = "ACS接收WMS任务") // @Log(value = "ACS接收WMS任务")
@SaIgnore // @SaIgnore
public ResponseEntity<Object> createFromWms(@RequestBody String whereJson) { // public ResponseEntity<Object> createFromWms(@RequestBody String whereJson) {
return new ResponseEntity<>(wmstoacsService.crateTask(whereJson), HttpStatus.OK); // return new ResponseEntity<>(wmstoacsService.crateTask(whereJson), HttpStatus.OK);
} // }
//
@PostMapping("/cancelTask") // @PostMapping("/cancelTask")
@Log(value = "WMS取消任务") // @Log(value = "WMS取消任务")
@SaIgnore // @SaIgnore
public ResponseEntity<Object> cancelFromWms(@RequestBody List<CancelTaskRequest> reqs) throws Exception { // public ResponseEntity<Object> cancelFromWms(@RequestBody List<CancelTaskRequest> reqs) throws Exception {
return new ResponseEntity<>(wmstoacsService.cancelFromWms(reqs), HttpStatus.OK); // return new ResponseEntity<>(wmstoacsService.cancelFromWms(reqs), HttpStatus.OK);
} // }
//
@PostMapping("/switchInOut") // @PostMapping("/switchInOut")
@Log(value = "切换出入库模式") // @Log(value = "切换出入库模式")
@SaIgnore // @SaIgnore
public ResponseEntity<Object> switchInOut(@RequestBody JSONObject reqs) throws Exception { // public ResponseEntity<Object> switchInOut(@RequestBody JSONObject reqs) throws Exception {
return new ResponseEntity<>(wmstoacsService.switchInOut(reqs), HttpStatus.OK); // return new ResponseEntity<>(wmstoacsService.switchInOut(reqs), HttpStatus.OK);
} // }
//
@PostMapping("/pinckStartStop") // @PostMapping("/pinckStartStop")
@Log(value = "拣选工位启停") // @Log(value = "拣选工位启停")
@SaIgnore // @SaIgnore
public ResponseEntity<Object> pinckStartStop(@RequestBody JSONObject reqs) throws Exception { // public ResponseEntity<Object> pinckStartStop(@RequestBody JSONObject reqs) throws Exception {
return new ResponseEntity<>(wmstoacsService.pinkStartStop(reqs), HttpStatus.OK); // return new ResponseEntity<>(wmstoacsService.pinkStartStop(reqs), HttpStatus.OK);
} // }
//
//
//
//
//
} }

View File

@@ -1,24 +1,10 @@
package org.nl.acs.ext.wms.service; package org.nl.acs.ext.wms.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.acs.ext.UnifiedResponse; import org.nl.acs.ext.UnifiedResponse;
import org.nl.acs.ext.wms.data.req.CommonRequest;
public interface AcsToWmsService { public interface AcsToWmsService {
<T> UnifiedResponse<T> apply(CommonRequest request);
<T> UnifiedResponse<T> apply(CommonRequest request, Class<T> type);
public UnifiedResponse applyTaskToWms(JSONObject jo);
/**
* 向WMS反馈任务状态
* @param arr
* @return
*/
public UnifiedResponse feedbackTaskStatusToWms(JSONArray arr);
public UnifiedResponse feedPinkStartStop(JSONObject req);
} }

View File

@@ -1,38 +1,31 @@
package org.nl.acs.ext.wms.service; package org.nl.acs.ext.wms.service;
import com.alibaba.fastjson.JSONObject;
import org.nl.acs.ext.wms.data.one.*;
import java.util.List;
public interface WmsToAcsService { public interface WmsToAcsService {
/** // /**
* crateTask // * crateTask
* @param param // * @param param
* @return // * @return
*/ // */
org.nl.acs.ext.wms.data.CreateTaskResponse crateTask(String param); // crateTask(String param);
//
// /**
// * 创建任务
// *
// * @param reqs
// * @return
// */
// CreateTaskResponse crateTask(List<CreateTaskRequest> reqs);
//
//
// /**
// * 取消任务
// * @param reqs
// * @return
// * @throws Exception
// */
// CancelTaskResponse cancelFromWms(List<CancelTaskRequest> reqs) throws Exception;
/**
* 创建任务
*
* @param reqs
* @return
*/
CreateTaskResponse crateTask(List<CreateTaskRequest> reqs);
/**
* 取消任务
* @param reqs
* @return
* @throws Exception
*/
CancelTaskResponse cancelFromWms(List<CancelTaskRequest> reqs) throws Exception;
JSONObject switchInOut(JSONObject reqs);
JSONObject pinkStartStop(JSONObject reqs);
} }

View File

@@ -1,19 +1,13 @@
package org.nl.acs.ext.wms.service.impl; package org.nl.acs.ext.wms.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.acs.address.service.AddressService; import org.nl.acs.address.service.AddressService;
import org.nl.acs.address.service.dto.AddressDto; import org.nl.acs.address.service.dto.AddressDto;
import org.nl.acs.ext.LmsHttpUtil; import org.nl.acs.ext.LmsHttpUtil;
import org.nl.acs.ext.UnifiedResponse; import org.nl.acs.ext.UnifiedResponse;
import org.nl.acs.ext.wms.RetryableUtil; import org.nl.acs.ext.wms.data.req.CommonRequest;
import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.task.service.TaskService;
import org.nl.config.lucene.service.LuceneExecuteLogService;
import org.nl.system.service.param.ISysParamService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -26,22 +20,15 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
private AddressService addressService; private AddressService addressService;
@Override @Override
public UnifiedResponse<JSONObject> applyTaskToWms(JSONObject jo) { public <T> UnifiedResponse<T> apply(CommonRequest request) {
AddressDto addressDto = addressService.findByCode("applyTaskToWms"); AddressDto addressDto = addressService.findByCode("apply");
return LmsHttpUtil.sendPostRequest(addressDto.getMethods_url(), jo, null); return LmsHttpUtil.sendPostRequest(addressDto.getMethods_url(), request, null);
} }
@Override @Override
public UnifiedResponse<JSONObject> feedbackTaskStatusToWms(JSONArray arr) { public <T> UnifiedResponse<T> apply(CommonRequest request, Class<T> type) {
AddressDto addressDto = addressService.findByCode("feedTaskStatus"); AddressDto addressDto = addressService.findByCode("apply");
return LmsHttpUtil.sendPostRequest(addressDto.getMethods_url(), arr, null); return LmsHttpUtil.sendPostRequest(addressDto.getMethods_url(), request, type);
} }
@Override
public UnifiedResponse feedPinkStartStop(JSONObject req) {
AddressDto addressDto = addressService.findByCode("feedPinkStartStop");
return LmsHttpUtil.sendPostRequest(addressDto.getMethods_url(), req, null);
}
} }

View File

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