Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/dev' into dev

hejq 8 anni fa
parent
commit
60a4f56175

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

@@ -308,7 +308,6 @@ public class VendorsServiceImpl implements VendorService {
 	 *
 	 * @param productMatchCondition 物料模糊匹配条件
 	 * @param enterpriseMatchCondition 企业搜索匹配条件
-	 * @param productCondition 物料精确匹配条件
 	 * @param page 页面
 	 * @param size 每页条数
 	 * @return
@@ -339,8 +338,8 @@ public class VendorsServiceImpl implements VendorService {
 				.append(enUU).append(") isVendor from (select t.*,rownum as r1 from (").append(enterpriseSql).append(rownumSql);
 		// 因为需求更改为所有有销售产品的企业都会被返回,所以total直接取除本企业外其他有销售产品的企业数即可,之前的匹配企业数不再返回
 		StringBuffer totalSql = new StringBuffer().append(" select count(1) from (select en_uu from sec$enterprises left join " +
-				" v$products on en_uu = pr_enuu where pr_b2bdisabled <> 1 and en_uu <> ")
-				.append(enUU).append(" group by en_uu)");
+				" v$products on en_uu = pr_enuu where pr_b2bdisabled <> 1 and en_name not like '%测试%' and en_name not like '%test%' and en_uu <> ")
+				.append(enUU).append(" and ").append(productMatchCondition).append(" and ").append(enterpriseMatchCondition).append(" group by en_uu)");
 //        System.out.println("SQL:" + vendorRecommendUusSql.toString());
 //        System.out.println("NUM_SQL:" + totalSql.toString());
 		Integer total = commonDao.queryForObject(totalSql.toString(), Integer.class);
@@ -454,30 +453,31 @@ public class VendorsServiceImpl implements VendorService {
 	@Override
 	public com.uas.account.support.Page<Product> getProductsByVendorRecommend(int page, int size, Long vendUU, String productMatchCondition, String whereCondition) {
 		System.out.println("进入方法:" + System.currentTimeMillis());
+		if (StringUtils.isEmpty(whereCondition)) {
+			whereCondition = " 1 = 1 ";
+		}
 		long start = System.currentTimeMillis();
 		// UAS企业UU
 		Long enUU = SystemSession.getUser().getEnterprise().getUu();
-		// 先查询当前企业的采购物料(待购&&不在售)的标准物料标准料号
 		StringBuffer cmpCodesSql = new StringBuffer();
 		cmpCodesSql.append("select 1 from v$products where pr_cmpcode = p1.pr_cmpcode and pr_enuu = ")
-				.append(enUU).append(" and nvl(pr_issale,0) <> 1 and pr_ispurchase = 1 and pr_b2bdisabled <> 1 ");
+				.append(enUU).append(" and pr_b2bdisabled <> 1 ");
 		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).append(" and p1.pr_issale = 1 and p1.pr_b2bdisabled <> 1 and ")
+				.append(") and p1.pr_enuu = ").append(vendUU).append(" and p1.pr_b2bdisabled <> 1 and ")
 				.append(null != whereCondition ? whereCondition : "").append(" order by pr_code desc)");
 		// 查找不匹配但是在售物料的语句  union all 方便排序
 		StringBuffer notMatchProductsSql = new StringBuffer();
 		notMatchProductsSql.append("select pr_id from (select pr_id from v$products p1 where not exists (").append(cmpCodesSql)
-				.append(") and p1.pr_enuu = ").append(vendUU).append(" and p1.pr_issale = 1 and p1.pr_b2bdisabled <> 1 and ")
+				.append(") and p1.pr_enuu = ").append(vendUU).append(" and p1.pr_b2bdisabled <> 1 and ")
 				.append(null != whereCondition ? whereCondition : "").append(" order by pr_code desc)");
 		// 物料id
 		StringBuffer idSql = new StringBuffer();
-		String countSql = "select count(1) from v$products where pr_enuu = " + vendUU
-				+ " and pr_issale = 1 and pr_b2bdisabled <> 1";
+		String countSql = "select count(1) from v$products where pr_enuu = " + vendUU + " and pr_b2bdisabled <> 1 and " + whereCondition;
 		// rownum 控制
 		String rownumSql = " t where rownum <= " + page * size + ") where r1 > " + (page - 1) * size;
 		idSql.append("select pr_id from (select t.*,rownum as r1 from (").append(productsMatchSql).append(" union all ").append(notMatchProductsSql)
@@ -485,12 +485,14 @@ public class VendorsServiceImpl implements VendorService {
 		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);
+        System.out.println("count:" + countSql);
+        System.out.println("id:" + idSql);
 		List<Product> products = new ArrayList<>();
 		for (Long id : ids) {
 		    Product product = productDao.findOne(id);
 		    if (matchedIds.contains(id)) {
 		    	StringBuffer matchCodeSql = new StringBuffer();
-		    	matchCodeSql.append("select wm_concat(pr_code) from v$products where nvl(pr_issale,0) <> 1 and pr_ispurchase = 1 and pr_b2bdisabled <> 1 and pr_enuu = ")
+		    	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 <= 20");
 		    	String matchCodes = commonDao.queryForObject(matchCodeSql.toString(), String.class);
 		    	product.setIfMatched(matchCodes);