| | |
| | | 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; |
| | |
| | | |
| | | @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) { |
| | |
| | | @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; |
| | |
| | | } |
| | | |
| | | @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); |