|
@@ -12,6 +12,7 @@ import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import top.lvzhiqiang.config.WebAppConfig;
|
|
import top.lvzhiqiang.config.WebAppConfig;
|
|
|
import top.lvzhiqiang.dto.JavAllInfo;
|
|
import top.lvzhiqiang.dto.JavAllInfo;
|
|
|
|
|
+import top.lvzhiqiang.dto.JavAllInfo4Uncensored;
|
|
|
import top.lvzhiqiang.entity.*;
|
|
import top.lvzhiqiang.entity.*;
|
|
|
import top.lvzhiqiang.enumeration.ResultCodeEnum;
|
|
import top.lvzhiqiang.enumeration.ResultCodeEnum;
|
|
|
import top.lvzhiqiang.exception.BusinessException;
|
|
import top.lvzhiqiang.exception.BusinessException;
|
|
@@ -62,6 +63,8 @@ public class BgServiceImpl implements BgService {
|
|
|
private DicCodeMapper dicCodeMapper;
|
|
private DicCodeMapper dicCodeMapper;
|
|
|
@Resource
|
|
@Resource
|
|
|
private VideoInfoOtherMapper videoInfoOtherMapper;
|
|
private VideoInfoOtherMapper videoInfoOtherMapper;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private VideoInfoUncensoredMapper videoInfoUncensoredMapper;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* findDicCode
|
|
* findDicCode
|
|
@@ -258,19 +261,31 @@ public class BgServiceImpl implements BgService {
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
@Async
|
|
@Async
|
|
|
- public void initQibingData() {
|
|
|
|
|
|
|
+ public void initVideoInfoData(Integer type, Integer isDel) {
|
|
|
long startTime = System.currentTimeMillis();
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
- DicCode dicCode = WebAppConfig.dicCodeList.stream().filter(x -> 1 == x.getType() && "qibing_path".equals(x.getCodeKey())).findFirst().get();
|
|
|
|
|
|
|
+ DicCode dicCode = null;
|
|
|
|
|
+ if (type == 1) {
|
|
|
|
|
+ dicCode = WebAppConfig.dicCodeList.stream().filter(x -> 1 == x.getType() && "qibing_path".equals(x.getCodeKey())).findFirst().get();
|
|
|
|
|
+ } else if (type == 3) {
|
|
|
|
|
+ dicCode = WebAppConfig.dicCodeList.stream().filter(x -> 1 == x.getType() && "liuchu_path".equals(x.getCodeKey())).findFirst().get();
|
|
|
|
|
+ }
|
|
|
if (dicCode == null) {
|
|
if (dicCode == null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
String picPath = dicCode.getCodeValue();
|
|
String picPath = dicCode.getCodeValue();
|
|
|
|
|
|
|
|
- JavAllInfo javAllInfo = new JavAllInfo();
|
|
|
|
|
- getAllFilePaths(picPath, javAllInfo);
|
|
|
|
|
|
|
+ if (type == 1) {
|
|
|
|
|
+ JavAllInfo javAllInfo = new JavAllInfo();
|
|
|
|
|
+ getAllFilePaths(picPath, javAllInfo);
|
|
|
|
|
+
|
|
|
|
|
+ saveInfo(javAllInfo);
|
|
|
|
|
+ } else if (type == 3) {
|
|
|
|
|
+ JavAllInfo4Uncensored javAllInfo4Uncensored = new JavAllInfo4Uncensored();
|
|
|
|
|
+ getAllFilePaths4Uncensored(picPath, javAllInfo4Uncensored);
|
|
|
|
|
|
|
|
- saveInfo(javAllInfo);
|
|
|
|
|
|
|
+ saveInfo4Uncensored(javAllInfo4Uncensored, isDel);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
long endTime = System.currentTimeMillis();
|
|
long endTime = System.currentTimeMillis();
|
|
|
System.err.println((endTime - startTime) / 1000);
|
|
System.err.println((endTime - startTime) / 1000);
|
|
@@ -662,6 +677,64 @@ public class BgServiceImpl implements BgService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void getAllFilePaths4Uncensored(String filePath, JavAllInfo4Uncensored javAllInfo4Uncensored) {
|
|
|
|
|
+ File[] files = new File(filePath).listFiles();
|
|
|
|
|
+ if (files == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (File file : files) {
|
|
|
|
|
+ if (file.isDirectory()) {
|
|
|
|
|
+ // 文件夹
|
|
|
|
|
+ getAllFilePaths4Uncensored(file.getAbsolutePath(), javAllInfo4Uncensored);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ String fileName = file.getName();
|
|
|
|
|
+ if (fileName.endsWith(".jpg")) {
|
|
|
|
|
+ String parentName = file.getParentFile().getName();
|
|
|
|
|
+ // 识别码
|
|
|
|
|
+ String name = fileName.substring(10).replace(".jpg", "").trim();
|
|
|
|
|
+ String[] nameArr = name.split("\\s+");
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 获取正片信息
|
|
|
|
|
+ VideoInfoUncensored videoInfoUncensored = new VideoInfoUncensored();
|
|
|
|
|
+ // 发行日期
|
|
|
|
|
+ String issueDate = fileName.substring(0, 10);
|
|
|
|
|
+ videoInfoUncensored.setIssueDate(LocalDate.parse(issueDate, DateUtils.dateFormatter));
|
|
|
|
|
+ videoInfoUncensored.setIdentificationCode(nameArr[0]);
|
|
|
|
|
+ // 名称
|
|
|
|
|
+ if (nameArr.length > 1) {
|
|
|
|
|
+ videoInfoUncensored.setName(name.substring(nameArr[0].length()).trim());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ videoInfoUncensored.setName(nameArr[0]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 类型
|
|
|
|
|
+ videoInfoUncensored.setStatus(1);
|
|
|
|
|
+ // 图片URL
|
|
|
|
|
+ videoInfoUncensored.setImgUrl(parentName.concat("/").concat(fileName));
|
|
|
|
|
+ // 创建时间 TODO
|
|
|
|
|
+ // 修改时间
|
|
|
|
|
+ videoInfoUncensored.setCreateTime(Instant.ofEpochMilli(file.lastModified()).atZone(ZoneOffset.ofHours(8)).toLocalDateTime());
|
|
|
|
|
+
|
|
|
|
|
+ // 主体是谁
|
|
|
|
|
+ videoInfoUncensored.setMainWho(parentName);
|
|
|
|
|
+
|
|
|
|
|
+ javAllInfo4Uncensored.getVideoInfoUncensoredList().add(videoInfoUncensored);
|
|
|
|
|
+ System.out.println("success:" + file.getAbsolutePath());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ System.err.println("error:" + file.getAbsolutePath());
|
|
|
|
|
+ System.err.println("error reason:" + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (!fileName.endsWith(".jpg") && !fileName.endsWith(".srt")) {
|
|
|
|
|
+ String[] nameArr = fileName.substring(0, fileName.lastIndexOf(".")).split("\\s+");
|
|
|
|
|
+ String parentName = file.getParentFile().getName();
|
|
|
|
|
+
|
|
|
|
|
+ javAllInfo4Uncensored.getVideoUrlMap().put(nameArr[1], parentName.concat("/").concat(fileName));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 保存所有文件
|
|
// 保存所有文件
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
public void saveInfo(JavAllInfo javAllInfo) {
|
|
public void saveInfo(JavAllInfo javAllInfo) {
|
|
@@ -724,6 +797,25 @@ public class BgServiceImpl implements BgService {
|
|
|
videoInfoCastMapper.insertList(videoInfoCastSet);
|
|
videoInfoCastMapper.insertList(videoInfoCastSet);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
|
|
+ public void saveInfo4Uncensored(JavAllInfo4Uncensored javAllInfo4Uncensored, Integer isDel) {
|
|
|
|
|
+ // 删除所有
|
|
|
|
|
+ if (isDel == 1) {
|
|
|
|
|
+ videoInfoUncensoredMapper.deleteAll();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // 保存影片信息
|
|
|
|
|
+ List<VideoInfoUncensored> videoInfoUncensoredList = javAllInfo4Uncensored.getVideoInfoUncensoredList();
|
|
|
|
|
+ Map<String, String> videoUrlMap = javAllInfo4Uncensored.getVideoUrlMap();
|
|
|
|
|
+ videoInfoUncensoredList.parallelStream().forEach(e -> {
|
|
|
|
|
+ e.setVideoUrl(videoUrlMap.get(e.getIdentificationCode()));
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ int videoInfoCount = videoInfoUncensoredMapper.insertList(videoInfoUncensoredList);
|
|
|
|
|
+ System.out.println("videoInfoCount:" + videoInfoCount);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private List<String> readFromIcodeStream(InputStream inputStream) {
|
|
private List<String> readFromIcodeStream(InputStream inputStream) {
|
|
|
List<String> list = new ArrayList<>();
|
|
List<String> list = new ArrayList<>();
|
|
|
BufferedReader br = null;
|
|
BufferedReader br = null;
|