| | |
| | | } |
| | | bomList.add(bom); |
| | | } |
| | | //产生的bom物料列表,查询是否有 相同编码和型号的 |
| | | List<Material> existMaterialListWithSameSubCodeAndModel = mService.getSameSubCodeAndModel(bomList); |
| | | List<String> dbCodeModelUnionList = existMaterialListWithSameSubCodeAndModel.stream().map(material -> material.getSubCode() + "/" + (material.getSubModel().contains("-[系统追加-")?material.getSubModel().split("-\\[系统追加-")[0]:material.getSubModel())).collect(Collectors.toList()); |
| | | //List<String> dbCodeOriginalModelUnionList = existMaterialListWithSameSubCodeAndModel.stream().map(material -> material.getSubCode() + "/" + material.getSubModel()).collect(Collectors.toList()); |
| | | List<String> dbCodeModelCategoryUnionList = existMaterialListWithSameSubCodeAndModel.stream().map(material -> material.getSubCode() + "/" + (material.getSubModel().contains("-[系统追加-")?material.getSubModel().split("-\\[系统追加-")[0]:material.getSubModel())+"/"+material.getCategory()).collect(Collectors.toList()); |
| | | List<String> dbCodeOriginalModelCategoryUnionList = existMaterialListWithSameSubCodeAndModel.stream().map(material -> material.getSubCode() + "/" + material.getSubModel()+"/"+material.getCategory()).collect(Collectors.toList()); |
| | | bomList.forEach(bom->{ |
| | | //同编码和型号 |
| | | String codeModelUnionStr = bom.getSubCode() + "/" + bom.getSubModel(); |
| | | if(dbCodeModelUnionList.contains(codeModelUnionStr)){ |
| | | String codeModelCategoryUnionStr = bom.getSubCode() + "/" + bom.getSubModel() + "/" + bom.getCategory(); |
| | | if(dbCodeModelCategoryUnionList.contains(codeModelCategoryUnionStr)){ |
| | | //相同类别,完全相同. 型号需要与数据库内记录的处理保持一致 |
| | | if(!dbCodeOriginalModelCategoryUnionList.contains(codeModelCategoryUnionStr)){ |
| | | bom.setSubModel(bom.getSubModel()+"-[系统追加-"+bom.getCategory()+"]"); |
| | | } |
| | | }else{ //不同类别 |
| | | //重写型号 |
| | | bom.setSubModel(bom.getSubModel()+"-[系统追加-"+bom.getCategory()+"]"); |
| | | } |
| | | } |
| | | }); |
| | | //上传的bom物料列表自己对比,校验是否 [编号/型号相同]及[编号/型号,类别相同] |
| | | List<ProductBom> reviewedBomList = new LinkedList<>(); |
| | | for (int i1 = 0; i1 < bomList.size(); i1++) { |
| | | ProductBom bom = bomList.get(i1); |
| | | for (int j = 0; j < reviewedBomList.size(); j++) { |
| | | ProductBom reviewedBom = reviewedBomList.get(j); |
| | | if((reviewedBom.getSubCode()+"/"+reviewedBom.getSubModel()).equals(bom.getSubCode()+"/"+bom.getSubModel())){ |
| | | //已经遍历的记录中,与当前正在遍历的记录 编号/型号相同 |
| | | if((reviewedBom.getSubCode()+"/"+reviewedBom.getSubModel()+"/"+reviewedBom.getCategory()) |
| | | .equals(bom.getSubCode()+"/"+bom.getSubModel()+"/"+bom.getCategory())){ |
| | | //类别相同 |
| | | return response.set(1,false,"解析失败,原因:存在两个完全相同的物料-子件编码"+bom.getSubCode()+"/子件型号"+bom.getSubModel()+"/类别"+reviewedBom.getCategory()); |
| | | }else{ |
| | | //类别不同,型号内系统默认追加类别 |
| | | bomList.get(j).setSubModel(reviewedBom.getSubModel()+"-[系统追加-"+reviewedBom.getCategory()+"]"); |
| | | bomList.get(i1).setSubModel(bom.getSubModel()+"-[系统追加-"+bom.getCategory()+"]"); |
| | | } |
| | | } |
| | | } |
| | | //遍历一个,添加一个到reviewedBomList |
| | | reviewedBomList.add(bom); |
| | | } |
| | | |
| | | product.setBomList(bomList); |
| | | } |
| | | } |
| | |
| | | material.setPictureUrl(bom.getPictureUrl()); |
| | | // TODO 是否要更新同物料编码的老物料状态为0? |
| | | material.setStatus(1); |
| | | material.setCategory(bom.getCategory()); |
| | | material.setSubCode(bom.getSubCode()); |
| | | material.setSubModel(bom.getSubModel()); |
| | | material.setSubName(bom.getSubName()); |
| | |
| | | // product的主键沿用对应product_history的 |
| | | //根据编码和型号确定物料id并对应quantity,存入数据库. |
| | | //List<Material> bomMaterialList = mService.getListByCodeAndModelList2(bomList); |
| | | //List<ProductBom> bomMaterialList = pbService.getListByCodeAndModelList2(bomList); |
| | | List<Material> existMaterialListWithSameSubCodeAndModel = mService.getSameSubCodeAndModel(bomList); |
| | | List<ProductBom> bomMaterialList; |
| | | bomList.forEach(bom->{ |
| | | String codeModelUnionStr = bom.getSubCode() + "/" + bom.getSubModel(); |
| | | for (int i = 0; i < existMaterialListWithSameSubCodeAndModel.size(); i++) { |
| | | Material materialExists = existMaterialListWithSameSubCodeAndModel.get(i); |
| | | if(codeModelUnionStr.equals(materialExists.getSubCode() + "/" + materialExists.getSubModel())){ |
| | | bom.setId(materialExists.getId()); |
| | | break; |
| | | } |
| | | } |
| | | }); |
| | | bomMaterialList = bomList; |
| | | List<ProductBom> bomMaterialList = pbService.getListByCodeAndModelList2(bomList); |
| | | // -> product_history |
| | | ProductHistory productHistory = new ProductHistory(); |
| | | productHistory.setParentCode(product.getParentCode()); |