123456
2024-07-16 b10f7dc5c05062e6792f522ae1fb4de446189d3e
区间合并,检验下单时型号参数匹配
已修改1个文件
148 ■■■■■ 文件已修改
inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java 148 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java
@@ -11,6 +11,7 @@
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;
@@ -48,8 +49,144 @@
    @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) {
@@ -59,7 +196,13 @@
    @Override
    public List<StandardProductList> selectStandardProductList(InsSample insSample) {
        String[] models = insSample.getModel().split("-(?=[^-]*$)");//拆分最后一个【-】
        List<StandardProductList> list = standardProductListMapper.selectDetail(insSample.getStandardMethodListId(), 1, models[0]);
            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]);
            }
        if (list.size() == 0) {
            if (Objects.equals(insSample.getFactory(), "") || insSample.getFactory() == null) {
                return null;
@@ -296,7 +439,8 @@
    }
    @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);