| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.yulichang.query.MPJQueryWrapper; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | |
| | | import com.github.yulichang.query.MPJLambdaQueryWrapper; |
| | | import com.github.yulichang.toolkit.JoinWrappers; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.mes.common.config.Const; |
| | | import com.mes.downstorage.entity.DownStorageCage; |
| | | import com.mes.downstorage.entity.DownStorageCageDetails; |
| | | import com.mes.downstorage.mapper.DownStorageCageDetailsMapper; |
| | | |
| | | import com.mes.downstorage.mapper.DownStorageCageMapper; |
| | | import com.mes.downstorage.service.DownStorageCageDetailsService; |
| | | import com.mes.downworkstation.entity.DownWorkstation; |
| | |
| | | return downStorageCageDetailsMapper.selectJoinMaps(JoinWrappers.lambda(DownStorageCageDetails.class) // 使用 JoinWrappers.lambda 创建联合查询 |
| | | .selectAll(DownStorageCageDetails.class) // 选择所有字段 |
| | | .eq(DownStorageCage::getSlot, DownStorageCageDetails::getSlot) // 设置关联条件 |
| | | .eq(DownStorageCageDetails::getState, Const.GLASS_STATE_IN) |
| | | .orderByAsc(DownStorageCage::getSlot) // 按 slot 字段升序排序 |
| | | ); |
| | | } |
| | |
| | | // |
| | | // } |
| | | |
| | | // @Override |
| | | // public List<GlassInfo> DirectConnection(){ |
| | | // LambdaQueryWrapper<GlassInfo> queryWrapper2 = Wrappers.lambdaQuery(); |
| | | // queryWrapper2.select(GlassInfo::getFlowCardId, |
| | | // GlassInfo::getGlassId, |
| | | // GlassInfo::getTemperingLayoutId, |
| | | // GlassInfo::getTemperingFeedSequence) |
| | | // .notInSql(GlassInfo::getGlassId, "SELECT glass_id FROM down_glass_info") |
| | | // .orderByAsc(GlassInfo::getTemperingLayoutId) |
| | | // .orderByDesc(GlassInfo::getTemperingFeedSequence) |
| | | // .last("LIMIT 1"); |
| | | // |
| | | // // 查询 GlassInfo 表 |
| | | // log.info("直通查询"); |
| | | // return glassInfoMapper.selectList(queryWrapper2); |
| | | // |
| | | // }; |
| | | |
| | | @Override |
| | | public List<GlassInfo> DirectConnection(){ |
| | | LambdaQueryWrapper<GlassInfo> queryWrapper2 = Wrappers.lambdaQuery(); |
| | | queryWrapper2.select(GlassInfo::getFlowCardId, |
| | | GlassInfo::getGlassId, |
| | | GlassInfo::getTemperingLayoutId, |
| | | GlassInfo::getTemperingFeedSequence) |
| | | public boolean DirectConnection(GlassInfo glassInfo) { |
| | | LambdaQueryWrapper<GlassInfo> queryWrapper = Wrappers.lambdaQuery(); |
| | | queryWrapper.eq(GlassInfo::getGlassId, glassInfo.getGlassId()) |
| | | .notInSql(GlassInfo::getGlassId, "SELECT glass_id FROM down_glass_info") |
| | | .orderByAsc(GlassInfo::getTemperingLayoutId) |
| | | .orderByDesc(GlassInfo::getTemperingFeedSequence) |
| | | .orderByDesc(GlassInfo::getGlassType) |
| | | .groupBy(GlassInfo::getFlowCardId) |
| | | .last("LIMIT 1"); |
| | | |
| | | // 查询 GlassInfo 表 |
| | | log.info("直通查询"); |
| | | return glassInfoMapper.selectList(queryWrapper2); |
| | | // 查询符合条件的 GlassInfo 记录数量 |
| | | int count = glassInfoMapper.selectCount(queryWrapper); |
| | | |
| | | }; |
| | | return count > 0; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public String getGlassInfoMaxCount(String glassId, List<Integer> workList) { |
| | | DownStorageCageDetails glassInfoMaxCount = baseMapper.getGlassInfoMaxCount(workList); |
| | | return null == glassInfoMaxCount ? glassId : glassInfoMaxCount.getGlassId(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<DownStorageCageDetails> CacheOut1(int start, int end) { |
| | | |
| | | |
| | | List<DownStorageCageDetails> cageDetails = downStorageCageDetailsMapper.selectList(null); |
| | | // 创建一个 LambdaQueryWrapper 实例 |
| | | LambdaQueryWrapper<DownStorageCageDetails> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | // 条件 state=100 |
| | | lambdaQueryWrapper.eq(DownStorageCageDetails::getState, Const.GLASS_STATE_IN); |
| | | List<DownStorageCageDetails> cageDetails = downStorageCageDetailsMapper.selectList(lambdaQueryWrapper); |
| | | // Step 5: 判断 down_storage_cage_details 结果数量是否为9,如果是,则执行另外一个查询 |
| | | if (cageDetails.size() == 9) { |
| | | log.info("1、笼子满了的时候,按照笼内版图id 版图片序出"); |
| | | List<DownWorkstation> workstationList = downWorkstationMapper.selectList(new QueryWrapper<DownWorkstation>().between("workstation_id", start, end)); |
| | | |
| | | |
| | | List<String> flowCardIds = new ArrayList<>(); |
| | | for (DownWorkstation workstation : workstationList) { |
| | |
| | | anotherQueryWrapper.orderByAsc(DownStorageCageDetails::getTemperingLayoutId); |
| | | anotherQueryWrapper.orderByDesc(DownStorageCageDetails::getTemperingFeedSequence); |
| | | anotherQueryWrapper.in(DownStorageCageDetails::getFlowCardId, flowCardIds); |
| | | anotherQueryWrapper.eq(DownStorageCageDetails::getState, Const.GLASS_STATE_IN); |
| | | anotherQueryWrapper.last("LIMIT 1"); |
| | | return downStorageCageDetailsMapper.selectList(anotherQueryWrapper); |
| | | } else { |
| | |
| | | // Step 1: 查询 DownWorkstation 表获取对应 workstation_id 的 flow_card_id |
| | | List<DownWorkstation> workstationList = downWorkstationMapper.selectList(new QueryWrapper<DownWorkstation>().between("workstation_id", start, end)); |
| | | |
| | | |
| | | List<String> flowCardIds = new ArrayList<>(); |
| | | for (DownWorkstation workstation : workstationList) { |
| | | flowCardIds.add(workstation.getFlowCardId()); |
| | | } |
| | | |
| | | if (flowCardIds.isEmpty()) { |
| | | log.error("2、未找到对应的 flow_card_id"); |
| | | return Collections.emptyList(); // 返回空列表或者抛出异常,视情况而定 |
| | |
| | | LambdaQueryWrapper<DownStorageCageDetails> cageDetailsQueryWrapper = Wrappers.lambdaQuery(); |
| | | cageDetailsQueryWrapper.in(DownStorageCageDetails::getGlassId, glassIds); |
| | | cageDetailsQueryWrapper.in(DownStorageCageDetails::getFlowCardId, flowCardIds); |
| | | |
| | | cageDetailsQueryWrapper.eq(DownStorageCageDetails::getState, Const.GLASS_STATE_IN); |
| | | log.info("按照流程卡的版图id 版图片序出"); |
| | | // Step 4: 查询 down_storage_cage_details 表并返回结果 |
| | | return downStorageCageDetailsMapper.selectList(cageDetailsQueryWrapper); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<DownStorageCageDetails> CacheOut2(int start, int end) { |
| | | |
| | | |
| | | // 创建一个 LambdaQueryWrapper 实例 |
| | | LambdaQueryWrapper<DownStorageCageDetails> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | // 条件 state=100 |
| | | lambdaQueryWrapper.eq(DownStorageCageDetails::getState, Const.GLASS_STATE_IN); |
| | | List<DownStorageCageDetails> cageDetails = downStorageCageDetailsMapper.selectList(lambdaQueryWrapper); |
| | | // Step 5: 判断 down_storage_cage_details 结果数量是否为9,如果是,则执行另外一个查询 |
| | | if (cageDetails.size() == 9) { |
| | | log.info("1、笼子满了的时候,按照笼内流程卡顺序出 GlassType目前是流程卡中的顺序"); |
| | | List<DownWorkstation> workstationList = downWorkstationMapper.selectList(new QueryWrapper<DownWorkstation>().between("workstation_id", start, end)); |
| | | |
| | | List<String> flowCardIds = new ArrayList<>(); |
| | | for (DownWorkstation workstation : workstationList) { |
| | | flowCardIds.add(workstation.getFlowCardId()); |
| | | } |
| | | |
| | | if (flowCardIds.isEmpty()) { |
| | | log.error("未找到对应的 flow_card_id"); |
| | | return Collections.emptyList(); // 返回空列表或者抛出异常,视情况而定 |
| | | } |
| | | LambdaQueryWrapper<DownStorageCageDetails> anotherQueryWrapper = Wrappers.lambdaQuery(); |
| | | |
| | | anotherQueryWrapper.orderByAsc(DownStorageCageDetails::getGlassType); |
| | | anotherQueryWrapper.in(DownStorageCageDetails::getFlowCardId, flowCardIds); |
| | | anotherQueryWrapper.eq(DownStorageCageDetails::getState, Const.GLASS_STATE_IN); |
| | | anotherQueryWrapper.last("LIMIT 1"); |
| | | return downStorageCageDetailsMapper.selectList(anotherQueryWrapper); |
| | | } else { |
| | | |
| | | // Step 1: 查询 DownWorkstation 表获取对应 workstation_id 的 flow_card_id |
| | | List<DownWorkstation> workstationList = downWorkstationMapper.selectList(new QueryWrapper<DownWorkstation>().between("workstation_id", start, end)); |
| | | |
| | | List<String> flowCardIds = new ArrayList<>(); |
| | | for (DownWorkstation workstation : workstationList) { |
| | | flowCardIds.add(workstation.getFlowCardId()); |
| | | } |
| | | if (flowCardIds.isEmpty()) { |
| | | log.error("2、未找到对应的 flow_card_id"); |
| | | return Collections.emptyList(); // 返回空列表或者抛出异常,视情况而定 |
| | | } |
| | | log.info("流程卡:{}", flowCardIds); |
| | | LambdaQueryWrapper<GlassInfo> queryWrapper2 = Wrappers.lambdaQuery(); |
| | | queryWrapper2.select(GlassInfo::getFlowCardId, |
| | | GlassInfo::getGlassId) |
| | | .notInSql(GlassInfo::getGlassId, "SELECT glass_id FROM down_glass_info") |
| | | .orderByAsc(GlassInfo::getGlassType) |
| | | .last("LIMIT 1"); |
| | | |
| | | // 查询 GlassInfo 表 |
| | | List<GlassInfo> glassInfos = glassInfoMapper.selectList(queryWrapper2); |
| | | if (glassInfos.isEmpty()) { |
| | | log.error("未找到对应的玻璃信息"); |
| | | return Collections.emptyList(); // 返回空列表或者抛出异常,视情况而定 |
| | | } |
| | | // Step 3: 构造查询 down_storage_cage_details 表的条件 |
| | | List<String> glassIds = glassInfos.stream().map(GlassInfo::getGlassId).collect(Collectors.toList()); |
| | | LambdaQueryWrapper<DownStorageCageDetails> cageDetailsQueryWrapper = Wrappers.lambdaQuery(); |
| | | cageDetailsQueryWrapper.in(DownStorageCageDetails::getGlassId, glassIds); |
| | | cageDetailsQueryWrapper.in(DownStorageCageDetails::getFlowCardId, flowCardIds); |
| | | cageDetailsQueryWrapper.eq(DownStorageCageDetails::getState, Const.GLASS_STATE_IN); |
| | | log.info("按照流程卡的顺序出"); |
| | | // Step 4: 查询 down_storage_cage_details 表并返回结果 |
| | | return downStorageCageDetailsMapper.selectList(cageDetailsQueryWrapper); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public boolean identWorn(String glassId, int ControlsId) { |
| | | List<DownStorageCageDetails> edgStorageCageDetails = baseMapper.selectList(new MPJLambdaQueryWrapper<DownStorageCageDetails>().selectAll(DownStorageCageDetails.class).eq(DownStorageCageDetails::getGlassId, glassId)); |
| | | if (edgStorageCageDetails.size() == 1) { |
| | | DownStorageCageDetails item = edgStorageCageDetails.get(0); |
| | | item.setState(ControlsId); |
| | | baseMapper.update(item, new MPJLambdaWrapper<DownStorageCageDetails>().selectAll(DownStorageCageDetails.class).eq(DownStorageCageDetails::getGlassId, glassId)); |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |