diff --git a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/app/OtherController.java b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/app/OtherController.java index f88e8ef..3bf20c1 100644 --- a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/app/OtherController.java +++ b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/app/OtherController.java @@ -97,7 +97,7 @@ public class OtherController { handleType = "删除"; if (file.isDirectory()) result = common.deleteAllFile(dir, file); - else if(file.isFile()) + else if (file.isFile()) result = file.delete(); } log.info(String.format("%s文件或文件夹, 路径为: %s, 结果为: %s", handleType, dir, Objects.isNull(result) ? "未执行" : (result ? "成功" : "失败"))); diff --git a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/common/DataExchangeController.java b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/common/DataExchangeController.java index 1bb5145..21d4175 100644 --- a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/common/DataExchangeController.java +++ b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/common/DataExchangeController.java @@ -117,6 +117,7 @@ public class DataExchangeController { * 计算图片相似度 * * @param theme 主题名 + * @param themeId 主题id * @param fid 服务器图片id * @param coverUrl 作品封面图地址 * @param itemId 作品id @@ -125,8 +126,8 @@ public class DataExchangeController { * @throws Exception */ @GetMapping("/calcSimilarity") - public Message calcSimilarity(String theme, String fid, String coverUrl, String account, String itemId, Integer type) throws Exception { - return success(commonBizService.validCover(theme, fid, coverUrl, account, itemId, type)); + public Message calcSimilarity(String theme, Long themeId, String fid, String coverUrl, String account, String itemId, Integer type) throws Exception { + return success(commonBizService.validCover(theme, themeId, fid, coverUrl, account, itemId, type)); } /** diff --git a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/task/OtherTask.java b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/task/OtherTask.java index 2769dc5..7b1e40b 100644 --- a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/task/OtherTask.java +++ b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/task/OtherTask.java @@ -32,7 +32,7 @@ public class OtherTask { /** * 每天都找已经停止抓数据7天及其更久的主题, 删除缓存封面图 */ - @Scheduled(fixedRate = 15 * 60 * 1000, initialDelay = 5 * 1000) + @Scheduled(fixedRate = 60 * 60 * 1000, initialDelay = 5 * 1000) public void deleteCoverFiles() { final List themeList = activityThemeService.lambdaQuery() .list() @@ -47,7 +47,10 @@ public class OtherTask { sb.append(tempDir); sb.append("activityTheme"); sb.append(File.separator); + sb.append(item.getId()); + sb.append("「"); sb.append(item.getTheme()); + sb.append("」"); String dirPath = sb.toString(); File file = new File(dirPath); if (file.isDirectory()) diff --git a/fw-dalaran-server/src/main/resources/application-local.yml b/fw-dalaran-server/src/main/resources/application-local.yml index 4481327..f3d0979 100644 --- a/fw-dalaran-server/src/main/resources/application-local.yml +++ b/fw-dalaran-server/src/main/resources/application-local.yml @@ -20,6 +20,6 @@ rocketmq: name-srv-addr: 172.26.154.169:9876 producer-group: ${spring.application.name} task: - switch: 'on' + switch: 'off' file-server-addr: 'http://testgate.feewee.cn/file/show?fid=' diff --git a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/CommonBizService.java b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/CommonBizService.java index fa5da6f..edab9a4 100644 --- a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/CommonBizService.java +++ b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/CommonBizService.java @@ -214,7 +214,7 @@ public class CommonBizService { .list(); for (ThemeFile themeFile : list) { try { - final BigDecimal coverSimilarity = this.validCover(activityTheme.getTheme(), themeFile.getFileId(), videoCover, accountNo, videoId, 1); + final BigDecimal coverSimilarity = this.validCover(activityTheme.getTheme(), themeFile.getThemeId(), themeFile.getFileId(), videoCover, accountNo, videoId, 1); if (validCover = coverSimilarity.compareTo(rate) >= 0) break; } catch (Exception e) { @@ -491,7 +491,7 @@ public class CommonBizService { .list(); for (ThemeFile themeFile : list) { try { - final BigDecimal coverSimilarity = this.validCover(activityTheme.getTheme(), themeFile.getFileId(), liveCover, accountNo, roomNo, 2); + final BigDecimal coverSimilarity = this.validCover(activityTheme.getTheme(), activityTheme.getId(), themeFile.getFileId(), liveCover, accountNo, roomNo, 2); if (validCover = coverSimilarity.compareTo(rate) >= 0) break; } catch (Exception e) { @@ -959,6 +959,7 @@ public class CommonBizService { * 验证封面匹配度 * * @param theme 主题名 + * @param themeId 主题id * @param fileId 文件id(主题配置指定封面图文件) * @param coverUrl 用户作品封面图地址 * @param account 账户号 @@ -967,20 +968,20 @@ public class CommonBizService { * @return 封面图匹配度 * @throws Exception */ - public BigDecimal validCover(String theme, String fileId, String coverUrl, String account, String itemId, Integer type) throws Exception { + public BigDecimal validCover(String theme, Long themeId, String fileId, String coverUrl, String account, String itemId, Integer type) throws Exception { int[][] imagePixArr1;// 图片1的像素数组 int[][] imagePixArr2;// 图片2的像素数组 - File imageFile1 = this.findLocalCacheImageTheme(theme, fileId); + File imageFile1 = this.findLocalCacheImageTheme(theme, themeId, fileId); imagePixArr1 = ImageUtils.readImagePixel(imageFile1); File imageFile2; - File localCacheImage = this.findLocalCacheImageUser(theme, account, itemId, type); + File localCacheImage = this.findLocalCacheImageUser(theme, themeId, account, itemId, type); if (Objects.nonNull(localCacheImage)) { imageFile2 = localCacheImage; } else { imageFile2 = ImageUtils.convertFileByUrl(coverUrl, itemId); String tempDir = common.getActivityThemeCoverDir(); File file = new File(ImageUtils.modifyResolution1(imageFile2.getPath(), - tempDir + "activityTheme" + File.separator + theme + File.separator + account + File.separator + (Objects.equals(type, 1) ? "video" : "live"), + tempDir + "activityTheme" + File.separator + themeId + "「" + theme + "」" + File.separator + account + File.separator + (Objects.equals(type, 1) ? "video" : "live"), "fw_theme_cover_" + itemId, 512, 512)); if (imageFile2.delete()) { @@ -996,13 +997,14 @@ public class CommonBizService { * 获取本地已下载的封面图(用户作品封面图) * * @param theme 主题名 + * @param themeId 主题id * @param account 账号 * @param itemId 视频id/直播间id * @param type 1:视频, 2:直播 */ - private File findLocalCacheImageUser(String theme, String account, String itemId, Integer type) { + private File findLocalCacheImageUser(String theme, Long themeId, String account, String itemId, Integer type) { String tempDir = common.getActivityThemeCoverDir(); - File file = new File(tempDir + File.separator + "activityTheme" + File.separator + theme + File.separator + account + File.separator + (Objects.equals(type, 1) ? "video" : "live")); + File file = new File(tempDir + File.separator + "activityTheme" + File.separator + themeId + "「" + theme + "」" + File.separator + account + File.separator + (Objects.equals(type, 1) ? "video" : "live")); if (!file.exists()) { boolean mkdirs = file.mkdirs(); if (mkdirs) @@ -1021,12 +1023,13 @@ public class CommonBizService { /** * 获取本地已下载的主题背景图 * - * @param theme 主题名 - * @param fileId 文件id(主题配置指定封面图文件) + * @param theme 主题名 + * @param themeId 主题id + * @param fileId 文件id(主题配置指定封面图文件) */ - private File findLocalCacheImageTheme(String theme, String fileId) { + private File findLocalCacheImageTheme(String theme, Long themeId, String fileId) { String tempDir = common.getActivityThemeCoverDir(); - File file = new File(tempDir + "activityTheme" + File.separator + theme + File.separator + "settingCover"); + File file = new File(tempDir + "activityTheme" + File.separator + themeId + "「" + theme + "」" + File.separator + "settingCover"); if (!file.exists()) { boolean mkdirs = file.mkdirs(); if (mkdirs) diff --git a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/ActivityThemeServiceImpl.java b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/ActivityThemeServiceImpl.java index 68d786d..3ae5bfc 100644 --- a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/ActivityThemeServiceImpl.java +++ b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/ActivityThemeServiceImpl.java @@ -99,7 +99,7 @@ public class ActivityThemeServiceImpl extends ServiceImpl 0; + return !shopIds1.isEmpty(); } } @@ -346,7 +346,7 @@ public class ActivityThemeServiceImpl extends ServiceImpl 0) + if (!fileList.isEmpty()) return themeFileService.saveBatch(fileList); return true; } @@ -365,7 +365,7 @@ public class ActivityThemeServiceImpl extends ServiceImpl