Commit 2c9d680d by 阳浪

日期查询优化1-今年2-本月3-今日4-本周

parent 0d47e437
...@@ -64,15 +64,7 @@ public class PointUserServiceImpl extends ServiceImpl<PointUserMapper, PointUser ...@@ -64,15 +64,7 @@ public class PointUserServiceImpl extends ServiceImpl<PointUserMapper, PointUser
Integer start =(vo.getPageNo()-1)*vo.getPageSize(); Integer start =(vo.getPageNo()-1)*vo.getPageSize();
Integer end=vo.getPageNo()*vo.getPageSize(); Integer end=vo.getPageNo()*vo.getPageSize();
Page<PointUserListVO> page = new Page<PointUserListVO>(vo.getPageNo(), vo.getPageSize()); Page<PointUserListVO> page = new Page<PointUserListVO>(vo.getPageNo(), vo.getPageSize());
String date = DateUtil.toDay(new Date()); vo.setDateString(getDateString(vo.getDateType()));
String[] dateArrays = date.split("-");
vo.setDateString(date);
if(Objects.equals(vo.getDateType(),1)){
vo.setDateString(dateArrays[0]);
}
if(Objects.equals(vo.getDateType(),2)){
vo.setDateString(dateArrays[0]+"-"+dateArrays[1]);
}
vo.setPageNo(start); vo.setPageNo(start);
vo.setPageSize(end); vo.setPageSize(end);
List<PointUserListVO> pointUserListVOS = pointUserMapper.getNewUserRankList(vo); List<PointUserListVO> pointUserListVOS = pointUserMapper.getNewUserRankList(vo);
...@@ -235,4 +227,25 @@ public class PointUserServiceImpl extends ServiceImpl<PointUserMapper, PointUser ...@@ -235,4 +227,25 @@ public class PointUserServiceImpl extends ServiceImpl<PointUserMapper, PointUser
return hashMap; return hashMap;
} }
public String getDateString(Integer dateType) {
String dateString = DateUtil.toDay(new Date());
String[] dateArrays = dateString.split("-");
if(Objects.equals(dateType,1)){
dateString = dateArrays[0];
}
if(Objects.equals(dateType,2)){
dateString = dateArrays[0]+"-"+dateArrays[1];
}
if(Objects.equals(dateType,4)){
Calendar calendar = Calendar.getInstance();
int week = calendar.get(Calendar.WEEK_OF_YEAR);
if(week==1){
dateString = String.valueOf(Integer.valueOf(dateArrays[0])-1);
}else{
dateString = dateArrays[0];
}
}
return dateString;
}
} }
...@@ -73,6 +73,9 @@ ...@@ -73,6 +73,9 @@
<if test="vo.dateType!=null and vo.dateType==3"> <if test="vo.dateType!=null and vo.dateType==3">
and DATE_FORMAT(pu.create_time, '%Y-%m-%d') = #{vo.dateString} and DATE_FORMAT(pu.create_time, '%Y-%m-%d') = #{vo.dateString}
</if> </if>
<if test="vo.dateType!=null and vo.dateType==4">
and WEEK(pu.create_time) = WEEK(now())
</if>
<if test="vo.nameType!=null and vo.nameType==1"> <if test="vo.nameType!=null and vo.nameType==1">
group by aug.name group by aug.name
</if> </if>
...@@ -188,6 +191,9 @@ ...@@ -188,6 +191,9 @@
<if test="vo.dateType!=null and vo.dateType==3"> <if test="vo.dateType!=null and vo.dateType==3">
and DATE_FORMAT(pu.create_time, '%Y-%m-%d') = #{vo.dateString} and DATE_FORMAT(pu.create_time, '%Y-%m-%d') = #{vo.dateString}
</if> </if>
<if test="vo.dateType!=null and vo.dateType==4">
and WEEK(pu.create_time) = WEEK(now())
</if>
<if test="vo.nameType!=null and vo.nameType==1"> <if test="vo.nameType!=null and vo.nameType==1">
group by aug.name group by aug.name
</if> </if>
......
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