Browse Source

离港管理添加报警预警

zhaoke 2 years ago
parent
commit
e8fa5069fd

+ 4 - 0
public/config.js

@@ -68,6 +68,7 @@ window.DATACONTENT_ID = {
   /***-----离港管理------***/
   departureAirMainId: 65, //离港管理-机场选择
   departureTableMainId: 66, //离港管理-表格
+  departureWarningId: 18040, //离港管理-报警策略
 
   /***-----中转进港------***/
   departureAirId: 72, // 中转进港-机场选择
@@ -188,6 +189,9 @@ window.SERVICE_ID = {
   /***-----权限项管理------***/
   authScId: 13, //权限项管理-增删改
 
+  /***-----离港管理------***/
+  departureScId: 8011, //发送报警预警日志信息
+
   sysProtoTabId: 1, //系统设置-协议管理-表格-增删改
   sysServiceAddId: 3, //系统设置-服务管理-新增服务-提交-id/服务管理-编辑服务-保存
   sysServiceEditBoxId: 4, //系统设置-服务管理-编辑服务-部署机器-多选框

+ 108 - 2
src/views/baggageManagement/components/departure/index.vue

@@ -137,9 +137,11 @@ import formMixin from "../../mixins/form";
 import tableColsMixin from "../../mixins/tableCols";
 import timeZoneMixin from "../../mixins/timeZone";
 import { getQuery } from "@/api/flight";
+import { GeneralDataReception } from "@/api/dataIntegration";
 import TableHeaderCell from "@/components/TableHeaderCell";
-import { setTableFilters, throttledExportToExcel } from "@/utils/table";
-
+import { setTableFilters, throttledExportToExcel, timeInZone } from "@/utils/table";
+import { parseTime } from '@/utils/index';
+import { mapGetters } from 'vuex';
 export default {
   name: "DepartureTerminalView",
   components: { Dialog, TimeZoneSelector, TableHeaderCell },
@@ -290,12 +292,14 @@ export default {
       baggageCount: 0,
       hasSetTableScroll: false,
       table: null,
+      WarningData: []
     };
   },
   computed: {
     singleDay () {
       return this.startDate === this.endDate;
     },
+    ...mapGetters(['timeZone'])
   },
   mounted () {
     this.getAirPortData();
@@ -308,6 +312,7 @@ export default {
   activated () {
     this.table.scrollTop = this.scrollTop;
     this.getTableData();
+    this.getWarningData();
     this.loopEvent = setInterval(this.getTableData, LOOP_INTERVAL.departureTable);
   },
   deactivated () {
@@ -353,6 +358,22 @@ export default {
         this.$message.error("失败");
       }
     },
+    async getWarningData () {
+      try {
+        const res = await getQuery({
+          id: DATACONTENT_ID.departureWarningId,
+          dataContent: [],
+        });
+        if (Number(res.code) === 0) {
+          const { listValues } = res.returnData;
+          this.WarningData = listValues;
+        } else {
+          this.$message.error(res.message);
+        }
+      } catch (error) {
+        this.$message.error("失败");
+      }
+    },
     tableRowClassName ({ row, rowIndex }) {
       const classes = [];
       if (row.flightStatus === "DLY") {
@@ -417,14 +438,56 @@ export default {
       }
     },
     initTableData (tableData) {
+      const currentTime = new Date();
+      const curTime = this.formatTime(currentTime);
       this.leaveCount = 0;
       this.baggageCount = 0;
       tableData.forEach((item) => {
         item["flightCanceled"] = item["flightStatus"] === "CAN" ? 1 : 0;
         item["tounLoad"] -= item["OFFCount"];
+        item["exceptions"] = item["preLoad"] - item["boardID"];
         if (item["hasTakeOff"] === 1 && !item["flightCanceled"]) {
           this.leaveCount++;
         }
+        if (item["hasTakeOff"] !== 1 && !item["flightCanceled"] && item["preLoad"] - Math.max(item.loadNumber, item.boardID) > 0) {
+          this.WarningData.forEach(p => {
+            const startTime = this.formatTime(timeInZone((p.startDate ?? '').replace('T', ' '), this.timeZone), 2);
+            const endTime = this.formatTime(timeInZone((p.endDate ?? '').replace('T', ' '), this.timeZone), 2);
+            const planTime = this.formatTime(timeInZone((item.planDepartureTime ?? '').replace('T', ' '), this.timeZone), 2);
+            const capTime = Math.ceil((planTime - curTime) / (1000 * 60));
+            if (Number(startTime) - Number(curTime) < 0 && Number(endTime) - Number(curTime) > 0) {
+              if (p.flightNO != '' && p.flightNO == item.flightNO) {
+                if (capTime - p.warningDuration < 0 && capTime - p.alarmDuration > 0) {
+                  item["warning"] = item["preLoad"] - Math.max(item.loadNumber, item.boardID);
+                  item["warningState"] = 1;
+                  const returnedTarget = Object.assign(item, p);
+                  this.sendLog(returnedTarget);
+                }
+                if (capTime - p.alarmDuration < 0) {
+                  item["warning"] = item["preLoad"] - Math.max(item.loadNumber, item.boardID);
+                  item["warningState"] = 2;
+                  const returnedTarget = Object.assign(item, p);
+                  this.sendLog(returnedTarget);
+                }
+              } else if (p.flightNO == '' && p.IATACode != '') {
+                if (item.flightNO.substring(0, 2) == p.IATACode) {
+                  if (capTime - p.warningDuration < 0 && capTime - p.alarmDuration > 0) {
+                    item["warning"] = item["preLoad"] - Math.max(item.loadNumber, item.boardID);
+                    item["warningState"] = 1;
+                    const returnedTarget = Object.assign(item, p);
+                    this.sendLog(returnedTarget);
+                  }
+                  if (capTime - p.alarmDuration < 0) {
+                    item["warning"] = item["preLoad"] - Math.max(item.loadNumber, item.boardID);
+                    item["warningState"] = 2;
+                    const returnedTarget = Object.assign(item, p);
+                    this.sendLog(returnedTarget);
+                  }
+                }
+              }
+            }
+          })
+        }
         this.baggageCount = this.baggageCount + item.preLoad;
       });
       this.tableData = this._.orderBy(tableData, ["hasTakeOff", "planDepartureTime"], ["desc", "asc"]);
@@ -434,6 +497,35 @@ export default {
         this.setTableScroll();
       });
     },
+    formatTime (date, type = 1) {
+      let time = null;
+      if (type == 1) {
+        time = parseTime(date, "{y}-{m}-{d} {h}:{i}:{s}");
+      } else {
+        time = date;
+      }
+      const newTimt = new Date(time);
+      return newTimt.getTime();
+    },
+    async sendLog (obj) {
+      try {
+        const newObj = {
+          logTime: parseTime(new Date(), "{y}-{m}-{d} {h}:{i}:{s}"),
+          logInfo: obj,
+          flightNO: obj.flightNO,
+          flightDate: obj.flightDate,
+          luggageSN: '',
+          strategyUseID: obj.alarmStrategyID,
+          event: 1
+        }
+        await GeneralDataReception({
+          serviceId: SERVICE_ID.departureScId,
+          dataContent: JSON.stringify(newObj),
+        });
+      } catch (error) {
+        this.$message.error("失败");
+      }
+    },
     setTableScroll () {
       if (!this.singleDay || this.hasSetTableScroll || this.leaveCount === 0) {
         return;
@@ -679,6 +771,20 @@ export default {
           border: 2px dashed red;
         }
       }
+      td.cell-tounLoadNew {
+        background: #fcf0b1 !important;
+        position: relative;
+        &::after {
+          content: "";
+          display: block;
+          width: 100%;
+          height: 100%;
+          position: absolute;
+          top: 0;
+          left: 0;
+          border: 2px dashed #e28913;
+        }
+      }
       .el-table__cell.is-hidden > * {
         visibility: visible;
       }

+ 20 - 12
src/views/baggageManagement/mixins/terminal.js

@@ -11,7 +11,7 @@ import { mapGetters } from 'vuex'
 import { commonTableCellClass } from '@/utils/table'
 
 export default {
-  data() {
+  data () {
     return {
       // 表格数据
       tableData: [],
@@ -24,18 +24,18 @@ export default {
       computedTableHeight: undefined
     }
   },
-  created() {
+  created () {
     this.setFilterAndSort(this.tableCols)
   },
-  updated() {
+  updated () {
     this.setTableHeight()
   },
-  activated() {
+  activated () {
     this.setTableHeight()
   },
   computed: {
     ...mapGetters(['clickedCells']),
-    dealedTableData() {
+    dealedTableData () {
       const filtered = this.tableData.filter(item => {
         let flag = true
         Object.entries(this.filterValues).forEach(([key, arr]) => {
@@ -61,7 +61,7 @@ export default {
   },
   watch: {
     dealedTableData: {
-      handler(val) {
+      handler (val) {
         this.spanArr = []
         let contactDot = this.contactDot
         val.forEach((item, index, arr) => {
@@ -86,7 +86,7 @@ export default {
   },
   methods: {
     // 设置表格高度
-    setTableHeight() {
+    setTableHeight () {
       const headerHeight = 80
       const bottomBlankHeight = 41
       const formWrapHeight = this.$refs['formWrap'].offsetHeight
@@ -96,7 +96,7 @@ export default {
       })
     },
     // 设置筛选和排序
-    setFilterAndSort(tableCols) {
+    setFilterAndSort (tableCols) {
       const self = this
       Object.values(tableCols).forEach(({ prop, filterable, sortable, children }) => {
         if (children) {
@@ -113,7 +113,7 @@ export default {
       })
     },
     // 合计行
-    summaryMethod({ columns, data }) {
+    summaryMethod ({ columns, data }) {
       const sums = []
       if (columns.length > 0) {
         columns.forEach((column, index) => {
@@ -170,7 +170,9 @@ export default {
               'inTransferBaggageCount',
               'inTransferredBaggageCount',
               'outTransferBaggageCount',
-              'outTransferredBaggageCount'
+              'outTransferredBaggageCount',
+              'exceptions',
+              'warning'
             ].includes(column.property)
           ) {
             const values = data.map(item => Number(item[column.property]))
@@ -194,7 +196,7 @@ export default {
       }
       return sums
     },
-    cellClass({ row, column, rowIndex, columnIndex }) {
+    cellClass ({ row, column, rowIndex, columnIndex }) {
       const classes = commonTableCellClass({ row, column, rowIndex, columnIndex })
       if (
         [
@@ -242,9 +244,15 @@ export default {
       if (column.property === 'tounLoad' && row[column.property]) {
         classes.push('cell-tounLoad')
       }
+      if (column.property === 'warning' && row['warningState'] && row['warningState'] == 2) {
+        classes.push('cell-tounLoad')
+      }
+      if (column.property === 'warning' && row['warningState'] && row['warningState'] == 1) {
+        classes.push('cell-tounLoadNew')
+      }
       return classes.join(' ')
     },
-    cellClickHandler(row, column, cell, event) {
+    cellClickHandler (row, column, cell, event) {
       if (
         [
           'flightNO',