浏览代码

统计指定时间和应用新增企业和个人数接口
统计指定时间登录个人数接口
统计指定月份前未登录人数接口

huyy 7 年之前
父节点
当前提交
571b45cf8b

+ 22 - 5
sso-server/src/main/java/com/uas/sso/controller/UserManagerController.java

@@ -3,6 +3,7 @@ package com.uas.sso.controller;
 import com.uas.account.exception.AccountException;
 import com.uas.account.exception.AccountException;
 import com.uas.sso.core.Const;
 import com.uas.sso.core.Const;
 import com.uas.sso.entity.*;
 import com.uas.sso.entity.*;
+import com.uas.sso.i.CountCallBack;
 import com.uas.sso.service.ApplyUserSpaceService;
 import com.uas.sso.service.ApplyUserSpaceService;
 import com.uas.sso.service.UserService;
 import com.uas.sso.service.UserService;
 import com.uas.sso.service.UserspaceService;
 import com.uas.sso.service.UserspaceService;
@@ -446,11 +447,12 @@ public class UserManagerController extends BaseController {
 
 
     /**
     /**
      * 统计指定应用个人用户总数
      * 统计指定应用个人用户总数
+     *
      * @param fromApps
      * @param fromApps
      * @return
      * @return
      */
      */
-    @RequestMapping(value = "/count/apps",method = RequestMethod.GET)
-    public ModelMap countForApp(String fromApps){
+    @RequestMapping(value = "/count/apps", method = RequestMethod.GET)
+    public ModelMap countForApp(String fromApps) {
         String[] apps = fromApps.split(",");
         String[] apps = fromApps.split(",");
         return success(userService.count(new ArrayList<>(Arrays.asList(apps))));
         return success(userService.count(new ArrayList<>(Arrays.asList(apps))));
     }
     }
@@ -567,16 +569,31 @@ public class UserManagerController extends BaseController {
         }
         }
         return null;
         return null;
     }
     }
+
     /**
     /**
      * 统计指定时间内个人用户登录总数
      * 统计指定时间内个人用户登录总数
      */
      */
     @RequestMapping(value = "/count/login", method = RequestMethod.GET)
     @RequestMapping(value = "/count/login", method = RequestMethod.GET)
-    public ModelMap countByLogin(String start,String end) throws ParseException {
-        return new ModelMap("count", userService.countByLogin(start,end));
+    public ModelMap countByLogin(String start, String end) throws ParseException {
+        return new ModelMap("count", userService.countByLogin(start, end));
     }
     }
 
 
     /**
     /**
-     * 统计指定时间内个人用户登录总数
+     * 统计指定时间内X未登录用户数
+     *
+     * @param start
+     * @param end
+     * @param month
+     * @return
+     * @throws ParseException
+     */
+    @RequestMapping(value = "/count/notlgoin/month", method = RequestMethod.GET)
+    public ModelMap countByNotLogin(String start, String end, int month) throws ParseException {
+        return new ModelMap("count", userService.countByLoginInputMonth(start, end, month));
+    }
+
+    /**
+     * 统计指定时间内个人用户未登录总数
      */
      */
     @RequestMapping(value = "/count/notlogin", method = RequestMethod.GET)
     @RequestMapping(value = "/count/notlogin", method = RequestMethod.GET)
     public ModelMap countByNotLogin(int month) throws ParseException {
     public ModelMap countByNotLogin(int month) throws ParseException {

+ 10 - 0
sso-server/src/main/java/com/uas/sso/service/UserService.java

@@ -451,4 +451,14 @@ public interface UserService {
      * @return
      * @return
      */
      */
     long countByNotLogin(int month);
     long countByNotLogin(int month);
+
+    /**
+     * 统计XXX和月前登录人数
+     * @param startTime
+     * @param endTime
+     * @param month
+     * @return
+     * @throws ParseException
+     */
+    Long countByLoginInputMonth(String startTime,String endTime, int month) throws ParseException;
 }
 }

+ 19 - 0
sso-server/src/main/java/com/uas/sso/service/impl/UserServiceImpl.java

@@ -653,6 +653,23 @@ public class UserServiceImpl implements UserService {
         return userRecordDao.getCountByLogin(new Timestamp(starttime.getTimeInMillis()),new Timestamp(endtime.getTimeInMillis()));
         return userRecordDao.getCountByLogin(new Timestamp(starttime.getTimeInMillis()),new Timestamp(endtime.getTimeInMillis()));
     }
     }
 
 
+    @Override
+    public Long countByLoginInputMonth(String startTime,String endTime, int month) throws ParseException {
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date startToDate = simpleDateFormat.parse(startTime);
+        Date endToDate = simpleDateFormat.parse(endTime);
+        Calendar start = Calendar.getInstance();
+        start.setTime(startToDate);
+        start.add(Calendar.MONTH, -month);
+        Calendar end = Calendar.getInstance();
+        end.setTime(endToDate);
+        end.add(Calendar.MONTH, -month);
+        System.out.println(new Timestamp(start.getTimeInMillis()));
+        System.out.println(new Timestamp(end.getTimeInMillis()));
+        return userRecordDao.getCountByLogin(new Timestamp(start.getTimeInMillis()),new Timestamp(end.getTimeInMillis()));
+
+    }
+
     @Override
     @Override
     public long countByRegisterDate(final Calendar start, final Calendar end) {
     public long countByRegisterDate(final Calendar start, final Calendar end) {
         return userDao.count(new Specification<User>() {
         return userDao.count(new Specification<User>() {
@@ -679,6 +696,8 @@ public class UserServiceImpl implements UserService {
         return data;
         return data;
     }
     }
 
 
+
+
     @Override
     @Override
     public long countInCurrentMonth() {
     public long countInCurrentMonth() {
         return CountUtils.countInCurrentMonth(new CountCallBack<Long>() {
         return CountUtils.countInCurrentMonth(new CountCallBack<Long>() {

+ 4 - 2
sso-server/src/main/java/com/uas/sso/util/HttpUtil.java

@@ -9,6 +9,8 @@ import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.util.EntityUtils;
 import org.apache.http.util.EntityUtils;
 import org.springframework.http.MediaType;
 import org.springframework.http.MediaType;
 
 
+import java.io.IOException;
+
 /**
 /**
  * @author wangmh
  * @author wangmh
  * @create 2018-07-18 18:01
  * @create 2018-07-18 18:01
@@ -16,7 +18,7 @@ import org.springframework.http.MediaType;
  **/
  **/
 public class HttpUtil {
 public class HttpUtil {
 
 
-    public static String doPost(String postUrl, String formData) throws Exception {
+    public static String doPost(String postUrl, String formData) throws IOException {
         HttpClient httpClient = new DefaultHttpClient();
         HttpClient httpClient = new DefaultHttpClient();
         HttpPost post = new HttpPost(postUrl);
         HttpPost post = new HttpPost(postUrl);
         StringEntity postingString = new StringEntity(formData, "UTF-8");
         StringEntity postingString = new StringEntity(formData, "UTF-8");
@@ -27,7 +29,7 @@ public class HttpUtil {
         return content;
         return content;
     }
     }
 
 
-    public static String doPut(String putUrl, String formData) throws Exception {
+    public static String doPut(String putUrl, String formData) throws IOException {
         HttpClient httpClient = new DefaultHttpClient();
         HttpClient httpClient = new DefaultHttpClient();
         HttpPut post = new HttpPut(putUrl);
         HttpPut post = new HttpPut(putUrl);
         StringEntity postingString = new StringEntity(formData, "UTF-8");
         StringEntity postingString = new StringEntity(formData, "UTF-8");