Browse Source

营销统计报表后台开发

anderx 7 years ago
parent
commit
2f50d251e8

+ 17 - 7
src/main/java/com/goafanti/common/dao/DailySalesReportMapper.java

@@ -51,17 +51,27 @@ public interface DailySalesReportMapper {
 	List<ModelMap> selectSalesDepartmentExtraReports(@Param("startTime") Date startTime,
 			@Param("endTime") Date endTime);
 
-	List<marketingESBo> findmarketingStatisticsList(@Param("depId")String depId);
-
-	List<marketingESBo> marketingDepStatisticsList(@Param("depId")String depId);
-
-	CountMarketingStatisticsBo privateCustomersCount(@Param("depId")String depId);
-
-	CountDepMarketingStatisticsBo privateCustomersDepCount(@Param("depId")String depId);
+	List<marketingESBo> findmarketingStatisticsList(@Param("depId")String depId, @Param("dayStart")String dayStart, @Param("dayEnd")String dayEnd,
+			@Param("weeklyStart")String weeklyStart, @Param("weeklyEnd")String weeklyEnd, @Param("monthStart")String monthStart, @Param("monthEnd")String monthEnd,
+			@Param("yearStart")String yearStart, @Param("yearEnd")String yearEnd);
+	
+	List<marketingESBo> marketingDepStatisticsList(@Param("depId")String depId, @Param("dayStart")String dayStart, @Param("dayEnd")String dayEnd,
+			@Param("weeklyStart")String weeklyStart, @Param("weeklyEnd")String weeklyEnd, @Param("monthStart")String monthStart, @Param("monthEnd")String monthEnd,
+			@Param("yearStart")String yearStart, @Param("yearEnd")String yearEnd);
+
+	CountMarketingStatisticsBo privateCustomersCount(@Param("depId")String depId, @Param("dayStart")String dayStart, @Param("dayEnd")String dayEnd,
+			@Param("weeklyStart")String weeklyStart, @Param("weeklyEnd")String weeklyEnd, @Param("monthStart")String monthStart, @Param("monthEnd")String monthEnd,
+			@Param("yearStart")String yearStart, @Param("yearEnd")String yearEnd);
+
+	CountDepMarketingStatisticsBo privateCustomersDepCount(@Param("depId")String depId, @Param("dayStart")String dayStart, @Param("dayEnd")String dayEnd,
+			@Param("weeklyStart")String weeklyStart, @Param("weeklyEnd")String weeklyEnd, @Param("monthStart")String monthStart, @Param("monthEnd")String monthEnd,
+			@Param("yearStart")String yearStart, @Param("yearEnd")String yearEnd);
 
 	List<SomeTimeMarketingBo> sometimeMarketingStatistics(@Param("depId")String depId, @Param("startTime")String startTime, @Param("endTime")String endTime);
 
 	List<SomeTimeMarketingBo> sometimeMarketingDepStatistics(@Param("depId")String depId, @Param("startTime")String startTime, @Param("endTime")String endTime);
 
 	SomeTimeMarketingBo countsometimeMarketingStatistics(@Param("depId")String depId, @Param("startTime")String startTime, @Param("endTime")String endTime);
+
+
 }

+ 288 - 59
src/main/java/com/goafanti/common/mapper/DailySalesReportMapper.xml

@@ -167,98 +167,332 @@
   </select>
   
    <select id="findmarketingStatisticsList" parameterType="String" resultType="com.goafanti.report.bo.marketingESBo">
-		select a.id ,a.name,a.department_id as departmentId,d.name as departmentName,d.manager_id,f.name as departmentManagerName,
+		select t1.id,t1.name,t1.departmentId,t1.departmentName,t1.manager_id,t1.departmentManagerName,
+		t1.roleName,t1.privateCustomersCount,t1.entryTime,
+		 t2.yearFollowNo,t2.yearVisitNo,t2.yearTelNo,
+			 t2.monthFollowNo,t2.monthVisitNo,t2.monthTelNo,
+			 t2.weeklyFollowNo,t2.weeklyVisitNo,t2.weeklyTelNo,
+			 t2.dayFollowNo,t2.dayVisitNo,t2.dayTelNo 
+		from(
+		select a.id as id,a.name as name,a.department_id as departmentId,d.name as departmentName,d.manager_id,f.name as departmentManagerName,
 				c.role_name as roleName,ifnull(e.privateCustomersCount,0)as privateCustomersCount,a.create_time as entryTime
 		from admin a left join user_role b
 		on a.id=b.uid left join role c
 		on b.rid=c.id left join department_management d
-		on a.department_id=d.id left join (select aid,count(0) as privateCustomersCount from user group by aid)e
+		on a.department_id=d.id left join (select aid,count(0) as privateCustomersCount from user where aid is not null and aid != '' group by aid)e
 		on a.id=e.aid left join admin f
 		on d.manager_id=f.id
-		where 1=1
-		and (c.role_name='营销员' or c.role_name='营销经理'or c.role_name='营销管理员')
-	<if test="depId != null">
+		where c.role_name in ('营销员' ,'营销经理','营销管理员')
+		<if test="depId != null">
 		and a.department_id = #{depId,jdbcType=VARCHAR}
 	</if>
-	order by a.name desc
+)t1
+left join (
+select x.aid,x.yearFollowNo,x.yearVisitNo,x.yearTelNo,
+			 y.monthFollowNo,y.monthVisitNo,y.monthTelNo,
+			 z.weeklyFollowNo,z.weeklyVisitNo,z.weeklyTelNo,
+			 w.dayFollowNo,w.dayVisitNo,dayTelNo
+			 from (
+select
+			aid,
+			count(0) as yearFollowNo,
+			ifnull(sum(case when contact_type = 0 then 1 else 0 end) ,0)as yearVisitNo, 
+			ifnull(sum(case when contact_type = 1 then 1 else 0 end) ,0)as yearTelNo
+			from user_follow where 1=1
+			and create_time &gt; #{yearStart,jdbcType=VARCHAR}
+			and create_time &lt; #{yearEnd,jdbcType=VARCHAR}
+			group by aid
+)x  left join (
+select
+			aid,
+			count(0) as monthFollowNo,
+			ifnull(sum(case when contact_type = 0 then 1 else 0 end) ,0)as monthVisitNo, 
+			ifnull(sum(case when contact_type = 1 then 1 else 0 end) ,0)as monthTelNo
+			from user_follow where 1=1
+			and create_time &gt; #{monthStart,jdbcType=VARCHAR}
+			and create_time &lt; #{monthEnd,jdbcType=VARCHAR}
+			group by aid
+)y on x.aid = y.aid
+left join (
+select
+			aid,
+			count(0) as weeklyFollowNo,
+			ifnull(sum(case when contact_type = 0 then 1 else 0 end) ,0)as weeklyVisitNo, 
+			ifnull(sum(case when contact_type = 1 then 1 else 0 end) ,0)as weeklyTelNo
+			from user_follow where 1=1
+			and create_time &gt; #{weeklyStart,jdbcType=VARCHAR}
+			and create_time &lt; #{weeklyEnd,jdbcType=VARCHAR}
+			group by aid
+)z on y.aid = z.aid
+left join (
+select
+			aid,
+			count(0) as dayFollowNo,
+			ifnull(sum(case when contact_type = 0 then 1 else 0 end) ,0)as dayVisitNo, 
+			ifnull(sum(case when contact_type = 1 then 1 else 0 end) ,0)as dayTelNo
+			from user_follow where 1=1
+			and create_time &gt; #{dayStart,jdbcType=VARCHAR}
+			and create_time &lt; #{dayEnd,jdbcType=VARCHAR}
+			group by aid
+)w on y.aid = w.aid
+)t2 on t1.id = t2.aid
  </select>
   
   <select id="marketingDepStatisticsList" parameterType="String" resultType="com.goafanti.report.bo.marketingESBo">
-	select
+	select t1.departmentId,t1.departmentName,t1.departmentManagerName,t1.privateCustomersCount,t1.departmentNumber,
+			t2.yearFollowNo,t2.yearVisitNo,t2.yearTelNo,
+			 t2.monthFollowNo,t2.monthVisitNo,t2.monthTelNo,
+			 t2.weeklyFollowNo,t2.weeklyVisitNo,t2.weeklyTelNo,
+			 t2.dayFollowNo,t2.dayVisitNo,t2.dayTelNo ,
+			 t2.dayFollowNo/t1.departmentNumber as dayAVG
+		from(select
 	a.department_id as departmentId,
 	b.name as departmentName,
-	b.manager_id,
 	c.name as departmentManagerName,
 	a.count2 as privateCustomersCount,
 	d.count3 as departmentNumber
-from
-	(
-		select
+from ( select
 			z.department_id,
-			sum( y.count1 ) as count2
-		from
-			(
-				select
-					a.id,
-					count( a.id ) as count1
-				from
-					admin a left join user b on
-					a.id = b.aid 
-				group by
-					a.id
+			sum( y.count1 ) as count2 from
+			( select aid, count( aid ) as count1
+				from user 
+				where aid is not null and aid !=''
+				group by aid
 			) y left join admin z on
-			y.id = z.id
+			y.aid = z.id
 		group by
 			z.department_id
 	) a left join department_management b 
 	on a.department_id = b.id left join admin c
 	on b.manager_id=c.id left join (select department_id,count(0) as count3 from admin   	group by department_id)d
 	on a.department_id = d.department_id
-	where 1=1
+	where a.department_id is not null
 	<if test="depId != null">
 		and a.department_id = #{depId,jdbcType=VARCHAR}
 	</if>
-	order by b.name desc
-		
+)t1
+left join (
+select m.department_id as departmentId,sum(n.dayFollowNo)as dayFollowNo,sum(n.dayVisitNo)as dayVisitNo,sum(n.dayTelNo) as dayTelNo
+					,sum(n.weeklyFollowNo)as weeklyFollowNo,sum(n.weeklyVisitNo)as weeklyVisitNo,sum(n.weeklyTelNo) as weeklyTelNo
+					,sum(n.monthFollowNo)as monthFollowNo,sum(n.monthVisitNo)as monthVisitNo,sum(n.monthTelNo) as monthTelNo
+					,sum(n.yearFollowNo)as yearFollowNo,sum(n.yearVisitNo)as yearVisitNo,sum(n.yearTelNo) as yearTelNo
+from admin m left join 
+(select x.aid,x.yearFollowNo,x.yearVisitNo,x.yearTelNo,
+			 y.monthFollowNo,y.monthVisitNo,y.monthTelNo,
+			 z.weeklyFollowNo,z.weeklyVisitNo,z.weeklyTelNo,
+			 w.dayFollowNo,w.dayVisitNo,dayTelNo
+			 from (
+select
+			aid,
+			count(0) as yearFollowNo,
+			ifnull(sum(case when contact_type = 0 then 1 else 0 end) ,0)as yearVisitNo, 
+			ifnull(sum(case when contact_type = 1 then 1 else 0 end) ,0)as yearTelNo
+			from user_follow where 1=1
+			and create_time &gt; #{yearStart,jdbcType=VARCHAR}
+			and create_time &lt; #{yearEnd,jdbcType=VARCHAR}
+			group by aid
+)x  left join (
+select
+			aid,
+			count(0) as monthFollowNo,
+			ifnull(sum(case when contact_type = 0 then 1 else 0 end) ,0)as monthVisitNo, 
+			ifnull(sum(case when contact_type = 1 then 1 else 0 end) ,0)as monthTelNo
+			from user_follow where 1=1
+			and create_time &gt; #{monthStart,jdbcType=VARCHAR}
+			and create_time &lt; #{monthEnd,jdbcType=VARCHAR}
+			group by aid
+)y on x.aid = y.aid
+left join (
+select
+			aid,
+			count(0) as weeklyFollowNo,
+			ifnull(sum(case when contact_type = 0 then 1 else 0 end) ,0)as weeklyVisitNo, 
+			ifnull(sum(case when contact_type = 1 then 1 else 0 end) ,0)as weeklyTelNo
+			from user_follow where 1=1
+			and create_time &gt; #{weeklyStart,jdbcType=VARCHAR}
+			and create_time &lt; #{weeklyEnd,jdbcType=VARCHAR}
+			group by aid
+)z on y.aid = z.aid
+left join (
+select
+			aid,
+			count(0) as dayFollowNo,
+			ifnull(sum(case when contact_type = 0 then 1 else 0 end) ,0)as dayVisitNo, 
+			ifnull(sum(case when contact_type = 1 then 1 else 0 end) ,0)as dayTelNo
+			from user_follow where 1=1
+			and create_time &gt; #{dayStart,jdbcType=VARCHAR}
+			and create_time &lt; #{dayEnd,jdbcType=VARCHAR}
+			group by aid
+)w on y.aid = w.aid) n on m.id=n.aid
+where m.department_id is not null and m.department_id !=''
+group by m.department_id
+)t2 on t1.departmentId = t2.departmentId
+ORDER by t1.departmentName
 	</select>
   <select id="privateCustomersCount" parameterType="string" resultType="com.goafanti.report.bo.CountMarketingStatisticsBo">
-	select sum(e.privateCustomersCount) as privateCustomersCount
+	select SUM( n.privateCustomersCount )as privateCustomersCount,
+	SUM( m.dayFollowNo )as dayFollowNo,
+	SUM( m.dayVisitNo )as dayVisitNo,
+	SUM( m.dayTelNo )as dayTelNo,
+	SUM( m.weeklyFollowNo )as weeklyFollowNo,
+	SUM( m.weeklyVisitNo )as weeklyVisitNo,
+	SUM( m.weeklyTelNo )as weeklyTelNo,
+	SUM( m.monthFollowNo )as monthFollowNo,
+	SUM( m.monthVisitNo )as monthVisitNo,
+	SUM( m.monthTelNo )as monthTelNo,
+	SUM( m.yearFollowNo )as yearFollowNo,
+	SUM( m.yearVisitNo )as yearVisitNo,
+	SUM( m.yearTelNo )as yearTelNo
+from( 
+select a.id,sum(e.privateCustomersCount) as privateCustomersCount
 	from admin a left join user_role b
 	on a.id=b.uid left join role c
-	on b.rid=c.id left join department_management d
-	on a.department_id=d.id left join (select aid,count(0) as privateCustomersCount from user group by aid)e
-	on a.id=e.aid  where 1=1
+	on b.rid=c.id left join (select aid,count(0) as privateCustomersCount from user group by aid)e
+	on a.id=e.aid  where c.role_name in ('营销员','营销经理','营销管理员')
 	<if test="depId != null">
-		and a.department_id = #{depId,jdbcType=VARCHAR}
+	and a.department_id = #{depId,jdbcType=VARCHAR}
 	</if>
-	and (c.role_name='营销员' or c.role_name='营销经理'or c.role_name='营销管理员')
+	GROUP by a.id
+) n left join (
+select x.aid,x.yearFollowNo,x.yearVisitNo,x.yearTelNo,
+			 y.monthFollowNo,y.monthVisitNo,y.monthTelNo,
+			 z.weeklyFollowNo,z.weeklyVisitNo,z.weeklyTelNo,
+			 w.dayFollowNo,w.dayVisitNo,dayTelNo
+			 from (
+select
+			aid,
+			count(0) as yearFollowNo,
+			ifnull(sum(case when contact_type = 0 then 1 else 0 end) ,0)as yearVisitNo, 
+			ifnull(sum(case when contact_type = 1 then 1 else 0 end) ,0)as yearTelNo
+			from user_follow where 1=1
+			and create_time &gt;  #{yearStart,jdbcType=VARCHAR}
+			and create_time &lt;  #{yearEnd,jdbcType=VARCHAR}
+			group by aid
+)x  left join (
+select
+			aid,
+			count(0) as monthFollowNo,
+			ifnull(sum(case when contact_type = 0 then 1 else 0 end) ,0)as monthVisitNo, 
+			ifnull(sum(case when contact_type = 1 then 1 else 0 end) ,0)as monthTelNo
+			from user_follow where 1=1
+			and create_time &gt;  #{monthStart,jdbcType=VARCHAR}
+			and create_time &lt;  #{monthEnd,jdbcType=VARCHAR}
+			group by aid
+)y on x.aid = y.aid
+left join (
+select
+			aid,
+			count(0) as weeklyFollowNo,
+			ifnull(sum(case when contact_type = 0 then 1 else 0 end) ,0)as weeklyVisitNo, 
+			ifnull(sum(case when contact_type = 1 then 1 else 0 end) ,0)as weeklyTelNo
+			from user_follow where 1=1
+			and create_time &gt;  #{weeklyStart,jdbcType=VARCHAR}
+			and create_time &lt;  #{weeklyEnd,jdbcType=VARCHAR}
+			group by aid
+)z on y.aid = z.aid
+left join (
+select
+			aid,
+			count(0) as dayFollowNo,
+			ifnull(sum(case when contact_type = 0 then 1 else 0 end) ,0)as dayVisitNo, 
+			ifnull(sum(case when contact_type = 1 then 1 else 0 end) ,0)as dayTelNo
+			from user_follow where 1=1
+			and create_time &gt;  #{dayStart,jdbcType=VARCHAR}
+			and create_time &lt;  #{dayEnd,jdbcType=VARCHAR}
+			group by aid
+)w on y.aid = w.aid
+)m on n.id=m.aid	
 	</select>
   
   <select id="privateCustomersDepCount" parameterType="String" resultType="com.goafanti.report.bo.CountDepMarketingStatisticsBo">
-	select
-	sum( a.count2 ) as privateCustomersCount,
-	sum( b.count3 ) as departmentNumber from(
-		select
+	select sum(t1.privateCustomersCount) as privateCustomersCount,sum(t1.departmentNumber) as departmentNumber,
+			sum(t2.yearFollowNo) as yearFollowNo,sum(t2.yearVisitNo) as yearVisitNo,sum(t2.yearTelNo) as yearTelNo,
+			 sum(t2.monthFollowNo) as monthFollowNo,sum(t2.monthVisitNo) as monthVisitNo,sum(t2.monthTelNo) as monthTelNo,
+			 sum(t2.weeklyFollowNo) as weeklyFollowNo,sum(t2.weeklyVisitNo) as weeklyVisitNo,sum(t2.weeklyTelNo) as weeklyTelNo,
+			 sum(t2.dayFollowNo) as dayFollowNo,sum(t2.dayVisitNo) as dayVisitNo,sum(t2.dayTelNo) as dayTelNo
+			,sum(t2.dayFollowNo)/sum(t1.departmentNumber) as dayAVG
+		from(select
+	a.department_id as departmentId,
+	b.name as departmentName,
+	c.name as departmentManagerName,
+	a.count2 as privateCustomersCount,
+	d.count3 as departmentNumber
+from ( select
 			z.department_id,
-			sum( y.count1 ) as count2
-		from
-			(select aid, count(id) as count1
-				from  user 
-				where aid is not null and aid != ''
-				group by
-					aid
+			sum( y.count1 ) as count2 from
+			( select aid, count( aid ) as count1
+				from user 
+				where aid is not null and aid !=''
+				group by aid
 			) y left join admin z on
 			y.aid = z.id
 		group by
 			z.department_id
-	) a left join (
-		SELECT department_id,count(0) as count3 from admin GROUP by department_id
-
-	) b on a.department_id = b.department_id 
-	where 1=1
-<if test="depId != null">
-and a.department_id = #{depId,jdbcType=VARCHAR}
-</if>
+	) a left join department_management b 
+	on a.department_id = b.id left join admin c
+	on b.manager_id=c.id left join (select department_id,count(0) as count3 from admin   	group by department_id)d
+	on a.department_id = d.department_id
+	where a.department_id is not null
+	<if test="depId != null">
+	and a.department_id = #{depId,jdbcType=VARCHAR}
+	</if>
+)t1
+left join (
+select m.department_id as departmentId,sum(n.dayFollowNo)as dayFollowNo,sum(n.dayVisitNo)as dayVisitNo,sum(n.dayTelNo) as dayTelNo
+					,sum(n.weeklyFollowNo)as weeklyFollowNo,sum(n.weeklyVisitNo)as weeklyVisitNo,sum(n.weeklyTelNo) as weeklyTelNo
+					,sum(n.monthFollowNo)as monthFollowNo,sum(n.monthVisitNo)as monthVisitNo,sum(n.monthTelNo) as monthTelNo
+					,sum(n.yearFollowNo)as yearFollowNo,sum(n.yearVisitNo)as yearVisitNo,sum(n.yearTelNo) as yearTelNo
+from admin m left join 
+(select x.aid,x.yearFollowNo,x.yearVisitNo,x.yearTelNo,
+			 y.monthFollowNo,y.monthVisitNo,y.monthTelNo,
+			 z.weeklyFollowNo,z.weeklyVisitNo,z.weeklyTelNo,
+			 w.dayFollowNo,w.dayVisitNo,dayTelNo
+			 from (
+select
+			aid,
+			count(0) as yearFollowNo,
+			ifnull(sum(case when contact_type = 0 then 1 else 0 end) ,0)as yearVisitNo, 
+			ifnull(sum(case when contact_type = 1 then 1 else 0 end) ,0)as yearTelNo
+			from user_follow where 1=1
+			and create_time &gt; #{yearStart,jdbcType=VARCHAR}
+			and create_time &lt; #{yearEnd,jdbcType=VARCHAR}
+			group by aid
+)x  left join (
+select
+			aid,
+			count(0) as monthFollowNo,
+			ifnull(sum(case when contact_type = 0 then 1 else 0 end) ,0)as monthVisitNo, 
+			ifnull(sum(case when contact_type = 1 then 1 else 0 end) ,0)as monthTelNo
+			from user_follow where 1=1
+			and create_time &gt; #{monthStart,jdbcType=VARCHAR}
+			and create_time &lt; #{monthEnd,jdbcType=VARCHAR}
+			group by aid
+)y on x.aid = y.aid
+left join (
+select
+			aid,
+			count(0) as weeklyFollowNo,
+			ifnull(sum(case when contact_type = 0 then 1 else 0 end) ,0)as weeklyVisitNo, 
+			ifnull(sum(case when contact_type = 1 then 1 else 0 end) ,0)as weeklyTelNo
+			from user_follow where 1=1
+			and create_time &gt; #{weeklyStart,jdbcType=VARCHAR}
+			and create_time &lt; #{weeklyEnd,jdbcType=VARCHAR}
+			group by aid
+)z on y.aid = z.aid
+left join (
+select
+			aid,
+			count(0) as dayFollowNo,
+			ifnull(sum(case when contact_type = 0 then 1 else 0 end) ,0)as dayVisitNo, 
+			ifnull(sum(case when contact_type = 1 then 1 else 0 end) ,0)as dayTelNo
+			from user_follow where 1=1
+			and create_time &gt; #{dayStart,jdbcType=VARCHAR}
+			and create_time &lt; #{dayEnd,jdbcType=VARCHAR}
+			group by aid
+)w on y.aid = w.aid) n on m.id=n.aid
+where m.department_id is not null and m.department_id !=''
+group by m.department_id
+)t2 on t1.departmentId = t2.departmentId
 </select>
 
 
@@ -266,7 +500,7 @@ and a.department_id = #{depId,jdbcType=VARCHAR}
 select a.id,a.name,d.name as departmentName,role_name as roleName,ifnull(e.telNo,0)as countTelNo,
 	ifnull(e.visitNo,0)as countVisitNo,ifnull(e.followNo,0)as countFollowNo
 	<if test="startTime !=null and endTime !=null">
-	,countFollowNo/datediff(#{endTime,jdbcType=VARCHAR},#{startTime,jdbcType=VARCHAR}) as AVG
+	,e.followNo/datediff(#{endTime,jdbcType=VARCHAR},#{startTime,jdbcType=VARCHAR}) as dayAVG
 	</if>
 	from admin a left join user_role b on
 	a.id = b.uid left join role c on
@@ -292,16 +526,11 @@ select a.id,a.name,d.name as departmentName,role_name as roleName,ifnull(e.telNo
 	and a.create_time &lt;  #{endTime,jdbcType=VARCHAR}
 	</if>
 		GROUP BY a.aid)e on a.id=e.aid
-	where
-	1 = 1
-	and(
-		c.role_name = '营销员'
-		or c.role_name = '营销经理'
-		or c.role_name = '营销管理员'
-	)
+	where c.role_name in ('营销员','营销经理','营销管理员')
 	<if test="depId != null">
 	and a.department_id= #{depId,jdbcType=VARCHAR}
 	</if>
+	order by a.name 
 </select>
 <select id="sometimeMarketingDepStatistics" parameterType="String" resultType="com.goafanti.report.bo.SomeTimeMarketingBo">
 	select

+ 0 - 1
src/main/java/com/goafanti/common/mapper/UserMapperExt.xml

@@ -1653,6 +1653,5 @@
 		</if>
 		and a.create_time &gt; #{dailyStart,jdbcType=VARCHAR}
 		and a.create_time &lt; #{dailyEnd,jdbcType=VARCHAR}
-		
 	</select>
 </mapper>

+ 18 - 18
src/main/java/com/goafanti/report/bo/CountMarketingStatisticsBo.java

@@ -2,9 +2,9 @@ package com.goafanti.report.bo;
 
 public class CountMarketingStatisticsBo {
 	private String privateCustomersCount;
-	private String dailyVisitNo;
-	private String dailyTelNo;
-	private String dailyFollowNo;
+	private String dayVisitNo;
+	private String dayTelNo;
+	private String dayFollowNo;
 	private String weeklyVisitNo;
 	private String weeklyTelNo;
 	private String weeklyFollowNo;
@@ -23,32 +23,32 @@ public class CountMarketingStatisticsBo {
 	public void setPrivateCustomersCount(String privateCustomersCount) {
 		this.privateCustomersCount = privateCustomersCount;
 	}
-	public String getDailyVisitNo() {
-		if (null==dailyVisitNo) {
+	public String getDayVisitNo() {
+		if (null==dayVisitNo) {
 			return "0";
 		}
-		return dailyVisitNo;
+		return dayVisitNo;
 	}
-	public void setDailyVisitNo(String dailyVisitNo) {
-		this.dailyVisitNo = dailyVisitNo;
+	public void setDayVisitNo(String dayVisitNo) {
+		this.dayVisitNo = dayVisitNo;
 	}
-	public String getDailyTelNo() {
-		if (null==dailyTelNo) {
+	public String getDayTelNo() {
+		if (null==dayTelNo) {
 			return "0";
 		}
-		return dailyTelNo;
+		return dayTelNo;
 	}
-	public void setDailyTelNo(String dailyTelNo) {
-		this.dailyTelNo = dailyTelNo;
+	public void setDayTelNo(String dailyTelNo) {
+		this.dayTelNo = dayTelNo;
 	}
-	public String getDailyFollowNo() {
-		if (null==dailyFollowNo) {
+	public String getDayFollowNo() {
+		if (null==dayFollowNo) {
 			return "0";
 		}
-		return dailyFollowNo;
+		return dayFollowNo;
 	}
-	public void setDailyFollowNo(String dailyFollowNo) {
-		this.dailyFollowNo = dailyFollowNo;
+	public void setDayFollowNo(String dayFollowNo) {
+		this.dayFollowNo = dayFollowNo;
 	}
 	public String getWeeklyVisitNo() {
 		if (null==weeklyVisitNo) {

+ 6 - 5
src/main/java/com/goafanti/report/bo/SomeTimeMarketingBo.java

@@ -10,7 +10,7 @@ public class SomeTimeMarketingBo {
 		private String countVisitNo;
 		private String countTelNo;
 		private String countFollowNo;
-		private String AVG;
+		private String dayAVG;
 		public String getId() {
 			return id;
 		}
@@ -65,11 +65,12 @@ public class SomeTimeMarketingBo {
 		public void setDepartmentManagerName(String departmentManagerName) {
 			this.departmentManagerName = departmentManagerName;
 		}
-		public String getAVG() {
-			return AVG;
+		public String getDayAVG() {
+			if (null==dayAVG)return "0";
+			return dayAVG;
 		}
-		public void setAVG(String aVG) {
-			AVG = aVG;
+		public void setDayAVG(String dayAVG) {
+			this.dayAVG = dayAVG;
 		}
 		
 }

+ 83 - 5
src/main/java/com/goafanti/report/bo/marketingESBo.java

@@ -12,11 +12,85 @@ public class marketingESBo {
 		private String roleName;
 		private String entryTime;
 		private String privateCustomersCount;
-		private Map<String,Object> values;
+		private String dayVisitNo;
+		private String dayTelNo;
+		private String dayFollowNo;
+		private String dayAVG;
+		private String weeklyVisitNo;
+		private String weeklyTelNo;
+		private String weeklyFollowNo;
+		private String monshVisitNo;
+		private String monthTelNo;
+		private String monthFollowNo;
 		private String yearVisitNo;
 		private String yearTelNo;
 		private String yearFollowNo;
+		
+		public String getDayVisitNo() {
+			if (null==dayVisitNo)	return "0";
+			return dayVisitNo;
+		}
+		public void setDayVisitNo(String dayVisitNo) {
+			this.dayVisitNo = dayVisitNo;
+		}
+		public String getDayTelNo() {
+			if (null==dayTelNo)	return "0";
+			return dayTelNo;
+		}
+		public void setDayTelNo(String dayTelNo) {
+			this.dayTelNo = dayTelNo;
+		}
+		public String getDayFollowNo() {
+			if (null==dayFollowNo)	return "0";
+			return dayFollowNo;
+		}
+		public void setDayFollowNo(String dayFollowNo) {
+			this.dayFollowNo = dayFollowNo;
+		}
+		public String getWeeklyVisitNo() {
+			if (null==weeklyVisitNo)	return "0";
+			return weeklyVisitNo;
+		}
+		public void setWeeklyVisitNo(String weeklyVisitNo) {
+			this.weeklyVisitNo = weeklyVisitNo;
+		}
+		public String getWeeklyTelNo() {
+			if (null==weeklyTelNo)	return "0";
+			return weeklyTelNo;
+		}
+		public void setWeeklyTelNo(String weeklyTelNo) {
+			this.weeklyTelNo = weeklyTelNo;
+		}
+		public String getWeeklyFollowNo() {
+			if (null==weeklyFollowNo)	return "0";
+			return weeklyFollowNo;
+		}
+		public void setWeeklyFollowNo(String weeklyFollowNo) {
+			this.weeklyFollowNo = weeklyFollowNo;
+		}
+		public String getMonshVisitNo() {
+			if (null==monshVisitNo)	return "0";
+			return monshVisitNo;
+		}
+		public void setMonshVisitNo(String monshVisitNo) {
+			this.monshVisitNo = monshVisitNo;
+		}
+		public String getMonthTelNo() {
+			if (null==monthTelNo)	return "0";
+			return monthTelNo;
+		}
+		public void setMonthTelNo(String monthTelNo) {
+			this.monthTelNo = monthTelNo;
+		}
+		public String getMonthFollowNo() {
+			if (null==monthFollowNo)	return "0";
+			return monthFollowNo;
+		}
+		public void setMonthFollowNo(String monthFollowNo) {
+			this.monthFollowNo = monthFollowNo;
+		}
 		public String getName() {
+
 			return name;
 		}
 		public void setName(String name) {
@@ -91,10 +165,14 @@ public class marketingESBo {
 		public void setDepartmentNumber(String departmentNumber) {
 			this.departmentNumber = departmentNumber;
 		}
-		public Map<String,Object> getValues() {
-			return values;
+		public String getDayAVG() {
+			if (null==dayAVG) {
+				return "0";
+			}
+			return dayAVG;
 		}
-		public void setValues(Map<String,Object> values) {
-			this.values = values;
+		public void setDayAVG(String dayAVG) {
+			this.dayAVG = dayAVG;
 		}
+		
 }

+ 1 - 1
src/main/java/com/goafanti/report/controller/ReportApiController.java

@@ -20,7 +20,7 @@ import com.goafanti.report.enums.SalesReportOrderField;
 import com.goafanti.report.service.SalesReportServiceImpl;
 
 @RestController
-@RequestMapping(value = "/api/admin/report")
+@RequestMapping(value = "/open/api/admin/report")
 public class ReportApiController extends BaseApiController {
 	@Autowired
 	SalesReportServiceImpl reportService;

+ 11 - 120
src/main/java/com/goafanti/report/service/SalesReportServiceImpl.java

@@ -257,143 +257,34 @@ public class SalesReportServiceImpl extends BaseMybatisDao<DailySalesReportMappe
 
 	
 	public List<marketingESBo> marketingStatistics(String depId) {
-		List<marketingESBo> list=salesReportMapper.findmarketingStatisticsList(depId);
 		ReportDate rd = new ReportDate(new Date());
-		for (marketingESBo m : list) {
-				Map<String,Object> map=new HashMap<>();
-				marketingESBo day=userMapper.marketingStatistics(m.getId(),DateFormatUtils.format(rd.getDailyStart(), AFTConstants.YYYYMMDDHHMMSS),DateFormatUtils.format(rd.getDailyEnd(), AFTConstants.YYYYMMDDHHMMSS));
-				Map<String,String> daily =valuesloading(day);
-				map.put("daily", daily);
-				marketingESBo weekly=userMapper.marketingStatistics(m.getId(),DateFormatUtils.format(rd.getWeeklyStart(), AFTConstants.YYYYMMDDHHMMSS),DateFormatUtils.format(rd.getWeeklyEnd(), AFTConstants.YYYYMMDDHHMMSS));
-					Map<String,String> week =valuesloading(weekly);
-					map.put("week", week);
-				marketingESBo month=userMapper.marketingStatistics(m.getId(),DateFormatUtils.format(rd.getMonthStart(), AFTConstants.YYYYMMDDHHMMSS),DateFormatUtils.format(rd.getMonthEnd(), AFTConstants.YYYYMMDDHHMMSS));
-					Map<String,String> months =valuesloading(month);
-					map.put("months", months);
-				marketingESBo year=userMapper.marketingStatistics(m.getId(),DateFormatUtils.format(rd.getYearStart(), AFTConstants.YYYYMMDDHHMMSS),DateFormatUtils.format(rd.getYearEnd(), AFTConstants.YYYYMMDDHHMMSS));
-					Map<String,String> annual =valuesloading(year);
-					map.put("annual", annual);
-				m.setValues(map);
-			}
+		List<marketingESBo> list=salesReportMapper.findmarketingStatisticsList(depId,rd.getStringDailyStart(),rd.getStringDailyEnd(),rd.getStringWeeklyStart(),rd.getStringWeeklyEnd(),
+														rd.getStringMonthStart(),rd.getStringMonthEnd(),rd.getStringYearStart(),rd.getStringYearEnd());
+		
 			return list;
 	}
 
-	
-	private Map<String, String> valuesloading(marketingESBo day) {
-		Map<String, String> map=new HashMap<>();
-		if (null!=day) {
-			map.put("VisitNo", day.getYearVisitNo());
-			map.put("TelNo", day.getYearTelNo());
-			map.put("FollowNo", day.getYearFollowNo());
-		}else {
-			map.put("VisitNo", "0");
-			map.put("TelNo", "0");
-			map.put("FollowNo", "0");
-		}
-		
-		return map;
-	}
 
 	public List<marketingESBo> marketingDepStatistics(String depId) {
-		List<marketingESBo> list=salesReportMapper.marketingDepStatisticsList(depId);
 		ReportDate rd = new ReportDate(new Date());
-			for (marketingESBo m : list) {
-				Map<String,Object> map=new HashMap<>();
-				marketingESBo day=null;
-				if(null!=m.getDepartmentId())day=userMapper.marketingDepStatistics(m.getDepartmentId(),DateFormatUtils.format(rd.getDailyStart(), AFTConstants.YYYYMMDDHHMMSS),DateFormatUtils.format(rd.getDailyEnd(), AFTConstants.YYYYMMDDHHMMSS));
-					Map<String,String> daily =valuesloading(day);
-					if (null==day||null==day.getYearFollowNo()||null==m.getDepartmentNumber()) {
-					daily.put("AVG", "0");
-					}else {
-						daily.put("AVG", calculateAVG(day.getYearFollowNo(),m.getDepartmentNumber()));
-					}
-					map.put("daily", daily);
-				marketingESBo weekly=null;
-				if(null!=m.getDepartmentId())weekly=userMapper.marketingDepStatistics(m.getDepartmentId(),DateFormatUtils.format(rd.getWeeklyStart(), AFTConstants.YYYYMMDDHHMMSS),DateFormatUtils.format(rd.getWeeklyEnd(), AFTConstants.YYYYMMDDHHMMSS));
-					Map<String,String> week =valuesloading(weekly);
-					map.put("week", week);
-				marketingESBo month=null;
-				if(null!=m.getDepartmentId())month=userMapper.marketingDepStatistics(m.getDepartmentId(),DateFormatUtils.format(rd.getMonthStart(), AFTConstants.YYYYMMDDHHMMSS),DateFormatUtils.format(rd.getMonthEnd(), AFTConstants.YYYYMMDDHHMMSS));
-					Map<String,String> months =valuesloading(month);
-					map.put("months", months);
-				marketingESBo year=null;
-				if(null!=m.getDepartmentId())year=userMapper.marketingDepStatistics(m.getDepartmentId(),DateFormatUtils.format(rd.getYearStart(), AFTConstants.YYYYMMDDHHMMSS),DateFormatUtils.format(rd.getYearEnd(), AFTConstants.YYYYMMDDHHMMSS));
-					Map<String,String> annual =valuesloading(year);
-					map.put("annual", annual);
-				m.setValues(map);
-			}
-				
+		List<marketingESBo> list=salesReportMapper.marketingDepStatisticsList(depId,rd.getStringDailyStart(),rd.getStringDailyEnd(),rd.getStringWeeklyStart(),rd.getStringWeeklyEnd(),
+				rd.getStringMonthStart(),rd.getStringMonthEnd(),rd.getStringYearStart(),rd.getStringYearEnd());
+			
 		return list;
 	}
 
 	public CountMarketingStatisticsBo countMarketingStatistics(String depId) {
-		CountMarketingStatisticsBo count=salesReportMapper.privateCustomersCount(depId);
-		if (null==count) {
-			count=new CountMarketingStatisticsBo();
-		}
 		ReportDate rd = new ReportDate(new Date());
-		CountMarketingStatisticsBo d=userMapper.countmarketingDepStatistics(depId,rd.getStringDailyStart(),rd.getStringDailyEnd());
-		if (null!=d.getYearFollowNo()) {
-			count.setDailyFollowNo(d.getYearFollowNo());
-			count.setDailyTelNo(d.getYearTelNo());
-			count.setDailyVisitNo(d.getYearVisitNo());	
-		}
-		CountMarketingStatisticsBo w=userMapper.countmarketingDepStatistics(depId,rd.getStringWeeklyStart(),rd.getStringWeeklyEnd());
-		if (null!=w) {
-		count.setWeeklyFollowNo(w.getYearFollowNo());
-		count.setWeeklyTelNo(w.getYearTelNo());
-		count.setWeeklyVisitNo(w.getYearVisitNo());
-		}
-		CountMarketingStatisticsBo m=userMapper.countmarketingDepStatistics(depId,rd.getStringMonthStart(),rd.getStringMonthEnd());
-		if (null!=d) {
-		count.setMonthFollowNo(m.getYearFollowNo());
-		count.setMonthTelNo(m.getYearTelNo());
-		count.setMonthVisitNo(m.getYearVisitNo());
-		}
-		CountMarketingStatisticsBo y=userMapper.countmarketingDepStatistics(depId,rd.getStringYearStart(),rd.getStringYearEnd());
-		if (null!=d) {
-		count.setYearFollowNo(y.getYearFollowNo());
-		count.setYearTelNo(y.getYearTelNo());
-		count.setYearVisitNo(y.getYearVisitNo());
-		}
+		CountMarketingStatisticsBo count=salesReportMapper.privateCustomersCount(depId,rd.getStringDailyStart(),rd.getStringDailyEnd(),rd.getStringWeeklyStart(),rd.getStringWeeklyEnd(),
+				rd.getStringMonthStart(),rd.getStringMonthEnd(),rd.getStringYearStart(),rd.getStringYearEnd());
 		return count;
 	}
 
 	public CountMarketingStatisticsBo countMarketingDepStatistics(String depId) {
-		
-		CountDepMarketingStatisticsBo count=salesReportMapper.privateCustomersDepCount(depId);
-		if (null==count) {
-			return new CountDepMarketingStatisticsBo();
-		}
 		ReportDate rd = new ReportDate(new Date());
-		CountMarketingStatisticsBo d=userMapper.countmarketingDepStatistics(depId,rd.getStringDailyStart(),rd.getStringDailyEnd());
-		if (null!=d) {
-		count.setDailyFollowNo(d.getYearFollowNo());
-		count.setDailyTelNo(d.getYearTelNo());
-		count.setDailyVisitNo(d.getYearVisitNo());
-		count.setDailyAVG(calculateAVG(count.getDailyFollowNo(),count.getDepartmentNumber()));
-		}
-		CountMarketingStatisticsBo w=userMapper.countmarketingDepStatistics(depId,rd.getStringWeeklyStart(),rd.getStringWeeklyEnd());
-		if (null!=w) {
-		count.setWeeklyFollowNo(w.getYearFollowNo());
-		count.setWeeklyTelNo(w.getYearTelNo());
-		count.setWeeklyVisitNo(w.getYearVisitNo());
-		count.setWeeklyAVG(calculateAVG(count.getWeeklyFollowNo(),count.getDepartmentNumber()));
-		}
-		CountMarketingStatisticsBo m=userMapper.countmarketingDepStatistics(depId,rd.getStringMonthStart(),rd.getStringMonthEnd());
-		if (null!=m) {
-		count.setMonthFollowNo(m.getYearFollowNo());
-		count.setMonthTelNo(m.getYearTelNo());
-		count.setMonthVisitNo(m.getYearVisitNo());
-		count.setMonthAVG(calculateAVG(count.getMonthFollowNo(),count.getDepartmentNumber()));
-		}
-		CountMarketingStatisticsBo y=userMapper.countmarketingDepStatistics(depId,rd.getStringYearStart(),rd.getStringYearEnd());
-		if (null!=y) {
-		count.setYearFollowNo(y.getYearFollowNo());
-		count.setYearTelNo(y.getYearTelNo());
-		count.setYearVisitNo(y.getYearVisitNo());
-		count.setYearAVG(calculateAVG(count.getYearFollowNo(),count.getDepartmentNumber()));
-		}
+		CountDepMarketingStatisticsBo count=salesReportMapper.privateCustomersDepCount(depId,rd.getStringDailyStart(),rd.getStringDailyEnd(),rd.getStringWeeklyStart(),rd.getStringWeeklyEnd(),
+				rd.getStringMonthStart(),rd.getStringMonthEnd(),rd.getStringYearStart(),rd.getStringYearEnd());
+		
 		return count;
 	}
 

+ 1 - 1
src/main/resources/props/config_test.properties

@@ -1,7 +1,7 @@
 #Driver
 jdbc.driverClassName=com.mysql.jdbc.Driver
 #\u6570\u636e\u5e93\u94fe\u63a5\uff0c
-jdbc.url=jdbc:mysql://127.0.0.1:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+jdbc.url=jdbc:mysql://127.0.0.1:3306/aft20180522?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
 #\u5e10\u53f7
 jdbc.username=root
 #\u5bc6\u7801