Sfoglia il codice sorgente

供应商资源库接口修改,企业列表没有物料也列出来

dongbw 8 anni fa
parent
commit
15206404b3

+ 15 - 103
src/main/java/com/uas/platform/b2b/service/impl/VendorsServiceImpl.java

@@ -321,8 +321,10 @@ public class VendorsServiceImpl implements VendorService {
             // 设置测试企业 - 优软测试二
             enUU = 10030994L;
         }
-        if (StringUtils.isEmpty(productMatchCondition)) {
+        if (StringUtils.isEmpty(productMatchCondition) || productMatchCondition.contains("1=1")) {
 			productMatchCondition = " 1=1 ";
+		} else {
+        	productMatchCondition = productMatchCondition + " and pr_issale = 1 and pr_b2bdisabled <> 1";
 		}
 		if (StringUtils.isEmpty(enterpriseMatchCondition)) {
 			enterpriseMatchCondition = " 1=1 ";
@@ -330,19 +332,19 @@ public class VendorsServiceImpl implements VendorService {
 		// 查询所有的企业信息
 		StringBuffer enterpriseSql = new StringBuffer();
 		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 from sec$enterprises left join v$products on en_uu = pr_enuu  where ").append(productMatchCondition).append(" and pr_issale = 1 and pr_b2bdisabled <> 1 " +
-				" and en_uu <> ").append(enUU).append(" and en_name not like '%测试%' and 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");
+				" select en_uu, count(1) as counts from sec$enterprises left join v$products on en_uu = pr_enuu where ").append(productMatchCondition).append(" and en_uu <> ")
+				.append(enUU).append(" and en_name not like '%测试%' and 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");
 		// rownum 控制
 		String rownumSql = ") t where rownum <= " + page * size + ") s where r1 > " + (page - 1) * size;
 		// 查找非供应商的卖当前商品的企业UU
 		StringBuffer vendorRecommendUusSql = new StringBuffer();
-		vendorRecommendUusSql.append("select s.*,( select wm_concat(pr_title || (case when pr_brand is not null then '(' || pr_brand || ')' else ' ' end)) from v$products where pr_enuu=en_uu and ").append(productMatchCondition)
-				.append(" and rownum<5 ) productInfo, (select 1 from purc$vendors where ve_vendenuu = en_uu and ve_myenuu = ")
+		vendorRecommendUusSql.append("select s.*,( select wm_concat(pr_title || (case when pr_brand is not null then '(' || pr_brand || ')' else ' ' end)) from v$products where pr_enuu=en_uu and ")
+				.append(productMatchCondition).append(" and pr_issale = 1 and pr_b2bdisabled <> 1  and rownum<5 ) productInfo, (select 1 from purc$vendors where ve_vendenuu = en_uu and ve_myenuu = ")
 				.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_issale = 1 and pr_b2bdisabled <> 1 and en_name not like '%测试%' and en_name not like '%test%' and en_uu <> ")
+				" v$products on en_uu = pr_enuu where 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());
@@ -352,97 +354,6 @@ public class VendorsServiceImpl implements VendorService {
 		return new com.uas.account.support.Page<VendorRecommend>(page, size, vendorRecommends, total);
 	}
 
-//	/**
-//	 * 组装物料匹配条件
-//	 * @param enUU  企业UU
-//	 * @param productMatchCondition 物料模糊匹配条件
-//	 * @param productCondition 物料精确匹配条件
-//	 * @return
-//	 */
-//	private String concatProductCondition(Long enUU, String productMatchCondition, String productCondition) {
-//		// 先查询当前企业的采购物料(待购&&不在售)的标准物料标准料号
-//		StringBuffer productMatchSql = new StringBuffer();
-//		if (null != productMatchCondition && !"".equals(productMatchCondition)) {
-//			productMatchSql.append(" and ").append(productMatchCondition);
-//		}
-//		// productCondition 不为空时,使用其中条件进行精确匹配
-//		if (null != productCondition && !"".equals(productCondition)) {
-//			JSONObject prodCondition = JSON.parseObject(productCondition);
-//			String code = (String) prodCondition.get("pr_code");
-//			String title = (String) prodCondition.get("pr_title");
-//			String spec = (String) prodCondition.get("pr_spec");
-//			if (null != code && !"".equals(code)) {
-//				List<Product> products = productDao.findByEnUUAndCode(enUU, code);
-//				// 已上传的,标准物料使用原厂型号精确匹配,并根据物料名称模糊搜索, 非标物料使用物料名称模糊搜索
-//				if (!CollectionUtils.isEmpty(products)) {
-//					Product product = products.get(0);
-//					productMatchSql.append(" and pr.pr_title like '%").append(product.getTitle()).append("%' ");
-//					if (product.getStandard() == 1) {
-//						productMatchSql.append(" and pr.pr_cmpcode = ").append(product.getCmpCode());
-//					}
-//				} else {
-//					if (null != title && !"".equals(title)) {
-//						productMatchSql.append(" and pr.pr_title like '%").append(title).append("%' ");
-//					}
-//				}
-//			} else if (null != title && !"".equals(title)) {
-//				productMatchSql.append(" and pr.pr_title like '%").append(title).append("%' ");
-//			} else if (null != spec && !"".equals(spec)) {
-//				productMatchSql.append(" and pr.pr_spec like '%").append(spec).append("%' ");
-//			}
-//		}
-//		return productMatchSql.toString();
-//	}
-
-//	/**
-//	 * 根据供应商UU返回供应商推荐信息列表
-//	 * @param enUU 本企业UU
-//	 * @param vendorRecommends 供应商推荐实体 ,仅包含enuu和hitNums
-//	 * @param page 页数
-//	 * @param size 每页条数
-//	 * @param total 总条数
-//	 * @return 供应商推荐page
-//	 */
-//	private com.uas.account.support.Page<VendorRecommend> getVendorRecommendByVendUUs(Long enUU, List<VendorRecommend> vendorRecommends, int page, int size, Integer total) {
-//		long start = System.currentTimeMillis();
-//		List<VendorRecommend> content = new ArrayList<>();
-//		for (VendorRecommend vendorRecommend : vendorRecommends) {
-//            Long vendUU = vendorRecommend.getEn_uu();
-//            Enterprise enterprise = enterPriseDao.findOne(vendorRecommend.getEn_uu());
-//		    if (null != enterprise) {
-//                vendorRecommend = covert(enterprise, vendorRecommend);
-//                content.add(vendorRecommend);
-//            }
-//		}
-//		System.out.println("处理完所有数据:" + (System.currentTimeMillis() - start));
-//		// 返回分页信息
-//		return new com.uas.account.support.Page<VendorRecommend>(page, size, content, total);
-//	}
-//
-//	/**
-//	 * 企业信息转换为推荐供应商信息
-//	 * @param enterprise 企业信息
-//     * @param vendorRecommend 包含enuu 和hitNums 的供应商推荐信息
-//	 * @return
-//	 */
-//	private VendorRecommend covert(Enterprise enterprise, VendorRecommend vendorRecommend) {
-//		vendorRecommend.setEn_address(enterprise.getEnAddress());
-//		vendorRecommend.setEn_businesscode(enterprise.getEnBussinessCode());
-//		vendorRecommend.setEn_contactman(enterprise.getContactMan());
-//		vendorRecommend.setEn_contacttel(enterprise.getContactTel());
-//		vendorRecommend.setEn_corporation(enterprise.getEnCorporation());
-//		vendorRecommend.setEn_email(enterprise.getEnEmail());
-//		vendorRecommend.setEn_name(enterprise.getEnName());
-//		vendorRecommend.setEn_profession(enterprise.getProfession());
-//		vendorRecommend.setEn_shortname(enterprise.getEnShortname());
-//		vendorRecommend.setEn_tags(enterprise.getTags());
-//		vendorRecommend.setEn_tel(enterprise.getEnTel());
-//		vendorRecommend.setEn_uu(enterprise.getUu());
-//		if (!StringUtils.isEmpty(vendorRecommend.getProductInfo())) {
-//			vendorRecommend.setProductInfo(vendorRecommend.getProductInfo().replace("()", " "));
-//		}
-//		return vendorRecommend;
-//	}
 
 	/**
 	 * 获取推荐企业物料列表(匹配到的排前面)
@@ -476,12 +387,12 @@ public class VendorsServiceImpl implements VendorService {
 			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(null != whereCondition ? whereCondition : "").append(" order by pr_code desc)");
+					.append(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(null != whereCondition ? whereCondition : "").append(" order by pr_code desc)");
+					.append(whereCondition).append(" order by pr_code desc)");
 			// 物料id
 			StringBuffer idSql = new StringBuffer();
 			// rownum 控制
@@ -504,9 +415,10 @@ public class VendorsServiceImpl implements VendorService {
 			}
 			System.out.println("返回数据:" + (System.currentTimeMillis() - start));
 		} else {
-			String prodSql = "select a.* from (select t.*,rownum as r1 from (select pr_id id, pr_code code, pr_title title, pr_spec spec, pr_cmpcode cmpCode, pr_unit unit, pr_kind kind, " +
-					"pr_minpack minPack, pr_minOrder minOrder, pr_brand brand, pr_standard standard from v$products where pr_b2bdisabled <> 1 and pr_issale = 1 and pr_enuu = " + vendUU + " and " +
-					whereCondition + " order by pr_standard desc, pr_id desc) t where rownum <= " + page * size + ") a where r1 > " + (page - 1) * size;
+			String prodSql = "select a.* from (select t.*,rownum as r1 from (select pr_id id, pr_code code, pr_title title, pr_spec spec, pr_cmpcode cmpCode, pr_unit unit, pr_kind kind, "
+					+ "pr_minpack minPack, pr_minOrder minOrder, pr_brand brand, pr_standard standard, pr_issale isSale, pr_ispurchase isPurchase from v$products where pr_enuu = "
+					+ vendUU + " and pr_issale = 1 and pr_b2bdisabled <> 1 and " + whereCondition
+					+ " order by pr_issale desc, pr_standard desc, pr_id desc) t where rownum <= " + page * size + ") a where r1 > " + (page - 1) * size;
 			System.out.println("无UU:" + prodSql);
 			products = commonDao.query(prodSql, Product.class);