From 051613aa73be3e75af5a6dfdb86a722bcb5af094 Mon Sep 17 00:00:00 2001 From: wangfei <3597712270@qq.com> Date: 星期五, 23 八月 2024 16:46:51 +0800 Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/HangZhouMes --- hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downstorage/service/impl/DownStorageCageServiceImpl.java | 67 +++++++++++++++++++++------------ 1 files changed, 42 insertions(+), 25 deletions(-) diff --git a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downstorage/service/impl/DownStorageCageServiceImpl.java b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downstorage/service/impl/DownStorageCageServiceImpl.java index 3643a74..18e1259 100644 --- a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downstorage/service/impl/DownStorageCageServiceImpl.java +++ b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downstorage/service/impl/DownStorageCageServiceImpl.java @@ -1,17 +1,13 @@ package com.mes.downstorage.service.impl; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.toolkit.JoinWrappers; import com.github.yulichang.wrapper.MPJLambdaWrapper; - -//import com.mes.device.PlcParameterObject; -import com.google.common.base.Functions; import com.mes.common.config.Const; import com.mes.downglassinfo.entity.DownGlassTask; import com.mes.downglassinfo.service.DownGlassTaskService; import com.mes.downstorage.entity.DownStorageCage; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.mes.downstorage.entity.DownStorageCageDetails; import com.mes.downstorage.mapper.DownStorageCageDetailsMapper; import com.mes.downstorage.mapper.DownStorageCageMapper; @@ -19,9 +15,7 @@ import com.mes.downstorage.service.DownStorageCageService; import com.mes.glassinfo.entity.GlassInfo; import com.mes.glassinfo.service.GlassInfoService; -import com.mes.pp.entity.OptimizeDetail; import lombok.extern.slf4j.Slf4j; -import net.sf.jsqlparser.statement.select.SelectItem; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -54,7 +48,7 @@ private DownStorageCageDetailsMapper downStorageCageDetailsMapper; @Override - public DownGlassTask createDownGlassTask(GlassInfo glassInfo, String startCell, String endCell, String taskType) { + public DownGlassTask createDownGlassTask(GlassInfo glassInfo, Integer startCell, Integer endCell, Integer taskType) { DownGlassTask downGlassTask = new DownGlassTask(); BeanUtils.copyProperties(glassInfo, downGlassTask); @@ -66,7 +60,7 @@ } @Override - public DownGlassTask createDownGlassTask(DownStorageCageDetails glassInfo, String startCell, String endCell, String taskType) { + public DownGlassTask createDownGlassTask(DownStorageCageDetails glassInfo, Integer startCell, Integer endCell, Integer taskType) { DownGlassTask downGlassTask = new DownGlassTask(); BeanUtils.copyProperties(glassInfo, downGlassTask); @@ -75,25 +69,44 @@ downGlassTask.setEndCell(endCell); return downGlassTask; } - - //鎵惧埌绌烘牸瀛� @Override public List<DownStorageCageDetails> selectCacheEmpty() { - return baseMapper.selectJoinList(DownStorageCageDetails.class, + return this.selectJoinList(DownStorageCageDetails.class, JoinWrappers.lambda(DownStorageCage.class) .selectAll(DownStorageCage.class) - .select(DownStorageCageDetails::getWidth, DownStorageCageDetails::getHeight, DownStorageCageDetails::getGlassId) .leftJoin(DownStorageCageDetails.class, on -> on .eq(DownStorageCageDetails::getDeviceId, DownStorageCage::getDeviceId) .eq(DownStorageCageDetails::getSlot, DownStorageCage::getSlot) - .eq(DownStorageCageDetails::getState, Const.GLASS_STATE_IN) - ) + .eq(DownStorageCageDetails::getState, Const.GLASS_STATE_IN)) .isNull(DownStorageCageDetails::getSlot) ); } + + //鎵惧埌绌烘牸瀛� + @Override + public DownStorageCage selectCacheEmpty(int currentSlot, boolean flag) { + List<DownStorageCage> emptyList = this.selectJoinList(DownStorageCage.class, + JoinWrappers.lambda(DownStorageCage.class) + .selectAll(DownStorageCage.class) + .leftJoin(DownStorageCageDetails.class, on -> on + .eq(DownStorageCageDetails::getSlot, DownStorageCage::getSlot) + .eq(DownStorageCageDetails::getState, Const.GLASS_STATE_IN)) + .isNull(DownStorageCageDetails::getSlot) + .eq(DownStorageCage::getEnableState, Const.SLOT_ON) + .last("order by abs(t.slot - " + currentSlot + ") asc limit 2") + ); + if (flag && CollectionUtil.isNotEmpty(emptyList)) { + return emptyList.get(0); + } + if (CollectionUtil.isEmpty(emptyList) || emptyList.size() == 1) { + return null; + } + return emptyList.get(0); + } + @Override public List<DownStorageCageDetails> selectCacheMax() { @@ -104,7 +117,7 @@ .leftJoin(DownStorageCageDetails.class, on -> on .eq(DownStorageCageDetails::getDeviceId, DownStorageCage::getDeviceId) .eq(DownStorageCageDetails::getSlot, DownStorageCage::getSlot) - .eq(DownStorageCageDetails::getState, Const.GLASS_STATE_IN)) + .eq(DownStorageCageDetails::getState, Const.GLASS_STATE_IN)) .isNull(DownStorageCageDetails::getSlot) .eq(DownStorageCage::getEnableState, 1) .groupBy(DownStorageCageDetails::getFlowCardId) // 鏍规嵁 flowCardId 鍒嗙粍 @@ -113,11 +126,6 @@ ); } - - - - - @@ -144,11 +152,20 @@ @Override public boolean updateDownStorageCage(DownStorageCage downStorageCage) { DownStorageCage downItem = baseMapper.selectById(downStorageCage.getId()); - downItem.setEnableState(downStorageCage.getEnableState()); - baseMapper.updateById(downItem); - return true; + if (downItem != null) { + downItem.setEnableState(downStorageCage.getEnableState()); + int rowsAffected = baseMapper.updateById(downItem); + if (rowsAffected > 0) { + return true; + } else { + return false; + } + } else { + return false; + } } + /** * 淇敼鐞嗙墖绗间俊鎭� 鍔熻兘锛氬绗煎唴鏍呮牸鐜荤拑 銆愭坊鍔�/鍒犻櫎/鏇存崲銆� * -- Gitblit v1.8.0