Browse Source

供应商资源库接口按需优化

dongbw 8 years ago
parent
commit
ecd9bf84fe

+ 12 - 0
src/main/java/com/uas/platform/b2b/dao/ProductDao.java

@@ -190,6 +190,18 @@ public interface ProductDao extends JpaSpecificationExecutor<Product>, JpaReposi
      */
     public List<Product> findByTitleAndCmpCodeAndBrandAndEnUU(String title, String cmpcode, String brand, Long enUU);
 
+	/**
+	 * 通过企业UU,物料名称、规格、品牌(非标准)、型号
+	 *
+	 * @param enUU 企业uu
+	 * @param title  名称
+	 * @param spec 规格
+	 * @param cmpcode 型号
+	 * @param brand 品牌
+	 * @return
+	 */
+	public List<Product> findByTitleAndSpecAndCmpCodeAndBrandAndEnUU(String title, String spec, String cmpcode, String brand, Long enUU);
+
     /**
      * 通过企业UU,物料名称、规格、品牌(标准)
      * 

+ 11 - 0
src/main/java/com/uas/platform/b2b/model/ProductUsers.java

@@ -64,6 +64,17 @@ public class ProductUsers implements Serializable {
     @Column(name = "pu_erpid")
     private Long erpid;
 
+    public ProductUsers() {
+
+    }
+
+    public ProductUsers(Long prId, Long enUU, Long userUU, Date date) {
+        this.setPrid(prId);
+        this.setEnuu(enUU);
+        this.setUseruu(userUU);
+        this.setDate(date);
+    }
+
     public Long getId() {
         return id;
     }

+ 1 - 0
src/main/java/com/uas/platform/b2b/ps/ProductUtils.java

@@ -125,6 +125,7 @@ public class ProductUtils {
     public static ModelMap updateProdInfoAndAddToProductUser(List<Product> products) throws Exception {
         ModelMap map = new ModelMap();
         String res = HttpUtil.doPost(PRODUCT_PUBLIC_SERVICE_URL + "/product/update/addToProductUser", FlexJsonUtils.toJsonDeep(products));
+        System.out.println("批量更新并加入个人物料库 res:" + res);
         JSONObject response = JSON.parseObject(res);
         if ("true".equals(response.get("success"))) {
             map.put("success", "true");

+ 2 - 2
src/main/java/com/uas/platform/b2b/service/impl/BaseInfoServiceImpl.java

@@ -336,7 +336,7 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 				if ("true".equals(map.get("success"))) {
 					modelMap.put("success", null != map.get("result") ? map.get("result") : 0);
 				} else {
-					modelMap.put("error", "物料添加失败(" + null != map.get("message") ? map.get("message") : "" + ")");
+					modelMap.put("error", "物料添加出现异常(" + null != map.get("message") ? map.get("message") : "" + ")");
 				}
 //                start = System.currentTimeMillis();
 //                if (!CollectionUtils.isEmpty(idList)) {
@@ -350,7 +350,7 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 //                    }
 //                }
 			} catch (Exception e) {
-				modelMap.put("error", "物料添加失败(" + e.getMessage() + ")");
+				modelMap.put("error", "物料添加出现异常(" + e.getMessage() + ")");
 			}
         }
     }

+ 2 - 2
src/main/java/com/uas/platform/b2b/service/impl/PurcProductServiceImpl.java

@@ -244,7 +244,7 @@ public class PurcProductServiceImpl implements PurcProductService {
                 if ("true".equals(map.get("success"))) {
                     modelMap.put("success", null != map.get("result") ? map.get("result") : 0);
                 } else {
-                    modelMap.put("error", "物料添加失败(" + null != map.get("message") ? map.get("message") : "" + ")");
+                    modelMap.put("error", "物料添加出现异常(" + null != map.get("message") ? map.get("message") : "" + ")");
                 }
 //                start = System.currentTimeMillis();
 //                if (!CollectionUtils.isEmpty(idList)) {
@@ -258,7 +258,7 @@ public class PurcProductServiceImpl implements PurcProductService {
 //                    }
 //                }
             } catch (Exception e) {
-                modelMap.put("error", "物料添加失败(" + e.getMessage() + ")");
+                modelMap.put("error", "物料添加出现异常(" + e.getMessage() + ")");
             }
         }
     }

+ 5 - 7
src/main/java/com/uas/platform/b2b/service/impl/VendorsServiceImpl.java

@@ -432,11 +432,10 @@ public class VendorsServiceImpl implements VendorService {
                 if (null != vendorRecommend.getHitNums() && vendorRecommend.getHitNums() > 0) {
                     StringBuffer productInfosSql = new StringBuffer();
 //                    StringBuffer productNumSql = new StringBuffer();
-                    productInfosSql.append("select wm_concat(pr_title || '(' || pr_brand || ')') productInfo from v$products pr where pr.pr_enuu = ").append(vendUU)
-                            .append(" and pr.pr_issale =1 and exists (select 1 from v$products p1 " +
-                                    " where p1.pr_cmpcode = pr.pr_cmpcode and p1.pr_ispurchase = 1 and nvl(pr_issale, 0) <> 1 " +
-                                    " and p1.pr_b2bdisabled <> 1 and p1.pr_enuu = ")
-                            .append(enUU).append(") and rownum <= 5 order by pr_standard,pr_id desc");
+                    productInfosSql.append("select wm_concat(pr_title || '(' || pr_brand || ')') productInfo from (select pr_title,pr_brand from v$products pr where pr.pr_enuu = ")
+							.append(vendUU).append(" and pr.pr_issale =1 and exists (select 1 from v$products p1 where p1.pr_cmpcode = pr.pr_cmpcode and p1.pr_ispurchase = 1 " +
+							"and nvl(pr_issale, 0) <> 1 and p1.pr_b2bdisabled <> 1 and p1.pr_enuu = ").append(enUU).append(") order by pr_standard desc,pr_id desc) where rownum <= 5");
+					System.out.println("wm_concat:" + productInfosSql.toString());
 //                    productNumSql.append("select count(1) from v$products pr where pr.pr_enuu = ").append(vendUU)
 //                            .append(" and pr.pr_issale =1 and exists (select 1 from v$products p1 " +
 //                                    " where p1.pr_cmpcode = pr.pr_cmpcode and p1.pr_ispurchase = 1 and nvl(pr_issale, 0) <> 1 " +
@@ -447,7 +446,7 @@ public class VendorsServiceImpl implements VendorService {
                     // 获取前五条匹配物料
                     String productInfo = commonDao.queryForObject(productInfosSql.toString(), String.class);
 //                    Integer hitNums = commonDao.queryForObject(productNumSql.toString(), Integer.class);
-                    vendorRecommend.setProductInfo(productInfo);
+                    vendorRecommend.setProductInfo(productInfo.replace("()", ""));
 //                    vendorRecommend.setHitNums(hitNums);
                 }
                 List<Vendor> vendors = vendorDao.findByMyEnUUAndVendUU(enUU, vendUU);
@@ -530,7 +529,6 @@ public class VendorsServiceImpl implements VendorService {
 				.append(")").append(rownumSql);
 //		System.out.println(idSql.toString());
 //        System.out.println(productsMatchSql.toString());
-//        System.out.println(countSql.toString());
 		List<Long> matchedIds = commonDao.queryForList(productsMatchSql.toString(), Long.class);
 		Integer count = commonDao.queryForObject(countSql, Integer.class);
 		List<Long> ids = commonDao.queryForList(idSql.toString(), Long.class);