Quellcode durchsuchen

增加有效供应商数量接口,供应商搜索出现空记录问题处理

dongbw vor 7 Jahren
Ursprung
Commit
f07cb745ba

+ 10 - 0
src/main/java/com/uas/platform/b2c/trade/vendor/controller/VendorIntroductionController.java

@@ -139,4 +139,14 @@ public class VendorIntroductionController {
 		return vendorIntroductionService.getRecommendVendor(pageable);
 	}
 
+    /**
+     * 获取供应商总数
+     *
+     * @return 有效供应商数量
+     */
+    @RequestMapping(value = "/vendor/count", method = RequestMethod.GET)
+    public ModelMap getVendorCount() {
+        return vendorIntroductionService.getVendorCount();
+    }
+
 }

+ 7 - 0
src/main/java/com/uas/platform/b2c/trade/vendor/service/VendorIntroductionService.java

@@ -5,6 +5,7 @@ import com.uas.platform.b2c.prod.commodity.model.V_ProductPrivate;
 import com.uas.platform.b2c.trade.vendor.model.VendorIntroduction;
 import com.uas.sso.support.Page;
 import org.springframework.data.domain.Pageable;
+import org.springframework.ui.ModelMap;
 
 /**
  * The interface VendorIntroduction service.
@@ -54,4 +55,10 @@ public interface VendorIntroductionService {
      * @return
      */
     Page<Enterprise> getRecommendVendor(Pageable pageable);
+
+    /**
+     * 获取有效供应商数量
+     * @return 数量信息
+     */
+    ModelMap getVendorCount();
 }

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

@@ -16,6 +16,7 @@ import com.uas.sso.support.Page;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
+import org.springframework.ui.ModelMap;
 import org.springframework.util.StringUtils;
 
 import java.util.List;
@@ -174,6 +175,23 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 		return new Page<>(pageable.getPageNumber(), pageable.getPageSize(), enterprises, enterprises.size() * pageable.getPageNumber());
 	}
 
+	/**
+	 * 获取有效供应商数量
+	 *
+	 * @return 数量信息
+	 */
+	@Override
+	public ModelMap getVendorCount() {
+		Long enUU = 0L;
+		if (null != SystemSession.getUser() && null != SystemSession.getUser().getEnterprise()) {
+			enUU = SystemSession.getUser().getEnterprise().getUu();
+		}
+		Integer count = getTotalCount(enUU, null, null);
+		ModelMap map = new ModelMap();
+		map.put("count", count);
+		return map;
+	}
+
 	/**
 	 * 获取供应商资源信息
 	 * @param enUU 本企业UU
@@ -241,7 +259,7 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 				" 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 ");
-		if (StringUtils.isEmpty(productCondition)) {
+		if (StringUtils.isEmpty(productCondition) && !StringUtils.isEmpty(enterpriseCondition)) {
 			enCountSql.append(enterpriseCondition).append(" and ");
 		}
 		enCountSql.append(" en_uu <> ").append(enUU).append(") e ");
@@ -270,7 +288,7 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 				" 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");
 		if (!StringUtils.isEmpty(productCondition)) {
-			enUUSql.append(" right join ( select pr_enuu from products where ").append(productCondition).append(") p on pr_enuu = en_uu ");
+			enUUSql.append(" inner join ( select pr_enuu from products where ").append(productCondition).append(") p on pr_enuu = en_uu ");
 		}
 		return enUUSql.toString();
 	}