张江玮
1 year ago
3 changed files with 88 additions and 6 deletions
@ -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); |
|||
} |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
Loading…
Reference in new issue