Type a work-order doc and stamp the Maximo ``type`` (used by the type indexes).
(doc)
| 36 | |
| 37 | |
| 38 | def workorder(doc): |
| 39 | """Type a work-order doc and stamp the Maximo ``type`` (used by the type indexes).""" |
| 40 | doc.setdefault("type", "workorder") |
| 41 | |
| 42 | for f in _WO_INT: |
| 43 | if isinstance(doc.get(f), str): |
| 44 | doc[f] = int(float(doc[f])) |
| 45 | for f in _WO_FLOAT: |
| 46 | if isinstance(doc.get(f), str): |
| 47 | doc[f] = float(doc[f]) |
| 48 | |
| 49 | if isinstance(doc.get("wplabor"), str): # JSON-string column → list |
| 50 | doc["wplabor"] = json.loads(doc["wplabor"]) |
| 51 | |
| 52 | evidence = doc.get("aob_source", {}).get("evidence") |
| 53 | if isinstance(evidence, dict): |
| 54 | for f in _WO_EVIDENCE_FLOAT: |
| 55 | if isinstance(evidence.get(f), str): |
| 56 | evidence[f] = float(evidence[f]) |
| 57 | |
| 58 | return doc |