| | |
| | | |
| | | import cn.hutool.core.lang.Assert; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.github.yulichang.base.MPJBaseServiceImpl; |
| | | import com.github.yulichang.toolkit.JoinWrappers; |
| | |
| | | import com.mes.bigstoragetask.mapper.BigStorageCageFeedTaskMapper; |
| | | import com.mes.bigstoragetask.mapper.BigStorageCageOutTaskMapper; |
| | | import com.mes.common.config.Const; |
| | | import com.mes.common.utils.RedisUtil; |
| | | import com.mes.damage.entity.Damage; |
| | | import com.mes.damage.service.DamageService; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.temperingglass.mapper.TemperingGlassInfoMapper; |
| | | import com.mes.temperingglass.service.TemperingGlassInfoService; |
| | | import com.mes.utils.RedisUtil; |
| | | 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; |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | @Override |
| | | public BigStorageDTO queryTargetSlotByTempering(GlassInfo glassInfo) { |
| | | List<GlassInfo> glassInfoList = glassInfoService.list( |
| | | new LambdaQueryWrapper<GlassInfo>() |
| | | .eq(GlassInfo::getEngineerId, glassInfo.getEngineerId()) |
| | | .eq(GlassInfo::getTemperingLayoutId, glassInfo.getTemperingLayoutId()) |
| | | .eq(GlassInfo::getTargetSlot, glassInfo.getTargetSlot()) |
| | | ); |
| | | List<String> glassIds = glassInfoList.stream().map(GlassInfo::getGlassId).collect(Collectors.toList()); |
| | | BigStorageDTO bigStorageDTO = null; |
| | | MPJLambdaWrapper<BigStorageCage> wrapper = new MPJLambdaWrapper<>(BigStorageCage.class) |
| | | .selectAll(BigStorageCage.class) |
| | |
| | | .eq(BigStorageCageDetails::getEngineerId, glassInfo.getEngineerId()) |
| | | .eq(BigStorageCageDetails::getTemperingLayoutId, glassInfo.getTemperingLayoutId()) |
| | | .gt(BigStorageCage::getRemainWidth, Math.max(glassInfo.getWidth(), glassInfo.getHeight())) |
| | | .in(BigStorageCageDetails::getGlassId, glassIds) |
| | | .last("limit 1"); |
| | | if (glassInfo.getTemperingLayoutId() == 0) { |
| | | wrapper.eq(BigStorageCageDetails::getFlowCardId, glassInfo.getFlowCardId()) |
| | | .eq(BigStorageCageDetails::getLayer, glassInfo.getLayer()); |
| | | // wrapper.eq(BigStorageCageDetails::getWidth, glassInfo.getWidth()).eq(BigStorageCageDetails::getHeight, glassInfo.getHeight()); |
| | | } else { |
| | | wrapper.eq(BigStorageCageDetails::getTemperingFeedSequence, glassInfo.getTemperingFeedSequence() + 1); |
| | | wrapper.eq(BigStorageCageDetails::getTemperingFeedSequence, glassInfo.getTemperingFeedSequence() - 1); |
| | | } |
| | | BigStorageCage bigStorageCage = bigStorageCageService.selectJoinOne(BigStorageCage.class, wrapper); |
| | | if (null != bigStorageCage) { |
| | |
| | | .groupBy(BigStorageCageDetails::getEngineerId) |
| | | .between(BigStorageCageDetails::getDeviceId, 6, 8) |
| | | ); |
| | | if (glassInfo.getThickness() == 8) { |
| | | deviceUsedList.removeIf(device -> device < 6); |
| | | } else { |
| | | if (engineerCount1.size() > engineerCount2.size()) { |
| | | BigStorageCageDetails bigStorageCageDetails = baseMapper.selectOne( |
| | | new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .eq(BigStorageCageDetails::getEngineerId, glassInfo.getEngineerId()) |
| | | .orderByAsc(BigStorageCageDetails::getSlot) |
| | | .last("limit 1") |
| | | ); |
| | | if (bigStorageCageDetails == null) { |
| | | if (glassInfo.getThickness() == 8) { |
| | | deviceUsedList.removeIf(device -> device < 6); |
| | | } else { |
| | | if (engineerCount1.size() > engineerCount2.size()) { |
| | | deviceUsedList.removeIf(device -> device < 6); |
| | | } else { |
| | | deviceUsedList.removeIf(device -> device > 5); |
| | | } |
| | | } |
| | | } else { |
| | | if (bigStorageCageDetails.getDeviceId() >= 1 && bigStorageCageDetails.getDeviceId() <= 5) { |
| | | deviceUsedList.removeIf(device -> device > 5); |
| | | } else { |
| | | deviceUsedList.removeIf(device -> device < 6); |
| | | } |
| | | } |
| | | |
| | | if (CollectionUtils.isEmpty(deviceUsedList)) { |
| | | deviceUsedList = deviceUseds; |
| | | } |
| | |
| | | temperingGlassInfoLambdaQueryWrapper |
| | | .eq(TemperingGlassInfo::getState, Const.TEMPERING_NEW); |
| | | List<TemperingGlassInfo> temperingGlassInfoList = temperingGlassInfoMapper.selectList(temperingGlassInfoLambdaQueryWrapper); |
| | | |
| | | if (temperingGlassInfoList.size() == 0) { |
| | | List<TemperingGlassInfo> temperingGlassInfos = glassInfoService.selectJoinList(TemperingGlassInfo.class, JoinWrappers.lambda(GlassInfo.class) |
| | | .selectAll(GlassInfo.class) |
| | |
| | | if (CollectionUtils.isNotEmpty(temperingGlassInfos)) { |
| | | if ("0".equals(temperingFeedSequence)) { |
| | | if (CollectionUtils.isNotEmpty(temperingGlassInfos)) { |
| | | plcStorageCageTask.computeOutMoreGlassInfo(temperingGlassInfos, Boolean.FALSE, ""); |
| | | plcStorageCageTask.computeOutMoreGlassInfo(temperingGlassInfos, Boolean.FALSE, 1); |
| | | } |
| | | } else { |
| | | temperingGlassInfoService.saveBatch(temperingGlassInfos); |