Selaa lähdekoodia

获取各地区品牌类型分布情况 -更改-> 获取各地区品牌网点数量分布情况

云殇忆 1 vuosi sitten
vanhempi
säilyke
03a3075515

+ 3 - 6
benyun-core/src/main/java/com/benyun/core/controller/BrandController.java

@@ -89,13 +89,10 @@ public class BrandController extends BaseController {
         return R.ok(brandService.searchAvgScoreByBrandId(brandId));
     }
 
-//    获取品牌网点类型分布情况
-    @GetMapping("/categoryDistribution")
+//    获取各地区品牌网点数量分布情况
+    @GetMapping("/countDistribution")
     public R categoryDis(BrandListQueryBody body){
         List<String> addrCode = body.getAddrCode();
-        List<String> industryCode = body.getIndustryCode();
-        return R.ok(brandService.searchAddrTypeDisByMulti(addrCode,industryCode));
+        return R.ok(brandService.searchAddrDistribution(addrCode));
     }
-
-//    获取连锁品牌近期开关店情况
 }

+ 2 - 3
benyun-core/src/main/java/com/benyun/core/dao/BrandMapper.java

@@ -1,7 +1,7 @@
 package com.benyun.core.dao;
 
 import com.benyun.core.entity.Brand;
-import com.benyun.core.entity.bo.BrandAddrTypeDistribution;
+import com.benyun.core.entity.bo.BrandAddrDistribution;
 import com.benyun.core.entity.bo.BrandSearch;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -13,6 +13,5 @@ public interface BrandMapper {
     List<Brand> searchList(String text);
     Brand searchById(String brandId);
     List<Brand> searchByIndustryCodeList(String brandId, String industryCode);
-    List<BrandSearch> searchSearchByMulti(@Param("text") String text,@Param("industryCode") List<String> industryCode,@Param("countUp") Integer countUp,@Param("countDown") Integer countDown,@Param("coverUp") Integer coverUp,@Param("coverDown") Integer coverDown,@Param("addrCode") List<String> addrCode,@Param("orderBy") Integer orderBy);
-    List<BrandAddrTypeDistribution> searchAddrTypeDisByMulti(@Param("addrCodes") List<String> addrCodes,@Param("industryCodes") List<String> industryCodes);
+    List<BrandSearch> searchSearchByMulti(@Param("text") String text,@Param("industryCode") List<String> industryCode,@Param("countUp") Integer countUp,@Param("countDown") Integer countDown,@Param("coverUp") Integer coverUp,@Param("coverDown") Integer coverDown);
 }

+ 2 - 0
benyun-core/src/main/java/com/benyun/core/dao/BrandZoneMapper.java

@@ -1,6 +1,7 @@
 package com.benyun.core.dao;
 
 import com.benyun.core.entity.BrandZone;
+import com.benyun.core.entity.bo.BrandAddrDistribution;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -10,4 +11,5 @@ import java.util.List;
 public interface BrandZoneMapper {
     List<BrandZone> searchByBrandId(String brandId);
     List<BrandZone> searchByMulti(@Param("addrCodes") List<String> addrCodes,@Param("industryCodes") List<String> industryCodes,@Param("brandIds") List<String> brandIds);
+    List<BrandAddrDistribution> searchByAddrCodeGroup(@Param("addrCodes") List<String> addrCodes);
 }

+ 1 - 2
benyun-core/src/main/java/com/benyun/core/entity/bo/BrandAddrTypeDistribution.java → benyun-core/src/main/java/com/benyun/core/entity/bo/BrandAddrDistribution.java

@@ -3,8 +3,7 @@ package com.benyun.core.entity.bo;
 import lombok.Data;
 
 @Data
-public class BrandAddrTypeDistribution {
-    private String industryCode;
+public class BrandAddrDistribution {
     private String addrCode;
     private Integer count;
 }

+ 1 - 1
benyun-core/src/main/java/com/benyun/core/service/BrandService.java

@@ -18,5 +18,5 @@ public interface BrandService {
     PageInfo<List<BrandSearch>> searchListByMulti(BrandListQueryBody body);
     List<BrandTotal> searchTotal();
     BStoreData searchAvgScoreByBrandId(String brandId);
-    List<BrandAddrTypeDistribution> searchAddrTypeDisByMulti(List<String> addrCodes, List<String> typeCodes);
+    List<BrandAddrDistribution> searchAddrDistribution(List<String> addrCodes);
 }

+ 5 - 9
benyun-core/src/main/java/com/benyun/core/service/impl/BrandServiceImpl.java

@@ -241,13 +241,8 @@ public class BrandServiceImpl implements BrandService {
             coverDown = Integer.parseInt(body.getCoverCityCount().get(0));
             coverUp = Integer.parseInt(body.getCoverCityCount().get(1));
         }catch (Exception e){}
-        List<String> addrCode = body.getAddrCode();
-        int orderBy = 1;
-        if (body.getOrderBy().equals("total"))
-            orderBy = 2;
-        if (body.getOrderBy().equals("custom"))
-            orderBy = 3;
-        PageInfo info = new PageInfo(brandMapper.searchSearchByMulti(text, industryCode, countUp, countDown, coverUp, coverDown, addrCode, orderBy));
+        List<BrandSearch> brandSearches = brandMapper.searchSearchByMulti(text, industryCode, countUp, countDown, coverUp, coverDown);
+        PageInfo info = new PageInfo(brandSearches);
         return info;
     }
 
@@ -290,7 +285,8 @@ public class BrandServiceImpl implements BrandService {
     }
 
     @Override
-    public List<BrandAddrTypeDistribution> searchAddrTypeDisByMulti(List<String> addrCodes, List<String> industryCodes) {
-        return brandMapper.searchAddrTypeDisByMulti(addrCodes, industryCodes);
+    public List<BrandAddrDistribution> searchAddrDistribution(List<String> addrCodes) {
+        List<BrandAddrDistribution> list = brandZoneMapper.searchByAddrCodeGroup(addrCodes);
+        return list;
     }
 }

+ 4 - 52
benyun-core/src/main/resources/mapper/BrandMapper.xml

@@ -34,9 +34,8 @@
         <result property="total" column="total"/>
         <result property="updateTime" column="update_time"/>
     </resultMap>
-    <resultMap type="com.benyun.core.entity.bo.BrandAddrTypeDistribution" id="AddrTypeDisResult">
+    <resultMap type="com.benyun.core.entity.bo.BrandAddrDistribution" id="AddrDisResult">
         <result property="addrCode" column="addr_code"/>
-        <result property="industryCode" column="industry_code"/>
         <result property="count" column="count"/>
     </resultMap>
     <select id="searchList" resultMap="BrandResult">
@@ -54,17 +53,14 @@
             db.brand_name as brand_name,
             brand_img,
             index_score,
-            enterprise_name,
             cover_city_count,
             total,
             bbs.update_time as update_time
         FROM
-            ddt_brand db,
-            ddt_enterprise de,
-            bl_brand_statistics bbs
+            `ddt_brand` db,
+            `bl_brand_statistics` bbs
         WHERE
-            db.enterprise_usci = de.enterprise_usci
-        AND bbs.brand_id = db.brand_id
+            bbs.brand_id = db.brand_id
         <if test="text != null">
             AND db.brand_name LIKE concat('%',#{text},'%')
         </if>
@@ -85,49 +81,5 @@
         <if test="coverUp != null">
             AND cover_city_count <![CDATA[<=]]> #{coverUp}
         </if>
-        <if test="addrCode != null">
-            <foreach collection="addrCode" item="addr_code" open="AND addr_code IN (" separator="," close=")">
-                #{addr_code,jdbcType=VARCHAR}
-            </foreach>
-        </if>
-        <if test="orderBy == 1">
-            ORDER BY
-            db.update_time
-        </if>
-        <if test="orderBy == 2">
-            ORDER BY
-            db.total
-        </if>
-        <if test="orderBy == 3">
-            ORDER BY
-            db.brand_id
-        </if>
-    </select>
-    <select id="searchAddrTypeDisByMulti" resultMap="AddrTypeDisResult">
-        SELECT
-            addr_code,
-            db.industry_code,
-            COUNT(*) count
-        FROM
-            `ddt_brand` db,
-            `ddt_enterprise` de
-        WHERE
-            db.enterprise_usci = de.enterprise_usci
-          AND db.enterprise_usci IS NOT NULL
-        <if test="addrCodes != null">
-            <foreach collection="addrCodes" item="addrCode" open="AND addr_code IN (" separator="," close=")">
-                #{addrCode,jdbcType=VARCHAR}
-            </foreach>
-        </if>
-        <if test="industryCodes != null">
-            <foreach collection="industryCodes" item="industryCode" open="AND db.industry_code IN (" separator="," close=")">
-                #{industryCode,jdbcType=VARCHAR}
-            </foreach>
-        </if>
-        GROUP BY
-            addr_code,
-            db.industry_code
-        ORDER BY count DESC;
     </select>
-
 </mapper>

+ 18 - 0
benyun-core/src/main/resources/mapper/BrandZoneMapper.xml

@@ -17,6 +17,10 @@
         <result property="avgScore" column="avg_score"/>
         <result property="updateTime" column="update_time"/>
     </resultMap>
+    <resultMap type="com.benyun.core.entity.bo.BrandAddrDistribution" id="AddrDisResult">
+        <result property="addrCode" column="addr_code"/>
+        <result property="count" column="count"/>
+    </resultMap>
     <select id="searchByBrandId" resultMap="BrandZoneResult">
         select * from bl_brand_zone_distribution where brand_id = #{brandId}
     </select>
@@ -43,4 +47,18 @@
             </if>
         </trim>
     </select>
+    <select id="searchByAddrCodeGroup" resultMap="AddrDisResult">
+        SELECT
+            addr_code,
+            COUNT(*) count
+        FROM
+            `bl_brand_zone_distribution`
+        <where>
+            <foreach collection="addrCodes" item="addrCode" open="addr_code IN (" separator="," close=")">
+                #{addrCode,jdbcType=VARCHAR}
+            </foreach>
+        </where>
+        GROUP BY
+            addr_code;
+    </select>
 </mapper>

+ 2 - 5
benyun-core/src/test/java/com/benyun/core/service/BrandServiceImplTest.java

@@ -1,6 +1,6 @@
 package com.benyun.core.service;
 
-import com.benyun.core.entity.bo.BrandAddrTypeDistribution;
+import com.benyun.core.entity.bo.BrandAddrDistribution;
 import com.benyun.core.entity.bo.BrandSearch;
 import com.benyun.core.entity.vo.BrandListQueryBody;
 import com.github.pagehelper.PageInfo;
@@ -110,10 +110,7 @@ public class BrandServiceImplTest {
         List<String> addrCodes = new ArrayList<>();
         addrCodes.add("410105000000");
         addrCodes.add("420111000000");
-        List<String> industryCodes = new ArrayList<>();
-        industryCodes.add("199");
-        industryCodes.add("28");
-        List<BrandAddrTypeDistribution> list = brandService.searchAddrTypeDisByMulti(addrCodes, industryCodes);
+        List<BrandAddrDistribution> list = brandService.searchAddrDistribution(addrCodes);
         System.out.println(list);
     }
 }