Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
service-campaign
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nguyen Ha
service-campaign
Commits
bad14c05
Commit
bad14c05
authored
Aug 26, 2019
by
Nguyen Ha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edit filter
parent
9d63d53e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
85 deletions
+88
-85
src/main/java/com/viettel/campaign/filter/CorsFilter.java
src/main/java/com/viettel/campaign/filter/CorsFilter.java
+23
-21
src/main/java/com/viettel/campaign/job/CampaignJob.java
src/main/java/com/viettel/campaign/job/CampaignJob.java
+63
-63
src/main/java/com/viettel/campaign/utils/Config.java
src/main/java/com/viettel/campaign/utils/Config.java
+2
-1
No files found.
src/main/java/com/viettel/campaign/filter/CorsFilter.java
View file @
bad14c05
package
com.viettel.campaign.filter
;
import
com.viettel.campaign.utils.RedisUtil
;
import
com.viettel.econtact.filter.UserSession
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.*
;
...
...
@@ -28,27 +30,27 @@ public class CorsFilter implements Filter {
HttpServletRequest
request
=
(
HttpServletRequest
)
req
;
chain
.
doFilter
(
req
,
response
);
//
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
//
chain.doFilter(req, resp);
//
return;
//
}
//
if ("/".equals(request.getRequestURI())) {
//
chain.doFilter(req, resp);
//
return;
//
}
//
String xAuthToken = request.getHeader("X-Auth-Token");
//
if (xAuthToken == null || "".equals(xAuthToken)) {
//
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The token is null.");
//
return;
//
}
//
Object obj = RedisUtil.getInstance().get(xAuthToken);
//
if (obj instanceof UserSession) {
//
chain.doFilter(req, resp);
//
} else {
//
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The token is invalid.");
//
}
//
chain.doFilter(req, response);
if
(
"OPTIONS"
.
equalsIgnoreCase
(
request
.
getMethod
()))
{
chain
.
doFilter
(
req
,
resp
);
return
;
}
if
(
"/"
.
equals
(
request
.
getRequestURI
()))
{
chain
.
doFilter
(
req
,
resp
);
return
;
}
String
xAuthToken
=
request
.
getHeader
(
"X-Auth-Token"
);
if
(
xAuthToken
==
null
||
""
.
equals
(
xAuthToken
))
{
response
.
sendError
(
HttpServletResponse
.
SC_UNAUTHORIZED
,
"The token is null."
);
return
;
}
Object
obj
=
RedisUtil
.
getInstance
().
get
(
xAuthToken
);
if
(
obj
instanceof
UserSession
)
{
chain
.
doFilter
(
req
,
resp
);
}
else
{
response
.
sendError
(
HttpServletResponse
.
SC_UNAUTHORIZED
,
"The token is invalid."
);
}
}
@Override
...
...
src/main/java/com/viettel/campaign/job/CampaignJob.java
View file @
bad14c05
...
...
@@ -42,69 +42,69 @@ public class CampaignJob {
// @Scheduled(fixedRate = 5000)
// @Transactional( propagation = Propagation.REQUIRED)
public
void
process
()
{
//
log.info(Thread.currentThread().getName() + " The Task executed at " + dateFormat.format(new Date()));
//
List<ProcessConfig> list = processConfigService.findAll();
//
//
list.parallelStream().forEach(p -> {
//
boolean isExecute = DateTimeUtil.isRun(p.getConfigValue(), p.getLastProcess());
//
switch (p.getConfigCode()){
//
case CUSTOMER_INACTIVE_DUARATION:
//
if(isExecute){
//
List<Customer> customers = customerService.findAllByCondition(p.getSiteId(), new Date());
//
updateCustomer(customers);
//
updateCustomerTime(customers);
//
log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
//
p.setLastProcess(new Date());
//
processConfigService.update(p);
//
}
//
break;
//
case CRON_EXPRESSION_CHECK_START:
//
// process
//
if(isExecute){
//
List<Long> status = new ArrayList<>();
//
status.add(1L);
//
status.add(1L);
//
List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndStartTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
//
campaigns.parallelStream().forEach(campaign -> {
//
log.info("Chuyen trang thai chien dich ... #{} ... tu Du thao sang Trien khai", campaign.getCampaignId());
//
campaign.setProcessStatus(1);
//
campaign.setStatus(2L);
//
campaign.setCampaignStart(new Date());
//
campaignService.updateProcess(campaign);
//
//write log
//
saveLog(campaign, 1);
//
});
//
//
log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
//
p.setLastProcess(new Date());
//
processConfigService.update(p);
//
}
//
break;
//
case CRON_EXPRESSION_CHECK_END:
//
// process
//
if(isExecute){
//
List<Long> status = new ArrayList<>();
//
status.add(2L);
//
status.add(3L);
//
List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
//
campaigns.parallelStream().forEach(campaign -> {
//
log.info("Chuyen trang thai chien dich ... #{} ... sang Ket thuc", campaign.getCampaignId());
//
campaign.setStatus(4L);
//
campaign.setCampaignEnd(new Date());
//
campaignService.updateProcess(campaign);
//
//write log
//
saveLog(campaign, 2);
//
});
//
//
log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
//
p.setLastProcess(new Date());
//
processConfigService.update(p);
//
}
//
break;
//
default:
//
// update last check time
//
}
//
});
log
.
info
(
Thread
.
currentThread
().
getName
()
+
" The Task executed at "
+
dateFormat
.
format
(
new
Date
()));
List
<
ProcessConfig
>
list
=
processConfigService
.
findAll
();
list
.
parallelStream
().
forEach
(
p
->
{
boolean
isExecute
=
DateTimeUtil
.
isRun
(
p
.
getConfigValue
(),
p
.
getLastProcess
());
switch
(
p
.
getConfigCode
()){
case
CUSTOMER_INACTIVE_DUARATION:
if
(
isExecute
){
List
<
Customer
>
customers
=
customerService
.
findAllByCondition
(
p
.
getSiteId
(),
new
Date
());
updateCustomer
(
customers
);
updateCustomerTime
(
customers
);
log
.
info
(
"Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}"
,
p
.
getSiteId
());
p
.
setLastProcess
(
new
Date
());
processConfigService
.
update
(
p
);
}
break
;
case
CRON_EXPRESSION_CHECK_START:
// process
if
(
isExecute
){
List
<
Long
>
status
=
new
ArrayList
<>();
status
.
add
(
1L
);
status
.
add
(
1L
);
List
<
Campaign
>
campaigns
=
campaignService
.
findCampaignByCompanySiteIdAndStartTimeIsLessThanEqualAndStatusIn
(
p
.
getSiteId
(),
new
Date
(),
status
);
campaigns
.
parallelStream
().
forEach
(
campaign
->
{
log
.
info
(
"Chuyen trang thai chien dich ... #{} ... tu Du thao sang Trien khai"
,
campaign
.
getCampaignId
());
campaign
.
setProcessStatus
(
1
);
campaign
.
setStatus
(
2L
);
campaign
.
setCampaignStart
(
new
Date
());
campaignService
.
updateProcess
(
campaign
);
//write log
saveLog
(
campaign
,
1
);
});
log
.
info
(
"Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}"
,
p
.
getSiteId
());
p
.
setLastProcess
(
new
Date
());
processConfigService
.
update
(
p
);
}
break
;
case
CRON_EXPRESSION_CHECK_END:
// process
if
(
isExecute
){
List
<
Long
>
status
=
new
ArrayList
<>();
status
.
add
(
2L
);
status
.
add
(
3L
);
List
<
Campaign
>
campaigns
=
campaignService
.
findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn
(
p
.
getSiteId
(),
new
Date
(),
status
);
campaigns
.
parallelStream
().
forEach
(
campaign
->
{
log
.
info
(
"Chuyen trang thai chien dich ... #{} ... sang Ket thuc"
,
campaign
.
getCampaignId
());
campaign
.
setStatus
(
4L
);
campaign
.
setCampaignEnd
(
new
Date
());
campaignService
.
updateProcess
(
campaign
);
//write log
saveLog
(
campaign
,
2
);
});
log
.
info
(
"Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}"
,
p
.
getSiteId
());
p
.
setLastProcess
(
new
Date
());
processConfigService
.
update
(
p
);
}
break
;
default
:
// update last check time
}
});
}
...
...
src/main/java/com/viettel/campaign/utils/Config.java
View file @
bad14c05
package
com.viettel.campaign.utils
;
import
com.viettel.security.PassTranformer
;
import
org.apache.log4j.Logger
;
import
java.io.File
;
...
...
@@ -60,7 +61,7 @@ public class Config {
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
Config
.
class
.
getName
()).
error
(
ex
.
getMessage
(),
ex
);
}
//
PassTranformer.setInputKey("Ipcc#987654321#@!");
PassTranformer
.
setInputKey
(
"Ipcc#987654321#@!"
);
// rabbitConnection = properties.getProperty("rabbit_connection_string");
// fbGatewayUser = PassTranformer.decrypt(properties.getProperty("rabbit_user", "").trim());
...
...
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