Browse Source

本地数据库更换地址以及营销报表上传

anderx 7 years ago
parent
commit
3b8790d0d6

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

@@ -73,5 +73,7 @@ public interface DailySalesReportMapper {
 
 	SomeTimeMarketingBo countsometimeMarketingStatistics(@Param("depId")String depId, @Param("startTime")String startTime, @Param("endTime")String endTime);
 
+	SomeTimeMarketingBo countsometimeMarketingDepStatistics(@Param("depId")String depId, @Param("startTime")String startTime, @Param("endTime")String endTime);
+
 
 }

+ 45 - 33
src/main/java/com/goafanti/common/mapper/DailySalesReportMapper.xml

@@ -533,54 +533,39 @@ select a.id,a.name,d.name as departmentName,role_name as roleName,ifnull(e.telNo
 	order by a.name 
 </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
-	<if test="startTime !=null and endTime !=null">
-			,e.followNo/datediff(#{endTime,jdbcType=VARCHAR},#{startTime,jdbcType=VARCHAR}) as AVG
-			</if>
-	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,
+	select z.id,z.name as departmentName,y.name as departmentManagerName,
+ 		x.followNo as countFollowNo,x.visitNo as countVisitNo,x.telNo as countTelNo
+ 		<if test="startTime !=null and endTime !=null">
+			,x.followNo/datediff(#{endTime,jdbcType=VARCHAR},#{startTime,jdbcType=VARCHAR}) as dayAVG
+		</if>
+	 from (select b.department_id as departmentId,sum(a.followNo) as followNo,sum(a.visitNo)as visitNo,sum(a.telNo)as telNo
+			from (select
+		aid,
 		count( 0 ) as followNo,
 		ifnull(
-			sum( case when a.contact_type = 0 then 1 else 0 end ),
+			sum( case when contact_type = 0 then 1 else 0 end ),
 			0
 		) as visitNo,
 		ifnull(
-			sum( case when a.contact_type = 1 then 1 else 0 end ),
+			sum( case when 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
+	from user_follow a 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 = '营销管理员'
-	)
+	GROUP BY aid)a left join admin b on a.aid=b.id
+	left join department_management c on b.department_id=c.id
+	where b.department_id is not null  and b.department_id !=''
 	<if test="depId != null">
-	and a.department_id= #{depId,jdbcType=VARCHAR}
+	and b.department_id=#{depId,jdbcType=VARCHAR}
 	</if>
-	group by a.department_id
+	GROUP by b.department_id
+) x left join department_management z on x.departmentId=z.id
+	left join admin y on z.manager_id=y.id
 	</select>
 	<select id="countsometimeMarketingStatistics" parameterType="String" resultType="com.goafanti.report.bo.SomeTimeMarketingBo">
 		select
@@ -608,4 +593,31 @@ select a.id,a.name,d.name as departmentName,role_name as roleName,ifnull(e.telNo
 		and a.department_id= #{depId,jdbcType=VARCHAR}
 		</if>
 	</select>
+	
+	<select id="countsometimeMarketingDepStatistics" parameterType="String" resultType="com.goafanti.report.bo.SomeTimeMarketingBo">
+		select
+			count( 0 ) as countFollowNo,
+			ifnull(
+				sum( case when a.contact_type = 0 then 1 else 0 end ),
+				0
+			) as countVisitNo,
+			ifnull(
+				sum( case when a.contact_type = 1 then 1 else 0 end ),
+				0
+			) as countTelNo
+			<if test="startTime !=null and endTime !=null">
+			,count( 0 )/datediff(#{endTime,jdbcType=VARCHAR},#{startTime,jdbcType=VARCHAR}) as A
+			</if>
+		from
+			user_follow a left join admin b on
+			a.aid = b.id left join department_management c on
+			b.department_id = c.id left join user_role d on
+			b.id = d.uid left join role e on
+			d.rid = e.id
+		where 1 = 1
+		and( e.role_name = '营销员' or e.role_name = '营销经理' or e.role_name = '营销管理员')
+		<if test="depId != null">
+		and a.department_id= #{depId,jdbcType=VARCHAR}
+		</if>
+	</select>
 </mapper>

+ 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 = "/open/api/admin/report")
+@RequestMapping(value = "/api/admin/report")
 public class ReportApiController extends BaseApiController {
 	@Autowired
 	SalesReportServiceImpl reportService;

+ 18 - 2
src/main/java/com/goafanti/report/service/SalesReportServiceImpl.java

@@ -362,8 +362,24 @@ public class SalesReportServiceImpl extends BaseMybatisDao<DailySalesReportMappe
 
 	public SomeTimeMarketingBo countSometimeMarketingDepStatistics(String depId, Integer timeType, String startTime,
 			String endTime) {
-		
-		return null;
+
+		ReportDate rd = new ReportDate(new Date());
+		if (TimeType.WEEKLY.getCode()==timeType) {
+			return salesReportMapper.countsometimeMarketingDepStatistics(depId,rd.getStringWeeklyStart(),rd.getStringWeeklyEnd());
+		}
+		if (TimeType.MONTH.getCode()==timeType) {
+			return salesReportMapper.countsometimeMarketingDepStatistics(depId,rd.getStringMonthStart(),rd.getStringMonthEnd());
+		}
+		if (TimeType.QTR.getCode()==timeType) {
+			return salesReportMapper.countsometimeMarketingDepStatistics(depId,rd.getStringQuarterStart(),rd.getStringQuarterEnd());
+		}
+		if (TimeType.YEAR.getCode()==timeType) {
+			return salesReportMapper.countsometimeMarketingDepStatistics(depId,rd.getStringYearStart(),rd.getStringYearEnd());
+		}
+		if (TimeType.ZS.getCode()==timeType) {
+			return salesReportMapper.countsometimeMarketingDepStatistics(depId,startTime,endTime);
+		}
+			return null;
 	}
 	
 

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

@@ -40,7 +40,7 @@ jdbc.filters=stat
 
 logging.level.com.goafanti=DEBUG
 
-jedis.host=192.168.1.213
+jedis.host=127.0.0.1
 jedis.port=6379
 jedis.timeout=5000
 jedis.password=aft123456