Revert "重大更新:相同编码和型号,如果类别不同,区别为不同物料.处理方式为:型号内追加类别,最终以不同型号处理区分物料. 不影响 编码和型号确定唯一物料这一基本规则前提下区分类别不同的同编码和型号的物料"

This reverts commit 9f18181807420a7f5cfbacaf594c694fae6b9946.
5个文件已修改
85 ■■■■■ 已修改文件
src/main/java/com/whyc/mapper/MaterialMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/Material.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/MaterialService.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/ProductService.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/MaterialMapper.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/MaterialMapper.java
@@ -36,6 +36,4 @@
    void updateDwgUrlAndPicUrl(List<Material> materialUpdateList);
    List<Material> getSameSubCodeAndModel(List<ProductBom> bomList);
}
src/main/java/com/whyc/pojo/Material.java
@@ -19,8 +19,6 @@
    private Integer   id;
    @ApiModelProperty("母料编号")
    private String type;
    @ApiModelProperty("类别")
    private String category;
    @ApiModelProperty("子件编码")
    private String     subCode;
    @ApiModelProperty("子件名称")
@@ -193,13 +191,5 @@
    public void setAttachLocks(List<AttachLock> attachLocks) {
        this.attachLocks = attachLocks;
    }
    public String getCategory() {
        return category;
    }
    public void setCategory(String category) {
        this.category = category;
    }
}
src/main/java/com/whyc/service/MaterialService.java
@@ -274,7 +274,7 @@
                        cellValue = cell.getStringCellValue();
                        switch (m){
                            case 2:{material.setCategory(cellValue);}break;
                            //case 2:{material.setCategory(cellValue);}break;
                            case 3:{material.setSubCode(cellValue);}break;
                            case 4:{material.setSubName(cellValue);}break;
                            case 5:{material.setSubModel(cellValue);}break;
@@ -519,9 +519,5 @@
    public void updateDwgUrlAndPicUrl(List<Material> materialUpdateList) {
        mapper.updateDwgUrlAndPicUrl(materialUpdateList);
    }
    public List<Material> getSameSubCodeAndModel(List<ProductBom> bomList) {
        return mapper.getSameSubCodeAndModel(bomList);
    }
}
src/main/java/com/whyc/service/ProductService.java
@@ -288,51 +288,6 @@
                    }
                    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);
            }
        }
@@ -669,7 +624,6 @@
                    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());
@@ -714,20 +668,7 @@
            // 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());
src/main/resources/mapper/MaterialMapper.xml
@@ -296,10 +296,4 @@
        select DISTINCT tb_attach_lock.*  FROM tb_attach_lock
        where tb_attach_lock.material_id=#{id}
    </select>
    <select id="getSameSubCodeAndModel" resultType="com.whyc.pojo.Material">
        select * from tb_material where
        <foreach collection="list" item="item" separator="or">
            (sub_code = #{item.subCode} and sub_model = #{item.subModel})
        </foreach>
    </select>
</mapper>