opt:优化kit调用时可能导致的并发问题
This commit is contained in:
@@ -2,8 +2,6 @@ package org.nl.acs.device_driver;
|
||||
|
||||
import org.nl.acs.opc.Device;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DeviceDriver {
|
||||
default String getDeviceCode() {
|
||||
return this.getDevice().getDevice_code();
|
||||
@@ -19,5 +17,9 @@ public interface DeviceDriver {
|
||||
return this.getDriverDefination().getDriverCode();
|
||||
}
|
||||
|
||||
// B设置新任务
|
||||
default void setDeviceInnerParam(String taskId, String agvphase) {
|
||||
throw new RuntimeException("not such method");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,26 +11,22 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dreamlu.mica.core.utils.StringUtil;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device.service.dto.StorageCellDto;
|
||||
import org.nl.acs.device.service.impl.StorageCellServiceImpl;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToHJXService;
|
||||
import org.nl.acs.ext.wms.service.AcsToMesService;
|
||||
import org.nl.acs.ext.wms.service.AcsToNDCService;
|
||||
import org.nl.acs.ext.wms.service.AcsToZDWmsService;
|
||||
import org.nl.acs.instruction.enums.InstTypeEnum;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.opc.WcsConfig;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||
@@ -81,6 +77,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
//有货标记
|
||||
protected boolean has_goods_tag = false;
|
||||
|
||||
|
||||
int mode = 0;
|
||||
int error = 0;
|
||||
int move = 0;
|
||||
@@ -137,7 +134,8 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
*/
|
||||
private volatile String reqTakeInstCode = null;
|
||||
private volatile Boolean reqTakeRequireSuccess = false;
|
||||
|
||||
private volatile String lastTakeInstCode = null; // 上次处理的taskId,处理完成后更新
|
||||
private final Object lock = new Object();
|
||||
//申请搬运任务
|
||||
private Boolean apply_handling = false;
|
||||
//申请物料
|
||||
@@ -180,9 +178,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
if (ObjectUtils.isEmpty(result) || result.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
} else {
|
||||
Object ext_system = device.getExtraValue().get("ext_system");
|
||||
@@ -210,9 +206,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
if (ObjectUtils.isEmpty(result1) || result1.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
} else {
|
||||
log.error("请求wms取货失败参数:{}", response);
|
||||
@@ -263,9 +257,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
if (ObjectUtils.isEmpty(result1) || result1.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
} else {
|
||||
log.error("请求焊接线失败,申请区货 错误信息{}", response);
|
||||
@@ -288,9 +280,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
if (ObjectUtils.isEmpty(result1) || result1.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -323,9 +313,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
if (ObjectUtils.isEmpty(result) || result.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
} else {
|
||||
Object ext_system = device.getExtraValue().get("ext_system");
|
||||
@@ -353,9 +341,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
if (ObjectUtils.isEmpty(result1) || result1.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
} else {
|
||||
log.error("请求wms取货失败参数:{}", response);
|
||||
@@ -399,9 +385,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
if (ObjectUtils.isEmpty(result1) || result1.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
} else {
|
||||
log.info("请求焊接线失败,申请取货完成 错误信息{}", response2);
|
||||
@@ -431,9 +415,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
if (ObjectUtils.isEmpty(result1) || result1.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -460,9 +442,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
if (ObjectUtils.isEmpty(result1) || result1.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
} else {
|
||||
Object ext_system = device.getExtraValue().get("ext_system");
|
||||
@@ -490,9 +470,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
if (ObjectUtils.isEmpty(result1) || result1.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
} else {
|
||||
log.error("请求wms请求放货失败参数:{}", response);
|
||||
@@ -525,9 +503,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
if (ObjectUtils.isEmpty(result1) || result1.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
} else {
|
||||
log.error("请求焊接线放货失败,申请区货 错误信息{}", response);
|
||||
@@ -545,9 +521,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
if (ObjectUtils.isEmpty(result1) || result1.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -573,9 +547,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
if (ObjectUtils.isEmpty(result1) || result1.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
} else {
|
||||
Object ext_system = device.getExtraValue().get("ext_system");
|
||||
@@ -603,9 +575,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
if (ObjectUtils.isEmpty(result1) || result1.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
} else {
|
||||
log.error("请求wms放货失败参数:{}", response);
|
||||
@@ -648,9 +618,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
if (ObjectUtils.isEmpty(result1) || result1.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
} else {
|
||||
log.info("请求焊接线放货货完成失败 错误信息{}", response2);
|
||||
@@ -682,9 +650,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
if (ObjectUtils.isEmpty(result1) || result1.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
} else {
|
||||
log.info("请求MES放货货完成失败 错误信息{}", responseCode);
|
||||
@@ -901,4 +867,30 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
// B设置新任务
|
||||
@Override
|
||||
public void setDeviceInnerParam(String taskId, String agvphase) {
|
||||
synchronized (lock) {
|
||||
// 不允许设置和上次处理相同的taskId
|
||||
if (taskId.equals(lastTakeInstCode)) {
|
||||
// 可以记录日志并返回,或者抛出异常
|
||||
return;
|
||||
}
|
||||
// 设置新任务
|
||||
this.agvphase = Integer.valueOf(agvphase);
|
||||
this.reqTakeInstCode = taskId;
|
||||
this.reqTakeRequireSuccess = true;
|
||||
}
|
||||
}
|
||||
// B设置新任务
|
||||
public void resetInstTask() {
|
||||
synchronized (lock) {
|
||||
// 设置新任务
|
||||
// 处理完成,更新状态
|
||||
this.lastTakeInstCode = reqTakeInstCode;
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,8 @@ import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.nl.acs.agv.server.AgvService;
|
||||
import org.nl.acs.agv.server.NDCAgvService;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device.service.StorageCellService;
|
||||
import org.nl.acs.device.service.dto.StorageCellDto;
|
||||
import org.nl.acs.device.service.impl.StorageCellServiceImpl;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
@@ -134,6 +132,8 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
|
||||
*/
|
||||
private volatile String reqTakeInstCode = null;
|
||||
private volatile Boolean reqTakeRequireSuccess = false;
|
||||
private volatile String lastTakeInstCode = null; // 上次处理的taskId,处理完成后更新
|
||||
private final Object lock = new Object();
|
||||
int index = 0;
|
||||
|
||||
int mode = 2;
|
||||
@@ -161,9 +161,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
|
||||
if (ObjectUtils.isEmpty(result) || result.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
}
|
||||
if (agvphase == 2) {
|
||||
@@ -183,9 +181,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
|
||||
if (ObjectUtils.isEmpty(result) || result.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
} else {
|
||||
//MES下发需要上报取货完成
|
||||
@@ -208,9 +204,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
|
||||
if (ObjectUtils.isEmpty(result) || result.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -230,9 +224,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
|
||||
if (ObjectUtils.isEmpty(result) || result.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
}
|
||||
if (agvphase == 4) {
|
||||
@@ -252,9 +244,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
|
||||
if (ObjectUtils.isEmpty(result) || result.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
} else {
|
||||
//mes下发需要上报放货完成
|
||||
@@ -291,9 +281,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
|
||||
if (ObjectUtils.isEmpty(result) || result.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
resetInstTask();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -345,5 +333,32 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
|
||||
// B设置新任务
|
||||
@Override
|
||||
public void setDeviceInnerParam(String taskId, String agvphase) {
|
||||
synchronized (lock) {
|
||||
// 不允许设置和上次处理相同的taskId
|
||||
if (taskId.equals(lastTakeInstCode)) {
|
||||
// 可以记录日志并返回,或者抛出异常
|
||||
return;
|
||||
}
|
||||
// 设置新任务
|
||||
this.agvphase = Integer.valueOf(agvphase);
|
||||
this.reqTakeInstCode = taskId;
|
||||
this.reqTakeRequireSuccess = true;
|
||||
}
|
||||
}
|
||||
// B设置新任务
|
||||
public void resetInstTask() {
|
||||
synchronized (lock) {
|
||||
// 设置新任务
|
||||
// 处理完成,更新状态
|
||||
this.lastTakeInstCode = reqTakeInstCode;
|
||||
this.reqTakeRequireSuccess = false;
|
||||
this.reqTakeInstCode = null;
|
||||
this.agvphase = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public enum TaskPhaseEnum {
|
||||
/**
|
||||
* 根据值获取对应的枚举
|
||||
*/
|
||||
public static TaskPhaseEnum fromValue(String value) {
|
||||
public static TaskPhaseEnum fromPhase(String value) {
|
||||
for (TaskPhaseEnum phase : values()) {
|
||||
if (phase.getValue() == value) {
|
||||
return phase;
|
||||
|
||||
@@ -9,24 +9,19 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.service.StorageCellService;
|
||||
import org.nl.acs.device.service.dto.StorageCellDto;
|
||||
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.ext.wms.enums.MsgTypeEnum;
|
||||
import org.nl.acs.ext.wms.enums.TaskPhaseEnum;
|
||||
import org.nl.acs.ext.wms.enums.TaskStateEnum;
|
||||
import org.nl.acs.ext.wms.service.NDCToAcsService;
|
||||
import org.nl.acs.instruction.enums.InstStatusEnum;
|
||||
import org.nl.acs.instruction.enums.InstTypeEnum;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@@ -46,197 +41,89 @@ public class NDCToAcsServiceImpl implements NDCToAcsService {
|
||||
JSONObject params = requestParam.getJSONObject("params");
|
||||
//任务状态上报
|
||||
if (MsgTypeEnum.TASK_STATE_RPT.getValue().equals(type)) {
|
||||
String taskId = params.getString("taskId");
|
||||
String instTaskId = params.getString("taskId");
|
||||
String taskPhase = params.getString("taskPhase");
|
||||
String taskState = params.getString("taskState");
|
||||
String taskPoint = params.getString("taskPoint");//请求进入/离开需要上报站点号
|
||||
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
|
||||
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
|
||||
//请求进入/请求离开
|
||||
if (StrUtil.isNotEmpty(taskPhase)
|
||||
&&(TaskPhaseEnum.ENTER_REQUEST_OR_ALLOWED.getValue().equals(taskPhase)
|
||||
||TaskPhaseEnum.LEAVE_NOTICE_OR_ALLOWED.getValue().equals(taskPhase))){
|
||||
StorageCellDto storageCellDto = storageCellService.findByAddress(taskPoint);
|
||||
if (ObjectUtil.isEmpty(storageCellDto)) {
|
||||
resp.put("code", "400");
|
||||
resp.put("message", "请求失败,点位信息不存在,点位站点号:" + taskPoint);
|
||||
return resp;
|
||||
}
|
||||
Device device = deviceAppService.findDeviceByCode(storageCellDto.getStorage_code());
|
||||
if (ObjectUtil.isEmpty(device)) {
|
||||
resp.put("code", "400");
|
||||
resp.put("message", "请求失败,请求位置编号不存在!");
|
||||
return resp;
|
||||
}
|
||||
if (TaskPhaseEnum.ENTER_REQUEST_OR_ALLOWED.getValue().equals(taskPhase)){
|
||||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver){
|
||||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
||||
standardOrdinarySiteDeviceDriver.setAgvphase(-1);
|
||||
standardOrdinarySiteDeviceDriver.setReqTakeInstCode(taskId);
|
||||
standardOrdinarySiteDeviceDriver.setReqTakeRequireSuccess(true);
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
|
||||
standardInspectSiteDeviceDriver.setAgvphase(-1);
|
||||
standardInspectSiteDeviceDriver.setReqTakeInstCode(taskId);
|
||||
standardInspectSiteDeviceDriver.setReqTakeRequireSuccess(true);
|
||||
}
|
||||
resp.put("code", "200");
|
||||
resp.put("message", "反馈请求进入成功");
|
||||
return resp;
|
||||
}
|
||||
if (TaskPhaseEnum.LEAVE_NOTICE_OR_ALLOWED.getValue().equals(taskPhase)){
|
||||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver){
|
||||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
||||
standardOrdinarySiteDeviceDriver.setAgvphase(-2);
|
||||
standardOrdinarySiteDeviceDriver.setReqTakeInstCode(taskId);
|
||||
standardOrdinarySiteDeviceDriver.setReqTakeRequireSuccess(true);
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
|
||||
standardInspectSiteDeviceDriver.setAgvphase(-2);
|
||||
standardInspectSiteDeviceDriver.setReqTakeInstCode(taskId);
|
||||
standardInspectSiteDeviceDriver.setReqTakeRequireSuccess(true);
|
||||
}
|
||||
resp.put("code", "200");
|
||||
resp.put("message", "反馈请求离开成功");
|
||||
return resp;
|
||||
}
|
||||
if (StrUtil.isEmpty(taskPhase)){
|
||||
resp.put("code", "400");
|
||||
resp.put("message", "taskPhase参数异常");
|
||||
return resp;
|
||||
}
|
||||
else if (StrUtil.isNotEmpty(taskPhase)&&(TaskPhaseEnum.PICKUP_REQUEST_OR_RESPONSE.getValue().equals(taskPhase)
|
||||
||TaskPhaseEnum.PICKUP_COMPLETE.getValue().equals(taskPhase)
|
||||
||TaskPhaseEnum.RELEASE_REQUEST_OR_RESPONSE.getValue().equals(taskPhase)
|
||||
||TaskPhaseEnum.RELEASE_COMPLETE.getValue().equals(taskPhase)
|
||||
||TaskStateEnum.NOT_STARTED.getValue().equals(taskPhase)
|
||||
||TaskStateEnum.EXECUTING.getValue().equals(taskPhase)||TaskStateEnum.COMPLETED.getValue().equals(taskPhase))){
|
||||
Instruction instruction = instructionService.findByCodeFromCache(taskId);
|
||||
if (ObjectUtil.isEmpty(instruction)) {
|
||||
Instruction instruction = instructionService.findByCodeFromCache(instTaskId);
|
||||
if (ObjectUtil.isEmpty(instruction)) {
|
||||
instruction = instructionService.findByTaskcode(instTaskId);
|
||||
if (ObjectUtil.isEmpty(instruction)){
|
||||
resp.put("code", "400");
|
||||
resp.put("message", "请求失败,任务信息不存在,指令号:" + taskId);
|
||||
resp.put("message", "请求失败,任务信息不存在,指令号:" + instTaskId);
|
||||
return resp;
|
||||
}
|
||||
|
||||
//taskPhase 任务完成
|
||||
if (TaskStateEnum.COMPLETED.getValue().equals(taskState)){
|
||||
instructionService.finish(instruction.getInstruction_id());
|
||||
resp.put("code", "200");
|
||||
resp.put("message", "完成任务成功");
|
||||
return resp;
|
||||
}
|
||||
//taskPhase 任务取消
|
||||
if (TaskStateEnum.CANCELED.getValue().equals(taskState)){
|
||||
instructionService.cancel(instruction.getInstruction_id());
|
||||
resp.put("code", "200");
|
||||
resp.put("message", "取消任务成功");
|
||||
return resp;
|
||||
}
|
||||
String start_point_code = instruction.getStart_point_code();
|
||||
String next_point_code = instruction.getNext_point_code();
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_point_code);
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_point_code);
|
||||
//taskPhase 请求取货上报
|
||||
if (TaskPhaseEnum.PICKUP_REQUEST_OR_RESPONSE.getValue().equals(taskPhase)){
|
||||
if (ObjectUtil.isEmpty(startDevice)) {
|
||||
resp.put("code", "400");
|
||||
resp.put("message", "请求取货失败,请求位置编号不存在!");
|
||||
return resp;
|
||||
}
|
||||
if (startDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver){
|
||||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) startDevice.getDeviceDriver();
|
||||
standardOrdinarySiteDeviceDriver.setAgvphase(1);
|
||||
standardOrdinarySiteDeviceDriver.setReqTakeInstCode(taskId);
|
||||
standardOrdinarySiteDeviceDriver.setReqTakeRequireSuccess(true);
|
||||
}
|
||||
if (startDevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startDevice.getDeviceDriver();
|
||||
standardInspectSiteDeviceDriver.setAgvphase(1);
|
||||
standardInspectSiteDeviceDriver.setReqTakeInstCode(taskId);
|
||||
standardInspectSiteDeviceDriver.setReqTakeRequireSuccess(true);
|
||||
}
|
||||
instruction.setExecute_status("1");
|
||||
instructionService.update(instruction);
|
||||
resp.put("code", "200");
|
||||
resp.put("message", "反馈请求取货成功");
|
||||
return resp;
|
||||
}
|
||||
//taskPhase 取货完成上报
|
||||
if (TaskPhaseEnum.PICKUP_COMPLETE.getValue().equals(taskPhase)){
|
||||
if (ObjectUtil.isEmpty(startDevice)) {
|
||||
resp.put("code", "400");
|
||||
resp.put("message", "请求取货完成失败,请求位置编号不存在!");
|
||||
return resp;
|
||||
}
|
||||
if (startDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver){
|
||||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) startDevice.getDeviceDriver();
|
||||
standardOrdinarySiteDeviceDriver.setAgvphase(2);
|
||||
standardOrdinarySiteDeviceDriver.setReqTakeInstCode(taskId);
|
||||
standardOrdinarySiteDeviceDriver.setReqTakeRequireSuccess(true);
|
||||
}
|
||||
if (startDevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startDevice.getDeviceDriver();
|
||||
standardInspectSiteDeviceDriver.setAgvphase(2);
|
||||
standardInspectSiteDeviceDriver.setReqTakeInstCode(taskId);
|
||||
standardInspectSiteDeviceDriver.setReqTakeRequireSuccess(true);
|
||||
}
|
||||
instruction.setExecute_status("2");
|
||||
instructionService.update(instruction);
|
||||
resp.put("code", "200");
|
||||
resp.put("message", "反馈取货完成成功");
|
||||
return resp;
|
||||
}
|
||||
//taskPhase 请求放货上报
|
||||
if (TaskPhaseEnum.RELEASE_REQUEST_OR_RESPONSE.getValue().equals(taskPhase)){
|
||||
if (ObjectUtil.isEmpty(nextDevice)) {
|
||||
resp.put("code", "400");
|
||||
resp.put("message", "请求放货失败,请求位置编号不存在!");
|
||||
return resp;
|
||||
}
|
||||
if (nextDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver){
|
||||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) nextDevice.getDeviceDriver();
|
||||
standardOrdinarySiteDeviceDriver.setAgvphase(3);
|
||||
standardOrdinarySiteDeviceDriver.setReqTakeInstCode(taskId);
|
||||
standardOrdinarySiteDeviceDriver.setReqTakeRequireSuccess(true);
|
||||
}
|
||||
if (nextDevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextDevice.getDeviceDriver();
|
||||
standardInspectSiteDeviceDriver.setAgvphase(3);
|
||||
standardInspectSiteDeviceDriver.setReqTakeInstCode(taskId);
|
||||
standardInspectSiteDeviceDriver.setReqTakeRequireSuccess(true);
|
||||
}
|
||||
instruction.setExecute_status("3");
|
||||
instructionService.update(instruction);
|
||||
resp.put("code", "200");
|
||||
resp.put("message", "反馈请求放货成功");
|
||||
return resp;
|
||||
}
|
||||
//taskPhase 放货完成上报
|
||||
if (TaskPhaseEnum.RELEASE_COMPLETE.getValue().equals(taskPhase)){
|
||||
if (ObjectUtil.isEmpty(nextDevice)) {
|
||||
resp.put("code", "400");
|
||||
resp.put("message", "请求放货完成失败,请求位置编号不存在!");
|
||||
return resp;
|
||||
}
|
||||
if (nextDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver){
|
||||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) nextDevice.getDeviceDriver();
|
||||
standardOrdinarySiteDeviceDriver.setAgvphase(4);
|
||||
standardOrdinarySiteDeviceDriver.setReqTakeInstCode(taskId);
|
||||
standardOrdinarySiteDeviceDriver.setReqTakeRequireSuccess(true);
|
||||
}
|
||||
if (nextDevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextDevice.getDeviceDriver();
|
||||
standardInspectSiteDeviceDriver.setAgvphase(4);
|
||||
standardInspectSiteDeviceDriver.setReqTakeInstCode(taskId);
|
||||
standardInspectSiteDeviceDriver.setReqTakeRequireSuccess(true);
|
||||
}
|
||||
instruction.setExecute_status("4");
|
||||
instructionService.update(instruction);
|
||||
resp.put("code", "200");
|
||||
resp.put("message", "反馈放货完成成功");
|
||||
return resp;
|
||||
}
|
||||
}else {
|
||||
throw new BadRequestException("上报的阶段值有误!");
|
||||
instructionService.reload();
|
||||
}
|
||||
//taskPhase 任务完成
|
||||
if (TaskStateEnum.COMPLETED.getValue().equals(taskState)){
|
||||
instructionService.finish(instruction.getInstruction_id());
|
||||
resp.put("code", "200");
|
||||
resp.put("message", "完成任务成功");
|
||||
return resp;
|
||||
}
|
||||
//taskPhase 任务取消
|
||||
if (TaskStateEnum.CANCELED.getValue().equals(taskState)){
|
||||
instructionService.cancel(instruction.getInstruction_id());
|
||||
resp.put("code", "200");
|
||||
resp.put("message", "取消任务成功");
|
||||
return resp;
|
||||
}
|
||||
Device device = null;
|
||||
TaskPhaseEnum taskPhaseEnum = TaskPhaseEnum.fromPhase(taskPhase);
|
||||
switch (taskPhaseEnum){
|
||||
case ENTER_REQUEST_OR_ALLOWED:
|
||||
case LEAVE_NOTICE_OR_ALLOWED:
|
||||
StorageCellDto storageCellDto = storageCellService.findByAddress(taskPoint);
|
||||
if (ObjectUtil.isEmpty(storageCellDto)) {
|
||||
resp.put("code", "400");
|
||||
resp.put("message", "请求失败,点位信息不存在,点位站点号:" + taskPoint);
|
||||
return resp;
|
||||
}
|
||||
device = deviceAppService.findDeviceByCode(storageCellDto.getStorage_code());
|
||||
if (ObjectUtil.isEmpty(device)) {
|
||||
resp.put("code", "400");
|
||||
resp.put("message", "请求失败,请求位置编号不存在!");
|
||||
return resp;
|
||||
}
|
||||
DeviceDriver deviceDriver = device.getDeviceDriver();
|
||||
deviceDriver.setDeviceInnerParam(instTaskId,taskPhase);
|
||||
break;
|
||||
case PICKUP_REQUEST_OR_RESPONSE:
|
||||
case PICKUP_COMPLETE:
|
||||
case RELEASE_REQUEST_OR_RESPONSE:
|
||||
case RELEASE_COMPLETE:
|
||||
if (TaskPhaseEnum.PICKUP_REQUEST_OR_RESPONSE.getValue().equals(taskPhase) || TaskPhaseEnum.PICKUP_COMPLETE.getValue().equals(taskPhase)){
|
||||
device = deviceAppService.findDeviceByCode(instruction.getStart_point_code());
|
||||
}
|
||||
//taskPhase 请求放货上报,放货完成上报
|
||||
if (TaskPhaseEnum.RELEASE_REQUEST_OR_RESPONSE.getValue().equals(taskPhase)||TaskPhaseEnum.RELEASE_COMPLETE.getValue().equals(taskPhase)){
|
||||
device = deviceAppService.findDeviceByCode(instruction.getNext_point_code());
|
||||
}
|
||||
if (device == null){
|
||||
resp.put("code", "400");
|
||||
resp.put("message", "点位驱动不存在");
|
||||
return resp;
|
||||
}
|
||||
device.getDeviceDriver().setDeviceInnerParam(instTaskId,taskPhase);
|
||||
if (!instruction.getExecute_status().equals(taskPhase)){
|
||||
instruction.setExecute_status(taskPhase);
|
||||
instructionService.update(instruction);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
resp.put("code", "400");
|
||||
resp.put("message", "taskPhase值不存在");
|
||||
return resp;
|
||||
}
|
||||
resp.put("code", "200");
|
||||
resp.put("message", taskPhaseEnum.getDescription()+"处理完毕");
|
||||
return resp;
|
||||
}
|
||||
//任务分配车辆上报
|
||||
else if (MsgTypeEnum.AGV_ID_RPT.getValue().equals(type)){
|
||||
@@ -305,6 +192,8 @@ public class NDCToAcsServiceImpl implements NDCToAcsService {
|
||||
resp.put("message", "更新指令执行中成功");
|
||||
return resp;
|
||||
}
|
||||
return null;
|
||||
resp.put("code", "400");
|
||||
resp.put("message", type+"type类型未定义");
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user