3cb97d99 by 冯轩

init 5377

1 parent 0be86bfd
......@@ -498,6 +498,8 @@ class BSWorkbook(Workbook, LoggerMixin):
return row_value
def build_month_sheet(self, ms, role_name, card, month_mapping, is_reverse, statistics_header_info, max_column, classify):
self.online_log.warn('{0} [build_month_sheet] [role_name={1}] [card={2}] [month_mapping={3}] [is_reverse={4}] [statistics_header_info={5}] [max_column={6}]'.format(
self.log_base, role_name, card, month_mapping, is_reverse, statistics_header_info, max_column))
summary_cell_idx = statistics_header_info.get(consts.SUMMARY_KEY)
date_cell_idx = statistics_header_info.get(consts.DATE_KEY)
amount_cell_idx = statistics_header_info.get(consts.AMOUNT_KEY) # None or src or append
......@@ -506,6 +508,8 @@ class BSWorkbook(Workbook, LoggerMixin):
outlay_cell_idx = statistics_header_info.get(consts.OUTLAY_KEY)
borrow_cell_idx = statistics_header_info.get(consts.BORROW_KEY)
header = list(statistics_header_info.get(consts.HEADER_KEY))
self.online_log.warn('{0} [build_month_sheet] [summary_cell_idx={1}] [date_cell_idx={2}] [amount_cell_idx={3}] [over_cell_idx={4}] [income_cell_idx={5}] [outlay_cell_idx={6}] [borrow_cell_idx={7}]'.format(
self.log_base, summary_cell_idx, date_cell_idx, amount_cell_idx, over_cell_idx, income_cell_idx, outlay_cell_idx, borrow_cell_idx))
src_header_len = len(header)
if max_column > src_header_len:
for i in range(max_column - src_header_len):
......@@ -809,6 +813,49 @@ class BSWorkbook(Workbook, LoggerMixin):
for sheet in sheets_list:
self.remove(self.get_sheet_by_name(sheet))
# 5.新增统计项
# jyds_per_month 统计主要交易对手,按月提示交易频繁的交易对手信息(如前三名对手姓名及交易总金额)
jyds_per_month = {}
sheet_date_pattern = re.compile(r'^\d{4}-\d{2}')
number_of_sheets = len(self.worksheets)
self.online_log.warn('{0} [bs_rebuild new ==========>] [number_of_sheets={1}]'.format(self.log_base, number_of_sheets))
for sheet in self.worksheets:
sheet_name = sheet.title
#self.online_log.warn('{0} [bs_rebuild new ==========>] [sheet name={1}]'.format(self.log_base, sheet_name))
#for row in sheet.iter_rows(values_only=True):
# self.online_log.warn('{0} [bs_rebuild new ==========>] [sheet row={1}]'.format(
# self.log_base, row))
# self.online_log.warn('-' * 40)
if sheet_date_pattern.match(sheet_name[:7]):
self.online_log.warn('{0} [bs_rebuild new ==========>] [sheet name={1}] 的前7位满足 yyyy-MM 格式'.format(self.log_base, sheet_name))
# 月明细sheet中,统计jyds_per_month信息
jyds_name_idx = -1
jyds_amount_idx = -1
for row in sheet.iter_rows(min_row=1, max_row=1, values_only=True):
for cell_idx, cell_value in row:
if cell_value == '交易对手':
jyds_name_idx = cell_idx
if cell_value == '金额':
jyds_amount_idx = cell_idx
one_month_detail = {}
for row in sheet.iter_rows(min_row=2, values_only=True):
jyds_name = row[jyds_name_idx]
jyds_amount = row[jyds_amount_idx]
if jyds_amount is None or jyds_amount == "":
jyds_amount_float = 0.0
else:
jyds_amount_float = float(jyds_amount)
if jyds_name in one_month_detail:
one_month_detail[jyds_name] += jyds_amount_float
else:
one_month_detail[jyds_name] = jyds_amount_float
sorted_data = sorted(one_month_detail.items(), key=lambda x: int(x[1]), reverse=True)[:3]
jyds_per_month[sheet_name] = sorted_data
else:
self.online_log.warn('{0} [bs_rebuild new ==========>] [sheet name={1}] 的前7位不满足 yyyy-MM 格式'.format(self.log_base, sheet_name))
self.online_log.warn('{0} [bs_rebuild new ==========>] [jyds_per_month={1}]'.format(self.log_base, jyds_per_month))
def license_rebuild(self, license_summary, document_scheme, count_list):
for classify, (_, name, field_order, side_diff, scheme_diff, field_str) in consts.LICENSE_ORDER:
license_list = license_summary.get(classify)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!