|
@@ -7,10 +7,7 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.core.util.ZipUtil;
|
|
import cn.hutool.core.util.ZipUtil;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.izouma.wenlvju.domain.ArtType;
|
|
|
|
|
-import com.izouma.wenlvju.domain.GradingOrganization;
|
|
|
|
|
-import com.izouma.wenlvju.domain.Organization;
|
|
|
|
|
-import com.izouma.wenlvju.domain.Setting;
|
|
|
|
|
|
|
+import com.izouma.wenlvju.domain.*;
|
|
|
import com.izouma.wenlvju.domain.performance.*;
|
|
import com.izouma.wenlvju.domain.performance.*;
|
|
|
import com.izouma.wenlvju.dto.ArrangeProgrammeDTO;
|
|
import com.izouma.wenlvju.dto.ArrangeProgrammeDTO;
|
|
|
import com.izouma.wenlvju.dto.PageQuery;
|
|
import com.izouma.wenlvju.dto.PageQuery;
|
|
@@ -33,14 +30,21 @@ import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.io.FilenameUtils;
|
|
import org.apache.commons.io.FilenameUtils;
|
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
|
import org.apache.poi.util.TempFile;
|
|
import org.apache.poi.util.TempFile;
|
|
|
|
|
+import org.bytedeco.javacv.FFmpegFrameGrabber;
|
|
|
|
|
+import org.bytedeco.javacv.Frame;
|
|
|
|
|
+import org.bytedeco.javacv.Java2DFrameConverter;
|
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageImpl;
|
|
import org.springframework.data.domain.PageImpl;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
+import javax.imageio.ImageIO;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
import javax.persistence.criteria.Predicate;
|
|
|
import javax.transaction.Transactional;
|
|
import javax.transaction.Transactional;
|
|
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
import java.io.*;
|
|
import java.io.*;
|
|
|
|
|
+import java.net.FileNameMap;
|
|
|
|
|
+import java.net.URLConnection;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
@@ -193,13 +197,16 @@ public class ProgrammeService {
|
|
|
|
|
|
|
|
File destDir = TempFile.createTempDirectory("import");
|
|
File destDir = TempFile.createTempDirectory("import");
|
|
|
ZipUtil.unzip(file.getInputStream(), destDir, StandardCharsets.UTF_8);
|
|
ZipUtil.unzip(file.getInputStream(), destDir, StandardCharsets.UTF_8);
|
|
|
-// FileUtils.unzip(file.getInputStream(), destDir);
|
|
|
|
|
|
|
|
|
|
- Map<String, File> map = FileUtils.findExcel(destDir);
|
|
|
|
|
- if (map == null) return;
|
|
|
|
|
|
|
+ File xlsxFile = FileUtils.findExcel1(destDir);
|
|
|
|
|
+ if (xlsxFile == null) {
|
|
|
|
|
+ Map<String, File> map = FileUtils.findExcel(destDir);
|
|
|
|
|
+ if (map == null) return;
|
|
|
|
|
+
|
|
|
|
|
+ xlsxFile = map.get("file");
|
|
|
|
|
+ destDir = map.get("destDir");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- File xlsxFile = map.get("file");
|
|
|
|
|
- destDir = map.get("destDir");
|
|
|
|
|
|
|
|
|
|
InputStream indicatorStream = new FileInputStream(xlsxFile);
|
|
InputStream indicatorStream = new FileInputStream(xlsxFile);
|
|
|
UploadDataListener<ProgrammeDTO> listener = new UploadDataListener<>();
|
|
UploadDataListener<ProgrammeDTO> listener = new UploadDataListener<>();
|
|
@@ -236,6 +243,40 @@ public class ProgrammeService {
|
|
|
} else if (dto.getCompetitionGroup().equals(CompetitionGroup.COLLECTIVE)) {
|
|
} else if (dto.getCompetitionGroup().equals(CompetitionGroup.COLLECTIVE)) {
|
|
|
programme.setLevelSettingId(mapMap.get(4).get(dto.getLevel()));
|
|
programme.setLevelSettingId(mapMap.get(4).get(dto.getLevel()));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if (dto.getVideo() != null) {
|
|
|
|
|
+ File uploadFile = new File(destDir, dto.getVideo());
|
|
|
|
|
+ if (uploadFile.exists()) {
|
|
|
|
|
+ // 上传
|
|
|
|
|
+ String videoPath = "video/" + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date())
|
|
|
|
|
+ + RandomStringUtils.randomAlphabetic(8)
|
|
|
|
|
+ + "." + FilenameUtils.getExtension(uploadFile.getName());
|
|
|
|
|
+ String url = storageService.uploadFromInputStream(new FileInputStream(uploadFile), videoPath);
|
|
|
|
|
+
|
|
|
|
|
+// InputStream is2 = new FileInputStream(uploadFile);
|
|
|
|
|
+//
|
|
|
|
|
+// FFmpegFrameGrabber g = new FFmpegFrameGrabber(is2);
|
|
|
|
|
+// g.start();
|
|
|
|
|
+//
|
|
|
|
|
+// Frame frame = g.grabKeyFrame();
|
|
|
|
|
+// Java2DFrameConverter converter = new Java2DFrameConverter();
|
|
|
|
|
+// BufferedImage image = converter.convert(frame);
|
|
|
|
|
+// ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
|
|
|
|
|
+// ImageIO.write(image, "jpeg", baos1);
|
|
|
|
|
+// String posterPath = String.format("application/image/%s.jpg",
|
|
|
|
|
+// new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date())
|
|
|
|
|
+// + RandomStringUtils.randomAlphabetic(8));
|
|
|
|
|
+// String posterUrl = storageService
|
|
|
|
|
+// .uploadFromInputStream(new ByteArrayInputStream(baos1.toByteArray()), posterPath);
|
|
|
|
|
+// g.stop();
|
|
|
|
|
+
|
|
|
|
|
+ VideoObject vo = new VideoObject();
|
|
|
|
|
+// vo.setPoster(posterUrl);
|
|
|
|
|
+ vo.setSrc(url);
|
|
|
|
|
+ programme.setVideo(vo);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
pid = programmeRepo.save(programme).getId();
|
|
pid = programmeRepo.save(programme).getId();
|
|
|
}
|
|
}
|
|
|
|
|
|