fix: 联调

This commit is contained in:
2024-05-31 17:17:48 +08:00
parent 7abf41f2f4
commit 7bc761a53b
13 changed files with 231 additions and 78 deletions

View File

@@ -173,7 +173,6 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
int to_height_level = 0;
int last_to_height_level = 0;
String barcode = null;
//子卷条码
@@ -240,7 +239,7 @@ 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) {
@@ -249,7 +248,10 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
clearWrite();
}
}
if (move != last_mode && move==0) {
requireSucess = false;
clearWrite();
}
if (move != 0 && task > 0) {
update_instruction_status();
@@ -281,7 +283,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
break;
case 2:
//申请任务
if (move == 1 && !requireSucess) {
if (move == 1 && !requireSucess) {
instruction_require();
} else {
String remark = "";
@@ -314,7 +316,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
//request_for_shipment(String.valueOf(mode), item_out_seq_arr, item_out_qty_arr);
}
break;
case 5:
case 19:
//申请AGV任务
if (move == 1 && !requireSucess) {
applyAgvTask();
@@ -415,20 +417,9 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
List list1 = new ArrayList();
Map map = new HashMap();
map.put("code", "to_command");
map.put("value", 8);
map.put("value", 19);
list1.add(map);
this.writing(list1);
List list = new ArrayList();
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".to_command").toString()
, "8")) {
this.writing(list);
logServer.deviceExecuteLog(device_code, "", "", "再次下发mode信号");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content("申请AGV任务,返回参数:" + jo.getString("body"))
@@ -437,7 +428,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
luceneExecuteLogService.deviceExecuteLog(logDto);
requireSucess = true;
} else {
message = "one_message17" + jo.get("message").toString();
message = "one_message17";
}
}
return;
@@ -445,7 +436,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
JSONObject apply = new JSONObject();
apply.put("device_code", device_code);
apply.put("vehicle_code", barcode);
apply.put("vehicle_code", material_barcode);
String str = acsToWmsService.applySendOutTwo(apply);
logServer.deviceExecuteLog(this.device_code, "", "", "申请AGV任务,请求参数:" + apply + ",响应参数");
@@ -460,23 +451,13 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
List list = new ArrayList();
Map map = new HashMap();
map.put("code", "to_command");
map.put("value", "8");
map.put("value", 19);
list.add(map);
this.writing(list);
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".to_command").toString()
, "8")) {
this.writing(list);
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发mode信号");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
logServer.deviceExecuteLog(this.device_code, "", "", "申请AGV任务,返回参数:" + jo);
requireSucess = true;
} else {
message = "one_message17" + jo.get("message").toString();
message = "one_message17";
}
}

View File

@@ -63,6 +63,11 @@ public class ItemProtocol {
*/
public static String item_to_target = "to_target";
/**
* 子卷条码
*/
public static String item_material_barcode = "material_barcode";
@@ -74,6 +79,10 @@ public class ItemProtocol {
this.driver = driver;
}
public String getMaterialBarcode() {
return this.getOpcStringValue(item_material_barcode);
}
public int getHeartbeat() {
return this.getOpcIntegerValue(item_heartbeat);
}
@@ -144,6 +153,7 @@ public class ItemProtocol {
public String getOpcStringValue(String protocol) {
String value = this.driver.getStringValue(protocol);
if (StrUtil.isBlank(value)) {
//throw new BusinessException("{} : {}", new Object[]{protocol, DeviceErrorProtocol.getMessage(10000)});
} else {
return value;
@@ -172,6 +182,7 @@ 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;
}
@@ -181,6 +192,7 @@ public class ItemProtocol {
list.add(new ItemDto(item_to_command, "下发命令", "DB102.W4"));
list.add(new ItemDto(item_to_task, "下发任务号", "DB102.D1"));
list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB102.B5"));
return list;
}

View File

@@ -206,6 +206,16 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol));
}
if (mode != last_mode) {
requireSucess = false;
if(mode == 2){
clearWrite();
}
}
if (move != last_mode && move==0) {
requireSucess = false;
clearWrite();
}
if (mode == 0) {
this.setIsonline(false);
@@ -276,6 +286,30 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i
last_to_height = to_height;
}
private void clearWrite() {
List list = new ArrayList<>();
Map map = new HashMap<>();
map.put("code","to_target");
map.put("value","0");
list.add(map);
Map map2 = new HashMap<>();
map2.put("code","to_task");
map2.put("value","0");
list.add(map2);
Map map3 = new HashMap<>();
map3.put("code","to_command");
map3.put("value","0");
list.add(map3);
Map map4 = new HashMap<>();
map4.put("code","to_container_type");
map4.put("value","0");
list.add(map4);
this.writing(list);
message=null;
vehicle_code=null;
}
public boolean exe_error() {
if (this.error == 0) {

View File

@@ -198,6 +198,17 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol));
}
if (mode != last_mode) {
requireSucess = false;
if(mode == 2){
clearWrite();
}
}
if (move != last_mode && move==0) {
requireSucess = false;
clearWrite();
}
if (mode == 0) {
this.setIsonline(false);
@@ -260,6 +271,30 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i
last_to_height = to_height;
}
private void clearWrite() {
List list = new ArrayList<>();
Map map = new HashMap<>();
map.put("code","to_target");
map.put("value","0");
list.add(map);
Map map2 = new HashMap<>();
map2.put("code","to_task");
map2.put("value","0");
list.add(map2);
Map map3 = new HashMap<>();
map3.put("code","to_command");
map3.put("value","0");
list.add(map3);
Map map4 = new HashMap<>();
map4.put("code","to_container_type");
map4.put("value","0");
list.add(map4);
this.writing(list);
message=null;
vehicle_code=null;
}
public boolean exe_error() {
if (this.error == 0) {

View File

@@ -122,9 +122,7 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr
int to_height = 0;
int last_to_height = 0;
//托盘条码
String barcode = null;
String last_barcode = null;
String material_barcode = null;
String last_material_barcode = null;
@@ -180,7 +178,7 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr
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();
@@ -188,7 +186,6 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr
to_task = this.itemProtocol.getTo_task();
heartbeat = this.itemProtocol.getHeartbeat();
material_barcode = this.itemProtocol.getMaterialBarCode();
barcode = this.itemProtocol.getBarcode();
if (mode != last_mode) {
JSONObject param = new JSONObject();
@@ -212,6 +209,17 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol));
}
if (mode != last_mode) {
requireSucess = false;
if(mode == 2){
clearWrite();
}
}
if (move != last_mode && move==0) {
requireSucess = false;
clearWrite();
}
if (mode == 0) {
this.setIsonline(false);
@@ -314,6 +322,29 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr
last_to_height = to_height;
}
private void clearWrite() {
List list = new ArrayList<>();
Map map = new HashMap<>();
map.put("code","to_target");
map.put("value","0");
list.add(map);
Map map2 = new HashMap<>();
map2.put("code","to_task");
map2.put("value","0");
list.add(map2);
Map map3 = new HashMap<>();
map3.put("code","to_command");
map3.put("value","0");
list.add(map3);
Map map4 = new HashMap<>();
map4.put("code","to_container_type");
map4.put("value","0");
list.add(map4);
this.writing(list);
message=null;
}
private void applyLaStrangulationAndLabeling(int mode) {
Date date = new Date();
if (date.getTime() - this.require_apply_strangulation_time.getTime() < (long) this.instruction_require_time_out) {
@@ -671,7 +702,6 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr
jo.put("isError", this.getIserror());
jo.put("message", LangProcess.msg(message));
jo.put("hand_barcode", hand_barcode);
jo.put("barcode", this.getMove() == 0 ? null : checkInst() == null ? barcode : checkInst().getVehicle_code());
jo.put("is_click", true);
jo.put("requireSucess", requireSucess);
jo.put("driver_type", "siemens_conveyor");

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";
/**
* 载具类型
@@ -48,10 +48,6 @@ public class ItemProtocol {
*/
public static String item_task = "task";
/**
* 托盘条码
*/
public static String item_barcode = "barcode";
/**
* 动作信号
@@ -152,8 +148,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() {
@@ -180,9 +176,6 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_action);
}
public String getBarcode() {
return this.getOpcStringValue(item_barcode);
}
Boolean isonline;
@@ -220,13 +213,12 @@ 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"));
list.add(new ItemDto(item_task, "任务号", "DB600.D8"));
list.add(new ItemDto(item_material_barcode, "物料条码", "DB81.STRING14.50"));
list.add(new ItemDto(item_barcode, "托盘条码", "DB602.STRING1.50"));
return list;
}

View File

@@ -185,7 +185,6 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements
qty = this.itemProtocol.getQty();
to_container_type = this.itemProtocol.getTo_container_type();
container_type = this.itemProtocol.getContainer_type();
barcode = this.itemProtocol.getBarcode();
carrier_direction = this.itemProtocol.getCarrier_direction();
if (mode != last_mode) {
JSONObject param = new JSONObject();
@@ -209,6 +208,18 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements
}
if (mode != last_mode) {
requireSucess = false;
if(mode == 2){
clearWrite();
}
}
if (move != last_mode && move==0) {
requireSucess = false;
clearWrite();
}
//托盘去扫码位
if (mode == 4) {
List list1 = new ArrayList();
@@ -298,6 +309,31 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements
last_carrier_direction = carrier_direction;
}
private void clearWrite() {
List list = new ArrayList<>();
Map map = new HashMap<>();
map.put("code","to_target");
map.put("value","0");
list.add(map);
Map map2 = new HashMap<>();
map2.put("code","to_task");
map2.put("value","0");
list.add(map2);
Map map3 = new HashMap<>();
map3.put("code","to_command");
map3.put("value","0");
list.add(map3);
Map map4 = new HashMap<>();
map4.put("code","to_container_type");
map4.put("value","0");
list.add(map4);
this.writing(list);
message=null;
vehicle_code=null;
}
/**
* 请求指令

View File

@@ -28,7 +28,7 @@ public class ItemProtocol {
//托盘类型
public static String item_container_type="container_type";
//托盘方向
public static String item_carrier_direction="carrier_direction";
public static String item_container_direction="container_direction";
//下发命令
public static String item_to_command = "to_command";
@@ -39,17 +39,11 @@ public class ItemProtocol {
//下发托盘类型
public static String item_to_container_type = "to_container_type";
/**
* 托盘条码
*/
public static String item_barcode = "barcode";
private FoldDiscSiteDeviceDriver driver;
public String getBarcode() {
return this.getOpcStringValue(item_barcode);
}
public ItemProtocol(FoldDiscSiteDeviceDriver driver){
this.driver=driver;
@@ -84,7 +78,7 @@ public class ItemProtocol {
}
public int getCarrier_direction(){
return this.getOpcIntegerValue(item_carrier_direction);
return this.getOpcIntegerValue(item_container_direction);
}
public int getTo_task() {
@@ -142,7 +136,6 @@ public class ItemProtocol {
list.add(new ItemDto(item_task, "任务号", "DB1.D6"));
list.add(new ItemDto(item_container_type, "托盘类型", "DB1.B7"));
list.add(new ItemDto(item_qty, "数量", "DB1.B8"));
list.add(new ItemDto(item_barcode, "托盘条码", "DB601.STRING1.50"));
return list;
}

View File

@@ -241,6 +241,17 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
}
if (mode != last_mode) {
requireSucess = false;
if(mode == 2){
clearWrite();
}
}
if (move != last_mode && move==0) {
requireSucess = false;
clearWrite();
}
if(move !=last_move){
if (ObjectUtil.isNotEmpty(inst)){
@@ -468,6 +479,31 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
}
}
public void clearWrite() {
List list = new ArrayList<>();
Map map = new HashMap<>();
map.put("code","to_target");
map.put("value","0");
list.add(map);
Map map2 = new HashMap<>();
map2.put("code","to_task");
map2.put("value","0");
list.add(map2);
Map map3 = new HashMap<>();
map3.put("code","to_command");
map3.put("value","0");
list.add(map3);
Map map4 = new HashMap<>();
map4.put("code","to_container_type");
map4.put("value","0");
list.add(map4);
this.writing(list);
message=null;
vehicle_code=null;
}
private void applyErrorTask() {
Date date = new Date();
if (date.getTime() - this.require_apply_strangulation_time.getTime()

View File

@@ -343,7 +343,7 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
Map<String, Object> map10 = new HashMap<>();
Map<String, Object> map11 = new HashMap<>();
try {
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instruction.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9,map10,map11);
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instruction.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9,map10,map11,instruction.getVehicle_code());
} catch (Exception e) {
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
+ instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code()
@@ -376,7 +376,7 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
BeltConveyorDeviceDriver beltConveyorDeviceDriver;
if (startDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) startDevice.getDeviceDriver();
if (beltConveyorDeviceDriver.getMove() != 1) {
if (beltConveyorDeviceDriver.getMove() != 1&&beltConveyorDeviceDriver.getMode() != 2) {
notCreateInstMessage = "universal_notCreateInstMessage2";
return false;
}
@@ -398,7 +398,8 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
.content(device_code+"创建指令时出现异常:" + e.getMessage())
.build();
logDto.setLog_level(2);
luceneExecuteLogService.deviceExecuteLog(logDto); return false;
luceneExecuteLogService.deviceExecuteLog(logDto);
return false;
}
//创建指令后修改任务状态
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
@@ -417,7 +418,7 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
Map<String, Object> map10 = new HashMap<>();
Map<String, Object> map11 = new HashMap<>();
try {
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9,map10, map11);
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9,map10, map11, taskDto.getVehicle_code());
} catch (Exception e) {
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
@@ -439,7 +440,7 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
private void pushPLC(Map<String, Object> map1, Map<String, Object> map2, String next_addr, Map<String, Object> map3, String start_addr, Map<String, Object> map4, String task, InteractionJsonDTO interactionJsonDTO, Map<String, Object> map5, Map<String, Object> map6, Map<String, Object> map7, Map<String, Object> map8, Map<String, Object> map9, Map<String, Object> map10, Map<String, Object> map11) {
private void pushPLC(Map<String, Object> map1, Map<String, Object> map2, String next_addr, Map<String, Object> map3, String start_addr, Map<String, Object> map4, String task, InteractionJsonDTO interactionJsonDTO, Map<String, Object> map5, Map<String, Object> map6, Map<String, Object> map7, Map<String, Object> map8, Map<String, Object> map9, Map<String, Object> map10, Map<String, Object> map11, String vehicleCode) {
List list = new ArrayList();
map1.put("code", "to_command");
@@ -485,9 +486,9 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
map10.put("value", interactionJsonDTO.getIsBinding());
list.add(map10);
}
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getIsBinding())) {
if (ObjectUtil.isNotEmpty(vehicleCode)) {
map11.put("code", "to_material");
map11.put("value", interactionJsonDTO.getBarcode());
map11.put("value", vehicleCode);
list.add(map11);
}
Map<String, Object> map12 = new HashMap<>();

View File

@@ -343,6 +343,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
jo.put("params", params);
jo.put("params2", params2);
jo.put("task_type", StrUtil.isEmpty(task_type) ? 1 : Integer.parseInt(task_type));
jo.put("route_plan_code", route_plan_code);
jo.put("paper_array", JSONUtil.toJsonStr(paper_array));
jo.put("truss_type", JSONUtil.toJsonStr(truss_type));
jo.put("empty_site", JSONUtil.toJsonStr(empty_site));

View File

@@ -149,7 +149,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
if (log.isWarnEnabled()) {
tag = Thread.currentThread().getName();
if (this.OpcServer != null) {
tag = tag + this.getOpcGroupID();
tag = tag + "," + this.getOpcGroupID();
}
}

View File

@@ -156,16 +156,7 @@ public class CreateDDJInst {
next_device_code = taskDto.getNext_device_code();
// nextDevice = appService.findDeviceByCode(next_device_code);
// BeltConveyorDeviceDriver beltConveyorDeviceDriver;
// if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
// beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver();
// if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 1) {
// log.error("输送机,{}未联机或执行中", next_device_code);
// ((BeltConveyorDeviceDriver) nextDevice.getDeviceDriver()).setNotCreateInstMessage("one_message7");
// return;
// }
// }
/**
* 开始平均分配
*/
@@ -206,6 +197,17 @@ public class CreateDDJInst {
} else {
next_point_code = next_device_code;
}
nextDevice = appService.findDeviceByCode(next_device_code);
BeltConveyorDeviceDriver beltConveyorDeviceDriver;
if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver();
if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 1) {
log.error("输送机,{}未联机或执行中", next_device_code);
((BeltConveyorDeviceDriver) nextDevice.getDeviceDriver()).setNotCreateInstMessage("one_message7");
return;
}
}
//单台堆垛机最多只能创建固定数量指令
Instruction instruction = new Instruction();
instruction.setInstruction_status(CommonFinalParam.ONE);