Commit 88ca41bf authored by suntao's avatar suntao

异步操作 使用cglib 代理

parent 0c27a4d3
......@@ -15,7 +15,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@EnableAutoConfiguration
@EnableFeignClients
@EnableAsync
@EnableAsync(proxyTargetClass = true)
public class Bootstrap {
public static void main(String[] args) {
......
......@@ -4,6 +4,7 @@ import cn.quantgroup.cashloanflowboss.api.login.model.Principal;
import cn.quantgroup.cashloanflowboss.api.user.dictionary.UserStatus;
import cn.quantgroup.cashloanflowboss.api.user.entity.User;
import cn.quantgroup.cashloanflowboss.api.user.model.UserInfo;
import cn.quantgroup.cashloanflowboss.api.user.service.UserService;
import cn.quantgroup.cashloanflowboss.api.user.service.UserServiceImpl;
import cn.quantgroup.cashloanflowboss.core.asserts.Assert;
import cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationDictionary;
......@@ -28,7 +29,7 @@ import java.util.concurrent.ConcurrentHashMap;
public class LoginServiceImpl implements LoginService {
@Autowired
private UserServiceImpl userService;
private UserService userService;
@Autowired
private HttpServletRequest request;
......
......@@ -107,6 +107,7 @@ public class OrderServiceImpl implements OrderService{
private static final String auth = "dXNlcj14dWV6aiZwYXNzd29yZD0xMjMxMjNxd2Vxd2U%3D";
private static final int CONSCONT_STATUS = 2;
@Override
......@@ -316,7 +317,7 @@ public class OrderServiceImpl implements OrderService{
// 更新合同状态
Contract conscont= xyqbCenterService.findContractByUserId(orderMapping.getQgUserId());
if (conscont != null) {
if (conscont.getGenerateStatus() != 2) {
if (conscont.getGenerateStatus() != CONSCONT_STATUS) {
log.info("secondAudit,合同状态不对,channelOrderNumber=".concat(channelOrderNumber));
// 修改合同状态
ArrayList<String> updateContract = Lists.newArrayList();
......
......@@ -130,8 +130,8 @@ public class UserController {
@PutMapping("/order/clean")
@Security(authorityId = "User.Order.cleanUserOrder")
public Result<Boolean> cleanUserOrder(@RequestParam @Valid @NotEmpty(message = "无效的用户手机号") String mobile) {
Tuple<Boolean, String> result = userService.cleanUserActiveOrder(mobile);
return Result.buildSuccess(result.getKey(), result.getValue());
userService.cleanUserActiveOrder(mobile);
return Result.buildSuccess(true, "异步请求成功");
}
/**
......@@ -143,8 +143,8 @@ public class UserController {
@PutMapping("/info/clean")
@Security(authorityId = "User.Order.cleanUserInfo")
public Boolean deleteByUserId(@RequestParam @Valid @NotEmpty(message = "无效的用户手机号") String mobile) {
Tuple<Boolean, String> result = this.xyqbUserService.deleteByUserId(mobile);
return result.getKey();
this.xyqbUserService.deleteByUserId(mobile);
return true;
}
}
package cn.quantgroup.cashloanflowboss.api.user.service;
import cn.quantgroup.cashloanflowboss.api.login.model.Principal;
import cn.quantgroup.cashloanflowboss.api.optlog.model.OptEnumName;
import cn.quantgroup.cashloanflowboss.api.user.dictionary.UserStatus;
import cn.quantgroup.cashloanflowboss.api.user.entity.User;
import cn.quantgroup.cashloanflowboss.api.user.model.QueryUserListModel;
......@@ -9,7 +8,6 @@ import cn.quantgroup.cashloanflowboss.api.user.model.UserDetailInfo;
import cn.quantgroup.cashloanflowboss.api.user.model.UserInfoModel;
import cn.quantgroup.cashloanflowboss.api.user.repository.UserRepository;
import cn.quantgroup.cashloanflowboss.core.Application;
import cn.quantgroup.cashloanflowboss.core.annotation.opt.OperationAnno;
import cn.quantgroup.cashloanflowboss.core.asserts.Assert;
import cn.quantgroup.cashloanflowboss.core.base.Tuple;
import cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationStatus;
......@@ -23,6 +21,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.persistence.criteria.Predicate;
......@@ -191,7 +190,8 @@ public class UserServiceImpl implements UserService{
return userRepository.save(user1);
}
@OperationAnno(channelNo = "#this[0]", opt = OptEnumName.USER_ORDER_CLEAN, succSPEL = "#this.key", optDetailSPEL = "#this.value")
@Async("commonAsyncExecutor")
//@OperationAnno(channelNo = "#this[0]", opt = OptEnumName.USER_ORDER_CLEAN, succSPEL = "#this.key", optDetailSPEL = "#this.value")
@Override
public Tuple<Boolean,String> cleanUserActiveOrder(String mobile) {
XUser user = xyqbUserService.findUserByPhoneNo(mobile);
......
package cn.quantgroup.cashloanflowboss.core.asyncer;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
import java.util.concurrent.Executor;
/**
* function:
* date: 2019/12/6
*
* @author: suntao
*/
@Component
public class MyAsyncExecutor {
@Bean(name = "commonAsyncExecutor")
public Executor commonAsyncExecutor() {
return generateThreadPoolTaskExecutor(10, 30, 100, true, 30, true, "commonAsyncExecutor-");
}
/**
* 生成线程池
* @param corePoolSize
* @param maxPoolSize
* @param queueCapacity
* @param waitForCompleteOnShutdown
* @param prefix
* @return
*/
private ThreadPoolTaskExecutor generateThreadPoolTaskExecutor(int corePoolSize, int maxPoolSize, int queueCapacity,
boolean waitForCompleteOnShutdown, int keepAliveSeconds,
boolean allowCoreThreadTimeOut, String prefix) {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(corePoolSize);
executor.setMaxPoolSize(maxPoolSize);
executor.setQueueCapacity(queueCapacity);
executor.setKeepAliveSeconds(keepAliveSeconds);
executor.setAllowCoreThreadTimeOut(allowCoreThreadTimeOut);
executor.setWaitForTasksToCompleteOnShutdown(waitForCompleteOnShutdown);
executor.setThreadNamePrefix(prefix);
executor.initialize();
return executor ;
}
}
......@@ -31,6 +31,7 @@ public class JolyneServiceImpl implements JolyneService {
@Override
public String executeSQL(JolyneDB jolyneDB, String jsonData) {
return jolyneCenter.executeSQL(jolyneDB.getDbName(), jsonData);
......@@ -42,7 +43,7 @@ public class JolyneServiceImpl implements JolyneService {
jolyneCenter.reloadJob(jobName);
}
@Async
@Async("commonAsyncExecutor")
@Override
public String delayUpdateWaitingXyqbSql(Long loanId, Long delayTime) {
......@@ -56,7 +57,7 @@ public class JolyneServiceImpl implements JolyneService {
try {
Thread.sleep(delayTime);
} catch (InterruptedException e) {
e.printStackTrace();
log.error("Thread.sleep error");
}
loanApplicationHistory = xyqbCenterService.findLoanApplicationHistoryById(loanId);
......@@ -80,7 +81,7 @@ public class JolyneServiceImpl implements JolyneService {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
log.error("Thread.sleep error");
}
reloadJob("cn.qg.clotho.job.FetchDataLoanJob");
......@@ -88,7 +89,7 @@ public class JolyneServiceImpl implements JolyneService {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
log.error("Thread.sleep error");
}
reloadJob("cn.qg.clotho.job.LoanDataJob");
......
......@@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.*;
......@@ -130,8 +131,10 @@ public class XyqbUserServiceImpl implements XyqbUserService {
}
@OperationAnno(channelNo = "#this[0]", opt = OptEnumName.USER_INFO_CLEAN, succSPEL = "#this.key", optDetailSPEL = "#this.value")
@Override public Tuple<Boolean,String> deleteByUserId(String phoneNo) {
//@OperationAnno(channelNo = "#this[0]", opt = OptEnumName.USER_INFO_CLEAN, succSPEL = "#this.key", optDetailSPEL = "#this.value")
@Async("commonAsyncExecutor")
@Override
public Tuple<Boolean,String> deleteByUserId(String phoneNo) {
try{
UserSysResult<XUser> xUser = userSysService.getService().findUserByPhoneNo(phoneNo);
if (xUser == null || xUser.getData() == null) {
......@@ -156,8 +159,8 @@ public class XyqbUserServiceImpl implements XyqbUserService {
if(userKeys!=null){
redisTemplate.delete(userKeys);
}
String token_key = "userid-sessionvalue:cache::"+userId+":xyqb";
String token = redisTemplate.opsForValue().get(token_key);
String tokenKey = "userid-sessionvalue:cache::"+userId+":xyqb";
String token = redisTemplate.opsForValue().get(tokenKey);
if(token!=null && redisTemplate.keys(token)!=null){
Set<String> tokenKeys = redisTemplate.keys(token);
redisTemplate.delete(tokenKeys);
......
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