Browse Source

fix 请求取放货

master
张江玮 1 year ago
parent
commit
3d7c5a7c0f
  1. 16
      hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvWaitUtil.java
  2. 40
      hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java
  3. 16
      hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java
  4. 35
      hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java
  5. 2
      hd/nladmin-system/src/main/resources/config/application-prod.yml

16
hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvWaitUtil.java

@ -23,9 +23,6 @@ import org.springframework.stereotype.Service;
@RequiredArgsConstructor @RequiredArgsConstructor
@Slf4j @Slf4j
public class AgvWaitUtil { public class AgvWaitUtil {
private final DeviceAppService deviceAppService;
private final AcsToWmsZDServiceImpl acsToWmsZDService;
private final InstructionService instructionService;
private final AcsToWmsService acsToWmsService; private final AcsToWmsService acsToWmsService;
@Autowired @Autowired
LogServer logServer; LogServer logServer;
@ -107,14 +104,6 @@ public class AgvWaitUtil {
public JSONObject waitOutPut(String endDeviceCode, Instruction inst) { public JSONObject waitOutPut(String endDeviceCode, Instruction inst) {
log.info("仙工AGV放货完成后请求离开,设备号 - {}", endDeviceCode); log.info("仙工AGV放货完成后请求离开,设备号 - {}", endDeviceCode);
JSONObject responseBody = acsToWmsService.gccQueryStationState(inst);
if (ObjectUtil.isNotEmpty(responseBody) && 200 == responseBody.optInt("status")) {
JSONArray data = responseBody.optJSONArray("data");
for (int i = 0; i < data.size(); i++) {
JSONObject datum = data.getJSONObject(i);
if (endDeviceCode.equals(datum.optString("Station_Code"))
&& datum.optBoolean("IsHasGoods")) {
JSONObject map = new JSONObject(); JSONObject map = new JSONObject();
map.put("status", 200); map.put("status", 200);
map.put("message", "允许离开!"); map.put("message", "允许离开!");
@ -122,8 +111,3 @@ public class AgvWaitUtil {
return map; return map;
} }
} }
}
throw new BadRequestException("请求失败!");
}
}

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

@ -2181,26 +2181,26 @@ public class AgvServiceImpl implements AgvService {
jo4.put("operation", "JackUnload"); jo4.put("operation", "JackUnload");
ja.add(jo4); ja.add(jo4);
// if ("true".equals(nextDevice.getExtraValue().get("ignore_release_check"))) { if ("true".equals(nextDevice.getExtraValue().get("ignore_release_check"))) {
// //放货完成等待 //放货完成等待
// com.alibaba.fastjson.JSONObject jo5 = new com.alibaba.fastjson.JSONObject(); com.alibaba.fastjson.JSONObject jo5 = new com.alibaba.fastjson.JSONObject();
// jo5.put("blockId", IdUtil.simpleUUID()); jo5.put("blockId", IdUtil.simpleUUID());
// 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/interact.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();
// com.alibaba.fastjson.JSONObject reach5 = new com.alibaba.fastjson.JSONObject(); com.alibaba.fastjson.JSONObject reach5 = new com.alibaba.fastjson.JSONObject();
// reach5.put("task_code", inst.getInstruction_code()); reach5.put("task_code", inst.getInstruction_code());
// reach5.put("address", inst.getNext_point_code() + "OUTPUT"); reach5.put("address", inst.getNext_point_code() + "OUTPUT");
// data5.put("reach", reach5); data5.put("reach", reach5);
// script_args5.put("data", data5); script_args5.put("data", data5);
// script_args5.put("protocol", "HTTP"); script_args5.put("protocol", "HTTP");
// jo5.put("script_args", script_args5); jo5.put("script_args", script_args5);
// ja.add(jo5); ja.add(jo5);
// } }
return ja; return ja;
} }

16
hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java

@ -53,6 +53,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors;
/** /**
* @author ldjun * @author ldjun
@ -64,7 +65,7 @@ import java.util.regex.Pattern;
@Slf4j @Slf4j
public class InstructionServiceImpl implements InstructionService, ApplicationAutoInitial { public class InstructionServiceImpl implements InstructionService, ApplicationAutoInitial {
List<Instruction> instructions = new ArrayList(); List<Instruction> instructions = new ArrayList<>();
@Autowired @Autowired
DeviceAppService deviceAppService; DeviceAppService deviceAppService;
@ -1212,12 +1213,15 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override @Override
public Instruction findByInstCodeFromCache(String inst_code) { public Instruction findByInstCodeFromCache(String inst_code) {
for (int i = 0; i < this.instructions.size(); i++) { if (StrUtil.isBlank(inst_code)) {
Instruction inst = instructions.get(i); return null;
if (StrUtil.equals(inst_code, inst.getInstruction_code())) {
return inst;
}
} }
List<Instruction> list = this.instructions.stream().filter(i -> inst_code.equals(i.getInstruction_code())).collect(Collectors.toList());
if (list.isEmpty()) {
return null; return null;
} else {
return list.get(0);
}
} }
} }

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

@ -1,6 +1,5 @@
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.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpResponse;
@ -15,8 +14,6 @@ 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任务状态
*/ */
@ -36,27 +33,33 @@ public class QueryXZAgvTaskStatus {
@Autowired @Autowired
TaskService taskService; TaskService taskService;
private boolean lock = false;
public void run() throws Exception { public void run() throws Exception {
if (!this.lock) {
try {
this.lock = true;
HttpResponse response = agvService.queryXZAgvInstStatus(); HttpResponse response = agvService.queryXZAgvInstStatus();
com.alibaba.fastjson.JSONObject jo = JSONArray.parseObject(response.body()); JSONObject jo = JSONArray.parseObject(response.body());
JSONArray ja = JSONArray.parseArray(jo.getString("list")); JSONArray ja = JSONArray.parseArray(jo.getString("list"));
for (int i = 0; i < ja.size(); i++) { for (int i = 0; i < ja.size(); i++) {
com.alibaba.fastjson.JSONObject one = (com.alibaba.fastjson.JSONObject) ja.get(i); JSONObject one = ja.getJSONObject(i);
String inst_code = one.getString("id"); String inst_code = one.getString("id");
Instruction inst = instructionService.findByInstCodeFromCache(inst_code); Instruction inst = instructionService.findByInstCodeFromCache(inst_code);
if (ObjectUtil.isEmpty(inst)) if (ObjectUtil.isEmpty(inst)) {
continue; continue;
//子任务状态 待以后处理
JSONArray blocks = JSONArray.parseArray(one.getString("blocks"));
for(int j=0;j<blocks.size();j++){
com.alibaba.fastjson.JSONObject blocksjo = (JSONObject) blocks.get(j);
String blockId = blocksjo.getString("blockId");
String device_code = blocksjo.getString("location");
String state = blocksjo.getString("state");
} }
// //子任务状态 待以后处理
// JSONArray blocks = JSONArray.parseArray(one.getString("blocks"));
// for(int j=0;j<blocks.size();j++){
// com.alibaba.fastjson.JSONObject blocksjo = (JSONObject) blocks.get(j);
// String blockId = blocksjo.getString("blockId");
// String device_code = blocksjo.getString("location");
// String state = blocksjo.getString("state");
//
// }
String state = one.getString("state"); String state = one.getString("state");
if (!StrUtil.isEmpty(one.getString("vehicle"))) { if (!StrUtil.isEmpty(one.getString("vehicle"))) {
@ -99,6 +102,10 @@ public class QueryXZAgvTaskStatus {
// } // }
// } // }
} }
} finally {
this.lock = false;
}
}
} }
} }

2
hd/nladmin-system/src/main/resources/config/application-prod.yml

@ -137,4 +137,4 @@ file:
avatarMaxSize: 5 avatarMaxSize: 5
agvToAcs: agvToAcs:
addr: http://192.168.2.96:8010 addr: http://10.118.33.115:8010

Loading…
Cancel
Save