fix: 出库大批量测试、入库测试

This commit is contained in:
2024-06-03 18:35:07 +08:00
parent 12b38767a5
commit 32f2a07c91
14 changed files with 198 additions and 94 deletions

View File

@@ -25,6 +25,7 @@ import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.device_driver.one_conveyor.fold_disc_site.FoldDiscSiteDeviceDriver;
import org.nl.acs.device_driver.one_manipulator.box_package_manipulator.InteractionJsonDTO;
import org.nl.acs.enums.AcsToLmsApplyTaskTypeEnum;
import org.nl.acs.enums.StorageTypeEnum;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
import org.nl.acs.history.ErrorUtil;
@@ -226,8 +227,6 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
@Override
public void execute() {
System.out.println("in"+ LocalDateTime.now() +"开始时间"+this.getDeviceCode());
try {
device_code = this.getDeviceCode();
heartbeat = this.itemProtocol.getHeartbeat();
@@ -242,7 +241,6 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
to_target = this.itemProtocol.getTotarget();
to_task = this.itemProtocol.getTo_task();
to_container_no = this.itemProtocol.getContainer_direction();
material_barcode = this.itemProtocol.getMaterialBarcode();
if (mode != last_mode) {
@@ -266,6 +264,16 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
}
//申请空托盘出库
if (mode == 8 && !requireSucess) {
if (container_type==0){
message = "universal_notCreateInstMessage7";
}
applyEmptyTask(StorageTypeEnum.DISKS_OUT.getType(), mode);
}
if (mode == 0) {
this.setIsonline(false);
message = "universal_off-line";
@@ -319,13 +327,8 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
//request_for_shipment(String.valueOf(mode), item_out_seq_arr, item_out_qty_arr);
}
break;
case 19:
//申请AGV任务
if (move == 1 && !requireSucess) {
applyAgvTask();
}
break;
default:
@@ -346,7 +349,6 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
last_to_task = to_task;
last_to_container_no = to_container_no;
last_to_container_type = to_container_type;
System.out.println("out"+ LocalDateTime.now() +"结束时间"+this.getDeviceCode());
}
public void clearWrite() {
@@ -389,86 +391,58 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
luceneExecuteLogService.deviceExecuteLog(logDto);
}
public synchronized void applyAgvTask() {
private void applyEmptyTask(String type, int mode) {
Date date = new Date();
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
if (date.getTime() - this.require_apply_strangulation_time.getTime()
< (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return;
} else {
String hand_barcode = null;
this.instruction_require_time = date;
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
//判断是否有手动补码 如果有就申请补码agv任务
if (StrUtil.isNotEmpty(hand_barcode)) {
JSONObject apply = new JSONObject();
apply.put("device_code", device_code);
apply.put("vehicle_code", hand_barcode);
String str = acsToWmsService.applyTaskToWms(apply);
JSONObject jo = JSON.parseObject(str);
try {
JSONObject param = new JSONObject();
param.put("device_code", device_code);
param.put("container_type", container_type);
param.put("type", type);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content("申请空托盘出入库,参数:" + param)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
String response = acsToWmsService.applyTwo(param);
JSONObject jo = JSON.parseObject(response);
if (jo.getInteger("status") == 200) {
LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code(device_code)
.content("申请AGV任务,参数,接口返回:" + jo)
.content("申请空托盘出入库,参数,接口返回:" + jo)
.build();
logDto2.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto2);
if (ObjectUtil.isEmpty(jo)) {
message = "one_message15";
} else {
if (jo.getInteger("status") == 200) {
message = "one_message16";
List list1 = new ArrayList();
Map map = new HashMap();
map.put("code", "to_command");
map.put("value", 19);
list1.add(map);
this.writing(list1);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content("申请AGV任务,返回参数:" + jo.getString("body"))
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
requireSucess = true;
} else {
message = "one_message17";
}
}
return;
}
JSONObject apply = new JSONObject();
apply.put("device_code", device_code);
apply.put("vehicle_code", material_barcode);
String str = acsToWmsService.applySendOutTwo(apply);
logServer.deviceExecuteLog(this.device_code, "", "", "申请AGV任务,请求参数:" + apply + ",响应参数");
JSONObject jo = JSON.parseObject(str);
if (ObjectUtil.isEmpty(jo)) {
message = "one_message15";
// requireSucess = true;
List list1 = new ArrayList();
Map map = new HashMap();
map.put("code", "to_command");
map.put("value", mode);
list1.add(map);
this.writing(list1);
this.requireSucess = true;
} else {
if (jo.getInteger("status") == 200) {
message = "one_message16";
List list = new ArrayList();
Map map = new HashMap();
map.put("code", "to_command");
map.put("value", 19);
list.add(map);
this.writing(list);
logServer.deviceExecuteLog(this.device_code, "", "", "申请AGV任务,返回参数:" + jo);
requireSucess = true;
} else {
message = "one_message17";
}
LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code(device_code)
.content("申请空托盘出入库,返回参数:" + jo.getString("body"))
.build();
logDto2.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto2);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* 申请任务
*/

View File

@@ -63,10 +63,7 @@ public class ItemProtocol {
*/
public static String item_to_target = "to_target";
/**
* 子卷条码
*/
public static String item_material_barcode = "material_barcode";
@@ -79,9 +76,6 @@ public class ItemProtocol {
this.driver = driver;
}
public String getMaterialBarcode() {
return this.getOpcStringValue(item_material_barcode);
}
public int getHeartbeat() {
return this.getOpcIntegerValue(item_heartbeat);
@@ -182,7 +176,6 @@ public class ItemProtocol {
list.add(new ItemDto(item_action, "动作类型", "DB101.B6"));
list.add(new ItemDto(item_error, "报警", "DB101.B58"));
list.add(new ItemDto(item_task, "任务号", "DB101.D68"));
list.add(new ItemDto(item_material_barcode, "子卷条码", "DB601.STRING1.50"));
return list;
}

View File

@@ -4,11 +4,13 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.nl.acs.AcsConfig;
import org.nl.acs.agv.server.NDCAgvService;
import org.nl.acs.common.base.CommonFinalParam;
import org.nl.acs.device.domain.Device;
@@ -38,6 +40,7 @@ import org.nl.config.language.LangProcess;
import org.nl.config.lucene.service.LuceneExecuteLogService;
import org.nl.config.lucene.service.dto.LuceneLogDto;
import org.nl.config.thread.ThreadPoolExecutorUtil;
import org.nl.system.service.param.ISysParamService;
import org.openscada.opc.lib.da.Server;
import java.util.*;
@@ -74,6 +77,9 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i
DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl");
ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
//当前指令
Instruction inst = null;
@@ -170,7 +176,7 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i
device_code = this.getDeviceCode();
mode = this.itemProtocol.getMode();
move = this.itemProtocol.getMove();
carrier_direction = this.itemProtocol.getCarrier_direction();
carrier_direction = this.itemProtocol.getContainer_direction();
error = this.itemProtocol.getError();
task = this.itemProtocol.getTask();
to_command = this.itemProtocol.getTo_command();
@@ -228,6 +234,16 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i
case 1:
log.debug("设备运转模式:等待工作");
break;
case 19:
//申请AGV任务
if (move == 1 && !requireSucess) {
if (StrUtil.isEmpty(material_barcode)){
message = "universal_notCreateInstMessage8";
}
applyAgvTask();
}
break;
case 2:
//申请任务
if (move > 0 && !requireSucess) {
@@ -305,6 +321,84 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i
}
}
public synchronized void applyAgvTask() {
Date date = new Date();
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return;
} else {
String hand_barcode = null;
this.instruction_require_time = date;
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
//判断是否有手动补码 如果有就申请补码agv任务
if (StrUtil.isNotEmpty(hand_barcode)) {
JSONObject apply = new JSONObject();
apply.put("device_code", device_code);
apply.put("vehicle_code", hand_barcode);
String str = acsToWmsService.applyTaskToWms(apply);
JSONObject jo = JSON.parseObject(str);
LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code(device_code)
.content("申请AGV任务,参数,接口返回:" + jo)
.build();
luceneExecuteLogService.deviceExecuteLog(logDto2);
if (ObjectUtil.isEmpty(jo)) {
message = "one_message15";
} else {
if (jo.getInteger("status") == 200) {
message = "one_message16";
List list1 = new ArrayList();
Map map = new HashMap();
map.put("code", "to_command");
map.put("value", 19);
list1.add(map);
this.writing(list1);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content("申请AGV任务,返回参数:" + jo.getString("body"))
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
requireSucess = true;
} else {
message = "one_message17";
}
}
return;
}
JSONObject apply = new JSONObject();
apply.put("device_code", device_code);
apply.put("vehicle_code", material_barcode);
String str = acsToWmsService.applySendOutTwo(apply);
logServer.deviceExecuteLog(this.device_code, "", "", "申请AGV任务,请求参数:" + apply + ",响应参数");
JSONObject jo = JSON.parseObject(str);
if (ObjectUtil.isEmpty(jo)) {
message = "one_message15";
// requireSucess = true;
} else {
if (jo.getInteger("status") == 200) {
message = "one_message16";
List list = new ArrayList();
Map map = new HashMap();
map.put("code", "to_command");
map.put("value", 19);
list.add(map);
this.writing(list);
logServer.deviceExecuteLog(this.device_code, "", "", "申请AGV任务,返回参数:" + jo);
requireSucess = true;
} else {
message = "one_message17";
}
}
}
}
}
public boolean exe_business() {
return true;

View File

@@ -27,7 +27,7 @@ public class ItemProtocol {
/**
* 托盘方向
*/
public static String item_carrier_direction = "carrier_direction";
public static String item_container_direction = "container_direction";
/**
* 载具类型
@@ -95,8 +95,8 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_move);
}
public int getCarrier_direction() {
return this.getOpcIntegerValue(item_carrier_direction);
public int getContainer_direction() {
return this.getOpcIntegerValue(item_container_direction);
}
public int getError() {
@@ -161,7 +161,7 @@ public class ItemProtocol {
list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0"));
list.add(new ItemDto(item_mode, "工作模式", "DB600.B2"));
list.add(new ItemDto(item_move, "光电信号", "DB600.B3"));
list.add(new ItemDto(item_carrier_direction, "托盘方向", "DB600.B4"));
list.add(new ItemDto(item_container_direction, "托盘方向", "DB600.B4"));
list.add(new ItemDto(item_action, "动作信号", "DB600.B5"));
list.add(new ItemDto(item_error, "报警信号", "DB600.B6"));
list.add(new ItemDto(item_container_type, "托盘类型", "DB101.B7"));

View File

@@ -249,6 +249,9 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements
//申请空托盘入库
if (mode == 9 && move == 1 && !requireSucess) {
if (container_type==0){
message = "universal_notCreateInstMessage7";
}
applyEmptyTask(StorageTypeEnum.DISKS_IN.getType(), mode);
}
@@ -256,6 +259,9 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements
//申请空托盘出库
if (mode == 8 && !requireSucess) {
if (container_type==0){
message = "universal_notCreateInstMessage7";
}
applyEmptyTask(StorageTypeEnum.DISKS_OUT.getType(), mode);

View File

@@ -304,12 +304,18 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
List toInstructions;
//木箱入库申请入库任务
if (mode == 6 && !requireSucess){
if (StrUtil.isEmpty(barcode)){
message = "universal_notCreateInstMessage8";
}
applyIn(StorageTypeEnum.BOX_IN.getType(),mode);
}
//子卷入库申请入库任务
if (mode == 7 && !requireSucess){
if (StrUtil.isEmpty(barcode)||StrUtil.isEmpty(material_barcode)){
message = "universal_notCreateInstMessage8";
}
applyIn(StorageTypeEnum.STORAGE.getType(),mode);
}
@@ -317,16 +323,25 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
//申请空托盘入库
if (mode == 9 && move == 1 && !requireSucess){
if (container_type==0){
message = "universal_notCreateInstMessage7";
}
applyEmptyTask(StorageTypeEnum.DISKS_IN.getType(), mode);
}
//申请退货入库
if (mode == 18 && move == 1 && !requireSucess){
if (StrUtil.isEmpty(barcode)){
message = "universal_notCreateInstMessage8";
}
applyBoxReturnTask(StorageTypeEnum.BOX_RETURN.getType(), mode);
}
if (mode == 23 && !requireSucess){
if (StrUtil.isEmpty(barcode)||StrUtil.isEmpty(material_barcode)){
message = "universal_notCreateInstMessage8";
}
applyErrorHeight();
}

View File

@@ -302,7 +302,6 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
@Override
public void execute() throws Exception {
System.out.println("in"+ LocalDateTime.now() +"开始时间"+this.getDeviceCode());
try {
device_code = this.getDeviceCode();
heartbeat = this.itemProtocol.getItem_heartbeat();
@@ -544,7 +543,6 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
last_special1 = special1;
last_special2 = special2;
last_storage_cache = storage_cache;
System.out.println("out"+ LocalDateTime.now() +"结束时间"+this.getDeviceCode());
}
@@ -921,7 +919,9 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
//指令未执行
if (StrUtil.equals(inst.getInstruction_status(), "0")) {
String start_device_code = inst.getStart_device_code();
String next_device_code = inst.getNext_device_code();
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
BeltConveyorDeviceDriver beltConveyorDeviceDriver;
if (startDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) startDevice.getDeviceDriver();
@@ -931,6 +931,14 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
return false;
}
}
if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver();
if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() != 0) {
notCreateInstMessage = "未下发电气信号原因->输送线-货架对接位:" + beltConveyorDeviceDriver.getDevice_code() +
"无货或未联机,无法下发指令!指令号:" + inst.getInstruction_code();
return false;
}
}
List list = new ArrayList();
pakageCommand(list, "1", inst.getInstruction_code());
packagePlcCoordinate(startDevice, list);

View File

@@ -109,7 +109,6 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
@Override
public void subRun() throws Exception {
System.out.println("add 线程开始时间"+ LocalDateTime.now() + deviceDriver.getDeviceCode() );
deviceDriver.executeAuto();
}
@@ -123,7 +122,6 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
}
runnable.setIndex(this.runs);
this.executorService.submit(runnable);
System.out.println("run 线程开始时间"+ LocalDateTime.now() + deviceDriver.getDeviceCode() );
}
}

View File

@@ -147,8 +147,8 @@ public class CreateDDJInst {
StandardStackerDeviceDriver standardStackerDeviceDriver;
if (deviceByCode.getDeviceDriver() instanceof StandardStackerDeviceDriver) {
standardStackerDeviceDriver = (StandardStackerDeviceDriver) deviceByCode.getDeviceDriver();
if (standardStackerDeviceDriver.getMode() != 3 || standardStackerDeviceDriver.getForkCargo() == 1 || standardStackerDeviceDriver.getCommand() != 0) {
log.error("堆垛机,{}未联机或者在执行中", deviceByCode.getDevice_code());
if (standardStackerDeviceDriver.getMode() != 3 || standardStackerDeviceDriver.getForkCargo() == 1 || standardStackerDeviceDriver.getCommand() != 0 || standardStackerDeviceDriver.getError() != 0) {
log.error("堆垛机,{}未联机或者在执行中或者有异常", deviceByCode.getDevice_code());
((StandardStackerDeviceDriver) deviceByCode.getDeviceDriver()).setNotCreateInstMessage("堆垛机,{}未联机或者在执行中");
return;
}
@@ -208,6 +208,7 @@ public class CreateDDJInst {
return;
}
}
//单台堆垛机最多只能创建固定数量指令
Instruction instruction = new Instruction();
instruction.setInstruction_status(CommonFinalParam.ONE);