feat: daoru_material 增加校验

This commit is contained in:
caoqianming 2024-08-20 14:39:38 +08:00
parent 561c2a0c31
commit 1e667e69ac
1 changed files with 9 additions and 6 deletions

View File

@ -73,21 +73,24 @@ def daoru_material(path: str):
type_str = sheet[f'b{i}'].value.replace(' ', '') type_str = sheet[f'b{i}'].value.replace(' ', '')
try: try:
type = type_dict[type_str] type = type_dict[type_str]
number = sheet[f'a{i}'].value.replace(' ', '') number = sheet[f'a{i}'].value.replace(' ', '') if sheet[f'a{i}'].value else None
name = sheet[f'c{i}'].value.replace(' ', '') if sheet[f'c{i}'].value:
name = sheet[f'c{i}'].value.replace(' ', '')
else:
raise ParseError(f'{i}行物料信息错误: 物料名称必填')
specification = sheet[f'd{i}'].value.replace( specification = sheet[f'd{i}'].value.replace(
'×', '*').replace(' ', '') '×', '*').replace(' ', '') if sheet[f'd{i}'].value else None
model = sheet[f'e{i}'].value.replace(' ', '') model = sheet[f'e{i}'].value.replace(' ', '') if sheet[f'e{i}'].value else None
unit = sheet[f'f{i}'].value.replace(' ', '') unit = sheet[f'f{i}'].value.replace(' ', '')
count_safe = sheet[f'h{i}'].value count_safe = sheet[f'h{i}'].value
unit_price = sheet[f'i{i}'].value unit_price = sheet[f'i{i}'].value
except Exception as e: except Exception as e:
raise ParseError(f'{i}行物料信息错误: {str(e)}') raise ParseError(f'{i}行物料信息错误: {e}')
if type in [20, 30]: if type in [20, 30]:
try: try:
process = process_d[sheet[f'g{i}'].value.replace(' ', '')] process = process_d[sheet[f'g{i}'].value.replace(' ', '')]
except Exception as e: except Exception as e:
raise ParseError(f'{i}行物料信息错误: {str(e)}') raise ParseError(f'{i}行物料信息错误: {e}')
try: try:
filters = {'type': type, 'name': name, 'specification': specification, filters = {'type': type, 'name': name, 'specification': specification,
'model': model, 'unit__iexact': unit} 'model': model, 'unit__iexact': unit}