|
|
@ -2,9 +2,14 @@ package org.nl.modules.quartz.task; |
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
|
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.apache.commons.lang3.ObjectUtils; |
|
|
|
import org.nl.acs.agv.server.AgvService; |
|
|
|
import org.nl.acs.config.AcsConfig; |
|
|
|
import org.nl.acs.config.server.AcsConfigService; |
|
|
|
import org.nl.acs.device_driver.lamp_three_color.LampThreecolorDeviceDriver; |
|
|
@ -28,6 +33,7 @@ import org.nl.logger.BusinessLoggerFactory; |
|
|
|
import org.nl.logger.NoRepeatBusinessLogger; |
|
|
|
import org.nl.logger.impl.BusinessLoggerImpl; |
|
|
|
import org.nl.utils.SpringContextHolder; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
@ -41,6 +47,8 @@ import java.util.List; |
|
|
|
public class AutoCreateInst { |
|
|
|
protected BusinessLogger execute_log; |
|
|
|
protected NoRepeatBusinessLogger device_log; |
|
|
|
@Autowired |
|
|
|
AgvService agvService; |
|
|
|
|
|
|
|
private volatile boolean lock = false; |
|
|
|
|
|
|
@ -404,6 +412,54 @@ public class AutoCreateInst { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HttpResponse response = agvService.queryXZAgvInstStatus(); |
|
|
|
JSONObject jo = JSONArray.parseObject(response.body()); |
|
|
|
|
|
|
|
JSONArray ja = JSONArray.parseArray(jo.getString("list")); |
|
|
|
for (int j = 0; j < ja.size(); j++) { |
|
|
|
JSONObject one = (JSONObject) ja.get(j); |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//创建指令后修改任务状态
|
|
|
|
acsTask.setTask_status("1"); |
|
|
|
taskserver.update(acsTask); |
|
|
|