Ver código fonte

xuanpin库 bug 修改

zhaoxian 3 anos atrás
pai
commit
f2a0ed58f8

+ 2 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/material/mapper/xml/ProductMaterialMapper.xml

@@ -50,7 +50,7 @@
                 and start_month >= #{startMonth}
             </if>
             <if test="endMonth!=null">
-                and end_month &lt;= #{endMonth}
+                AND (end_month &lt;= #{endMonth} OR (end_month IS NULL  AND start_month &lt;= #{endMonth}))
             </if>
             <if test="itemRun!=null">
                 and item_run = #{itemRun}
@@ -104,7 +104,7 @@
             and t1.start_month >= #{startMonth}
         </if>
         <if test="endMonth!=null">
-            AND (t1.end_month &lt;= #{endMonth} or t1.end_month is null)
+            AND (t1.end_month &lt;= #{endMonth} OR (t1.end_month IS NULL  AND t1.start_month &lt;= #{endMonth}))
         </if>
         <if test="itemRun!=null">
             and t1.item_run = #{itemRun}

+ 27 - 15
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/material/service/impl/ProductMaterialServiceImpl.java

@@ -33,6 +33,8 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 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}")
     private String downloadPath;
 
-
+    static ExecutorService videoService = Executors.newFixedThreadPool(8);
     @Override
     public Result<Object> queryPageList(ProductMaterial productMaterial, Integer pageNo, Integer pageSize) {
         String startMonth = productMaterial.getStartMonth();
@@ -133,24 +135,35 @@ public class ProductMaterialServiceImpl extends ServiceImpl<ProductMaterialMappe
                     List<String >urls = Arrays.asList(videoUrl.split(","));
                     HashSet<String> set = new HashSet<>(urls);
                     for (String url : set) {
-                        ProductMaterial material = new ProductMaterial();
                         count++;
                         //获取MD5
                         String localPath = LoadFileUtil.downLoadFromUrl(url, downloadPath);
                         String md5 = MD5Util.getMd5(localPath);
+                        LoadFileUtil.delFile(localPath);
                         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 {
                             flag = true;
                             if (msg.contains(tradeName)) {
@@ -159,7 +172,6 @@ public class ProductMaterialServiceImpl extends ServiceImpl<ProductMaterialMappe
                                 msg += "商品(" + tradeName + ")下的第" + count + "条视频已存在,";
                             }
                         }
-                        LoadFileUtil.delFile(localPath);
                     }
                 } else {
                     ProductMaterial material = new ProductMaterial();