Пример #1
0
def run():
    main_process_name = gol.get_value('main_process_name', 'hms.exe')
    main_process_path = gol.get_value('main_process_path', 'hms.exe')
    sub_process_name = gol.get_value('sub_process_name', 'cmd.exe')
    log = gol.get_value('log')

    # 结束主进程
    try:
        os.system("taskkill /F /IM %s" %main_process_name)
        log.info('更新主程序前:结束滞留主进程!')
    except Exception as e:
        print(e)

    # 更新文件
    extra_update_file()
    # 更新版本号
    try:
        update_version()
    except Exception as e:
        log.info('版本文件:version.ini 更新失败!错误信息:%s' %e)
    # 启动主进程
    try:
        os.popen(main_process_path)
        log.info('更新主程序完成:重启主进程!')
    except Exception as e:
        print(e)

    # 结束自身进程
    try:
        os.system("taskkill /F /IM %s" %sub_process_name)
        log.info('更新主程序完成:结束自身进程!')
    except Exception as e:
        print(e)
Пример #2
0
def extra_update_file():
    update_path = '%s/%s' %(gol.get_value('app_path') ,gol.get_value('update_path'))
    file_zips = glob.glob(os.path.join(update_path,'*.zip'))
    file_rars = glob.glob(os.path.join(update_path,'*.rar'))
    # print(file_zip,file_rar)

    if file_zips:
        for file_zip in file_zips:
            file_zip_obj = zipfile.ZipFile(file_zip, 'r')
            for file in file_zip_obj.namelist():
                try:
                    file_zip_obj.extract(file, gol.get_value('app_path'))
                except Exception as e:
                    print("文件%s:解压失败。错误信息:%s" %(file,e))
            # file_zip.extractall(gol.get_value('app_path'))
            file_zip_obj.close()
            os.remove(file_zip)

    if file_rars:
        for file_rar in file_rars:
            file_rar_obj = rarfile.RarFile(file_rar, 'r')
            for file in file_rar_obj.namelist():
                try:
                    file_rar_obj.extract(file, gol.get_value('app_path'))
                except Exception as e:
                    print("文件%s:解压失败。错误信息:%s" %(file,e))
            #file_rar_obj.extractall(gol.get_value('app_path'))
            file_rar_obj.close()
            os.remove(file_rar)
Пример #3
0
 def run(self):
     while self.runing:
         for tjbh in self.tjbhs:
             # for i in range(len(self.tjbhs)-1,-1,-1):
             # 中途暂停打印 处理
             if self.runing:
                 if self.is_remote:
                     # 网络打印
                     if api_print(tjbh, self.printer):
                         # 打印成功
                         self.signalCur.emit(tjbh, 1)
                     else:
                         # 打印失败
                         self.signalCur.emit(tjbh, 0)
                 else:
                     # 本地打印 需要下载
                     url = gol.get_value('api_report_down') % tjbh
                     filename = os.path.join(gol.get_value('path_tmp'),
                                             '%s.pdf' % tjbh)
                     if request_get(url, filename):
                         # 打印成功
                         if print_pdf_gsprint(filename) == 0:
                             # 打印成功
                             self.signalCur.emit(tjbh, 1)
                         else:
                             # 打印失败
                             self.signalCur.emit(tjbh, 0)
                     else:
                         # 打印失败
                         self.signalCur.emit(tjbh, 0)
             else:
                 return
         self.stop()
         self.signalExit.emit()
Пример #4
0
    def closeEvent(self, QEvent):
        if self.close_count == 1:
            # 第二次直接关闭子进程,无须提示信息
            QEvent.accept()
        else:
            button = mes_warn(self, "温馨提示:您确认退出系统吗?")
            if button != QMessageBox.Yes:
                QEvent.ignore()
                return
            else:
                QEvent.accept()
        self.close_count = self.close_count + 1
        try:
            self.session.query(MT_TJ_LOGIN).filter(
                MT_TJ_LOGIN.login_id == self.login_id,
                MT_TJ_LOGIN.lid == gol.get_value('login_lid', 0)).update(
                    {MT_TJ_LOGIN.login_out: cur_datetime()})
            self.session.commit()
        except Exception as e:
            self.session.rollback()
            mes_about(self, '执行发生错误:%s' % e)

        super(TJ_Main_UI, self).closeEvent(QEvent)
        try:
            if hasattr(self, 'SampleManager'):
                getattr(self, 'SampleManager').close()
        except Exception as e:
            self.log.info("关闭时发生错误:%s " % e)

        QThread.currentThread().quit()
        self.log.info("用户:%s(%s) 退出成功!" % (
            gol.get_value('login_user_name', '未知'),
            gol.get_value('login_user_id', ''),
        ))
Пример #5
0
 def initParas(self):
     self.login_title = gol.get_value('login_title', '明州体检')
     self.lgoin_width = gol.get_value('login_width', 500)
     self.login_height = gol.get_value('login_height', 400)
     self.login_bg = file_ico("login.png")
     self.login_style = "font: 75 14pt \"微软雅黑\";" \
                   "color:  rgb(45, 135, 66);" \
                   "background-image: url(:/resource/image/login.png);"
     self.login_font = "font: 75 8pt;color:  #CD0000"
     # 获取用户名
     self.session = gol.get_value("tjxt_session_local")
     self.log = gol.get_value("log")
Пример #6
0
    def closeEvent(self, *args, **kwargs):
        super(TJ_Main_UI, self).closeEvent(*args, **kwargs)
        try:
            if hasattr(self, 'SampleManager'):
                getattr(self, 'SampleManager').close()
        except Exception as e:
            self.log.info("关闭时发生错误:%s " % e)

        QThread.currentThread().quit()
        self.log.info("用户:%s(%s) 退出成功!" % (
            gol.get_value('login_user_name', '未知'),
            gol.get_value('login_user_id', ''),
        ))
Пример #7
0
 def open_page(self, data):
     self.cur_data = data
     bgzt = data[0]
     tjbh = data[3]
     xm = data[4]
     xb = data[5]
     nl = data[6]
     syrq = data[7]
     syxm = data[8]
     dwmc = data[9]
     sybz = data[10]
     self.cur_tjbh = tjbh
     # 更新title
     self.gp_bottom.setTitle('体检编号:%s  姓名:%s 性别:%s  年龄:%s  单位名称:%s' %
                             (tjbh, xm, xb, nl, dwmc))
     self.gp_bottom.setStyleSheet(
         '''font: 75 14pt '微软雅黑';color: rgb(0,128,0);''')
     # 未审阅则打开HTML 页面
     url = gol.get_value('api_report_preview') % ('html', tjbh)
     self.wv_report_equip.load(url)
     # 刷新界面
     self.gp_review_user.setData({
         'sybz': sybz,
         'syrq': syrq,
         'syxm': syxm,
         'syzt': bgzt
     })
     results = self.session.query(MT_TJ_TJJLMXB).filter(
         MT_TJ_TJJLMXB.tjbh == self.cur_tjbh,
         MT_TJ_TJJLMXB.xmbh.in_(
             ('1122', '1931', '0903', '501732', '501933', '501934'))).all()
     if results:
         self.gp_review_user.setData2(",".join(
             [str2(result.xmmc) for result in results]))
Пример #8
0
 def __init__(self):
     nodes= ['导检收单']
     super(RegisterManager,self).__init__('登记管理',nodes)
     default_menu_name = gol.get_value('menu_child_name','')
     if default_menu_name in nodes:
         self.addTab(default_menu_name)
     self.addTab('导检收单')
Пример #9
0
    def report_show(tjbh):
        print(' %s:外网客户端(%s):%s报告预览请求!' %
              (cur_datetime(), request.remote_addr, tjbh))
        tmp_path = app.config['UPLOAD_FOLDER_TMP']
        tmp_filename = os.path.join(tmp_path, "%s.pdf" % tjbh)
        if len(str(tjbh)) == 8:
            tjbh = '%09d' % tjbh
        elif len(str(tjbh)) == 9:
            tjbh = str(tjbh)
        else:
            abort(404)

        result = db.session.query(MT_TJ_BGGL).filter(
            MT_TJ_BGGL.tjbh == tjbh).scalar()
        if result:
            if result.bglj:
                filename = os.path.join(result.bglj, "%s.pdf" % tjbh)
                if os.path.exists(filename):
                    shutil.copy2(filename, tmp_filename)
                    return ujson.dumps({'code': 1, 'mes': '处理成功', 'data': ''})

        # 历史
        session = gol.get_value('tj_cxk')
        result = session.query(MT_TJ_PDFRUL).filter(
            MT_TJ_PDFRUL.TJBH == tjbh).order_by(
                MT_TJ_PDFRUL.CREATETIME.desc()).scalar()
        if result:
            filename = os.path.join('D:/pdf/', result.PDFURL)
            if os.path.exists(filename):
                shutil.copy2(filename, tmp_filename)
                return ujson.dumps({'code': 1, 'mes': '处理成功', 'data': ''})

        abort(404)
Пример #10
0
    def addTab(self, title):
        super(InfoManager, self).addTab(title)
        if gol.get_value('login_user_name',
                         '') not in ['朱飞达', '张倩', '陈璇玑', '张兆丰', '管理员', '陈卫龙']:
            mes_about(self, "您没有查看的权限!")
            return
        if title == '固定资产':
            from .info_asset import InfoEquipAsset
            widget = InfoEquipAsset(self)
            self.rwidget.addPage(widget, Icon(title), title)

        elif title == '机密文档':
            from .info_supplier import InfoSupplier
            widget = InfoSupplier(self)
            self.rwidget.addPage(widget, Icon(title), title)

        elif title == '值班交接':
            from .info_overtime import InfoOverTime
            widget = InfoOverTime(self)
            self.rwidget.addPage(widget, Icon(title), title)

        elif title == '工作总结':
            from .info_work_summary import WorkSummaryWidget
            widget = WorkSummaryWidget(self)
            self.rwidget.addPage(widget, Icon(title), title)
Пример #11
0
    def report_print(tjbh, printer):
        print(' %s:客户端(%s):%s报告打印请求!' %
              (cur_datetime(), request.remote_addr, tjbh))
        if len(str(tjbh)) == 8:
            tjbh = '%09d' % tjbh
        elif len(str(tjbh)) == 9:
            tjbh = str(tjbh)
        else:
            abort(404)
        result = db.session.query(MT_TJ_BGGL).filter(
            MT_TJ_BGGL.tjbh == tjbh).scalar()
        if result:
            if result.bglj:
                filename = os.path.join(result.bglj, "%s.pdf" % tjbh)
                if os.path.exists(filename):
                    mes_obj = {
                        'filename': filename,
                        'action': 'print',
                        'printer': printer
                    }
                    if print_queue:
                        print_queue.put(mes_obj)
                        return ujson.dumps({
                            'code': 1,
                            'mes': '报告打印成功!',
                            'data': ''
                        })

        # else:
        # 历史
        session = gol.get_value('tj_cxk')
        result = session.query(MT_TJ_PDFRUL).filter(
            MT_TJ_PDFRUL.TJBH == tjbh).order_by(
                MT_TJ_PDFRUL.CREATETIME.desc()).scalar()
        if result:
            filename = os.path.join('D:/pdf/', result.PDFURL)
        else:
            filename = os.path.join('D:/tmp/', '%s.pdf' % tjbh)
            url = "http://10.8.200.201:4000/api/file/down/%s/%s" % (tjbh,
                                                                    'report')
            request_get(url, filename)
        if os.path.exists(filename):
            mes_obj = {
                'filename': filename,
                'action': 'print',
                'printer': printer
            }
            if print_queue:
                print_queue.put(mes_obj)
                return ujson.dumps({'code': 1, 'mes': '报告打印成功!', 'data': ''})
            else:
                abort(404)
            # result= print_pdf_gsprint(filename,printer)
            # if result==0:
            #     return ujson.dumps({'code': 1, 'mes': '报告打印成功!', 'data': ''})
            # else:
            #     return ujson.dumps({'code': 0, 'mes': '报告打印失败!', 'data': ''})
        else:
            abort(404)
Пример #12
0
def sql_init(sqlfile, paras: dict):
    log = gol.get_value("log")
    sqlfile = os.path.join(gol.get_value("path_sql"), '%s' % sqlfile)
    try:
        content = open(sqlfile).read()
        try:
            return Template(content).substitute(paras)
        except Exception as e:
            log.info('SQL文件:%s 初始化解析有误,会影响查询结果,请检查!错误信息:%s' % (sqlfile, e))
            try:
                return Template(content).safe_substitute(paras)
            except Exception as e:
                log.info('SQL文件:%s 初始化解析错误,请检查!' % e)
                return ''
    except Exception as e:
        log.info('SQL文件:%s 读取失败,请检查文件编码!错误信息:%s' % (sqlfile, e))
        return ''
Пример #13
0
def get_chart_url(title,tstart,tend):
    default_url = "http://10.7.200.101:5005/api/chart/%s/%s/%s" %(title,tstart,tend)
    config_url = gol.get_value('api_chart_show',None)
    if config_url:
        url = config_url  %(title,tstart,tend)
    else:
        url = default_url
    return url
Пример #14
0
def request_create_report(tjbh, filetype='html'):
    url = gol.get_value('api_report_create') % (filetype, tjbh, 'BSSA')
    response = requests.post(url)
    if response.status_code == 200:
        print('API:%s 上传请求成功!' % url)
        return response.json()
    else:
        print('API:%s 上传请求失败!' % url)
        return False
Пример #15
0
def sure_path(file_path):
    try:
        if not os.path.isdir(file_path):
            os.makedirs(file_path)
        return True
    except Exception as e:
        log = gol.get_value("log")
        log.info('路径:%s 不准确,请调整!错误信息:%s' % (file_path, e))
        return False
Пример #16
0
def get_pdf_url(session,tjbh):
    # 优先打开 新系统生成的
    result = session.query(MT_TJ_BGGL).filter(MT_TJ_BGGL.tjbh == tjbh).scalar()
    if result:
        filename = os.path.join(result.bglj, '%s.pdf' % tjbh).replace('D:/activefile/', '')
        url = gol.get_value('api_pdf_new_show') % filename
        return url
    else:
        try:
            ora_session = gol.get_value('cxk_session')
            result = ora_session.query(MT_TJ_PDFRUL).filter(MT_TJ_PDFRUL.TJBH == tjbh).scalar()
            if result:
                url = gol.get_value('api_pdf_old_show') % result.PDFURL
                return url
            else:
                return False
        except Exception as e:
            return False
Пример #17
0
def request_chart_get(title,tstart,tend):
    default_url = "http://10.7.200.101:5005/api/chart/%s/%s/%s" %(title,tstart,tend)
    config_url = gol.get_value('api_chart_show',None)
    if config_url:
        url = config_url  %(title,tstart,tend)
    else:
        url = default_url
    response = requests.get(url)
    return response
Пример #18
0
def set_equip_env(termial=False):
    app_path = os.path.split(os.path.abspath(sys.argv[0]))[0]
    parse_log = get_log_class('parse.log')
    gol.init()
    gol.set_value('parse_log', parse_log)  # 添加设备日志   # 防止多进程日志写入冲突
    gol.set_value("host_name", hostname())  # 添加主机名
    gol.set_value("host_ip", hostip())  # 添加主机IP
    gol.set_value("app_path", app_path)  # 添加程序根目录
    gol.set_value("path_tmp", "%s/tmp/" % app_path)  # 添加临时文件目录
    gol.set_value("path_ico", "%s/resource/image/" % app_path)  # 添加资源文件目录
    gol.set_value("path_sql", "%s/sqlfiles/" % app_path)  # 添加SQL文件目录

    # 读取配置文件,加入全局参数
    parse_log.info('程序启动......')
    gol.merge(config_parse('mztj.ini'))  # 主程序配置
    parse_log.info('读取配置(mztj.ini)文件成功')
    gol.merge(config_parse('parse.ini'))  # 设备解析配置
    parse_log.info('读取配置(parse.ini)文件成功')
    gol.merge(config_parse('custom.ini'))  # 用户登录信息
    parse_log.info('读取配置(custom.ini)文件成功')
    gol.merge(config_parse('version.ini'))  # 版本信息
    parse_log.info('读取配置(version.ini)文件成功')
    gol.merge(config_parse('database.ini', True))  # 数据库配置
    parse_log.info('读取配置(database.ini)文件成功')

    # app_api = APIRquest(login_id=gol.get_value('login_user_id',''),
    #                 host = gol.get_value('api_host',''),
    #                 port = gol.get_value('api_port',''),
    #                 log = gol.get_value('log','')
    #                 )
    # gol.set_value('app_api', app_api)                                           # 添加API请求

    ####################体检数据链接#####################################
    session = get_tjxt_session(hostname=gol.get_value('tjxt_host',
                                                      '10.8.200.201'),
                               dbname=gol.get_value('tjxt_database', 'tjxt'),
                               user=gol.get_value('tjxt_user', 'bsuser'),
                               passwd=gol.get_value('tjxt_passwd',
                                                    'admin2389'),
                               port=gol.get_value2('tjxt_port', 1433),
                               echo=termial)
    gol.set_value("tjxt_session_local", session)
    if termial:
        gol.print_paras()
Пример #19
0
 def initParas(self):
     self.log = gol.get_value('log')
     self.stylesheet = file_style(gol.get_value('file_qss', 'mztj.qss'))
     self.update_auto = gol.get_value('update_auto', True)
     self.update_timer = gol.get_value('update_timer', 360)
     self.user_menu_sid = gol.get_value('menu_sid', 5001)
     self.login_id = gol.get_value('login_user_id')
     sys_version = gol.get_value('system_version', 1.0)
     update_url = gol.get_value(
         'system_update', "http://10.7.200.101:5005/api/version/%s/%s")
     self.url = update_url % (get_system(), sys_version)
Пример #20
0
 def init(self):
     try:
         self.tmp_file = gol.get_value('path_tmp')
         self.log = gol.get_value('log', '')
         self.session = gol.get_value('tjxt_session_local', '')
         self.session_lis = gol.get_value('lis_session', '')
         self.login_id = gol.get_value('login_user_id', '')
         self.login_name = gol.get_value('login_user_name', '')
         self.login_time = gol.get_value('login_time', '')
         self.login_area = gol.get_value('login_area', '')
         self.api_host = gol.get_value('api_host', '')
         self.api_port = gol.get_value('api_port', '')
     except Exception as e:
         self.log = ''
         self.session = ''
         self.login_id = ''
         self.login_name = ''
         self.login_time = ''
         self.login_area = ''
Пример #21
0
def set_report_env(termial=False):
    app_path = os.path.split(os.path.abspath(sys.argv[0]))[0]
    # 打开日志功能
    report_log = get_log_class('report.log')
    gol.init()
    # 添加基础参数
    gol.set_value('report_log', report_log)  # 添加设备日志   # 防止多进程日志写入冲突
    gol.set_value("host_name", hostname())  # 添加主机名
    gol.set_value("host_ip", hostip())  # 添加主机IP
    gol.set_value("app_path", app_path)  # 添加程序根目录
    gol.set_value("path_tmp", "%s/tmp/" % app_path)  # 添加临时文件目录

    # 读取本地配置文件,加入全局参数
    report_log.info('程序启动......')
    parse, no_parse = config_report_parse('report.ini')
    gol.merge(parse)  # 服务配置
    report_log.info('读取配置(report.ini)文件成功')
    # 连接数据库,设置session
    ####################体检数据链接#####################################
    try:
        session = get_tjxt_session(
            hostname=gol.get_value('tjxt_host', '10.8.200.201'),
            dbname=gol.get_value('tjxt_database', 'tjxt'),
            user=gol.get_value('tjxt_user', 'bsuser'),
            passwd=gol.get_value('tjxt_passwd', 'admin2389'),
            port=gol.get_value2('tjxt_port', 1433))
    except Exception as e:
        session = None
        report_log.info('连接体检数据库失败!错误信息:%s' % e)
    try:
        cxk_session = get_cxk_session()
    except Exception as e:
        cxk_session = None
        report_log.info('连接外网查询库数据库失败!错误信息:%s' % e)
    gol.set_value("session_tjxt", session)
    gol.set_value("session_cxk", cxk_session)
    if termial:
        gol.print_paras()

    return no_parse
Пример #22
0
 def initUI(self):
     self.lb_version = StatusLabel('版本:v%s' %gol.get_value('system_version',''))
     self.lb_version.clicked.connect(self.label_clicked)
     self.lb_login = StatusLabel('用户:%s '%gol.get_value('login_user_name',''))
     self.lb_login.clicked.connect(self.label_clicked)
     self.lb_hostname = StatusLabel('主机:%s ' % gol.get_value('host_name','未获取到'))
     self.lb_hostip = StatusLabel('IP:%s ' % gol.get_value('host_ip','未获取到'))
     self.lb_room = StatusLabel('房间:%s ' % gol.get_value('login_area', '未获取到'))
     self.lb_room.clicked.connect(self.label_clicked)
     self.lb_count_login = StatusLabel('登录:')
     self.lb_count_login.clicked.connect(self.label_clicked)
     self.lb_count_online = StatusLabel('在线:')
     self.lb_count_online.clicked.connect(self.label_clicked)
     self.lb_handle_mes = StatusLabel()
     self.lb_login_time = StatusLabel(' 登录时间:%s ' % gol.get_value('login_time',''))
     self.lb_cur_time = StatusLabel()
     self.lb_cur_time.setText(" 当前时间:%s " %time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())))
     self.addWidget(self.lb_version)
     self.addWidget(self.lb_login)
     self.addWidget(self.lb_hostname)
     self.addWidget(self.lb_hostip)
     self.addWidget(self.lb_room)
     self.addWidget(self.lb_count_login)
     self.addWidget(self.lb_count_online)
     # self.addWidget(self.lb_handle_mes)
     self.addPermanentWidget(self.lb_login_time)
     self.addPermanentWidget(self.lb_cur_time)
Пример #23
0
def api_print(tjbh, printer):
    url = gol.get_value("api_report_print", None)
    if url:
        # try:
        response = requests.post(url % (tjbh, printer))
        if response.status_code == 200:
            if response.json()['code'] == 1:
                # if '报告打印成功' in response.json():
                return True
            else:
                return False
        else:
            return False
Пример #24
0
    def report_down(tjbh):
        print(' %s:客户端(%s):%s报告下载请求!' %
              (cur_datetime(), request.remote_addr, tjbh))
        if len(str(tjbh)) == 8:
            tjbh = '%09d' % tjbh
        elif len(str(tjbh)) == 9:
            tjbh = str(tjbh)
        else:
            abort(404)
        # 当前
        result = db.session.query(MT_TJ_BGGL).filter(
            MT_TJ_BGGL.tjbh == tjbh).scalar()
        if result:
            if result.bglj:
                filename = os.path.join(result.bglj, "%s.pdf" % tjbh)
                if os.path.exists(filename):
                    update_czjl(db.session, tjbh, request.remote_addr)
                    # 返回下载
                    response = make_response(
                        send_file(filename, as_attachment=True))
                    response.headers['Content-Type'] = mimetypes.guess_type(
                        os.path.basename(filename))[0]
                    response.headers[
                        'Content-Disposition'] = 'attachment; filename={}'.format(
                            os.path.basename(filename))
                    return response

        # 历史
        session = gol.get_value('tj_cxk')
        result = session.query(MT_TJ_PDFRUL).filter(
            MT_TJ_PDFRUL.TJBH == tjbh).order_by(
                MT_TJ_PDFRUL.CREATETIME.desc()).scalar()
        if result:
            filename = os.path.join('D:/pdf/', result.PDFURL)
            if os.path.exists(filename):
                update_czjl(db.session, tjbh, request.remote_addr)
                #返回下载
                response = make_response(
                    send_file(filename, as_attachment=True))
                response.headers['Content-Type'] = mimetypes.guess_type(
                    os.path.basename(filename))[0]
                response.headers[
                    'Content-Disposition'] = 'attachment; filename={}'.format(
                        os.path.basename(filename))
                return response

        # 向历史的报告服务发送请求
        url = "http://10.8.200.201:4000/api/file/down/%s/%s" % (tjbh, 'report')
        return api_file_down(url)
Пример #25
0
def build_chart(title,datas,chart='bar',height=240):
    url2 = "http://10.7.200.101:5005/api/chart/show/%s"
    default_url = "http://10.7.200.101:5005/api/chart/create/%s/%s"
    url = gol.get_value('api_chart_ctrate',None)
    if not url:
        url =default_url
    try:
        response = requests.post(url %(chart,height), data=json.dumps({'title':title,'datas':datas}))
        if response.status_code == 200:
            filename = response.json().get('data',None)
            if filename:
                print(url2 %filename)
                return url2 %filename
    except Exception as e:
        return None
Пример #26
0
def trans_pacs_pic(tjbh, ksbm, xmbh):
    url_default = "http://10.7.200.101:4009/api/pacs/pic/%s/%s/%s" % (
        tjbh, ksbm, xmbh)
    url_config = gol.get_value('api_pacs_pic', '')
    if url_config:
        url = url_config % (tjbh, ksbm, xmbh)
    else:
        url = url_default
    try:
        response = requests.post(url)
        if response.status_code == 200:
            if response.json()['code'] == 1:
                return True
            else:
                return False
    except Exception as e:
        return False
Пример #27
0
def create_app():
    # 基础配置  # 修改静态文件夹的目录
    app = Flask(__name__, static_folder='', static_url_path='')
    # 跨域访问
    # CORS(app, supports_credentials=True,resources=r'/*')
    # app = Flask(__name__,static_url_path='/app_reportserver/')
    # app.config["SQLALCHEMY_DATABASE_URI"] = "mssql+pymssql://bsuser:[email protected]/tjxt"
    # app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] =False
    # app.config["SQLALCHEMY_ECHO"] =False
    # app.config["SQLALCHEMY_COMMIT_ON_TEARDOWN"]=True
    # app.config['UPLOAD_FOLDER'] = 'D:/tmp/'

    app.config["SQLALCHEMY_DATABASE_URI"] = gol.get_value(
        "SQLALCHEMY_DATABASE_URI")
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = gol.get_value(
        "SQLALCHEMY_TRACK_MODIFICATIONS")
    app.config["SQLALCHEMY_ECHO"] = gol.get_value("SQLALCHEMY_ECHO")
    app.config["SQLALCHEMY_COMMIT_ON_TEARDOWN"] = gol.get_value(
        "SQLALCHEMY_COMMIT_ON_TEARDOWN")
    app.config['UPLOAD_FOLDER_PHOTO'] = gol.get_value(
        "SQLALCHEMY_UPLOAD_FOLDER_PHOTO")
    app.config['UPLOAD_FOLDER_EQUIP'] = gol.get_value(
        "SQLALCHEMY_UPLOAD_FOLDER_EQUIP")
    app.config['UPLOAD_FOLDER_REPORT'] = gol.get_value(
        "SQLALCHEMY_UPLOAD_FOLDER_REPORT")
    app.config['UPLOAD_FOLDER_UPDATE'] = gol.get_value(
        "SQLALCHEMY_UPLOAD_FOLDER_UPDATE")
    app.config['UPLOAD_FOLDER_TMP'] = gol.get_value(
        "SQLALCHEMY_UPLOAD_FOLDER_TMP")

    # 日志配置
    # handler = TimedRotatingFileHandler(filename='api_server.log',when='d',interval=1,backupCount=10)
    # formatter = logging.Formatter('[%(asctime)s-%(levelname)s] - %(message)s')
    # handler.setLevel(logging.INFO)
    # handler.setFormatter(formatter)
    # app.logger.addHandler(handler)

    return app
Пример #28
0
 def __init__(self, parent=None):
     super(SelfHelpMachine, self).__init__(parent)
     # 载入样式
     self.stylesheet = file_style(gol.get_value('file_qss', 'mztj.qss'))
     with open(self.stylesheet) as f:
         self.setStyleSheet(f.read())
     self.setWindowTitle('明州体检')
     self.setWindowIcon(Icon('mztj'))
     self.initUI()
     self.setBackgroundImage()
     # 绑定信号槽
     self.le_tjbh.returnPressed.connect(self.on_le_tjbh_press)
     self.btn_sfz.clicked.connect(self.on_btn_sfz_read)
     self.btn_keyboard.clicked.connect(self.on_btn_keyboard_click)
     # 右键菜单
     self.setContextMenuPolicy(Qt.CustomContextMenu)  ######允许右键产生子菜单
     self.customContextMenuRequested.connect(self.onTableMenu)  ####右键菜单
     # 特殊变量
     self.gp_keyboard = None  #键盘区域
     self.print_thread = None
     self.dg_p = None  #进度窗口,温馨提示
     self.pd_ui_num = 0
Пример #29
0
    http_server.serve_forever()

def server_on_tornado_run(app,host,port):
    http_server = HTTPServer(WSGIContainer(app))
    http_server.listen(port,host)
    IOLoop.instance().start()

if __name__ == '__main__':
    import cgitb
    cgitb.enable(logdir="./error/",format="text")
    multiprocessing.freeze_support()
    Init_env_vars(['api.ini'])
    # 全局进程队列
    gol_print_queue = Queue()
    gol_report_queue = Queue()
    process_print_num = gol.get_value('process_print_num', 3)
    process_report_num = gol.get_value('process_report_num', 3)
    ##############打印进程########################
    for i in range(process_print_num):
        print_process = Process(target=report_run_api, args=(gol_print_queue,),name="报告生成进程%s" %str(i+1))
        # 启动报告服务
        print_process.start()
    ##############报告进程########################
    for i in range(process_report_num):
        report_process = Process(target=report_run_api, args=(gol_report_queue,),name="报告生成进程%s" %str(i+1))
        # 启动报告服务
        report_process.start()
    ##############创建进程组####################
    # p = Pool(processes=process_count)
    # for i in range(process_count):
    #     p.apply_async(report_run_api,(gol_process_queue,))  # 向进程池添加任务
Пример #30
0
 def get_gol_para(self, para_name):
     return gol.get_value(para_name, '')