def read_excel(filename, username): filename = './sample/contract/' + filename + ".xlsx" workbook = xlrd.open_workbook(filename) sheet = workbook.sheet_by_index(0) row = sheet.nrows col = sheet.ncols print("行数", row, "列数", col) contract_name = sheet.cell(1, 1).value print(contract_name) contract_id = util.get_id(username, contract_name) party_a = sheet.cell(2, 2).value print(party_a) sig_a = "lll" party_b = sheet.cell(3, 2).value print(party_b) sig_b = "lll" valid_time = "2019-08-14" object_desc = '' content = [] for i in range(8, row): res = {} res['person'] = sheet.cell(i, 1).value res['premise'] = sheet.cell(i, 2).value res['res'] = sheet.cell(i, 3).value res['time'] = "" print(sheet.cell(i, 3).value) content.append(res) print(content) db.save_contract(username, contract_name, contract_id, party_a, sig_a, party_b, sig_b, valid_time, object_desc, json.dumps(content))
def save(): args = request.get_json() contract_id = util.get_id(args['username'], args['contract_name']) db.save_contract(args['username'], args['contract_name'], contract_id, args['party_a'], args['sig_a'], args['party_b'], args['sig_b'], args['valid_time'], args['object_desc'], json.dumps(args['content'])) print(args['content']) #t = threading.Thread(target=create_task, args=(args['content'],contract_id)) #t.start() #t.join() #create_task(json.dumps(args['content']),contract_id) return 'success'
def saveContract(): args = request.get_json() contract_id = util.get_id(args['contract_name']) jsondata = json.dumps(args['content']) GenerateDGA(jsondata, contract_id) res = db.save_contract(args['contract_name'], contract_id, args['Obligor'], args['creditor'], jsondata) ConctracList = db.getConctracList() return render_template('contractList.html', contractList=ConctracList), 200