fix
This commit is contained in:
@@ -6,18 +6,15 @@ 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.ext.wms.service.AcsToWmsService;
|
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||||
import org.nl.acs.ext.wms.service.impl.AcsToWmsZDServiceImpl;
|
|
||||||
import org.nl.acs.instruction.service.InstructionService;
|
import org.nl.acs.instruction.service.InstructionService;
|
||||||
import org.nl.acs.instruction.service.dto.Instruction;
|
import org.nl.acs.instruction.service.dto.Instruction;
|
||||||
import org.nl.acs.log.service.LogServer;
|
import org.nl.acs.log.service.LogServer;
|
||||||
import org.nl.acs.opc.DeviceAppService;
|
|
||||||
import org.nl.exception.BadRequestException;
|
import org.nl.exception.BadRequestException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: geng by
|
* @author zhangjiangwei
|
||||||
* @createDate: 2022/12/5
|
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@@ -27,6 +24,9 @@ public class AgvWaitUtil {
|
|||||||
@Autowired
|
@Autowired
|
||||||
LogServer logServer;
|
LogServer logServer;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
InstructionService instructionService;
|
||||||
|
|
||||||
//取货前等待
|
//取货前等待
|
||||||
public JSONObject waitInGet(String startDeviceCode, Instruction inst) {
|
public JSONObject waitInGet(String startDeviceCode, Instruction inst) {
|
||||||
log.info("仙工AGV请求取货,设备号 - {}", startDeviceCode);
|
log.info("仙工AGV请求取货,设备号 - {}", startDeviceCode);
|
||||||
@@ -55,25 +55,15 @@ public class AgvWaitUtil {
|
|||||||
public JSONObject waitOutGet(String startDeviceCode, Instruction inst) {
|
public JSONObject waitOutGet(String startDeviceCode, Instruction inst) {
|
||||||
log.info("仙工AGV取货完成后请求离开,设备号 - {}", startDeviceCode);
|
log.info("仙工AGV取货完成后请求离开,设备号 - {}", startDeviceCode);
|
||||||
|
|
||||||
JSONObject responseBody = acsToWmsService.gccQueryStationState(inst);
|
inst.setExecute_status("2");
|
||||||
|
instructionService.update(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 (startDeviceCode.equals(datum.optString("Station_Code"))
|
|
||||||
&& !datum.optBoolean("IsHasGoods", true)) {
|
|
||||||
JSONObject map = new JSONObject();
|
JSONObject map = new JSONObject();
|
||||||
map.put("status", 200);
|
map.put("status", 200);
|
||||||
map.put("message", "允许离开!");
|
map.put("message", "允许离开!");
|
||||||
log.info("允许仙工AGV取货完成后请求离开,设备号 - {}", startDeviceCode);
|
log.info("允许仙工AGV取货完成后请求离开,设备号 - {}", startDeviceCode);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new BadRequestException("请求失败!");
|
|
||||||
}
|
|
||||||
|
|
||||||
//放货前等待
|
//放货前等待
|
||||||
public JSONObject waitInPut(String endDeviceCode, Instruction inst) {
|
public JSONObject waitInPut(String endDeviceCode, Instruction inst) {
|
||||||
|
|||||||
@@ -663,6 +663,21 @@ public class AgvServiceImpl implements AgvService {
|
|||||||
String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
|
String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
|
||||||
|
|
||||||
agvurl = agvurl + ":" + agvport + "/orders?page=1&size=9999";
|
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)//超时,毫秒
|
||||||
@@ -2132,26 +2147,24 @@ public class AgvServiceImpl implements AgvService {
|
|||||||
jo1.put("operation", "JackLoad");
|
jo1.put("operation", "JackLoad");
|
||||||
ja.add(jo1);
|
ja.add(jo1);
|
||||||
|
|
||||||
// if ("true".equals(startDevice.getExtraValue().get("ignore_pickup_check"))) {
|
//取货完成等待
|
||||||
// //取货完成等待
|
com.alibaba.fastjson.JSONObject jo2 = new com.alibaba.fastjson.JSONObject();
|
||||||
// com.alibaba.fastjson.JSONObject jo2 = new com.alibaba.fastjson.JSONObject();
|
jo2.put("blockId", IdUtil.simpleUUID());
|
||||||
// jo2.put("blockId", IdUtil.simpleUUID());
|
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/interact.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();
|
com.alibaba.fastjson.JSONObject reach2 = new com.alibaba.fastjson.JSONObject();
|
||||||
// com.alibaba.fastjson.JSONObject reach2 = new com.alibaba.fastjson.JSONObject();
|
reach2.put("task_code", inst.getInstruction_code());
|
||||||
// reach2.put("task_code", inst.getInstruction_code());
|
reach2.put("address", inst.getStart_point_code() + "OUTGET");
|
||||||
// reach2.put("address", inst.getStart_point_code() + "OUTGET");
|
data2.put("reach", reach2);
|
||||||
// data2.put("reach", reach2);
|
script_args2.put("data", data2);
|
||||||
// script_args2.put("data", data2);
|
script_args2.put("protocol", "HTTP");
|
||||||
// script_args2.put("protocol", "HTTP");
|
jo2.put("script_args", script_args2);
|
||||||
// jo2.put("script_args", script_args2);
|
ja.add(jo2);
|
||||||
// ja.add(jo2);
|
|
||||||
// }
|
|
||||||
|
|
||||||
Device nextDevice = deviceAppService.findDeviceByCode(inst.getNext_device_code());
|
Device nextDevice = deviceAppService.findDeviceByCode(inst.getNext_device_code());
|
||||||
if ("true".equals(nextDevice.getExtraValue().get("ignore_release_check"))) {
|
if ("true".equals(nextDevice.getExtraValue().get("ignore_release_check"))) {
|
||||||
|
|||||||
@@ -70,4 +70,10 @@ public class WmsToAcsController {
|
|||||||
return new ResponseEntity<>(wmstoacsService.queryDevice(whereJson), HttpStatus.OK);
|
return new ResponseEntity<>(wmstoacsService.queryDevice(whereJson), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/gccCancelTask")
|
||||||
|
@Log("广钞厂取消任务")
|
||||||
|
@ApiOperation("广钞厂取消任务")
|
||||||
|
public ResponseEntity<Object> gccCancelTask(@RequestBody String whereJson) {
|
||||||
|
return new ResponseEntity<>(wmstoacsService.gccCancelTask(whereJson), HttpStatus.OK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,4 +52,6 @@ public interface WmsToAcsService {
|
|||||||
* @return Map<String, Object>
|
* @return Map<String, Object>
|
||||||
*/
|
*/
|
||||||
Map<String, Object> queryDevice(String jsonObject) throws Exception;
|
Map<String, Object> queryDevice(String jsonObject) throws Exception;
|
||||||
|
|
||||||
|
Map<String, Object> gccCancelTask(String whereJson);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.nl.acs.ext.wms.service.impl;
|
package org.nl.acs.ext.wms.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
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 lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -41,6 +42,8 @@ import org.nl.acs.route.service.RouteLineService;
|
|||||||
import org.nl.acs.route.service.dto.RouteLineDto;
|
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||||
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.acs.task.service.dto.TaskDto;
|
||||||
|
import org.nl.exception.BadRequestException;
|
||||||
|
import org.nl.utils.SecurityUtils;
|
||||||
import org.nl.utils.SpringContextHolder;
|
import org.nl.utils.SpringContextHolder;
|
||||||
import org.nl.wql.core.bean.WQLObject;
|
import org.nl.wql.core.bean.WQLObject;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -938,4 +941,60 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
return resultJson;
|
return resultJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> gccCancelTask(String whereJson) {
|
||||||
|
try {
|
||||||
|
log.info("gccCancelTask 请求参数:{}", whereJson);
|
||||||
|
JSONObject param = JSONObject.fromObject(whereJson);
|
||||||
|
String taskCode = param.optString("task_code");
|
||||||
|
if (StrUtil.isBlank(taskCode)) {
|
||||||
|
throw new BadRequestException("任务号不能为空,操作失败!");
|
||||||
|
}
|
||||||
|
|
||||||
|
TaskDto task = TaskService.findByCode(taskCode);
|
||||||
|
if (task == null) {
|
||||||
|
throw new BadRequestException(taskCode + "不存在,操作失败!");
|
||||||
|
}
|
||||||
|
if ("2".equals(task.getTask_status())) {
|
||||||
|
throw new BadRequestException(taskCode + "已完成,操作失败!");
|
||||||
|
}
|
||||||
|
|
||||||
|
Instruction inst = InstructionService.findByTaskcode(taskCode);
|
||||||
|
if (ObjectUtil.isNotEmpty(inst)) {
|
||||||
|
if (Integer.parseInt(inst.getExecute_status()) >= 2) {
|
||||||
|
throw new BadRequestException("AGV已取货完成,无法取消!");
|
||||||
|
}
|
||||||
|
InstructionService.cancel(inst.getInstruction_id());
|
||||||
|
}
|
||||||
|
|
||||||
|
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||||
|
String now = DateUtil.now();
|
||||||
|
task.setUpdate_time(now);
|
||||||
|
task.setUpdate_by(currentUsername);
|
||||||
|
task.setTask_status("3");
|
||||||
|
|
||||||
|
WQLObject wo = WQLObject.getWQLObject("acs_task");
|
||||||
|
JSONObject json = JSONObject.fromObject(task);
|
||||||
|
wo.update(json);
|
||||||
|
//清理缓存
|
||||||
|
for (int i = 0; i < TaskService.findAllTaskFromCache().size(); i++) {
|
||||||
|
TaskDto taskDto = TaskService.findAllTaskFromCache().get(i);
|
||||||
|
if (taskDto.getTask_code().equals(taskCode)) {
|
||||||
|
TaskService.findAllTaskFromCache().remove(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
JSONObject resultJson = new JSONObject();
|
||||||
|
resultJson.put("status", HttpStatus.BAD_REQUEST.value());
|
||||||
|
resultJson.put("message", e.getMessage());
|
||||||
|
log.info("gccCancelTask 响应参数:{}", resultJson);
|
||||||
|
return resultJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject resultJson = new JSONObject();
|
||||||
|
resultJson.put("status", HttpStatus.OK.value());
|
||||||
|
resultJson.put("message", "操作成功!");
|
||||||
|
log.info("gccCancelTask 响应参数:{}", resultJson);
|
||||||
|
return resultJson;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class InstructionDto implements Serializable {
|
|||||||
* 执行状态
|
* 执行状态
|
||||||
*/
|
*/
|
||||||
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
|
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
|
||||||
private String execute_status;
|
private String execute_status = "0";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行状态描述
|
* 执行状态描述
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ public class AutoCreateInst {
|
|||||||
protected BusinessLogger execute_log;
|
protected BusinessLogger execute_log;
|
||||||
protected NoRepeatBusinessLogger device_log;
|
protected NoRepeatBusinessLogger device_log;
|
||||||
|
|
||||||
|
private volatile boolean lock = false;
|
||||||
|
|
||||||
public AutoCreateInst() {
|
public AutoCreateInst() {
|
||||||
this.execute_log = new BusinessLoggerImpl(BusinessDomain.device_execute.name());
|
this.execute_log = new BusinessLoggerImpl(BusinessDomain.device_execute.name());
|
||||||
this.device_log = BusinessLoggerFactory.getNoRepeatBusinessLogger(BusinessDomain.device_execute.name());
|
this.device_log = BusinessLoggerFactory.getNoRepeatBusinessLogger(BusinessDomain.device_execute.name());
|
||||||
@@ -53,6 +55,9 @@ public class AutoCreateInst {
|
|||||||
* 创建指令前需要判断是否条件具备:起始位置是否有货、目标位置是否有货
|
* 创建指令前需要判断是否条件具备:起始位置是否有货、目标位置是否有货
|
||||||
*/
|
*/
|
||||||
public void run() throws Exception {
|
public void run() throws Exception {
|
||||||
|
if (!lock) {
|
||||||
|
lock = true;
|
||||||
|
try {
|
||||||
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
|
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
|
||||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
||||||
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
|
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
|
||||||
@@ -404,5 +409,11 @@ public class AutoCreateInst {
|
|||||||
taskserver.update(acsTask);
|
taskserver.update(acsTask);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
if (lock) {
|
||||||
|
lock = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import org.springframework.stereotype.Component;
|
|||||||
* 查询AGV任务状态
|
* 查询AGV任务状态
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component("queryXZAgvTaskStatus")
|
||||||
public class QueryXZAgvTaskStatus {
|
public class QueryXZAgvTaskStatus {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -33,33 +33,23 @@ public class QueryXZAgvTaskStatus {
|
|||||||
@Autowired
|
@Autowired
|
||||||
TaskService taskService;
|
TaskService taskService;
|
||||||
|
|
||||||
private boolean lock = false;
|
private volatile boolean lock = false;
|
||||||
|
|
||||||
public void run() throws Exception {
|
public void run() throws Exception {
|
||||||
|
if (!lock) {
|
||||||
if (!this.lock) {
|
lock = true;
|
||||||
try {
|
try {
|
||||||
this.lock = true;
|
|
||||||
HttpResponse response = agvService.queryXZAgvInstStatus();
|
HttpResponse response = agvService.queryXZAgvInstStatus();
|
||||||
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++) {
|
||||||
JSONObject one = ja.getJSONObject(i);
|
JSONObject one = (JSONObject) ja.get(i);
|
||||||
String inst_code = one.getString("id");
|
String inst_code = one.getString("id");
|
||||||
Instruction inst = instructionService.findByInstCodeFromCache(inst_code);
|
Instruction inst = instructionService.findByCodeFromCache(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");
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
String state = one.getString("state");
|
String state = one.getString("state");
|
||||||
if (!StrUtil.isEmpty(one.getString("vehicle"))) {
|
if (!StrUtil.isEmpty(one.getString("vehicle"))) {
|
||||||
@@ -93,19 +83,13 @@ public class QueryXZAgvTaskStatus {
|
|||||||
instructionService.update(inst);
|
instructionService.update(inst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// else if ("STOPPED".equals(state)){
|
|
||||||
// if (inst != null) {
|
|
||||||
// instructionService.cancel(inst.getInstruction_id());
|
|
||||||
//
|
|
||||||
// TaskDto taskDto = taskService.findByCode(inst.getTask_code());
|
|
||||||
// taskService.cancel(taskDto.getTask_id());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
this.lock = false;
|
if (lock) {
|
||||||
|
lock = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user