| | |
| | | import com.ruoyi.basic.pojo.StandardProductListSupplierAsk; |
| | | import com.ruoyi.basic.pojo.StandardTree; |
| | | import com.ruoyi.basic.service.StandardProductListService; |
| | | import com.ruoyi.basic.service.StandardProductListService2; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | |
| | | private StandardTreeMapper standardTreeMapper; |
| | | |
| | | private StandardProductListService2 standardProductListService2; |
| | | |
| | | private IfsInventoryQuantityMapper ifsInventoryQuantityMapper; |
| | | |
| | | private StandardProductListSupplierAskMapper standardProductListSupplierAskMapper; |
| | |
| | | return standardProductListMapper.updateById(list); |
| | | } |
| | | |
| | | @Override |
| | | public int delStandardProduct(JSONArray list) { |
| | | return standardProductListMapper.deleteBatchIds(list); |
| | | } |
| | | |
| | | @Override |
| | | public List<StandardProductList> selectStandardProductList(InsSampleReceiveDto insSample) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param str 判定公式 |
| | | * @param model 型号 |
| | | * @param standardCores 芯数 |
| | | * @param conductorMaterial 导体材质 |
| | | * @param conductorType 导体类型 |
| | | * @param str 判定公式 |
| | | * @param model 型号 |
| | | * @param standardCores 芯数 |
| | | * @param conductorMaterial 导体材质 |
| | | * @param conductorType 导体类型 |
| | | * @param insSample |
| | | * @return |
| | | */ |
| | | private boolean getIsIf(String str, String model, String standardCores, String conductorMaterial, String conductorType,InsSampleReceiveDto insSample) { |
| | | private boolean getIsIf(String str, String model, String standardCores, String conductorMaterial, String conductorType, InsSampleReceiveDto insSample) { |
| | | Matcher matcher = Pattern.compile("\\d+(\\.\\d+)?").matcher(model); |
| | | String model2 = ""; |
| | | while (matcher.find()) { |
| | |
| | | |
| | | @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) { |
| | |
| | | if (sp.getTemplateId() != null && !sp.getTemplateId().equals("")) { |
| | | pl.setTemplateId(sp.getTemplateId()); |
| | | } |
| | | //因为还有个产品叫耐张线夹 接续金具 ,这两个项目的数据完全一样,特殊处理 |
| | | if (sp.getTree() != null && !sp.getTree().equals("") && !pl.getTree().equals("中天科技检测中心 - 电力产品实验室 - 金具 - 耐张线夹 - null")) { |
| | | pl.setTree(sp.getTree()); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | 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)); |
| | | } |
| | | |
| | | 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())); |
| | | } catch (Exception e) { |
| | | // 处理重复 ID 的记录,重新生成 ID 并继续尝试插入 |
| | | for (StandardProductList productList : list) { |
| | | productList.setId(IdWorker.getId()); |
| | | } |
| | | } |
| | | |
| | | 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<>(); |
| | | |
| | | |
| | | 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()); |
| | | // this.saveBatch(productLists); |
| | | // 批量添加标准 |
| | | if (CollectionUtils.isNotEmpty(productLists)) { |
| | | baseMapper.saveBatchProductLists(productLists); |
| | | } |
| | | |
| | | |
| | | Collections.sort(list, (o1, o2) -> { |
| | | String field1 = o1.getManHourGroup(); |
| | | String field2 = o2.getManHourGroup(); |
| | |
| | | return Integer.compare(num1, num2); |
| | | } |
| | | }); |
| | | // 按照索引排序 |
| | | // 按照索引排序 |
| | | if (isDrag) { |
| | | list.sort((o1, o2) -> (o1.getSort() == null ? 0 : o1.getSort()) |
| | | - (o2.getSort() == null ? 0 : o2.getSort())); |
| | | list.sort(Comparator.comparingInt(o -> (o.getSort() == null ? 0 : o.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; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Map<String, Object> buildStandardProductListNoDrag(Integer id, String tree) { |
| | | |
| | | String[] trees = tree.split(" - "); |
| | | List<StandardProductList> list = new ArrayList<>(); |
| | | if (trees.length == 3) { |
| | | List<StandardTree> treeList = new ArrayList<>(); |
| | | StandardTree standardTree = new StandardTree(); |
| | | standardTree.setFactory(trees[0]); |
| | | standardTree.setLaboratory(trees[1]); |
| | | standardTree.setSampleType(trees[2]); |
| | | |
| | | List<ProductDto> pList = standardTreeMapper.selectPList(trees[2]); |
| | | if (CollectionUtils.isEmpty(pList) || pList.get(0) == null) { |
| | | List<StandardTree> treeList1 = |
| | | standardTreeMapper.selectList( |
| | | Wrappers.<StandardTree>lambdaQuery() |
| | | .eq(StandardTree::getLaboratory, trees[1]) |
| | | .eq(StandardTree::getSampleType, trees[2]) |
| | | ); |
| | | if (CollectionUtils.isEmpty(treeList1)) { |
| | | treeList.add(standardTree); |
| | | } else { |
| | | treeList.addAll(treeList1); |
| | | } |
| | | } else { |
| | | for (ProductDto p : pList) { |
| | | standardTree.setSample(p.getName()); |
| | | List<StandardTree> treeList1 = |
| | | standardTreeMapper.selectList( |
| | | Wrappers.<StandardTree>lambdaQuery() |
| | | .eq(StandardTree::getLaboratory, trees[1]) |
| | | .eq(StandardTree::getSampleType, trees[2]) |
| | | .eq(StandardTree::getSample, p.getName()) |
| | | ); |
| | | if (CollectionUtils.isEmpty(treeList1)) { |
| | | treeList.add(JSON.parseObject( |
| | | JSON.toJSONString(standardTree), |
| | | StandardTree.class |
| | | )); |
| | | } else { |
| | | treeList.addAll(treeList1); |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (StandardTree st : treeList) { |
| | | String tree2 = trees[0] + " - " + trees[1] + " - " + trees[2] |
| | | + " - " + st.getSample() + " - " + st.getModel(); |
| | | |
| | | list.addAll( |
| | | standardTreeMapper.selectStandardProductListByTree( |
| | | "\"" + trees[2] + "\"", |
| | | st.getSample(), |
| | | st.getModel(), |
| | | tree2, |
| | | trees[1] |
| | | ) |
| | | ); |
| | | list.addAll( |
| | | standardTreeMapper.selectStandardProductListByTree2( |
| | | "\"" + trees[2] + "\",\"" + st.getSample() + "\"", |
| | | st.getSample(), |
| | | st.getModel(), |
| | | tree2, |
| | | trees[1] |
| | | ) |
| | | ); |
| | | } |
| | | |
| | | } else if (trees.length == 4) { |
| | | |
| | | List<StandardTree> treeList = |
| | | standardTreeMapper.selectList( |
| | | Wrappers.<StandardTree>lambdaQuery() |
| | | .eq(StandardTree::getLaboratory, trees[1]) |
| | | .eq(StandardTree::getSampleType, trees[2]) |
| | | .eq(StandardTree::getSample, trees[3]) |
| | | ); |
| | | |
| | | if (CollectionUtils.isEmpty(treeList)) { |
| | | StandardTree st = new StandardTree(); |
| | | st.setFactory(trees[0]); |
| | | st.setLaboratory(trees[1]); |
| | | st.setSampleType(trees[2]); |
| | | st.setSample(trees[3]); |
| | | treeList.add(st); |
| | | } |
| | | |
| | | for (StandardTree st : treeList) { |
| | | String str = tree + " - " + st.getModel(); |
| | | list.addAll( |
| | | standardTreeMapper.selectStandardProductListByTree( |
| | | "\"" + trees[2] + "\"", |
| | | st.getSample(), |
| | | st.getModel(), |
| | | str, |
| | | trees[1] |
| | | ) |
| | | ); |
| | | list.addAll( |
| | | standardTreeMapper.selectStandardProductListByTree2( |
| | | "\"" + trees[2] + "\",\"" + trees[3] + "\"", |
| | | st.getSample(), |
| | | st.getModel(), |
| | | str, |
| | | trees[1] |
| | | ) |
| | | ); |
| | | } |
| | | |
| | | } else { |
| | | list.addAll( |
| | | standardTreeMapper.selectStandardProductListByTree( |
| | | "\"" + trees[2] + "\"", |
| | | "null".equals(trees[3]) ? null : trees[3], |
| | | trees[4], |
| | | tree, |
| | | trees[1] |
| | | ) |
| | | ); |
| | | list.addAll( |
| | | standardTreeMapper.selectStandardProductListByTree2( |
| | | "\"" + trees[2] + "\",\"" + trees[3] + "\"", |
| | | "null".equals(trees[3]) ? null : trees[3], |
| | | trees[4], |
| | | tree, |
| | | trees[1] |
| | | ) |
| | | ); |
| | | } |
| | | |
| | | for (StandardProductList p : list) { |
| | | p.setId(IdWorker.getId()); |
| | | } |
| | | List<StandardProductList> oldList = |
| | | standardProductListMapper.selectList( |
| | | Wrappers.<StandardProductList>lambdaQuery() |
| | | .eq(StandardProductList::getStandardMethodListId, id) |
| | | .like(StandardProductList::getTree, tree) |
| | | ); |
| | | |
| | | for (StandardProductList old : oldList) { |
| | | for (StandardProductList cur : list) { |
| | | |
| | | // 半径只有一个值,自动赋值 |
| | | String radiusList = cur.getRadiusList(); |
| | | if (StringUtils.isNotBlank(radiusList) |
| | | && !"null".equals(radiusList) |
| | | && !"\"\"".equals(radiusList)) { |
| | | JSONArray jsonArray = JSON.parseArray(radiusList); |
| | | List<String> radius = jsonArray.toJavaList(String.class); |
| | | if (CollectionUtils.isNotEmpty(radius) && radius.size() == 1) { |
| | | cur.setRadius(radius.get(0)); |
| | | } |
| | | } |
| | | |
| | | if (Objects.equals(old.getInspectionItem(), cur.getInspectionItem()) |
| | | && Objects.equals( |
| | | Objects.toString(old.getInspectionItemSubclass(), ""), |
| | | Objects.toString(cur.getInspectionItemSubclass(), "") |
| | | ) |
| | | && Objects.equals(old.getModel(), cur.getModel()) |
| | | && old.getTree().contains( |
| | | cur.getSample() == null ? "null" : cur.getSample() |
| | | ) |
| | | && Objects.equals( |
| | | old.getStructureItemParameterId(), |
| | | cur.getStructureItemParameterId() |
| | | )) { |
| | | |
| | | cur.setId(old.getId()); |
| | | cur.setSort(old.getSort()); |
| | | cur.setState(old.getState()); |
| | | cur.setMethod(old.getMethodS()); |
| | | cur.setRadius(old.getRadius()); |
| | | cur.setRates(old.getRates()); |
| | | cur.setAsk(old.getAsk()); |
| | | cur.setTell(old.getTell()); |
| | | cur.setPrice(old.getPrice()); |
| | | cur.setManHour(old.getManHour()); |
| | | cur.setSection(old.getSection()); |
| | | cur.setCores(old.getCores()); |
| | | cur.setConductorMaterial(old.getConductorMaterial()); |
| | | cur.setConductorType(old.getConductorType()); |
| | | cur.setTemplateId(old.getTemplateId()); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | list.sort((o1, o2) -> { |
| | | String f1 = o1.getManHourGroup(); |
| | | String f2 = o2.getManHourGroup(); |
| | | |
| | | boolean e1 = StringUtils.isBlank(f1); |
| | | boolean e2 = StringUtils.isBlank(f2); |
| | | |
| | | if (e1 && e2) return 0; |
| | | if (e1) return 1; |
| | | if (e2) return -1; |
| | | |
| | | return Integer.compare( |
| | | extractNumber(f1), |
| | | extractNumber(f2) |
| | | ); |
| | | }); |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("productList", list); |
| | | map.put("total", list.size()); |
| | | return map; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 修改标准库区间 |
| | | * |
| | | * @param list |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 标准库拖拽 |
| | | * |
| | | * @param resetTreeDragDTO |
| | | */ |
| | | @Override |
| | |
| | | resetTreeDragDTO.getTree()); |
| | | |
| | | // 从下往上 |
| | | } else if (beginIndex > endIndex){ |
| | | } else if (beginIndex > endIndex) { |
| | | standardProductListMapper.updateSortDown(beginIndex, |
| | | endIndex, |
| | | methodId, |
| | |
| | | |
| | | @Override |
| | | public void resetTreeDragBatch(List<StandardProductList> standardProductLists) { |
| | | standardProductListService2.updateBatchById(standardProductLists); |
| | | this.updateBatchById(standardProductLists); |
| | | } |
| | | |
| | | /** |
| | | * 检验项要求值对比 |
| | | * |
| | | * @param copyDto |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 检验项复制对比一个 |
| | | * |
| | | * @param dto |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 检验项复制排序 |
| | | * |
| | | * @param copyDto |
| | | * @return |
| | | */ |