Browse Source

客户管理项目显示不全BUG修复

anderx 7 years ago
parent
commit
fdc4a5341e

+ 1 - 1
src/main/java/com/goafanti/business/service/impl/BusinessProjectServiceImpl.java

@@ -71,7 +71,7 @@ public class BusinessProjectServiceImpl extends BaseMybatisDao<BusinessProjectMa
 			pNo = 1;
 		}
 
-		if (pSize == null || pSize < 0 || pSize > 10) {
+		if (pSize == null || pSize < 0 ) {
 			pSize = 10;
 		} 	
 		Pagination<BusinessProjectBo> pt=(Pagination<BusinessProjectBo>)findPage("findProjectListByPage", "findProjectListCount",

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

@@ -2,13 +2,18 @@ package com.goafanti.common.dao;
 
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.ibatis.annotations.Param;
 import org.springframework.ui.ModelMap;
 
 import com.goafanti.common.model.DailySalesReport;
+import com.goafanti.report.bo.CountDepMarketingStatisticsBo;
+import com.goafanti.report.bo.CountMarketingStatisticsBo;
 import com.goafanti.report.bo.DepartmentSalesReportBO;
 import com.goafanti.report.bo.PersonalSalesReportBO;
+import com.goafanti.report.bo.SomeTimeMarketingBo;
+import com.goafanti.report.bo.marketingESBo;
 
 public interface DailySalesReportMapper {
 
@@ -45,4 +50,16 @@ 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<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);
 }

+ 4 - 1
src/main/java/com/goafanti/common/dao/UserMapper.java

@@ -21,6 +21,7 @@ import com.goafanti.customer.bo.CustomerPersonalDetailBo;
 import com.goafanti.customer.bo.CustomerSimpleBo;
 import com.goafanti.customer.bo.FollowBusinessBo;
 import com.goafanti.customer.bo.LockingReleaseBo;
+import com.goafanti.report.bo.CountMarketingStatisticsBo;
 import com.goafanti.report.bo.marketingESBo;
 
 public interface UserMapper {
@@ -232,5 +233,7 @@ public interface UserMapper {
 
 	marketingESBo marketingStatistics(@Param("id")String id, @Param("dailyStart")String dailyStart, @Param("dailyEnd")String dailyEnd);
 
-	marketingESBo marketingDepStatistics(@Param("id")String id, @Param("dailyStart")String dailyStart, @Param("dailyEnd")String dailyEnd);
+	marketingESBo marketingDepStatistics(@Param("depId")String depId, @Param("dailyStart")String dailyStart, @Param("dailyEnd")String dailyEnd);
+
+	CountMarketingStatisticsBo countmarketingDepStatistics(@Param("depId")String depId, @Param("dailyStart")String dailyStart, @Param("dailyEnd")String dailyEnd);
 }

+ 142 - 51
src/main/java/com/goafanti/common/mapper/DailySalesReportMapper.xml

@@ -166,7 +166,7 @@
 	</if>
   </select>
   
-   <select id="findmarketingStatisticsListByPage" parameterType="String" resultType="com.goafanti.report.bo.marketingESBo">
+   <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,
 				c.role_name as roleName,ifnull(e.privateCustomersCount,0)as privateCustomersCount,a.create_time as entryTime
 		from admin a left join user_role b
@@ -177,62 +177,153 @@
 		on d.manager_id=f.id
 		where 1=1
 		and (c.role_name='营销员' or c.role_name='营销经理'or c.role_name='营销管理员')
-	<if test="id != null">
-		and a.department_id = #{id,jdbcType=VARCHAR}
+	<if test="depId != null">
+		and a.department_id = #{depId,jdbcType=VARCHAR}
 	</if>
-	order by a.create_time desc
-	<if test="page_sql!=null">
-			${page_sql}
-	</if>
-  </select>
+	order by a.name desc
+ </select>
   
-  <select id="findmarketingStatisticsCount" parameterType="String" resultType="java.lang.Integer">
-  	select count(0)
-			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 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="id != null">
-		and a.department_id = #{id,jdbcType=VARCHAR}
+  <select id="marketingDepStatisticsList" parameterType="String" resultType="com.goafanti.report.bo.marketingESBo">
+			select d.id as departmentId, d.name as departmentName, count( a.name )as departmentNumber, f.name as departmentManagerName,
+		a.create_time as entryTime, ifnull( e.privateCustomersCount,0) 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 z3.id as depId, count( 0 ) as privateCustomersCount
+			from user z1 left join admin z2 on z1.aid = z2.id 
+			left join department_management z3 on z2.department_id = z3.id
+			group by z3.id ) e on a.department_id = e.depId 
+		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">
+		and a.department_id = #{depId,jdbcType=VARCHAR}
 	</if>
-  </select>
-  
+		group by a.department_id
+		order by d.name desc
+	</select>
+  <select id="privateCustomersCount" parameterType="string" resultType="com.goafanti.report.bo.CountMarketingStatisticsBo">
+	select 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
+	<if test="depId != null">
+		and a.department_id = #{depId,jdbcType=VARCHAR}
+	</if>
+	and (c.role_name='营销员' or c.role_name='营销经理'or c.role_name='营销管理员')
+	</select>
   
-  <select id="findmarketingDepStatisticsListByPage" parameterType="String" resultType="com.goafanti.report.bo.marketingESBo">
-		select a.id as departmentId,a.name as departmentName
-	from department_management a left join admin b
-	on a.id=b.department_id left join user_role c
-	on b.id =c.uid left join role d
-	on c.rid =d.id 
-	where 1=1
-	and (d.role_name='营销员' or d.role_name='营销经理'or d.role_name='营销管理员')
-	<if test="id != null">
-		and a.id = #{id,jdbcType=VARCHAR}
+  <select id="privateCustomersDepCount" parameterType="String" resultType="com.goafanti.report.bo.CountDepMarketingStatisticsBo">
+	select
+	count( a.name )as departmentNumber,
+	ifnull(e.privateCustomersCount,0) 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(
+		select z3.id as depId, count( 0 ) as privateCustomersCount
+		from user z1 left join admin z2 on z1.aid = z2.id 
+		left join department_management z3 on z2.department_id = z3.id
+		group by z3.id ) e on a.department_id = e.depId 
+where 1 = 1
+and(c.role_name = '营销员' or c.role_name = '营销经理' or c.role_name = '营销管理员')
+<if test="depId != null">
+and a.department_id = #{depId,jdbcType=VARCHAR}
+</if>
+</select>
+
+
+<select id="sometimeMarketingStatistics" parameterType="String" resultType="com.goafanti.report.bo.SomeTimeMarketingBo">
+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
 	</if>
-	group by a.id
-	order by a.create_time desc
-	<if test="page_sql!=null">
-			${page_sql}
+	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
+		a.aid,
+		count( 0 ) as followNo,
+		ifnull(
+			sum( case when a.contact_type = 0 then 1 else 0 end ),
+			0
+		) as visitNo,
+		ifnull(
+			sum( case when a.contact_type = 1 then 1 else 0 end ),
+			0
+			) as telNo
+	from user_follow a 
+	where
+		1 = 1
+	<if test="startTime !=null">
+	and a.create_time &gt;  #{startTime,jdbcType=VARCHAR}
 	</if>
-  </select>
-  
-  <select id="findmarketingDepStatisticsCount" parameterType="String" resultType="java.lang.Integer">
-  	select count(0)
-	from (select a.id,a.name
-	from department_management a left join admin b
-	on a.id=b.department_id left join user_role c
-	on b.id =c.uid left join role d
-	on c.rid =d.id 
-	where 1=1
-	and (d.role_name='营销员' or d.role_name='营销经理'or d.role_name='营销管理员')
-	<if test="id != null">
-		and a.id = #{id,jdbcType=VARCHAR}
+	<if test="endTime !=null">
+	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 = '营销管理员'
+	)
+	<if test="depId != null">
+	and a.department_id= #{depId,jdbcType=VARCHAR}
 	</if>
-	group by a.id)x
+</select>
+<select id="sometimeMarketingDepStatistics" parameterType="String" resultType="com.goafanti.report.bo.SomeTimeMarketingBo">
+	select
+	a.department_id as departmentId,
+	d.name as  departmentName,
+	f.name as departmentManagerName,
+	d.manager_id,
+	ifnull(e.telNo,0) as countTelNo,
+	ifnull(e.visitNo,0) as countVisitNo,
+	ifnull(e.followNo,0) as countFollowNo,
+	a.department_id
+	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 admin f on 
+	d.manager_id=f.id left join (select
+		b.department_id,
+		count( 0 ) as followNo,
+		ifnull(
+			sum( case when a.contact_type = 0 then 1 else 0 end ),
+			0
+		) as visitNo,
+		ifnull(
+			sum( case when a.contact_type = 1 then 1 else 0 end ),
+			0
+			) as telNo
+	from user_follow a left join admin b on a.aid=b.id
+	left join department_management c on b.department_id=c.id
+	where
+		1 = 1
+	<if test="startTime !=null">
+	and a.create_time &gt;  #{startTime,jdbcType=VARCHAR}
+	</if>
+	<if test="endTime !=null">
+	and a.create_time &lt;  #{endTime,jdbcType=VARCHAR}
+	</if>
+		GROUP BY b.department_id)e on a.department_id=e.department_id
+	where
+	1 = 1
+	and(
+		c.role_name = '营销员'
+		or c.role_name = '营销经理'
+		or c.role_name = '营销管理员'
+	)
+	<if test="depId != null">
+	and a.department_id= #{depId,jdbcType=VARCHAR}
+	</if>
+	group by a.department_id
 	</select>
-  
 </mapper>

+ 27 - 3
src/main/java/com/goafanti/common/mapper/UserMapperExt.xml

@@ -1612,7 +1612,7 @@
 			GROUP BY aid
 	</select>
 	<select id="marketingDepStatistics" parameterType="java.lang.String" resultType="com.goafanti.report.bo.marketingESBo">
-	   	 					select
+	   	 select
 		b.department_id,
 		count( 0 ) as yearFollowNo,
 		ifnull(
@@ -1622,13 +1622,37 @@
 		ifnull(
 			sum( case when a.contact_type = 1 then 1 else 0 end ),
 			0
-		) as yearTelNo
+			) as yearTelNo
 	from user_follow a left join admin b on a.aid =b.id
 	where
 		1 = 1
-		and b.department_id = #{id,jdbcType=VARCHAR}
+		<if test="depId !=null">
+		and b.department_id = #{depId,jdbcType=VARCHAR}
+		</if>
 		and a.create_time &gt; #{dailyStart,jdbcType=VARCHAR}
 		and a.create_time &lt; #{dailyEnd,jdbcType=VARCHAR}
 		GROUP BY b.department_id
 	</select>
+	
+	<select id="countmarketingDepStatistics" parameterType="java.lang.String" resultType="com.goafanti.report.bo.CountMarketingStatisticsBo">
+	   	 					select
+		count( 0 ) as yearFollowNo,
+		ifnull(
+			sum( case when a.contact_type = 0 then 1 else 0 end ),
+			0
+		) as yearVisitNo,
+		ifnull(
+			sum( case when a.contact_type = 1 then 1 else 0 end ),
+			0
+		) as yearTelNo
+	from user_follow a left join admin b on a.aid =b.id
+	where
+		1 = 1
+		<if test="depId !=null">
+		and b.department_id = #{depId,jdbcType=VARCHAR}
+		</if>
+		and a.create_time &gt; #{dailyStart,jdbcType=VARCHAR}
+		and a.create_time &lt; #{dailyEnd,jdbcType=VARCHAR}
+		
+	</select>
 </mapper>

+ 51 - 0
src/main/java/com/goafanti/report/bo/CountDepMarketingStatisticsBo.java

@@ -0,0 +1,51 @@
+package com.goafanti.report.bo;
+
+
+
+public class CountDepMarketingStatisticsBo extends CountMarketingStatisticsBo{
+		private String departmentNumber;
+		private String dailyAVG;
+		private String weeklyAVG;
+		private String monthAVG;
+		private String yearAVG;
+		public String getDailyAVG() {
+			return dailyAVG;
+		}
+
+		public void setDailyAVG(String dailyAVG) {
+			this.dailyAVG = dailyAVG;
+		}
+		
+		public String getWeeklyAVG() {
+			return weeklyAVG;
+		}
+
+		public void setWeeklyAVG(String weeklyAVG) {
+			this.weeklyAVG = weeklyAVG;
+		}
+		
+
+		public String getMonthAVG() {
+			return monthAVG;
+		}
+
+		public void setMonthAVG(String monthAVG) {
+			this.monthAVG = monthAVG;
+		}
+
+		public String getYearAVG() {
+			return yearAVG;
+		}
+
+		public void setYearAVG(String yearAVG) {
+			this.yearAVG = yearAVG;
+		}
+
+		public String getDepartmentNumber() {
+			return departmentNumber;
+		}
+
+		public void setDepartmentNumber(String departmentNumber) {
+			this.departmentNumber = departmentNumber;
+		}
+}

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

@@ -0,0 +1,99 @@
+package com.goafanti.report.bo;
+
+public class CountMarketingStatisticsBo {
+	private String privateCustomersCount;
+	private String dailyVisitNo;
+	private String dailyTelNo;
+	private String dailyFollowNo;
+	private String weeklyVisitNo;
+	private String weeklyTelNo;
+	private String weeklyFollowNo;
+	private String monthVisitNo;
+	private String monthTelNo;
+	private String monthFollowNo;
+	private String yearVisitNo;
+	private String yearTelNo;
+	private String yearFollowNo;
+	public String getPrivateCustomersCount() {
+		if (null==privateCustomersCount) {
+			return "0";
+		}
+		return privateCustomersCount;
+	}
+	public void setPrivateCustomersCount(String privateCustomersCount) {
+		this.privateCustomersCount = privateCustomersCount;
+	}
+	public String getDailyVisitNo() {
+		return dailyVisitNo;
+	}
+	public void setDailyVisitNo(String dailyVisitNo) {
+		this.dailyVisitNo = dailyVisitNo;
+	}
+	public String getDailyTelNo() {
+		return dailyTelNo;
+	}
+	public void setDailyTelNo(String dailyTelNo) {
+		this.dailyTelNo = dailyTelNo;
+	}
+	public String getDailyFollowNo() {
+		return dailyFollowNo;
+	}
+	public void setDailyFollowNo(String dailyFollowNo) {
+		this.dailyFollowNo = dailyFollowNo;
+	}
+	public String getWeeklyVisitNo() {
+		return weeklyVisitNo;
+	}
+	public void setWeeklyVisitNo(String weeklyVisitNo) {
+		this.weeklyVisitNo = weeklyVisitNo;
+	}
+	public String getWeeklyTelNo() {
+		return weeklyTelNo;
+	}
+	public void setWeeklyTelNo(String weeklyTelNo) {
+		this.weeklyTelNo = weeklyTelNo;
+	}
+	public String getWeeklyFollowNo() {
+		return weeklyFollowNo;
+	}
+	public void setWeeklyFollowNo(String weeklyFollowNo) {
+		this.weeklyFollowNo = weeklyFollowNo;
+	}
+	public String getMonthVisitNo() {
+		return monthVisitNo;
+	}
+	public void setMonthVisitNo(String monthVisitNo) {
+		this.monthVisitNo = monthVisitNo;
+	}
+	public String getMonthTelNo() {
+		return monthTelNo;
+	}
+	public void setMonthTelNo(String monthTelNo) {
+		this.monthTelNo = monthTelNo;
+	}
+	public String getMonthFollowNo() {
+		return monthFollowNo;
+	}
+	public void setMonthFollowNo(String monthFollowNo) {
+		this.monthFollowNo = monthFollowNo;
+	}
+	public String getYearVisitNo() {
+		return yearVisitNo;
+	}
+	public void setYearVisitNo(String yearVisitNo) {
+		this.yearVisitNo = yearVisitNo;
+	}
+	public String getYearTelNo() {
+		return yearTelNo;
+	}
+	public void setYearTelNo(String yearTelNo) {
+		this.yearTelNo = yearTelNo;
+	}
+	public String getYearFollowNo() {
+		return yearFollowNo;
+	}
+	public void setYearFollowNo(String yearFollowNo) {
+		this.yearFollowNo = yearFollowNo;
+	}
+
+}

+ 34 - 1
src/main/java/com/goafanti/report/bo/ReportDate.java

@@ -3,6 +3,9 @@ package com.goafanti.report.bo;
 import java.util.Calendar;
 import java.util.Date;
 
+import org.apache.commons.lang3.time.DateFormatUtils;
+
+import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.utils.DateUtils;
 
 public class ReportDate {
@@ -114,5 +117,35 @@ public class ReportDate {
 	public void setYearEnd(Date yearEnd) {
 		this.yearEnd = yearEnd;
 	}
-
+	public String getStringDailyEnd() {
+		return DateFormatUtils.format(this.getDailyEnd(), AFTConstants.YYYYMMDDHHMMSS);
+	}
+	public String getStringDailyStart() {
+		return DateFormatUtils.format(this.getDailyStart(), AFTConstants.YYYYMMDDHHMMSS);
+	}
+	public String getStringWeeklyStart() {
+		return DateFormatUtils.format(this.getWeeklyStart(), AFTConstants.YYYYMMDDHHMMSS);
+	}
+	public String getStringWeeklyEnd() {
+		return DateFormatUtils.format(this.getWeeklyEnd(), AFTConstants.YYYYMMDDHHMMSS);
+	}
+	public String getStringMonthStart() {
+		return DateFormatUtils.format(this.getMonthStart(), AFTConstants.YYYYMMDDHHMMSS);
+	}
+	public String getStringMonthEnd() {
+		return DateFormatUtils.format(this.getMonthEnd(), AFTConstants.YYYYMMDDHHMMSS);
+	}
+	public String getStringYearStart() {
+		return DateFormatUtils.format(this.getYearStart(), AFTConstants.YYYYMMDDHHMMSS);
+	}
+	public String getStringYearEnd() {
+		return DateFormatUtils.format(this.getYearEnd(), AFTConstants.YYYYMMDDHHMMSS);
+	}
+	public String getStringQuarterStart() {
+		return DateFormatUtils.format(this.getQuarterStart(), AFTConstants.YYYYMMDDHHMMSS);
+	}
+	public String getStringQuarterEnd() {
+		return DateFormatUtils.format(this.getQuarterEnd(), AFTConstants.YYYYMMDDHHMMSS);
+	}
+	
 }

+ 75 - 0
src/main/java/com/goafanti/report/bo/SomeTimeMarketingBo.java

@@ -0,0 +1,75 @@
+package com.goafanti.report.bo;
+
+public class SomeTimeMarketingBo {
+		private String id;
+		private String name;
+		private String departmentId;
+		private String departmentManagerName;
+		private String departmentName;
+		private String roleName;
+		private String countVisitNo;
+		private String countTelNo;
+		private String countFollowNo;
+		private String AVG;
+		public String getId() {
+			return id;
+		}
+		public void setId(String id) {
+			this.id = id;
+		}
+		public String getName() {
+			return name;
+		}
+		public void setName(String name) {
+			this.name = name;
+		}
+		public String getDepartmentName() {
+			return departmentName;
+		}
+		public void setDepartmentName(String departmentName) {
+			this.departmentName = departmentName;
+		}
+		public String getRoleName() {
+			return roleName;
+		}
+		public void setRoleName(String roleName) {
+			this.roleName = roleName;
+		}
+		public String getCountVisitNo() {
+			return countVisitNo;
+		}
+		public void setCountVisitNo(String countVisitNo) {
+			this.countVisitNo = countVisitNo;
+		}
+		public String getCountTelNo() {
+			return countTelNo;
+		}
+		public void setCountTelNo(String countTelNo) {
+			this.countTelNo = countTelNo;
+		}
+		public String getCountFollowNo() {
+			return countFollowNo;
+		}
+		public void setCountFollowNo(String countFollowNo) {
+			this.countFollowNo = countFollowNo;
+		}
+		public String getDepartmentId() {
+			return departmentId;
+		}
+		public void setDepartmentId(String departmentId) {
+			this.departmentId = departmentId;
+		}
+		public String getDepartmentManagerName() {
+			return departmentManagerName;
+		}
+		public void setDepartmentManagerName(String departmentManagerName) {
+			this.departmentManagerName = departmentManagerName;
+		}
+		public String getAVG() {
+			return AVG;
+		}
+		public void setAVG(String aVG) {
+			AVG = aVG;
+		}
+		
+}

+ 16 - 72
src/main/java/com/goafanti/report/bo/marketingESBo.java

@@ -1,23 +1,18 @@
 package com.goafanti.report.bo;
 
+import java.util.Map;
+
 public class marketingESBo {
 		private String id;
 		private String name;
 		private String departmentName;
+		private String departmentNumber;
 		private String departmentId;
 		private String departmentManagerName;
 		private String roleName;
 		private String entryTime;
 		private String privateCustomersCount;
-		private String dailyVisitNo;
-		private String dailyTelNo;
-		private String dailyFollowNo;
-		private String weeklyVisitNo;
-		private String weeklyTelNo;
-		private String weeklyFollowNo;
-		private String monthVisitNo;
-		private String monthTelNo;
-		private String monthFollowNo;
+		private Map<String,Object> values;
 		private String yearVisitNo;
 		private String yearTelNo;
 		private String yearFollowNo;
@@ -51,69 +46,6 @@ public class marketingESBo {
 		public void setPrivateCustomersCount(String privateCustomersCount) {
 			this.privateCustomersCount = privateCustomersCount;
 		}
-		public String getDailyVisitNo() {
-			if (null==dailyVisitNo)	return "0";
-			return dailyVisitNo;
-		}
-		public void setDailyVisitNo(String dailyVisitNo) {
-			this.dailyVisitNo = dailyVisitNo;
-		}
-		public String getDailyTelNo() {
-			if (null==dailyTelNo)	return "0";
-			return dailyTelNo;
-		}
-		public void setDailyTelNo(String dailyTelNo) {
-			this.dailyTelNo = dailyTelNo;
-		}
-		public String getDailyFollowNo() {
-			if (null==dailyFollowNo)	return "0";
-			return dailyFollowNo;
-		}
-		public void setDailyFollowNo(String dailyFollowNo) {
-			this.dailyFollowNo = dailyFollowNo;
-		}
-		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 getMonthVisitNo() {
-			if (null==monthVisitNo)	return "0";
-			return monthVisitNo;
-		}
-		public void setMonthVisitNo(String monthVisitNo) {
-			this.monthVisitNo = monthVisitNo;
-		}
-		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 getYearVisitNo() {
 			if (null==yearVisitNo)	return "0";
 			return yearVisitNo;
@@ -153,4 +85,16 @@ public class marketingESBo {
 		public void setId(String id) {
 			this.id = id;
 		}
+		public String getDepartmentNumber() {
+			return departmentNumber;
+		}
+		public void setDepartmentNumber(String departmentNumber) {
+			this.departmentNumber = departmentNumber;
+		}
+		public Map<String,Object> getValues() {
+			return values;
+		}
+		public void setValues(Map<String,Object> values) {
+			this.values = values;
+		}
 }

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

@@ -108,9 +108,34 @@ public class ReportApiController extends BaseApiController {
 		// 统计从指定日期前一天的17点到指定日期17点的数据,算作改日期数据
 		return res().data(reportService.insertDailyReports(start, now.getTime()));
 	}
-	
+	/**
+	 * 客户营销统计表
+	 * @param depId
+	 * @param type
+	 * @return
+	 */
 	@RequestMapping(value = "/sales/marketingStatistics", method = RequestMethod.GET)
-	public Result marketingStatistics(String depId,Integer type,Integer pNo,Integer pSize) {
+	public Result marketingStatistics(String depId,Integer type) {
+		Result res=new Result();
+		
+		if (null==type||type>1) {
+			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "参数错误", "参数"));
+	            return res;
+		}
+		if (Integer.valueOf(type)==0) {
+			return res.data(reportService.marketingStatistics(depId));
+		}else {
+			return res.data(reportService.marketingDepStatistics(depId));
+		}
+	}
+	/**
+	 * 客户营销统计表(总计)
+	 * @param depId
+	 * @param type
+	 * @return
+	 */
+	@RequestMapping(value = "/sales/countMarketingStatistics", method = RequestMethod.GET)
+	public Result countMarketingStatistics(String depId,Integer type) {
 		Result res=new Result();
 		
 		if (null==type||type>1) {
@@ -118,10 +143,71 @@ public class ReportApiController extends BaseApiController {
 	            return res;
 		}
 		if (Integer.valueOf(type)==0) {
-			return res.data(reportService.marketingStatistics(depId,pNo,pSize));
+			return res.data(reportService.countMarketingStatistics(depId));
+		}else {
+			return res.data(reportService.countMarketingDepStatistics(depId));
+		}
+	}
+	public static void main(String[] args) {
+		int timeType = 0;
+		boolean a=(timeType==5);
+	}
+	/**
+	 * 客户营销时段统计表
+	 * @param depId
+	 * @param type
+	 * @return
+	 */
+	@RequestMapping(value = "/sales/sometimeMarketingStatistics", method = RequestMethod.GET)
+	public Result sometimeMarketingStatistics(String depId,Integer timeType,Integer type,String startTime,String endTime) {
+		Result res=new Result();
+		if (null==type||type>1) {
+			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "参数错误", "参数"));
+	            return res;
+		}
+		if (null==timeType||timeType>4) {
+			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "日期类型参数参数错误", "日期类型参数"));
+	            return res;
+	    }
+	   if (timeType==4&&null==startTime&&null==endTime) {
+			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "日期类型参数参数错误", "日期类型参数"));
+	            return res;
+		}
+		if (Integer.valueOf(type)==0) {
+			return res.data(reportService.sometimeMarketingStatistics(depId,timeType,startTime,endTime));
 		}else {
-			return res.data(reportService.marketingDepStatistics(depId,pNo,pSize));
+			return res.data(reportService.sometimeMarketingDepStatistics(depId,timeType,startTime,endTime));
+		}
+	}
+	/**
+	 * 客户营销时段统计表(总计)
+	 * @param depId
+	 * @param type
+	 * @return
+	 */
+	@RequestMapping(value = "/sales/countsometimeMarketingStatistics", method = RequestMethod.GET)
+	public Result countsometimeMarketingStatistics(String depId,Integer timeType,Integer type,String startTime,String endTime) {
+		Result res=new Result();
+		if (null==type||type>1) {
+			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "参数错误", "参数"));
+	            return res;
 		}
+		if (null==timeType||timeType>4) {
+			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "日期类型参数参数错误", "日期类型参数"));
+	            return res;
+	    }
+	   if (timeType==4&&null==startTime&&null==endTime) {
+			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "日期类型参数参数错误", "日期类型参数"));
+	            return res;
+		}
+	   return res;
+		/*if (Integer.valueOf(type)==0) {
+			return res.data(reportService.countSometimeMarketingStatistics(depId,timeType,startTime,endTime));
+		}else {
+			return res.data(reportService.countSometimeMarketingDepStatistics(depId,timeType,startTime,endTime));
+		}*/
 	}
+	
+	
 
 }

+ 47 - 0
src/main/java/com/goafanti/report/enums/TimeType.java

@@ -0,0 +1,47 @@
+package com.goafanti.report.enums;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public enum TimeType {
+	WEEKLY(0, "本周"),
+	MONTH(1, "本月"),
+	QTR(2, "本季"),
+	YEAR(3, "本年"),
+	ZS(4, "自选");
+
+	private TimeType(Integer code, String desc) {
+		this.code = code;
+		this.desc = desc;
+	}
+
+	private static Map<Integer, TimeType> status = new HashMap<Integer, TimeType>();
+
+	static {
+		for (TimeType value : TimeType.values()) {
+			status.put(value.getCode(), value);
+		}
+	}
+
+	public static TimeType getField(String code) {
+		if (containsType(code)) {
+			return status.get(code);
+		}
+		return ZS;
+	}
+
+	public static boolean containsType(String code) {
+		return status.containsKey(code);
+	}
+
+	private Integer	code;
+	private String	desc;
+
+	public Integer getCode() {
+		return code;
+	}
+
+	public String getDesc() {
+		return desc;
+	}
+}

+ 172 - 116
src/main/java/com/goafanti/report/service/SalesReportServiceImpl.java

@@ -15,6 +15,8 @@ import org.apache.commons.lang3.time.DateFormatUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.ui.ModelMap;
+
+import com.alibaba.druid.sql.visitor.functions.If;
 import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.dao.DailySalesReportMapper;
 import com.goafanti.common.dao.UserMapper;
@@ -22,13 +24,17 @@ import com.goafanti.common.error.BusinessException;
 import com.goafanti.common.model.DailySalesReport;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.report.bo.CountDepMarketingStatisticsBo;
+import com.goafanti.report.bo.CountMarketingStatisticsBo;
 import com.goafanti.report.bo.DepartmentSalesReportBO;
 import com.goafanti.report.bo.PersonalSalesReportBO;
 import com.goafanti.report.bo.ReportDate;
 import com.goafanti.report.bo.SalesValues;
+import com.goafanti.report.bo.SomeTimeMarketingBo;
 import com.goafanti.report.bo.marketingESBo;
 import com.goafanti.report.enums.OrderBy;
 import com.goafanti.report.enums.SalesReportOrderField;
+import com.goafanti.report.enums.TimeType;
 
 @Service
 public class SalesReportServiceImpl extends BaseMybatisDao<DailySalesReportMapper> {
@@ -249,138 +255,188 @@ public class SalesReportServiceImpl extends BaseMybatisDao<DailySalesReportMappe
 		}
 	}
 
-	@SuppressWarnings("unchecked")
-	public Pagination<marketingESBo> marketingStatistics(String depId,Integer pNo,Integer pSize) {
-		if (pNo == null || pNo < 0) {
-			pNo = 1;
-		}
-
-		if (pSize == null || pSize < 0 || pSize > 10) {
-			pSize = 10;
-		}
-		Map<String, Object> params=new HashMap<>();
-		if (StringUtils.isNotBlank(depId)) {
-			params.put("depId", depId);
-		}
-		Pagination<marketingESBo> p=(Pagination<marketingESBo>) findPage("findmarketingStatisticsListByPage",
-				"findmarketingStatisticsCount",params,
-				pNo, pSize);
-		List<marketingESBo> list=(List<marketingESBo>) p.getList();
-		List<marketingESBo> l=new ArrayList<>();
-		
-			ReportDate rd = new ReportDate(new Date());
-			
-			for (marketingESBo m : list) {
+	
+	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));
-				if (day!=null&&StringUtils.isBlank(day.getYearFollowNo())) {
-					m.setDailyFollowNo(day.getYearFollowNo());
-				}
-				if (day!=null&&StringUtils.isBlank(day.getYearTelNo())) {
-					m.setDailyTelNo(day.getYearTelNo());
-				}
-				if (day!=null&&StringUtils.isBlank(day.getYearVisitNo())) {
-					m.setDailyVisitNo(day.getYearVisitNo());
-				}
+				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));
-				if (weekly!=null&&StringUtils.isNotBlank(weekly.getYearFollowNo())) {
-					m.setWeeklyFollowNo(weekly.getYearFollowNo());
-				}
-				if (weekly!=null&&StringUtils.isNotBlank(weekly.getYearTelNo())) {
-					m.setWeeklyTelNo(weekly.getYearTelNo());
-				}
-				if (weekly!=null&&StringUtils.isNotBlank(weekly.getYearVisitNo())) {
-					m.setWeeklyVisitNo(weekly.getYearVisitNo());
-				}
+					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));
-				if (month!=null&&StringUtils.isNotBlank(month.getYearFollowNo())) {
-					m.setMonthFollowNo(month.getYearFollowNo());
-				}
-				if (month!=null&&StringUtils.isNotBlank(month.getYearTelNo())) {
-					m.setMonthTelNo(month.getYearTelNo());
-				}
-				if (month!=null&&StringUtils.isNotBlank(month.getYearVisitNo())) {
-					m.setMonthVisitNo(month.getYearVisitNo());
-				}
+					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));
-				if (year!=null&&StringUtils.isNotBlank(year.getYearFollowNo())) {
-					m.setYearFollowNo(year.getYearFollowNo());
-				}
-				if (year!=null&&StringUtils.isNotBlank(year.getYearTelNo())) {
-					m.setYearTelNo(year.getYearTelNo());
-				}
-				if (year!=null&&StringUtils.isNotBlank(year.getYearVisitNo())) {
-					m.setYearVisitNo(year.getYearVisitNo());
-				}
-				l.add(m);
+					Map<String,String> annual =valuesloading(year);
+					map.put("annual", annual);
+				m.setValues(map);
 			}
-			p.setList(l);	
-		return p;
+			return list;
 	}
 
-	@SuppressWarnings("unchecked")
-	public Pagination<marketingESBo> marketingDepStatistics(String depId, Integer pNo, Integer pSize) {
-		if (pNo == null || pNo < 0) {
-			pNo = 1;
+	
+	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;
+	}
 
-		if (pSize == null || pSize < 0 || pSize > 10) {
-			pSize = 10;
-		}
-		Map<String, Object> params=new HashMap<>();
-		if (StringUtils.isNotBlank(depId)) {
-			params.put("depId", depId);
-		}
-		Pagination<marketingESBo> p=(Pagination<marketingESBo>) findPage("findmarketingDepStatisticsListByPage","findmarketingDepStatisticsCount",params,pNo, pSize);
-		List<marketingESBo> list=(List<marketingESBo>) p.getList();
-		List<marketingESBo> l=new ArrayList<>();
+	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=userMapper.marketingDepStatistics(m.getDepartmentId(),DateFormatUtils.format(rd.getDailyStart(), AFTConstants.YYYYMMDDHHMMSS),DateFormatUtils.format(rd.getDailyEnd(), AFTConstants.YYYYMMDDHHMMSS));
-				if (day!=null&&StringUtils.isNotBlank(day.getYearFollowNo())) {
-					m.setDailyFollowNo(day.getYearFollowNo());
-					System.out.println(day.getYearFollowNo());
-					System.out.println(m.getDailyFollowNo());
-				}
-				if (day!=null&&StringUtils.isNotBlank(day.getYearTelNo())) {
-					m.setDailyTelNo(day.getYearTelNo());
-				}
-				if (day!=null&&StringUtils.isNotBlank(day.getYearVisitNo())) {
-					m.setDailyVisitNo(day.getYearVisitNo());
-				}
+					Map<String,String> daily =valuesloading(day);
+					daily.put("AVG", calculateAVG((null==day||null==day.getYearFollowNo())?"0":day.getYearFollowNo(),(null==day||null==day.getDepartmentNumber())?"0":day.getDepartmentNumber()));
+					map.put("daily", daily);
 				marketingESBo weekly=userMapper.marketingDepStatistics(m.getDepartmentId(),DateFormatUtils.format(rd.getWeeklyStart(), AFTConstants.YYYYMMDDHHMMSS),DateFormatUtils.format(rd.getWeeklyEnd(), AFTConstants.YYYYMMDDHHMMSS));
-				if (weekly!=null&&StringUtils.isNotBlank(weekly.getYearFollowNo())) {
-					m.setWeeklyFollowNo(weekly.getYearFollowNo());
-				}
-				if (weekly!=null&&StringUtils.isNotBlank(weekly.getYearTelNo())) {
-					m.setWeeklyTelNo(weekly.getYearTelNo());
-				}
-				if (weekly!=null&&StringUtils.isNotBlank(weekly.getYearVisitNo())) {
-					m.setWeeklyVisitNo(weekly.getYearVisitNo());
-				}
+					Map<String,String> week =valuesloading(weekly);
+					map.put("week", week);
 				marketingESBo month=userMapper.marketingDepStatistics(m.getDepartmentId(),DateFormatUtils.format(rd.getMonthStart(), AFTConstants.YYYYMMDDHHMMSS),DateFormatUtils.format(rd.getMonthEnd(), AFTConstants.YYYYMMDDHHMMSS));
-				if (month!=null&&StringUtils.isNotBlank(month.getYearFollowNo())) {
-					m.setMonthFollowNo(month.getYearFollowNo());
-				}
-				if (month!=null&&StringUtils.isNotBlank(month.getYearTelNo())) {
-					m.setMonthTelNo(month.getYearTelNo());
-				}
-				if (month!=null&&StringUtils.isNotBlank(month.getYearVisitNo())) {
-					m.setMonthVisitNo(month.getYearVisitNo());
-				}
+					Map<String,String> months =valuesloading(month);
+					map.put("months", months);
 				marketingESBo year=userMapper.marketingDepStatistics(m.getDepartmentId(),DateFormatUtils.format(rd.getYearStart(), AFTConstants.YYYYMMDDHHMMSS),DateFormatUtils.format(rd.getYearEnd(), AFTConstants.YYYYMMDDHHMMSS));
-				if (year!=null&&StringUtils.isNotBlank(year.getYearFollowNo())) {
-					m.setYearFollowNo(year.getYearFollowNo());
-				}
-				if (year!=null&&StringUtils.isNotBlank(year.getYearTelNo())) {
-					m.setYearTelNo(year.getYearTelNo());
-				}
-				if (year!=null&&StringUtils.isNotBlank(year.getYearVisitNo())) {
-					m.setYearVisitNo(year.getYearVisitNo());
-				}
-				l.add(m);
+					Map<String,String> annual =valuesloading(year);
+					map.put("annual", annual);
+				m.setValues(map);
 			}
-			p.setList(l);	
-		return p;
+				
+		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());
+		}
+		return count;
+	}
+
+	public CountMarketingStatisticsBo countMarketingDepStatistics(String depId) {
+		
+		CountDepMarketingStatisticsBo count=salesReportMapper.privateCustomersDepCount(depId);
+		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()));
+		}
+		return count;
+	}
+
+	public String calculateAVG(String a, String b) {
+		if (StringUtils.isNumeric(a)&&StringUtils.isNumeric(b)) {
+			if ((float)Integer.valueOf(a)==0||(float)Integer.valueOf(b)==0)return "0"; 
+			float f=(float)Integer.valueOf(a)/(float)Integer.valueOf(b);
+			return String.valueOf(f);	
+		}else {
+			return"0";
+		}
+	}
+
+	public List<SomeTimeMarketingBo> sometimeMarketingStatistics(String depId, Integer timeType, String startTime, String endTime) {
+		List<SomeTimeMarketingBo> list = null;
+		ReportDate rd = new ReportDate(new Date());
+		if (TimeType.WEEKLY.getCode()==timeType) {
+			list=salesReportMapper.sometimeMarketingStatistics(depId,rd.getStringWeeklyStart(),rd.getStringWeeklyEnd());
+		}
+		if (TimeType.MONTH.getCode()==timeType) {
+			list=salesReportMapper.sometimeMarketingStatistics(depId,rd.getStringMonthStart(),rd.getStringMonthEnd());
+		}
+		if (TimeType.QTR.getCode()==timeType) {
+			list=salesReportMapper.sometimeMarketingStatistics(depId,rd.getStringQuarterStart(),rd.getStringQuarterEnd());
+		}
+		if (TimeType.YEAR.getCode()==timeType) {
+			list=salesReportMapper.sometimeMarketingStatistics(depId,rd.getStringYearStart(),rd.getStringYearEnd());
+		}
+		if (TimeType.ZS.getCode()==timeType) {
+			list=salesReportMapper.sometimeMarketingStatistics(depId,startTime,endTime);
+		}
+		return list;
+	}
+
+	public List<SomeTimeMarketingBo> sometimeMarketingDepStatistics(String depId, Integer timeType, String startTime, String endTime) {
+		List<SomeTimeMarketingBo> list = null;
+		ReportDate rd = new ReportDate(new Date());
+		if (TimeType.WEEKLY.getCode()==timeType) {
+			list=salesReportMapper.sometimeMarketingDepStatistics(depId,rd.getStringWeeklyStart(),rd.getStringWeeklyEnd());
+		}
+		if (TimeType.MONTH.getCode()==timeType) {
+			list=salesReportMapper.sometimeMarketingDepStatistics(depId,rd.getStringMonthStart(),rd.getStringMonthEnd());
+		}
+		if (TimeType.QTR.getCode()==timeType) {
+			list=salesReportMapper.sometimeMarketingDepStatistics(depId,rd.getStringQuarterStart(),rd.getStringQuarterEnd());
+		}
+		if (TimeType.YEAR.getCode()==timeType) {
+			list=salesReportMapper.sometimeMarketingDepStatistics(depId,rd.getStringYearStart(),rd.getStringYearEnd());
+		}
+		if (TimeType.ZS.getCode()==timeType) {
+			list=salesReportMapper.sometimeMarketingDepStatistics(depId,startTime,endTime);
+		}
+		return list;
 	}
+	
 
 }