{
  "name": "wpa/productivity_report/time_period.json",
  "database": "4d",
  "parameter": {
    "show_sql": true,
    "track_time_type": "OA",
    "start_date2": "",
    "end_date2": "",
    "load_group": [],
    "subqueryXX": "SELECT record_id FROM work_phase_actual WHERE CONCAT(production_lot, CONCAT('#', work_phase_est_id)) IN (SELECT CONCAT(production_lot, CONCAT('#', work_phase_est_id)) FROM work_phase_actual WHERE date_ BETWEEN '{{start_date2}}' AND '{{end_date2}}' AND work_load_group_id IN ({{load_group}}))"
  },
  "query": [
    ["wpa_date_", ">=", "start_date2"], "and",
    ["wpa_date_", "<=", "end_date2"], "and",
    ["wpa_type_", "<>", "track_time_type"], "and",
    ["take_shift_in_previous_day"], "and",
    ["remove_start_day_shift"], "and",
    ["remove_end_day_shift"], "and",
    ["take_shift_in_next_day"], "and",
    ["wpa_work_load_group_id", "in", "load_group"]
  ],
  "set": {
    "take_shift_in_previous_day": [
       ["wpa_date_", "<>", "start_date2"], "or", "shift_in_previous_day"
    ],
    "shift_in_previous_day": [
     ["wpa_end_time", ">=", "12:00:00"], "and",
     ["wpa_shift_number", "=", 1]
    ],
    "remove_start_day_shift": [
       ["wpa_date_", "<>", "start_date"], "or",
       ["wpa_end_time", ">=", "12:00:00"], "or",
       ["wpa_shift_number", "<", 3]
    ],
    "remove_end_day_shift": [
      ["wpa_date_", "<>", "end_date"], "or",
      ["wpa_end_time", "<", "12:00:00"], "or",
      ["wpa_shift_number", ">", 1]
    ],
    "take_shift_in_next_day": [
      ["wpa_date_", "<>", "end_date2"], "or", "shift_in_next_day"
    ],
    "shift_in_next_day": [
      ["wpa_end_time", "<", "12:00:00"], "and",
      ["wpa_shift_number", ">=", 3]
    ]
  },
  "order": ["wpa_production_lot", ">", "wpa_work_phase_est_id", ">"],
  "field": [
    "wpa_work_load_group_id",
    "wpa_production_lot",
    "wpa_work_phase_est_id",
    "wpa_type_",
    "wpa_start_shift_number",
    "wpa_shift_number",
    "wpa_work_time__amount",
    "wpa_machine_hours",
    "wpa_target_time",
    "wpa_produced_amount",
    "wpa_failed_amount",
    "wpa_start_date",
    "wpa_start_time",
    "wpa_date_",
    "wpa_end_time",
    "wpa_track_time_status",
    "wpa_measured_track_time",
    "wpa_record_id",
    "wlg_name",
    "wlg_follow_track_time",
    "wo_drawing_number",
    "wo_work__position_num_id",
    "wo_row_number",
    "w_name",
    "wlg_use_automatic_receipt",
    "wpa_employee_id"
  ]
}
