Commit bad14c05 authored by Nguyen Ha's avatar Nguyen Ha

edit filter

parent 9d63d53e
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
......
......@@ -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
}
});
}
......
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());
......
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