|
@@ -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.JavAllInfo4Infantry;
|
|
|
import top.lvzhiqiang.dto.JavAllInfo4Uncensored;
|
|
import top.lvzhiqiang.dto.JavAllInfo4Uncensored;
|
|
|
import top.lvzhiqiang.entity.*;
|
|
import top.lvzhiqiang.entity.*;
|
|
|
import top.lvzhiqiang.enumeration.ResultCodeEnum;
|
|
import top.lvzhiqiang.enumeration.ResultCodeEnum;
|
|
@@ -65,6 +66,8 @@ public class BgServiceImpl implements BgService {
|
|
|
private VideoInfoOtherMapper videoInfoOtherMapper;
|
|
private VideoInfoOtherMapper videoInfoOtherMapper;
|
|
|
@Resource
|
|
@Resource
|
|
|
private VideoInfoUncensoredMapper videoInfoUncensoredMapper;
|
|
private VideoInfoUncensoredMapper videoInfoUncensoredMapper;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private VideoInfoInfantryMapper videoInfoInfantryMapper;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* findDicCode
|
|
* findDicCode
|
|
@@ -406,7 +409,7 @@ 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 initVideoInfoData(Integer type, Integer isDel) {
|
|
|
|
|
|
|
+ public void initVideoInfoData(Integer type, Integer isDel, String infantryType) {
|
|
|
long startTime = System.currentTimeMillis();
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
DicCode dicCode = null;
|
|
DicCode dicCode = null;
|
|
@@ -414,6 +417,8 @@ public class BgServiceImpl implements BgService {
|
|
|
dicCode = WebAppConfig.dicCodeList.stream().filter(x -> 1 == x.getType() && "qibing_path".equals(x.getCodeKey())).findFirst().get();
|
|
dicCode = WebAppConfig.dicCodeList.stream().filter(x -> 1 == x.getType() && "qibing_path".equals(x.getCodeKey())).findFirst().get();
|
|
|
} else if (type == 3) {
|
|
} else if (type == 3) {
|
|
|
dicCode = WebAppConfig.dicCodeList.stream().filter(x -> 1 == x.getType() && "liuchu_path".equals(x.getCodeKey())).findFirst().get();
|
|
dicCode = WebAppConfig.dicCodeList.stream().filter(x -> 1 == x.getType() && "liuchu_path".equals(x.getCodeKey())).findFirst().get();
|
|
|
|
|
+ } else if (type == 2) {
|
|
|
|
|
+ dicCode = WebAppConfig.dicCodeList.stream().filter(x -> 1 == x.getType() && "bubing_path".equals(x.getCodeKey())).findFirst().get();
|
|
|
}
|
|
}
|
|
|
if (dicCode == null) {
|
|
if (dicCode == null) {
|
|
|
return;
|
|
return;
|
|
@@ -430,6 +435,12 @@ public class BgServiceImpl implements BgService {
|
|
|
getAllFilePaths4Uncensored(picPath, javAllInfo4Uncensored);
|
|
getAllFilePaths4Uncensored(picPath, javAllInfo4Uncensored);
|
|
|
|
|
|
|
|
saveInfo4Uncensored(javAllInfo4Uncensored, isDel);
|
|
saveInfo4Uncensored(javAllInfo4Uncensored, isDel);
|
|
|
|
|
+ } else if (type == 2) {
|
|
|
|
|
+ JavAllInfo4Infantry javAllInfo4Infantry = new JavAllInfo4Infantry();
|
|
|
|
|
+ picPath = picPath.concat(infantryType);
|
|
|
|
|
+ getAllFilePaths4Infantry(picPath, javAllInfo4Infantry, infantryType);
|
|
|
|
|
+
|
|
|
|
|
+ saveInfo4Infantry(javAllInfo4Infantry, isDel);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
long endTime = System.currentTimeMillis();
|
|
long endTime = System.currentTimeMillis();
|
|
@@ -987,6 +998,66 @@ public class BgServiceImpl implements BgService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void getAllFilePaths4Infantry(String filePath, JavAllInfo4Infantry javAllInfo4Infantry, String infantryType) {
|
|
|
|
|
+ File[] files = new File(filePath).listFiles();
|
|
|
|
|
+ if (files == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (File file : files) {
|
|
|
|
|
+ if (file.isDirectory()) {
|
|
|
|
|
+ // 文件夹
|
|
|
|
|
+ getAllFilePaths4Infantry(file.getAbsolutePath(), javAllInfo4Infantry, infantryType);
|
|
|
|
|
+ } 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 {
|
|
|
|
|
+ // 获取正片信息
|
|
|
|
|
+ VideoInfoInfantry videoInfoInfantry = new VideoInfoInfantry();
|
|
|
|
|
+ // 发行日期
|
|
|
|
|
+ String issueDate = fileName.substring(0, 10);
|
|
|
|
|
+ videoInfoInfantry.setIssueDate(LocalDate.parse(issueDate, DateUtils.dateFormatter));
|
|
|
|
|
+ videoInfoInfantry.setIdentificationCode(nameArr[0]);
|
|
|
|
|
+ // 名称
|
|
|
|
|
+ if (nameArr.length > 1) {
|
|
|
|
|
+ videoInfoInfantry.setName(name.substring(nameArr[0].length()).trim());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ videoInfoInfantry.setName(nameArr[0]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 状态
|
|
|
|
|
+ videoInfoInfantry.setStatus(1);
|
|
|
|
|
+ // 类型
|
|
|
|
|
+ videoInfoInfantry.setType(infantryType);
|
|
|
|
|
+ // 图片URL
|
|
|
|
|
+ videoInfoInfantry.setImgUrl(parentName.concat("/").concat(fileName));
|
|
|
|
|
+ // 创建时间 TODO
|
|
|
|
|
+ // 修改时间
|
|
|
|
|
+ videoInfoInfantry.setCreateTime(Instant.ofEpochMilli(file.lastModified()).atZone(ZoneOffset.ofHours(8)).toLocalDateTime());
|
|
|
|
|
+
|
|
|
|
|
+ // 主体是谁
|
|
|
|
|
+ videoInfoInfantry.setMainWho(parentName);
|
|
|
|
|
+
|
|
|
|
|
+ javAllInfo4Infantry.getVideoInfoInfantryList().add(videoInfoInfantry);
|
|
|
|
|
+ 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") && !fileName.endsWith(".txt")) {
|
|
|
|
|
+ String[] nameArr = fileName.substring(0, fileName.lastIndexOf(".")).split("\\s+");
|
|
|
|
|
+ String parentName = file.getParentFile().getName();
|
|
|
|
|
+
|
|
|
|
|
+ javAllInfo4Infantry.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) {
|
|
@@ -1068,6 +1139,27 @@ public class BgServiceImpl implements BgService {
|
|
|
System.out.println("videoInfoCount:" + videoInfoCount);
|
|
System.out.println("videoInfoCount:" + videoInfoCount);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
|
|
+ public void saveInfo4Infantry(JavAllInfo4Infantry javAllInfo4Infantry, Integer isDel) {
|
|
|
|
|
+ // 删除所有
|
|
|
|
|
+ if (isDel == 1) {
|
|
|
|
|
+ videoInfoInfantryMapper.deleteAll();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 保存影片信息
|
|
|
|
|
+ List<VideoInfoInfantry> videoInfoInfantryList = javAllInfo4Infantry.getVideoInfoInfantryList();
|
|
|
|
|
+ Map<String, String> videoUrlMap = javAllInfo4Infantry.getVideoUrlMap();
|
|
|
|
|
+ videoInfoInfantryList.parallelStream().forEach(e -> {
|
|
|
|
|
+ e.setVideoUrl(videoUrlMap.get(e.getIdentificationCode()));
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ int videoInfoCount = 0;
|
|
|
|
|
+ if (videoInfoInfantryList.size() > 0) {
|
|
|
|
|
+ videoInfoCount = videoInfoInfantryMapper.insertList(videoInfoInfantryList);
|
|
|
|
|
+ }
|
|
|
|
|
+ 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;
|