add 二次请求
This commit is contained in:
@@ -15,8 +15,6 @@ import org.nl.acs.device.device.service.DeviceAppService;
|
||||
import org.nl.acs.task.history.ErrorUtil;
|
||||
import org.nl.acs.task.instruction.domain.Instruction;
|
||||
import org.nl.acs.task.instruction.service.InstructionService;
|
||||
import org.nl.acs.task.task.service.TaskService;
|
||||
import org.nl.acs.task.task.service.dto.TaskDto;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.language.LangProcess;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
@@ -40,7 +38,6 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver {
|
||||
|
||||
private final LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
||||
private final InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
||||
private final TaskService taskService = SpringContextHolder.getBean(TaskService.class);
|
||||
private final AcsToKitService acsToKitService = SpringContextHolder.getBean(AcsToKitService.class);
|
||||
private final DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
|
||||
private final AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class);
|
||||
@@ -166,9 +163,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver {
|
||||
log.info("点位上报状态,{},{}",instruction.getTask_code(),agvphase);
|
||||
if (ObjectUtil.isNotEmpty(instruction) && StrUtil.equals(instruction.getStart_point_code(), this.devicecode)) {
|
||||
if (agvphase == 1) {
|
||||
TaskService taskService = SpringContextHolder.getBean("taskServiceImpl");
|
||||
TaskDto task = taskService.findByCode(instruction.getTask_code());
|
||||
if ((StrUtil.startWith(task.getTask_code(), "-"))) {
|
||||
if ((StrUtil.startWith(instruction.getTask_code(), "-"))) {
|
||||
log.info("定点任务下发agv允许取货信号");
|
||||
StorageCellDto dto = StorageCellServiceImpl.Storage_Cache_Map.get(instruction.getStart_point_code());
|
||||
if (dto == null) {
|
||||
@@ -185,9 +180,6 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver {
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (!requestPermission(task, instruction, WmsFeedbackStatusEnum.APPLY_TAKE.getValue(), WmsFeedbackStatusEnum.TAKING.getValue())) {
|
||||
return;
|
||||
}
|
||||
HttpResponse result1 = acsToKitService.genAgvSchedulingTask(instruction, 10);
|
||||
if (ObjectUtils.isEmpty(result1) || result1.getStatus() != 200) {
|
||||
return;
|
||||
@@ -197,10 +189,8 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver {
|
||||
}
|
||||
}
|
||||
if (agvphase == 2) {
|
||||
TaskService taskService = SpringContextHolder.getBean("taskServiceImpl");
|
||||
TaskDto task = taskService.findByCode(instruction.getTask_code());
|
||||
acsToWmsService.feedbackTask(task, resolveCard(task, instruction), WmsFeedbackStatusEnum.TAKE_FINISH.getValue());
|
||||
if ((StrUtil.startWith(task.getTask_code(), "-"))) {
|
||||
acsToWmsService.feedbackTask(instruction, WmsFeedbackStatusEnum.TAKE_FINISH.getValue());
|
||||
if ((StrUtil.startWith(instruction.getTask_code(), "-"))) {
|
||||
log.info("定点任务下发agv允许取货信号");
|
||||
StorageCellDto dto = StorageCellServiceImpl.Storage_Cache_Map.get(instruction.getStart_point_code());
|
||||
if (dto == null) {
|
||||
@@ -228,12 +218,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver {
|
||||
//放货申请
|
||||
else if (ObjectUtil.isNotEmpty(instruction) && StrUtil.equals(instruction.getNext_point_code(), this.devicecode)) {
|
||||
if (agvphase == 3) {
|
||||
TaskService taskService = SpringContextHolder.getBean("taskServiceImpl");
|
||||
TaskDto task = taskService.findByCode(instruction.getTask_code());
|
||||
if (!requestPermission(task, instruction, WmsFeedbackStatusEnum.APPLY_PUT.getValue(), WmsFeedbackStatusEnum.PUTTING.getValue())) {
|
||||
return;
|
||||
}
|
||||
if ((StrUtil.startWith(task.getTask_code(), "-"))) {
|
||||
if ((StrUtil.startWith(instruction.getTask_code(), "-"))) {
|
||||
log.info("定点任务下发agv允许取货信号");
|
||||
StorageCellDto dto = StorageCellServiceImpl.Storage_Cache_Map.get(instruction.getNext_point_code());
|
||||
if (dto == null) {
|
||||
@@ -258,10 +243,8 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver {
|
||||
}
|
||||
}
|
||||
if (agvphase == 4) {
|
||||
TaskService taskService = SpringContextHolder.getBean("taskServiceImpl");
|
||||
TaskDto task = taskService.findByCode(instruction.getTask_code());
|
||||
acsToWmsService.feedbackTask(task, resolveCard(task, instruction), WmsFeedbackStatusEnum.PUT_FINISH.getValue());
|
||||
if ((StrUtil.startWith(task.getTask_code(), "-"))) {
|
||||
acsToWmsService.feedbackTask(instruction, WmsFeedbackStatusEnum.PUT_FINISH.getValue());
|
||||
if ((StrUtil.startWith(instruction.getTask_code(), "-"))) {
|
||||
log.info("定点任务下发agv允许取货信号");
|
||||
StorageCellDto dto = StorageCellServiceImpl.Storage_Cache_Map.get(instruction.getNext_point_code());
|
||||
if (dto == null) {
|
||||
@@ -419,20 +402,17 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean requestPermission(TaskDto task, Instruction instruction, String permissionStatus, String progressStatus) {
|
||||
boolean allowed = acsToWmsService.feedbackTask(task, resolveCard(task, instruction), permissionStatus);
|
||||
if (allowed && task != null) {
|
||||
private boolean requestPermission(Instruction instruction, String permissionStatus, String progressStatus) {
|
||||
boolean allowed = acsToWmsService.feedbackTask(instruction, permissionStatus);
|
||||
if (allowed) {
|
||||
// WMS 放行后,先把外部状态推进到执行中,再继续给 AGV 下发动作。
|
||||
acsToWmsService.feedbackTask(task, resolveCard(task, instruction), progressStatus);
|
||||
acsToWmsService.feedbackTask(instruction, progressStatus);
|
||||
}
|
||||
return allowed;
|
||||
}
|
||||
|
||||
private String resolveCard(TaskDto task, Instruction instruction) {
|
||||
private String unusedResolveCard(Instruction instruction) {
|
||||
// 优先取任务上已绑定的车号,没有时再回退到当前指令上的车号。
|
||||
if (task != null && StrUtil.isNotBlank(task.getCarno())) {
|
||||
return task.getCarno();
|
||||
}
|
||||
return instruction == null ? "" : StrUtil.blankToDefault(instruction.getCarno(), "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,6 @@ import org.nl.acs.device.storageMgt.service.impl.StorageCellServiceImpl;
|
||||
import org.nl.acs.device.device.service.DeviceAppService;
|
||||
import org.nl.acs.task.instruction.domain.Instruction;
|
||||
import org.nl.acs.task.instruction.service.InstructionService;
|
||||
import org.nl.acs.task.task.service.TaskService;
|
||||
import org.nl.acs.task.task.service.dto.TaskDto;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.extInterface.agvKit.service.AcsToKitService;
|
||||
import org.nl.extInterface.wms.service.AcsToWmsService;
|
||||
@@ -83,20 +81,24 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractStandardDeviceDriv
|
||||
|
||||
if (ObjectUtil.isNotEmpty(instruction) && StrUtil.equals(instruction.getStart_point_code(), this.deviceCode)) {
|
||||
if (agvPhase == 1) {
|
||||
TaskService taskService = SpringContextHolder.getBean("taskServiceImpl");
|
||||
TaskDto task = taskService.findByCode(instruction.getTask_code());
|
||||
if (!requestPermission(task, instruction, WmsFeedbackStatusEnum.APPLY_TAKE.getValue(), WmsFeedbackStatusEnum.TAKING.getValue())) {
|
||||
//取货申请
|
||||
if (!requestPermission(instruction, WmsFeedbackStatusEnum.APPLY_TAKE.getValue())) {
|
||||
return;
|
||||
}
|
||||
// device = deviceAppService.findDeviceByCode(this.deviceCode);
|
||||
StorageCellDto dto = StorageCellServiceImpl.Storage_Cache_Map.get(instruction.getStart_point_code());
|
||||
//二次请求判断
|
||||
Instruction currentInstruction = redirectIfNeeded(instruction);
|
||||
if (currentInstruction == null) {
|
||||
return;
|
||||
}
|
||||
StorageCellDto dto = StorageCellServiceImpl.Storage_Cache_Map.get(currentInstruction.getStart_point_code());
|
||||
if (dto == null) {
|
||||
log.error(instruction.getStart_point_code() + "Storage_Cache_Map数据不存在");
|
||||
return;
|
||||
}
|
||||
instruction.setOffSet(dto.getAddress());
|
||||
instruction.setOffSetName(instruction.getStart_point_code());
|
||||
HttpResponse result = acsToKitService.genAgvSchedulingTask(instruction, 10);
|
||||
currentInstruction.setOffSet(dto.getAddress());
|
||||
currentInstruction.setOffSetName(currentInstruction.getStart_point_code());
|
||||
//反馈取货申请
|
||||
HttpResponse result = acsToKitService.genAgvSchedulingTask(currentInstruction, 10);
|
||||
if (ObjectUtils.isEmpty(result) || result.getStatus() != 200) {
|
||||
return;
|
||||
} else {
|
||||
@@ -104,9 +106,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractStandardDeviceDriv
|
||||
}
|
||||
}
|
||||
if (agvPhase == 2) {
|
||||
TaskService taskService = SpringContextHolder.getBean("taskServiceImpl");
|
||||
TaskDto task = taskService.findByCode(instruction.getTask_code());
|
||||
acsToWmsService.feedbackTask(task, resolveCard(task, instruction), WmsFeedbackStatusEnum.TAKE_FINISH.getValue());
|
||||
acsToWmsService.feedbackTask(instruction, WmsFeedbackStatusEnum.TAKE_FINISH.getValue());
|
||||
StorageCellDto dto = StorageCellServiceImpl.Storage_Cache_Map.get(instruction.getStart_point_code());
|
||||
if (dto == null) {
|
||||
log.error(instruction.getStart_point_code() + "Storage_Cache_Map数据不存在");
|
||||
@@ -114,7 +114,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractStandardDeviceDriv
|
||||
}
|
||||
instruction.setOffSet(dto.getAddress());
|
||||
instruction.setOffSetName(instruction.getStart_point_code());
|
||||
if ((StrUtil.startWith(task.getTask_code(), "-"))) {
|
||||
if ((StrUtil.startWith(instruction.getTask_code(), "-"))) {
|
||||
log.info("定点任务下发agv允许取货信号");
|
||||
HttpResponse result = acsToKitService.genAgvSchedulingTask(instruction, 10);
|
||||
if (ObjectUtils.isEmpty(result) || result.getStatus() != 200) {
|
||||
@@ -135,9 +135,8 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractStandardDeviceDriv
|
||||
//放货申请
|
||||
else if (ObjectUtil.isNotEmpty(instruction) && StrUtil.equals(instruction.getNext_point_code(), this.deviceCode)) {
|
||||
if (agvPhase == 3) {
|
||||
TaskService taskService = SpringContextHolder.getBean("taskServiceImpl");
|
||||
TaskDto task = taskService.findByCode(instruction.getTask_code());
|
||||
if (!requestPermission(task, instruction, WmsFeedbackStatusEnum.APPLY_PUT.getValue(), WmsFeedbackStatusEnum.PUTTING.getValue())) {
|
||||
//放货申请
|
||||
if (!requestPermission(instruction, WmsFeedbackStatusEnum.APPLY_PUT.getValue())) {
|
||||
return;
|
||||
}
|
||||
StorageCellDto dto = StorageCellServiceImpl.Storage_Cache_Map.get(instruction.getNext_point_code());
|
||||
@@ -155,9 +154,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractStandardDeviceDriv
|
||||
}
|
||||
}
|
||||
if (agvPhase == 4) {
|
||||
TaskService taskService = SpringContextHolder.getBean("taskServiceImpl");
|
||||
TaskDto task = taskService.findByCode(instruction.getTask_code());
|
||||
acsToWmsService.feedbackTask(task, resolveCard(task, instruction), WmsFeedbackStatusEnum.PUT_FINISH.getValue());
|
||||
acsToWmsService.feedbackTask(instruction, WmsFeedbackStatusEnum.PUT_FINISH.getValue());
|
||||
StorageCellDto dto = StorageCellServiceImpl.Storage_Cache_Map.get(instruction.getNext_point_code());
|
||||
if (dto == null) {
|
||||
log.error(instruction.getStart_point_code() + "Storage_Cache_Map数据不存在");
|
||||
@@ -165,7 +162,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractStandardDeviceDriv
|
||||
}
|
||||
instruction.setOffSet(dto.getAddress1());
|
||||
instruction.setOffSetName(instruction.getNext_point_code());
|
||||
if ((StrUtil.startWith(task.getTask_code(), "-"))) {
|
||||
if ((StrUtil.startWith(instruction.getTask_code(), "-"))) {
|
||||
log.info("定点任务下发agv允许取货信号");
|
||||
HttpResponse result = acsToKitService.genAgvSchedulingTask(instruction, 10);
|
||||
if (ObjectUtils.isEmpty(result) || result.getStatus() != 200) {
|
||||
@@ -243,21 +240,29 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractStandardDeviceDriv
|
||||
}
|
||||
}
|
||||
|
||||
private boolean requestPermission(TaskDto task, Instruction instruction, String permissionStatus, String progressStatus) {
|
||||
boolean allowed = acsToWmsService.feedbackTask(task, resolveCard(task, instruction), permissionStatus);
|
||||
if (allowed && task != null) {
|
||||
// WMS 放行后,先把外部状态推进到执行中,再继续给 AGV 下发动作。
|
||||
acsToWmsService.feedbackTask(task, resolveCard(task, instruction), progressStatus);
|
||||
}
|
||||
return allowed;
|
||||
private boolean requestPermission(Instruction instruction, String permissionStatus) {
|
||||
return acsToWmsService.feedbackTask(instruction, permissionStatus);
|
||||
}
|
||||
|
||||
private String resolveCard(TaskDto task, Instruction instruction) {
|
||||
// 优先取任务上已绑定的车号,没有时再回退到当前指令上的车号。
|
||||
if (task != null && StrUtil.isNotBlank(task.getCarno())) {
|
||||
return task.getCarno();
|
||||
private Instruction redirectIfNeeded(Instruction instruction) {
|
||||
|
||||
if (!StrUtil.equals(instruction.getNext_point_code(), "7E")) {
|
||||
return instruction;
|
||||
}
|
||||
return instruction == null ? "" : StrUtil.blankToDefault(instruction.getCarno(), "");
|
||||
JSONObject response = acsToWmsService.taskRedirection(instruction.getTask_code(), instruction.getNext_point_code());
|
||||
if (response == null || !Integer.valueOf(0).equals(response.getInteger("responseCode"))) {
|
||||
log.error("taskRedirection failed, taskCode:{}, currLocation:{}, response:{}",
|
||||
instruction.getTask_code(), instruction.getNext_point_code(), response);
|
||||
return null;
|
||||
}
|
||||
String locationNew = response.getString("locationNew");
|
||||
if (StrUtil.isBlank(locationNew)) {
|
||||
log.error("taskRedirection locationNew is blank, taskCode:{}, response:{}",
|
||||
instruction.getTask_code(), response);
|
||||
return null;
|
||||
}
|
||||
instruction.setStart_device_code(locationNew);
|
||||
return instruction;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -436,7 +436,8 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
if (StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) {
|
||||
throw new BadRequestException(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由类型不是agv类型");
|
||||
}
|
||||
if (shortPathsList.size() > 0 && StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE) && dto.getAgv_system_type().equals(AgvSystemTypeEnum.Two_NDC_System_Type.getIndex())) {
|
||||
if (shortPathsList.size() > 0 && StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE) && dto.getAgv_system_type().equals(AgvSystemTypeEnum.Two_NDC_System_Type.getIndex()))
|
||||
{
|
||||
// 0为输送、立库任务 1 1楼叉车系统 2 2楼1区域AGV系统 3 2楼2区域AGV系统
|
||||
if (!StrUtil.equals(task.getAgv_system_type(), "0")
|
||||
&& ObjectUtil.isNotEmpty(task.getAgv_system_type())) {
|
||||
@@ -444,31 +445,11 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
String agv_system_type = task.getAgv_system_type();
|
||||
String task_type = task.getTask_type();
|
||||
if (!StrUtil.equals(agv_system_type, "1")) {
|
||||
// task_type
|
||||
//1、生箔; Itype=1:取空,取满,放空,放满;
|
||||
//2、分切 Itype=3取满、取空、放满、放空;
|
||||
//3、普通任务 Itype=2:取货、放货;
|
||||
//4、叉车任务
|
||||
//5、输送任务
|
||||
//6、行架
|
||||
//7、立库
|
||||
if (StrUtil.equals(task_type, "1")) {
|
||||
dto.setAgv_inst_type("1");
|
||||
} else if (StrUtil.equals(task_type, "3")) {
|
||||
dto.setAgv_inst_type("2");
|
||||
} else if (StrUtil.equals(task_type, "2")) {
|
||||
dto.setAgv_inst_type("3");
|
||||
} else if (StrUtil.equals(task_type, "8")) {
|
||||
dto.setAgv_inst_type("2");
|
||||
} else {
|
||||
log.info("未找到对应的AGV指令类型,任务号:" + task.getTask_code() + ",task_type:" + task.getTask_type());
|
||||
}
|
||||
} else {
|
||||
dto.setAgv_inst_type("4");
|
||||
|
||||
}
|
||||
dto.setAgv_system_type(task.getAgv_system_type());
|
||||
}
|
||||
|
||||
try {
|
||||
if (StrUtil.isEmpty(dto.getAgv_inst_type()) || StrUtil.isEmpty(dto.getAgv_system_type())) {
|
||||
log.info("sendAgvInstToNDC 指令校验:" + dto.getInstruction_code() + ",inst_type:" + dto.getInstruction_type()
|
||||
|
||||
@@ -861,7 +861,6 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
//向缓存添加任务信息
|
||||
this.addTaskToCache(dto);
|
||||
//反馈上位系统任务状态
|
||||
|
||||
this.feedWmsTaskStatus(dto);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.nl.extInterface.wms.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.acs.task.instruction.domain.Instruction;
|
||||
import org.nl.acs.task.task.service.dto.TaskDto;
|
||||
|
||||
public interface AcsToWmsService {
|
||||
@@ -9,6 +10,8 @@ public interface AcsToWmsService {
|
||||
*/
|
||||
boolean feedbackTask(TaskDto taskDto, String card, String feedbackStatus);
|
||||
|
||||
boolean feedbackTask(Instruction instruction, String feedbackStatus);
|
||||
|
||||
boolean deprecateTask(TaskDto taskDto, String reason);
|
||||
|
||||
JSONObject taskRedirection(String taskCode, String currLocation);
|
||||
@@ -19,4 +22,6 @@ public interface AcsToWmsService {
|
||||
* 判断任务是否需要进入 WMS 回传链路,避免本地任务误回传。
|
||||
*/
|
||||
boolean isWmsTask(TaskDto taskDto);
|
||||
|
||||
boolean isWmsInstruction(Instruction instruction);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.task.TaskConfig;
|
||||
import org.nl.acs.task.instruction.domain.Instruction;
|
||||
import org.nl.acs.task.task.service.dto.TaskDto;
|
||||
import org.nl.common.db.CommonFinalParam;
|
||||
import org.nl.extInterface.wms.service.AcsToWmsService;
|
||||
@@ -40,6 +41,20 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
return isSuccess(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean feedbackTask(Instruction instruction, String feedbackStatus) {
|
||||
if (!isWmsInstruction(instruction)) {
|
||||
return true;
|
||||
}
|
||||
JSONObject body = baseBody();
|
||||
body.put("taskCode", instruction.getTask_code());
|
||||
body.put("card", StrUtil.blankToDefault(instruction.getCarno(), ""));
|
||||
body.put("taskType", StrUtil.blankToDefault(instruction.getInstruction_type(), ""));
|
||||
body.put("feedbackStatus", feedbackStatus);
|
||||
JSONObject response = postJson(buildUrl(FEEDBACK_TASK_PATH), body);
|
||||
return isSuccess(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deprecateTask(TaskDto taskDto, String reason) {
|
||||
if (!isWmsTask(taskDto)) {
|
||||
@@ -79,6 +94,14 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
&& StrUtil.equals("1", getParam(TaskConfig.HASWMS, "0"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWmsInstruction(Instruction instruction) {
|
||||
return instruction != null
|
||||
&& StrUtil.isNotBlank(instruction.getTask_code())
|
||||
&& !StrUtil.startWith(instruction.getTask_code(), CommonFinalParam.HYPHEN_)
|
||||
&& StrUtil.equals("1", getParam(TaskConfig.HASWMS, "0"));
|
||||
}
|
||||
|
||||
protected JSONObject postJson(String url, JSONObject body) {
|
||||
try {
|
||||
String result = HttpRequest.post(url)
|
||||
|
||||
Reference in New Issue
Block a user