add 老车间包装线驱动

This commit is contained in:
USER-20220102CG\noblelift
2023-05-23 12:26:30 +08:00
parent b5aca2b6a8
commit 2eba078ddb
19 changed files with 562 additions and 470 deletions

View File

@@ -11,7 +11,7 @@ import java.util.LinkedList;
import java.util.List;
/**
* 开箱
* 刻字包装
*/
@Service
public class HailiangOldLetteringPackageDeviceDefination implements OpcDeviceDriverDefination {

View File

@@ -29,7 +29,7 @@ import java.util.List;
import java.util.Map;
/**
* 老车间-刻字包装输送线
* 老车间-刻字包装
*/
@Slf4j
@Data
@@ -76,10 +76,7 @@ public class HailiangOldLetteringPackageDeviceDriver extends AbstractOpcDeviceDr
try {
device_code = this.getDeviceCode();
mode = this.itemProtocol.getMode();
move = this.itemProtocol.getMove();
error = this.itemProtocol.getError();
task = this.itemProtocol.getTask();
barcode = this.itemProtocol.getBarcode();
if (mode != last_mode) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode + "复位请求标记");
@@ -96,9 +93,6 @@ public class HailiangOldLetteringPackageDeviceDriver extends AbstractOpcDeviceDr
logServer.deviceExecuteLog(this.device_code, "", "", "信号error" + last_error + "->" + error + "复位请求标记");
}
if (task != last_task) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号task" + last_task + "->" + task + "复位请求标记");
}
} catch (Exception var17) {
var17.printStackTrace();
@@ -117,12 +111,6 @@ public class HailiangOldLetteringPackageDeviceDriver extends AbstractOpcDeviceDr
Instruction instruction = null;
List toInstructions;
if(move == 1 && error == 0 && barcode.length() > 0){
}
}
@@ -150,27 +138,27 @@ public class HailiangOldLetteringPackageDeviceDriver extends AbstractOpcDeviceDr
}
@Override
public void issuedOrderInfo(ProduceshiftorderDto dto) {
EalingOrderDto ealingOrderDto = dto.getEalingOrderDto();
if (ealingOrderDto != null) {
String is_foreward = ealingOrderDto.getIs_foreward();
Map<String, Object> map = new HashMap<>();
map.put("to_clear", "1");
map.put("to_is_foreward", is_foreward);
map.put("to_order_box_num", ealingOrderDto.getOrder_box_num());
map.put("to_order", ealingOrderDto.getOrder_code());
map.put("to_qty", dto.getQty());
map.put("to_order", dto.getOrder_code());
map.put("item_to_bz_qty", dto.getPackage_qty());
map.put("item_to_box_qty", dto.getBox_num());
map.put("to_one_box_qty", dto.getOne_box_package_qty());
map.put("to_one_bag_qty", dto.getOne_package_qty());
map.put("to_one_box_qty", dto.getOne_box_package_qty());
this.writing(map);
}
}
@Override
public void issuedOrderFinish(String autoFinish) {
if (StrUtil.equals(autoFinish, WorkerOrderEnum.FORCEFINISH.getCode())) {
this.writing("to_order_compel_finished", "1");
} else {
this.writing("to_confirm_finished", "1");
}
}
@Override

View File

@@ -13,20 +13,32 @@ public class ItemProtocol {
public static String item_heartbeat = "heartbeat";
public static String item_mode = "mode";
public static String item_move = "move";
public static String item_action = "action";
public static String item_kz_mode = "kz_mode";
public static String item_ds_mode = "ds_mode";
public static String item_bz_mode = "bz_mode";
public static String item_kz_status = "kz_status";
public static String item_ds_status = "ds_status";
public static String item_bz_status = "bz_status";
public static String item_error = "error";
public static String item_direction = "direction";
public static String item_vehicle_type = "vehicle_type";
public static String item_task = "task";
public static String item_barcode = "barcode";
public static String item_to_command = "to_command";
public static String item_to_target = "to_target";
public static String item_to_vehicle_type = "to_vehicle_type";
public static String item_to_task = "to_task";
public static String item_kz_error = "kz_error";
public static String item_ds_error = "ds_error";
public static String item_bz_error = "bz_error";
public static String item_kz_qty = "kz_qty";
public static String item_ds_qty = "ds_qty";
public static String item_bz_qty = "bz_qty";
public static String item_order_finish = "order_finish";
public static String item_order_compulsion_finish = "order_compulsion_finish";
public static String item_order = "order";
public static String item_to_order_qty = "to_order_qty";
public static String item_to_bz_qty = "to_bz_qty";
public static String item_to_box_qty = "to_box_qty";
public static String item_to_one_box_qty = "to_one_box_qty";
public static String item_to_one_bag_qty = "to_one_bag_qty";
public static String item_to_finish = "to_finish";
public static String item_to_compulsion_finish = "to_compulsion_finish";
public static String item_to_order = "to_order";
public static String item_to_clear = "to_clear";
private HailiangOldLetteringPackageDeviceDriver driver;
@@ -43,45 +55,62 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_mode);
}
public int getMove() {
return this.getOpcIntegerValue(item_move);
public int getKz_mode() {
return this.getOpcIntegerValue(item_kz_mode);
}
public int getAction() {
return this.getOpcIntegerValue(item_action);
public int getDs_mode() {
return this.getOpcIntegerValue(item_ds_mode);
}
public String getBarcode() {
return this.getOpcStringValue(item_barcode);
public int getBz_mode() {
return this.getOpcIntegerValue(item_bz_mode);
}
public int getKz_status() {
return this.getOpcIntegerValue(item_kz_status);
}
public int getDs_status() {
return this.getOpcIntegerValue(item_ds_status);
}
public int getBz_status() {
return this.getOpcIntegerValue(item_bz_status);
}
public int getKz_qty() {
return this.getOpcIntegerValue(item_kz_qty);
}
public int getDs_qty() {
return this.getOpcIntegerValue(item_ds_qty);
}
public int getBz_qty() {
return this.getOpcIntegerValue(item_bz_qty);
}
public int getError() {
return this.getOpcIntegerValue(item_error);
}
public int getVehicle_type() {
return this.getOpcIntegerValue(item_vehicle_type);
public int getKz_error() {
return this.getOpcIntegerValue(item_kz_error);
}
public int getTask() {
return this.getOpcIntegerValue(item_task);
public int getDs_error() {
return this.getOpcIntegerValue(item_ds_error);
}
public int getToCommand() {
return this.getOpcIntegerValue(item_to_command);
public int getBz_error() {
return this.getOpcIntegerValue(item_bz_error);
}
public int getToTarget() {
return this.getOpcIntegerValue(item_to_target);
public int getOrder() {
return this.getOpcIntegerValue(item_order);
}
public int getToVehicle_type() {
return this.getOpcIntegerValue(item_to_vehicle_type);
}
public int getToTask() {
return this.getOpcIntegerValue(item_to_task);
}
//是否有货
public int hasGoods(int move) {
@@ -116,24 +145,38 @@ public class ItemProtocol {
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_heartbeat, "心跳", "VW0"));
list.add(new ItemDto(item_mode, "工作状态", "VW2", Boolean.valueOf(true)));
list.add(new ItemDto(item_move, "光电开关信号", "VW4"));
list.add(new ItemDto(item_action, "取放信号", "VW6"));
list.add(new ItemDto(item_direction, "电机方向", "VW8"));
list.add(new ItemDto(item_vehicle_type, "托盘类型", "VW10"));
list.add(new ItemDto(item_error, "报警信号", "VW12"));
list.add(new ItemDto(item_task, "任务号", "VD14"));
list.add(new ItemDto(item_barcode, "条码", "VB18.20"));
list.add(new ItemDto(item_heartbeat, "心跳", "DB600.W0"));
list.add(new ItemDto(item_mode, "工作模式", "DB600.W2", Boolean.valueOf(true)));
list.add(new ItemDto(item_kz_mode, "刻字机工作模式", "DB600.W4", Boolean.valueOf(true)));
list.add(new ItemDto(item_ds_mode, "点数机工作模式", "DB600.W6", Boolean.valueOf(true)));
list.add(new ItemDto(item_bz_mode, "包装机工作模式", "DB600.W8", Boolean.valueOf(true)));
list.add(new ItemDto(item_kz_status, "刻字机工作状态", "DB600.W10"));
list.add(new ItemDto(item_ds_status, "点数机工作状态", "DB600.W12"));
list.add(new ItemDto(item_bz_status, "包装机工作状态", "DB600.W14"));
list.add(new ItemDto(item_error, "报警信号", "DB600.W16"));
list.add(new ItemDto(item_kz_error, "刻字机报警信号", "DB600.W18"));
list.add(new ItemDto(item_ds_error, "点数机报警信号", "DB600.W20"));
list.add(new ItemDto(item_bz_error, "包装机报警信号", "DB600.W22"));
list.add(new ItemDto(item_kz_qty, "刻字数量", "DB600.W24"));
list.add(new ItemDto(item_ds_qty, "点数数量", "DB600.W26"));
list.add(new ItemDto(item_bz_qty, "包装数量", "DB600.W28"));
list.add(new ItemDto(item_order_finish, "工单完成", "DB600.W30"));
list.add(new ItemDto(item_order_compulsion_finish, "工单强制完成", "DB600.W32"));
list.add(new ItemDto(item_order, "工单号", "DB600.D34"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "下发作业命令", "VW2", Boolean.valueOf(true)));
list.add(new ItemDto(item_to_target, "下发目标站", "VW4"));
list.add(new ItemDto(item_to_vehicle_type, "下发托盘类型", "VW6"));
list.add(new ItemDto(item_to_task, "任务号", "VD8"));
list.add(new ItemDto(item_to_order_qty, "下发工单数量", "DB610.W2", Boolean.valueOf(true)));
list.add(new ItemDto(item_to_bz_qty, "下发包装袋数", "DB610.W4"));
list.add(new ItemDto(item_to_box_qty, "下发箱数", "DB610.W6"));
list.add(new ItemDto(item_to_one_box_qty, "下发每箱袋数", "DB610.W8"));
list.add(new ItemDto(item_to_one_bag_qty, "下发每袋数量", "DB610.W10"));
list.add(new ItemDto(item_to_finish, "下发工单完成反馈", "DB610.W12"));
list.add(new ItemDto(item_to_compulsion_finish, "下发工单强制完成反馈", "DB610.W14"));
list.add(new ItemDto(item_to_order, "下发工单号", "DB610.D16"));
list.add(new ItemDto(item_to_clear, "下发清零", "DB610.W20"));
return list;
}

View File

@@ -34,7 +34,7 @@ import java.util.Map;
@Slf4j
@Data
@RequiredArgsConstructor
public class HailiangOldPackageReceivingStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, IssuedDeviceOrderInfo {
public class HailiangOldPackageReceivingStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
@@ -162,36 +162,4 @@ public class HailiangOldPackageReceivingStationDeviceDriver extends AbstractOpcD
}
@Override
public void issuedOrderInfo(ProduceshiftorderDto dto) {
EalingOrderDto ealingOrderDto = dto.getEalingOrderDto();
if (ealingOrderDto != null) {
String is_foreward = ealingOrderDto.getIs_foreward();
Map<String, Object> map = new HashMap<>();
map.put("to_clear", "1");
map.put("to_is_foreward", is_foreward);
map.put("to_order_box_num", ealingOrderDto.getOrder_box_num());
map.put("to_order", ealingOrderDto.getOrder_code());
this.writing(map);
}
}
@Override
public void issuedOrderFinish(String autoFinish) {
if (StrUtil.equals(autoFinish, WorkerOrderEnum.FORCEFINISH.getCode())) {
this.writing("to_order_compel_finished", "1");
} else {
this.writing("to_confirm_finished", "1");
}
}
@Override
public void toStop() {
}
@Override
public void toStart() {
}
}

View File

@@ -92,8 +92,8 @@ public class HailiangLetteringPackageSsxDeviceDriver extends AbstractOpcDeviceDr
this.writing("to_command", "0");
this.writing("to_target", "0");
}
requireSucess =false;
}
if (error != last_error) {
if (error != 0) {
DeviceErrorLogDto dto = new DeviceErrorLogDto();
@@ -104,7 +104,6 @@ public class HailiangLetteringPackageSsxDeviceDriver extends AbstractOpcDeviceDr
}
logServer.deviceExecuteLog(this.device_code, "", "", "信号error" + last_error + "->" + error + "复位请求标记");
}
if (task != last_task) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号task" + last_task + "->" + task + "复位请求标记");
}
@@ -126,7 +125,7 @@ public class HailiangLetteringPackageSsxDeviceDriver extends AbstractOpcDeviceDr
Instruction instruction = null;
List toInstructions;
if(move == 1 && error == 0 && barcode.length() > 0){
if(move == 1 && error == 0 && barcode.length() > 0 && requireSucess == false ){
//2305281100001
if(barcode.trim().length() == 16){
if(isNumeric(barcode.trim())){
@@ -140,9 +139,10 @@ public class HailiangLetteringPackageSsxDeviceDriver extends AbstractOpcDeviceDr
int isFlip = Integer.parseInt(barcode.trim().substring(9,10));
int target = Integer.parseInt(barcode.trim().substring(10,11));
if(isFlip>0 && target>0){
this.writing("to_command", String.valueOf(isFlip));
this.writing("to_is_flip",String.valueOf(isFlip));
this.writing("to_target", String.valueOf(target));
this.writing("to_command","1");
requireSucess = true;
} else {
message = "条码:"+ barcode + ",是否翻转:"+isFlip + "目标巷道:"+target;
}
@@ -165,6 +165,7 @@ public class HailiangLetteringPackageSsxDeviceDriver extends AbstractOpcDeviceDr
last_move = move;
last_error = error;
last_task = task;
last_barcode = barcode;
}
@@ -172,8 +173,33 @@ public class HailiangLetteringPackageSsxDeviceDriver extends AbstractOpcDeviceDr
public JSONObject getDeviceStatusName() {
JSONObject jo = new JSONObject();
jo.put("device_name", this.getDevice().getDevice_name());
jo.put("mode", mode == 1 ? "联机" : "未联机");
jo.put("move", move == 1 ? "有货" : "无货");
String mode = "";
String action = "";
String move = "";
if (this.getMode() == 0) {
mode = "未联机";
} else if (this.getMode() == 1) {
mode = "单机";
} else if (this.getMode() == 2) {
mode = "联机";
} else if (this.getMode() == 3) {
mode = "运行中";
}
if (this.getMove() == 0) {
move = "无货";
jo.put("hasGoods", false);
} else if (this.getMove() == 1) {
move = "有货";
jo.put("hasGoods", true);
} else if (this.getMove() == 2) {
move = "有托盘有货";
jo.put("move", move);
jo.put("hasGoods", true);
}
jo.put("move", move);
jo.put("mode", mode);
jo.put("isOnline", this.getIsonline());
jo.put("isError", this.getIserror());
jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(error)));
jo.put("task", task);
jo.put("barcode", barcode);

View File

@@ -19,15 +19,17 @@ public class ItemProtocol {
public static String item_action = "action";
public static String item_error = "error";
public static String item_direction = "direction";
public static String item_vehicle_type = "vehicle_type";
public static String item_is_flip = "is_flip";
public static String item_task = "task";
public static String item_barcode = "barcode";
public static String item_to_command = "to_command";
public static String item_to_target = "to_target";
public static String item_to_vehicle_type = "to_vehicle_type";
public static String item_to_task = "to_task";
public static String item_to_is_flip = "to_is_flip";
public static String item_to_barcode = "to_barcode";
@@ -61,8 +63,8 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_error);
}
public int getVehicle_type() {
return this.getOpcIntegerValue(item_vehicle_type);
public int getIsflip() {
return this.getOpcIntegerValue(item_is_flip);
}
public int getTask() {
@@ -77,10 +79,6 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_to_target);
}
public int getToVehicle_type() {
return this.getOpcIntegerValue(item_to_vehicle_type);
}
public int getToTask() {
return this.getOpcIntegerValue(item_to_task);
}
@@ -123,7 +121,7 @@ public class ItemProtocol {
list.add(new ItemDto(item_move, "光电开关信号", "DB600.W4"));
list.add(new ItemDto(item_action, "取放信号", "DB600.W6"));
list.add(new ItemDto(item_direction, "电机方向", "DB600.W8"));
list.add(new ItemDto(item_vehicle_type, "托盘类型", "DB600.W10"));
list.add(new ItemDto(item_is_flip, "是否翻转", "DB600.W10"));
list.add(new ItemDto(item_error, "报警信号", "DB600.W12"));
list.add(new ItemDto(item_task, "任务号", "DB600.D14"));
list.add(new ItemDto(item_barcode, "条码", "DB600.STRING18.20"));
@@ -132,10 +130,11 @@ public class ItemProtocol {
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "下发作业命令", "DB601.W0", Boolean.valueOf(true)));
list.add(new ItemDto(item_to_target, "下发目标站", "DB601.W2"));
list.add(new ItemDto(item_to_vehicle_type, "下发托盘类型", "DB601.W4"));
list.add(new ItemDto(item_to_task, "任务号", "DB601.D6"));
list.add(new ItemDto(item_to_command, "下发作业命令", "DB610.W2", Boolean.valueOf(true)));
list.add(new ItemDto(item_to_target, "下发目标站", "DB610.W4"));
list.add(new ItemDto(item_to_is_flip, "下发是否翻转", "DB610.W6"));
list.add(new ItemDto(item_to_task, "下发任务号", "DB610.D8"));
list.add(new ItemDto(item_to_barcode, "下发条码", "DB610.STRING12.20"));
return list;
}

View File

@@ -12,6 +12,7 @@ import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
import org.nl.acs.history.ErrorUtil;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.log.service.DeviceExecuteLogService;
@@ -185,6 +186,34 @@ public class HailiangOldPalletizingStationDriver extends AbstractOpcDeviceDriver
@Override
public JSONObject getDeviceStatusName() {
JSONObject jo = new JSONObject();
jo.put("device_name", this.getDevice().getDevice_name());
String mode = "";
String action = "";
String move = "";
if (this.getMode() == 0) {
mode = "未联机";
} else if (this.getMode() == 1) {
mode = "单机";
} else if (this.getMode() == 2) {
mode = "联机";
} else if (this.getMode() == 3) {
mode = "运行中";
}
if (this.getMove() == 0) {
move = "无货";
jo.put("hasGoods", false);
} else if (this.getMove() == 1) {
move = "有货";
jo.put("hasGoods", true);
} else if (this.getMove() == 2) {
move = "有托盘有货";
jo.put("hasGoods", true);
}
jo.put("isOnline", this.getIsonline());
jo.put("isError", this.getIserror());
jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(error)));
jo.put("isOnline", this.itemProtocol.getIsonline());
jo.put("message", message);
return jo;
}

View File

@@ -1,5 +1,8 @@
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_stacking_manipulator;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
@@ -8,18 +11,25 @@ import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_package_ssx.HailiangLetteringPackageSsxDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_palletizing_station.HailiangOldPalletizingStationDriver;
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_auto_cache_line.HailiangAutoCacheLineDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
import org.nl.acs.history.ErrorUtil;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
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.modules.lucene.service.LuceneExecuteLogService;
import org.nl.modules.lucene.service.dto.LuceneLogDto;
import org.nl.modules.wql.util.SpringContextHolder;
import org.openscada.opc.lib.da.Server;
import org.springframework.beans.factory.annotation.Autowired;
@@ -52,6 +62,9 @@ public class HailiangOldStackingManipulatorDriver extends AbstractOpcDeviceDrive
ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.class);
@Autowired
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
@Autowired
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class);
//心跳
int heartbeat = 0;
int last_heartbeat = 0;
@@ -87,7 +100,7 @@ public class HailiangOldStackingManipulatorDriver extends AbstractOpcDeviceDrive
//请求码垛完成标志
Boolean stackingRequireSuccess = false;
JSONArray barcodeArr = new JSONArray();
//当前设备状态 01代表 关机, 02代表 开机, 03代表 生产中, 04代表 待机, 05代表 异常
int status_type = 0;
//上次设备状态
@@ -139,6 +152,9 @@ public class HailiangOldStackingManipulatorDriver extends AbstractOpcDeviceDrive
logServer.deviceExecuteLog(this.device_code, "", "", "信号status" + last_status + "->" + status);
}
if (action != last_action) {
vehicleInfoRequireSuccess = false;
singlePlacementRequireSuccess =false;
stackingRequireSuccess = false;
logServer.deviceItemValue(this.device_code, "action", String.valueOf(action));
logServer.deviceExecuteLog(this.device_code, "", "", "信号action" + last_action + "->" + action);
}
@@ -220,28 +236,92 @@ public class HailiangOldStackingManipulatorDriver extends AbstractOpcDeviceDrive
//根据kep读取到的抓取工位的值 - 1 得到对应设备的下标,再根据下标获得对应设备的编码
String getDeviceCode = getDeviceCodeList.get(getGetStation() - 1).replace("\"", "");
//根据抓取工位获取托盘信息
JSONObject map = new JSONObject();
map.put("getStation", getDeviceCode);
JSONObject resp = acsToWmsService.getVehicle(map);
int code = Integer.parseInt(resp.getString("code"));
String message = resp.getString("message");
String getStation = resp.getString("getStation");
String putStation = resp.getString("putStation");
String encoder_qty = resp.getString("encoder_qty");
String boxtype = resp.getString("boxtype");
if (code == 200) {
//根据获取托盘信息返回的结果 得到对应抓取工位/放货工位设备编码所在的索引位置
int getIndex = getDeviceCodeList.indexOf(getStation);
int putIndex = putDeviceCodeList.indexOf(putStation);
//将的到的索引 + 1 写入kep中
this.writing("to_getStation", String.valueOf(getIndex + 1));
// JSONObject map = new JSONObject();
// map.put("getStation", getDeviceCode);
// JSONObject resp = acsToWmsService.getVehicle(map);
// int code = Integer.parseInt(resp.getString("code"));
// String message = resp.getString("message");
// String getStation = resp.getString("getStation");
// String putStation = resp.getString("putStation");
// String encoder_qty = resp.getString("encoder_qty");
// String boxtype = resp.getString("boxtype");
// if (code == 200) {
// //根据获取托盘信息返回的结果 得到对应抓取工位/放货工位设备编码所在的索引位置
// int getIndex = getDeviceCodeList.indexOf(getStation);
// int putIndex = putDeviceCodeList.indexOf(putStation);
// //将的到的索引 + 1 写入kep中
// this.writing("to_getStation", String.valueOf(getIndex + 1));
// this.writing("to_putStation", String.valueOf(putIndex + 1));
// this.writing("to_boxtype", boxtype);
// this.writing("to_feedback", "1");
// //获取托盘信息成功后 设为true 防止多次请求 等单次防止完成时设为false
// this.setVehicleInfoRequireSuccess(true);
// } else {
// log.warn("获取托盘信息失败!设备号:{},原因{}", device_code, message);
// }
int getIndex = 0;
int putIndex = 0;
//获取取货位条码
Device getDevice = deviceAppservice.findDeviceByCode(getDeviceCode);
HailiangLetteringPackageSsxDeviceDriver hailiangLetteringPackageSsxDeviceDriver;
if(getDevice.getDeviceDriver() instanceof HailiangLetteringPackageSsxDeviceDriver ) {
hailiangLetteringPackageSsxDeviceDriver = (HailiangLetteringPackageSsxDeviceDriver) getDevice.getDeviceDriver();
String barcode = hailiangLetteringPackageSsxDeviceDriver.getBarcode();
if (Objects.isNull(barcode)) {
message = "获取托盘信息,取货位:" + getDeviceCode + "条码为空";
return false;
}
String order = barcode.trim().substring(0,9);
ProduceshiftorderDto dto =produceshiftorderService.findByCodeFromCache(order);
if(Objects.isNull(dto)){
message = "获取托盘信息,工单号:" + order + "未找到对应工单";
return false;
}
String boxType = dto.getBox_type();
String tray_full_num = dto.getTray_full_num();
String targetStation = null;
for(int i=0;i<putDeviceCodeList.size();i++){
Device device = deviceAppservice.findDeviceByCode(putDeviceCodeList.get(i));
HailiangOldPalletizingStationDriver hailiangOldPalletizingStationDriver;
if(device.getDeviceDriver() instanceof HailiangOldPalletizingStationDriver){
hailiangOldPalletizingStationDriver = (HailiangOldPalletizingStationDriver) device.getDeviceDriver();
if(hailiangOldPalletizingStationDriver.getMode() == 2 && hailiangOldPalletizingStationDriver.getMove()==1
&& StrUtil.equals(String.valueOf(hailiangOldPalletizingStationDriver.getBoxtype()),boxType)
&& hailiangOldPalletizingStationDriver.getNumber() < Integer.parseInt(tray_full_num) ){
targetStation = putDeviceCodeList.get(i);
putIndex = i;
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code,"单次码垛完成,取货位:"+getDeviceCode+",条码:"+barcode +",分配放货位:"+ putDeviceCodeList.get(i)));
break;
}
}
}
if(StrUtil.isEmpty(targetStation)){
for(int i=0;i<putDeviceCodeList.size();i++){
Device device = deviceAppservice.findDeviceByCode(putDeviceCodeList.get(i));
HailiangOldPalletizingStationDriver hailiangOldPalletizingStationDriver;
if(device.getDeviceDriver() instanceof HailiangOldPalletizingStationDriver){
hailiangOldPalletizingStationDriver = (HailiangOldPalletizingStationDriver) device.getDeviceDriver();
if(hailiangOldPalletizingStationDriver.getNumber() == 0 ){
targetStation = putDeviceCodeList.get(i);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code,"单次码垛完成,取货位:"+getDeviceCode+",条码:"+barcode +",未找到相同箱型放货位,分配空放货位:"+ putDeviceCodeList.get(i)));
putIndex = i;
break;
}
}
}
}
if(StrUtil.isEmpty(targetStation)){
message = "单次码垛完成,取货位["+getDeviceCode+"],条码["+barcode + "]未找到可放置的放货位";
return false;
}
this.writing("to_getStation", String.valueOf(this.getStation));
this.writing("to_putStation", String.valueOf(putIndex + 1));
this.writing("to_boxtype", boxtype);
this.writing("to_boxtype", boxType);
this.writing("to_feedback", "1");
//获取托盘信息成功后 设为true 防止多次请求 等单次防止完成时设为false
this.setVehicleInfoRequireSuccess(true);
} else {
log.warn("获取托盘信息失败!设备号:{},原因{}", device_code, message);
}
}
return true;
@@ -264,21 +344,38 @@ public class HailiangOldStackingManipulatorDriver extends AbstractOpcDeviceDrive
String getDeviceCode = getDeviceCodeList.get(getGetStation() - 1).replace("\"", "");
//根据kep读取到的放货工位的值 - 1 得到对应设备的下标,再根据下标获得对应设备的编码
String putDeviceCode = putDeviceCodeList.get(getPutStation() - 1).replace("\"", "");
JSONObject map = new JSONObject();
map.put("getStation", getDeviceCode);
map.put("putStation", putDeviceCode);
map.put("encoder_qty", getEncoder_qty());
map.put("boxtype", getBoxtype());
JSONObject resp = acsToWmsService.singlePlacementCompleted(map);
int code = Integer.parseInt(resp.getString("code"));
String message = resp.getString("message");
JSONObject data = resp.getJSONObject("data");
if (code == 200) {
this.writing("to_feedback", "2");
this.setSinglePlacementRequireSuccess(true);
} else {
log.warn("单次放置完成反馈失败!设备号:{},原因{}", device_code, message);
// JSONObject map = new JSONObject();
// map.put("getStation", getDeviceCode);
// map.put("putStation", putDeviceCode);
// map.put("encoder_qty", getEncoder_qty());
// map.put("boxtype", getBoxtype());
// JSONObject resp = acsToWmsService.singlePlacementCompleted(map);
// int code = Integer.parseInt(resp.getString("code"));
// String message = resp.getString("message");
// JSONObject data = resp.getJSONObject("data");
// if (code == 200) {
// this.writing("to_feedback", "2");
// this.setSinglePlacementRequireSuccess(true);
// } else {
// log.warn("单次放置完成反馈失败!设备号:{},原因{}", device_code, message);
// }
//暂时不反馈MES
Device getDevice = deviceAppservice.findDeviceByCode(getDeviceCode);
HailiangLetteringPackageSsxDeviceDriver hailiangLetteringPackageSsxDeviceDriver;
if(getDevice.getDeviceDriver() instanceof HailiangLetteringPackageSsxDeviceDriver ){
hailiangLetteringPackageSsxDeviceDriver = (HailiangLetteringPackageSsxDeviceDriver) getDevice.getDeviceDriver();
String barcode = hailiangLetteringPackageSsxDeviceDriver.getLast_barcode();
if(Objects.isNull(barcode)){
message = "单次码垛完成,取货位:"+getDeviceCode+"条码为空";
return false;
}
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code,"单次码垛完成,取货位:"+getDeviceCode+",条码:"+barcode));
barcodeArr.add(barcode);
}
this.writing("to_feedback", "2");
this.setSinglePlacementRequireSuccess(true);
}
return true;
}
@@ -297,9 +394,11 @@ public class HailiangOldStackingManipulatorDriver extends AbstractOpcDeviceDrive
//根据kep读取到的放货工位的值 - 1 得到对应设备的下标,再根据下标获得对应设备的编码
String putDeviceCode = putDeviceCodeList.get(getPutStation() - 1).replace("\"", "");
JSONObject map = new JSONObject();
map.put("putStation", putDeviceCode);
map.put("encoder_qty", getEncoder_qty());
map.put("boxtype", getBoxtype());
map.put("device_code", putDeviceCode);
map.put("encoder_qty", String.valueOf(getEncoder_qty()));
map.put("boxtype", String.valueOf(getBoxtype()));
map.put("barcodeArr",barcodeArr);
map.put("id", IdUtil.simpleUUID());
JSONObject resp = acsToWmsService.stackingCompleted(map);
int code = Integer.parseInt(resp.getString("code"));
String message = resp.getString("message");
@@ -340,7 +439,15 @@ public class HailiangOldStackingManipulatorDriver extends AbstractOpcDeviceDrive
@Override
public JSONObject getDeviceStatusName() {
return null;
JSONObject jo = new JSONObject();
jo.put("device_name", this.getDevice().getDevice_name());
jo.put("mode", mode == 1 ? "联机" : "未联机");
jo.put("action", action);
jo.put("error", ErrorUtil.getDictDetail("jxs_error_type", String.valueOf(error)));
jo.put("barcodeArr", barcodeArr);
jo.put("isOnline", this.itemProtocol.getIsonline());
jo.put("message", message);
return jo;
}
@Override

View File

@@ -34,7 +34,7 @@ import java.util.Map;
@Slf4j
@Data
@RequiredArgsConstructor
public class HailiangOldUnboxingMachineDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, IssuedDeviceOrderInfo {
public class HailiangOldUnboxingMachineDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
@@ -44,34 +44,22 @@ public class HailiangOldUnboxingMachineDeviceDriver extends AbstractOpcDeviceDri
int heartbeat = 0;
int mode = 0;
int unboxing_error = 0;
int unboxing_running = 0;
int unboxing_ready = 0;
int order_finish = 0;
int order_compel_finish = 0;
int qty = 0;
int one_qty = 0;
int two_qty = 0;
int three_qty = 0;
int four_qty = 0;
int five_qty = 0;
int one_status = 0;
int two_status = 0;
int three_status = 0;
int four_status = 0;
int five_status = 0;
int error = 0;
int now_order_num = 0;
int task = 0;
int open_ready_time = 0;
int device_running_time = 0;
int await_time = 0;
int order = 0;
int last_heartbeat = 0;
int last_mode = 0;
int last_unboxing_error = 0;
int last_unboxing_running = 0;
int last_unboxing_ready = 0;
int last_order_finish = 0;
int last_order_compel_finish = 0;
int last_error = 0;
int last_now_order_num = 0;
int last_task = 0;
int last_open_ready_time = 0;
int last_device_running_time = 0;
int last_await_time = 0;
int last_order = 0;
Boolean isonline = true;
String message = null;
@@ -95,6 +83,8 @@ public class HailiangOldUnboxingMachineDeviceDriver extends AbstractOpcDeviceDri
device_code = this.getDeviceCode();
mode = this.itemProtocol.getMode();
error = this.itemProtocol.getError();
qty = this.itemProtocol.getQty();
if (mode != last_mode) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode + "复位请求标记");
@@ -142,9 +132,19 @@ public class HailiangOldUnboxingMachineDeviceDriver extends AbstractOpcDeviceDri
jo.put("device_name", this.getDevice().getDevice_name());
jo.put("mode", mode == 1 ? "联机" : "未联机");
jo.put("error", ErrorUtil.getDictDetail("unbox_error_type", String.valueOf(error)));
jo.put("now_order_num", now_order_num);
jo.put("task", task);
jo.put("order", order);
jo.put("qty", qty);
jo.put("status", this.itemProtocol.getStatus()==1 ? "未知":"工作中");
jo.put("one_qty", this.itemProtocol.getOne_qty());
jo.put("two_qty", this.itemProtocol.getTwo_qty());
jo.put("three_qty", this.itemProtocol.getThree_qty());
jo.put("four_qty", this.itemProtocol.getFour_qty());
jo.put("five_qty", this.itemProtocol.getFive_qty());
jo.put("one_status", this.itemProtocol.getStatus());
jo.put("two_status", this.itemProtocol.getStatus());
jo.put("three_status", this.itemProtocol.getStatus());
jo.put("four_status", this.itemProtocol.getStatus());
jo.put("five_status", this.itemProtocol.getStatus());
jo.put("is_disable", this.itemProtocol.getIs_disable());
jo.put("isOnline", this.itemProtocol.getIsonline());
return jo;
}
@@ -154,36 +154,4 @@ public class HailiangOldUnboxingMachineDeviceDriver extends AbstractOpcDeviceDri
}
@Override
public void issuedOrderInfo(ProduceshiftorderDto dto) {
EalingOrderDto ealingOrderDto = dto.getEalingOrderDto();
if (ealingOrderDto != null) {
String is_foreward = ealingOrderDto.getIs_foreward();
Map<String, Object> map = new HashMap<>();
map.put("to_clear", "1");
map.put("to_is_foreward", is_foreward);
map.put("to_order_box_num", ealingOrderDto.getOrder_box_num());
map.put("to_order", ealingOrderDto.getOrder_code());
this.writing(map);
}
}
@Override
public void issuedOrderFinish(String autoFinish) {
if (StrUtil.equals(autoFinish, WorkerOrderEnum.FORCEFINISH.getCode())) {
this.writing("to_order_compel_finished", "1");
} else {
this.writing("to_confirm_finished", "1");
}
}
@Override
public void toStop() {
}
@Override
public void toStart() {
}
}

View File

@@ -41,6 +41,8 @@ public class ItemProtocol {
public static String item_four_status = "four_status";
//前往5巷道状态
public static String item_five_status = "five_status";
//是否禁用
public static String item_is_disable = "is_disable";
//前往1巷道状态
@@ -55,6 +57,9 @@ public class ItemProtocol {
public static String item_to_five_status = "to_five_status";
//清零
public static String item_to_clear = "to_clear";
//禁用
public static String item_to_is_disable = "to_is_disable";
private HailiangOldUnboxingMachineDeviceDriver driver;
@@ -122,6 +127,9 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_five_status);
};
public int getIs_disable() {
return this.getOpcIntegerValue(item_is_disable);
};
Boolean isonline;
@@ -155,17 +163,20 @@ public class ItemProtocol {
list.add(new ItemDto(item_three_status, "3号巷道状态", "DB600.W24"));
list.add(new ItemDto(item_four_status, "4号巷道状态", "DB600.W26"));
list.add(new ItemDto(item_five_status, "5号巷道状态", "DB600.W28"));
list.add(new ItemDto(item_is_disable, "是否禁用", "DB600.W30"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_one_status, "禁用1号巷道状态", "DB601.W2"));
list.add(new ItemDto(item_to_two_status, "禁用2号巷道状态", "DB600.W4"));
list.add(new ItemDto(item_to_three_status, "禁用3号巷道状态", "DB600.W6"));
list.add(new ItemDto(item_to_four_status, "禁用4号巷道状态", "DB600.W8"));
list.add(new ItemDto(item_to_five_status, "禁用5号巷道状态", "DB600.W10"));
list.add(new ItemDto(item_to_clear, "清零", "DB600.W12"));
list.add(new ItemDto(item_to_one_status, "禁用1号巷道状态", "DB610.W2"));
list.add(new ItemDto(item_to_two_status, "禁用2号巷道状态", "DB610.W4"));
list.add(new ItemDto(item_to_three_status, "禁用3号巷道状态", "DB610.W6"));
list.add(new ItemDto(item_to_four_status, "禁用4号巷道状态", "DB610.W8"));
list.add(new ItemDto(item_to_five_status, "禁用5号巷道状态", "DB610.W10"));
list.add(new ItemDto(item_to_clear, "下发清零", "DB610.W12"));
list.add(new ItemDto(item_to_is_disable, "下发禁用", "DB610.W14"));
return list;
}

View File

@@ -572,34 +572,34 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
@Override
public JSONObject stackingCompleted(JSONObject param) {
a = 20;
JSONObject map = new JSONObject();
map.put("code", 200);
map.put("message", "成功");
map.put("data", null);
return map;
// try {
// MDC.put(log_file_type, log_type);
// String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue();
// HttpResponse result = null;
// log.info("stackingCompleted-----码垛完成请求");
// AddressDto addressDto = addressService.findByCode("stackingCompleted");
// String methods_url = addressDto.getMethods_url();
// try {
// result = HttpRequest.get(wmsurl + methods_url)
// .body("")
// .execute();
// log.info("stackingCompleted-----码垛完成输出参数{}", result.body().toString());
// } catch (Exception e) {
// String msg = e.getMessage();
// //网络不通
// System.out.println(msg);
// }
// JSONObject jo = JSONObject.parseObject(result.body());
// return jo;
// } finally {
// MDC.remove(log_file_type);
// }
// a = 20;
// JSONObject map = new JSONObject();
// map.put("code", 200);
// map.put("message", "成功");
// map.put("data", null);
// return map;
try {
MDC.put(log_file_type, log_type);
String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue();
HttpResponse result = null;
log.info("stackingCompleted-----码垛完成请求");
AddressDto addressDto = addressService.findByCode("stackingCompleted");
String methods_url = addressDto.getMethods_url();
try {
result = HttpRequest.get(wmsurl + methods_url)
.body("")
.execute();
log.info("stackingCompleted-----码垛完成输出参数{}", result.body().toString());
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
System.out.println(msg);
}
JSONObject jo = JSONObject.parseObject(result.body());
return jo;
} finally {
MDC.remove(log_file_type);
}
}
}

View File

@@ -246,6 +246,28 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
String is_used_fxx = param.getString("is_used_fxx");
String ealing_device_code = param.getString("ealing_device_code");
String unboxing_device_code = param.getString("unboxing_device_code");
Map<String, Object> extra_map = param.getJSONObject("extra_map");
//老车间包装工单信息
//每箱袋数
String one_box_package_qty = extra_map.get("one_box_package_qty").toString();
//袋数
String package_qty = extra_map.get("package_qty").toString();
//每袋数量
String one_package_qty = extra_map.get("one_package_qty").toString();
//箱数
String box_num = extra_map.get("box_num").toString();
//箱型
String box_type = extra_map.get("box_type").toString();
//目标巷道
String target_roadway = extra_map.get("target_roadway").toString();
//是否翻转
String is_flip = extra_map.get("is_flip").toString();
//托盘满托数量
String tray_full_num = extra_map.get("tray_full_num").toString();
Map<String, Object> params = param.getJSONObject("params");
EalingOrderDto ealingOrderDto = null;
if (ObjectUtil.isNotEmpty(params)) {
@@ -317,6 +339,14 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
dto.setIs_used_fxx(is_used_fxx);
dto.setEaling_device_code(ealing_device_code);
dto.setUnboxing_device_code(unboxing_device_code);
dto.setOne_box_package_qty(one_box_package_qty);
dto.setOne_package_qty(one_package_qty);
dto.setPackage_qty(package_qty);
dto.setBox_num(box_num);
dto.setBox_type(box_type);
dto.setTarget_roadway(target_roadway);
dto.setIs_flip(is_flip);
dto.setTray_full_num(tray_full_num);
dto.setEalingOrderDto(ealingOrderDto);
dto.setCreate_by("mes");
try {

View File

@@ -135,4 +135,44 @@ public class ProduceshiftorderDto implements Serializable {
*/
private EalingOrderDto ealingOrderDto;
/**
* 每箱袋数
*/
private String one_box_package_qty;
/**
* 每袋数量
*/
private String one_package_qty;
/**
* 箱数
*/
private String box_num;
/**
* 箱型
*/
private String box_type;
/**
* 目标巷道
*/
private String target_roadway;
/**
* 是否翻转
*/
private String is_flip;
/**
* 托盘满托数量
*/
private String tray_full_num;
/**
* 袋数
*/
private String package_qty;
}

View File

@@ -82,4 +82,13 @@ public class LuceneLogDto {
+ last_home + " -> "
+ home;
}
public LuceneLogDto(final String device_code, final String remark) {
super();
this.device_code = device_code;
this.content = "设备 ["
+ device_code
+ "] : "
+ remark;
}
}