|
|
@@ -9,6 +9,7 @@ import com.uas.platform.b2c.prod.commodity.dao.V_ProductPrivateDao;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.V_ProductPrivate;
|
|
|
import com.uas.platform.b2c.prod.store.dao.StoreInDao;
|
|
|
import com.uas.platform.b2c.trade.order.dao.PurchaseDao;
|
|
|
+import com.uas.platform.b2c.trade.vendor.model.ProductAmount;
|
|
|
import com.uas.platform.b2c.trade.vendor.model.VendorIntroduction;
|
|
|
import com.uas.platform.b2c.trade.vendor.service.VendorIntroductionService;
|
|
|
import com.uas.ps.core.util.CollectionUtils;
|
|
|
@@ -68,20 +69,69 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
|
|
|
*/
|
|
|
private static final String PBRANDEN_EQUAL = "brand";
|
|
|
|
|
|
+ /* =========================================企业分数计算start==================================================== */
|
|
|
+
|
|
|
/**
|
|
|
* 价格排行和库存排行分数基数
|
|
|
*/
|
|
|
- private static final Integer PRICE_RESERVE_BASE = 15;
|
|
|
+ private static final Integer PRICE_RESERVE_BASE_SCORE = 15;
|
|
|
|
|
|
/**
|
|
|
* 回价分数基数
|
|
|
*/
|
|
|
- private static final Integer INQUIRY_REPLU_BASE = 10;
|
|
|
+ private static final Integer INQUIRY_REPLU_BASE_SCORE = 10;
|
|
|
|
|
|
/**
|
|
|
* 交易额分数基数
|
|
|
*/
|
|
|
- private static final Integer PURCHASE_AMOUNT_BASE = 20;
|
|
|
+ private static final Integer PURCHASE_AMOUNT_BASE_SCORE = 20;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 最高档产品数量要求
|
|
|
+ */
|
|
|
+ private static final Integer FIRST_PRODUCT_AMOUNT_BASE = 10000;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 第二档产品数量要求
|
|
|
+ */
|
|
|
+ private static final Integer SECOND_PRODUCT_AMOUNT_BASE = 1000;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 第三档产品数量要求
|
|
|
+ */
|
|
|
+ private static final Integer THIRD_PRODUCT_AMOUNT_BASE = 10;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 主营产品分数
|
|
|
+ */
|
|
|
+ private static final Integer MAIN_PRODUCT_SCORE = 5;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 公司介绍分数
|
|
|
+ */
|
|
|
+ private static final Integer DESCRIPTION_SCORE = 4;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 联系方式分数
|
|
|
+ */
|
|
|
+ private static final Integer TEL_SCORE = 4;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 最高档产品数量分数
|
|
|
+ */
|
|
|
+ private static final Integer FIRST_PRODUCT_AMOUNT_SCORE = 25;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 第二档产品数量分数
|
|
|
+ */
|
|
|
+ private static final Integer SECOND_PRODUCT_AMOUNT_SCORE = 15;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 第三档产品数量分数
|
|
|
+ */
|
|
|
+ private static final Integer THIRD_PRODUCT_AMOUNT_SCORE = 5;
|
|
|
+
|
|
|
+ /* =========================================企业分数计算end==================================================== */
|
|
|
|
|
|
/**
|
|
|
* 根据关键词(非必填)精确匹配来获取供应商资源列表
|
|
|
@@ -213,109 +263,151 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
|
|
|
public void calculateEnterpriseScore() {
|
|
|
long start = System.currentTimeMillis();
|
|
|
List<Enterprise> enterprises = enterpriseDao.findAll();
|
|
|
- // 商家信息
|
|
|
- StringBuilder infoSqls = new StringBuilder();
|
|
|
- for (Enterprise enterprise : enterprises) {
|
|
|
- int info = 0;
|
|
|
- if (StringUtils.hasText(enterprise.getEnIndustry())) {
|
|
|
- info += 5;
|
|
|
- }
|
|
|
- if (StringUtils.hasText(enterprise.getDescription())) {
|
|
|
- info += 4;
|
|
|
+ if (!CollectionUtils.isEmpty(enterprises)) {
|
|
|
+ // 商家信息 企业介绍 联系方式
|
|
|
+ StringBuilder infoSqls = new StringBuilder();
|
|
|
+ for (Enterprise enterprise : enterprises) {
|
|
|
+ // 初始化分数 所有企业
|
|
|
+ int info = 0;
|
|
|
+ if (StringUtils.hasText(enterprise.getDescription())) {
|
|
|
+ info += DESCRIPTION_SCORE;
|
|
|
+ }
|
|
|
+ if (StringUtils.hasText(enterprise.getEnTel())) {
|
|
|
+ info += TEL_SCORE;
|
|
|
+ }
|
|
|
+ infoSqls.append("update sec$enterprises set en_score = ").append(info).append(" where en_uu = ")
|
|
|
+ .append(enterprise.getUu()).append(";");
|
|
|
}
|
|
|
- if (StringUtils.hasText(enterprise.getEnTel())) {
|
|
|
- info += 4;
|
|
|
+ commonDao.getJdbcTemplate().execute(infoSqls.toString());
|
|
|
+ logger.info("商家信息分数更新,条数:{},耗时:{}", enterprises.size(), (System.currentTimeMillis() - start));
|
|
|
+ start = System.currentTimeMillis();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 主营产品
|
|
|
+ List<Long> storeUUs = commonDao.queryForList("select st_enuu from store$info where st_description is not null", Long.class);
|
|
|
+ if (!CollectionUtils.isEmpty(storeUUs)) {
|
|
|
+ // 主营产品更新执行语句
|
|
|
+ StringBuilder storeUpdateSqls = new StringBuilder();
|
|
|
+ for (Long storeUU : storeUUs) {
|
|
|
+ // 添加主营产品分数增加语句
|
|
|
+ storeUpdateSqls.append("update sec$enterprises set en_score = convert((en_score + ").append(MAIN_PRODUCT_SCORE)
|
|
|
+ .append("),DECIMAL(20,6)) where en_uu = ").append(storeUU).append(";");
|
|
|
}
|
|
|
- infoSqls.append("update sec$enterprises set en_score = ").append(info).append(" where en_uu = ")
|
|
|
- .append(enterprise.getUu()).append(";");
|
|
|
+ commonDao.getJdbcTemplate().execute(storeUpdateSqls.toString());
|
|
|
+ logger.info("主营产品分数更新,条数:{},耗时:{}", storeUUs.size(), (System.currentTimeMillis() - start));
|
|
|
+ start = System.currentTimeMillis();
|
|
|
}
|
|
|
- commonDao.getJdbcTemplate().execute(infoSqls.toString());
|
|
|
- logger.info("商家信息分数更新,耗时:{}", (System.currentTimeMillis() - start));
|
|
|
- start = System.currentTimeMillis();
|
|
|
+
|
|
|
+ // 产品数量
|
|
|
+ List<ProductAmount> productAmounts = commonDao.query("select * from (select pr_enuu as enUU,count(1) as amount from products group by pr_enuu) a where a.amount > 10", ProductAmount.class);
|
|
|
+ if (!CollectionUtils.isEmpty(productAmounts)) {
|
|
|
+ StringBuilder productAmountUpdateSqls = new StringBuilder();
|
|
|
+ for (ProductAmount productAmount : productAmounts) {
|
|
|
+ if (productAmount.getAmount() > FIRST_PRODUCT_AMOUNT_BASE) {
|
|
|
+ // 产品数量分数更新执行语句
|
|
|
+ productAmountUpdateSqls.append("update sec$enterprises set en_score = convert((en_score + ").append(FIRST_PRODUCT_AMOUNT_SCORE)
|
|
|
+ .append("),DECIMAL(20,6)) where en_uu = ").append(productAmount.getEnUU()).append(";");
|
|
|
+ } else if (productAmount.getAmount() > SECOND_PRODUCT_AMOUNT_BASE) {
|
|
|
+ productAmountUpdateSqls.append("update sec$enterprises set en_score = convert((en_score + ").append(SECOND_PRODUCT_AMOUNT_SCORE)
|
|
|
+ .append("),DECIMAL(20,6)) where en_uu = ").append(productAmount.getEnUU()).append(";");
|
|
|
+ } else if (productAmount.getAmount() > THIRD_PRODUCT_AMOUNT_BASE) {
|
|
|
+ productAmountUpdateSqls.append("update sec$enterprises set en_score = convert((en_score + ").append(THIRD_PRODUCT_AMOUNT_SCORE)
|
|
|
+ .append("),DECIMAL(20,6)) where en_uu = ").append(productAmount.getEnUU()).append(";");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ commonDao.getJdbcTemplate().execute(productAmountUpdateSqls.toString());
|
|
|
+ logger.info("产品数量分数更新,条数:{},耗时:{}", productAmounts.size(), (System.currentTimeMillis() - start));
|
|
|
+ start = System.currentTimeMillis();
|
|
|
+ }
|
|
|
|
|
|
// 有价数量
|
|
|
// 有价数量排序
|
|
|
-// StringBuilder priceSql = new StringBuilder().append("select pr_enuu from products where pr_price > 0 group by pr_enuu order by count(1) desc");
|
|
|
-// List<Long> priceUUs = commonDao.query(priceSql.toString(), Long.class);
|
|
|
List<BigInteger> priceUUs = enterpriseDao.findEnRankByPriceProductAmount();
|
|
|
- // 价格排行更新执行语句
|
|
|
- StringBuilder priceUpdateSqls = new StringBuilder();
|
|
|
Double i = 1d;
|
|
|
- for (BigInteger priceUU : priceUUs) {
|
|
|
- Double score = new BigDecimal(PRICE_RESERVE_BASE / i).setScale(6, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
- if (score > 0) {
|
|
|
- priceUpdateSqls.append("update sec$enterprises set en_score = convert((en_score + ").append(score)
|
|
|
- .append("),DECIMAL(20,6)) where en_uu = ").append(priceUU.longValue()).append(";");
|
|
|
- } else {
|
|
|
- break;
|
|
|
+ if (!CollectionUtils.isEmpty(priceUUs)) {
|
|
|
+ // 价格排行更新执行语句
|
|
|
+ StringBuilder priceUpdateSqls = new StringBuilder();
|
|
|
+ for (BigInteger priceUU : priceUUs) {
|
|
|
+ Double score = new BigDecimal(PRICE_RESERVE_BASE_SCORE / i).setScale(6, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ if (score > 0) {
|
|
|
+ priceUpdateSqls.append("update sec$enterprises set en_score = convert((en_score + ").append(score)
|
|
|
+ .append("),DECIMAL(20,6)) where en_uu = ").append(priceUU).append(";");
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ i++;
|
|
|
}
|
|
|
- i++;
|
|
|
+ commonDao.getJdbcTemplate().execute(priceUpdateSqls.toString());
|
|
|
+ logger.info("有价数量分数更新,条数:{},耗时:{}", priceUUs.size(), (System.currentTimeMillis() - start));
|
|
|
+ start = System.currentTimeMillis();
|
|
|
}
|
|
|
- commonDao.getJdbcTemplate().execute(priceUpdateSqls.toString());
|
|
|
- logger.info("有价数量分数更新,耗时:{}", (System.currentTimeMillis() - start));
|
|
|
- start = System.currentTimeMillis();
|
|
|
|
|
|
// 有库存数量
|
|
|
// 有库存数量排序
|
|
|
-// StringBuilder reserveSql = new StringBuilder().append("select pr_enuu from products where pr_reserve > 0 group by pr_enuu order by count(1) desc");
|
|
|
-// List<Long> reserveUUs = commonDao.query(reserveSql.toString(), Long.class);
|
|
|
List<BigInteger> reserveUUs = enterpriseDao.findEnRankByReserveProductAmount();
|
|
|
- // 价格排行更新执行语句
|
|
|
- StringBuilder reserveUpdateSqls = new StringBuilder();
|
|
|
- i = 1d;
|
|
|
- for (BigInteger reserveUU : reserveUUs) {
|
|
|
- Double score = new BigDecimal(PRICE_RESERVE_BASE / i).setScale(6, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
- if (score > 0) {
|
|
|
- reserveUpdateSqls.append("update sec$enterprises set en_score = convert((en_score + ").append(score)
|
|
|
- .append("),DECIMAL(20,6)) where en_uu = ").append(reserveUU.longValue()).append(";");
|
|
|
- } else {
|
|
|
- break;
|
|
|
+ if (!CollectionUtils.isEmpty(reserveUUs)) {
|
|
|
+ // 价格排行更新执行语句
|
|
|
+ StringBuilder reserveUpdateSqls = new StringBuilder();
|
|
|
+ i = 1d;
|
|
|
+ for (BigInteger reserveUU : reserveUUs) {
|
|
|
+ Double score = new BigDecimal(PRICE_RESERVE_BASE_SCORE / i).setScale(6, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ if (score > 0) {
|
|
|
+ reserveUpdateSqls.append("update sec$enterprises set en_score = convert((en_score + ").append(score)
|
|
|
+ .append("),DECIMAL(20,6)) where en_uu = ").append(reserveUU).append(";");
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ i++;
|
|
|
}
|
|
|
- i++;
|
|
|
+ commonDao.getJdbcTemplate().execute(reserveUpdateSqls.toString());
|
|
|
+ logger.info("有库存数量分数更新,条数:{},耗时:{}", reserveUUs.size(), (System.currentTimeMillis() - start));
|
|
|
+ start = System.currentTimeMillis();
|
|
|
}
|
|
|
- commonDao.getJdbcTemplate().execute(reserveUpdateSqls.toString());
|
|
|
- logger.info("有库存数量分数更新,耗时:{}", (System.currentTimeMillis() - start));
|
|
|
- start = System.currentTimeMillis();
|
|
|
|
|
|
// 回价数量
|
|
|
// 回价数量排序
|
|
|
List<Long> replyUUs = commonDao.queryForList("select id_venduu from public$inquiryitems group by id_venduu order by count(1) desc", Long.class);
|
|
|
// 价格排行更新执行语句
|
|
|
StringBuilder replyUpdateSqls = new StringBuilder();
|
|
|
- i = 1d;
|
|
|
- for (Long replyUU : replyUUs) {
|
|
|
- Double score = new BigDecimal(INQUIRY_REPLU_BASE / i).setScale(6, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
- if (score > 0) {
|
|
|
- replyUpdateSqls.append("update sec$enterprises set en_score = convert((en_score + ").append(score)
|
|
|
- .append("),DECIMAL(20,6)) where en_uu = ").append(replyUU).append(";");
|
|
|
- } else {
|
|
|
- break;
|
|
|
+ if (!CollectionUtils.isEmpty(replyUUs)) {
|
|
|
+ i = 1d;
|
|
|
+ for (Long replyUU : replyUUs) {
|
|
|
+ Double score = new BigDecimal(INQUIRY_REPLU_BASE_SCORE / i).setScale(6, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ if (score > 0) {
|
|
|
+ replyUpdateSqls.append("update sec$enterprises set en_score = convert((en_score + ").append(score)
|
|
|
+ .append("),DECIMAL(20,6)) where en_uu = ").append(replyUU).append(";");
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ i++;
|
|
|
}
|
|
|
- i++;
|
|
|
+ commonDao.getJdbcTemplate().execute(replyUpdateSqls.toString());
|
|
|
+ logger.info("回价数量分数更新,条数:{},耗时:{}", replyUUs.size(), (System.currentTimeMillis() - start));
|
|
|
+ start = System.currentTimeMillis();
|
|
|
}
|
|
|
- commonDao.getJdbcTemplate().execute(replyUpdateSqls.toString());
|
|
|
- logger.info("回价数量分数更新,耗时:{}", (System.currentTimeMillis() - start));
|
|
|
- start = System.currentTimeMillis();
|
|
|
|
|
|
// 交易额
|
|
|
// 交易额排序
|
|
|
List<BigInteger> purchaseUUs = purchaseDao.rankByStoreTransactionVolume();
|
|
|
// 价格排行更新执行语句
|
|
|
StringBuilder purchaseUpdateSqls = new StringBuilder();
|
|
|
- i = 1d;
|
|
|
- for (BigInteger purchaseUU : purchaseUUs) {
|
|
|
- Double score = new BigDecimal(PURCHASE_AMOUNT_BASE / i).setScale(6, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
- if (score > 0) {
|
|
|
- purchaseUpdateSqls.append("update sec$enterprises set en_score = convert((en_score + ").append(score)
|
|
|
- .append("),DECIMAL(20,6)) where en_uu = ").append(purchaseUU.longValue()).append(";");
|
|
|
- } else {
|
|
|
- break;
|
|
|
+ if (!CollectionUtils.isEmpty(purchaseUUs)) {
|
|
|
+ i = 1d;
|
|
|
+ for (BigInteger purchaseUU : purchaseUUs) {
|
|
|
+ Double score = new BigDecimal(PURCHASE_AMOUNT_BASE_SCORE / i).setScale(6, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ if (score > 0) {
|
|
|
+ purchaseUpdateSqls.append("update sec$enterprises set en_score = convert((en_score + ").append(score)
|
|
|
+ .append("),DECIMAL(20,6)) where en_uu = ").append(purchaseUU).append(";");
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ i++;
|
|
|
}
|
|
|
- i++;
|
|
|
+ commonDao.getJdbcTemplate().execute(purchaseUpdateSqls.toString());
|
|
|
+ logger.info("交易额数量分数更新,条数:{},耗时:{}", purchaseUUs.size(), (System.currentTimeMillis() - start));
|
|
|
+ start = System.currentTimeMillis();
|
|
|
}
|
|
|
- commonDao.getJdbcTemplate().execute(purchaseUpdateSqls.toString());
|
|
|
- logger.info("交易额数量分数更新,耗时:{}", (System.currentTimeMillis() - start));
|
|
|
- start = System.currentTimeMillis();
|
|
|
|
|
|
// 更新店铺中的分数(原厂、经销排行)
|
|
|
storeInDao.updateStoreScore();
|