|
|
@@ -392,10 +392,10 @@ public class BgServiceImpl implements BgService {
|
|
|
++retryCount;
|
|
|
|
|
|
if (retryCount < 4) {
|
|
|
- log.error("jsoupVideoInfo error重试:i={},retryCount={},time={},identificationCode={}", i, retryCount, System.currentTimeMillis() - start, identificationCode, e);
|
|
|
+ log.error("jsoupVideoInfo error重试:i={},retryCount={},time={},identificationCode={},javbusUrl={}", i, retryCount, System.currentTimeMillis() - start, identificationCode, javbusUrl, e);
|
|
|
} else if (retryCount == 4) {
|
|
|
videoInfoMapper.updateStatus(identificationCode, 3);
|
|
|
- log.error("jsoupVideoInfo error:i={},time={},identificationCode={}", i, System.currentTimeMillis() - start, identificationCode, e);
|
|
|
+ log.error("jsoupVideoInfo error:i={},time={},identificationCode={},javbusUrl={}", i, System.currentTimeMillis() - start, identificationCode, javbusUrl, e);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -427,9 +427,20 @@ public class BgServiceImpl implements BgService {
|
|
|
|
|
|
if (type == 1) {
|
|
|
JavAllInfo javAllInfo = new JavAllInfo();
|
|
|
- getAllFilePaths(picPath, javAllInfo);
|
|
|
|
|
|
- saveInfo(javAllInfo);
|
|
|
+ // 删除所有
|
|
|
+ if (isDel == 1) {
|
|
|
+ videoGenresMapper.deleteAll();
|
|
|
+ videoInfoMapper.deleteAll();
|
|
|
+ videoCastMapper.deleteAll();
|
|
|
+ videoInfoGenresMapper.deleteAll();
|
|
|
+ videoInfoCastMapper.deleteAll();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> allIcode = videoInfoMapper.findAllIcode();
|
|
|
+ getAllFilePaths(picPath, javAllInfo, allIcode);
|
|
|
+
|
|
|
+ saveInfo(javAllInfo, isDel);
|
|
|
} else if (type == 3) {
|
|
|
JavAllInfo4Uncensored javAllInfo4Uncensored = new JavAllInfo4Uncensored();
|
|
|
getAllFilePaths4Uncensored(picPath, javAllInfo4Uncensored);
|
|
|
@@ -440,7 +451,7 @@ public class BgServiceImpl implements BgService {
|
|
|
picPath = picPath.concat(infantryType);
|
|
|
getAllFilePaths4Infantry(picPath, javAllInfo4Infantry, infantryType);
|
|
|
|
|
|
- saveInfo4Infantry(javAllInfo4Infantry, isDel);
|
|
|
+ saveInfo4Infantry(javAllInfo4Infantry, isDel, infantryType);
|
|
|
}
|
|
|
|
|
|
long endTime = System.currentTimeMillis();
|
|
|
@@ -846,7 +857,7 @@ public class BgServiceImpl implements BgService {
|
|
|
}
|
|
|
|
|
|
// 递归获取某目录下的所有子目录以及子文件
|
|
|
- private void getAllFilePaths(String filePath, JavAllInfo javAllInfo) {
|
|
|
+ private void getAllFilePaths(String filePath, JavAllInfo javAllInfo, List<String> allIcode) {
|
|
|
File[] files = new File(filePath).listFiles();
|
|
|
if (files == null) {
|
|
|
return;
|
|
|
@@ -861,7 +872,7 @@ public class BgServiceImpl implements BgService {
|
|
|
for (File file : files) {
|
|
|
if (file.isDirectory()) {
|
|
|
// 文件夹
|
|
|
- getAllFilePaths(file.getAbsolutePath(), javAllInfo);
|
|
|
+ getAllFilePaths(file.getAbsolutePath(), javAllInfo, allIcode);
|
|
|
} else {
|
|
|
String fileName = file.getName();
|
|
|
if (fileName.endsWith(".jpg") || (fileName.endsWith(".lnk") && fileName.contains(".jpg"))) {
|
|
|
@@ -872,6 +883,10 @@ public class BgServiceImpl implements BgService {
|
|
|
try {
|
|
|
boolean isMain = false;
|
|
|
if (fileName.endsWith(".jpg")) {
|
|
|
+ if (allIcode.contains(nameArr[0])) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
isMain = true;
|
|
|
// 获取正片信息
|
|
|
VideoInfo videoInfo = new VideoInfo();
|
|
|
@@ -932,6 +947,10 @@ public class BgServiceImpl implements BgService {
|
|
|
}
|
|
|
} else if (!fileName.endsWith(".jpg") && !fileName.endsWith(".lnk")) {
|
|
|
String[] nameArr = fileName.substring(0, fileName.lastIndexOf(".")).split("\\s+");
|
|
|
+ if (allIcode.contains(nameArr[1])) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
String parentName = file.getParentFile().getName();
|
|
|
|
|
|
javAllInfo.getVideoUrlMap().put(nameArr[1], parentName.concat("/").concat(fileName));
|
|
|
@@ -1060,21 +1079,14 @@ public class BgServiceImpl implements BgService {
|
|
|
|
|
|
// 保存所有文件
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
- public void saveInfo(JavAllInfo javAllInfo) {
|
|
|
- // 删除所有
|
|
|
- videoGenresMapper.deleteAll();
|
|
|
- videoInfoMapper.deleteAll();
|
|
|
- videoCastMapper.deleteAll();
|
|
|
- videoGenresMapper.deleteAll();
|
|
|
- videoInfoCastMapper.deleteAll();
|
|
|
-
|
|
|
+ public void saveInfo(JavAllInfo javAllInfo, Integer isDel) {
|
|
|
// 保存分类
|
|
|
Set<String> videoGenresSet = javAllInfo.getVideoGenresSet();
|
|
|
//List<VideoGenres> videoGenresList = new ArrayList<>();
|
|
|
for (String s : videoGenresSet) {
|
|
|
VideoGenres videoGenres = new VideoGenres();
|
|
|
videoGenres.setName(s);
|
|
|
- videoGenresMapper.insert(videoGenres);
|
|
|
+ videoGenresMapper.insertOrUpdate(videoGenres);
|
|
|
System.out.println(videoGenres);
|
|
|
//videoGenresList.add(videoGenres);
|
|
|
}
|
|
|
@@ -1087,7 +1099,7 @@ public class BgServiceImpl implements BgService {
|
|
|
VideoCast videoCast = new VideoCast();
|
|
|
videoCast.setName(entry.getKey());
|
|
|
videoCast.setType(Integer.parseInt(entry.getValue()));
|
|
|
- videoCastMapper.insert(videoCast);
|
|
|
+ videoCastMapper.insertOrUpdate(videoCast);
|
|
|
System.out.println(videoCast);
|
|
|
//videoCastList.add(videoCast);
|
|
|
}
|
|
|
@@ -1114,10 +1126,10 @@ public class BgServiceImpl implements BgService {
|
|
|
|
|
|
// 保存影片类别关联信息
|
|
|
Set<VideoInfoGenres> videoInfoGenresSet = javAllInfo.getVideoInfoGenresSet();
|
|
|
- videoInfoGenresMapper.insertList(videoInfoGenresSet);
|
|
|
+ videoInfoGenresMapper.insertOrUpdate(videoInfoGenresSet);
|
|
|
// 保存影片类别关联信息
|
|
|
Set<VideoInfoCast> videoInfoCastSet = javAllInfo.getVideoInfoCastSet();
|
|
|
- videoInfoCastMapper.insertList(videoInfoCastSet);
|
|
|
+ videoInfoCastMapper.insertOrUpdate(videoInfoCastSet);
|
|
|
}
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
@@ -1127,31 +1139,53 @@ public class BgServiceImpl implements BgService {
|
|
|
videoInfoUncensoredMapper.deleteAll();
|
|
|
}
|
|
|
|
|
|
+ List<String> allIcode = videoInfoUncensoredMapper.findAllIcode();
|
|
|
|
|
|
// 保存影片信息
|
|
|
List<VideoInfoUncensored> videoInfoUncensoredList = javAllInfo4Uncensored.getVideoInfoUncensoredList();
|
|
|
+ int videoInfoUncensoredListBefore = videoInfoUncensoredList.size();
|
|
|
Map<String, String> videoUrlMap = javAllInfo4Uncensored.getVideoUrlMap();
|
|
|
+ Iterator<VideoInfoUncensored> iterator = videoInfoUncensoredList.iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ if (allIcode.contains(iterator.next().getIdentificationCode())) {
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
videoInfoUncensoredList.parallelStream().forEach(e -> {
|
|
|
e.setVideoUrl(videoUrlMap.get(e.getIdentificationCode()));
|
|
|
});
|
|
|
+ System.out.println("videoInfoUncensoredListBefore:" + videoInfoUncensoredListBefore + ",videoInfoUncensoredListAfter:" + videoInfoUncensoredList.size());
|
|
|
|
|
|
- int videoInfoCount = videoInfoUncensoredMapper.insertList(videoInfoUncensoredList);
|
|
|
+ int videoInfoCount = 0;
|
|
|
+ if (videoInfoUncensoredList.size() > 0) {
|
|
|
+ videoInfoCount = videoInfoUncensoredMapper.insertList(videoInfoUncensoredList);
|
|
|
+ }
|
|
|
System.out.println("videoInfoCount:" + videoInfoCount);
|
|
|
}
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
- public void saveInfo4Infantry(JavAllInfo4Infantry javAllInfo4Infantry, Integer isDel) {
|
|
|
+ public void saveInfo4Infantry(JavAllInfo4Infantry javAllInfo4Infantry, Integer isDel, String infantryType) {
|
|
|
// 删除所有
|
|
|
if (isDel == 1) {
|
|
|
videoInfoInfantryMapper.deleteAll();
|
|
|
}
|
|
|
|
|
|
+ List<String> allIcode = videoInfoInfantryMapper.findAllIcode(infantryType);
|
|
|
+
|
|
|
// 保存影片信息
|
|
|
List<VideoInfoInfantry> videoInfoInfantryList = javAllInfo4Infantry.getVideoInfoInfantryList();
|
|
|
+ int videoInfoInfantryListBefore = videoInfoInfantryList.size();
|
|
|
Map<String, String> videoUrlMap = javAllInfo4Infantry.getVideoUrlMap();
|
|
|
+ Iterator<VideoInfoInfantry> iterator = videoInfoInfantryList.iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ if (allIcode.contains(iterator.next().getIdentificationCode())) {
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
videoInfoInfantryList.parallelStream().forEach(e -> {
|
|
|
e.setVideoUrl(videoUrlMap.get(e.getIdentificationCode()));
|
|
|
});
|
|
|
+ System.out.println("videoInfoInfantryListBefore:" + videoInfoInfantryListBefore + ",videoInfoInfantryListAfter:" + videoInfoInfantryList.size());
|
|
|
|
|
|
int videoInfoCount = 0;
|
|
|
if (videoInfoInfantryList.size() > 0) {
|