1
14 小时以前 e711c834aec2293c53b07efe53e81e3573c289b6
rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
@@ -30,6 +30,7 @@
import com.vincent.rsf.server.manager.mapper.LocItemMapper;
import com.vincent.rsf.server.manager.service.*;
import com.vincent.rsf.server.manager.service.impl.LocServiceImpl;
import com.vincent.rsf.server.manager.utils.WarehouseLocationRetrievalUtil;
import com.vincent.rsf.server.system.constant.SerialRuleCode;
import com.vincent.rsf.server.manager.enums.LocStsType;
import com.vincent.rsf.server.system.entity.*;
@@ -130,7 +131,7 @@
    public InTaskMsgDto createInTask(TaskInParam param) {
        // 验证设备站点
        DeviceSite deviceSite = validateDeviceSite(param);
//        DeviceSite deviceSite = validateDeviceSite(param);
        // 验证组拖状态
        WaitPakin waitPakin = validateWaitPakin(param.getBarcode());
@@ -148,7 +149,7 @@
        // 创建并保存任务
        Task task = createTask(ruleCode, locNo.getLocNo(), waitPakin.getBarcode(),
                deviceSite.getDeviceSite(), param.getSourceStaNo().toString(), param.getUser());
                null, param.getSourceStaNo().toString(), param.getUser());
        // 更新库位状态
        updateLocStatus(task.getTargLoc(), waitPakin.getBarcode());
@@ -171,16 +172,16 @@
    /**
     * 验证设备站点
     */
    private DeviceSite validateDeviceSite(TaskInParam param) {
        DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                .eq(DeviceSite::getSite, param.getSourceStaNo())
                .eq(DeviceSite::getType, param.getIoType()));
        if (Objects.isNull(deviceSite)) {
            throw new CoolException("站点不存在!!");
        }
        return deviceSite;
    }
//    private DeviceSite validateDeviceSite(TaskInParam param) {
//        DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
//                .eq(DeviceSite::getSite, param.getSourceStaNo())
//                .eq(DeviceSite::getType, param.getIoType()));
//
//        if (Objects.isNull(deviceSite)) {
//            throw new CoolException("站点不存在!!");
//        }
//        return deviceSite;
//    }
    /**
     * 验证组拖状态
@@ -393,6 +394,42 @@
//        return locNo;
//    }
    @Override
    public InTaskMsgDto getLocNoArea(TaskInParam param) throws Exception {
        String matnr = null;
        String batch = null;
        List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, param.getBarcode()));
        if (Cools.isEmpty(waitPakins) && param.getIoType().equals(TaskType.TASK_TYPE_IN.type)) {
            throw new CoolException("未找到组托信息,请组托");
        } else if (!Cools.isEmpty(waitPakins)) {
            matnr = waitPakins.get(0).getCode();
            batch = waitPakins.get(0).getCode();
        }
        DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(param.getSourceStaNo()));
        if (Cools.isEmpty(deviceBind)) {
            throw new CoolException("数据异常,请联系管理员===>库位规则未知");
        }
        WarehouseAreas warehouseArea = warehouseAreasService.getById(deviceBind.getTypeId());
        if (Cools.isEmpty(warehouseArea)) {
            throw new CoolException("未找到所属库区信息");
        }
        LocTypeDto locTypeDto = new LocTypeDto(param);
        InTaskMsgDto dto = null;
        //根据立库类型获取获取库位
        if (warehouseArea.getType().equals(WarehType.WAREHOUSE_TYPE_CRN.val)) {
            //堆垛机
            dto = getLocNoCrn(param.getOrgLoc(), deviceBind, warehouseArea.getId(), param.getSourceStaNo(), matnr, batch, locTypeDto, 0, param.getIoType());
        } else if (warehouseArea.getType().equals(WarehType.WAREHOUSE_TYPE_FOUR_DIRECTIONS.val)) {
            //四向库
        } else {
            //CTU 库以及其它
            dto = getLocNoCtu(deviceBind, warehouseArea.getId(), param.getSourceStaNo(), matnr, batch, locTypeDto, 0, param.getIoType());
        }
        return dto;
    }
    @Override
    public InTaskMsgDto getLocNo(TaskInParam param) throws Exception {
        String matnr = null;
        String batch = null;
@@ -403,13 +440,13 @@
            matnr = waitPakins.get(0).getCode();
            batch = waitPakins.get(0).getCode();
        }
        List<DeviceSite> deviceSites = deviceSiteService.list(new LambdaQueryWrapper<DeviceSite>()
                .eq(DeviceSite::getSite, param.getSourceStaNo())
                .eq(DeviceSite::getType, param.getIoType())
        );
        if (Cools.isEmpty(deviceSites)) {
            throw new CoolException("未找到站点路径信息");
        }
//        List<DeviceSite> deviceSites = deviceSiteService.list(new LambdaQueryWrapper<DeviceSite>()
//                .eq(DeviceSite::getSite, param.getSourceStaNo())
//                .eq(DeviceSite::getType, param.getIoType())
//        );
//        if (Cools.isEmpty(deviceSites)) {
//            throw new CoolException("未找到站点路径信息");
//        }
        DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(param.getSourceStaNo()));
        if (Cools.isEmpty(deviceBind)) {
            throw new CoolException("数据异常,请联系管理员===>库位规则未知");
@@ -730,40 +767,22 @@
            }
        }
//        // 靠近摆放规则 --- 空托 //互通版
//        if (ioType == 10 && deviceBind.getEmptySimilar().equals("1")) {
//            List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
//                    .eq("loc_sts", "D").ge("row1", sRow).le("row1", eRow).eq("whs_type", rowLastnoType.getType().longValue()));
//            if (!locMasts.isEmpty()) {
//                for (LocMast loc : locMasts) {
//                    if (Utils.isShallowLoc(slaveProperties, loc.getLocNo())) {
//                        continue;
//                    }
//                    String shallowLocNo = Utils.getShallowLoc(slaveProperties, loc.getLocNo());
//                    // 检测目标库位是否为空库位
//                    LocMast shallowLoc = locMastService.selectById(shallowLocNo);
//                    if (shallowLoc != null && shallowLoc.getLocSts().equals("O")) {
//                        if (VersionUtils.locMoveCheckLocTypeComplete(shallowLoc, locTypeDto)) {
//                            if (basCrnpService.checkSiteError(shallowLoc.getCrnNo(), true)) {
//                                locMast = shallowLoc;
//                                crnNo = locMast.getCrnNo();
//                                break;
//                            }
//                        }
//                    }
//                }
//            }
//        }
        //查找路径
        DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                .eq(DeviceSite::getType, ioType)
                .eq(DeviceSite::getSite, sourceStaNo)
                .eq(DeviceSite::getChannel, channel).last("limit 1")
        );
        if (Cools.isEmpty(deviceSite)) {
            channel = 0;
        } else {
            inTaskMsgDto.setStaNo(deviceSite.getDeviceSite());
        if (loc != null) {
            //查找路径
            boolean available = new WarehouseLocationRetrievalUtil().queryPathIsItAvailableInArea(sourceStaNo, loc.getAreaId().toString() ,loc.getBarcode(),"in");
//            DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
//                    .eq(DeviceSite::getType, ioType)
//                    .eq(DeviceSite::getSite, sourceStaNo)
//                    .eq(DeviceSite::getChannel, channel).last("limit 1")
//            );
            if (!available) {
                channel = 0;
                loc = null;
            } else {
                inTaskMsgDto.setStaNo(sourceStaNo);
            }
        }
        //更新当前排
@@ -891,6 +910,23 @@
                }
            }
        }
        if (loc != null) {
            //查找路径
            boolean available = new WarehouseLocationRetrievalUtil().queryPathIsItAvailableInArea(sourceStaNo, loc.getAreaId().toString() ,loc.getBarcode(),"in");
//            DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
//                    .eq(DeviceSite::getType, ioType)
//                    .eq(DeviceSite::getSite, sourceStaNo)
//                    .eq(DeviceSite::getChannel, channel).last("limit 1")
//            );
            if (!available) {
                channel = 0;
                loc = null;
            } else {
                inTaskMsgDto.setStaNo(sourceStaNo);
            }
        }
        //查询当前库位类型空库位 小于5个则locmast = null
        List<Loc> locTypeLocMasts = locService.list(new LambdaQueryWrapper<Loc>()
                .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
@@ -954,18 +990,34 @@
            loc = loc2;
            break;
        }
        //查找路径
        DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                .eq(DeviceSite::getType, ioType)
                .eq(DeviceSite::getSite, sourceStaNo)
                .eq(!Objects.isNull(loc.getDeviceNo()), DeviceSite::getDeviceCode, loc.getDeviceNo())
        );
        if (Cools.isEmpty(deviceSite)) {
            deviceNo = 0;
            loc = null;
        } else {
            inTaskMsgDto.setStaNo(deviceSite.getDeviceSite());
        if (loc != null) {
            //查找路径
            boolean available = new WarehouseLocationRetrievalUtil().queryPathIsItAvailableInArea(sourceStaNo, loc.getAreaId().toString() ,loc.getBarcode(),"in");
//            DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
//                    .eq(DeviceSite::getType, ioType)
//                    .eq(DeviceSite::getSite, sourceStaNo)
//                    .eq(DeviceSite::getChannel, channel).last("limit 1")
//            );
            if (!available) {
                deviceNo = 0;
                loc = null;
            } else {
                inTaskMsgDto.setStaNo(sourceStaNo);
            }
        }
//        DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
//                .eq(DeviceSite::getType, ioType)
//                .eq(DeviceSite::getSite, sourceStaNo)
//                .eq(!Objects.isNull(loc.getDeviceNo()), DeviceSite::getDeviceCode, loc.getDeviceNo())
//        );
//        if (Cools.isEmpty(deviceSite)) {
//            deviceNo = 0;
//            loc = null;
//        } else {
//            inTaskMsgDto.setStaNo(deviceSite.getDeviceSite());
//        }
        // 递归查询
        if (Cools.isEmpty(loc) || !loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) {
            // 当前巷道无空库位时,递归调整至下一巷道,检索全部巷道无果后,跳出递归