zss
2024-12-30 97bb7a8832281eafe0ef947ea095258d355e52f5
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsProductServiceImpl.java
@@ -99,13 +99,24 @@
            if (insProducts.stream().map(InsProduct::getId).collect(Collectors.toList()).equals(ids)) {
                //如果该检验单下的所有项目全部都撤销,那么这个单子也需要撤销
                insOrder.setState(3);
            } else {
            }
            else {
                List<InsProduct> products = insProductMapper.selectBatchIds(ids);
                //首先根据选择的项目id进行撤销项目
                updateBatchById(products.stream().map(insProduct -> {
                    insProduct.setState(0);
                    return insProduct;
                }).collect(Collectors.toList()));
                //如果该检验单某个样品下的项目全部都撤销了,那么这个样品也需要删掉
                List<Integer> sampleIds = products.stream().map(InsProduct::getInsSampleId).distinct().collect(Collectors.toList());
                for (Integer sampleId : sampleIds) {
                    Long count = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery()
                            .eq(InsProduct::getInsSampleId, sampleId)
                            .eq(InsProduct::getState, 1));
                    if(count<=0){
                        insSampleMapper.deleteById(sampleId);
                    }
                }
            }
            //insProductMapper.updateInspected(id);
        }