Quellcode durchsuchen

定时任务推送

xiongwanxiong vor 6 Stunden
Ursprung
Commit
12d916d5fa

+ 0 - 4
wxjy-wxjy-service/src/main/java/cn/gov/customs/wxjy/task/AbstractCatalogTask.java

@@ -1,4 +0,0 @@
-package cn.gov.customs.wxjy.task;
-
-public class AbstractCatalogTask {
-}

+ 0 - 1
wxjy-wxjy-service/src/main/java/cn/gov/customs/wxjy/task/BaseBusinessTask.java

@@ -93,7 +93,6 @@ public abstract class BaseBusinessTask<T> {
 
             if (CollectionUtils.isEmpty(dataList)) {
                 log.info("{}:没有需要同步的数据", getTaskName());
-                recordTaskLog(TaskStatusEnum.SUCCESS, startTime, null);
                 return;
             }
 

+ 44 - 1
wxjy-wxjy-web/src/views/base/ChemicalsCatalog.vue

@@ -139,7 +139,7 @@
 
 <script lang="ts" setup>
 import { onMounted, reactive, ref } from 'vue'
-import { ElMessage } from 'element-plus'
+import { ElLoading, ElMessage } from 'element-plus'
 import config from '@/config'
 import {
   SuccessResultCode,
@@ -151,6 +151,7 @@ import {
 import type { ChemicalsCatalog, ChemicalsCatalogQuery } from '@/types/base/ChemicalsCatalog'
 import {getList} from '@/apis/base/ChemicalsCatalog'
 import { permissionStatus } from '@/utils/globalPermission'
+import { scheduledTask } from '@/apis/base/TaskLog'
 
 // 表单引用
 const queryFormRef = ref<SearchPanelLayoutInstance>()
@@ -226,6 +227,13 @@ const state = reactive<State>({
 
 // 表格操作按钮配置
 const actions = <Array<TableAction>>[
+  {
+    key: 'syncBaseData',
+    text: '数据同步',
+    onclick: onSyncData,
+    limit: permissionStatus('none', 'CHEMICALS_CATALOG_SYNC_BT'),
+    type: 'primary'
+  },
   {
     key: 'view',
     text: '查看',
@@ -276,6 +284,41 @@ function onView(row: ChemicalsCatalog) {
   state.viewTitle = '危化品详情'
 }
 
+//数据同步
+async function onSyncData() {
+  // 创建加载实例
+  const loadingInstance = ElLoading.service({
+    lock: true,
+    text: '数据同步中...',
+    background: 'rgba(0, 0, 0, 0.7)',
+  })
+
+  try {
+    await scheduledTask("9")
+
+    // 关闭加载
+    loadingInstance.close()
+
+    // 显示成功消息
+    ElMessage({
+      message: '同步成功',
+      type: 'success',
+      duration: 3000
+    })
+  } catch (error) {
+    // 关闭加载
+    loadingInstance.close()
+
+    // 显示错误消息
+    ElMessage({
+      message: `同步失败: ${error}`,
+      type: 'error',
+      duration: 3000
+    })
+    console.error('同步失败:', error)
+  }
+}
+
 // 数据查询
 async function onLoadData() {
   setLoading(true)

+ 44 - 1
wxjy-wxjy-web/src/views/base/GoodsCatalog.vue

@@ -197,7 +197,7 @@
 
 <script lang="ts" setup>
 import { onMounted, reactive, ref } from 'vue'
-import { ElMessage } from 'element-plus'
+import { ElLoading, ElMessage } from 'element-plus'
 import config from '@/config'
 import {
   SuccessResultCode,
@@ -211,6 +211,7 @@ import { getList } from '@/apis/base/GoodsCatalog'
 import { permissionStatus } from '@/utils/globalPermission'
 import { useDictType } from '@/components/useDict'
 import DictTag from '@/components/DictTag/dictTag.vue'
+import { scheduledTask } from '@/apis/base/TaskLog'
 const { dict } = useDictType('pack_type')
 
 // 表单引用
@@ -298,6 +299,13 @@ const state = reactive<State>({
 
 // 表格操作按钮配置
 const actions = <Array<TableAction>>[
+  {
+    key: 'syncBaseData',
+    text: '数据同步',
+    onclick: onSyncData,
+    limit: permissionStatus('none', 'GOODS_CATALOG_SYNC_BT'),
+    type: 'primary'
+  },
   {
     key: 'view',
     text: '查看',
@@ -348,6 +356,41 @@ function onView(row: GoodsCatalog) {
   state.viewTitle = '危险货物详情'
 }
 
+//数据同步
+async function onSyncData() {
+  // 创建加载实例
+  const loadingInstance = ElLoading.service({
+    lock: true,
+    text: '数据同步中...',
+    background: 'rgba(0, 0, 0, 0.7)',
+  })
+
+  try {
+    await scheduledTask("10")
+
+    // 关闭加载
+    loadingInstance.close()
+
+    // 显示成功消息
+    ElMessage({
+      message: '同步成功',
+      type: 'success',
+      duration: 3000
+    })
+  } catch (error) {
+    // 关闭加载
+    loadingInstance.close()
+
+    // 显示错误消息
+    ElMessage({
+      message: `同步失败: ${error}`,
+      type: 'error',
+      duration: 3000
+    })
+    console.error('同步失败:', error)
+  }
+}
+
 // 数据查询
 async function onLoadData() {
   setLoading(true)

+ 33 - 3
wxjy-wxjy-web/src/views/base/PackCatalog.vue

@@ -101,7 +101,7 @@
 
 <script lang="ts" setup>
 import { onMounted, reactive, ref } from 'vue'
-import { ElMessage} from 'element-plus'
+import { ElLoading, ElMessage } from 'element-plus'
 import config from '@/config'
 import {
   SuccessResultCode,
@@ -173,7 +173,7 @@ const actions = <Array<TableAction>>[
     key: 'syncBaseData',
     text: '数据同步',
     onclick: onSyncData,
-    limit: 'none',
+    limit: permissionStatus('none', 'PACK_CATALOG_SYNC_BT'),
     type: 'primary'
   },
   {
@@ -228,7 +228,37 @@ function onView(row: PackCatalog) {
 
 //数据同步
 async function onSyncData() {
-  await scheduledTask("8")
+  // 创建加载实例
+  const loadingInstance = ElLoading.service({
+    lock: true,
+    text: '数据同步中...',
+    background: 'rgba(0, 0, 0, 0.7)',
+  })
+
+  try {
+    await scheduledTask("8")
+
+    // 关闭加载
+    loadingInstance.close()
+
+    // 显示成功消息
+    ElMessage({
+      message: '同步成功',
+      type: 'success',
+      duration: 3000
+    })
+  } catch (error) {
+    // 关闭加载
+    loadingInstance.close()
+
+    // 显示错误消息
+    ElMessage({
+      message: `同步失败: ${error}`,
+      type: 'error',
+      duration: 3000
+    })
+    console.error('同步失败:', error)
+  }
 }
 
 // 数据查询