def on_btn_save_click(self, state: int, xqid: int): if self.isEditable(state): return if not self.richtext.text(): return # 当前节点是本人提交的或者是新节点 try: self.session.query(MT_TJ_XQGL).filter( MT_TJ_XQGL.DID == xqid).update({ MT_TJ_XQGL.shnr: self.richtext.html(), MT_TJ_XQGL.shsj: cur_datetime(), MT_TJ_XQGL.shxm: self.login_name, MT_TJ_XQGL.state: str(self.self_state), MT_TJ_XQGL.zdy_pj1: self.zdy_pj1.get_score(), MT_TJ_XQGL.zdy_pj2: self.zdy_pj2.get_score(), MT_TJ_XQGL.zdy_pj3: self.zdy_pj3.get_score(), }) self.session.commit() mes_about(self, "验收评价:保存成功!") self.signal_close.emit() except Exception as e: self.session.rollback() mes_about(self, '验收评价:更新 TJ_XQGL 记录失败!错误代码:%s' % e)
def on_btn_add_click(self): sjhm = self.le_sjhm.text() content = self.pt_phone_content.toPlainText() if all([sjhm, content]): data1_obj = { 'jllx': '0080', 'jlmc': '0080', 'tjbh': self.le_tjbh.text(), 'mxbh': sjhm, 'czgh': self.login_id, 'czxm': self.login_name, 'czqy': self.login_area, 'jlnr': content, 'bz': None } data2_obj = { 'tjbh': self.le_tjbh.text(), 'jllx': 1, 'jlnr': content, 'jlr': self.login_name, 'jlsj': cur_datetime() } try: self.session.bulk_insert_mappings(MT_TJ_CZJLB, [data1_obj]) self.session.bulk_insert_mappings(MT_TJ_DHGTJLB, [data2_obj]) self.session.commit() except Exception as e: self.session.rollback() mes_about(self, "执行数据库出错!错误信息:%s" % e) return mes_about(self, '记录成功!') self.on_le_tjbh_press() else: mes_about(self, '手机号码与记录内容不能为空!')
def on_btn_delete_click(self, state: int, xqid: int): if not self.richtext.text(): mes_about(self, "请填写作废理由!") return try: self.session.query(MT_TJ_XQGL).filter( MT_TJ_XQGL.DID == xqid).update({ MT_TJ_XQGL.zfyy: self.richtext.html(), MT_TJ_XQGL.zfsj: cur_datetime(), MT_TJ_XQGL.zfxm: self.login_name, MT_TJ_XQGL.state: None }) self.session.commit() mes_about(self, "需求作废:保存成功!") self.signal_close.emit() except Exception as e: self.session.rollback() mes_about(self, '需求作废:更新 TJ_XQGL 记录失败!错误代码:%s' % e)
def on_btn_save_click(self, state: int, xqid: int): if self.isEditable(state): return if not self.richtext.text(): return try: self.session.query(MT_TJ_XQGL).filter( MT_TJ_XQGL.DID == xqid).update({ MT_TJ_XQGL.syqk: self.richtext.html(), MT_TJ_XQGL.gzsj: cur_datetime(), MT_TJ_XQGL.gzxm: self.login_name, MT_TJ_XQGL.state: str(self.self_state) }) self.session.commit() mes_about(self, "使用跟踪:保存成功!") self.signal_close.emit() except Exception as e: self.session.rollback() mes_about(self, '使用跟踪:更新 TJ_XQGL 记录失败!错误代码:%s' % e)
def on_btn_audit_click(self, shzt: bool, xmzd: str): ''' :param shzt: 审核/取消审核 :param xmzd: 审核:项目诊断;取消审核:取消原因 :return: ''' if not self.cur_tjbh: mes_about(self, '请选择体检顾客!') return # 审核 if shzt: # 更新TJ_TJJLMXB、TJ_EQUIP、TJ_CZJLB try: self.session.query(MT_TJ_TJJLMXB).filter( MT_TJ_TJJLMXB.tjbh == self.cur_tjbh, MT_TJ_TJJLMXB.zhbh == self.cur_zhbh).update({ MT_TJ_TJJLMXB.zxpb: '1', MT_TJ_TJJLMXB.jsbz: '1', MT_TJ_TJJLMXB.qzjs: None, MT_TJ_TJJLMXB.ycbz: '1', MT_TJ_TJJLMXB.shrq: cur_datetime(), MT_TJ_TJJLMXB.shys: self.login_id, MT_TJ_TJJLMXB.zd: xmzd }) data_obj = { 'jllx': '0124', 'jlmc': '%s结果录入' % get_key(self.equips, self.cur_zhbh), 'tjbh': self.cur_tjbh, 'mxbh': self.cur_zhbh, 'czgh': self.login_id, 'czxm': self.login_name, 'czqy': self.login_area, 'jlnr': xmzd, 'bz': None } self.session.bulk_insert_mappings(MT_TJ_CZJLB, [data_obj]) self.gp_review_user.statechange(self.login_name, cur_date()) self.session.commit() mes_about(self, "审核完成!") except Exception as e: self.session.rollback() mes_about(self, "审核失败,错误信息:%s" % e) return # 取消审核 else: bgys = self.table_report_equip.getCurItemValueOfKey('bgys') if self.login_name != bgys: mes_about(self, '该报告不是您审核的,您没有权限修改!') return try: self.session.query(MT_TJ_TJJLMXB).filter( MT_TJ_TJJLMXB.tjbh == self.cur_tjbh, MT_TJ_TJJLMXB.zhbh == self.cur_zhbh).update({ MT_TJ_TJJLMXB.zxpb: '0', MT_TJ_TJJLMXB.jsbz: '0', MT_TJ_TJJLMXB.qzjs: None, MT_TJ_TJJLMXB.ycbz: '1', MT_TJ_TJJLMXB.shrq: None, MT_TJ_TJJLMXB.shys: None, MT_TJ_TJJLMXB.zd: None }) data_obj = { 'jllx': '0128', 'jlmc': '%s结果录入取消' % get_key(self.equips, self.cur_zhbh), 'tjbh': self.cur_tjbh, 'mxbh': self.cur_zhbh, 'czgh': self.login_id, 'czxm': self.login_name, 'czqy': self.login_area, 'jlnr': '%s报告取消审核' % get_key(self.equips, self.cur_zhbh), 'bz': xmzd } self.session.bulk_insert_mappings(MT_TJ_CZJLB, [data_obj]) self.session.commit() self.gp_review_user.statechange() mes_about(self, "取消审核完成!") except Exception as e: self.session.rollback() mes_about(self, "取消审核失败,错误信息:%s" % e) return
def on_btn_submit_click(self, state: int, xqid: int): # 说明已经进入了其他节点 if state > 1: return if not self.le_demand_title.text(): mes_about(self, "请输入需求名称!") return if not self.rt_question_describe.text(): mes_about(self, "请输入现状描述!") return if not self.rt_demand_describe.text(): mes_about(self, "请输入需求描述!") return button = mes_warn(self, "您确定提交本需求?") if button != QMessageBox.Yes: return # 新提交的 if state == 0: # 绑定数据获取对象 data_get_obj = { 'state': '1', 'dname': self.le_demand_title.text(), 'submiter': self.login_name, 'submitime': cur_datetime(), 'expect_date': self.le_expected_time.text(), 'question': self.rt_question_describe.html(), 'demand': self.rt_demand_describe.html(), 'system': self.cb_system.currentText(), 'module': self.cb_module.currentText(), 'level': self.cb_level.currentText(), 'dtype': self.cb_demand_type.currentText(), } try: self.session.bulk_insert_mappings(MT_TJ_XQGL, [data_get_obj]) self.session.commit() mes_about(self, "需求提交:提交成功!") self.signal_close.emit() except Exception as e: self.session.rollback() mes_about(self, '需求提交:插入 TJ_XQGL 记录失败!错误代码:%s' % e) # 编辑的 elif state == 1: print(self.login_name, self.lb_submiter.text()) if self.login_name != self.lb_submiter.text(): return try: self.session.query(MT_TJ_XQGL).filter( MT_TJ_XQGL.DID == xqid).update({ MT_TJ_XQGL.dname: self.le_demand_title.text(), MT_TJ_XQGL.submiter: self.login_name, MT_TJ_XQGL.submitime: cur_datetime(), MT_TJ_XQGL.expect_date: self.le_expected_time.text(), MT_TJ_XQGL.question: self.rt_question_describe.html(), MT_TJ_XQGL.demand: self.rt_demand_describe.html(), MT_TJ_XQGL.system: self.cb_system.currentText(), MT_TJ_XQGL.module: self.cb_module.currentText(), MT_TJ_XQGL.level: self.cb_level.currentText(), MT_TJ_XQGL.dtype: self.cb_demand_type.currentText(), }) self.session.commit() mes_about(self, "需求提交:保存成功!") self.signal_close.emit() except Exception as e: self.session.rollback() mes_about(self, '需求提交:更新TJ_XQGL 记录失败!错误代码:%s' % e)
def on_btn_review_click(self, syzt: bool, num: int): # 未双击过查看过报告 不允许审核 if not self.cur_tjbh: mes_about(self, '您还未打开报告,不允许审阅') return # 完成审阅 if syzt: # 更新数据库 TJ_CZJLB TJ_BGGL data_obj = { 'jllx': '0031', 'jlmc': '报告审阅', 'tjbh': self.cur_tjbh, 'mxbh': '', 'czgh': self.login_id, 'czxm': self.login_name, 'czqy': self.login_area, 'jlnr': str(num), 'bz': self.gp_review_user.get_sybz() } try: self.session.bulk_insert_mappings(MT_TJ_CZJLB, [data_obj]) self.session.query(MT_TJ_BGGL).filter( MT_TJ_BGGL.tjbh == self.cur_tjbh).update({ MT_TJ_BGGL.syxm: self.login_name, MT_TJ_BGGL.sygh: self.login_id, MT_TJ_BGGL.syrq: cur_datetime(), MT_TJ_BGGL.sybz: self.gp_review_user.get_sybz(), MT_TJ_BGGL.sysc: num, MT_TJ_BGGL.bgzt: 2, }) sql = "UPDATE TJ_TJDJB SET TJZT='8' WHERE TJBH='%s';" % self.cur_tjbh self.session.execute(sql) self.session.commit() except Exception as e: self.session.rollback() mes_about(self, '更新数据库失败!错误信息:%s' % e) return # 刷新控件 self.gp_review_user.statechange() # 刷新内存中的数据 self.cur_data[0] = '已审阅' self.cur_data[7] = cur_datetime() self.cur_data[8] = self.login_name self.cur_data[10] = self.gp_review_user.get_sybz() self.datas[self.cur_index] = self.cur_data self.gp_review_user.setData({ 'sybz': self.gp_review_user.get_sybz(), 'syrq': cur_datetime(), 'syxm': self.login_name, 'syzt': 2 }) # HTML 报告需要重新生成 request_create_report(self.cur_tjbh, 'html') # 生成PDF 报告请求 request_create_report(self.cur_tjbh, 'pdf') # 是否发送短信 if self.btn_auto_sms.isChecked(): try: result = self.session.query(MV_RYXX).filter( MV_RYXX.tjbh == self.cur_tjbh).scalar() if result.sjhm: sms_api(result.sjhm, report_sms_content) except Exception as e: mes_about(self, "短信发送失败!错误信息:%s" % e) # 是否下一个 if self.btn_auto_next.isChecked(): self.on_btn_next_click() # 取消审阅 else: if not self.gp_review_user.get_sybz(): mes_about(self, '请您输入取消审阅原因!') return # 更新数据库 TJ_CZJLB TJ_BGGL data_obj = { 'jllx': '0032', 'jlmc': '取消审阅', 'tjbh': self.cur_tjbh, 'mxbh': '', 'czgh': self.login_id, 'czxm': self.login_name, 'czqy': self.login_area, 'bz': self.gp_review_user.get_sybz() } try: self.session.bulk_insert_mappings(MT_TJ_CZJLB, [data_obj]) self.session.query(MT_TJ_BGGL).filter( MT_TJ_BGGL.tjbh == self.cur_tjbh).update({ MT_TJ_BGGL.syxm: None, MT_TJ_BGGL.sygh: None, MT_TJ_BGGL.syrq: None, MT_TJ_BGGL.sybz: None, MT_TJ_BGGL.gcbz: self.gp_review_user.get_sybz(), MT_TJ_BGGL.sysc: 0, MT_TJ_BGGL.bgzt: 1, }) sql = "UPDATE TJ_TJDJB SET TJZT='7' WHERE TJBH='%s';" % self.cur_tjbh self.session.execute(sql) self.session.commit() except Exception as e: self.session.rollback() mes_about(self, '更新数据库失败!错误信息:%s' % e) return # 刷新控件 self.gp_review_user.clearData() # 清空数据 # 刷新内存中的数据 self.cur_data[0] = '已审核' self.cur_data[7] = '' self.cur_data[8] = '' self.cur_data[10] = self.gp_review_user.get_sybz() self.datas[self.cur_index] = self.cur_data
def transfer_pic(self,flag=False): # 是否迁移HTML 图片 # 默认为PDF 图片 # ################ 1、条码号图片 ########################## if flag: bc = BarCodeBuild(path=self.get_html_img_dir) else: bc = BarCodeBuild(path=self.get_img_dir) bc.create2(self.tjbh) # ################ 2、B超、内镜、病理图片 ######################## # 文件传输服务 hander_pis = RemoteFileHandler('administrator', 'tomtaw') hander_pacs = RemoteFileHandler('administrator', 'Admin2389') # 取图片,是否齐全 results = self.session_tjk.query(MT_TJ_PACS_PIC).filter(MT_TJ_PACS_PIC.tjbh == self.tjbh).all() tmp = None count = 0 for result in results: if tmp == result.zhbh: count = count + 1 else: count = 1 tmp = result.zhbh if flag: file_local = os.path.join(self.get_html_img_dir, '%s_%s_%s.jpg' % (result.tjbh, result.zhbh, count)) else: file_local = os.path.join(self.get_img_dir, '%s_%s_%s.jpg' % (result.tjbh, result.zhbh, count)) # 病理 if result.ksbm.strip() == '0026': if result.picpath: file_remote = result.picpath.replace('\\', '/').lstrip('//') is_done, error = hander_pis.down(file_remote, file_local) if is_done: if not self.pic.get(result.zhbh, 0): self.pic[result.zhbh] = [] # if flag: self.pic[result.zhbh].append(file_local.replace(self.html_path,'')) else: self.pic[result.zhbh].append(file_local) else: # 缺图 print('%s:(%s)病理科室:项目(%s)不存在图片!' %(cur_datetime(),self.tjbh,result.zhbh)) self.user_data['sybz'].append('病理科室:项目(%s)不存在图片;' %result.zhbh) # PACS elif result.ksbm.strip() in ['0020', '0024']: if result.picname: file_remote = '10.7.200.101/d$/space/pic/%s' % result.picname.replace('\\', '/') is_done, error = hander_pacs.down(file_remote, file_local) if is_done: if not self.pic.get(result.zhbh, 0): self.pic[result.zhbh] = [] if flag: # print(file_local) # print(file_local.replace(self.html_path, '')) self.pic[result.zhbh].append(file_local.replace(self.html_path, '')) else: self.pic[result.zhbh].append(file_local) #self.pic[result.zhbh].append(file_local) else: # 缺图 print('%s:(%s)彩超/内镜科室:项目(%s)不存在图片!' %(cur_datetime(),self.tjbh,result.zhbh)) self.user_data['sybz'].append('彩超/内镜科室:项目(%s)不存在图片;' % result.zhbh) else: pass # 4、骨密度、心电图、人体成分 results = self.session_tjk.query(MT_TJ_TJJLMXB).filter(MT_TJ_TJJLMXB.tjbh == self.tjbh,MT_TJ_TJJLMXB.sfzh == '1').all() for zhbh in list(set([result.zhbh for result in results])&set(list(('501576','0806','5402','1000074')))): result = self.session_tjk.query(MT_TJ_EQUIP).filter(MT_TJ_EQUIP.tjbh == self.tjbh,MT_TJ_EQUIP.xmbh == zhbh).scalar() # 服务端 if result: if flag: file_local = os.path.join(self.get_html_img_dir, '%s_%s.png' % (result.tjbh, result.xmbh)) else: file_local = os.path.join(self.get_img_dir, '%s_%s.png' % (result.tjbh, result.xmbh)) #file_local = os.path.join(self.get_img_dir, '%s_%s.png' % (result.tjbh, result.xmbh)) if result.file_path: if os.path.exists(result.file_path.replace('.pdf', '.png')): try: shutil.copy2(result.file_path.replace('.pdf', '.png'),file_local) # shutil.copy2(file_local, result.file_path) except Exception as e: print("文件复制失败,错误信息:%s。源码错误:report_build_start/line 521" %(e)) else: # 存在PDF,不存在png 图片,则后台转换,针对历史报告 if os.path.exists(result.file_path): pdf2pic(result.file_path,file_local) else: # 如果心电图PDF不存在,则从DCP_FIELS 读取 if zhbh == '0806': result = self.session_tjk.query(MT_DCP_files).filter(MT_DCP_files.cusn == self.tjbh).scalar() if result: tmp_file = "%s_08.pdf" % self.tjbh with open(tmp_file, "wb") as f: f.write(result.filecontent) pdf2pic(tmp_file, file_local) try: os.remove(tmp_file) except Exception as e: print("删除文件失败(%s),错误信息:%s" %(tmp_file,e)) # 添加 if flag: self.pic['0806'] = file_local.replace(self.html_path, '') else: self.pic['0806'] = file_local return # 添加 if flag: self.pic[result.xmbh] = file_local.replace(self.html_path, '') else: self.pic[result.xmbh] = file_local # self.pic[result.xmbh] = file_local else: # 如果心电图PDF不存在,则从DCP_FIELS 读取 if zhbh == '0806': result = self.session_tjk.query(MT_DCP_files).filter(MT_DCP_files.cusn == self.tjbh).scalar() if result: tmp_file = "%s_08.pdf" % self.tjbh with open(tmp_file, "wb") as f: f.write(result.filecontent) pdf2pic(tmp_file, file_local) try: os.remove(tmp_file) except Exception as e: print("删除文件失败(%s),错误信息:%s" % (tmp_file, e)) # 添加 if flag: self.pic['0806'] = file_local.replace(self.html_path, '') else: self.pic['0806'] = file_local #本地测试 # if result: # if flag: # file_local = os.path.join(self.get_html_img_dir, '%s_%s.png' % (result.tjbh, result.xmbh)) # else: # file_local = os.path.join(self.get_img_dir, '%s_%s.png' % (result.tjbh, result.xmbh)) # # file_local = os.path.join(self.get_img_dir, '%s_%s.png' % (result.tjbh, result.xmbh)) # file_remote = '10.7.200.101/d$/%s' % result.file_path.replace('D:/', '').replace('.pdf', '.png') # is_done, error = hander_pacs.down(file_remote, file_local) # if is_done: # #添加 # if flag: # self.pic[result.xmbh] = file_local.replace(self.html_path, '') # else: # self.pic[result.xmbh] = file_local # self.pic[result.xmbh] = file_local else: # 如果心电图未插入到接口 即TJ_EQUIP中不存在,则从DCP_FIELS 读取 if zhbh == '0806': if flag: file_local = os.path.join(self.get_html_img_dir, '%s_%s.png' % (self.tjbh, '0806')) else: file_local = os.path.join(self.get_img_dir, '%s_%s.png' % (self.tjbh, '0806')) try: # MT_DCP_files 存在重复多条记录 result = self.session_tjk.query(MT_DCP_files).filter(MT_DCP_files.cusn == self.tjbh).scalar() except Exception as e: print("体检编号:%s 表DCP_files中心电图记录重复!" %self.tjbh) result = self.session_tjk.query(MT_DCP_files).filter(MT_DCP_files.cusn == self.tjbh).first() if result: tmp_file = "%s_08.pdf" % self.tjbh with open(tmp_file, "wb") as f: f.write(result.filecontent) pdf2pic(tmp_file, file_local) try: os.remove(tmp_file) except Exception as e: print(e) # 添加 if flag: self.pic['0806'] = file_local.replace(self.html_path, '') else: self.pic['0806'] = file_local else: # 缺图 print('%s (%s)设备接口:项目(%s)不存在图片!' %(cur_datetime(),self.tjbh,zhbh)) self.user_data['sybz'].append('设备接口:项目(%s)不存在图片;' % zhbh)
def report_run(queue): #######################初始化 全局参数###################################### pdf_options = set_report_env(True) log = gol.get_value('report_log') # from pprint import pprint # pprint(pdf_options) ####################### 获取变量 ########################### pdf_config = pdfkit.configuration(wkhtmltopdf=gol.get_value('report_dll')) # wkhtmltopdf 所在位置,带路径。如果加入环境变量,则需路径; pdf_css = gol.get_value('report_css') # 主文件样式表 pdf_cover_css = gol.get_value('report_cover_css') # 封面样式表 pdf_bg_img = gol.get_value('report_head_pic') # 封面背景图 pdf_sign_img = gol.get_value('report_sign') # 签名图片位置 html_css = gol.get_value('report_html_css') # 主文件样式表 html_bg_img = gol.get_value('report_html_head_pic') # 封面背景图 html_sign_img = gol.get_value('report_html_sign') # 签名图片位置 session_tjxt = gol.get_value('session_tjxt') # 数据库链接 session_cxk = gol.get_value('session_cxk') # 数据库链接 cachet = {'zjys':None,'shys':None,'warn':None,'syys':None} # 公章、总检、审核医生签名 footer_user = pdf_options['footer-left'] html_path =gol.get_value('report_html_resource') gc_count = 0 ####################### 数据准备:图片、首页、html ########################### while True: if not queue.empty(): # 循环 try: mes_obj = queue.get_nowait() # 获取进程队列消息,非阻塞模式 except Exception as e: print('%s 进程(ID:%s) 从队列中获得消息出错!' % (cur_datetime(), os.getpid())) mes_obj = {} if mes_obj: gc_count = gc_count + 1 # 显式释放内存 if gc_count==100: gc.collect() print('%s 进程(ID:%s) 从队列中获得消息:%s' %(cur_datetime(),os.getpid(),ujson.dumps(mes_obj))) log.info('%s 进程(ID:%s) 从队列中获得消息:%s' % (cur_datetime(), os.getpid(), ujson.dumps(mes_obj))) action = mes_obj['action'] # 获取执行动作 :生成HTML还是生成PDF还是打印 if action=='print': # 打印服务 filename = mes_obj['filename'] printer = mes_obj['printer'] result = print_pdf_gsprint(filename, printer) if result == 0: print('%s 文件(%s),通过打印机(%s) 打印成功!' % (cur_datetime(), filename,printer)) log.info('%s 文件(%s),通过打印机(%s) 打印成功!' % (cur_datetime(), filename,printer)) else: print('%s 文件(%s),通过打印机(%s) 打印失败!' % (cur_datetime(), filename,printer)) log.info('%s 文件(%s),通过打印机(%s) 打印失败!' % (cur_datetime(), filename,printer)) else: # 报告生成服务 tjbh = mes_obj['tjbh'] # 获取体检编号 time_start = time.time() # pdf 数据对象 pdf_data_obj = PdfData(session_tjxt,session_cxk,gol.get_value('report_path'),tjbh,action) # 设置报告生成状态 pdf_data_obj.set_bgzt(action) # 设置html报告路径 用于网站展示 默认放置 static 目录下 pdf_data_obj.set_html_path(html_path) # ######################## PDF 报告封面是否单独生成 ####################### i_user = pdf_data_obj.get_user_data if not i_user: log.info("未查询到顾客:%s 信息 " %tjbh) return if action=='pdf': # 资源文件位置不一致 i_user['css'] = pdf_css i_user['cover_css'] = pdf_cover_css i_user['head_pic'] = pdf_bg_img sign_img = pdf_sign_img # 传输 图片 pdf_data_obj.transfer_pic() if i_user['film']: i_user['film'] = os.path.join(sign_img, 'tick.png') # 单独生成封面 write_home_html(pdf_data_obj.get_head_html,i_user) ######################## PDF 报告主体 从内容页开始写入 ####################### pdf_build_obj = buildBodyHtml(pdf_data_obj.get_body_html,pdf_css) else: # 资源文件位置不一致 i_user['css'] = html_css i_user['head_pic'] = html_bg_img sign_img = html_sign_img pdf_data_obj.transfer_pic(True) # HTML 报告 if i_user['film']: i_user['film'] = os.path.join(sign_img, 'tick.png') ######################## PDF 报告主体 从首页开始写入 ####################### pdf_build_obj = buildBodyHtml(pdf_data_obj.get_html, pdf_css,False) pdf_data_obj.set_bglj(pdf_data_obj.get_html) pdf_build_obj.write_home(i_user) ######################## 写入排班信息 ######################## pdf_build_obj.write_yspb(pdf_data_obj.get_yspb) ######################## 写入小结、建议信息 ######################## summarys, suggestions = pdf_data_obj.get_user_xjjy pdf_build_obj.write_xj(summarys) pdf_build_obj.write_jy(summarys,suggestions) ######################## 写入总检、审核医生签名及公章 ######################## cachet['zjys'] = os.path.join(sign_img,'%s.png' %i_user['zjys']) cachet['shys'] = os.path.join(sign_img,'%s.png' %i_user['shys']) if i_user['syys']: cachet['syys'] = os.path.join(sign_img,'%s.png' %i_user['syys']) else: cachet['syys'] = None cachet['warn'] = warn pdf_build_obj.write_cachet(cachet) ######################## 写入项目结果 ####################### pdf_build_obj.write_items(pdf_data_obj.get_item_result) ######################## 写入设备报告 ####################### equip_pic = pdf_data_obj.get_equip_pic if equip_pic: pdf_build_obj.write_equip(equip_pic) ######################## 写入保健处方 ####################### health = pdf_data_obj.get_jkcf if health: pdf_build_obj.write_health_care(health) # 关闭文件 pdf_build_obj.close() time_end = time.time() print("%s: %s HTML报告生成成功!耗时:%s " % (cur_datetime(),tjbh,time_end - time_start)) log.info("%s: %s HTML报告生成成功!耗时:%s " % (cur_datetime(),tjbh,time_end - time_start)) # print('HTML头文件:%s' % pdf_data_obj.get_head_html) # print('HTML主文件:%s' % pdf_data_obj.get_body_html) if action == 'pdf': pdf_options['footer-left'] =footer_user %i_user['tjbh'] pdf_toc = {'dump-default-toc-xsl':'pdf_toc'} # pprint(pdf_options) ######################### 生成 PDF ####################### pdfkit.from_file( input=pdf_data_obj.get_body_html, # path to HTML file or list with paths or file-like object output_path=pdf_data_obj.get_pdf, # path to output PDF file. False means file will be returned as string. options=pdf_options, # (optional) dict with wkhtmltopdf options, with or w/o '--' configuration=pdf_config, # (optional) instance of pdfkit.configuration.Configuration() cover=pdf_data_obj.get_head_html, # (optional) string with url/filename with a cover html page css=pdf_css # (optional) string with path to css file which will be added to a single input file ) time_end2 = time.time() print("%s: %s PDF报告生成成功!耗时:%s " %(cur_datetime(),tjbh,time_end2 - time_start)) log.info("%s: %s PDF报告生成成功!耗时:%s " % (cur_datetime(),tjbh,time_end2 - time_start)) pdf_data_obj.set_bglj(pdf_data_obj.get_pdf) ############################## 更新数据库 ######################################## pdf_data_obj.update_user_report() # 删除数据对象 del pdf_data_obj del pdf_build_obj else: time.sleep(1)
def onTableMenu(self, pos): row_num = -1 indexs = self.table_health.selectionModel().selection().indexes() if indexs: for i in indexs: row_num = i.row() menu = QMenu() item1 = menu.addAction(Icon("报告中心"), "报告禁止查询") item2 = menu.addAction(Icon("报告中心"), "报告恢复查询") # item3 = menu.addAction(Icon("预约"), "设置预约客户") # item4 = menu.addAction(Icon("预约"), "电话记录") # item5 = menu.addAction(Icon("预约"), "本次体检结果") # item6 = menu.addAction(Icon("预约"), "历年体检结果") # item7 = menu.addAction(Icon("预约"), "浏览体检报告") # item8 = menu.addAction(Icon("预约"), "下载电子报告") action = menu.exec_(self.table_health.mapToGlobal(pos)) if action == item1: tjbh = self.table_health.getCurItemValueOfKey('tjbh') if not tjbh: mes_about(self, '请先选择一个人!') return button = mes_warn(self, '您确认禁止顾客本人查询体检报告吗?') if button == QMessageBox.Yes: result = self.session.query(MT_TJ_Forbidden).filter( MT_TJ_Forbidden.tjbh == tjbh).scalar() if result: mes_about(self, '该顾客已被禁用!') else: data_obj = { 'tjbh': tjbh, 'operator': self.login_name, 'operatime': cur_datetime() } data_obj2 = { 'tjbh': tjbh, 'jllx': '0129', 'jlmc': '报告禁止查询', 'mxbh': '', 'czgh': self.login_id, 'czxm': self.login_name, 'czqy': self.login_area, } try: self.session.bulk_insert_mappings( MT_TJ_Forbidden, [data_obj]) self.session.bulk_insert_mappings( MT_TJ_CZJLB, [data_obj2]) self.session.commit() mes_about(self, '禁止顾客本人查询体检报告操作成功!') except Exception as e: self.session.rollback() mes_about(self, '禁止顾客查询报告操作失败,错误信息:%s' % e) if action == item2: tjbh = self.table_health.getCurItemValueOfKey('tjbh') if not tjbh: mes_about(self, '请先选择一个人!') return button = mes_warn(self, '您确认恢复顾客本人查询体检报告吗?') if button == QMessageBox.Yes: result = self.session.query(MT_TJ_Forbidden).filter( MT_TJ_Forbidden.tjbh == tjbh).scalar() if not result: mes_about(self, '未找到该体检报告被禁用的记录') else: data_obj = { 'tjbh': tjbh, 'jllx': '0129', 'jlmc': '报告恢复查询', 'mxbh': '', 'czgh': self.login_id, 'czxm': self.login_name, 'czqy': self.login_area, } try: self.session.query(MT_TJ_Forbidden).filter( MT_TJ_Forbidden.tjbh == tjbh).delete() self.session.bulk_insert_mappings( MT_TJ_CZJLB, [data_obj]) self.session.commit() mes_about(self, '恢复顾客本人查询体检报告操作成功!') except Exception as e: self.session.rollback() mes_about(self, '恢复顾客查询报告操作失败,错误信息:%s' % e)