|
@ -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; |
|
@ -9,6 +10,7 @@ import lombok.extern.slf4j.Slf4j; |
|
|
import net.sf.json.JSONArray; |
|
|
import net.sf.json.JSONArray; |
|
|
import net.sf.json.JSONObject; |
|
|
import net.sf.json.JSONObject; |
|
|
import org.nl.acs.agv.server.AgvService; |
|
|
import org.nl.acs.agv.server.AgvService; |
|
|
|
|
|
import org.nl.acs.agv.server.AgvWaitUtil; |
|
|
import org.nl.acs.agv.server.dto.AgvDto; |
|
|
import org.nl.acs.agv.server.dto.AgvDto; |
|
|
import org.nl.acs.config.AcsConfig; |
|
|
import org.nl.acs.config.AcsConfig; |
|
|
import org.nl.acs.config.server.AcsConfigService; |
|
|
import org.nl.acs.config.server.AcsConfigService; |
|
@ -44,6 +46,7 @@ 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.http.HttpStatus; |
|
|
import org.springframework.http.HttpStatus; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
@ -78,6 +81,12 @@ public class AgvServiceImpl implements AgvService { |
|
|
|
|
|
|
|
|
private final LogServer logServer; |
|
|
private final LogServer logServer; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
AgvWaitUtil agvWaitUtil; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${agvToAcs.addr}") |
|
|
|
|
|
private String addr; |
|
|
|
|
|
|
|
|
Map<String, AgvDto> AGVDeviceStatus = new HashMap(); |
|
|
Map<String, AgvDto> AGVDeviceStatus = new HashMap(); |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -589,10 +598,12 @@ public class AgvServiceImpl implements AgvService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public HttpResponse queryXZAgvDeviceStatus() { |
|
|
public HttpResponse queryXZAgvDeviceStatus() { |
|
|
|
|
|
|
|
|
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { |
|
|
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "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); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String agvurl1 = agvurl + ":" + agvport + "/api/route/vehicles"; |
|
|
String agvurl1 = agvurl + ":" + agvport + "/api/route/vehicles"; |
|
|
String agvurl2 = agvurl + ":" + agvport + "/api/route/vehicleDetails"; |
|
|
String agvurl2 = agvurl + ":" + agvport + "/api/route/vehicleDetails"; |
|
|
|
|
|
|
|
@ -604,44 +615,22 @@ public class AgvServiceImpl implements AgvService { |
|
|
HttpResponse result2 = HttpRequest.get(agvurl2) |
|
|
HttpResponse result2 = HttpRequest.get(agvurl2) |
|
|
.timeout(20000)//超时,毫秒
|
|
|
.timeout(20000)//超时,毫秒
|
|
|
.execute(); |
|
|
.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()); |
|
|
com.alibaba.fastjson.JSONArray ja = (com.alibaba.fastjson.JSONArray) com.alibaba.fastjson.JSONArray.parse(result.body()); |
|
|
|
|
|
|
|
|
for (int i = 0; i < ja.size(); i++) { |
|
|
for (int i = 0; i < ja.size(); i++) { |
|
|
JSONObject jo = (JSONObject) ja.get(i); |
|
|
com.alibaba.fastjson.JSONObject jo = (com.alibaba.fastjson.JSONObject) ja.get(i); |
|
|
String name = jo.getString("name"); |
|
|
String name = jo.getString("name"); |
|
|
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()); |
|
|
com.alibaba.fastjson.JSONObject detailjo = (com.alibaba.fastjson.JSONObject) com.alibaba.fastjson.JSONObject.parse(result2.body()); |
|
|
JSONObject item = (JSONObject) detailjo.get(name); |
|
|
com.alibaba.fastjson.JSONObject item = (com.alibaba.fastjson.JSONObject) detailjo.get(name); |
|
|
if (ObjectUtil.isEmpty(detailjo.get(name))) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
String x = item.getString("x"); |
|
|
String x = item.getString("x"); |
|
|
String y = item.getString("y"); |
|
|
String y = item.getString("y"); |
|
|
String angle = item.getString("angle"); |
|
|
String angle = item.getString("angle"); |
|
|
String battery_temp = item.getString("battery_temp"); |
|
|
|
|
|
String blocked = item.getString("blocked"); |
|
|
|
|
|
String brake = item.getString("brake"); |
|
|
|
|
|
String charging = item.getString("charging"); |
|
|
|
|
|
String controller_temp = item.getString("controller_temp"); |
|
|
|
|
|
String current_map = item.getString("current_map"); |
|
|
|
|
|
String current_station = item.getString("current_station"); |
|
|
|
|
|
String emergency = item.getString("emergency"); |
|
|
|
|
|
String odo = item.getString("odo"); |
|
|
|
|
|
String requestCurrent = item.getString("requestCurrent"); |
|
|
|
|
|
String requestVoltage = item.getString("requestVoltage"); |
|
|
|
|
|
String soft_emc = item.getString("soft_emc"); |
|
|
|
|
|
String today_odo = item.getString("today_odo"); |
|
|
|
|
|
String voltage = item.getString("voltage"); |
|
|
|
|
|
String vx = item.getString("vx"); |
|
|
|
|
|
String vy = item.getString("vy"); |
|
|
|
|
|
String w = item.getString("w"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AgvDto dto = new AgvDto(); |
|
|
AgvDto dto = new AgvDto(); |
|
|
dto.setName(name); |
|
|
dto.setName(name); |
|
|
dto.setEnergyLevel(energyLevel); |
|
|
dto.setEnergyLevel(energyLevel); |
|
@ -650,21 +639,6 @@ public class AgvServiceImpl implements AgvService { |
|
|
dto.setPositionAngle(angle); |
|
|
dto.setPositionAngle(angle); |
|
|
dto.setPositionX(x); |
|
|
dto.setPositionX(x); |
|
|
dto.setPositionY(y); |
|
|
dto.setPositionY(y); |
|
|
dto.setBattery_temp(battery_temp); |
|
|
|
|
|
dto.setBlocked(blocked); |
|
|
|
|
|
dto.setBrake(brake); |
|
|
|
|
|
dto.setCharging(charging); |
|
|
|
|
|
dto.setController_temp(controller_temp); |
|
|
|
|
|
dto.setCurrent_station(current_station); |
|
|
|
|
|
dto.setEmergency(emergency); |
|
|
|
|
|
dto.setOdo(odo); |
|
|
|
|
|
dto.setRequestCurrent(requestCurrent); |
|
|
|
|
|
dto.setRequestVoltage(requestVoltage); |
|
|
|
|
|
dto.setVoltage(voltage); |
|
|
|
|
|
dto.setSoft_emc(soft_emc); |
|
|
|
|
|
dto.setVx(vx); |
|
|
|
|
|
dto.setVy(vy); |
|
|
|
|
|
dto.setW(w); |
|
|
|
|
|
if (AGVDeviceStatus.containsKey(name)) { |
|
|
if (AGVDeviceStatus.containsKey(name)) { |
|
|
AGVDeviceStatus.remove(name); |
|
|
AGVDeviceStatus.remove(name); |
|
|
AGVDeviceStatus.put(name, dto); |
|
|
AGVDeviceStatus.put(name, dto); |
|
@ -677,30 +651,28 @@ public class AgvServiceImpl implements AgvService { |
|
|
} else { |
|
|
} else { |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public HttpResponse queryXZAgvInstStatus(String instCode) { |
|
|
public HttpResponse queryXZAgvInstStatus() { |
|
|
|
|
|
|
|
|
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { |
|
|
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "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 + "/api/route/transportOrders/" + instCode; |
|
|
agvurl = agvurl + ":" + agvport + "/orders?page=1&size=9999"; |
|
|
|
|
|
|
|
|
HttpResponse result = HttpRequest.get(agvurl) |
|
|
HttpResponse result = HttpRequest.get(agvurl) |
|
|
.timeout(20000)//超时,毫秒
|
|
|
.timeout(20000)//超时,毫秒
|
|
|
.execute(); |
|
|
.execute(); |
|
|
System.out.println("查询agv指令数据:" + result.body()); |
|
|
log.info("queryXZAgvInstStatus----查询agv指令数据:{}" + result.body()); |
|
|
|
|
|
|
|
|
return result; |
|
|
return result; |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
|
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -747,25 +719,24 @@ public class AgvServiceImpl implements AgvService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public HttpResponse deleteXZAgvInst(String instCode) { |
|
|
public HttpResponse deleteXZAgvInst(String instCode) { |
|
|
|
|
|
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV), "1")) { |
|
|
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "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 + "/api/route/transportOrders/" + instCode + "/withdrawal"; |
|
|
com.alibaba.fastjson.JSONObject param = new com.alibaba.fastjson.JSONObject(); |
|
|
|
|
|
param.put("id", instCode); |
|
|
|
|
|
param.put("disableVehicle", false); |
|
|
|
|
|
agvurl = agvurl + ":" + agvport + "/terminate"; |
|
|
log.info("删除agv指令请求agvurl:{}", agvurl); |
|
|
log.info("删除agv指令请求agvurl:{}", agvurl); |
|
|
HttpResponse result = HttpRequest.post(agvurl) |
|
|
HttpResponse result = HttpRequest.post(agvurl) |
|
|
|
|
|
.body(param.toJSONString()) |
|
|
.timeout(20000)//超时,毫秒
|
|
|
.timeout(20000)//超时,毫秒
|
|
|
.execute(); |
|
|
.execute(); |
|
|
log.info("删除agv指令请求反馈:{}", result); |
|
|
log.info("删除agv指令请求反馈:{}", result); |
|
|
|
|
|
|
|
|
return result; |
|
|
return result; |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
|
|
|
|
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -1680,33 +1651,17 @@ public class AgvServiceImpl implements AgvService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public HttpResponse sendOrderSequencesToXZ(Instruction inst) throws Exception { |
|
|
public HttpResponse sendOrderSequencesToXZ(Instruction inst) throws Exception { |
|
|
|
|
|
com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject(); |
|
|
JSONObject jo = new JSONObject(); |
|
|
jo.put("id", inst.getInstruction_code()); |
|
|
jo.put("intendedVehicle", ""); |
|
|
jo.put("complete", true); |
|
|
jo.put("category", ""); |
|
|
jo.put("blocks", createBlocksData(inst)); |
|
|
jo.put("failureFatal", false); |
|
|
jo.put("priority", inst.getPriority()); |
|
|
jo.put("complete", false); |
|
|
|
|
|
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))//表单内容
|
|
@ -1714,7 +1669,6 @@ 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; |
|
@ -2068,7 +2022,7 @@ public class AgvServiceImpl implements AgvService { |
|
|
public JSONObject xgAGVControlDoorSwitch(JSONObject requestParam) { |
|
|
public JSONObject xgAGVControlDoorSwitch(JSONObject requestParam) { |
|
|
try { |
|
|
try { |
|
|
JSONObject requestWMSParam = new JSONObject(); |
|
|
JSONObject requestWMSParam = new JSONObject(); |
|
|
requestWMSParam.put("device_code", requestParam.optString("deviceID")); |
|
|
requestWMSParam.put("device_code", requestParam.optString("doorName")); |
|
|
requestWMSParam.put("device_status", "1".equals(requestParam.optString("state")) ? "open" : "close"); |
|
|
requestWMSParam.put("device_status", "1".equals(requestParam.optString("state")) ? "open" : "close"); |
|
|
JSONObject wmsResult = acsToWmsService.gccControlDoorSwitch(requestWMSParam); |
|
|
JSONObject wmsResult = acsToWmsService.gccControlDoorSwitch(requestWMSParam); |
|
|
|
|
|
|
|
@ -2091,9 +2045,9 @@ public class AgvServiceImpl implements AgvService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public JSONObject xgAGVQueryDoorStatus(JSONObject requestParam) { |
|
|
public JSONObject xgAGVQueryDoorStatus(JSONObject requestParam) { |
|
|
String[] deviceIDs = requestParam.optString("deviceIDs").split(","); |
|
|
String[] doorNameList = requestParam.optJSONArray("doorNameList").optString(0).split(","); |
|
|
|
|
|
|
|
|
if (deviceIDs.length == 1 && StrUtil.isBlank(deviceIDs[0])) { |
|
|
if (doorNameList.length == 1 && StrUtil.isBlank(doorNameList[0])) { |
|
|
JSONObject result = new JSONObject(); |
|
|
JSONObject result = new JSONObject(); |
|
|
result.put("result", 0); |
|
|
result.put("result", 0); |
|
|
result.put("message", "操作成功"); |
|
|
result.put("message", "操作成功"); |
|
@ -2107,28 +2061,34 @@ public class AgvServiceImpl implements AgvService { |
|
|
JSONObject result = new JSONObject(); |
|
|
JSONObject result = new JSONObject(); |
|
|
result.put("result", 0); |
|
|
result.put("result", 0); |
|
|
result.put("message", "操作成功"); |
|
|
result.put("message", "操作成功"); |
|
|
result.put("data", Arrays.stream(deviceIDs) |
|
|
result.put("data", Arrays.stream(doorNameList) |
|
|
.map(id -> { |
|
|
.map(doorName -> { |
|
|
JSONObject door = new JSONObject(); |
|
|
JSONObject door = new JSONObject(); |
|
|
door.put("deviceID", id); |
|
|
door.put("doorName", doorName); |
|
|
door.put("doorState", -1); |
|
|
door.put("state", -1); |
|
|
door.put("timePoke", System.currentTimeMillis()); |
|
|
door.put("timestamp", System.currentTimeMillis()); |
|
|
return door; |
|
|
return door; |
|
|
}).collect(Collectors.toList())); |
|
|
}).collect(Collectors.toList())); |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
List<JSONObject> data = Arrays.stream(deviceIDs).map(id -> { |
|
|
List<JSONObject> data = Arrays.stream(doorNameList).map(doorName -> { |
|
|
JSONObject door = new JSONObject(); |
|
|
JSONObject door = new JSONObject(); |
|
|
door.put("deviceID", id); |
|
|
door.put("doorName", doorName); |
|
|
List<Object> list = wmsResult.stream().filter(o -> id.equals(((com.alibaba.fastjson.JSONObject) o).getString("device_code"))).collect(Collectors.toList()); |
|
|
List<Object> list = wmsResult.stream().filter(o -> doorName.equals(((com.alibaba.fastjson.JSONObject) o).getString("device_code"))).collect(Collectors.toList()); |
|
|
if (list.isEmpty()) { |
|
|
if (list.isEmpty()) { |
|
|
door.put("doorState", -1); |
|
|
door.put("state", -1); |
|
|
} else { |
|
|
} else { |
|
|
com.alibaba.fastjson.JSONObject row = (com.alibaba.fastjson.JSONObject) list.get(0); |
|
|
com.alibaba.fastjson.JSONObject row = (com.alibaba.fastjson.JSONObject) list.get(0); |
|
|
door.put("doorState", "close".equals(row.getString("device_status")) ? 0 : 1); |
|
|
int state = 1; |
|
|
|
|
|
if ("close".equals(row.getString("device_status"))) { |
|
|
|
|
|
state = 0; |
|
|
|
|
|
} else if ("open".equals(row.getString("device_status"))) { |
|
|
|
|
|
state = 2; |
|
|
} |
|
|
} |
|
|
door.put("timePoke", System.currentTimeMillis()); |
|
|
door.put("state", state); |
|
|
|
|
|
} |
|
|
|
|
|
door.put("timestamp", System.currentTimeMillis()); |
|
|
return door; |
|
|
return door; |
|
|
}).collect(Collectors.toList()); |
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
@ -2144,4 +2104,150 @@ public class AgvServiceImpl implements AgvService { |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
// if ("true".equals(startDevice.getExtraValue().get("ignore_pickup_check"))) {
|
|
|
|
|
|
// //取货完成等待
|
|
|
|
|
|
// 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 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 |
|
|
|
|
|
public JSONObject xgAGVWaitPointRequest(JSONObject requestParam) { |
|
|
|
|
|
log.info("仙工AGV请求取放货,请求参数 - {}", requestParam); |
|
|
|
|
|
String inst_code = requestParam.getString("task_code"); |
|
|
|
|
|
Instruction instructionDto = instructionService.findByCodeFromCache(inst_code); |
|
|
|
|
|
if (ObjectUtil.isEmpty(instructionDto)) { |
|
|
|
|
|
throw new BadRequestException("请求失败,未找到指令!"); |
|
|
|
|
|
} |
|
|
|
|
|
String address = requestParam.getString("address"); |
|
|
|
|
|
if (StrUtil.isBlank(address)) { |
|
|
|
|
|
throw new BadRequestException("请求失败,地址为空!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (address.contains("IN")) { |
|
|
|
|
|
String deviceCodeNow = address.substring(0, address.length() - 5); |
|
|
|
|
|
if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) { |
|
|
|
|
|
throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (address.contains("GET")) { |
|
|
|
|
|
return agvWaitUtil.waitInGet(deviceCodeNow); |
|
|
|
|
|
} else if (address.contains("PUT")) { |
|
|
|
|
|
return agvWaitUtil.waitInPut(deviceCodeNow); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (address.contains("OUT")) { |
|
|
|
|
|
String deviceCodeNow = address.substring(0, address.length() - 6); |
|
|
|
|
|
if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) { |
|
|
|
|
|
throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (address.contains("GET")) { |
|
|
|
|
|
return agvWaitUtil.waitOutGet(deviceCodeNow); |
|
|
|
|
|
} else if (address.contains("PUT")) { |
|
|
|
|
|
return agvWaitUtil.waitOutPut(deviceCodeNow); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
throw new BadRequestException("请求失败,IN OUT 站点错误!"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|