Browse Source

定时器和接口数据

master
周俊杰 2 years ago
parent
commit
7d0e51eccd
  1. 0
      hd/logPath_IS_UNDEFINED/2023-03-30.0.log
  2. 0
      hd/logPath_IS_UNDEFINED/ACS请求ERP/2023-03-30.0.log
  3. 0
      hd/logPath_IS_UNDEFINED/ACS请求WMS/2023-03-30.0.log
  4. 0
      hd/logPath_IS_UNDEFINED/AGV请求离开/2023-03-30.0.log
  5. 0
      hd/logPath_IS_UNDEFINED/NDC/2023-03-30.0.log
  6. 0
      hd/logPath_IS_UNDEFINED/WMS下发ACS/2023-03-30.0.log
  7. 0
      hd/logPath_IS_UNDEFINED/反馈AGV请求/2023-03-30.0.log
  8. 0
      hd/logPath_IS_UNDEFINED/扫码记录/2023-03-30.0.log
  9. 0
      hd/logPath_IS_UNDEFINED/查询AGV指令状态/2023-03-30.0.log
  10. 0
      hd/logPath_IS_UNDEFINED/查询仙知AGV指令状态/2023-03-30.0.log
  11. 0
      hd/logPath_IS_UNDEFINED/自动创建指令/2023-03-30.0.log
  12. 26
      hd/nladmin-system/src/main/java/org/nl/acs/agv/AgvUtil.java
  13. 4
      hd/nladmin-system/src/main/java/org/nl/acs/agv/rest/ZheDaAgvController.java
  14. 11
      hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvService.java
  15. 381
      hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java
  16. 7
      hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java
  17. 101
      hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryAgvTaskStatus.java

0
hd/logPath_IS_UNDEFINED/2023-03-30.0.log

0
hd/logPath_IS_UNDEFINED/ACS请求ERP/2023-03-30.0.log

0
hd/logPath_IS_UNDEFINED/ACS请求WMS/2023-03-30.0.log

0
hd/logPath_IS_UNDEFINED/AGV请求离开/2023-03-30.0.log

0
hd/logPath_IS_UNDEFINED/NDC/2023-03-30.0.log

0
hd/logPath_IS_UNDEFINED/WMS下发ACS/2023-03-30.0.log

0
hd/logPath_IS_UNDEFINED/反馈AGV请求/2023-03-30.0.log

0
hd/logPath_IS_UNDEFINED/扫码记录/2023-03-30.0.log

0
hd/logPath_IS_UNDEFINED/查询AGV指令状态/2023-03-30.0.log

0
hd/logPath_IS_UNDEFINED/查询仙知AGV指令状态/2023-03-30.0.log

0
hd/logPath_IS_UNDEFINED/自动创建指令/2023-03-30.0.log

26
hd/nladmin-system/src/main/java/org/nl/acs/agv/AgvUtil.java

@ -0,0 +1,26 @@
package org.nl.acs.agv;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
public class AgvUtil {
/**
* 获得之后num个天的时间
*
* @param num
* @return
*/
public static String getNextDay(int num) {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH, num);
Date date = calendar.getTime();
TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai");
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
df.setTimeZone(tz);
String nowAsISO = df.format(date);
return nowAsISO;
}
}

4
hd/nladmin-system/src/main/java/org/nl/acs/agv/rest/ZheDaAgvController.java

@ -0,0 +1,4 @@
package org.nl.acs.agv.rest;
public class ZheDaAgvController {
}

11
hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvService.java

@ -10,6 +10,14 @@ import java.util.Map;
public interface AgvService {
/**
* 下发指令
* @param inst 指令对象
* @return
* @throws Exception
*/
public HttpResponse sendAgvInstToAgv(Instruction inst) throws Exception;
/**
* 下发agv任务
*
@ -39,6 +47,7 @@ public interface AgvService {
void updateAgvFromCache(AgvDto dto);
String process(String jobno, String type, String address, String action, String processingVehicle);
/**
* 删除magic任务
*
@ -74,7 +83,7 @@ public interface AgvService {
* @param processingVehicle
* @return
*/
public String process(String jobno, String type, String address, String action, String processingVehicle);
/**
* Magic AGV 请求离开调用

381
hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java

@ -23,6 +23,7 @@ import org.nl.acs.device_driver.special_ordinary_site.SpecialOrdinarySiteDeviceD
import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver;
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.device_driver.standard_manipulator_inspect_site.StandardManipulatorInspectSiteDeviceDriver;
import org.nl.acs.device_driver.standard_manipulator_stacking_site.StandardManipulatorStackingSiteDeviceDriver;
import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.standard_storage.StandardStorageDeviceDriver;
import org.nl.acs.device_driver.weighing_site.WeighingSiteDeviceDriver;
@ -38,6 +39,7 @@ import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.opc.DeviceType;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.exception.BadRequestException;
import org.nl.logger.BusinessLogger;
import org.nl.start.auto.run.NDCSocketConnectionAutoRun;
@ -75,22 +77,22 @@ public class AgvServiceImpl implements AgvService {
Map<String, AgvDto> AGVDeviceStatus = new HashMap();
/**
* 获得之后num个天的时间
*
* @param num
* @return
*/
public static String getNextDay(int num) {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH, num);
Date date = calendar.getTime();
TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai");
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
df.setTimeZone(tz);
String nowAsISO = df.format(date);
return nowAsISO;
}
// /**
// * 获得之后num个天的时间
// *
// * @param num
// * @return
// */
// public static String getNextDay(int num) {
// Calendar calendar = Calendar.getInstance();
// calendar.add(Calendar.DAY_OF_MONTH, num);
// Date date = calendar.getTime();
// TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai");
// DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
// df.setTimeZone(tz);
// String nowAsISO = df.format(date);
// return nowAsISO;
// }
/**
* 返回一个点位操作子任务
@ -258,6 +260,48 @@ public class AgvServiceImpl implements AgvService {
return destinationOrder;
}
@Override
public HttpResponse sendAgvInstToAgv(Instruction inst) throws Exception {
com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject();
String start_point_code = inst.getStart_point_code();
String next_point_code = inst.getNext_point_code();
//1楼AGV普通任务
//2楼AGV普通任务
//2楼AGV起点追加任务
//2楼AGV终点追加任务
String task_type = inst.getInstruction_type();
jo.put("deadline", this.getNextDay(1));
//判断是否追加任务
jo.put("complete", "true");
jo.put("task_code", inst.getInstruction_code());
//根据任务,下发指令类型
com.alibaba.fastjson.JSONArray destinations = new com.alibaba.fastjson.JSONArray();
destinations.add(destination(start_point_code, "Load", "1", "1"));
destinations.add(destination(next_point_code, "Unload", "1", "1"));
jo.put("destinations", destinations);
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
String agvurl = acsConfigService.findByCode(AcsConfig.AGVURL).getValue();
String agvport = acsConfigService.findByCode(AcsConfig.AGVPORT).getValue();
agvurl = agvurl + ":" + agvport + "/rmds/v1/transportOrders/" + inst.getInstruction_code();
log.info("下发agv任务请求:{}", agvurl);
log.info("下发agv任务参数:{}", jo.toString());
HttpResponse result = HttpRequest.post(agvurl)
.body(String.valueOf(jo))//表单内容
.timeout(20000)//超时,毫秒
.execute();
log.info("下发agv任务请求反馈:{}", result);
return result;
} else {
return null;
}
}
@Override
public HttpResponse sendAgvInstToMagic(Instruction inst) throws Exception {
JSONArray ja = new JSONArray();
@ -488,11 +532,14 @@ public class AgvServiceImpl implements AgvService {
String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + instCode;
agvurl = agvurl + ":" + agvport + "/rmds/v1/transportOrders/query";
HttpResponse result = HttpRequest.get(agvurl)
HttpResponse result = HttpRequest.post(agvurl)
.body("{}")
.timeout(20000)//超时,毫秒
.execute();
log.info("查询agv指令数据:{}", result.body());
System.out.println("查询agv指令数据:" + result.body());
return result;
@ -791,233 +838,119 @@ public class AgvServiceImpl implements AgvService {
//1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
@Override
public synchronized String process(String jobno, String type, String address, String action, String processingVehicle) {
log.info("查询到AGV请求参数,jobno:{},address:{}", jobno + ",address:" + address + ",type:" + type + ",action:" + action);
boolean is_feedback = false;
String str = "";
String backaddress = address;
if (address.indexOf(".") > 0) {
str = address.substring(address.indexOf("."), address.length());
address = address.substring(0, address.indexOf("."));
} else if (address.indexOf("-") > 0) {
address = address.substring(0, address.indexOf("-"));
}
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
Instruction inst = instructionService.findByCodeFromCache(jobno);
public synchronized String process(String jobno, String type, String address, String action, String processingVehicle)
{
{
log.info("查询到AGV请求参数,jobno:{},address:{}", jobno + ",address:" + address + ",type:" + type + ",action:" + action);
//释放AGV资源,继续后续动作
boolean is_feedback = false;
String str = "";
String backaddress = address;
if (address.indexOf(".") > 0) {
str = address.substring(address.indexOf(".") + 1, address.length());
address = address.substring(0, address.indexOf("."));
} else if (address.indexOf("-") > 0) {
address = address.substring(0, address.indexOf("-"));
}
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
TaskService taskService = SpringContextHolder.getBean("taskServiceImpl");
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
Instruction inst = instructionService.findByCodeFromCache(jobno);
TaskDto task = taskService.findByCode(inst.getTask_code());
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device addressdevice = appService.findDeviceByCode(address);
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
SpecialOrdinarySiteDeviceDriver specialOrdinarySiteDeviceDriver;
YzjaSpecialDeviceDriver yzjaSpecialDeviceDriver;
//请求进入
if ("onEntry".equals(type)) {
if (addressdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) addressdevice.getDeviceDriver();
//请求取货
if ("Load".equals(action)) {
if (standardInspectSiteDeviceDriver.getMode() == 2 && standardInspectSiteDeviceDriver.getMove() > 0) {
inst.setExecute_status("1");
is_feedback = true;
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device addressdevice = appService.findDeviceByCode(address);
StandardManipulatorStackingSiteDeviceDriver standardManipulatorStackingSiteDeviceDriver;
//取货的进入前等待和离开等待
if (action.equals("Load")) {
if ("EntryRequired".equals(type)) {
//
if (addressdevice.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) {
standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) addressdevice.getDeviceDriver();
if(standardManipulatorStackingSiteDeviceDriver.getMove()==1){
is_feedback = true;
} else {
log.info("设备{} 请求取货,光电信号:{}",addressdevice,standardManipulatorStackingSiteDeviceDriver.getMove());
}
}
//请求放货
} else if ("Unload".equals(action)) {
if (standardInspectSiteDeviceDriver.getMode() == 2 && standardInspectSiteDeviceDriver.getMove() == 0) {
inst.setExecute_status("3");
if (addressdevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
is_feedback = true;
}
}
}
if (addressdevice.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) {
specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver();
//请求取货
if ("Load".equals(action)) {
if (addressdevice.getHas_goods() > 0) {
inst.setExecute_status("1");
is_feedback = true;
if ("PauseOnStation".equals(type)) {
if (addressdevice.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) {
standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) addressdevice.getDeviceDriver();
if(standardManipulatorStackingSiteDeviceDriver.getMove()==0){
is_feedback = true;
} else {
log.info("设备{} 请求离开,光电信号:{}",addressdevice,standardManipulatorStackingSiteDeviceDriver.getMove());
}
}
//请求放货
} else if ("Unload".equals(action)) {
if (addressdevice.getHas_goods() == 0) {
inst.setExecute_status("3");
if (addressdevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
is_feedback = true;
}
}
}
if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver();
//请求取货
if ("Load".equals(action)) {
if (addressdevice.getHas_goods() > 0) {
inst.setExecute_status("1");
is_feedback = true;
//放货的进入前等待和离开等待
if (action.equals("Unload")) {
if ("EntryRequired".equals(type)) {
if (addressdevice.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) {
standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) addressdevice.getDeviceDriver();
if(standardManipulatorStackingSiteDeviceDriver.getMove()==0){
is_feedback = true;
} else {
log.info("设备{} 请求放货,光电信号:{}",addressdevice,standardManipulatorStackingSiteDeviceDriver.getMove());
}
}
//请求放货
} else if ("Unload".equals(action)) {
if (addressdevice.getHas_goods() == 0) {
inst.setExecute_status("3");
if (addressdevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
is_feedback = true;
}
}
}
if (addressdevice.getDeviceDriver() instanceof YzjaSpecialDeviceDriver) {
yzjaSpecialDeviceDriver = (YzjaSpecialDeviceDriver) addressdevice.getDeviceDriver();
//是否需要人工确认
String is_unlock = yzjaSpecialDeviceDriver.getIs_unlock();
//请求取货
if ("Load".equals(action)) {
if (is_unlock.equals("true")) {
if (addressdevice.getHas_goods() > 0 && yzjaSpecialDeviceDriver.getManua_confirm() == 2) {
yzjaSpecialDeviceDriver.setManua_confirm(0);
inst.setExecute_status("1");
is_feedback = true;
} else if (ObjectUtil.isEmpty(inst.getExecute_status()) || !inst.getExecute_status().equals("1")){
yzjaSpecialDeviceDriver.setManua_confirm(1);
}
} else {
if (addressdevice.getHas_goods() > 0) {
inst.setExecute_status("1");
is_feedback = true;
}
}
//请求放货
} else if ("Unload".equals(action)) {
if (is_unlock.equals("true")) {
if (addressdevice.getHas_goods() == 0 && yzjaSpecialDeviceDriver.getManua_confirm() == 2) {
yzjaSpecialDeviceDriver.setManua_confirm(0);
inst.setExecute_status("3");
is_feedback = true;
} else if (ObjectUtil.isEmpty(inst.getExecute_status()) || !inst.getExecute_status().equals("3")){
yzjaSpecialDeviceDriver.setManua_confirm(1);
}
} else {
if (addressdevice.getHas_goods() == 0) {
inst.setExecute_status("3");
if ("PauseOnStation".equals(type)) {
if (addressdevice.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) {
standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) addressdevice.getDeviceDriver();
if(standardManipulatorStackingSiteDeviceDriver.getMove()==1){
is_feedback = true;
} else {
log.info("设备{} 请求离开,光电信号:{}",addressdevice,standardManipulatorStackingSiteDeviceDriver.getMove());
}
}
}
}
if (addressdevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
//请求取货
if ("Load".equals(action)) {
inst.setExecute_status("1");
is_feedback = true;
//请求放货
} else if ("Unload".equals(action)) {
inst.setExecute_status("3");
is_feedback = true;
}
}
//取放货完成
} else if ("onStation".equals(type)) {
System.out.println("取放货完成");
if (addressdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) addressdevice.getDeviceDriver();
//取货完成
if ("Load".equals(action)) {
if (standardInspectSiteDeviceDriver.getMode() == 2 && standardInspectSiteDeviceDriver.getMove() == 0) {
inst.setExecute_device_code(processingVehicle);
inst.setExecute_status("2");
is_feedback = true;
}
//放货完成
} else if ("Unload".equals(action)) {
if (standardInspectSiteDeviceDriver.getMode() == 2 && standardInspectSiteDeviceDriver.getMove() > 0) {
inst.setExecute_device_code(address);
inst.setExecute_status("4");
if (addressdevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
is_feedback = true;
}
}
}
if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver();
//取货完成
if ("Load".equals(action)) {
inst.setExecute_device_code(processingVehicle);
inst.setExecute_status("2");
is_feedback = true;
//放货完成
} else if ("Unload".equals(action)) {
inst.setExecute_device_code(address);
inst.setExecute_status("4");
is_feedback = true;
com.alibaba.fastjson.JSONObject requestjo = new com.alibaba.fastjson.JSONObject();
if (is_feedback) {
requestjo.put("task_code", jobno);
requestjo.put("operation", action);
if (type.equals("entryRequired") || type.equals("EntryRequired")) {
requestjo.put("entryRequired", "true");
} else {
requestjo.put("pauseOnStation", "true");
}
log.info("反馈AGV请求数据:{}", requestjo);
System.out.println("back agv:" + requestjo);
}
if (addressdevice.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) {
specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver();
//取货完成
if ("Load".equals(action)) {
inst.setExecute_device_code(processingVehicle);
inst.setExecute_status("2");
is_feedback = true;
//放货完成
} else if ("Unload".equals(action)) {
inst.setExecute_device_code(processingVehicle);
inst.setExecute_status("4");
is_feedback = true;
}
}
if (addressdevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
//取货完成
if ("Load".equals(action)) {
inst.setExecute_device_code(processingVehicle);
inst.setExecute_status("2");
is_feedback = true;
//放货完成
} else if ("Unload".equals(action)) {
inst.setExecute_device_code(processingVehicle);
inst.setExecute_status("4");
is_feedback = true;
}
}
}
JSONObject requestjo = new JSONObject();
JSONArray ja = new JSONArray();
if (is_feedback) {
String param = "";
JSONObject jo = new JSONObject();
if (str.length() > 0) {
backaddress = backaddress + str;
}
if ("onEntry".equals(type)) {
param = "EntryPermitted-" + backaddress + action;
} else if ("onStation".equals(type)) {
param = "ContinueOnStation-" + backaddress + action;
}
String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
jo.put("key", param);
jo.put("value", "False");
ja.add(jo);
requestjo.put("properties", ja);
log.info("反馈AGV请求数据:{}", requestjo);
System.out.println("back agv:" + requestjo);
agvurl = agvurl + ":" + agvport + "/api/route/transportOrders/" + jobno + "/interact";
String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + jobno + "/interact";
HttpResponse result = HttpRequest.post(agvurl)
.body(String.valueOf(requestjo))
.timeout(20000)//超时,毫秒
.execute();
}
return requestjo.toString();
HttpResponse result = HttpRequest.post(agvurl)
.body(String.valueOf(requestjo))
.timeout(20000)//超时,毫秒
.execute();
}
is_feedback = false;
return requestjo.toString();
}
@Override
@ -2002,6 +1935,24 @@ public class AgvServiceImpl implements AgvService {
return ret;
}
/**
* 获得之后num个天的时间
*
* @param num
* @return
*/
public static String getNextDay(int num) {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH, num);
Date date = calendar.getTime();
TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai");
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
df.setTimeZone(tz);
String nowAsISO = df.format(date);
return nowAsISO;
}
public static void main(String[] args) {
String address = "L1-01-01";
if (address.indexOf("-") > 0) {

7
hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java

@ -450,6 +450,13 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
dto.setSend_status("1");
}
}
} else if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "4")) {
HttpResponse result = agvService.sendAgvInstToAgv(dto);
if (ObjectUtils.isEmpty(result) || result.getStatus() != 200) {
dto.setSend_status("2");
} else {
dto.setSend_status("1");
}
}
}
} catch (Exception e) {

101
hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryAgvTaskStatus.java

@ -0,0 +1,101 @@
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) {
}
}
}
Loading…
Cancel
Save