| | |
| | | package com.mes.bigstorage.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.bigstorage.entity.BigStorageCage; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | |
| | | import com.mes.bigstorage.mapper.BigStorageCageMapper; |
| | | import com.mes.bigstorage.service.BigStorageCageService; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | /** |
| | |
| | | * @since 2024-03-27 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class BigStorageCageServiceImpl extends ServiceImpl<BigStorageCageMapper, BigStorageCage> implements BigStorageCageService { |
| | | @Resource |
| | | private BigStorageCageMapper bigStorageCageMapper; |
| | | |
| | | @Resource |
| | | private BigStorageCageDetailsMapper bigStorageCageDetailsMapper; |
| | | |
| | | @Override |
| | | public BigStorageCageDetails FeedGlass(GlassInfo glassInfo, BigStorageCageDetails bigStorageCageDetails) { |
| | | |
| | | public BigStorageCageDetails feedGlass(GlassInfo glassInfo, BigStorageCageDetails bigStorageCageDetails) { |
| | | |
| | | //1、查询理片笼内玻璃片序等于当前玻璃片序-1的玻璃 |
| | | LambdaQueryWrapper<BigStorageCageDetails> wapper = new LambdaQueryWrapper<>(); |
| | | wapper.eq(BigStorageCageDetails::getTemperingLayoutId, glassInfo.getTemperingLayoutId()) |
| | | LambdaQueryWrapper<BigStorageCageDetails> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(BigStorageCageDetails::getTemperingLayoutId, glassInfo.getTemperingLayoutId()) |
| | | .eq(BigStorageCageDetails::getTemperingFeedSequence, glassInfo.getTemperingFeedSequence() + 1); |
| | | BigStorageCageDetails layoutSlotInfo = bigStorageCageDetailsMapper.selectOne(wapper); |
| | | bigStorageCageDetails.setSlot(layoutSlotInfo.getSlot()); |
| | | bigStorageCageDetails.setGlassId(bigStorageCageDetails.getGlassId()); |
| | | bigStorageCageDetails.setFlowCardId(glassInfo.getFlowcardId()); |
| | | bigStorageCageDetails.setGlassType(glassInfo.getGlassType()); |
| | | bigStorageCageDetails.setWidth(glassInfo.getWidth()); |
| | | bigStorageCageDetails.setHeight(glassInfo.getHeight()); |
| | | bigStorageCageDetails.setThickness(glassInfo.getThickness()); |
| | | bigStorageCageDetails.setTemperingLayoutId(glassInfo.getTemperingLayoutId()); |
| | | bigStorageCageDetails.setTemperingFeedSequence(glassInfo.getTemperingFeedSequence()); |
| | | |
| | | BigStorageCageDetails layoutSlotInfo = bigStorageCageDetailsMapper.selectOne(wrapper); |
| | | BeanUtils.copyProperties(glassInfo, bigStorageCageDetails); |
| | | bigStorageCageDetails.setSlot(layoutSlotInfo.getSlot()); |
| | | |
| | | //2、有符合条件的格子活片序为1时 |
| | | if (layoutSlotInfo.getSlot() != null ) { |
| | | //将玻璃信息填入理片笼详情表 |
| | | |
| | | |
| | | bigStorageCageDetailsMapper.updateById(bigStorageCageDetails); |
| | | bigStorageCageDetails.setSlot(layoutSlotInfo.getSlot()); |
| | | } else { |
| | | //获取不到时: |
| | | // LambdaQueryWrapper<BigStorageCageDetails> BigStorageCageDetailslambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | // BigStorageCageDetailslambdaQueryWrapper |
| | | // .select(BigStorageCageDetails::getTemperingLayoutId) |
| | | // .groupBy(BigStorageCageDetails::getTemperingLayoutId); |
| | | // List<Map<String, Object>> temperingLayoutIdList= bigStorageCageDetailsMapper.selectMaps(BigStorageCageDetailslambdaQueryWrapper); |
| | | // for (Map<String, Object> map : temperingLayoutIdList) { |
| | | // for (Map.Entry<String, Object> entry : map.entrySet()) { |
| | | // String prefix = entry.getKey().substring(0, entry.getKey().indexOf('-')); |
| | | // String suffix = entry.getKey().substring(entry.getKey().indexOf('-') + 1); |
| | | // if(suffix.equals(entry.getValue())){ |
| | | // |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | |
| | | //获取可进片格子信息 |
| | | BigStorageCageDetails EmptySlotInfo = bigStorageCageMapper.SelectEmptyFeedSlot(); |
| | | if (EmptySlotInfo != null) { |
| | | bigStorageCageDetails.setSlot(EmptySlotInfo.getSlot()); |
| | | } else { |
| | | //获取其他笼格子- |
| | | BigStorageCageDetails OtherSlotInfo = bigStorageCageMapper.SelectOtherFeedSlot(); |
| | | bigStorageCageDetails.setSlot(OtherSlotInfo.getSlot()); |
| | | } |
| | | // BigStorageCageDetails EmptySlotInfo = bigStorageCageMapper.selectEmptyFeedSlot(); |
| | | // if (EmptySlotInfo != null) { |
| | | // bigStorageCageDetails.setSlot(EmptySlotInfo.getSlot()); |
| | | // } else { |
| | | // //获取其他笼格子- |
| | | // BigStorageCageDetails OtherSlotInfo = bigStorageCageMapper.selectOtherFeedSlot(); |
| | | // bigStorageCageDetails.setSlot(OtherSlotInfo.getSlot()); |
| | | // } |
| | | //将玻璃信息放入该格子 |
| | | |
| | | } |
| | | |
| | | if (bigStorageCageDetails.getSlot() != null) { |
| | | bigStorageCageDetailsMapper.insert(bigStorageCageDetails); |
| | | updateRemainWidth(bigStorageCageDetails.getSlot()); |
| | | } |
| | | return bigStorageCageDetails; |
| | | } |
| | | |
| | | @Override |
| | | public boolean outGlass() { |
| | | // // 1、查询钢化小片任务表是否有待出玻璃 |
| | | // List<TemperingGlassInfo> temperingGlassInfoList = temperingGlassInfoService.SelectTemperingGlassInfo(); |
| | | // //没有可出的玻璃时 |
| | | // if (temperingGlassInfoList != null) { |
| | | // //查询是否有小片全部到齐的钢化版图 |
| | | // } else { |
| | | // //继续当前钢化版图的任务 |
| | | // } |
| | | LambdaQueryWrapper<BigStorageCageDetails> bigStorageCageDetailslambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | bigStorageCageDetailslambdaQueryWrapper |
| | | .select(BigStorageCageDetails::getTemperingLayoutId) |
| | | .groupBy(BigStorageCageDetails::getTemperingLayoutId); |
| | | List<Map<String, Object>> temperingLayoutIdList = bigStorageCageDetailsMapper.selectMaps(bigStorageCageDetailslambdaQueryWrapper); |
| | | for (Map<String, Object> map : temperingLayoutIdList) { |
| | | for (Map.Entry<String, Object> entry : map.entrySet()) { |
| | | String prefix = entry.getKey().substring(0, entry.getKey().indexOf('-')); |
| | | String suffix = entry.getKey().substring(entry.getKey().indexOf('-') + 1); |
| | | if (suffix.equals(entry.getValue())) { |
| | | |
| | | } |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | //修改格子剩余宽度 |
| | | @Override |
| | | public void updateRemainWidth(int Slot) { |
| | | public void updateRemainWidth(int slot) { |
| | | //获取该格子内玻璃信息 |
| | | int width = 5000; |
| | | List<BigStorageCageDetails> bigStorageCageDetailsList = Collections.singletonList(bigStorageCageDetailsMapper.selectById(Slot)); |
| | | Integer width = 5000; |
| | | List<BigStorageCageDetails> bigStorageCageDetailsList = Collections.singletonList(bigStorageCageDetailsMapper.selectById(slot)); |
| | | for (BigStorageCageDetails bigStorageCageDetails : bigStorageCageDetailsList |
| | | ) { |
| | | width -= Integer.parseInt(bigStorageCageDetails.getWidth().toString()) + bigStorageCageDetails.getGap(); |
| | | } |
| | | //修改格子剩余宽度 |
| | | bigStorageCageMapper.UpdateRemainWidth(Slot, width); |
| | | BigStorageCage bigStorageCage = new BigStorageCage(); |
| | | bigStorageCage.setRemainWidth(width); |
| | | UpdateWrapper<BigStorageCage> bigStorageCageWrapper = new UpdateWrapper<>(); |
| | | bigStorageCageWrapper.eq("remain_width", width); |
| | | bigStorageCageMapper.update(bigStorageCage, bigStorageCageWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<BigStorageCage> querybigStorageCageDetail() { |
| | | //1、获取大理片笼信息 |
| | | List<BigStorageCage> bigStorageCages = bigStorageCageMapper.selectList(null); |
| | | log.info("1、获取大理片笼信息完成,获取到的数据{}", bigStorageCages.size()); |
| | | //2获取理片笼所有信息 |
| | | List<BigStorageCageDetails> bigStorageCageDetailsList = bigStorageCageDetailsMapper.selectList(null); |
| | | Map<Integer, List<BigStorageCageDetails>> listMap = bigStorageCageDetailsList.stream().collect(Collectors.groupingBy(BigStorageCageDetails::getSlot)); |
| | | for (BigStorageCage bigStorageCage : bigStorageCages) { |
| | | List<BigStorageCageDetails> bigStorageCageDetails = listMap.get(bigStorageCage.getSlot()); |
| | | bigStorageCage.setBigStorageCageDetails(bigStorageCageDetails); |
| | | } |
| | | return bigStorageCages; |
| | | } |
| | | |
| | | } |