| | |
| | | import com.mes.bigstorage.entity.BigStorageGlassInfo; |
| | | import com.mes.bigstorage.entity.BigStorageGlassRelationInfo; |
| | | import com.mes.bigstorage.entity.dto.BigStorageDTO; |
| | | import com.mes.bigstorage.entity.dto.BigStorageRelationDTO; |
| | | import com.mes.bigstorage.entity.dto.BigStorageSequenceDTO; |
| | | import com.mes.bigstorage.mapper.BigStorageGlassInfoMapper; |
| | | import com.mes.bigstorage.service.BigStorageCageDetailsService; |
| | | import com.mes.bigstorage.service.BigStorageCageService; |
| | |
| | | private Integer slotWidth; |
| | | @Value("${mes.glassGap}") |
| | | private Integer glassGap; |
| | | @Value("${mes.outCarMaxSize}") |
| | | private Integer outCarMaxSize; |
| | | |
| | | @Override |
| | | public BigStorageDTO queryBigStorageTargetSlot(String glassId) { |
| | | public BigStorageDTO queryBigStorageTargetSlot(String engineerId, Integer temperingLayoutId, Integer temperingFeedSequence) { |
| | | //按照玻璃信息获取关系表是否有对应的关系 |
| | | BigStorageGlassRelationInfo relationInfoOne = bigStorageGlassRelationInfoService.getOne(new LambdaQueryWrapper<BigStorageGlassRelationInfo>() |
| | | .eq(BigStorageGlassRelationInfo::getGlassId, glassId)); |
| | | .eq(BigStorageGlassRelationInfo::getEngineerId, engineerId) |
| | | .eq(BigStorageGlassRelationInfo::getTemperingLayoutId, temperingLayoutId) |
| | | .eq(BigStorageGlassRelationInfo::getTemperingFeedSequence, temperingFeedSequence) |
| | | ); |
| | | if (relationInfoOne == null) { |
| | | //理片笼关系表中没有对应的数据,查看理片笼虚拟位置表是否有本工程下的所有玻璃虚拟信息 |
| | | BigStorageGlassInfo bigStorageGlassInfo = this.getOne(new LambdaQueryWrapper<BigStorageGlassInfo>().eq(BigStorageGlassInfo::getGlassId, glassId)); |
| | | BigStorageGlassInfo bigStorageGlassInfo = this.getOne(new LambdaQueryWrapper<BigStorageGlassInfo>() |
| | | .eq(BigStorageGlassInfo::getEngineerId, engineerId) |
| | | .eq(BigStorageGlassInfo::getTemperingLayoutId, temperingLayoutId) |
| | | .eq(BigStorageGlassInfo::getTemperingFeedSequence, temperingFeedSequence)); |
| | | if (null == bigStorageGlassInfo) { |
| | | //虚拟位置表没有本工程下的所有玻璃虚拟信息,按照玻璃id生成本工程下所有玻璃的虚拟信息 |
| | | generateBigStorageGlassInfo(glassId); |
| | | bigStorageGlassInfo = this.getOne(new LambdaQueryWrapper<BigStorageGlassInfo>().eq(BigStorageGlassInfo::getGlassId, glassId)); |
| | | generateBigStorageGlassInfo(engineerId, temperingLayoutId); |
| | | bigStorageGlassInfo = this.getOne(new LambdaQueryWrapper<BigStorageGlassInfo>() |
| | | .eq(BigStorageGlassInfo::getEngineerId, engineerId) |
| | | .eq(BigStorageGlassInfo::getTemperingLayoutId, temperingLayoutId) |
| | | .eq(BigStorageGlassInfo::getTemperingFeedSequence, temperingFeedSequence)); |
| | | } |
| | | //按照虚拟位置和大理片笼现有可用格子生成关系表 |
| | | bigStorageSlotPair(bigStorageGlassInfo); |
| | | //关系表获取实际位置 |
| | | relationInfoOne = bigStorageGlassRelationInfoService.getOne(new LambdaQueryWrapper<BigStorageGlassRelationInfo>() |
| | | .eq(BigStorageGlassRelationInfo::getGlassId, glassId)); |
| | | .eq(BigStorageGlassRelationInfo::getEngineerId, engineerId) |
| | | .eq(BigStorageGlassRelationInfo::getTemperingLayoutId, temperingLayoutId) |
| | | .eq(BigStorageGlassRelationInfo::getTemperingFeedSequence, temperingFeedSequence)); |
| | | } |
| | | BigStorageCageDetails bigStorageCageDetails = bigStorageCageDetailsService.getOne(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .eq(BigStorageCageDetails::getSlot, relationInfoOne.getSlot()).in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL_ZERO) |
| | |
| | | if (null == relationInfoBefore) { |
| | | //表示序号没有或者 序号为1又不是第一块来的 新开一格 |
| | | storageCage = bigStorageCageService.getOne(new LambdaQueryWrapper<BigStorageCage>() |
| | | .eq(BigStorageCage::getEnableState, Const.SLOT_ON).eq(BigStorageCage::getRemainWidth, slotWidth).last("limit 1")); |
| | | .eq(BigStorageCage::getEnableState, Const.SLOT_ON).eq(BigStorageCage::getRemainWidth, slotWidth).orderByAsc(BigStorageCage::getSlot).last("limit 1")); |
| | | } else { |
| | | BigStorageCageDetails beforeGlass = bigStorageCageDetailsService.getOne(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL_ZERO).eq(BigStorageCageDetails::getGlassId, relationInfoBefore.getGlassId()) |
| | | .in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL_ZERO) |
| | | .eq(BigStorageCageDetails::getEngineerId, relationInfoBefore.getEngineerId()) |
| | | .eq(BigStorageCageDetails::getTemperingLayoutId, relationInfoBefore.getTemperingLayoutId()) |
| | | .eq(BigStorageCageDetails::getTemperingFeedSequence, relationInfoBefore.getTemperingFeedSequence()) |
| | | ); |
| | | if (null == beforeGlass) { |
| | | storageCage = bigStorageCageService.getOne(new LambdaQueryWrapper<BigStorageCage>() |
| | | .eq(BigStorageCage::getEnableState, Const.SLOT_ON).eq(BigStorageCage::getRemainWidth, slotWidth).last("limit 1")); |
| | | .eq(BigStorageCage::getEnableState, Const.SLOT_ON).eq(BigStorageCage::getRemainWidth, slotWidth).orderByAsc(BigStorageCage::getSlot).last("limit 1")); |
| | | } else { |
| | | storageCage = bigStorageCageService.getOne(new LambdaQueryWrapper<BigStorageCage>() |
| | | .eq(BigStorageCage::getEnableState, Const.SLOT_ON).eq(BigStorageCage::getSlot, beforeGlass.getSlot())); |
| | |
| | | return storageDTO; |
| | | } |
| | | |
| | | public void dispatchBigStorageSlot() { |
| | | //todo:获取笼内单格已经到齐的玻璃格子信息 |
| | | List<BigStorageRelationDTO> virtualList = bigStorageCageDetailsService.queryIsAllNeedDispatchVirtualSlot(); |
| | | if (CollectionUtil.isEmpty(virtualList)) { |
| | | log.info("没有需要调度的格子"); |
| | | } |
| | | for (BigStorageRelationDTO dto : virtualList) { |
| | | List<BigStorageSequenceDTO> sequenceDTOList = bigStorageCageDetailsService.dispatchBigStorageGlassInfo(dto); |
| | | if (CollectionUtil.isEmpty(sequenceDTOList) || sequenceDTOList.size() == 1) { |
| | | continue; |
| | | } |
| | | int sequence = 0; |
| | | int startSlot = 0; |
| | | int targetSlot = 0; |
| | | for (BigStorageSequenceDTO item : sequenceDTOList) { |
| | | if (item.getMinSequence() == sequence + 1) { |
| | | //生成调度任务 |
| | | startSlot = item.getSlot(); |
| | | break; |
| | | } |
| | | sequence = item.getMaxSequence(); |
| | | targetSlot = item.getSlot(); |
| | | } |
| | | } |
| | | // |
| | | } |
| | | |
| | | @Override |
| | | public void generateBigStorageGlassInfo(String glassId) { |
| | | GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, glassId)); |
| | | public void generateBigStorageGlassInfo(String engineerId, int temperingLayoutId) { |
| | | List<BigStorageGlassInfo> list = this.list(new LambdaQueryWrapper<BigStorageGlassInfo>() |
| | | .eq(BigStorageGlassInfo::getEngineerId, glassInfo.getEngineerId()).eq(BigStorageGlassInfo::getTemperingLayoutId, glassInfo.getTemperingLayoutId())); |
| | | .eq(BigStorageGlassInfo::getEngineerId, engineerId).eq(BigStorageGlassInfo::getTemperingLayoutId, temperingLayoutId)); |
| | | if (CollectionUtil.isNotEmpty(list)) { |
| | | return; |
| | | } |
| | |
| | | // .eq(Engineering::getEngineerId, glassInfo.getEngineerId())); |
| | | //获取玻璃的工程id,按照工程id获取工程下的所有玻璃信息 |
| | | List<GlassInfo> glassInfoList = glassInfoService.list(new LambdaQueryWrapper<GlassInfo>() |
| | | .eq(GlassInfo::getEngineerId, glassInfo.getEngineerId()) |
| | | .eq(GlassInfo::getEngineerId, engineerId) |
| | | .orderByAsc(GlassInfo::getTemperingLayoutId).orderByAsc(GlassInfo::getTemperingFeedSequence)); |
| | | Map<Integer, List<GlassInfo>> trmperingIdMap = glassInfoList.stream().collect(Collectors.groupingBy(GlassInfo::getTemperingLayoutId)); |
| | | List<BigStorageGlassInfo> bigStorageGlassInfoList = new ArrayList<>(); |
| | |
| | | int slotSequence = 1; |
| | | for (GlassInfo item : v) { |
| | | int maxLength = (int) Math.max(item.getWidth(), item.getHeight()); |
| | | if (remainWidth > maxLength) { |
| | | if (remainWidth > maxLength && slotSequence <= outCarMaxSize) { |
| | | remainWidth = remainWidth - maxLength - glassGap; |
| | | } else { |
| | | slotNumber = slotNumber + 1; |
| | |
| | | public int bigStorageSlotPair(BigStorageGlassInfo bigStorageGlassInfo) { |
| | | //获取所有空闲可用的格子号 |
| | | BigStorageCage storageCage = bigStorageCageService.getOne(new LambdaQueryWrapper<BigStorageCage>() |
| | | .eq(BigStorageCage::getEnableState, Const.SLOT_ON).eq(BigStorageCage::getRemainWidth, slotWidth).last("limit 1")); |
| | | .eq(BigStorageCage::getEnableState, Const.SLOT_ON).eq(BigStorageCage::getRemainWidth, slotWidth).orderByAsc(BigStorageCage::getSlot).last("limit 1")); |
| | | Assert.isTrue(null != storageCage, "没有空余的笼子存放玻璃"); |
| | | Integer slot = storageCage.getSlot(); |
| | | //获取该工程同一流程卡同一车的玻璃信息 |