ソースを参照

Merge remote-tracking branch 'origin/V2.0.1' into V2.0.1

zxa 3 年 前
コミット
189e56232c

+ 46 - 44
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}
@@ -68,7 +68,7 @@
         t1.trade_name as 'tradeName',
         t1.trade_type as 'tradeType',
         t1.item_run as 'itemRun',
-        IF(t4.videoCount is null ,'-',IFNULL(t2.charge,0.00)) as 'charge',
+        IF(t4.videoCount is null ,'-',IFNULL(sum(t2.charge),0.00)) as 'charge',
         CONCAT_WS(' ~ ',t1.start_month,t1.end_month) AS 'time',
         IFNULL(t3.realname,'-') as 'user',
         IFNULL(t4.videoCount ,'-') as 'videoCount'
@@ -94,21 +94,21 @@
         WHERE video_url is not null
         GROUP BY product_id,trade_name) t4 ON t1.product_id = t4.product_id AND t1.trade_name= t4.trade_name
         <where>
-        <if test="productId!=null">
-            and t1.product_id = #{productId}
-        </if>
-        <if test="tradeName!=null">
-            and t1.trade_name like CONCAT(CONCAT('%', #{tradeName}), '%')
-        </if>
-        <if test="startMonth!=null">
-            and t1.start_month >= #{startMonth}
-        </if>
-        <if test="endMonth!=null">
-            AND (t1.end_month &lt;= #{endMonth} or t1.end_month is null)
-        </if>
-        <if test="itemRun!=null">
-            and t1.item_run = #{itemRun}
-        </if>
+            <if test="productId!=null">
+                and t1.product_id = #{productId}
+            </if>
+            <if test="tradeName!=null">
+                and t1.trade_name like CONCAT(CONCAT('%', #{tradeName}), '%')
+            </if>
+            <if test="startMonth!=null">
+                and t1.start_month >= #{startMonth}
+            </if>
+            <if test="endMonth!=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}
+            </if>
         </where>
         group by t1.product_id,t1.trade_name
         ORDER BY t1.create_time desc
@@ -117,40 +117,42 @@
     <select id="videoListTotal" resultType="java.lang.Long">
         SELECT IFNULL(sum(1), 0)
         from (
-                 select trade_name
-                 FROM ctop_product_material
-                 WHERE video_url is not null
-                   and product_id = #{productId}
-                   and trade_name = #{tradeName}
-                   and start_month >= #{startMonth}
-                   and end_month &lt;= #{endMonth}
-                 group by signature
-             ) t
+        select trade_name
+        FROM ctop_product_material
+        WHERE video_url is not null
+        and product_id = #{productId}
+        and trade_name = #{tradeName}
+        and start_month >= #{startMonth}
+        <if test="endMonth!=null">
+            and end_month &lt;= #{endMonth}
+        </if>
+        group by signature
+        ) t
     </select>
 
     <select id="videoList" resultType="com.alibaba.fastjson.JSONObject">
         SELECT t1.id,
-               t1.product_name as 'productName',
-               t1.trade_name as 'tradeName',
-               t1.video_url as 'videoUrl',
-               IFNULL(t2.charge, 0.00) as 'charge',
-               IFNULL(t3.realname, '-') as 'user'
+        t1.product_name as 'productName',
+        t1.trade_name as 'tradeName',
+        t1.video_url as 'videoUrl',
+        IFNULL(t2.charge, 0.00) as 'charge',
+        IFNULL(t3.realname, '-') as 'user'
         FROM ctop_product_material t1
-                 LEFT JOIN (
-            SELECT signature, sum(charge) as 'charge'
-            FROM application.kuaishou_material_video_report_daily_dw
-            where product_id = #{productId}
-              AND stat_date >= DATE_FORMAT(#{startDate}, '%Y%m%d')
-              AND stat_date &lt;= DATE_FORMAT(#{endDate}, '%Y%m%d')
-            GROUP BY signature
+        LEFT JOIN (
+        SELECT signature, sum(charge) as 'charge'
+        FROM application.kuaishou_material_video_report_daily_dw
+        where product_id = #{productId}
+        AND stat_date >= DATE_FORMAT(#{startDate}, '%Y%m%d')
+        AND stat_date &lt;= DATE_FORMAT(#{endDate}, '%Y%m%d')
+        GROUP BY signature
         ) t2 ON t1.signature = t2.signature
-                 LEFT JOIN (select id, realname from sys_user) t3 on t1.uploader_id = t3.id
+        LEFT JOIN (select id, realname from sys_user) t3 on t1.uploader_id = t3.id
         WHERE video_url is not null
         and product_id = #{productId}
-          and trade_name = #{tradeName}
-          and start_month >= #{startMonth}
+        and trade_name = #{tradeName}
+        and start_month >= #{startMonth}
         <if test="endMonth!=null">
-          and end_month &lt;= #{endMonth}
+            and end_month &lt;= #{endMonth}
         </if>
         ORDER BY t1.create_time desc
     </select>
@@ -170,7 +172,7 @@
         IFNULL(t3.realname, '-') as 'user'
         FROM ctop_product_material t1
         LEFT JOIN
-        ( SELECT  product_id,signature , sum(charge) as 'charge' FROM application.kuaishou_material_video_report_daily_dw
+        ( SELECT product_id,signature , sum(charge) as 'charge' FROM application.kuaishou_material_video_report_daily_dw
         <where>
             <if test="productId!=null">
                 and product_id = #{productId}
@@ -196,7 +198,7 @@
             and t1.start_month >= #{startMonth}
         </if>
         <if test="endMonth!=null">
-            and t1.end_month &lt;= #{endMonth}
+            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}

+ 23 - 16
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,30 @@ 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.setUploaderId(entity.getUserId());
+                                        material.setTradeName(tradeName);
+                                        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 +167,6 @@ public class ProductMaterialServiceImpl extends ServiceImpl<ProductMaterialMappe
                                 msg += "商品(" + tradeName + ")下的第" + count + "条视频已存在,";
                             }
                         }
-                        LoadFileUtil.delFile(localPath);
                     }
                 } else {
                     ProductMaterial material = new ProductMaterial();
@@ -167,7 +174,7 @@ public class ProductMaterialServiceImpl extends ServiceImpl<ProductMaterialMappe
                     material.setTradeName(tradeName);
                     material.setVideoUrl(videoUrl);
                     material.setSignature(signature);
-                    material.setUploaderId(uploaderId);
+                    material.setUploaderId(entity.getUserId());
                     if (checkVideo(entity.getProductId(), tradeName, signature)) {
                         lists.add(material);
                     }