def get_json(hos): header = ce.config().get('get', 'content_type') token = ce.config().get('get', 'token') url = ce.config().get('get', 'url') headers = {'Content-Type': header, 'X-Access-Token': token} response = requests.get(url + hos, headers=headers) s = response.json() # print(s["data"]["rows"][0]) return s
def post_json(data_json): data = str(data_json) # print(data_json) header = ce.config().get('path', 'content_type') token = ce.config().get('path', 'token') url = ce.config().get('path', 'url') headers = {'Content-Type': header, 'X-Access-Token': token} #print(headers) response = requests.post(url=url, headers=headers, json=json.loads(data)) print(response.json())
def user_json(): try: Data_sheet = con.globalw().sheets()[0] # 获取总行数 rowNum = Data_sheet.nrows for i in range(1, rowNum): mt = con.read(i, 0) if mt[2] == '男': cn = 'M' elif mt[2] == '女': cn = 'F' if mt[3] != '': cf = mt[3] else: cf = con.mobile() if mt[5] != '': cc = mt[5] else: cc = "" if mt[4] != '': ce = mt[4] else: ce = 1234 module_json = '{'+'"'+'code'+'"'+':''"'+mt[0]+'"\n'+\ ',''"'+'description'+'"'+':''"'+'"\n'+\ ',''"'+'email'+'"'+':''"'+str(cc)+'"\n'+\ ',''"'+'format'+'"'+':''"'+'json'+'"\n'+\ ',''"'+'gender'+'"'+':''"'+str(cn)+'"\n'+\ ',''"'+'hos_id'+'"'+':''"'+str(con.config().get('path', 'hos_id'))+'"\n'+\ ',''"'+'method'+'"'+':''"'+'hidoctor.user.add'+'"\n'+\ ',''"'+'mobile'+'"'+':''"'+str(int(cf))+'"\n'+\ ',''"'+'name'+'"'+':''"'+str(mt[1])+'"\n'+\ ',''"'+'password'+'"'+':''"'+str(int(ce))+'"\n'+\ ',''"'+'role_id'+'"'+':''"'+str(con.config().get('path', 'role_id'))+'"\n'+\ ',''"'+'skills'+'"'+':''"'+''+'"\n'+\ ',''"'+'v'+'"'+':''"'+'1.0'+'"'+'}\n' print(module_json) return module_json except Exception as e: print(e)
def insert_json(yid, code, name, address, phone, status): try: server = con.hot() db = pymysql.connect(server[0], server[1], server[2], con.config().get('mysql', 'db'), charset='utf8') # 使用cursor()方法获取操作游标 cursor = db.cursor() # 创建数据表SQL语句 sql = """insert into hos(yid, code, name, address, phone, status) values(%s,%s,%s,%s,%s,%s);""" cd = cursor.execute(sql, [yid, code, name, address, phone, status]) db.commit() except Exception as e: raise RuntimeWarning(yid+' '+'数据已存在,请检查') finally: db.close()
def select_dept_hos(): try: server = con.hot() db = pymysql.connect(server[0], server[1], server[2], con.config().get('mysql', 'db'), charset='utf8') # 使用cursor()方法获取操作游标 cursor = db.cursor() sql = """SELECT did,hos_id FROM department;""" cursor.execute(sql) db = cursor.fetchall() cursor.close() return db except Exception as e: print(e) finally: cursor.close()
def dept_insert_json(did, hos_id, code, type, name, creator, created, modifier, status): try: server = con.hot() db = pymysql.connect(server[0], server[1], server[2], con.config().get('mysql', 'db'), charset='utf8') # 使用cursor()方法获取操作游标 cursor = db.cursor() # 创建数据表SQL语句 sql = """insert into department(did, hos_id ,code, type, name, creator, created, modifier, status) values(%s,%s,%s,%s,%s,%s,%s,%s,%s);""" cd = cursor.execute(sql, [did, hos_id, code, type, name, creator, created, modifier, status]) db.commit() # db.close() except Exception as e: raise RuntimeWarning(did+' '+'数据已存在,请检查') finally: db.close()
def update_dept_user(dept_id, dept_name, duty_id, duty_name, hos_id, u_id): try: server = con.hot() db = pymysql.connect(server[0], server[1], server[2], con.config().get('mysql', 'db'), charset='utf8') # 使用cursor()方法获取操作游标 cursor = db.cursor() # 创建数据表SQL语句 sql = """UPDATE hos_user SET dept_id = %s,dept_name = %s,duty_id = %s,duty_name = %s WHERE hos_id = %s AND u_id = %s ;""" cd = cursor.execute(sql, [dept_id, dept_name, duty_id, duty_name, hos_id, u_id]) db.commit() cursor.close() db.close() except Exception as e: print(e) finally: print()
def department_json(): try: Data_sheet = con.globalw().sheets()[1] # 获取总行数 rowNum = Data_sheet.nrows print(rowNum) for i in range(1, rowNum): mt = con.read(i, 1) if '门诊' in mt[2]: cn = '1' elif '住院' in mt[2]: cn = '2' print(str(mt[0])) module_json = '{' + '"' + 'code' + '"' + ':''"' + str(mt[0]) + '"\n' + \ ',''"' + 'format' + '"' + ':''"' + 'json' + '"\n' + \ ',''"' + 'type' + '"' + ':''"' + str(cn) + '"\n''' + \ ',''"' + 'hos_id' + '"' + ':''"' + str(con.config().get('path', 'hos_id')) + '"\n' + \ ',''"' + 'method' + '"' + ':''"' + 'hidoctor.dept.add' + '"\n' + \ ',''"' + 'name' + '"' + ':''"' + str(mt[1]) + '"\n' + \ ',''"' + 'v' + '"' + ':''"' + '1.0' + '"' + '}\n' con.conversion(module_json) except Exception as e: print(e)