浏览代码

新增根据物料型号和品牌获取类目信息的接口

dongbw 7 年之前
父节点
当前提交
bc09d6e809

+ 20 - 0
src/main/java/com/uas/ps/product/controller/ProductUsersController.java

@@ -239,4 +239,24 @@ public class ProductUsersController {
             throw new RuntimeException("根据企业UU和物料原厂型号cmpCode获取个人产品库信息失败");
             throw new RuntimeException("根据企业UU和物料原厂型号cmpCode获取个人产品库信息失败");
         }
         }
     }
     }
+
+    /**
+     * 根据品牌和型号,返回类目
+     * @param brand 品牌
+     * @param cmpCode  物料型号
+     * @return 物料类目
+     */
+    @HttpLog
+    @RequestMapping(value = "/match/getKind", method = RequestMethod.GET)
+    public String getKindByCmpCodeAndBrand(@RequestParam String cmpCode, @RequestParam String brand) {
+        String kind = "";
+        try {
+            kind = productService.getKindByCmpCodeAndBrand(cmpCode, brand);
+            logger.log("成功", "根据品牌和型号获取类目成功", null, null, null, null);
+        } catch (Exception e) {
+            e.printStackTrace();
+            logger.log("失败", "根据品牌和型号获取类目失败", null, null, null, null);
+        }
+        return kind;
+    }
 }
 }

+ 8 - 0
src/main/java/com/uas/ps/product/service/ProductService.java

@@ -232,4 +232,12 @@ public interface ProductService {
      * @return 处理结果
      * @return 处理结果
      */
      */
     ModelMap saveInquiryProducts(Product product);
     ModelMap saveInquiryProducts(Product product);
+
+    /**
+     * 根据品牌和型号,返回类目
+     * @param brand 品牌
+     * @param cmpCode  物料型号
+     * @return 物料类目
+     */
+    String getKindByCmpCodeAndBrand(String cmpCode, String brand);
 }
 }

+ 24 - 0
src/main/java/com/uas/ps/product/service/impl/ProductServiceImpl.java

@@ -354,6 +354,30 @@ public class ProductServiceImpl implements ProductService {
         return map;
         return map;
     }
     }
 
 
+    /**
+     * 根据品牌和型号,返回类目
+     *
+     * @param cmpCode 物料型号
+     * @param brand   品牌
+     * @return 物料类目
+     */
+    @Override
+    public String getKindByCmpCodeAndBrand(String cmpCode, String brand) {
+        String kind = "";
+        // 获取品牌
+        String brandUrl = urlProperties.getB2cUrl() + "/api/product/brand/byName/brand?name=" + brand;
+        BrandInfo brandInfo = restTemplate.getForEntity(brandUrl, BrandInfo.class).getBody();
+        if (brandInfo.getUuid() != null) {
+            String componentUrl = urlProperties.getB2cUrl() + "/api/product/component/codeAndBrand/info?brandId="
+                    + brandInfo.getId() + "&cmpCode=" + cmpCode;
+            ComponentInfo component = restTemplate.getForEntity(componentUrl, ComponentInfo.class).getBody();
+            if (null != component.getKind()) {
+                kind = component.getKind().getNameCn();
+            }
+        }
+        return kind;
+    }
+
     /**
     /**
      * 更新物料信息
      * 更新物料信息
      * @param data 物料资料
      * @param data 物料资料