kgdxpr 7 months ago
commit 7c7053c6f6

@ -217,6 +217,7 @@
<artifactId>druid</artifactId>
<version>1.2.23</version>
</dependency>
<!--强制升级httpclient和httpcore-->
<dependency>
<groupId>org.apache.httpcomponents</groupId>

@ -518,6 +518,7 @@ public class YunXiao {
List<Record> writeList = new ArrayList<>();
for (Record record : lessonList) {
String original_school_name = record.getStr("teacher_school_name");//原始学校名称
String teacher_name= record.getStr("teacher_name");
String organization_name = "";
String organization_no = "";
String gather_regionc = "";
@ -547,6 +548,7 @@ public class YunXiao {
rWrite.set("organization_no", organization_no);
rWrite.set("gather_regionc", gather_regionc);
rWrite.set("match_type", match_type);
rWrite.set("teacher_name", teacher_name);
writeList.add(rWrite);
}
//对writeList根据lesson_id去重

@ -0,0 +1,23 @@
package UnitTest;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
public class TestGetUrl {
public static void main(String[] args) {
//m3u8的lessonId
//String lessonId = "931303979da03dfa291ed5e6531b82e5";
//mp4的lessonId
String lessonId = "2144ddfe45ef13b94eb06dd4e9bdee2b";
String sourceUrl = "https://yx.ccsjy.cn/api/cloud-school/v1/cloudLesson/getById?lessonId=" + lessonId;
String content = HttpUtil.get(sourceUrl);
JSONObject jo = JSONObject.parseObject(content);
String fileUrl = jo.getJSONObject("data").getJSONArray("lessonResources").getJSONObject(0).getString("fileUrl");
if (fileUrl.contains(".mp4")) {
fileUrl = "https://ccschool.edusoa.com/" + fileUrl;
}
System.out.println(fileUrl);
}
}

@ -0,0 +1,47 @@
package com.dsideal.QingLong.Render;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import com.jfinal.render.Render;
/**
*
*
* @author CC11001100
*/
public class ImageRender extends Render {
/**
*
*/
private File imgFile;
public ImageRender(File imgFile) {
super();
this.imgFile = imgFile;
}
public File getImgFile() {
return imgFile;
}
public void setImgFile(File imgFile) {
this.imgFile = imgFile;
}
/**
*
*/
public void render() {
response.setContentType("image/jpeg");
try {
FileUtils.copyFile(imgFile, response.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
}
}
}

@ -1,9 +1,11 @@
package com.dsideal.QingLong.YunXiao.Controller;
import com.dsideal.QingLong.Interceptor.IsLoginInterface;
import com.dsideal.QingLong.Render.ImageRender;
import com.dsideal.QingLong.Util.CommonUtil;
import com.dsideal.QingLong.YunXiao.Model.YunXiaoModel;
import com.dsideal.QingLong.YunXiao.Util.YunXiaoExportExcelUtil;
import com.dsideal.QingLong.YunXiao.Util.YunXiaoVideoUtil;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.jfinal.ext.interceptor.GET;
@ -112,7 +114,7 @@ public class YunXiaoController extends Controller {
//获取系统临时目录
String tmpDir = System.getProperty("java.io.tmpdir");
//使用guid生成一个临时文件名然后拼接到tmpDir后面生成完整的临时文件路径
String tmpFile = tmpDir + File.separator + UUID.randomUUID() + ".xlsx";
String tmpFile = tmpDir + UUID.randomUUID() + ".xlsx";
exporter.LessonConstructionExportExcel(tmpFile, list1, list2, list3);
//提供下载
renderFile(new File(tmpFile), "课程建设情况报表.xlsx");
@ -133,9 +135,28 @@ public class YunXiaoController extends Controller {
//获取系统临时目录
String tmpDir = System.getProperty("java.io.tmpdir");
//使用guid生成一个临时文件名然后拼接到tmpDir后面生成完整的临时文件路径
String tmpFile = tmpDir + File.separator + UUID.randomUUID() + ".xlsx";
String tmpFile = tmpDir + UUID.randomUUID() + ".xlsx";
exporter.LessonConstructionInfoByXzqhSchool(tmpFile, list1, list2, list3, list4);
//提供下载
renderFile(new File(tmpFile), "【区域+学校】课程建设情况报表.xlsx");
}
/**
*
*
* @param lessonId id
*/
// http://10.10.21.20:9000/QingLong/yx/getLessonCover?lessonId=931303979da03dfa291ed5e6531b82e5
// http://10.10.21.20:9000/QingLong/yx/getLessonCover?lessonId=2144ddfe45ef13b94eb06dd4e9bdee2b
@Before(GET.class)
public void getLessonCover(String lessonId) throws InterruptedException {
String url = YunXiaoVideoUtil.getUrlByLessonId(lessonId);
//获取系统临时目录
String tmpDir = System.getProperty("java.io.tmpdir");
//使用guid生成一个临时文件名然后拼接到tmpDir后面生成完整的临时文件路径
String tmpFile = tmpDir + UUID.randomUUID() + ".jpg";
YunXiaoVideoUtil.getCover(url, tmpFile);
File imgFile = new File(tmpFile);
render(new ImageRender(imgFile));
}
}

@ -0,0 +1,98 @@
package com.dsideal.QingLong.YunXiao.Util;
import cn.hutool.core.util.RuntimeUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import java.io.*;
public class YunXiaoVideoUtil {
//MP4的片头长10秒
public static final int MP4 = 10;
//MU38的片头长7秒
public static final int M3U8 = 5;
//ffmpeg路径
public static final String FFMPEG_PATH = "D:\\ffmpeg\\ffmpeg.exe";
/**
*
*
* @param ffmpegPath
* @param videoInputPath
* @param videoOutputPath
* @return
*/
private static String getCmdMp4(String ffmpegPath, int seconds, String videoInputPath, String videoOutputPath) {
return ffmpegPath + " -ss " + seconds + " -i " + videoInputPath + " -frames:v 1 -q:v 2 -s 1280x720 " + videoOutputPath;
}
/**
* m3u8
*
* @param ffmpegPath
* @param seconds
* @param videoInputPath
* @param videoOutputPath
* @return
*/
private static String getCmdM3u8(String ffmpegPath, int seconds, String videoInputPath, String videoOutputPath) {
return ffmpegPath + " -i " + videoInputPath + " -ss " + seconds + " -vframes 1 -s 1280x720 " + videoOutputPath;
}
/**
*
*
* @param videoInputPath
* @param videoOutputPath
* @return
*/
public static String getCmd(String videoInputPath, String videoOutputPath) {
if (videoInputPath.toLowerCase().endsWith(".m3u8")) {
return getCmdM3u8(FFMPEG_PATH, M3U8, videoInputPath, videoOutputPath);
}
return getCmdMp4(FFMPEG_PATH, MP4, videoInputPath, videoOutputPath);
}
/**
*
*
* @param url
* @param JpegPath
*/
public static void getCover(String url, String JpegPath) throws InterruptedException {
String cmd = getCmd(url, JpegPath);
//使用java调用ffmpeg命令行工具生成图片
Process process = RuntimeUtil.exec(cmd);
process.waitFor();
}
/**
* id
* @param lessonId id
* @return
*/
public static String getUrlByLessonId(String lessonId){
String sourceUrl = "https://yx.ccsjy.cn/api/cloud-school/v1/cloudLesson/getById?lessonId=" + lessonId;
String content = HttpUtil.get(sourceUrl);
JSONObject jo = JSONObject.parseObject(content);
String fileUrl = jo.getJSONObject("data").getJSONArray("lessonResources").getJSONObject(0).getString("fileUrl");
if (fileUrl.contains(".mp4")) {
fileUrl = "https://ccschool.edusoa.com/" + fileUrl;
}
return fileUrl;
}
public static void main(String[] args) throws InterruptedException {
String[] a = {
"https://ccschool.edusoa.com/cloud_file/project/ccyx-0012/material/5b/c5/5bc51a9075751b69a9c1c5d722c39485.mp4",
"https://ccmsyk-video.edusoa.com/down/M3u8/BE/BECBF507-1EAF-4301-A417-AE25593A62F1.m3u8",
"https://ccmsyk-video.edusoa.com/down/M3u8/73/7311BCC2-D260-4D34-9B70-3722DB884CB6.m3u8",
"https://ccmsyk-video.edusoa.com/down/M3u8/9A/9A69A401-BF92-433D-AB96-7B9965BDDD87.m3u8"
};
for (int i = 0; i < a.length; i++) {
File f = new File("c:\\" + (i + 1) + ".jpg");
if (f.exists()) f.delete();
getCover(a[i], f.getAbsolutePath());
}
}
}
Loading…
Cancel
Save