|
|
@@ -329,25 +329,19 @@ public class VendorsServiceImpl implements VendorService {
|
|
|
// 查询所有的企业信息
|
|
|
StringBuilder enterpriseSql = new StringBuilder();
|
|
|
String productFilterSql;
|
|
|
- StringBuilder totalSql = new StringBuilder();
|
|
|
// 物料无过滤条件时,直接关联速度更快, 而存在过滤条件时,先过滤在关联速度更快
|
|
|
if (StringUtils.isEmpty(productMatchCondition) || productMatchCondition.contains("1=1")) {
|
|
|
+ productMatchCondition = " 1=1 ";
|
|
|
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 ").append(enterpriseFilterSql)
|
|
|
- .append(" left join products on en_uu = pr_enuu group by en_uu order by count(1) desc" +
|
|
|
+ " en.en_contacttel from sec$enterprises en right join ( select en_uu, count(1) as counts from sec$enterprises inner join products on en_uu = pr_enuu where en_uu <> "
|
|
|
+ + enUU + " and en_name not like '%测试%' and en_name not like '%test%' group by en_uu order by count(1) desc" +
|
|
|
" ) a on en.en_uu = a.en_uu order by counts desc");
|
|
|
- // 因为需求更改为所有有销售产品的企业都会被返回,所以total直接取除本企业外其他有销售产品的企业数即可,之前的匹配企业数不再返回
|
|
|
- totalSql.append(" select count(1) from (select en_uu from sec$enterprises left join " +
|
|
|
- " 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) a");
|
|
|
} else {
|
|
|
// 物料过滤
|
|
|
productFilterSql = "(select pr_enuu from products where " + productMatchCondition + ") p";
|
|
|
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 ").append(enterpriseFilterSql).append(" left join ").append(productFilterSql)
|
|
|
+ " en.en_contacttel from sec$enterprises en right join ( select en_uu, count(1) as counts from ").append(enterpriseFilterSql).append(" inner join ").append(productFilterSql)
|
|
|
.append(" on e.en_uu = p.pr_enuu group by en_uu order by count(1) desc) a on en.en_uu = a.en_uu order by counts desc");
|
|
|
- totalSql.append(" select count(1) from ( select en_uu from ").append(enterpriseFilterSql).append(" left join ").append(productFilterSql)
|
|
|
- .append(" on e.en_uu = p.pr_enuu group by en_uu) a");
|
|
|
}
|
|
|
// 分页控制
|
|
|
String rownumSql = ") s limit " + (page - 1) * size + "," + size;
|
|
|
@@ -356,7 +350,10 @@ public class VendorsServiceImpl implements VendorService {
|
|
|
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);
|
|
|
System.out.println("拼接完语句" + (System.currentTimeMillis() - start));
|
|
|
- Integer total = commonDao.queryForObject(totalSql.toString(), Integer.class);
|
|
|
+ String totalSql = " select count(1) from (select distinct(en_uu) from sec$enterprises inner join " +
|
|
|
+ " products on en_uu = pr_enuu where en_name not like '%测试%' and en_name not like '%test%' and en_uu <> " +
|
|
|
+ enUU + " and " + productMatchCondition + " and " + enterpriseMatchCondition + ") a";
|
|
|
+ Integer total = commonDao.queryForObject(totalSql, Integer.class);
|
|
|
List<VendorRecommend> vendorRecommends = commonDao.query(vendorRecommendUusSql.toString(), VendorRecommend.class);
|
|
|
long start1 = System.currentTimeMillis();
|
|
|
for (VendorRecommend vendorRecommend : vendorRecommends) {
|