Quellcode durchsuchen

master: Fixed 修复报警

gitboyzcf vor 4 Monaten
Ursprung
Commit
2490e89b4b

+ 1 - 1
.env.development

@@ -1,3 +1,3 @@
-VITE_API_BASE_URL= 'https://36.133.244.231:15000'
+VITE_API_BASE_URL= 'https://192.168.10.182:8443'
 VITE_API_INTERCOM_TOKEN_IP ='36.133.244.231:667'
 VITE_API_INTERCOM_IP = '36.133.244.231:666'

+ 69 - 78
src/views/preview-list/children/preview-info.vue

@@ -237,42 +237,49 @@
                     :width="180"
                   >
                   </a-table-column>
-                  <!-- <a-table-column
-                    :title="t('previewList.status')"
+                  <a-table-column
+                    :title="$t('previewList.status')"
                     data-index="status"
                     :width="150"
                     :body-cell-style="
                       (record) => ({
-                        background: record.status ? '' : '#7e2d2d',
+                        background: record.status ? '#4cd26380' : '#7e2d2d80',
                       })
                     "
                   >
                     <template #cell="{ record }">
                       <span>{{
                         record.status
-                          ? t('previewList.ycl')
-                          : t('previewList.wcl')
+                          ? $t('previewList.ycl')
+                          : $t('previewList.wcl')
                       }}</span>
                     </template>
-                  </a-table-column> -->
-                  <!-- <a-table-column
-                    :title="t('previewList.dqstatus')"
-                    data-index="isRead"
+                  </a-table-column>
+                  <a-table-column
+                    :title="$t('previewList.bjgd')"
+                    data-index="AlarmArchiving"
                     :width="150"
                     :body-cell-style="
                       (record) => ({
-                        background: record.isRead ? '' : '#2d4f7e',
+                        background:
+                          record.AlarmArchiving == '0'
+                            ? '#ffb65d80'
+                            : record.AlarmArchiving == '1'
+                            ? '#4cd26380'
+                            : '#7e2d2d80',
                       })
                     "
                   >
                     <template #cell="{ record }">
                       <span>{{
-                        record.isRead
-                          ? t('previewList.yd')
-                          : t('previewList.wd')
+                        record.AlarmArchiving == '0'
+                          ? '未归档'
+                          : record.AlarmArchiving == '1'
+                          ? '正确报警'
+                          : '错误报警'
                       }}</span>
                     </template>
-                  </a-table-column> -->
+                  </a-table-column>
                   <a-table-column :title="t('previewList.cz')" :width="150">
                     <template #cell="{ record }">
                       <a-button
@@ -337,13 +344,13 @@
       :fullscreen="true"
       :closable="true"
     >
-      <AlarmAll :guid="data.id" :is-show-cl="isShowCl" />
+      <AlarmAll :guid="data.id" :is-show-cl="true" />
     </PubModal>
     <ViewDrawer
       ref="viewDrawerRef"
-      v-model:view-data="viewData"
       :guid="data.id"
-      :is-show-cl="false"
+      :is-show-cl="true"
+      @update:view-data="(v) => Object.assign(viewData, v)"
     />
     <div id="participants-area" style="display: none"></div>
   </div>
@@ -351,13 +358,22 @@
 
 <script setup lang="ts">
   import useWorker from '@/assets/js/video-lib/omnimatrix-video-player';
-  import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
+  import {
+    computed,
+    nextTick,
+    onMounted,
+    onUnmounted,
+    ref,
+    watch,
+    provide,
+    toRaw,
+  } from 'vue';
   import { IntercomFn } from '@/utils/Intercom';
   import { useI18n } from 'vue-i18n';
   import { Icon } from '@iconify/vue';
-  import { getCropFullInfo } from '@/api/system';
+  import { getCropFullInfo, getAlarmImgFiles } from '@/api/system';
   import { useAppStore } from '@/store';
-  import dayjs from 'dayjs';
+  // import dayjs from 'dayjs';
   import { Message } from '@arco-design/web-vue';
   import useWheel from '@/assets/js/useWheel';
   import Speech from '../components/speech.vue';
@@ -376,7 +392,7 @@
   const app = useAppStore();
 
   const viewData = ref<AlarmData>({});
-  const isShowCl = ref(false);
+  provide('viewData', viewData);
   const modalRef = ref();
   const workerObj: any = ref({ qj: null });
   const cropFullInfo = ref<{
@@ -598,62 +614,35 @@
 
   const intercomDisabled = ref<'open' | 'loading' | 'close'>('close');
   const intercomClick = () => {
-    // (app.ip as string).split('//')[1]
     IntercomFn(intercomDisabled, props.data.id);
   };
   const viewDrawerRef = ref();
-  const showView = (record: any) => {
-    record.isRead = true;
-    const alarmLog = [record];
-    // AlgorithmName: '人员计数D';
-    // CameraDeviceId: 21;
-    // classId: 1;
-    // h: 386;
-    // isRead: true;
-    // src: 'originPicture/20241218/20241218192906_180909_30_21_src.jpg?serverUUID=3f16a3b113234807b81f6f8d0f268232';
-    // status: 0;
-    // time: 1734521346;
-    // timeN: '2024-12-18 19:29:06';
-    // type: '人员计数D';
-    // w: 680;
-    // x: 1454;
-    // y: 19;
+  const showView = async (record: any) => {
     record.loading = true;
-    const img = document.createElement('img');
-    img.src = `${app.ip}/rpc/rabbitMQ/KunPengYun/Files/${record.src}&GUID=${props.data.id}`;
-    img.onload = () => {
-      const [w, h] = [img.width, img.height];
-      const newAlarmData = alarmLog.map((item: any, i: number) => {
-        return {
-          ...item,
-          Name: item.AlgorithmName,
-          type: item.AlgorithmName,
-          status: 0,
-          isRead: false,
-          img: img.src,
-          tImg: img.src,
-          imgJson: {
-            imageHeight: h,
-            imageWidth: w,
-            resultData: {
-              objectList: [
-                {
-                  rect: {
-                    ...alarmLog[i],
-                    width: alarmLog[i].w,
-                    height: alarmLog[i].h,
-                  },
-                },
-              ],
-            },
-          },
-        };
-      });
-      const [firstAlarmData] = newAlarmData;
-      viewData.value = firstAlarmData;
-      viewDrawerRef.value.open();
-      record.loading = false;
-    };
+    record.isRead = true;
+    const imgJson = await getAlarmImgFiles(record.JsonFile, {
+      GUID: props.data.id,
+    });
+
+    Object.assign(record, {
+      Name: record.AlertType,
+      type: record.AlertType,
+      status:
+        record.status !== 'undefined' ? record.status : +record.HandleStatus,
+      isRead: false,
+      img: `${app.ip}/rpc/rabbitMQ/KunPengYun/Files/${record.OriginPicture}&GUID=${props.data.id}`,
+      tImg: `${app.ip}/rpc/rabbitMQ/KunPengYun/Files/${record.Thumbnail}&GUID=${props.data.id}`,
+      imgJson,
+      AlarmArchiving: `${
+        record.AlarmArchiving !== 'undefined'
+          ? record.AlarmArchiving
+          : record.Archived
+      }`,
+    });
+    viewData.value = record;
+
+    viewDrawerRef.value.open();
+    record.loading = false;
   };
   watch(
     radioActive,
@@ -732,15 +721,17 @@
       (e) => {
         const data = JSON.parse(e.data);
         alarmData.value.unshift({
-          type: data.AlgorithmName,
-          status: 0,
+          type: data.AlertType,
+          status: +data.HandleStatus,
           isRead: false,
           loading: false,
-          timeN: dayjs(+`${data.time}`.padEnd(13, '0')).format(
-            'YYYY-MM-DD HH:mm:ss'
-          ),
+          timeN: data.CreatedAt,
+          AlarmArchiving: `${data.Archived}`,
           ...data,
         });
+        if (alarmData.value.length >= 100) {
+          alarmData.value.splice(50, 50);
+        }
       },
       false
     );

+ 2 - 2
src/views/preview-list/components/alarm-all.vue

@@ -184,7 +184,7 @@
 <script setup lang="ts">
   // import dayjs from 'dayjs';
   import { useAppStore } from '@/store';
-  import { ref, reactive, onMounted } from 'vue';
+  import { ref, reactive, onMounted, provide } from 'vue';
   import {
     getAlarmImgFiles,
     getAlarmLog,
@@ -234,7 +234,7 @@
     },
   ]);
   const viewData = ref<AlarmData>({});
-
+  provide('viewData', viewData);
   const alarmData = ref<AlarmData[]>([
     // {
     //   type: '行人闯入',

+ 25 - 18
src/views/preview-list/components/view-alarm.vue

@@ -20,7 +20,11 @@
       <a-divider />
       <a-row class="grid-demo" justify="center" style="margin-bottom: 16px">
         <a-col :span="19">
-          <a-radio-group v-model="alarmArchiving" type="button" size="small">
+          <a-radio-group
+            v-model="viewData.AlarmArchiving"
+            type="button"
+            size="small"
+          >
             <a-radio
               v-for="(item, i) in alarmArchivingOptions"
               :key="i"
@@ -29,7 +33,10 @@
                 ><Icon :icon="item.icon" />{{ item.label }}</div
               ></a-radio
             >
-            <a-button size="small" @click="() => (alarmArchiving = '0')">
+            <a-button
+              size="small"
+              @click="() => (viewData.AlarmArchiving = '0')"
+            >
               <template #icon>
                 <icon-refresh />
               </template>
@@ -51,7 +58,7 @@
 </template>
 
 <script setup lang="ts">
-  import { onMounted, onUnmounted, ref, watch } from 'vue';
+  import { onMounted, onUnmounted, ref, watch, inject } from 'vue';
   import { Icon } from '@iconify/vue';
   import { getSetArchived } from '@/api/system';
   import Viewer from 'viewerjs';
@@ -61,12 +68,13 @@
     [key: string]: any;
   }
 
+  const viewData = inject('viewData');
+
   const props = defineProps<{
     data: DataProps;
     guid: any;
     isShowCl: boolean;
   }>();
-  const emits = defineEmits(['alarmArchiving']);
   const viewer = ref<Viewer | null>(null);
   const loading = ref(true);
 
@@ -74,7 +82,6 @@
   const init = () => {
     const canvas = document.createElement('canvas');
     const { imgJson, img } = props.data;
-    console.log(imgJson);
 
     canvas.width = imgJson.imageWidth;
     canvas.height = imgJson.imageHeight;
@@ -159,7 +166,6 @@
       }, 'image/jpeg');
     };
   };
-  const alarmArchiving = ref('0');
   const alarmArchivingOptions = ref<any[]>([
     {
       label: '正确报警',
@@ -172,23 +178,24 @@
       icon: 'mdi:alarm-light-off-outline',
     },
   ]);
-  watch(alarmArchiving, async (Archived) => {
-    if (Archived === props.data.AlarmArchiving) return;
-    emits('alarmArchiving', Archived);
-    await getSetArchived(
-      {
-        AlarmID: props.data.Id,
-        Archived,
-      },
-      { GUID: props.guid }
-    );
-  });
+  watch(
+    () => viewData.value.AlarmArchiving,
+    async (Archived) => {
+      await getSetArchived(
+        {
+          AlarmID: props.data.Id,
+          Archived,
+        },
+        { GUID: props.guid }
+      );
+    }
+  );
   onMounted(() => {
-    alarmArchiving.value = props.data.AlarmArchiving;
     init();
   });
   onUnmounted(() => {
     viewer.value?.destroy();
+    viewer.value = null;
     URL.revokeObjectURL(url);
   });
 </script>

+ 5 - 23
src/views/preview-list/components/view-drawer.vue

@@ -11,12 +11,7 @@
     @cancel="handleCancel"
   >
     <template #title>{{ $t('previewList.tpck') }}</template>
-    <ViewAlarm
-      :data="viewData"
-      :guid="guid"
-      :is-show-cl="isShowCl"
-      @alarm-archiving="(v) => (alarmArchiving = v)"
-    />
+    <ViewAlarm :data="viewData" :guid="guid" :is-show-cl="isShowCl" />
     <template #footer>
       <a-button type="primary" :loading="clLoading" @click="handleCl">{{
         $t('previewList.cl')
@@ -26,22 +21,20 @@
 </template>
 
 <script setup lang="ts">
-  import { ref } from 'vue';
+  import { ref, inject } from 'vue';
   import { setProcessingStatus } from '@/api/system';
   import ViewAlarm from './view-alarm.vue';
 
   interface AlarmData {
     [key: string]: number | string | boolean;
   }
+  const viewData = inject<AlarmData>('viewData');
   const props = defineProps<{
-    viewData: AlarmData;
     guid: any;
     isShowCl: boolean;
   }>();
-  const emits = defineEmits(['update:viewData']);
   const clLoading = ref(false);
   const tpckVisible = ref(false);
-  const alarmArchiving = ref('0');
 
   const close = () => {
     tpckVisible.value = false;
@@ -50,33 +43,22 @@
     tpckVisible.value = true;
   };
   const handleOk = () => {
-    emits('update:viewData', {
-      ...props.viewData,
-      isRead: true,
-      AlarmArchiving: alarmArchiving.value,
-    });
     close();
   };
   const handleCancel = () => {
-    handleOk();
     close();
   };
   const handleCl = async () => {
     clLoading.value = true;
     await setProcessingStatus(
       {
-        AlarmID: props.viewData.Id,
+        AlarmID: viewData.value.Id,
         State: 'Procesed',
       },
       { GUID: props.guid }
     );
+    viewData.value.status = 1;
     clLoading.value = false;
-    emits('update:viewData', {
-      ...props.viewData,
-      isRead: true,
-      status: 1,
-      AlarmArchiving: alarmArchiving.value,
-    });
     close();
   };