| | |
| | | package com.mes.edgstoragecage.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.github.yulichang.base.MPJBaseServiceImpl; |
| | | import com.github.yulichang.toolkit.JoinWrappers; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | |
| | | |
| | | @Override |
| | | public EdgStorageCage selectNearestEmpty(int currentSlot) { |
| | | return this.selectJoinOne(EdgStorageCage.class, new MPJLambdaWrapper<EdgStorageCage>() |
| | | List<EdgStorageCage> emptyList = this.selectJoinList(EdgStorageCage.class, new MPJLambdaWrapper<EdgStorageCage>() |
| | | .selectAll(EdgStorageCage.class) |
| | | .leftJoin(EdgStorageCageDetails.class, on -> on |
| | | .eq(EdgStorageCageDetails::getSlot, EdgStorageCage::getSlot) |
| | | .eq(EdgStorageCageDetails::getState, Const.GLASS_STATE_IN)) |
| | | .isNull(EdgStorageCageDetails::getSlot) |
| | | .last("order by abs(t.slot - " + currentSlot + ") asc limit 1") |
| | | .last("order by abs(t.slot - " + currentSlot + ") asc limit 2") |
| | | ); |
| | | if (CollectionUtil.isEmpty(emptyList) || emptyList.size() < 2) { |
| | | return null; |
| | | } |
| | | return emptyList.get(0); |
| | | } |
| | | |
| | | /** |