|
@@ -33,6 +33,8 @@ import java.util.HashSet;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
|
+import java.util.concurrent.Executors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 选品库——产品与商品信息
|
|
* 选品库——产品与商品信息
|
|
@@ -51,7 +53,7 @@ public class ProductMaterialServiceImpl extends ServiceImpl<ProductMaterialMappe
|
|
@Value("${zip.local.download-path}")
|
|
@Value("${zip.local.download-path}")
|
|
private String downloadPath;
|
|
private String downloadPath;
|
|
|
|
|
|
-
|
|
|
|
|
|
+ static ExecutorService videoService = Executors.newFixedThreadPool(8);
|
|
@Override
|
|
@Override
|
|
public Result<Object> queryPageList(ProductMaterial productMaterial, Integer pageNo, Integer pageSize) {
|
|
public Result<Object> queryPageList(ProductMaterial productMaterial, Integer pageNo, Integer pageSize) {
|
|
String startMonth = productMaterial.getStartMonth();
|
|
String startMonth = productMaterial.getStartMonth();
|
|
@@ -133,24 +135,35 @@ public class ProductMaterialServiceImpl extends ServiceImpl<ProductMaterialMappe
|
|
List<String >urls = Arrays.asList(videoUrl.split(","));
|
|
List<String >urls = Arrays.asList(videoUrl.split(","));
|
|
HashSet<String> set = new HashSet<>(urls);
|
|
HashSet<String> set = new HashSet<>(urls);
|
|
for (String url : set) {
|
|
for (String url : set) {
|
|
- ProductMaterial material = new ProductMaterial();
|
|
|
|
count++;
|
|
count++;
|
|
//获取MD5
|
|
//获取MD5
|
|
String localPath = LoadFileUtil.downLoadFromUrl(url, downloadPath);
|
|
String localPath = LoadFileUtil.downLoadFromUrl(url, downloadPath);
|
|
String md5 = MD5Util.getMd5(localPath);
|
|
String md5 = MD5Util.getMd5(localPath);
|
|
|
|
+ LoadFileUtil.delFile(localPath);
|
|
if (checkVideo(entity.getProductId(), tradeName, md5)) {
|
|
if (checkVideo(entity.getProductId(), tradeName, md5)) {
|
|
- BeanUtils.copyProperties(entity, material);
|
|
|
|
- material.setTradeName(tradeName);
|
|
|
|
- MaterialInfo info = materialInfoService.getMaterialInfoByCode(md5);
|
|
|
|
- if (!Check.isNull(info)) {
|
|
|
|
- material.setUploaderId(uploaderId);
|
|
|
|
- } else {
|
|
|
|
- material.setUploaderId(material.getUserId());
|
|
|
|
- }
|
|
|
|
- material.setSignature(md5);
|
|
|
|
- String cosUrl = getCosUrl(url);
|
|
|
|
- material.setVideoUrl(cosUrl);
|
|
|
|
- lists.add(material);
|
|
|
|
|
|
+ videoService.submit(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ try {
|
|
|
|
+ ProductMaterial material = new ProductMaterial();
|
|
|
|
+ BeanUtils.copyProperties(entity, material);
|
|
|
|
+ material.setTradeName(tradeName);
|
|
|
|
+ MaterialInfo info = materialInfoService.getMaterialInfoByCode(md5);
|
|
|
|
+ if (!Check.isNull(info)) {
|
|
|
|
+ material.setUploaderId(uploaderId);
|
|
|
|
+ } else {
|
|
|
|
+ material.setUploaderId(material.getUserId());
|
|
|
|
+ }
|
|
|
|
+ material.setSignature(md5);
|
|
|
|
+ String cosUrl = getCosUrl(url);
|
|
|
|
+ material.setVideoUrl(cosUrl);
|
|
|
|
+ baseMapper.insert(material);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
flag = true;
|
|
flag = true;
|
|
if (msg.contains(tradeName)) {
|
|
if (msg.contains(tradeName)) {
|
|
@@ -159,7 +172,6 @@ public class ProductMaterialServiceImpl extends ServiceImpl<ProductMaterialMappe
|
|
msg += "商品(" + tradeName + ")下的第" + count + "条视频已存在,";
|
|
msg += "商品(" + tradeName + ")下的第" + count + "条视频已存在,";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- LoadFileUtil.delFile(localPath);
|
|
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
ProductMaterial material = new ProductMaterial();
|
|
ProductMaterial material = new ProductMaterial();
|