diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_old/hailiang_hr_ssx/HailiangHrSsxDeviceDriver.java b/wcs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_old/hailiang_hr_ssx/HailiangHrSsxDeviceDriver.java index 34f1d9b1..1fa95b87 100644 --- a/wcs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_old/hailiang_hr_ssx/HailiangHrSsxDeviceDriver.java +++ b/wcs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_old/hailiang_hr_ssx/HailiangHrSsxDeviceDriver.java @@ -3,6 +3,7 @@ package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_hr_ssx; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; @@ -80,6 +81,8 @@ public class HailiangHrSsxDeviceDriver extends AbstractOpcDeviceDriver implement String message = null; Boolean iserror = false; private Date instruction_require_time = new Date(); + private Date containerArrivedRequestTime = new Date(); + private Date inTaskRequestTime = new Date(); private int instruction_require_time_out = 30000; boolean requireSucess = false; @@ -113,11 +116,8 @@ public class HailiangHrSsxDeviceDriver extends AbstractOpcDeviceDriver implement if (last_move == 1 && move == 0) { this.lastHasContainerTime = System.currentTimeMillis(); } - if (move == 1 && barcode.length() > 0 && !requireSucess) { - String containerArrived = ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("containerArrived")) ? "false" : this.getDevice().getExtraValue().get("apply_task").toString(); - if ("true".equals(containerArrived)) { - this.containerArrived(); - } + if (move == 1) { + inTaskRequestTime = new Date(); } } if (error != last_error) { @@ -140,10 +140,17 @@ public class HailiangHrSsxDeviceDriver extends AbstractOpcDeviceDriver implement Instruction instruction = null; List toInstructions; + if (mode == 3 && move == 1 && barcode.length() > 0 && !"000000000".equals(barcode) && !requireSucess) { + String containerArrived = ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("containerArrived")) ? "false" : this.getDevice().getExtraValue().get("containerArrived").toString(); + if ("true".equals(containerArrived)) { + this.containerArrived(); + } + } + String applyEmpty = ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("apply_task")) ? "false" : this.getDevice().getExtraValue().get("apply_task").toString(); if (StrUtil.equals("true", applyEmpty)) { //申请空框任务 - if (mode == 2 && move == 0 && !requireSucess) { + if (mode == 3 && move == 0 && !requireSucess) { this.applyEmptyTask(); } } @@ -162,15 +169,27 @@ public class HailiangHrSsxDeviceDriver extends AbstractOpcDeviceDriver implement * 申请出空框任务 acs->lms */ public void applyEmptyTask() { + if (System.currentTimeMillis() - instruction_require_time.getTime() + < this.instruction_require_time_out) { + return; + } + Object apply_empty = this.getDevice().getExtraValue().get("apply_empty"); + if (apply_empty == null) { + return; + } + instruction_require_time = new Date(); JSONObject reqParam = new JSONObject(); - reqParam.put("device_code", this.getDevice_code()); + reqParam.put("device_code1", apply_empty.toString()); reqParam.put("type", StatusEnum.HAIROU_LIKU_REQ.getCode()); reqParam.put("item_type", StatusEnum.HAIROU_EMPTY_OUT_REQ.getCode()); reqParam.put("number", this.getDevice().getExtraValue().get("apply_num")); HttpResponse httpResponse = acsToWmsService.applyTaskToWms(reqParam); if (httpResponse != null && httpResponse.getStatus() == 200) { - requireSucess = true; - log.info("{}:申请空框任务成功!", this.getDevice_code()); + JSONObject resp = JSONObject.parseObject(httpResponse.body()); + if (resp.getInteger("status") == 200) { + requireSucess = true; + log.info("{}:申请空框任务成功!", this.getDevice_code()); + } } } @@ -180,26 +199,27 @@ public class HailiangHrSsxDeviceDriver extends AbstractOpcDeviceDriver implement * @return */ public void containerArrived() throws Exception { + if (System.currentTimeMillis() - containerArrivedRequestTime.getTime() + < this.instruction_require_time_out) { + return; + } TaskDto vehicle_dto = taskServer.findByContainer(barcode); - if (vehicle_dto == null) { - instruction_require_time = new Date(); + if (vehicle_dto != null) { + containerArrivedRequestTime = new Date(); ContainerArrivedRequest containerArrivedRequest = new ContainerArrivedRequest(); NodeStates nodeStates = new NodeStates(); containerArrivedRequest.setSlotCode(device_code); containerArrivedRequest.setContainerCode(barcode); - Date date = new Date(); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd :hh:mm:ss"); - nodeStates.setLastHasContainerTime(Long.parseLong(dateFormat.format(date))); - nodeStates.setLastReadTime(Long.parseLong(dateFormat.format(date))); - nodeStates.setLastReportTime(Long.parseLong(dateFormat.format(date))); + nodeStates.setLastHasContainerTime(lastHasContainerTime); + nodeStates.setLastReadTime(lastReadTime); + nodeStates.setLastReportTime(lastReportTime); Resp containerArrivedResp = acsToLiKuService.containerArrived(containerArrivedRequest); - JSONObject response = JSONObject.parseObject(String.valueOf(containerArrivedResp)); - int code = response.getInteger("code"); - String msg = response.getString("msg"); - if (code == 0) { + String code = containerArrivedResp.getCode(); + String msg = containerArrivedResp.getMsg(); + if ("0".equals(code)) { requireSucess = true; this.setLastReportTime(System.currentTimeMillis()); - log.info("请求成功 请求结果{}", code, msg); + log.info("请求成功,code:{},请求结果{}", code, msg); } } } diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_old/hailiang_with_station/WithStationDeviceDriver.java b/wcs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_old/hailiang_with_station/WithStationDeviceDriver.java index 961a7f94..c289f746 100644 --- a/wcs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_old/hailiang_with_station/WithStationDeviceDriver.java +++ b/wcs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_old/hailiang_with_station/WithStationDeviceDriver.java @@ -198,53 +198,55 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements TaskDto vehicle_dto = taskServer.findByContainer(hailiangHrSsxDeviceDriver.getBarcode()); if (vehicle_dto == null) { //如果设备满足请求条件、并且超过等待时间 则就直接请求 - if(hailiangHrSsxDeviceDriver.getMove() == 0){ - requireSucess =false; + if (hailiangHrSsxDeviceDriver.getMove() == 0) { + requireSucess = false; } - if (hailiangHrSsxDeviceDriver.getMode() == 2 && + if (hailiangHrSsxDeviceDriver.getMode() == 3 && hailiangHrSsxDeviceDriver.getMove() == 1 && - ObjectUtil.isNotEmpty(hailiangHrSsxDeviceDriver.getBarcode()) && - !requireSucess + ObjectUtil.isNotEmpty(hailiangHrSsxDeviceDriver.getBarcode()) + && !"0000000000".equals(hailiangHrSsxDeviceDriver.getBarcode()) + && !requireSucess ) { //判断是否超过等待时间 - if (System.currentTimeMillis() - hailiangHrSsxDeviceDriver.getInstruction_require_time().getTime() + if (System.currentTimeMillis() - hailiangHrSsxDeviceDriver.getInTaskRequestTime().getTime() > Integer.parseInt(this.getExtraValue().get("apply_time").toString()) * 1000) { //否则对接位单独申请任务 JSONObject reqParam = new JSONObject(); //半成品入库 - if(StrUtil.equals(hailiangHrSsxDeviceDriver.getDevice_code(),"A3_BCP_RM_01")||StrUtil.equals(hailiangHrSsxDeviceDriver.getDevice_code(),"A3_BCP_RM_02")) { + if (StrUtil.equals(hailiangHrSsxDeviceDriver.getDevice_code(), "A3_BCP_RM_01") || StrUtil.equals(hailiangHrSsxDeviceDriver.getDevice_code(), "A3_BCP_RM_02")) { reqParam.put("type", StatusEnum.HAIROU_LIKU_REQ.getCode()); reqParam.put("item_type", StatusEnum.HAIROU_IN_REQ.getCode()); reqParam.put("device_code1", hailiangHrSsxDeviceDriver.getDevice_code()); reqParam.put("barcode1", hailiangHrSsxDeviceDriver.getBarcode()); } //空载具入库 - if(StrUtil.equals(hailiangHrSsxDeviceDriver.getDevice_code(),"A3_BCP_RK_01")||StrUtil.equals(hailiangHrSsxDeviceDriver.getDevice_code(),"A3_BCP_RK_02")) { + if (StrUtil.equals(hailiangHrSsxDeviceDriver.getDevice_code(), "A3_BCP_RK_01") || StrUtil.equals(hailiangHrSsxDeviceDriver.getDevice_code(), "A3_BCP_RK_02")) { reqParam.put("type", StatusEnum.HAIROU_LIKU_REQ.getCode()); reqParam.put("item_type", StatusEnum.HAIROU_EMPTY_IN_REQ.getCode()); reqParam.put("device_code1", hailiangHrSsxDeviceDriver.getDevice_code()); reqParam.put("barcode1", hailiangHrSsxDeviceDriver.getBarcode()); } //联调时加上 -// HttpResponse httpResponse = acsToWmsService.applyTaskToWms(reqParam); -// if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) { -// requireSucess = true; -// } + HttpResponse httpResponse = acsToWmsService.applyTaskToWms(reqParam); + if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) { + requireSucess = true; + } log.info("单工位请求成功"); - requireSucess = true; + // requireSucess = true; } else { //否则判断另一个位置 - Device neiRouDevice = deviceAppservice.findDeviceByCode(haiRouDeviceCodeList.get(i+1)); + Device neiRouDevice = deviceAppservice.findDeviceByCode(haiRouDeviceCodeList.get(i + 1)); if (neiRouDevice.getDeviceDriver() instanceof HailiangHrSsxDeviceDriver) { hailiangHrSsxDeviceDriver2 = (HailiangHrSsxDeviceDriver) neiRouDevice.getDeviceDriver(); - if (hailiangHrSsxDeviceDriver2.getMode() == 2 && + if (hailiangHrSsxDeviceDriver2.getMode() == 3 && hailiangHrSsxDeviceDriver2.getMove() == 1 && - ObjectUtil.isNotEmpty(hailiangHrSsxDeviceDriver2.getBarcode()) + ObjectUtil.isNotEmpty(hailiangHrSsxDeviceDriver2.getBarcode()) && + !"0000000000".equals(hailiangHrSsxDeviceDriver.getBarcode()) ) { JSONObject reqParam = new JSONObject(); //半成品入库 - if(StrUtil.equals(hailiangHrSsxDeviceDriver.getDevice_code(),"A3_BCP_RM_01")||StrUtil.equals(hailiangHrSsxDeviceDriver.getDevice_code(),"A3_BCP_RM_02")) { + if (StrUtil.equals(hailiangHrSsxDeviceDriver.getDevice_code(), "A3_BCP_RM_01") || StrUtil.equals(hailiangHrSsxDeviceDriver.getDevice_code(), "A3_BCP_RM_02")) { reqParam.put("type", StatusEnum.HAIROU_LIKU_REQ.getCode()); reqParam.put("item_type", StatusEnum.HAIROU_IN_REQ.getCode()); reqParam.put("device_code1", hailiangHrSsxDeviceDriver.getDevice_code()); @@ -253,7 +255,7 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements reqParam.put("barcode2", hailiangHrSsxDeviceDriver2.getBarcode()); } //空载具入库 - if(StrUtil.equals(hailiangHrSsxDeviceDriver.getDevice_code(),"A3_BCP_RK_01")||StrUtil.equals(hailiangHrSsxDeviceDriver.getDevice_code(),"A3_BCP_RK_02")) { + if (StrUtil.equals(hailiangHrSsxDeviceDriver.getDevice_code(), "A3_BCP_RK_01") || StrUtil.equals(hailiangHrSsxDeviceDriver.getDevice_code(), "A3_BCP_RK_02")) { reqParam.put("type", StatusEnum.HAIROU_LIKU_REQ.getCode()); reqParam.put("item_type", StatusEnum.HAIROU_EMPTY_IN_REQ.getCode()); reqParam.put("device_code1", hailiangHrSsxDeviceDriver.getDevice_code()); @@ -262,13 +264,13 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements reqParam.put("barcode2", hailiangHrSsxDeviceDriver2.getBarcode()); } //向lms请求任务 - // 联调时加上 -// HttpResponse httpResponse = acsToWmsService.applyTaskToWms(reqParam); -// if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) { -// requireSucess = true; -// } + //联调时加上 + HttpResponse httpResponse = acsToWmsService.applyTaskToWms(reqParam); + if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) { + requireSucess = true; + } log.info("双工位请求成功"); - requireSucess = true; + //requireSucess = true; } } } diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/AcsUtil.java b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/AcsUtil.java index 67279d8f..c55bbcd8 100644 --- a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/AcsUtil.java +++ b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/AcsUtil.java @@ -1,14 +1,11 @@ package org.nl.acs.ext.wms; -import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; -import org.nl.acs.log.LokiLog; -import org.nl.acs.log.LokiLogType; -import org.nl.acs.log.service.DeviceExecuteLogService; import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.system.service.ParamService; import org.nl.modules.system.service.impl.ParamServiceImpl; @@ -20,31 +17,47 @@ import org.nl.modules.wql.util.SpringContextHolder; @Slf4j public class AcsUtil { - public static String notifyAcs(String api, W requestParam) { + private static final String IS_CONNECT_LIKU_WCS = "is_connect_liKu_Wcs"; + private static final String LIKU_WCS_URL = "liKu_wcs_url"; + + private static String liKuWcsUrl; + private static boolean isConnect; + + static { ParamService paramService = SpringContextHolder.getBean(ParamServiceImpl.class); - //判断是否连接立库WCS系统 - String isConnect = paramService.findByCode("is_connect_liKu_Wcs").getValue(); - if (StrUtil.equals("0", isConnect)) { - log.info("ACS请求ESS,请求路径:{},参数配置表中-is_connect_liKu_Wcs为:0", api); - throw new BadRequestException("参数配置表中-is_connect_liKu_Wcs为:0"); - } - log.info("ACS请求ESS,请求路径:{},请求参数:{}", api, JSON.toJSONString(requestParam)); - String liKu_wcs_url = paramService.findByCode("liKu_wcs_url").getValue(); - try { - String body = HttpRequest - .post(liKu_wcs_url + api) - .setConnectionTimeout(5000) - .body(JSON.toJSONString(requestParam)) - .execute() - .body(); - log.info("ACS请求ESS,请求路径:{},响应参数:{}", api, body); - return body; - } catch (Exception e) { + isConnect = "1".equals(paramService.findByCode(IS_CONNECT_LIKU_WCS).getValue()); + liKuWcsUrl = paramService.findByCode(LIKU_WCS_URL).getValue(); + } + + public static String notifyAcs(String api, W requestParam) { + if (isConnect) { + log.info("ACS开始请求ESS, 请求路径: {}, 请求参数: {}", api, JSON.toJSONString(requestParam)); + try { + HttpResponse response = HttpRequest + .post(liKuWcsUrl + api) + .setConnectionTimeout(5000) + .body(JSON.toJSONString(requestParam)) + .execute(); + if (response.getStatus() != 200) { + throw new BadRequestException("ACS请求ESS失败, 状态码: " + response.getStatus() + ",原因:" + response.body()); + } + String body = response.body(); + log.info("ACS请求ESS成功, 请求路径: {}, 响应参数: {}", api, body); + return body; + } catch (Exception e) { + JSONObject result = new JSONObject(); + result.put("code", "1"); + result.put("msg", e.getMessage()); + result.put("data", new JSONObject()); + log.error("ACS请求ESS,请求路径:{},响应参数:{}", api, result); + return String.valueOf(result); + } + } else { JSONObject result = new JSONObject(); result.put("code", "1"); - result.put("msg", e.getMessage()); + result.put("msg", "ACS未开启连接立库WCS配置项!"); result.put("data", new JSONObject()); - log.error("ACS请求ESS,请求路径:{},响应参数:{}", api, result.toString()); + log.error("ACS请求ESS,请求路径:{},响应参数:{}", api, result); return String.valueOf(result); } } diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/StationPointMapping.java b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/StationPointMapping.java new file mode 100644 index 00000000..d81808e6 --- /dev/null +++ b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/StationPointMapping.java @@ -0,0 +1,24 @@ +package org.nl.acs.ext.wms; + +import io.jsonwebtoken.lang.Maps; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * @Description TODO + * @Author Gengby + * @Date 2024/1/19 + */ +public class StationPointMapping { + + public static Map> mappings = + Maps.of("STATION-1", Arrays.asList("A3_BCP_RM_01", "A3_BCP_CK_03")) + .and("STATION-2", Arrays.asList("A3_BCP_CM_03", "A3_BCP_RK_01")).build(); + + public static List getPointMapping(String station) { + return mappings.get(station) == null ? new ArrayList<>() : mappings.get(station); + } +} \ No newline at end of file diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/liKuData/a/LocationQueryRequest.java b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/liKuData/a/LocationQueryRequest.java index c60acba2..736dd63e 100644 --- a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/liKuData/a/LocationQueryRequest.java +++ b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/liKuData/a/LocationQueryRequest.java @@ -12,7 +12,7 @@ public class LocationQueryRequest { * 可传多个⼯作位,若不传则查全部 * 若多个字段均填写,则互为且关系 */ - public Map> locationCodes ; + public List locationCodes ; /** * 容器编码 * 查看容器下的所有⼯作位 @@ -23,5 +23,5 @@ public class LocationQueryRequest { * 可传多个⼯作位,若不传则查全部 * 若多个字段均填写,则互为且关系 */ - public Map> locationTypeCodes ; + public List locationTypeCodes ; } diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/liKuData/a/RobotQueryRequest.java b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/liKuData/a/RobotQueryRequest.java index f15b914a..59e051d3 100644 --- a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/liKuData/a/RobotQueryRequest.java +++ b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/liKuData/a/RobotQueryRequest.java @@ -11,7 +11,7 @@ public class RobotQueryRequest { * 机器⼈编码 * 可传多个,若不传则查全部 */ - public Map> robotCodes ; + public List robotCodes ; //public List robotCodes; } diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/liKuData/b/OutTaskDescribe.java b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/liKuData/b/OutTaskDescribe.java index 1b329c71..94615864 100644 --- a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/liKuData/b/OutTaskDescribe.java +++ b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/liKuData/b/OutTaskDescribe.java @@ -27,5 +27,7 @@ public class OutTaskDescribe extends TaskDescribe { List toStationCode ; + String toLocationCode; + } diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToLiKuController.java b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToLiKuController.java index 154a55a6..69a31960 100644 --- a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToLiKuController.java +++ b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToLiKuController.java @@ -1,5 +1,6 @@ package org.nl.acs.ext.wms.rest; +import cn.dev33.satoken.annotation.SaIgnore; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; @@ -52,12 +53,14 @@ public class AcsToLiKuController { @PostMapping("/robot/query") @Log(value = "机器⼈查询接⼝",isInterfaceLog = true,interfaceLogType= InterfaceLogType.ACS_TO_LK) @ApiOperation("机器⼈查询接⼝") + @SaIgnore public ResponseEntity robotQuery(@RequestBody RobotQueryRequest requestParam) throws Exception { return new ResponseEntity<>(acsToLiKuService.robotQuery(requestParam), HttpStatus.OK); } @PostMapping("/location/query") @Log(value = "⼯作位查询接⼝",isInterfaceLog = true,interfaceLogType= InterfaceLogType.ACS_TO_LK) @ApiOperation("⼯作位查询接⼝") + @SaIgnore public ResponseEntity locationQuery(@RequestBody LocationQueryRequest requestParam) throws Exception { return new ResponseEntity<>(acsToLiKuService.locationQuery(requestParam), HttpStatus.OK); } diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/LiKuToACSController.java b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/LiKuToACSController.java index e129bb9f..92ef98d7 100644 --- a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/LiKuToACSController.java +++ b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/LiKuToACSController.java @@ -5,11 +5,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.nl.acs.ext.wms.liKuData.InStoreReportRequest; -import org.nl.acs.ext.wms.liKuData.MoveStoreReportRequest; -import org.nl.acs.ext.wms.liKuData.OutStoreReportRequest; import org.nl.acs.ext.wms.liKuData.a.*; -import org.nl.acs.ext.wms.liKuData.putEmptyPalletRequest; import org.nl.acs.ext.wms.service.LiKuToAcsService; import org.nl.modules.logging.InterfaceLogType; import org.nl.modules.logging.annotation.Log; @@ -46,6 +42,15 @@ public class LiKuToACSController { public ResponseEntity queryNodeReader(@RequestBody QueryNodeReaderRequest requestParam) throws Exception { return new ResponseEntity<>(liKuToAcsService.queryNodeReader(requestParam), HttpStatus.OK); } + + @SaIgnore + @PostMapping("/loadContainerRequest") + @Log(value = "取容器请求",isInterfaceLog = true,interfaceLogType= InterfaceLogType.LK_TO_ACS) + @ApiOperation("取容器请求") + public ResponseEntity loadContainerRequest(@RequestBody LoadContainerFinishRequest requestParam) throws Exception { + return new ResponseEntity<>(liKuToAcsService.loadContainerRequest(requestParam), HttpStatus.OK); + } + @SaIgnore @PostMapping("/loadContainerFinish") @Log(value = "取容器完成通知",isInterfaceLog = true,interfaceLogType= InterfaceLogType.LK_TO_ACS) @@ -75,14 +80,14 @@ public class LiKuToACSController { return new ResponseEntity<>(liKuToAcsService.moveContainer(requestParam), HttpStatus.OK); } @SaIgnore - @PostMapping("/taskstatusreporting") + @PostMapping("/taskStatusReport") @Log(value = "任务状态上报",isInterfaceLog = true,interfaceLogType= InterfaceLogType.LK_TO_ACS) @ApiOperation("任务状态上报") public ResponseEntity taskstatusreporting(@RequestBody TaskstatusReportingRequest requestParam) throws Exception { return new ResponseEntity<>(liKuToAcsService.taskstatusreporting(requestParam), HttpStatus.OK); } @SaIgnore - @PostMapping("/abnormalreporting") + @PostMapping("/abnormalReport") @Log(value = "异常上报",isInterfaceLog = true,interfaceLogType= InterfaceLogType.LK_TO_ACS) @ApiOperation("异常上报") public ResponseEntity abnormalreporting(@RequestBody AbnormarReportingRequest requestParam) throws Exception { diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/LiKuToAcsService.java b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/LiKuToAcsService.java index ed7d56bf..736be4f4 100644 --- a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/LiKuToAcsService.java +++ b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/LiKuToAcsService.java @@ -23,6 +23,14 @@ public interface LiKuToAcsService { */ public JSONObject queryNodeReader(QueryNodeReaderRequest requestParam) throws Exception; + + /** + * 取容器请求 + * @param requestParam + * @return + */ + public JSONObject loadContainerRequest(LoadContainerFinishRequest requestParam) throws Exception; + /** * 取容器完成通知 * @param requestParam diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java index a59f4e02..351a9940 100644 --- a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java +++ b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java @@ -6,6 +6,7 @@ import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import io.jsonwebtoken.lang.Maps; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.AcsConfig; @@ -13,6 +14,7 @@ import org.nl.acs.acsEnum.StatusEnum; import org.nl.acs.device.address.service.AddressService; import org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_hr_ssx.HailiangHrSsxDeviceDriver; import org.nl.acs.ext.wms.RespUtil; +import org.nl.acs.ext.wms.StationPointMapping; import org.nl.acs.ext.wms.liKuData.Resp; import org.nl.acs.ext.wms.liKuData.a.*; import org.nl.acs.ext.wms.liKuData.b.AGVTask; @@ -66,33 +68,38 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService { log.info("查询输送线料箱状态-----输入参数{}", JSON.toJSONString(requestParam)); JSONObject result = new JSONObject(); try { - String conveyorCodes = requestParam.getConveyorCodes(); - NodeStates nodeStates = new NodeStates(); - List list2 = new ArrayList<>(); - Conveyors conveyors = new Conveyors(); - Device device = deviceAppService.findDeviceByCode(conveyorCodes); + JSONArray conveyorCodes = JSONArray.parseArray(requestParam.getConveyorCodes()); QueryConveyorResponse queryConveyorResponse = new QueryConveyorResponse(); - if (device != null && device.getDeviceDriver() instanceof HailiangHrSsxDeviceDriver) { - HailiangHrSsxDeviceDriver hailiangHrSsxDeviceDriver = (HailiangHrSsxDeviceDriver) device.getDeviceDriver(); - if (!ObjectUtil.isEmpty(device.getDevice_code())) { - conveyors.setCode(device.getDevice_code()); - } - if (!ObjectUtil.isEmpty(device.getLocation())) { - nodeStates.setSlotCode(device.getDevice_code()); - } - if (hailiangHrSsxDeviceDriver.getMove() == 1) { - nodeStates.setHasContainer(true); - } else { - nodeStates.setHasContainer(false); - } - nodeStates.setLastReadTime(hailiangHrSsxDeviceDriver.getLastReadTime()); - hailiangHrSsxDeviceDriver.setLastReadTime(System.currentTimeMillis()); - nodeStates.setLastReportTime(hailiangHrSsxDeviceDriver.getLastReportTime()); - } - list2.add(nodeStates); - conveyors.setNodeStates(list2); List list = new ArrayList<>(); - list.add(conveyors); + Conveyors conveyors = new Conveyors(); + for (int i = 0; i < conveyorCodes.size(); i++) { + conveyors = new Conveyors(); + String station = conveyorCodes.getString(i); + List points = StationPointMapping.getPointMapping(station); + conveyors.setCode(station); + List list2 = new ArrayList<>(); + for (int j = 0; j < points.size(); j++) { + NodeStates nodeStates = new NodeStates(); + String conveyorCode = points.get(j); + Device device = deviceAppService.findDeviceByCode(conveyorCode); + if (device != null && device.getDeviceDriver() instanceof HailiangHrSsxDeviceDriver) { + HailiangHrSsxDeviceDriver hailiangHrSsxDeviceDriver = (HailiangHrSsxDeviceDriver) device.getDeviceDriver(); + nodeStates.setSlotCode(conveyorCode); + if (hailiangHrSsxDeviceDriver.getMove() == 1) { + nodeStates.setHasContainer(true); + } else { + nodeStates.setHasContainer(false); + } + nodeStates.setLastReadTime(hailiangHrSsxDeviceDriver.getLastReadTime()); + hailiangHrSsxDeviceDriver.setLastReadTime(System.currentTimeMillis()); + nodeStates.setLastReportTime(hailiangHrSsxDeviceDriver.getLastReportTime()); + nodeStates.setLastHasContainerTime(hailiangHrSsxDeviceDriver.getLastHasContainerTime()); + } + list2.add(nodeStates); + } + conveyors.setNodeStates(list2); + list.add(conveyors); + } queryConveyorResponse.setConveyors(list); result.put("code", "0"); result.put("msg", "success"); @@ -127,6 +134,39 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService { return result; } + @Override + public JSONObject loadContainerRequest(LoadContainerFinishRequest requestParam) throws Exception { + log.info("取容器请求-----输入参数{}", JSON.toJSONString(requestParam)); + JSONObject result = new JSONObject(); + UnloadContainerReqResponse unloadContainerReqResponse = new UnloadContainerReqResponse(); + try { + String slotCode = requestParam.getSlotCode(); + String containerCode = requestParam.getContainerCode(); + Device device = deviceAppService.findDeviceByCode(slotCode); + if (device != null && device.getDeviceDriver() instanceof HailiangHrSsxDeviceDriver) { + HailiangHrSsxDeviceDriver hailiangHrSsxDeviceDriver = (HailiangHrSsxDeviceDriver) device.getDeviceDriver(); + hailiangHrSsxDeviceDriver.writing("to_command", "2"); + //TODO plc没给action信号1 暂时判断光电和条码 + if (hailiangHrSsxDeviceDriver.getMove() == 1 && hailiangHrSsxDeviceDriver.getBarcode().equals(containerCode)) { + unloadContainerReqResponse.setAllow(true); + } else { + unloadContainerReqResponse.setAllow(false); + } + } + result.put("code", "0"); + result.put("msg", "success"); + result.put("data", unloadContainerReqResponse); + + } catch (Exception e) { + result = new JSONObject(); + result.put("code", "1"); + result.put("msg", e.getMessage()); + result.put("data", unloadContainerReqResponse); + } + log.info("取容器请求-----输出参数{}", JSON.toJSONString(result)); + return result; + } + @Override public JSONObject loadContainerFinish(LoadContainerFinishRequest requestParam) throws Exception { log.info("取容器完成通知-----输入参数{}", JSON.toJSONString(requestParam)); @@ -134,13 +174,11 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService { try { String slotCode = requestParam.getSlotCode(); String containerCode = requestParam.getContainerCode(); -// LoadContainerFinishResponse loadContainerFinishResponse = new LoadContainerFinishResponse(); Device device = deviceAppService.findDeviceByCode(slotCode); if (device != null && device.getDeviceDriver() instanceof HailiangHrSsxDeviceDriver) { HailiangHrSsxDeviceDriver hailiangHrSsxDeviceDriver = (HailiangHrSsxDeviceDriver) device.getDeviceDriver(); //下发输送线电气取货完成 - hailiangHrSsxDeviceDriver.writing("to_command", "2"); -// JSONObject json = (JSONObject) JSONObject.toJSON(loadContainerFinishResponse); + hailiangHrSsxDeviceDriver.writing("to_command", "3"); result.put("code", "0"); result.put("msg", "success"); result.put("data", new JSONObject()); @@ -170,7 +208,7 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService { Device device = deviceAppService.findDeviceByCode(slotCode); if (device != null && device.getDeviceDriver() instanceof HailiangHrSsxDeviceDriver) { HailiangHrSsxDeviceDriver hailiangHrSsxDeviceDriver = (HailiangHrSsxDeviceDriver) device.getDeviceDriver(); - hailiangHrSsxDeviceDriver.writing("to_command", "3"); + hailiangHrSsxDeviceDriver.writing("to_command", "4"); if (hailiangHrSsxDeviceDriver.getAction() == 2) { unloadContainerReqResponse.setAllow(true); } else { @@ -202,7 +240,7 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService { Device device = deviceAppService.findDeviceByCode(slotCode); if (device != null && device.getDeviceDriver() instanceof HailiangHrSsxDeviceDriver) { HailiangHrSsxDeviceDriver hailiangHrSsxDeviceDriver = (HailiangHrSsxDeviceDriver) device.getDeviceDriver(); - hailiangHrSsxDeviceDriver.writing("to_command", "4"); + hailiangHrSsxDeviceDriver.writing("to_command", "5"); } JSONObject json = (JSONObject) JSONObject.toJSON(unloadContainerFinishResponse); result.put("code", "0"); diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index c6b59bfc..80939d2b 100644 --- a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -163,15 +163,15 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { continue; } } - TaskDto start_device_task = taskService.findByStartCode(start_point_code); - if (start_device_task != null) { - JSONObject json = new JSONObject(); - json.put("task_id", task_id); -// json.put("message", "已存在该设备的任务,设备号:" + start_point_code + ",对应的任务号:" + task_code); - json.put("message", "已提交过任务!请勿重复点击!"); - errArr.add(json); - continue; - } +// TaskDto start_device_task = taskService.findByStartCode(start_point_code); +// if (start_device_task != null) { +// JSONObject json = new JSONObject(); +// json.put("task_id", task_id); +//// json.put("message", "已存在该设备的任务,设备号:" + start_point_code + ",对应的任务号:" + task_code); +// json.put("message", "已提交过任务!请勿重复点击!"); +// errArr.add(json); +// continue; +// } //刻字上料任务特殊处理 if (StrUtil.equals(start_point_code,"A1_KZ_SL")) { Device device = deviceAppService.findDeviceByCode(start_point_code); diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/wcs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 2185d7a1..681783c8 100644 --- a/wcs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/wcs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -384,7 +384,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu OutTaskDescribe outTaskDescribe = new OutTaskDescribe(); outTaskDescribe.setContainerCode(dto.getVehicle_code()); outTaskDescribe.setFromLocationCode(dto.getStart_point_code()); - outTaskDescribe.setToStationCode(new ArrayList(Collections.singleton(dto.getNext_device_code()))); + outTaskDescribe.setToLocationCode(dto.getNext_point_code()); AGVTask agvTask = new AGVTask(); agvTask.setTaskDescribe(outTaskDescribe); @@ -463,10 +463,11 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu Thread.sleep(5000L); if (StrUtil.equals("1", dto.getAgv_system_type())) { ndcAgvService.sendAgvTwoInstToNDC(dto, null); + dto.setSend_status("1"); } else if (StrUtil.equals("2", dto.getAgv_system_type())) { ndcAgvService.sendAgvOneInstToNDC(dto); + dto.setSend_status("1"); } - dto.setSend_status("1"); } catch (InterruptedException ex) { ex.printStackTrace(); } catch (Exception exception) { @@ -1021,7 +1022,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu this.create(instdto); } catch (Exception e) { e.printStackTrace(); - log.error("完成并创建下一条指令", e.getMessage()); + log.error("完成并创建下一条指令失败:{}", e.getMessage()); } } diff --git a/wcs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateAgvOneInst.java b/wcs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateAgvOneInst.java index 4c579d48..8ffb2290 100644 --- a/wcs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateAgvOneInst.java +++ b/wcs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateAgvOneInst.java @@ -32,7 +32,7 @@ public class AutoCreateAgvOneInst { * @throws Exception */ public void run() throws Exception { - List list = taskService.queryAll("task_status = '0' and agv_system_type = '2' or agv_system_type = '3'"); + List list = taskService.queryAll("task_status = '0' and (agv_system_type = '2' or agv_system_type = '3')"); for (int i = 0; i < list.size(); i++) { TaskDto taskDto = list.get(i); String link_no = CodeUtil.getNewCode("LINK_NO"); diff --git a/wcs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryRobot.java b/wcs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryRobot.java index 2ff9ff7f..c19e951f 100644 --- a/wcs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryRobot.java +++ b/wcs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryRobot.java @@ -44,8 +44,7 @@ public class QueryRobot { list.add(devices.get(i).getDevice_code()); } } - map.put("robotCodes", list); - robotQueryRequest.setRobotCodes(map); + robotQueryRequest.setRobotCodes(list); Resp robotResp = acsToLiKuService.robotQuery(robotQueryRequest); JSONArray jsonArray = robotResp.getData().getJSONArray("robots"); List robotsList = jsonArray.toJavaList(Robots.class); diff --git a/wcs/nladmin-system/src/main/resources/config/application-dev.yml b/wcs/nladmin-system/src/main/resources/config/application-dev.yml index f4870d7a..6906480c 100644 --- a/wcs/nladmin-system/src/main/resources/config/application-dev.yml +++ b/wcs/nladmin-system/src/main/resources/config/application-dev.yml @@ -136,13 +136,12 @@ file: avatarMaxSize: 5 logging: file: - path: /Users/onepiece/myFile/acs_logs + path: C:\acs_log config: classpath:logback-spring.xml lucene: index: - path: /lucene + path: C:\acs\lucene\index -# /Users/onepiece/myFile/lucene/index # Sa-Token配置 sa-token: diff --git a/wcs/nladmin-system/src/main/resources/logback-spring.xml b/wcs/nladmin-system/src/main/resources/logback-spring.xml index f5fffc33..94d90e41 100644 --- a/wcs/nladmin-system/src/main/resources/logback-spring.xml +++ b/wcs/nladmin-system/src/main/resources/logback-spring.xml @@ -31,6 +31,7 @@ https://juejin.cn/post/6844903775631572999 + diff --git a/wcs/nladmin-ui/src/views/acs/device/driver/hailiang_hr_ssx_station.vue b/wcs/nladmin-ui/src/views/acs/device/driver/hailiang_hr_ssx_station.vue index 63f0b89b..4d88b54e 100644 --- a/wcs/nladmin-ui/src/views/acs/device/driver/hailiang_hr_ssx_station.vue +++ b/wcs/nladmin-ui/src/views/acs/device/driver/hailiang_hr_ssx_station.vue @@ -106,7 +106,6 @@ - - - - - @@ -284,7 +278,7 @@ export default { ignore_release_check: true, apply_task: true, apply_num: '', - apply_empty: [], + apply_empty: '', manual_create_task: true, is_pickup: true, is_release: true,