|  |  | 
 |  |  |  | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
 |  |  | import com.vincent.rsf.framework.common.SpringUtils; | 
 |  |  | import com.vincent.rsf.framework.exception.CoolException; | 
 |  |  | import com.vincent.rsf.server.api.utils.LocUtils; | 
 |  |  | import com.vincent.rsf.server.manager.controller.dto.ExistDto; | 
 |  |  | import com.vincent.rsf.server.manager.controller.dto.OrderOutItemDto; | 
 |  |  | import com.vincent.rsf.server.manager.controller.params.WaveToLocParams; | 
 |  |  | import com.vincent.rsf.server.manager.entity.*; | 
 |  |  | import com.vincent.rsf.server.manager.enums.ContainerType; | 
 |  |  | import com.vincent.rsf.server.manager.enums.TaskType; | 
 |  |  | import com.vincent.rsf.server.manager.enums.WaveRuleType; | 
 |  |  | import com.vincent.rsf.server.manager.service.*; | 
 |  |  | import com.vincent.rsf.server.manager.enums.LocStsType; | 
 |  |  | import io.swagger.models.auth.In; | 
 |  |  | import org.apache.commons.lang3.StringUtils; | 
 |  |  |  | 
 |  |  | import javax.swing.*; | 
 |  |  | 
 |  |  | public class LocManageUtil { | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * @author Ryan | 
 |  |  |      * @description  获取目标库位, 包含库位获取策略 | 
 |  |  |      * @param | 
 |  |  |      * @return | 
 |  |  |      * @author Ryan | 
 |  |  |      * @description 获取目标库位, 包含库位获取策略 | 
 |  |  |      * @time 2025/3/31 08:50 | 
 |  |  |      */ | 
 |  |  |     public static String getTargetLoc(Long areaId) { | 
 |  |  |         //TODO 库位策略后续排期 | 
 |  |  |  | 
 |  |  |         return getTargetLoc(areaId, null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public static String getTargetLoc(Long areaId, Long containerType) { | 
 |  |  |         Long locType = null; | 
 |  |  |         if (!Objects.isNull(containerType)) { | 
 |  |  |             LocTypeService locService = SpringUtils.getBean(LocTypeService.class); | 
 |  |  |             if (containerType.equals(ContainerType.CONTAINER_TYPE_NORMAL.val)) { | 
 |  |  |                 LocType low = locService.getOne(new LambdaQueryWrapper<LocType>() | 
 |  |  |                         .eq(LocType::getCode, "L")); | 
 |  |  |                 if (Objects.isNull(low)) { | 
 |  |  |                     throw new CoolException("庫位類型不存在!!"); | 
 |  |  |                 } | 
 |  |  |                 locType = low.getId(); | 
 |  |  |             } else { | 
 |  |  |                 LocType low = locService.getOne(new LambdaQueryWrapper<LocType>() | 
 |  |  |                         .eq(LocType::getCode, "H")); | 
 |  |  |                 if (Objects.isNull(low)) { | 
 |  |  |                     throw new CoolException("庫位類型不存在!!"); | 
 |  |  |                 } | 
 |  |  |                 locType = low.getId(); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         //TODO 库位策略后续排期 | 
 |  |  |         LocService locService = SpringUtils.getBean(LocService.class); | 
 |  |  |         Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>() | 
 |  |  |                 .eq(!Objects.isNull(locType), Loc::getType, locType) | 
 |  |  |                 .eq(Loc::getAreaId, areaId) | 
 |  |  |                 .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) | 
 |  |  |                 .orderByAsc(Loc::getLev) | 
 |  |  |                 .orderByAsc(Loc::getCol) | 
 |  |  |                 .orderByAsc(Loc::getRow) | 
 |  |  |                 .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type), false | 
 |  |  |                 .last("LIMIT 1") | 
 |  |  |         ); | 
 |  |  |  | 
 |  |  |         return !Objects.isNull(loc) ? loc.getCode() : null; | 
 |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |     * @author Ryan | 
 |  |  |     * @description 获取目标站点 | 
 |  |  |     * @param | 
 |  |  |     * @return | 
 |  |  |     * @time 2025/3/31 09:49 | 
 |  |  |     */ | 
 |  |  |      * @param | 
 |  |  |      * @return | 
 |  |  |      * @author Ryan | 
 |  |  |      * @description 获取目标站点 | 
 |  |  |      * @time 2025/3/31 09:49 | 
 |  |  |      */ | 
 |  |  |     public static String getTargetSite() { | 
 |  |  |         //TODO 站点策略后续排期 | 
 |  |  |         DeviceSiteService deviceSite = SpringUtils.getBean(DeviceSiteService.class); | 
 |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 出库策略:--〈效率优化〉 | 
 |  |  |      * | 
 |  |  |      * @param matnrCode | 
 |  |  |      * @param splrBatch | 
 |  |  |      * @param anfme | 
 |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 出库策略:--<先进先出> | 
 |  |  |      * | 
 |  |  |      * @param matnrCode | 
 |  |  |      * @param splrBatch | 
 |  |  |      * @param anfme | 
 |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 获取出库库位信息 | 
 |  |  |      * | 
 |  |  |      * @param params | 
 |  |  |      * @param waveRule | 
 |  |  |      * @return | 
 |  |  | 
 |  |  |                         orderOutItemDto.setLocItem(locItem); | 
 |  |  |  | 
 |  |  |                         List<DeviceSite> deviceSites = deviceSiteService.list(new LambdaQueryWrapper<DeviceSite>() | 
 |  |  |                                 .eq(DeviceSite::getChannel, loc.getChannel()) | 
 |  |  |                                 .eq(!Objects.isNull(loc.getChannel()), DeviceSite::getChannel, loc.getChannel()) | 
 |  |  |                                 .eq(DeviceSite::getType, issued.doubleValue() >= locItem.getAnfme() && itemList.size() == 1 ? TaskType.TASK_TYPE_OUT.type : TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) | 
 |  |  |                         ); | 
 |  |  |  | 
 |  |  | 
 |  |  |                             orderOutItemDto.setStaNos(maps); | 
 |  |  |                             //默认获取第一站点 | 
 |  |  |                             DeviceSite deviceSite = deviceSites.stream().findFirst().get(); | 
 |  |  |                             orderOutItemDto.setSiteNo(deviceSite.getSite()); | 
 |  |  |                             BasStationService basStationService = SpringUtils.getBean(BasStationService.class); | 
 |  |  |                             BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>() | 
 |  |  |                                     .eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) | 
 |  |  |                                     .last("LIMIT 1")); | 
 |  |  |                             if (Objects.isNull(basStation)) { | 
 |  |  |                                 throw new CoolException("站點不存在!!"); | 
 |  |  |                             } | 
 |  |  |                             orderOutItemDto.setSitesNo(basStation.getStationName()); | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  |                         orderOutItemDto.setSource(item.getItemId()) |