|
|
#!/usr/bin/env python
|
|
|
# -*- encoding: utf-8 -*-
|
|
|
'''
|
|
|
@Date:2022/07/18 16:41:18
|
|
|
'''
|
|
|
import sys
|
|
|
sys.path.append(".")
|
|
|
import json
|
|
|
import datetime
|
|
|
from sqlalchemy import or_, desc
|
|
|
from db_logic.db_base import Repository
|
|
|
from models.log_models import EntityLog
|
|
|
from Common.Utils import Utils
|
|
|
from db_logic.user import BllUser
|
|
|
|
|
|
#日志信息业务逻辑类
|
|
|
class BllLog(Repository):
|
|
|
def __init__(self, entityType=EntityLog):
|
|
|
return super().__init__(entityType)
|
|
|
|
|
|
#获取系统日志列表
|
|
|
def getLogList(self, customerId, pageParam, keyWord=''):
|
|
|
keyWord = '%' + keyWord + '%'
|
|
|
orm_query = self.findList().filter(EntityLog.CustomerId == customerId
|
|
|
).filter(or_(EntityLog.OperateUserName.like(keyWord), EntityLog.OperateType.like(keyWord))).order_by(desc(EntityLog.OperateDate))
|
|
|
return self.queryPage(orm_query, pageParam)
|
|
|
|
|
|
# 插入日志记录函数
|
|
|
def insert_log_record(self, currentInfo_json, ExecuteResult):
|
|
|
currentInfo = json.loads(currentInfo_json)
|
|
|
UserId = currentInfo.get('UserId')
|
|
|
ClientCode = currentInfo.get('ClientCode')
|
|
|
CustomerId = currentInfo.get('CustomerId')
|
|
|
user = BllUser().findEntity(UserId)
|
|
|
entity_log = EntityLog(LogId=str(Utils.UUID()), CustomerId=CustomerId, LogType=1, OperateUserId=UserId,
|
|
|
OperateAccount=user.Account, OperateUserName=user.RealName,
|
|
|
OperateTypeCode='通信成功', OperateType='通信成功',
|
|
|
ExecuteResult="终端{0}:{1}".format(
|
|
|
ClientCode, ExecuteResult),
|
|
|
OperateDate=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), IsAdd=1)
|
|
|
self.insert(entity_log)
|