Procházet zdrojové kódy

Merge branch 'dev-mysql' into feature/yc-mobile_maimai-0525

yangc před 7 roky
rodič
revize
f901fd655e

+ 1 - 12
src/main/java/com/uas/platform/b2c/common/search/constant/SearchUrl.java

@@ -15,18 +15,7 @@ public class SearchUrl {
     /**
     /**
      * 获取企业物料
      * 获取企业物料
      */
      */
-    public static final String ALL_PRODUCT_ID_URL = "/search/productIds?enUU={enUU}&keyword={keyword}&page={page}&size={size}";
-
-
-    /**
-     * 获取企业物料(标准)
-     */
-    public static final String STANDARD_PRODUCT_ID_URL = "/search/standardProductIds?enUU={enUU}&keyword={keyword}&page={page}&size={size}";
-
-    /**
-     * 获取企业物料(非标准)
-     */
-    public static final String NONSTANDARD_PRODUCT_ID_URL = "/search/nonStandardProductIds?enUU={enUU}&keyword={keyword}&page={page}&size={size}";
+    public static final String PRODUCT_ID_URL = "/search/productIds?enUU={enUU}&keyword={keyword}&page={page}&size={size}&type={type}";
 
 
     /**
     /**
      * 获取类目的数据
      * 获取类目的数据

+ 3 - 8
src/main/java/com/uas/platform/b2c/common/search/rpc/service/Impl/SearchServiceImpl.java

@@ -78,14 +78,9 @@ public class SearchServiceImpl implements SearchService{
     public SPage<Long> getProducts(Long enUU, String keyword, Integer page, Integer size, String type) throws SearchException {
     public SPage<Long> getProducts(Long enUU, String keyword, Integer page, Integer size, String type) throws SearchException {
         Map<String, Object> map = initSearchMap(keyword, page, size);
         Map<String, Object> map = initSearchMap(keyword, page, size);
         map.put("enUU", enUU);
         map.put("enUU", enUU);
-        String str = "";
-        if (type.equals("standard")) {
-            str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.STANDARD_PRODUCT_ID_URL, String.class, map);
-        } else if (type.equals("nStandard")) {
-            str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.NONSTANDARD_PRODUCT_ID_URL, String.class, map);
-        } else if (type.equals("all")) {
-            str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.ALL_PRODUCT_ID_URL, String.class, map);
-        }
+        // standard 标准  nStandard 非标 其他为所有
+        map.put("type", type);
+        String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.PRODUCT_ID_URL, String.class, map);
         if(StringUtils.isEmpty(str)) {
         if(StringUtils.isEmpty(str)) {
             return null;
             return null;
         } else {
         } else {

+ 0 - 5
src/main/java/com/uas/platform/b2c/core/filter/SSOInterceptor.java

@@ -99,7 +99,6 @@ public class SSOInterceptor extends AbstractSSOInterceptor {
 
 
     @Override
     @Override
     protected boolean onAuthenticateFailed(HttpServletRequest request, HttpServletResponse response) {
     protected boolean onAuthenticateFailed(HttpServletRequest request, HttpServletResponse response) {
-        logger.info("当前访问进入------------>>>>onAuthenticateFailed()方法!");
         SystemSession.clear();
         SystemSession.clear();
         if (request.getRequestURI().endsWith(PathConstant.AUTHENTICATION_URL)) {
         if (request.getRequestURI().endsWith(PathConstant.AUTHENTICATION_URL)) {
             return true;
             return true;
@@ -180,11 +179,9 @@ public class SSOInterceptor extends AbstractSSOInterceptor {
         if (request.getPathInfo() != null) {
         if (request.getPathInfo() != null) {
             resourceUrl = resourceUrl + request.getPathInfo();
             resourceUrl = resourceUrl + request.getPathInfo();
         }
         }
-        logger.info("【"+user.getUserUU()+"当前访问路径】:*******"+"resourceUrl:"+resourceUrl);
         if (null == configAttributes || configAttributes.size() == 0 || user.isSys() || user.getEnterprise() == null) {
         if (null == configAttributes || configAttributes.size() == 0 || user.isSys() || user.getEnterprise() == null) {
             return;
             return;
         }
         }
-        logger.info("【"+user.getUserUU()+"当前资源的权限】:*******"+"configAttributes:"+FastjsonUtils.toJson(configAttributes));
         Iterator<ConfigAttribute> iterator = configAttributes.iterator();
         Iterator<ConfigAttribute> iterator = configAttributes.iterator();
         String needPermission = null;
         String needPermission = null;
         if (null == authorities || !authorities.containsKey(user.getUserUU())) {
         if (null == authorities || !authorities.containsKey(user.getUserUU())) {
@@ -192,7 +189,6 @@ public class SSOInterceptor extends AbstractSSOInterceptor {
         }
         }
         //获取当前登录用户的所有权限;
         //获取当前登录用户的所有权限;
         Collection<GrantedAuthority> userAuthorities = authorities.get(user.getUserUU());
         Collection<GrantedAuthority> userAuthorities = authorities.get(user.getUserUU());
-        logger.info("【"+user.getUserUU()+"用户所有权限】:*******"+"userAuthorities:"+FastjsonUtils.toJson(userAuthorities));
         //匹配当前访问权限;
         //匹配当前访问权限;
         while (iterator.hasNext()) {
         while (iterator.hasNext()) {
             ConfigAttribute configAttribute = iterator.next();
             ConfigAttribute configAttribute = iterator.next();
@@ -248,7 +244,6 @@ public class SSOInterceptor extends AbstractSSOInterceptor {
 				resourceMap.put(resource.getMethod() + ":" + resource.getUrl(), configAttributes);
 				resourceMap.put(resource.getMethod() + ":" + resource.getUrl(), configAttributes);
 			}
 			}
 		}
 		}
-		logger.info("【权限控制资源】"+"size:"+resourceMap.size()+"*******"+"resourceMap:"+FastjsonUtils.toJSON(resourceMap));
     }
     }
 
 
     /**
     /**

+ 6 - 11
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ProductServiceImpl.java

@@ -258,12 +258,12 @@ public class ProductServiceImpl implements ProductService {
     @Override
     @Override
     public Page<V_ProductPrivate> getAllProducts(final PageInfo page, String keyword, String type, Long userUU) {
     public Page<V_ProductPrivate> getAllProducts(final PageInfo page, String keyword, String type, Long userUU) {
         Long enUU = SystemSession.getUser().getEnterprise().getUu();
         Long enUU = SystemSession.getUser().getEnterprise().getUu();
-//        page.expression(PredicateUtils.eq("enUU", enuu, true));
-//        page.expression(PredicateUtils.isNotNull("pcmpcode"));
-//        page.expression(PredicateUtils.isNotNull("pbranden"));
         if (StringUtils.isEmpty(type)) {
         if (StringUtils.isEmpty(type)) {
             type = "nStandard";
             type = "nStandard";
         }
         }
+//        page.expression(PredicateUtils.eq("enUU", enuu, true));
+//        page.expression(PredicateUtils.isNotNull("pcmpcode"));
+//        page.expression(PredicateUtils.isNotNull("pbranden"));
 //        if (type.contains("standard")) {
 //        if (type.contains("standard")) {
 //           SPage<Long> ids = searchService.get
 //           SPage<Long> ids = searchService.get
 //        } else if (type.contains("nonStandard")) {
 //        } else if (type.contains("nonStandard")) {
@@ -585,12 +585,6 @@ public class ProductServiceImpl implements ProductService {
                 }
                 }
                 productPrivate.setB2cEnabled(IntegerConstant.NO_SHORT);
                 productPrivate.setB2cEnabled(IntegerConstant.NO_SHORT);
                 productPrivateDao.save(productPrivate);
                 productPrivateDao.save(productPrivate);
-                product.setB2cEnabled(IntegerConstant.NO_SHORT);
-                // 设置物料不可用时,为了更新索引,也需要更新物料资料
-                product.setIsSale(Constant.NO);
-                product.setIsPurchase(Constant.NO);
-                product.setErpDate(new Date());
-                productDao.save(product);
                 //productDao.delete(id);  不允许删除
                 //productDao.delete(id);  不允许删除
             } else {
             } else {
                 throw new
                 throw new
@@ -1600,8 +1594,9 @@ public class ProductServiceImpl implements ProductService {
             standard = v_productPersonDao.getCountByEnuuAndUserUUAndStatusAndEnabled(enUU, userUU, ShortConstant.YES_SHORT, IntegerConstant.YES_SHORT);
             standard = v_productPersonDao.getCountByEnuuAndUserUUAndStatusAndEnabled(enUU, userUU, ShortConstant.YES_SHORT, IntegerConstant.YES_SHORT);
             nStandard = v_productPersonDao.getCountByEnuuAndUserUUAndStatusAndEnabled(enUU, userUU, ShortConstant.NO_SHORT, IntegerConstant.YES_SHORT);
             nStandard = v_productPersonDao.getCountByEnuuAndUserUUAndStatusAndEnabled(enUU, userUU, ShortConstant.NO_SHORT, IntegerConstant.YES_SHORT);
         } else {
         } else {
-            standard = productDao.getCountByEnuuAndStatusAndEnabled(enUU, ShortConstant.YES_SHORT, IntegerConstant.YES_SHORT);
-            nStandard = productDao.getCountByEnuuAndStatusAndEnabled(enUU, ShortConstant.NO_SHORT, IntegerConstant.YES_SHORT);
+            // 数据量大时,从数据库查询数量也变得很慢,所以改用查索引获取 dongbw 2018年5月28日 11:24:17
+            standard = (int) searchService.getProducts(enUU, null, 1, 10, "standard").getTotalElement();
+            nStandard = (int) searchService.getProducts(enUU, null, 1, 10, "nStandard").getTotalElement();
         }
         }
         resultMap.put("standard", standard);
         resultMap.put("standard", standard);
         resultMap.put("nStandard", nStandard);
         resultMap.put("nStandard", nStandard);

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

@@ -1,12 +1,15 @@
 package com.uas.platform.b2c.trade.vendor.service.impl;
 package com.uas.platform.b2c.trade.vendor.service.impl;
 
 
 import com.uas.platform.b2c.common.base.dao.CommonDao;
 import com.uas.platform.b2c.common.base.dao.CommonDao;
+import com.uas.platform.b2c.common.search.rpc.service.SearchService;
+import com.uas.platform.b2c.common.search.util.SPage;
 import com.uas.platform.b2c.core.constant.IntegerConstant;
 import com.uas.platform.b2c.core.constant.IntegerConstant;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.prod.commodity.dao.V_ProductPrivateDao;
 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.commodity.model.V_ProductPrivate;
 import com.uas.platform.b2c.trade.vendor.model.VendorIntroduction;
 import com.uas.platform.b2c.trade.vendor.model.VendorIntroduction;
 import com.uas.platform.b2c.trade.vendor.service.VendorIntroductionService;
 import com.uas.platform.b2c.trade.vendor.service.VendorIntroductionService;
+import com.uas.ps.core.util.CollectionUtils;
 import com.uas.sso.support.Page;
 import com.uas.sso.support.Page;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
@@ -27,6 +30,9 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 	@Autowired
 	@Autowired
 	private V_ProductPrivateDao v_productPrivateDao;
 	private V_ProductPrivateDao v_productPrivateDao;
 
 
+	@Autowired
+	private SearchService searchService;
+
 	/**
 	/**
 	 * 获取供应商资源列表
 	 * 获取供应商资源列表
 	 * @param page    页码
 	 * @param page    页码
@@ -64,28 +70,12 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 	 */
 	 */
 	@Override
 	@Override
 	public Page<V_ProductPrivate> getVendorProductList(int page, int size, Long vendUU, String keyword) {
 	public Page<V_ProductPrivate> getVendorProductList(int page, int size, Long vendUU, String keyword) {
-		String whereCondition = " 1 = 1 ";
-		if (!StringUtils.isEmpty(keyword)) {
-		    keyword = keyword.trim();
-			// 物料名称、规格、品牌、原厂型号、单位
-			whereCondition = " (pr_title like '%" + keyword + "%' or pr_spec like '%" + keyword + "%' or pr_brand like '%"
-					+ keyword + "%' or pr_cmpcode like '%" + keyword + "%' or pr_unit like '%" + keyword + "%' or pr_kind like '%"
-					+ keyword + "%') ";
+		SPage<Long> ids = searchService.getProducts(vendUU, keyword, page, size, "all");
+		if (CollectionUtils.isEmpty(ids.getContent())) {
+			return null;
 		}
 		}
-		long start = System.currentTimeMillis();
-		// 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_pbranden pbranden, pr_standard standard from v$product$private where pr_enuu = "
-				+ vendUU + " and " + whereCondition + " and pr_pbranden is not null and pr_pcmpcode is not null and ifnull(pr_b2cenabled, 1) <> 0 order by 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 " + whereCondition
-				+ " and pr_pbranden is not null and pr_pcmpcode is not null and ifnull(pr_b2cenabled, 1) <> 0";
-		Integer count = commonDao.queryForObject(countSql, Integer.class);
-//		System.out.println("count:" + countSql);
-		List<V_ProductPrivate> products = commonDao.query(prodSql, V_ProductPrivate.class);
-//		System.out.println("耗时" + (System.currentTimeMillis() - start));
-		return new Page<>(page, size, products, count);
+		List<V_ProductPrivate> productPrivateList = v_productPrivateDao.findAll(ids.getContent());
+		return new Page<>(page, size, productPrivateList, (int) ids.getTotalElement());
 	}
 	}
 
 
 	/**
 	/**