更新
This commit is contained in:
@@ -28,26 +28,31 @@ public class QueryMagicAgvTaskStatus {
|
|||||||
AgvService agvService;
|
AgvService agvService;
|
||||||
|
|
||||||
|
|
||||||
public void run() throws Exception {
|
public void run() {
|
||||||
List<Instruction> instList = instructionService.findAllInstFromCache();
|
|
||||||
log.info("instList:{}", instList.size());
|
List<Instruction> instList = instructionService.findAllInstFromCache();
|
||||||
if (instList.size() > 0) {
|
log.info("instList:{}", instList.size());
|
||||||
for (int i = 0; i < instList.size(); i++) {
|
if (instList.size() > 0) {
|
||||||
Instruction inst = instList.get(i);
|
for (int i = 0; i < instList.size(); i++) {
|
||||||
String instcode = inst.getInstruction_code();
|
Instruction inst = instList.get(i);
|
||||||
HttpResponse response = agvService.queryAgvInstStatus(instcode);
|
if (!inst.getSend_status().equals("1")) {
|
||||||
JSONObject jo = JSONObject.fromObject(response.body());
|
continue;
|
||||||
if (MapUtil.isEmpty(jo)) continue;
|
}
|
||||||
//反馈结果状态
|
//指令执行状态
|
||||||
log.info("instcode:" + instcode + "," + jo.toString());
|
try {
|
||||||
//指令执行状态
|
String instcode = inst.getInstruction_code();
|
||||||
String state = jo.getString("state");
|
HttpResponse response = agvService.queryAgvInstStatus(instcode);
|
||||||
String processingVehicle = "";
|
JSONObject jo = JSONObject.fromObject(response.body());
|
||||||
//正在执行指令agv车号
|
if (MapUtil.isEmpty(jo)) continue;
|
||||||
if (!StrUtil.isEmpty(jo.getString("processingVehicle"))) {
|
//反馈结果状态
|
||||||
processingVehicle = jo.getString("processingVehicle");
|
log.info("instcode:" + instcode + "," + jo.toString());
|
||||||
inst.setCarno(processingVehicle);
|
String state = jo.getString("state");
|
||||||
}
|
String processingVehicle = "";
|
||||||
|
//正在执行指令agv车号
|
||||||
|
if (!StrUtil.isEmpty(jo.getString("processingVehicle"))) {
|
||||||
|
processingVehicle = jo.getString("processingVehicle");
|
||||||
|
inst.setCarno(processingVehicle);
|
||||||
|
}
|
||||||
// RAW:初始状态
|
// RAW:初始状态
|
||||||
// ACTIVE:业务订单已激活
|
// ACTIVE:业务订单已激活
|
||||||
// DISPATCHABLE:业务订单已通过系统验证,等待被调度执行
|
// DISPATCHABLE:业务订单已通过系统验证,等待被调度执行
|
||||||
@@ -57,56 +62,59 @@ public class QueryMagicAgvTaskStatus {
|
|||||||
// FAILED:业务订单已失败
|
// FAILED:业务订单已失败
|
||||||
// UNROUTABLE:无法规划该业务订单的执行路线
|
// UNROUTABLE:无法规划该业务订单的执行路线
|
||||||
|
|
||||||
//执行中
|
//执行中
|
||||||
if ("BEING_PROCESSED".equals(state)) {
|
if ("BEING_PROCESSED".equals(state)) {
|
||||||
if (inst != null) {
|
if (inst != null) {
|
||||||
inst.setInstruction_status("1");
|
inst.setInstruction_status("1");
|
||||||
instructionService.update(inst);
|
instructionService.update(inst);
|
||||||
}
|
}
|
||||||
} else if ("FINISHED".equals(state)) {
|
} else if ("FINISHED".equals(state)) {
|
||||||
if (inst != null) {
|
if (inst != null) {
|
||||||
inst.setInstruction_status("2");
|
inst.setInstruction_status("2");
|
||||||
instructionService.finish(inst);
|
instructionService.finish(inst);
|
||||||
}
|
}
|
||||||
} else if ("WITHDRAWN".equals(state) || "FAILED".equals(state)) {
|
} else if ("WITHDRAWN".equals(state) || "FAILED".equals(state)) {
|
||||||
if (inst != null) {
|
if (inst != null) {
|
||||||
inst.setInstruction_status("3");
|
inst.setInstruction_status("3");
|
||||||
instructionService.update(inst);
|
instructionService.update(inst);
|
||||||
instructionService.removeByCodeFromCache(instcode);
|
instructionService.removeByCodeFromCache(instcode);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
JSONArray ja = jo.getJSONArray("properties");
|
|
||||||
for (int j = 0; j < ja.size(); j++) {
|
|
||||||
JSONObject item = ja.getJSONObject(j);
|
|
||||||
if ("True".equals(item.get("value"))) {
|
|
||||||
String param = item.get("key").toString();
|
|
||||||
String[] strs = param.split("-");
|
|
||||||
//onEntry请求进入 onStation请求离开
|
|
||||||
//onStation-库位名-动作名"
|
|
||||||
String type = null;
|
|
||||||
String device = null;
|
|
||||||
String action = null;
|
|
||||||
// =5表示为货位
|
|
||||||
if (strs.length == 5) {
|
|
||||||
type = strs[0];
|
|
||||||
device = strs[1] + "-" + strs[2] + "-" + strs[3];
|
|
||||||
action = strs[4];
|
|
||||||
} else {
|
} else {
|
||||||
type = strs[0];
|
|
||||||
device = strs[1];
|
|
||||||
action = strs[2];
|
|
||||||
}
|
}
|
||||||
|
JSONArray ja = jo.getJSONArray("properties");
|
||||||
|
for (int j = 0; j < ja.size(); j++) {
|
||||||
|
JSONObject item = ja.getJSONObject(j);
|
||||||
|
if ("True".equals(item.get("value"))) {
|
||||||
|
String param = item.get("key").toString();
|
||||||
|
String[] strs = param.split("-");
|
||||||
|
//onEntry请求进入 onStation请求离开
|
||||||
|
//onStation-库位名-动作名"
|
||||||
|
String type = null;
|
||||||
|
String device = null;
|
||||||
|
String action = null;
|
||||||
|
// =5表示为货位
|
||||||
|
if (strs.length == 5) {
|
||||||
|
type = strs[0];
|
||||||
|
device = strs[1] + "-" + strs[2] + "-" + strs[3];
|
||||||
|
action = strs[4];
|
||||||
|
} else {
|
||||||
|
type = strs[0];
|
||||||
|
device = strs[1];
|
||||||
|
action = strs[2];
|
||||||
|
}
|
||||||
|
|
||||||
String mes = "";
|
String mes = "";
|
||||||
|
|
||||||
agvService.process(instcode, type, device, action, processingVehicle);
|
agvService.process(instcode, type, device, action, processingVehicle);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("未查询到相关任务号");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user