king
2024-10-17 044a4ec4ebe85f8c00e889fe3914de17a6ea1f28
src/components/querylog/index.jsx
@@ -1,4 +1,5 @@
import { Component } from 'react'
import { notification } from 'antd'
import moment from 'moment'
import Api from '@/api'
@@ -6,7 +7,7 @@
import MKEmitter from '@/utils/events.js'
/**
 * @description 操作记录,每隔六分钟更新一次
 * @description 操作记录,每隔10分钟更新一次
 */
class QueryLog extends Component {
  state = {
@@ -14,12 +15,10 @@
  }
  componentDidMount () {
    if (window.GLOB.systemType === 'production') {
      MKEmitter.addListener('queryTrigger', this.queryTrigger)
      setTimeout(() => {
        this.sendLog()
      }, 300000)
    }
    MKEmitter.addListener('queryTrigger', this.queryTrigger)
    setTimeout(() => {
      this.sendLog()
    }, 600000)
  }
  /**
@@ -35,40 +34,57 @@
  sendLog = () => {
    const { logs } = this.state
    if (logs && logs.length > 0 && sessionStorage.getItem('isEditState') !== 'true') {
      let logMap = new Map()
    let logMap = new Map()
      logs.forEach(item => {
        if (logMap.has(item.menuId)) {
          let _item = logMap.get(item.menuId)
          _item.times++
          logMap.set(item.menuId, _item)
        } else {
          item.times = 1
          logMap.set(item.menuId, item)
        }
      })
      let userid = sessionStorage.getItem('UserID') || ''
      let LText = [...logMap.values()].map(item => `select '${item.menuId}','${item.times}','${item.name}','${window.GLOB.appkey}','${userid}'`)
      let param = {
        func: 's_get_users_operation_log',
        exec_type: 'y', // 后台解码
        LText: LText.join(' union all ')
    logs.forEach(item => {
      if (logMap.has(item.menuId)) {
        let _item = logMap.get(item.menuId)
        _item.times++
        logMap.set(item.menuId, _item)
      } else {
        item.times = 1
        logMap.set(item.menuId, item)
      }
    })
      param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
      param.secretkey = Utils.encrypt('', param.timestamp)
      param.LText = Utils.formatOptions(param.LText)
    let userid = sessionStorage.getItem('UserID') || ''
    let LText = [...logMap.values()].map(item => `select '${item.menuId}','${item.times}','${item.name || ''}','${window.GLOB.appkey}','${userid}'`)
      Api.getSystemConfig(param)
      this.setState({logs: []})
    if (LText.length === 0) {
      setTimeout(() => {
        this.sendLog()
      }, 600000)
      return
    }
    setTimeout(() => {
      this.sendLog()
    }, 300000)
    // {func: 's_get_local_users_operation_log'} 本地接口 返回 long_param 传入 sso 的 s_get_users_operation_log
    let param = {
      func: 's_get_users_operation_log',
      exec_type: window.GLOB.execType || 'y',
      LText: LText.join(' union all '),
      long_param: ''
    }
    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
    param.secretkey = Utils.encrypt('', param.timestamp)
    param.LText = Utils.formatOptions(param.LText, param.exec_type)
    Api.getSystemConfig(param).then(result => {
      if (!result.status) {
        notification.warning({
          top: 92,
          message: result.message,
          duration: 3
        })
        return
      }
      setTimeout(() => {
        this.sendLog()
      }, 600000)
      this.setState({logs: []})
    })
  }
  queryTrigger = (item) => {