From 507feb92199a9f8cf336fd9616e0466e0b73868b Mon Sep 17 00:00:00 2001 From: 15066119699 Date: Fri, 14 Mar 2025 14:22:08 +0800 Subject: [PATCH] 1 --- .../ruoyi/common/constant/AppConstants.java | 2 +- .../com/ruoyi/app/domain/AppLocation.java | 7 +- .../service/impl/AppLocationServiceImpl.java | 88 +++++++++++++++---- .../mapper/app/AppLocationMapper.xml | 2 +- 4 files changed, 75 insertions(+), 24 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/AppConstants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/AppConstants.java index 9c2e3ffb..a33ebf65 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/AppConstants.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/AppConstants.java @@ -33,7 +33,7 @@ public class AppConstants { public static final String OUT_ORDER_STATUS_0 = "0"; public static final String OUT_ORDER_STATUS_1 = "1"; public static final String OUT_ORDER_STATUS_2 = "2"; - //1:出库 2:入库 9:移库 4:拣选 + //1:入库 2:出库 9:移库 4:拣选 public static final Integer TASK_TYPE_OUT = 2; public static final Integer TASK_TYPE_IN = 1; public static final Integer TASK_TYPE_TRANSFER = 9; diff --git a/ruoyi-system/src/main/java/com/ruoyi/app/domain/AppLocation.java b/ruoyi-system/src/main/java/com/ruoyi/app/domain/AppLocation.java index a5379d53..6443303a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/app/domain/AppLocation.java +++ b/ruoyi-system/src/main/java/com/ruoyi/app/domain/AppLocation.java @@ -19,6 +19,9 @@ public class AppLocation extends BaseEntity * 主键 */ private Long id; + /** 库位编码 */ + @Excel(name = "库位编码") + private String locationId; /** * 排 */ @@ -33,9 +36,7 @@ public class AppLocation extends BaseEntity @Excel(name = "货架层") private Integer wLayer; - /** 库位编码 */ - @Excel(name = "库位编码") - private String locationId; + /** 备注 */ @Excel(name = "备注") diff --git a/ruoyi-system/src/main/java/com/ruoyi/app/service/impl/AppLocationServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/app/service/impl/AppLocationServiceImpl.java index 1d8b70bc..e0f25883 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/app/service/impl/AppLocationServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/app/service/impl/AppLocationServiceImpl.java @@ -9,11 +9,16 @@ import java.util.stream.Collectors; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import com.ruoyi.app.domain.AppLocation; +import com.ruoyi.app.domain.AppStock; +import com.ruoyi.app.domain.AppTask; import com.ruoyi.app.mapper.AppLocationMapper; +import com.ruoyi.app.mapper.AppStockMapper; +import com.ruoyi.app.mapper.AppTaskMapper; import com.ruoyi.app.service.IAppLocationService; import com.ruoyi.common.constant.AppConstants; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.StringUtils; +import org.apache.commons.collections4.CollectionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -28,11 +33,16 @@ import org.springframework.transaction.annotation.Transactional; */ @Service public class AppLocationServiceImpl implements IAppLocationService { - private static final Logger log = LoggerFactory.getLogger(AppLocationServiceImpl.class); + private static final Logger logger = LoggerFactory.getLogger(AppLocationServiceImpl.class); @Autowired private AppLocationMapper appLocationMapper; + @Autowired + private AppStockMapper appStockMapper; + @Autowired + private AppTaskMapper appTaskMapper; + /** * 查询【请填写功能名称】 * @@ -128,28 +138,59 @@ public class AppLocationServiceImpl implements IAppLocationService { locationQuery.setLocationStatus(0); locationQuery.setIsLock(0); // todo 先放进二深度后 - locationQuery.setwDepth(2); +// locationQuery.setwDepth(2); List appLocationList = appLocationMapper.selectAppLocationList(locationQuery); if (appLocationList == null || appLocationList.isEmpty()) { return null; } // 结果库位 AppLocation resultLocation = null; - // 可用库位列表 -// List availableLocationList = appLocationList.stream().filter(item -> -// item.getIsWorking() == 0 && item.getIsLock() == 0 && item.getLocationStatus() == 0).sorted(Comparator -// .comparingInt(AppLocation::getwCol).thenComparingInt(AppLocation::getwLayer).thenComparingInt(AppLocation::getwDepth)).collect(Collectors.toList()); -// // 排序 -// for (AppLocation appLocation : availableLocationList) { -// if (appLocation.getIsWorking() == 1 || appLocation.getIsLock() == 1 || appLocation.getLocationStatus() == 1) { -// continue; -// } -// if (isMaxDepthAvailable(appLocationList, appLocation)) { -// resultLocation = appLocation; -// break; -// } -// } - return appLocationList.get(0); + for(AppLocation appLocation1 : appLocationList) { + String locId = appLocation1.getLocationId(); + AppLocation appLocation = appLocationMapper.selectAppLocationByLocationId(locId); + if (appLocation.getwDepth() == 2) { + //判断01是否有货 + String locationId = locId.substring(0, locId.length() - 1) + "1"; + List appTasks = getAppTaskByVehicleId(null, locationId); + if (!CollectionUtils.isEmpty(appTasks)) { + logger.error(locationId + "有任务执行,请稍后再试"); + throw new RuntimeException(locationId + "有任务执行,请稍后再试!"); + } + + AppLocation areaLocation = new AppLocation(); + areaLocation.setLocationStatus(1); + areaLocation.setLocationId(locationId); + List tBaseStorageAreaLocations = appLocationMapper.selectAppLocationList(areaLocation); + if (!tBaseStorageAreaLocations.isEmpty()) { + AppStock AppStock1 = new AppStock(); + AppStock1.setLocationId(locationId); + List tMiStocks1 = appStockMapper.selectAppStockList(AppStock1); + if (!tMiStocks1.isEmpty()) { + continue; + } + throw new RuntimeException("库位状态异常:"+ locationId); + } else { + AppStock tMiStock1 = new AppStock(); + tMiStock1.setLocationId(locationId); + List tMiStocks1 = appStockMapper.selectAppStockList(tMiStock1); + if (!tMiStocks1.isEmpty()) { + throw new RuntimeException("库位状态异常:"+ locationId); + } + resultLocation = appLocation1; + break; + } + }else{ + AppStock tMiStock1 = new AppStock(); + tMiStock1.setLocationId(locId); + List tMiStocks1 = appStockMapper.selectAppStockList(tMiStock1); + if (!tMiStocks1.isEmpty()) { + throw new RuntimeException("库位状态异常:"+ locId); + } + resultLocation = appLocation1; + } + } + + return resultLocation; } // @Override @@ -185,7 +226,16 @@ public class AppLocationServiceImpl implements IAppLocationService { // return locationId; // // } - + private List getAppTaskByVehicleId(String vehicleId,String locationId) { + AppTask appTask =new AppTask(); + appTask.setVehicleId(vehicleId); + appTask.setLocationId(locationId); + if(StringUtils.isBlank(locationId)) { + appTask.setTaskType(AppConstants.TASK_TYPE_OUT); + } + //判断该托盘是否产生任务 + return appTaskMapper.selectAppTaskList(appTask); + } /** * 是否是最内层可用库位 * @@ -292,7 +342,7 @@ public class AppLocationServiceImpl implements IAppLocationService { failureNum++; String msg = "
" + failureNum + "、库位 " + appLocation.getLocationId() + " 导入失败:"; failureMsg.append(msg + e.getMessage()); - log.error(msg, e); + logger.error(msg, e); } } if (failureNum > 0) { diff --git a/ruoyi-system/src/main/resources/mapper/app/AppLocationMapper.xml b/ruoyi-system/src/main/resources/mapper/app/AppLocationMapper.xml index aab5c7e8..4b28b6a7 100644 --- a/ruoyi-system/src/main/resources/mapper/app/AppLocationMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/app/AppLocationMapper.xml @@ -66,8 +66,8 @@ order by w_layer asc, - w_col asc, w_depth desc, + w_col asc, w_row asc