phase-4: preventive maintenance and calibration modules
This commit is contained in:
@@ -59,9 +59,11 @@ def _lead_settings(db: Session) -> dict[str, int]:
|
||||
"warranty": int(get_setting_value(db, "warranty_expiry_alert_days")),
|
||||
"contract": int(get_setting_value(db, "contract_expiry_alert_days")),
|
||||
"insurance": int(get_setting_value(db, "insurance_expiry_alert_days")),
|
||||
"calibration": int(get_setting_value(db, "calibration_due_window_days")),
|
||||
"calibration": int(get_setting_value(db, "calibration_lead_days", 15)),
|
||||
"pm": int(get_setting_value(db, "pm_due_window_days")),
|
||||
"red": int(get_setting_value(db, "contract_critical_alert_days")),
|
||||
"pm_in_house": int(get_setting_value(db, "pm_inhouse_lead_days", 15)),
|
||||
"pm_outsourced": int(get_setting_value(db, "pm_outsourced_lead_days", 15)),
|
||||
"red": int(get_setting_value(db, "red_threshold_days", 7)),
|
||||
}
|
||||
|
||||
|
||||
@@ -771,13 +773,19 @@ def get_asset_overview(
|
||||
|
||||
pm_rec_rows = (
|
||||
db.query(PMRecord)
|
||||
.options(joinedload(PMRecord.schedule))
|
||||
.filter(PMRecord.asset_id == asset.id)
|
||||
.order_by(PMRecord.planned_date.desc(), PMRecord.id.desc())
|
||||
.all()
|
||||
)
|
||||
pm_rec_out = []
|
||||
for r in pm_rec_rows:
|
||||
st, sev = compute_schedule_status(r.planned_date, r.status, today, leads["pm"], leads["red"])
|
||||
pm_lead = (
|
||||
leads["pm_in_house"]
|
||||
if r.schedule and r.schedule.service_mode == "in_house"
|
||||
else leads["pm_outsourced"]
|
||||
)
|
||||
st, sev = compute_schedule_status(r.planned_date, r.status, today, pm_lead, leads["red"])
|
||||
pm_rec_out.append(
|
||||
PMRecordSummaryOut(
|
||||
id=r.id,
|
||||
|
||||
Reference in New Issue
Block a user