def finDiffstyles(self, stylesId, signal, MenuAiSql): sql = "SELECT * FROM sys_handle_permissions_styles WHERE handlePermissionId ='%s' ;" sql = sql % (stylesId) from_result, diff_list = self.bijiaoCaidan(signal, sql, '按钮styles') for menu in from_result: if diff_list.__contains__(menu["id"]): signal.emit("···正在执行按钮--styles同步(" + menu["id"] + ")···") MenuAiSql.write("-- 按钮styles同步sql------\n") inset_sql = bsUtil.productSql(menu, "sys_handle_permissions_styles") MenuAiSql.write(str(inset_sql))
def compareSencondCaidan(self, menuId, signal, MenuAiSql): sql = "SELECT * FROM sys_menu_permissions where pId ='" + menuId + "' " from_result, diff_list = self.bijiaoCaidan(signal, sql, '二级菜单') for menu in from_result: if diff_list.__contains__(menu["id"]): MenuAiSql.write("-- 二级菜单同步sql------\n") MenuAiSql.write("-- Mark正在处理菜单《" + str(menu["name"]) + "》------\n") inset_sql = bsUtil.productSql(menu, "sys_menu_permissions") MenuAiSql.write(str(inset_sql)) self.findDiffAnNiu(menu['id'], signal, MenuAiSql)
def findDiffAnNiu(self, menuId, signal, MenuAiSql): sql = "SELECT * FROM sys_handle_permissions WHERE menuId ='" + menuId + "' AND rolePermissionAllotId IS NULL AND adminUserPermissionAllotId IS NULL;" from_result, diff_list = self.bijiaoCaidan(signal, sql, '按钮') for menu in from_result: if diff_list.__contains__(menu["id"]): signal.emit("···正在执行按钮同步(" + menu["id"] + ")···") MenuAiSql.write("-- 按钮同步sql------\n") inset_sql = bsUtil.productSql(menu, "sys_handle_permissions") MenuAiSql.write(str(inset_sql)) self.finDiffAttr(menu['id'], signal, MenuAiSql) self.finDiffclass(menu['id'], signal, MenuAiSql) self.finDiffevents(menu['id'], signal, MenuAiSql) self.finDiffstyles(menu['id'], signal, MenuAiSql)
def getDeffMenu(self, caidanName, signal): try: caidanStr = "一级菜单" allCaidanSql = "SELECT * FROM sys_menu_permissions where pId is null" if caidanName is None or caidanName == '': signal.emit("···开始对比所有菜单权限···") else: signal.emit("···开始对比指定菜单《" + caidanName + "》权限···") caidanStr = caidanName + " 菜单" allCaidanSql = "SELECT * FROM sys_menu_permissions where `name` IN ('" + caidanName + "');" from_result, diff_list = self.bijiaoCaidan(signal, allCaidanSql, caidanStr) signal.emit("···请注意即将生成sql 到同级目录的MenuAiSql.txt文件中···") now_time = time.strftime("%Y%m%d%H%M%S", time.localtime()) MenuAiSql = open("./MenuAiSql_" + now_time + ".txt", "a") MenuAiSql.write("-- QmsSyncMenuUtil AUTO PRODUCT SQL ------\n") for menu in from_result: if diff_list.__contains__(menu["id"]): MenuAiSql.write("-- 菜单同步sql------\n") MenuAiSql.write("-- Mark正在处理菜单《" + str(menu["name"]) + "》------\n") inset_sql = bsUtil.productSql(menu, "sys_menu_permissions") MenuAiSql.write(str(inset_sql)) # 既然是新增的,必然可能有新增按钮,随便把按钮也处理了 self.findDiffAnNiu(menu['id'], signal, MenuAiSql) if menu["pId"] is None or menu["pId"] == "": self.compareSencondCaidan(menu["id"], signal, MenuAiSql) else: self.compareTongJiCaidan(menu["id"], signal, MenuAiSql) MenuAiSql.close() signal.emit("···同步sql已生成完毕···") if self.fromDb is not None: self.fromDb.close if self.toDb is not None: self.toDb.close except Exception as e: print(str(e)) error = open("./error_log.txt", "a") error.write(str(e)) error.close() self.textBrowser.insertPlainText("error") if self.fromDb is not None: self.fromDb.close if self.toDb is not None: self.toDb.close
bankkey = bankMap.get(s["inCompanyType"]) backToArticleRecorded = {} backCode = backCode + 1 backToArticleRecorded["code"] = backCode backToArticleRecorded["payType"] = 1 backToArticleRecorded["payeeAccount"] = bankkey backToArticleRecorded["createtime"] = "2020-07-16 12:00:00" backToArticleRecorded["claimstatus"] = 3 backToArticleRecorded["recheckstatus"] = 3 backToArticleRecorded["syncstatus"] = 3 backToArticleRecorded["type"] = 3 backToArticleRecorded["version"] = 0 backToArticleRecorded["outerserialnumber"] = getUUID() id = getUUID() backToArticleRecorded["id"] = id backSql = bsUtil.productSql(backToArticleRecorded, "ums_finance_back_to_article_recorded") backSqls.append(backSql) # 获取认款单数据 claimSql = "select * from ums_finance_claim where id = '" + s["claimId"] + "'" cour.execute(claimSql) claimresult = cour.fetchall()[0] financeClaim = {} financeClaim["type"] = 3 financeClaim["version"] = 0 financeClaim["claimMoney"] = s["adjustMoney"] financeClaim["projectname"] = claimresult["programNum"] financeClaim["feeName"] = claimresult["feeName"] financeClaim["feecode"] = claimresult["code"] financeClaim["summoney"] = claimresult["billMoney"] financeClaim["configId"] = claimresult["configId"] financeClaim["idValue"] = claimresult["idValue"]
def getDefDict(self, signal): try: sql = "select name from sys_dictionary_group" signal.emit("···开始对比所有数据字典组···") self.fromCour.execute(sql) from_result = self.fromCour.fetchall() self.toCour.execute(sql) to_result = self.toCour.fetchall() if len(to_result) < 1 or len(from_result) < 1: print("没有数据") signal.emit("···未查询到数据集合···") return else: tb_to = [] for b in to_result: tb_to.append(b["name"]) tb_to_not = [] zd_not_in_to = [] for i in from_result: if tb_to.__contains__(i["name"]): signal.emit("···开始检查<" + str(i["name"]) + ">下数据项是否新增···") # 查询当前 分组下 的相值是否缺少 sql1 = "select id from sys_dictionary_group where name ='" + i["name"] + "' " self.toCour.execute(sql1) contents_to_zdian_id = self.toCour.fetchall() self.fromCour.execute(sql1) contents_from_zdian_id = self.fromCour.fetchall() sql2 = "select id,value from sys_dictionary where groupId ='%s'" self.toCour.execute(sql2 % contents_to_zdian_id[0]["id"]) contents_to_zdian = self.toCour.fetchall() self.fromCour.execute(sql2 % contents_from_zdian_id[0]["id"]) contents_from_zdian = self.fromCour.fetchall() if len(contents_to_zdian) != len(contents_from_zdian): zd_to = [] for b in contents_to_zdian: zd_to.append(b["value"]) for j in contents_from_zdian: if zd_to.__contains__(j["value"]): pass else: signal.emit("···<" + str(i["name"]) + ">下有新增数据项--[" + str(j["value"]) + "]···") d = {i["name"]: j} zd_not_in_to.append(d) else: tb_to_not.append(i["name"]) signal.emit("···发现新增数据字典组<" + str(i["name"]) + ">···") print("新的字典分组:") now_time = time.strftime("%Y%m%d%H%M%S", time.localtime()) getGroupData = "select * from sys_dictionary_group where name = '%s' " zd_txt = open("./字典变更sql_" + now_time + ".txt", "a") signal.emit("···开始生成同步字典组···") zd_txt.write("-- 开始同步字典组*****************************\n") valueOfGroup = "select * from sys_dictionary where groupId = '%s' " for k in tb_to_not: self.fromCour.execute(getGroupData % k) data = self.fromCour.fetchall()[0] signal.emit("···<" + str(data["name"]) + "> 数据同步中···") inset_sql = bsUtil.productSql(data, "sys_dictionary_group") signal.emit("···" + str(inset_sql) + "···") zd_txt.write(str(inset_sql) + "\n") # 查询当前组下所有的字典项 self.fromCour.execute(valueOfGroup % data["id"]) underGroupData = self.fromCour.fetchall() for ss in underGroupData: under_sql = bsUtil.productSql(ss, "sys_dictionary") signal.emit("···发现字典项" + str(ss["value"]) + " 数据生成中···") signal.emit("···" + str(under_sql) + "···") zd_txt.write(str(under_sql) + "\n") signal.emit("···开始同步新增字典项···") getZdData = "select * from sys_dictionary where id = '%s' " zd_txt.write("-- 开始同步新增字典项*****************************" + "\n") for k in zd_not_in_to: self.fromCour.execute(getZdData % list(k.values())[0]["id"]) data1 = self.fromCour.fetchall()[0] signal.emit("···发现新增字典项<" + str(data1["value"]) + ">···") inset_sql1 = bsUtil.productSql(data1, "sys_dictionary") signal.emit("···" + str(inset_sql1) + "···") zd_txt.write(str(inset_sql1) + "\n") zd_txt.close() signal.emit("*********执行完毕*********") except Exception as e: print(str(e)) error = open("./error_log.txt", "a") error.write(str(e)) error.close() self.textBrowser.insertPlainText("error:\n" + str(e)) if self.fromDb is not None: self.fromDb.close if self.toDb is not None: self.toDb.close
if zd_05.__contains__(j["value"]): pass else: zd_not_in_05[i["id"]] = j else: tb_05_not.append(i["name"]) print("新的字典分组:") now_time = time.strftime("%Y%m%d%H%M%S", time.localtime()) getGroupData = "select * from sys_dictionary_group where name = '%s' " zd_txt = open("./字典变更sql_" + now_time + ".txt", "a") zd_txt.write("-- 开始同步字典组*****************************") for k in tb_05_not: cursor_34.execute(getGroupData % k) data = cursor_34.fetchall()[0] inset_sql = bsUtil.productSql(data, "sys_dictionary_group") zd_txt.write(str(inset_sql)) print(k) print("新增字典项:") getZdData = "select * from sys_dictionary where id = '%s' " zd_txt.write("-- 开始同步新增字典项*****************************") for k, v in zd_not_in_05.items(): print(str(k) + "---------") print(str(v)) cursor_34.execute(getZdData % v["id"]) data1 = cursor_34.fetchall()[0] inset_sql1 = bsUtil.productSql(data1, "sys_dictionary") zd_txt.write(str(inset_sql1)) zd_txt.close()