zhuo
2025-02-24 6888584781c77de6854b62f93a57dcce53240cf9
basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardProductListServiceImpl.java
@@ -57,10 +57,6 @@
        return standardProductListMapper.updateById(list);
    }
    @Override
    public int delStandardProduct(JSONArray list) {
        return standardProductListMapper.deleteBatchIds(list);
    }
    @Override
    public List<StandardProductList> selectStandardProductList(InsSampleReceiveDto insSample) {
@@ -139,7 +135,7 @@
                    }
                    return true;
                }).peek(standardProductList -> {
                    // todo: 判断是否是原材下单, 需要啊把颜色绑定到试样颜色的要求值上
                    //判断是否是原材下单, 需要啊把颜色绑定到试样颜色的要求值上
                    if (StringUtils.isNotBlank(insSample.getPartNo())) {
                        // 判断是否有这个字段且是文本类型
                        if (StringUtils.isNotBlank(standardProductList.getInspectionItem())
@@ -263,13 +259,9 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Map<String, Object> selectStandardProductListByMethodId(Integer id, String tree, Integer page) {
    public Map<String, Object> selectStandardProductListByMethodId(Integer id, String tree) {
        String[] trees = tree.split(" - ");
        try {
            String tree1 = trees[2];
        } catch (Exception e) {
            throw new BaseException("操作太快,系统传参错误!!!!");
        }
        // 判断是否拖拽
        boolean isDrag = false;
        List<StandardProductList> list = new ArrayList<>();
        if (trees.length == 3) {
@@ -419,47 +411,36 @@
                }
            }
        }
        if (page == 1) {
            Integer userId = SecurityUtils.getUserId().intValue();
//            CompletableFuture.supplyAsync(() -> {
            if (trees.length == 5) {
                standardProductListMapper.delete(Wrappers.<StandardProductList>lambdaUpdate()
                        .eq(StandardProductList::getStandardMethodListId, id)
                        .eq(StandardProductList::getTree, tree));
            } else {
                standardProductListMapper.delete(Wrappers.<StandardProductList>lambdaUpdate()
                        .eq(StandardProductList::getStandardMethodListId, id)
                        .like(StandardProductList::getTree, tree));
            }
            boolean success = false;
            int retryCount = 0;
            while (!success && retryCount < 100) {
                try {
                    standardProductListService2.saveBatch(list.stream().map(a -> {
                        a.setFactory(trees[0]);
                        a.setLaboratory(trees[1]);
                        a.setSampleType(trees[2]);
                        a.setCreateUser(userId);
                        a.setUpdateUser(userId);
                        a.setStandardMethodListId(id);
                        return a;
                    }).collect(Collectors.toList()));
                    ;
                    success = true;
                } catch (Exception e) {
                    // 处理重复 ID 的记录,重新生成 ID 并继续尝试插入
                    for (StandardProductList productList : list) {
                        productList.setId(IdWorker.getId());
                    }
                }
            }
            if (!success) {
                throw new RuntimeException("插入失败");
            }
        Integer userId = SecurityUtils.getUserId().intValue();
        if (trees.length == 5) {
            standardProductListMapper.delete(Wrappers.<StandardProductList>lambdaUpdate()
                    .eq(StandardProductList::getStandardMethodListId, id)
                    .eq(StandardProductList::getTree, tree));
        } else {
            standardProductListMapper.delete(Wrappers.<StandardProductList>lambdaUpdate()
                    .eq(StandardProductList::getStandardMethodListId, id)
                    .like(StandardProductList::getTree, tree));
        }
        Map<String, Object> map = new HashMap<>();
        try {
            List<StandardProductList> productLists = list.stream().map(a -> {
                a.setFactory(trees[0]);
                a.setLaboratory(trees[1]);
                a.setSampleType(trees[2]);
                a.setCreateUser(userId);
                a.setUpdateUser(userId);
                a.setStandardMethodListId(id);
                return a;
            }).collect(Collectors.toList());
            standardProductListService2.saveBatch(productLists);
        } catch (Exception e) {
            // 处理重复 ID 的记录,重新生成 ID 并继续尝试插入
            for (StandardProductList productList : list) {
                productList.setId(IdWorker.getId());
            }
        }
        Collections.sort(list, (o1, o2) -> {
            String field1 = o1.getManHourGroup();
            String field2 = o2.getManHourGroup();
@@ -484,11 +465,9 @@
            list.sort((o1, o2) -> (o1.getSort() == null ? 0 : o1.getSort())
                    - (o2.getSort() == null ? 0 : o2.getSort()));
        }
        try {
            map.put("productList", list.subList((page - 1) * 300, page * 300));
        } catch (IndexOutOfBoundsException e) {
            map.put("productList", list.subList((page - 1) * 300, list.size()));
        }
        Map<String, Object> map = new HashMap<>();
        map.put("productList", list);
        map.put("total", list.size());
        return map;
    }