Browse Source

配置文件修改

master
luoweijian 1 month ago
parent
commit
27ce990557
  1. 11
      pom.xml
  2. 2
      src/main/java/com/project/base/config/ScheduledTaskProperties.java
  3. 1
      src/main/java/com/project/ding/config/DingProperties.java
  4. 2
      src/main/java/com/project/question/domain/job/InventoryCheckJob.java
  5. 2
      src/main/java/com/project/task/domain/job/TaskNotifyJob.java
  6. 14
      src/main/java/com/project/task/domain/service/impl/NotifyTaskDomainServiceImpl.java
  7. 3
      src/main/resources/application-dev.yml
  8. 1
      src/main/resources/application-test.yml
  9. 59
      src/test/java/com/project/exam/domain/service/impl/NotifyExamRecordDomainServiceImplTest.java

11
pom.xml

@ -119,6 +119,12 @@
<artifactId>vavr</artifactId> <artifactId>vavr</artifactId>
<version>0.10.4</version> <version>0.10.4</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring-boot.version}</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId> <artifactId>mybatis-plus-boot-starter</artifactId>
@ -236,6 +242,11 @@
<artifactId>easyexcel</artifactId> <artifactId>easyexcel</artifactId>
<version>3.3.4</version> <version>3.3.4</version>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

2
src/main/java/com/project/base/config/ScheduledTaskProperties.java

@ -9,6 +9,6 @@ import org.springframework.stereotype.Component;
@Component @Component
@ConfigurationProperties(prefix = "scheduled-task") @ConfigurationProperties(prefix = "scheduled-task")
public class ScheduledTaskProperties { public class ScheduledTaskProperties {
private String owner = "dev"; private String owner = "local";
} }

1
src/main/java/com/project/ding/config/DingProperties.java

@ -12,4 +12,5 @@ public class DingProperties {
private String appSecret; private String appSecret;
private String agentId; private String agentId;
private String corpId; private String corpId;
private String noticeUrlPrefix;
} }

2
src/main/java/com/project/question/domain/job/InventoryCheckJob.java

@ -47,7 +47,7 @@ public class InventoryCheckJob {
@Scheduled(fixedRate = 600000) @Scheduled(fixedRate = 600000)
public void run() { public void run() {
if ("dev".equalsIgnoreCase(taskProps.getOwner())) { if ("local".equalsIgnoreCase(taskProps.getOwner())) {
return; return;
} }

2
src/main/java/com/project/task/domain/job/TaskNotifyJob.java

@ -25,7 +25,7 @@ public class TaskNotifyJob {
*/ */
@Scheduled(cron = "0 0 9 * * ?") @Scheduled(cron = "0 0 9 * * ?")
public void run() { public void run() {
if ("dev".equalsIgnoreCase(taskProps.getOwner())) { if ("local".equalsIgnoreCase(taskProps.getOwner())) {
return; return;
} }
log.info(">>> [每日通知任务] 启动执行..."); log.info(">>> [每日通知任务] 启动执行...");

14
src/main/java/com/project/task/domain/service/impl/NotifyTaskDomainServiceImpl.java

@ -9,6 +9,7 @@ import com.github.tingyugetc520.ali.dingtalk.bean.message.DtCorpConversationMess
import com.github.tingyugetc520.ali.dingtalk.bean.message.DtCorpConversationMsgSendResult; import com.github.tingyugetc520.ali.dingtalk.bean.message.DtCorpConversationMsgSendResult;
import com.github.tingyugetc520.ali.dingtalk.bean.message.DtMessage; import com.github.tingyugetc520.ali.dingtalk.bean.message.DtMessage;
import com.github.tingyugetc520.ali.dingtalk.error.DtErrorException; import com.github.tingyugetc520.ali.dingtalk.error.DtErrorException;
import com.project.ding.config.DingProperties;
import com.project.task.domain.dto.TaskDTO; import com.project.task.domain.dto.TaskDTO;
import com.project.task.domain.entity.TaskEntity; import com.project.task.domain.entity.TaskEntity;
import com.project.task.domain.entity.TaskUserEntity; import com.project.task.domain.entity.TaskUserEntity;
@ -36,6 +37,9 @@ public class NotifyTaskDomainServiceImpl implements NotifyTaskDomainService {
@Autowired @Autowired
private DtService dtService; private DtService dtService;
@Autowired
private DingProperties dingTalkProperties;
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日"); private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
@ -97,7 +101,10 @@ public class NotifyTaskDomainServiceImpl implements NotifyTaskDomainService {
.markdown(markdown.toString()) .markdown(markdown.toString())
.singleTitle("查看详情") .singleTitle("查看详情")
// todo 修改为对应页面 // todo 修改为对应页面
.singleUrl("https://www.baidu.com/").build()) .singleUrl(dingTalkProperties.getNoticeUrlPrefix() +
"/ai-evaluator/examTasks?dd_nav_translucent=true&dd_full_screen=true&dd_nav_bgcolor=33E0EEFF&" +
"corpid=" + dingTalkProperties.getCorpId() +
"&id=" + taskDTO.getId()).build())
.build(); .build();
try { try {
DtCorpConversationMsgSendResult result = dtService.getCorpConversationMsgService().send(message); DtCorpConversationMsgSendResult result = dtService.getCorpConversationMsgService().send(message);
@ -139,7 +146,10 @@ public class NotifyTaskDomainServiceImpl implements NotifyTaskDomainService {
.markdown(markdown.toString()) .markdown(markdown.toString())
.singleTitle("查看详情") .singleTitle("查看详情")
// todo 修改为对应页面 // todo 修改为对应页面
.singleUrl("https://www.baidu.com/").build()) .singleUrl(dingTalkProperties.getNoticeUrlPrefix() +
"/examTasks?dd_nav_translucent=true&dd_full_screen=true&dd_nav_bgcolor=33E0EEFF&" +
"corpid=" + dingTalkProperties.getCorpId() +
"&id=" + taskDTO.getId()).build())
.build(); .build();
try { try {
DtCorpConversationMsgSendResult result = dtService.getCorpConversationMsgService().send(message); DtCorpConversationMsgSendResult result = dtService.getCorpConversationMsgService().send(message);

3
src/main/resources/application-dev.yml

@ -73,6 +73,7 @@ ding:
appSecret: nK104mgXPbkCWjX1I-EcYiubjM0FJAYcfqBKPkVcyvrBsLMF9XK1g9Qd_QVOndcK appSecret: nK104mgXPbkCWjX1I-EcYiubjM0FJAYcfqBKPkVcyvrBsLMF9XK1g9Qd_QVOndcK
agentId: 4283077101 agentId: 4283077101
corpId: ding13d71da66ad91ff0f5bf40eda33b7ba0 corpId: ding13d71da66ad91ff0f5bf40eda33b7ba0
noticeUrlPrefix: https://107pm707566hq.vicp.fun/ai-evaluator
algo: algo:
clusterUrl: /semantic-cluster clusterUrl: /semantic-cluster
baseUrl: http://172.16.204.50:8002 baseUrl: http://172.16.204.50:8002
@ -86,3 +87,5 @@ question:
generation: generation:
# 限流速率:每秒允许的API请求数 # 限流速率:每秒允许的API请求数
rate-limit: 20 rate-limit: 20
scheduled-task:
owner: test

1
src/main/resources/application-test.yml

@ -70,6 +70,7 @@ ding:
appSecret: nK104mgXPbkCWjX1I-EcYiubjM0FJAYcfqBKPkVcyvrBsLMF9XK1g9Qd_QVOndcK appSecret: nK104mgXPbkCWjX1I-EcYiubjM0FJAYcfqBKPkVcyvrBsLMF9XK1g9Qd_QVOndcK
agentId: 4283077101 agentId: 4283077101
corpId: ding13d71da66ad91ff0f5bf40eda33b7ba0 corpId: ding13d71da66ad91ff0f5bf40eda33b7ba0
noticeUrlPrefix: https://107pm707566hq.vicp.fun/ai-evaluator-test/
algo: algo:
clusterUrl: /algo/semantic-cluster clusterUrl: /algo/semantic-cluster
baseUrl: https://107pm707566hq.vicp.fun baseUrl: https://107pm707566hq.vicp.fun

59
src/test/java/com/project/exam/domain/service/impl/NotifyExamRecordDomainServiceImplTest.java

@ -0,0 +1,59 @@
//package com.project.exam.domain.service.impl;
//
//
//import com.github.tingyugetc520.ali.dingtalk.api.DtService;
//import com.github.tingyugetc520.ali.dingtalk.bean.message.DtCorpConversationMessage;
//import com.github.tingyugetc520.ali.dingtalk.bean.message.DtCorpConversationMsgSendResult;
//import com.github.tingyugetc520.ali.dingtalk.bean.message.DtMessage;
//import org.junit.Test;
//import org.junit.runner.RunWith;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.test.context.junit4.SpringRunner;
//
//import java.util.Collections;
//
//@SpringBootTest
//@RunWith(SpringRunner.class) // 必须添加这一行
//
//public class NotifyExamRecordDomainServiceImplTest {
// @Autowired
// private DtService dtService;
// @Test
// public void notifyExamRecord() {
// System.out.println("111");
// String userId = "01231011386731976125,01291369685624598595";
//
// // 不阻碍正常业务
// try {
// String markdown = String.format("### 【%s】考试成绩已公布,请留意查收\n\n", "" +
// String.format("考试成绩:%.2f\n\n",0.1) +
// String.format("考试结果:%s\n\n", Boolean.FALSE ? "考试通过" : "考试不通过") +
// String.format("%s\n\n", Boolean.TRUE ? "恭喜考试通过,请继续保持!可以自行查看考试结果" :
// "遗憾考试不通过,请再接再厉!可以查看考试结果或尝试重新补考"));
// DtCorpConversationMessage message = DtCorpConversationMessage.builder()
// .agentId(dtService.getDtConfigStorage().getAgentId())
// .userIds(Collections.singletonList(userId))
// .msg(DtMessage.ACTIONCARD()
// .title("产品知识考核")
// .markdown(markdown)
// .singleTitle("查看详情")
// // todo 修改为对应页面
// .singleUrl("http://172.16.25.182:5173/examResult/?" +
// "dd_nav_translucent=true&dd_full_screen=true&dd_nav_bgcolor=33E0EEFF&" +
// "corpid=ding13d71da66ad91ff0f5bf40eda33b7ba0&id=688755610295992320&index=1").build())
// .build();
// DtCorpConversationMsgSendResult result = dtService.getCorpConversationMsgService().send(message);
// if (result.getErrCode() == 0) {
//
// } else {
//
// }
//
// } catch (Exception e) {
//
// }
//
// }
//
//}
Loading…
Cancel
Save