|
@ -1,5 +1,6 @@ |
|
|
package org.nl.acs.agv.server.impl; |
|
|
package org.nl.acs.agv.server.impl; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import cn.hutool.http.HttpRequest; |
|
|
import cn.hutool.http.HttpRequest; |
|
@ -39,13 +40,16 @@ import org.nl.acs.opc.DeviceAppService; |
|
|
import org.nl.acs.opc.DeviceAppServiceImpl; |
|
|
import org.nl.acs.opc.DeviceAppServiceImpl; |
|
|
import org.nl.acs.opc.DeviceType; |
|
|
import org.nl.acs.opc.DeviceType; |
|
|
import org.nl.acs.task.service.TaskService; |
|
|
import org.nl.acs.task.service.TaskService; |
|
|
|
|
|
import org.nl.acs.task.service.dto.TaskDto; |
|
|
import org.nl.exception.BadRequestException; |
|
|
import org.nl.exception.BadRequestException; |
|
|
import org.nl.logger.BusinessLogger; |
|
|
import org.nl.logger.BusinessLogger; |
|
|
import org.nl.start.auto.run.NDCSocketConnectionAutoRun; |
|
|
import org.nl.start.auto.run.NDCSocketConnectionAutoRun; |
|
|
import org.nl.utils.SpringContextHolder; |
|
|
import org.nl.utils.SpringContextHolder; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
import java.text.DateFormat; |
|
|
import java.text.DateFormat; |
|
|
import java.text.SimpleDateFormat; |
|
|
import java.text.SimpleDateFormat; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
@ -76,6 +80,8 @@ public class AgvServiceImpl implements AgvService { |
|
|
|
|
|
|
|
|
Map<String, AgvDto> AGVDeviceStatus = new HashMap(); |
|
|
Map<String, AgvDto> AGVDeviceStatus = new HashMap(); |
|
|
|
|
|
|
|
|
|
|
|
@Value("${agvToAcs.addr}") |
|
|
|
|
|
private String addr; |
|
|
/** |
|
|
/** |
|
|
* 获得之后num个天的时间 |
|
|
* 获得之后num个天的时间 |
|
|
* |
|
|
* |
|
@ -589,19 +595,12 @@ public class AgvServiceImpl implements AgvService { |
|
|
String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); |
|
|
String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); |
|
|
String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); |
|
|
String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); |
|
|
|
|
|
|
|
|
String agvurl1 = agvurl + ":" + agvport + "/api/route/vehicles"; |
|
|
agvurl = agvurl + ":" + agvport + "/robotsStatus"; |
|
|
String agvurl2 = agvurl + ":" + agvport + "/api/route/vehicleDetails"; |
|
|
|
|
|
|
|
|
|
|
|
HttpResponse result = HttpRequest.get(agvurl1) |
|
|
HttpResponse result = HttpRequest.get(agvurl) |
|
|
.timeout(20000)//超时,毫秒
|
|
|
.timeout(20000)//超时,毫秒
|
|
|
.execute(); |
|
|
.execute(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HttpResponse result2 = HttpRequest.get(agvurl2) |
|
|
|
|
|
.timeout(20000)//超时,毫秒
|
|
|
|
|
|
.execute(); |
|
|
|
|
|
log.info("查询agv状态数据 vehicles:" + result.body()); |
|
|
|
|
|
log.info("查询agv状态数据 vehicleDetails:" + result2.body()); |
|
|
|
|
|
System.out.println("查询agv状态数据:" + result.body()); |
|
|
System.out.println("查询agv状态数据:" + result.body()); |
|
|
if (result.getStatus() == 200) { |
|
|
if (result.getStatus() == 200) { |
|
|
JSONArray ja = JSONArray.fromObject(result.body()); |
|
|
JSONArray ja = JSONArray.fromObject(result.body()); |
|
@ -611,7 +610,7 @@ public class AgvServiceImpl implements AgvService { |
|
|
String state = jo.getString("state"); |
|
|
String state = jo.getString("state"); |
|
|
String energyLevel = jo.getString("energyLevel"); |
|
|
String energyLevel = jo.getString("energyLevel"); |
|
|
String transportOrder = jo.getString("transportOrder"); |
|
|
String transportOrder = jo.getString("transportOrder"); |
|
|
JSONObject detailjo = JSONObject.fromObject(result2.body()); |
|
|
JSONObject detailjo = JSONObject.fromObject(result.body()); |
|
|
JSONObject item = (JSONObject) detailjo.get(name); |
|
|
JSONObject item = (JSONObject) detailjo.get(name); |
|
|
if(ObjectUtil.isEmpty(detailjo.get(name))){ |
|
|
if(ObjectUtil.isEmpty(detailjo.get(name))){ |
|
|
continue; |
|
|
continue; |
|
@ -1067,250 +1066,108 @@ public class AgvServiceImpl implements AgvService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public String waitPointRequest(String param) { |
|
|
public JSONObject xgAGVWaitPointRequest(JSONObject requestParam) { |
|
|
log.info("收到AGV请求参数:{}", param); |
|
|
log.info("仙工AGV请求取放货,请求参数 - {}", requestParam); |
|
|
String[] strs = param.split("-"); |
|
|
String instCode = requestParam.getString("task_code"); |
|
|
String address = strs[0]; |
|
|
Instruction inst = instructionService.findByCodeFromCache(instCode); |
|
|
String inst_code = strs[1]; |
|
|
if (ObjectUtil.isEmpty(inst)) { |
|
|
String type = strs[2]; |
|
|
throw new BadRequestException("请求失败,未找到指令!"); |
|
|
String newaddress = null; |
|
|
|
|
|
// 前置点会加上p
|
|
|
|
|
|
if (address.endsWith("IN")) { |
|
|
|
|
|
newaddress = address.substring(0, address.length() - 2); |
|
|
|
|
|
} else if (address.endsWith("OUT")) { |
|
|
|
|
|
newaddress = address.substring(0, address.length() - 3); |
|
|
|
|
|
} else if (address.endsWith("P") || address.endsWith("L") || address.endsWith("R")) { |
|
|
|
|
|
newaddress = address.substring(0, address.length() - 1); |
|
|
|
|
|
} else if (address.endsWith("CZ")) { |
|
|
|
|
|
newaddress = address.substring(0, address.length() - 2); |
|
|
|
|
|
} else if (address.endsWith("IQ") || address.endsWith("OQ")) { |
|
|
|
|
|
newaddress = address.substring(0, address.length() - 2); |
|
|
|
|
|
} else { |
|
|
|
|
|
newaddress = address; |
|
|
|
|
|
} |
|
|
|
|
|
boolean is_feedback = false; |
|
|
|
|
|
|
|
|
|
|
|
Device device = deviceAppService.findDeviceByCode(newaddress); |
|
|
|
|
|
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; |
|
|
|
|
|
MachinesSiteDeviceDriver machinesSiteDeviceDriver; |
|
|
|
|
|
WeighingSiteDeviceDriver weighingSiteDeviceDriver; |
|
|
|
|
|
StandardManipulatorInspectSiteDeviceDriver sandardManipulatorInspectSiteDeviceDriver; |
|
|
|
|
|
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; |
|
|
|
|
|
NdxySpecialTwoDeviceDriver ndxySpecialTwoDeviceDriver; |
|
|
|
|
|
YkbkSpecialDeviceDriver ykbkSpecialDeviceDriver; |
|
|
|
|
|
YzjaSpecialDeviceDriver yzjaSpecialDeviceDriver; |
|
|
|
|
|
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { |
|
|
|
|
|
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); |
|
|
|
|
|
//人工确认信号
|
|
|
|
|
|
if (standardOrdinarySiteDeviceDriver.getManua_confirm() == 2) { |
|
|
|
|
|
is_feedback = true; |
|
|
|
|
|
standardOrdinarySiteDeviceDriver.setManua_confirm(0); |
|
|
|
|
|
} else { |
|
|
|
|
|
standardOrdinarySiteDeviceDriver.setManua_confirm(1); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
|
|
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); |
|
|
|
|
|
//请求取货
|
|
|
|
|
|
if (StrUtil.equals(type, "01") && address.endsWith("IN") |
|
|
|
|
|
&& standardInspectSiteDeviceDriver.getMove() != 0) { |
|
|
|
|
|
standardInspectSiteDeviceDriver.writing(1, 1); |
|
|
|
|
|
is_feedback = true; |
|
|
|
|
|
} |
|
|
} |
|
|
//取货完成
|
|
|
TaskDto task = taskService.findByCodeFromCache(inst.getTask_code()); |
|
|
else if (StrUtil.equals(type, "02")) { |
|
|
if (ObjectUtil.isEmpty(task)) { |
|
|
standardInspectSiteDeviceDriver.writing(1, 2); |
|
|
throw new BadRequestException("请求失败,未找到指令对应任务!"); |
|
|
is_feedback = true; |
|
|
|
|
|
} |
|
|
} |
|
|
//取货完成离开
|
|
|
String address = requestParam.getString("address"); |
|
|
else if (StrUtil.equals(type, "05") && address.endsWith("OUT") |
|
|
if (StrUtil.isBlank(address)) { |
|
|
&& standardInspectSiteDeviceDriver.getMove() == 0) { |
|
|
throw new BadRequestException("请求失败,地址为空!"); |
|
|
standardInspectSiteDeviceDriver.writing(1, 5); |
|
|
|
|
|
is_feedback = true; |
|
|
|
|
|
} |
|
|
|
|
|
//请求放货
|
|
|
|
|
|
else if (StrUtil.equals(type, "03") && address.endsWith("IN") |
|
|
|
|
|
&& standardInspectSiteDeviceDriver.getMove() == 0) { |
|
|
|
|
|
standardInspectSiteDeviceDriver.writing(1, 3); |
|
|
|
|
|
is_feedback = true; |
|
|
|
|
|
} |
|
|
|
|
|
//放货完成
|
|
|
|
|
|
else if (StrUtil.equals(type, "04")) { |
|
|
|
|
|
standardInspectSiteDeviceDriver.writing(1, 4); |
|
|
|
|
|
is_feedback = true; |
|
|
|
|
|
} |
|
|
|
|
|
//放货完成离开
|
|
|
|
|
|
else if (StrUtil.equals(type, "06") && address.endsWith("OUT") |
|
|
|
|
|
&& standardInspectSiteDeviceDriver.getMove() != 0) { |
|
|
|
|
|
standardInspectSiteDeviceDriver.writing(1, 6); |
|
|
|
|
|
is_feedback = true; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
if (device.getDeviceDriver() instanceof StandardManipulatorInspectSiteDeviceDriver) { |
|
|
|
|
|
sandardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) device.getDeviceDriver(); |
|
|
|
|
|
//请求进
|
|
|
|
|
|
if (StrUtil.equals(type, "07") && address.endsWith("IQ")) { |
|
|
|
|
|
sandardManipulatorInspectSiteDeviceDriver.writing(1, 7); |
|
|
|
|
|
if ( sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 1 |
|
|
|
|
|
|| sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 3) { |
|
|
|
|
|
is_feedback = true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//请求取货
|
|
|
//请求取货
|
|
|
else if (StrUtil.equals(type, "01") && address.endsWith("IN")) { |
|
|
if (address.contains("INGET")) { |
|
|
sandardManipulatorInspectSiteDeviceDriver.writing(1, 1); |
|
|
JSONObject jo=new JSONObject(); |
|
|
if ((sandardManipulatorInspectSiteDeviceDriver.getActoin() == 1 || sandardManipulatorInspectSiteDeviceDriver.getActoin() == 3) |
|
|
jo.put("device_code",inst.getStart_device_code()); |
|
|
&& sandardManipulatorInspectSiteDeviceDriver.getMove() != 0) { |
|
|
jo.put("device_status","enter"); |
|
|
is_feedback = true; |
|
|
log.info("请求参数:{}", jo); |
|
|
} |
|
|
JSONArray ja=new JSONArray(); |
|
|
} |
|
|
for(Object key:jo.keySet()){ |
|
|
//取货完成
|
|
|
JSONObject jo1=new JSONObject(); |
|
|
else if (StrUtil.equals(type, "02")) { |
|
|
jo1.put(key,jo.get(key)); |
|
|
sandardManipulatorInspectSiteDeviceDriver.writing(1, 2); |
|
|
ja.add(jo1); |
|
|
is_feedback = true; |
|
|
} |
|
|
} |
|
|
HttpResponse result=acsToWmsService.vehicle(ja); |
|
|
//取货完成离开
|
|
|
com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body()); |
|
|
else if (StrUtil.equals(type, "05") && address.endsWith("OUT")) { |
|
|
int responseCode = response.getInteger("status"); |
|
|
sandardManipulatorInspectSiteDeviceDriver.writing(1, 5); |
|
|
if (responseCode == 200) { |
|
|
if ((sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 2 |
|
|
log.info("上位允许取货 请求结果{}", responseCode); |
|
|
|| sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 3) && sandardManipulatorInspectSiteDeviceDriver.getMove() == 0) { |
|
|
|
|
|
is_feedback = true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//请求离开
|
|
|
|
|
|
else if (StrUtil.equals(type, "08") && address.endsWith("OQ")) { |
|
|
|
|
|
sandardManipulatorInspectSiteDeviceDriver.writing(1, 8); |
|
|
|
|
|
if (sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 2 |
|
|
|
|
|
|| sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 3) { |
|
|
|
|
|
is_feedback = true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//请求放货
|
|
|
|
|
|
else if (StrUtil.equals(type, "03") && address.endsWith("IN")) { |
|
|
|
|
|
sandardManipulatorInspectSiteDeviceDriver.writing(1, 3); |
|
|
|
|
|
if ((sandardManipulatorInspectSiteDeviceDriver.getActoin() == 2 || sandardManipulatorInspectSiteDeviceDriver.getActoin() == 3) |
|
|
|
|
|
&& sandardManipulatorInspectSiteDeviceDriver.getMove() == 0) { |
|
|
|
|
|
is_feedback = true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//放货完成
|
|
|
|
|
|
else if (StrUtil.equals(type, "04")) { |
|
|
|
|
|
sandardManipulatorInspectSiteDeviceDriver.writing(1, 4); |
|
|
|
|
|
is_feedback = true; |
|
|
|
|
|
} |
|
|
|
|
|
//放货完成离开
|
|
|
|
|
|
else if (StrUtil.equals(type, "06") && address.endsWith("OUT")) { |
|
|
|
|
|
sandardManipulatorInspectSiteDeviceDriver.writing(1, 6); |
|
|
|
|
|
if ((sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 2 |
|
|
|
|
|
|| sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 3) && sandardManipulatorInspectSiteDeviceDriver.getMove() != 0) { |
|
|
|
|
|
is_feedback = true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
if (device.getDeviceDriver() instanceof WeighingSiteDeviceDriver) { |
|
|
|
|
|
weighingSiteDeviceDriver = (WeighingSiteDeviceDriver) device.getDeviceDriver(); |
|
|
|
|
|
Instruction inst = instructionService.findByCodeFromCache(inst_code); |
|
|
|
|
|
weighingSiteDeviceDriver.setInst(inst); |
|
|
|
|
|
//调用erp接口
|
|
|
|
|
|
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.HASOTHERSYSTEM).toString(), "1")) { |
|
|
|
|
|
log.info("请求ERP接口参数:{}", inst.getStart_device_code()); |
|
|
|
|
|
JSONObject jo = acsToErpService.sendDeviceToWms(inst.getStart_device_code()); |
|
|
|
|
|
log.info("ERP接口反馈:{}", jo); |
|
|
|
|
|
} |
|
|
|
|
|
is_feedback = true; |
|
|
|
|
|
} |
|
|
|
|
|
if (device.getDeviceDriver() instanceof MachinesSiteDeviceDriver) { |
|
|
|
|
|
machinesSiteDeviceDriver = (MachinesSiteDeviceDriver) device.getDeviceDriver(); |
|
|
|
|
|
//请求进
|
|
|
|
|
|
if (address.endsWith("IN")) { |
|
|
|
|
|
if (machinesSiteDeviceDriver.getIoaction() == 1 || machinesSiteDeviceDriver.getIoaction() == 3) { |
|
|
|
|
|
is_feedback = true; |
|
|
|
|
|
}else{ |
|
|
}else{ |
|
|
machinesSiteDeviceDriver.writing(6); |
|
|
throw new BadRequestException("上位系统不允许取货"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
//请求离开
|
|
|
//取货完成离开
|
|
|
else if (address.endsWith("OUT")) { |
|
|
if (address.contains("OUTGET")) { |
|
|
machinesSiteDeviceDriver.writing(6); |
|
|
JSONObject jo=new JSONObject(); |
|
|
machinesSiteDeviceDriver.writing(6); |
|
|
jo.put("device_code",inst.getStart_device_code()); |
|
|
is_feedback = true; |
|
|
jo.put("device_status","left"); |
|
|
|
|
|
log.info("请求参数:{}", jo); |
|
|
} else { |
|
|
JSONArray ja=new JSONArray(); |
|
|
|
|
|
for(Object key:jo.keySet()){ |
|
|
if (machinesSiteDeviceDriver.getIoaction() == 2 || machinesSiteDeviceDriver.getIoaction() == 3) { |
|
|
JSONObject jo1=new JSONObject(); |
|
|
is_feedback = true; |
|
|
jo1.put(key,jo.get(key)); |
|
|
|
|
|
ja.add(jo1); |
|
|
|
|
|
} |
|
|
|
|
|
HttpResponse result=acsToWmsService.vehicle(ja); |
|
|
|
|
|
com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body()); |
|
|
|
|
|
int responseCode = response.getInteger("status"); |
|
|
|
|
|
if (responseCode == 200) { |
|
|
|
|
|
log.info("上位允许取货离开 请求结果{}", responseCode); |
|
|
}else{ |
|
|
}else{ |
|
|
machinesSiteDeviceDriver.writing(5); |
|
|
throw new BadRequestException("上位系统不允许取货完成离开"); |
|
|
machinesSiteDeviceDriver.writing(2, device.getAddress() == null ? 0 : Integer.parseInt(device.getAddress())); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (device.getDeviceDriver() instanceof NdxySpecialTwoDeviceDriver) { |
|
|
|
|
|
ndxySpecialTwoDeviceDriver = (NdxySpecialTwoDeviceDriver) device.getDeviceDriver(); |
|
|
|
|
|
//请求取货
|
|
|
|
|
|
if (StrUtil.equals(type, "01") && ndxySpecialTwoDeviceDriver.getMove() != 0) { |
|
|
|
|
|
ndxySpecialTwoDeviceDriver.writing(1, 1); |
|
|
|
|
|
is_feedback = true; |
|
|
|
|
|
} |
|
|
|
|
|
//取货完成
|
|
|
|
|
|
else if (StrUtil.equals(type, "02")) { |
|
|
|
|
|
ndxySpecialTwoDeviceDriver.writing(1, 2); |
|
|
|
|
|
is_feedback = true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//请求放货
|
|
|
//请求放货
|
|
|
else if (StrUtil.equals(type, "03") && ndxySpecialTwoDeviceDriver.getMove() == 0) { |
|
|
if (address.contains("INPUT")) { |
|
|
ndxySpecialTwoDeviceDriver.writing(1, 3); |
|
|
JSONObject jo=new JSONObject(); |
|
|
is_feedback = true; |
|
|
jo.put("device_code",inst.getNext_device_code()); |
|
|
} |
|
|
jo.put("device_status","enter"); |
|
|
//放货完成
|
|
|
log.info("请求参数:{}", jo); |
|
|
else if (StrUtil.equals(type, "04")) { |
|
|
JSONArray ja=new JSONArray(); |
|
|
ndxySpecialTwoDeviceDriver.writing(1, 4); |
|
|
for(Object key:jo.keySet()){ |
|
|
is_feedback = true; |
|
|
JSONObject jo1=new JSONObject(); |
|
|
} |
|
|
jo1.put(key,jo.get(key)); |
|
|
} |
|
|
ja.add(jo1); |
|
|
if (device.getDeviceDriver() instanceof YkbkSpecialDeviceDriver) { |
|
|
} |
|
|
ykbkSpecialDeviceDriver = (YkbkSpecialDeviceDriver) device.getDeviceDriver(); |
|
|
HttpResponse result=acsToWmsService.vehicle(ja); |
|
|
//请求取货
|
|
|
com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body()); |
|
|
if (StrUtil.equals(type, "01") && ykbkSpecialDeviceDriver.getMove() != 0) { |
|
|
int responseCode = response.getInteger("status"); |
|
|
ykbkSpecialDeviceDriver.writing(1, 1); |
|
|
if (responseCode == 200) { |
|
|
is_feedback = true; |
|
|
log.info("上位允许放货 请求结果{}", responseCode); |
|
|
|
|
|
}else{ |
|
|
|
|
|
throw new BadRequestException("上位系统不允许请求放货"); |
|
|
} |
|
|
} |
|
|
//取货完成
|
|
|
|
|
|
else if (StrUtil.equals(type, "02")) { |
|
|
|
|
|
ykbkSpecialDeviceDriver.writing(1, 2); |
|
|
|
|
|
is_feedback = true; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//请求放货
|
|
|
//放货完成离开
|
|
|
else if (StrUtil.equals(type, "03") && ykbkSpecialDeviceDriver.getMove() == 0) { |
|
|
if (address.contains("OUTPUT")) { |
|
|
ykbkSpecialDeviceDriver.writing(1, 3); |
|
|
|
|
|
is_feedback = true; |
|
|
|
|
|
} |
|
|
|
|
|
//放货完成
|
|
|
|
|
|
else if (StrUtil.equals(type, "04")) { |
|
|
|
|
|
ykbkSpecialDeviceDriver.writing(1, 4); |
|
|
|
|
|
is_feedback = true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
JSONObject jo=new JSONObject(); |
|
|
JSONObject jo=new JSONObject(); |
|
|
if (is_feedback) { |
|
|
jo.put("device_code",inst.getNext_device_code()); |
|
|
jo.put("name", param); |
|
|
jo.put("device_status","left"); |
|
|
jo.put("lastAction", "wait"); |
|
|
log.info("请求参数:{}", jo); |
|
|
jo.put("lastActionStatus", "DONE"); |
|
|
JSONArray ja=new JSONArray(); |
|
|
jo.put("status", "IDLE"); |
|
|
for(Object key:jo.keySet()){ |
|
|
|
|
|
JSONObject jo1=new JSONObject(); |
|
|
|
|
|
jo1.put(key,jo.get(key)); |
|
|
|
|
|
ja.add(jo1); |
|
|
|
|
|
} |
|
|
|
|
|
HttpResponse result=acsToWmsService.vehicle(ja); |
|
|
|
|
|
com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body()); |
|
|
|
|
|
int responseCode = response.getInteger("status"); |
|
|
|
|
|
if (responseCode == 200) { |
|
|
|
|
|
log.info("上位允许放货离开 请求结果{}", responseCode); |
|
|
}else{ |
|
|
}else{ |
|
|
jo.put("name", param); |
|
|
throw new BadRequestException("上位系统不允许放货完成离开"); |
|
|
jo.put("lastAction", "wait"); |
|
|
|
|
|
jo.put("lastActionStatus", "FAILED"); |
|
|
|
|
|
jo.put("status", "IDLE"); |
|
|
|
|
|
} |
|
|
} |
|
|
is_feedback = false; |
|
|
} |
|
|
log.info("反馈AGV请求参数:{}", jo.toString()); |
|
|
throw new BadRequestException("请求失败,IN OUT 站点错误!"); |
|
|
|
|
|
|
|
|
return jo.toString(); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -1677,32 +1534,17 @@ public class AgvServiceImpl implements AgvService { |
|
|
@Override |
|
|
@Override |
|
|
public HttpResponse sendOrderSequencesToXZ(Instruction inst) throws Exception { |
|
|
public HttpResponse sendOrderSequencesToXZ(Instruction inst) throws Exception { |
|
|
|
|
|
|
|
|
JSONObject jo = new JSONObject(); |
|
|
com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject(); |
|
|
jo.put("intendedVehicle", ""); |
|
|
jo.put("id", inst.getInstruction_code()); |
|
|
jo.put("category", ""); |
|
|
jo.put("complete", true); |
|
|
jo.put("failureFatal", false); |
|
|
jo.put("blocks", createBlocksData(inst)); |
|
|
jo.put("complete", false); |
|
|
jo.put("priority", inst.getPriority()); |
|
|
JSONArray transports = new JSONArray(); |
|
|
|
|
|
JSONObject orderjo = new JSONObject(); |
|
|
|
|
|
orderjo.put("name", inst.getInstruction_code()); |
|
|
|
|
|
orderjo.put("order", createOrederData(inst, "1")); |
|
|
|
|
|
transports.add(orderjo); |
|
|
|
|
|
jo.put("transports", transports); |
|
|
|
|
|
|
|
|
|
|
|
JSONArray ja1 = new JSONArray(); |
|
|
|
|
|
JSONObject jo1 = new JSONObject(); |
|
|
|
|
|
jo1.put("key", ""); |
|
|
|
|
|
jo1.put("value", ""); |
|
|
|
|
|
ja1.add(jo1); |
|
|
|
|
|
jo.put("properties", ja1); |
|
|
|
|
|
|
|
|
|
|
|
log.info("任务号:{},指令号{},下发agv订单序列参数:{}", inst.getTask_code(), inst.getInstruction_code(), jo.toString()); |
|
|
log.info("任务号:{},指令号{},下发agv订单序列参数:{}", inst.getTask_code(), inst.getInstruction_code(), jo.toString()); |
|
|
|
|
|
|
|
|
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { |
|
|
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV), "1")) { |
|
|
String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); |
|
|
String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); |
|
|
String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); |
|
|
String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); |
|
|
|
|
|
agvurl = agvurl + ":" + agvport + "/setOrder"; |
|
|
agvurl = agvurl + ":" + agvport + "/api/route/orderSequences/" + inst.getTask_code(); |
|
|
|
|
|
|
|
|
|
|
|
HttpResponse result = HttpRequest.post(agvurl) |
|
|
HttpResponse result = HttpRequest.post(agvurl) |
|
|
.body(String.valueOf(jo))//表单内容
|
|
|
.body(String.valueOf(jo))//表单内容
|
|
@ -1710,13 +1552,126 @@ public class AgvServiceImpl implements AgvService { |
|
|
.execute(); |
|
|
.execute(); |
|
|
log.info(agvurl); |
|
|
log.info(agvurl); |
|
|
log.info("任务号:{},指令号{},状态{},下发agv订单序列反馈:{}", inst.getTask_code(), inst.getInstruction_code(), result.getStatus(), result.body()); |
|
|
log.info("任务号:{},指令号{},状态{},下发agv订单序列反馈:{}", inst.getTask_code(), inst.getInstruction_code(), result.getStatus(), result.body()); |
|
|
|
|
|
|
|
|
return result; |
|
|
return result; |
|
|
} else { |
|
|
} else { |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
public com.alibaba.fastjson.JSONArray createBlocksData(Instruction inst) { |
|
|
|
|
|
com.alibaba.fastjson.JSONArray ja = new com.alibaba.fastjson.JSONArray(); |
|
|
|
|
|
|
|
|
|
|
|
Device startDevice = deviceAppService.findDeviceByCode(inst.getStart_device_code()); |
|
|
|
|
|
if ("true".equals(startDevice.getExtraValue().get("ignore_pickup_check"))) { |
|
|
|
|
|
//取货前等待
|
|
|
|
|
|
com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject(); |
|
|
|
|
|
jo.put("blockId", IdUtil.simpleUUID()); |
|
|
|
|
|
jo.put("location", inst.getStart_point_code() + "INGET"); |
|
|
|
|
|
jo.put("operation", "script"); |
|
|
|
|
|
jo.put("id", inst.getStart_point_code() + "INGET"); |
|
|
|
|
|
jo.put("script_name", "userpy/interact.py"); |
|
|
|
|
|
com.alibaba.fastjson.JSONObject script_args = new com.alibaba.fastjson.JSONObject(); |
|
|
|
|
|
script_args.put("addr", addr); |
|
|
|
|
|
com.alibaba.fastjson.JSONObject data = new com.alibaba.fastjson.JSONObject(); |
|
|
|
|
|
com.alibaba.fastjson.JSONObject reach = new com.alibaba.fastjson.JSONObject(); |
|
|
|
|
|
reach.put("task_code", inst.getInstruction_code()); |
|
|
|
|
|
reach.put("address", inst.getStart_point_code() + "INGET"); |
|
|
|
|
|
data.put("reach", reach); |
|
|
|
|
|
script_args.put("data", data); |
|
|
|
|
|
script_args.put("protocol", "HTTP"); |
|
|
|
|
|
jo.put("script_args", script_args); |
|
|
|
|
|
ja.add(jo); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
com.alibaba.fastjson.JSONObject jo1 = new com.alibaba.fastjson.JSONObject(); |
|
|
|
|
|
jo1.put("blockId", IdUtil.simpleUUID()); |
|
|
|
|
|
jo1.put("location", inst.getStart_point_code()); |
|
|
|
|
|
jo1.put("operation", "JackLoad"); |
|
|
|
|
|
ja.add(jo1); |
|
|
|
|
|
|
|
|
|
|
|
//取货完成等待
|
|
|
|
|
|
com.alibaba.fastjson.JSONObject jo2 = new com.alibaba.fastjson.JSONObject(); |
|
|
|
|
|
jo2.put("blockId", IdUtil.simpleUUID()); |
|
|
|
|
|
jo2.put("location", inst.getStart_point_code() + "OUTGET"); |
|
|
|
|
|
jo2.put("operation", "script"); |
|
|
|
|
|
jo2.put("id", inst.getStart_point_code() + "OUTGET"); |
|
|
|
|
|
jo2.put("script_name", "userpy/interact.py"); |
|
|
|
|
|
com.alibaba.fastjson.JSONObject script_args2 = new com.alibaba.fastjson.JSONObject(); |
|
|
|
|
|
script_args2.put("addr", addr); |
|
|
|
|
|
com.alibaba.fastjson.JSONObject data2 = new com.alibaba.fastjson.JSONObject(); |
|
|
|
|
|
com.alibaba.fastjson.JSONObject reach2 = new com.alibaba.fastjson.JSONObject(); |
|
|
|
|
|
reach2.put("task_code", inst.getInstruction_code()); |
|
|
|
|
|
reach2.put("address", inst.getStart_point_code() + "OUTGET"); |
|
|
|
|
|
data2.put("reach", reach2); |
|
|
|
|
|
script_args2.put("data", data2); |
|
|
|
|
|
script_args2.put("protocol", "HTTP"); |
|
|
|
|
|
jo2.put("script_args", script_args2); |
|
|
|
|
|
ja.add(jo2); |
|
|
|
|
|
|
|
|
|
|
|
Device nextDevice = deviceAppService.findDeviceByCode(inst.getNext_device_code()); |
|
|
|
|
|
if ("true".equals(nextDevice.getExtraValue().get("ignore_release_check"))) { |
|
|
|
|
|
//放货前等待
|
|
|
|
|
|
com.alibaba.fastjson.JSONObject jo3 = new com.alibaba.fastjson.JSONObject(); |
|
|
|
|
|
jo3.put("blockId", IdUtil.simpleUUID()); |
|
|
|
|
|
jo3.put("location", inst.getNext_point_code() + "INPUT"); |
|
|
|
|
|
jo3.put("operation", "script"); |
|
|
|
|
|
jo3.put("id", inst.getNext_point_code() + "INPUT"); |
|
|
|
|
|
jo3.put("script_name", "userpy/interact.py"); |
|
|
|
|
|
com.alibaba.fastjson.JSONObject script_args3 = new com.alibaba.fastjson.JSONObject(); |
|
|
|
|
|
script_args3.put("addr", addr); |
|
|
|
|
|
com.alibaba.fastjson.JSONObject data3 = new com.alibaba.fastjson.JSONObject(); |
|
|
|
|
|
com.alibaba.fastjson.JSONObject reach3 = new com.alibaba.fastjson.JSONObject(); |
|
|
|
|
|
reach3.put("task_code", inst.getInstruction_code()); |
|
|
|
|
|
reach3.put("address", inst.getNext_point_code() + "INPUT"); |
|
|
|
|
|
data3.put("reach", reach3); |
|
|
|
|
|
script_args3.put("data", data3); |
|
|
|
|
|
script_args3.put("protocol", "HTTP"); |
|
|
|
|
|
jo3.put("script_args", script_args3); |
|
|
|
|
|
ja.add(jo3); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// //放货前下发旋转角度
|
|
|
|
|
|
// com.alibaba.fastjson.JSONObject json1 = new com.alibaba.fastjson.JSONObject();
|
|
|
|
|
|
// AcsPointAngleDto acsPointAngleDto = acsPointAngleService.findByCode(inst.getStart_device_code(),inst.getNext_device_code());
|
|
|
|
|
|
// if (ObjectUtil.isNotEmpty(acsPointAngleDto)){
|
|
|
|
|
|
// log.info("acsPointAngleDto----參數,{}", acsPointAngleDto.toString());
|
|
|
|
|
|
// com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
|
|
|
|
|
|
// BigDecimal next_point_angle = acsPointAngleDto.getNext_point_angle();
|
|
|
|
|
|
// operation_args.put("increase_spin_angle",next_point_angle);//弧度值,如3.14
|
|
|
|
|
|
// operation_args.put("skill_name","GoByOdometer");
|
|
|
|
|
|
// json1.put("blockId", IdUtil.simpleUUID());
|
|
|
|
|
|
// json1.put("location", inst.getNext_point_code() + "INPUT");
|
|
|
|
|
|
// json1.put("operation_args",operation_args);
|
|
|
|
|
|
// ja.add(json1);
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
com.alibaba.fastjson.JSONObject jo4 = new com.alibaba.fastjson.JSONObject(); |
|
|
|
|
|
jo4.put("blockId", IdUtil.simpleUUID()); |
|
|
|
|
|
jo4.put("location", inst.getNext_point_code()); |
|
|
|
|
|
jo4.put("operation", "JackUnload"); |
|
|
|
|
|
ja.add(jo4); |
|
|
|
|
|
|
|
|
|
|
|
if ("true".equals(nextDevice.getExtraValue().get("ignore_release_check"))) { |
|
|
|
|
|
//放货完成等待
|
|
|
|
|
|
com.alibaba.fastjson.JSONObject jo5 = new com.alibaba.fastjson.JSONObject(); |
|
|
|
|
|
jo5.put("blockId", IdUtil.simpleUUID()); |
|
|
|
|
|
jo5.put("location", inst.getNext_point_code() + "OUTPUT"); |
|
|
|
|
|
jo5.put("operation", "script"); |
|
|
|
|
|
jo5.put("id", inst.getNext_point_code() + "OUTPUT"); |
|
|
|
|
|
jo5.put("script_name", "userpy/interact.py"); |
|
|
|
|
|
com.alibaba.fastjson.JSONObject script_args5 = new com.alibaba.fastjson.JSONObject(); |
|
|
|
|
|
script_args5.put("addr", addr); |
|
|
|
|
|
com.alibaba.fastjson.JSONObject data5 = new com.alibaba.fastjson.JSONObject(); |
|
|
|
|
|
com.alibaba.fastjson.JSONObject reach5 = new com.alibaba.fastjson.JSONObject(); |
|
|
|
|
|
reach5.put("task_code", inst.getInstruction_code()); |
|
|
|
|
|
reach5.put("address", inst.getNext_point_code() + "OUTPUT"); |
|
|
|
|
|
data5.put("reach", reach5); |
|
|
|
|
|
script_args5.put("data", data5); |
|
|
|
|
|
script_args5.put("protocol", "HTTP"); |
|
|
|
|
|
jo5.put("script_args", script_args5); |
|
|
|
|
|
ja.add(jo5); |
|
|
|
|
|
} |
|
|
|
|
|
return ja; |
|
|
|
|
|
} |
|
|
@Override |
|
|
@Override |
|
|
public HttpResponse addOrderSequences(Instruction inst) throws Exception { |
|
|
public HttpResponse addOrderSequences(Instruction inst) throws Exception { |
|
|
JSONObject orderjo = createOrederData(inst, "1"); |
|
|
JSONObject orderjo = createOrederData(inst, "1"); |
|
|