Bladeren bron

分析统计

傅行帆 5 jaren geleden
bovenliggende
commit
f02b992fb6

+ 29
- 1
src/main/java/com/huiju/estateagents/statistic/controller/TaCustomerGenderStatisticController.java Bestand weergeven

@@ -18,6 +18,9 @@ import org.springframework.web.bind.annotation.RequestParam;
18 18
 import org.springframework.web.bind.annotation.ResponseBody;
19 19
 import org.springframework.web.bind.annotation.RestController;
20 20
 
21
+import javax.servlet.http.HttpServletRequest;
22
+import java.util.List;
23
+
21 24
 /**
22 25
  * <p>
23 26
     * 客户分析性别统计表 小程序盘客工具客户分析 前端控制器
@@ -27,7 +30,7 @@ import org.springframework.web.bind.annotation.RestController;
27 30
  * @since 2019-11-08
28 31
  */
29 32
 @RestController
30
-@RequestMapping("/")
33
+@RequestMapping("/api")
31 34
 public class TaCustomerGenderStatisticController extends BaseController {
32 35
 
33 36
     private final Logger logger = LoggerFactory.getLogger(TaCustomerGenderStatisticController.class);
@@ -146,4 +149,29 @@ public class TaCustomerGenderStatisticController extends BaseController {
146 149
         }
147 150
         return responseBean;
148 151
     }
152
+    
153
+    /**
154
+     * 微信端查询三条性别列表数据
155
+     * @return
156
+     */
157
+    @RequestMapping(value="/wx/genderStatistic/{customerType}",method= RequestMethod.GET)
158
+    public ResponseBean wxCustomerGenderStatisticList(@PathVariable(value = "customerType") String customerType, HttpServletRequest request){
159
+        ResponseBean responseBean = new ResponseBean();
160
+        try {
161
+            //查询当前小程序的男女比统计
162
+            QueryWrapper<TaCustomerGenderStatistic> queryWrapper = new QueryWrapper<>();
163
+            queryWrapper.eq("org_id",getOrgId(request));
164
+            queryWrapper.eq("customer_type",customerType);
165
+            queryWrapper.orderByDesc("create_date");
166
+     
167
+            List<TaCustomerGenderStatistic> result = iTaCustomerGenderStatisticService.list(queryWrapper);
168
+            responseBean.addSuccess(result);
169
+        }catch (Exception e){
170
+            e.printStackTrace();
171
+            logger.error("taCustomerGenderStatisticList -=- {}",e.toString());
172
+            responseBean.addError(e.getMessage());
173
+        }
174
+        return responseBean;
175
+    }
176
+    
149 177
 }

+ 24
- 1
src/main/java/com/huiju/estateagents/statistic/controller/TaCustomerStatisticDailyController.java Bestand weergeven

@@ -18,6 +18,9 @@ import org.springframework.web.bind.annotation.RequestParam;
18 18
 import org.springframework.web.bind.annotation.ResponseBody;
19 19
 import org.springframework.web.bind.annotation.RestController;
20 20
 
21
+import javax.servlet.http.HttpServletRequest;
22
+import java.util.List;
23
+
21 24
 /**
22 25
  * <p>
23 26
     * 客户分析日统计表 小程序盘客工具客户分析 前端控制器
@@ -27,7 +30,7 @@ import org.springframework.web.bind.annotation.RestController;
27 30
  * @since 2019-11-08
28 31
  */
29 32
 @RestController
30
-@RequestMapping("/")
33
+@RequestMapping("/api")
31 34
 public class TaCustomerStatisticDailyController extends BaseController {
32 35
 
33 36
     private final Logger logger = LoggerFactory.getLogger(TaCustomerStatisticDailyController.class);
@@ -146,4 +149,24 @@ public class TaCustomerStatisticDailyController extends BaseController {
146 149
         }
147 150
         return responseBean;
148 151
     }
152
+    
153
+    /**
154
+     * 微信端查询日客户分析统计数据
155
+     * 日筛选:可以选择包括当前日往前的31日
156
+     * @return
157
+     */
158
+    @RequestMapping(value="/wx/customerStatisticDaily/{customerType}",method= RequestMethod.GET)
159
+    public ResponseBean wxCustomerStatisticDailyList(@PathVariable(value = "customerType") String customerType,
160
+                                                     HttpServletRequest request){
161
+        ResponseBean responseBean = new ResponseBean();
162
+        try {
163
+            List<TaCustomerStatisticDaily> list = iTaCustomerStatisticDailyService.getDailyList(customerType,getOrgId(request));
164
+            responseBean.addSuccess(list);
165
+        }catch (Exception e){
166
+            e.printStackTrace();
167
+            logger.error("wxCustomerStatisticDailyList -=- {}",e.toString());
168
+            responseBean.addError(e.getMessage());
169
+        }
170
+        return responseBean;
171
+    }
149 172
 }

+ 25
- 1
src/main/java/com/huiju/estateagents/statistic/controller/TaCustomerStatisticMonthlyController.java Bestand weergeven

@@ -18,6 +18,9 @@ import org.springframework.web.bind.annotation.RequestParam;
18 18
 import org.springframework.web.bind.annotation.ResponseBody;
19 19
 import org.springframework.web.bind.annotation.RestController;
20 20
 
21
+import javax.servlet.http.HttpServletRequest;
22
+import java.util.List;
23
+
21 24
 /**
22 25
  * <p>
23 26
     * 客户分析月统计表 小程序盘客工具客户分析 前端控制器
@@ -27,7 +30,7 @@ import org.springframework.web.bind.annotation.RestController;
27 30
  * @since 2019-11-08
28 31
  */
29 32
 @RestController
30
-@RequestMapping("/")
33
+@RequestMapping("/api")
31 34
 public class TaCustomerStatisticMonthlyController extends BaseController {
32 35
 
33 36
     private final Logger logger = LoggerFactory.getLogger(TaCustomerStatisticMonthlyController.class);
@@ -146,4 +149,25 @@ public class TaCustomerStatisticMonthlyController extends BaseController {
146 149
         }
147 150
         return responseBean;
148 151
     }
152
+    
153
+    /**
154
+     * 微信端查询月客户分析统计数据
155
+     * 月筛选:可以选择包括当前月往前的12个月
156
+     * @return
157
+     */
158
+    @RequestMapping(value="/wx/customerStatisticMonthly/{customerType}",method= RequestMethod.GET)
159
+    public ResponseBean taCustomerStatisticMonthlyList(@PathVariable(value = "customerType") String customerType,
160
+                                                       HttpServletRequest request){
161
+        ResponseBean responseBean = new ResponseBean();
162
+        try {
163
+            //查询月客户分析数据
164
+            List<TaCustomerStatisticMonthly> result = iTaCustomerStatisticMonthlyService.getCustomerMonthlyList(customerType, getOrgId(request));
165
+            responseBean.addSuccess(result);
166
+        }catch (Exception e){
167
+            e.printStackTrace();
168
+            logger.error("taCustomerStatisticMonthlyList -=- {}",e.toString());
169
+            responseBean.addError(e.getMessage());
170
+        }
171
+        return responseBean;
172
+    }
149 173
 }

+ 10
- 0
src/main/java/com/huiju/estateagents/statistic/mapper/TaCustomerStatisticDailyMapper.java Bestand weergeven

@@ -42,4 +42,14 @@ public interface TaCustomerStatisticDailyMapper extends BaseMapper<TaCustomerSta
42 42
 	 * @return
43 43
 	 */
44 44
 	List<TaCustomerStatisticDaily> getVisiteCustomerData(@Param("nowDate") LocalDateTime nowDate,@Param("checkin") int checkin);
45
+	
46
+	/**
47
+	 * 获取31天的统计数据
48
+	 * @param customerType
49
+	 * @param orgId
50
+	 * @param nowDate
51
+	 * @param beforeDate
52
+	 * @return
53
+	 */
54
+	List<TaCustomerStatisticDaily> getDailyList(@Param("customerType") String customerType,@Param("orgId")  Integer orgId,@Param("nowDate")  LocalDateTime nowDate,@Param("beforeDate")  LocalDateTime beforeDate);
45 55
 }

+ 10
- 0
src/main/java/com/huiju/estateagents/statistic/mapper/TaCustomerStatisticMonthlyMapper.java Bestand weergeven

@@ -41,4 +41,14 @@ public interface TaCustomerStatisticMonthlyMapper extends BaseMapper<TaCustomerS
41 41
 	 * @return
42 42
 	 */
43 43
 	List<TaCustomerStatisticMonthly> getVisiteStatisticMonthly(@Param("nowDate") LocalDateTime nowDate,@Param("checkin") int checkin);
44
+	
45
+	/**
46
+	 * 获取12个月的统计数据
47
+	 * @param customerType
48
+	 * @param orgId
49
+	 * @param nowDate
50
+	 * @param beforeDate
51
+	 * @return
52
+	 */
53
+	List<TaCustomerStatisticMonthly> getMonthlyList(@Param("customerType") String customerType,@Param("orgId") Integer orgId,@Param("nowDate") LocalDateTime nowDate,@Param("beforeDate") LocalDateTime beforeDate);
44 54
 }

+ 9
- 0
src/main/java/com/huiju/estateagents/statistic/service/ITaCustomerStatisticDailyService.java Bestand weergeven

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
4 4
 import com.huiju.estateagents.statistic.entity.TaCustomerStatisticDaily;
5 5
 
6 6
 import java.time.LocalDateTime;
7
+import java.util.List;
7 8
 
8 9
 /**
9 10
  * <p>
@@ -32,4 +33,12 @@ public interface ITaCustomerStatisticDailyService extends IService<TaCustomerSta
32 33
 	 * @param nowDate
33 34
 	 */
34 35
 	void visiteStatisticDaily(LocalDateTime nowDate);
36
+	
37
+	/**
38
+	 * 获取日统计数据
39
+	 * @param customerType
40
+	 * @param orgId
41
+	 * @return
42
+	 */
43
+	List<TaCustomerStatisticDaily> getDailyList(String customerType, Integer orgId);
35 44
 }

+ 9
- 0
src/main/java/com/huiju/estateagents/statistic/service/ITaCustomerStatisticMonthlyService.java Bestand weergeven

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
4 4
 import com.huiju.estateagents.statistic.entity.TaCustomerStatisticMonthly;
5 5
 
6 6
 import java.time.LocalDateTime;
7
+import java.util.List;
7 8
 
8 9
 /**
9 10
  * <p>
@@ -32,4 +33,12 @@ public interface ITaCustomerStatisticMonthlyService extends IService<TaCustomerS
32 33
 	 * @param nowDate
33 34
 	 */
34 35
 	void visiteStatisticMonthly(LocalDateTime nowDate);
36
+	
37
+	/**
38
+	 * 查询12个月的客户统计分析数据
39
+	 * @param customerType
40
+	 * @param orgId
41
+	 * @return
42
+	 */
43
+	List<TaCustomerStatisticMonthly> getCustomerMonthlyList(String customerType, Integer orgId);
35 44
 }

+ 18
- 0
src/main/java/com/huiju/estateagents/statistic/service/impl/TaCustomerStatisticDailyServiceImpl.java Bestand weergeven

@@ -73,6 +73,24 @@ public class TaCustomerStatisticDailyServiceImpl extends ServiceImpl<TaCustomerS
73 73
 		statisticDailySaveBatch(saveList,nowDate,CommConstant.CUSTOMER_TYPE_VISITE);
74 74
 	}
75 75
 	
76
+	/**
77
+	 * 获取日统计数据
78
+	 *
79
+	 * @param customerType
80
+	 * @param orgId
81
+	 * @return
82
+	 */
83
+	@Override
84
+	public List<TaCustomerStatisticDaily> getDailyList(String customerType, Integer orgId) {
85
+		//当前日期
86
+		LocalDateTime nowDate = LocalDateTime.now();
87
+		//31天前的日期
88
+		LocalDateTime beforeDate = nowDate.plusDays(-31);
89
+		//获取31天的日期数据
90
+		List<TaCustomerStatisticDaily> list = customerStatisticDailyMapper.getDailyList(customerType,orgId,nowDate,beforeDate);
91
+		return list;
92
+	}
93
+	
76 94
 	/**
77 95
 	 * 批量保存当天的统计数据
78 96
 	 * @param list

+ 19
- 0
src/main/java/com/huiju/estateagents/statistic/service/impl/TaCustomerStatisticMonthlyServiceImpl.java Bestand weergeven

@@ -3,6 +3,7 @@ package com.huiju.estateagents.statistic.service.impl;
3 3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5 5
 import com.huiju.estateagents.common.CommConstant;
6
+import com.huiju.estateagents.statistic.entity.TaCustomerStatisticDaily;
6 7
 import com.huiju.estateagents.statistic.entity.TaCustomerStatisticMonthly;
7 8
 import com.huiju.estateagents.statistic.mapper.TaCustomerStatisticMonthlyMapper;
8 9
 import com.huiju.estateagents.statistic.service.ITaCustomerStatisticMonthlyService;
@@ -71,6 +72,24 @@ public class TaCustomerStatisticMonthlyServiceImpl extends ServiceImpl<TaCustome
71 72
 		statisticMonthlySaveBatch(newVisiteMonthList,nowDate, CommConstant.CUSTOMER_TYPE_FOLLOW);
72 73
 	}
73 74
 	
75
+	/**
76
+	 * 查询12个月的客户统计分析数据
77
+	 *
78
+	 * @param customerType
79
+	 * @param orgId
80
+	 * @return
81
+	 */
82
+	@Override
83
+	public List<TaCustomerStatisticMonthly> getCustomerMonthlyList(String customerType, Integer orgId) {
84
+		//当前日期
85
+		LocalDateTime nowDate = LocalDateTime.now();
86
+		//12个月前的日期
87
+		LocalDateTime beforeDate = nowDate.plusMonths(-12);
88
+		//获取31天的日期数据
89
+		List<TaCustomerStatisticMonthly> list = customerStatisticMonthlyMapper.getMonthlyList(customerType,orgId,nowDate,beforeDate);
90
+		return list;
91
+	}
92
+	
74 93
 	/**
75 94
 	 * 批量保存当月的统计数据
76 95
 	 * @param list

+ 12
- 0
src/main/resources/mapper/statistic/TaCustomerStatisticDailyMapper.xml Bestand weergeven

@@ -41,4 +41,16 @@
41 41
         GROUP BY
42 42
             c.org_id
43 43
     </select>
44
+
45
+    <select id="getDailyList" resultType="com.huiju.estateagents.statistic.entity.TaCustomerStatisticDaily">
46
+        SELECT
47
+          *
48
+        FROM
49
+          ta_customer_statistic_daily
50
+        WHERE
51
+          org_id = #{orgId}
52
+        AND customer_type = #{customerType}
53
+        AND date_format( create_date, '%Y-%m-%d' ) >= date_format( #{beforeDate}, '%Y-%m-%d' )
54
+        AND date_format( create_date, '%Y-%m-%d' ) &lt;= date_format( #{nowDate}, '%Y-%m-%d' )
55
+    </select>
44 56
 </mapper>

+ 11
- 0
src/main/resources/mapper/statistic/TaCustomerStatisticMonthlyMapper.xml Bestand weergeven

@@ -44,4 +44,15 @@
44 44
         GROUP BY
45 45
             c.org_id
46 46
     </select>
47
+    <select id="getMonthlyList" resultType="com.huiju.estateagents.statistic.entity.TaCustomerStatisticMonthly">
48
+        SELECT
49
+          *
50
+        FROM
51
+          ta_customer_statistic_monthly
52
+        WHERE
53
+          org_id = #{orgId}
54
+        AND customer_type = #{customerType}
55
+        AND date_format( create_date, '%Y-%m-%d' ) >= date_format( #{beforeDate}, '%Y-%m-%d' )
56
+        AND date_format( create_date, '%Y-%m-%d' ) &lt;= date_format( #{nowDate}, '%Y-%m-%d' )
57
+    </select>
47 58
 </mapper>