{
  "name": "query/manager/product/product_work/actual/latest_maintenance.json.json",
  "database": "4d",
  "parameter": {
    "show_sql": true,
    "days_before": 15,
    "start_minutes_before": 60,
    "last_date": "",
    "start_date": "",
    "start_time": "",
    "start_type": ["AL"],
		"maintenance_work_not_in_use": ["16279", "16280", "16281"],
		"maintenance_work": []
  },
  "map_parameter": [
		["maintenance_work", "=", ["preferenceTagValue", ["manager/maintenance.json", "work_number_arr"]]],
    ["days_before_negative", "=", ["-", ["days_before"]]],
    [
      "last_date",
      "=",
      ["daysToCurrentDateStringAdd", ["days_before_negative"]]
    ],
    ["current_dt", "=", ["currentDateTime"]],
    ["start_minutes_before_negative", "=", ["-", ["start_minutes_before"]]],
    [
      "start_seconds_before_negative",
      "=",
      ["start_minutes_before_negative", "*", 60]
    ],
    [
      "start_dt",
      "=",
      ["secondsAdd", ["current_dt", "start_seconds_before_negative"]]
    ],
    ["start_date", "=", ["dateTimeToDateString", ["start_dt"]]],
    ["start_time", "=", ["dateTimeToTimeString", ["start_dt"]]]
  ],
  "query": [
		"valid_date_or_started", 
		"and", 
		["wpa_work__position_num_id", "in", "maintenance_work"]
	],
  "set": {
		"valid_date_or_started": [["wpa_date_", ">=", "last_date"], "or", "started"],
    "started": ["started_1", "or", "started_2"],
    "started_1": [
      ["wpa_type_", "in", "start_type"],
      "and",
      ["wpa_start_date", "=", "start_date"],
      "and",
      ["wpa_start_time", ">=", "start_time"]
    ],
    "started_2": [
      ["wpa_type_", "in", "start_type"],
      "and",
      ["wpa_start_date", ">", "start_date"]
    ]
  },
  "order": ["wpa_date_", "<", "wpa_end_time", "<"],
  "limit": 1000000,
  "field": ["wpa_record_id"]
}
