feat(sj_1.3.0-beta1): 定时任务新增告警通知场景

This commit is contained in:
wodeyangzipingpingwuqi 2024-12-07 17:47:52 +08:00
parent 1e7856f2da
commit 2b22acb21c
9 changed files with 5675 additions and 5638 deletions

File diff suppressed because it is too large Load Diff

View File

@ -52,18 +52,21 @@ export const retryNotifyScene: Record<Api.NotifyConfig.RetryNotifyScene, App.I18
3: 'page.notifyConfig.retryNotifyScene.clientReportError',
4: 'page.notifyConfig.retryNotifyScene.clientComponentError',
5: 'page.notifyConfig.retryNotifyScene.retryTaskReachThreshold',
6: 'page.notifyConfig.retryNotifyScene.retryTaskEnterDeadLetter'
6: 'page.notifyConfig.retryNotifyScene.retryTaskEnterDeadLetter',
7: 'page.notifyConfig.retryNotifyScene.retryNoClientNodesError'
};
export const retryNotifySceneOptions = transformRecordToNumberOption(retryNotifyScene);
export const jobNotifyScene: Record<Api.NotifyConfig.JobNotifyScene, App.I18n.I18nKey> = {
1: 'page.notifyConfig.jobNotifyScene.jobTaskError',
2: 'page.notifyConfig.jobNotifyScene.jobClientError'
2: 'page.notifyConfig.jobNotifyScene.jobClientError',
3: 'page.notifyConfig.jobNotifyScene.jobNoClientNodesError'
};
export const jobNotifySceneOptions = transformRecordToNumberOption(jobNotifyScene);
export const workflowNotifyScene: Record<Api.NotifyConfig.WorkflowNotifyScene, App.I18n.I18nKey> = {
2: 'page.notifyConfig.workflowNotifyScene.workflowClientError',
3: 'page.notifyConfig.workflowNotifyScene.workNoClientNodesError',
100: 'page.notifyConfig.workflowNotifyScene.workTaskError'
};
export const workflowNotifySceneOptions = transformRecordToNumberOption(workflowNotifyScene);

View File

@ -533,6 +533,7 @@ const local: App.I18n.Schema = {
title: 'Alarm Notify List',
groupName: 'Group name',
businessName: 'Business ID',
notifyName: 'Notify name',
notifyStatus: 'State',
notifyType: 'Notify type',
notifyScene: 'Notify scene',
@ -543,13 +544,13 @@ const local: App.I18n.Schema = {
job: 'Job',
workflow: 'Workflow',
form: {
businessId: 'Please select Business ID',
description: 'Please enter Describe',
notifyType: 'Please select Notification type',
notifyAttribute: 'Please enter notify attribute',
notifyScene: 'Please select Notification scene',
groupName: 'Please select Group name',
notifyThreshold: 'Please enter Notification threshold',
notifyName: 'Please enter name',
notifyStatus: 'Please select State',
systemTaskType: 'Please enter task type',
notifyRecipient: 'Please enter recipient',
@ -567,15 +568,18 @@ const local: App.I18n.Schema = {
clientReportError: 'Client report error',
clientComponentError: 'Client component error',
retryTaskReachThreshold: 'Retry task reach threshold',
retryTaskEnterDeadLetter: 'Retry task enter dead letter'
retryTaskEnterDeadLetter: 'Retry task enter dead letter',
retryNoClientNodesError: 'Retry task no client node'
},
jobNotifyScene: {
jobTaskError: 'Task execute error',
jobClientError: 'Client execute error'
jobClientError: 'Client execute error',
jobNoClientNodesError: 'Job No Client execute error'
},
workflowNotifyScene: {
workTaskError: 'Workflow task execute error',
workflowClientError: 'Client execute error'
workflowClientError: 'Client execute error',
workNoClientNodesError: 'Workflow No Client execute error',
workTaskError: 'Workflow task execute error'
},
notifyRecipient: 'Notify recipient',
rateLimiterStatus: 'Rate limiter status',

View File

@ -541,6 +541,7 @@ const local: App.I18n.Schema = {
title: '告警通知列表',
groupName: '组名称',
businessName: '业务ID',
notifyName: '告警通知名称',
notifyStatus: '通知状态',
notifyType: '通知类型',
notifyScene: '通知场景',
@ -551,7 +552,7 @@ const local: App.I18n.Schema = {
job: '定时任务',
workflow: '工作流',
form: {
businessId: '请选择业务ID',
notifyName: '请选择告警通知名称',
description: '请输入描述',
notifyType: '请选择通知类型',
notifyAttribute: '请求输入通知属性',
@ -575,15 +576,18 @@ const local: App.I18n.Schema = {
clientReportError: '客户端上报失败',
clientComponentError: '客户端组件异常',
retryTaskReachThreshold: '任务重试失败数量超过阈值',
retryTaskEnterDeadLetter: '任务重试失败进入死信队列'
retryTaskEnterDeadLetter: '任务重试失败进入死信队列',
retryNoClientNodesError: '没有可执行的客户端节点'
},
jobNotifyScene: {
jobTaskError: '任务执行失败',
jobClientError: '客户端执行失败'
jobClientError: '客户端执行失败',
jobNoClientNodesError: '没有可执行的客户端节点'
},
workflowNotifyScene: {
workTaskError: '工作流任务执行失败',
workflowClientError: '客户端执行失败'
workflowClientError: '客户端执行失败',
workNoClientNodesError: '没有可执行的客户端节点',
workTaskError: '工作流任务执行失败'
},
notifyRecipient: '通知人信息',
rateLimiterStatus: '限流状态',

View File

@ -9,6 +9,14 @@ export function fetchGetNotifyConfigList(params?: Api.NotifyConfig.NotifySearchP
});
}
/** get notify systemTaskType list */
export function fetchGetNotifyConfigSystemTaskTypeList(systemTaskType: number) {
return request<CommonType.Option<number>[]>({
url: `/notify-config/all/${systemTaskType}`,
method: 'get'
});
}
/** add notify */
export function fetchAddNotify(data: Api.NotifyConfig.NotifyConfig) {
return request<boolean>({

29
src/typings/api.d.ts vendored
View File

@ -125,7 +125,7 @@ declare namespace Api {
interface LoginToken {
id: string;
mode: string;
role: String;
role: string;
token: string;
refreshToken: string;
createDt: string;
@ -576,14 +576,14 @@ declare namespace Api {
type NotifyConfig = Common.CommonRecord<{
/** 组名称 */
groupName: string | null;
/** 业务ID */
businessId: string | null;
/** 通知人id */
recipientIds: number[];
/** 任务类型 1、重试任务 2、回调任务、3、JOB任务 4、WORKFLOW任务 */
systemTaskType: SystemTaskType | null;
/** 业务名称 */
businessName?: string;
/** 通知名称 */
notifyName: string;
/** 状态 */
notifyStatus: Api.Common.EnableStatusNumber;
/** 通知场景 */
@ -600,10 +600,7 @@ declare namespace Api {
/** notify-config search params */
type NotifySearchParams = CommonType.RecordNullable<
Pick<
Api.NotifyConfig.NotifyConfig,
'groupName' | 'businessId' | 'systemTaskType' | 'notifyStatus' | 'notifyScene'
> &
Pick<Api.NotifyConfig.NotifyConfig, 'groupName' | 'systemTaskType' | 'notifyStatus' | 'notifyScene'> &
CommonSearchParams
>;
@ -613,14 +610,14 @@ declare namespace Api {
/** 任务类型 1、重试任务 2、回调任务、 3、JOB任务 4、WORKFLOW任务 */
type SystemTaskType = 1 | 3 | 4;
/** 1、场景重试数量超过阈值 2、场景重试失败数量超过阈值 3、客户端上报失败 4、客户端组件异常 5、任务重试失败数量超过阈值 6、任务重试失败进入死信队列 */
type RetryNotifyScene = 1 | 2 | 3 | 4 | 5 | 6;
/** 1、场景重试数量超过阈值 2、场景重试失败数量超过阈值 3、客户端上报失败 4、客户端组件异常 5、任务重试失败数量超过阈值 6、任务重试失败进入死信队列 7、没有可执行的客户端节点 */
type RetryNotifyScene = 1 | 2 | 3 | 4 | 5 | 6 | 7;
/** 1、任务执行失败 2、客户端执行失败 */
type JobNotifyScene = 1 | 2;
/** 1、任务执行失败 2、客户端执行失败 3、没有可执行的客户端节点 */
type JobNotifyScene = 1 | 2 | 3;
/** 2、 客户端执行失败 100、工作流任务执行失败 */
type WorkflowNotifyScene = 2 | 100;
/** 2、 客户端执行失败 3、没有可执行的客户端节点 100、工作流任务执行失败 */
type WorkflowNotifyScene = 2 | 3 | 100;
}
/**
@ -934,7 +931,7 @@ declare namespace Api {
>;
type ExportWorkflow = Common.CommonRecord<{
workflowIds: String[];
workflowIds: string[];
}> &
WorkflowSearchParams;
@ -954,6 +951,8 @@ declare namespace Api {
type Job = Common.CommonRecord<{
/** 组名称 */
groupName: string;
/** 通知场景ids */
notifyIds: number[];
/** 任务名称 */
jobName: string;
/** 方法参数 */
@ -992,6 +991,8 @@ declare namespace Api {
bucketIndex?: number;
/** 描述 */
description?: string;
/** 通知场景 */
notifyScene?: string;
}>;
/** JobTask search params */

View File

@ -741,6 +741,7 @@ declare namespace App {
title: string;
groupName: string;
businessName: string;
notifyName: string;
notifyStatus: string;
notifyType: string;
notifyScene: string;
@ -751,13 +752,13 @@ declare namespace App {
job: string;
workflow: string;
form: {
businessId: string;
description: string;
notifyType: string;
notifyAttribute: string;
notifyScene: string;
groupName: string;
notifyThreshold: string;
notifyName: string;
notifyStatus: string;
systemTaskType: string;
notifyRecipient: string;
@ -776,14 +777,17 @@ declare namespace App {
clientComponentError: string;
retryTaskReachThreshold: string;
retryTaskEnterDeadLetter: string;
retryNoClientNodesError: string;
};
jobNotifyScene: {
jobTaskError: string;
jobClientError: string;
jobNoClientNodesError: string;
};
workflowNotifyScene: {
workTaskError: string;
workflowClientError: string;
workNoClientNodesError: string;
workTaskError: string;
};
notifyRecipient: string;
rateLimiterStatus: string;

View File

@ -1,11 +1,11 @@
<script setup lang="ts">
import { computed, reactive, ref, watch } from 'vue';
import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue';
import { type FormInst, NInputNumber } from 'naive-ui';
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
import OperateDrawer from '@/components/common/operate-drawer.vue';
import { $t } from '@/locales';
import { enableStatusNumberOptions } from '@/constants/business';
import { fetchAddJob, fetchEditJob } from '@/service/api';
import { fetchAddJob, fetchEditJob, fetchGetNotifyConfigSystemTaskTypeList } from '@/service/api';
import RouteKey from '@/components/common/route-key.vue';
import BlockStrategy from '@/components/common/block-strategy.vue';
import ExecutorType from '@/components/common/executor-type.vue';
@ -13,6 +13,7 @@ import TaskType from '@/components/common/task-type.vue';
import CodeMirror from '@/components/common/code-mirror.vue';
import JobTriggerInterval from '@/components/common/job-trigger-interval.vue';
import { isNotNull } from '@/utils/common';
import SelectGroup from '@/components/common/select-group.vue';
defineOptions({
name: 'JobTaskOperateDrawer'
@ -25,6 +26,7 @@ interface Props {
rowData?: Api.Job.Job | null;
}
const notifyNameList = ref<CommonType.Option<number>[]>([]);
const props = defineProps<Props>();
interface Emits {
@ -59,6 +61,7 @@ type Model = Pick<
Api.Job.Job,
| 'id'
| 'groupName'
| 'notifyIds'
| 'jobName'
| 'argsStr'
| 'argsType'
@ -75,14 +78,27 @@ type Model = Pick<
| 'taskType'
| 'parallelNum'
| 'description'
| 'notifyScene'
>;
onMounted(() => {
nextTick(() => {
getNotifyConfigSystemTaskTypeList();
});
});
async function getNotifyConfigSystemTaskTypeList() {
const res = await fetchGetNotifyConfigSystemTaskTypeList(3);
notifyNameList.value = res.data as CommonType.Option<number>[];
}
const model: Model = reactive(createDefaultModel());
function createDefaultModel(): Model {
return {
// @ts-expect-error groupName is required
groupName: undefined,
notifyIds: [],
jobName: '',
argsStr: '',
argsType: 1,
@ -252,6 +268,7 @@ async function handleSubmit() {
const {
id,
groupName,
notifyIds,
jobName,
argsType,
jobStatus,
@ -286,6 +303,7 @@ async function handleSubmit() {
if (props.operateType === 'add') {
const { error } = await fetchAddJob({
groupName,
notifyIds,
jobName,
argsStr,
argsType,
@ -311,6 +329,7 @@ async function handleSubmit() {
const { error } = await fetchEditJob({
id,
groupName,
notifyIds,
jobName,
argsStr,
argsType,
@ -512,7 +531,9 @@ const scriptMethodOptions = [
<icon-ic-round-delete class="text-icon" />
</NButton>
</NFormItem>
<NButton block dashed attr-type="button" @click="addItem"><icon-ic-round-plus class="text-icon" /></NButton>
<NButton block dashed attr-type="button" @click="addItem">
<icon-ic-round-plus class="text-icon" />
</NButton>
</NCard>
<CodeMirror v-else v-model="model.argsStr" lang="json" :placeholder="$t('page.jobTask.form.argsStr')" />
</template>
@ -679,6 +700,17 @@ const scriptMethodOptions = [
</NFormItem>
</NGi>
</NGrid>
<NFormItem :label="$t('page.notifyConfig.notifyName')" path="notifyIds">
<NSelect
v-model:value="model.notifyIds"
value-field="id"
label-field="notifyName"
:placeholder="$t('page.notifyConfig.form.notifyName')"
:options="notifyNameList"
clearable
multiple
/>
</NFormItem>
<NFormItem :label="$t('page.jobTask.description')" path="description">
<NInput v-model:value="model.description" type="textarea" :placeholder="$t('page.jobTask.form.description')" />
</NFormItem>

View File

@ -74,9 +74,9 @@ type Model = Pick<
Api.NotifyConfig.NotifyConfig,
| 'id'
| 'groupName'
| 'businessId'
| 'recipientIds'
| 'systemTaskType'
| 'notifyName'
| 'notifyStatus'
| 'notifyScene'
| 'notifyThreshold'
@ -101,9 +101,9 @@ const model: Model = reactive(createDefaultModel());
function createDefaultModel(): Model {
return {
groupName: null,
businessId: '',
recipientIds: [],
systemTaskType: null,
notifyName: '',
notifyStatus: 1,
notifyScene: null,
notifyThreshold: 16,
@ -116,9 +116,9 @@ function createDefaultModel(): Model {
type RuleKey = Extract<
keyof Model,
| 'groupName'
| 'businessId'
| 'systemTaskType'
| 'recipientIds'
| 'notifyName'
| 'notifyStatus'
| 'notifyScene'
| 'rateLimiterStatus'
@ -127,8 +127,8 @@ type RuleKey = Extract<
const rules: Record<RuleKey, App.Global.FormRule> = {
groupName: defaultRequiredRule,
businessId: defaultRequiredRule,
systemTaskType: defaultRequiredRule,
notifyName: defaultRequiredRule,
notifyStatus: defaultRequiredRule,
notifyScene: defaultRequiredRule,
recipientIds: defaultRequiredRule,
@ -160,9 +160,9 @@ async function handleSubmit() {
if (props.operateType === 'add') {
const {
groupName,
businessId,
recipientIds,
systemTaskType,
notifyName,
notifyStatus,
notifyScene,
notifyThreshold,
@ -172,9 +172,9 @@ async function handleSubmit() {
} = model;
const { error } = await fetchAddNotify({
groupName,
businessId,
recipientIds,
systemTaskType,
notifyName,
notifyStatus,
notifyScene,
notifyThreshold,
@ -189,9 +189,9 @@ async function handleSubmit() {
const {
id,
groupName,
businessId,
recipientIds,
notifyStatus,
notifyName,
systemTaskType,
notifyScene,
notifyThreshold,
@ -202,9 +202,9 @@ async function handleSubmit() {
const { error } = await fetchEditNotify({
id,
groupName,
businessId,
recipientIds,
systemTaskType,
notifyName,
notifyStatus,
notifyScene,
notifyThreshold,
@ -239,14 +239,6 @@ async function systemTaskTypeChange(value: number | null) {
}) as Api.Workflow.Workflow[];
notifySceneOptions.value = translateOptions(workflowNotifySceneOptions);
}
if (value !== props.rowData?.systemTaskType) {
model.businessId = null;
model.notifyScene = null;
} else {
model.businessId = props.rowData?.businessId;
model.notifyScene = props.rowData?.notifyScene;
}
}
async function retrySceneChange(
@ -278,7 +270,7 @@ watch(visible, () => {
<OperateDrawer v-model="visible" :title="title" :min-size="480" @handle-submit="handleSubmit">
<NForm ref="formRef" :model="model" :rules="rules">
<NFormItem :label="$t('page.notifyConfig.groupName')" path="groupName">
<SelectGroup v-model:modelValue="model.groupName" @update:model-value="groupNameUpdate" />
<SelectGroup v-model:value="model.groupName" @update:model-value="groupNameUpdate" />
</NFormItem>
<NFormItem :label="$t('page.notifyConfig.systemTaskType')" path="systemTaskType">
<NSelect
@ -288,32 +280,8 @@ watch(visible, () => {
@update:value="systemTaskTypeChange"
/>
</NFormItem>
<NFormItem v-if="model.systemTaskType === 1" :label="$t('page.notifyConfig.retryScene')" path="businessId">
<NSelect
v-model:value="model.businessId"
:placeholder="$t('page.notifyConfig.form.sceneName')"
:options="retryScenes"
label-field="sceneName"
value-field="sceneName"
/>
</NFormItem>
<NFormItem v-if="model.systemTaskType === 3" :label="$t('page.notifyConfig.job')" path="businessId">
<NSelect
v-model:value="model.businessId"
:placeholder="$t('page.notifyConfig.form.jobName')"
:options="jobs"
label-field="jobName"
value-field="id"
/>
</NFormItem>
<NFormItem v-if="model.systemTaskType === 4" :label="$t('page.notifyConfig.workflow')" path="businessId">
<NSelect
v-model:value="model.businessId"
:placeholder="$t('page.notifyConfig.form.workflowName')"
:options="workflows"
label-field="workflowName"
value-field="id"
/>
<NFormItem :label="$t('page.notifyConfig.notifyName')" path="notifyName">
<NInput v-model:value="model.notifyName" :placeholder="$t('page.notifyConfig.form.notifyName')" />
</NFormItem>
<NFormItem :label="$t('page.notifyConfig.notifyScene')" path="notifyScene">
<NSelect