zhoushihao
2024-11-21 b4f51417997c20dd15e3db19d5055edd55d872cd
hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/OpcCacheGlassTask.java
@@ -32,6 +32,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
 * @Author : zhoush
@@ -526,13 +527,13 @@
    private boolean updateCellRemainWidth(int slot, int device) {
        List<EdgStorageCageDetails> list = edgStorageCageDetailsService.list(new LambdaQueryWrapper<EdgStorageCageDetails>().eq(EdgStorageCageDetails::getSlot, slot)
                .eq(EdgStorageCageDetails::getState, Const.GLASS_STATE_IN));
        int remainWidth = cellLength;
        List<Integer> slotList = new ArrayList<>();
        if (CollectionUtil.isNotEmpty(list)) {
            int widthTotal = (int) list.stream().map(e -> Math.max(e.getWidth(), e.getHeight()) + glassGap).mapToDouble(Double::intValue).sum();
            remainWidth = cellLength - widthTotal >= 0 ? cellLength - widthTotal : 0;
            slotList = list.stream().map(EdgStorageCageDetails::getSlot).distinct().collect(Collectors.toList());
        }
        list.removeAll(slotList);
        edgStorageCageService.update(new LambdaUpdateWrapper<EdgStorageCage>().
                set(EdgStorageCage::getRemainWidth, remainWidth).eq(EdgStorageCage::getSlot, slot).eq(EdgStorageCage::getDeviceId, device));
                set(EdgStorageCage::getRemainWidth, cellLength).eq(EdgStorageCage::getSlot, slot).eq(EdgStorageCage::getDeviceId, device));
        return Boolean.TRUE;
    }