|
|
@@ -346,11 +346,13 @@ public class VendorsServiceImpl implements VendorService {
|
|
|
*/
|
|
|
@Override
|
|
|
public com.uas.account.support.Page<VendorRecommend> getVendorRecommend(String productMatchCondition, String enterpriseMatchCondition, String productCondition, int page, int size) {
|
|
|
+ System.out.println("进入方法:" + System.currentTimeMillis());
|
|
|
final Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
String cmpCodesSql = concatProductCondition(enUU, productMatchCondition, productCondition);
|
|
|
+ System.out.println("查找物料语句拼接完成:" + System.currentTimeMillis());
|
|
|
// // 根据标准料号找出对应的供应商UU
|
|
|
// String vendUUsSql = "select distinct(ve_vendenuu) from purc$vendors left join v$products on pr_enuu = ve_vendenuu" +
|
|
|
-// " where ve_myenuu = " + enUU + " and pr_issale = 1 and pr_standard = 1 and pr_cmpcode in (" + cmpCodesSql + ")";
|
|
|
+// " where ve_myenuu = " + enUU + " and pr_issale = 1 and pr_cmpcode in (" + cmpCodesSql + ")";
|
|
|
// 采购物料原厂型号
|
|
|
System.out.println(cmpCodesSql);
|
|
|
// final List<String> cmpCodes = commonDao.queryForList(cmpCodesSql.toString(), String.class);
|
|
|
@@ -386,8 +388,10 @@ public class VendorsServiceImpl implements VendorService {
|
|
|
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_uu <> ")
|
|
|
.append(enUU).append(" group by en_uu)");
|
|
|
+ System.out.println("所有语句拼接完成:" + System.currentTimeMillis());
|
|
|
Integer total = commonDao.queryForObject(totalSql.toString(), Integer.class);
|
|
|
List<Long> vendUUs = commonDao.queryForList(vendorRecommendUusSql.toString(), Long.class);
|
|
|
+ System.out.println("查找出所有推荐企业UU:" + System.currentTimeMillis());
|
|
|
return getVendorRecommendByVendUUs(enUU, vendUUs, page, size, total);
|
|
|
}
|
|
|
|
|
|
@@ -445,7 +449,10 @@ public class VendorsServiceImpl implements VendorService {
|
|
|
*/
|
|
|
private com.uas.account.support.Page<VendorRecommend> getVendorRecommendByVendUUs(Long enUU, List<Long> vendUUs, int page, int size, Integer total) {
|
|
|
List<VendorRecommend> content = new ArrayList<>();
|
|
|
+ int i = 0;
|
|
|
for (final Long vendUU : vendUUs) {
|
|
|
+ i = i+ 1;
|
|
|
+ System.out.println("开始处理第" + i + "条数据:" + System.currentTimeMillis());
|
|
|
Enterprise vendor = enterPriseDao.findOne(vendUU);
|
|
|
if (null != vendor) {
|
|
|
// if (null != vendor.getEnAdminuu()) {
|
|
|
@@ -455,17 +462,21 @@ public class VendorsServiceImpl implements VendorService {
|
|
|
StringBuffer productIdsSql = new StringBuffer();
|
|
|
StringBuffer productNumSql = new StringBuffer();
|
|
|
productIdsSql.append("select pr.pr_id from v$products pr where pr.pr_enuu = ").append(vendUU)
|
|
|
- .append(" and pr.pr_issale =1 and pr.pr_standard =1 and exists (select 1 from v$products p1 " +
|
|
|
- "where p1.pr_cmpcode = pr.pr_cmpcode and p1.pr_ispurchase = 1 and (p1.pr_issale is null or p1.pr_issale = 0) " +
|
|
|
- "and p1.pr_standard = 1 and p1.pr_b2bdisabled <> 1 and p1.pr_enuu = ")
|
|
|
- .append(enUU).append(") and rownum <= 5 order by pr_id desc");
|
|
|
+ .append(" and pr.pr_issale =1 and pr.pr_cmpcode in (select pr_cmpcode from v$products p1 " +
|
|
|
+ " where p1.pr_ispurchase = 1 and (p1.pr_issale is null or p1.pr_issale = 0) " +
|
|
|
+ " and p1.pr_b2bdisabled <> 1 and p1.pr_enuu = ")
|
|
|
+ .append(enUU).append(") and rownum <= 5 order by pr_standard,pr_id desc");
|
|
|
productNumSql.append("select count(1) from v$products pr where pr.pr_enuu = ").append(vendUU)
|
|
|
- .append(" and pr.pr_issale =1 and pr.pr_standard =1 and exists (select 1 from v$products p1 " +
|
|
|
- "where p1.pr_cmpcode = pr.pr_cmpcode and p1.pr_ispurchase = 1 and (p1.pr_issale is null or p1.pr_issale = 0) " +
|
|
|
- "and p1.pr_standard = 1 and p1.pr_b2bdisabled <> 1 and p1.pr_enuu = ")
|
|
|
+ .append(" and pr.pr_issale =1 and pr.pr_cmpcode in (select pr_cmpcode from v$products p1 " +
|
|
|
+ " where p1.pr_ispurchase = 1 and (p1.pr_issale is null or p1.pr_issale = 0) " +
|
|
|
+ " and p1.pr_b2bdisabled <> 1 and p1.pr_enuu = ")
|
|
|
.append(enUU).append(")");
|
|
|
+ System.out.println("第" + i + "条数据物料查找语句拼接完成:" + System.currentTimeMillis());
|
|
|
+ System.out.println(productIdsSql.toString());
|
|
|
+ System.out.println(productNumSql.toString());
|
|
|
List<Long> prodIds = commonDao.queryForList(productIdsSql.toString(), Long.class);
|
|
|
Integer hitNums = commonDao.queryForObject(productNumSql.toString(), Integer.class);
|
|
|
+ System.out.println("第" + i + "条数据匹配物料id及数量查找完成:" + System.currentTimeMillis());
|
|
|
// 获取前五条匹配物料
|
|
|
List<Product> hitsProducts = productDao.findAll(prodIds);
|
|
|
VendorRecommend vendorRecommend = new VendorRecommend();
|
|
|
@@ -478,6 +489,7 @@ public class VendorsServiceImpl implements VendorService {
|
|
|
} else {
|
|
|
vendorRecommend.setIsVendor(Constant.NO);
|
|
|
}
|
|
|
+ System.out.println("第" + i + "条数据处理完毕,添加到content:" + System.currentTimeMillis());
|
|
|
content.add(vendorRecommend);
|
|
|
}
|
|
|
}
|
|
|
@@ -510,12 +522,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_standard = 1 and p1.pr_b2bdisabled <> 1 and ")
|
|
|
+ .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)");
|
|
|
// 查找不匹配但是在售物料的语句 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_standard = 1 and p1.pr_b2bdisabled <> 1 and ")
|
|
|
+ .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)");
|
|
|
// 物料id
|
|
|
StringBuffer idSql = new StringBuffer();
|