Browse Source

上传文件 获取基本信息

yumeng 5 years ago
parent
commit
cd33cf5f90

BIN
module-common/lib/jave-1.0.2.jar


+ 2 - 31
module-common/pom.xml

@@ -23,27 +23,12 @@
     </properties>
     </properties>
 
 
     <dependencies>
     <dependencies>
-        <!--<dependency>
-            <groupId>cn.com.ctop</groupId>
-            <artifactId>module-toutiao</artifactId>
-            <version>2.0.2</version>
-        </dependency>
         <dependency>
         <dependency>
-            <groupId>cn.com.ctop</groupId>
-            <artifactId>module-kuaishou</artifactId>
-            <version>2.0.2</version>
-        </dependency>-->
-
-
-        <dependency>
-            <groupId>com.lgg.jave</groupId>
+            <groupId>thirtpart</groupId>
             <artifactId>jave</artifactId>
             <artifactId>jave</artifactId>
-            <scope>system</scope>
-            <version>1.0.2</version>
-            <systemPath>${project.basedir}/lib/jave-1.0.2.jar</systemPath>
+            <version>1.0</version>
         </dependency>
         </dependency>
 
 
-
         <dependency>
         <dependency>
             <groupId>junit</groupId>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <artifactId>junit</artifactId>
@@ -76,21 +61,7 @@
 
 
     </dependencies>
     </dependencies>
     <build>
     <build>
-        <!--
-                <plugins>
-                    <plugin>
-                        <groupId>org.springframework.boot</groupId>
-                        <artifactId>spring-boot-maven-plugin</artifactId>
-                        <configuration>
-                            <includeSystemScope>true</includeSystemScope>
-                        </configuration>
-                    </plugin>
-                </plugins>-->
-
-
         <resources>
         <resources>
-
-
             <resource>
             <resource>
                 <directory>lib</directory>
                 <directory>lib</directory>
                 <targetPath>BOOT-INF/lib/</targetPath>
                 <targetPath>BOOT-INF/lib/</targetPath>

+ 48 - 49
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -146,7 +146,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                     }
                     }
                 }
                 }
             }
             }
-            //  getFile(info);
+            getFile(info);
             ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS.getCode());
             ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS.getCode());
         } catch (Exception e) {
         } catch (Exception e) {
             ResultMapUtils.setResultMap(resultMap, StatusCode.MATERIAL_UPLOAD_FAIL.getCode());
             ResultMapUtils.setResultMap(resultMap, StatusCode.MATERIAL_UPLOAD_FAIL.getCode());
@@ -253,61 +253,60 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
     private MaterialParameterMapper materialParameterMapper;
     private MaterialParameterMapper materialParameterMapper;
 
 
     public void getFile(MaterialInfo materialInfo) {
     public void getFile(MaterialInfo materialInfo) {
-       /* uploadExecutorService.submit(new Runnable() {
+        uploadExecutorService.submit(new Runnable() {
             @Override
             @Override
-            public void run() {*/
-        try {
-            System.err.println("开始获取素材基本信息");
-            System.err.println(materialInfo);
-            if (!Check.isNull(materialInfo)) {
-                String url = materialInfo.getUrl();
-                long l = System.currentTimeMillis();
-                //PropertiesUtils.getValue("kuaishou_config", "video_sava_path")
-                String localUrl = LoadFileUtil.downLoadFromUrl(url, PropertiesUtils.getValue("kuaishou_config", "video_sava_path"));
-                File file = new File(localUrl);
-                it.sauronsoftware.jave.Encoder encoder = new Encoder();
-                /*try {*/
-                it.sauronsoftware.jave.MultimediaInfo m = encoder.getInfo(file);
-                long duration = m.getDuration();
-                long secondDuration = duration / 1000;
-                MaterialParameter materialParameter = new MaterialParameter();
-                materialParameter.setMaterialId(materialInfo.getId());
-                // 视频秒数
-                materialParameter.setSecond(secondDuration);
-                // 视频格式
-                materialParameter.setFormat(m.getFormat());
-                // 视频宽
-                materialParameter.setWidth(String.valueOf(m.getVideo().getSize().getWidth()));
-                // 视频高
-                materialParameter.setHeight(String.valueOf(m.getVideo().getSize().getHeight()));
-
-                FileInputStream fis = new FileInputStream(file);
-                FileChannel fc = fis.getChannel();
-                BigDecimal fileSize = new BigDecimal(fc.size());
-                String size = fileSize.divide(new BigDecimal(1048576), 2, RoundingMode.HALF_UP) + "MB";
-                materialParameter.setSize(size);
-
-                Map<String, Object> deleteMap = new HashMap<>();
-                deleteMap.put("material_id", materialInfo.getId());
-                materialParameterMapper.deleteByMap(deleteMap);
-
-                int insert = materialParameterMapper.insert(materialParameter);
-                if (insert > 0) {
-                    log.info("素材基本信息入库完成,用时:{} s", (System.currentTimeMillis() - l) / 1000);
-
-                }
-                System.err.println(2222222);
+            public void run() {
+                try {
+                    System.err.println("开始获取素材基本信息");
+                    System.err.println(materialInfo);
+                    if (!Check.isNull(materialInfo)) {
+                        String url = materialInfo.getUrl();
+                        long l = System.currentTimeMillis();
+                        //PropertiesUtils.getValue("kuaishou_config", "video_sava_path")
+                        String localUrl = LoadFileUtil.downLoadFromUrl(url, PropertiesUtils.getValue("kuaishou_config", "video_sava_path"));
+                        File file = new File(localUrl);
+                        it.sauronsoftware.jave.Encoder encoder = new Encoder();
+                        /*try {*/
+                        it.sauronsoftware.jave.MultimediaInfo m = encoder.getInfo(file);
+                        long duration = m.getDuration();
+                        long secondDuration = duration / 1000;
+                        MaterialParameter materialParameter = new MaterialParameter();
+                        materialParameter.setMaterialId(materialInfo.getId());
+                        // 视频秒数
+                        materialParameter.setSecond(secondDuration);
+                        // 视频格式
+                        materialParameter.setFormat(m.getFormat());
+                        // 视频宽
+                        materialParameter.setWidth(String.valueOf(m.getVideo().getSize().getWidth()));
+                        // 视频高
+                        materialParameter.setHeight(String.valueOf(m.getVideo().getSize().getHeight()));
+
+                        FileInputStream fis = new FileInputStream(file);
+                        FileChannel fc = fis.getChannel();
+                        BigDecimal fileSize = new BigDecimal(fc.size());
+                        String size = fileSize.divide(new BigDecimal(1048576), 2, RoundingMode.HALF_UP) + "MB";
+                        materialParameter.setSize(size);
+
+                        Map<String, Object> deleteMap = new HashMap<>();
+                        deleteMap.put("material_id", materialInfo.getId());
+                        materialParameterMapper.deleteByMap(deleteMap);
+
+                        int insert = materialParameterMapper.insert(materialParameter);
+                        if (insert > 0) {
+                            log.info("素材基本信息入库完成,用时:{} s", (System.currentTimeMillis() - l) / 1000);
+
+                        }
                /* } catch (Exception e) {
                /* } catch (Exception e) {
                     e.printStackTrace();
                     e.printStackTrace();
                 } *//*finally {
                 } *//*finally {
                     file.delete();
                     file.delete();
                 }*/
                 }*/
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
             }
             }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-       /*     }
-        });*/
+        });
     }
     }