fix 请求取放货
This commit is contained in:
@@ -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,23 +104,10 @@ 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);
|
JSONObject map = new JSONObject();
|
||||||
|
map.put("status", 200);
|
||||||
if (ObjectUtil.isNotEmpty(responseBody) && 200 == responseBody.optInt("status")) {
|
map.put("message", "允许离开!");
|
||||||
JSONArray data = responseBody.optJSONArray("data");
|
log.info("允许仙工AGV放货完成后请求离开,设备号 - {}", endDeviceCode);
|
||||||
for (int i = 0; i < data.size(); i++) {
|
return map;
|
||||||
JSONObject datum = data.getJSONObject(i);
|
|
||||||
if (endDeviceCode.equals(datum.optString("Station_Code"))
|
|
||||||
&& datum.optBoolean("IsHasGoods")) {
|
|
||||||
JSONObject map = new JSONObject();
|
|
||||||
map.put("status", 200);
|
|
||||||
map.put("message", "允许离开!");
|
|
||||||
log.info("允许仙工AGV放货完成后请求离开,设备号 - {}", endDeviceCode);
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new BadRequestException("请求失败!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
} else {
|
||||||
|
return list.get(0);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,33 +33,39 @@ public class QueryXZAgvTaskStatus {
|
|||||||
@Autowired
|
@Autowired
|
||||||
TaskService taskService;
|
TaskService taskService;
|
||||||
|
|
||||||
|
private boolean lock = false;
|
||||||
|
|
||||||
public void run() throws Exception {
|
public void run() throws Exception {
|
||||||
|
|
||||||
HttpResponse response = agvService.queryXZAgvInstStatus();
|
if (!this.lock) {
|
||||||
com.alibaba.fastjson.JSONObject jo = JSONArray.parseObject(response.body());
|
try {
|
||||||
|
this.lock = true;
|
||||||
|
HttpResponse response = agvService.queryXZAgvInstStatus();
|
||||||
|
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++){
|
// JSONArray blocks = JSONArray.parseArray(one.getString("blocks"));
|
||||||
com.alibaba.fastjson.JSONObject blocksjo = (JSONObject) blocks.get(j);
|
// for(int j=0;j<blocks.size();j++){
|
||||||
String blockId = blocksjo.getString("blockId");
|
// com.alibaba.fastjson.JSONObject blocksjo = (JSONObject) blocks.get(j);
|
||||||
String device_code = blocksjo.getString("location");
|
// String blockId = blocksjo.getString("blockId");
|
||||||
String state = blocksjo.getString("state");
|
// String device_code = blocksjo.getString("location");
|
||||||
|
// String state = blocksjo.getString("state");
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
String state = one.getString("state");
|
||||||
|
if (!StrUtil.isEmpty(one.getString("vehicle"))) {
|
||||||
String state = one.getString("state");
|
String carno = one.getString("vehicle");
|
||||||
if (!StrUtil.isEmpty(one.getString("vehicle"))) {
|
inst.setCarno(carno);
|
||||||
String carno = one.getString("vehicle");
|
}
|
||||||
inst.setCarno(carno);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 已创建=CREATED,
|
// 已创建=CREATED,
|
||||||
// 待分配=TOBEDISPATCHED,
|
// 待分配=TOBEDISPATCHED,
|
||||||
@@ -73,23 +76,23 @@ public class QueryXZAgvTaskStatus {
|
|||||||
// 无法执行=Error(参数错误),
|
// 无法执行=Error(参数错误),
|
||||||
// 等待=WAITING
|
// 等待=WAITING
|
||||||
|
|
||||||
//执行中
|
//执行中
|
||||||
if ("RUNNING".equals(state) || "CREATED".equals(state) || "TOBEDISPATCHED".equals(state) || "WAITING".equals(state)) {
|
if ("RUNNING".equals(state) || "CREATED".equals(state) || "TOBEDISPATCHED".equals(state) || "WAITING".equals(state)) {
|
||||||
if (inst != null) {
|
if (inst != null) {
|
||||||
inst.setInstruction_status("1");
|
inst.setInstruction_status("1");
|
||||||
instructionService.update(inst);
|
instructionService.update(inst);
|
||||||
}
|
}
|
||||||
} else if ("FINISHED".equals(state)) {
|
} else if ("FINISHED".equals(state)) {
|
||||||
if (inst != null) {
|
if (inst != null) {
|
||||||
inst.setInstruction_status("2");
|
inst.setInstruction_status("2");
|
||||||
instructionService.finish(inst);
|
instructionService.finish(inst);
|
||||||
}
|
}
|
||||||
} else if ("STOPPED".equals(state) || "FAILED".equals(state) || "Error".equals(state)) {
|
} else if ("STOPPED".equals(state) || "FAILED".equals(state) || "Error".equals(state)) {
|
||||||
if (inst != null) {
|
if (inst != null) {
|
||||||
inst.setInstruction_status("1");
|
inst.setInstruction_status("1");
|
||||||
instructionService.update(inst);
|
instructionService.update(inst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// else if ("STOPPED".equals(state)){
|
// else if ("STOPPED".equals(state)){
|
||||||
// if (inst != null) {
|
// if (inst != null) {
|
||||||
// instructionService.cancel(inst.getInstruction_id());
|
// instructionService.cancel(inst.getInstruction_id());
|
||||||
@@ -98,6 +101,10 @@ public class QueryXZAgvTaskStatus {
|
|||||||
// taskService.cancel(taskDto.getTask_id());
|
// taskService.cancel(taskDto.getTask_id());
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
this.lock = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user