码垛机械手驱动更新

This commit is contained in:
loujf
2022-08-18 18:39:39 +08:00
parent a326fe39aa
commit 478c760ea3
5 changed files with 293 additions and 42 deletions

View File

@@ -217,12 +217,12 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
stageActorTab.update(map, "device_code = '" + device_code + "'");
log.debug("根据设备编码查询在缓存里面的舞台数据,并删除掉!");
JSONArray jsonArr = WQL.getWO("QStage_01").addParam("flag", "1").addParam("device_code", device_code).process().getResultJSONArray(0);
for (int i = 0; i < jsonArr.size(); i++) {
String stage_code = jsonArr.getJSONObject(i).getString("stage_code");
redisUtils.del("stage:mst:" + stage_code);
redisUtils.del("stage:dtl:" + stage_code);
}
// JSONArray jsonArr = WQL.getWO("QStage_01").addParam("flag", "1").addParam("device_code", device_code).process().getResultJSONArray(0);
// for (int i = 0; i < jsonArr.size(); i++) {
// String stage_code = jsonArr.getJSONObject(i).getString("stage_code");
// redisUtils.del("stage:mst:" + stage_code);
// redisUtils.del("stage:dtl:" + stage_code);
// }
log.debug("删除缓存里面的设备!");
Device deviceByCode = deviceAppService.findDeviceByCode(device_code);
List<Device> allDevice = deviceAppService.findAllDevice();

View File

@@ -24,16 +24,27 @@ public class ItemProtocol {
public static String item_barcode = "barcode";
public static String item_specifications = "specifications";
public static String item_batch = "batch";
public static String item_container_type = "container_type";
public static String item_AlongSide = "AlongSide";
public static String item_BshortSide = "BshortSide";
public static String item_Htrapezoidal = "Htrapezoidal";
public static String item_Wthickness = "Wthickness";
public static String item_status = "status";
public static String item_unqualified_qty = "unqualified_qty";
public static String item_encoder_qty = "encoder_qty";
public static String item_order_No = "order_No";
public static String item_order_qty = "order_qty";
public static String item_to_command = "to_command";
public static String item_to_target = "to_target";
public static String item_to_task = "to_task";
public static String item_to_barcode = "to_barcode";
public static String item_to_error = "to_error";
public static String item_to_allow_pallet_qty = "to_allow_pallet_qty";
public static String item_to_material_type = "to_material_type";
public static String item_to_material_code = "to_material_code";
public static String item_to_order_No = "to_order_No";
public static String item_to_product_code = "to_product_code";
public static String item_to_order_qty = "to_order_qty";
Boolean isonline;
@@ -92,10 +103,6 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_batch);
}
public int getContainer_type() {
return this.getOpcIntegerValue(item_container_type);
}
public int getAlongSide() {
return this.getOpcIntegerValue(item_AlongSide);
}
@@ -112,6 +119,26 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_Wthickness);
}
public int getStatus() {
return this.getOpcIntegerValue(item_status);
}
public int getEncoder_qty() {
return this.getOpcIntegerValue(item_encoder_qty);
}
public int getUnqualified_qty() {
return this.getOpcIntegerValue(item_unqualified_qty);
}
public int getOrder_qty() {
return this.getOpcIntegerValue(item_order_qty);
}
public String getOrder_No() {
return this.getOpcStringValue(item_order_No);
}
public int getToCommand() {
return this.getOpcIntegerValue(item_to_command);
}
@@ -128,6 +155,34 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_to_barcode);
}
public int getTo_error() {
return this.getOpcIntegerValue(item_to_error);
}
public int getTo_allow_pallet_qty() {
return this.getOpcIntegerValue(item_to_allow_pallet_qty);
}
public int getTo_material_type() {
return this.getOpcIntegerValue(item_to_material_type);
}
public int getTo_material_code() {
return this.getOpcIntegerValue(item_to_material_code);
}
public String getTo_order_No() {
return this.getOpcStringValue(item_to_order_No);
}
public int getTo_Product_code() {
return this.getOpcIntegerValue(item_to_product_code);
}
public int getTo_order_qty() {
return this.getOpcIntegerValue(item_to_order_qty);
}
//是否有货
public int hasGoods(int move) {
return move;
@@ -169,11 +224,15 @@ public class ItemProtocol {
list.add(new ItemDto(item_specifications, "规格", "DB112.S18"));
list.add(new ItemDto(item_material, "物料", "DB112.S274"));
list.add(new ItemDto(item_barcode, "条码", "DB112.S530"));
list.add(new ItemDto(item_container_type, "托盘类型", "DB112.B786"));
list.add(new ItemDto(item_AlongSide, "A长", "DB112.W788"));
list.add(new ItemDto(item_BshortSide, "B短边", "DB112.W790"));
list.add(new ItemDto(item_Htrapezoidal, "H梯形高", "DB112.W792"));
list.add(new ItemDto(item_Wthickness, "W厚度", "DB112.W794"));
list.add(new ItemDto(item_AlongSide, "A长边", "DB112.W786"));
list.add(new ItemDto(item_BshortSide, "B短", "DB112.W788"));
list.add(new ItemDto(item_Htrapezoidal, "H梯形高", "DB112.W790"));
list.add(new ItemDto(item_Wthickness, "W厚度", "DB112.W792"));
list.add(new ItemDto(item_status, "设备状态", "DB112.B795"));
list.add(new ItemDto(item_unqualified_qty, "不合格数量", "DB112.D796"));
list.add(new ItemDto(item_encoder_qty, "码盘位当前码盘数量", "DB112.D800"));
list.add(new ItemDto(item_order_qty, "当前工单数量", "DB112.D804"));
list.add(new ItemDto(item_order_No, "工单号", "DB112.S808"));
return list;
}
@@ -183,6 +242,13 @@ public class ItemProtocol {
list.add(new ItemDto(item_to_target, "目标站", "DB113.W2"));
list.add(new ItemDto(item_to_task, "任务号", "DB113.D4"));
list.add(new ItemDto(item_to_barcode, "条码", "DB113.S8"));
list.add(new ItemDto(item_to_error, "故障代码", "DB113.B265"));
list.add(new ItemDto(item_to_allow_pallet_qty, "允许码垛数量", "DB113.W266"));
list.add(new ItemDto(item_to_material_type, "托盘类型", "DB113.D268"));
list.add(new ItemDto(item_to_material_code, "下发物料编号", "DB113.D272"));
list.add(new ItemDto(item_to_order_qty, "下发工单数量", "DB113.D276"));
list.add(new ItemDto(item_to_product_code, "产品编号", "DB113.D280"));
list.add(new ItemDto(item_to_order_No, "工单号", "DB113.S284"));
return list;
}

View File

@@ -73,6 +73,11 @@ public class LnshPalletizingManipulatorSiteDefination implements OpcDeviceDriver
list.add(new ItemDto(ItemProtocol.item_BshortSide, "B短边", "DB112.W788"));
list.add(new ItemDto(ItemProtocol.item_Htrapezoidal, "H梯形高", "DB112.W790"));
list.add(new ItemDto(ItemProtocol.item_Wthickness, "W厚度", "DB112.W792"));
list.add(new ItemDto(ItemProtocol.item_status, "设备状态", "DB112.B795"));
list.add(new ItemDto(ItemProtocol.item_unqualified_qty, "不合格数量", "DB112.D796"));
list.add(new ItemDto(ItemProtocol.item_encoder_qty, "码盘位当前码盘数量", "DB112.D800"));
list.add(new ItemDto(ItemProtocol.item_order_qty, "当前工单数量", "DB112.D804"));
list.add(new ItemDto(ItemProtocol.item_order_No, "工单号", "DB112.S808"));
return list;
}

View File

@@ -19,16 +19,15 @@ import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.opc.Device;
import org.nl.acs.order.service.ProduceshiftorderService;
import org.nl.acs.order.service.dto.ProduceshiftorderDto;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.utils.SpringContextHolder;
import org.openscada.opc.lib.da.Server;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 嘉耐-码垛机械手工位
@@ -50,6 +49,9 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
@Autowired
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
@Autowired
ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean("produceshiftorderServiceImpl");
String device_code;
int mode = 0;
int error = 0;
@@ -116,6 +118,19 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
int batch = 0;
int last_batch = 0;
int status = 0;
int last_status = 0;
int unqualified_qty = 0;
int last_unqualified_qty = 0;
int encoder_qty = 0;
int last_encoder_qty = 0;
int order_qty = 0;
int last_order_qty = 0;
String order_No = "";
String last_order_No = "";
@Override
public Device getDevice() {
return this.device;
@@ -144,6 +159,11 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
BshortSide = this.itemProtocol.getBshortSide();
Htrapezoidal = this.itemProtocol.getHtrapezoidal();
Wthickness = this.itemProtocol.getWthickness();
order_qty = this.itemProtocol.getOrder_qty();
order_No = this.itemProtocol.getOrder_No();
encoder_qty = this.itemProtocol.getEncoder_qty();
status = this.itemProtocol.getStatus();
unqualified_qty = this.itemProtocol.getUnqualified_qty();
if (mode != last_mode) {
this.setRequireSucess(false);
@@ -206,6 +226,26 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
logServer.deviceItemValue(this.device_code,"Wthickness",String.valueOf(Wthickness));
logServer.deviceExecuteLog(this.device_code,"","","信号Wthickness: " + last_Wthickness + "->" + Wthickness);
}
if (status != last_status) {
logServer.deviceItemValue(this.device_code,"status" ,String.valueOf(status));
logServer.deviceExecuteLog(this.device_code,"","","信号status" + last_status + "->" + status);
}
if (encoder_qty != last_encoder_qty) {
logServer.deviceItemValue(this.device_code,"encoder_qty" ,String.valueOf(encoder_qty));
logServer.deviceExecuteLog(this.device_code,"","","信号encoder_qty" + last_encoder_qty + "->" + encoder_qty);
}
if (!StrUtil.equals(order_No,last_order_No)) {
logServer.deviceItemValue(this.device_code,"order_No", order_No);
logServer.deviceExecuteLog(this.device_code,"","","信号order_No" + last_order_No + "->" + order_No);
}
if (order_qty != last_order_qty) {
logServer.deviceItemValue(this.device_code,"order_qty" ,String.valueOf(order_qty));
logServer.deviceExecuteLog(this.device_code,"","","信号order_qty" + last_order_qty + "->" + order_qty);
}
if (unqualified_qty != last_unqualified_qty) {
logServer.deviceItemValue(this.device_code,"unqualified_qty" ,String.valueOf(unqualified_qty));
logServer.deviceExecuteLog(this.device_code,"","","信号unqualified_qty" + last_unqualified_qty + "->" + unqualified_qty);
}
} catch (Exception var17) {
return;
@@ -243,9 +283,15 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
case 2:
break;
case 4:
//叫料
if (!requireSucess && this.move == 0) {
callMaterial();
//排产单确认
if (!requireSucess && !order_No.equals("0")) {
JSONObject json = new JSONObject();
json.put("producetask_code",order_No);
json.put("device_code",this.device_code);
json.put("material_code",material);
json.put("qty",encoder_qty);
json.put("type","1");
enterProduction(json);
}
break;
case 5:
@@ -260,6 +306,30 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
putStorage();
}
break;
case 7:
//码垛完成
if (!requireSucess) {
palletizing();
}
break;
case 8:
//码垛强制完成
if (!requireSucess) {
mandatoryPalletizing();
}
break;
case 9:
//工单完成
if (!requireSucess && !order_No.equals("0")) {
JSONObject json = new JSONObject();
json.put("producetask_code",order_No);
json.put("device_code",this.device_code);
json.put("material_code",material);
json.put("qty",encoder_qty);
json.put("type","2");
enterProduction(json);
}
break;
}
@@ -290,6 +360,11 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
last_BshortSide = BshortSide;
last_Htrapezoidal = Htrapezoidal;
last_Wthickness = Wthickness;
last_order_No = order_No;
last_order_qty = order_qty;
last_encoder_qty = encoder_qty;
last_status = status;
last_unqualified_qty = unqualified_qty;
}
@@ -313,7 +388,7 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
if (ObjectUtil.isNotEmpty(result)) {
JSONObject jsonObject = JSONObject.parseObject(result.body());
if (result.getStatus() == 200 && StrUtil.equals(jsonObject.getString("status"),"200")) {
this.writing(1);
this.writing(this.mode);
this.setRequireSucess(true);
}
}
@@ -322,11 +397,42 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
}
/**
* 叫料
* 排产单确认
*
* @param
*/
public synchronized boolean callMaterial() {
public synchronized boolean enterProduction(JSONObject json) {
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 false;
} else {
this.instruction_require_time = date;
HttpResponse result = acsToWmsService.enterOrder(json);
if (ObjectUtil.isNotEmpty(result)) {
JSONObject jsonObject = JSONObject.parseObject(result.body());
if (result.getStatus() == 200 && StrUtil.equals(jsonObject.getString("status"),"200")) {
ProduceshiftorderDto dto = produceshiftorderService.findByCode(order_No);
if (this.mode == 4) {
dto.setOrder_status("1");
} else if (this.mode == 9) {
dto.setOrder_status("2");
}
produceshiftorderService.update(dto);
this.writing(this.mode);
this.setRequireSucess(true);
}
}
return true;
}
}
/**
* 码垛完成
*
* @param
*/
public synchronized boolean palletizing() {
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);
@@ -334,19 +440,60 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
} else {
this.instruction_require_time = date;
JSONObject json = new JSONObject();
String linkobj = (String)this.getDevice().getExtraValue().get("link_device_code");
String demosub = linkobj.substring(1,linkobj.length()-1);
String demoArray[] = demosub.split(",");
List<String> demoList = Arrays.asList(demoArray);
json.put("device_code",this.device_code);
json.put("type","2");
json.put("pcsn",batch);
json.put("vehicle_code",barcode);
json.put("is_full","0");
HttpResponse result = acsToWmsService.lnshApplyTaskToWms(json);
json.put("material_code",material);
json.put("qty",encoder_qty);
json.put("batch",batch);
json.put("producetask_code",order_No);
json.put("is_full","1");
HttpResponse result = acsToWmsService.applyTaskManipulatorToWms(json);
if (ObjectUtil.isNotEmpty(result)) {
JSONObject jsonObject = JSONObject.parseObject(result.body());
if (result.getStatus() == 200 && StrUtil.equals(jsonObject.getString("status"),"200")) {
this.writing(1);
this.writing(this.mode);
this.setRequireSucess(true);
}
}
return true;
}
}
/**
* 码垛强制完成
*
* @param
*/
public synchronized boolean mandatoryPalletizing() {
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 false;
} else {
this.instruction_require_time = date;
JSONObject json = new JSONObject();
String linkobj = (String)this.getDevice().getExtraValue().get("link_device_code");
String demosub = linkobj.substring(1,linkobj.length()-1);
String demoArray[] = demosub.split(",");
List<String> demoList = Arrays.asList(demoArray);
json.put("device_code",this.device_code);
json.put("material_code",material);
json.put("qty",encoder_qty);
json.put("batch",batch);
json.put("producetask_code",order_No);
json.put("is_full","1");
HttpResponse result = acsToWmsService.applyTaskManipulatorToWms(json);
if (ObjectUtil.isNotEmpty(result)) {
JSONObject jsonObject = JSONObject.parseObject(result.body());
if (result.getStatus() == 200 && StrUtil.equals(jsonObject.getString("status"),"200")) {
this.writing(this.mode);
this.setRequireSucess(true);
}
}
this.setRequireSucess(true);
return true;
}
}
@@ -373,9 +520,9 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
if (ObjectUtil.isNotEmpty(result)) {
JSONObject jsonObject = JSONObject.parseObject(result.body());
if (result.getStatus() == 200 && StrUtil.equals(jsonObject.getString("status"),"200")) {
this.writing(1);
this.writing(this.mode);
this.setRequireSucess(true);
}
this.setRequireSucess(true);
}
return true;
}