Browse Source

add 增加点位旋转和是否能够进入离开区域

master
周俊杰 1 month ago
parent
commit
8c560a9c95
  1. 13
      hd/nladmin-system/src/main/java/org/nl/acs/agv/rest/AgvController.java
  2. 20
      hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvService.java
  3. 20
      hd/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java
  4. 598
      hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java
  5. 6
      hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java
  6. 7
      hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java
  7. 111
      hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java
  8. 5
      hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/ToAgvDevice.java
  9. 40
      hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java
  10. 14
      hd/nladmin-system/src/main/resources/log/ToAgvDevice.xml
  11. 1
      hd/nladmin-system/src/main/resources/logback-spring.xml

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

@ -94,5 +94,16 @@ public class AgvController {
return new ResponseEntity<>(agvService.queryDeviceStation(), HttpStatus.OK); return new ResponseEntity<>(agvService.queryDeviceStation(), HttpStatus.OK);
} }
@PostMapping ("/releaseBlockGroup")
@Log("释放互斥组")
@ApiOperation("释放互斥组")
public ResponseEntity<JSONObject> releaseBlockGroup(@RequestBody JSONObject requestParam) {
return new ResponseEntity<>(agvService.releaseBlockGroup(requestParam), HttpStatus.OK);
}
@PostMapping ("/acquireBlockGroup")
@Log("占用互斥组")
@ApiOperation("占用互斥组")
public ResponseEntity<JSONObject> getBlockGroup(@RequestBody JSONObject requestParam) {
return new ResponseEntity<>(agvService.getBlockGroup(requestParam), HttpStatus.OK);
}
} }

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

@ -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();
@ -122,7 +122,7 @@ public interface AgvService {
public byte[] sendAgvOneModeInst(int phase, int index, int result1, int result2); public byte[] sendAgvOneModeInst(int phase, int index, int result1, int result2);
/** /**
* 下发agv单工动作指令 * agv单工动作指令
* *
* @param phase * @param phase
* @param index * @param index
@ -182,4 +182,20 @@ public interface AgvService {
String queryDeviceStation(); String queryDeviceStation();
/**
* 释放互斥组
*
* @param
* @return
*/
JSONObject releaseBlockGroup(JSONObject requestParam);
/**
* 占用互斥组
*
* @param
* @return
*/
JSONObject getBlockGroup(JSONObject requestParam);
} }

20
hd/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java

@ -27,7 +27,7 @@ public class AgvDto implements Serializable {
/** /**
* 机器人的剩余电量值单位整数百分比 * 机器人的剩余电量值单位整数百分比
*/ */
private String energyLevel; private Float energyLevel;
/** /**
* *
@ -57,17 +57,17 @@ public class AgvDto implements Serializable {
/** /**
* 角度 * 角度
*/ */
private String positionAngle; private float positionAngle;
/** /**
* X坐标 * X坐标
*/ */
private String positionX; private float positionX;
/** /**
* Y坐标 * Y坐标
*/ */
private String positionY; private float positionY;
/** /**
* 当前任务号 * 当前任务号
@ -79,6 +79,11 @@ public class AgvDto implements Serializable {
*/ */
private String battery_temp; private String battery_temp;
/**
* 电池电量
*/
private float battery_level;
/** /**
* 是否阻挡 * 是否阻挡
*/ */
@ -92,7 +97,12 @@ public class AgvDto implements Serializable {
/** /**
* 是否充电 * 是否充电
*/ */
private String charging; private Boolean charging;
/**
* 机器人连接状态0表示断连1表示连接上
*/
private Integer connection_status;
/** /**
* 控制器温度 * 控制器温度

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

@ -511,48 +511,7 @@ public class AgvServiceImpl implements AgvService {
@Override @Override
public HttpResponse queryMagicAgvDeviceStatus() { public HttpResponse queryMagicAgvDeviceStatus() {
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { return null;
String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
agvurl = agvurl + ":" + agvport + "/v1/vehicles";
HttpResponse result = HttpRequest.get(agvurl)
.timeout(20000)//超时,毫秒
.execute();
System.out.println("查询agv状态数据:" + result.body());
if (result.getStatus() == 200) {
JSONArray ja = JSONArray.fromObject(result.body());
for (int i = 0; i < ja.size(); i++) {
JSONObject jo = (JSONObject) ja.get(i);
String name = jo.getString("name");
String state = jo.getString("state");
String energyLevel = jo.getString("energyLevel");
String transportOrder = jo.getString("transportOrder");
String positionAngle = jo.getString("positionAngle");
String positionX = jo.getString("positionX");
String positionY = jo.getString("positionY");
AgvDto dto = new AgvDto();
dto.setName(name);
dto.setEnergyLevel(energyLevel);
dto.setState(state);
dto.setPositionAngle(positionAngle);
dto.setPositionX(positionX);
dto.setPositionY(positionY);
dto.setTransportOrder(transportOrder);
if (AGVDeviceStatus.containsKey(name)) {
AGVDeviceStatus.remove(name);
AGVDeviceStatus.put(name, dto);
} else {
AGVDeviceStatus.put(name, dto);
}
}
}
return result;
} else {
return null;
}
} }
@Override @Override
@ -591,9 +550,10 @@ public class AgvServiceImpl implements AgvService {
@Override @Override
public HttpResponse queryXZAgvDeviceStatus() { public HttpResponse queryXZAgvDeviceStatus() {
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); if (StrUtil.equals(acsConfigService.findByCode(AcsConfig.FORKAGV).getValue().toString(), "1")) {
String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); String agvurl = acsConfigService.findByCode(AcsConfig.AGVURL).getValue();
String agvport = acsConfigService.findByCode(AcsConfig.AGVPORT).getValue();
agvurl = agvurl + ":" + agvport + "/robotsStatus"; agvurl = agvurl + ":" + agvport + "/robotsStatus";
@ -603,99 +563,110 @@ public class AgvServiceImpl implements AgvService {
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.JSONObject body = com.alibaba.fastjson.JSONObject.parseObject(result.body());
com.alibaba.fastjson.JSONArray ja = body.getJSONArray("report");
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 = ja.getJSONObject(i);
String name = jo.getString("name"); //机器人编码
String state = jo.getString("state"); String agv_code = jo.getString("uuid");
String energyLevel = jo.getString("energyLevel"); //机器人详细状态信息
String transportOrder = jo.getString("transportOrder"); com.alibaba.fastjson.JSONObject rbk_report = jo.getJSONObject("rbk_report");
JSONObject detailjo = JSONObject.fromObject(result.body()); //是否正在充电
JSONObject item = (JSONObject) detailjo.get(name); Boolean charging = rbk_report.getBoolean("charging");
if(ObjectUtil.isEmpty(detailjo.get(name))){ //电池电量
continue; float battery_level1 = rbk_report.getFloatValue("battery_level");
float battery_level=battery_level1*100;
//当前地图
String current_map = rbk_report.getString("current_map");
//角度
float angle = rbk_report.getFloatValue("angle");
//执行运单信息
com.alibaba.fastjson.JSONObject current_order = jo.getJSONObject("current_order");
int task_status=rbk_report.getInteger("task_status");
String state=null;
if(task_status==0){
state="NONE";
}if(task_status==1){
state="WAITING";
}if(task_status==2){
state="RUNNING";
}if(task_status==3){
state="SUSPENDED";
}if(task_status==4){
state="COMPLETED";
}if(task_status==5){
state="FAILED";
}if(task_status==6){
state="CANCELED";
} }
String x = item.getString("x"); Integer connectionStatus = jo.getInteger("connection_status");
String y = item.getString("y"); String inst_code = current_order.getString("id");
String angle = item.getString("angle"); String taskNo= "0";
String battery_temp = item.getString("battery_temp"); if (StrUtil.isNotEmpty(inst_code)) {
String blocked = item.getString("blocked"); Instruction inst = instructionService.findByCodeFromCache(inst_code);
String brake = item.getString("brake"); if (ObjectUtil.isNotEmpty(inst)) {
String charging = item.getString("charging"); //任务号
String controller_temp = item.getString("controller_temp"); taskNo = inst.getTask_code();
String current_map = item.getString("current_map"); }
String current_station = item.getString("current_station"); }
String emergency = item.getString("emergency"); //x坐标
String odo = item.getString("odo"); float x = rbk_report.getFloatValue("x");
String requestCurrent = item.getString("requestCurrent"); //y坐标
String requestVoltage = item.getString("requestVoltage"); float y = rbk_report.getFloatValue("y");
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(agv_code);
dto.setEnergyLevel(energyLevel); dto.setCurrent_map(current_map);
dto.setState(state); dto.setCharging(charging);
dto.setTransportOrder(transportOrder); dto.setBattery_level(battery_level);
dto.setPositionAngle(angle); dto.setTransportOrder(taskNo);
dto.setPositionX(x); dto.setPositionX(x);
dto.setPositionY(y); dto.setPositionY(y);
dto.setBattery_temp(battery_temp); dto.setPositionAngle(angle);
dto.setBlocked(blocked); dto.setConnection_status(connectionStatus);
dto.setBrake(brake); dto.setState(state);
dto.setCharging(charging); AGVDeviceStatus.put(agv_code, dto);
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)) {
AGVDeviceStatus.remove(name);
AGVDeviceStatus.put(name, dto);
} else {
AGVDeviceStatus.put(name, dto);
}
} }
} }
return result; return result;
} 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";
List<Instruction> insts = instructionService.findAllInstFromCache();
if (!insts.isEmpty()) {
JSONObject where = new JSONObject();
where.put("relation", "OR");
JSONArray predicates = new JSONArray();
where.put("predicates", predicates);
for (Instruction instruction : insts) {
JSONArray row = new JSONArray();
row.add("id");
row.add("EQ");
row.add(instruction.getInstruction_code());
predicates.add(row);
}
agvurl = agvurl+ "&where=" + where;
}
HttpResponse result = HttpRequest.get(agvurl) HttpResponse result = HttpRequest.get(agvurl)
.timeout(20000)//超时,毫秒 .timeout(20000)//超时,毫秒
.execute(); .execute();
System.out.println("查询agv指令数据:" + result.body());
return result; return result;
} else { } else {
return null; return null;
} }
} }
@Override @Override
@ -742,25 +713,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
@ -1081,24 +1051,26 @@ public class AgvServiceImpl implements AgvService {
if (StrUtil.isBlank(address)) { if (StrUtil.isBlank(address)) {
throw new BadRequestException("请求失败,地址为空!"); throw new BadRequestException("请求失败,地址为空!");
} }
String startcode=inst.getStart_device_code();
//请求取货 //请求取货
if (address.contains("INGET")) { if (address.contains("INGET")) {
JSONObject jo=new JSONObject(); JSONObject jo=new JSONObject();
jo.put("device_code",inst.getStart_device_code()); jo.put("device_code",inst.getStart_device_code());
jo.put("device_status","enter"); jo.put("task_code",inst.getTask_code());
log.info("请求参数:{}", jo); jo.put("status","1");
jo.put("vehicle_code",inst.getVehicle_code());
JSONArray ja=new JSONArray(); JSONArray ja=new JSONArray();
for(Object key:jo.keySet()){ ja.add(jo);
JSONObject jo1=new JSONObject();
jo1.put(key,jo.get(key));
ja.add(jo1);
}
HttpResponse result=acsToWmsService.vehicle(ja); HttpResponse result=acsToWmsService.vehicle(ja);
log.info("请求取货请求参数:{}", ja);
com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body()); com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body());
log.info("上位反馈请求取货请求参数:{}",response);
int responseCode = response.getInteger("status"); int responseCode = response.getInteger("status");
if (responseCode == 200) { if (responseCode == 200) {
JSONObject jo2 = new JSONObject();
jo2.put("status",200);
log.info("上位允许取货 请求结果{}", responseCode); log.info("上位允许取货 请求结果{}", responseCode);
return jo2;
}else{ }else{
throw new BadRequestException("上位系统不允许取货"); throw new BadRequestException("上位系统不允许取货");
} }
@ -1106,41 +1078,46 @@ public class AgvServiceImpl implements AgvService {
//取货完成离开 //取货完成离开
if (address.contains("OUTGET")) { if (address.contains("OUTGET")) {
JSONObject jo=new JSONObject(); JSONObject jo=new JSONObject();
jo.put("device_code",inst.getStart_device_code()); jo.put("device_code",inst.getStart_device_code());
jo.put("device_status","left"); jo.put("task_code",inst.getTask_code());
log.info("请求参数:{}", jo); jo.put("status","2");
jo.put("vehicle_code",inst.getVehicle_code());
JSONArray ja=new JSONArray(); JSONArray ja=new JSONArray();
for(Object key:jo.keySet()){ ja.add(jo);
JSONObject jo1=new JSONObject(); log.info("取货完成离开请求参数:{}", ja);
jo1.put(key,jo.get(key));
ja.add(jo1);
}
HttpResponse result=acsToWmsService.vehicle(ja); HttpResponse result=acsToWmsService.vehicle(ja);
com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body()); com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body());
log.info("上位反馈取货完成离开请求参数:{}",response);
int responseCode = response.getInteger("status"); int responseCode = response.getInteger("status");
if (responseCode == 200) { if (responseCode == 200) {
JSONObject jo2 = new JSONObject();
jo2.put("status",200);
log.info("上位允许取货离开 请求结果{}", responseCode); log.info("上位允许取货离开 请求结果{}", responseCode);
return jo2;
}else{ }else{
throw new BadRequestException("上位系统不允许取货完成离开"); throw new BadRequestException("上位系统不允许取货完成离开");
} }
} }
//请求放货 //请求放货
if (address.contains("INPUT")) { if (address.contains("INPUT")) {
JSONObject jo=new JSONObject(); JSONObject jo=new JSONObject();
jo.put("device_code",inst.getNext_device_code()); jo.put("device_code",inst.getNext_device_code());
jo.put("device_status","enter"); jo.put("task_code",inst.getTask_code());
log.info("请求参数:{}", jo); jo.put("status","3");
jo.put("vehicle_code",inst.getVehicle_code());
JSONArray ja=new JSONArray(); JSONArray ja=new JSONArray();
for(Object key:jo.keySet()){ ja.add(jo);
JSONObject jo1=new JSONObject(); log.info("请求放货请求参数:{}", ja);
jo1.put(key,jo.get(key));
ja.add(jo1);
}
HttpResponse result=acsToWmsService.vehicle(ja); HttpResponse result=acsToWmsService.vehicle(ja);
com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body()); com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body());
log.info("上位反馈请求放货请求参数:{}",response);
int responseCode = response.getInteger("status"); int responseCode = response.getInteger("status");
if (responseCode == 200) { if (responseCode == 200) {
JSONObject jo2 = new JSONObject();
jo2.put("status",200);
log.info("上位允许放货 请求结果{}", responseCode); log.info("上位允许放货 请求结果{}", responseCode);
return jo2;
}else{ }else{
throw new BadRequestException("上位系统不允许请求放货"); throw new BadRequestException("上位系统不允许请求放货");
} }
@ -1149,20 +1126,22 @@ public class AgvServiceImpl implements AgvService {
//放货完成离开 //放货完成离开
if (address.contains("OUTPUT")) { if (address.contains("OUTPUT")) {
JSONObject jo=new JSONObject(); JSONObject jo=new JSONObject();
jo.put("device_code",inst.getNext_device_code()); jo.put("device_code",inst.getNext_device_code());
jo.put("device_status","left"); jo.put("task_code",inst.getTask_code());
log.info("请求参数:{}", jo); jo.put("status","4");
jo.put("vehicle_code",inst.getVehicle_code());
JSONArray ja=new JSONArray(); JSONArray ja=new JSONArray();
for(Object key:jo.keySet()){ ja.add(jo);
JSONObject jo1=new JSONObject(); log.info("放货完成离开:{}", ja);
jo1.put(key,jo.get(key));
ja.add(jo1);
}
HttpResponse result=acsToWmsService.vehicle(ja); HttpResponse result=acsToWmsService.vehicle(ja);
com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body()); com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body());
log.info("上位反馈放货完成离开请求参数:{}",response);
int responseCode = response.getInteger("status"); int responseCode = response.getInteger("status");
if (responseCode == 200) { if (responseCode == 200) {
JSONObject jo2 = new JSONObject();
jo2.put("status",200);
log.info("上位允许放货离开 请求结果{}", responseCode); log.info("上位允许放货离开 请求结果{}", responseCode);
return jo2;
}else{ }else{
throw new BadRequestException("上位系统不允许放货完成离开"); throw new BadRequestException("上位系统不允许放货完成离开");
} }
@ -1540,7 +1519,6 @@ public class AgvServiceImpl implements AgvService {
jo.put("blocks", createBlocksData(inst)); jo.put("blocks", createBlocksData(inst));
jo.put("priority", inst.getPriority()); jo.put("priority", inst.getPriority());
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), "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);
@ -1568,7 +1546,7 @@ public class AgvServiceImpl implements AgvService {
jo.put("location", inst.getStart_point_code() + "INGET"); jo.put("location", inst.getStart_point_code() + "INGET");
jo.put("operation", "script"); jo.put("operation", "script");
jo.put("id", inst.getStart_point_code() + "INGET"); jo.put("id", inst.getStart_point_code() + "INGET");
jo.put("script_name", "userpy/interact.py"); jo.put("script_name", "userpy/interact1.py");
com.alibaba.fastjson.JSONObject script_args = new com.alibaba.fastjson.JSONObject(); com.alibaba.fastjson.JSONObject script_args = new com.alibaba.fastjson.JSONObject();
script_args.put("addr", addr); script_args.put("addr", addr);
com.alibaba.fastjson.JSONObject data = new com.alibaba.fastjson.JSONObject(); com.alibaba.fastjson.JSONObject data = new com.alibaba.fastjson.JSONObject();
@ -1594,7 +1572,7 @@ public class AgvServiceImpl implements AgvService {
jo2.put("location", inst.getStart_point_code() + "OUTGET"); jo2.put("location", inst.getStart_point_code() + "OUTGET");
jo2.put("operation", "script"); jo2.put("operation", "script");
jo2.put("id", inst.getStart_point_code() + "OUTGET"); jo2.put("id", inst.getStart_point_code() + "OUTGET");
jo2.put("script_name", "userpy/interact.py"); jo2.put("script_name", "userpy/interact1.py");
com.alibaba.fastjson.JSONObject script_args2 = new com.alibaba.fastjson.JSONObject(); com.alibaba.fastjson.JSONObject script_args2 = new com.alibaba.fastjson.JSONObject();
script_args2.put("addr", addr); script_args2.put("addr", addr);
com.alibaba.fastjson.JSONObject data2 = new com.alibaba.fastjson.JSONObject(); com.alibaba.fastjson.JSONObject data2 = new com.alibaba.fastjson.JSONObject();
@ -1615,7 +1593,7 @@ public class AgvServiceImpl implements AgvService {
jo3.put("location", inst.getNext_point_code() + "INPUT"); jo3.put("location", inst.getNext_point_code() + "INPUT");
jo3.put("operation", "script"); jo3.put("operation", "script");
jo3.put("id", inst.getNext_point_code() + "INPUT"); jo3.put("id", inst.getNext_point_code() + "INPUT");
jo3.put("script_name", "userpy/interact.py"); jo3.put("script_name", "userpy/interact1.py");
com.alibaba.fastjson.JSONObject script_args3 = new com.alibaba.fastjson.JSONObject(); com.alibaba.fastjson.JSONObject script_args3 = new com.alibaba.fastjson.JSONObject();
script_args3.put("addr", addr); script_args3.put("addr", addr);
com.alibaba.fastjson.JSONObject data3 = new com.alibaba.fastjson.JSONObject(); com.alibaba.fastjson.JSONObject data3 = new com.alibaba.fastjson.JSONObject();
@ -1628,22 +1606,249 @@ public class AgvServiceImpl implements AgvService {
jo3.put("script_args", script_args3); jo3.put("script_args", script_args3);
ja.add(jo3); ja.add(jo3);
} }
//放货前下发旋转角度
// //放货前下发旋转角度 com.alibaba.fastjson.JSONObject json1 = new com.alibaba.fastjson.JSONObject();
// com.alibaba.fastjson.JSONObject json1 = new com.alibaba.fastjson.JSONObject(); if(inst.getStart_device_code().equals("3010")&&inst.getNext_device_code().equals("4031")){
// AcsPointAngleDto acsPointAngleDto = acsPointAngleService.findByCode(inst.getStart_device_code(),inst.getNext_device_code()); com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
// if (ObjectUtil.isNotEmpty(acsPointAngleDto)){ operation_args.put("increase_spin_angle",3.14);//弧度值,如3.14
// log.info("acsPointAngleDto----參數,{}", acsPointAngleDto.toString()); operation_args.put("skill_name","GoByOdometer");
// com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); json1.put("blockId", IdUtil.simpleUUID());
// BigDecimal next_point_angle = acsPointAngleDto.getNext_point_angle(); json1.put("location", inst.getNext_point_code() + "INPUT");
// operation_args.put("increase_spin_angle",next_point_angle);//弧度值,如3.14 json1.put("operation_args",operation_args);
// operation_args.put("skill_name","GoByOdometer"); ja.add(json1);
// json1.put("blockId", IdUtil.simpleUUID()); }else if(inst.getStart_device_code().equals("3031")&&inst.getNext_device_code().equals("4010")){
// json1.put("location", inst.getNext_point_code() + "INPUT"); com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
// json1.put("operation_args",operation_args); operation_args.put("increase_spin_angle",3.14);//弧度值,如3.14
// ja.add(json1); 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);
}else if(inst.getStart_device_code().equals("3012")&&inst.getNext_device_code().equals("4019")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3019")&&inst.getNext_device_code().equals("4012")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3001")&&inst.getNext_device_code().equals("4019")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3019")&&inst.getNext_device_code().equals("4001")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3019")&&inst.getNext_device_code().equals("4027")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3027")&&inst.getNext_device_code().equals("4019")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3027")&&inst.getNext_device_code().equals("4019")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3019")&&inst.getNext_device_code().equals("4028")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3028")&&inst.getNext_device_code().equals("4019")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3019")&&inst.getNext_device_code().equals("4017")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3017")&&inst.getNext_device_code().equals("4019")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3019")&&inst.getNext_device_code().equals("4036")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3036")&&inst.getNext_device_code().equals("4019")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3036")&&inst.getNext_device_code().equals("4019")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3010")&&inst.getNext_device_code().equals("4032")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3032")&&inst.getNext_device_code().equals("4010")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3010")&&inst.getNext_device_code().equals("4033")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3033")&&inst.getNext_device_code().equals("4010")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3010")&&inst.getNext_device_code().equals("4034")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3034")&&inst.getNext_device_code().equals("4010")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3010")&&inst.getNext_device_code().equals("4015")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3035")&&inst.getNext_device_code().equals("4010")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3010")&&inst.getNext_device_code().equals("4003")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3003")&&inst.getNext_device_code().equals("4010")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3034")&&inst.getNext_device_code().equals("4018")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3035")&&inst.getNext_device_code().equals("4018")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3018")&&inst.getNext_device_code().equals("4034")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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);
}else if(inst.getStart_device_code().equals("3018")&&inst.getNext_device_code().equals("4035")){
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
operation_args.put("increase_spin_angle",3.14);//弧度值,如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(); com.alibaba.fastjson.JSONObject jo4 = new com.alibaba.fastjson.JSONObject();
jo4.put("blockId", IdUtil.simpleUUID()); jo4.put("blockId", IdUtil.simpleUUID());
jo4.put("location", inst.getNext_point_code()); jo4.put("location", inst.getNext_point_code());
@ -1657,7 +1862,7 @@ public class AgvServiceImpl implements AgvService {
jo5.put("location", inst.getNext_point_code() + "OUTPUT"); jo5.put("location", inst.getNext_point_code() + "OUTPUT");
jo5.put("operation", "script"); jo5.put("operation", "script");
jo5.put("id", inst.getNext_point_code() + "OUTPUT"); jo5.put("id", inst.getNext_point_code() + "OUTPUT");
jo5.put("script_name", "userpy/interact.py"); jo5.put("script_name", "userpy/interact1.py");
com.alibaba.fastjson.JSONObject script_args5 = new com.alibaba.fastjson.JSONObject(); com.alibaba.fastjson.JSONObject script_args5 = new com.alibaba.fastjson.JSONObject();
script_args5.put("addr", addr); script_args5.put("addr", addr);
com.alibaba.fastjson.JSONObject data5 = new com.alibaba.fastjson.JSONObject(); com.alibaba.fastjson.JSONObject data5 = new com.alibaba.fastjson.JSONObject();
@ -1987,6 +2192,58 @@ public class AgvServiceImpl implements AgvService {
return null; return null;
} }
@Override
public JSONObject releaseBlockGroup(JSONObject requestParam) {
JSONArray datas = JSONArray.fromObject(requestParam);
log.info("仙工AGV离开进入管制区域,请求参数 - {}", requestParam);
for (int i = 0; i < requestParam.size(); i++) {
JSONObject jo = datas.getJSONObject(i);
// String robot_name = jo.optString("robot_name");
// jo.put("device code", robot_name);
jo.put("status", 6);
log.info("请求参数:{}", jo);
JSONArray ja = new JSONArray();
ja.add(jo);
HttpResponse result = acsToWmsService.vehicle(ja);
com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body());
int responseCode = response.getInteger("status");
JSONObject jo2 = new JSONObject();
jo2.put("message","ok");
jo2.put("code",200);
log.info("上位允许仙工AGV请求离开管制区 请求结果{}", responseCode);
return jo2;
}
throw new BadRequestException("请求失败,参数错误!");
}
@Override
public JSONObject getBlockGroup(JSONObject requestParam) {
JSONArray datas = JSONArray.fromObject(requestParam);
log.info("仙工AGV请求进入管制区域,请求参数 - {}", requestParam);
for (int i = 0; i < requestParam.size(); i++) {
JSONObject jo = datas.getJSONObject(i);
// String robot_name = jo.optString("robot_name");
// jo.put("device code",robot_name);
jo.put("status", "5");
log.info("请求参数:{}", jo);
JSONArray ja = new JSONArray();
ja.add(jo);
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) {
JSONObject jo2 = new JSONObject();
jo2.put("message","ok");
jo2.put("code",200);
log.info("上位允许仙工AGV请求进入管制区域 请求结果{}", responseCode);
return jo2;
} else {
throw new BadRequestException("上位不允许仙工AGV请求进入管制区域");
}
}
throw new BadRequestException("请求失败,参数错误!");
}
String hexToString(int i) { String hexToString(int i) {
return (i < 16 ? "0" + Integer.toHexString(i) : Integer.toHexString(i)).toUpperCase(); return (i < 16 ? "0" + Integer.toHexString(i) : Integer.toHexString(i)).toUpperCase();
} }
@ -2023,4 +2280,5 @@ public class AgvServiceImpl implements AgvService {
System.out.println(address); System.out.println(address);
} }
} }
} }

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

@ -454,19 +454,19 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
String methods_url = addressDto.getMethods_url(); String methods_url = addressDto.getMethods_url();
String url = wmsUrl + methods_url; String url = wmsUrl + methods_url;
HttpResponse result = null; HttpResponse result = null;
log.info("feedbackAgv----请求参数{}", from); log.info("vehicle----请求参数{}", from);
try { try {
result = HttpRequest.post(url) result = HttpRequest.post(url)
.body(String.valueOf(from)) .body(String.valueOf(from))
.execute(); .execute();
System.out.println(result); System.out.println(result);
log.info("feedbackAgv----返回参数{}", result); log.info("vehicle----返回参数{}", result);
} catch (Exception e) { } catch (Exception e) {
String msg = e.getMessage(); String msg = e.getMessage();
//网络不通 //网络不通
System.out.println(msg); System.out.println(msg);
log.info("feedbackAgv----异常{}", msg); log.info("vehicle----异常{}", msg);
} }
return result; return result;
} }

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

@ -1121,13 +1121,6 @@ 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任务
if (!StrUtil.equals(type, "0")) {
if (StrUtil.equals(acsConfigService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) {
AgvServiceImpl xianGongAgv = SpringContextHolder.getBean(AgvServiceImpl.class);
xianGongAgv.markComplete(entity.getTask_code());
}
}
} }
@Override @Override

111
hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java

@ -1,23 +1,24 @@
package org.nl.modules.quartz.task; package org.nl.modules.quartz.task;
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;
import java.util.List;
/** /**
* 查询AGV任务状态 * 查询AGV任务状态
*/ */
@Slf4j @Slf4j
@Component @Component("queryXZAgvTaskStatus")
public class QueryXZAgvTaskStatus { public class QueryXZAgvTaskStatus {
@Autowired @Autowired
@ -26,59 +27,69 @@ public class QueryXZAgvTaskStatus {
@Autowired @Autowired
AgvService agvService; AgvService agvService;
@Autowired
AcsToWmsService acsToWmsService;
@Autowired
TaskService taskService;
private volatile boolean lock = false;
public void run() throws Exception { public void run() throws Exception {
List<Instruction> instList = instructionService.findAllInstFromCache(); if (!lock) {
if (instList.size() > 0) { lock = true;
for (int i = 0; i < instList.size(); i++) { try {
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:业务订单已激活 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) { JSONObject one = (JSONObject) ja.get(i);
inst.setInstruction_status("1"); String inst_code = one.getString("id");
instructionService.update(inst); Instruction inst = instructionService.findByCodeFromCache(inst_code);
} if (ObjectUtil.isEmpty(inst))
} else if ("FINISHED".equals(state)) { continue;
if (inst != null) {
inst.setInstruction_status("2"); String state = one.getString("state");
instructionService.finish(inst); if (!StrUtil.isEmpty(one.getString("vehicle"))) {
} String carno = one.getString("vehicle");
} else if ("WITHDRAWN".equals(state) || "FAILED".equals(state)) { inst.setCarno(carno);
if (inst != null) {
inst.setInstruction_status("4");
instructionService.update(inst);
//instructionService.removeByCodeFromCache(instcode);
} }
} else {
} // 已创建=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);
}
}
}
} finally {
if (lock) {
lock = false;
}
} }
} }
} }
} }

5
hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/ToAgvDevice.java

@ -30,6 +30,7 @@ public class ToAgvDevice {
public void run() throws Exception { public void run() throws Exception {
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
Map<String, AgvDto> agv_map = agvService.findAllAgvFromCache(); Map<String, AgvDto> agv_map = agvService.findAllAgvFromCache();
log.info("AGV设备数据为{}",agv_map);
if(ObjectUtil.isEmpty(agv_map)){ if(ObjectUtil.isEmpty(agv_map)){
System.out.println("AGV设备数据为空,无法反馈"); System.out.println("AGV设备数据为空,无法反馈");
return; return;
@ -39,7 +40,7 @@ public class ToAgvDevice {
for (AgvDto agvDto : agv_map.values()) { for (AgvDto agvDto : agv_map.values()) {
row.put("device_code", agvDto.getName()); row.put("device_code", agvDto.getName());
row.put("energyLevel", agvDto.getEnergyLevel()); row.put("energyLevel", agvDto.getBattery_level());
row.put("device_status",agvDto.getState()); row.put("device_status",agvDto.getState());
row.put("transportOrder", agvDto.getTransportOrder()); row.put("transportOrder", agvDto.getTransportOrder());
row.put("positionX", agvDto.getPositionX()); row.put("positionX", agvDto.getPositionX());
@ -48,7 +49,9 @@ public class ToAgvDevice {
agv_rows.add(row); agv_rows.add(row);
} }
// json.put("agv_rows", agv_rows); // json.put("agv_rows", agv_rows);
log.info("向集控中心反馈设备状态为{}",agv_rows);
acsToWmsService.feedbackAgv(agv_rows); acsToWmsService.feedbackAgv(agv_rows);
} }
} }

40
hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java

@ -780,7 +780,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dto = new AgvDto(); dto = new AgvDto();
} }
dto.setName(String.valueOf(carno)); dto.setName(String.valueOf(carno));
dto.setPositionX(String.valueOf(ikey)); dto.setPositionX(Float.valueOf(ikey));
AgvService.updateAgvFromCache(dto); AgvService.updateAgvFromCache(dto);
} }
//Y坐标 //Y坐标
@ -794,7 +794,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dto = new AgvDto(); dto = new AgvDto();
} }
dto.setName(String.valueOf(carno)); dto.setName(String.valueOf(carno));
dto.setPositionY(String.valueOf(ikey)); dto.setPositionY(Float.valueOf(ikey));
AgvService.updateAgvFromCache(dto); AgvService.updateAgvFromCache(dto);
} }
//角度 //角度
@ -808,7 +808,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dto = new AgvDto(); dto = new AgvDto();
} }
dto.setName(String.valueOf(carno)); dto.setName(String.valueOf(carno));
dto.setPositionAngle(String.valueOf(ikey)); dto.setPositionAngle(Float.valueOf(ikey));
AgvService.updateAgvFromCache(dto); AgvService.updateAgvFromCache(dto);
} }
//电量 //电量
@ -822,7 +822,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dto = new AgvDto(); dto = new AgvDto();
} }
dto.setName(String.valueOf(carno)); dto.setName(String.valueOf(carno));
dto.setEnergyLevel(String.valueOf(ikey)); dto.setEnergyLevel(Float.valueOf(ikey));
AgvService.updateAgvFromCache(dto); AgvService.updateAgvFromCache(dto);
} }
break; break;
@ -1407,7 +1407,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dto = new AgvDto(); dto = new AgvDto();
} }
dto.setName(String.valueOf(carno)); dto.setName(String.valueOf(carno));
dto.setPositionX(String.valueOf(ikey)); dto.setPositionX(Float.valueOf(ikey));
AgvService.updateAgvFromCache(dto); AgvService.updateAgvFromCache(dto);
} }
//Y坐标 //Y坐标
@ -1420,7 +1420,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dto = new AgvDto(); dto = new AgvDto();
} }
dto.setName(String.valueOf(carno)); dto.setName(String.valueOf(carno));
dto.setPositionY(String.valueOf(ikey)); dto.setPositionY(Float.valueOf(ikey));
AgvService.updateAgvFromCache(dto); AgvService.updateAgvFromCache(dto);
} }
//角度 //角度
@ -1434,7 +1434,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dto = new AgvDto(); dto = new AgvDto();
} }
dto.setName(String.valueOf(carno)); dto.setName(String.valueOf(carno));
dto.setPositionAngle(String.valueOf(ikey)); dto.setPositionAngle(Float.valueOf(ikey));
AgvService.updateAgvFromCache(dto); AgvService.updateAgvFromCache(dto);
} }
@ -1448,7 +1448,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dto = new AgvDto(); dto = new AgvDto();
} }
dto.setName(String.valueOf(carno)); dto.setName(String.valueOf(carno));
dto.setEnergyLevel(String.valueOf(ikey)); dto.setEnergyLevel(Float.valueOf(ikey));
AgvService.updateAgvFromCache(dto); AgvService.updateAgvFromCache(dto);
} }
@ -1826,7 +1826,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dto = new AgvDto(); dto = new AgvDto();
} }
dto.setName(String.valueOf(carno)); dto.setName(String.valueOf(carno));
dto.setPositionX(String.valueOf(ikey)); dto.setPositionX(Float.valueOf(ikey));
AgvService.updateAgvFromCache(dto); AgvService.updateAgvFromCache(dto);
} }
//Y坐标 //Y坐标
@ -1839,7 +1839,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dto = new AgvDto(); dto = new AgvDto();
} }
dto.setName(String.valueOf(carno)); dto.setName(String.valueOf(carno));
dto.setPositionY(String.valueOf(ikey)); dto.setPositionY(Float.valueOf(ikey));
AgvService.updateAgvFromCache(dto); AgvService.updateAgvFromCache(dto);
} }
//角度 //角度
@ -1853,7 +1853,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dto = new AgvDto(); dto = new AgvDto();
} }
dto.setName(String.valueOf(carno)); dto.setName(String.valueOf(carno));
dto.setPositionAngle(String.valueOf(ikey)); dto.setPositionAngle(Float.valueOf(ikey));
AgvService.updateAgvFromCache(dto); AgvService.updateAgvFromCache(dto);
} }
@ -1867,7 +1867,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dto = new AgvDto(); dto = new AgvDto();
} }
dto.setName(String.valueOf(carno)); dto.setName(String.valueOf(carno));
dto.setEnergyLevel(String.valueOf(ikey)); dto.setEnergyLevel(Float.valueOf(ikey));
AgvService.updateAgvFromCache(dto); AgvService.updateAgvFromCache(dto);
} else { } else {
@ -2946,7 +2946,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dto = new AgvDto(); dto = new AgvDto();
} }
dto.setName(String.valueOf(carno)); dto.setName(String.valueOf(carno));
dto.setPositionX(String.valueOf(ikey)); dto.setPositionX(Float.valueOf(ikey));
AgvService.updateAgvFromCache(dto); AgvService.updateAgvFromCache(dto);
} }
//Y坐标 //Y坐标
@ -2959,7 +2959,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dto = new AgvDto(); dto = new AgvDto();
} }
dto.setName(String.valueOf(carno)); dto.setName(String.valueOf(carno));
dto.setPositionY(String.valueOf(ikey)); dto.setPositionY(Float.valueOf(ikey));
AgvService.updateAgvFromCache(dto); AgvService.updateAgvFromCache(dto);
} }
//角度 //角度
@ -2973,7 +2973,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dto = new AgvDto(); dto = new AgvDto();
} }
dto.setName(String.valueOf(carno)); dto.setName(String.valueOf(carno));
dto.setPositionAngle(String.valueOf(ikey)); dto.setPositionAngle(Float.valueOf(ikey));
AgvService.updateAgvFromCache(dto); AgvService.updateAgvFromCache(dto);
} }
@ -2987,7 +2987,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dto = new AgvDto(); dto = new AgvDto();
} }
dto.setName(String.valueOf(carno)); dto.setName(String.valueOf(carno));
dto.setEnergyLevel(String.valueOf(ikey)); dto.setEnergyLevel(Float.valueOf(ikey));
AgvService.updateAgvFromCache(dto); AgvService.updateAgvFromCache(dto);
} }
break; break;
@ -3596,7 +3596,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dto = new AgvDto(); dto = new AgvDto();
} }
dto.setName(String.valueOf(carno)); dto.setName(String.valueOf(carno));
dto.setPositionX(String.valueOf(ikey)); dto.setPositionX(Float.valueOf(ikey));
AgvService.updateAgvFromCache(dto); AgvService.updateAgvFromCache(dto);
} }
//Y坐标 //Y坐标
@ -3610,7 +3610,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dto = new AgvDto(); dto = new AgvDto();
} }
dto.setName(String.valueOf(carno)); dto.setName(String.valueOf(carno));
dto.setPositionY(String.valueOf(ikey)); dto.setPositionY(Float.valueOf(ikey));
AgvService.updateAgvFromCache(dto); AgvService.updateAgvFromCache(dto);
} }
//角度 //角度
@ -3624,7 +3624,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dto = new AgvDto(); dto = new AgvDto();
} }
dto.setName(String.valueOf(carno)); dto.setName(String.valueOf(carno));
dto.setPositionAngle(String.valueOf(ikey)); dto.setPositionAngle(Float.valueOf(ikey));
AgvService.updateAgvFromCache(dto); AgvService.updateAgvFromCache(dto);
} }
//电量 //电量
@ -3638,7 +3638,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dto = new AgvDto(); dto = new AgvDto();
} }
dto.setName(String.valueOf(carno)); dto.setName(String.valueOf(carno));
dto.setEnergyLevel(String.valueOf(ikey)); dto.setEnergyLevel(Float.valueOf(ikey));
AgvService.updateAgvFromCache(dto); AgvService.updateAgvFromCache(dto);
} }
break; break;

14
hd/nladmin-system/src/main/resources/log/ToAgvDevice.xml

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="$CONTROLLER_NAME$"
prefHeight="400.0" prefWidth="600.0">
</AnchorPane>

1
hd/nladmin-system/src/main/resources/logback-spring.xml

@ -27,6 +27,7 @@ https://juejin.cn/post/6844903775631572999
<include resource="log/NDCSocketConnectionAutoRun.xml"/> <include resource="log/NDCSocketConnectionAutoRun.xml"/>
<include resource="log/ScannerBarcode.xml"/> <include resource="log/ScannerBarcode.xml"/>
<include resource="log/QueryXZAgvDeviceStatus.xml"/> <include resource="log/QueryXZAgvDeviceStatus.xml"/>
<include resource="log/ToAgvDevice.xml"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">

Loading…
Cancel
Save