Parcourir la source

new: 统计关键字频率

lwh il y a 6 jours
Parent
commit
7390bdba7d

+ 106 - 4
pig-marketing/pig-marketing-biz/src/main/java/com/pig4cloud/pig/marketing/service/impl/MarketingAppsServiceImpl.java

@@ -467,11 +467,13 @@ public class MarketingAppsServiceImpl implements MarketingAppsService {
 	 * 从lafa服务获取应用列表
 	 * @return 应用列表
 	 */
-	public List<MarketingApps> getAppsFromLafaService(){
+	public List<MarketingApps> getAppsFromLafaService2(){
 
 		// 构建请求参数
 		JSONObject requestParam = new JSONObject();
 		requestParam.put("accessKey", accessKey);
+		requestParam.put("page", "1");
+		requestParam.put("size", "20");
 		// 创建OkHttp客户端
 		OkHttpClient client = new OkHttpClient();
 
@@ -489,19 +491,31 @@ public class MarketingAppsServiceImpl implements MarketingAppsService {
 			// 发送请求并获取响应
 			Response response = client.newCall(request).execute();
 			ArrayList<MarketingApps> appList = new ArrayList<>();
+			log.info("获取应用列表请求地址: {}", getAppListUrl);
+			log.info("获取应用列表请求参数: {}", requestParam);
+			log.info("获取应用列表请求响应数据-------: {}", response);
 			if (response.isSuccessful() && response.body() != null) {
 				JSONObject responseBody = JSONObject.parseObject(response.body().string());
-				JSONArray apps = responseBody.getJSONArray("apps");
+				JSONArray apps = responseBody.getJSONArray("content");
 				apps.forEach(item -> {
 					JSONObject app = (JSONObject) item;
 					MarketingApps marketingApps = new MarketingApps();
+
+//					marketingApps.setAppId(app.getString("id"));
+//					marketingApps.setAppName(app.getString("name"));
+//					marketingApps.setAppImg(app.getString("img"));
+//					marketingApps.setBundle(app.getString("bundle"));
+//					marketingApps.setAppUrl("https://"+app.getString("download_url")+"/"+marketingApps.getAppId());
+//					marketingApps.setBackupUrl("https://"+app.getString("backup_url")+"/"+marketingApps.getAppId());
+//					marketingApps.setDomainType(app.getInteger("type"));
+
 					marketingApps.setAppId(app.getString("id"));
 					marketingApps.setAppName(app.getString("name"));
 					marketingApps.setAppImg(app.getString("img"));
-					marketingApps.setBundle(app.getString("bundle"));
+					marketingApps.setBundle(app.getString("id"));
 					marketingApps.setAppUrl("https://"+app.getString("download_url")+"/"+marketingApps.getAppId());
 					marketingApps.setBackupUrl("https://"+app.getString("backup_url")+"/"+marketingApps.getAppId());
-					marketingApps.setDomainType(app.getInteger("type"));
+					marketingApps.setDomainType(1);
 					appList.add(marketingApps);
 				});
 				return appList;
@@ -517,6 +531,94 @@ public class MarketingAppsServiceImpl implements MarketingAppsService {
 		}
 	}
 
+
+	/**
+	 * 从lafa服务获取应用列表
+	 * @return 应用列表
+	 */
+	public List<MarketingApps> getAppsFromLafaService(){
+		ArrayList<MarketingApps> allAppList = new ArrayList<>();
+		int currentPage = 1;
+		int pageSize = 40;
+		boolean hasMoreData = true;
+
+		// 创建OkHttp客户端
+		OkHttpClient client = new OkHttpClient();
+
+		while (hasMoreData) {
+			// 构建请求参数
+			JSONObject requestParam = new JSONObject();
+			requestParam.put("accessKey", accessKey);
+			requestParam.put("page", String.valueOf(currentPage));
+			requestParam.put("size", String.valueOf(pageSize));
+
+			// 构建POST请求体
+			MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
+			RequestBody body = RequestBody.create(mediaType, requestParam.toJSONString());
+
+			// 构建请求
+			Request request = new Request.Builder()
+					.url(getAppListUrl)
+					.post(body)
+					.build();
+
+			try {
+				// 发送请求并获取响应
+				Response response = client.newCall(request).execute();
+				log.info("获取应用列表请求地址: {}", getAppListUrl);
+				log.info("获取应用列表请求参数: {}", requestParam);
+				log.info("获取应用列表请求响应数据-------: {}", response);
+
+				if (response.isSuccessful() && response.body() != null) {
+					JSONObject responseBody = JSONObject.parseObject(response.body().string());
+					JSONArray apps = responseBody.getJSONArray("content");
+
+					// 检查是否还有数据
+					if (apps == null || apps.isEmpty()) {
+						hasMoreData = false;
+						break;
+					}
+
+					// 处理当前页的应用数据
+					apps.forEach(item -> {
+						JSONObject app = (JSONObject) item;
+						MarketingApps marketingApps = new MarketingApps();
+
+						marketingApps.setAppId(app.getString("id"));
+						marketingApps.setAppName(app.getString("name"));
+						marketingApps.setAppImg(app.getString("img"));
+						marketingApps.setBundle(app.getString("id"));
+						marketingApps.setAppUrl("https://"+app.getString("download_url")+"/"+marketingApps.getAppId());
+						marketingApps.setBackupUrl("https://"+app.getString("backup_url")+"/"+marketingApps.getAppId());
+						marketingApps.setDomainType(1);
+						allAppList.add(marketingApps);
+					});
+
+					// 检查是否还有下一页
+					// 如果当前页返回的数据少于pageSize,说明已经是最后一页
+					if (apps.size() < pageSize) {
+						hasMoreData = false;
+					} else {
+						currentPage++;
+					}
+
+					log.info("第{}页获取到{}条应用数据,累计获取{}条", currentPage, apps.size(), allAppList.size());
+
+				} else {
+					// 响应失败
+					log.error("请求失败,响应码: {}", response.code());
+					hasMoreData = false;
+				}
+			} catch (IOException e) {
+				// 网络请求异常
+				log.error("网络请求异常: {}", e.getLocalizedMessage());
+				hasMoreData = false;
+			}
+		}
+
+		log.info("总共获取到{}条应用数据", allAppList.size());
+		return allAppList;
+	}
 	/**
 	 * 对比两个应用是否相同
 	 * @param newApp 新数据

+ 54 - 19
pom.xml

@@ -298,35 +298,70 @@
 	</build>
 
 	<profiles>
+<!--		<profile>-->
+<!--			<id>cloud</id>-->
+<!--			<properties>-->
+<!--				&lt;!&ndash; 环境标识,需要与配置文件的名称相对应 &ndash;&gt;-->
+<!--				<profiles.active>dev</profiles.active>-->
+<!--				<nacos.address>http://192.168.3.17:8848</nacos.address>-->
+<!--				<nacos.namespace>${profiles.active}</nacos.namespace>-->
+<!--				<nacos.username>nacos</nacos.username>-->
+<!--				<nacos.password>nacos</nacos.password>-->
+<!--			</properties>-->
+<!--			<activation>-->
+<!--				&lt;!&ndash; 默认环境 &ndash;&gt;-->
+<!--				<activeByDefault>true</activeByDefault>-->
+<!--			</activation>-->
+<!--		</profile>-->
+
+<!--		<profile>-->
+<!--			<id>cloud</id>-->
+<!--			<properties>-->
+<!--				&lt;!&ndash; 环境标识,需要与配置文件的名称相对应 &ndash;&gt;-->
+<!--				<profiles.active>prod</profiles.active>-->
+<!--				<nacos.address>http://43.199.205.45:8848</nacos.address>-->
+<!--				<nacos.namespace>${profiles.active}</nacos.namespace>-->
+<!--				<nacos.username>nacos</nacos.username>-->
+<!--				<nacos.password>ckztSZtHFD</nacos.password>-->
+<!--			</properties>-->
+<!--			<activation>-->
+<!--				&lt;!&ndash; 默认环境 &ndash;&gt;-->
+<!--				<activeByDefault>true</activeByDefault>-->
+<!--			</activation>-->
+<!--		</profile>-->
+
+
 		<profile>
-			<id>cloud</id>
+			<id>test</id>
 			<properties>
 				<!-- 环境标识,需要与配置文件的名称相对应 -->
 				<profiles.active>dev</profiles.active>
-				<nacos.address>http://127.0.0.1:8848</nacos.address>
-				<nacos.namespace>${profiles.active}</nacos.namespace>
+				<nacos.address>http://43.199.205.45:8848</nacos.address>
+				<nacos.namespace>75810fa8-f894-4980-bf60-e95ead645787</nacos.namespace>
 				<nacos.username>nacos</nacos.username>
-				<nacos.password>nacos</nacos.password>
+				<nacos.password>ckztSZtHFD</nacos.password>
 			</properties>
 			<activation>
 				<!-- 默认环境 -->
 				<activeByDefault>true</activeByDefault>
 			</activation>
 		</profile>
-		<profile>
-			<id>test</id>
-			<properties>
-				<!-- 环境标识,需要与配置文件的名称相对应 -->
-				<profiles.active>test</profiles.active>
-				<nacos.address>http://192.168.10.101:8848</nacos.address>
-				<nacos.namespace>${profiles.active}</nacos.namespace>
-				<nacos.username></nacos.username>
-				<nacos.password></nacos.password>
-			</properties>
-			<activation>
-				<!-- 默认环境 -->
-				<activeByDefault>false</activeByDefault>
-			</activation>
-		</profile>
+
+
+<!--		<profile>-->
+<!--			<id>test</id>-->
+<!--			<properties>-->
+<!--				&lt;!&ndash; 环境标识,需要与配置文件的名称相对应 &ndash;&gt;-->
+<!--				<profiles.active>test</profiles.active>-->
+<!--				<nacos.address>http://192.168.10.101:8848</nacos.address>-->
+<!--				<nacos.namespace>${profiles.active}</nacos.namespace>-->
+<!--				<nacos.username></nacos.username>-->
+<!--				<nacos.password></nacos.password>-->
+<!--			</properties>-->
+<!--			<activation>-->
+<!--				&lt;!&ndash; 默认环境 &ndash;&gt;-->
+<!--				<activeByDefault>true</activeByDefault>-->
+<!--			</activation>-->
+<!--		</profile>-->
 	</profiles>
 </project>