فهرست منبع

【供应商资源】产品导入默认设置销售属性为1;修改供应商搜索接口问题

dongbw 7 سال پیش
والد
کامیت
700103aa31

+ 4 - 1
src/main/java/com/uas/platform/b2c/common/account/model/Enterprise.java

@@ -16,7 +16,10 @@ import java.util.Date;
  * @author yingp
  */
 @Entity
-@Table(name = "sec$enterprises")
+@Table(name = "sec$enterprises", indexes = {
+		@Index(name = "en_name_index", columnList = "en_name"),
+		@Index(name = "en_address_index", columnList = "en_address"),
+		@Index(name = "en_industry_index", columnList = "en_industry"), })
 @Cacheable
 @Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "com.uas.platform.b2c.model.EnterpriseUas")
 public class Enterprise implements Serializable {

+ 4 - 2
src/main/java/com/uas/platform/b2c/prod/commodity/model/Product.java

@@ -16,8 +16,10 @@ import java.util.Set;
  */
 @Entity
 @Table(name = "products", indexes = {@Index(name = "products_code_index", columnList = "pr_code"),
-@Index(name = "products_enuu_index", columnList = "pr_enuu"),
-@Index(name = "products_enuu_code_index", columnList = "pr_code, pr_enuu", unique = true)})
+	@Index(name = "products_enuu_index", columnList = "pr_enuu"),
+	@Index(name = "products_cmpcode_index", columnList = "pr_cmpcode"),
+	@Index(name = "products_brand_index", columnList = "pr_brand"),
+	@Index(name = "products_enuu_code_index", columnList = "pr_code, pr_enuu", unique = true)})
 @Logger
 //@Cacheable
 //@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "com.uas.platform.b2b.model.Product")

+ 24 - 21
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ReleaseProductByBatchServiceImpl.java

@@ -1,7 +1,5 @@
 package com.uas.platform.b2c.prod.commodity.service.impl;
 
-import static com.uas.platform.b2c.core.utils.NumberUtil.fractionNumCeil;
-
 import com.alibaba.fastjson.JSON;
 import com.uas.platform.b2c.common.account.model.Enterprise;
 import com.uas.platform.b2c.common.account.service.EnterpriseService;
@@ -41,25 +39,6 @@ import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.persistence.criteria.CriterionExpression;
 import com.uas.platform.core.persistence.criteria.PredicateUtils;
 import com.uas.platform.core.persistence.criteria.SimpleExpression;
-import java.math.BigDecimal;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.poi.hssf.usermodel.HSSFCell;
 import org.apache.poi.hssf.usermodel.HSSFDateUtil;
@@ -80,6 +59,28 @@ import org.springframework.ui.ModelMap;
 import org.springframework.util.StringUtils;
 import org.springframework.web.client.RestTemplate;
 
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import java.math.BigDecimal;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import static com.uas.platform.b2c.core.utils.NumberUtil.fractionNumCeil;
+
 @Service
 public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchService {
 
@@ -1244,6 +1245,8 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
                 product.setStandard(releaseProductByBatch.getComponentUuId() == null ? (short)0 : (short)1);
                 product.setCmpUuid(releaseProductByBatch.getComponentUuId());
                 product.setCreateTime(new Date(System.currentTimeMillis()));
+                // 产品导入默认可销售
+                product.setIsSale((short) 1);
                 if (isAPerson) {
                     product.setSpec(releaseProductByBatch.getPackaging());
                 }

+ 15 - 12
src/main/java/com/uas/platform/b2c/trade/vendor/service/impl/VendorIntroductionServiceImpl.java

@@ -67,12 +67,12 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 		// and Pr_Title not like '%测试%' and lower(Pr_Title) not like '%test%' and Pr_code not like '%测试%' and lower(Pr_code) not like '%test%'
 		String prodSql = "select a.* from (select pr_id id, pr_code prodNum, pr_title prodName, pr_spec spec, pr_cmpcode cmpCode, pr_unit unit, pr_kind kind, "
 				+ " pr_brand brand, pr_standard standard from v$product$private where ifnull(pr_b2cenabled, 1) <> 0  and pr_enuu = "
-				+ vendUU + " and pr_issale = 1 and ifnull(pr_b2cenabled, 1) <> 0 and "
-				+ whereCondition + " order by pr_issale desc, pr_standard desc, pr_id desc) a limit " + (page - 1) * size + "," + size;
+				+ vendUU + " and pr_issale = 1 and " + whereCondition
+                + " order by pr_issale desc, pr_standard desc, pr_id desc) a limit " + (page - 1) * size + "," + size;
 		System.out.println("prod:" + prodSql);
+		// and Pr_Title not like '%测试%' and lower(Pr_Title) not like '%test%' and Pr_code not like '%测试%' and lower(Pr_code) not like '%test%'
 		String countSql = "select count(1) from v$product$private where pr_enuu = " + vendUU
-				+ " and pr_issale = 1 and ifnull(pr_b2cenabled, 1) <> 0  and Pr_Title not like '%测试%' and lower(Pr_Title) not like '%test%' and Pr_code not like '%测试%' and lower(Pr_code) not like '%test%' and "
-				+ whereCondition;
+				+ " and pr_issale = 1 and ifnull(pr_b2cenabled, 1) <> 0 and " + whereCondition;
 		Integer count = commonDao.queryForObject(countSql, Integer.class);
 		List<V_ProductPrivate> products = commonDao.query(prodSql, V_ProductPrivate.class);
 		System.out.println("耗时" + (System.currentTimeMillis() - start));
@@ -108,17 +108,19 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 				" from sec$enterprises en right join (").append(enUUSql)
 				.append(" ) a on en.en_uu = a.en_uu order by en.en_weight desc, counts desc");
 		// rownum 控制
-		String rownumSql = ") s order by isStore desc limit " + (page - 1) * size + "," + size ;
+		String rownumSql = ") s order by isStore desc,prodCounts desc limit " + (page - 1) * size + "," + size ;
 //		// 查询企业简要物料信息语句
 //		String prodInfoSql = "select wm_concat(pr_title || (case when pr_brand is not null then '(' || pr_brand || ')' else ' ' end)) from v$product$private where pr_enuu=en_uu and "
 //				+ " and pr_issale = 1 and pr_b2cenabled = 1 and rownum<5 ";
 		// 查询企业是否开店语句
 		// 查找非供应商的卖当前商品的企业UU
-		String vendorIntroductionUusSql = "select s.*, ( select 1 from store$info where st_enuu = enUU and st_status = 'OPENED') isStore, " +
-                "(select 1 from v$product$private where ifnull(pr_b2cenabled, 1) = 1 and pr_issale = 1 and pr_enuu = enUU limit 0,1) hasProduct from ("
+		String vendorIntroductionUusSql = "select s.*, ( select 1 from store$info where st_enuu = enUU and st_status = 'OPENED') isStore, "
+                + "(select 1 from v$product$private where ifnull(pr_b2cenabled, 1) = 1 and pr_issale = 1 and pr_enuu = enUU limit 0,1) hasProduct,"
+                + "(select count(1) from v$product$private where ifnull(pr_b2cenabled, 1) = 1 and pr_enuu = enUU and pr_issale = 1) prodCounts from ("
 				+ enterpriseSql + rownumSql;
 //		String vendorIntroductionUusSql = "select s.*,( " + prodInfoSql + ") productInfo, (" + storeSql +
 //				") isStore from (select t.*,rownum as r1 from (" + enterpriseSql + rownumSql;
+        System.out.println("ens:" + vendorIntroductionUusSql);
 		return commonDao.query(vendorIntroductionUusSql, VendorIntroduction.class);
 	}
 
@@ -139,6 +141,7 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 					" and lower(en_name) not like '%test%') en left join products on en.en_uu = pr_enuu where en_uu <> ").append(enUU);
 		}
 		enCountSql.append(" group by en_uu ) a");
+        System.out.println("en_count:" + enCountSql.toString());
 		return commonDao.queryForObject(enCountSql.toString(), Integer.class);
 	}
 
@@ -149,11 +152,11 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 	 * @return
 	 */
 	private String getKeywordSql(Long enUU, String keyword) {
-		return "select en_uu,count(1) as counts from sec$enterprises left join products on pr_enuu = en_uu where en_name not like '%测试%' " +
-				"and lower(en_name) not like '%test%' and pr_issale = 1 and (en_name like '%"
+		return "select en_uu,count(1) as counts from sec$enterprises left join v$product$private on pr_enuu = en_uu where en_name not like '%测试%' " +
+				"and lower(en_name) not like '%test%' and ((en_name like '%"
 				+ keyword + "%' or en_address like '%" + keyword + "%' or en_industry like '%" + keyword
-				+ "%' or pr_cmpcode like '%" + keyword + "%' or pr_brand like '%" + keyword
-				+ "%') and en_uu <> " + enUU;
+				+ "%') or ((pr_cmpcode like '%" + keyword + "%' or pr_brand like '%" + keyword
+				+ "%') and ifnull(pr_b2cenabled, 1) = 1 and pr_issale = 1 )) and en_uu <> " + enUU;
 	}
 
 	/**
@@ -169,7 +172,7 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 			enUUSql.append(getKeywordSql(enUU, keyword));
 		} else {
 			enUUSql.append("select en_uu, count(1) as counts from (select * from sec$enterprises where en_name not like '%测试%' " +
-					" and lower(en_name) not like '%test%') en left join products on en.en_uu = pr_enuu where pr_issale = 1 and en.en_uu <> ").append(enUU);
+					" and lower(en_name) not like '%test%') en left join products on en.en_uu = pr_enuu where en.en_uu <> ").append(enUU);
 		}
 		enUUSql.append(" group by en_uu order by count(1) desc ");
 		return enUUSql.toString();