更新
This commit is contained in:
@@ -28,26 +28,31 @@ public class QueryMagicAgvTaskStatus {
|
||||
AgvService agvService;
|
||||
|
||||
|
||||
public void run() throws Exception {
|
||||
List<Instruction> instList = instructionService.findAllInstFromCache();
|
||||
log.info("instList:{}", instList.size());
|
||||
if (instList.size() > 0) {
|
||||
for (int i = 0; i < instList.size(); i++) {
|
||||
Instruction inst = instList.get(i);
|
||||
String instcode = inst.getInstruction_code();
|
||||
HttpResponse response = agvService.queryAgvInstStatus(instcode);
|
||||
JSONObject jo = JSONObject.fromObject(response.body());
|
||||
if (MapUtil.isEmpty(jo)) continue;
|
||||
//反馈结果状态
|
||||
log.info("instcode:" + instcode + "," + jo.toString());
|
||||
//指令执行状态
|
||||
String state = jo.getString("state");
|
||||
String processingVehicle = "";
|
||||
//正在执行指令agv车号
|
||||
if (!StrUtil.isEmpty(jo.getString("processingVehicle"))) {
|
||||
processingVehicle = jo.getString("processingVehicle");
|
||||
inst.setCarno(processingVehicle);
|
||||
}
|
||||
public void run() {
|
||||
|
||||
List<Instruction> instList = instructionService.findAllInstFromCache();
|
||||
log.info("instList:{}", instList.size());
|
||||
if (instList.size() > 0) {
|
||||
for (int i = 0; i < instList.size(); i++) {
|
||||
Instruction inst = instList.get(i);
|
||||
if (!inst.getSend_status().equals("1")) {
|
||||
continue;
|
||||
}
|
||||
//指令执行状态
|
||||
try {
|
||||
String instcode = inst.getInstruction_code();
|
||||
HttpResponse response = agvService.queryAgvInstStatus(instcode);
|
||||
JSONObject jo = JSONObject.fromObject(response.body());
|
||||
if (MapUtil.isEmpty(jo)) continue;
|
||||
//反馈结果状态
|
||||
log.info("instcode:" + instcode + "," + jo.toString());
|
||||
String state = jo.getString("state");
|
||||
String processingVehicle = "";
|
||||
//正在执行指令agv车号
|
||||
if (!StrUtil.isEmpty(jo.getString("processingVehicle"))) {
|
||||
processingVehicle = jo.getString("processingVehicle");
|
||||
inst.setCarno(processingVehicle);
|
||||
}
|
||||
// RAW:初始状态
|
||||
// ACTIVE:业务订单已激活
|
||||
// DISPATCHABLE:业务订单已通过系统验证,等待被调度执行
|
||||
@@ -57,56 +62,59 @@ public class QueryMagicAgvTaskStatus {
|
||||
// FAILED:业务订单已失败
|
||||
// UNROUTABLE:无法规划该业务订单的执行路线
|
||||
|
||||
//执行中
|
||||
if ("BEING_PROCESSED".equals(state)) {
|
||||
if (inst != null) {
|
||||
inst.setInstruction_status("1");
|
||||
instructionService.update(inst);
|
||||
}
|
||||
} else if ("FINISHED".equals(state)) {
|
||||
if (inst != null) {
|
||||
inst.setInstruction_status("2");
|
||||
instructionService.finish(inst);
|
||||
}
|
||||
} else if ("WITHDRAWN".equals(state) || "FAILED".equals(state)) {
|
||||
if (inst != null) {
|
||||
inst.setInstruction_status("3");
|
||||
instructionService.update(inst);
|
||||
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];
|
||||
//执行中
|
||||
if ("BEING_PROCESSED".equals(state)) {
|
||||
if (inst != null) {
|
||||
inst.setInstruction_status("1");
|
||||
instructionService.update(inst);
|
||||
}
|
||||
} else if ("FINISHED".equals(state)) {
|
||||
if (inst != null) {
|
||||
inst.setInstruction_status("2");
|
||||
instructionService.finish(inst);
|
||||
}
|
||||
} else if ("WITHDRAWN".equals(state) || "FAILED".equals(state)) {
|
||||
if (inst != null) {
|
||||
inst.setInstruction_status("3");
|
||||
instructionService.update(inst);
|
||||
instructionService.removeByCodeFromCache(instcode);
|
||||
}
|
||||
} 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