This commit is contained in:
2023-05-08 11:04:32 +08:00
29 changed files with 1151 additions and 731 deletions

View File

@@ -216,6 +216,7 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
e.printStackTrace();
}
if (standardAutodoorDeviceDriver.getOpen() == 1) {
log.info("下发开门信号值为:{},下发关门信号值为:{}", standardAutodoorDeviceDriver.getToOpen(), standardAutodoorDeviceDriver.getToClose());
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
}

View File

@@ -348,9 +348,9 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
jo.put("mode", mode);
jo.put("move", move);
jo.put("action", action);
jo.put("isOnline", this.getIsonline());
jo.put("error", this.getError());
jo.put("isError", this.getIserror());
// jo.put("isOnline", this.getIsonline());
// jo.put("error", this.getError());
// jo.put("isError", this.getIserror());
jo.put("task", this.getTask());
return jo;
}

View File

@@ -71,6 +71,22 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_task);
}
public int getTo_command() {
return this.getOpcIntegerValue(item_to_command);
}
public int getTo_target() {
return this.getOpcIntegerValue(item_to_target);
}
public int getTo_task() {
return this.getOpcIntegerValue(item_to_task);
}
public int getTo_onset() {
return this.getOpcIntegerValue(item_to_onset);
}
Boolean isonline;

View File

@@ -88,7 +88,17 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
int heartbeat = 0;
int last_heartbeat = 0;
int to_command = 0;
int last_to_command = 0;
int to_target = 0;
int last_to_target = 0;
int to_task = 0;
int last_to_task = 0;
int to_onset = 0;
int last_to_onset = 0;
Boolean isonline = true;
int hasGoods = 0;
@@ -137,9 +147,26 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
error = this.itemProtocol.getError();
task = this.itemProtocol.getTask();
heartbeat = this.itemProtocol.getHeartbeat();
to_command = this.itemProtocol.getTo_command();
to_target = this.itemProtocol.getTo_target();
to_task = this.itemProtocol.getTo_task();
to_onset = this.itemProtocol.getTo_onset();
// if(heartbeat != last_heartbeat){
// logServer.deviceExecuteLog(this.device_code, "", "", "heartbeat" + last_heartbeat + "->" + heartbeat);
// }
if (to_onset != last_to_onset) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_onset" + last_to_onset + "->" + to_onset);
}
if (to_command != last_to_command) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command" + last_to_command + "->" + to_command);
}
if (to_target != last_to_target) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target" + last_to_target + "->" + to_target);
}
if (to_task != last_to_task) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task" + last_to_task + "->" + to_task);
}
if (mode != last_mode) {
if (mode == 2) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号复位前requireSuccess" + requireSucess);
@@ -379,11 +406,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task));
if (inst2 != null) {
if (StrUtil.equals(inst2.getInstruction_status(), "1")) {
try {
finish_instruction(inst2);
} catch (Exception e) {
e.printStackTrace();
}
TaskDto taskDto = taskserver.findByCode(inst2.getTask_code());
String next_device_code = inst2.getNext_device_code();
@@ -430,18 +453,15 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
}
}
if (this.getNow_steps_type() == 5) {
this.writing("to_command", "5");
this.setNow_steps_type(6);
this.setNow_steps_type(0);
feedMessage = "";
} else {
//logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为放货完成now_steps_type=5");
try {
finish_instruction(inst2);
} catch (Exception e) {
e.printStackTrace();
}
// this.writing("to_onset", "0");
// this.writing("to_target", "0");
// this.writing("to_task", "0");
feedMessage = "";
}
}
} else {
@@ -527,6 +547,10 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
last_error = error;
last_task = task;
last_heartbeat = heartbeat;
last_to_task = to_task;
last_to_command = to_command;
last_to_target = to_target;
last_to_onset = to_onset;
}

View File

@@ -17,6 +17,7 @@ public class ItemProtocol {
public static String item_inventory_qty ="inventory_qty";
public static String item_out_finish = "out_finish";
public static String item_material = "material";
public static String item_error = "error";
public static String item_to_target = "to_target";
@@ -48,6 +49,10 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_out_finish);
}
public int getError() {
return this.getOpcIntegerValue(item_error);
}
public String getMaterial() {
return this.getOpcStringValue(item_material);
}
@@ -100,6 +105,7 @@ public class ItemProtocol {
list.add(new ItemDto(item_inventory_qty, "库存数量", "DB101.W4"));
list.add(new ItemDto(item_out_finish, "出库完成 ", "DB101.W6"));
list.add(new ItemDto(item_material, "物料", "DB101.STRING8.50"));
list.add(new ItemDto(item_error, "error", "DB101.W58"));
return list;
}

View File

@@ -1,5 +1,6 @@
package org.nl.acs.device_driver.basedriver.paper_tube_device;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
@@ -12,6 +13,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.log.service.DeviceExecuteLogService;
import org.nl.acs.monitor.DeviceStageMonitor;
@@ -63,6 +65,9 @@ public class PaperTubeConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
int mode = 0;
int inventory_qty =0;
int out_finish =0;
int error =0;
int to_command =0;
int to_target =0;
String material = null;
Boolean isonline = true;
@@ -75,6 +80,7 @@ public class PaperTubeConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
int last_mode = 0;
int last_inventory_qty =0;
int last_out_finish =0;
int last_error = 0;
String last_material = null;
String device_code;
@@ -97,25 +103,52 @@ public class PaperTubeConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
inventory_qty = this.itemProtocol.getInventory_qty();
out_finish =this.itemProtocol.getOut_finish();
material = this.itemProtocol.getMaterial();
error = this.itemProtocol.getError();
to_command = this.itemProtocol.getTo_command();
to_target = this.itemProtocol.getTotarget();
if (mode != last_mode) {
this.setRequireSucess(false);
}
if (mode == 0) {
this.setIsonline(false);
this.setIserror(true);
message = "未联机";
} else {
this.setIsonline(true);
this.setIserror(false);
}
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode);
}
if (inventory_qty != last_inventory_qty) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号inventory_qty" + last_inventory_qty + "->" + inventory_qty);
}
if (out_finish != last_out_finish) {
if(out_finish == 1){
this.writing(0);
this.writing("to_target","0");
this.writing("to_out_qty","0");
}
logServer.deviceExecuteLog(this.device_code, "", "", "信号out_finish" + last_out_finish + "->" + out_finish);
}
if (!StrUtil.equals(material,last_material)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号material" + last_material + "->" + material);
}
if (error != last_error) {
if(error > 0){
this.setIserror(true);
} else {
if(error > 0){
this.setIserror(false);
}
}
logServer.deviceExecuteLog(this.device_code, "", "", "信号out_finish" + last_out_finish + "->" + out_finish);
}
last_mode = mode;
last_inventory_qty = inventory_qty;
last_out_finish = out_finish;
last_error = error;
last_material = material;
}
@@ -155,9 +188,11 @@ public class PaperTubeConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
}
jo.put("device_name", this.getDevice().getDevice_name());
jo.put("mode", mode);
jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError())));
jo.put("inventory_qty", inventory_qty);
jo.put("out_finish", out_finish);
jo.put("material", material);
jo.put("isOnline", this.getIsonline());
return jo;
}

View File

@@ -77,6 +77,14 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_to_command);
}
public int getTo_target() {
return this.getOpcIntegerValue(item_to_target);
}
public int getTo_task() {
return this.getOpcIntegerValue(item_to_task);
}
Boolean isonline;

View File

@@ -103,6 +103,13 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
int agvphase = 0;
String task_code = null;
int to_command = 0;
int last_to_command = 0;
int to_target = 0;
int last_to_target = 0;
int to_task = 0;
int last_to_task = 0;
int phase = 0;
int index = 0;
@@ -111,6 +118,8 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
String message = null;
Boolean iserror = false;
String barcode = null;
Integer heartbeat_tag;
private Date instruction_require_time = new Date();
private Date require_apply_labeling_time = new Date();
@@ -121,10 +130,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
private int instruction_require_time_out = 3000;
//行架机械手申请任务成功标识
boolean requireSucess = false;
boolean requireApplyLabelingSuccess = false;
boolean requireApplyLaStrangulationSuccess = false;
boolean requireEmptyInSuccess = false;
boolean requireEmptyOutSuccess = false;
boolean requiresShipDeviceUpdate = true;
private int instruction_finished_time_out;
@@ -159,29 +165,43 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
error = this.itemProtocol.getError();
task = this.itemProtocol.getTask();
to_command = this.itemProtocol.getTo_command();
to_target = this.itemProtocol.getTo_target();
to_task = this.itemProtocol.getTo_task();
heartbeat = this.itemProtocol.getHeartbeat();
// if(heartbeat != last_heartbeat){
// logServer.deviceExecuteLog(this.device_code, "", "", "heartbeat" + last_heartbeat + "->" + heartbeat);
// }
if (to_command != last_to_command) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command" + last_to_command + "->" + to_command);
}
if (to_target != last_to_target) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target" + last_to_target + "->" + to_target);
}
if (to_task != last_to_task) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task" + last_to_task + "->" + to_task);
}
if (mode != last_mode) {
if (mode == 2) {
//Boolean flag = ObjectUtil.isEmpty(this.device.getExtraValue().get("special_flag")) ? false : Boolean.valueOf(this.device.getExtraValue().get("special_flag").toString());
//暂时这样写 后续通过配置判断
if (StrUtil.equals(this.device_code, "1018")) {
if (mode == 6 && last_mode == 2) {
requireSucess = false;
requireApplyLabelingSuccess = false;
requireApplyLaStrangulationSuccess = false;
requireEmptyInSuccess = false;
requireEmptyOutSuccess = false;
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode + "复位请求标记");
}
if (mode == 6) {
requireEmptyInSuccess = false;
}
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
} else {
requireSucess = false;
requireEmptyInSuccess = false;
}
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode + "复位请求标记:" + requireSucess);
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode);
}
if (move != last_move) {
message = null;
if (move == 0) {
inst_message = null;
this.barcode = null;
this.clearWrite();
}
if (move == 0 && last_move == 1) {
@@ -300,8 +320,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
case 5:
//申请贴标
if (move > 0 && !requireSucess) {
applyLabeling();
//applyLabeling();
}
break;
case 6:
@@ -340,6 +359,9 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
last_error = error;
last_task = task;
last_heartbeat = heartbeat;
last_to_task = to_task;
last_to_command = to_command;
last_to_target = to_target;
}
private void shipDeviceUpdate() {
@@ -494,6 +516,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError())));
jo.put("isError", this.getIserror());
jo.put("message", this.getMessage());
jo.put("barcode", barcode);
jo.put("is_click", true);
jo.put("requireSucess", requireSucess);
jo.put("driver_type", "siemens_conveyor");
@@ -508,6 +531,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
} else if (StrUtil.equals(requestSucess, "1")) {
this.requireSucess = true;
}
this.barcode = data.getString("barcode");
}
@Override
@@ -735,61 +759,6 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
}
}
//申请贴标
public synchronized void applyLabeling() {
Date date = new Date();
if (date.getTime() - this.require_apply_labeling_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return;
} else {
this.require_apply_labeling_time = date;
String vehicle_code = "";
if (task > 0) {
Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task));
vehicle_code = instruction.getVehicle_code();
} else {
logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备任务号:" + task + "异常");
message = "申请贴标电气设备任务号:" + task + "异常";
throw new RuntimeException("任务号为空!");
}
if (StrUtil.isEmpty(vehicle_code)) {
logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备任务号:" + task + "未找到载具号");
message = "申请贴标电气设备任务号:" + task + "未找到载具号";
throw new RuntimeException("载具号为空!");
}
ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest =
new ApplyLabelingAndBindingRequest();
JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + this.device_code + "'").uniqueResult(0);
String start_point_code = null;
if (!ObjectUtil.isEmpty(device_json)) {
start_point_code = (String) device_json.get("parent_storage_code") == null ? this.device_code : (String) device_json.get("parent_storage_code");
}
applyLabelingAndBindingRequest.setDevice_code(start_point_code);
applyLabelingAndBindingRequest.setType("1");
applyLabelingAndBindingRequest.setVehicle_code(vehicle_code);
logServer.deviceExecuteLog(this.device_code, "", "", "申请贴标,请求参数:" + applyLabelingAndBindingRequest);
ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
if (applyLabelingAndBindingResponse.getstatus() == 200) {
message = "申请贴标成功";
List list = new ArrayList();
Map map = new HashMap();
map.put("code", "to_command");
map.put("value", "5");
list.add(map);
this.writing(list);
this.writing(list);
message = "申请贴标下发电气信号成功";
requireApplyLabelingSuccess = true;
logServer.deviceExecuteLog(this.device_code, "", "", "申请贴标,返回参数:" + applyLabelingAndBindingResponse);
} else {
message = "申请贴标失败," + applyLabelingAndBindingResponse.getMessage();
logServer.deviceExecuteLog(this.device_code, "", "", "申请贴标,返回参数:" + applyLabelingAndBindingResponse);
}
}
}
//申请捆扎
@SneakyThrows
public synchronized void applyLaStrangulation(String mode) {
@@ -870,7 +839,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
// this.writing(list);
logServer.deviceExecuteLog(this.device_code, "", "", "申请捆扎,返回参数:" + applyLabelingAndBindingResponse);
message = "申请捆扎成功";
requireSucess = true;
//requireSucess = true;
} else {
message = "未返回尺寸信息";
logServer.deviceExecuteLog(this.device_code, "", "", "申请捆扎,返回参数:" + applyLabelingAndBindingResponse);
@@ -931,6 +900,34 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
} else {
this.instruction_require_time = date;
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
//判断是否有手动补码 如果有就申请补码agv任务
if (StrUtil.isNotEmpty(barcode)) {
message = "申请补码AGV搬运任务中...";
JSONObject apply = new JSONObject();
apply.put("device_code", device_code);
apply.put("type", "4");
apply.put("vehicle_code", barcode);
String str = acsToWmsService.applyTaskToWms(apply);
logServer.deviceExecuteLog(this.device_code, "", "", "申请AGV任务,请求参数:" + apply + ",响应参数," + str);
JSONObject jo = JSON.parseObject(str);
if (ObjectUtil.isEmpty(jo)) {
message = "申请补码AGV搬运任务接口不通";
// requireSucess = true;
} else {
if (jo.getInteger("status") == 200) {
message = "申请补码AGV搬运任务成功";
logServer.deviceExecuteLog(this.device_code, "", "", "申请补码AGV任务,返回参数:" + jo);
requireSucess = true;
} else {
// requireSucess = true;
message = "申请补码AGV搬运任务失败," + jo.get("message").toString();
}
}
return;
}
//没有就正常申请agv任务
Instruction instruction = instructionService.findByCode(String.valueOf(task));
if (ObjectUtil.isEmpty(instruction)) {
message = "指令号" + task + "未找到对应指令";
@@ -940,6 +937,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
message = "指令号" + task + "未找到对应木箱号";
return;
}
message = "申请AGV搬运任务中...";
JSONObject apply = new JSONObject();
apply.put("device_code", device_code);
@@ -947,7 +945,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
apply.put("vehicle_code", instruction.getVehicle_code());
String str = acsToWmsService.applyTaskToWms(apply);
logServer.deviceExecuteLog(this.device_code, "", "", "申请AGV任务,请求参数:" + apply);
logServer.deviceExecuteLog(this.device_code, "", "", "申请AGV任务,请求参数:" + apply + ",响应参数");
JSONObject jo = JSON.parseObject(str);
if (ObjectUtil.isEmpty(jo)) {

View File

@@ -73,6 +73,17 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_task);
}
public int getTo_command() {
return this.getOpcIntegerValue(item_to_command);
}
public int getTo_target() {
return this.getOpcIntegerValue(item_to_target);
}
public int getTo_task() {
return this.getOpcIntegerValue(item_to_task);
}
Boolean isonline;

View File

@@ -103,6 +103,7 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
int hasGoods = 0;
String message = null;
Boolean iserror = false;
String barcode = null;
Integer heartbeat_tag;
private Date instruction_require_time = new Date();
@@ -124,7 +125,14 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
int branchProtocol = 0;
String inst_message;
String last_inst_message;
int to_command = 0;
int last_to_command = 0;
int to_target = 0;
int last_to_target = 0;
int to_task = 0;
int last_to_task = 0;
//当前指令
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
@@ -151,9 +159,21 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
error = this.itemProtocol.getError();
task = this.itemProtocol.getTask();
heartbeat = this.itemProtocol.getHeartbeat();
to_command = this.itemProtocol.getTo_command();
to_target = this.itemProtocol.getTo_target();
to_task = this.itemProtocol.getTo_task();
// if(heartbeat != last_heartbeat){
// logServer.deviceExecuteLog(this.device_code, "", "", "heartbeat" + last_heartbeat + "->" + heartbeat);
// }
if (to_command != last_to_command) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command" + last_to_command + "->" + to_command);
}
if (to_target != last_to_target) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target" + last_to_target + "->" + to_target);
}
if (to_task != last_to_task) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task" + last_to_task + "->" + to_task);
}
if (mode != last_mode) {
if (mode == 2) {
requireSucess = false;
@@ -170,6 +190,7 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
message = null;
if (move == 0) {
inst_message = null;
barcode = null;
requireSucess = false;
this.clearWrite();
}
@@ -282,6 +303,9 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
last_error = error;
last_task = task;
last_heartbeat = heartbeat;
last_to_task = to_task;
last_to_command = to_command;
last_to_target = to_target;
}
private void shipDeviceUpdate() {
@@ -437,8 +461,7 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
jo.put("task", task);
jo.put("last_task", last_task);
jo.put("task_code", task_code);
// jo.put("barcode", barcode);
jo.put("barcode", barcode);
// jo.put("last_task", last_task);
jo.put("inst_message", this.inst_message);
jo.put("last_inst_message", this.last_inst_message);
@@ -448,7 +471,7 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
jo.put("message", this.getMessage());
jo.put("is_click", true);
jo.put("requireSucess", requireSucess);
jo.put("driver_type", "siemens_conveyor");
jo.put("driver_type", "siemens_conveyor_ckk");
return jo;
}
@@ -460,6 +483,8 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
} else if (StrUtil.equals(requestSucess, "1")) {
this.requireSucess = true;
}
String barcode = data.getString("barcode");
this.setBarcode(barcode);
}
@Override
@@ -503,6 +528,68 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
return false;
} else {
this.instruction_require_time = date;
if (!StrUtil.isEmpty(barcode) && task == 0) {
Instruction inst = instructionService.findByBarcodeFromCache(barcode);
if (ObjectUtil.isEmpty(inst)) {
TaskDto taskDto = taskserver.findByContainer(barcode);
if (ObjectUtil.isEmpty(taskDto)) {
message = "未找到手动补码:" + barcode + "对应立库指令,请检查";
return false;
}
String next_device_code = taskDto.getNext_device_code();
Instruction instdto = new Instruction();
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setRoute_plan_code(taskDto.getRoute_plan_code());
instdto.setRemark(taskDto.getRemark());
instdto.setMaterial(taskDto.getMaterial());
instdto.setQuantity(taskDto.getQuantity());
instdto.setTask_id(taskDto.getTask_id());
instdto.setTask_code(taskDto.getTask_code());
instdto.setVehicle_code(barcode);
String now = DateUtil.now();
instdto.setCreate_time(now);
instdto.setCreate_by("auto");
instdto.setStart_device_code(this.device.getDevice_code());
instdto.setNext_device_code(taskDto.getNext_device_code());
instdto.setStart_point_code(this.device.getDevice_code());
instdto.setNext_point_code(taskDto.getNext_device_code());
instdto.setPriority(taskDto.getPriority());
instdto.setInstruction_status("0");
instdto.setExecute_device_code(this.device.getDevice_code());
try {
instructionService.create(instdto);
} catch (Exception e) {
e.printStackTrace();
log.error("指令创建失败!", e.getMessage());
return false;
}
Device nextdevice = deviceAppservice.findDeviceByCode(taskDto.getNext_device_code());
requireSucess = true;
String next_addr = nextdevice.getExtraValue().get("address").toString();
List list = new ArrayList();
Map map = new HashMap();
map.put("code", "to_target");
map.put("value", next_addr);
list.add(map);
Map map2 = new HashMap();
map2.put("code", "to_task");
map2.put("value", instdto.getInstruction_code());
list.add(map2);
Map map3 = new HashMap();
map3.put("code", "to_command");
map3.put("value", "1");
list.add(map3);
this.writing(list);
return true;
}
try {
instructionService.finish(inst);
} catch (Exception e) {
e.printStackTrace();
}
logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务手动补码完成指令成功,指令号:" + inst.getInstruction_code());
} else {
if (task > 0) {
Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task));
if (ObjectUtil.isEmpty(instruction)) {
@@ -527,6 +614,7 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
message = "申请输送任务电气设备任务号:" + task + "异常";
return false;
}
}
//判断是否存在起点相同 任务状态就绪的任务
TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code);
@@ -708,239 +796,5 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
}
}
//申请贴标
public synchronized void applyLabeling() {
Date date = new Date();
if (date.getTime() - this.require_apply_labeling_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return;
} else {
this.require_apply_labeling_time = date;
String vehicle_code = "";
if (task > 0) {
Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task));
vehicle_code = instruction.getVehicle_code();
} else {
logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备任务号:" + task + "异常");
message = "申请贴标电气设备任务号:" + task + "异常";
throw new RuntimeException("任务号为空!");
}
if (StrUtil.isEmpty(vehicle_code)) {
logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备任务号:" + task + "未找到载具号");
message = "申请贴标电气设备任务号:" + task + "未找到载具号";
throw new RuntimeException("载具号为空!");
}
ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest =
new ApplyLabelingAndBindingRequest();
JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + this.device_code + "'").uniqueResult(0);
String start_point_code = null;
if (!ObjectUtil.isEmpty(device_json)) {
start_point_code = (String) device_json.get("parent_storage_code") == null ? this.device_code : (String) device_json.get("parent_storage_code");
}
applyLabelingAndBindingRequest.setDevice_code(start_point_code);
applyLabelingAndBindingRequest.setType("1");
applyLabelingAndBindingRequest.setVehicle_code(vehicle_code);
ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
if (applyLabelingAndBindingResponse.getstatus() == 200) {
message = "申请贴标成功";
List list = new ArrayList();
Map map = new HashMap();
map.put("code", "to_command");
map.put("value", "5");
list.add(map);
this.writing(list);
this.writing(list);
message = "申请贴标下发电气信号成功";
requireApplyLabelingSuccess = true;
} else {
message = "申请贴标失败," + applyLabelingAndBindingResponse.getMessage();
}
}
}
//申请捆扎
@SneakyThrows
public synchronized void applyLaStrangulation() {
Date date = new Date();
if (date.getTime() - this.require_apply_strangulation_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return;
} else {
this.require_apply_strangulation_time = date;
String vehicle_code = "";
if (task > 0) {
Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task));
if (ObjectUtil.isEmpty(instruction)) {
message = "申请捆扎电气设备任务号:" + task + "未找到对应指令";
throw new RuntimeException("该电气任务号未找到对应指令!");
}
vehicle_code = instruction.getVehicle_code();
} else {
logServer.deviceExecuteLog(device_code, "", "", "申请捆扎电气设备任务号:" + task + "异常");
message = "申请捆扎电气设备任务号:" + task + "异常";
throw new RuntimeException("任务号为空!");
}
if (StrUtil.isEmpty(vehicle_code)) {
logServer.deviceExecuteLog(device_code, "", "", "申请捆扎电气设备任务号:" + task + "未找到载具号");
message = "申请捆扎电气设备任务号:" + task + "未找到载具号";
throw new RuntimeException("载具号为空!");
}
ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest =
new ApplyLabelingAndBindingRequest();
JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + this.device_code + "'").uniqueResult(0);
String start_point_code = null;
if (!ObjectUtil.isEmpty(device_json)) {
start_point_code = (String) device_json.get("parent_storage_code") == null ? this.device_code : (String) device_json.get("parent_storage_code");
}
applyLabelingAndBindingRequest.setDevice_code(start_point_code);
applyLabelingAndBindingRequest.setType("2");
applyLabelingAndBindingRequest.setVehicle_code(vehicle_code);
ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
if (applyLabelingAndBindingResponse.getstatus() == 200) {
if (ObjectUtil.isNotEmpty(applyLabelingAndBindingResponse.getData())) {
Map datas = applyLabelingAndBindingResponse.getData();
String length = datas.get("box_length").toString();
String width = datas.get("box_width").toString();
String box_high = datas.get("box_high").toString();
String bundle_times = datas.get("bundle_times").toString();
List list = new ArrayList();
Map map = new HashMap();
map.put("code", "to_length");
map.put("value", length);
list.add(map);
Map map2 = new HashMap();
map2.put("code", "to_weight");
map2.put("value", width);
list.add(map2);
Map map3 = new HashMap();
map3.put("code", "to_height");
map3.put("value", box_high);
list.add(map3);
Map map4 = new HashMap();
map4.put("code", "to_strap_times");
map4.put("value", bundle_times);
list.add(map4);
Map map5 = new HashMap();
map5.put("code", "to_command");
map5.put("value", "4");
list.add(map5);
this.writing(list);
// this.writing(list);
message = "申请捆扎成功";
requireSucess = true;
} else {
message = "未返回尺寸信息";
}
} else {
message = applyLabelingAndBindingResponse.getMessage();
}
}
}
public synchronized void emptyIn() {
Date date = new Date();
if (date.getTime() - this.require_empty_in_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return;
} else {
this.require_empty_in_time = date;
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
message = "申请空盘入库任务中...";
JSONObject apply = new JSONObject();
apply.put("device_code", device_code);
apply.put("type", "2");
String str = acsToWmsService.applyTaskToWms(apply);
JSONObject jo = JSON.parseObject(str);
if (ObjectUtil.isEmpty(jo)) {
message = "申请空盘入库接口不通";
requireEmptyInSuccess = true;
} else {
if (jo.getInteger("status") == 200) {
message = "申请空盘入库成功";
requireEmptyInSuccess = true;
} else {
requireEmptyInSuccess = true;
message = "申请空盘入库失败," + jo.get("message").toString();
}
}
}
}
}
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 {
this.instruction_require_time = date;
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
Instruction instruction = instructionService.findByCode(String.valueOf(task));
if (ObjectUtil.isEmpty(instruction)) {
message = "指令号" + task + "未找到对应指令";
return;
}
message = "申请AGV搬运任务中...";
JSONObject apply = new JSONObject();
apply.put("device_code", device_code);
apply.put("type", "4");
apply.put("vehicle_code", instruction.getVehicle_code());
String str = acsToWmsService.applyTaskToWms(apply);
JSONObject jo = JSON.parseObject(str);
if (ObjectUtil.isEmpty(jo)) {
message = "申请AGV搬运任务接口不通";
requireSucess = true;
} else {
if (jo.getInteger("status") == 200) {
message = "申请AGV搬运任务成功";
requireSucess = true;
} else {
requireSucess = true;
message = "申请AGV搬运任务失败," + jo.get("message").toString();
}
}
}
}
}
public synchronized void emptyOut() {
Date date = new Date();
if (date.getTime() - this.require_empty_out_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return;
} else {
this.require_empty_out_time = date;
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
message = "申请空盘出库任务中...";
JSONObject apply = new JSONObject();
apply.put("device_code", device_code);
apply.put("type", "3");
String str = acsToWmsService.applyTaskToWms(apply);
JSONObject jo = JSON.parseObject(str);
if (ObjectUtil.isEmpty(jo)) {
message = "申请空盘出库接口不通";
// requireSucess = true;
} else {
if (jo.getInteger("status") == 200) {
message = "申请空盘出库成功";
requireSucess = true;
} else {
// requireSucess = true;
message = "申请空盘出库失败," + jo.get("message").toString();
}
}
}
}
}
}

View File

@@ -77,6 +77,14 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_to_command);
}
public int getTo_target() {
return this.getOpcIntegerValue(item_to_target);
}
public int getTo_task() {
return this.getOpcIntegerValue(item_to_task);
}
Boolean isonline;

View File

@@ -97,6 +97,13 @@ public class SiemensOneFloorAGVConveyorDeviceDriver extends AbstractOpcDeviceDri
int agvphase = 0;
String task_code = null;
int to_command = 0;
int last_to_command = 0;
int to_target = 0;
int last_to_target = 0;
int to_task = 0;
int last_to_task = 0;
private String error_type = "ssx_error_type";
int phase = 0;
int index = 0;
@@ -152,6 +159,17 @@ public class SiemensOneFloorAGVConveyorDeviceDriver extends AbstractOpcDeviceDri
error = this.itemProtocol.getError();
task = this.itemProtocol.getTask();
to_command = this.itemProtocol.getTo_command();
to_target = this.itemProtocol.getTo_target();
to_task = this.itemProtocol.getTo_task();
if (to_command != last_to_command) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command" + last_to_command + "->" + to_command);
}
if (to_target != last_to_target) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target" + last_to_target + "->" + to_target);
}
if (to_task != last_to_task) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task" + last_to_task + "->" + to_task);
}
if (error != last_error) {
if (error != 0) {
DeviceErrorLogDto dto = new DeviceErrorLogDto();
@@ -185,6 +203,9 @@ public class SiemensOneFloorAGVConveyorDeviceDriver extends AbstractOpcDeviceDri
last_carrier_direction = carrier_direction;
last_error = error;
last_task = task;
last_to_task = to_task;
last_to_command = to_command;
last_to_target = to_target;
}

View File

@@ -128,6 +128,22 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_to_task2);
}
public int getTo_target1() {
return this.getOpcIntegerValue(item_to_target1);
}
public int getTo_target2() {
return this.getOpcIntegerValue(item_to_target2);
}
public int getTo_onset1() {
return this.getOpcIntegerValue(item_to_onset1);
}
public int getTo_onset2() {
return this.getOpcIntegerValue(item_to_onset2);
}
//是否有货
public int hasGoods(int move) {

View File

@@ -101,9 +101,22 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
int task2 = 0;
int last_task2 = 0;
int to_command1 = 0;
int last_to_command1 = 0;
int to_command2 = 0;
int last_to_command2 = 0;
int to_task1 = 0;
int last_to_task1 = 0;
int to_task2 = 0;
int last_to_task2 = 0;
int to_target1 = 0;
int last_to_target1 = 0;
int to_target2 = 0;
int last_to_target2 = 0;
int to_onset1 = 0;
int last_to_onset1 = 0;
int to_onset2 = 0;
int last_to_onset2 = 0;
Boolean isonline = true;
//前工位申请任务请求标记
Boolean requireSucess = false;
@@ -179,6 +192,36 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
heartbeat = this.itemProtocol.getHeartbeat();
to_task1 = this.itemProtocol.getTo_task1();
to_task2 = this.itemProtocol.getTo_task2();
to_target1 = this.itemProtocol.getTo_target1();
to_target2 = this.itemProtocol.getTo_target2();
to_onset1 = this.itemProtocol.getTo_onset1();
to_onset2 = this.itemProtocol.getTo_onset2();
if (to_command1 != last_to_command1) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command1" + last_to_command1 + "->" + to_command1);
}
if (to_target1 != last_to_target1) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target1" + last_to_target1 + "->" + to_target1);
}
if (to_task1 != last_to_task1) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task1" + last_to_task1 + "->" + to_task1);
}
if (to_onset1 != last_to_onset1) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_onset1" + last_to_onset1 + "->" + to_onset1);
}
if (to_command2 != last_to_command2) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command2" + last_to_command2 + "->" + to_command2);
}
if (to_target2 != last_to_target2) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target2" + last_to_target2 + "->" + to_target2);
}
if (to_task2 != last_to_task2) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task2" + last_to_task2 + "->" + to_task2);
}
if (to_onset2 != last_to_onset2) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_onset2" + last_to_onset2 + "->" + to_onset2);
}
// if(heartbeat != last_heartbeat){
// logServer.deviceExecuteLog(this.device_code, "", "", "heartbeat" + last_heartbeat + "->" + heartbeat);
// }
@@ -189,13 +232,6 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
logServer.deviceExecuteLog(device_code, "", "", "开始请求标记复位`此时请求标记值为:" + requireSucess);
requireSucess = false;
logServer.deviceExecuteLog(device_code, "", "", "请求标记复位成功`此时请求标记值为:" + requireSucess);
// if (task1 == 0 && task2 == 0 && type == 0) {
// logServer.deviceExecuteLog(device_code, "", "", "开始复位当前执行步骤");
// this.setNow_steps_type1(0);
// this.setNow_steps_type2(0);
// this.setNow_steps_type3(0);
// logServer.deviceExecuteLog(device_code, "", "", "复位当前执行步骤成功");
// }
feedMessage = "";
notCreateTaskMessage = "";
notCreateInstMessage = "";
@@ -469,12 +505,12 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task2));
if (inst2 != null) {
if (StrUtil.equals(inst2.getInstruction_status(), "1")) {
finish_instruction(inst2);
if (to_command2 != 5) {
this.writing("to_command2", "5");
}
this.setNow_steps_type2(6);
this.setNow_steps_type2(0);
finish_instruction(inst2);
}
}
} else {
@@ -594,12 +630,12 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1));
if (inst1 != null) {
if (StrUtil.equals(inst1.getInstruction_status(), "1")) {
this.finish_instruction(inst1);
if (to_command1 != 5) {
this.writing("to_command1", "5");
}
this.setNow_steps_type1(6);
this.setNow_steps_type1(0);
this.finish_instruction(inst1);
}
}
} else {
@@ -630,12 +666,12 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1));
if (inst1 != null) {
if (StrUtil.equals(inst1.getInstruction_status(), "1")) {
this.finish_instruction(inst1);
if (to_command1 != 5) {
this.writing("to_command1", "5");
}
this.setNow_steps_type3(10);
this.setNow_steps_type3(0);
this.finish_instruction(inst1);
}
}
} else {
@@ -761,6 +797,14 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
last_task1 = task1;
last_task2 = task2;
last_heartbeat = heartbeat;
last_to_command1 = to_command1;
last_to_task1 = to_task1;
last_to_onset1 = to_onset1;
last_to_target1 = to_target1;
last_to_command2 = to_command2;
last_to_task2 = to_task2;
last_to_onset2 = to_onset2;
last_to_target2 = to_target2;
}
public synchronized boolean task_check() {

View File

@@ -31,7 +31,13 @@ public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implem
int last_open = 0;
int last_close = 0;
int toOpen = 0;
int last_toOpen = 0;
int toClose = 0;
int last_toClose = 0;
String device_code = null;
@Override
public Device getDevice() {
return this.device;
@@ -45,6 +51,8 @@ public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implem
device_code = this.getDevice().getDevice_code();
open = this.itemProtocol.getOpen();
close = this.itemProtocol.getClose();
toOpen = this.itemProtocol.getToOpen();
toClose = this.itemProtocol.getToClose();
if (open != last_open) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号open" + last_open + "->" + open);
}
@@ -52,9 +60,17 @@ public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implem
logServer.deviceExecuteLog(this.device_code, "", "", "信号close" + last_close + "->" + close);
}
if (toClose != last_toClose) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号toClose" + last_toClose + "->" + toClose);
}
if (toOpen != last_toOpen) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号toOpen" + last_toOpen + "->" + toOpen);
}
last_open = open;
last_close = close;
last_toClose = toClose;
last_toOpen = toOpen;
}

View File

@@ -92,7 +92,15 @@ public class ItemProtocol {
return this.getOpcStringValue(item_barcode);
}
public int getTotTask() {
public int getTo_command() {
return this.getOpcIntegerValue(item_to_command);
}
public int getTo_target() {
return this.getOpcIntegerValue(item_to_target);
}
public int getTo_task() {
return this.getOpcIntegerValue(item_to_task);
}

View File

@@ -95,7 +95,6 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
int error = 0;
int task = 0;
int weight = 0;
int to_task = 0;
String plcbarcode = null;
String last_plcbarcode = null;
int plcbarcode_length = 0;
@@ -117,6 +116,15 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
String inst_message;
String device_code;
int to_command = 0;
int last_to_command = 0;
int to_target = 0;
int last_to_target = 0;
int to_task = 0;
int last_to_task = 0;
String message;
private String error_type = "ssx_error_type";
//请求成功标记
@@ -207,8 +215,20 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
task = this.itemProtocol.getTask();
plcbarcode = this.itemProtocol.getplcBarCode();
plcbarcode_length = this.itemProtocol.getBarCode_length();
to_task = this.itemProtocol.getTotTask();
to_command = this.itemProtocol.getTo_command();
to_target = this.itemProtocol.getTo_target();
to_task = this.itemProtocol.getTo_task();
weight = this.itemProtocol.getWeight();
if (to_command != last_to_command) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command" + last_to_command + "->" + to_command);
}
if (to_target != last_to_target) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target" + last_to_target + "->" + to_target);
}
if (to_task != last_to_task) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task" + last_to_task + "->" + to_task);
}
if (mode != last_mode) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode + "复位请求标记");
if (mode == 2) {
@@ -351,6 +371,9 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
last_plcbarcode_length = plcbarcode_length;
last_plcbarcode = plcbarcode;
last_weight = weight;
last_to_task = to_task;
last_to_command = to_command;
last_to_target = to_target;
}
public boolean exe_error() {

View File

@@ -1,11 +1,13 @@
package org.nl.acs.device_driver.driver;
import lombok.extern.slf4j.Slf4j;
import org.jinterop.dcom.common.JIException;
import org.nl.acs.ext.wms.data.JsonUtl;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.opc.*;
import org.nl.acs.udw.UnifiedDataAccessor;
import org.nl.acs.udw.UnifiedDataAccessorFactory;
import org.nl.acs.udw.UnifiedDataAppService;
import org.nl.modules.wql.exception.WDKException;
import org.nl.modules.wql.util.SpringContextHolder;
import org.openscada.opc.lib.da.AddFailedException;
@@ -16,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import java.util.*;
@Slf4j
public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements OpcDeviceDriver {
@Autowired
@@ -135,11 +138,13 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
sb.append(":");
sb.append(JsonUtl.parseWithoutException(udw_value));
sb.append(";");
// if (!need_write && !UnifiedDataAppService.isEquals(udw_value, write_value)) {
// need_write = true;
// }
}
if (!need_write && !UnifiedDataAppService.isEquals(udw_value, write_value)) {
need_write = true;
} else {
log.warn("下发信号点位{} 当前写入值:{} 与系统内存值:{} 相同,不再写入 ", code, write_value, udw_value );
}
}
//need_write = true;
if (need_write) {
Date date = new Date();

View File

@@ -143,4 +143,12 @@ public class WmsToAcsController {
public ResponseEntity<Object> realTimefaultInfo(@RequestBody JSONObject param){
return new ResponseEntity<>(wmstoacsService.realTimefaultInfo(param), HttpStatus.OK);
}
@PostMapping("/paperTubeAction")
@Log(value = "下发纸管库动作",isInterfaceLog = true,interfaceLogType= InterfaceLogType.LMS_TO_ACS)
@ApiOperation("下发纸管库动作")
@SaIgnore
public ResponseEntity<Object> paperTubeAction(@RequestBody JSONObject param){
return new ResponseEntity<>(wmstoacsService.paperTubeAction(param), HttpStatus.OK);
}
}

View File

@@ -107,4 +107,7 @@ public interface WmsToAcsService {
Map<String, Object> syncfaultInfo();
Map<String, Object> realTimefaultInfo(JSONObject param);
Map<String, Object> paperTubeAction(JSONObject param);
}

View File

@@ -24,6 +24,7 @@ import org.nl.acs.device_driver.basedriver.empty_vehicle_stacking_position.Empty
import org.nl.acs.device_driver.basedriver.hongxiang_conveyor.HongXiangStationDeviceDriver;
import org.nl.acs.device_driver.basedriver.hongxiang_device.HongXiangConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.lamp_three_color.LampThreecolorDeviceDriver;
import org.nl.acs.device_driver.basedriver.paper_tube_device.PaperTubeConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.plug_pull_device_site.PlugPullDeviceSiteDeviceDriver;
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver;
@@ -225,7 +226,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
//货梯对接线-带扫码器
StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver;
//纸管库
PaperTubeConveyorDeviceDriver paperTubeConveyorDeviceDriver;
if (datas.size() == 0) {
throw new BadRequestException("缺少输入参数!");
}
@@ -272,6 +274,16 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
jo.put("move", standardCoveyorControlWithScannerDeviceDriver.getMove());
jo.put("action", standardCoveyorControlWithScannerDeviceDriver.getAction());
jo.put("error", standardCoveyorControlWithScannerDeviceDriver.getError());
} else if (device.getDeviceDriver() instanceof PaperTubeConveyorDeviceDriver) {
paperTubeConveyorDeviceDriver = (PaperTubeConveyorDeviceDriver) device.getDeviceDriver();
jo.put("device_code", parent_device_code);
jo.put("qty", paperTubeConveyorDeviceDriver.getInventory_qty());
jo.put("mode", paperTubeConveyorDeviceDriver.getMode());
jo.put("error", paperTubeConveyorDeviceDriver.getError());
jo.put("material_code", ObjectUtil.isEmpty(paperTubeConveyorDeviceDriver.getMaterial())? "":paperTubeConveyorDeviceDriver.getMaterial() );
jo.put("out_finish", paperTubeConveyorDeviceDriver.getOut_finish());
}else {
jo.put("device_code", parent_device_code);
}
@@ -1000,4 +1012,77 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
return resp;
}
@Override
public Map<String, Object> paperTubeAction(JSONObject param) {
log.info("paperTubeAction--------------:输入参数" + param.toString());
JSONObject resp = new JSONObject();
String device_code = param.getString("device_code");
String type = param.getString("type");
String material_code = param.getString("material_code");
String qty = param.getString("qty");
if (StrUtil.isNotEmpty(device_code)) {
Device device = deviceAppService.findDeviceByCode(device_code);
if (device == null) {
resp.put("status", 400);
resp.put("message", "未找到对应设备");
log.info("paperTubeAction--------------:输出参数" + resp.toString());
return resp;
}
if (device.getDeviceDriver() instanceof PaperTubeConveyorDeviceDriver) {
PaperTubeConveyorDeviceDriver paperTubeConveyorDeviceDriver = (PaperTubeConveyorDeviceDriver) device.getDeviceDriver();
if(paperTubeConveyorDeviceDriver.getMode() != 2){
resp.put("status", 400);
resp.put("message", "设备:"+ device_code +"未待机,无法下发信号");
log.info("paperTubeAction--------------:输出参数" + resp.toString());
return resp;
}
if(StrUtil.equals(type,"1")){
if(paperTubeConveyorDeviceDriver.getInventory_qty() > 0){
resp.put("status", 400);
resp.put("message", "设备:"+ device_code +"当前数量为"+paperTubeConveyorDeviceDriver.getInventory_qty() +"无法设置物料");
log.info("paperTubeAction--------------:输出参数" + resp.toString());
return resp;
}
paperTubeConveyorDeviceDriver.writing("to_material",material_code);
} else if (StrUtil.equals(type,"2")) {
if(paperTubeConveyorDeviceDriver.getInventory_qty() < Integer.parseInt(qty)){
resp.put("status", 400);
resp.put("message", "设备:"+ device_code +"当前数量为"+paperTubeConveyorDeviceDriver.getInventory_qty() +"小于出库数量"+qty);
log.info("paperTubeAction--------------:输出参数" + resp.toString());
return resp;
}
if(StrUtil.isEmpty(paperTubeConveyorDeviceDriver.getMaterial())){
resp.put("status", 400);
resp.put("message", "设备:"+ device_code +"设备上报物料为空无法出库");
log.info("paperTubeAction--------------:输出参数" + resp.toString());
return resp;
} else {
if(!StrUtil.equals(paperTubeConveyorDeviceDriver.getMaterial(),material_code)){
resp.put("status", 400);
resp.put("message", "设备:"+ device_code +"设备上报物料为"+paperTubeConveyorDeviceDriver.getMaterial() +"与出库物料"+material_code+"不匹配");
log.info("paperTubeAction--------------:输出参数" + resp.toString());
return resp;
}
}
if(paperTubeConveyorDeviceDriver.getTo_command() != 0 || paperTubeConveyorDeviceDriver.getTo_target() != 0 ){
resp.put("status", 400);
resp.put("message", "设备:"+ device_code +"下发命令信号值为"+paperTubeConveyorDeviceDriver.getTo_command() + ",下发目标站:" + paperTubeConveyorDeviceDriver.getTo_target() +",已存在待执行的任务");
log.info("paperTubeAction--------------:输出参数" + resp.toString());
return resp;
}
paperTubeConveyorDeviceDriver.writing("to_out_qty",qty);
paperTubeConveyorDeviceDriver.writing("to_target",device.getAddress());
paperTubeConveyorDeviceDriver.writing("to_command","2");
}
}
}
resp.put("status", 200);
resp.put("message", "操作成功");
return resp;
}
}

View File

@@ -1,33 +1,34 @@
package org.nl.acs.opc;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.udw.UnifiedDataAccessor;
import org.nl.acs.udw.UnifiedDataAccessorFactory;
import org.openscada.opc.lib.da.Group;
import org.openscada.opc.lib.da.Item;
import org.openscada.opc.lib.da.ItemState;
import org.openscada.opc.lib.da.Server;
import org.nl.acs.udw.UnifiedDataAppService;
import org.openscada.opc.lib.da.*;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Slf4j
public class DeviceOpcProtocolRunable implements Runnable {
public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerConnectionStateListener {
List<OpcItemDto> protocols;
OpcServerManageDto OpcServer;
int error_num;
String message;
int maxResartNum;
private Server server;
//boolean flag =false;
private Group group;
boolean flag = false;
private int all_null;
private Map<String, OpcItemDto> itemSearchCache;
public DeviceOpcProtocolRunable() {
this.error_num = 0;
this.all_null = 0;
this.message = null;
this.itemSearchCache = new HashMap();
this.server = null;
}
@@ -47,36 +48,58 @@ public class DeviceOpcProtocolRunable implements Runnable {
this.OpcServer = opcServer;
}
OpcItemDto getItem(String item) {
Iterator var2 = this.protocols.iterator();
OpcItemDto dto;
do {
if (!var2.hasNext()) {
return null;
private OpcItemDto getItem(String item) {
OpcItemDto x = (OpcItemDto) this.itemSearchCache.get(item);
if (x == null) {
Iterator var3 = this.protocols.iterator();
while (var3.hasNext()) {
OpcItemDto dto = (OpcItemDto) var3.next();
if (StrUtil.equals(item, dto.getItem_code())) {
x = dto;
this.itemSearchCache.put(item, dto);
break;
}
}
}
dto = (OpcItemDto) var2.next();
} while (!StrUtil.equals(item, dto.getItem_code()));
return dto;
return x;
}
@Override
public void run() {
while (true) {
try {
this.server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
// Group group = server.addGroup(this.OpcServer.getOpc_host());
Group group = server.addGroup(this.OpcServer.getOpc_code());
if(ObjectUtil.isEmpty(group)){
log.info("group is null ");
if (OpcConfig.opc_item_read_using_callback) {
this.runNew();
} else {
this.runOld();
}
}
List<String> itemsString = new ArrayList();
Iterator it = this.protocols.iterator();
while (it.hasNext()) {
OpcItemDto protocol = (OpcItemDto) it.next();
private void runOld() {
while (true) {
start:
try {
if (this.group != null) {
group.clear();
group.remove();
log.trace("清理group...");
}
if (this.server != null) {
server.disconnect();
log.trace("清理server...");
}
this.server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
this.server.addStateListener(this);
group = this.server.addGroup();
List<String> itemsString = new ArrayList();
Iterator var3 = this.protocols.iterator();
while (var3.hasNext()) {
OpcItemDto protocol = (OpcItemDto) var3.next();
String item = protocol.getItem_code();
itemsString.add(item);
}
@@ -84,55 +107,57 @@ public class DeviceOpcProtocolRunable implements Runnable {
Map<String, Item> itemsMap = new LinkedHashMap();
boolean is_error = false;
StringBuilder err_message = new StringBuilder();
Iterator var7 = itemsString.iterator();
Iterator var6 = itemsString.iterator();
while (var7.hasNext()) {
String string = (String) var7.next();
while (var6.hasNext()) {
String string = (String) var6.next();
try {
itemsMap.put(string, group.addItem(string));
Item item = group.addItem(string);
itemsMap.put(string, item);
log.trace("添加成功 {}", string);
} catch (Exception var29) {
err_message.append(string + ":" + var29.getMessage());
} catch (Exception var26) {
err_message.append(string + ":" + var26.getMessage());
if (!is_error) {
is_error = true;
}
}
}
String tag;
if (is_error) {
log.info("设备OPC数据同步配置异常");
tag = err_message.toString();
log.warn("{}:{}", OpcConfig.resource_code, tag);
}
if (!OpcStartTag.is_run) {
OpcStartTag.is_run = true;
}
//线程名
String tag = Thread.currentThread().getName();
tag = "";
if (log.isWarnEnabled()) {
tag = Thread.currentThread().getName();
if (this.OpcServer != null) {
tag = tag + this.OpcServer.getOpc_code();
tag = tag + this.getOpcGroupID();
}
}
UnifiedDataAccessor accessor_value = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key);
UnifiedDataAccessor accessor_value = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key);
boolean time_out = false;
label97:
while (true) {
while (DeviceOpcSynchronizeAutoRun.isRun) {
long begin = System.currentTimeMillis();
Map<Item, ItemState> itemStatus = null;
try {
itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0]));
} catch (Exception e){
System.out.println("数据同步异常:"+ this.getOpcServer().getOpc_code());
log.trace("数据同步异常:{}", this.getOpcServer().getOpc_code());
//e.printStackTrace();
}
long end = System.currentTimeMillis();
if (log.isTraceEnabled()) {
log.trace("{} 开始记时{}", tag, DateUtil.now());
}
Map<Item, ItemState> itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0]));
long end = System.currentTimeMillis();
long duration = end - begin;
if (log.isTraceEnabled()) {
log.trace("{} 读取耗时:{}", tag, duration);
System.out.println("线程:"+tag + " 读取耗时:"+ duration);
}
if (duration > 1000L) {
if (!time_out) {
log.warn("{} 读取超时 : {}", tag, duration);
@@ -143,124 +168,195 @@ public class DeviceOpcProtocolRunable implements Runnable {
time_out = false;
}
if(ObjectUtil.isEmpty(itemStatus)) {
System.out.println( tag + " :itemStatus is null");
log.warn(" {} 读取异常 : {} itemStatus is null", tag);
}
boolean valueAllNotNull = false;
Set<Item> items = itemStatus.keySet();
Iterator var18 = items.iterator();
while (true) {
Item item;
//当前值
Object value;
//旧的值
Object his;
do {
if (!var18.hasNext()) {
while (var18.hasNext()) {
Item item = (Item) var18.next();
ItemState itemState = (ItemState) itemStatus.get(item);
Object value = OpcUtl.getValue(item, itemState);
if (value != null) {
valueAllNotNull = true;
}
String itemId = item.getId();
Object his = accessor_value.getValue(itemId);
if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) {
log.warn("opc 值不健康 item: {}, 状态: {}", itemId, itemState.getQuality());
}
if (!UnifiedDataAppService.isEquals(value, his)) {
OpcItemDto itemDto = this.getItem(itemId);
if (true) {
this.logItemChanged(itemId, accessor_value, value, itemDto);
}
accessor_value.setValue(itemId, value);
}
}
end = System.currentTimeMillis();
if (log.isTraceEnabled()) {
log.trace("{}", itemsString);
log.trace("{} 计算完成耗时{}", tag, end - begin);
Thread.sleep((long) OpcConfig.synchronized_millisecond);
}
ThreadUtl.sleep((long) OpcConfig.synchronized_millisecond);
if (this.error_num != 0) {
this.error_num = 0;
this.message = null;
}
continue label97;
if (!valueAllNotNull) {
int random = (new Random()).nextInt(10) + 1;
random *= 1000;
if (this.all_null < 3) {
if (log.isWarnEnabled()) {
log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null,5000 + random);
}
item = (Item) var18.next();
ItemState itemState = (ItemState) itemStatus.get(item);
value = OpcUtl.getValue(item, itemState);
his = accessor_value.getValue(item.getId());
if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) {
//flag = true;
log.warn("opc 值不健康 item: {}, 状态: {},当前读取值:{}, 系统内存值{} ", item.getId(), itemState.getQuality(), value, his);
ThreadUtl.sleep((long) (5000 + random));
} else if (this.all_null < 6) {
if (log.isWarnEnabled()) {
log.warn(tag + "重新创建server");
log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null,30000 + random);
}
// if(flag){
// if (this.server != null) {
// try {
// this.server.disconnect();
// } catch (Exception var25) {
// log.warn("{} : server disconnect", var25);
// }
// }
// DeviceOpcProtocolRunable runable = new DeviceOpcProtocolRunable();
// runable.setProtocols(protocols);
// runable.setOpcServer(OpcServer);
// ExecutorService executorService = Executors.newCachedThreadPool();
// executorService.submit(runable);
// log.warn("opc 值不健康 item: {}, 重新创建连接,当前线程名:{}", item.getId(),tag);
// break;
// }
} while (ObjectUtil.equal(value, his));//如果两次的值相等,不走下面的代码
// if(flag){
// break;
// }
OpcItemDto itemDto = this.getItem(item.getId());
//默认记录日志
if (true) {
StringBuilder sb = new StringBuilder();
//设备的ITEM项
List<String> relate_items = itemDto.getRelate_items();
Iterator var26 = relate_items.iterator();
while (var26.hasNext()) {
String relate = (String) var26.next();
Object obj = accessor_value.getValue(relate);
sb.append("key:" + relate + "value:" + obj + ";");
// ThreadUtl.sleep((long) (30000 + random));
ThreadUtl.sleep((long) ((new Random()).nextInt(3) +1) * 1000);
break start;
} else if (this.all_null < 12) {
if (log.isWarnEnabled()) {
log.warn("{} 所有内容都为空, all_null:{} ,暂定{}ms", tag, all_null, '\uea60' + random);
}
log.warn("信号{}变更从{}->{};信号快照:{}", new Object[]{item.getId(), his, value, sb});
ThreadUtl.sleep((long) ('\uea60' + random));
} else {
if (log.isWarnEnabled()) {
log.warn("{} 所有内容都为空, all_null:{} ,暂定{}ms", tag, all_null, 120000 + random);
}
ThreadUtl.sleep((long) (120000 + random));
}
++this.all_null;
} else {
this.all_null = 0;
}
// break start;
}
// accessor_value.setValueWithPersistence(item.getId(),accessor_value.getValue(item.getId()));
// accessor_value.getHistoryUnifiedData(item.getId());
//设置值
accessor_value.setValue(item.getId(), value);
// if(flag){
// break;
// }
}
// if(flag){
// break;
// }
}
} catch (Exception var30) {
log.warn("opc线程停止。。。");
return;
} catch (Exception var27) {
if (this.server != null) {
try {
this.server.disconnect();
} catch (Exception var25) {
log.warn("{} : server disconnect", var25);
}
}
this.server = null;
if (!DeviceOpcSynchronizeAutoRun.isRun) {
log.warn("opc线程停止2。。。");
return;
}
String error_message = "设备信息同步异常,"+var30;
String error_message = "设备信息同步异常";
if (!StrUtil.equals(this.message, error_message)) {
log.warn("", var30);
log.warn(error_message, var27);
}
try {
Thread.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000));
} catch (InterruptedException e) {
e.printStackTrace();
log.warn("OPC 读取线程读取异常{} :", e);
// Thread.currentThread().interrupt();不会真正停止线程
}
ThreadUtl.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000));
++this.error_num;
if (this.error_num > 3 && !StrUtil.equals(this.message, error_message)) {
log.info("设备同步通信异常");
this.message = error_message;
}
}
}
}
private void runNew() {
Async20Access accessor = null;
while (true) {
String opcGroupId = this.getOpcGroupID();
try {
if (this.server == null) {
this.server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
this.server.addStateListener(this);
accessor = new Async20Access(this.server, OpcConfig.synchronized_millisecond, true);
Iterator var9 = this.protocols.iterator();
while (var9.hasNext()) {
OpcItemDto protocol = (OpcItemDto) var9.next();
String itemId = protocol.getItem_code();
accessor.addItem(itemId, this);
}
accessor.bind();
log.info("Async20Access bind {}", opcGroupId);
}
Thread.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000));
} catch (Exception var8) {
if (accessor != null) {
try {
log.warn("Async20Access unbind {}", opcGroupId);
accessor.unbind();
} catch (Exception var7) {
var7.printStackTrace();
}
accessor = null;
}
if (this.server != null) {
try {
this.server.disconnect();
} catch (Exception var6) {
}
this.server = null;
}
if (var8 instanceof InterruptedException) {
log.warn("OPC 同步线程(%s)被中断", opcGroupId);
return;
}
log.warn("设备信息同步异常", var8);
ThreadUtl.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000));
String error_message = var8.getMessage();
if (error_message == null) {
error_message = var8.toString();
}
++this.error_num;
if (this.error_num > 3 && !StrUtil.equals(this.message, error_message)) {
this.message = error_message;
}
}
}
}
public void connectionStateChanged(boolean connected) {
if (!connected) {
this.server = null;
}
log.warn("opc server {} {}", this.getOpcGroupID(), connected ? "connected" : "disconnected");
}
private String getOpcGroupID() {
String var10000 = this.OpcServer.getOpc_code();
return var10000 + "(" + this.protocols.size() + " items)";
}
public static String formatDuring(long mss) {
long days = mss / 86400000L;
long hours = mss % 86400000L / 3600000L;
@@ -268,4 +364,55 @@ public class DeviceOpcProtocolRunable implements Runnable {
long seconds = mss % 60000L / 1000L;
return days + " days " + hours + " hours " + minutes + " minutes " + seconds + " seconds ";
}
public void changed(Item item, ItemState itemState) {
String itemId = item.getId();
try {
Object value = OpcUtl.getValue(item, itemState);
UnifiedDataAccessor accessor_value = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key);
accessor_value.setValue(itemId, value);
// if (value != null) {
// if (log.isTraceEnabled()) {
// log.trace("Item {} new value: {}, Timestamp: {}", new Object[]{itemId, itemState.getValue(), itemState.getTimestamp().getTime()});
// }
// } else if (log.isInfoEnabled()) {
// log.info("Item {} new value: {}, Timestamp: {}, Quality: {}", new Object[]{itemId, itemState.getValue(), itemState.getTimestamp().getTime(), itemState.getQuality()});
// }
log.trace("Item {} new value: {}, Timestamp: {}", new Object[]{itemId, itemState.getValue(), itemState.getTimestamp().getTime()});
OpcItemDto itemDto = this.getItem(itemId);
// if (Boolean.TRUE.equals(itemDto.getNeed_log())) {
// this.logItemChanged(itemId, accessor_value, value, itemDto);
// }
this.logItemChanged(itemId, accessor_value, value, itemDto);
} catch (Exception var7) {
log.error(itemId, var7);
}
}
private void logItemChanged(String itemId, UnifiedDataAccessor accessor_value, Object value, OpcItemDto itemDto) {
Object his = accessor_value.getValue(itemId);
List<String> relate_items = itemDto.getRelate_items();
if (relate_items != null && !relate_items.isEmpty()) {
StringBuilder sb = new StringBuilder();
Iterator var8 = relate_items.iterator();
while (var8.hasNext()) {
String relate = (String) var8.next();
Object obj = accessor_value.getValue(relate);
sb.append("key:" + relate + "value:" + obj + ";");
}
log.warn("设备:{}信号{}变更从{}->{};信号快照:{}", new Object[]{itemDto.getDevice_code(), itemId, his, value, sb});
// this.businessLogger.setResource(itemDto.getDevice_code(), itemDto.getDevice_name()).log("信号{}变更从{}->{};信号快照:{}", new Object[]{itemId, his, value, sb});
} else {
log.warn("设备:{}信号{}变更从{}->{};信号快照:{}", new Object[]{itemDto.getDevice_code(), itemId, his, value});
// this.businessLogger.setResource(itemDto.getDevice_code(), itemDto.getDevice_name()).log("信号{}变更从{}->{}", new Object[]{itemId, his, value});
}
}
}

View File

@@ -1,8 +1,10 @@
package org.nl.acs.opc;
import cn.hutool.core.util.StrUtil;
import org.jinterop.dcom.common.JIException;
import org.nl.acs.auto.initial.ApplicationAutoInitial;
import org.nl.acs.device_driver.driver.ItemValue;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.wql.exception.WDKException;
import org.openscada.opc.lib.common.NotConnectedException;
import org.openscada.opc.lib.da.Group;
@@ -65,32 +67,38 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
this.opcServerManageDtos = Collections.synchronizedMap(this.opcServerManageDtos);
}
public synchronized Group getServer(String code) {
public Group getServer(String code) {
synchronized(this.buildLock(code)) {
Group group = null;
group = (Group)this.groups.get(code);
if (group != null) {
label68: {
Group var10000;
try {
if (group.isActive()) {
return group;
if (!group.isActive()) {
break label68;
}
} catch (JIException var9) {
var9.printStackTrace();
var10000 = group;
} catch (JIException var14) {
log.error(code, var14);
break label68;
}
return var10000;
}
}
Server server = (Server)this.servers.get(code);
boolean needcreate = false;
String groupName = code;
if (server == null) {
needcreate = true;
} else {
try {
group = server.findGroup(OpcConfig.opc_server_default_group);
} catch (UnknownHostException
| JIException
| UnknownGroupException
| NotConnectedException
| IllegalArgumentException var8) {
var8.printStackTrace();
group = server.findGroup(groupName);
} catch (UnknownHostException | JIException | UnknownGroupException | NotConnectedException | IllegalArgumentException var13) {
log.error(code, var13);
needcreate = true;
}
}
@@ -98,23 +106,26 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
if (needcreate) {
OpcServerManageDto dto = (OpcServerManageDto)this.opcServerManageDtos.get(code);
if (dto == null) {
throw new WDKException("code 不存在");
throw new BadRequestException(code + "{} 不存在");
}
server = OpcServerUtl.getServerWithOutException(
dto.getOpc_host(),
dto.getCls_id(),
dto.getUser(),
dto.getPassword(),
dto.getDomain());
// server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
if (server == null) {
server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
}
try {
group = server.addGroup(OpcConfig.opc_server_default_group);
} catch (Exception var7) {
throw new WDKException(var7);
group = server.addGroup(groupName);
} catch (Exception var12) {
this.clearServer(code);
ThreadUtl.sleep(5000L);
log.warn("获取opc出错重新获取", code, var12);
server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
try {
group = server.addGroup(groupName);
} catch (Exception var11) {
var11.printStackTrace();
}
}
this.servers.put(code, server);
@@ -123,22 +134,20 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
return group;
}
public synchronized void clearServer(String code) {
try {
Server server = (Server) this.servers.get(code);
if (server!=null){
server.disconnect();
}
} catch (Exception e) {
e.printStackTrace();
log.error("清理server异常,",e.getMessage());
public void clearServer(String code) {
synchronized(this.buildLock(code)) {
try {
Server server = (Server)this.servers.get(code);
server.disconnect();
} catch (Exception var5) {
}
this.servers.remove(code);
this.groups.remove(code);
}
}
public void writeInteger(String code, ItemValue... values) {
try {
@@ -151,4 +160,15 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
throw var4;
}
}
private String buildLock(String key) {
if (StrUtil.isEmpty(key)) {
key = "";
}
StringBuilder builder = new StringBuilder();
builder.append("OpcServerService.");
builder.append(key);
String lock = builder.toString().intern();
return lock;
}
}

View File

@@ -142,6 +142,11 @@
<el-switch v-model="form.ship_device_update" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="特殊请求标记复位" label-width="150px">
<el-switch v-model="form.special_flag" />
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
@@ -314,7 +319,8 @@ export default {
is_pickup: true,
is_release: true,
link_device_code: [],
ship_device_update: true
ship_device_update: true,
special_flag: true
},
rules: {}
}

View File

@@ -116,6 +116,27 @@
</div>
</el-dialog>
<el-dialog title="设备设置" :visible.sync="dialogFormVisible7" width="35%">
<el-form :model="form" size="small">
<el-form-item label="设备编号" prop="device_code" label-width="120px">
<el-input v-model="form.device_code" :disabled="true" />
</el-form-item>
<el-form-item label="条码" label-width="120px">
<el-input v-model="form.barcode" :disabled="false" />
</el-form-item>
<el-form-item label="请求标记" prop="requireSucess" label-width="120px">
<el-radio-group v-model="form.requireSucess">
<el-radio-button :label="0"></el-radio-button>
<el-radio-button :label="1"></el-radio-button>
</el-radio-group>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible7 = false"> </el-button>
<el-button type="primary" @click="dialogSave"> </el-button>
</div>
</el-dialog>
<el-dialog title="设备设置" :visible.sync="dialogFormVisible6" width="35%">
<el-form :model="form" size="small">
<el-form-item label="设备编号" prop="device_code" label-width="120px">
@@ -147,7 +168,7 @@
<el-input v-model="form.device_code" :disabled="true" />
</el-form-item>
<el-form-item label="条码" label-width="80px">
<el-form-item label="条码" prop="device_code" label-width="80px">
<el-input v-model="form.barcode" :disabled="false" />
</el-form-item>
</el-form>
@@ -190,6 +211,7 @@ export default {
dialogFormVisible4: false,
dialogFormVisible5: false,
dialogFormVisible6: false,
dialogFormVisible7: false,
form: {
device_code: '',
hasGoodStatus: null,
@@ -331,7 +353,13 @@ export default {
} else if (clickObj.data.driver_type === 'slit_two_manipulator') {
this.dialogFormVisible4 = true
} else if (clickObj.data.driver_type === 'siemens_conveyor') {
if (clickObj.data.device_name.includes('1016')) {
this.dialogFormVisible7 = true
} else {
this.dialogFormVisible5 = true
}
} else if (clickObj.data.driver_type === 'siemens_conveyor_ckk') {
this.dialogFormVisible7 = true
} else if (clickObj.data.driver_type === 'standard_conveyor_control_with_scanner') {
this.dialogFormVisible6 = true
} else {
@@ -347,6 +375,7 @@ export default {
this.form.fullrequireSucess = clickObj.data.fullrequireSucess
this.form.is_disable = clickObj.data.is_disable1
this.form.applySucess = clickObj.data.applySucess
this.form.barcode = clickObj.data.barcode
},
moveShow(nodeData) { // 点击之后显示出来的数据----只需要设备信息
let item = ''
@@ -528,6 +557,12 @@ export default {
} else if (val === 'applySucess') {
const obj = { name: 'applySucess', value: data[val] }
this.arr.push(obj)
} else if (val === 'out_finish') {
const obj = { name: '出库完成', value: data[val] }
this.arr.push(obj)
} else if (val === 'inventory_qty') {
const obj = { name: '库存数量', value: data[val] }
this.arr.push(obj)
}
}
}
@@ -576,12 +611,14 @@ export default {
this.dialogFormVisible4 = false
this.dialogFormVisible5 = false
this.dialogFormVisible6 = false
this.dialogFormVisible7 = false
this.initStageData()
}).catch(err => {
this.dialogFormVisible = false
this.dialogFormVisible3 = false
this.dialogFormVisible4 = false
this.dialogFormVisible5 = false
this.dialogFormVisible7 = false
console.log(err.response.data.message)
})
},

View File

@@ -52,25 +52,14 @@
<result column="updateTime" property="updateTime" />
<result column="extpersonId" property="extpersonId" />
<result column="extuserId" property="extuserId" />
<collection property="depts" ofType="org.nl.system.service.dept.dao.SysDept">
<id property="deptId" column="deptId"/>
<result column="deptName" property="name"/>
</collection>
<collection property="roles" ofType="org.nl.system.service.role.dao.SysRole">
<id property="roleId" column="roleId"/>
</collection>
<collection property="depts" ofType="org.nl.system.service.dept.dao.SysDept" column="userId" select="selectDept"></collection>
<collection property="roles" ofType="org.nl.system.service.role.dao.SysRole" column="userId" select="selectRole"></collection>
</resultMap>
<select id="getUserDetail" resultMap="UserDetail">
SELECT
<include refid="Base_Column_List"/>
,sys_dept.dept_id as deptId
,sys_dept.name as deptName
,sys_users_roles.role_id as roleId
FROM
sys_user
left join sys_user_dept on sys_user.user_id = sys_user_dept.user_id
left join sys_users_roles on sys_users_roles.user_id = sys_user.user_id
left join sys_dept on sys_user_dept.dept_id = sys_dept.dept_id
<where>
<if test="query.deptId != null">
and
@@ -90,6 +79,20 @@
</if>
</where>
</select>
<select id="selectDept" resultType="org.nl.system.service.dept.dao.SysDept">
select
sys_dept.dept_id as deptId,
sys_dept.name as name
from sys_dept
left join sys_user_dept
on sys_user_dept.dept_id = sys_dept.dept_id
where user_id = #{userId}
</select>
<select id="selectRole" resultType="org.nl.system.service.role.dao.SysRole">
select role_id as roleId
from sys_users_roles
where user_id = #{userId}
</select>
<select id="getDetailForMap" resultType="java.util.Map">
SELECT

View File

@@ -85,6 +85,10 @@ public class HandMoveStorServiceImpl implements HandMoveStorService {
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_MoveInv");
//任务表
WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task");
//点位表
WQLObject wo_Point = WQLObject.getWQLObject("sch_base_point");
//仓位表
WQLObject wo_Attr = WQLObject.getWQLObject("st_ivt_structattr");
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
@@ -96,11 +100,13 @@ public class HandMoveStorServiceImpl implements HandMoveStorService {
map.put("update_time", now);
JSONObject jo_mst = wo_mst.query("moveinv_id='" + moveinv_id + "'").uniqueResult(0);
JSONArray ja = wo_dtl.query("moveinv_id='" + moveinv_id + "'").getResultJSONArray(0);
String point_code2 = "";
for (int i = 0; i < ja.size(); i++) {
JSONObject jo = ja.getJSONObject(i);
//删除任务
HashMap<String, String> task_map = new HashMap<>();
task_map.put("is_delete", "1");
point_code2 = wo_Task.query("task_id = '" + jo.getString("task_id") + "'").uniqueResult(0).getString("point_code2");
wo_Task.update(task_map, "task_id='" + jo.getString("task_id") + "'");
//解锁起点点位、仓位
JSONObject from_start = new JSONObject();
@@ -133,6 +139,15 @@ public class HandMoveStorServiceImpl implements HandMoveStorService {
}
//更新主表
wo_mst.update(map, "moveinv_id='" + moveinv_id + "'");
// 更新移入点位
JSONObject jsonPoint = wo_Point.query("point_code = '" + point_code2 + "'").uniqueResult(0);
jsonPoint.put("vehicle_code", "");
wo_Point.update(jsonPoint);
JSONObject jsonAttr = wo_Attr.query("struct_code = '" + point_code2 + "'").uniqueResult(0);
jsonAttr.put("storagevehicle_code", "");
wo_Attr.update(jsonAttr);
}
@Override

View File

@@ -4864,6 +4864,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
oneMap.put("deliveryaddress", jsonMst.getString("deliveryaddress")); // 送货方地址
oneMap.put("deliveryname", jsonMst.getString("deliveryname")); // 送货方联系人
oneMap.put("deliveryphone", jsonMst.getString("deliveryphone")); // 送货方联系电话
oneMap.put("contractno", jsonMst.getString("contractno")); // 合同号
} else {
if (ObjectUtil.isEmpty(jsonCust)) throw new BadRequestException("客户不存在");
@@ -4918,6 +4919,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
oneMap.put("deliveryaddress", jsonMst.getString("deliveryaddress")); // 送货方地址
oneMap.put("deliveryname", jsonMst.getString("deliveryname")); // 送货方联系人
oneMap.put("deliveryphone", jsonMst.getString("deliveryphone")); // 送货方联系电话
oneMap.put("contractno", jsonMst.getString("contractno")); // 合同号
}
// 6.多组填充

View File

@@ -413,7 +413,7 @@ export default {
} else {
this.confirm_flag = true
}
if (current.bill_status === '40') {
if (current.bill_status === '40' || current.bill_status === '30') {
this.outReturn_flag = false
} else {
this.outReturn_flag = true