Commit b41411964d979920822700564af0a469247cf36e

Authored by 王明元
2 parents eda94563 1b21938b

Merge branch 'dev' into test

fw-dalaran-server/pom.xml
... ... @@ -140,6 +140,11 @@
140 140 <artifactId>fw-dalaran-domain</artifactId>
141 141 <version>1.0.0</version>
142 142 </dependency>
  143 + <dependency>
  144 + <groupId>org.hibernate.validator</groupId>
  145 + <artifactId>hibernate-validator</artifactId>
  146 + <version>6.0.11.Final</version>
  147 + </dependency>
143 148  
144 149 </dependencies>
145 150  
... ... @@ -205,6 +210,12 @@
205 210 </properties>
206 211 </profile>
207 212 <profile>
  213 + <id>local</id>
  214 + <properties>
  215 + <activatedProfiles>local</activatedProfiles>
  216 + </properties>
  217 + </profile>
  218 + <profile>
208 219 <id>test</id>
209 220 <properties>
210 221 <activatedProfiles>test</activatedProfiles>
... ...
fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/app/OtherController.java
... ... @@ -97,7 +97,7 @@ public class OtherController {
97 97 handleType = "删除";
98 98 if (file.isDirectory())
99 99 result = common.deleteAllFile(dir, file);
100   - else if(file.isFile())
  100 + else if (file.isFile())
101 101 result = file.delete();
102 102 }
103 103 log.info(String.format("%s文件或文件夹, 路径为: %s, 结果为: %s", handleType, dir, Objects.isNull(result) ? "未执行" : (result ? "成功" : "失败")));
... ...
fw-dalaran-server/src/main/java/cn/fw/dalaran/server/controller/common/DataExchangeController.java
... ... @@ -117,6 +117,7 @@ public class DataExchangeController {
117 117 * 计算图片相似度
118 118 *
119 119 * @param theme 主题名
  120 + * @param themeId 主题id
120 121 * @param fid 服务器图片id
121 122 * @param coverUrl 作品封面图地址
122 123 * @param itemId 作品id
... ... @@ -125,8 +126,8 @@ public class DataExchangeController {
125 126 * @throws Exception
126 127 */
127 128 @GetMapping("/calcSimilarity")
128   - public Message<BigDecimal> calcSimilarity(String theme, String fid, String coverUrl, String account, String itemId, Integer type) throws Exception {
129   - return success(commonBizService.validCover(theme, fid, coverUrl, account, itemId, type));
  129 + public Message<BigDecimal> calcSimilarity(String theme, Long themeId, String fid, String coverUrl, String account, String itemId, Integer type) throws Exception {
  130 + return success(commonBizService.validCover(theme, themeId, fid, coverUrl, account, itemId, type));
130 131 }
131 132  
132 133 /**
... ...
fw-dalaran-server/src/main/java/cn/fw/dalaran/server/task/OtherTask.java
... ... @@ -32,7 +32,7 @@ public class OtherTask {
32 32 /**
33 33 * 每天都找已经停止抓数据7天及其更久的主题, 删除缓存封面图
34 34 */
35   - @Scheduled(fixedRate = 15 * 60 * 1000, initialDelay = 5 * 1000)
  35 + @Scheduled(fixedRate = 60 * 60 * 1000, initialDelay = 5 * 1000)
36 36 public void deleteCoverFiles() {
37 37 final List<ActivityTheme> themeList = activityThemeService.lambdaQuery()
38 38 .list()
... ... @@ -47,7 +47,10 @@ public class OtherTask {
47 47 sb.append(tempDir);
48 48 sb.append("activityTheme");
49 49 sb.append(File.separator);
  50 + sb.append(item.getId());
  51 + sb.append("「");
50 52 sb.append(item.getTheme());
  53 + sb.append("」");
51 54 String dirPath = sb.toString();
52 55 File file = new File(dirPath);
53 56 if (file.isDirectory())
... ...
fw-dalaran-server/src/main/resources/application-local.yml
... ... @@ -17,9 +17,14 @@ rocketmq:
17 17 name-server: 172.26.154.169:9876
18 18 producer:
19 19 group: ${spring.application.name}
20   - name-srv-addr: 192.168.0.230:9876
  20 + name-srv-addr: 172.26.154.169:9876
21 21 producer-group: ${spring.application.name}
22 22 task:
23   - switch: 'on'
  23 + switch: 'off'
  24 +jedis:
  25 + pool:
  26 + host: 172.26.154.169
  27 + pwd: fw@test@redis
  28 + port: 6378
24 29  
25 30 file-server-addr: 'http://testgate.feewee.cn/file/show?fid='
... ...
fw-dalaran-server/src/main/resources/application-prd.yml
... ... @@ -13,6 +13,7 @@ spring:
13 13 password: Feewee_Data2_Root123
14 14 redis:
15 15 host: 192.168.0.101
  16 + port: 6379
16 17 url:
17 18 http-file-url: https://gate.feewee.cn/file
18 19  
... ... @@ -29,6 +30,7 @@ fastdfs:
29 30 jedis:
30 31 pool:
31 32 host: 192.168.0.101
  33 + port: 6379
32 34 logging:
33 35 file:
34 36 max-history: 15
... ...
fw-dalaran-server/src/main/resources/application-test.yml
... ... @@ -26,19 +26,9 @@ rocketmq:
26 26 name-server: 172.26.154.169:9876
27 27 producer:
28 28 group: ${spring.application.name}
29   - name-srv-addr: 192.168.0.230:9876
  29 + name-srv-addr: 172.26.154.169:9876
30 30 producer-group: ${spring.application.name}
31 31  
32   -fastdfs:
33   - charset: UTF-8
34   - connectTimeout: 2
35   - group: dalarandfs
36   - networkTimeout: 30
37   - port: 8080
38   - secretKey: FastDFS1234567890
39   - servers: 192.168.0.230:22122
40   - token: 'no'
41   -
42 32 jedis:
43 33 pool:
44 34 host: 172.26.154.169
... ...
fw-dalaran-server/src/main/resources/application.yml
... ... @@ -8,7 +8,6 @@ spring:
8 8 key-prefix: 'dalaran:locker'
9 9 custom:
10 10 global-prefix: 'dalaran'
11   -
12 11 cloud:
13 12 nacos:
14 13 discovery:
... ... @@ -34,7 +33,6 @@ spring:
34 33 active: cache,${activatedProfiles}
35 34 redis:
36 35 host: 172.26.154.169
37   - port: 6378
38 36 lettuce:
39 37 pool:
40 38 max-active: 20
... ... @@ -54,15 +52,6 @@ auth:
54 52 key: bN7DVjFMJPcoWDcR
55 53 ignore:
56 54 start-with: /user/*,/role/*,/user/login
57   -fastdfs:
58   - charset: UTF-8
59   - connectTimeout: 2
60   - group: dalarandfs
61   - networkTimeout: 30
62   - port: 8080
63   - secretKey: FastDFS1234567890
64   - servers: 192.168.0.230:22122
65   - token: 'no'
66 55  
67 56 hystrix:
68 57 command:
... ... @@ -92,8 +81,7 @@ jedis:
92 81 test-on-borrow: false
93 82 test-on-return: false
94 83 test-while-idle: true
95   - host: 192.168.0.8
96   - port: 6379
  84 + host: 172.26.154.169
97 85 db: 4
98 86 mybatis-plus:
99 87 configuration:
... ...
fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/CommonBizService.java
... ... @@ -214,7 +214,7 @@ public class CommonBizService {
214 214 .list();
215 215 for (ThemeFile themeFile : list) {
216 216 try {
217   - final BigDecimal coverSimilarity = this.validCover(activityTheme.getTheme(), themeFile.getFileId(), videoCover, accountNo, videoId, 1);
  217 + final BigDecimal coverSimilarity = this.validCover(activityTheme.getTheme(), themeFile.getThemeId(), themeFile.getFileId(), videoCover, accountNo, videoId, 1);
218 218 if (validCover = coverSimilarity.compareTo(rate) >= 0)
219 219 break;
220 220 } catch (Exception e) {
... ... @@ -491,7 +491,7 @@ public class CommonBizService {
491 491 .list();
492 492 for (ThemeFile themeFile : list) {
493 493 try {
494   - final BigDecimal coverSimilarity = this.validCover(activityTheme.getTheme(), themeFile.getFileId(), liveCover, accountNo, roomNo, 2);
  494 + final BigDecimal coverSimilarity = this.validCover(activityTheme.getTheme(), activityTheme.getId(), themeFile.getFileId(), liveCover, accountNo, roomNo, 2);
495 495 if (validCover = coverSimilarity.compareTo(rate) >= 0)
496 496 break;
497 497 } catch (Exception e) {
... ... @@ -959,6 +959,7 @@ public class CommonBizService {
959 959 * 验证封面匹配度
960 960 *
961 961 * @param theme 主题名
  962 + * @param themeId 主题id
962 963 * @param fileId 文件id(主题配置指定封面图文件)
963 964 * @param coverUrl 用户作品封面图地址
964 965 * @param account 账户号
... ... @@ -967,20 +968,20 @@ public class CommonBizService {
967 968 * @return 封面图匹配度
968 969 * @throws Exception
969 970 */
970   - public BigDecimal validCover(String theme, String fileId, String coverUrl, String account, String itemId, Integer type) throws Exception {
  971 + public BigDecimal validCover(String theme, Long themeId, String fileId, String coverUrl, String account, String itemId, Integer type) throws Exception {
971 972 int[][] imagePixArr1;// 图片1的像素数组
972 973 int[][] imagePixArr2;// 图片2的像素数组
973   - File imageFile1 = this.findLocalCacheImageTheme(theme, fileId);
  974 + File imageFile1 = this.findLocalCacheImageTheme(theme, themeId, fileId);
974 975 imagePixArr1 = ImageUtils.readImagePixel(imageFile1);
975 976 File imageFile2;
976   - File localCacheImage = this.findLocalCacheImageUser(theme, account, itemId, type);
  977 + File localCacheImage = this.findLocalCacheImageUser(theme, themeId, account, itemId, type);
977 978 if (Objects.nonNull(localCacheImage)) {
978 979 imageFile2 = localCacheImage;
979 980 } else {
980 981 imageFile2 = ImageUtils.convertFileByUrl(coverUrl, itemId);
981 982 String tempDir = common.getActivityThemeCoverDir();
982 983 File file = new File(ImageUtils.modifyResolution1(imageFile2.getPath(),
983   - tempDir + "activityTheme" + File.separator + theme + File.separator + account + File.separator + (Objects.equals(type, 1) ? "video" : "live"),
  984 + tempDir + "activityTheme" + File.separator + themeId + "「" + theme + "」" + File.separator + account + File.separator + (Objects.equals(type, 1) ? "video" : "live"),
984 985 "fw_theme_cover_" + itemId,
985 986 512, 512));
986 987 if (imageFile2.delete()) {
... ... @@ -996,13 +997,14 @@ public class CommonBizService {
996 997 * 获取本地已下载的封面图(用户作品封面图)
997 998 *
998 999 * @param theme 主题名
  1000 + * @param themeId 主题id
999 1001 * @param account 账号
1000 1002 * @param itemId 视频id/直播间id
1001 1003 * @param type 1:视频, 2:直播
1002 1004 */
1003   - private File findLocalCacheImageUser(String theme, String account, String itemId, Integer type) {
  1005 + private File findLocalCacheImageUser(String theme, Long themeId, String account, String itemId, Integer type) {
1004 1006 String tempDir = common.getActivityThemeCoverDir();
1005   - File file = new File(tempDir + File.separator + "activityTheme" + File.separator + theme + File.separator + account + File.separator + (Objects.equals(type, 1) ? "video" : "live"));
  1007 + File file = new File(tempDir + File.separator + "activityTheme" + File.separator + themeId + "「" + theme + "」" + File.separator + account + File.separator + (Objects.equals(type, 1) ? "video" : "live"));
1006 1008 if (!file.exists()) {
1007 1009 boolean mkdirs = file.mkdirs();
1008 1010 if (mkdirs)
... ... @@ -1021,12 +1023,13 @@ public class CommonBizService {
1021 1023 /**
1022 1024 * 获取本地已下载的主题背景图
1023 1025 *
1024   - * @param theme 主题名
1025   - * @param fileId 文件id(主题配置指定封面图文件)
  1026 + * @param theme 主题名
  1027 + * @param themeId 主题id
  1028 + * @param fileId 文件id(主题配置指定封面图文件)
1026 1029 */
1027   - private File findLocalCacheImageTheme(String theme, String fileId) {
  1030 + private File findLocalCacheImageTheme(String theme, Long themeId, String fileId) {
1028 1031 String tempDir = common.getActivityThemeCoverDir();
1029   - File file = new File(tempDir + "activityTheme" + File.separator + theme + File.separator + "settingCover");
  1032 + File file = new File(tempDir + "activityTheme" + File.separator + themeId + "「" + theme + "」" + File.separator + "settingCover");
1030 1033 if (!file.exists()) {
1031 1034 boolean mkdirs = file.mkdirs();
1032 1035 if (mkdirs)
... ...
fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/ActivityThemeServiceImpl.java
... ... @@ -99,7 +99,7 @@ public class ActivityThemeServiceImpl extends ServiceImpl&lt;ActivityThemeDao, Acti
99 99 return true;
100 100 } else {
101 101 shopIds1.retainAll(shopIds2);
102   - return shopIds1.size() > 0;
  102 + return !shopIds1.isEmpty();
103 103 }
104 104 }
105 105  
... ... @@ -346,7 +346,7 @@ public class ActivityThemeServiceImpl extends ServiceImpl&lt;ActivityThemeDao, Acti
346 346 .type(item.getType())
347 347 .build())
348 348 .collect(Collectors.toList());
349   - if (fileList.size() > 0)
  349 + if (!fileList.isEmpty())
350 350 return themeFileService.saveBatch(fileList);
351 351 return true;
352 352 }
... ... @@ -365,7 +365,7 @@ public class ActivityThemeServiceImpl extends ServiceImpl&lt;ActivityThemeDao, Acti
365 365 String fileId = item.getFid();
366 366 File downloadFile = ImageUtils.convertFileByUrl(serverAddr + fileId, fileId);
367 367 ImageUtils.modifyResolution1(downloadFile.getPath(),
368   - tempDir + "activityTheme" + File.separator + activityTheme.getTheme() + File.separator + "settingCover",
  368 + tempDir + "activityTheme" + File.separator + activityTheme.getId() + "「" + activityTheme.getTheme() + "」" + File.separator + "settingCover",
369 369 "fw_theme_cover_" + fileId,
370 370 512, 512);
371 371 boolean result = downloadFile.delete();
... ...
fw-dalaran-service/src/main/test/example/ImageListener.java
... ... @@ -19,13 +19,13 @@ public class ImageListener implements ActionListener {
19 19 }
20 20  
21 21 public ImageListener() throws Exception {
22   - File imageFile1 = ImageUtils.convertFileByUrl("https://p2.a.yximgs.com/upic/2022/07/02/18/BMjAyMjA3MDIxODQyNDVfMTA2MjU5OTU5MV83ODE2MDkwNTkzMF8yXzM=_B50b9301c2d61ea0faf60a882a60cd336.jpg?tag=1-1656909189-nil-0-b9qwvimwnk-c1383d641aa55e8e&clientCacheKey=3x62tedv27b8a39.jpg&di=6f711692&bp=10000");
23   - File imageFile2 = ImageUtils.convertFileByUrl("http://gate.feewee.cn/file/show?fid=f19fd7afd5504b0f919b1f806bbe0a2a");
  22 + File imageFile1 = ImageUtils.convertFileByUrl("https://gate.feewee.cn/file/show?fid=e1d71b45dd0e4d73bde25afc3e260de5");
  23 + File imageFile2 = ImageUtils.convertFileByUrl("https://gate.feewee.cn/file/show?fid=7dfedbed8996443584b6b2221b79235e");
24 24 //File imageFile2 = ImageUtils.convertFileByUrl("https://p2.a.yximgs.com/upic/2022/01/20/20/BMjAyMjAxMjAyMDEyMTZfNDcwOTM0NDgyXzY1MzMwMDA5Mjk0XzJfMw==_B0296c8ed5afa94b9b7a06dd1612c3ecb.jpg?tag=1-1642748356-nil-0-ndrgo4aid6-21e0d82706b2e935&clientCacheKey=3x4xb3uvxtpibvc.jpg&di=abd4f314&bp=10000");
25 25 /*File imageFile1 = new File("C:\\Users\\wmy3969\\Desktop\\2.png");
26 26 File imageFile2 = new File("C:\\Users\\wmy3969\\Desktop\\2022.4.23-4.30短视频背景封面jpg\\春风十里焕新鲸喜\\1.png");*/
27   - imagePixArr1 = ImageUtils.readImagePixel(new File(ImageUtils.modifyResolution(imageFile1.getPath(), "C:\\Users\\wmy3969\\Desktop", 256, 512)));
28   - imagePixArr2 = ImageUtils.readImagePixel(new File(ImageUtils.modifyResolution(imageFile2.getPath(), "C:\\Users\\wmy3969\\Desktop", 256, 512)));
  27 + imagePixArr1 = ImageUtils.readImagePixel(new File(ImageUtils.modifyResolution(imageFile1.getPath(), "C:\\Users\\wmy3969\\Desktop", 512, 512)));
  28 + imagePixArr2 = ImageUtils.readImagePixel(new File(ImageUtils.modifyResolution(imageFile2.getPath(), "C:\\Users\\wmy3969\\Desktop", 512, 512)));
29 29 /*imagePixArr1 = ImageUtils.readImagePixel(imageFile1);
30 30 imagePixArr2 = ImageUtils.readImagePixel(imageFile2);*/
31 31 }
... ...