Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -209,34 +209,12 @@ def process_equipment_utilization(equip, proj, use_h, idle_h, move_f, cost_h, la
|
|
| 209 |
logger.error(f"Error in process_equipment_utilization: {e}")
|
| 210 |
raise ValueError(f"Processing failed: {str(e)}")
|
| 211 |
|
| 212 |
-
def format_output(result):
|
| 213 |
-
summary = result.get("Summary", {})
|
| 214 |
-
cost_val = summary.get("Cost per Hour", 0)
|
| 215 |
-
try:
|
| 216 |
-
cost_str = locale.currency(cost_val, grouping=True)
|
| 217 |
-
except:
|
| 218 |
-
cost_str = f"₹{cost_val:,.2f}"
|
| 219 |
-
conf_pct = summary.get("Confidence", 0) # Already percentage (0-100)
|
| 220 |
-
util_score = summary.get("Utilization Score", 0) # Already percentage (0-100)
|
| 221 |
-
lines = [
|
| 222 |
-
f" • AI Suggestion: {summary.get('Suggestion', 'N/A')}",
|
| 223 |
-
f" • Suggestion Confidence: {conf_pct:.2f}%",
|
| 224 |
-
f" • Utilization Score: {util_score:.2f}%",
|
| 225 |
-
f" • Equipment Name: {summary.get('Equipment Name', 'N/A')}",
|
| 226 |
-
f" • Project: {summary.get('Project', 'N/A')}",
|
| 227 |
-
f" • Usage Hours: {summary.get('Usage Hours', 0):.2f}",
|
| 228 |
-
f" • Idle Hours: {summary.get('Idle Hours', 0):.2f}",
|
| 229 |
-
f" • Cost per Hour: {cost_str}",
|
| 230 |
-
f" • Last Maintenance: {summary.get('Last Maintenance', 'N/A')}"
|
| 231 |
-
]
|
| 232 |
-
return "\n".join(lines)
|
| 233 |
-
|
| 234 |
def format_batch_output(records):
|
| 235 |
lines = []
|
| 236 |
for i, rec in enumerate(records, 1):
|
| 237 |
summary = rec.get("Summary", {})
|
| 238 |
-
|
| 239 |
-
#
|
| 240 |
record_details = [
|
| 241 |
f"Record {i}:",
|
| 242 |
f" • Record ID: {rec['Salesforce_Record_Id']}",
|
|
@@ -252,6 +230,7 @@ def format_batch_output(records):
|
|
| 252 |
]
|
| 253 |
lines.append("\n".join(record_details))
|
| 254 |
lines.append("\n---\n") # Separator between records
|
|
|
|
| 255 |
return "\n".join(lines)
|
| 256 |
|
| 257 |
def generate_batch_pdf(records, batch_uid):
|
|
|
|
| 209 |
logger.error(f"Error in process_equipment_utilization: {e}")
|
| 210 |
raise ValueError(f"Processing failed: {str(e)}")
|
| 211 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
def format_batch_output(records):
|
| 213 |
lines = []
|
| 214 |
for i, rec in enumerate(records, 1):
|
| 215 |
summary = rec.get("Summary", {})
|
| 216 |
+
|
| 217 |
+
# Start by creating a header for each record
|
| 218 |
record_details = [
|
| 219 |
f"Record {i}:",
|
| 220 |
f" • Record ID: {rec['Salesforce_Record_Id']}",
|
|
|
|
| 230 |
]
|
| 231 |
lines.append("\n".join(record_details))
|
| 232 |
lines.append("\n---\n") # Separator between records
|
| 233 |
+
|
| 234 |
return "\n".join(lines)
|
| 235 |
|
| 236 |
def generate_batch_pdf(records, batch_uid):
|