Commit 9b6c3def by guojuxing

解除联合定时器修复

parent f9ba3865
......@@ -153,7 +153,7 @@ public interface UnionEnterpriseAuthApiService {
ServiceResponse<String> deleteUnionEnterpriseAuthAppByUnionEnterpriseAuthId(@NotNull Integer unionEnterpriseAuthId);
/**
* 到期发送解除联合通知
* 到期发送解除联合通知 定时器名:联合商户解除通知
* @param param
* @return
*/
......
......@@ -10,6 +10,7 @@ import javax.validation.constraints.NotNull;
import com.alibaba.fastjson.JSON;
import com.gic.enterprise.constant.union.UnionEnterpriseAuthResTypeEnum;
import com.gic.enterprise.utils.ExecutorPoolSingleton;
import com.gic.marketing.process.api.service.sms.SmsSendApiService;
import com.gic.member.config.api.service.AuthorizationEnterConfApiService;
import org.apache.commons.collections.CollectionUtils;
......@@ -140,11 +141,12 @@ public class UnionEnterpriseAuthApiServiceImpl implements UnionEnterpriseAuthApi
resourceGroupApiService.syncResourceAuthChangeMQ(dto.getOwnEnterpriseId(), dto.getUnionEnterpriseId(), resourceGroupDTO, oldResourceGroupDTO, resourceGroupChangeType);
//门店通知
if (resourceGroupDTO.getStoreResource() != null) {
try {
storeAuthorizationApiService.authStore(resourceGroupDTO.getStoreResource().intValue(), dto.getUnionEnterpriseId(), dto.getOwnEnterpriseId());
} catch (Exception e) {
LOGGER.warn("调用门店授权接口错误:{}", e.getMessage(), e);
}
ExecutorPoolSingleton.getInstance().executeTask(new Runnable() {
@Override
public void run() {
storeAuthorizationApiService.authStore(resourceGroupDTO.getStoreResource().intValue(), dto.getUnionEnterpriseId(), dto.getOwnEnterpriseId());
}
});
}
return ServiceResponse.success();
......@@ -416,9 +418,9 @@ public class UnionEnterpriseAuthApiServiceImpl implements UnionEnterpriseAuthApi
int days = differentDaysByMillisecond(calendar.getTime(), new Date());
if (days == 0) {
smsArr = new String[] { enterpriseMap.get(temp.getUnionEnterpriseId()),
enterpriseMap.get(temp.getOwnEnterpriseId()),
enterpriseMap.get(temp.getOwnEnterpriseId())};
smsArr = new String[] { enterpriseMap.get(temp.getUnionEnterpriseId().toString()),
enterpriseMap.get(temp.getOwnEnterpriseId().toString()),
enterpriseMap.get(temp.getOwnEnterpriseId().toString())};
if (UnionEnterpriseAuthStatusEnum.TO_DO_RELIEVE.getCode().equals(temp.getStatusFlag())) {
//todo 发通知
......@@ -429,11 +431,11 @@ public class UnionEnterpriseAuthApiServiceImpl implements UnionEnterpriseAuthApi
} else {
//发送短信模板
smsArr = new String[] { enterpriseMap.get(temp.getUnionEnterpriseId()),
enterpriseMap.get(temp.getOwnEnterpriseId()),
smsArr = new String[] { enterpriseMap.get(temp.getUnionEnterpriseId().toString()),
enterpriseMap.get(temp.getOwnEnterpriseId().toString()),
String.valueOf(days),
sdf.format(calendar.getTime()),
enterpriseMap.get(temp.getOwnEnterpriseId())};
enterpriseMap.get(temp.getOwnEnterpriseId().toString())};
}
ServiceResponse<UserDTO> userResponse = userApiService.getUserByEnterpriseId(temp.getUnionEnterpriseId());
......
package com.gic.enterprise.utils;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import javax.inject.Singleton;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* 线程池单例类
* 用于导出数据异步使用
* @ClassName: ExecutorPoolSingleton

* @Description: 

* @author guojuxing

* @date 2019/11/5 7:56 PM

*/
public class ExecutorPoolSingleton {
private Logger logger = LogManager.getLogger(ExecutorPoolSingleton.class);
private static final int availableProcessor = Runtime.getRuntime().availableProcessors();
private static ExecutorService executorService;
private ExecutorPoolSingleton() {
if (executorService == null) {
int coreNum = availableProcessor / 2;
// 用单例模式创建线程池,保留2个核心线程,最多线程为CPU个数的2n+1的两倍.
int maxProcessor = (availableProcessor * 2 + 1) * 2 ;
executorService = new ThreadPoolExecutor(coreNum > 2 ? 2 : coreNum, maxProcessor,
60L, TimeUnit.SECONDS,
new SynchronousQueue<Runnable>());
}
}
private static ExecutorPoolSingleton instance;
public static ExecutorPoolSingleton getInstance() {
if (instance == null) {
synchronized (Singleton.class) {
if (instance == null) {
instance = new ExecutorPoolSingleton();
}
}
}
return instance;
}
int executeThreadNum = 1;
/**
* 执行任务
* @param runnable
*/
public void executeTask(Runnable runnable) {
executorService.execute(runnable);
logger.info("异步线程执行了%d次:{} ", executeThreadNum++);
}
}
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