1
2 天以前 e461c84027885a02f8af27cca01e0cbff0c5ade4
rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/LocManageUtil.java
@@ -8,15 +8,12 @@
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.*;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@@ -36,26 +33,45 @@
        return getTargetLoc(areaId, null);
    }
    public static String getTargetLoc(Long areaId, Long containerType,List<Integer> rowList) {
        Long locType = containerType;
        //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)
                .in(Objects.nonNull(rowList) && !rowList.isEmpty(), Loc::getRow, rowList)
                .orderByAsc(Loc::getLev)
                .orderByAsc(Loc::getCol)
                .orderByAsc(Loc::getRow)
                .last("LIMIT 1")
        );
        return !Objects.isNull(loc) ? loc.getCode() : 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();
            }
        }
//        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>()
@@ -129,7 +145,12 @@
        LambdaQueryWrapper<LocItem> locItemQueryWrapper = new LambdaQueryWrapper<>();
        locItemQueryWrapper.eq(LocItem::getMatnrCode, matnrCode);
        locItemQueryWrapper.eq(StringUtils.isNotEmpty(splrBatch), LocItem::getBatch, splrBatch);
        locItemQueryWrapper.orderByAsc(LocItem::getCreateTime);
        //如果批次不为空,按批次先后出库
        if (StringUtils.isNotBlank(splrBatch)) {
            locItemQueryWrapper.orderByAsc(LocItem::getBatch);
        } else {
            locItemQueryWrapper.orderByAsc(LocItem::getCreateTime);
        }
        String applySql = String.format(
                "EXISTS (SELECT 1 FROM man_loc ml " +
                        "WHERE ml.use_status = '%s'" +
@@ -224,7 +245,6 @@
                        orderOutItemDto.setSource(item.getItemId())
                                .setSourceId(item.getWaveId());
                        list.add(orderOutItemDto);
                        issued = issued.subtract(new BigDecimal(locItem.getAnfme().toString()));