Authored by linlong

update

... ... @@ -59,6 +59,9 @@ public class ChannelGroupRest {
UserInfoBO userInfoBO= (UserInfoBO) session.getAttribute("userSession");
logger.info("ChannelGroupRest.sendMessage:useinfo is {}", userInfoBO);
if(userInfoBO==null){
return new ApiResponse.ApiResponseBuilder().code(500).message("获取发送人不成功,请刷新页面!").build();
}
int result = channelGroupService.sendMessage(channelGroupRequestBO,userInfoBO.getPid());
// int result = channelGroupService.sendMessage(channelGroupRequestBO,14);
if(result==1){
... ...
... ... @@ -30,6 +30,10 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
... ... @@ -111,6 +115,14 @@ public class ChannelGroupServiceImpl implements IChannelGroupService {
}};
/**
* 默认10个线程,
*/
private ExecutorService sendMessageExecutor = new ThreadPoolExecutor(5, 10,10L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(DEFAULT_QUEUECAPACITY));
private static final int DEFAULT_QUEUECAPACITY = 20000;
@Override
public PageChannelGroupRspBO queryChannelGroupList(ChannelGroupRequestBO channelGroupRequestBO) {
logger.info("enter queryChannelGroupList. param channelGroupRequestBO={}", channelGroupRequestBO);
... ... @@ -233,7 +245,12 @@ public class ChannelGroupServiceImpl implements IChannelGroupService {
}
}
channelSmsDetailDAO.batchInsert(smsDetails);
//异步记录日志表,以后查询日志方便
try {
saveSmsDetail(smsDetails);
} catch (Exception e) {
logger.error("", e);
}
logger.info("sendMessage:insert channelSmsDetai,smsDetails is {}", smsDetails);
//5.修改分组表的分组人数、发送时间、修改时间、内容、发送人
... ... @@ -253,6 +270,17 @@ public class ChannelGroupServiceImpl implements IChannelGroupService {
return count;
}
private void saveSmsDetail(List<ChannelSmsDetail> smsDetails) {
sendMessageExecutor.execute(new Runnable() {
@Override
public void run()
{
channelSmsDetailDAO.batchInsert(smsDetails);
logger.info("sendMessage:end insert channelSmsDetai,smsDetails is {}", smsDetails);
}
});
}
@Override
public Map<Integer, String> getCondition(String ids) {
logger.info("enter getCondition. param ids={}", ids);
... ...