Refactor lab routing by detail items
This commit is contained in:
@@ -16,8 +16,10 @@ from openpyxl.styles import Font
|
||||
|
||||
PROCESSOR_DIR = Path(__file__).resolve().parent / "processors"
|
||||
SUMMARY_SHEET_NAME = "\u672a\u68c0\u6d4b\u5230\u5185\u5bb9\u6c47\u603b"
|
||||
UNASSIGNED_SHEET_NAME = "\u672a\u5f52\u5c5e\u68c0\u6d4b\u5185\u5bb9"
|
||||
UNMATCHED_HEADER = "\u672a\u5339\u914d\u68c0\u6d4b\u5185\u5bb9"
|
||||
UNMATCHED_FILL = PatternFill(fill_type="solid", fgColor="FCE4D6")
|
||||
MAX_PREVIEW_ROWS = 10000
|
||||
SORT_FIELDS = {"none", "name", "sample_time", "reason"}
|
||||
SORT_ORDERS = {"asc", "desc"}
|
||||
|
||||
@@ -556,7 +558,7 @@ def _remove_not_found_rows(workbook) -> None:
|
||||
def _collect_summary_records(workbook) -> list[dict[str, object]]:
|
||||
records: list[dict[str, object]] = []
|
||||
for sheet in workbook.worksheets:
|
||||
if sheet.title == SUMMARY_SHEET_NAME or sheet.max_row < 2:
|
||||
if sheet.title != UNASSIGNED_SHEET_NAME or sheet.max_row < 2:
|
||||
continue
|
||||
header = [_cell_text(sheet.cell(1, col).value) for col in range(1, sheet.max_column + 1)]
|
||||
unmatched_col = _find_header_index(header, UNMATCHED_HEADER)
|
||||
@@ -570,7 +572,7 @@ def _collect_summary_records(workbook) -> list[dict[str, object]]:
|
||||
_cell_text(sheet.cell(row_index, col).value)
|
||||
for col in range(5, standard_end + 1)
|
||||
]
|
||||
if not _all_standard_values_missing(standard_values):
|
||||
if standard_values and not _all_standard_values_missing(standard_values):
|
||||
continue
|
||||
item_values = _summary_item_values(sheet, row_index, header, unmatched_col, standard_end)
|
||||
if not item_values:
|
||||
@@ -874,7 +876,7 @@ def _summarize_workbook(path: Path, output_dir: Path, preview_rows: int) -> Exce
|
||||
try:
|
||||
for sheet in workbook.worksheets:
|
||||
preview: list[list[str]] = []
|
||||
for row in sheet.iter_rows(max_row=max(2, min(preview_rows, 200)), values_only=True):
|
||||
for row in sheet.iter_rows(max_row=max(2, min(preview_rows, MAX_PREVIEW_ROWS)), values_only=True):
|
||||
preview.append([_cell_to_text(value) for value in row])
|
||||
sheets.append(
|
||||
SheetSummary(
|
||||
|
||||
Reference in New Issue
Block a user