Browse Source

Merge branch 'lcy' of http://47.107.53.207:3000/traineeCoder001/Bailian-Al

# Conflicts:
#	benyun-core/src/main/java/com/ruoyi/benyun/entity/Brand.java
JensionDzero 1 year ago
parent
commit
8d0bf735af
20 changed files with 168 additions and 27 deletions
  1. 4 0
      benyun-core/src/main/java/com/ruoyi/benyun/entity/Brand.java
  2. 22 0
      benyun-core/src/main/java/com/ruoyi/benyun/job/AttentionPoolJob.java
  3. 2 0
      benyun-core/src/main/java/com/ruoyi/benyun/mapper/AttentionPoolDao.java
  4. 1 1
      benyun-core/src/main/java/com/ruoyi/benyun/mapper/BrandBusinessDao.java
  5. 1 0
      benyun-core/src/main/java/com/ruoyi/benyun/mapper/BrandDao.java
  6. 2 1
      benyun-core/src/main/java/com/ruoyi/benyun/mapper/BrandZoneDao.java
  7. 1 0
      benyun-core/src/main/java/com/ruoyi/benyun/mapper/BusinessOpportunitiesDao.java
  8. 1 0
      benyun-core/src/main/java/com/ruoyi/benyun/mapper/FollowUpDao.java
  9. 41 0
      benyun-core/src/main/java/com/ruoyi/benyun/utils/statistics/AttentionPoolStat.java
  10. 6 2
      benyun-core/src/main/java/com/ruoyi/benyun/utils/statistics/BrandBusinessStat.java
  11. 8 3
      benyun-core/src/main/java/com/ruoyi/benyun/utils/statistics/BrandCityStat.java
  12. 11 3
      benyun-core/src/main/java/com/ruoyi/benyun/utils/statistics/BrandProvinceStat.java
  13. 7 3
      benyun-core/src/main/java/com/ruoyi/benyun/utils/statistics/BrandStat.java
  14. 12 8
      benyun-core/src/main/java/com/ruoyi/benyun/utils/statistics/BrandZoneStat.java
  15. 14 0
      benyun-core/src/main/resources/mapper/benyun/AttentionPoolMapper.xml
  16. 3 3
      benyun-core/src/main/resources/mapper/benyun/BrandBusinessMapper.xml
  17. 7 0
      benyun-core/src/main/resources/mapper/benyun/BrandDao.xml
  18. 9 3
      benyun-core/src/main/resources/mapper/benyun/BrandZone2Mapper.xml
  19. 8 0
      benyun-core/src/main/resources/mapper/benyun/BusinessOpportunitiesMapper.xml
  20. 8 0
      benyun-core/src/main/resources/mapper/benyun/FollowUpMapper.xml

+ 4 - 0
benyun-core/src/main/java/com/ruoyi/benyun/entity/Brand.java

@@ -21,12 +21,16 @@ public class Brand {
     private String brandId;
     @TableField("brand_img")
     private String brandImg;
+
     @TableField("brand_name")
     private String brandName;
+
     @TableField("industry_code")
     private String industryCode;
+
     @TableField("enterprise_usci")
     private String enterpriseUsci;
+
     @TableField("per_capita_consumption")
     private Float perCapitaConsumption;
     @TableField("comment_count")

+ 22 - 0
benyun-core/src/main/java/com/ruoyi/benyun/job/AttentionPoolJob.java

@@ -0,0 +1,22 @@
+package com.ruoyi.benyun.job;
+
+import com.ruoyi.benyun.utils.statistics.AttentionPoolStat;
+import lombok.extern.slf4j.Slf4j;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Slf4j
+@Component
+public class AttentionPoolJob  implements Job {
+    @Autowired
+    AttentionPoolStat stat;
+
+    // 每天一次
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        stat.insert();
+    }
+}

+ 2 - 0
benyun-core/src/main/java/com/ruoyi/benyun/mapper/AttentionPoolDao.java

@@ -15,4 +15,6 @@ public interface AttentionPoolDao extends BaseMapper<AttentionPool> {
     AttentionPool searchByAttentionIdAndUserId(@Param("attentionId") String attentionId, @Param("userId") String userId);
     AttentionPool searchByBrandIdOrWdIdAndUserId(@Param("brandId") String brandId, @Param("wdId") String wdId, @Param("userId") String userId);
     int deleteByBrandIdOrWdIdAndUserId(@Param("brandId") String brandId, @Param("wdId") String wdId, @Param("userId") String userId);
+    Integer selectCount(@Param("userId") String userId);
+    List<String> selectAllUser();
 }

+ 1 - 1
benyun-core/src/main/java/com/ruoyi/benyun/mapper/BrandBusinessDao.java

@@ -9,6 +9,6 @@ import java.util.List;
 
 @Mapper
 public interface BrandBusinessDao extends BaseMapper<BrandBusiness> {
-    List<BrandBusiness> selectByStatistics(@Param("notIns") List<String> notIns);
+    List<BrandBusiness> selectByStatistics(@Param("ins") List<String> ins);
     List<String> selectIns();
 }

+ 1 - 0
benyun-core/src/main/java/com/ruoyi/benyun/mapper/BrandDao.java

@@ -18,4 +18,5 @@ public interface BrandDao extends BaseMapper<Brand> {
     void updateCommentCountByBrandId(String brandId);
     void updateIndexScoreByBrandId(String brandId);
     List<Brand> searchNotIns(@Param("notIns") List<String> notIns);
+    List<String> selectAllId();
 }

+ 2 - 1
benyun-core/src/main/java/com/ruoyi/benyun/mapper/BrandZoneDao.java

@@ -16,5 +16,6 @@ public interface BrandZoneDao extends BaseMapper<BrandZone> {
     Integer searchCityCountByBrandId(String brandId);
     Integer searchZoneCountByBrandId(String brandId);
     List<String> searchStatedBrandIds(@Param("month") String month);
-    List<BrandZone> searchQuicklyStatistics(@Param("notIns") List<String> notIns);
+    List<BrandZone> searchQuicklyStatistics(@Param("ins") List<String> ins);
+    List<String> selectIns();
 }

+ 1 - 0
benyun-core/src/main/java/com/ruoyi/benyun/mapper/BusinessOpportunitiesDao.java

@@ -14,4 +14,5 @@ public interface BusinessOpportunitiesDao extends BaseMapper<BusinessOpportuniti
     int deleteByAttentionIdAndUserId(@Param("attentionId")String attentionId, @Param("userId") String userId);
     List<BusinessOpportunitiesClue> searchAllByMulti(@Param("text") String text, @Param("userId") String userId);
     int updateFollowUpCountByClueIdAndUserId(@Param("clueId") String clueId, @Param("count") Integer count , @Param("userId") String userId);
+    Integer selectCount(@Param("userId") String userId);
 }

+ 1 - 0
benyun-core/src/main/java/com/ruoyi/benyun/mapper/FollowUpDao.java

@@ -13,4 +13,5 @@ public interface FollowUpDao extends BaseMapper<FollowUpRecord> {
     List<FollowUpRecord> searchAllByClueIdAndUserId(@Param("clueId") String clueId, @Param("userId") String userId);
     int deleteByClueIdAndUserId(@Param("clueId") String clueId, @Param("userId") String userId);
     List<FollowUpRecord> searchAllByMulti(@Param("clueId") String clueId,@Param("text") String text, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("userId") String userId);
+    Integer selectCountByWay(@Param("userId") String userId, @Param("way") String way);
 }

+ 41 - 0
benyun-core/src/main/java/com/ruoyi/benyun/utils/statistics/AttentionPoolStat.java

@@ -0,0 +1,41 @@
+package com.ruoyi.benyun.utils.statistics;
+
+import com.ruoyi.benyun.entity.AttentionPoolStatistics;
+import com.ruoyi.benyun.mapper.AttentionPoolDao;
+import com.ruoyi.benyun.mapper.AttentionPoolStatisticsDao;
+import com.ruoyi.benyun.mapper.BusinessOpportunitiesDao;
+import com.ruoyi.benyun.mapper.FollowUpDao;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.List;
+import java.util.UUID;
+
+@Component
+public class AttentionPoolStat {
+    @Autowired
+    AttentionPoolDao poolDao;
+    @Autowired
+    BusinessOpportunitiesDao opportunitiesDao;
+    @Autowired
+    FollowUpDao followUpDao;
+    @Autowired
+    AttentionPoolStatisticsDao statisticsDao;
+
+    public void insert(){
+        List<String> ins = poolDao.selectAllUser();
+        for (String userId : ins){
+            AttentionPoolStatistics statistics = new AttentionPoolStatistics();
+            statistics.setStatId(UUID.randomUUID().toString().replace("-",""));
+            statistics.setAttentionCount(poolDao.selectCount(userId));
+            statistics.setClueCount(opportunitiesDao.selectCount(userId));
+            statistics.setOnlineCount(followUpDao.selectCountByWay(userId,"线上电话"));
+            statistics.setOfflineCount(followUpDao.selectCountByWay(userId,"线下实地"));
+            statistics.setUserId(userId);
+            statistics.setStatTime(LocalDateTime.now(ZoneId.of("Asia/Shanghai")));
+            statisticsDao.insert(statistics);
+        }
+    }
+}

+ 6 - 2
benyun-core/src/main/java/com/ruoyi/benyun/utils/statistics/BrandBusinessStat.java

@@ -2,6 +2,7 @@ package com.ruoyi.benyun.utils.statistics;
 
 import com.ruoyi.benyun.entity.BrandBusiness;
 import com.ruoyi.benyun.mapper.BrandBusinessDao;
+import com.ruoyi.benyun.mapper.BrandZoneDao;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -11,10 +12,13 @@ import java.util.List;
 public class BrandBusinessStat {
     @Autowired
     BrandBusinessDao brandBusinessDao;
+    @Autowired
+    BrandZoneDao zoneDao;
 
     public void continueInsert(){
-        List<String> ins = brandBusinessDao.selectIns();
-        System.out.println("已经处理:" + ins.size() + "个");
+//        List<String> ins = brandBusinessDao.selectIns();
+//        System.out.println("已经处理:" + ins.size() + "个");
+        List<String> ins = zoneDao.selectIns();
         List<BrandBusiness> brandBusinesses = brandBusinessDao.selectByStatistics(ins);
         int i = 0;
         int total = brandBusinesses.size();

+ 8 - 3
benyun-core/src/main/java/com/ruoyi/benyun/utils/statistics/BrandCityStat.java

@@ -1,5 +1,6 @@
 package com.ruoyi.benyun.utils.statistics;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.ruoyi.benyun.entity.Brand;
 import com.ruoyi.benyun.entity.BrandCity;
 import com.ruoyi.benyun.mapper.BrandCityDao;
@@ -27,9 +28,13 @@ public class BrandCityStat {
     StoreDao storeDao;
 
     public void continueInsert(){
-        List<String> notIns = brandCityDao.selectIns();
-        System.out.println("已处理:" + notIns.size() + "个");
-        List<Brand> brands = brandDao.searchNotIns(notIns);
+//        List<String> ins = brandCityDao.selectIns();
+//        System.out.println("已处理:" + notIns.size() + "个");
+//        List<Brand> brands = brandDao.searchNotIns(notIns);
+        List<String> ins = brandZoneDao.selectIns();
+        QueryWrapper<Brand> queryWrapper = new QueryWrapper<>();
+        queryWrapper.in("brand_id",ins);
+        List<Brand> brands = brandDao.selectList(queryWrapper);
         int index = 1;
         int total = brands.size();
         for (Brand brand : brands){

+ 11 - 3
benyun-core/src/main/java/com/ruoyi/benyun/utils/statistics/BrandProvinceStat.java

@@ -1,7 +1,9 @@
 package com.ruoyi.benyun.utils.statistics;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.ruoyi.benyun.entity.Brand;
 import com.ruoyi.benyun.entity.BrandProvince;
+import com.ruoyi.benyun.mapper.BrandCityDao;
 import com.ruoyi.benyun.mapper.BrandDao;
 import com.ruoyi.benyun.mapper.BrandProvinceDao;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -19,11 +21,17 @@ public class BrandProvinceStat {
     BrandDao brandDao;
     @Autowired
     BrandProvinceDao brandProvinceDao;
+    @Autowired
+    BrandCityDao cityDao;
 
     public void continueInsert(){
-        List<String> notIns = brandProvinceDao.selectIns();
-        System.out.println("已处理:" + notIns.size() + "个");
-        List<Brand> brands = brandDao.searchNotIns(notIns);
+//        List<String> notIns = brandProvinceDao.selectIns();
+//        System.out.println("已处理:" + notIns.size() + "个");
+//        List<Brand> brands = brandDao.searchNotIns(notIns);
+        List<String> ins = cityDao.selectIns();
+        QueryWrapper<Brand> queryWrapper = new QueryWrapper<>();
+        queryWrapper.in("brand_id",ins);
+        List<Brand> brands = brandDao.selectList(queryWrapper);
         int index = 1;
         int total = brands.size();
         for (Brand brand : brands){

+ 7 - 3
benyun-core/src/main/java/com/ruoyi/benyun/utils/statistics/BrandStat.java

@@ -32,10 +32,14 @@ public class BrandStat {
 
     public void continueInsertPlus2(){
 //        查询已统计的品牌
-        List<String> notIns = brandStatisticsDao.searchStated();
-        System.out.println("已处理品牌:"+notIns.size()+"个");
+//        List<String> notIns = brandStatisticsDao.searchStated();
+//        System.out.println("已处理品牌:"+notIns.size()+"个");
 //        处理剩下的
-        List<Brand> brands = brandMapper.searchNotIns(notIns);
+//        List<Brand> brands = brandMapper.searchNotIns(notIns);
+        List<String> ins = brandZoneDao.selectIns();
+        QueryWrapper<Brand> queryWrapper = new QueryWrapper<>();
+        queryWrapper.in("brand_id",ins);
+        List<Brand> brands = brandMapper.selectList(queryWrapper);
         int index = 0;
         int total = brands.size();
         for (Brand brand : brands){

+ 12 - 8
benyun-core/src/main/java/com/ruoyi/benyun/utils/statistics/BrandZoneStat.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.ruoyi.benyun.entity.AddrCategory;
 import com.ruoyi.benyun.entity.BrandZone;
 import com.ruoyi.benyun.mapper.AddrCategoryDao;
+import com.ruoyi.benyun.mapper.BrandDao;
 import com.ruoyi.benyun.mapper.BrandZoneDao;
 import com.ruoyi.benyun.mapper.StoreDao;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -22,11 +23,12 @@ public class BrandZoneStat {
     BrandZoneDao brandZoneDao;
     @Autowired
     AddrCategoryDao addrCategoryDao;
+    @Autowired
+    BrandDao brandDao;
 
     public void continueQuicklyInsert(){
-        List<String> notIns = brandZoneDao.searchStatedBrandIds(null);
-        System.out.println("已经处理:" + notIns.size() + "个品牌");
-        List<BrandZone> zones = brandZoneDao.searchQuicklyStatistics(notIns);
+        List<String> ins = brandDao.selectAllId();
+        List<BrandZone> zones = brandZoneDao.searchQuicklyStatistics(ins);
         int total = zones.size();
         int i = 0;
         for (BrandZone zone : zones) {
@@ -36,11 +38,13 @@ public class BrandZoneStat {
             QueryWrapper<AddrCategory> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("addr_code",zone.getAddrCode());
             AddrCategory one = addrCategoryDao.selectOne(queryWrapper);
-            zone.setZone(one.getDistrict());
-            zone.setCity(one.getCity());
-            zone.setProvince(one.getProvince());
-            zone.setLat(one.getLatGd());
-            zone.setLng(one.getLngGd());
+            if (one != null){
+                zone.setZone(one.getDistrict());
+                zone.setCity(one.getCity());
+                zone.setProvince(one.getProvince());
+                zone.setLat(one.getLatGd());
+                zone.setLng(one.getLngGd());
+            }
 
             i += brandZoneDao.insert(zone);
             System.out.println(i+"/"+total);

+ 14 - 0
benyun-core/src/main/resources/mapper/benyun/AttentionPoolMapper.xml

@@ -76,4 +76,18 @@
             and attention_id = #{attentionId}
         </trim>
     </select>
+    <select id="selectCount" resultType="java.lang.Integer">
+        SELECT
+            COUNT(*) count
+        FROM
+            `bl_attention_pool`
+        WHERE
+            user_id = #{userId}
+    </select>
+    <select id="selectAllUser" resultType="java.lang.String">
+        SELECT DISTINCT
+            user_id
+        FROM
+            `bl_attention_pool`;
+    </select>
 </mapper>

+ 3 - 3
benyun-core/src/main/resources/mapper/benyun/BrandBusinessMapper.xml

@@ -13,9 +13,9 @@
             `ddt_store_wd`
         WHERE brand_id <![CDATA[<>]]> ''
         AND brand_id IS NOT NULL
-        <if test="notIns != null">
-            <foreach collection="notIns" item="notIn" open="AND brand_id NOT IN (" separator="," close=")">
-                #{notIn,jdbcType=VARCHAR}
+        <if test="ins != null">
+            <foreach collection="ins" item="in" open="AND brand_id IN (" separator="," close=")">
+                #{in,jdbcType=VARCHAR}
             </foreach>
         </if>
         GROUP BY

+ 7 - 0
benyun-core/src/main/resources/mapper/benyun/BrandDao.xml

@@ -107,4 +107,11 @@
             </if>
         </where>
     </select>
+    <select id="selectAllId" resultType="java.lang.String">
+        SELECT DISTINCT
+            brand_id
+        FROM
+            `ddt_brand`
+        WHERE show_delete = 0;
+    </select>
 </mapper>

+ 9 - 3
benyun-core/src/main/resources/mapper/benyun/BrandZone2Mapper.xml

@@ -132,9 +132,9 @@
             dsw.wd_id = dwi.wd_id
         AND brand_id IS NOT NULL
         AND brand_id <![CDATA[<>]]> ''
-        <if test="notIns != null">
-            <foreach collection="notIns" item="notIn" open="and brand_id not in (" separator="," close=")">
-                #{notIn,jdbcType=VARCHAR}
+        <if test="ins != null">
+            <foreach collection="ins" item="in" open="and brand_id in (" separator="," close=")">
+                #{in,jdbcType=VARCHAR}
             </foreach>
         </if>
         GROUP BY
@@ -142,4 +142,10 @@
             brand_name,
             addr_code;
     </select>
+    <select id="selectIns" resultType="java.lang.String">
+        SELECT DISTINCT
+            brand_id
+        FROM
+            `bl_brand_zone_distribution`;
+    </select>
 </mapper>

+ 8 - 0
benyun-core/src/main/resources/mapper/benyun/BusinessOpportunitiesMapper.xml

@@ -65,4 +65,12 @@
             </if>
         </trim>
     </select>
+    <select id="selectCount" resultType="java.lang.Integer">
+        SELECT
+            COUNT(*) count
+        FROM
+            `bl_business_opportunities_clue`
+        WHERE
+            user_id = #{userId};
+    </select>
 </mapper>

+ 8 - 0
benyun-core/src/main/resources/mapper/benyun/FollowUpMapper.xml

@@ -59,4 +59,12 @@
             </if>
         </trim>
     </select>
+    <select id="selectCountByWay" resultType="java.lang.Integer">
+        SELECT
+            COUNT(*)
+        FROM
+            `bl_follow_up_record`
+        WHERE user_id = #{userId}
+        AND follow_way = #{way};
+    </select>
 </mapper>