wu
2025-10-28 62aac62534d688a1b0753d10fca06dbebfadc23a
hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/service/impl/BigStorageGlassInfoServiceImpl.java
@@ -15,11 +15,12 @@
import com.mes.bigstorage.service.BigStorageGlassInfoService;
import com.mes.bigstorage.service.BigStorageGlassRelationInfoService;
import com.mes.common.config.Const;
import com.mes.common.config.ConstSysConfig;
import com.mes.glassinfo.entity.GlassInfo;
import com.mes.glassinfo.service.GlassInfoService;
import com.mes.sysconfig.service.SysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -45,12 +46,14 @@
    BigStorageCageDetailsService bigStorageCageDetailsService;
    @Resource
    BigStorageGlassRelationInfoService bigStorageGlassRelationInfoService;
    @Value("${mes.slotWidth}")
    private Integer slotWidth;
    @Value("${mes.glassGap}")
    private Integer glassGap;
    @Value("${mes.outCarMaxSize}")
    private Integer outCarMaxSize;
    @Resource
    SysConfigService sysConfigService;
//    @Value("${mes.slotWidth}")
//    private Integer slotWidth;
//    @Value("${mes.glassGap}")
//    private Integer glassGap;
//    @Value("${mes.outCarMaxSize}")
//    private Integer outCarMaxSize;
    @Override
    public BigStorageDTO queryBigStorageTargetSlot(String engineerId, Integer temperingLayoutId, Integer temperingFeedSequence) {
@@ -82,6 +85,7 @@
                    .eq(BigStorageGlassRelationInfo::getTemperingLayoutId, temperingLayoutId)
                    .eq(BigStorageGlassRelationInfo::getTemperingFeedSequence, temperingFeedSequence));
        }
        Integer slotWidth = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_SLOT_WIDTH);
        BigStorageCageDetails bigStorageCageDetails = bigStorageCageDetailsService.getOne(new LambdaQueryWrapper<BigStorageCageDetails>()
                .eq(BigStorageCageDetails::getSlot, relationInfoOne.getSlot()).in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL_ZERO)
                .orderByDesc(BigStorageCageDetails::getSequence).last("limit 1"));
@@ -98,11 +102,10 @@
                .eq(BigStorageGlassRelationInfo::getTemperingLayoutId, relationInfoOne.getTemperingLayoutId())
                .eq(BigStorageGlassRelationInfo::getVirtualSlot, relationInfoOne.getVirtualSlot())
                .eq(BigStorageGlassRelationInfo::getSlotSequence, relationInfoOne.getSlotSequence() - 1));
        BigStorageCage storageCage = null;
        BigStorageDTO storageCageDTO = null;
        if (null == relationInfoBefore) {
            //表示序号没有或者  序号为1又不是第一块来的 新开一格
            storageCage = bigStorageCageService.getOne(new LambdaQueryWrapper<BigStorageCage>()
                    .eq(BigStorageCage::getEnableState, Const.SLOT_ON).eq(BigStorageCage::getRemainWidth, slotWidth).orderByAsc(BigStorageCage::getSlot).last("limit 1"));
            storageCageDTO = bigStorageCageDetailsService.queryTargetSlot(engineerId, bigStorageCageDetails.getGlassId(), (int) bigStorageCageDetails.getThickness());
        } else {
            BigStorageCageDetails beforeGlass = bigStorageCageDetailsService.getOne(new LambdaQueryWrapper<BigStorageCageDetails>()
                    .in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL_ZERO)
@@ -111,20 +114,18 @@
                    .eq(BigStorageCageDetails::getTemperingFeedSequence, relationInfoBefore.getTemperingFeedSequence())
            );
            if (null == beforeGlass) {
                storageCage = bigStorageCageService.getOne(new LambdaQueryWrapper<BigStorageCage>()
                        .eq(BigStorageCage::getEnableState, Const.SLOT_ON).eq(BigStorageCage::getRemainWidth, slotWidth).orderByAsc(BigStorageCage::getSlot).last("limit 1"));
                storageCageDTO = bigStorageCageDetailsService.queryTargetSlot(engineerId, bigStorageCageDetails.getGlassId(), (int) bigStorageCageDetails.getThickness());
            } else {
                storageCage = bigStorageCageService.getOne(new LambdaQueryWrapper<BigStorageCage>()
                BigStorageCage bigStorageCage = bigStorageCageService.getOne(new LambdaQueryWrapper<BigStorageCage>()
                        .eq(BigStorageCage::getEnableState, Const.SLOT_ON).eq(BigStorageCage::getSlot, beforeGlass.getSlot()));
                Assert.isTrue(null != bigStorageCage, "没有空余的笼子存放玻璃");
                storageCageDTO = new BigStorageDTO();
                storageCageDTO.setWidth(bigStorageCage.getRemainWidth());
                storageCageDTO.setSlot(bigStorageCage.getSlot());
                storageCageDTO.setDeviceId(bigStorageCage.getDeviceId());
            }
        }
        Assert.isTrue(null != storageCage, "没有空余的笼子存放玻璃");
        BigStorageDTO storageDTO = new BigStorageDTO();
        storageDTO.setDeviceId(storageCage.getDeviceId());
        storageDTO.setSlotSequence(relationInfoOne.getSlotSequence());
        storageDTO.setSlot(storageCage.getSlot());
        storageDTO.setWidth(storageCage.getRemainWidth());
        return storageDTO;
        return storageCageDTO;
    }
    @Override
@@ -134,12 +135,13 @@
        if (CollectionUtil.isNotEmpty(list)) {
            return;
        }
//        Engineering engineering = engineeringMapper.selectOne(new LambdaQueryWrapper<Engineering>()
//                .eq(Engineering::getEngineerId, glassInfo.getEngineerId()));
        Integer slotWidth = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_SLOT_WIDTH);
        Integer outCarMaxSize = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_OUT_CAR_SIZE);
        //获取玻璃的工程id,按照工程id获取工程下的所有玻璃信息
        List<GlassInfo> glassInfoList = glassInfoService.list(new LambdaQueryWrapper<GlassInfo>()
                .eq(GlassInfo::getEngineerId, engineerId)
                .orderByAsc(GlassInfo::getTemperingLayoutId).orderByAsc(GlassInfo::getTemperingFeedSequence));
        Integer glassGap = getGlassGapByThickness(glassInfoList.get(0).getThickness());
        Map<Integer, List<GlassInfo>> trmperingIdMap = glassInfoList.stream().collect(Collectors.groupingBy(GlassInfo::getTemperingLayoutId));
        List<BigStorageGlassInfo> bigStorageGlassInfoList = new ArrayList<>();
        //方式一:将玻璃按版图、版序 依次生成虚拟格子信息,格子一直往后累加
@@ -172,10 +174,10 @@
    @Override
    public int bigStorageSlotPair(BigStorageGlassInfo bigStorageGlassInfo) {
        //获取所有空闲可用的格子号
        BigStorageCage storageCage = bigStorageCageService.getOne(new LambdaQueryWrapper<BigStorageCage>()
                .eq(BigStorageCage::getEnableState, Const.SLOT_ON).eq(BigStorageCage::getRemainWidth, slotWidth).orderByAsc(BigStorageCage::getSlot).last("limit 1"));
        Assert.isTrue(null != storageCage, "没有空余的笼子存放玻璃");
        Integer slot = storageCage.getSlot();
        BigStorageDTO bigStorageDTO = bigStorageCageDetailsService.queryTargetSlot(bigStorageGlassInfo.getEngineerId(),
                bigStorageGlassInfo.getGlassId(), bigStorageGlassInfo.getThickness().intValue());
        Assert.isTrue(null != bigStorageDTO, "没有空余的笼子存放玻璃");
        Integer slot = bigStorageDTO.getSlot();
        //获取该工程同一流程卡同一车的玻璃信息
        List<BigStorageGlassInfo> bigStorageGlassInfoList = this.list(new LambdaQueryWrapper<BigStorageGlassInfo>()
                .eq(BigStorageGlassInfo::getEngineerId, bigStorageGlassInfo.getEngineerId())
@@ -186,7 +188,7 @@
            BigStorageGlassRelationInfo info = new BigStorageGlassRelationInfo();
            BeanUtils.copyProperties(e, info);
            info.setSlot(slot);
            info.setDeviceId(storageCage.getDeviceId());
            info.setDeviceId(bigStorageDTO.getDeviceId());
            return info;
        }).collect(Collectors.toList());
        //保存关系表
@@ -196,5 +198,18 @@
    }
    private Integer getGlassGapByThickness(Double thickness) {
        int sysKey = 0;
        if (thickness >= 12) {
            sysKey = ConstSysConfig.VERTICAL_GLASS_GAP_12;
        } else if (thickness == 8) {
            sysKey = ConstSysConfig.VERTICAL_GLASS_GAP_8;
        } else if (thickness == 10) {
            sysKey = ConstSysConfig.VERTICAL_GLASS_GAP_10;
        } else {
            sysKey = ConstSysConfig.VERTICAL_GLASS_GAP;
        }
        return sysConfigService.queryConfigValue(sysKey);
    }
}