# coding=utf-8

import os
import sys

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

ImageStoragePathMap = {'srcdir':'/dx', '../tests/volume':'C:\\Users\\Administrator\\Desktop'}

def dir_exist(path):
    if not os.path.exists(path):
        os.makedirs(path, exist_ok=True)
    return path

DEBUG = False
PORT = 8085
PROCESS_NUM = 0   # 进程数

# 日志配置
LOGCONF = {
    "dir": "/var/log/webpacsai",
    "name": "main",
    "level": "DEBUG",
    "backcount": 10
}

# 数据库配置
DATABASE = {
    "hyx": {
        'host': '10.119.43.84',
        'user': 'postgres',
        'passwd': '<PASSWORD>',
        'dbname': 'test',
        'encoding': 'utf8',
        'echo': False
    },
    "rispacs": {
        'host': '10.11.12.148',
        'user': 'postgres',
        'passwd': '<PASSWORD>',
        'dbname': 'test',
        'encoding': 'utf8',
        'echo': False
    }
}


# 文件路径配置
FILEPATH = {
    "ai": {
        "compress": dir_exist(os.path.join(BASE_DIR, 'data/ai/compress')),
        "failed": dir_exist(os.path.join(BASE_DIR, 'data/ai/failed')),
    },
    "study": {
            "compress": dir_exist(os.path.join(BASE_DIR, 'data/study/compress')),
            "failed": dir_exist(os.path.join(BASE_DIR, 'data/study/failed')),
    },
    "report": {
            "compress": dir_exist(os.path.join(BASE_DIR, 'data/report/compress')),
            "failed": dir_exist(os.path.join(BASE_DIR, 'data/report/failed')),
            "backups": dir_exist(os.path.join(BASE_DIR, 'data/report/backups'))
    }
}

SFTP = {
    "host": "172.16.31.10",
    "port": 22,
    "username": "root",
    "password": "<PASSWORD>.",
    # "local": 'F:\\sftptest\\aaa\\test.py', # 本地目录或文件
    "remote": "/data/sftptest/" # 远程目录
}

PARTITION_SIZE = 8*1024*1024    # 8M
Content_Type = "application/octet-stream"  # HTTP请求内容类型
IF_AISERVER = True
IF_INCREASE_STUDY = True
IF_INCREASE_REPORT = True

URL = {
    "AISERVER_URL": "http://172.16.31.10:8004",  # 测试服务器地址
    "AI_UPLOAD_SERVER_URL": "http://172.16.31.10:8001"
}


# Ai相关配置信息
AICONF = {
    "CHANNEL_ID": "0000060000",  # 渠道ID
    "ORGANIZATION_ID": "003131010100000080000000",  # 数据机构ID
    "ACCESS_KEY": "<KEY>",
    "SECRET_KEY": "<KEY>",
    "PUBLIC_KEY": "<KEY>",
    "LocalIP": '10.11.12.91',
    "DeviceID": '00:00:00:00:00:00',
}

# API相关配置
APICONF = {
    "API_VERSION": "1.1",  # API版本
    "API_REQUEST_AI": "/api/ai/request",  # 发起AI请求
    "API_REQUEST_AI_RESULT": "/api/ai/result",  # 获取AI结果
    "API_OUT_PATIENT": '/api/patient/outPatient', # 门诊患者信息
    "API_FILE_UPLOAD": "/fileupload/data/serialUID=",  # 文件地址
}

# 加密相关配置
ENCRYP = {
    "SIGN_METHOD": "sha256",
    "ALGORITHM_KEY": "AES",  # 密钥算法
    "ALGORITHM_ECB": "AES/ECB/PKCS5Padding",  # 加密算法/工作模型/填充模式
}

get = lambda key, default=dict(): sys.modules[__name__].__dict__.get(key, default)

# coding=utf-8

import os
import sys

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

ImageStoragePathMap = {'srcdir':'/dx', '../tests/volume':'C:\\Users\\Administrator\\Desktop'}

def dir_exist(path):
    if not os.path.exists(path):
        os.makedirs(path, exist_ok=True)
    return path

DEBUG = False
PORT = 8085
PROCESS_NUM = 0   # 进程数

# 日志配置
LOGCONF = {
    "dir": "/var/log/webpacsai",
    "name": "main",
    "level": "DEBUG",
    "backcount": 10
}

# 数据库配置
DATABASE = {
    "hyx": {
        'host': '10.119.43.84',
        'user': 'postgres',
        'passwd': '<PASSWORD>',
        'dbname': 'test',
        'encoding': 'utf8',
        'echo': False
    },
    "rispacs": {
        'host': '10.11.12.148',
        'user': 'postgres',
        'passwd': '<PASSWORD>',
        'dbname': 'test',
        'encoding': 'utf8',
        'echo': False
    }
}


# 文件路径配置
FILEPATH = {
    "ai": {
        "compress": dir_exist(os.path.join(BASE_DIR, 'data/ai/compress')),
        "failed": dir_exist(os.path.join(BASE_DIR, 'data/ai/failed')),
    },
    "study": {
            "compress": dir_exist(os.path.join(BASE_DIR, 'data/study/compress')),
            "failed": dir_exist(os.path.join(BASE_DIR, 'data/study/failed')),
    },
    "report": {
            "compress": dir_exist(os.path.join(BASE_DIR, 'data/report/compress')),
            "failed": dir_exist(os.path.join(BASE_DIR, 'data/report/failed')),
            "backups": dir_exist(os.path.join(BASE_DIR, 'data/report/backups'))
    }
}

SFTP = {
    "host": "172.16.31.10",
    "port": 22,
    "username": "root",
    "password": "<PASSWORD>.",
    # "local": 'F:\\sftptest\\aaa\\test.py', # 本地目录或文件
    "remote": "/data/sftptest/" # 远程目录
}

PARTITION_SIZE = 8*1024*1024    # 8M
Content_Type = "application/octet-stream"  # HTTP请求内容类型
IF_AISERVER = True
IF_INCREASE_STUDY = True
IF_INCREASE_REPORT = True

URL = {
    "AISERVER_URL": "http://172.16.31.10:8004",  # 测试服务器地址
    "AI_UPLOAD_SERVER_URL": "http://172.16.31.10:8001"
}


# Ai相关配置信息
AICONF = {
    "CHANNEL_ID": "0000060000",  # 渠道ID
    "ORGANIZATION_ID": "003131010100000080000000",  # 数据机构ID
    "ACCESS_KEY": "<KEY>",
    "SECRET_KEY": "<KEY>",
    "PUBLIC_KEY": "<KEY>",
    "LocalIP": '10.11.12.91',
    "DeviceID": '00:00:00:00:00:00',
}

# API相关配置
APICONF = {
    "API_VERSION": "1.1",  # API版本
    "API_REQUEST_AI": "/api/ai/request",  # 发起AI请求
    "API_REQUEST_AI_RESULT": "/api/ai/result",  # 获取AI结果
    "API_OUT_PATIENT": '/api/patient/outPatient', # 门诊患者信息
    "API_FILE_UPLOAD": "/fileupload/data/serialUID=",  # 文件地址
}

# 加密相关配置
ENCRYP = {
    "SIGN_METHOD": "sha256",
    "ALGORITHM_KEY": "AES",  # 密钥算法
    "ALGORITHM_ECB": "AES/ECB/PKCS5Padding",  # 加密算法/工作模型/填充模式
}

get = lambda key, default=dict(): sys.modules[__name__].__dict__.get(key, default)

# coding=utf-8 # 进程数 # 日志配置 # 数据库配置 # 文件路径配置 # "local": 'F:\\sftptest\\aaa\\test.py', # 本地目录或文件 # 远程目录 # 8M # HTTP请求内容类型 # 测试服务器地址 # Ai相关配置信息 # 渠道ID # 数据机构ID # API相关配置 # API版本 # 发起AI请求 # 获取AI结果 # 门诊患者信息 # 文件地址 # 加密相关配置 # 密钥算法 # 加密算法/工作模型/填充模式