zhangnaiwen hace 2 años
padre
commit
6b451ca00f

BIN
config/device.xls


+ 2 - 3
src/app/api/__init__.py

@@ -14,6 +14,7 @@ from app.api.download import ns as download
 from app.api.strategy import ns as strategy
 from app.api.system_monitoring import ns as system_monitoring
 from app.api.server import ns as server
+from app.api.system_index import ns as system_index
 
 api = Api(version='v1.0', title='operation_management_center', description='运营管理中心', doc='/api')
 
@@ -32,6 +33,4 @@ api.add_namespace(download)
 
 api.add_namespace(system_monitoring)
 api.add_namespace(server)
-
-
-# todo 公司联级查询
+api.add_namespace(system_index)

+ 184 - 67
src/app/api/device.py

@@ -4,12 +4,12 @@ import os
 import xlrd
 from flask import request, jsonify, current_app, Response
 from flask_restx import Resource, Namespace, reqparse
-from sqlalchemy import select, insert, update, delete
+from sqlalchemy import select, insert, update, delete, func
 from sqlalchemy.orm import Session
 from werkzeug.datastructures import FileStorage
 
 from app.defines import StatesCode, Module, OperationType
-from app.modle.device import DeviceType, SecurityDevice, EnergyDeviceType
+from app.modle.device import DeviceType, SecurityDevice, EnergyDeviceType, DeviceMessage
 from app.utils.jwt_util import login_required
 from app.utils.save_log import save_log
 from app.utils.util import to_dict
@@ -150,6 +150,32 @@ class DeviceKindApi(Resource):
             return jsonify(code=StatesCode.UNKNOWN_ERROR, message=str(e))
 
 
+device_kind_list = reqparse.RequestParser(bundle_errors=True)
+device_kind_list.add_argument(name='id', type=str, location='args', required=False, help='设备种类id')
+
+
+@ns.route('/device_kind_list')
+class DeviceKindListApi(Resource):
+
+    @ns.doc(description='根据设备种类获取设备列表')
+    @ns.expect(device_kind_list)
+    def get(self):
+        """根据设备种类获取设备列表"""
+        device_type_id = request.args.get('id')
+        try:
+            with Session(current_app.engine) as session:
+                stmt = select(SecurityDevice).where(SecurityDevice.device_type == device_type_id)
+                results = session.execute(stmt).scalars().all()
+
+            save_log(request, Module.DEVICE, OperationType.INQUIRE, StatesCode.SUCCESS)
+
+            return jsonify(code=StatesCode.SUCCESS, message='成功', data=to_dict(results))
+
+        except Exception as e:
+            save_log(request, Module.DEVICE, OperationType.INQUIRE, StatesCode.UNKNOWN_ERROR)
+            return jsonify(code=StatesCode.UNKNOWN_ERROR, message=str(e))
+
+
 device_list = reqparse.RequestParser(bundle_errors=True)
 device_list.add_argument(name='id', type=str, location='args', required=False, help='设备类别id')
 # device_list.add_argument(name='name', type=str, location='args', required=False, help='过滤设备名')
@@ -180,6 +206,9 @@ class DeviceListApi(Resource):
                 device_ids = session.execute(stmt).scalars().first()
 
                 if device_ids:
+                    count = select(func.count(SecurityDevice.id)).where(SecurityDevice.id.in_(json.loads(device_ids)))
+                    count_results = session.execute(count).scalars().first()
+
                     stmt = select(SecurityDevice).where(SecurityDevice.id.in_(json.loads(device_ids))).offset(
                         page_size * (page - 1)).limit(page_size)
                     results = session.execute(stmt).scalars().all()
@@ -188,7 +217,7 @@ class DeviceListApi(Resource):
 
             save_log(request, Module.DEVICE, OperationType.INQUIRE, StatesCode.SUCCESS)
 
-            return jsonify(code=StatesCode.SUCCESS, message='成功', data=to_dict(results))
+            return jsonify(code=StatesCode.SUCCESS, message='成功', total=count_results, data=to_dict(results))
 
         except Exception as e:
             save_log(request, Module.DEVICE, OperationType.INQUIRE, StatesCode.UNKNOWN_ERROR)
@@ -206,18 +235,17 @@ delete_device = reqparse.RequestParser(bundle_errors=True)
 delete_device.add_argument(name='device_id', type=str, location='form', required=False, help='设备id')
 delete_device.add_argument(name='device_type_id', type=str, location='form', required=False, help='设备类别id')
 
-
 device_details = reqparse.RequestParser(bundle_errors=True)
 device_details.add_argument(name='id', type=str, location='form', required=False, help='设备id')
 device_details.add_argument(name='device_name', type=str, location='form', required=False, help='设备名称')
-device_details.add_argument(name='device_id', type=str, location='form', required=False, help='设备id')
-device_details.add_argument(name='device_type', type=str, location='form', required=False, help='设备类型(1-摄像头)')
+# device_details.add_argument(name='device_id', type=str, location='form', required=False, help='设备id')
+# device_details.add_argument(name='device_type', type=str, location='form', required=False, help='设备类型(1-摄像头)')
 device_details.add_argument(name='device_location', type=str, location='form', required=False, help='设备位置')
-device_details.add_argument(name='loop_detail', type=str, location='form', required=False, help='回路地址')
-device_details.add_argument(name='gateway_code', type=str, location='form', required=False, help='所属单位ID')
-device_details.add_argument(name='gateway_ip', type=str, location='form', required=False, help='网关服务器')
-device_details.add_argument(name='usage', type=str, location='form', required=False, help='用途')
-device_details.add_argument(name='status', type=str, location='form', required=False, help='设备状态(1-开启)')
+# device_details.add_argument(name='loop_detail', type=str, location='form', required=False, help='回路地址')
+# device_details.add_argument(name='gateway_code', type=str, location='form', required=False, help='所属单位ID')
+# device_details.add_argument(name='gateway_ip', type=str, location='form', required=False, help='网关服务器')
+# device_details.add_argument(name='usage', type=str, location='form', required=False, help='用途')
+# device_details.add_argument(name='status', type=str, location='form', required=False, help='设备状态(1-开启)')
 
 
 @ns.route('/device')
@@ -237,11 +265,11 @@ class DeviceApi(Resource):
         try:
             with Session(current_app.engine) as session:
                 stmt = select(SecurityDevice).where(SecurityDevice.id == device_id)
-                results = session.execute(stmt).scalars().all()
-
+                results = session.execute(stmt).scalars().first().__dict__
+                del results['_sa_instance_state']
             save_log(request, Module.DEVICE, OperationType.INQUIRE, StatesCode.SUCCESS)
 
-            return jsonify(code=StatesCode.SUCCESS, message='成功', data=to_dict(results))
+            return jsonify(code=StatesCode.SUCCESS, message='成功', data=results)
 
         except Exception as e:
             save_log(request, Module.DEVICE, OperationType.INQUIRE, StatesCode.UNKNOWN_ERROR)
@@ -285,14 +313,14 @@ class DeviceApi(Resource):
 
         id = request.form.get('id')
         device_name = request.form.get('device_name')
-        device_id = request.form.get('device_id')
-        device_type = request.form.get('device_type')
+        # device_id = request.form.get('device_id')
+        # device_type = request.form.get('device_type')
         device_location = request.form.get('device_location')
-        loop_detail = request.form.get('device_age')
-        gateway_code = request.form.get('company_id')
-        gateway_ip = request.form.get('user_id')
-        usage = request.form.get('device_group')
-        status = request.form.get('status')
+        # loop_detail = request.form.get('device_age')
+        # gateway_code = request.form.get('company_id')
+        # gateway_ip = request.form.get('user_id')
+        # usage = request.form.get('device_group')
+        # status = request.form.get('status')
 
         if device_name is None:
             return jsonify(code=StatesCode.PARA_ERROR, message='设备名称不能为空')
@@ -300,14 +328,14 @@ class DeviceApi(Resource):
             with Session(current_app.engine) as session:
                 stmt = update(SecurityDevice).where(SecurityDevice.id == id).values(
                     device_name=device_name,
-                    device_id=device_id,
-                    device_type=device_type,
+                    # device_id=device_id,
+                    # device_type=device_type,
                     device_location=device_location,
-                    loop_detail=loop_detail,
-                    gateway_code=gateway_code,
-                    gateway_ip=gateway_ip,
-                    usage=usage,
-                    status=status,
+                    # loop_detail=loop_detail,
+                    # gateway_code=gateway_code,
+                    # gateway_ip=gateway_ip,
+                    # usage=usage,
+                    # status=status,
 
                 )
                 session.execute(stmt)
@@ -377,7 +405,7 @@ class BatchDeleteDeviceApi(Resource):
         device_ids = request.form.get('device_ids')
         device_type_id = request.form.get('device_type_id')
 
-        if device_ids is not None or device_type_id is not None:
+        if device_ids and device_type_id:
             device_ids = json.loads(device_ids)
             device_type_id = int(device_type_id)
         else:
@@ -416,28 +444,28 @@ import_device.add_argument(name='group_id', type=str, required=True, location='f
 class ImportDeviceApi(Resource):
     # method_decorators = [login_required]
 
-    @ns.doc(id='import_device', description='导入模版下载')
-    def get(self):
-        """导入模版下载"""
-        try:
-            manage_path = os.path.dirname(os.path.abspath(__file__))
-            config_yml_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(manage_path))), 'config',
-                                           'device.xls')
-
-            file_data = open(config_yml_path, 'rb')
-            buf = file_data.read()
-            file_data.close()
-
-            response = Response(buf)
-            response.headers['Content-Type'] = 'application/octet-stream'
-            response.headers['Content-Disposition'] = 'attachment; filename=%s' % 'device.xls'
-
-            save_log(request, Module.DEVICE, OperationType.EXPORT, StatesCode.SUCCESS)
-
-            return response
-        except Exception as e:
-            save_log(request, Module.DEVICE, OperationType.EXPORT, StatesCode.UNKNOWN_ERROR)
-            return jsonify(code=StatesCode.UNKNOWN_ERROR, message=str(e))
+    # @ns.doc(id='import_device', description='导入模版下载')
+    # def get(self):
+    #     """导入模版下载"""
+    #     try:
+    #         manage_path = os.path.dirname(os.path.abspath(__file__))
+    #         config_yml_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(manage_path))), 'config',
+    #                                        'device.xls')
+    #
+    #         file_data = open(config_yml_path, 'rb')
+    #         buf = file_data.read()
+    #         file_data.close()
+    #
+    #         response = Response(buf)
+    #         response.headers['Content-Type'] = 'application/octet-stream'
+    #         response.headers['Content-Disposition'] = 'attachment; filename=%s' % 'device.xls'
+    #
+    #         save_log(request, Module.DEVICE, OperationType.EXPORT, StatesCode.SUCCESS)
+    #
+    #         return response
+    #     except Exception as e:
+    #         save_log(request, Module.DEVICE, OperationType.EXPORT, StatesCode.UNKNOWN_ERROR)
+    #         return jsonify(code=StatesCode.UNKNOWN_ERROR, message=str(e))
 
     @ns.doc(id='import_device', description='设备导入')
     @ns.expect(import_device)
@@ -446,7 +474,7 @@ class ImportDeviceApi(Resource):
         device_file = request.files.get('files')
         device_group_id = request.form.get('group_id')
 
-        if os.path.splitext(device_file.name)[-1] != '.xls':
+        if os.path.splitext(device_file.filename)[-1] != '.xls':
             return jsonify(code=StatesCode.PARA_ERROR, message='不支持的文件格式,仅支持 .xls 文件')
 
         if device_group_id is None:
@@ -457,26 +485,49 @@ class ImportDeviceApi(Resource):
 
             with Session(current_app.engine) as session:
 
+                # 记录新添加的设备id
+                upload_device = []
+
                 for sheet in xlsx.sheets():
 
                     # 添加设备数据
                     for i in range(1, sheet.nrows):  # 逐行打印sheet数据
                         value = sheet.row_values(i)
-                        add_device = insert(SecurityDevice).values(
-                            device_name=value[0],
-                            device_id=value[1],
-                            device_type=int(value[2]) if value[2] != '' else None,
-                            device_location=value[3],
-                            device_age=int(value[4]) if value[4] != '' else None,
-                            company_id=value[5],
-                            user_id=value[6],
-                            device_group=device_group_id,
-                            status=int(value[7]) if value[7] != '' else None,
-                            floor_id=int(value[8]) if value[8] != '' else None,
-                            third_id=value[9]
-                        )
-                        session.execute(add_device)
-                        session.commit()
+                        id = int(value[0])
+
+                        # 查找设备,没有则添加有记录id
+                        device_stmt = select(SecurityDevice.id).where(SecurityDevice.id == id)
+                        device_id = session.execute(device_stmt).scalars().first()
+                        if device_id:
+                            upload_device.append(device_id)
+                        else:
+                            add_device = insert(SecurityDevice).values(
+                                device_name=value[1],
+                                device_id=value[2],
+                                device_type=int(value[3]) if value[3] != '' else None,
+                                device_location=value[4],
+                                loop_detail=int(value[5]) if value[5] != '' else None,
+                                gateway_code=value[6],
+                                gateway_ip=value[7],
+                                usage=value[8],
+                                status=int(value[9]) if value[9] != '' else None,
+                            )
+                            result = session.execute(add_device)
+                            session.commit()
+                            upload_device.append(result.inserted_primary_key[0])
+
+                # 与设备类别做关联
+                res = session.execute(
+                    select(DeviceType.device_ids).where(DeviceType.id == device_group_id)
+                ).scalars().first()
+                res = json.loads(res)
+                res.extend(upload_device)
+
+                stmt = update(DeviceType).where(DeviceType.id == device_group_id).values(
+                    device_ids=json.dumps(res)
+                )
+                session.execute(stmt)
+                session.commit()
 
             save_log(request, Module.DEVICE, OperationType.IMPORT, StatesCode.SUCCESS)
 
@@ -484,3 +535,69 @@ class ImportDeviceApi(Resource):
         except Exception as e:
             save_log(request, Module.DEVICE, OperationType.IMPORT, StatesCode.UNKNOWN_ERROR)
             return jsonify(code=StatesCode.UNKNOWN_ERROR, message=str(e))
+
+
+device_alarm = reqparse.RequestParser(bundle_errors=True)
+device_alarm.add_argument(name='alarm_type', type=str, location='args', required=True,
+                          help='告警类别(1 一般告警 2紧急告警 3重要告警)')
+device_alarm.add_argument(name='page_size', type=int, location='args', required=False, help='每页记录数量,默认:20')
+device_alarm.add_argument(name='page', type=int, location='args', required=False, help='第几页')
+
+
+delete_device_alarm = reqparse.RequestParser(bundle_errors=True)
+delete_device_alarm.add_argument(name='alarm_message_id', type=str, location='form', required=True, help='异常消息id')
+
+
+@ns.route('/device_alarm')
+class DeviceAlarmApi(Resource):
+
+    @ns.doc(description='获取设备告警列表')
+    @ns.expect(device_alarm)
+    def get(self):
+        """获取设备告警列表"""
+        alarm_type = request.args.get('alarm_type')
+        page_size = int(request.args.get('page_size', 20))
+        page = int(request.args.get('page', 1))
+
+        if alarm_type is None:
+            return jsonify(code=StatesCode.PARA_ERROR, message='告警类别不能为空')
+        try:
+
+            with Session(current_app.engine) as session:
+                count = select(func.count(DeviceMessage.id)).where(DeviceMessage.type == alarm_type)
+                count_results = session.execute(count).scalars().first()
+
+                stmt = select(DeviceMessage).where(DeviceMessage.type == alarm_type).offset(
+                    page_size * (page - 1)).limit(page_size)
+                results = session.execute(stmt).scalars().all()
+
+            save_log(request, Module.DEVICE, OperationType.IMPORT, StatesCode.SUCCESS)
+
+            return jsonify(code=StatesCode.SUCCESS, message='成功', total=count_results, data=to_dict(results))
+        except Exception as e:
+            save_log(request, Module.DEVICE, OperationType.IMPORT, StatesCode.UNKNOWN_ERROR)
+            return jsonify(code=StatesCode.UNKNOWN_ERROR, message=str(e))
+
+    @ns.doc(description='删除设备告警')
+    @ns.expect(delete_device_alarm)
+    def delete(self):
+        """删除设备告警"""
+        alarm_message_id = request.form.get('alarm_message_id')
+
+        if alarm_message_id is None:
+            return jsonify(code=StatesCode.PARA_ERROR, message='告警消息id不能为空')
+
+        try:
+            with Session(current_app.engine) as session:
+                stmt = update(DeviceMessage).where(DeviceMessage.id == alarm_message_id).values(
+                    type=None
+                )
+                session.execute(stmt)
+                session.commit()
+
+            save_log(request, Module.DEVICE, OperationType.DELETE, StatesCode.SUCCESS)
+
+            return jsonify(code=StatesCode.SUCCESS, message='成功')
+        except Exception as e:
+            save_log(request, Module.DEVICE, OperationType.DELETE, StatesCode.UNKNOWN_ERROR)
+            return jsonify(code=StatesCode.UNKNOWN_ERROR, message=str(e))

+ 12 - 1
src/app/api/message.py

@@ -20,9 +20,20 @@ ns = Namespace('message', description='消息管理接口')
 config = Config()
 
 
+@ns.route('/messager_module')
+class MessageModuleApi(Resource):
+
+    def get(self):
+        """获取消息模块类型"""
+
+        save_log(request, Module.MESSAGE, OperationType.INQUIRE, StatesCode.SUCCESS)
+
+        return jsonify(code=StatesCode.SUCCESS, message='成功', data=config.common.MESSAGR_TYPE)
+
+
 @ns.route('/message_list')
 class MessageTypeApi(Resource):
-    ####method_decorators = [login_required]
+    #method_decorators = [login_required]
 
     @ns.doc(id='message_list', description='消息列表')
     def get(self):

+ 7 - 2
src/app/api/organization.py

@@ -69,6 +69,7 @@ company_details.add_argument(name='contact_information', type=str, location='for
 company_details.add_argument(name='company_code', type=str, location='form', required=False, help='公司编码')
 company_details.add_argument(name='staff_size', type=str, location='form', required=False, help='编制人数')
 company_details.add_argument(name='on_guard_size', type=str, location='form', required=False, help='在岗人数')
+company_details.add_argument(name='parent_company', type=str, location='form', required=False, help='上级公司id')
 
 delete_company = reqparse.RequestParser(bundle_errors=True)
 delete_company.add_argument(name='company_id', type=int, location='form', required=False, help='公司id')
@@ -120,6 +121,7 @@ class CompanyApi(Resource):
         company_code = request.form.get('company_code')
         staff_size = request.form.get('staff_size')
         on_guard_size = request.form.get('on_guard_size')
+        parent_company = request.form.get('parent_company')
 
         if company_name is None:
             return jsonify(code=StatesCode.PARA_ERROR, message="公司名不能为空")
@@ -152,7 +154,8 @@ class CompanyApi(Resource):
                     contact_information=contact_information,
                     company_code=company_code,
                     staff_size=staff_size,
-                    on_guard_size=on_guard_size
+                    on_guard_size=on_guard_size,
+                    Parent_company=parent_company
                 )
                 session.execute(stmt)
 
@@ -182,6 +185,7 @@ class CompanyApi(Resource):
         company_code = request.form.get('company_code')
         staff_size = request.form.get('staff_size')
         on_guard_size = request.form.get('on_guard_size')
+        parent_company = request.form.get('parent_company')
 
         if company_name is None:
             return jsonify(code=StatesCode.PARA_ERROR, message="公司名不能为空")
@@ -207,7 +211,8 @@ class CompanyApi(Resource):
                     contact_information=contact_information,
                     company_code=company_code,
                     staff_size=staff_size,
-                    on_guard_size=on_guard_size
+                    on_guard_size=on_guard_size,
+                    Parent_company=parent_company
                 )
                 session.execute(stmt)
                 session.commit()

+ 26 - 6
src/app/api/server.py

@@ -19,12 +19,32 @@ class ServerListApi(Resource):
         page = int(request.args.get('page', 1))
 
         #  服务名称,简介,图片,安装状态
-        data = {
-            'name': '海康威视软件包',
-            'introduction': 'xxxxxxxx',
-            'picture': '',
-            'setup_status': True
-        }
+        data = [
+            {
+                'name': '海康威视软件包',
+                'introduction': 'xxxxxxxx',
+                'picture': '',
+                'setup_status': True
+            },
+            {
+                'name': '海康威视软件包',
+                'introduction': 'xxxxxxxx',
+                'picture': '',
+                'setup_status': True
+            },
+            {
+                'name': '海康威视软件包',
+                'introduction': 'xxxxxxxx',
+                'picture': '',
+                'setup_status': True
+            },
+            {
+                'name': '海康威视软件包',
+                'introduction': 'xxxxxxxx',
+                'picture': '',
+                'setup_status': True
+            }
+        ]
         return jsonify(code=StatesCode.SUCCESS, message='成功', data=data)
 
 

+ 36 - 3
src/app/api/system_index.py

@@ -16,16 +16,18 @@ index_list.add_argument(name='page', type=int, location='args', required=False,
 index_list.add_argument(name='parent_id', type=int, location='args', required=False, help='父id')
 
 
-@ns.route('index_list')
+@ns.route('/index_list')
 class IndexApi(Resource):
-    #method_decorators = [login_required]
+    # method_decorators = [login_required]
 
     @ns.doc(description='获取指标配置列表')
     @ns.expect(index_list)
     def get(self):
-        parent_id = int(request.args.get('parent_id'))
+        parent_id = request.args.get('parent_id')
         page_size = int(request.args.get('page_size', 20))
         page = int(request.args.get('page', 1))
+        if parent_id:
+            parent_id = int(parent_id)
         params = {
             'parentId': parent_id,
             'page': page,
@@ -38,3 +40,34 @@ class IndexApi(Resource):
             params=params, headers={'clientId': "99"}).json()
 
         return jsonify(code=StatesCode.SUCCESS, message='成功', data=rep)
+
+
+get_system_menus_list = reqparse.RequestParser(bundle_errors=True)
+get_system_menus_list.add_argument(name='parentId', type=int, location='args', required=False)
+
+
+@ns.route('/get_system_menus_list')
+class SystemMenusListApi(Resource):
+
+    @ns.doc(description='查询所有菜单')
+    @ns.expect(get_system_menus_list)
+    def get(self):
+        """查询所有菜单"""
+        parentId = request.args.get('parentId')
+
+        if parentId:
+            parentId = int(parentId)
+
+        params = {
+            'parentId': parentId,
+
+        }
+
+        rep = requests.get(
+            'http://{host}:{post}/ioc-api/system_index/getSystemMenusList'.format(host=config.system_monitoring.HOST,
+                                                                            post=config.system_monitoring.POST
+                                                                            ),
+            params=params, headers={'clientId': "99"}).json()
+
+        return jsonify(code=StatesCode.SUCCESS, message='成功', data=rep)
+

+ 1 - 1
src/app/api/system_monitoring.py

@@ -49,6 +49,6 @@ class TimedTaskApi(Resource):
         rep = requests.get(
             'http://{host}:{post}/ioc-api/quartz_job/getJobList'.format(host=config.system_monitoring.HOST,
                                                                         post=config.system_monitoring.POST
-                                                                        ), data=data, headers={'clientId': "99"}).json()
+                                                                        ), params=data, headers={'clientId': "99"}).json()
 
         return jsonify(code=StatesCode.SUCCESS, message='成功', data=rep)

+ 18 - 2
src/app/modle/device.py

@@ -1,4 +1,4 @@
-from sqlalchemy import String, Column, Integer
+from sqlalchemy import String, Column, Integer, DateTime, Text
 
 from app.modle import Base
 
@@ -10,7 +10,7 @@ class DeviceType(Base):
 
     id = Column(Integer, primary_key=True, autoincrement=True, nullable=False, unique=True, doc='id')
     type_name = Column(String, nullable=False, unique=True, index=False, doc='类别名称', comment='类别名称')
-    device_ids = Column(String, nullable=False, unique=True, index=False, doc='关联设备id列表',
+    device_ids = Column(Text, nullable=False, unique=True, index=False, doc='关联设备id列表',
                         comment='关联设备id列表')
 
 
@@ -40,6 +40,22 @@ class SecurityDevice(Base):
     usage = Column(String, nullable=True, unique=False, index=False, doc='用途', comment='用途')
     status = Column(String, nullable=True, unique=False, index=False, doc='设备状态(1-开启)', comment='设备状态(1-开启)')
 
+
+class DeviceMessage(Base):
+    """设备告警"""
+    __tablename__ = 'device_message'
+    id = Column(Integer, primary_key=True, autoincrement=True, nullable=False, unique=True, doc='id')
+    device_id = Column(Integer, nullable=True, unique=False, index=False)
+    service = Column(String, nullable=True, unique=False, index=False)
+    supplier_id = Column(String, nullable=True, unique=False, index=False)
+    api_url = Column(String, nullable=True, unique=False, index=False)
+    module = Column(String, nullable=True, unique=False, index=False)
+    message = Column(String, nullable=True, unique=False, index=False)
+    create_time = Column(DateTime, nullable=True, unique=False, index=False)
+    device_name = Column(String, nullable=True, unique=False, index=False)
+    type = Column(Integer, nullable=True, unique=False, index=False)
+
+
 # class SecurityDevice(Base):
 #     """设备表"""
 #

+ 3 - 1
src/app/modle/organization.py

@@ -19,10 +19,12 @@ class Company(Base):
     legal_person_name = Column(String, nullable=True, unique=False, index=False, doc='法人姓名')
     contact_person = Column(String, nullable=True, unique=False, index=False, doc='联系人')
     contact_information = Column(String, nullable=True, unique=False, index=False, doc='联系人电话')
-    company_code = Column(Integer, nullable=True, unique=False, index=False, doc='公司编码')
+    company_code = Column(String, nullable=True, unique=False, index=False, doc='公司编码')
     staff_size = Column(Integer, nullable=True, unique=False, index=False, doc='编制人数')
     on_guard_size = Column(Integer, nullable=True, unique=False, index=False, doc='在岗人数')
     Parent_company = Column(Integer, nullable=True, unique=False, index=False, doc='上级公司id')
+    area_id = Column(Integer, nullable=True, unique=False, index=False, doc='区域id')
+    office_id = Column(Integer, nullable=True, unique=False, index=False, doc='部门id')
     department = relationship('Department', cascade='all, delete-orphan')