50017fdb by 周伟奇

add split \n

1 parent 95966861
......@@ -896,6 +896,7 @@ OTHER_CLASSIFY_SET = {OTHER_CLASSIFY}
LICENSE_CLASSIFY_SET_1 = {IC_CLASSIFY, VAT_CLASSIFY, MVC_CLASSIFY, MVI_CLASSIFY}
LICENSE_CLASSIFY_SET_2 = {BL_CLASSIFY, UCI_CLASSIFY, EEP_CLASSIFY, DL_CLASSIFY, PP_CLASSIFY, BC_CLASSIFY}
NYYH_CLASSIFY = 17
MS_CLASSIFY = 21
MS_ERROR_COL = (5, 6)
WECHART_CLASSIFY = 12
......
......@@ -312,7 +312,7 @@ class BSWorkbook(Workbook):
return res_str
@staticmethod
def wechart_func(row_value, pre_col, next_col):
def rm_cn_char(row_value, pre_col, next_col):
row_value = list(row_value)
if isinstance(row_value[pre_col], str):
cn_chars = re.findall(consts.CN_RE, row_value[pre_col])
......@@ -324,6 +324,29 @@ class BSWorkbook(Workbook):
row_value[next_col] = '{0}\n{1}'.format(cn_str, row_value[next_col])
return row_value
@staticmethod
def rm_second_row(row_value, amount_cell_idx, over_cell_idx):
row_value = list(row_value)
if isinstance(over_cell_idx, int) and isinstance(amount_cell_idx, int):
max_idx = max(over_cell_idx, amount_cell_idx)
elif isinstance(over_cell_idx, int):
max_idx = over_cell_idx
elif isinstance(amount_cell_idx, int):
max_idx = amount_cell_idx
else:
max_idx = 0
if max_idx > 1:
append_list = []
for i in range(2, max_idx+1):
if isinstance(row_value[i], str):
split_list = row_value[i].split('\n')
row_value[i] = split_list[0]
append_list.extend(split_list[1:])
if isinstance(row_value[1], str):
append_list.insert(0, row_value[1])
row_value[1] = '\n'.join(append_list)
return row_value
def build_month_sheet(self, ms, card, month_mapping, is_reverse, statistics_header_info, max_column, classify):
summary_cell_idx = statistics_header_info.get(consts.SUMMARY_KEY)
date_cell_idx = statistics_header_info.get(consts.DATE_KEY)
......@@ -357,9 +380,11 @@ class BSWorkbook(Workbook):
for row_value in ws.iter_rows(min_row=part[1], max_row=part[2], values_only=True):
if any(row_value):
if classify == consts.WECHART_CLASSIFY:
row_value = self.wechart_func(row_value, *consts.WECHART_ERROR_COL)
row_value = self.rm_cn_char(row_value, *consts.WECHART_ERROR_COL)
elif classify == consts.MS_CLASSIFY:
row_value = self.wechart_func(row_value, *consts.MS_ERROR_COL)
row_value = self.rm_cn_char(row_value, *consts.MS_ERROR_COL)
elif classify == consts.NYYH_CLASSIFY:
row_value = self.rm_second_row(row_value, amount_cell_idx, over_cell_idx)
new_ws.append(row_value)
# 3.2.提取信息、高亮
amount_mapping = {}
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!