去掉不使用的功能

This commit is contained in:
yuxin-pc 2025-12-23 19:23:51 +08:00
parent 3cb5a02f03
commit 4de86e5f40
4 changed files with 23 additions and 134 deletions

View File

@ -16,18 +16,6 @@ import java.util.concurrent.Executors;
@Component @Component
public class Configuration { public class Configuration {
@Value("${es.ip}")
String esIp;
@Value("${es.port}")
Integer esPort;
@Value("${es.username}")
String esUsername;
@Value("${es.password}")
String esPassword;
@Bean @Bean
public JacksonJsonParser getJacksonParser() { public JacksonJsonParser getJacksonParser() {
return new JacksonJsonParser(); return new JacksonJsonParser();
@ -48,8 +36,4 @@ public class Configuration {
return Executors.newFixedThreadPool(4); return Executors.newFixedThreadPool(4);
} }
@Bean
public RestHighLevelClient esClient() {
return EsUtils.getElasticsearchClient(esIp, esPort, esUsername, esPassword);
}
} }

View File

@ -6,6 +6,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.json.JacksonJsonParser; import org.springframework.boot.json.JacksonJsonParser;
import org.springframework.cloud.stream.annotation.EnableBinding; import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener; import org.springframework.cloud.stream.annotation.StreamListener;
@ -21,6 +22,7 @@ import java.util.concurrent.Executors;
@Component @Component
@EnableBinding(FileDlBinding.class) @EnableBinding(FileDlBinding.class)
@ConditionalOnProperty(name = "switch.enable-file-dl-service", havingValue = "true", matchIfMissing = true)
public class FileDlService extends StreamService { public class FileDlService extends StreamService {
@Autowired @Autowired
@ -78,31 +80,14 @@ public class FileDlService extends StreamService {
} }
int dlResult = fileUtils.downloadFromUrl(fileURL, protoSavePath); int dlResult = fileUtils.downloadFromUrl(fileURL, protoSavePath);
if (dlResult == 1) { if (dlResult == 1) {
File transferPath = new File(transferBackupPath); File transferPath = new File(protoSavePath);
File[] files = transferPath.listFiles(); File[] files = transferPath.listFiles();
if (files != null && files.length > 0) { if (files != null && files.length > 0) {
for (File transferFile : files) { for (File transferFile : files) {
if (transferFile.getName().endsWith(".tar.gz")) { if (transferFile.getName().endsWith(".tar.gz")) {
if (transferFile.getName().startsWith("attach")) {
try {
fileUtils.UnzipTarGzip(transferFile.getAbsolutePath(), nginxPath);
logger.info("Unzip attachments " + transferFile.getName());
} catch (Exception e) {
logger.error("Unzip error!");
}
} else {
try {
fileUtils.UnzipTarGzip(transferFile.getAbsolutePath(), fileUnzipPath);
logger.info("Unzip " + transferFile.getName());
} catch (Exception e) {
logger.error("Unzip error!");
}
}
}
fileUtils.moveFileToBackupFolder(transferFile, keepBackupFile); fileUtils.moveFileToBackupFolder(transferFile, keepBackupFile);
} }
// Runnable upload2Ceph = () -> fileUtils.uploadToCeph(fileUnzipPath); }
// pool.execute(upload2Ceph);
} }
} else if (dlResult == 0) { } else if (dlResult == 0) {
logger.error("File " + fileName + " download failure"); logger.error("File " + fileName + " download failure");

View File

@ -12,12 +12,14 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.json.JacksonJsonParser; import org.springframework.boot.json.JacksonJsonParser;
import org.springframework.cloud.stream.annotation.EnableBinding; import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener; import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.support.MessageBuilder; import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -30,6 +32,7 @@ import java.util.Map;
@Component @Component
@EnableBinding(ProtobufBinding.class) @EnableBinding(ProtobufBinding.class)
@ConditionalOnProperty(name = "switch.enable-protobuf-service", havingValue = "true", matchIfMissing = true)
public class ProtobufService extends StreamService { public class ProtobufService extends StreamService {
@Autowired @Autowired
@ -41,9 +44,6 @@ public class ProtobufService extends StreamService {
@Value("${custom.proto_save_path}") @Value("${custom.proto_save_path}")
String protoSavePath; String protoSavePath;
@Value("${custom.transfer_backup_path}")
String transferBackupPath;
@Value("${custom.keep_backup_file}") @Value("${custom.keep_backup_file}")
String keepBackupFile; String keepBackupFile;
@ -55,7 +55,7 @@ public class ProtobufService extends StreamService {
private final Logger logger = LogManager.getLogger(ProtobufService.class.getName()); private final Logger logger = LogManager.getLogger(ProtobufService.class.getName());
@Autowired @Resource
private ProtobufBinding source; private ProtobufBinding source;
@Override @Override
@ -169,7 +169,7 @@ public class ProtobufService extends StreamService {
} }
logger.debug("protobuf done"); logger.debug("protobuf done");
// 转移备份目录的todist文件 // 转移备份目录的todist文件
File transferPath = new File(transferBackupPath); File transferPath = new File(protoSavePath);
File[] files = transferPath.listFiles(); File[] files = transferPath.listFiles();
if (files != null && files.length > 0) { if (files != null && files.length > 0) {
for (File transferFile : files) { for (File transferFile : files) {

View File

@ -37,99 +37,19 @@ public class AutoPatroller {
@Value("${custom.socialUpdateAPI}") @Value("${custom.socialUpdateAPI}")
String socialUpdateAPI; String socialUpdateAPI;
@Value("${es.ip}") // @Scheduled(cron = "0 45 0/3 * * *")
String esIp; // public void checkNewsSite() {
// checkWebsite("es_sitename", "es_carriertype", "news");
@Value("${es.port}") // }
Integer esPort; //
// @Scheduled(cron = "0 15 1/3 * * *")
@Value("${es.username}") // public void checkWechat() {
String esUsername; // checkSocial("es_authors", "es_carriertype", "wechat", "5");
// }
@Value("${es.password}") //
String esPassword; // @Scheduled(cron = "0 0 2/4 * * *")
// public void checkArticleSite() {
@Scheduled(cron = "0 45 0/3 * * *") // checkWebsite("es_sitename", "es_carriertype", "article");
public void checkNewsSite() { // }
checkWebsite("es_sitename", "es_carriertype", "news");
}
@Scheduled(cron = "0 15 1/3 * * *")
public void checkWechat() {
checkSocial("es_authors", "es_carriertype", "wechat", "5");
}
@Scheduled(cron = "0 0 2/4 * * *")
public void checkArticleSite() {
checkWebsite("es_sitename", "es_carriertype", "article");
}
public void checkWebsite(String aggFieldName, String queryFieldName, String queryFieldValue) {
try {
Map<String, SearchAggregation> searchAggregationMap = performAggregationSearch(
esIp, esPort, esUsername, esPassword, aggFieldName, queryFieldName, queryFieldValue);
JSONObject dataObject = new JSONObject();
dataObject.put("carrierType", queryFieldValue);
String rsp = HttpUtils.post(websiteQueryAPI, dataObject);
JSONObject rspObj = JSON.parseObject(rsp);
if (rspObj.getIntValue("code") == 200) {
JSONArray rspArr = rspObj.getJSONArray("content");
for (Object obj : rspArr) {
TargetWebsite targetWebsite = JSONObject.parseObject(obj.toString(), TargetWebsite.class);
String siteName = targetWebsite.getSiteName();
if (searchAggregationMap.containsKey(siteName)) {
SearchAggregation checkInfo = searchAggregationMap.get(siteName);
targetWebsite.setCheckTotalNum(checkInfo.getCount());
targetWebsite.setCheckLastTime(checkInfo.getLastTime());
targetWebsite.setCheckUpdateTime(new Date());
String updateRsp = HttpUtils.post(websiteUpdateAPI, targetWebsite);
JSONObject updateRspObj = JSONObject.parseObject(updateRsp);
if (updateRspObj.getIntValue("code") != 200) {
logger.warning("更新站点【" + siteName + "】巡检信息失败");
}
Thread.sleep(updateInterval);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
logger.info("站点巡检完毕");
}
public void checkSocial(String aggFieldName, String queryFieldName, String queryFieldValue, String socialTypeCode) {
try {
Map<String, SearchAggregation> searchAggregationMap = performAggregationSearch(
esIp, esPort, esUsername, esPassword, aggFieldName, queryFieldName, queryFieldValue);
TargetSocial postData = new TargetSocial();
postData.setUserFlag("0");
postData.setUserType(socialTypeCode);
String rsp = HttpUtils.post(socialQueryAPI, postData);
JSONObject rspObj = JSON.parseObject(rsp);
if (rspObj.getIntValue("code") == 200) {
JSONArray rspArr = rspObj.getJSONArray("content");
for (Object obj : rspArr) {
TargetSocial targetSocial = JSONObject.parseObject(obj.toString(), TargetSocial.class);
String userName = targetSocial.getUserName();
if (searchAggregationMap.containsKey(userName)) {
SearchAggregation checkInfo = searchAggregationMap.get(userName);
targetSocial.setCheckTotalNum(checkInfo.getCount());
targetSocial.setCheckLastTime(checkInfo.getLastTime());
targetSocial.setCheckUpdateTime(new Date());
String updateRsp = HttpUtils.post(socialUpdateAPI, targetSocial);
JSONObject updateRspObj = JSONObject.parseObject(updateRsp);
if (updateRspObj.getIntValue("code") != 200) {
logger.warning("更新账号【" + userName + "】巡检信息失败");
}
Thread.sleep(updateInterval);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
logger.info("社交帐号巡检完毕");
}
} }