Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
cd8313f9
Commit
cd8313f9
authored
Jul 17, 2020
by
董建华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
清洗数据
parent
b82e73e0
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
160 additions
and
13 deletions
+160
-13
InnerController.java
...tgroup/xyqb/controller/internal/user/InnerController.java
+11
-7
IUserExtInfoRepository.java
...cn/quantgroup/xyqb/repository/IUserExtInfoRepository.java
+8
-0
CleanDataService.java
...ava/cn/quantgroup/xyqb/service/user/CleanDataService.java
+7
-0
IUserExtInfoService.java
.../cn/quantgroup/xyqb/service/user/IUserExtInfoService.java
+4
-0
CleanDataServiceImp.java
...uantgroup/xyqb/service/user/impl/CleanDataServiceImp.java
+114
-0
UserExtInfoServiceImpl.java
...tgroup/xyqb/service/user/impl/UserExtInfoServiceImpl.java
+10
-1
logback-dev.xml
src/main/resources/logback-dev.xml
+6
-5
No files found.
src/main/java/cn/quantgroup/xyqb/controller/internal/user/InnerController.java
View file @
cd8313f9
...
@@ -47,13 +47,7 @@ import cn.quantgroup.xyqb.service.merchant.IMerchantService;
...
@@ -47,13 +47,7 @@ import cn.quantgroup.xyqb.service.merchant.IMerchantService;
import
cn.quantgroup.xyqb.service.register.IUserRegisterService
;
import
cn.quantgroup.xyqb.service.register.IUserRegisterService
;
import
cn.quantgroup.xyqb.service.session.ISessionService
;
import
cn.quantgroup.xyqb.service.session.ISessionService
;
import
cn.quantgroup.xyqb.service.sms.ISmsService
;
import
cn.quantgroup.xyqb.service.sms.ISmsService
;
import
cn.quantgroup.xyqb.service.user.IAddressService
;
import
cn.quantgroup.xyqb.service.user.*
;
import
cn.quantgroup.xyqb.service.user.IContactService
;
import
cn.quantgroup.xyqb.service.user.IUserBtRegisterService
;
import
cn.quantgroup.xyqb.service.user.IUserDetailService
;
import
cn.quantgroup.xyqb.service.user.IUserExtInfoService
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.service.user.IUserSpouseService
;
import
cn.quantgroup.xyqb.service.user.vo.UserDetailVO
;
import
cn.quantgroup.xyqb.service.user.vo.UserDetailVO
;
import
cn.quantgroup.xyqb.service.wechat.IWechatService
;
import
cn.quantgroup.xyqb.service.wechat.IWechatService
;
import
cn.quantgroup.xyqb.util.AesUtil
;
import
cn.quantgroup.xyqb.util.AesUtil
;
...
@@ -137,6 +131,8 @@ public class InnerController implements IBaseController {
...
@@ -137,6 +131,8 @@ public class InnerController implements IBaseController {
private
IUserRegisterService
userRegisterService
;
private
IUserRegisterService
userRegisterService
;
@Resource
@Resource
private
ApplicationEventPublisher
applicationEventPublisher
;
private
ApplicationEventPublisher
applicationEventPublisher
;
@Resource
private
CleanDataService
cleanDataService
;
private
static
final
String
RESET_PWD_TOKEN
=
"ecf75c1f-2ccb-4661-8e4b-2874c0f45a2b"
;
private
static
final
String
RESET_PWD_TOKEN
=
"ecf75c1f-2ccb-4661-8e4b-2874c0f45a2b"
;
private
static
final
String
MODIFY_CONTACT_TOKEN
=
"@qwsdedad131323213w!"
;
private
static
final
String
MODIFY_CONTACT_TOKEN
=
"@qwsdedad131323213w!"
;
...
@@ -601,6 +597,9 @@ public class InnerController implements IBaseController {
...
@@ -601,6 +597,9 @@ public class InnerController implements IBaseController {
info
.
setIncomeRangeEnum
(
cn
.
quantgroup
.
user
.
enums
.
IncomeRangeEnum
.
valueOf
(
incomeRangeEnum
.
name
()));
info
.
setIncomeRangeEnum
(
cn
.
quantgroup
.
user
.
enums
.
IncomeRangeEnum
.
valueOf
(
incomeRangeEnum
.
name
()));
}
}
if
(
occupationEnum
!=
null
)
{
if
(
occupationEnum
!=
null
)
{
if
(
occupationEnum
==
OccupationEnum
.
STUDENT
)
{
//如果是学生那么转成其他
occupationEnum
=
OccupationEnum
.
OTHER
;
}
info
.
setOccupationEnum
(
cn
.
quantgroup
.
user
.
enums
.
OccupationEnum
.
valueOf
(
occupationEnum
.
name
()));
info
.
setOccupationEnum
(
cn
.
quantgroup
.
user
.
enums
.
OccupationEnum
.
valueOf
(
occupationEnum
.
name
()));
}
}
if
(
educationEnum
!=
null
)
{
if
(
educationEnum
!=
null
)
{
...
@@ -1502,4 +1501,9 @@ public class InnerController implements IBaseController {
...
@@ -1502,4 +1501,9 @@ public class InnerController implements IBaseController {
return
JsonResult
.
buildSuccessResult
(
"用户禁用微信成功"
,
affectedRows
);
return
JsonResult
.
buildSuccessResult
(
"用户禁用微信成功"
,
affectedRows
);
}
}
@RequestMapping
(
"/clean"
)
public
JsonResult
clean
(){
cleanDataService
.
cleanData
();
return
JsonResult
.
buildSuccessResult
(
"已经开始清洗"
);
}
}
}
\ No newline at end of file
src/main/java/cn/quantgroup/xyqb/repository/IUserExtInfoRepository.java
View file @
cd8313f9
package
cn
.
quantgroup
.
xyqb
.
repository
;
package
cn
.
quantgroup
.
xyqb
.
repository
;
import
cn.quantgroup.user.enums.OccupationEnum
;
import
cn.quantgroup.xyqb.entity.UserExtInfo
;
import
cn.quantgroup.xyqb.entity.UserExtInfo
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.sql.Timestamp
;
import
java.util.List
;
import
static
cn
.
quantgroup
.
user
.
enums
.
OccupationEnum
.
STUDENT
;
/**
/**
* Created by 11 on 2016/12/30.
* Created by 11 on 2016/12/30.
*/
*/
public
interface
IUserExtInfoRepository
extends
JpaRepository
<
UserExtInfo
,
Long
>
{
public
interface
IUserExtInfoRepository
extends
JpaRepository
<
UserExtInfo
,
Long
>
{
UserExtInfo
findByUserId
(
Long
userId
);
UserExtInfo
findByUserId
(
Long
userId
);
List
<
UserExtInfo
>
findByCreatedAtAfterAndCreatedAtBeforeAndOccupationEnum
(
Timestamp
start
,
Timestamp
end
,
OccupationEnum
student
);
}
}
src/main/java/cn/quantgroup/xyqb/service/user/CleanDataService.java
0 → 100644
View file @
cd8313f9
package
cn
.
quantgroup
.
xyqb
.
service
.
user
;
import
java.util.Map
;
public
interface
CleanDataService
{
Map
<
String
,
Object
>
cleanData
();
}
src/main/java/cn/quantgroup/xyqb/service/user/IUserExtInfoService.java
View file @
cd8313f9
...
@@ -2,6 +2,8 @@ package cn.quantgroup.xyqb.service.user;
...
@@ -2,6 +2,8 @@ package cn.quantgroup.xyqb.service.user;
import
cn.quantgroup.xyqb.entity.UserExtInfo
;
import
cn.quantgroup.xyqb.entity.UserExtInfo
;
import
java.util.Map
;
/**
/**
* Created by Miraculous on 2017/1/3.
* Created by Miraculous on 2017/1/3.
*/
*/
...
@@ -10,4 +12,6 @@ public interface IUserExtInfoService {
...
@@ -10,4 +12,6 @@ public interface IUserExtInfoService {
UserExtInfo
findByUserId
(
Long
userId
);
UserExtInfo
findByUserId
(
Long
userId
);
UserExtInfo
save
(
UserExtInfo
info
);
UserExtInfo
save
(
UserExtInfo
info
);
}
}
src/main/java/cn/quantgroup/xyqb/service/user/impl/CleanDataServiceImp.java
0 → 100644
View file @
cd8313f9
package
cn
.
quantgroup
.
xyqb
.
service
.
user
.
impl
;
import
cn.quantgroup.user.enums.OccupationEnum
;
import
cn.quantgroup.xyqb.entity.UserExtInfo
;
import
cn.quantgroup.xyqb.repository.IUserExtInfoRepository
;
import
cn.quantgroup.xyqb.service.user.CleanDataService
;
import
cn.quantgroup.xyqb.service.user.IUserExtInfoService
;
import
com.google.common.base.Stopwatch
;
import
com.google.common.collect.Maps
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.sql.Timestamp
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
/**
* @author :dongjianhua
* @date :Created in 2020/7/17 11:32
* @description:清洗数据
* @modified By:
* @version: 1.0
*/
@Slf4j
@Service
public
class
CleanDataServiceImp
implements
CleanDataService
{
@Resource
private
IUserExtInfoService
iUserExtInfoService
;
@Autowired
private
IUserExtInfoRepository
userExtInfoRepository
;
@Autowired
@Qualifier
(
"stringRedisTemplate"
)
private
RedisTemplate
<
String
,
String
>
stringRedisTemplate
;
public
final
String
LOCKKEY
=
"681F0307-C7F9-11EA-A303-0A58AC100553"
;
@Async
@Override
public
Map
<
String
,
Object
>
cleanData
()
{
Map
<
String
,
Object
>
re
=
Maps
.
newHashMap
();
Boolean
lock
=
stringRedisTemplate
.
opsForValue
().
setIfAbsent
(
LOCKKEY
,
"lock"
);
try
{
if
(!
lock
)
{
return
re
;
}
SimpleDateFormat
sf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
Stopwatch
s
=
Stopwatch
.
createStarted
();
Date
parse
=
null
;
try
{
parse
=
sf
.
parse
(
"2015-08-14 00:00:00"
);
// parse = sf.parse("2020-01-01 00:00:00");
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
parse
);
long
all
=
0L
;
while
(
true
)
{
Timestamp
start
=
new
Timestamp
(
calendar
.
getTime
().
getTime
());
calendar
.
add
(
Calendar
.
MONTH
,
1
);
Timestamp
end
=
new
Timestamp
(
calendar
.
getTime
().
getTime
());
List
<
UserExtInfo
>
list
=
userExtInfoRepository
.
findByCreatedAtAfterAndCreatedAtBeforeAndOccupationEnum
(
start
,
end
,
OccupationEnum
.
STUDENT
);
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
for
(
UserExtInfo
userExtInfo
:
list
)
{
try
{
userExtInfo
.
setOccupationEnum
(
OccupationEnum
.
OTHER
);
iUserExtInfoService
.
save
(
userExtInfo
);
all
++;
}
catch
(
Exception
e
)
{
log
.
error
(
"保存异常o:{} "
,
userExtInfo
);
}
}
}
String
starDate
=
(
start
.
getYear
()
+
1900
)
+
"年"
+
(
start
.
getMonth
()
+
1
)
+
"月"
+
start
.
getDate
()
+
"日"
;
String
endDate
=
(
end
.
getYear
()
+
1900
)
+
"年"
+
(
end
.
getMonth
()
+
1
)
+
"月"
+
end
.
getDate
()
+
"日"
;
log
.
info
(
"开始时间start:{},结束时间end: {} ,条数:{}"
,
starDate
,
endDate
,
list
.
size
());
re
.
put
(
starDate
+
"-"
+
endDate
,
list
.
size
());
if
(
end
.
after
(
new
Date
()))
{
break
;
}
}
log
.
info
(
"清洗结束总共清洗了all:{}条,耗时:{}秒"
,
all
,
s
.
elapsed
(
TimeUnit
.
SECONDS
));
log
.
info
(
"清洗明细:{} "
,
re
);
}
catch
(
Exception
e
)
{
}
finally
{
stringRedisTemplate
.
delete
(
LOCKKEY
);
}
return
null
;
}
}
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserExtInfoServiceImpl.java
View file @
cd8313f9
package
cn
.
quantgroup
.
xyqb
.
service
.
user
.
impl
;
package
cn
.
quantgroup
.
xyqb
.
service
.
user
.
impl
;
import
cn.quantgroup.user.enums.OccupationEnum
;
import
cn.quantgroup.xyqb.entity.UserExtInfo
;
import
cn.quantgroup.xyqb.entity.UserExtInfo
;
import
cn.quantgroup.xyqb.repository.IUserExtInfoRepository
;
import
cn.quantgroup.xyqb.repository.IUserExtInfoRepository
;
import
cn.quantgroup.xyqb.service.user.IUserExtInfoService
;
import
cn.quantgroup.xyqb.service.user.IUserExtInfoService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* Created by Miraculous on 2017/1/3.
* Created by Miraculous on 2017/1/3.
*/
*/
@Slf4j
@Service
@Service
public
class
UserExtInfoServiceImpl
implements
IUserExtInfoService
{
public
class
UserExtInfoServiceImpl
implements
IUserExtInfoService
{
...
@@ -32,5 +42,4 @@ public class UserExtInfoServiceImpl implements IUserExtInfoService {
...
@@ -32,5 +42,4 @@ public class UserExtInfoServiceImpl implements IUserExtInfoService {
public
UserExtInfo
save
(
UserExtInfo
info
)
{
public
UserExtInfo
save
(
UserExtInfo
info
)
{
return
userExtInfoRepository
.
save
(
info
);
return
userExtInfoRepository
.
save
(
info
);
}
}
}
}
src/main/resources/logback-dev.xml
View file @
cd8313f9
...
@@ -10,14 +10,15 @@
...
@@ -10,14 +10,15 @@
<logger
name=
"cn.quantgroup"
level=
"DEBUG"
/>
<logger
name=
"cn.quantgroup"
level=
"DEBUG"
/>
<logger
name=
"org.springframework"
level=
"INFO"
/>
<logger
name=
"org.springframework"
level=
"INFO"
/>
<!--<logger name="java.sql.Connection" level="DEBUG"/>-->
<logger
name=
"java.sql.Connection"
level=
"DEBUG"
/>
<!--<logger name="java.sql.Statement" level="DEBUG"/>-->
<logger
name=
"java.sql.Statement"
level=
"DEBUG"
/>
<!--<logger name="java.sql.PreparedStatement" level="DEBUG"/>-->
<logger
name=
"java.sql.PreparedStatement"
level=
"DEBUG"
/>
<logger
name=
"org.hibernate"
level=
"warn"
/>
<logger
name=
"org.hibernate"
level=
"DEBUG"
/>
<!--<logger name="org.hibernate" level="warn"/>-->
<logger
name=
"org.apache"
level=
"warn"
/>
<logger
name=
"org.apache"
level=
"warn"
/>
<logger
name=
"ch.qos.logback"
level=
"warn"
/>
<logger
name=
"ch.qos.logback"
level=
"warn"
/>
<root
level=
"
INFO
"
>
<root
level=
"
DEBUG
"
>
<appender-ref
ref=
"CONSOLE"
/>
<appender-ref
ref=
"CONSOLE"
/>
</root>
</root>
...
...
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