Browse Source

fix 仙工请求取放货接口和任务取消接口

master
周俊杰 7 months ago
parent
commit
8804a8b666
  1. 14
      hd/nladmin-system/src/main/java/org/nl/acs/agv/rest/AgvController.java
  2. 4
      hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvService.java
  3. 475
      hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java
  4. 2
      hd/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java
  5. 15
      hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java
  6. 29
      hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/XGToAcsController.java
  7. 8
      hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java
  8. 12
      hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/XGToAcsService.java
  9. 25
      hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java
  10. 13
      hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java
  11. 55
      hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/XGToAcsImpl.java
  12. 25
      hd/nladmin-system/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java
  13. 6
      hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

14
hd/nladmin-system/src/main/java/org/nl/acs/agv/rest/AgvController.java

@ -4,6 +4,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.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.nl.acs.agv.server.AgvService; import org.nl.acs.agv.server.AgvService;
import org.nl.acs.device.service.DeviceService; import org.nl.acs.device.service.DeviceService;
@ -69,14 +70,11 @@ public class AgvController {
return new ResponseEntity<>(agvService.sendAgvInstToMagic(instcode), HttpStatus.OK); return new ResponseEntity<>(agvService.sendAgvInstToMagic(instcode), HttpStatus.OK);
} }
@GetMapping("/waitPointRequest/locationDevices/{param}") @PostMapping ("/agv/xg/waitPointRequest")
@Log("agv等待点请求") @Log("仙工AGV请求取放货")
@ApiOperation("下发agv任务") @ApiOperation("仙工AGV请求取放货")
//@PreAuthorize("@el.check('routePlan:list')") public ResponseEntity<JSONObject> xgAGVWaitPointRequest(@RequestBody JSONObject requestParam) {
public ResponseEntity<Object> waitPointRequest(HttpServletRequest req) throws Exception { return new ResponseEntity<>(agvService.xgAGVWaitPointRequest(requestParam), HttpStatus.OK);
String serviceName = req.getRequestURI();
String param = StringUtils.substringAfterLast(serviceName, "/");
return new ResponseEntity<>(agvService.waitPointRequest(param), HttpStatus.OK);
} }
@GetMapping("/findAllAgvFromCache") @GetMapping("/findAllAgvFromCache")

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

@ -64,7 +64,7 @@ public interface AgvService {
public void deleteAgvInstToNDC(Instruction inst) throws Exception; public void deleteAgvInstToNDC(Instruction inst) throws Exception;
/** /*VV*
* 查询Magic AGV任务状态调用 * 查询Magic AGV任务状态调用
* *
* @param jobno * @param jobno
@ -90,7 +90,7 @@ public interface AgvService {
* @param * @param
* @return * @return
*/ */
public String waitPointRequest(String param); JSONObject xgAGVWaitPointRequest(JSONObject requestParam);
/** /**
* 请求开门关门 * 请求开门关门

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

@ -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) { TaskDto task = taskService.findByCodeFromCache(inst.getTask_code());
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); if (ObjectUtil.isEmpty(task)) {
//请求取货 throw new BadRequestException("请求失败,未找到指令对应任务!");
if (StrUtil.equals(type, "01") && address.endsWith("IN")
&& standardInspectSiteDeviceDriver.getMove() != 0) {
standardInspectSiteDeviceDriver.writing(1, 1);
is_feedback = true;
}
//取货完成
else if (StrUtil.equals(type, "02")) {
standardInspectSiteDeviceDriver.writing(1, 2);
is_feedback = true;
}
//取货完成离开
else if (StrUtil.equals(type, "05") && address.endsWith("OUT")
&& standardInspectSiteDeviceDriver.getMove() == 0) {
standardInspectSiteDeviceDriver.writing(1, 5);
is_feedback = true;
} }
//请求放货 String address = requestParam.getString("address");
else if (StrUtil.equals(type, "03") && address.endsWith("IN") if (StrUtil.isBlank(address)) {
&& standardInspectSiteDeviceDriver.getMove() == 0) { throw new BadRequestException("请求失败,地址为空!");
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();
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{
throw new BadRequestException("上位系统不允许取货");
} }
} }
//取货完成
else if (StrUtil.equals(type, "02")) {
sandardManipulatorInspectSiteDeviceDriver.writing(1, 2);
is_feedback = true;
}
//取货完成离开 //取货完成离开
else if (StrUtil.equals(type, "05") && address.endsWith("OUT")) { if (address.contains("OUTGET")) {
sandardManipulatorInspectSiteDeviceDriver.writing(1, 5); JSONObject jo=new JSONObject();
if ((sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 2 jo.put("device_code",inst.getStart_device_code());
|| sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 3) && sandardManipulatorInspectSiteDeviceDriver.getMove() == 0) { jo.put("device_status","left");
is_feedback = true; log.info("请求参数:{}", jo);
} JSONArray ja=new JSONArray();
} for(Object key:jo.keySet()){
//请求离开 JSONObject jo1=new JSONObject();
else if (StrUtil.equals(type, "08") && address.endsWith("OQ")) { jo1.put(key,jo.get(key));
sandardManipulatorInspectSiteDeviceDriver.writing(1, 8); ja.add(jo1);
if (sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 2 }
|| sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 3) { HttpResponse result=acsToWmsService.vehicle(ja);
is_feedback = true; com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body());
int responseCode = response.getInteger("status");
if (responseCode == 200) {
log.info("上位允许取货离开 请求结果{}", responseCode);
}else{
throw new BadRequestException("上位系统不允许取货完成离开");
} }
} }
//请求放货 //请求放货
else if (StrUtil.equals(type, "03") && address.endsWith("IN")) { if (address.contains("INPUT")) {
sandardManipulatorInspectSiteDeviceDriver.writing(1, 3); JSONObject jo=new JSONObject();
if ((sandardManipulatorInspectSiteDeviceDriver.getActoin() == 2 || sandardManipulatorInspectSiteDeviceDriver.getActoin() == 3) jo.put("device_code",inst.getNext_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, "04")) { jo1.put(key,jo.get(key));
sandardManipulatorInspectSiteDeviceDriver.writing(1, 4); 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, "06") && address.endsWith("OUT")) { int responseCode = response.getInteger("status");
sandardManipulatorInspectSiteDeviceDriver.writing(1, 6); if (responseCode == 200) {
if ((sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 2 log.info("上位允许放货 请求结果{}", responseCode);
|| sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 3) && sandardManipulatorInspectSiteDeviceDriver.getMove() != 0) { }else{
is_feedback = true; throw new BadRequestException("上位系统不允许请求放货");
} }
} }
//放货完成离开
if (address.contains("OUTPUT")) {
JSONObject jo=new JSONObject();
jo.put("device_code",inst.getNext_device_code());
jo.put("device_status","left");
log.info("请求参数:{}", jo);
JSONArray ja=new JSONArray();
for(Object key:jo.keySet()){
JSONObject jo1=new JSONObject();
jo1.put(key,jo.get(key));
ja.add(jo1);
} }
if (device.getDeviceDriver() instanceof WeighingSiteDeviceDriver) { HttpResponse result=acsToWmsService.vehicle(ja);
weighingSiteDeviceDriver = (WeighingSiteDeviceDriver) device.getDeviceDriver(); com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body());
Instruction inst = instructionService.findByCodeFromCache(inst_code); int responseCode = response.getInteger("status");
weighingSiteDeviceDriver.setInst(inst); if (responseCode == 200) {
//调用erp接口 log.info("上位允许放货离开 请求结果{}", responseCode);
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.HASOTHERSYSTEM).toString(), "1")) { }else{
log.info("请求ERP接口参数:{}", inst.getStart_device_code()); throw new BadRequestException("上位系统不允许放货完成离开");
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 {
machinesSiteDeviceDriver.writing(6);
}
}
//请求离开
else if (address.endsWith("OUT")) {
machinesSiteDeviceDriver.writing(6);
machinesSiteDeviceDriver.writing(6);
is_feedback = true;
} else {
if (machinesSiteDeviceDriver.getIoaction() == 2 || machinesSiteDeviceDriver.getIoaction() == 3) {
is_feedback = true;
} else {
machinesSiteDeviceDriver.writing(5);
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) {
ndxySpecialTwoDeviceDriver.writing(1, 3);
is_feedback = true;
}
//放货完成
else if (StrUtil.equals(type, "04")) {
ndxySpecialTwoDeviceDriver.writing(1, 4);
is_feedback = true;
}
}
if (device.getDeviceDriver() instanceof YkbkSpecialDeviceDriver) {
ykbkSpecialDeviceDriver = (YkbkSpecialDeviceDriver) device.getDeviceDriver();
//请求取货
if (StrUtil.equals(type, "01") && ykbkSpecialDeviceDriver.getMove() != 0) {
ykbkSpecialDeviceDriver.writing(1, 1);
is_feedback = true;
}
//取货完成
else if (StrUtil.equals(type, "02")) {
ykbkSpecialDeviceDriver.writing(1, 2);
is_feedback = true;
}
//请求放货
else if (StrUtil.equals(type, "03") && ykbkSpecialDeviceDriver.getMove() == 0) {
ykbkSpecialDeviceDriver.writing(1, 3);
is_feedback = true;
}
//放货完成
else if (StrUtil.equals(type, "04")) {
ykbkSpecialDeviceDriver.writing(1, 4);
is_feedback = true;
} }
} }
JSONObject jo = new JSONObject(); throw new BadRequestException("请求失败,IN OUT 站点错误!");
if (is_feedback) {
jo.put("name", param);
jo.put("lastAction", "wait");
jo.put("lastActionStatus", "DONE");
jo.put("status", "IDLE");
} else {
jo.put("name", param);
jo.put("lastAction", "wait");
jo.put("lastActionStatus", "FAILED");
jo.put("status", "IDLE");
}
is_feedback = false;
log.info("反馈AGV请求参数:{}", jo.toString());
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");

2
hd/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java

@ -340,8 +340,6 @@ public class DeviceController {
//@PreAuthorize("@el.check('routePlan:list')") //@PreAuthorize("@el.check('routePlan:list')")
public ResponseEntity<Object> selectDriverCodeList(@PathVariable String device_code) { public ResponseEntity<Object> selectDriverCodeList(@PathVariable String device_code) {
DeviceDto device = deviceService.findByCode(device_code); DeviceDto device = deviceService.findByCode(device_code);
//System.out.println(device.getDevice_type());
//return new ResponseEntity<>(DriverTypeEnum.getList(), HttpStatus.OK);
return new ResponseEntity<>(DriverTypeEnum.getListByType(device.getDevice_type()), HttpStatus.OK); return new ResponseEntity<>(DriverTypeEnum.getListByType(device.getDevice_type()), HttpStatus.OK);
} }

15
hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java

@ -26,7 +26,7 @@ import java.util.Map;
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@Api(tags = "wms接口") @Api(tags = "wms接口")
@RequestMapping("/api/wms") @RequestMapping("/api/agv")
@Slf4j @Slf4j
public class AcsToWmsController { public class AcsToWmsController {
private final AcsToWmsService acstowmsService; private final AcsToWmsService acstowmsService;
@ -38,7 +38,7 @@ public class AcsToWmsController {
return new ResponseEntity<>(acstowmsService.applyTaskToWms(device_code, container_code, height, weight), HttpStatus.OK); return new ResponseEntity<>(acstowmsService.applyTaskToWms(device_code, container_code, height, weight), HttpStatus.OK);
} }
@PostMapping("/taskStatusFeedback") @PostMapping("/task")
@Log("向WMS反馈任务状态") @Log("向WMS反馈任务状态")
@ApiOperation("向WMS反馈任务状态") @ApiOperation("向WMS反馈任务状态")
public ResponseEntity<Object> feedbackTaskStatusToWms(@RequestBody Map whereJson) { public ResponseEntity<Object> feedbackTaskStatusToWms(@RequestBody Map whereJson) {
@ -60,7 +60,7 @@ public class AcsToWmsController {
return new ResponseEntity<>(acstowmsService.feedbackAgvStatus(device_code, error, error_message), HttpStatus.OK); return new ResponseEntity<>(acstowmsService.feedbackAgvStatus(device_code, error, error_message), HttpStatus.OK);
} }
@PostMapping("/feedbackAgv") @PostMapping("/device")
@Log("反馈AGV设备信息") @Log("反馈AGV设备信息")
@ApiOperation("反馈AGV设备信息") @ApiOperation("反馈AGV设备信息")
public ResponseEntity<Object> feedbackAgv(@RequestBody String from) { public ResponseEntity<Object> feedbackAgv(@RequestBody String from) {
@ -81,4 +81,13 @@ public class AcsToWmsController {
public ResponseEntity<Object> feedbackDeviceStatus(@RequestBody String device_code, String code, String value) { public ResponseEntity<Object> feedbackDeviceStatus(@RequestBody String device_code, String code, String value) {
return new ResponseEntity<>(acstowmsService.feedbackDeviceStatus(device_code, code, value), HttpStatus.OK); return new ResponseEntity<>(acstowmsService.feedbackDeviceStatus(device_code, code, value), HttpStatus.OK);
} }
@PostMapping("/vehicle")
@Log("动作请求")
@ApiOperation("动作请求")
public ResponseEntity<Object> vehicle(@RequestBody String from) {
JSONArray array = JSONArray.fromObject(from);
return new ResponseEntity<>(acstowmsService.vehicle(array), HttpStatus.OK);
}
} }

29
hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/XGToAcsController.java

@ -0,0 +1,29 @@
package org.nl.acs.ext.wms.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.XGToAcsService;
import org.nl.annotation.Log;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
@RequiredArgsConstructor
@Api(tags = "XGToacs接口")
@Slf4j
public class XGToAcsController {
private final XGToAcsService XGToAcsService;
@PostMapping ("/xgAGVQueryWlsStatus")
@Log("是否允许进入离开")
@ApiOperation("是否允许进入离开")
public ResponseEntity<JSONObject> xgAGVQueryWlsStatus(@RequestBody JSONObject requestParam) {
return new ResponseEntity<>(XGToAcsService.xgAGVQueryWlsStatus(requestParam), HttpStatus.OK);
}
}

8
hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java

@ -82,6 +82,14 @@ public interface AcsToWmsService {
*/ */
HttpResponse feedbackAgv(JSONArray from); HttpResponse feedbackAgv(JSONArray from);
/**
* 动作请求
*
* @param from
* @return
*/
HttpResponse vehicle(JSONArray from);
/** /**
* 称重确认回传 * 称重确认回传
* *

12
hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/XGToAcsService.java

@ -0,0 +1,12 @@
package org.nl.acs.ext.wms.service;
import net.sf.json.JSONObject;
public interface XGToAcsService {
/**
* 查询外部互斥组请求历史
*
* @return Map<String, Object>
*/
public JSONObject xgAGVQueryWlsStatus(JSONObject from);
}

25
hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java

@ -446,6 +446,31 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
return result; return result;
} }
@Override
public HttpResponse vehicle(JSONArray from) {
String wmsUrl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL);
AddressDto addressDto = addressService.findByCode("vehicle");
String methods_url = addressDto.getMethods_url();
String url = wmsUrl + methods_url;
HttpResponse result = null;
log.info("feedbackAgv----请求参数{}", from);
try {
result = HttpRequest.post(url)
.body(String.valueOf(from))
.execute();
System.out.println(result);
log.info("feedbackAgv----返回参数{}", result);
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
System.out.println(msg);
log.info("feedbackAgv----异常{}", msg);
}
return result;
}
@Override @Override
public HttpResponse feedWeighing(JSONObject from) { public HttpResponse feedWeighing(JSONObject from) {
String wmsUrl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL); String wmsUrl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL);

13
hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java

@ -217,14 +217,15 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
errArr.add(json); errArr.add(json);
} }
} }
// if (ObjectUtil.isEmpty(errArr)) { if (ObjectUtil.isEmpty(errArr)) {
// resultJson.put("status", 200);
// } else {
// resultJson.put("status", 400);
// }
resultJson.put("status", 200); resultJson.put("status", 200);
resultJson.put("errArr", errArr);
resultJson.put("message", "操作成功"); resultJson.put("message", "操作成功");
resultJson.put("errArr", errArr);
} else {
resultJson.put("status", 400);
resultJson.put("message", "操作失败");
resultJson.put("errArr", errArr);
}
resultJson.put("data", new JSONObject()); resultJson.put("data", new JSONObject());
log.info("createFromWms--------------:输出参数:" + resultJson.toString()); log.info("createFromWms--------------:输出参数:" + resultJson.toString());
logServer.log("", "createFromWms", "info",tasks.toString(), resultJson.toString(), "200", "", ""); logServer.log("", "createFromWms", "info",tasks.toString(), resultJson.toString(), "200", "", "");

55
hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/XGToAcsImpl.java

@ -0,0 +1,55 @@
package org.nl.acs.ext.wms.service.impl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.nl.acs.config.server.AcsConfigService;
import org.nl.acs.device.address.service.AddressService;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.XGToAcsService;
import org.nl.acs.log.service.LogServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
@Slf4j
public class XGToAcsImpl implements XGToAcsService {
@Autowired
AcsConfigService acsConfigService;
@Autowired
LogServer logServer;
@Autowired
AddressService addressService;
@Autowired
AcsToWmsService acsToWmsService;
@Override
public JSONObject xgAGVQueryWlsStatus(JSONObject from) {
JSONArray datas = JSONArray.fromObject(from);
log.info("xgAGVQueryWlsStatus--------------:输入参数" + datas.toString());
for (int i = 0; i < datas.size(); i++) {
JSONObject data = datas.getJSONObject(i);
String robot_name = data.optString("robot_name");
String block_group_id = data.optString("block_group_id");
JSONObject jo = new JSONObject();
jo.put("robot_name", robot_name);
jo.put("block_group_id", block_group_id);
//暂时没定先用,之后是请求进入离开区域
acsToWmsService.feedWeighing(jo);
}
JSONObject resultJson = new JSONObject();
resultJson.put("status", HttpStatus.OK);
resultJson.put("message", "操作成功");
resultJson.put("data", new JSONObject());
log.info("updateDeviceGoodsFromWms--------------:输出参数" + resultJson.toString());
return resultJson;
}
}

25
hd/nladmin-system/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java

@ -260,7 +260,7 @@ public class RouteLineServiceImpl implements RouteLineService, ApplicationAutoIn
} }
} }
} }
// reload(); reload();
} }
@Override @Override
@ -425,28 +425,8 @@ public class RouteLineServiceImpl implements RouteLineService, ApplicationAutoIn
RoutePlanDto routePlan = (RoutePlanDto) var2.next(); RoutePlanDto routePlan = (RoutePlanDto) var2.next();
Map map1 = new HashMap(); Map map1 = new HashMap();
map1.put("route_plan_id", routePlan.getPlan_uuid()); map1.put("route_plan_id", routePlan.getPlan_uuid());
//List<Entity> allRouteLines = Db.use().query(initsql,param);
/*long l = System.currentTimeMillis();
List<Entity> allRouteLines = Db.use((DataSource) SpringContextHolder.getBean("dataSource")).query(initsql,param);
long l1 = System.currentTimeMillis();
System.out.println("加载时间"+(l1-l));*/
replaceAccess(routePlan.getPlan_uuid()); replaceAccess(routePlan.getPlan_uuid());
this.routePlans.put(routePlan.getPlan_code(), routePlan); this.routePlans.put(routePlan.getPlan_code(), routePlan);
/*List<RouteLineDto> routeDaoList = allRouteLines.stream().map(entity -> {
RouteLineDto routeLineDto = new RouteLineDto();
routeLineDto.setDevice_code(entity.get("device_code").toString());
routeLineDto.setNext_device_code(entity.get("next_device_code").toString());
routeLineDto.setRoute_plan_id(entity.get("route_plan_id").toString());
routeLineDto.setType(entity.get("type").toString());
routeLineDto.setPath(entity.get("path").toString());
routeLineDto.setWeights(Integer.parseInt(entity.get("weights").toString()));
return routeLineDto;
}).collect(Collectors.toList());*/
List<RouteLineDto> routeDaoList = routePlansList.stream().map(entity -> { List<RouteLineDto> routeDaoList = routePlansList.stream().map(entity -> {
RouteLineDto routeLineDto = new RouteLineDto(); RouteLineDto routeLineDto = new RouteLineDto();
routeLineDto.setDevice_code(entity.get("device_code").toString()); routeLineDto.setDevice_code(entity.get("device_code").toString());
@ -459,7 +439,6 @@ public class RouteLineServiceImpl implements RouteLineService, ApplicationAutoIn
}).collect(Collectors.toList()); }).collect(Collectors.toList());
Iterator var = routeDaoList.iterator(); Iterator var = routeDaoList.iterator();
List list = new ArrayList<>(); List list = new ArrayList<>();
while (var.hasNext()) { while (var.hasNext()) {
RouteLineDto routeLine = (RouteLineDto) var.next(); RouteLineDto routeLine = (RouteLineDto) var.next();
@ -469,8 +448,6 @@ public class RouteLineServiceImpl implements RouteLineService, ApplicationAutoIn
} }
routeLines.put(routePlan.getPlan_code(), list); routeLines.put(routePlan.getPlan_code(), list);
} }
} }
@Override @Override

6
hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

@ -14,6 +14,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.impl.AgvServiceImpl;
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;
import org.nl.acs.device.service.DeviceAssignedService; import org.nl.acs.device.service.DeviceAssignedService;
@ -1122,8 +1123,9 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
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.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) {
agvService.markComplete(entity.getTask_code()); AgvServiceImpl xianGongAgv = SpringContextHolder.getBean(AgvServiceImpl.class);
xianGongAgv.markComplete(entity.getTask_code());
} }
} }
} }

Loading…
Cancel
Save