|
|
@@ -317,38 +317,47 @@ public class VendorsServiceImpl implements VendorService {
|
|
|
@Override
|
|
|
public com.uas.sso.support.Page<VendorRecommend> getVendorRecommend(Long enUU, String productMatchCondition, String enterpriseMatchCondition, int page, int size) {
|
|
|
long start = System.currentTimeMillis();
|
|
|
-// final Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
if (null == enUU) {
|
|
|
// 设置不存在的企业
|
|
|
enUU = 0L;
|
|
|
}
|
|
|
- if (StringUtils.isEmpty(productMatchCondition) || productMatchCondition.contains("1=1")) {
|
|
|
- productMatchCondition = " 1=1 ";
|
|
|
- } else {
|
|
|
- productMatchCondition = productMatchCondition + " and pr_issale = 1";
|
|
|
- }
|
|
|
if (StringUtils.isEmpty(enterpriseMatchCondition)) {
|
|
|
enterpriseMatchCondition = " 1=1 ";
|
|
|
}
|
|
|
- // 查询所有的企业信息
|
|
|
- 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, 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 counts desc");
|
|
|
- // rownum 控制
|
|
|
+ // 企业表过滤
|
|
|
+ String enterpriseFilterSql = "(select en_uu from sec$enterprises where " + enterpriseMatchCondition + " and en_uu <> " + enUU + " and en_name not like '%测试%' and en_name not like '%test%') e";
|
|
|
+ // 查询所有的企业信息
|
|
|
+ StringBuilder enterpriseSql = new StringBuilder();
|
|
|
+ String productFilterSql;
|
|
|
+ StringBuilder totalSql = new StringBuilder();
|
|
|
+ // 物料无过滤条件时,直接关联速度更快, 而存在过滤条件时,先过滤在关联速度更快
|
|
|
+ if (StringUtils.isEmpty(productMatchCondition) || productMatchCondition.contains("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" +
|
|
|
+ " ) 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)
|
|
|
+ .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;
|
|
|
// 查找非供应商的卖当前商品的企业UU
|
|
|
- StringBuffer vendorRecommendUusSql = new StringBuffer();
|
|
|
- // and instr(Pr_Title,'测试')<1 and instr(lower(Pr_Title),'test')<1
|
|
|
+ StringBuilder vendorRecommendUusSql = new StringBuilder();
|
|
|
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 " +
|
|
|
- " products on en_uu = pr_enuu where en_name not like '%测试%' and lower(en_name) not like '%test%' and en_uu <> ")
|
|
|
- .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);
|
|
|
+ System.out.println("拼接完语句" + (System.currentTimeMillis() - start));
|
|
|
+ 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= "
|
|
|
@@ -383,7 +392,6 @@ public class VendorsServiceImpl implements VendorService {
|
|
|
System.out.println("进入方法:" + System.currentTimeMillis());
|
|
|
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 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%' ");
|