Ver código fonte

公司商机,物料库查询企业UU接口

dongbw 7 anos atrás
pai
commit
cd2e3a6093

+ 14 - 0
src/main/java/com/uas/ps/product/controller/ProductController.java

@@ -522,4 +522,18 @@ public class ProductController {
         }
         return map;
     }
+
+    /**
+     * 根据企业UU和物料原厂型号cmpCode和品牌获取其他有相同物料的企业号
+     *
+     * @param enUU    企业UU
+     * @param pCmpCode 物料原厂型号
+     * @param pBrandEn 品牌
+     * @return 存在相同物料的其他企业UU号
+     */
+    @HttpLog
+    @RequestMapping(value = "/businessOpportunity", method = RequestMethod.GET)
+    public ModelMap getBusinessOpportunity(Long enUU, String pCmpCode, String pBrandEn) {
+        return productService.getBusinessOpportunity(enUU, pCmpCode, pBrandEn);
+    }
 }

+ 21 - 0
src/main/java/com/uas/ps/product/repository/ProductDao.java

@@ -166,6 +166,27 @@ public interface ProductDao extends JpaSpecificationExecutor<Product>, JpaReposi
     @Query("select p from Product p where p.enUU = :enUU and (p.isPurchase <> :switchStatus or p.isSale is null)")
     List<Product> findByEnUUAndNotIsPurchase(@Param("enUU") Long enUU, @Param("switchStatus") Short switchStatus);
 
+    /**
+     * 根据企业UU和物料原厂型号cmpCode和品牌获取其他有相同物料的企业号
+     *
+     * @param enUU    企业UU
+     * @param pCmpCode 物料原厂型号
+     * @param pBrandEn 品牌
+     * @return 存在相同物料的其他企业UU号
+     */
+    @Query(value = "select p.pr_enuu from v$product$private p where p.pr_enuu <> :enUU and p.pr_pcmpcode = :pCmpCode and p.pr_pbranden = :pBrandEn and p.pr_b2cenabled = 1 group by p.pr_enuu", nativeQuery = true)
+    List<Long> getBusinessOpportunityWithPBrandEn(@Param("enUU")Long enUU, @Param("pCmpCode")String pCmpCode, @Param("pBrandEn")String pBrandEn);
+
+    /**
+     * 根据企业UU和物料原厂型号cmpCode和品牌获取其他有相同物料的企业号
+     *
+     * @param enUU    企业UU
+     * @param pCmpCode 物料原厂型号
+     * @return 存在相同物料的其他企业UU号
+     */
+    @Query(value = "select p.pr_enuu from v$product$private p where p.pr_enuu <> :enUU and p.pr_pcmpcode = :pCmpCode and p.pr_b2cenabled = 1 group by p.pr_enuu", nativeQuery = true)
+    List<Long> getBusinessOpportunityWithoutPBrandEn(@Param("enUU")Long enUU, @Param("pCmpCode")String pCmpCode);
+
 //    /**
 //     * 通过uu查询非标准器件进行存储
 //     *

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

@@ -240,4 +240,14 @@ public interface ProductService {
      * @return 物料类目
      */
     String getKindByCmpCodeAndBrand(String cmpCode, String brand);
+
+    /**
+     * 根据企业UU和物料原厂型号cmpCode和品牌获取其他有相同物料的企业号
+     *
+     * @param enUU    企业UU
+     * @param pCmpCode 物料原厂型号
+     * @param pBrandEn 品牌
+     * @return 存在相同物料的其他企业UU号
+     */
+    ModelMap getBusinessOpportunity(Long enUU, String pCmpCode, String pBrandEn);
 }

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

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
 import com.uas.platform.core.util.StringUtil;
 import com.uas.ps.brand.entity.BrandInfo;
 import com.uas.ps.component.entity.ComponentInfo;
+import com.uas.ps.core.util.StringUtils;
 import com.uas.ps.entity.Product;
 import com.uas.ps.entity.ProductMatchResult;
 import com.uas.ps.entity.ProductPrivate;
@@ -405,6 +406,33 @@ public class ProductServiceImpl implements ProductService {
         return kind;
     }
 
+    /**
+     * 根据企业UU和物料原厂型号cmpCode和品牌获取其他有相同物料的企业号
+     *
+     * @param enUU     企业UU
+     * @param pCmpCode 物料原厂型号
+     * @param pBrandEn 品牌
+     * @return 存在相同物料的其他企业UU号
+     */
+    @Override
+    public ModelMap getBusinessOpportunity(Long enUU, String pCmpCode, String pBrandEn) {
+        ModelMap map = new ModelMap();
+        try {
+            List<Long> enUUs;
+            if (!StringUtils.isEmpty(pBrandEn)) {
+                enUUs = productDao.getBusinessOpportunityWithPBrandEn(enUU, pCmpCode, pBrandEn);
+            } else {
+                enUUs = productDao.getBusinessOpportunityWithoutPBrandEn(enUU, pCmpCode);
+            }
+            map.put("enUUs", enUUs);
+            map.put("success", true);
+        } catch (Exception e) {
+            map.put("success", false);
+            map.put("message", e.getMessage());
+        }
+        return map;
+    }
+
     /**
      * 更新物料信息
      * @param data 物料资料