diff --git a/pom.xml b/pom.xml index 220aab2..8eab379 100644 --- a/pom.xml +++ b/pom.xml @@ -119,6 +119,12 @@ vavr 0.10.4 + + org.springframework.boot + spring-boot-starter-test + ${spring-boot.version} + test + com.baomidou mybatis-plus-boot-starter @@ -236,6 +242,11 @@ easyexcel 3.3.4 + + junit + junit + test + diff --git a/src/main/java/com/project/base/config/ScheduledTaskProperties.java b/src/main/java/com/project/base/config/ScheduledTaskProperties.java index f818c8f..de823b5 100644 --- a/src/main/java/com/project/base/config/ScheduledTaskProperties.java +++ b/src/main/java/com/project/base/config/ScheduledTaskProperties.java @@ -9,6 +9,6 @@ import org.springframework.stereotype.Component; @Component @ConfigurationProperties(prefix = "scheduled-task") public class ScheduledTaskProperties { - private String owner = "dev"; + private String owner = "local"; } diff --git a/src/main/java/com/project/ding/config/DingProperties.java b/src/main/java/com/project/ding/config/DingProperties.java index 205c186..48a3703 100644 --- a/src/main/java/com/project/ding/config/DingProperties.java +++ b/src/main/java/com/project/ding/config/DingProperties.java @@ -12,4 +12,5 @@ public class DingProperties { private String appSecret; private String agentId; private String corpId; + private String noticeUrlPrefix; } \ No newline at end of file diff --git a/src/main/java/com/project/question/domain/job/InventoryCheckJob.java b/src/main/java/com/project/question/domain/job/InventoryCheckJob.java index 3510853..9cf0adf 100644 --- a/src/main/java/com/project/question/domain/job/InventoryCheckJob.java +++ b/src/main/java/com/project/question/domain/job/InventoryCheckJob.java @@ -47,7 +47,7 @@ public class InventoryCheckJob { @Scheduled(fixedRate = 600000) public void run() { - if ("dev".equalsIgnoreCase(taskProps.getOwner())) { + if ("local".equalsIgnoreCase(taskProps.getOwner())) { return; } diff --git a/src/main/java/com/project/task/domain/job/TaskNotifyJob.java b/src/main/java/com/project/task/domain/job/TaskNotifyJob.java index d433971..ce6da76 100644 --- a/src/main/java/com/project/task/domain/job/TaskNotifyJob.java +++ b/src/main/java/com/project/task/domain/job/TaskNotifyJob.java @@ -25,7 +25,7 @@ public class TaskNotifyJob { */ @Scheduled(cron = "0 0 9 * * ?") public void run() { - if ("dev".equalsIgnoreCase(taskProps.getOwner())) { + if ("local".equalsIgnoreCase(taskProps.getOwner())) { return; } log.info(">>> [每日通知任务] 启动执行..."); diff --git a/src/main/java/com/project/task/domain/service/impl/NotifyTaskDomainServiceImpl.java b/src/main/java/com/project/task/domain/service/impl/NotifyTaskDomainServiceImpl.java index 3b3a657..a8473c7 100644 --- a/src/main/java/com/project/task/domain/service/impl/NotifyTaskDomainServiceImpl.java +++ b/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.DtMessage; 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.entity.TaskEntity; import com.project.task.domain.entity.TaskUserEntity; @@ -36,6 +37,9 @@ public class NotifyTaskDomainServiceImpl implements NotifyTaskDomainService { @Autowired private DtService dtService; + @Autowired + private DingProperties dingTalkProperties; + private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日"); @@ -97,7 +101,10 @@ public class NotifyTaskDomainServiceImpl implements NotifyTaskDomainService { .markdown(markdown.toString()) .singleTitle("查看详情") // 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(); try { DtCorpConversationMsgSendResult result = dtService.getCorpConversationMsgService().send(message); @@ -139,7 +146,10 @@ public class NotifyTaskDomainServiceImpl implements NotifyTaskDomainService { .markdown(markdown.toString()) .singleTitle("查看详情") // 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(); try { DtCorpConversationMsgSendResult result = dtService.getCorpConversationMsgService().send(message); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 6054a68..1f28312 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -73,6 +73,7 @@ ding: appSecret: nK104mgXPbkCWjX1I-EcYiubjM0FJAYcfqBKPkVcyvrBsLMF9XK1g9Qd_QVOndcK agentId: 4283077101 corpId: ding13d71da66ad91ff0f5bf40eda33b7ba0 + noticeUrlPrefix: https://107pm707566hq.vicp.fun/ai-evaluator algo: clusterUrl: /semantic-cluster baseUrl: http://172.16.204.50:8002 @@ -86,3 +87,5 @@ question: generation: # 限流速率:每秒允许的API请求数 rate-limit: 20 +scheduled-task: + owner: test \ No newline at end of file diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index 3ffc312..c798768 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -70,6 +70,7 @@ ding: appSecret: nK104mgXPbkCWjX1I-EcYiubjM0FJAYcfqBKPkVcyvrBsLMF9XK1g9Qd_QVOndcK agentId: 4283077101 corpId: ding13d71da66ad91ff0f5bf40eda33b7ba0 + noticeUrlPrefix: https://107pm707566hq.vicp.fun/ai-evaluator-test/ algo: clusterUrl: /algo/semantic-cluster baseUrl: https://107pm707566hq.vicp.fun diff --git a/src/test/java/com/project/exam/domain/service/impl/NotifyExamRecordDomainServiceImplTest.java b/src/test/java/com/project/exam/domain/service/impl/NotifyExamRecordDomainServiceImplTest.java new file mode 100644 index 0000000..693816a --- /dev/null +++ b/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) { +// +// } +// +// } +// +//} \ No newline at end of file