perf:消息配置
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -35,7 +35,7 @@
|
||||
<dependency>
|
||||
<groupId>com.xiang</groupId>
|
||||
<artifactId>xservice-message-starter</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.xiang</groupId>
|
||||
|
||||
@@ -18,9 +18,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
"com.xiang.xservice.xb.repository"
|
||||
})
|
||||
@ConfigurationPropertiesScan(basePackages = {
|
||||
"com.xiang.xservice.fwd.config",
|
||||
"com.xiang.xservice.xb.config",
|
||||
"com.xiang.xservice.glados.config",
|
||||
"com.xiang.xservice.config"
|
||||
})
|
||||
public class ServiceScriptApplication {
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.xiang.xservice.domain.service;
|
||||
|
||||
import com.xiang.xservice.basic.xservice.dingTalk.service.DingTalkService;
|
||||
import com.xiang.xservice.config.DingTalkRobotScriptConfig;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-08-07 10:30
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DingTalkScriptDomainService {
|
||||
|
||||
private final DingTalkService dingTalkService;
|
||||
private final DingTalkRobotScriptConfig dingTalkRobotScriptConfig;
|
||||
|
||||
/**
|
||||
* 发送脚本消息
|
||||
* @param msg 消息
|
||||
*/
|
||||
public void sendScriptMsg(String msg) {
|
||||
try {
|
||||
dingTalkService.sendRobotMessage(dingTalkRobotScriptConfig.getSecret(), dingTalkRobotScriptConfig.getToken(),
|
||||
dingTalkRobotScriptConfig.getUsers(), msg);
|
||||
} catch (Exception e) {
|
||||
log.error("信息发送异常, 信息:{}", msg, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,9 @@ import com.aliyun.alidns20150109.models.DescribeSubDomainRecordsResponse;
|
||||
import com.aliyun.alidns20150109.models.DescribeSubDomainRecordsResponseBody;
|
||||
import com.aliyun.alidns20150109.models.UpdateDomainRecordRequest;
|
||||
import com.aliyun.teaopenapi.models.Config;
|
||||
import com.xiang.xservice.basic.xservice.dingTalk.service.DingTalkService;
|
||||
import com.xiang.xservice.domain.config.AliyunDnsPropertyConfig;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -38,10 +36,7 @@ public class IDomainServiceImpl implements IDomainService {
|
||||
private final AliyunDnsPropertyConfig aliyunDnsPropertyConfig;
|
||||
private static final String TYPE = "A";
|
||||
|
||||
private final DingTalkService dingTalkService;
|
||||
@Value("${DingTalk.chatId}")
|
||||
private String chatId;
|
||||
|
||||
private final DingTalkScriptDomainService dingTalkService;
|
||||
@Override
|
||||
public void dynamicDomainAnalysis(String publicIp) throws Exception {
|
||||
Client client = createClient();
|
||||
@@ -58,14 +53,14 @@ public class IDomainServiceImpl implements IDomainService {
|
||||
if (records.isEmpty()) {
|
||||
log.info("未找到记录,添加记录..., ip:{}", publicIp);
|
||||
addDnsRecord(client, publicIp, rr);
|
||||
dingTalkService.sendRobotMessage("动态解析公网ip成功,域名:" + rr + "." + DOMAIN_NAME + ", 新ip:" + publicIp);
|
||||
dingTalkService.sendScriptMsg("动态解析公网ip成功,域名:" + rr + "." + DOMAIN_NAME + ", 新ip:" + publicIp);
|
||||
} else {
|
||||
String recordId = records.get(0).getRecordId();
|
||||
String currentValue = records.get(0).getValue();
|
||||
if (!publicIp.equals(currentValue)) {
|
||||
log.info("IP变更,更新记录...,ip:{}", publicIp);
|
||||
updateDnsRecord(client, recordId, publicIp, rr);
|
||||
dingTalkService.sendRobotMessage("动态解析公网ip成功,域名:" + rr + "." + DOMAIN_NAME + ", 新ip:" + publicIp);
|
||||
dingTalkService.sendScriptMsg("动态解析公网ip成功,域名:" + rr + "." + DOMAIN_NAME + ", 新ip:" + publicIp);
|
||||
} else {
|
||||
log.info("ip未变更,无需修改,ip:{}", publicIp);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import com.xiang.xservice.fwd.mapper.FwdAudienceConfigMapper;
|
||||
import com.xiang.xservice.fwd.mapper.FwdPerformConfigMapper;
|
||||
import com.xiang.xservice.fwd.mapper.FwdPerformProjectInfoMapper;
|
||||
import com.xiang.xservice.fwd.mapper.FwdUserConfigMapper;
|
||||
import com.xiang.xservice.fwd.service.DingTalkScriptMsgService;
|
||||
import com.xiang.xservice.fwd.service.DingTalkScriptFWDService;
|
||||
import com.xiang.xservice.fwd.service.IPerformService;
|
||||
import com.xiang.xservice.fwd.service.IPerformServiceHttp;
|
||||
import com.xiang.xservice.schedule.core.DynamicTaskScheduler;
|
||||
@@ -31,7 +31,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -62,16 +61,13 @@ public class FwdImportantMsgJob {
|
||||
private final FwdPerformProjectInfoMapper performProjectInfoMapper;
|
||||
private final FwdPerformConfigMapper performConfigMapper;
|
||||
private final DynamicTaskScheduler dynamicTaskScheduler;
|
||||
private final DingTalkScriptMsgService dingTalkScriptMsgService;
|
||||
private final DingTalkScriptFWDService dingTalkScriptFWDService;
|
||||
private final FwdUserConfigMapper fwdUserConfigMapper;
|
||||
private final FwdAudienceConfigMapper fwdAudienceConfigMapper;
|
||||
private final IPerformService iPerformService;
|
||||
private final IDynamicTaskSchedulerService dynamicTaskSchedulerService;
|
||||
private final IPerformServiceHttp iPerformServiceHttp;
|
||||
|
||||
@Value("${DingTalk.chatId}")
|
||||
private String chatId;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
log.info("xs-fwd任务调度系统初始化!");
|
||||
@@ -132,7 +128,7 @@ public class FwdImportantMsgJob {
|
||||
savaTask(data, taskId, params);
|
||||
}
|
||||
msg.append("请注意进行数据库配置的更改!");
|
||||
dingTalkScriptMsgService.sendScriptMsg(msg.toString());
|
||||
dingTalkScriptFWDService.sendScriptMsg(msg.toString());
|
||||
log.info("【芬玩岛】演唱会预售定时任务结束!time:{}", System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@@ -229,7 +225,7 @@ public class FwdImportantMsgJob {
|
||||
}
|
||||
}
|
||||
});
|
||||
dingTalkScriptMsgService.sendScriptMsg(msg.toString());
|
||||
dingTalkScriptFWDService.sendScriptMsg(msg.toString());
|
||||
}
|
||||
|
||||
private void savaTask(FPerformProjectInfo data, long taskId, Map<String, Object> params) {
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.xiang.xservice.fwd.server;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.xiang.xservice.basic.common.resp.Result;
|
||||
import com.xiang.xservice.basic.xservice.dingTalk.service.DingTalkService;
|
||||
import com.xiang.xservice.fwd.service.DingTalkScriptFWDService;
|
||||
import com.xiang.xservice.fwd.service.IPerformService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -24,7 +24,7 @@ import java.util.Map;
|
||||
public class FwdUserController {
|
||||
|
||||
private final IPerformService performService;
|
||||
private final DingTalkService dingTalkService;
|
||||
private final DingTalkScriptFWDService dingTalkService;
|
||||
|
||||
@GetMapping("/token")
|
||||
public Result<Void> updateUserTokenFromHttpProxy(@RequestParam Map<String, String> params) {
|
||||
@@ -35,7 +35,7 @@ public class FwdUserController {
|
||||
if (b) {
|
||||
String msg = "用户:" + name + "的token更新成功!";
|
||||
try {
|
||||
dingTalkService.sendRobotMessage(msg);
|
||||
dingTalkService.sendScriptMsg(msg);
|
||||
} catch (Exception e) {
|
||||
log.error("消息发送失败", e);
|
||||
return Result.error("消息发送失败");
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.springframework.stereotype.Service;
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DingTalkScriptMsgService {
|
||||
public class DingTalkScriptFWDService {
|
||||
|
||||
private final DingTalkService dingTalkService;
|
||||
private final DingTalkRobotScriptConfig dingTalkRobotConfig;
|
||||
@@ -12,14 +12,13 @@ import com.xiang.xservice.fwd.mapper.FwdPerformConfigMapper;
|
||||
import com.xiang.xservice.fwd.mapper.FwdPerformProjectInfoMapper;
|
||||
import com.xiang.xservice.fwd.mapper.FwdPerformSeatInfoMapper;
|
||||
import com.xiang.xservice.fwd.mapper.FwdUserConfigMapper;
|
||||
import com.xiang.xservice.fwd.service.DingTalkScriptMsgService;
|
||||
import com.xiang.xservice.fwd.service.DingTalkScriptFWDService;
|
||||
import com.xiang.xservice.fwd.service.IPerformService;
|
||||
import com.xiang.xservice.fwd.service.IPerformServiceHttp;
|
||||
import com.xiang.xservice.http.helper.HttpRequestHelper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -45,10 +44,8 @@ public class PerformServiceImpl implements IPerformService {
|
||||
private final FwdPerformProjectInfoMapper fwdPerformProjectInfoMapper;
|
||||
private final FwdPerformConfigMapper fwdPerformConfigMapper;
|
||||
private final IPerformServiceHttp performServiceHttp;
|
||||
private final DingTalkScriptMsgService dingTalkService;
|
||||
private final DingTalkScriptFWDService dingTalkService;
|
||||
private final FwdUserConfigMapper fwdUserConfigMapper;
|
||||
@Value("${DingTalk.chatId}")
|
||||
private String chatId;
|
||||
private final HttpRequestHelper httpRequestHelper;
|
||||
private final ExecutorService es =
|
||||
new ThreadPoolExecutor(
|
||||
|
||||
@@ -20,7 +20,6 @@ public class GladosCheckInJob {
|
||||
private final GLaDOSService glaDOSService;
|
||||
|
||||
@Scheduled(cron = "0 0 8,16 1/1 * ?")
|
||||
// @Scheduled(cron = "0 0/1 * * * ?")
|
||||
public void checkInJon() {
|
||||
log.info("[job] Glados Check In Job start, time:{}", LocalDateTime.now());
|
||||
glaDOSService.checkIn();
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.springframework.stereotype.Service;
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DingTalkScriptMsgService {
|
||||
public class DingTalkScriptGladosService {
|
||||
|
||||
private final DingTalkService dingTalkService;
|
||||
private final DingTalkRobotScriptConfig dingTalkRobotScriptConfig;
|
||||
@@ -11,7 +11,6 @@ import com.xiang.xservice.glados.repository.GladosMapper;
|
||||
import com.xiang.xservice.xb.entity.pojo.User;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -32,13 +31,7 @@ public class GLaDOSServiceImpl implements GLaDOSService{
|
||||
|
||||
private final GladosMapper gladosMapper;
|
||||
|
||||
private final DingTalkScriptMsgService dingTalkService;
|
||||
|
||||
@Value("${DingTalk.userList}")
|
||||
private String userList;
|
||||
|
||||
@Value("${DingTalk.chatId}")
|
||||
private String chatId;
|
||||
private final DingTalkScriptGladosService dingTalkService;
|
||||
|
||||
/**
|
||||
* 签到
|
||||
|
||||
@@ -33,7 +33,7 @@ public class JntyzxServiceImpl implements JntyzxService{
|
||||
|
||||
private final DingTalkService dingTalkService;
|
||||
|
||||
@Value("${DingTalk.chatId}")
|
||||
@Value("${dingtalk.chatId}")
|
||||
private String chatId;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,16 +2,15 @@ package com.xiang.xservice.xb.schedule.xb;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.xiang.xservice.basic.xservice.dingTalk.service.DingTalkService;
|
||||
import com.xiang.xservice.xb.entity.pojo.xb.XbFundCount;
|
||||
import com.xiang.xservice.xb.entity.pojo.xb.XbFundList;
|
||||
import com.xiang.xservice.xb.entity.response.xbyj.fund.FundList;
|
||||
import com.xiang.xservice.xb.service.DingTalkRobotService;
|
||||
import com.xiang.xservice.xb.service.FundService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -37,9 +36,7 @@ import java.util.stream.Collectors;
|
||||
public class FundCountJob {
|
||||
|
||||
private final FundService fundService;
|
||||
private final DingTalkService dingTalkService;
|
||||
@Value("${DingTalk.chatId}")
|
||||
private String chatId;
|
||||
private final DingTalkRobotService dingTalkService;
|
||||
@Scheduled(cron = "0 0 22 * * ?")
|
||||
public void countFundJob() {
|
||||
// 周六周日过滤
|
||||
@@ -96,7 +93,7 @@ public class FundCountJob {
|
||||
sb.append("【").append(fundCounts.get(0).getName()).append("】本周平均涨跌幅为:").append(avg).append("\n");
|
||||
});
|
||||
if (StringUtils.isNotBlank(sb)) {
|
||||
dingTalkService.sendChatMessage(chatId, sb.toString());
|
||||
dingTalkService.sendXbMsg(sb.toString());
|
||||
}
|
||||
log.info("==========================[基金统计] 基金本周涨跌幅消息发送定时任务结束!==========================");
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -59,108 +58,9 @@ public class FundInfoQueryJob {
|
||||
new ThreadPoolExecutor.AbortPolicy());
|
||||
@Value("${xiaobei.codeArr}")
|
||||
private String codeArr;
|
||||
@Value("${DingTalk.chatId}")
|
||||
@Value("${dingtalk.chatId}")
|
||||
private String chatId;
|
||||
|
||||
/**
|
||||
* 基金增长定时任务查询
|
||||
* 半个小时一次 9点开始到3.30结束
|
||||
*/
|
||||
// @Scheduled(cron = "0 1,31 9,10,11,13,14 * * ? ")
|
||||
public void queryFundJob() throws Exception {
|
||||
// 周六周日过滤
|
||||
if (Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SATURDAY) ||
|
||||
Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SUNDAY)) {
|
||||
return;
|
||||
}
|
||||
log.info("==========================[基金查询] 基金查询定时任务启动!==========================");
|
||||
List<FundMessage> result = queryFund(1);
|
||||
if (CollectionUtils.isEmpty(result)) {
|
||||
return;
|
||||
}
|
||||
log.info("查询的基金涨跌幅数据:{}", JSONObject.toJSONString(result));
|
||||
result = result.stream().sorted(Comparator.comparing(FundMessage::getChange)).collect(Collectors.toList());
|
||||
StringBuilder sb = new StringBuilder("今天的A股行情:");
|
||||
for (FundMessage fundMessage : result) {
|
||||
sb.append("基金名称:")
|
||||
.append(fundMessage.getName())
|
||||
.append("于")
|
||||
.append(fundMessage.getUpdate())
|
||||
.append("更新涨跌幅:")
|
||||
.append(fundMessage.getChange()
|
||||
.multiply(new BigDecimal("100"))
|
||||
.setScale(2, RoundingMode.HALF_UP).toString())
|
||||
.append("%\n");
|
||||
}
|
||||
dingTalkService.sendChatMessage(chatId, sb.toString());
|
||||
log.info("==========================[基金查询] 基金查询定时任务结束!==========================");
|
||||
}
|
||||
/**
|
||||
* 美股基金每日早上9点消息一次
|
||||
*/
|
||||
// @Scheduled(cron = "0 0 9 * * ? ")
|
||||
public void queryFundJob3() throws Exception {
|
||||
// 周六周日过滤
|
||||
if (Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SATURDAY) ||
|
||||
Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SUNDAY)) {
|
||||
return;
|
||||
}
|
||||
log.info("==========================[基金查询] 基金查询定时任务启动!==========================");
|
||||
List<FundMessage> result = queryFund(3);
|
||||
if (CollectionUtils.isEmpty(result)) {
|
||||
return;
|
||||
}
|
||||
log.info("查询的美股基金涨跌幅数据:{}", JSONObject.toJSONString(result));
|
||||
result = result.stream().sorted(Comparator.comparing(FundMessage::getChange)).collect(Collectors.toList());
|
||||
StringBuilder sb = new StringBuilder("今天的美股行情:\n");
|
||||
for (FundMessage fundMessage : result) {
|
||||
sb.append("基金名称:")
|
||||
.append(fundMessage.getName())
|
||||
.append("于")
|
||||
.append(fundMessage.getUpdate())
|
||||
.append("更新涨跌幅:")
|
||||
.append(fundMessage.getChange()
|
||||
.multiply(new BigDecimal("100"))
|
||||
.setScale(2, RoundingMode.HALF_UP).toString())
|
||||
.append("%\n");
|
||||
}
|
||||
dingTalkService.sendChatMessage(chatId, sb.toString());
|
||||
log.info("==========================[基金查询] 基金查询定时任务结束!==========================");
|
||||
}
|
||||
/**
|
||||
* 港股基金增长定时任务查询
|
||||
* 半个小时一次 9点开始到3.30结束
|
||||
*/
|
||||
// @Scheduled(cron = "0 1,31 9,10,11,13,14,15 * * ? ")
|
||||
public void queryFundJob2() throws Exception {
|
||||
// 周六周日过滤
|
||||
if (Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SATURDAY) ||
|
||||
Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SUNDAY)) {
|
||||
return;
|
||||
}
|
||||
log.info("==========================[基金查询] 基金查询定时任务启动!==========================");
|
||||
List<FundMessage> result = queryFund(2);
|
||||
if (CollectionUtils.isEmpty(result)) {
|
||||
return;
|
||||
}
|
||||
log.info("查询的港股基金涨跌幅数据:{}", JSONObject.toJSONString(result));
|
||||
result = result.stream().sorted(Comparator.comparing(FundMessage::getChange)).collect(Collectors.toList());
|
||||
StringBuilder sb = new StringBuilder("今天的港股行情:\n");
|
||||
for (FundMessage fundMessage : result) {
|
||||
sb.append("基金名称:")
|
||||
.append(fundMessage.getName())
|
||||
.append("于")
|
||||
.append(fundMessage.getUpdate())
|
||||
.append("更新涨跌幅:")
|
||||
.append(fundMessage.getChange()
|
||||
.multiply(new BigDecimal("100"))
|
||||
.setScale(2, RoundingMode.HALF_UP).toString())
|
||||
.append("%\n");
|
||||
}
|
||||
dingTalkService.sendChatMessage(chatId, sb.toString());
|
||||
log.info("==========================[基金查询] 基金查询定时任务结束!==========================");
|
||||
}
|
||||
|
||||
/**
|
||||
* 基金涨跌幅5分钟超过2%重点通知
|
||||
*/
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
package com.xiang.xservice.xb.schedule.xb;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.xiang.xservice.basic.xservice.dingTalk.service.DingTalkService;
|
||||
import com.xiang.xservice.xb.entity.pojo.xb.XbFundList;
|
||||
import com.xiang.xservice.xb.entity.response.xbyj.fund.FundList;
|
||||
import com.xiang.xservice.xb.service.DingTalkRobotService;
|
||||
import com.xiang.xservice.xb.service.FundService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
@@ -32,18 +33,18 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class FundMsgReportJob {
|
||||
|
||||
private final FundService fundService;
|
||||
private final DingTalkService dingTalkService;
|
||||
@Value("${DingTalk.chatId}")
|
||||
private String chatId;
|
||||
private final DingTalkRobotService dingTalkService;
|
||||
private static final Integer TYPE_A = 1;
|
||||
private static final Integer TYPE_M = 3;
|
||||
private static final Integer TYPE_G = 2;
|
||||
|
||||
@Scheduled(cron = "0 1,31 9,10,11,13,14 * * ?")
|
||||
@PostMapping("/asdasda")
|
||||
public void fundReport4A() {
|
||||
log.info("===========A股基金变化通知!===========");
|
||||
// 周六周日过滤
|
||||
@@ -67,11 +68,7 @@ public class FundMsgReportJob {
|
||||
log.info("http查询基金信息:{}", JSON.toJSONString(funds));
|
||||
StringBuilder msg = new StringBuilder(date).append("===》A股基金变化通知:\n");
|
||||
buildMsg(funds, fundMap, msg);
|
||||
try {
|
||||
dingTalkService.sendChatMessage(chatId, msg.toString());
|
||||
} catch (Exception e) {
|
||||
log.error("钉钉消息通知异常.", e);
|
||||
}
|
||||
dingTalkService.sendXbMsg(msg.toString());
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 1,31 9,10,11,13,14,15 * * ?")
|
||||
@@ -98,11 +95,7 @@ public class FundMsgReportJob {
|
||||
log.info("http查询港股基金信息:{}", JSON.toJSONString(funds));
|
||||
StringBuilder msg = new StringBuilder(date).append("===》港股基金变化通知:\n");
|
||||
buildMsg(funds, fundMap, msg);
|
||||
try {
|
||||
dingTalkService.sendChatMessage(chatId, msg.toString());
|
||||
} catch (Exception e) {
|
||||
log.error("钉钉消息通知异常.", e);
|
||||
}
|
||||
dingTalkService.sendXbMsg(msg.toString());
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0 9 * * ?")
|
||||
@@ -129,11 +122,7 @@ public class FundMsgReportJob {
|
||||
log.info("http查询美股基金信息:{}", JSON.toJSONString(funds));
|
||||
StringBuilder msg = new StringBuilder(date).append("===》美股基金变化通知:\n");
|
||||
buildMsg(funds, fundMap, msg);
|
||||
try {
|
||||
dingTalkService.sendChatMessage(chatId, msg.toString());
|
||||
} catch (Exception e) {
|
||||
log.error("钉钉消息通知异常.", e);
|
||||
}
|
||||
dingTalkService.sendXbMsg(msg.toString());
|
||||
}
|
||||
|
||||
private static void buildMsg(List<FundList> funds, Map<String, XbFundList> fundMap, StringBuilder msg) {
|
||||
|
||||
@@ -1,8 +1,31 @@
|
||||
package com.xiang.xservice.xb.service;
|
||||
|
||||
import com.xiang.xservice.basic.xservice.dingTalk.service.DingTalkService;
|
||||
import com.xiang.xservice.config.DingTalkRobotXbConfig;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-08-07 11:02
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class DingTalkRobotService {
|
||||
private final DingTalkService dingTalkService;
|
||||
private final DingTalkRobotXbConfig dingTalkRobotConfig;
|
||||
|
||||
/**
|
||||
* 发送脚本消息
|
||||
* @param msg 消息
|
||||
*/
|
||||
public void sendXbMsg(String msg) {
|
||||
try {
|
||||
dingTalkService.sendRobotMessage(dingTalkRobotConfig.getSecret(), dingTalkRobotConfig.getToken(), dingTalkRobotConfig.getUsers(), msg);
|
||||
} catch (Exception e) {
|
||||
log.error("信息发送异常, 信息:{}", msg, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user