Commit 0fcfd98f by 阳浪

投稿统计

parent 298a324a
...@@ -22,6 +22,7 @@ public interface EventTrackMapper extends BaseMapper<EventTrack> { ...@@ -22,6 +22,7 @@ public interface EventTrackMapper extends BaseMapper<EventTrack> {
EventTrackDayNumVo getTodayNum(@Param("date") String date); EventTrackDayNumVo getTodayNum(@Param("date") String date);
DayNumVo getNumByType(@Param("date") String date,@Param("dateString") String dateString,@Param("types")List<Integer> types); DayNumVo getNumByType(@Param("date") String date,@Param("dateString") String dateString,@Param("types")List<Integer> types);
DayNumVo getTgNumByType(@Param("date") String date,@Param("dateString") String dateString);
List<EventTrackTypeNumVo> queryNumByType(@Param("deptId") Long deptId,@Param("date") String date,@Param("dateString") String dateString,@Param("types")List<Integer> types,@Param("subNameList")List<String> subNameList); List<EventTrackTypeNumVo> queryNumByType(@Param("deptId") Long deptId,@Param("date") String date,@Param("dateString") String dateString,@Param("types")List<Integer> types,@Param("subNameList")List<String> subNameList);
......
...@@ -150,7 +150,13 @@ public class EventTrackServiceImpl extends ServiceImpl<EventTrackMapper, EventTr ...@@ -150,7 +150,13 @@ public class EventTrackServiceImpl extends ServiceImpl<EventTrackMapper, EventTr
if(ObjectUtils.isEmpty(date)){ if(ObjectUtils.isEmpty(date)){
date = "3"; date = "3";
} }
if(CollectionUtil.isEmpty(types)){
return new DayNumVo(){{setNum(0);setPreNum(0);}};
}
String dateString =getDateString(date); String dateString =getDateString(date);
if(Objects.equals(types.get(0),5)){
return this.baseMapper.getTgNumByType(date,dateString);
}
return this.baseMapper.getNumByType(date,dateString,types); return this.baseMapper.getNumByType(date,dateString,types);
} }
......
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
select ifnull(sum(num),0) as num,ifnull(sum(preNum),0) as preNum select ifnull(sum(num),0) as num,ifnull(sum(preNum),0) as preNum
from( from(
select select
case when e.type = 1 and case when
<if test="date==4"> <if test="date==4">
WEEK(e.create_time) = WEEK(now()) and DATE_FORMAT(e.create_time, '%Y') = DATE_FORMAT(now(), '%Y') WEEK(e.create_time) = WEEK(now()) and DATE_FORMAT(e.create_time, '%Y') = DATE_FORMAT(now(), '%Y')
</if> </if>
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
DATE_FORMAT(e.create_time, '%Y') = #{dateString} DATE_FORMAT(e.create_time, '%Y') = #{dateString}
</if> </if>
then 1 else 0 end as num, then 1 else 0 end as num,
case when e.type = 1 and case when
<if test="date==4"> <if test="date==4">
WEEK(e.create_time) = WEEK(DATE_SUB(DATE_FORMAT(now(), '%Y-%m-%d'), INTERVAL 7 DAY)) and DATE_FORMAT(e.create_time, '%Y') = #{dateString} WEEK(e.create_time) = WEEK(DATE_SUB(DATE_FORMAT(now(), '%Y-%m-%d'), INTERVAL 7 DAY)) and DATE_FORMAT(e.create_time, '%Y') = #{dateString}
</if> </if>
...@@ -113,6 +113,42 @@ ...@@ -113,6 +113,42 @@
</if> </if>
) a ) a
</select> </select>
<select id="getTgNumByType" resultType="com.yizhi.site.application.vo.site.DayNumVo">
select ifnull(sum(num),0) as num,ifnull(sum(preNum),0) as preNum
from(
select
case when
<if test="date==4">
WEEK(e.create_time) = WEEK(now()) and DATE_FORMAT(e.create_time, '%Y') = DATE_FORMAT(now(), '%Y')
</if>
<if test="date==3">
DATE_FORMAT(e.create_time, '%Y-%m-%d') = #{dateString}
</if>
<if test="date==2">
DATE_FORMAT(e.create_time, '%Y-%m') = #{dateString}
</if>
<if test="date==1">
DATE_FORMAT(e.create_time, '%Y') = #{dateString}
</if>
then 1 else 0 end as num,
case when
<if test="date==4">
WEEK(e.create_time) = WEEK(DATE_SUB(DATE_FORMAT(now(), '%Y-%m-%d'), INTERVAL 7 DAY)) and DATE_FORMAT(e.create_time, '%Y') = #{dateString}
</if>
<if test="date==3">
DATE_SUB(DATE_FORMAT(e.create_time, '%Y-%m-%d'), INTERVAL -1 DAY) = #{dateString}
</if>
<if test="date==2">
DATE_FORMAT(DATE_SUB(DATE_FORMAT(now(), '%Y-%m-%d'), INTERVAL 1 MONTH),'%Y-%m') = #{dateString}
</if>
<if test="date==1">
DATE_FORMAT(DATE_SUB(DATE_FORMAT(now(), '%Y-%m-%d'), INTERVAL 1 YEAR),'%Y') = #{dateString}
</if>
then 1 else
0 end as preNum from publication e
) a
</select>
<select id="getNum" resultType="java.lang.Integer"> <select id="getNum" resultType="java.lang.Integer">
select count(1) from event_track e where e.deleted =0 select count(1) from event_track e where e.deleted =0
and e.type=#{type} and e.business_id = #{businessId} and e.type=#{type} and e.business_id = #{businessId}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment