Crunchy
2024-07-17 ee22e4cdf5656272443365aa54bf08863f7fae52
inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java
@@ -11,7 +11,6 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanchu.mom.common.GetLook;
import com.yuanchu.mom.dto.ProductDto;
import com.yuanchu.mom.exception.ErrorException;
import com.yuanchu.mom.mapper.StandardProductListMapper;
import com.yuanchu.mom.mapper.StandardTreeMapper;
import com.yuanchu.mom.pojo.InsSample;
@@ -49,144 +48,8 @@
    @Override
    public int upStandardProductList(StandardProductList list) {
        String section = list.getSection();
        String a = section;
        if (a != null) {
            section = interval(section);
            list.setSection(section);
        } else {
            list.setSection(null);
        }
        return standardProductListMapper.updateById(list);
    }
    private  String interval(String section) {
        section = section.replace("\"", "");
        section = section.replace("[", "");
        section = section.replace("]", "");
        String[] split = section.split(",");
        int[] start1 = new int[20];
        int[] start2 = new int[20];
        int[] end1 = new int[20];
        int[] end2 = new int[20];
        int y = 0;
        for (String str : split) {
            String[] conditions = str.split("&");
            for (int i = 0; i < conditions.length; i++) {
                if (conditions[i].contains("<=")) {
                    end2[y] = Integer.parseInt(conditions[i].replace("<=", ""));
                    y++;
                } else if (conditions[i].contains("<")) {
                    end1[y] = Integer.parseInt(conditions[i].replace("<", ""));
                    y++;
                }
                if (conditions[i].contains(">=")) {
                    start2[y] = Integer.parseInt(conditions[i].replace(">=", ""));
                    y++;
                } else if (conditions[i].contains(">")) {
                    start1[y] = Integer.parseInt(conditions[i].replace(">", ""));
                    y++;
                }
            }
        }
        Set<Integer> start = new TreeSet<>();
        for (
                int value : start1) {
            start.add(value);
        }
        for (
                int value : start2) {
            start.add(value);
        }
        Set<Integer> end = new TreeSet<>();
        for (
                int value : end1) {
            end.add(value);
        }
        for (
                int value : end2) {
            end.add(value);
        }
        section = "";
        ArrayList<Integer> ab = new ArrayList<>();
        for (Integer integer : end) {
            if (integer != 0) {
                ab.add(integer);
            }
        }
        ArrayList<Integer> ac = new ArrayList<>();
        for (Integer integer : start) {
            if (integer != 0) {
                ac.add(integer);
            }
        }
        if (!ab.isEmpty() && !ac.isEmpty()) {
            int min = Collections.min(ab);
            int max = Collections.max(ac);
            if (min <= max) {
                throw new ErrorException("区间错误");
            }
            int minValue = 0;
            int maxValue = 0;
            for (int i = 1; i < end2.length; i++) {
                if (end2[i] < minValue) {
                    minValue = end2[i];
                }
            }
            for (int i = 1; i < start2.length; i++) {
                if (start2[i] > maxValue) {
                    maxValue = start2[i];
                }
            }
            if (min == minValue && max == maxValue) {
                section = ("[" + "\"" + ">" + "=" + max + "&" + "<" + "=" + min + "\"" + "]");
            }
            if (min != minValue && max == maxValue) {
                section = ("[" + "\"" + ">" + "=" + max + "&" + "<" + min + "\"" + "]");
            }
            if (min == minValue && max != maxValue) {
                section = ("[" + "\"" + ">" + max + "&" + "<" + "=" + min + "\"" + "]");
            }
            if (min != minValue && max != maxValue) {
                section = ("[" + "\"" + ">" + max + "&" + "<" + min + "\"" + "]");
            }
        }
        if (ab.isEmpty() && !ac.isEmpty()) {
            int max = Collections.max(ac);
            int maxValue = 0;
            for (int i = 1; i < start2.length; i++) {
                if (start2[i] > maxValue) {
                    maxValue = start2[i];
                }
            }
            if (max == maxValue) {
                section = ("[" + "\"" + ">" + "=" + max + "\"" + "]");
            }
            if (max != maxValue) {
                section = ("[" + "\"" + ">" + max + "\"" + "]");
            }
        }
        if (!ab.isEmpty() && ac.isEmpty()) {
            int min = Collections.min(ab);
            int minValue = 0;
            for (int i = 1; i < end2.length; i++) {
                if (end2[i] < minValue) {
                    minValue = end2[i];
                }
            }
            if (min == minValue) {
                section = ("[" + "\"" + "<" + "=" + min + "\"" + "]");
            }
            if (min != minValue) {
                section = ("[" + "\"" + "<" + min + "\"" + "]");
            }
        }
        return section;
    }
        @Override
        public int delStandardProduct (JSONArray list){
@@ -196,13 +59,7 @@
        @Override
        public List<StandardProductList> selectStandardProductList (InsSample insSample){
            String[] models = insSample.getModel().split("-(?=[^-]*$)");//拆分最后一个【-】
            List<StandardProductList> list = new ArrayList<>();
            if (models.length==1) {
                list=standardProductListMapper.selectDetail(insSample.getStandardMethodListId(), 1, models[0]);
            }
            if (models.length==2) {
                list=standardProductListMapper.selectDetail(insSample.getStandardMethodListId(), 1, models[0]+"-"+models[1]);
            }
        List<StandardProductList> list = standardProductListMapper.selectDetail(insSample.getStandardMethodListId(), 1, models[0]);
            if (list.size() == 0) {
                if (Objects.equals(insSample.getFactory(), "") || insSample.getFactory() == null) {
                    return null;
@@ -228,8 +85,8 @@
                            if (Objects.equals(a.getBsm(), "1")) {
                                return true;
                            } else {
                                if (sections.get(i).contains("@")) {
                                    String[] split = sections.get(i).split("@");
                            if (sections.get(i).contains("&")) {
                                String[] split = sections.get(i).split("&");
                                    isIf = getIsIf(split[0], models[1]) && getIsIf(split[1], models[1]);
                                } else {
                                    isIf = getIsIf(sections.get(i), models[1]);
@@ -379,6 +236,7 @@
            if (page == 1) {
                Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId");
                CompletableFuture.supplyAsync(() -> {
                System.out.println("开始开始开始开始!!!!!!!!!!");
                    if (trees.length == 5) {
                        standardProductListMapper.delete(Wrappers.<StandardProductList>lambdaUpdate().eq(StandardProductList::getStandardMethodListId, id).eq(StandardProductList::getTree, tree));
                    } else {
@@ -393,6 +251,7 @@
                        a.setStandardMethodListId(id);
                        return a;
                    }).collect(Collectors.toList()));
                System.out.println("结束结束结束结束@@@@@@@@@@@@");
                    return null;
                }).thenAccept(res -> {
                }).exceptionally(e -> {
@@ -439,8 +298,7 @@
        }
        @Override
        public IPage<StandardProductList> selectStandardProductByMethodId (Integer id, String tree, Integer page, String
        laboratory, String item, String items){
    public IPage<StandardProductList> selectStandardProductByMethodId(Integer id, String tree, Integer page, String laboratory, String item, String items) {
            IPage<StandardProductList> iPage = new Page<>();
            iPage.setSize(100);
            iPage.setCurrent(page);