Browse Source

upd:更新

master
耿宝印 2 weeks ago
parent
commit
5adf84f50b
  1. 170
      hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java
  2. 2
      hd/nladmin-system/src/main/java/org/nl/acs/device_driver/yu_qing/call_task/YqCallTaskDeviceDriver.java
  3. 16
      hd/nladmin-system/src/main/java/org/nl/acs/device_driver/yu_qing/gu_rong_lu/YqGRLDeviceDriver.java
  4. 13
      hd/nladmin-system/src/main/java/org/nl/acs/device_driver/yu_qing/shi_xiao_lu/YqSXLDeviceDriver.java

170
hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java

@ -1142,120 +1142,52 @@ public class AgvServiceImpl implements AgvService {
@Override @Override
public JSONObject xgAGVWaitPointRequest(JSONObject requestParam) { public JSONObject xgAGVWaitPointRequest(JSONObject requestParam) {
log.info("仙工AGV请求取放货,请求参数 - {}", requestParam); log.info("仙工AGV请求取放货,请求参数 - {}", requestParam);
JSONObject resp = new JSONObject();
String instCode = requestParam.getString("task_code"); String instCode = requestParam.getString("task_code");
Instruction inst = instructionService.findByCodeFromCache(instCode); Instruction inst = instructionService.findByCodeFromCache(instCode);
instcode = instCode; instcode = instCode;
if (ObjectUtil.isEmpty(inst)) { if (ObjectUtil.isEmpty(inst)) {
throw new BadRequestException("请求失败,未找到指令!"); resp.put("code", 400);
resp.put("status", 400);
resp.put("message", "请求失败,请求任务信息不存在!");
log.info("仙工AGV请求取放货,响应参数 - {}", resp);
return resp;
} }
TaskDto task = taskService.findByCodeFromCache(inst.getTask_code()); TaskDto task = taskService.findByCodeFromCache(inst.getTask_code());
if (ObjectUtil.isEmpty(task)) { if (ObjectUtil.isEmpty(task)) {
throw new BadRequestException("请求失败,未找到指令对应任务!"); resp.put("code", 400);
resp.put("status", 400);
resp.put("message", "请求失败,请求任务信息不存在!");
log.info("仙工AGV请求取放货,响应参数 - {}", resp);
return resp;
} }
String address = requestParam.getString("address"); String address = requestParam.getString("address");
if (StrUtil.isBlank(address)) { if (StrUtil.isBlank(address)) {
throw new BadRequestException("请求失败,地址为空!"); resp.put("code", 400);
} resp.put("status", 400);
String startcode = inst.getStart_device_code(); resp.put("message", "请求失败,地址为空!");
//请求取货 log.info("仙工AGV请求取放货,响应参数 - {}", resp);
if (address.contains("INGET")) { return resp;
JSONObject jo = new JSONObject();
jo.put("device_code", inst.getStart_device_code());
jo.put("task_code", inst.getTask_code());
jo.put("status", "1");
jo.put("vehicle_code", inst.getVehicle_code());
JSONArray ja = new JSONArray();
ja.add(jo);
HttpResponse result = acsToWmsService.vehicle(ja);
log.info("请求取货请求参数:{}", ja);
com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body());
log.info("上位反馈请求取货请求参数:{}", response);
int responseCode = response.getInteger("status");
if (responseCode == 200) {
JSONObject jo2 = new JSONObject();
jo2.put("status", 200);
startPointInget = true;
log.info("上位允许取货 请求结果{}", responseCode);
return jo2;
} else {
throw new BadRequestException("上位系统不允许取货");
}
}
//取货完成离开
if (address.contains("OUTGET")) {
JSONObject jo = new JSONObject();
jo.put("device_code", inst.getStart_device_code());
jo.put("task_code", inst.getTask_code());
jo.put("status", "2");
jo.put("vehicle_code", inst.getVehicle_code());
JSONArray ja = new JSONArray();
ja.add(jo);
log.info("取货完成离开请求参数:{}", ja);
HttpResponse result = acsToWmsService.vehicle(ja);
com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body());
log.info("上位反馈取货完成离开请求参数:{}", response);
int responseCode = response.getInteger("status");
if (responseCode == 200) {
JSONObject jo2 = new JSONObject();
jo2.put("status", 200);
startPointOutget = true;
log.info("上位允许取货离开 请求结果{}", responseCode);
return jo2;
} else {
throw new BadRequestException("上位系统不允许取货完成离开");
}
}
//请求放货
if (address.contains("INPUT")) {
JSONObject jo = new JSONObject();
jo.put("device_code", inst.getNext_device_code());
jo.put("task_code", inst.getTask_code());
jo.put("status", "3");
jo.put("vehicle_code", inst.getVehicle_code());
JSONArray ja = new JSONArray();
ja.add(jo);
log.info("请求放货请求参数:{}", ja);
HttpResponse result = acsToWmsService.vehicle(ja);
com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body());
log.info("上位反馈请求放货请求参数:{}", response);
int responseCode = response.getInteger("status");
if (responseCode == 200) {
JSONObject jo2 = new JSONObject();
jo2.put("status", 200);
endPointInput = true;
log.info("上位允许放货 请求结果{}", responseCode);
return jo2;
} else {
throw new BadRequestException("上位系统不允许请求放货");
}
} }
//放货完成离开 //放货完成离开
if (address.contains("OUTPUT")) { if (address.contains("OUTPUT")) {
JSONObject jo = new JSONObject(); String next_device_code = inst.getNext_device_code();
jo.put("device_code", inst.getNext_device_code()); Device device = deviceAppService.findDeviceByCode(next_device_code);
jo.put("task_code", inst.getTask_code()); if (device != null && device.getDeviceDriver() instanceof YqGRLDeviceDriver) {
jo.put("status", "4"); YqGRLDeviceDriver grlDeviceDriver = (YqGRLDeviceDriver) device.getDeviceDriver();
jo.put("vehicle_code", inst.getVehicle_code()); grlDeviceDriver.writing(3);
JSONArray ja = new JSONArray(); log.info("AGV放货完成给{}下发{}", next_device_code, 3);
ja.add(jo); } else if (device != null && device.getDeviceDriver() instanceof YqSXLDeviceDriver) {
log.info("放货完成离开:{}", ja); YqSXLDeviceDriver sxlDeviceDriver = (YqSXLDeviceDriver) device.getDeviceDriver();
HttpResponse result = acsToWmsService.vehicle(ja); sxlDeviceDriver.writing(3);
com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body()); log.info("AGV放货完成给{}下发{}", next_device_code, 3);
log.info("上位反馈放货完成离开请求参数:{}", response);
int responseCode = response.getInteger("status");
if (responseCode == 200) {
JSONObject jo2 = new JSONObject();
endPointOutput = true;
jo2.put("status", 200);
log.info("上位允许放货离开 请求结果{}", responseCode);
return jo2;
} else {
throw new BadRequestException("上位系统不允许放货完成离开");
} }
} }
throw new BadRequestException("请求失败,IN OUT 站点错误!"); resp.put("code", 200);
resp.put("status", 200);
resp.put("message", "请求成功!");
log.info("仙工AGV请求取放货,响应参数 - {}", resp);
return resp;
} }
@Override @Override
@ -1647,7 +1579,7 @@ public class AgvServiceImpl implements AgvService {
public JSONArray createBlocksData(Instruction inst) { public JSONArray createBlocksData(Instruction inst) {
// String ip = paramService.findByCode("local_host").getValue(); // String ip = paramService.findByCode("local_host").getValue();
String addr = "http://192.168.81.251:8010"; String addr = "http://10.186.139.24:8010";
JSONArray blocks = new JSONArray(); JSONArray blocks = new JSONArray();
@ -1714,23 +1646,23 @@ public class AgvServiceImpl implements AgvService {
Device device2 = deviceAppService.findDeviceByCode(inst.getNext_device_code()); Device device2 = deviceAppService.findDeviceByCode(inst.getNext_device_code());
if ("true".equals(device2.getExtraValue().get("ignore_release_check"))) { if ("true".equals(device2.getExtraValue().get("ignore_release_check"))) {
//放货前等待 //放货前等待
block = new JSONObject(); // block = new JSONObject();
block.put("blockId", IdUtil.simpleUUID()); // block.put("blockId", IdUtil.simpleUUID());
block.put("location", inst.getNext_point_code() + "INPUT"); // block.put("location", inst.getNext_point_code() + "INPUT");
block.put("operation", "script"); // block.put("operation", "script");
block.put("id", inst.getNext_point_code() + "INPUT"); // block.put("id", inst.getNext_point_code() + "INPUT");
block.put("script_name", "userpy/interact.py"); // block.put("script_name", "userpy/interact.py");
JSONObject scriptArgs = new JSONObject(); // JSONObject scriptArgs = new JSONObject();
scriptArgs.put("addr", addr); // scriptArgs.put("addr", addr);
JSONObject data = new JSONObject(); // JSONObject data = new JSONObject();
JSONObject reach = new JSONObject(); // JSONObject reach = new JSONObject();
reach.put("task_code", inst.getInstruction_code()); // reach.put("task_code", inst.getInstruction_code());
reach.put("address", inst.getNext_point_code() + "INPUT"); // reach.put("address", inst.getNext_point_code() + "INPUT");
data.put("reach", reach); // data.put("reach", reach);
scriptArgs.put("data", data); // scriptArgs.put("data", data);
scriptArgs.put("protocol", "HTTP"); // scriptArgs.put("protocol", "HTTP");
block.put("script_args", scriptArgs); // block.put("script_args", scriptArgs);
blocks.add(block); // blocks.add(block);
} }
block = new JSONObject(); block = new JSONObject();
@ -2163,6 +2095,7 @@ public class AgvServiceImpl implements AgvService {
} else { } else {
//到达固熔炉 //到达固熔炉
grlDeviceDriver.writing(1); grlDeviceDriver.writing(1);
log.info("AGV到达{}下发{}", grlDeviceDriver.getDevice_code(), 1);
//返回AGV失败 //返回AGV失败
resp.put("code", 400); resp.put("code", 400);
resp.put("message", "安全门未开到位||固熔炉门未开到位||卷扬机未到达中位"); resp.put("message", "安全门未开到位||固熔炉门未开到位||卷扬机未到达中位");
@ -2178,6 +2111,7 @@ public class AgvServiceImpl implements AgvService {
return resp; return resp;
} else { } else {
sxlDeviceDriver.writing(1); sxlDeviceDriver.writing(1);
log.info("AGV到达{}下发{}", sxlDeviceDriver.getDevice_code(), 1);
resp.put("code", 400); resp.put("code", 400);
resp.put("message", "时效炉门未开到位"); resp.put("message", "时效炉门未开到位");
log.info("上位不允许仙工AGV请求进入自动门区域 请求结果{}", resp); log.info("上位不允许仙工AGV请求进入自动门区域 请求结果{}", resp);
@ -2216,6 +2150,7 @@ public class AgvServiceImpl implements AgvService {
YqGRLDeviceDriver grlDeviceDriver = (YqGRLDeviceDriver) device.getDeviceDriver(); YqGRLDeviceDriver grlDeviceDriver = (YqGRLDeviceDriver) device.getDeviceDriver();
//离开固熔炉 //离开固熔炉
grlDeviceDriver.writing(2); grlDeviceDriver.writing(2);
log.info("AGV离开{}下发{}", grlDeviceDriver.getDevice_code(), 2);
//返回AGV失败 //返回AGV失败
resp.put("code", 200); resp.put("code", 200);
resp.put("message", "ok"); resp.put("message", "ok");
@ -2225,6 +2160,7 @@ public class AgvServiceImpl implements AgvService {
YqSXLDeviceDriver sxlDeviceDriver = (YqSXLDeviceDriver) device.getDeviceDriver(); YqSXLDeviceDriver sxlDeviceDriver = (YqSXLDeviceDriver) device.getDeviceDriver();
//离开时效炉 //离开时效炉
sxlDeviceDriver.writing(2); sxlDeviceDriver.writing(2);
log.info("AGV离开{}下发{}", sxlDeviceDriver.getDevice_code(), 2);
resp.put("code", 200); resp.put("code", 200);
resp.put("message", "ok"); resp.put("message", "ok");
log.info("上位允许仙工AGV请求离开自动门区域 请求结果{}", resp); log.info("上位允许仙工AGV请求离开自动门区域 请求结果{}", resp);

2
hd/nladmin-system/src/main/java/org/nl/acs/device_driver/yu_qing/call_task/YqCallTaskDeviceDriver.java

@ -100,7 +100,7 @@ public class YqCallTaskDeviceDriver extends AbstractOpcDeviceDriver implements D
this.execute_log.log("设备:" + device_code + ",last_mode -> mode:" + last_mode + "->" + mode); this.execute_log.log("设备:" + device_code + ",last_mode -> mode:" + last_mode + "->" + mode);
} }
} catch (Exception var17) { } catch (Exception var17) {
return; log.error("读取信号异常:{},{}", var17.getMessage(), Arrays.toString(var17.getStackTrace()));
} }
if (!this.itemProtocol.getIsOnline()) { if (!this.itemProtocol.getIsOnline()) {
this.setIsOnline(false); this.setIsOnline(false);

16
hd/nladmin-system/src/main/java/org/nl/acs/device_driver/yu_qing/gu_rong_lu/YqGRLDeviceDriver.java

@ -57,6 +57,12 @@ public class YqGRLDeviceDriver extends AbstractOpcDeviceDriver implements Device
private int middleStatus = 0; private int middleStatus = 0;
private int lastMiddleStatus = 0; private int lastMiddleStatus = 0;
/**
* 下发信号
*/
private int toCommand = 0;
private int lastToCommand = 0;
/** /**
* 设备在线状态 * 设备在线状态
*/ */
@ -106,6 +112,7 @@ public class YqGRLDeviceDriver extends AbstractOpcDeviceDriver implements Device
gDoorStatus = this.itemProtocol.getGDoorStatus(); gDoorStatus = this.itemProtocol.getGDoorStatus();
aDoorStatus = this.itemProtocol.getADoorStatus(); aDoorStatus = this.itemProtocol.getADoorStatus();
middleStatus = this.itemProtocol.getMiddleStatus(); middleStatus = this.itemProtocol.getMiddleStatus();
toCommand = this.itemProtocol.getToCommand();
if (gDoorStatus != lastGDoorStatus) { if (gDoorStatus != lastGDoorStatus) {
this.execute_log.setResource(this.device_code, this.device.getDevice_name()); this.execute_log.setResource(this.device_code, this.device.getDevice_name());
this.execute_log.log("设备:" + device_code + ",lastGDoorStatus -> gDoorStatus:" + lastGDoorStatus + "->" + gDoorStatus); this.execute_log.log("设备:" + device_code + ",lastGDoorStatus -> gDoorStatus:" + lastGDoorStatus + "->" + gDoorStatus);
@ -120,8 +127,14 @@ public class YqGRLDeviceDriver extends AbstractOpcDeviceDriver implements Device
this.execute_log.setResource(this.device_code, this.device.getDevice_name()); this.execute_log.setResource(this.device_code, this.device.getDevice_name());
this.execute_log.log("设备:" + device_code + ",lastMiddleStatus -> middleStatus:" + lastMiddleStatus + "->" + middleStatus); this.execute_log.log("设备:" + device_code + ",lastMiddleStatus -> middleStatus:" + lastMiddleStatus + "->" + middleStatus);
} }
if (toCommand != lastToCommand) {
this.execute_log.setResource(this.device_code, this.device.getDevice_name());
this.execute_log.log("设备:" + device_code + ",lastToCommand -> toCommand:" + lastToCommand + "->" + toCommand);
}
} catch (Exception var17) { } catch (Exception var17) {
return; log.error("读取信号异常:{},{}", var17.getMessage(), Arrays.toString(var17.getStackTrace()));
} }
if (!this.itemProtocol.getIsOnline()) { if (!this.itemProtocol.getIsOnline()) {
this.setIsOnline(false); this.setIsOnline(false);
@ -134,6 +147,7 @@ public class YqGRLDeviceDriver extends AbstractOpcDeviceDriver implements Device
lastGDoorStatus = gDoorStatus; lastGDoorStatus = gDoorStatus;
lastADoorStatus = aDoorStatus; lastADoorStatus = aDoorStatus;
lastMiddleStatus = middleStatus; lastMiddleStatus = middleStatus;
lastToCommand = toCommand;
} }

13
hd/nladmin-system/src/main/java/org/nl/acs/device_driver/yu_qing/shi_xiao_lu/YqSXLDeviceDriver.java

@ -42,6 +42,12 @@ public class YqSXLDeviceDriver extends AbstractOpcDeviceDriver implements Device
private int sDoorStatus = 0; private int sDoorStatus = 0;
private int lastSDoorStatus = 0; private int lastSDoorStatus = 0;
/**
* 下发信号
*/
private int toCommand = 0;
private int lastToCommand = 0;
/** /**
* 设备在线状态 * 设备在线状态
*/ */
@ -93,8 +99,12 @@ public class YqSXLDeviceDriver extends AbstractOpcDeviceDriver implements Device
this.execute_log.setResource(this.device_code, this.device.getDevice_name()); this.execute_log.setResource(this.device_code, this.device.getDevice_name());
this.execute_log.log("设备:" + device_code + ",lastSDoorStatus -> sDoorStatus:" + lastSDoorStatus + "->" + sDoorStatus); this.execute_log.log("设备:" + device_code + ",lastSDoorStatus -> sDoorStatus:" + lastSDoorStatus + "->" + sDoorStatus);
} }
if (toCommand != lastToCommand) {
this.execute_log.setResource(this.device_code, this.device.getDevice_name());
this.execute_log.log("设备:" + device_code + ",lastToCommand -> toCommand:" + lastToCommand + "->" + toCommand);
}
} catch (Exception var17) { } catch (Exception var17) {
return; log.error("读取信号异常:{},{}", var17.getMessage(), Arrays.toString(var17.getStackTrace()));
} }
if (!this.itemProtocol.getIsOnline()) { if (!this.itemProtocol.getIsOnline()) {
this.setIsOnline(false); this.setIsOnline(false);
@ -106,6 +116,7 @@ public class YqSXLDeviceDriver extends AbstractOpcDeviceDriver implements Device
} }
lastSDoorStatus = sDoorStatus; lastSDoorStatus = sDoorStatus;
lastToCommand = toCommand;
} }

Loading…
Cancel
Save