fix: 扫描补码、仙宫货叉调整

This commit is contained in:
2024-06-17 19:14:29 +08:00
parent 41fea50b24
commit 9b6291f146
8 changed files with 214 additions and 107 deletions

View File

@@ -4,6 +4,7 @@ import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import org.nl.acs.agv.server.dto.AgvDto;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.service.dto.InteractionJsonDTO;
import java.util.Map;
@@ -117,8 +118,10 @@ public interface XianGongAgvService {
/**
* 下发叉车运单
*
* @param dto
* @param interactionJsonDTO
* @return
*/
HttpResponse sendOrderSequencesToForklift(Instruction dto);
HttpResponse sendOrderSequencesToForklift(Instruction dto, InteractionJsonDTO interactionJsonDTO);
}

View File

@@ -14,13 +14,13 @@ import org.nl.acs.agv.AgvUtil;
import org.nl.acs.agv.AgvWaitUtil;
import org.nl.acs.agv.server.XianGongAgvService;
import org.nl.acs.agv.server.dto.AgvDto;
import org.nl.acs.angle.domain.AcsPointAngle;
import org.nl.acs.angle.service.IAcsPointAngleService;
import org.nl.acs.common.base.CommonFinalParam;
import org.nl.acs.device.domain.Device;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.InteractionJsonDTO;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.device.enums.DeviceType;
import org.nl.common.exception.BadRequestException;
@@ -32,7 +32,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@ -756,13 +755,13 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
}
@Override
public HttpResponse sendOrderSequencesToForklift(Instruction inst) {
public HttpResponse sendOrderSequencesToForklift(Instruction inst, InteractionJsonDTO interactionJsonDTO) {
com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject();
jo.put("id", inst.getInstruction_code());
//运单封口,true=创建运单之后不可添加动作块;false=创建运单可以添加动作块
jo.put("complete", true);
//动作块
jo.put("blocks", createBlocksForklift(inst));
jo.put("blocks", createBlocksForklift(inst,interactionJsonDTO));
//运单优先级
jo.put("priority", inst.getPriority());
LuceneLogDto logDto = LuceneLogDto.builder()
@@ -804,13 +803,17 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
* 叉车运单动作块
*
* @param inst
* @param interactionJsonDTO
* @return
*/
private JSONArray createBlocksForklift(Instruction inst) {
private JSONArray createBlocksForklift(Instruction inst, InteractionJsonDTO interactionJsonDTO) {
JSONArray ja = new JSONArray();
//起点
Device startDevice = deviceAppService.findDeviceByCode(inst.getStart_device_code());
String pointCode = inst.getStart_point_code();
//取货前等待
JSONObject jo = new JSONObject();
//动作块id
@@ -842,6 +845,42 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
jo1.put("binTask", "InForkHeight");
ja.add(jo1);
JSONObject jo3 = new JSONObject();
//动作块id
jo3.put("blockId", IdUtil.simpleUUID());
//目的地名称
jo3.put("location", pointCode + "INGET");
jo3.put("id", pointCode + "INGET");
//执行脚本
jo3.put("operation", "expand");
//通信脚本,动作前后与现场设备交互的场景
jo3.put("script_name", "Fork-expand.py");
JSONObject script_args2 = new JSONObject();
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getExpandWidthLength())) {
script_args2.put("expandWidth",interactionJsonDTO.getExpandWidthLength());
}
script_args2.put("operation", "expand");
jo3.put("script_args", script_args2);
ja.add(jo3);
JSONObject jo4 = new JSONObject();
//动作块id
jo4.put("blockId", IdUtil.simpleUUID());
//目的地名称
jo4.put("location", pointCode + "INGET");
jo4.put("id", pointCode + "INGET");
//执行脚本
jo4.put("operation", "stretch");
//通信脚本,动作前后与现场设备交互的场景
jo4.put("script_name", "Fork-expand.py");
JSONObject script_args1 = new JSONObject();
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getExpandWidthLength())) {
script_args2.put("stretchLength",interactionJsonDTO.getExpandWidthLength());
}
script_args1.put("operation", "stretch");
jo4.put("script_args", script_args1);
ja.add(jo4);
JSONObject jo6 = new JSONObject();
jo6.put("blockId", IdUtil.simpleUUID());
jo6.put("location", inst.getStart_point_code());
@@ -861,16 +900,16 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
jo2.put("operation", "script");
jo2.put("id", pointCode + "OUTGET");
jo2.put("script_name", "userpy/interact.py");
JSONObject script_args2 = new JSONObject();
script_args2.put("addr", addr);
JSONObject script_args4 = new JSONObject();
script_args4.put("addr", addr);
JSONObject data2 = new JSONObject();
JSONObject reach2 = new JSONObject();
reach2.put("task_code", inst.getInstruction_code());
reach2.put("address", pointCode + "OUTGET");
data2.put("reach", reach2);
script_args2.put("data", data2);
script_args2.put("protocol", "HTTP");
jo2.put("script_args", script_args2);
script_args4.put("data", data2);
script_args4.put("protocol", "HTTP");
jo2.put("script_args", script_args4);
ja.add(jo2);

View File

@@ -127,8 +127,6 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
int last_container_type = 0;
//行架任务号
int hj_task = 0;
int last_hj_task = 0;
@@ -243,7 +241,6 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
}
if (move != last_move && move == 0 && last_move == 1) {
requireSucess = false;
clearWrite();
@@ -399,8 +396,18 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
try {
JSONObject param = new JSONObject();
param.put("device_code", device_code);
if (StrUtil.isNotEmpty(hand_barcode)) {
param.put("vehicle_code", hand_barcode);
}
if (StrUtil.isNotEmpty(barcode)) {
param.put("vehicle_code", barcode);
}
if (StrUtil.isNotEmpty(material_barcode)) {
param.put("material_barcode", material_barcode);
}
if (StrUtil.isNotEmpty(hand_material_barcode)) {
param.put("material_barcode", hand_material_barcode);
}
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content("申请高度等级,参数:" + param)
@@ -454,8 +461,18 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
try {
JSONObject param = new JSONObject();
param.put("device_code", device_code);
if (StrUtil.isNotEmpty(hand_barcode)) {
param.put("vehicle_code", hand_barcode);
}
if (StrUtil.isNotEmpty(barcode)) {
param.put("vehicle_code", barcode);
}
if (StrUtil.isNotEmpty(material_barcode)) {
param.put("material_barcode", material_barcode);
}
if (StrUtil.isNotEmpty(hand_material_barcode)) {
param.put("material_barcode", hand_material_barcode);
}
param.put("type", type);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
@@ -558,7 +575,12 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
JSONObject param = new JSONObject();
param.put("device_code", device_code);
param.put("container_type", container_type);
if (StrUtil.isNotEmpty(hand_barcode)) {
param.put("vehicle_code", hand_barcode);
}
if (StrUtil.isNotEmpty(barcode)) {
param.put("vehicle_code", barcode);
}
param.put("type", type);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
@@ -607,8 +629,18 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
try {
JSONObject param = new JSONObject();
param.put("device_code", device_code);
if (StrUtil.isNotEmpty(hand_barcode)) {
param.put("vehicle_code", hand_barcode);
}
if (StrUtil.isNotEmpty(barcode)) {
param.put("vehicle_code", barcode);
}
if (StrUtil.isNotEmpty(material_barcode)) {
param.put("material_barcode", material_barcode);
}
if (StrUtil.isNotEmpty(hand_material_barcode)) {
param.put("material_barcode", hand_material_barcode);
}
param.put("type", type);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
@@ -640,8 +672,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
logDto2.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto2);
}
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
}
@@ -919,6 +950,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
}
}
public synchronized boolean finish_instruction() throws Exception {
instructionService.finish(inst);
return true;

View File

@@ -368,9 +368,14 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
message = "one_message7";
} else {
if (error != 0) {
Date date = new Date();
if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out);
} else {
//满入空出或者浅货位阻挡
erroBlock();
}
}
List list = new ArrayList();
switch (command) {
case 0:
@@ -521,6 +526,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
}
}
last_heartbeat = heartbeat;
last_item_deviceCode = item_deviceCode;
last_mode = mode;

View File

@@ -0,0 +1,13 @@
package org.nl.acs.instruction.service.dto;
import lombok.Data;
@Data
public class InteractionJsonDTO {
/**
* agv叉车调整长宽
*/
private Double expandWidthLength;
}

View File

@@ -42,6 +42,7 @@ import org.nl.acs.instruction.domain.InstructionMybatis;
import org.nl.acs.instruction.enums.InstructionStatusEnum;
import org.nl.acs.instruction.service.dto.InstructionDto;
import org.nl.acs.instruction.service.dto.InstructionQueryParam;
import org.nl.acs.instruction.service.dto.InteractionJsonDTO;
import org.nl.acs.limit_regional.server.LimitRegionalService;
import org.nl.acs.limit_regional.server.dto.LimitRegionalDto;
import org.nl.acs.opc.DeviceAppService;
@@ -514,8 +515,13 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
//
// } else
if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.XG_System_Type.getIndex())) {
String interactionJson = task.getInteraction_json();
if (StrUtil.isNotEmpty(interactionJson)){
throw new BadRequestException("agv叉车调整长宽参数为空");
}
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
//仙工叉车
HttpResponse response = xiangGongAgvService.sendOrderSequencesToForklift(dto);
HttpResponse response = xiangGongAgvService.sendOrderSequencesToForklift(dto,interactionJsonDTO);
if (ObjectUtils.isEmpty(response) || response.getStatus() != 200) {
dto.setSend_status("2");
} else {

View File

@@ -28,6 +28,8 @@ import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device.service.dto.DeviceAssignedDto;
import org.nl.acs.device.service.impl.DeviceServiceImpl;
import org.nl.acs.device_driver.DeviceDriverDefination;
import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.storage.standard_storage.StandardStorageDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.domain.InstructionMybatis;
@@ -906,6 +908,7 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
List<RouteLineDto> shortPathsList =
routeLineService.getShortPathLines(
start_device_code, acsTask.getNext_device_code(), route_plan_code);
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
RouteLineDto routeLineDto = shortPathsList.get(0);
String path = routeLineDto.getPath();
String type = routeLineDto.getType();
@@ -914,7 +917,12 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
int index = 0;
for (int m = 0; m < pathlist.size(); m++) {
if (pathlist.get(m).equals(start_device_code)) {
//起点为货架跳过堆垛机
if (startDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
index = m + 2;
}else {
index = m + 1;
}
break;
}
}

View File

@@ -59,7 +59,7 @@ public class CreateDDJInst {
//判断有无出入库任务是相同路线
TaskDto dto = taskserver.findByCodeAndExcute(next_device_code, start_device_code);
if (ObjectUtil.isNotEmpty(dto)) {
return;
continue;
}
if (startDevice.getDevice_type().equals(DeviceType.storage.name()) &&
(nextDevice.getDevice_type().equals(DeviceType.conveyor.name()) || nextDevice.getDevice_type().equals(DeviceType.storage.name()))) {
@@ -115,7 +115,7 @@ public class CreateDDJInst {
deviceByCode = appService.findDeviceByCode(pathlist.get(1));
if (ObjectUtils.isEmpty(deviceByCode)) {
log.error("没有找到DDJ设备");
return;
continue;
}
StandardStackerDeviceDriver standardStackerDeviceDriver;
if (deviceByCode.getDeviceDriver() instanceof StandardStackerDeviceDriver) {
@@ -123,7 +123,7 @@ public class CreateDDJInst {
if (standardStackerDeviceDriver.getMode() != 3 || standardStackerDeviceDriver.getForkCargo() == 1 || standardStackerDeviceDriver.getCommand() != 0) {
log.error("堆垛机,{}未联机或者在执行中", deviceByCode.getDevice_code());
((StandardStackerDeviceDriver) deviceByCode.getDeviceDriver()).setNotCreateInstMessage("堆垛机,{}未联机或者在执行中");
return;
continue;
}
}
next_device_code = start_device_code;
@@ -142,7 +142,7 @@ public class CreateDDJInst {
if (ObjectUtils.isEmpty(deviceByCode)) {
log.error("没有找到DDJ设备");
return;
continue;
}
StandardStackerDeviceDriver standardStackerDeviceDriver;
if (deviceByCode.getDeviceDriver() instanceof StandardStackerDeviceDriver) {
@@ -150,7 +150,7 @@ public class CreateDDJInst {
if (standardStackerDeviceDriver.getMode() != 3 || standardStackerDeviceDriver.getForkCargo() == 1 || standardStackerDeviceDriver.getCommand() != 0 || standardStackerDeviceDriver.getError() != 0) {
log.error("堆垛机,{}未联机或者在执行中或者有异常", deviceByCode.getDevice_code());
((StandardStackerDeviceDriver) deviceByCode.getDeviceDriver()).setNotCreateInstMessage("堆垛机,{}未联机或者在执行中");
return;
continue;
}
}
@@ -205,7 +205,7 @@ public class CreateDDJInst {
if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 1) {
log.error("输送机,{}未联机或执行中", next_device_code);
((BeltConveyorDeviceDriver) nextDevice.getDeviceDriver()).setNotCreateInstMessage("one_message7");
return;
continue;
}
}
@@ -219,7 +219,7 @@ public class CreateDDJInst {
List<Instruction> byCodeAndExcute = instructionService.findByCodeAndExcute(next_device_code);
if (CollUtil.isNotEmpty(byCodeAndExcute)){
((StandardStackerDeviceDriver) deviceByCode.getDeviceDriver()).setNotCreateInstMessage("有DDJ对接位出入库的指令");
return;
continue;
}
instdto.setInstruction_type(task_type);
instdto.setInstruction_id(IdUtil.simpleUUID());