add 自动查询仙工AGV任务状态
This commit is contained in:
@@ -45,7 +45,7 @@ public interface XianGongAgvService {
|
||||
*/
|
||||
public HttpResponse queryXZAgvDeviceStatus();
|
||||
|
||||
public HttpResponse queryXZAgvInstStatus(String instCode);
|
||||
public HttpResponse queryXZAgvInstStatus();
|
||||
|
||||
/**
|
||||
* 删除先知任务
|
||||
|
||||
@@ -180,19 +180,17 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
||||
|
||||
@LokiLog(type = LokiLogType.AGV)
|
||||
@Override
|
||||
public HttpResponse queryXZAgvInstStatus(String instCode) {
|
||||
|
||||
public HttpResponse queryXZAgvInstStatus() {
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) {
|
||||
String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
|
||||
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
|
||||
|
||||
agvurl = agvurl + ":" + agvport + "/api/route/transportOrders/" + instCode;
|
||||
agvurl = agvurl + ":" + agvport + "/orders?page=1&size=9999";
|
||||
|
||||
HttpResponse result = HttpRequest.get(agvurl)
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute();
|
||||
System.out.println("查询agv指令数据:" + result.body());
|
||||
|
||||
log.info("queryXZAgvInstStatus----查询agv指令数据:{}" + result.body());
|
||||
return result;
|
||||
} else {
|
||||
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
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.XianGongAgvService;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 查询AGV任务状态
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class QueryXZAgvTaskStatus {
|
||||
|
||||
@Autowired
|
||||
InstructionService instructionService;
|
||||
|
||||
@Autowired
|
||||
XianGongAgvService agvService;
|
||||
|
||||
@Autowired
|
||||
AcsToWmsService acsToWmsService;
|
||||
|
||||
@Autowired
|
||||
TaskService taskService;
|
||||
|
||||
public void run() throws Exception {
|
||||
|
||||
HttpResponse response = agvService.queryXZAgvInstStatus();
|
||||
JSONObject jo = JSONArray.parseObject(response.body());
|
||||
|
||||
JSONArray ja = JSONArray.parseArray(jo.getString("list"));
|
||||
for (int i = 0; i < ja.size(); i++) {
|
||||
JSONObject one = (JSONObject) ja.get(i);
|
||||
String inst_code = one.getString("id");
|
||||
Instruction inst = instructionService.findByCodeFromCache(inst_code);
|
||||
if (ObjectUtil.isEmpty(inst))
|
||||
continue;
|
||||
|
||||
String state = one.getString("state");
|
||||
if (!StrUtil.isEmpty(one.getString("vehicle"))) {
|
||||
String carno = one.getString("vehicle");
|
||||
inst.setCarno(carno);
|
||||
}
|
||||
|
||||
// 已创建=CREATED,
|
||||
// 待分配=TOBEDISPATCHED,
|
||||
// 正在执行=RUNNING,
|
||||
// 完成=FINISHED,
|
||||
// 失败=FAILED(主动失败),
|
||||
// 终止=STOPPED(被人为终止),
|
||||
// 无法执行=Error(参数错误),
|
||||
// 等待=WAITING
|
||||
|
||||
//执行中
|
||||
if ("RUNNING".equals(state) || "CREATED".equals(state) || "TOBEDISPATCHED".equals(state) || "WAITING".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 ("STOPPED".equals(state) || "FAILED".equals(state) || "Error".equals(state)) {
|
||||
if (inst != null) {
|
||||
inst.setInstruction_status("1");
|
||||
instructionService.update(inst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user