Баг фикс 1
This commit is contained in:
parent
671b4c89b7
commit
14841c0835
68
web_ui(1).py
68
web_ui(1).py
|
|
@ -20,7 +20,7 @@ import mimetypes
|
||||||
# ЗАГРУЗКА ШАБЛОНОВ ПИСЕМ
|
# ЗАГРУЗКА ШАБЛОНОВ ПИСЕМ
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
IMAGE_EXTS = ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'tiff', 'webp']
|
IMAGE_EXTS = ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'tiff', 'webp']
|
||||||
SHIPPING_TYPES_FILE = "shipping_types(1).json"
|
SHIPPING_TYPES_FILE = "shipping_types.json"
|
||||||
NO_INFO_TEXT = "Информация отсутствует"
|
NO_INFO_TEXT = "Информация отсутствует"
|
||||||
NO_INFO_TEXT_EN = "Information not available"
|
NO_INFO_TEXT_EN = "Information not available"
|
||||||
_UI_DIR = os.path.dirname(os.path.abspath(__file__))
|
_UI_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
@ -356,7 +356,7 @@ def format_dangerous_goods_summary(shipment: Dict) -> str:
|
||||||
if yes:
|
if yes:
|
||||||
return "Да: " + ", ".join(yes)
|
return "Да: " + ", ".join(yes)
|
||||||
if len(explicit_no) == len(dg_keys):
|
if len(explicit_no) == len(dg_keys):
|
||||||
return "Нет (по всем категориям в перечне)"
|
return "Нет"
|
||||||
if explicit_no:
|
if explicit_no:
|
||||||
return (
|
return (
|
||||||
"Нет: " + ", ".join(explicit_no) + " — по остальным категориям информации нет"
|
"Нет: " + ", ".join(explicit_no) + " — по остальным категориям информации нет"
|
||||||
|
|
@ -399,7 +399,7 @@ def format_dangerous_goods_summary_en(shipment: Dict) -> str:
|
||||||
if yes:
|
if yes:
|
||||||
return "Yes: " + ", ".join(yes)
|
return "Yes: " + ", ".join(yes)
|
||||||
if len(explicit_no) == len(dg_keys):
|
if len(explicit_no) == len(dg_keys):
|
||||||
return "No (all categories in the list)"
|
return "No"
|
||||||
if explicit_no:
|
if explicit_no:
|
||||||
return (
|
return (
|
||||||
"No: " + ", ".join(explicit_no) + " — no information on the remaining categories"
|
"No: " + ", ".join(explicit_no) + " — no information on the remaining categories"
|
||||||
|
|
@ -1714,6 +1714,19 @@ def render_shipment_criteria_checklist(
|
||||||
|
|
||||||
return "; ".join(parts) if parts else NO_INFO_TEXT
|
return "; ".join(parts) if parts else NO_INFO_TEXT
|
||||||
|
|
||||||
|
def _format_dimensions_any() -> str:
|
||||||
|
"""
|
||||||
|
Обязательный вывод для критериев с "габаритами":
|
||||||
|
сначала грузовые места, затем габариты ТС, если грузовых нет.
|
||||||
|
"""
|
||||||
|
cargo_dims = _format_dimensions(shipment.get("dimensions"))
|
||||||
|
if cargo_dims != NO_INFO_TEXT:
|
||||||
|
return cargo_dims
|
||||||
|
vehicle_dims = _format_dimensions(shipment.get("vehicle_dimensions"))
|
||||||
|
if vehicle_dims != NO_INFO_TEXT:
|
||||||
|
return vehicle_dims
|
||||||
|
return NO_INFO_TEXT
|
||||||
|
|
||||||
def _join_desc_and_hs(sh: Dict) -> str:
|
def _join_desc_and_hs(sh: Dict) -> str:
|
||||||
desc = (sh.get("cargo_description") or "").strip()
|
desc = (sh.get("cargo_description") or "").strip()
|
||||||
hs = (sh.get("hs_code") or "").strip()
|
hs = (sh.get("hs_code") or "").strip()
|
||||||
|
|
@ -1818,6 +1831,10 @@ def render_shipment_criteria_checklist(
|
||||||
def _answer_for_criterion(criterion_text: str) -> str:
|
def _answer_for_criterion(criterion_text: str) -> str:
|
||||||
c = criterion_text.lower()
|
c = criterion_text.lower()
|
||||||
|
|
||||||
|
# Любой критерий с "габарит" должен в приоритете возвращать размеры, а не перехватываться ветками по весу.
|
||||||
|
if "габарит" in c:
|
||||||
|
return _format_dimensions_any()
|
||||||
|
|
||||||
if "название клиента" in c:
|
if "название клиента" in c:
|
||||||
return (shipment.get("client_name") or "").strip() or NO_INFO_TEXT
|
return (shipment.get("client_name") or "").strip() or NO_INFO_TEXT
|
||||||
if "условия поставки" in c and "incoterms" in c:
|
if "условия поставки" in c and "incoterms" in c:
|
||||||
|
|
@ -1898,11 +1915,19 @@ def render_shipment_criteria_checklist(
|
||||||
):
|
):
|
||||||
return door_clearance_summary(shipment)
|
return door_clearance_summary(shipment)
|
||||||
|
|
||||||
|
# Для FTL/FCL-пунктов о габаритах палет/коробок приоритетно показываем размеры грузовых мест,
|
||||||
|
# не смешивая с проверкой проёмов контейнера.
|
||||||
|
if (
|
||||||
|
("палл" in c or "палет" in c or "короб" in c or "carton" in c or "box" in c)
|
||||||
|
and ("габарит" in c or "размер" in c or "size" in c or "dimension" in c)
|
||||||
|
):
|
||||||
|
return _format_dimensions_any()
|
||||||
|
|
||||||
# Габариты грузовых мест (LTL, FCL «без контейнеров», и п.8 FTL: «если нет данных о количестве
|
# Габариты грузовых мест (LTL, FCL «без контейнеров», и п.8 FTL: «если нет данных о количестве
|
||||||
# машин — габариты каждого грузового места…»). Слово «машин» здесь не про ТС — иначе ниже
|
# машин — габариты каждого грузового места…»). Слово «машин» здесь не про ТС — иначе ниже
|
||||||
# сработала бы ветка vehicle_dimensions и габариты груза не показались бы.
|
# сработала бы ветка vehicle_dimensions и габариты груза не показались бы.
|
||||||
if "габарит" in c and "грузов" in c and "мест" in c:
|
if "габарит" in c and "грузов" in c and "мест" in c:
|
||||||
return _format_dimensions(shipment.get("dimensions"))
|
return _format_dimensions_any()
|
||||||
|
|
||||||
if "габарит" in c and (
|
if "габарит" in c and (
|
||||||
"транспортн" in c
|
"транспортн" in c
|
||||||
|
|
@ -1912,10 +1937,10 @@ def render_shipment_criteria_checklist(
|
||||||
or "прицеп" in c
|
or "прицеп" in c
|
||||||
or "полуприцеп" in c
|
or "полуприцеп" in c
|
||||||
):
|
):
|
||||||
return _format_dimensions(shipment.get("vehicle_dimensions"))
|
return _format_dimensions_any()
|
||||||
|
|
||||||
if "габарит" in c:
|
if "габарит" in c:
|
||||||
return _format_dimensions(shipment.get("dimensions"))
|
return _format_dimensions_any()
|
||||||
|
|
||||||
if "характер груза" in c or "наименование груза" in c:
|
if "характер груза" in c or "наименование груза" in c:
|
||||||
return _join_desc_and_hs(shipment)
|
return _join_desc_and_hs(shipment)
|
||||||
|
|
@ -1953,10 +1978,15 @@ def render_shipment_criteria_checklist(
|
||||||
if msds_negative:
|
if msds_negative:
|
||||||
return msds_negative
|
return msds_negative
|
||||||
if "батаре" in c and _has_batteries(shipment) is not True:
|
if "батаре" in c and _has_batteries(shipment) is not True:
|
||||||
|
# Если батареек нет, документ по батарейкам не нужен.
|
||||||
|
if shipment.get("msds_required") is False:
|
||||||
|
return "Не нужен"
|
||||||
return NO_INFO_TEXT
|
return NO_INFO_TEXT
|
||||||
return _required_doc(shipment.get("msds_required"), "msds")
|
return _required_doc(shipment.get("msds_required"), "msds")
|
||||||
if re.search(r"(?<![a-z])dgm(?![a-z])", c):
|
if re.search(r"(?<![a-z])dgm(?![a-z])", c):
|
||||||
if "батаре" in c and _has_batteries(shipment) is not True:
|
if "батаре" in c and _has_batteries(shipment) is not True:
|
||||||
|
if shipment.get("dgm_report_required") is False:
|
||||||
|
return "Не нужен"
|
||||||
return NO_INFO_TEXT
|
return NO_INFO_TEXT
|
||||||
return _required_doc(shipment.get("dgm_report_required"), "dgm")
|
return _required_doc(shipment.get("dgm_report_required"), "dgm")
|
||||||
|
|
||||||
|
|
@ -2007,9 +2037,30 @@ def render_shipment_criteria_checklist(
|
||||||
|
|
||||||
if "дополнительный сервис" in c or "дополнительные услуги" in c or "дополнительные сервисы" in c or "сервисы" in c:
|
if "дополнительный сервис" in c or "дополнительные услуги" in c or "дополнительные сервисы" in c or "сервисы" in c:
|
||||||
extras = shipment.get("additional_services")
|
extras = shipment.get("additional_services")
|
||||||
if isinstance(extras, list) and extras:
|
lines: List[str] = []
|
||||||
return ", ".join(str(x) for x in extras if str(x).strip()) or NO_INFO_TEXT
|
if isinstance(extras, list):
|
||||||
|
lines.extend(str(x).strip() for x in extras if str(x).strip())
|
||||||
|
|
||||||
|
# Расширение доп.сервисов: показываем штрафы и сроки доставки, если они найдены в спецтребованиях.
|
||||||
|
req = (shipment.get("special_transport_requirements") or "").strip()
|
||||||
|
if req:
|
||||||
|
chunks = [p.strip() for p in req.split("|") if p.strip()]
|
||||||
|
for chunk in chunks:
|
||||||
|
cl = chunk.lower()
|
||||||
|
if any(k in cl for k in ("штраф", "неустой", "penalty", "срок", "transit", "delivery")):
|
||||||
|
lines.append(chunk)
|
||||||
|
|
||||||
|
if not lines:
|
||||||
return NO_INFO_TEXT
|
return NO_INFO_TEXT
|
||||||
|
dedup: List[str] = []
|
||||||
|
seen = set()
|
||||||
|
for line in lines:
|
||||||
|
key = line.lower()
|
||||||
|
if key in seen:
|
||||||
|
continue
|
||||||
|
seen.add(key)
|
||||||
|
dedup.append(line)
|
||||||
|
return ", ".join(dedup) or NO_INFO_TEXT
|
||||||
|
|
||||||
if "спецтребования" in c:
|
if "спецтребования" in c:
|
||||||
return (shipment.get("special_transport_requirements") or "").strip() or NO_INFO_TEXT
|
return (shipment.get("special_transport_requirements") or "").strip() or NO_INFO_TEXT
|
||||||
|
|
@ -2144,6 +2195,7 @@ def render_shipment_criteria_checklist(
|
||||||
# Для FCL по требованию: 5-й верхний столбец должен быть пунктом 9.
|
# Для FCL по требованию: 5-й верхний столбец должен быть пунктом 9.
|
||||||
st_name_for_top = (shipping_type_name or "").strip()
|
st_name_for_top = (shipping_type_name or "").strip()
|
||||||
fcl_types = {
|
fcl_types = {
|
||||||
|
"Автомобильная перевозка (FTL)",
|
||||||
"Морская перевозка (FCL)",
|
"Морская перевозка (FCL)",
|
||||||
"Железнодорожная перевозка (FCL)",
|
"Железнодорожная перевозка (FCL)",
|
||||||
"Мультимодальная перевозка море + ж/д (FCL)",
|
"Мультимодальная перевозка море + ж/д (FCL)",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue