周俊杰
2 years ago
6 changed files with 198 additions and 164 deletions
@ -0,0 +1,100 @@ |
|||
package org.nl.modules.quartz.task; |
|||
|
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import cn.hutool.core.util.StrUtil; |
|||
import cn.hutool.http.HttpResponse; |
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.acs.agv.server.AgvService; |
|||
import org.nl.acs.instruction.service.InstructionService; |
|||
import org.nl.acs.instruction.service.dto.Instruction; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* 查询AGV任务状态 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
public class QueryAgvTaskStatus { |
|||
@Autowired |
|||
InstructionService instructionService; |
|||
|
|||
@Autowired |
|||
AgvService agvService; |
|||
|
|||
|
|||
public void run() throws Exception { |
|||
try { |
|||
HttpResponse response = agvService.queryAgvInstStatus("1"); |
|||
//查询AGV指令列表
|
|||
JSONArray inst_rows = JSONArray.parseArray(response.body()); |
|||
for (int i = 0; i < inst_rows.size(); i++) { |
|||
JSONObject inst_jo = inst_rows.getJSONObject(i); |
|||
String inst_code = inst_jo.getString("task_code"); |
|||
Instruction inst = instructionService.findByCodeFromCache(inst_code); |
|||
if (ObjectUtil.isEmpty(inst)) { |
|||
continue; |
|||
} |
|||
//反馈结果状态
|
|||
log.info("instcode:" + inst_code + "," + inst_jo.toString()); |
|||
|
|||
String state = inst_jo.getString("state"); |
|||
String vehicle = ""; |
|||
//正在执行指令agv车号
|
|||
if (!StrUtil.isEmpty(inst_jo.getString("vehicle"))) { |
|||
vehicle = inst_jo.getString("vehicle"); |
|||
inst.setCarno(vehicle); |
|||
} |
|||
// RAW:初始状态
|
|||
// ACTIVE:业务订单已激活
|
|||
// DISPATCHABLE:业务订单已通过系统验证,等待被调度执行
|
|||
// BEING_PROCESSED:业务订单正在被执行
|
|||
// WITHDRAWN:业务订单已被撤销
|
|||
// FINISHED:业务订单已完成
|
|||
// 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(inst_jo.getString("task_code")); |
|||
} |
|||
} |
|||
JSONArray ja = inst_jo.getJSONArray("destinations"); |
|||
for (int j = 0; j < ja.size(); j++) { |
|||
JSONObject jo = ja.getJSONObject(j); |
|||
JSONArray pro_rows = jo.getJSONArray("properties"); |
|||
//Load 取货动作 Unload放货动作 Wait等待
|
|||
String operation = jo.getString("operation"); |
|||
String device = jo.getString("locationName"); |
|||
for (int k = 0; k < pro_rows.size(); k++) { |
|||
JSONObject item = pro_rows.getJSONObject(k); |
|||
if ("true".equals(item.get("value"))) { |
|||
String param = item.get("key").toString(); |
|||
//EntryRequired是否进入前等待 PauseOnStation是否离开等待 Wait在该点进行等待
|
|||
agvService.process(inst_code, param, device, operation, vehicle); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} catch (Exception e) { |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,6 @@ |
|||
{ |
|||
"name": "zhongDingTianNeng", |
|||
"lockfileVersion": 2, |
|||
"requires": true, |
|||
"packages": {} |
|||
} |
Loading…
Reference in new issue