Commit c219238a by kangxiaoshan

跑流量

parent 73730be0
...@@ -9,7 +9,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -9,7 +9,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
public interface TkioFlowRepository extends JpaRepository<TkioFlow, Long> { public interface TkioFlowRepository extends JpaRepository<TkioFlow, Long> {
@Query(value = "select sum(flow) from tkio_flow where email = ?1 and contract_code = ?2", nativeQuery = true) @Query(value = "select sum(flow) from tkio_flow where email = ?1 and contract_code = ?2", nativeQuery = true)
BigDecimal sumFlowByEmailAndContractCode(String email, String contractCode); BigDecimal sumFlowByEmailAndContractCode(String email, String contractCode);
...@@ -24,4 +24,9 @@ public interface TkioFlowRepository extends JpaRepository<TkioFlow, Long> { ...@@ -24,4 +24,9 @@ public interface TkioFlowRepository extends JpaRepository<TkioFlow, Long> {
@Query(value = "select sum(flow) from tkio_flow where contract_code in ?3 and ds >= ?1 and ds <= ?2", nativeQuery = true) @Query(value = "select sum(flow) from tkio_flow where contract_code in ?3 and ds >= ?1 and ds <= ?2", nativeQuery = true)
BigDecimal sumFlowByDsAndContractCodes(String startDate, String endDate, ArrayList<String> contractCode); BigDecimal sumFlowByDsAndContractCodes(String startDate, String endDate, ArrayList<String> contractCode);
@Transactional
@Modifying
@Query(value = "delete from tkio_flow where email = ?1 and ds = ?2", nativeQuery = true)
void deleteByEmailDs(String email, String yesterday);
} }
...@@ -27,7 +27,6 @@ import javax.servlet.http.HttpServletRequest; ...@@ -27,7 +27,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.util.Enumeration;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -61,8 +60,8 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { ...@@ -61,8 +60,8 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
//放开登录 //放开登录
String requestURL = request.getRequestURL().toString(); String requestURL = request.getRequestURL().toString();
if(requestURL.contains("findSaleInfo")){ if (requestURL.contains("findSaleInfo")) {
System.out.println("-----"+requestURL.contains("findSaleInfo")); System.out.println("-----" + requestURL.contains("findSaleInfo"));
return true; return true;
} }
// System.out.println("============="+requestURL); // System.out.println("============="+requestURL);
...@@ -72,15 +71,16 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { ...@@ -72,15 +71,16 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
|| requestURL.indexOf("user/forget") != -1 || requestURL.indexOf("user/forget") != -1
|| requestURL.indexOf("user/code") != -1 || requestURL.indexOf("user/code") != -1
|| requestURL.indexOf("txt2db") != -1 || requestURL.indexOf("txt2db") != -1
|| requestURL.indexOf("/test/contract/flow") != -1
|| requestURL.indexOf("contract/build") != -1 || requestURL.indexOf("contract/build") != -1
|| requestURL.indexOf("accountmng/findSaleInfo") != -1){ || requestURL.indexOf("accountmng/findSaleInfo") != -1) {
return true; return true;
} }
//从header中得到token //从header中得到token
String token = request.getHeader(httpHeaderName); String token = request.getHeader(httpHeaderName);
//token = StringUtil.isEmpty(token) ? getCookieToken(request.getCookies(), "TOKEN") : token; //token = StringUtil.isEmpty(token) ? getCookieToken(request.getCookies(), "TOKEN") : token;
if(null != token){ if (null != token) {
token = token.substring(httpHeaderPrefix.length()); token = token.substring(httpHeaderPrefix.length());
//验证token //验证token
String key = manager.getKeyFromToken(token); String key = manager.getKeyFromToken(token);
...@@ -101,15 +101,15 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { ...@@ -101,15 +101,15 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
one.setAuthdataDic(authdata); one.setAuthdataDic(authdata);
} }
request.getSession().setAttribute(Constant.CURRENT_ACCOUNT,one); request.getSession().setAttribute(Constant.CURRENT_ACCOUNT, one);
sessionAct = one; sessionAct = one;
} }
if(!sessionAct.getRole().equals(RoleEnum.MANAGER.getKey())){ if (!sessionAct.getRole().equals(RoleEnum.MANAGER.getKey())) {
//权限控制 //权限控制
AuthKey authKey = handler.getClass().getAnnotation(AuthKey.class); AuthKey authKey = handler.getClass().getAnnotation(AuthKey.class);
if(authKey!=null && sessionAct.getAuthdataDic().get(authKey.value().getIdKey())==null){ if (authKey != null && sessionAct.getAuthdataDic().get(authKey.value().getIdKey()) == null) {
printJsonResponse(response,"权限不足!"); printJsonResponse(response, "权限不足!");
return false; return false;
} }
...@@ -121,31 +121,31 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { ...@@ -121,31 +121,31 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
} }
printJsonResponse(response,null); printJsonResponse(response, null);
return false; return false;
} }
private void printJsonResponse(HttpServletResponse response,String message){ private void printJsonResponse(HttpServletResponse response, String message) {
try { try {
//如果验证token失败,并且方法注明了Authorization,返回401错误 //如果验证token失败,并且方法注明了Authorization,返回401错误
response.setStatus(HttpStatus.UNAUTHORIZED.value()); response.setStatus(HttpStatus.UNAUTHORIZED.value());
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(response.getOutputStream())); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(response.getOutputStream()));
response.setContentType(MediaType.APPLICATION_JSON_VALUE); response.setContentType(MediaType.APPLICATION_JSON_VALUE);
if(StringUtils.isEmpty(message)){ if (StringUtils.isEmpty(message)) {
message = new ObjectMapper().writeValueAsString(ResultModel.ERROR(ResultStatus.USERNAME_LOGIN_EXPIRE)); message = new ObjectMapper().writeValueAsString(ResultModel.ERROR(ResultStatus.USERNAME_LOGIN_EXPIRE));
} }
writer.write(message); writer.write(message);
writer.close(); writer.close();
} catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
private String getCookieToken(Cookie[] cookies, String name){ private String getCookieToken(Cookie[] cookies, String name) {
String token = null; String token = null;
......
package track.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import track.task.TrackingFlowTask;
@RestController
public class TestFlowController {
@Autowired
TrackingFlowTask trackingFlowTask;
@GetMapping("/test/contract/flow")
public void testFlow(String email) {
trackingFlowTask.reset(email);
}
}
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