|
@@ -22,6 +22,7 @@ import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* The type VendorIntroductionService.
|
|
* The type VendorIntroductionService.
|
|
|
|
|
+ * @author dongbw
|
|
|
* @version 2018年4月26日 17:25:03
|
|
* @version 2018年4月26日 17:25:03
|
|
|
*/
|
|
*/
|
|
|
@Service
|
|
@Service
|
|
@@ -85,7 +86,7 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
|
|
|
productCondition = "pr_pbranden = '" + keyword + "'";
|
|
productCondition = "pr_pbranden = '" + keyword + "'";
|
|
|
break;
|
|
break;
|
|
|
default :
|
|
default :
|
|
|
- enterpriseCondition = "(en_name like '%" + keyword + "%' or en_address like '%" + keyword + "%' or en_industry like '% "
|
|
|
|
|
|
|
+ enterpriseCondition = "(en_name like '%" + keyword + "%' or en_address like '%" + keyword + "%' or en_industry like '%"
|
|
|
+ keyword + "%')";
|
|
+ keyword + "%')";
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -99,12 +100,16 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
|
|
|
enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
}
|
|
}
|
|
|
// 查询所有企业个数
|
|
// 查询所有企业个数
|
|
|
- Integer total = getTotalCount(enUU, enterpriseCondition, productCondition);
|
|
|
|
|
|
|
+ Integer total;
|
|
|
// 查询企业
|
|
// 查询企业
|
|
|
List<VendorIntroduction> vendorIntroductions;
|
|
List<VendorIntroduction> vendorIntroductions;
|
|
|
if (!StringUtils.isEmpty(productCondition)) {
|
|
if (!StringUtils.isEmpty(productCondition)) {
|
|
|
|
|
+ enterpriseCondition = "(en_name like '%" + keyword + "%' or en_address like '%" + keyword + "%' or en_industry like '% "
|
|
|
|
|
+ + keyword + "%')";
|
|
|
|
|
+ total = getTotalCount(enUU, enterpriseCondition, productCondition);
|
|
|
vendorIntroductions = getEnterpriseWithProductCondition(enUU, enterpriseCondition, productCondition, page, size);
|
|
vendorIntroductions = getEnterpriseWithProductCondition(enUU, enterpriseCondition, productCondition, page, size);
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ total = getTotalCount(enUU, enterpriseCondition, productCondition);
|
|
|
vendorIntroductions = getEnterpriseWithoutProductCondition(enUU, enterpriseCondition, page, size);
|
|
vendorIntroductions = getEnterpriseWithoutProductCondition(enUU, enterpriseCondition, page, size);
|
|
|
}
|
|
}
|
|
|
return new Page<VendorIntroduction>(page, size, vendorIntroductions, total);
|
|
return new Page<VendorIntroduction>(page, size, vendorIntroductions, total);
|
|
@@ -181,12 +186,14 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
|
|
|
private List<VendorIntroduction> getEnterpriseWithProductCondition(Long enUU, String enterpriseCondition, String productCondition, int page, int size) {
|
|
private List<VendorIntroduction> getEnterpriseWithProductCondition(Long enUU, String enterpriseCondition, String productCondition, int page, int size) {
|
|
|
StringBuilder enterpriseSql = new StringBuilder();
|
|
StringBuilder enterpriseSql = new StringBuilder();
|
|
|
// 查询所有符合条件的enUU的语句,按待售物料数量排序
|
|
// 查询所有符合条件的enUU的语句,按待售物料数量排序
|
|
|
- String enUUSql = getEnUUGroupByEnUUOrderByCount(enUU, enterpriseCondition, productCondition);
|
|
|
|
|
|
|
+ String enUUSql = getEnUUGroupByEnUUOrderByCount(enUU, " 1 = 1 ", productCondition);
|
|
|
|
|
+ String noProductenUUSql = getEnUUGroupByEnUUOrderByCount(enUU, enterpriseCondition, null);
|
|
|
// 获取企业sql
|
|
// 获取企业sql
|
|
|
enterpriseSql.append("select en.en_uu enUU, en.en_name enName, en.en_shortname enShortname, st.st_logo_url storeLogoUrl, en.en_logurl enLogoUrl, en.en_address enAddress, en.en_tel enTel, " +
|
|
enterpriseSql.append("select en.en_uu enUU, en.en_name enName, en.en_shortname enShortname, st.st_logo_url storeLogoUrl, en.en_logurl enLogoUrl, en.en_address enAddress, en.en_tel enTel, " +
|
|
|
" en.en_email enEmail, en.en_corporation enCorporation, en.en_businesscode enBusinesscode, en.en_industry enIndustry, en.en_Businessscope enBusinessScope " +
|
|
" en.en_email enEmail, en.en_corporation enCorporation, en.en_businesscode enBusinesscode, en.en_industry enIndustry, en.en_Businessscope enBusinessScope " +
|
|
|
- ",st.st_uuid,st.st_status from sec$enterprises en left join store$info st on st.st_enuu = en.en_uu right join (").append(enUUSql)
|
|
|
|
|
- .append(" ) a on en.en_uu = a.en_uu order by en.en_weight desc, counts desc");
|
|
|
|
|
|
|
+ ",st.st_uuid,st.st_status from sec$enterprises en left join store$info st on st.st_enuu = en.en_uu right join (")
|
|
|
|
|
+ .append(enUUSql).append(" union ").append(noProductenUUSql)
|
|
|
|
|
+ .append(" ) a on en.en_uu = a.en_uu order by en.en_weight desc");
|
|
|
// 查找非供应商的卖当前商品的企业UU
|
|
// 查找非供应商的卖当前商品的企业UU
|
|
|
StringBuilder vendorIntroductionUusSql = new StringBuilder();
|
|
StringBuilder vendorIntroductionUusSql = new StringBuilder();
|
|
|
// 行数 控制
|
|
// 行数 控制
|
|
@@ -230,15 +237,20 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
|
|
|
*/
|
|
*/
|
|
|
private Integer getTotalCount(Long enUU, String enterpriseCondition, String productCondition) {
|
|
private Integer getTotalCount(Long enUU, String enterpriseCondition, String productCondition) {
|
|
|
StringBuilder enCountSql = new StringBuilder();
|
|
StringBuilder enCountSql = new StringBuilder();
|
|
|
- enCountSql.append("select count(1) from (select en_uu,count(1) from (select en_uu from sec$enterprises where en_name not like '%测试%' " +
|
|
|
|
|
|
|
+ enCountSql.append("select count(1) from (select distinct(en_uu) from (select en_uu from sec$enterprises where en_name not like '%测试%' " +
|
|
|
" and en_name not like '%test%' and (length(en_businesscode) > 12 or en_name like '%香港%' or en_name like '%HONG KONG%' " +
|
|
" and en_name not like '%test%' and (length(en_businesscode) > 12 or en_name like '%香港%' or en_name like '%HONG KONG%' " +
|
|
|
" or en_area like '%香港%')and (en_name not REGEXP '^[0-9]*$' and (en_name like '%ltd%' or en_name like '%limited%' or " +
|
|
" or en_area like '%香港%')and (en_name not REGEXP '^[0-9]*$' and (en_name like '%ltd%' or en_name like '%limited%' or " +
|
|
|
- " en_name like '%tcl%' or en_name not regexp '[\\u4e00-\\u9fa5_a-zA-Z0-9]') and ").append(enterpriseCondition).append(") and en_uu <> ")
|
|
|
|
|
- .append(enUU).append(") e ");
|
|
|
|
|
|
|
+ " en_name like '%tcl%' or en_name not regexp '[\\u4e00-\\u9fa5_a-zA-Z0-9]') ) and ");
|
|
|
|
|
+ if (StringUtils.isEmpty(productCondition)) {
|
|
|
|
|
+ enCountSql.append(enterpriseCondition).append(" and ");
|
|
|
|
|
+ }
|
|
|
|
|
+ enCountSql.append(" en_uu <> ").append(enUU).append(") e ");
|
|
|
if (!StringUtils.isEmpty(productCondition)) {
|
|
if (!StringUtils.isEmpty(productCondition)) {
|
|
|
- enCountSql.append("right join ( select pr_enuu from v$product$private where ").append(productCondition).append(") p on pr_enuu = en_uu");
|
|
|
|
|
|
|
+ enCountSql.append("right join ( select pr_enuu from products where ").append(productCondition).append(") p on pr_enuu = en_uu");
|
|
|
|
|
+ enCountSql.append(" union select en_uu from sec$enterprises where en_name not like '%测试%' and en_name not like '%test%' and (length(en_businesscode) > 12 or en_name like '%香港%' or en_name like '%HONG KONG%' or en_area like '%香港%')and (en_name not REGEXP '^[0-9]*$' and (en_name like '%ltd%' or en_name like '%limited%' or en_name like '%tcl%' or en_name not regexp '[\\u4e00-\\u9fa5_a-zA-Z0-9]') and ")
|
|
|
|
|
+ .append(enterpriseCondition).append(" and en_uu <> ").append(enUU).append(")");
|
|
|
}
|
|
}
|
|
|
- enCountSql.append(" group by en_uu )a");
|
|
|
|
|
|
|
+ enCountSql.append(")a");
|
|
|
return commonDao.queryForObject(enCountSql.toString(), Integer.class);
|
|
return commonDao.queryForObject(enCountSql.toString(), Integer.class);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -252,15 +264,14 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
|
|
|
private String getEnUUGroupByEnUUOrderByCount(Long enUU, String enterpriseCondition, String productCondition) {
|
|
private String getEnUUGroupByEnUUOrderByCount(Long enUU, String enterpriseCondition, String productCondition) {
|
|
|
StringBuilder enUUSql = new StringBuilder();
|
|
StringBuilder enUUSql = new StringBuilder();
|
|
|
// 含名称、企业执照号、地址、邮箱、电话、行业、经营范围搜索
|
|
// 含名称、企业执照号、地址、邮箱、电话、行业、经营范围搜索
|
|
|
- enUUSql.append("select en_uu, count(1) as counts from (select en_uu from sec$enterprises where en_name not like '%测试%' " +
|
|
|
|
|
|
|
+ enUUSql.append("select distinct(en_uu) from (select en_uu from sec$enterprises where en_name not like '%测试%' " +
|
|
|
" and en_name not like '%test%' and (length(en_businesscode) > 12 or en_name like '%香港%' or en_name like '%HONG KONG%' " +
|
|
" and en_name not like '%test%' and (length(en_businesscode) > 12 or en_name like '%香港%' or en_name like '%HONG KONG%' " +
|
|
|
" or en_area like '%香港%')and (en_name not REGEXP '^[0-9]*$' and (en_name like '%ltd%' or en_name like '%limited%' or " +
|
|
" or en_area like '%香港%')and (en_name not REGEXP '^[0-9]*$' and (en_name like '%ltd%' or en_name like '%limited%' or " +
|
|
|
" en_name like '%tcl%' or en_name not regexp '[\\u4e00-\\u9fa5_a-zA-Z0-9]')) and ").append(enterpriseCondition).append(" and en_uu <> ").append(enUU)
|
|
" en_name like '%tcl%' or en_name not regexp '[\\u4e00-\\u9fa5_a-zA-Z0-9]')) and ").append(enterpriseCondition).append(" and en_uu <> ").append(enUU)
|
|
|
.append(") e");
|
|
.append(") e");
|
|
|
if (!StringUtils.isEmpty(productCondition)) {
|
|
if (!StringUtils.isEmpty(productCondition)) {
|
|
|
- enUUSql.append(" right join ( select pr_enuu from v$product$private where ").append(productCondition).append(") p on pr_enuu = en_uu where en_uu is not null ");
|
|
|
|
|
|
|
+ enUUSql.append(" right join ( select pr_enuu from products where ").append(productCondition).append(") p on pr_enuu = en_uu ");
|
|
|
}
|
|
}
|
|
|
- enUUSql.append(" group by en_uu order by count(1) desc ");
|
|
|
|
|
return enUUSql.toString();
|
|
return enUUSql.toString();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|