feat:一楼仓储设备驱动(初步开发)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.nl.acs.device.deviceDriver.service.defination.opcDefination.one_floor.conveyor.belt_conveyor_agv;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -11,10 +12,14 @@ import org.nl.acs.device.deviceDriver.service.driver.DeviceDriver;
|
||||
import org.nl.acs.device.deviceDriver.service.driver.base.DeviceDriverBaseReader;
|
||||
import org.nl.acs.device.deviceDriver.service.driver.plugin.DeviceStageMonitorPlugin;
|
||||
import org.nl.acs.device.deviceDriver.service.driver.plugin.DriverExecutePlugin;
|
||||
import org.nl.common.base.ResponseData;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import com.google.common.util.concurrent.Uninterruptibles;
|
||||
import org.nl.extInterface.wms.WmsApi;
|
||||
import org.nl.extInterface.wms.data.req.CallTaskReqVO;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -30,7 +35,7 @@ public class BeltConveyorAgvDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
DeviceDriverBaseReader {
|
||||
|
||||
private final LuceneExecuteLogService logService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
||||
|
||||
private final WmsApi wmsApi = SpringContextHolder.getBean(WmsApi.class);
|
||||
/**
|
||||
* 心跳
|
||||
*/
|
||||
@@ -141,9 +146,9 @@ public class BeltConveyorAgvDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
* 请求时间间隔
|
||||
* long currentTimeMillis = System.currentTimeMillis();
|
||||
* if (!isTimeValid(currentTimeMillis)) {
|
||||
* log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
|
||||
* log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
|
||||
* } else {
|
||||
* this.requireTime = currentTimeMillis;
|
||||
* this.requireTime = currentTimeMillis;
|
||||
* }
|
||||
*
|
||||
* @param currentTimeMillis
|
||||
@@ -155,49 +160,95 @@ public class BeltConveyorAgvDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
|
||||
@Override
|
||||
public void executeLogic() {
|
||||
// 复位
|
||||
if (this.mode != this.lastMode) {
|
||||
this.requireSuccess = false;
|
||||
}
|
||||
|
||||
if (!this.online) {
|
||||
this.message = "设备离线";
|
||||
this.message = "设备离线";
|
||||
} else if (this.mode == 0) {
|
||||
this.message = "设备未联机";
|
||||
this.message = "设备未联机";
|
||||
} else if (this.error != 0) {
|
||||
this.message = "设备报警";
|
||||
this.isError = true;
|
||||
} else {
|
||||
this.isError = false;
|
||||
this.message = "";
|
||||
//编写业务逻辑方法
|
||||
this.templateMethod();
|
||||
}
|
||||
this.message = "设备报警";
|
||||
this.isError = true;
|
||||
} else {
|
||||
this.isError = false;
|
||||
this.message = "";
|
||||
//编写业务逻辑方法
|
||||
if (this.mode == 13 && !this.requireSuccess) {
|
||||
// 向WMS申请AGV出库
|
||||
applyOutboundAGVTask();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
this.lastMode = this.mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模板方法
|
||||
* 向WMS申请AGV出库
|
||||
*/
|
||||
public void templateMethod() {
|
||||
public void applyOutboundAGVTask() {
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
if (!isTimeValid(currentTimeMillis)) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
|
||||
} else {
|
||||
this.requireTime = currentTimeMillis;
|
||||
|
||||
if (this.move != 1) {
|
||||
this.message = "无货不允许申请AGV任务。";
|
||||
return;
|
||||
}
|
||||
|
||||
// todo: 由任务完成后将托盘号记录到此驱动变量中
|
||||
if (ObjectUtil.isEmpty(material_barcode)) {
|
||||
message = "托盘号不能为空!";
|
||||
return;
|
||||
}
|
||||
|
||||
// 申请任务
|
||||
try {
|
||||
JSONObject applyRes = ResponseData.getCheckData(
|
||||
wmsApi.requestOutboundAgvTask(CallTaskReqVO
|
||||
.builder()
|
||||
.deviceCode(this.device.getDevice_code())
|
||||
.vehicleCode(material_barcode)
|
||||
.build()));
|
||||
if (ObjectUtil.isNotEmpty(applyRes)) {
|
||||
if (applyRes.getIntValue("code") == 0) {
|
||||
this.writing("to_command", 13);
|
||||
this.requireSuccess = true;
|
||||
this.message = "呼叫AGV出库申请成功!";
|
||||
} else {
|
||||
this.message = "ACS请求WMS报错,错误相应:" + applyRes.getString("msg");
|
||||
}
|
||||
} else {
|
||||
this.message = "WMS 反馈数据为空!";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.message = "请求WMS出现异常:" + e.getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() throws Exception {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", this.currentDeviceCode);
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("driver_type", "belt_conveyor_agv");
|
||||
jo.put("is_click", false);
|
||||
jo.put("message", this.message);
|
||||
jo.put("isOnline", this.online);
|
||||
jo.put("isError", this.isError);
|
||||
return jo;
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", this.currentDeviceCode);
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("driver_type", "belt_conveyor_agv");
|
||||
jo.put("is_click", false);
|
||||
jo.put("message", this.message);
|
||||
jo.put("isOnline", this.online);
|
||||
jo.put("isError", this.isError);
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
material_barcode = data.getString("material_barcode");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.acs.device.deviceDriver.service.defination.opcDefination.one_floor.conveyor.conveyor_with_scanner_weight;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -11,12 +12,16 @@ import org.nl.acs.device.deviceDriver.service.driver.DeviceDriver;
|
||||
import org.nl.acs.device.deviceDriver.service.driver.base.DeviceDriverBaseReader;
|
||||
import org.nl.acs.device.deviceDriver.service.driver.plugin.DeviceStageMonitorPlugin;
|
||||
import org.nl.acs.device.deviceDriver.service.driver.plugin.DriverExecutePlugin;
|
||||
import org.nl.common.base.ResponseData;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import com.google.common.util.concurrent.Uninterruptibles;
|
||||
import org.nl.extInterface.wms.WmsApi;
|
||||
import org.nl.extInterface.wms.data.req.ApplyInboundReqVO;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
@@ -30,6 +35,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
DeviceDriverBaseReader {
|
||||
|
||||
private final LuceneExecuteLogService logService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
||||
private final WmsApi wmsApi = SpringContextHolder.getBean(WmsApi.class);
|
||||
|
||||
/**
|
||||
* 心跳
|
||||
@@ -156,9 +162,9 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
* 请求时间间隔
|
||||
* long currentTimeMillis = System.currentTimeMillis();
|
||||
* if (!isTimeValid(currentTimeMillis)) {
|
||||
* log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
|
||||
* log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
|
||||
* } else {
|
||||
* this.requireTime = currentTimeMillis;
|
||||
* this.requireTime = currentTimeMillis;
|
||||
* }
|
||||
*
|
||||
* @param currentTimeMillis
|
||||
@@ -170,19 +176,149 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
|
||||
@Override
|
||||
public void executeLogic() {
|
||||
if (this.mode != this.lastMode) {
|
||||
this.requireSuccess = false;
|
||||
}
|
||||
if (!this.online) {
|
||||
this.message = "设备离线";
|
||||
this.message = "设备离线";
|
||||
} else if (this.mode == 0) {
|
||||
this.message = "设备未联机";
|
||||
this.message = "设备未联机";
|
||||
} else if (this.error != 0) {
|
||||
this.message = "设备报警";
|
||||
this.isError = true;
|
||||
} else {
|
||||
this.isError = false;
|
||||
this.message = "";
|
||||
//编写业务逻辑方法
|
||||
this.templateMethod();
|
||||
}
|
||||
this.message = "设备报警";
|
||||
this.isError = true;
|
||||
} else {
|
||||
this.isError = false;
|
||||
this.message = "";
|
||||
//编写业务逻辑方法
|
||||
// 6-申请空拖盘入库
|
||||
if (this.mode == 6 && !this.requireSuccess) {
|
||||
applyEmptyPalletIn();
|
||||
}
|
||||
// 7-申请空木箱入库
|
||||
if (this.mode == 7 && !this.requireSuccess) {
|
||||
applyEmptyBoxIn();
|
||||
}
|
||||
// 8-申请退货入库
|
||||
if (this.mode == 8 && !this.requireSuccess) {
|
||||
applyReturnIn();
|
||||
}
|
||||
// 9-申请成品入库
|
||||
if (this.mode == 9 && !this.requireSuccess) {
|
||||
applyFinishedProductIn();
|
||||
}
|
||||
}
|
||||
lastMode = mode;
|
||||
}
|
||||
|
||||
public void applyEmptyBoxIn() {
|
||||
applyInbound("7", "申请空木箱入库");
|
||||
}
|
||||
|
||||
public void applyReturnIn() {
|
||||
applyInbound("8", "申请退货入库");
|
||||
}
|
||||
|
||||
public void applyFinishedProductIn() {
|
||||
applyInbound("9", "申请成品入库");
|
||||
}
|
||||
|
||||
private void applyInbound(String type, String businessName) {
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
|
||||
if (!isTimeValid(currentTimeMillis)) {
|
||||
log.trace("触发时间间隔小于 {} 毫秒,本次请求被忽略", requireTimeOut);
|
||||
return;
|
||||
}
|
||||
|
||||
// 只要请求进入处理流程,就记录本次触发时间
|
||||
this.requireTime = currentTimeMillis;
|
||||
|
||||
if (this.move != 1) {
|
||||
this.message = businessName + "失败,move 不等于 1,请检查!";
|
||||
return;
|
||||
}
|
||||
|
||||
if (ObjectUtil.isEmpty(this.barcode)) {
|
||||
this.message = businessName + "失败,没有托盘码或托盘码未能识别。";
|
||||
return;
|
||||
}
|
||||
|
||||
if (ObjectUtil.isEmpty(this.material_barcode)) {
|
||||
this.message = businessName + "失败,没有木箱号。";
|
||||
return;
|
||||
}
|
||||
|
||||
if (ObjectUtil.isEmpty(this.weight)) {
|
||||
this.message = businessName + "失败,重量读取为空。";
|
||||
return;
|
||||
}
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("vehicleCode", this.barcode);
|
||||
data.put("weight", this.weight);
|
||||
|
||||
ApplyInboundReqVO request = ApplyInboundReqVO.builder()
|
||||
.type(type)
|
||||
.deviceCode(this.device.getDevice_code())
|
||||
.data(data)
|
||||
.build();
|
||||
|
||||
JSONObject response = ResponseData.getCheckData(
|
||||
wmsApi.applyInboundTask(request)
|
||||
);
|
||||
|
||||
if (ObjectUtil.isEmpty(response)) {
|
||||
this.message = "WMS 反馈数据为空!";
|
||||
this.writing("to_command", 99);
|
||||
this.requireSuccess = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (response.getIntValue("code") != 0) {
|
||||
this.message = "ACS 请求 WMS 报错,错误响应:" + response.getString("msg");
|
||||
this.writing("to_command", 99);
|
||||
this.requireSuccess = true;
|
||||
return;
|
||||
}
|
||||
|
||||
writing("to_command", Integer.parseInt(type));
|
||||
this.requireSuccess = true;
|
||||
this.message = businessName + "成功!";
|
||||
}
|
||||
|
||||
public void applyEmptyPalletIn() {
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
if (!isTimeValid(currentTimeMillis)) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
|
||||
} else {
|
||||
if (this.move == 1) {
|
||||
// 调用 wms申请空托盘入库
|
||||
JSONObject applyRes = ResponseData.getCheckData(
|
||||
wmsApi.applyInboundTask(ApplyInboundReqVO
|
||||
.builder()
|
||||
.type("6")
|
||||
.deviceCode(this.device.getDevice_code())
|
||||
.build()));
|
||||
if (ObjectUtil.isNotEmpty(applyRes)) {
|
||||
if (applyRes.getIntValue("code") == 0) {
|
||||
this.writing("to_command", 6);
|
||||
this.requireSuccess = true;
|
||||
this.message = "空托盘入库任务申请成功!";
|
||||
} else {
|
||||
this.message = "ACS请求WMS报错,错误相应:" + applyRes.getString("msg");
|
||||
this.writing("to_command", 99);
|
||||
this.requireSuccess = true;
|
||||
}
|
||||
} else {
|
||||
this.message = "WMS 反馈数据为空!";
|
||||
this.writing("to_command", 99);
|
||||
this.requireSuccess = true;
|
||||
}
|
||||
} else {
|
||||
this.message = "申请空托盘入库失败,move不等于1,请检查!";
|
||||
}
|
||||
this.requireTime = currentTimeMillis;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,20 +335,20 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() throws Exception {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", this.currentDeviceCode);
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("driver_type", "conveyor_with_scanner_weight");
|
||||
jo.put("is_click", false);
|
||||
jo.put("message", this.message);
|
||||
jo.put("isOnline", this.online);
|
||||
jo.put("isError", this.isError);
|
||||
return jo;
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", this.currentDeviceCode);
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("driver_type", "conveyor_with_scanner_weight");
|
||||
jo.put("is_click", false);
|
||||
jo.put("message", this.message);
|
||||
jo.put("isOnline", this.online);
|
||||
jo.put("isError", this.isError);
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.nl.acs.device.deviceDriver.service.defination.opcDefination.one_floor.conveyor.finished_product_out_with_bind_lable_conveyor;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.util.concurrent.Uninterruptibles;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
@@ -11,12 +13,20 @@ import org.nl.acs.device.deviceDriver.service.driver.DeviceDriver;
|
||||
import org.nl.acs.device.deviceDriver.service.driver.base.DeviceDriverBaseReader;
|
||||
import org.nl.acs.device.deviceDriver.service.driver.plugin.DeviceStageMonitorPlugin;
|
||||
import org.nl.acs.device.deviceDriver.service.driver.plugin.DriverExecutePlugin;
|
||||
import org.nl.acs.task.instruction.domain.Instruction;
|
||||
import org.nl.acs.task.instruction.service.InstructionService;
|
||||
import org.nl.acs.task.task.service.TaskService;
|
||||
import org.nl.acs.task.task.service.dto.TaskDto;
|
||||
import org.nl.common.base.ResponseData;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import com.google.common.util.concurrent.Uninterruptibles;
|
||||
import org.nl.extInterface.wms.WmsApi;
|
||||
import org.nl.extInterface.wms.data.req.BundleInfoReqVO;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
@@ -30,7 +40,9 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr
|
||||
DeviceDriverBaseReader {
|
||||
|
||||
private final LuceneExecuteLogService logService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
||||
|
||||
private final WmsApi wmsApi = SpringContextHolder.getBean(WmsApi.class);
|
||||
private final InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
||||
private final TaskService taskService = SpringContextHolder.getBean(TaskService.class);
|
||||
/**
|
||||
* 心跳
|
||||
*/
|
||||
@@ -171,9 +183,9 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr
|
||||
* 请求时间间隔
|
||||
* long currentTimeMillis = System.currentTimeMillis();
|
||||
* if (!isTimeValid(currentTimeMillis)) {
|
||||
* log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
|
||||
* log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
|
||||
* } else {
|
||||
* this.requireTime = currentTimeMillis;
|
||||
* this.requireTime = currentTimeMillis;
|
||||
* }
|
||||
*
|
||||
* @param currentTimeMillis
|
||||
@@ -185,49 +197,119 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr
|
||||
|
||||
@Override
|
||||
public void executeLogic() {
|
||||
if (this.mode != this.lastMode) {
|
||||
this.requireSuccess = false;
|
||||
}
|
||||
if (!this.online) {
|
||||
this.message = "设备离线";
|
||||
this.message = "设备离线";
|
||||
} else if (this.mode == 0) {
|
||||
this.message = "设备未联机";
|
||||
this.message = "设备未联机";
|
||||
} else if (this.error != 0) {
|
||||
this.message = "设备报警";
|
||||
this.isError = true;
|
||||
} else {
|
||||
this.isError = false;
|
||||
this.message = "";
|
||||
//编写业务逻辑方法
|
||||
this.templateMethod();
|
||||
}
|
||||
this.message = "设备报警";
|
||||
this.isError = true;
|
||||
} else {
|
||||
this.isError = false;
|
||||
this.message = "";
|
||||
//编写业务逻辑方法
|
||||
if (this.mode == 12 && !requireSuccess) {
|
||||
this.requestBundleInfo();
|
||||
}
|
||||
}
|
||||
lastMode = mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模板方法
|
||||
*/
|
||||
public void templateMethod() {
|
||||
public void requestBundleInfo() {
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
if (!isTimeValid(currentTimeMillis)) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
|
||||
} else {
|
||||
this.requireTime = currentTimeMillis;
|
||||
|
||||
if (this.move != 1) {
|
||||
this.message = "无货不允许请求,请检查move信号";
|
||||
return;
|
||||
}
|
||||
if (ObjectUtil.isEmpty(this.task)) {
|
||||
message = "任务号不存在!";
|
||||
return;
|
||||
}
|
||||
// 调用WMS获取困扎信息
|
||||
try {
|
||||
// 根据指令号获取任务信息
|
||||
Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task));
|
||||
if (ObjectUtil.isEmpty(instruction)) {
|
||||
this.message = "指令[" + task + "]不存在!";
|
||||
return;
|
||||
}
|
||||
TaskDto taskDto = taskService.findByCodeFromCache(instruction.getTask_code());
|
||||
if (ObjectUtil.isEmpty(taskDto)) {
|
||||
this.message = "指令[" + task + "]任务不存在!";
|
||||
return;
|
||||
}
|
||||
|
||||
JSONObject applyRes = ResponseData.getCheckData(
|
||||
wmsApi.requestBundleInfo(BundleInfoReqVO
|
||||
.builder()
|
||||
.wmsTaskId(taskDto.getExt_task_id())
|
||||
.deviceCode(this.device.getDevice_code())
|
||||
.build()));
|
||||
if (ObjectUtil.isNotEmpty(applyRes)) {
|
||||
if (applyRes.getIntValue("code") == 0) {
|
||||
JSONObject data = applyRes.getJSONObject("data");
|
||||
if (ObjectUtil.isEmpty(data)) {
|
||||
this.message = "WMS 返回数据为空";
|
||||
return;
|
||||
}
|
||||
List<String> keys = new ArrayList<>();
|
||||
List<Object> values = new ArrayList<>();
|
||||
keys.add("to_command");
|
||||
values.add(12);
|
||||
keys.add("to_is_binding");
|
||||
values.add(data.getString("isBinding"));
|
||||
keys.add("to_leight");
|
||||
values.add(data.getString("length"));
|
||||
keys.add("to_wedth");
|
||||
values.add(data.getString("width"));
|
||||
keys.add("to_height");
|
||||
values.add(data.getString("height"));
|
||||
keys.add("to_binding_template");
|
||||
values.add(data.getString("bindingTemplate"));
|
||||
keys.add("to_binding_times");
|
||||
values.add(data.getIntValue("bindingTimes"));
|
||||
writing(keys, values);
|
||||
this.requireSuccess = true;
|
||||
this.message = "获取捆扎信息成功!";
|
||||
} else {
|
||||
this.message = "ACS请求WMS报错,错误相应:" + applyRes.getString("msg");
|
||||
}
|
||||
} else {
|
||||
this.message = "WMS 反馈数据为空!";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.message = "请求WMS出错," + e.getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() throws Exception {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", this.currentDeviceCode);
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("driver_type", "finished_product_out_with_bind_lable_conveyor");
|
||||
jo.put("is_click", false);
|
||||
jo.put("message", this.message);
|
||||
jo.put("isOnline", this.online);
|
||||
jo.put("isError", this.isError);
|
||||
return jo;
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", this.currentDeviceCode);
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("driver_type", "finished_product_out_with_bind_lable_conveyor");
|
||||
jo.put("is_click", false);
|
||||
jo.put("message", this.message);
|
||||
jo.put("isOnline", this.online);
|
||||
jo.put("isError", this.isError);
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.acs.device.deviceDriver.service.defination.opcDefination.one_floor.conveyor.fold_disc_site;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -11,10 +12,15 @@ import org.nl.acs.device.deviceDriver.service.driver.DeviceDriver;
|
||||
import org.nl.acs.device.deviceDriver.service.driver.base.DeviceDriverBaseReader;
|
||||
import org.nl.acs.device.deviceDriver.service.driver.plugin.DeviceStageMonitorPlugin;
|
||||
import org.nl.acs.device.deviceDriver.service.driver.plugin.DriverExecutePlugin;
|
||||
import org.nl.common.base.ResponseData;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import com.google.common.util.concurrent.Uninterruptibles;
|
||||
import org.nl.extInterface.wms.WmsApi;
|
||||
import org.nl.extInterface.wms.data.req.ApplyInboundReqVO;
|
||||
import org.nl.extInterface.wms.data.req.CallTaskReqVO;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -30,6 +36,7 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
DeviceDriverBaseReader {
|
||||
|
||||
private final LuceneExecuteLogService logService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
||||
private final WmsApi wmsApi = SpringContextHolder.getBean(WmsApi.class);
|
||||
|
||||
/**
|
||||
* 心跳
|
||||
@@ -141,9 +148,9 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
* 请求时间间隔
|
||||
* long currentTimeMillis = System.currentTimeMillis();
|
||||
* if (!isTimeValid(currentTimeMillis)) {
|
||||
* log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
|
||||
* log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
|
||||
* } else {
|
||||
* this.requireTime = currentTimeMillis;
|
||||
* this.requireTime = currentTimeMillis;
|
||||
* }
|
||||
*
|
||||
* @param currentTimeMillis
|
||||
@@ -155,49 +162,81 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
|
||||
@Override
|
||||
public void executeLogic() {
|
||||
// 复位
|
||||
if (this.mode != this.lastMode) {
|
||||
this.requireSuccess = false;
|
||||
}
|
||||
if (!this.online) {
|
||||
this.message = "设备离线";
|
||||
this.message = "设备离线";
|
||||
} else if (this.mode == 0) {
|
||||
this.message = "设备未联机";
|
||||
this.message = "设备未联机";
|
||||
} else if (this.error != 0) {
|
||||
this.message = "设备报警";
|
||||
this.isError = true;
|
||||
} else {
|
||||
this.isError = false;
|
||||
this.message = "";
|
||||
//编写业务逻辑方法
|
||||
this.templateMethod();
|
||||
}
|
||||
this.message = "设备报警";
|
||||
this.isError = true;
|
||||
} else {
|
||||
this.isError = false;
|
||||
this.message = "";
|
||||
//编写业务逻辑方法
|
||||
if (10 == this.mode) {
|
||||
this.doCallEmptyPalletStack();
|
||||
}
|
||||
}
|
||||
lastMode = mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模板方法
|
||||
* 呼叫空托盘垛
|
||||
*/
|
||||
public void templateMethod() {
|
||||
public void doCallEmptyPalletStack() {
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
if (!isTimeValid(currentTimeMillis)) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
|
||||
} else {
|
||||
this.requireTime = currentTimeMillis;
|
||||
if (this.move == 0) {
|
||||
// 调用 wms呼叫空托盘垛
|
||||
try {
|
||||
JSONObject applyRes = ResponseData.getCheckData(
|
||||
wmsApi.emptyPalletStack(CallTaskReqVO
|
||||
.builder()
|
||||
.deviceCode(this.device.getDevice_code())
|
||||
.build()));
|
||||
if (ObjectUtil.isNotEmpty(applyRes)) {
|
||||
if (applyRes.getIntValue("code") == 0) {
|
||||
this.writing("to_command", 10);
|
||||
this.requireSuccess = true;
|
||||
this.message = "呼叫空托盘垛任务申请成功!";
|
||||
} else {
|
||||
this.message = "ACS请求WMS报错,错误相应:" + applyRes.getString("msg");
|
||||
}
|
||||
} else {
|
||||
this.message = "WMS 反馈数据为空!";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.message = "请求WMS出错," + e.getMessage();
|
||||
}
|
||||
} else {
|
||||
this.message = "move=1,显示有货,无法呼叫空托盘垛";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() throws Exception {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", this.currentDeviceCode);
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("driver_type", "fold_disc_site");
|
||||
jo.put("is_click", false);
|
||||
jo.put("message", this.message);
|
||||
jo.put("isOnline", this.online);
|
||||
jo.put("isError", this.isError);
|
||||
return jo;
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", this.currentDeviceCode);
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("driver_type", "fold_disc_site");
|
||||
jo.put("is_click", false);
|
||||
jo.put("message", this.message);
|
||||
jo.put("isOnline", this.online);
|
||||
jo.put("isError", this.isError);
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,11 +12,16 @@ public enum ItemProtocol implements DeviceDriverBaseReader.KeyProvider {
|
||||
MOVE("move", "光电信号", "DB600.B3"),
|
||||
ACTION("action", "动作信号", "DB600.B4"),
|
||||
ERROR("error", "报警信号", "DB600.B5"),
|
||||
MATERIAL_BARCODE("material_barcode", "物料编码", "DB600.Sring6.50"),
|
||||
MATERIAL_BARCODE("material_barcode", "物料编码", "DB600.Sring6.50"),
|
||||
TASK("task", "任务号", "DB600.W58"),
|
||||
TO_COMMAND("to_command", "下发命令", "DB601.W0"),
|
||||
TO_TARGET("to_target", "下发目标站", "DB601.W2"),
|
||||
TO_TASK("to_task", "下发任务号", "DB601.D4");
|
||||
TO_TASK("to_task", "下发任务号", "DB601.D4"),
|
||||
TO_LENGTH("to_length", "木箱长度", "DB601.W14"),
|
||||
TO_WIDTH("to_width", "木箱宽度", "DB601.W16"),
|
||||
TO_HEIGHT("to_height", "木箱高度", "DB601.W18"),
|
||||
TO_DESICCANT("to_desiccant", "干燥机模板", "DB601.W22"),
|
||||
;
|
||||
|
||||
private final String key;
|
||||
private final String description;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.nl.acs.device.deviceDriver.service.defination.opcDefination.one_floor.conveyor.un_box_lable_conveyor;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -11,12 +13,23 @@ import org.nl.acs.device.deviceDriver.service.driver.DeviceDriver;
|
||||
import org.nl.acs.device.deviceDriver.service.driver.base.DeviceDriverBaseReader;
|
||||
import org.nl.acs.device.deviceDriver.service.driver.plugin.DeviceStageMonitorPlugin;
|
||||
import org.nl.acs.device.deviceDriver.service.driver.plugin.DriverExecutePlugin;
|
||||
import org.nl.acs.task.instruction.domain.Instruction;
|
||||
import org.nl.acs.task.instruction.service.InstructionService;
|
||||
import org.nl.acs.task.task.service.TaskService;
|
||||
import org.nl.acs.task.task.service.dto.TaskDto;
|
||||
import org.nl.common.base.ResponseData;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import com.google.common.util.concurrent.Uninterruptibles;
|
||||
import org.nl.extInterface.wms.WmsApi;
|
||||
import org.nl.extInterface.wms.data.req.BundleInfoReqVO;
|
||||
import org.nl.extInterface.wms.data.resp.OpenCoverInfoVO;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
@@ -30,6 +43,9 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
DeviceDriverBaseReader {
|
||||
|
||||
private final LuceneExecuteLogService logService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
||||
private final WmsApi wmsApi = SpringContextHolder.getBean(WmsApi.class);
|
||||
private final InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
||||
private final TaskService taskService = SpringContextHolder.getBean(TaskService.class);
|
||||
|
||||
/**
|
||||
* 心跳
|
||||
@@ -81,6 +97,26 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
*/
|
||||
private int to_task = 0;
|
||||
private int lastTo_task = 0;
|
||||
/**
|
||||
* 长
|
||||
*/
|
||||
private String to_length;
|
||||
private String lastTo_length;
|
||||
/**
|
||||
* 宽
|
||||
*/
|
||||
private String to_width;
|
||||
private String lastTo_width;
|
||||
/**
|
||||
* 高
|
||||
*/
|
||||
private String to_height;
|
||||
private String lastTo_height;
|
||||
/**
|
||||
* 干燥机模板
|
||||
*/
|
||||
private String to_desiccant;
|
||||
private String lastTo_desiccant;
|
||||
/**
|
||||
* 当前设备编号
|
||||
*/
|
||||
@@ -141,9 +177,9 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
* 请求时间间隔
|
||||
* long currentTimeMillis = System.currentTimeMillis();
|
||||
* if (!isTimeValid(currentTimeMillis)) {
|
||||
* log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
|
||||
* log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
|
||||
* } else {
|
||||
* this.requireTime = currentTimeMillis;
|
||||
* this.requireTime = currentTimeMillis;
|
||||
* }
|
||||
*
|
||||
* @param currentTimeMillis
|
||||
@@ -155,49 +191,120 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
|
||||
@Override
|
||||
public void executeLogic() {
|
||||
if (this.mode != this.lastMode) {
|
||||
this.requireSuccess = false;
|
||||
}
|
||||
if (!this.online) {
|
||||
this.message = "设备离线";
|
||||
this.message = "设备离线";
|
||||
} else if (this.mode == 0) {
|
||||
this.message = "设备未联机";
|
||||
this.message = "设备未联机";
|
||||
} else if (this.error != 0) {
|
||||
this.message = "设备报警";
|
||||
this.isError = true;
|
||||
} else {
|
||||
this.isError = false;
|
||||
this.message = "";
|
||||
//编写业务逻辑方法
|
||||
this.templateMethod();
|
||||
}
|
||||
this.message = "设备报警";
|
||||
this.isError = true;
|
||||
} else {
|
||||
this.isError = false;
|
||||
this.message = "";
|
||||
//编写业务逻辑方法
|
||||
if (mode == 11 && !requireSuccess) {
|
||||
// 请求开盖
|
||||
this.requestOpenCoverInfo();
|
||||
}
|
||||
}
|
||||
lastMode = mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模板方法
|
||||
* 请求开合盖
|
||||
*/
|
||||
public void templateMethod() {
|
||||
public void requestOpenCoverInfo() {
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
if (!isTimeValid(currentTimeMillis)) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
|
||||
} else {
|
||||
this.requireTime = currentTimeMillis;
|
||||
if (move != 1) {
|
||||
message = "开合盖申请失败,无货不允许请求,请检查move信号";
|
||||
return;
|
||||
}
|
||||
if (ObjectUtil.isEmpty(this.task)) {
|
||||
message = "任务号不存在!";
|
||||
return;
|
||||
}
|
||||
// 调用WMS获取困扎信息
|
||||
try {
|
||||
// 根据指令号获取任务信息
|
||||
Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task));
|
||||
if (ObjectUtil.isEmpty(instruction)) {
|
||||
this.message = "指令[" + task + "]不存在!";
|
||||
return;
|
||||
}
|
||||
TaskDto taskDto = taskService.findByCodeFromCache(instruction.getTask_code());
|
||||
if (ObjectUtil.isEmpty(taskDto)) {
|
||||
this.message = "指令[" + task + "]任务不存在!";
|
||||
return;
|
||||
}
|
||||
|
||||
JSONObject applyRes = ResponseData.getCheckData(
|
||||
wmsApi.requestOpenCoverInfo(BundleInfoReqVO
|
||||
.builder()
|
||||
.wmsTaskId(taskDto.getExt_task_id())
|
||||
.deviceCode(this.device.getDevice_code())
|
||||
.build()));
|
||||
if (ObjectUtil.isNotEmpty(applyRes)) {
|
||||
if (applyRes.getIntValue("code") == 0) {
|
||||
JSONObject data = applyRes.getJSONObject("data");
|
||||
if (ObjectUtil.isEmpty(data)) {
|
||||
this.message = "WMS 返回数据为空";
|
||||
return;
|
||||
}
|
||||
OpenCoverInfoVO openCoverInfoVO =
|
||||
JSONObject.parseObject(JSON.toJSONString(data), OpenCoverInfoVO.class);
|
||||
List<String> keys = new ArrayList<>();
|
||||
List<Object> values = new ArrayList<>();
|
||||
keys.add("to_command");
|
||||
values.add(11);
|
||||
keys.add("to_length");
|
||||
values.add(openCoverInfoVO.getLength());
|
||||
keys.add("to_width");
|
||||
values.add(openCoverInfoVO.getWidth());
|
||||
keys.add("to_height");
|
||||
values.add(openCoverInfoVO.getHeight());
|
||||
keys.add("to_desiccant");
|
||||
values.add(openCoverInfoVO.getDesiccant());
|
||||
writing(keys, values);
|
||||
this.requireSuccess = true;
|
||||
this.message = "获取开盖信息成功!";
|
||||
} else {
|
||||
this.message = "ACS请求WMS报错,错误相应:" + applyRes.getString("msg");
|
||||
writing("to_command", 99);
|
||||
this.requireSuccess = true;
|
||||
}
|
||||
} else {
|
||||
this.message = "WMS 反馈数据为空!";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.message = "出现异常:" + e.getMessage();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() throws Exception {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", this.currentDeviceCode);
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("driver_type", "un_box_lable_conveyor");
|
||||
jo.put("is_click", false);
|
||||
jo.put("message", this.message);
|
||||
jo.put("isOnline", this.online);
|
||||
jo.put("isError", this.isError);
|
||||
return jo;
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", this.currentDeviceCode);
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("driver_type", "un_box_lable_conveyor");
|
||||
jo.put("is_click", false);
|
||||
jo.put("message", this.message);
|
||||
jo.put("isOnline", this.online);
|
||||
jo.put("isError", this.isError);
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import com.google.common.util.concurrent.Uninterruptibles;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -186,9 +187,9 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
* 请求时间间隔
|
||||
* long currentTimeMillis = System.currentTimeMillis();
|
||||
* if (!isTimeValid(currentTimeMillis)) {
|
||||
* log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
|
||||
* log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
|
||||
* } else {
|
||||
* this.requireTime = currentTimeMillis;
|
||||
* this.requireTime = currentTimeMillis;
|
||||
* }
|
||||
*
|
||||
* @param currentTimeMillis
|
||||
@@ -200,19 +201,23 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
|
||||
@Override
|
||||
public void executeLogic() {
|
||||
if (this.mode != this.lastMode) {
|
||||
this.requireSuccess = false;
|
||||
}
|
||||
if (!this.online) {
|
||||
this.message = "设备离线";
|
||||
this.message = "设备离线";
|
||||
} else if (this.mode == 0) {
|
||||
this.message = "设备未联机";
|
||||
this.message = "设备未联机";
|
||||
} else if (this.error != 0) {
|
||||
this.message = "设备报警";
|
||||
this.isError = true;
|
||||
} else {
|
||||
this.isError = false;
|
||||
this.message = "";
|
||||
//编写业务逻辑方法
|
||||
this.templateMethod();
|
||||
}
|
||||
this.message = "设备报警";
|
||||
this.isError = true;
|
||||
} else {
|
||||
this.isError = false;
|
||||
this.message = "";
|
||||
//编写业务逻辑方法
|
||||
this.templateMethod();
|
||||
}
|
||||
lastMode = mode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -224,25 +229,31 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
|
||||
} else {
|
||||
this.requireTime = currentTimeMillis;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() throws Exception {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", this.currentDeviceCode);
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("driver_type", "box_storage_manipulator");
|
||||
jo.put("is_click", false);
|
||||
jo.put("message", this.message);
|
||||
jo.put("isOnline", this.online);
|
||||
jo.put("isError", this.isError);
|
||||
return jo;
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", this.currentDeviceCode);
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("driver_type", "box_storage_manipulator");
|
||||
jo.put("is_click", false);
|
||||
jo.put("message", this.message);
|
||||
jo.put("isOnline", this.online);
|
||||
jo.put("isError", this.isError);
|
||||
jo.put("x", this.x);
|
||||
jo.put("y", y);
|
||||
jo.put("walk_y", walk_y);
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,6 +34,14 @@ public interface InstructionService extends CommonService<InstructionMybatis> {
|
||||
*/
|
||||
InstructionDto findById(String id);
|
||||
|
||||
/**
|
||||
* 根据指令编号缓存查询
|
||||
*
|
||||
* @param code code
|
||||
* @return Instruction
|
||||
*/
|
||||
Instruction findByCodeFromCache(String code);
|
||||
|
||||
/**
|
||||
* 按主键直接更新数据库记录;调用方负责缓存同步。
|
||||
*
|
||||
|
||||
@@ -88,6 +88,18 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
return ConvertUtil.convert(getById(id), InstructionDto.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction findByCodeFromCache(String code) {
|
||||
Iterator<Instruction> it = instructions.iterator();
|
||||
while (it.hasNext()) {
|
||||
Instruction inst = it.next();
|
||||
if (StrUtil.equals(code, inst.getInstruction_code())) {
|
||||
return inst;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateById(InstructionDto resources) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.nl.common.base;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -125,4 +127,16 @@ public class ResponseData<T> implements Serializable {
|
||||
rspData.setRespCode(1);
|
||||
return new ResponseEntity(rspData, HttpStatus.OK);
|
||||
}
|
||||
|
||||
public static JSONObject getCheckData(ResponseEntity applydata) {
|
||||
if (ObjectUtil.isEmpty(applydata)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ResponseData<?> responseData = (ResponseData<?>) applydata.getBody();
|
||||
if (ObjectUtil.isEmpty(responseData)) {
|
||||
return null;
|
||||
}
|
||||
return JSONObject.parseObject(JSONObject.toJSONString(responseData.getData()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,12 +123,13 @@ public class WmsTaskCreateManager {
|
||||
taskDto.setStart_device_code2(startLocation2.getDeviceCode());
|
||||
taskDto.setNext_point_code2(nextLocation2.getPointCode());
|
||||
taskDto.setNext_device_code2(nextLocation2.getDeviceCode());
|
||||
taskDto.setPriority(task.getPriority());
|
||||
taskDto.setPriority(ObjectUtil.isEmpty(task.getPriority()) ? "1" : task.getPriority());
|
||||
taskDto.setVehicle_code(task.getVehicleCode());
|
||||
taskDto.setVehicle_code2(task.getVehicleCode2());
|
||||
taskDto.setTask_type(StrUtil.blankToDefault(task.getTaskType(), DEFAULT_TASK_TYPE));
|
||||
taskDto.setRoute_plan_code(getRoutePlanCode(task));
|
||||
taskDto.setRemark(task.getRemark());
|
||||
// todo: 需要检查
|
||||
taskDto.setParamJson(new JSONObject(buildTaskParam(task)));
|
||||
return taskDto;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@ import org.nl.acs.task.TaskConfig;
|
||||
import org.nl.common.base.ResponseData;
|
||||
import org.nl.extInterface.log.InterfaceLog;
|
||||
import org.nl.extInterface.wms.constand.WmsMethodConstand;
|
||||
import org.nl.extInterface.wms.data.req.ApplyInboundReqVO;
|
||||
import org.nl.extInterface.wms.data.req.BundleInfoReqVO;
|
||||
import org.nl.extInterface.wms.data.req.CallTaskReqVO;
|
||||
import org.nl.extInterface.wms.data.req.FeedbackTaskStatusRequest;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -31,6 +34,30 @@ public class WmsApi {
|
||||
public ResponseEntity feedbackTaskStatus(FeedbackTaskStatusRequest request) {
|
||||
return post(WmsMethodConstand.FEEDBACK_TASK_STATUS, request);
|
||||
}
|
||||
/**
|
||||
* 请求入库:WMS根据不同的类型自行区分;6-申请空拖盘入库;7-申请空木箱入库;8-申请退货入库;9-申请成品入库
|
||||
*/
|
||||
@InterfaceLog(direction = "ACS->WMS", path = WmsMethodConstand.APPLY_INBOUND_TASK, description = "输送线请求入库")
|
||||
public ResponseEntity applyInboundTask(ApplyInboundReqVO request) {
|
||||
return post(WmsMethodConstand.APPLY_INBOUND_TASK, request);
|
||||
}
|
||||
@InterfaceLog(direction = "ACS->WMS", path = WmsMethodConstand.CALL_EMPTY_PALLET_STACK, description = "呼叫空托盘垛")
|
||||
public ResponseEntity emptyPalletStack(CallTaskReqVO request) {
|
||||
return post(WmsMethodConstand.CALL_EMPTY_PALLET_STACK, request);
|
||||
}
|
||||
@InterfaceLog(direction = "ACS->WMS", path = WmsMethodConstand.REQUEST_BUNDLE_INFO, description = "获取困扎信息")
|
||||
public ResponseEntity requestBundleInfo(BundleInfoReqVO request) {
|
||||
return post(WmsMethodConstand.REQUEST_BUNDLE_INFO, request);
|
||||
}
|
||||
@InterfaceLog(direction = "ACS->WMS", path = WmsMethodConstand.APPLY_OUTBOUND_AGV_TASK, description = "申请AGV出库任务")
|
||||
public ResponseEntity requestOutboundAgvTask(CallTaskReqVO request) {
|
||||
return post(WmsMethodConstand.APPLY_OUTBOUND_AGV_TASK, request);
|
||||
}
|
||||
|
||||
@InterfaceLog(direction = "ACS->WMS", path = WmsMethodConstand.REQUEST_OPEN_COVER_INFO, description = "获取开盖信息")
|
||||
public ResponseEntity requestOpenCoverInfo(BundleInfoReqVO request) {
|
||||
return post(WmsMethodConstand.REQUEST_OPEN_COVER_INFO, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* post请求
|
||||
@@ -40,7 +67,8 @@ public class WmsApi {
|
||||
* @return
|
||||
*/
|
||||
public <T> ResponseEntity post(String apiPath, Object request) {
|
||||
String baseUrl = paramService.findByCode(TaskConfig.WMSURL).getValue();
|
||||
// String baseUrl = paramService.findByCode(TaskConfig.WMSURL).getValue();
|
||||
String baseUrl = "http://127.0.0.1:48080";
|
||||
try {
|
||||
String responseBody = HttpRequest.post(baseUrl.replaceAll("/+$", "") + apiPath)
|
||||
.header("Content-Type", "application/json")
|
||||
|
||||
@@ -2,4 +2,9 @@ package org.nl.extInterface.wms.constand;
|
||||
|
||||
public class WmsMethodConstand {
|
||||
public static final String FEEDBACK_TASK_STATUS = "/feedbackTaskStatus";
|
||||
public static final String APPLY_INBOUND_TASK = "/acs/call/inbound/apply";
|
||||
public static final String APPLY_OUTBOUND_AGV_TASK = "/acs/call/outbound/agv/apply";
|
||||
public static final String CALL_EMPTY_PALLET_STACK = "/acs/call/empty-pallet-stack";
|
||||
public static final String REQUEST_BUNDLE_INFO = "/acs/call/request-bundle-info";
|
||||
public static final String REQUEST_OPEN_COVER_INFO = "/acs/call/request-open-cover-info";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.nl.extInterface.wms.data.req;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 输送线申请入库
|
||||
* @Author: liyongde
|
||||
* @Date: 2026/8/4 10:10
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class ApplyInboundReqVO {
|
||||
/**
|
||||
* 类型:6-申请空拖盘入库;7-申请空木箱入库;8-申请退货入库;9-申请成品入库
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 设备号(请求点位)
|
||||
*/
|
||||
private String deviceCode;
|
||||
|
||||
/**
|
||||
* 参数,不同设备不同入参
|
||||
*/
|
||||
private Object data;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.nl.extInterface.wms.data.req;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @Author: liyongde
|
||||
* @Date: 2026/8/5 10:29
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class BundleInfoReqVO {
|
||||
private String wmsTaskId;
|
||||
|
||||
private String deviceCode;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.nl.extInterface.wms.data.req;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @Author: liyongde
|
||||
* @Date: 2026/8/5 9:22
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class CallTaskReqVO {
|
||||
|
||||
private String deviceCode;
|
||||
|
||||
private String vehicleCode;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.nl.extInterface.wms.data.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 开合盖信息实体
|
||||
* @Author: liyongde
|
||||
* @Date: 2026/8/5 17:21
|
||||
*/
|
||||
@Data
|
||||
public class OpenCoverInfoVO {
|
||||
/**
|
||||
* 长
|
||||
*/
|
||||
private String length;
|
||||
/**
|
||||
* 宽
|
||||
*/
|
||||
private String width;
|
||||
/**
|
||||
* 高
|
||||
*/
|
||||
private String height;
|
||||
/**
|
||||
* 干燥机模板
|
||||
*/
|
||||
private String desiccant;
|
||||
}
|
||||
@@ -22,7 +22,6 @@ import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
|
||||
@@ -39,7 +39,7 @@ public class AutoCreateInst {
|
||||
* 创建指令前需要判断是否条件具备:起始位置是否有货、目标位置是否有货
|
||||
*/
|
||||
public void run() throws Exception {
|
||||
log.info("自动生成指令"+DateUtil.now());
|
||||
log.info("自动生成指令" + DateUtil.now());
|
||||
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
|
||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
||||
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
|
||||
@@ -91,7 +91,7 @@ public class AutoCreateInst {
|
||||
boolean flag = false;
|
||||
for (int m = 0; m < pathlist.size(); m++) {
|
||||
if (pathlist.get(m).equals(start_device_code)) {
|
||||
if("1".equals(acsTask.getTask_type()) && !pathlist.get(m+1).equals(next_device_code)){
|
||||
if ("1".equals(acsTask.getTask_type()) && !pathlist.get(m + 1).equals(next_device_code)) {
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
@@ -142,18 +142,18 @@ public class AutoCreateInst {
|
||||
instdto.setVehicle_type(vehicleType);
|
||||
|
||||
try {
|
||||
instructionService.create(instdto);
|
||||
instructionService.create(instdto);
|
||||
} catch (Exception e) {
|
||||
acsTask.setRemark(e.getMessage());
|
||||
taskserver.updateByCodeFromCache(acsTask);
|
||||
continue;
|
||||
}
|
||||
//创建指令后修改任务状态
|
||||
acsTask.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
acsTask.setUpdate_time(DateUtil.now());
|
||||
acsTask.setRemark(" ");
|
||||
taskserver.update(acsTask);
|
||||
}
|
||||
acsTask.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
acsTask.setUpdate_time(DateUtil.now());
|
||||
acsTask.setRemark(" ");
|
||||
taskserver.update(acsTask);
|
||||
}
|
||||
}
|
||||
|
||||
private String getDeviceCode(String pointCode) {
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package org.nl.extInterface.wms;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.nl.common.base.ResponseData;
|
||||
import org.nl.extInterface.wms.data.req.ApplyInboundReqVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* WMS 入库申请接口集成测试。
|
||||
*
|
||||
* <p>运行前请确认:</p>
|
||||
* <ol>
|
||||
* <li>数据库中的 wmsurl 参数已配置为可访问的 WMS 地址;</li>
|
||||
* <li>WMS 服务已经启动;</li>
|
||||
* <li>测试设备 DEV001 已在 WMS 中配置。</li>
|
||||
* </ol>
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
class WmsApiTest {
|
||||
|
||||
@Autowired
|
||||
private WmsApi wmsApi;
|
||||
|
||||
@Test
|
||||
void shouldApplyEmptyPalletInboundTask() {
|
||||
ApplyInboundReqVO request = ApplyInboundReqVO.builder()
|
||||
.type("6")
|
||||
.deviceCode("DEV001")
|
||||
.build();
|
||||
|
||||
ResponseEntity<?> response = wmsApi.applyInboundTask(request);
|
||||
|
||||
assertTrue(response.getStatusCode().is2xxSuccessful(),
|
||||
"HTTP 请求失败,状态码:" + response.getStatusCode());
|
||||
assertNotNull(response.getBody(), "接口响应体不能为空");
|
||||
assertTrue(response.getBody() instanceof ResponseData,
|
||||
"响应体类型应为 ResponseData,实际为:" + response.getBody().getClass().getName());
|
||||
|
||||
// WmsApi.post() 会将 WMS 的原始 JSON 放到 ResponseData.data 中。
|
||||
ResponseData<?> responseData = (ResponseData<?>) response.getBody();
|
||||
assertEquals(Integer.valueOf(0), responseData.getRespCode(),
|
||||
"调用 WMS 失败:" + responseData.getRespMsg());
|
||||
assertNotNull(responseData.getData(), "WMS 原始响应不能为空");
|
||||
|
||||
JSONObject wmsResult = toJsonObject(responseData.getData());
|
||||
assertEquals(0, wmsResult.getIntValue("code"),
|
||||
"WMS 返回失败:" + wmsResult.getString("msg"));
|
||||
|
||||
JSONObject data = wmsResult.getJSONObject("data");
|
||||
assertNotNull(data, "WMS 响应中的 data 不能为空");
|
||||
assertEquals("DEV001", data.getString("deviceCode"));
|
||||
|
||||
System.out.println("申请空托盘入库成功,WMS响应:" + wmsResult.toJSONString());
|
||||
}
|
||||
|
||||
private JSONObject toJsonObject(Object value) {
|
||||
if (value instanceof JSONObject) {
|
||||
return (JSONObject) value;
|
||||
}
|
||||
return JSONObject.parseObject(JSONObject.toJSONString(value));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user