Browse Source

Merge branch 'feature-vendor-source-dongbw' into dev

dongbw 7 years ago
parent
commit
0a49c87046
1 changed files with 13 additions and 10 deletions
  1. 13 10
      src/main/java/com/uas/platform/b2b/service/impl/VendorsServiceImpl.java

+ 13 - 10
src/main/java/com/uas/platform/b2b/service/impl/VendorsServiceImpl.java

@@ -320,7 +320,7 @@ public class VendorsServiceImpl implements VendorService {
 //		final Long enUU = SystemSession.getUser().getEnterprise().getUu();
         if (null == enUU) {
             // 设置不存在的企业
-            enUU = 100411660L;
+            enUU = 0L;
         }
         if (StringUtils.isEmpty(productMatchCondition) || productMatchCondition.contains("1=1")) {
 			productMatchCondition = " 1=1 ";
@@ -335,15 +335,13 @@ public class VendorsServiceImpl implements VendorService {
 		enterpriseSql.append("select en.en_uu, en.en_name, en.en_shortname, en.en_address, en.en_tel, en.en_email, en.en_corporation, en.en_businesscode, en.en_profession, en.en_tags, en.en_contactman, en.en_contacttel from sec$enterprises en right join (" +
 				" select en_uu, count(1) as counts from sec$enterprises left join products on en_uu = pr_enuu where ").append(productMatchCondition).append(" and en_uu <> ")
 				.append(enUU).append(" and en_name not like '%测试%' and lower(en_name) not like '%test%' and ").append(enterpriseMatchCondition).append(" group by en_uu order by count(1) desc" +
-				" ) a on en.en_uu = a.en_uu order by en.en_weight desc, counts desc");
+				" ) a on en.en_uu = a.en_uu order by counts desc");
 		// rownum 控制
 		String rownumSql = ") s limit " + (page - 1) * size + "," + size;
 		// 查找非供应商的卖当前商品的企业UU
 		StringBuffer vendorRecommendUusSql = new StringBuffer();
 		// and instr(Pr_Title,'测试')<1 and instr(lower(Pr_Title),'test')<1
-		vendorRecommendUusSql.append("select s.*,( select group_concat(pr_title , (case when pr_brand is not null then concat('(', pr_brand, ')') else ' ' end)) from v$products where pr_enuu=en_uu and ")
-				.append(productMatchCondition).append(" and pr_issale = 1 and pr_b2bdisabled <> 1 limit 0,5 " +
-				" ) productInfo, (select 1 from purc$vendors where ve_vendenuu = en_uu and ve_myenuu = ").append(enUU)
+		vendorRecommendUusSql.append("select s.*, (select 1 from purc$vendors where ve_vendenuu = en_uu and ve_myenuu = ").append(enUU)
 				.append(") isVendor from (").append(enterpriseSql).append(rownumSql);
 		// 因为需求更改为所有有销售产品的企业都会被返回,所以total直接取除本企业外其他有销售产品的企业数即可,之前的匹配企业数不再返回
 		StringBuffer totalSql = new StringBuffer().append(" select count(1) from (select en_uu from sec$enterprises left join " +
@@ -351,6 +349,14 @@ public class VendorsServiceImpl implements VendorService {
 				.append(enUU).append(" and ").append(productMatchCondition).append(" and ").append(enterpriseMatchCondition).append(" group by en_uu) a");
 		Integer total = commonDao.queryForObject(totalSql.toString(), Integer.class);
 		List<VendorRecommend> vendorRecommends = commonDao.query(vendorRecommendUusSql.toString(), VendorRecommend.class);
+		long start1 = System.currentTimeMillis();
+		for (VendorRecommend vendorRecommend : vendorRecommends) {
+			String prodSql = "select group_concat(pr_title , (case when pr_brand is not null then concat('(', pr_brand, ')') else ' ' end)) from (select pr_title, pr_brand from v$products where pr_enuu= "
+					+ vendorRecommend.getEn_uu() + " and pr_issale = 1 and pr_b2bdisabled <> 1 limit 0,5) p";
+			String prodInfo = commonDao.queryForObject(prodSql, String.class);
+			vendorRecommend.setProductInfo(prodInfo);
+		}
+		System.out.println("循环完成" + (System.currentTimeMillis() - start1));
 		System.out.println("查找完企业UU" + (System.currentTimeMillis() - start));
 		return new com.uas.sso.support.Page<VendorRecommend>(page, size, vendorRecommends, total);
 	}
@@ -381,9 +387,6 @@ public class VendorsServiceImpl implements VendorService {
 			StringBuffer cmpCodesSql = new StringBuffer();
 			cmpCodesSql.append("select 1 from v$products where pr_cmpcode = p1.pr_cmpcode and pr_enuu = ")
 					.append(enUU).append(" and ifnull(pr_issale,0) <> 1 and pr_ispurchase = 1 and pr_b2bdisabled <> 1 and Pr_Title not like '%测试%' and Pr_Title not like '%test%' and Pr_code not like '%测试%' and Pr_code not like '%test%' ");
-//			if (null != productMatchCondition) {
-//				cmpCodesSql.append(" and ").append(productMatchCondition);
-//			}
 			// 查找匹配在售物料的语句
 			StringBuffer productsMatchSql = new StringBuffer();
 			productsMatchSql.append("select pr_id from (select pr_id from v$products p1 where exists (").append(cmpCodesSql).append(") and p1.pr_enuu = ").append(vendUU)
@@ -407,8 +410,8 @@ public class VendorsServiceImpl implements VendorService {
 				Product product = productDao.findOne(id);
 				if (matchedIds.contains(id)) {
 					StringBuffer matchCodeSql = new StringBuffer();
-					matchCodeSql.append("select wm_concat(pr_code) from v$products where pr_b2bdisabled <> 1 and pr_enuu = ")
-							.append(enUU).append(" and pr_cmpcode = '").append(product.getCmpCode()).append("'").append(" and rownum <= 5");
+					matchCodeSql.append("select group_concat(pr_code) from (select pr_code from v$products where pr_b2bdisabled <> 1 and pr_enuu = ")
+							.append(enUU).append(" and pr_cmpcode = '").append(product.getCmpCode()).append("'").append(" limit 0,5) p");
 					String matchCodes = commonDao.queryForObject(matchCodeSql.toString(), String.class);
 					product.setIfMatched(matchCodes);
 				}