diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index 62cac7f..c309725 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -834,6 +834,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { @Transactional(rollbackFor = Exception.class) public void update(TaskDto dto) { TaskDto entity = this.findById(dto.getTask_id()); + Instruction instruction = instructionService.findByTaskcode(dto.getTask_code()); + if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); String currentUsername = SecurityUtils.getCurrentUsername(); @@ -863,6 +865,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { feed_jo.put("task_code", dto.getTask_code()); feed_jo.put("ext_task_uuid", entity.getExt_task_uuid()); feed_jo.put("task_status", dto.getTask_status()); + feed_jo.put("agv_code",instruction.getCarno()); JSONArray ja = new JSONArray(); ja.add(feed_jo); String message = null; diff --git a/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java b/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java index 0ee0c80..bf8b351 100644 --- a/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java +++ b/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java @@ -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); diff --git a/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java b/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java index 91fc20d..a3319f7 100644 --- a/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java +++ b/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java @@ -11,6 +11,7 @@ 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.nl.acs.task.service.dto.TaskDto; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -71,16 +72,22 @@ public class QueryXZAgvTaskStatus { if (inst != null) { inst.setInstruction_status("1"); instructionService.update(inst); + TaskDto taskDto = taskService.findByCode(inst.getTask_code()); + taskService.update(taskDto); } } else if ("FINISHED".equals(state)) { if (inst != null) { inst.setInstruction_status("2"); instructionService.finish(inst); + TaskDto taskDto = taskService.findByCode(inst.getTask_code()); + taskService.update(taskDto); } } else if ("STOPPED".equals(state) || "FAILED".equals(state) || "Error".equals(state)) { if (inst != null) { inst.setInstruction_status("1"); instructionService.update(inst); + TaskDto taskDto = taskService.findByCode(inst.getTask_code()); + taskService.update(taskDto); } } }