From 6579c025bad6df8500cc72270b26df0de33209b0 Mon Sep 17 00:00:00 2001 From: gengby <858962040@qq.com> Date: Wed, 26 Jun 2024 14:56:38 +0800 Subject: [PATCH] =?UTF-8?q?rev=EF=BC=9A=E4=B8=8A=E4=BD=8D=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/nl/acs/ext/LmsHttpUtil.java | 5 +- .../org/nl/acs/ext/LmsResponseAdapter.java | 19 +- .../org/nl/acs/ext/MesResponseAdapter.java | 5 +- .../java/org/nl/acs/ext/ResponseAdapter.java | 5 +- .../main/java/org/nl/acs/ext/wms/IpUtil.java | 35 + .../acs/ext/wms/data/req/CommonRequest.java | 32 + .../acs/ext/wms/data/resp/CommonResponse.java | 18 + .../acs/ext/wms/rest/AcsToWmsController.java | 27 +- .../acs/ext/wms/rest/WmsToAcsController.java | 81 +- .../acs/ext/wms/service/AcsToWmsService.java | 20 +- .../acs/ext/wms/service/WmsToAcsService.java | 53 +- .../wms/service/impl/AcsToWmsServiceImpl.java | 27 +- .../wms/service/impl/WmsToAcsServiceImpl.java | 819 +++++++++--------- 13 files changed, 587 insertions(+), 559 deletions(-) create mode 100644 nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/IpUtil.java create mode 100644 nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/req/CommonRequest.java create mode 100644 nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/resp/CommonResponse.java diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/LmsHttpUtil.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/LmsHttpUtil.java index 81d95d5..ed09d0a 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/LmsHttpUtil.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/LmsHttpUtil.java @@ -2,7 +2,6 @@ package org.nl.acs.ext; import cn.hutool.http.HttpRequest; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import org.nl.config.SpringContextHolder; import org.nl.config.lucene.service.LuceneExecuteLogService; import org.nl.config.lucene.service.dto.LuceneLogDto; @@ -27,7 +26,7 @@ public class LmsHttpUtil { .body(JSON.toJSONString(requestParam)) .execute() .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); return LMS_RESPONSE_ADAPTER.adapt(body, type); } catch (Exception e) { @@ -48,7 +47,7 @@ public class LmsHttpUtil { .body(JSON.toJSONString(requestParam)) .execute() .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); return LMS_RESPONSE_ADAPTER.adapt(body, type); } catch (Exception e) { diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/LmsResponseAdapter.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/LmsResponseAdapter.java index bc064fc..1943bea 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/LmsResponseAdapter.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/LmsResponseAdapter.java @@ -1,6 +1,5 @@ package org.nl.acs.ext; - import com.alibaba.fastjson.JSONObject; /** @@ -8,15 +7,21 @@ import com.alibaba.fastjson.JSONObject; * @Author Gengby * @Date 2024/4/22 */ -public class LmsResponseAdapter implements ResponseAdapter { +public class LmsResponseAdapter implements ResponseAdapter { + @Override - public UnifiedResponse adapt(String responseBody, Class type) { + public UnifiedResponse adapt(String responseBody, Class type) { JSONObject jsonResponse = JSONObject.parseObject(responseBody); - boolean isSuccess = jsonResponse.getInteger("status") == 200; - String message = jsonResponse.getString("message"); + boolean isSuccess = jsonResponse.getInteger("code") == 200; + String message = jsonResponse.getString("msg"); if (type != null) { - T data = JSONObject.toJavaObject(jsonResponse.getJSONObject("data"), type); - return new UnifiedResponse<>(isSuccess, message, data); + if (type.isArray()) { + 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); } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/MesResponseAdapter.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/MesResponseAdapter.java index 988a9cd..69e8f3f 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/MesResponseAdapter.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/MesResponseAdapter.java @@ -8,9 +8,10 @@ import com.alibaba.fastjson.JSONObject; * @Author Gengby * @Date 2024/4/22 */ -public class MesResponseAdapter implements ResponseAdapter { +public class MesResponseAdapter implements ResponseAdapter { + @Override - public UnifiedResponse adapt(String responseBody, Class type) { + public UnifiedResponse adapt(String responseBody, Class type) { JSONObject jsonResponse = JSONObject.parseObject(responseBody); boolean isSuccess = jsonResponse.getInteger("code") == 0; String message = jsonResponse.getString("msg"); diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/ResponseAdapter.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/ResponseAdapter.java index b366224..b28363f 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/ResponseAdapter.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/ResponseAdapter.java @@ -1,11 +1,12 @@ package org.nl.acs.ext; + /** * @Description TODO * @Author Gengby * @Date 2024/4/22 */ -public interface ResponseAdapter { - UnifiedResponse adapt(String responseBody, Class type); +public interface ResponseAdapter { + public UnifiedResponse adapt(String responseBody, Class type); } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/IpUtil.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/IpUtil.java new file mode 100644 index 0000000..6c969f0 --- /dev/null +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/IpUtil.java @@ -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 networkInterfaces = NetworkInterface.getNetworkInterfaces(); + while (networkInterfaces.hasMoreElements()) { + NetworkInterface networkInterface = networkInterfaces.nextElement(); + Enumeration 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 ""; + } +} \ No newline at end of file diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/req/CommonRequest.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/req/CommonRequest.java new file mode 100644 index 0000000..e6841e0 --- /dev/null +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/req/CommonRequest.java @@ -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; +} \ No newline at end of file diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/resp/CommonResponse.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/resp/CommonResponse.java new file mode 100644 index 0000000..968484b --- /dev/null +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/resp/CommonResponse.java @@ -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; +} \ No newline at end of file diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java index f51cd04..44a7b70 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java @@ -2,11 +2,9 @@ package org.nl.acs.ext.wms.rest; -import com.alibaba.fastjson.JSONArray; - - import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.nl.acs.ext.wms.data.req.CommonRequest; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.springframework.http.HttpStatus; 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.RestController; -import java.util.Map; /** * @author ludj @@ -24,27 +21,15 @@ import java.util.Map; **/ @RestController @RequiredArgsConstructor -@RequestMapping("/api/wms") +@RequestMapping("/api/acsToWms") @Slf4j public class AcsToWmsController { private final AcsToWmsService acstowmsService; -// @PostMapping("/applyTask") -// @Log("向WMS申请任务") -// -// public ResponseEntity applyTaskToWms(@RequestBody String device_code, String container_code, int height, int weight) { -// return new ResponseEntity<>(acstowmsService.applyTaskToWms(device_code, container_code, height, weight), HttpStatus.OK); -// } - - - @PostMapping("/taskStatusFeedback") - @Log("向WMS反馈任务状态") - public ResponseEntity feedbackTaskStatusToWms(@RequestBody Map whereJson) { - JSONArray data = JSONArray.parseArray(String.valueOf(whereJson)); - return new ResponseEntity<>(acstowmsService.feedbackTaskStatusToWms(data), HttpStatus.OK); + @PostMapping("/apply") + @Log("向WMS申请") + public ResponseEntity applyTaskToWms(@RequestBody CommonRequest request) { + return new ResponseEntity<>(acstowmsService.apply(request), HttpStatus.OK); } - - - } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java index d77ab50..5172e15 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java @@ -2,24 +2,11 @@ package org.nl.acs.ext.wms.rest; -import cn.dev33.satoken.annotation.SaIgnore; - - -import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; 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.RestController; -import java.util.List; /** * @author ludj @@ -30,39 +17,39 @@ import java.util.List; @RequestMapping("/api/wms") @Slf4j public class WmsToAcsController { - private final WmsToAcsService wmstoacsService; - - @PostMapping("/task") - @Log(value = "ACS接收WMS任务") - @SaIgnore - public ResponseEntity createFromWms(@RequestBody String whereJson) { - return new ResponseEntity<>(wmstoacsService.crateTask(whereJson), HttpStatus.OK); - } - - @PostMapping("/cancelTask") - @Log(value = "WMS取消任务") - @SaIgnore - public ResponseEntity cancelFromWms(@RequestBody List reqs) throws Exception { - return new ResponseEntity<>(wmstoacsService.cancelFromWms(reqs), HttpStatus.OK); - } - - @PostMapping("/switchInOut") - @Log(value = "切换出入库模式") - @SaIgnore - public ResponseEntity switchInOut(@RequestBody JSONObject reqs) throws Exception { - return new ResponseEntity<>(wmstoacsService.switchInOut(reqs), HttpStatus.OK); - } - - @PostMapping("/pinckStartStop") - @Log(value = "拣选工位启停") - @SaIgnore - public ResponseEntity pinckStartStop(@RequestBody JSONObject reqs) throws Exception { - return new ResponseEntity<>(wmstoacsService.pinkStartStop(reqs), HttpStatus.OK); - } - - - - - +// private final WmsToAcsService wmstoacsService; +// +// @PostMapping("/task") +// @Log(value = "ACS接收WMS任务") +// @SaIgnore +// public ResponseEntity createFromWms(@RequestBody String whereJson) { +// return new ResponseEntity<>(wmstoacsService.crateTask(whereJson), HttpStatus.OK); +// } +// +// @PostMapping("/cancelTask") +// @Log(value = "WMS取消任务") +// @SaIgnore +// public ResponseEntity cancelFromWms(@RequestBody List reqs) throws Exception { +// return new ResponseEntity<>(wmstoacsService.cancelFromWms(reqs), HttpStatus.OK); +// } +// +// @PostMapping("/switchInOut") +// @Log(value = "切换出入库模式") +// @SaIgnore +// public ResponseEntity switchInOut(@RequestBody JSONObject reqs) throws Exception { +// return new ResponseEntity<>(wmstoacsService.switchInOut(reqs), HttpStatus.OK); +// } +// +// @PostMapping("/pinckStartStop") +// @Log(value = "拣选工位启停") +// @SaIgnore +// public ResponseEntity pinckStartStop(@RequestBody JSONObject reqs) throws Exception { +// return new ResponseEntity<>(wmstoacsService.pinkStartStop(reqs), HttpStatus.OK); +// } +// +// +// +// +// } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java index c65f68d..ae51857 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java @@ -1,24 +1,10 @@ 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.wms.data.req.CommonRequest; public interface AcsToWmsService { + UnifiedResponse apply(CommonRequest request); - - public UnifiedResponse applyTaskToWms(JSONObject jo); - - /** - * 向WMS反馈任务状态 - * @param arr - * @return - */ - public UnifiedResponse feedbackTaskStatusToWms(JSONArray arr); - - - public UnifiedResponse feedPinkStartStop(JSONObject req); - - - + UnifiedResponse apply(CommonRequest request, Class type); } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java index 9bcba4e..8af33d5 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java @@ -1,38 +1,31 @@ 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 { - /** - * crateTask - * @param param - * @return - */ - org.nl.acs.ext.wms.data.CreateTaskResponse crateTask(String param); +// /** +// * crateTask +// * @param param +// * @return +// */ +// crateTask(String param); +// +// /** +// * 创建任务 +// * +// * @param reqs +// * @return +// */ +// CreateTaskResponse crateTask(List reqs); +// +// +// /** +// * 取消任务 +// * @param reqs +// * @return +// * @throws Exception +// */ +// CancelTaskResponse cancelFromWms(List reqs) throws Exception; - /** - * 创建任务 - * - * @param reqs - * @return - */ - CreateTaskResponse crateTask(List reqs); - - - /** - * 取消任务 - * @param reqs - * @return - * @throws Exception - */ - CancelTaskResponse cancelFromWms(List reqs) throws Exception; - - - JSONObject switchInOut(JSONObject reqs); - - JSONObject pinkStartStop(JSONObject reqs); } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java index 9f1a634..163fcdb 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java @@ -1,19 +1,13 @@ package org.nl.acs.ext.wms.service.impl; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.address.service.AddressService; import org.nl.acs.address.service.dto.AddressDto; import org.nl.acs.ext.LmsHttpUtil; 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.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.stereotype.Service; @@ -26,22 +20,15 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { private AddressService addressService; @Override - public UnifiedResponse applyTaskToWms(JSONObject jo) { - AddressDto addressDto = addressService.findByCode("applyTaskToWms"); - return LmsHttpUtil.sendPostRequest(addressDto.getMethods_url(), jo, null); + public UnifiedResponse apply(CommonRequest request) { + AddressDto addressDto = addressService.findByCode("apply"); + return LmsHttpUtil.sendPostRequest(addressDto.getMethods_url(), request, null); } @Override - public UnifiedResponse feedbackTaskStatusToWms(JSONArray arr) { - AddressDto addressDto = addressService.findByCode("feedTaskStatus"); - return LmsHttpUtil.sendPostRequest(addressDto.getMethods_url(), arr, null); + public UnifiedResponse apply(CommonRequest request, Class type) { + AddressDto addressDto = addressService.findByCode("apply"); + 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); - } - - } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index b6def5e..5d3aa74 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -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 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 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 reqs) { - return null; - } - - @Override - public org.nl.acs.ext.wms.data.one.CancelTaskResponse cancelFromWms(List 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 reqs) { +// return null; +// } +// +// @Override +// public org.nl.acs.ext.wms.data.one.CancelTaskResponse cancelFromWms(List 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; +// } }