add:发货区出库

This commit is contained in:
2026-08-04 17:41:17 +08:00
parent 3b9843bbd6
commit 22dac231ae
8 changed files with 348 additions and 615 deletions

View File

@@ -64,6 +64,16 @@ public interface NDCAgvService {
*/
public byte[] sendAgvTwoModeInst(int phase, int index, int result,int offset,int quantity);
/**
* 下发agv偏移指令
* @param phase
* @param index
* @param result
* @return
*/
public byte[] sendAgvTwoModeInstNewPoint(int phase, int index, int result,int offset,int quantity,int newStation);
public byte[] sendAgvTwoModeInst();

View File

@@ -48,6 +48,9 @@ public class NDCAgvServiceImpl implements NDCAgvService {
@Override
public void deleteAgvInstToNDC(Instruction inst) throws Exception {
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
if (StrUtil.isEmpty(inst.getAgv_jobno())){
return;
}
int index = Integer.parseInt(inst.getAgv_jobno());
byte indexhigh = (byte) IntToHexHigh(index);
@@ -349,18 +352,54 @@ public class NDCAgvServiceImpl implements NDCAgvService {
byte offsetlow = (byte) IntToHexLow(offset);
byte quantityhigh = (byte) IntToHexHigh(quantity);
byte quantitylow = (byte) IntToHexLow(quantity);
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
(byte) 0X00, (byte) 0X08,
(byte) 0X00, (byte) 0X0E,
(byte) 0X00, (byte) 0X10,
(byte) 0X00, (byte) 0X01,
(byte) 0X00, (byte) 0X6D,
(byte) 0X00, (byte) 0X0A,
(byte) 0X00, (byte) 0X0C,
(byte) indexhigh, (byte) indexlow,
(byte) 0X01, (byte) 0X12,
(byte) phasehigh, (byte) phaselow,
(byte) offsethigh, (byte) offsetlow,
(byte) quantityhigh, (byte) quantitylow
(byte) quantityhigh, (byte) quantitylow,
(byte) 0X00, (byte) 0X00
};
log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:"
+ hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF) + ",是否侧移: " + (offset == 1 ? "侧移" : "不测移") + ",偏离量: " + quantity);
System.out.println("反馈agv动作数据:" + Bytes2HexString(b));
return b;
}
@Override
public byte[] sendAgvTwoModeInstNewPoint(int phase, int index, int result, int offset, int quantity, int newStation) {
if (phase < 0 || index < 0)
return null;
byte indexhigh = (byte) IntToHexHigh(index);
byte indexlow = (byte) IntToHexLow(index);
byte phasehigh = (byte) IntToHexHigh(phase);
byte phaselow = (byte) IntToHexLow(phase);
byte offsethigh = (byte) IntToHexHigh(offset);
byte offsetlow = (byte) IntToHexLow(offset);
byte quantityhigh = (byte) IntToHexHigh(quantity);
byte quantitylow = (byte) IntToHexLow(quantity);
byte newStationhigh = (byte) IntToHexHigh(newStation);
byte newStationlow = (byte) IntToHexLow(newStation);
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
(byte) 0X00, (byte) 0X08,
(byte) 0X00, (byte) 0X10,
(byte) 0X00, (byte) 0X01,
(byte) 0X00, (byte) 0X6D,
(byte) 0X00, (byte) 0X0C,
(byte) indexhigh, (byte) indexlow,
(byte) 0X01, (byte) 0X12,
(byte) phasehigh, (byte) phaselow,
(byte) offsethigh, (byte) offsetlow,
(byte) quantityhigh, (byte) quantitylow,
(byte) newStationhigh, (byte) newStationlow,
};

View File

@@ -2,6 +2,8 @@ package org.nl.acs.auto.run;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.AcsConfig;
import org.nl.acs.agv.domain.TwoFloorAgvStatus;
@@ -20,6 +22,11 @@ import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.agv.service.impl.TwoFloorAgvStatusService;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.storage_cell.service.StorageCellService;
import org.nl.acs.storage_cell.service.dto.StorageCellDto;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.acs.task.service.impl.TaskServiceImpl;
import org.nl.config.SpringContextHolder;
import org.nl.config.lucene.service.LuceneExecuteLogService;
import org.nl.config.lucene.service.dto.LuceneLogDto;
@@ -72,6 +79,12 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
private final ConcurrentHashMap<String, AtomicBoolean> CAR_PHASE = new ConcurrentHashMap<>();
@Autowired
StorageCellService storageCellService;
@Autowired
InstructionService instructionService;
@Autowired
TaskService taskService;
@Autowired
ISysParamService paramService;
@@ -345,6 +358,32 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
} else {
log.info(device_code + "对应设备号为空!");
}
} //
else if (phase == 0x0B) {
//二次分配
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
return;
}
//根据任务号直接请求上位分配新的点位
JSONObject apply = new JSONObject();
apply.put("task_code", inst.getTask_code());
String str = acsToWmsService.applySendOutTwo(apply);
JSONObject jo = JSON.parseObject(str);
if (jo != null && jo.getInteger("status") == 200) {
//申请成功以后更新指令和任务的终点
//反馈NDC
String newPoint = jo.getString("data");
updataTask(inst, newPoint);
StorageCellDto storageCellDto = storageCellService.findByCode(newPoint);
if (ObjectUtil.isNotEmpty(storageCellDto)) {
data = ndcAgvService.sendAgvTwoModeInstNewPoint(phase, index, 0, 0, 0, storageCellDto.getAddress());
} else {
LuceneLogDto logDto = LuceneLogDto.builder().device_code(device_code).content("未反馈NDC二次分配点位原因,货位表中未查询到该货位,对应的货位信息:" + newPoint).build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
}
}
} else {
//上报异常信息
//不需要WCS反馈
@@ -444,7 +483,16 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
}
}
private void updataTask(Instruction instructionDto, String newPoint) {
TaskDto taskUpdate = taskService.findByCodeFromCache(instructionDto.getTask_code());
instructionDto.setNext_point_code(newPoint);
taskUpdate.setNext_point_code(newPoint);
instructionDto.setNext_device_code(newPoint);
taskUpdate.setNext_device_code(newPoint);
taskUpdate.setTask_id(instructionDto.getTask_id());
instructionService.update(instructionDto);
taskService.update1(taskUpdate);
}
public static void write(byte[] b) {
try {
log.info("下发agv数据:" + Bytes2HexString(b));

View File

@@ -239,7 +239,7 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i
case 2:
//申请任务
if (move > 0 && !requireSucess) {
instruction_require();
// instruction_require();
} else {
String remark = "";
;
@@ -370,10 +370,14 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i
}
return;
}
if (StrUtil.isEmpty(material_barcode)){
this.message = "载具码为空不允许申请AGV任务";
return;
}
JSONObject apply = new JSONObject();
apply.put("device_code", device_code);
apply.put("vehicle_code", material_barcode);
apply.put("vehicle_code", material_barcode.replaceAll("\\s+", "")
.replaceAll(",+$", ""));
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)

View File

@@ -154,7 +154,34 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
@Override
public ApplyLabelingAndBindingResponse applyLabelingAndBindingRequest(ApplyLabelingAndBindingRequest param) {
return null;
try {
MDC.put(log_file_type, log_type);
ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = new ApplyLabelingAndBindingResponse();
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("applyLabelingAndBinding");
String methods_url = addressDto.getMethods_url();
String url = wmsUrl + methods_url;
log.info("ApplyLabelingAndBindingRequest----请求参数{}", param);
try {
// String result = "";
String result = HttpRequest.post(url)
.body(JSON.toJSONString(param))
.execute().body();
JSONObject jsonObject = JSONObject.parseObject(result);
log.info("ApplyLabelingAndBindingResponse----返回参数{}", result);
applyLabelingAndBindingResponse = JSONObject.toJavaObject(jsonObject, ApplyLabelingAndBindingResponse.class);
} catch (Exception e) {
JSONObject map = new JSONObject();
map.put("status", 400);
map.put("message", e.getMessage());
return JSONObject.toJavaObject(map, ApplyLabelingAndBindingResponse.class);
}
}
return applyLabelingAndBindingResponse;
} finally {
MDC.remove(log_file_type);
}
}
@Override

View File

@@ -54,6 +54,8 @@ public interface StorageCellService extends CommonService<StorageCell> {
*/
StorageCellDto findById(String id);
StorageCellDto findByCode(String code);
/**
* 新增数据
*

View File

@@ -178,6 +178,17 @@ public class StorageCellServiceImpl extends CommonServiceImpl<StorageCellMapper,
return null;
}
@Override
public StorageCellDto findByCode(String code) {
StorageCell storageCell = this.getOne(new LambdaQueryWrapper<StorageCell>().eq(StorageCell::getStorage_code, code));
if (ObjectUtil.isNotEmpty(storageCell)) {
final StorageCellDto obj = ConvertUtil.convert(storageCell, StorageCellDto.class);
return obj;
}
return null;
}
// @Override
// public StorageCellDto findByCode(String code) {
// WQLObject wo = WQLObject.getWQLObject("acs_storage_cell");
@@ -190,7 +201,6 @@ public class StorageCellServiceImpl extends CommonServiceImpl<StorageCellMapper,
// }
@Override
@Transactional(rollbackFor = Exception.class)
public void create(StorageCellDto dto) {
@@ -225,7 +235,7 @@ public class StorageCellServiceImpl extends CommonServiceImpl<StorageCellMapper,
List<StorageCellDto> allStorageCellFromCache = deviceServiceImpl.findAllStorageCellFromCache();
allStorageCellFromCache.forEach(storageCellDto -> {
if(storageCellDto.getStorage_id().equals(storageCell.getStorage_id())){
if (storageCellDto.getStorage_id().equals(storageCell.getStorage_id())) {
storageCellDto.setAddress(storageCell.getAddress());
}
});