Backend actualizado a v1.0.78

 Cambios aplicados:
📏 Nuevos tamaños de letra:
Preguntas: 11pt en negrita (más grandes y destacadas)
Respuestas: 10pt (tamaño medio legible)
Comentarios: 9pt con indentación (diferenciados visualmente)
🤖 Formato mejorado de comentarios IA:
 Removido prefijo "Análisis IA (98% confianza): "
 Salto de línea doble antes de "Recomendaciones:"
 "Recomendaciones:" ahora en negrita
 Indentación de 10mm en comentarios para mejor jerarquía visual
This commit is contained in:
2025-11-27 17:29:02 -03:00
parent 34221c4726
commit e79aa1f212

View File

@@ -204,7 +204,7 @@ def send_completed_inspection_to_n8n(inspection, db):
# No lanzamos excepción para no interrumpir el flujo normal
BACKEND_VERSION = "1.0.77"
BACKEND_VERSION = "1.0.78"
app = FastAPI(title="Checklist Inteligente API", version=BACKEND_VERSION)
# S3/MinIO configuration
@@ -1369,6 +1369,34 @@ def generate_inspection_pdf(inspection_id: int, db: Session) -> str:
textColor=colors.HexColor('#64748b')
)
# Estilos mejorados para preguntas y respuestas
question_style = ParagraphStyle(
'QuestionStyle',
parent=styles['Normal'],
fontSize=11,
textColor=colors.HexColor('#1f2937'),
spaceAfter=3,
fontName='Helvetica-Bold'
)
answer_style = ParagraphStyle(
'AnswerStyle',
parent=styles['Normal'],
fontSize=10,
textColor=colors.HexColor('#374151'),
spaceAfter=4
)
comment_style = ParagraphStyle(
'CommentStyle',
parent=styles['Normal'],
fontSize=9,
textColor=colors.HexColor('#6b7280'),
spaceAfter=6,
leftIndent=10,
rightIndent=10
)
# Obtener datos
mechanic = db.query(models.User).filter(models.User.id == inspection.mechanic_id).first()
checklist = db.query(models.Checklist).filter(models.Checklist.id == inspection.checklist_id).first()
@@ -1618,9 +1646,9 @@ def generate_inspection_pdf(inspection_id: int, db: Session) -> str:
# Tabla de pregunta/respuesta
question_data = []
# Fila 1: Pregunta
# Fila 1: Pregunta con estilo mejorado
question_data.append([
Paragraph(f"<b>{status_icon} {question.text}</b>", info_style),
Paragraph(f"<b>{status_icon} {question.text}</b>", question_style),
])
# Fila 2: Respuesta y estado - Convertir valor técnico a etiqueta legible
@@ -1628,16 +1656,28 @@ def generate_inspection_pdf(inspection_id: int, db: Session) -> str:
question_data.append([
Table([
[
Paragraph(f"<b>Respuesta:</b> {answer_text}", small_style),
Paragraph(f"<b>Estado:</b> {ans.status.upper()}", ParagraphStyle('status', parent=small_style, textColor=status_color, fontName='Helvetica-Bold'))
Paragraph(f"<b>Respuesta:</b> {answer_text}", answer_style),
Paragraph(f"<b>Estado:</b> {ans.status.upper()}", ParagraphStyle('status', parent=answer_style, textColor=status_color, fontName='Helvetica-Bold'))
]
], colWidths=[120*mm, 50*mm])
])
# Fila 3: Comentario (si existe)
# Fila 3: Comentario mejorado (si existe)
if ans.comment:
comment_text = ans.comment
# Limpiar prefijo de IA si existe
if "Análisis IA (" in comment_text and "): " in comment_text:
# Remover "Análisis IA (98% confianza): "
comment_text = comment_text.split("): ", 1)[1] if "): " in comment_text else comment_text
# Separar análisis y recomendaciones con salto de línea
if "Recomendaciones:" in comment_text or "Recomendación:" in comment_text:
comment_text = comment_text.replace("Recomendaciones:", "<br/><br/><b>Recomendaciones:</b>")
comment_text = comment_text.replace("Recomendación:", "<br/><br/><b>Recomendación:</b>")
question_data.append([
Paragraph(f"<b>Comentario:</b> {ans.comment}", small_style)
Paragraph(f"<b>Comentario:</b> {comment_text}", comment_style)
])
# Fila 4: Imágenes (si existen)