add 仙工AGV请求取放货
This commit is contained in:
@@ -96,18 +96,4 @@ public class AgvController {
|
|||||||
public ResponseEntity<Object> queryDevice() throws Exception {
|
public ResponseEntity<Object> queryDevice() throws Exception {
|
||||||
return new ResponseEntity<>(agvService.queryDeviceStation(), HttpStatus.OK);
|
return new ResponseEntity<>(agvService.queryDeviceStation(), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/xgAGVControlDoorSwitch")
|
|
||||||
@Log("仙工AGV控制门开关")
|
|
||||||
@ApiOperation("仙工AGV控制门开关")
|
|
||||||
public ResponseEntity<JSONObject> xgAGVControlDoorSwitch(@RequestBody JSONObject requestParam) {
|
|
||||||
return new ResponseEntity<>(agvService.xgAGVControlDoorSwitch(requestParam), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/xgAGVQueryDoorStatus")
|
|
||||||
@Log("仙工AGV查询门状态")
|
|
||||||
@ApiOperation("仙工AGV查询门状态")
|
|
||||||
public ResponseEntity<JSONObject> xgAGVQueryDoorStatus(@RequestBody JSONObject requestParam) {
|
|
||||||
return new ResponseEntity<>(agvService.xgAGVQueryDoorStatus(requestParam), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package org.nl.acs.agv.rest;
|
||||||
|
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
import org.nl.acs.agv.server.AgvService;
|
||||||
|
import org.nl.annotation.Log;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zhangjiangwei
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/agv/xg")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Api(tags = "仙工AGV")
|
||||||
|
@Slf4j
|
||||||
|
public class XGAGVController {
|
||||||
|
|
||||||
|
private final AgvService agvService;
|
||||||
|
|
||||||
|
@PostMapping("/controlDoor")
|
||||||
|
@Log("仙工AGV控制门开关")
|
||||||
|
@ApiOperation("仙工AGV控制门开关")
|
||||||
|
public ResponseEntity<JSONObject> xgAGVControlDoorSwitch(@RequestBody JSONObject requestParam) {
|
||||||
|
return new ResponseEntity<>(agvService.xgAGVControlDoorSwitch(requestParam), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/doorStateList")
|
||||||
|
@Log("仙工AGV查询门状态")
|
||||||
|
@ApiOperation("仙工AGV查询门状态")
|
||||||
|
public ResponseEntity<JSONObject> xgAGVQueryDoorStatus(@RequestBody JSONObject requestParam) {
|
||||||
|
return new ResponseEntity<>(agvService.xgAGVQueryDoorStatus(requestParam), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/waitPointRequest")
|
||||||
|
@Log("仙工AGV请求取放货")
|
||||||
|
@ApiOperation("仙工AGV请求取放货")
|
||||||
|
public ResponseEntity<JSONObject> xgAGVWaitPointRequest(@RequestBody JSONObject requestParam) {
|
||||||
|
return new ResponseEntity<>(agvService.xgAGVWaitPointRequest(requestParam), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,7 +33,7 @@ public interface AgvService {
|
|||||||
|
|
||||||
public HttpResponse queryXZAgvDeviceStatus();
|
public HttpResponse queryXZAgvDeviceStatus();
|
||||||
|
|
||||||
public HttpResponse queryXZAgvInstStatus(String instCode);
|
public HttpResponse queryXZAgvInstStatus();
|
||||||
|
|
||||||
Map<String, AgvDto> findAllAgvFromCache();
|
Map<String, AgvDto> findAllAgvFromCache();
|
||||||
|
|
||||||
@@ -216,4 +216,6 @@ public interface AgvService {
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
JSONObject xgAGVQueryDoorStatus(JSONObject requestParam);
|
JSONObject xgAGVQueryDoorStatus(JSONObject requestParam);
|
||||||
|
|
||||||
|
JSONObject xgAGVWaitPointRequest(JSONObject requestParam);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,136 @@
|
|||||||
|
package org.nl.acs.agv.server;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.sf.json.JSONArray;
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||||
|
import org.nl.acs.ext.wms.service.impl.AcsToWmsZDServiceImpl;
|
||||||
|
import org.nl.acs.instruction.service.InstructionService;
|
||||||
|
import org.nl.acs.log.service.LogServer;
|
||||||
|
import org.nl.acs.opc.DeviceAppService;
|
||||||
|
import org.nl.exception.BadRequestException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: geng by
|
||||||
|
* @createDate: 2022/12/5
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class AgvWaitUtil {
|
||||||
|
private final DeviceAppService deviceAppService;
|
||||||
|
private final AcsToWmsZDServiceImpl acsToWmsZDService;
|
||||||
|
private final InstructionService instructionService;
|
||||||
|
private final AcsToWmsService acsToWmsService;
|
||||||
|
@Autowired
|
||||||
|
LogServer logServer;
|
||||||
|
|
||||||
|
//取货前等待
|
||||||
|
public JSONObject waitInGet(String startDeviceCode) {
|
||||||
|
log.info("仙工AGV请求取货,设备号 - {}", startDeviceCode);
|
||||||
|
|
||||||
|
JSONObject requestWMSParam = new JSONObject();
|
||||||
|
requestWMSParam.put("StartStationCode", startDeviceCode);
|
||||||
|
JSONObject responseBody = acsToWmsService.gccQueryStationState(requestWMSParam);
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(responseBody) && 200 == responseBody.optInt("status")) {
|
||||||
|
JSONArray data = responseBody.optJSONArray("data");
|
||||||
|
for (int i = 0; i < data.size(); i++) {
|
||||||
|
JSONObject datum = data.getJSONObject(i);
|
||||||
|
if (startDeviceCode.equals(datum.optString("Station_Code"))
|
||||||
|
&& datum.optBoolean("IsHasGoods")) {
|
||||||
|
JSONObject map = new JSONObject();
|
||||||
|
map.put("status", 200);
|
||||||
|
map.put("message", "允许取货!");
|
||||||
|
log.info("允许仙工AGV取货,设备号 - {}", startDeviceCode);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new BadRequestException("请求失败!");
|
||||||
|
}
|
||||||
|
|
||||||
|
//取货完成等待
|
||||||
|
public JSONObject waitOutGet(String startDeviceCode) {
|
||||||
|
log.info("仙工AGV取货完成后请求离开,设备号 - {}", startDeviceCode);
|
||||||
|
|
||||||
|
JSONObject requestWMSParam = new JSONObject();
|
||||||
|
requestWMSParam.put("StartStationCode", startDeviceCode);
|
||||||
|
JSONObject responseBody = acsToWmsService.gccQueryStationState(requestWMSParam);
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(responseBody) && 200 == responseBody.optInt("status")) {
|
||||||
|
JSONArray data = responseBody.optJSONArray("data");
|
||||||
|
for (int i = 0; i < data.size(); i++) {
|
||||||
|
JSONObject datum = data.getJSONObject(i);
|
||||||
|
if (startDeviceCode.equals(datum.optString("Station_Code"))
|
||||||
|
&& !datum.optBoolean("IsHasGoods", true)) {
|
||||||
|
JSONObject map = new JSONObject();
|
||||||
|
map.put("status", 200);
|
||||||
|
map.put("message", "允许离开!");
|
||||||
|
log.info("允许仙工AGV取货完成后请求离开,设备号 - {}", startDeviceCode);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new BadRequestException("请求失败!");
|
||||||
|
}
|
||||||
|
|
||||||
|
//放货前等待
|
||||||
|
public JSONObject waitInPut(String endDeviceCode) {
|
||||||
|
log.info("仙工AGV请求放货,设备号 - {}", endDeviceCode);
|
||||||
|
|
||||||
|
JSONObject requestWMSParam = new JSONObject();
|
||||||
|
requestWMSParam.put("EndStationCode", endDeviceCode);
|
||||||
|
JSONObject responseBody = acsToWmsService.gccQueryStationState(requestWMSParam);
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(responseBody) && 200 == responseBody.optInt("status")) {
|
||||||
|
JSONArray data = responseBody.optJSONArray("data");
|
||||||
|
for (int i = 0; i < data.size(); i++) {
|
||||||
|
JSONObject datum = data.getJSONObject(i);
|
||||||
|
if (endDeviceCode.equals(datum.optString("Station_Code"))
|
||||||
|
&& !datum.optBoolean("IsHasGoods", true)) {
|
||||||
|
JSONObject map = new JSONObject();
|
||||||
|
map.put("status", 200);
|
||||||
|
map.put("message", "允许放货!");
|
||||||
|
log.info("允许仙工AGV放货,设备号 - {}", endDeviceCode);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new BadRequestException("请求失败!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//放货完成等待
|
||||||
|
public JSONObject waitOutPut(String endDeviceCode) {
|
||||||
|
log.info("仙工AGV放货完成后请求离开,设备号 - {}", endDeviceCode);
|
||||||
|
|
||||||
|
JSONObject requestWMSParam = new JSONObject();
|
||||||
|
requestWMSParam.put("EndStationCode", endDeviceCode);
|
||||||
|
JSONObject responseBody = acsToWmsService.gccQueryStationState(requestWMSParam);
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(responseBody) && 200 == responseBody.optInt("status")) {
|
||||||
|
JSONArray data = responseBody.optJSONArray("data");
|
||||||
|
for (int i = 0; i < data.size(); i++) {
|
||||||
|
JSONObject datum = data.getJSONObject(i);
|
||||||
|
if (endDeviceCode.equals(datum.optString("Station_Code"))
|
||||||
|
&& datum.optBoolean("IsHasGoods")) {
|
||||||
|
JSONObject map = new JSONObject();
|
||||||
|
map.put("status", 200);
|
||||||
|
map.put("message", "允许离开!");
|
||||||
|
log.info("允许仙工AGV放货完成后请求离开,设备号 - {}", endDeviceCode);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new BadRequestException("请求失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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("state", state);
|
||||||
}
|
}
|
||||||
door.put("timePoke", System.currentTimeMillis());
|
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 站点错误!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,4 +139,19 @@ public interface AcsToWmsService {
|
|||||||
* ]
|
* ]
|
||||||
*/
|
*/
|
||||||
com.alibaba.fastjson.JSONArray gccQueryDoorStatus();
|
com.alibaba.fastjson.JSONArray gccQueryDoorStatus();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 六维广钞厂查询站点有无货状态
|
||||||
|
* @param requestWMSParam 示例:{
|
||||||
|
* "StartStationCode":"111",
|
||||||
|
* "EndStationCode":"222"
|
||||||
|
* }
|
||||||
|
* @return 示例:{
|
||||||
|
* "errArr":null,
|
||||||
|
* "data":[{"Station_Code":"1170","IsHasGoods":true},{"Station_Code":"1030","IsHasGoods":true}],
|
||||||
|
* "status":"200",
|
||||||
|
* "message":"获取站点相关信息成功"
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
JSONObject gccQueryStationState(JSONObject requestWMSParam);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -559,4 +559,27 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
return new com.alibaba.fastjson.JSONArray();
|
return new com.alibaba.fastjson.JSONArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject gccQueryStationState(JSONObject requestWMSParam) {
|
||||||
|
try {
|
||||||
|
String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL);
|
||||||
|
AddressDto addressDto = addressService.findByCode("gccQueryStationState");
|
||||||
|
|
||||||
|
log.info("gccQueryStationState - 请求参数{}", requestWMSParam);
|
||||||
|
String responseBody = HttpRequest
|
||||||
|
.post(wmsurl + addressDto.getMethods_url())
|
||||||
|
.body(requestWMSParam.toString())
|
||||||
|
.execute()
|
||||||
|
.body();
|
||||||
|
log.info("gccQueryStationState - 响应参数{}", responseBody);
|
||||||
|
|
||||||
|
return JSONObject.fromObject(responseBody);
|
||||||
|
} catch (Exception e) {
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
result.put("status", HttpStatus.BAD_REQUEST.value());
|
||||||
|
result.put("message", e.getMessage());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,4 +242,5 @@ public interface InstructionService {
|
|||||||
|
|
||||||
boolean removeByCodeFromCache(String code);
|
boolean removeByCodeFromCache(String code);
|
||||||
|
|
||||||
|
public Instruction findByInstCodeFromCache(String inst_code);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1209,4 +1209,15 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
|
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
|
||||||
return pattern.matcher(str).matches();
|
return pattern.matcher(str).matches();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instruction findByInstCodeFromCache(String inst_code) {
|
||||||
|
for (int i = 0; i < this.instructions.size(); i++) {
|
||||||
|
Instruction inst = instructions.get(i);
|
||||||
|
if (StrUtil.equals(inst_code, inst.getInstruction_code())) {
|
||||||
|
return inst;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1069,13 +1069,13 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
|
|
||||||
}
|
}
|
||||||
//如果属于先知AGV,关闭运单序列
|
//如果属于先知AGV,关闭运单序列
|
||||||
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "3")) {
|
// if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "3")) {
|
||||||
try {
|
// try {
|
||||||
agvService.markComplete(entity.getTask_code());
|
// agvService.markComplete(entity.getTask_code());
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1121,11 +1121,11 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(entity.getStart_device_code(), entity.getNext_device_code(), entity.getRoute_plan_code());
|
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(entity.getStart_device_code(), entity.getNext_device_code(), entity.getRoute_plan_code());
|
||||||
String type = shortPathsList.get(0).getType();
|
String type = shortPathsList.get(0).getType();
|
||||||
// != 0 为agv任务
|
// != 0 为agv任务
|
||||||
if (!StrUtil.equals(type, "0")) {
|
// if (!StrUtil.equals(type, "0")) {
|
||||||
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "3")) {
|
// if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "3")) {
|
||||||
agvService.markComplete(entity.getTask_code());
|
// agvService.markComplete(entity.getTask_code());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import io.swagger.annotations.Api;
|
|||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
import org.nl.acs.test.service.TestService;
|
import org.nl.acs.test.service.TestService;
|
||||||
import org.nl.annotation.Log;
|
import org.nl.annotation.Log;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
@@ -35,18 +36,16 @@ public class TestController {
|
|||||||
@ApiOperation("test1")
|
@ApiOperation("test1")
|
||||||
@PostMapping("/test1")
|
@PostMapping("/test1")
|
||||||
//@PreAuthorize("@el.check('task:add')")
|
//@PreAuthorize("@el.check('task:add')")
|
||||||
public ResponseEntity<Object> test1() throws IOException {
|
public ResponseEntity<Object> test1(@RequestBody JSONObject requestParam) {
|
||||||
testService.test1();
|
return new ResponseEntity<>(testService.test1(requestParam), HttpStatus.OK);
|
||||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("test2")
|
@Log("test2")
|
||||||
@ApiOperation("test2")
|
@ApiOperation("test2")
|
||||||
@PostMapping("/test2")
|
@PostMapping("/test2")
|
||||||
//@PreAuthorize("@el.check('task:add')")
|
//@PreAuthorize("@el.check('task:add')")
|
||||||
public ResponseEntity<Object> test2() throws IOException {
|
public ResponseEntity<Object> test2(@RequestBody JSONObject requestParam) {
|
||||||
testService.test2();
|
return new ResponseEntity<>(testService.test2(requestParam), HttpStatus.OK);
|
||||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("test3")
|
@Log("test3")
|
||||||
|
|||||||
@@ -17,14 +17,14 @@ public interface TestService {
|
|||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
void test1() throws IOException;
|
JSONObject test1(JSONObject requestParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 触发打印
|
* 触发打印
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
void test2() throws IOException;
|
JSONObject test2(JSONObject requestParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载模板
|
* 加载模板
|
||||||
|
|||||||
@@ -4,12 +4,14 @@ package org.nl.acs.test.service.impl;
|
|||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.sf.json.JSONArray;
|
||||||
import net.sf.json.JSONObject;
|
import net.sf.json.JSONObject;
|
||||||
import org.nl.acs.test.service.TestService;
|
import org.nl.acs.test.service.TestService;
|
||||||
import org.nl.start.auto.run.LetteringSocketConnectionAutoRun;
|
import org.nl.start.auto.run.LetteringSocketConnectionAutoRun;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,32 +24,42 @@ import java.util.Map;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class TestServiceImpl implements TestService {
|
public class TestServiceImpl implements TestService {
|
||||||
|
|
||||||
|
private final HashMap<String, Integer> doors = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void test1() throws IOException {
|
public JSONObject test1(JSONObject requestParam) {
|
||||||
|
log.info("AGV控制门开关 - 请求参数{}", requestParam);
|
||||||
|
|
||||||
try {
|
doors.put(requestParam.optString("deviceID"), requestParam.optInt("state") == 0 ? 0 : 1);
|
||||||
//返回编译完成信号
|
|
||||||
LetteringSocketConnectionAutoRun.write("SETMSG 26 1" + "\r\n");
|
|
||||||
//返回打印开始信号
|
|
||||||
LetteringSocketConnectionAutoRun.write("SETMSG 2 1" + "\r\n");
|
|
||||||
//返回打印完成信号
|
|
||||||
LetteringSocketConnectionAutoRun.write("SETMSG 3 1" + "\r\n");
|
|
||||||
//返回每次打印的内容
|
|
||||||
LetteringSocketConnectionAutoRun.write("SETMSG 24 1" + "\r\n");
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
JSONObject result = new JSONObject();
|
||||||
e.printStackTrace();
|
result.put("result", 0);
|
||||||
}
|
result.put("message", "操作成功");
|
||||||
|
log.info("AGV控制门开关 - 响应参数{}", result);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void test2() throws IOException {
|
public JSONObject test2(JSONObject requestParam) {
|
||||||
try {
|
log.info("AGV查询门状态 - 请求参数{}", requestParam);
|
||||||
LetteringSocketConnectionAutoRun.write("BUFFERCLEAR" + "\r\n");
|
|
||||||
} catch (Exception e) {
|
String[] deviceIDs = requestParam.optString("deviceIDs").split(",");
|
||||||
e.printStackTrace();
|
JSONArray data = new JSONArray();
|
||||||
|
JSONObject row = new JSONObject();
|
||||||
|
for (String deviceID : deviceIDs) {
|
||||||
|
row.put("deviceID", deviceID);
|
||||||
|
row.put("doorState", doors.get(deviceID) == null ? -1 : doors.get(deviceID));
|
||||||
|
row.put("timePoke", System.currentTimeMillis());
|
||||||
|
data.add(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
result.put("result", 0);
|
||||||
|
result.put("message", "操作成功");
|
||||||
|
result.put("data", data);
|
||||||
|
log.info("AGV查询门状态 - 响应参数{}", result);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
package org.nl.modules.quartz.task;
|
package org.nl.modules.quartz.task;
|
||||||
|
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.http.HttpResponse;
|
import cn.hutool.http.HttpResponse;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.sf.json.JSONObject;
|
|
||||||
import org.nl.acs.agv.server.AgvService;
|
import org.nl.acs.agv.server.AgvService;
|
||||||
|
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||||
import org.nl.acs.instruction.service.InstructionService;
|
import org.nl.acs.instruction.service.InstructionService;
|
||||||
import org.nl.acs.instruction.service.dto.Instruction;
|
import org.nl.acs.instruction.service.dto.Instruction;
|
||||||
|
import org.nl.acs.task.service.TaskService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -26,59 +30,75 @@ public class QueryXZAgvTaskStatus {
|
|||||||
@Autowired
|
@Autowired
|
||||||
AgvService agvService;
|
AgvService agvService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
AcsToWmsService acsToWmsService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
TaskService taskService;
|
||||||
|
|
||||||
public void run() throws Exception {
|
public void run() throws Exception {
|
||||||
List<Instruction> instList = instructionService.findAllInstFromCache();
|
|
||||||
if (instList.size() > 0) {
|
|
||||||
for (int i = 0; i < instList.size(); i++) {
|
|
||||||
Instruction inst = instList.get(i);
|
|
||||||
if (!StrUtil.equals(inst.getSend_status(), "1")) continue;
|
|
||||||
String instcode = inst.getInstruction_code();
|
|
||||||
HttpResponse response = agvService.queryXZAgvInstStatus(instcode);
|
|
||||||
JSONObject jo = JSONObject.fromObject(response.body());
|
|
||||||
if (MapUtil.isEmpty(jo)) continue;
|
|
||||||
//反馈结果状态
|
|
||||||
log.info("instcode:" + instcode + "," + jo.toString());
|
|
||||||
//指令执行状态
|
|
||||||
String state = jo.getString("state");
|
|
||||||
String processingVehicle = "";
|
|
||||||
//正在执行指令agv车号
|
|
||||||
if (!StrUtil.isEmpty(jo.getString("processingVehicle"))) {
|
|
||||||
processingVehicle = jo.getString("processingVehicle");
|
|
||||||
inst.setCarno(processingVehicle);
|
|
||||||
}
|
|
||||||
|
|
||||||
// RAW:初始状态
|
HttpResponse response = agvService.queryXZAgvInstStatus();
|
||||||
// ACTIVE:业务订单已激活
|
com.alibaba.fastjson.JSONObject jo = JSONArray.parseObject(response.body());
|
||||||
// DISPATCHABLE:业务订单已通过系统验证,等待被调度执行
|
|
||||||
// BEING_PROCESSED:业务订单正在被执行
|
|
||||||
// WITHDRAWN:业务订单已被撤销
|
|
||||||
// FINISHED:业务订单已完成
|
|
||||||
// FAILED:业务订单已失败
|
|
||||||
// UNROUTABLE:无法规划该业务订单的执行路线
|
|
||||||
|
|
||||||
//执行中
|
JSONArray ja = JSONArray.parseArray(jo.getString("list"));
|
||||||
if ("BEING_PROCESSED".equals(state)) {
|
for (int i = 0; i < ja.size(); i++) {
|
||||||
if (inst != null) {
|
com.alibaba.fastjson.JSONObject one = (com.alibaba.fastjson.JSONObject) ja.get(i);
|
||||||
inst.setInstruction_status("1");
|
String inst_code = one.getString("id");
|
||||||
instructionService.update(inst);
|
Instruction inst = instructionService.findByInstCodeFromCache(inst_code);
|
||||||
}
|
if (ObjectUtil.isEmpty(inst))
|
||||||
} else if ("FINISHED".equals(state)) {
|
continue;
|
||||||
if (inst != null) {
|
//子任务状态 待以后处理
|
||||||
inst.setInstruction_status("2");
|
JSONArray blocks = JSONArray.parseArray(one.getString("blocks"));
|
||||||
instructionService.finish(inst);
|
for(int j=0;j<blocks.size();j++){
|
||||||
}
|
com.alibaba.fastjson.JSONObject blocksjo = (JSONObject) blocks.get(j);
|
||||||
} else if ("WITHDRAWN".equals(state) || "FAILED".equals(state)) {
|
String blockId = blocksjo.getString("blockId");
|
||||||
if (inst != null) {
|
String device_code = blocksjo.getString("location");
|
||||||
inst.setInstruction_status("4");
|
String state = blocksjo.getString("state");
|
||||||
instructionService.update(inst);
|
|
||||||
//instructionService.removeByCodeFromCache(instcode);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// else if ("STOPPED".equals(state)){
|
||||||
|
// if (inst != null) {
|
||||||
|
// instructionService.cancel(inst.getInstruction_id());
|
||||||
|
//
|
||||||
|
// TaskDto taskDto = taskService.findByCode(inst.getTask_code());
|
||||||
|
// taskService.cancel(taskDto.getTask_id());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,8 @@ spring:
|
|||||||
druid:
|
druid:
|
||||||
db-type: com.alibaba.druid.pool.DruidDataSource
|
db-type: com.alibaba.druid.pool.DruidDataSource
|
||||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||||
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:zgln_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
|
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:gcc_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
|
||||||
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:tg_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
|
|
||||||
username: ${DB_USER:root}
|
username: ${DB_USER:root}
|
||||||
# password: ${DB_PWD:P@ssw0rd}
|
|
||||||
# password: ${DB_PWD:Root.123456}
|
|
||||||
password: ${DB_PWD:123456}
|
password: ${DB_PWD:123456}
|
||||||
# 初始连接数
|
# 初始连接数
|
||||||
initial-size: 5
|
initial-size: 5
|
||||||
|
|||||||
@@ -135,3 +135,6 @@ file:
|
|||||||
# 文件大小 /M
|
# 文件大小 /M
|
||||||
maxSize: 100
|
maxSize: 100
|
||||||
avatarMaxSize: 5
|
avatarMaxSize: 5
|
||||||
|
|
||||||
|
agvToAcs:
|
||||||
|
addr: http://192.168.2.96:8010
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ ENV = 'production'
|
|||||||
|
|
||||||
# 如果使用 Nginx 代理后端接口,那么此处需要改为 '/',文件查看 Docker 部署篇,Nginx 配置
|
# 如果使用 Nginx 代理后端接口,那么此处需要改为 '/',文件查看 Docker 部署篇,Nginx 配置
|
||||||
# 接口地址,注意协议,如果你没有配置 ssl,需要将 https 改为 http
|
# 接口地址,注意协议,如果你没有配置 ssl,需要将 https 改为 http
|
||||||
VUE_APP_BASE_API = 'http://192.168.81.122:8010'
|
VUE_APP_BASE_API = 'http://127.0.0.1:8010'
|
||||||
#VUE_APP_BASE_API = 'http://127.0.0.1:8010'
|
#VUE_APP_BASE_API = 'http://127.0.0.1:8010'
|
||||||
# 如果接口是 http 形式, wss 需要改为 ws
|
# 如果接口是 http 形式, wss 需要改为 ws
|
||||||
VUE_APP_WS_API = 'ws://192.168.81.122:8010'
|
VUE_APP_WS_API = 'ws://127.0.0.1:8010'
|
||||||
#VUE_APP_WS_API = 'ws://127.0.0.1:8010'
|
#VUE_APP_WS_API = 'ws://127.0.0.1:8010'
|
||||||
|
|||||||
Reference in New Issue
Block a user