zss
2023-09-15 22899f74279a47f4ec79e1325f8489d948ced005
standard-server/src/main/java/com/yuanchu/mom/service/impl/StandardServiceImpl.java
@@ -61,7 +61,15 @@
    //(3级)新增-->标准,型号
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addStandard(StandardDto standardDto) {
    public String addStandard(StandardDto standardDto) {
        //校验添加该物料下的标准是否重复
        List<String> standNameList = standardMapper.selectList(Wrappers.<Standard>query().eq("material_id", standardDto.getId())).stream().map(standard -> {
            String standardName = standard.getName();
            return standardName;
        }).collect(Collectors.toList());
        if (standNameList.contains(standardDto.getStandard())){
            return "该产品下有该标准";
        }
        /*新增标准表*/
        Standard standard = new Standard();
        standard.setMaterial_id(standardDto.getId());
@@ -75,7 +83,17 @@
        /*新增标准BOM-->工艺路线(批量添加)*/
        //查询物料的大类(根据物料id)
        Material material = materialMapper.selectById(standardDto.getId());
        List<TechnologyTemplate> technologyTemplateList = technologyTemplateMapper.selectList(Wrappers.<TechnologyTemplate>query().eq("type", material.getFather()));
        Integer type = null;
        if (material.getFather().equals("橡胶连接器")){
            type=0;
        }else if (material.getFather().equals("金属连接器")){
            type=1;
        }else if(material.getFather().equals("湿插拔电连接器")){
            type=2;
        }else if(material.getFather().equals("分支组件")){
            type=3;
        }else return "添加标准【" + standardDto.getStandard() + "】成功";
        List<TechnologyTemplate> technologyTemplateList = technologyTemplateMapper.selectList(Wrappers.<TechnologyTemplate>query().eq("type", type));
        List<Technology> technologyList = technologyTemplateList.stream().map(technologyTemplate -> {
            Technology technology = new Technology();
            technology.setSpecificationsId(specifications.getId());
@@ -139,6 +157,7 @@
            }
        }
        techniqueService.saveBatch(techniqueList);
        return "添加标准【"+ standardDto.getStandard() +"】成功!";
    }
}