def initData(self, skuWhere=''): try: # 初始加载日期Tab rows = Na_Business_Report.select( Na_Business_Report.report_date).group_by( Na_Business_Report.report_date).order_by( Na_Business_Report.report_date.desc()) self.twDateList.setRowCount(0) _rowCount = len(rows) if (_rowCount > 0): self.twDateList.setRowCount(_rowCount) for i in range(_rowCount): self.twDateList.setItem( i, 0, utQTableWidgetItem(rows[i].report_date)) pass # 初始加载SKU Tab rows = Na_Product_Asin.select() if (skuWhere != ''): rows = eval('rows.where({0})'.format(skuWhere)) self.twSkuList.setRowCount(0) _rowCount = len(rows) nowTime = datetime.datetime.now() self.mainWin.progressBarShow(_rowCount) self.mainWin.statusMsg('开始加载 {0}...'.format( nowTime.strftime('%H:%M:%S'))) if (_rowCount > 0): self.twSkuList.setRowCount(_rowCount) for i in range(_rowCount): self.mainWin.progressBarContinue() self.twSkuList.setItem(i, 0, utQTableWidgetItem(rows[i].sku)) self.twSkuList.setItem(i, 1, utQTableWidgetItem(rows[i].asin)) self.twSkuList.setItem( i, 2, utQTableWidgetItem( self.CHOICES_COMBINE_TYPE[rows[i].combine_type])) endTime = datetime.datetime.now() self.mainWin.statusMsg('加载 {0}条数据,用时{1}'.format( _rowCount, (endTime - nowTime))) self.mainWin.progressBarHide() logger.info('加载了 %s 条, 每页 %s 条' % (i, self.pageSize)) pass self.loadReportList() except Exception as e: logger.info(e) pass
def initData(self, _where=''): try: # 初始加载第一页最新数据 rows = Na_Product_Line.select().paginate(1, self.pageSize) if (_where != ''): rows = eval('rows.where({0})'.format(_where)) self.twProductLine.setRowCount(0) _rowCount = len(rows) self.lbPagerInfo.setText(' R:{0}'.format(_rowCount)) nowTime = datetime.datetime.now() self.mainWin.progressBarShow(_rowCount) self.mainWin.statusMsg('开始加载 {0}...'.format( nowTime.strftime('%H:%M:%S'))) if (_rowCount > 0): # logger.info('加载了 %s 条, 每页 %s 条' %(_rowCount, self.pageSize)) self.twProductLine.setRowCount(_rowCount) for i in range(_rowCount): row = Na_Product_Line(**(rows[i].__data__)) self.mainWin.progressBarContinue() item = utQTableWidgetItem(row.id) # item.setCheckState(Qt.Unchecked) self.twProductLine.setItem(i, 0, item) self.twProductLine.setItem(i, 1, utQTableWidgetItem(row.code)) self.twProductLine.setItem(i, 2, utQTableWidgetItem(row.title)) self.twProductLine.setItem( i, 3, utQTableWidgetItem(row.updated_at)) self.twProductLine.setItem( i, 4, utQTableWidgetItem(row.created_at)) endTime = datetime.datetime.now() self.mainWin.statusMsg('加载 {0}条数据,用时{1}'.format( _rowCount, (endTime - nowTime))) self.mainWin.progressBarHide() logger.info('加载了 %s 条, 每页 %s 条' % (i, self.pageSize)) except Exception as e: logger.info(e) pass
def initData(self, _where=''): try: # 初始加载第一页最新数据,过滤Status为3的记录 try: rows = Pub_Product_Category.select().paginate( 1, self.pageSize).where(Pub_Product_Category.status != 3) dataType = True except Pub_Product_Category.DoesNotExist: # 新增操作 dataType = False if (_where != ''): rows = eval('rows.where({0})'.format(_where)) self.twNewaimProductCategoryList.setRowCount(0) if dataType: _rowCount = len(rows) self.lbPagerInfo.setText(' R:{0}'.format(_rowCount)) nowTime = datetime.datetime.now() self.mainWin.progressBarShow(_rowCount) self.mainWin.statusMsg('开始加载 {0}...'.format( nowTime.strftime('%H:%M:%S'))) if (_rowCount > 0): # logger.info('加载了 %s 条, 每页 %s 条' %(_rowCount, self.pageSize)) self.twNewaimProductCategoryList.setRowCount(_rowCount) for i in range(_rowCount): self.mainWin.progressBarContinue() row = Pub_Product_Category(**(rows[i].__data__)) item = utQTableWidgetItem(row.id) # item.setCheckState(Qt.Unchecked) self.twNewaimProductCategoryList.setItem(i, 0, item) self.twNewaimProductCategoryList.setItem( i, 1, utQTableWidgetItem(row.title)) self.twNewaimProductCategoryList.setItem( i, 2, utQTableWidgetItem(row.code)) self.twNewaimProductCategoryList.setItem( i, 3, utQTableWidgetItem(row.updated_at)) self.twNewaimProductCategoryList.setItem( i, 4, utQTableWidgetItem(row.created_at)) self.twNewaimProductCategoryList.setItem( i, 5, utQTableWidgetItem(row.level)) self.twNewaimProductCategoryList.setItem( i, 6, utQTableWidgetItem(row.parent_id)) endTime = datetime.datetime.now() self.mainWin.statusMsg('加载 {0}条数据,用时{1}'.format( _rowCount, (endTime - nowTime))) self.mainWin.progressBarHide() logger.info('加载了 %s 条, 每页 %s 条' % (i, self.pageSize)) except Exception as e: logger.info(e) pass
def actTbUpdateClicked(self): row_num = -1 for i in self.twOperators.selectionModel().selection().indexes(): row_num = i.row() if row_num > -1: self.twOperators.setItem( row_num, 1, utQTableWidgetItem(self.cbField.currentText())) self.twOperators.setItem( row_num, 2, utQTableWidgetItem(self.cbOperator.currentText())) for field in self.searchObj['fields']: if (field['label'] == self.cbField.currentText()): self.twOperators.setItem(row_num, 0, utQTableWidgetItem(field['name'])) self.twOperators.setItem(row_num, 5, utQTableWidgetItem(field['type'])) self.twOperators.setItem( row_num, 3, utQTableWidgetItem(self.getValueByType(field['type']))) self.twOperators.setItem( row_num, 4, utQTableWidgetItem(self.cbUnion.currentText()))
def actTbAddClicked(self): rows = self.twOperators.rowCount() if rows > 0: pass new_row = rows self.twOperators.setRowCount(new_row + 1) self.twOperators.setItem( new_row, 1, utQTableWidgetItem(self.cbField.currentText())) self.twOperators.setItem( new_row, 2, utQTableWidgetItem(self.cbOperator.currentText())) for field in self.searchObj['fields']: if (field['label'] == self.cbField.currentText()): self.twOperators.setItem(new_row, 0, utQTableWidgetItem(field['name'])) self.twOperators.setItem(new_row, 5, utQTableWidgetItem(field['type'])) self.twOperators.setItem( new_row, 3, utQTableWidgetItem(self.getValueByType(field['type']))) self.twOperators.setItem( new_row, 4, utQTableWidgetItem(self.cbUnion.currentText())) pass
def loadReportList(self, pageNo=1, pageSize=0, asin=None, sku=None, reportDate=None, _where=''): try: # 初始加载最新数据 _pageSize = pageSize if pageSize > 0 else self.pageSize rows = Na_Business_Report.select().paginate( pageNo, _pageSize).order_by(Na_Business_Report.report_date.desc()) if asin != None: if _where == '': rows = rows.where(Na_Business_Report.asin_child == asin) else: rows = eval( 'rows.where((Na_Business_Report.asin_child=="{0}") & {1})' .format(asin, _where)) elif reportDate != None: if _where == '': rows = rows.where( Na_Business_Report.report_date == reportDate) else: rows = eval( 'rows.where((Na_Business_Report.report_date=="{0}") & {1})' .format(reportDate, _where)) elif _where != '': rows = eval('rows.where({0})'.format(_where)) self.twReportList.setRowCount(0) _rowCount = len(rows) nowTime = datetime.datetime.now() self.mainWin.progressBarShow(_rowCount) self.mainWin.statusMsg('开始加载 {0}...'.format( nowTime.strftime('%H:%M:%S'))) if (_rowCount > 0): # logger.info('加载了 %s 条, 每页 %s 条' %(_rowCount, self.pageSize)) self.lbPagerInfo.setText('P:{0} | R:{1}'.format(1, _rowCount)) self.twReportList.setRowCount(_rowCount) for i in range(_rowCount): self.mainWin.progressBarContinue() row = Na_Business_Report(**(rows[i].__data__)) self.twReportList.setItem(i, 0, utQTableWidgetItem(row.id)) item = utQTableWidgetItem('') self.twReportList.setItem(i, 1, item) # item = QTableWidgetItem('%.4f' % row.run_time) # item.setTextAlignment(Qt.AlignRight + Qt.AlignVCenter) # item = QTableWidgetItem('{0}'.format( cuNone2Object(row.asin_parent) )) self.twReportList.setItem( i, 2, utQTableWidgetItem(row.asin_parent)) self.twReportList.setItem( i, 3, utQTableWidgetItem(row.asin_child)) self.twReportList.setItem(i, 4, utQTableWidgetItem(row.title)) self.twReportList.setItem( i, 5, utQTableWidgetItem(row.sessions, 0)) self.twReportList.setItem( i, 6, utQTableWidgetItem(row.sessions_percentage, 0.00)) self.twReportList.setItem( i, 7, utQTableWidgetItem(row.page_view, 0)) self.twReportList.setItem( i, 8, utQTableWidgetItem(row.page_view_percentage, 0.00)) self.twReportList.setItem( i, 9, utQTableWidgetItem(row.buy_box_percentage, 0.00)) self.twReportList.setItem( i, 10, utQTableWidgetItem(row.units_ordered, 0)) self.twReportList.setItem( i, 11, utQTableWidgetItem(row.unit_session_percentage, 0.00)) self.twReportList.setItem( i, 12, utQTableWidgetItem(row.ordered_product_sales, 0.00)) self.twReportList.setItem( i, 13, utQTableWidgetItem(row.total_order_items, 0)) self.twReportList.setItem( i, 14, utQTableWidgetItem(row.report_date)) self.twReportList.setItem( i, 15, utQTableWidgetItem(row.created_at)) endTime = datetime.datetime.now() self.mainWin.statusMsg('加载 {0}条数据,用时{1}'.format( _rowCount, (endTime - nowTime))) self.mainWin.progressBarHide() if _rowCount == 0: self.mainWin.statusMsg('该SKU {0} 对应的报告数据没有记录'.format(sku)) except Exception as e: import traceback traceback.print_exc() logger.info(e)
def initData(self, _where=''): try: # 初始加载第一页最新数据,过滤Status为3的记录 rows = Pub_Product_Asin_Keyword_Relation.select().paginate( 1, self.pageSize) products = True keywords = True if (len(_where) > 0): # products = eval(_where[0]) #categories = eval(_where(1).format(_where[1])) if len(_where) > 1 else categories products = eval(_where[0]) keywords = eval(_where[1]) if len(_where) > 1 else keywords self.twAmazonSKuKeywordRelation.setRowCount(0) _rowCount = len(rows) nowTime = datetime.datetime.now() self.mainWin.progressBarShow(_rowCount) self.mainWin.statusMsg('开始加载 {0}...'.format( nowTime.strftime('%H:%M:%S'))) self.lbPagerInfo.setText(' R:{0}'.format(_rowCount)) if (_rowCount > 0): for i in range(_rowCount): # 去掉第一行 self.twAmazonSKuKeywordRelation.removeRow(_rowCount - i - 1) #self.twAmazonSKuKeywordRelation.setRowCount(_rowCount) rowIndex = 0 for i in range(_rowCount): # 获取关系表数据 row = Pub_Product_Asin_Keyword_Relation( **(rows[i].__data__)) if rows[i].__data__['product_id'] == None or rows[ i].__data__['keyword_id'] == None: continue self.twAmazonSKuKeywordRelation.setRowCount(rowIndex + 1) #获取SKU #skuData = (Na_Product_Asin.select(Pub_Product_Category.title, Na_Product_Asin.sku).join(Pub_Product_Category, on=(Pub_Product_Category.id==rows[i].__data__['category_id'])).where(Na_Product_Asin.id==rows[i].__data__['product_id']).get()) # sql = 'SELECT keyword.title, product.sku FROM Pub_Sku_Keyword keyword JOIN Na_Product_Asin product ON product.id = {} WHERE category.id={}'.format(rows[i].__data__['product_id'] , rows[i].__data__['keyword_id']) # # row = pgDbClection.Conn(self).execute_sql(sql).fetchall() try: skuData = Na_Product_Asin.select().where( (Na_Product_Asin.id == rows[i].__data__['product_id']), products).get() except Na_Product_Asin.DoesNotExist: continue try: keywordData = Pub_Sku_Keyword.select().where( (Pub_Sku_Keyword.id == rows[i].__data__['keyword_id']), keywords).get() except Pub_Sku_Keyword.DoesNotExist: continue # print(skuData.sku) self.mainWin.progressBarContinue() item = utQTableWidgetItem(rowIndex) # item.setCheckState(Qt.Unchecked) self.twAmazonSKuKeywordRelation.setItem(rowIndex, 0, item) self.twAmazonSKuKeywordRelation.setItem( rowIndex, 1, utQTableWidgetItem(skuData.sku)) self.twAmazonSKuKeywordRelation.setItem( rowIndex, 2, utQTableWidgetItem(keywordData.title)) rowIndex = rowIndex + 1 endTime = datetime.datetime.now() self.mainWin.statusMsg('加载 {0}条数据,用时{1}'.format( _rowCount, (endTime - nowTime))) self.mainWin.progressBarHide() logger.info('加载了 %s 条, 每页 %s 条' % (rowIndex, self.pageSize)) except Exception as e: import traceback traceback.print_exc() print(e) logger.info(e) pass
def initData(self, _where = ''): try: # 初始加载第一页最新数据,过滤Status为3的记录 # rows = Amazon_Product_Category_Keyword_Relation.select().paginate(1, self.pageSize) rows = View_I_Amazon_Keyword_Category_Normal.select(View_I_Amazon_Keyword_Category_Normal.keyword,View_I_Amazon_Keyword_Category_Normal.category).where(View_I_Amazon_Keyword_Category_Normal.category != None).paginate(1, self.pageSize) if (_where != ''): rows = eval('rows.where({0})'.format(_where)) self.twAmazonCategoryKeywordRelation.setRowCount(0) _rowCount = len(rows) self.lbPagerInfo.setText(' R:{0}'.format(_rowCount)) nowTime = datetime.datetime.now() self.mainWin.progressBarShow(_rowCount) self.mainWin.statusMsg('开始加载 {0}...'.format(nowTime.strftime('%H:%M:%S'))) if (_rowCount > 0): # for i in range(_rowCount): # # 去掉第一行 # self.View_I_Amazon_Keyword_Category.removeRow(_rowCount - i - 1) self.twAmazonCategoryKeywordRelation.setRowCount(_rowCount) rowIndex = 0 for i in range(_rowCount): # 获取关系表数据 row = View_I_Amazon_Keyword_Category_Normal(**(rows[i].__data__)) print(row.keyword) print(row.category) # if rows[i].__data__['amazon_category_id'] ==None or rows[i].__data__['amazon_keyword_id'] == None: # continue # self.twAmazonCategoryKeywordRelation.setRowCount(rowIndex + 1) # #获取SKU # #skuData = (Amazon_Product_Category.select(Pub_Product_Category.title, Amazon_Product_Category.sku).join(Pub_Product_Category, on=(Pub_Product_Category.id==rows[i].__data__['category_id'])).where(Amazon_Product_Category.id==rows[i].__data__['amazon_category_id']).get()) # # sql = 'SELECT keyword.title, product.sku FROM Pub_Sku_Keyword keyword JOIN Amazon_Product_Category product ON product.id = {} WHERE category.id={}'.format(rows[i].__data__['amazon_category_id'] , rows[i].__data__['amazon_keyword_id']) # # # # row = pgDbClection.Conn(self).execute_sql(sql).fetchall() # # try: # categoryData = Amazon_Product_Category.select().where((Amazon_Product_Category.id == rows[i].__data__['amazon_category_id']) , products).get() # except Amazon_Product_Category.DoesNotExist: # continue # # try: # keywordData = Pub_Sku_Keyword.select().where((Pub_Sku_Keyword.id == rows[i].__data__['amazon_keyword_id']) , keywords).get() # except Pub_Sku_Keyword.DoesNotExist: # continue # print(skuData.sku) self.mainWin.progressBarContinue() item = utQTableWidgetItem(rowIndex) # item.setCheckState(Qt.Unchecked) self.twAmazonCategoryKeywordRelation.setItem(rowIndex,0 ,item) self.twAmazonCategoryKeywordRelation.setItem(rowIndex, 1, utQTableWidgetItem(row.keyword)) self.twAmazonCategoryKeywordRelation.setItem(rowIndex, 2, utQTableWidgetItem(row.category)) rowIndex = rowIndex + 1 endTime = datetime.datetime.now() self.mainWin.statusMsg('加载 {0}条数据,用时{1}'.format(_rowCount, (endTime - nowTime))) self.mainWin.progressBarHide() logger.info('加载了 %s 条, 每页 %s 条' % (rowIndex, self.pageSize)) except Exception as e: import traceback traceback.print_exc() print(e) logger.info(e) pass
def initData(self, _where=''): try: # 初始加载第一页最新数据,过滤Status为3的记录 rows = View_I_Amazon_Sku_Asin_Category_Normal.select( View_I_Amazon_Sku_Asin_Category_Normal.sku, View_I_Amazon_Sku_Asin_Category_Normal.category).where( View_I_Amazon_Sku_Asin_Category_Normal.category != None ).paginate(1, self.pageSize) # print(rows) if (_where != ''): rows = eval('rows.where({0})'.format(_where)) # print(productRows) self.twProductAsinNewaimCategoryList.setRowCount(0) _rowCount = len(rows) self.lbPagerInfo.setText(' R:{0}'.format(_rowCount)) nowTime = datetime.datetime.now() self.mainWin.progressBarShow(_rowCount) self.mainWin.statusMsg('开始加载 {0}...'.format( nowTime.strftime('%H:%M:%S'))) if (_rowCount > 0): for i in range(_rowCount): # 去掉第一行 self.twProductAsinNewaimCategoryList.removeRow(_rowCount - i - 1) self.twProductAsinNewaimCategoryList.setRowCount(_rowCount) rowIndex = 0 for i in range(_rowCount): # 获取关系表数据 row = View_I_Amazon_Sku_Asin_Category_Normal( **(rows[i].__data__)) self.mainWin.progressBarContinue() item = utQTableWidgetItem(rowIndex) # item.setCheckState(Qt.Unchecked) # print(skuData.sku) self.twProductAsinNewaimCategoryList.setItem( rowIndex, 0, item) self.twProductAsinNewaimCategoryList.setItem( rowIndex, 1, utQTableWidgetItem(row.sku)) self.twProductAsinNewaimCategoryList.setItem( rowIndex, 2, utQTableWidgetItem(row.category)) rowIndex = rowIndex + 1 #break endTime = datetime.datetime.now() self.mainWin.statusMsg('加载 {0}条数据,用时{1}'.format( _rowCount, (endTime - nowTime))) self.mainWin.progressBarHide() logger.info('加载了 %s 条, 每页 %s 条' % (rowIndex, self.pageSize)) except Exception as e: import traceback traceback.print_exc() print(e) logger.info(e) pass