|
@@ -69,7 +69,6 @@ public class MaterialServiceImpl implements MaterialService {
|
|
|
material.setMaterialCode(req.getMaterialCode());
|
|
|
material.setMaterialName(req.getMaterialName());
|
|
|
material.setMaterialType(req.getMaterialType());
|
|
|
- material.setBrandCode(req.getBrandCode());
|
|
|
material.setDescription(req.getDescription());
|
|
|
baseMaterialMapper.insert(material);
|
|
|
|
|
@@ -88,7 +87,6 @@ public class MaterialServiceImpl implements MaterialService {
|
|
|
//2-修改物料
|
|
|
material.setMaterialName(req.getMaterialName());
|
|
|
material.setMaterialType(req.getMaterialType());
|
|
|
- material.setBrandCode(req.getBrandCode());
|
|
|
material.setDescription(req.getDescription());
|
|
|
material.setValid(req.getValid());
|
|
|
baseMaterialMapper.updateById(material);
|
|
@@ -127,14 +125,8 @@ public class MaterialServiceImpl implements MaterialService {
|
|
|
BaseMaterial material = baseMaterialMapper.selectById(req.getId());
|
|
|
AssertUtil.isNull(material, "物料不存在");
|
|
|
|
|
|
- //2-查询父类品牌(前台需要)
|
|
|
- BaseBrand parentBrand = getBrand(material.getBrandCode());
|
|
|
- String parentBrandCode = parentBrand.getParentBrandCode();
|
|
|
- List<String> brandCodeList = Arrays.asList(parentBrandCode, material.getBrandCode());
|
|
|
-
|
|
|
//转化出参
|
|
|
GetMaterialRes res = PojoConverterUtils.copy(material, GetMaterialRes.class);
|
|
|
- res.setBrandCodeList(brandCodeList);
|
|
|
|
|
|
return res;
|
|
|
|
|
@@ -186,21 +178,6 @@ public class MaterialServiceImpl implements MaterialService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 查询品牌信息
|
|
|
- * @param brandCode
|
|
|
- * @return
|
|
|
- */
|
|
|
- private BaseBrand getBrand(String brandCode){
|
|
|
- QueryWrapper<BaseBrand> brandQw = new QueryWrapper<>();
|
|
|
- brandQw.eq("brand_code",brandCode);
|
|
|
- brandQw.eq("is_delete",0);
|
|
|
- BaseBrand baseBrand = baseBrandMapper.selectOne(brandQw);
|
|
|
- AssertUtil.isNull(baseBrand,"品牌不存在");
|
|
|
-
|
|
|
- return baseBrand;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 下拉选择物料列表
|
|
|
**/
|
|
@@ -220,56 +197,8 @@ public class MaterialServiceImpl implements MaterialService {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 下拉选择品牌列表
|
|
|
- **/
|
|
|
- @Override
|
|
|
- public ListBrandForSelectRes listBrandForSelect(ListBrandForSelectReq req) {
|
|
|
- //1-查询所有品牌
|
|
|
- QueryWrapper<BaseBrand> baseBrandQw = new QueryWrapper<>();
|
|
|
- baseBrandQw.eq("is_delete",0);
|
|
|
- List<BaseBrand> baseBrandList = baseBrandMapper.selectList(baseBrandQw);
|
|
|
-
|
|
|
- //出参列表
|
|
|
- List<ListBrandForSelectRes.BrandBean> brandBeanList = new ArrayList<>();
|
|
|
-
|
|
|
- //2-构造树形结构
|
|
|
- //定义map用来存放父类bean
|
|
|
- Map<String,ListBrandForSelectRes.BrandBean> brandBeanMap = new HashMap<>();
|
|
|
- //分一级和二级两组
|
|
|
- List<BaseBrand> l1BrandList = baseBrandList.stream().filter(brand -> brand.getBrandLevel() == 1).collect(Collectors.toList());
|
|
|
- List<BaseBrand> l2BrandList = baseBrandList.stream().filter(brand -> brand.getBrandLevel() == 2).collect(Collectors.toList());
|
|
|
- //循环放入一级
|
|
|
- for(BaseBrand brand:l1BrandList){
|
|
|
- ListBrandForSelectRes.BrandBean brandBean = new ListBrandForSelectRes.BrandBean();
|
|
|
- brandBean.setBrandCode(brand.getBrandCode());
|
|
|
- brandBean.setBrandName(brand.getBrandName());
|
|
|
- brandBean.setSubBrandBeanList(new ArrayList<>());
|
|
|
- //放入出参列表
|
|
|
- brandBeanList.add(brandBean);
|
|
|
- //放入map
|
|
|
- brandBeanMap.put(brandBean.getBrandCode(),brandBean);
|
|
|
- }
|
|
|
- //循环放入二级
|
|
|
- for(BaseBrand brand:l2BrandList){
|
|
|
- ListBrandForSelectRes.BrandBean parentBrandBean = brandBeanMap.get(brand.getParentBrandCode());
|
|
|
- if(parentBrandBean==null){
|
|
|
- continue;
|
|
|
- }
|
|
|
- //构建bean
|
|
|
- ListBrandForSelectRes.BrandBean brandBean = new ListBrandForSelectRes.BrandBean();
|
|
|
- brandBean.setBrandCode(brand.getBrandCode());
|
|
|
- brandBean.setBrandName(brand.getBrandName());
|
|
|
- //加入子品牌
|
|
|
- parentBrandBean.getSubBrandBeanList().add(brandBean);
|
|
|
- }
|
|
|
|
|
|
- //构造出参
|
|
|
- ListBrandForSelectRes res = new ListBrandForSelectRes();
|
|
|
- res.setBrandBeanList(brandBeanList);
|
|
|
|
|
|
- return res;
|
|
|
- }
|
|
|
|
|
|
|
|
|
}
|