| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer; |
| | | import com.github.yulichang.toolkit.JoinWrappers; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | |
| | | |
| | | String temperingEngineerId = redisUtil.getCacheObject("temperingEngineerId"); |
| | | if (StringUtils.isNotBlank(temperingEngineerId)) { |
| | | TemperingGlassInfo temperingGlassInfo = temperingGlassInfoService.getOne(new QueryWrapper<TemperingGlassInfo>() |
| | | .select("Top 1 *") |
| | | .eq("engineer_id", temperingEngineerId) |
| | | .orderByDesc("tempering_layout_id")); |
| | | List<TemperingGlassInfo> temperingGlassInfoList = temperingGlassInfoService.list( |
| | | new LambdaQueryWrapper<TemperingGlassInfo>() |
| | | .eq(TemperingGlassInfo::getEngineerId, temperingEngineerId) |
| | | .orderByAsc(TemperingGlassInfo::getId) |
| | | ); |
| | | int temperingLayoutId = 1; |
| | | if (temperingGlassInfo != null) { |
| | | temperingLayoutId = temperingGlassInfo.getTemperingLayoutId() + 1; |
| | | if (CollectionUtils.isEmpty(temperingGlassInfoList)) { |
| | | temperingLayoutId = 1; |
| | | } else { |
| | | List<Integer> tempIds = temperingGlassInfoList.stream() |
| | | .map(TemperingGlassInfo::getTemperingLayoutId) |
| | | .distinct() |
| | | .sorted() |
| | | .collect(Collectors.toList()); |
| | | |
| | | int expected = 1; |
| | | for (int current : tempIds) { |
| | | if (current > expected) { |
| | | break; // 找到第一个缺失值,跳出循环 |
| | | } else if (current == expected) { |
| | | expected++; // 连续则递增期望的值 |
| | | } |
| | | } |
| | | temperingLayoutId = expected; // 缺失则为expected,连续则为max+1 |
| | | } |
| | | List<GlassInfo> glassInfos = glassInfoService.list(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getEngineerId, temperingEngineerId).eq(GlassInfo::getTemperingLayoutId, temperingLayoutId)); |
| | | if (CollectionUtil.isEmpty(glassInfos)) { |