def EGFR_Liquid_reissue(code=""): # check EGFR_Liquid_user login db = getConnection() cur = db.cursor() sql = "select * from EGFR_Liquid_user" cur.execute(sql) user = cur.fetchall() user = user[0]["name"] if user == DEFAULT_USER: return render_template("barcode_please_login.html", title="barcode") # EGFR_Liquid_user log out sql = "update EGFR_Liquid_user SET name='" + DEFAULT_USER + "'" cur.execute(sql) db.commit() cur.close() db.close() barcodeID = [int("8" + str(int(code.split("21-")[1])).zfill(10) + "9")] imgs = [bg.get_kit_id_img(i) for i in barcodeID] sheet = bg.sheet_img() sheet.define_kit_id_images(imgs) sheet.define_cordinates() sheet.add_kit_id_images() sheet.write_sheet_img(str(barcodeID[0])) return render_template("barcode.html", title="barcode", sheetID=str(barcodeID[0]))
def EGFR_Liquid_issue(num=0): # check EGFR_Liquid_user login db = getConnection() cur = db.cursor() sql = "select * from EGFR_Liquid_user" cur.execute(sql) user = cur.fetchall() cur.close() db.close() user = user[0]["name"] if user == DEFAULT_USER: return render_template("barcode_please_login.html", title="barcode") # issue new kitId/barcode db = getConnection() cur = db.cursor() sql = "select * from EGFR_Liquid" cur.execute(sql) table = cur.fetchall() kitIds = [int(i["id"]) for i in table] if not len(table) == 0 else [0] newKitID = [str(max(kitIds) + i + 1).zfill(10) for i in range(int(num))] barcodeID = [int("8" + i + "9") for i in newKitID] imgs = [bg.get_kit_id_img(i) for i in barcodeID] sheet = bg.sheet_img() sheet.define_kit_id_images(imgs) sheet.define_cordinates() sheet.add_kit_id_images() sheet.write_sheet_img(newKitID[0] + ".png") # update EGFR_Liquid_table timestamp = datetime.datetime.now().strftime('%Y年%m月%d日 %H:%M:%S') for i in newKitID: cur = db.cursor() sql = "insert into LIMS.EGFR_Liquid values ('" + i + "', '" + user + "','','','','','','','','','','" + timestamp + "')" cur.execute(sql) db.commit() # EGFR_Liquid_user log out sql = "update EGFR_Liquid_user SET name='" + DEFAULT_USER + "'" cur.execute(sql) db.commit() cur.close() db.close() #return render_template("success.html", title="success") return render_template("barcode.html", title="barcode", sheetID=newKitID[0])
# -*- coding: utf-8 -*- import modules.barcode_generator as bg if __name__ == '__main__': #kits = sys.argv[1] kits = [ 800000000019, 800000000029, 800000000039, 800000000049, 800000000059, 800000000069 ] imgs = [bg.get_kit_id_img(i) for i in kits] sheet = bg.sheet_img() sheet.define_kit_id_images(imgs) sheet.define_cordinates() sheet.add_kit_id_images() sheet.write_sheet_img("test.png")