上传图片超时,邮件提醒开发相关人员
This commit is contained in:
@@ -27,6 +27,7 @@ import com.google.common.collect.Lists;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -77,10 +78,13 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
private String collectionElement;
|
||||
@Value("${minio.bucketName.gradient}")
|
||||
private String gradientBucketName;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public CollectionElementVO upload(CollectionElementUploadDTO uploadDTO) {
|
||||
long start = System.currentTimeMillis();
|
||||
//用户信息
|
||||
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
||||
CollectionLevel1TypeEnum level1TypeEnum = CollectionLevel1TypeEnum.uploadOf(uploadDTO.getLevel1Type());
|
||||
@@ -105,6 +109,17 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
collectionElementVO.setMinIOPath(collectionElementVO.getUrl());
|
||||
collectionElementVO.setUrl(minioUtil.getPreSignedUrl(collectionElementVO.getUrl(), 24 * 60));
|
||||
collectionElementVO.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
double floor = Math.floor((double) (end - start) / 1000);
|
||||
log.info("本次图片上传耗时:{} 毫秒", end - start);
|
||||
Long incrementCount = redisUtil.getIncrementCount(RedisUtil.UPLOAD_TIMEOUT_REMINDER_COUNTER);
|
||||
if (floor > 5 && incrementCount < 3) {
|
||||
// 邮件通知 一天最多通知3次
|
||||
log.info("上传超过5秒,发送邮件通知");
|
||||
SendEmailUtil.uploadTimeoutReminder(userInfo.getUsername(), String.valueOf(((end - start) / 1000)));
|
||||
redisUtil.increaseCount(RedisUtil.UPLOAD_TIMEOUT_REMINDER_COUNTER);
|
||||
}
|
||||
return collectionElementVO;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user