Browse Source

货位分配bug

master
常熟吴彦祖 4 months ago
parent
commit
1d79edf66f
  1. 35
      src/main/java/com/gaotao/modules/api/service/impl/WmsMessageServiceImpl.java
  2. 25
      src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/AutoTaskServiceImpl.java
  3. 12
      src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsIntegrationServiceImpl.java
  4. 10
      src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsTaskServiceImpl.java
  5. 6
      src/main/java/com/gaotao/modules/automatedWarehouse/task/WcsTaskScheduler.java

35
src/main/java/com/gaotao/modules/api/service/impl/WmsMessageServiceImpl.java

@ -569,36 +569,27 @@ public class WmsMessageServiceImpl implements WmsMessageService {
pallet.setLocationCode(request.getToStation());
pallet.setWcsLocation(request.getToStation());
palletMapper.updateLocationWithPalletId(pallet.getSite(),pallet.getPalletId(),pallet.getLocationCode(),pallet.getWcsLocation());
// palletMapper.updateLocationWithPalletId(pallet.getSite(),pallet.getPalletId(),pallet.getLocationCode(),pallet.getWcsLocation());
//如果更新wcs库位
//这里插入逻辑
// 检查该站点是否还有其他栈板如果没有则更新站点状态为空闲 - rqrq改用手写SQL避免锁表
long otherPalletCount = palletMapper.countOtherPalletsByLocation(
request.getSite(), currentLocationCode, request.getPalletId());
if (otherPalletCount == 0) {
// 没有其他栈板在该站点更新站点状态为空闲
log.info("站点 {} 无其他栈板,更新状态为空闲", currentLocationCode);
wcsIntegrationMapper.updateAgvStationStatus(currentLocationCode, 0, "空闲");
} else {
log.info("站点 {} 还有 {} 个其他栈板,保持站点状态", currentLocationCode, otherPalletCount);
}
// long otherPalletCount = palletMapper.countOtherPalletsByLocation(
// request.getSite(), currentLocationCode, request.getPalletId());
//
// if (otherPalletCount == 0) {
// // 没有其他栈板在该站点更新站点状态为空闲
// log.info("站点 {} 无其他栈板,更新状态为空闲", currentLocationCode);
// wcsIntegrationMapper.updateAgvStationStatus(currentLocationCode, 0, "空闲");
// } else {
// log.info("站点 {} 还有 {} 个其他栈板,保持站点状态", currentLocationCode, otherPalletCount);
// }
String fromWarehouseId;
String fromLocationId;
//如果是*说明在立库里需要查询里面料的当前位置
// if(currentStation.getLocationCode().equals("*")){
// List<PalletDetail> palletDetail2 = getPalletDetails(request.getSite(), request.getPalletId());
// List<HandlingUnit> checkPart= handlingUnitService.getHandlingUnitsBySiteAndUnid(palletDetail2.getFirst().getSite(),palletDetail2.getFirst().getSerialNo());
// if(checkPart.size()==0){
// throw new RuntimeException("栈板明细列表的条码号在WMS不存在,数据有问题");
// }
// fromWarehouseId = checkPart.getFirst().getWarehouseId();
// fromLocationId = checkPart.getFirst().getLocationId();
// }else {
fromWarehouseId = currentStation.getWarehouseCode();
fromLocationId = currentStation.getLocationCode();
// }
if(fromWarehouseId.equals(request.getToWarehouseId())&&fromLocationId.equals(request.getToLocationId())){
return "托盘无需执行移库操作:" + request.getPalletId();
}

25
src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/AutoTaskServiceImpl.java

@ -58,13 +58,6 @@ public class AutoTaskServiceImpl implements AutoTaskService {
if(!StringUtils.hasText(inData.getStationCode())){
throw new RuntimeException("参数验证失败:站点编码不能为空");
}
Integer getAgvStationStatus= wcsIntegrationMapper.getAgvStationStatus(inData.getStationCode());
if(getAgvStationStatus==null){
throw new RuntimeException("参数验证失败:站点编码不存在");
}
if(getAgvStationStatus!=0){
throw new RuntimeException("参数验证失败:站点不是空闲状态");
}
// 如果指定了栈板验证栈板是否已有未完成任务 - rqrq
if(StringUtils.hasText(inData.getPalletId())){
@ -114,11 +107,21 @@ public class AutoTaskServiceImpl implements AutoTaskService {
// detail.setActionType("生成AGV任务");
// detail.setStatus("成功");
// 保存运输任务到数据库
// 使用乐观锁尝试占用站点 - rqrq
int lockResult = wcsIntegrationMapper.updateAgvStationStatusWithLock(
inData.getStationCode(),
0, // expectedStatusDb - 期望当前是空闲
2, // newStatusDb - 更新为待放货
"待放货"
);
if(lockResult == 0){
throw new RuntimeException("站点【" + inData.getStationCode() + "】已被占用,无法创建预约任务");
}
// 保存运输任务到数据库 - rqrq
wcsIntegrationMapper.insertTransportTask(task);
// 更新目标站点状态为"待放货"
wcsIntegrationMapper.updateAgvStationStatus(inData.getStationCode(), 2, "待放货");
// wcsIntegrationMapper.insertWmsTransportTaskDetail(detail);
}

12
src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsIntegrationServiceImpl.java

@ -2310,16 +2310,8 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService {
}
System.out.println("自动分配站点成功 - rqrq,stationCode=" + finalTargetStation);
} else {
// 指定站点校验站点是否空闲 - rqrq
System.out.println("校验指定站点是否空闲 - rqrq,stationCode=" + finalTargetStation);
Integer stationStatus = wcsIntegrationMapper.getAgvStationStatus(finalTargetStation);
if (stationStatus == null) {
throw new RuntimeException("站点【" + finalTargetStation + "】不存在");
}
if (stationStatus != 0) {
throw new RuntimeException("站点【" + finalTargetStation + "】不是空闲状态(status_db=" + stationStatus + ")");
}
System.out.println("站点校验通过,站点空闲 - rqrq");
// 指定站点站点状态校验交给autoNeedPalletTask的乐观锁处理 - rqrq
System.out.println("使用指定站点 - rqrq,stationCode=" + finalTargetStation);
}
// 4. 第二步创建预约取盘任务autoNeedPalletTask- rqrq
System.out.println("开始创建预约取盘任务 - rqrq");

10
src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsTaskServiceImpl.java

@ -10,6 +10,7 @@ import com.gaotao.modules.automatedWarehouse.service.WcsIntegrationService;
import com.gaotao.modules.automatedWarehouse.service.WcsTaskService;
import com.gaotao.modules.handlingunit.entity.HandlingUnit;
import com.gaotao.modules.notify.mapper.NewIssureMapper;
import com.gaotao.modules.warehouse.dao.PalletMapper;
import com.gaotao.modules.warehouse.entity.Pallet;
import com.gaotao.modules.warehouse.service.PalletService;
@ -48,6 +49,8 @@ public class WcsTaskServiceImpl implements WcsTaskService {
@Autowired
private NewIssureMapper newIssureMapper;
@Autowired
private PalletMapper palletMapper;
@Override
public List<WcsCallbackTask> getPendingWcsCallbackTasks(String site) {
@ -106,13 +109,16 @@ public class WcsTaskServiceImpl implements WcsTaskService {
WareHouseTransferRequest request = buildWareHouseTransferRequest(callbackTask);
request.setUsername("sys_wms");
result = wmsMessageService.doWareHouseForPallet(request);
// 更新托盘状态 - rqrq
if ("入库".equals(callbackTask.getTransTypeDesc())) {
updateOrderTaskStatusForInbound(callbackTask);
palletMapper.updateLocationWithPalletId(request.getSite(),request.getPalletId(),request.getToStation(),request.getToStation());
wcsIntegrationMapper.updatePalletCallingFlag(callbackTask.getSite(), callbackTask.getPalletId(), "N", "SYS_WMS");
} else {
wcsIntegrationMapper.updatePalletWcsLocation(callbackTask.getSite(), callbackTask.getPalletId(), null);
palletMapper.updateLocationWithPalletId(request.getSite(),request.getPalletId(),"Virtual_AS",null);
// wcsIntegrationMapper.updatePalletWcsLocation(callbackTask.getSite(), callbackTask.getPalletId(), null);
wcsIntegrationMapper.updatePalletCallingFlag(callbackTask.getSite(), callbackTask.getPalletId(), "Y", "SYS_WMS");
}
} else if ("取货通知".equals(callbackTask.getTransTypeDesc())) {

6
src/main/java/com/gaotao/modules/automatedWarehouse/task/WcsTaskScheduler.java

@ -52,9 +52,9 @@ public class WcsTaskScheduler {
@Scheduled(fixedDelay = 2684)
public void scheduleWcsTaskProcessing() {
// 检查定时任务开关
if (!enabled) {
return;
}
// if (!enabled) {
// return;
// }
log.info("=== 开始处理WCS入库/出库相关业务 ===");

Loading…
Cancel
Save