Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
znks
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王夏晖
znks
Commits
d8bebe64
Commit
d8bebe64
authored
Nov 08, 2018
by
leyboy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2018/11/08,统计用户信息
parent
80ca43b6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
105 additions
and
26 deletions
+105
-26
UserController.java
.../main/java/com/adc/da/znks/controller/UserController.java
+14
-5
PositionDao.java
...a-main/src/main/java/com/adc/da/znks/dao/PositionDao.java
+23
-0
PositionService.java
...rc/main/java/com/adc/da/znks/service/PositionService.java
+1
-0
UserService.java
...in/src/main/java/com/adc/da/znks/service/UserService.java
+31
-18
PositionMapper.xml
...src/main/resources/mybatis/mapper/znks/PositionMapper.xml
+20
-0
SecurityUtilsTest.java
...rc/test/java/com/adc/da/gen/jasypt/SecurityUtilsTest.java
+16
-3
No files found.
adc-da-main/src/main/java/com/adc/da/znks/controller/UserController.java
View file @
d8bebe64
...
...
@@ -9,6 +9,7 @@ import com.adc.da.znks.entity.User;
import
com.adc.da.znks.service.LockRecordService
;
import
com.adc.da.znks.service.UserService
;
import
com.adc.da.znks.util.GenResponse
;
import
com.adc.da.znks.vo.UserCountVO
;
import
com.adc.da.znks.vo.UserSearch
;
import
com.adc.da.znks.vo.UserVO
;
import
com.github.pagehelper.PageHelper
;
...
...
@@ -21,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.List
;
/**
...
...
@@ -42,10 +44,10 @@ public class UserController extends BaseController<User> {
@PostMapping
(
value
=
{
"/loginOrRegisterUser"
})
public
ResponseEntity
<
Boolean
>
loginOrRegisterUser
(
String
phoneNumber
,
String
password
)
{
int
i
=
userService
.
loginOrRegister
(
phoneNumber
,
password
);
if
(
i
<
0
)
{
if
(
i
<
0
)
{
return
GenResponse
.
success
(
String
.
valueOf
(
HttpStatus
.
OK
),
"用户不存在"
,
false
);
}
else
{
if
(
i
>
0
)
{
if
(
i
>
0
)
{
return
GenResponse
.
success
(
String
.
valueOf
(
HttpStatus
.
OK
),
"登陆成功"
,
true
);
}
return
GenResponse
.
fail
(
"登录失败"
);
...
...
@@ -96,7 +98,7 @@ public class UserController extends BaseController<User> {
List
<
UserVO
>
userVOS
=
userService
.
listUserVOsByCondition
(
userSearch
,
pageNum
,
pageSize
);
try
{
if
(
CollectionUtils
.
isNotEmpty
(
userVOS
))
{
PageInfo
<
UserVO
>
pageInfo
=
new
PageInfo
<>(
userVOS
);
PageInfo
<
UserVO
>
pageInfo
=
new
PageInfo
<>(
userVOS
);
return
GenResponse
.
success
(
String
.
valueOf
(
HttpStatus
.
OK
.
value
()),
"分页查询成功"
,
pageInfo
);
}
else
{
...
...
@@ -114,7 +116,7 @@ public class UserController extends BaseController<User> {
User
user
=
new
User
();
user
.
setTemphone
(
phoneNumber
);
user
.
setHomeName
(
homeName
);
if
(
userService
.
updateHomeName
(
user
))
{
if
(
userService
.
updateHomeName
(
user
))
{
return
GenResponse
.
success
();
}
return
GenResponse
.
fail
(
"更新失败"
);
...
...
@@ -124,7 +126,7 @@ public class UserController extends BaseController<User> {
@PostMapping
(
"/getHomeName"
)
public
ResponseEntity
<
String
>
getHomeName
(
String
phoneNumber
)
{
String
name
=
userService
.
selectHomeNameByPhone
(
phoneNumber
);
return
GenResponse
.
success
(
"200"
,
""
,
name
);
return
GenResponse
.
success
(
"200"
,
""
,
name
);
}
@ApiOperation
(
value
=
"|User|增加用户"
)
...
...
@@ -134,4 +136,11 @@ public class UserController extends BaseController<User> {
return
GenResponse
.
success
(
String
.
valueOf
(
HttpStatus
.
OK
.
value
()),
""
,
flag
);
}
@ApiOperation
(
value
=
"|User|统计用户信息"
)
@PostMapping
(
"/countUserInfo"
)
public
ResponseEntity
<
UserCountVO
>
countUserInfo
()
{
return
GenResponse
.
success
(
String
.
valueOf
(
HttpStatus
.
OK
.
value
()),
"统计用户信息成功"
,
userService
.
getUserCountVO
());
}
}
adc-da-main/src/main/java/com/adc/da/znks/dao/PositionDao.java
View file @
d8bebe64
...
...
@@ -5,6 +5,7 @@ import com.adc.da.znks.entity.Position;
import
com.adc.da.znks.vo.PositionVO
;
import
org.apache.ibatis.annotations.*
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -16,4 +17,26 @@ import java.util.Map;
public
interface
PositionDao
extends
BaseDao
<
Position
>
{
List
<
PositionVO
>
listPositionByPage
(
@Param
(
"telphone"
)
String
telphone
,
@Param
(
"pageNum"
)
Integer
pageNum
,
@Param
(
"pageSize"
)
Integer
pageSize
);
Integer
getCurrentDayUsers
(
@Param
(
"currentDay"
)
Date
currentDayTime
);
/**
* 获得天津每个地区的人数,每1小时统计一次
*
* @param tianJinArea 天津区域
* @param recordTime1 当前时间的前1个小时
* @param currentTime 当前时间
**/
Integer
getUserCountInTianJinPerArea
(
@Param
(
"area"
)
String
tianJinArea
,
@Param
(
"recordTime1"
)
String
recordTime1
,
@Param
(
"currentTime"
)
String
currentTime
);
/**
* 获得每两小时间段的人数
*
* @param recordTime1 当前时间的前1个小时
* @param currentTime 当前时间
**/
Integer
getUserCountByPerHour
(
@Param
(
"recordTime1"
)
String
recordTime1
,
@Param
(
"currentTime"
)
String
currentTime
);
}
adc-da-main/src/main/java/com/adc/da/znks/service/PositionService.java
View file @
d8bebe64
...
...
@@ -35,4 +35,5 @@ public class PositionService extends BaseService<Position, String> {
return
dao
.
listPositionByPage
(
telphone
,
pageNum
,
pageSize
);
}
}
adc-da-main/src/main/java/com/adc/da/znks/service/UserService.java
View file @
d8bebe64
...
...
@@ -10,6 +10,7 @@ import com.adc.da.znks.entity.Position;
import
com.adc.da.znks.entity.User
;
import
com.adc.da.znks.page.UserPage
;
import
com.adc.da.znks.util.SecurityUtils
;
import
com.adc.da.znks.vo.UserCountVO
;
import
com.adc.da.znks.vo.UserSearch
;
import
com.adc.da.znks.vo.UserVO
;
import
org.apache.http.util.Asserts
;
...
...
@@ -22,6 +23,7 @@ import org.springframework.transaction.annotation.Propagation;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -52,7 +54,7 @@ public class UserService extends BaseService<User, String> {
public
Boolean
getUserByPhoneNumber
(
String
phoneNumber
)
{
Boolean
flag
=
false
;
User
user
=
dao
.
getUserByPhoneNumber
(
phoneNumber
);
if
(
user
!=
null
)
{
if
(
user
!=
null
)
{
/*if(user.getPassword()!=null && !"".equals(user.getPassword())){
flag = true;
}else{
...
...
@@ -96,7 +98,7 @@ public class UserService extends BaseService<User, String> {
* user login or register
**/
public
int
loginOrRegister
(
String
temphone
,
String
plainPassword
)
{
if
(
temphone
==
null
||
plainPassword
==
null
||
temphone
.
equals
(
""
)
||
plainPassword
.
equals
(
""
))
{
if
(
temphone
==
null
||
plainPassword
==
null
||
temphone
.
equals
(
""
)
||
plainPassword
.
equals
(
""
))
{
return
-
1
;
}
UserPage
userPage
=
new
UserPage
();
...
...
@@ -116,11 +118,11 @@ public class UserService extends BaseService<User, String> {
}*/
return
-
1
;
}
else
{
if
(
users
.
size
()>
1
)
{
if
(
users
.
size
()
>
1
)
{
return
0
;
}
String
mPassword
=
SecurityUtils
.
decrypt
(
users
.
get
(
0
).
getEncryptkey
(),
users
.
get
(
0
).
getPassword
());
if
(
plainPassword
.
equals
(
mPassword
))
{
String
mPassword
=
SecurityUtils
.
decrypt
(
users
.
get
(
0
).
getEncryptkey
(),
users
.
get
(
0
).
getPassword
());
if
(
plainPassword
.
equals
(
mPassword
))
{
return
1
;
}
return
0
;
...
...
@@ -142,7 +144,7 @@ public class UserService extends BaseService<User, String> {
}
public
List
<
Map
<
String
,
Object
>>
queryMacByPhone
(
String
phone
)
{
public
List
<
Map
<
String
,
Object
>>
queryMacByPhone
(
String
phone
)
{
return
dao
.
getGateWayByPhoneNumber
(
phone
);
}
...
...
@@ -150,47 +152,58 @@ public class UserService extends BaseService<User, String> {
dao
.
updateClientIdByPhoneNumber
(
clientId
,
phoneNumber
);
}
public
List
<
Map
<
String
,
Object
>>
queryClientByMac
(
String
macAddress
)
{
public
List
<
Map
<
String
,
Object
>>
queryClientByMac
(
String
macAddress
)
{
return
dao
.
queryClientByMac
(
macAddress
);
}
/**
* 获取用户列表记录
*
*
*/
public
List
<
UserVO
>
listUserVOsByCondition
(
UserSearch
userSearch
,
Integer
pageNUm
,
Integer
pageSize
)
{
List
<
UserVO
>
userVOS
=
dao
.
listUserVOs
(
userSearch
,
pageNUm
,
pageSize
);
**/
public
List
<
UserVO
>
listUserVOsByCondition
(
UserSearch
userSearch
,
Integer
pageNUm
,
Integer
pageSize
)
{
List
<
UserVO
>
userVOS
=
dao
.
listUserVOs
(
userSearch
,
pageNUm
,
pageSize
);
return
userVOS
;
}
public
boolean
updateHomeName
(
User
user
){
if
(
dao
.
updateHomeName
(
user
)>
0
)
{
public
boolean
updateHomeName
(
User
user
)
{
if
(
dao
.
updateHomeName
(
user
)
>
0
)
{
return
true
;
}
return
false
;
}
public
String
selectHomeNameByPhone
(
String
temphone
){
public
String
selectHomeNameByPhone
(
String
temphone
)
{
List
<
User
>
list
=
dao
.
selectHomeNameByPhone
(
temphone
);
if
(!
list
.
isEmpty
())
{
if
(!
list
.
isEmpty
())
{
return
list
.
get
(
0
).
getHomeName
();
}
return
null
;
}
public
boolean
addUser
(
String
temphone
){
public
boolean
addUser
(
String
temphone
)
{
User
user
=
dao
.
getUserByPhoneNumber
(
temphone
);
if
(
user
!=
null
)
{
if
(
user
!=
null
)
{
return
false
;
}
String
id
=
UUID
.
randomUUID
();
User
insertUser
=
new
User
(
id
,
temphone
,
""
,
""
);
logger
.
info
(
"insertUser: {}"
,
insertUser
);
int
result
=
dao
.
insertSelective
(
insertUser
);
if
(
result
>
0
)
{
if
(
result
>
0
)
{
return
true
;
}
return
false
;
}
public
UserCountVO
getUserCountVO
()
{
UserPage
userPage
=
new
UserPage
();
int
userCount
=
dao
.
queryByCount
(
userPage
);
UserCountVO
userCountVO
=
new
UserCountVO
();
userCountVO
.
setUserCount
(
userCount
);
double
clickRate
=
positionDao
.
getCurrentDayUsers
(
new
Date
(
System
.
currentTimeMillis
()))
/
userCount
;
userCountVO
.
setClickRate
(
clickRate
);
userCountVO
.
setDistributeVOS
(
ZnksTaskService
.
getDistributeVOS
());
return
userCountVO
;
}
}
adc-da-main/src/main/resources/mybatis/mapper/znks/PositionMapper.xml
View file @
d8bebe64
...
...
@@ -171,4 +171,24 @@ SELECT SEQ_tb_position.NEXTVAL FROM DUAL
order by p.record_time desc
</select>
<select
id=
"getCurrentDayUsers"
resultType=
"java.lang.Integer"
parameterType=
"object"
>
SELECT COUNT(DISTINCT(user_id)) AS CURRENT_USER_COUNT
FROM tb_position
WHERE TO_DAYS(`record_time`) = TO_DAYS(#{currentDay})
</select>
<select
id=
"getUserCountInTianJinPerArea"
resultType=
"java.lang.Integer"
parameterType=
"string"
>
SELECT COUNT(user_id) AS CURRENT_USER_COUNT
FROM tb_position
WHERE position_name LIKE #{area} AND record_time>=#{recordTime1} AND record_time
<
= #{currentTime}
</select>
<select
id=
"getUserCountByPerHour"
resultType=
"java.lang.Integer"
parameterType=
"string"
>
SELECT COUNT(user_id) AS CURRENT_USER_COUNT
FROM tb_position
WHERE record_time>=#{recordTime1} AND record_time
<
= #{currentTime}
</select>
</mapper>
adc-da-main/src/test/java/com/adc/da/gen/jasypt/SecurityUtilsTest.java
View file @
d8bebe64
package
com
.
adc
.
da
.
gen
.
jasypt
;
import
com.adc.da.util.util2.DateUtil
;
import
com.adc.da.util.utils.DateUtils
;
import
com.adc.da.znks.util.DateTimeUtil
;
import
com.adc.da.znks.util.SecurityUtils
;
import
org.junit.Test
;
import
java.util.Date
;
import
java.util.UUID
;
public
class
SecurityUtilsTest
{
@Test
public
void
encrypt
()
{
String
plainPassword
=
"123456"
;
String
uuid
=
UUID
.
randomUUID
().
toString
();
String
plainPassword
=
"123456"
;
String
uuid
=
UUID
.
randomUUID
().
toString
();
System
.
out
.
println
(
uuid
);
System
.
out
.
println
(
SecurityUtils
.
encrypt
(
plainPassword
,
uuid
));
}
@Test
public
void
decrypt
(){
public
void
decrypt
()
{
System
.
out
.
println
(
SecurityUtils
.
decrypt
(
"ad0b965b-2955-46ed-bc8c-ce1bc372184d"
,
"0UZAb4D4uVKUPf+seuc/Fg=="
));
}
@Test
public
void
testDateTimeUtil
()
{
long
hours
=
DateTimeUtil
.
getHoursFromCurrentDayStartTime
(
new
Date
(
System
.
currentTimeMillis
()));
System
.
out
.
println
(
hours
);
System
.
out
.
println
(
DateUtils
.
dateToString
(
new
Date
(
System
.
currentTimeMillis
()),
"HH:mm"
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment