{
  "name": "dialog/productivity_report/filter3.json",
  "definition": {
    "wpa_time_period": {
       "info": "wpa_time_period",
       "info2": "shift: yv=1, av=2, iv=3, em=4",
       "info3": "iv or em shift can be within next day, but it isn't next day work shift",
       "info4": "yv shift can be within pevious day, but it is time period work shift",
       "table": "wpa",
       "rule": [
         ["wpa_date_", ">=", "param.start_prev_date"],
         ["wpa_date_", "<=", "param.end_next_date"],
         [[["wpa_date_", "<>", "param.start_date"], "or", ["wpa_end_time", ">=", "12:00:00"], "or", ["wpa_shift_number", "<", 3]]],
         [[["wpa_date_", "<>", "param.end_date"], "or", ["wpa_end_time", "<=", "12:00:00"], "or", ["wpa_shift_number", "<>", 1]]],
         [[["wpa_date_", "<>", "param.start_prev_date"], "or", ["wpa_end_time", ">", "12:00:00"]]],
         [[["wpa_date_", "<>", "param.start_prev_date"], "or", ["wpa_shift_number", "==", 1]]],
         [[["wpa_date_", "<>", "param.end_next_date"], "or", ["wpa_end_time", "<", "12:00:00"]]],
         [[["wpa_date_", "<>", "param.end_next_date"], "or", ["wpa_shift_number", ">=", 3]]]
       ]
     },
    "finished_work_time": [
      {
        "info": "finished_work_time",
        "table": "wpa",
        "rule": [
          ["std_time", ">", 0]
        ]
      }
    ],
    "track_time_asked": [
      {
        "info": "track_time_asked",
        "table": "track_time",
        "rule": [
          [["wpa_track_time_status", ">=", 1], "and", ["wpa_track_time_status", "<=", 4]]
        ]
      }
    ],
    "track_time_measured": [
      {
        "info": "track_time_measured",
        "table": "track_time",
        "rule": [
          [["wpa_track_time_status", ">=", 2], "and", ["wpa_track_time_status", "<=", 3]]
        ]
      }
    ],
    "track_time_changed": [
      {
        "info": "track_time_changed",
        "table": "track_time",
        "rule": [
          ["previous_batch_number", "<>", 0],
          ["wpa_measured_track_time", "<>", 0]
        ]
      }
    ],
    "unproductive": [
      {
        "info": "unproductive",
        "table": "wpa",
        "rule": [
          ["wpa_type_", "==", "ET"]
         ]
      }
    ],
    "capacity_work_time": [
      {
        "info": "capacity_work_time",
        "table": "wpa",
        "rule": [
            ["wpa_type_", "<>", "ET"],
            ["wpa_shift_number", "==", "param.shift"]
         ]
      }
    ],
    "capacity_unproductive_work_time": [
      {
        "info": "capacity_unproductive_work_time",
        "table": "wpa",
        "rule": [
            ["wpa_type_", "==", "ET"],
            ["wpa_shift_number", "==", "param.shift"]
         ]
      },
      {
        "info": "wpa_time_period",
        "table": "wpa",
        "rule": "wpa_time_period"
      }
    ],
    "capacity_shift": [
      {
        "info": "shift",
        "table": "capacity",
        "rule": [
          ["shift", "==", "param.shift"]
        ]
      }
    ],
    "capacity": [
      {
        "info": "time_period",
        "info2": "shift: yv=1, av=2, iv=3, em=4",
        "info3": "em shift can be within next day, but it isn't next day work shift ",
        "table": "capacity",
        "rule": [
         ["end_dt", ">=", "param.start_date"],
         ["end_dt", "<=", "param.end_next_date"],
         [[["end_dt", "<>", "param.start_date"], "or", ["end_dt", ">=", "12:00:00"], "or", ["shift", "<", 3]]],
         [[["end_dt", "<>", "param.end_next_date"], "or", ["end_dt", "<", "12:00:00"]]],
         [[["end_dt", "<>", "param.end_next_date"], "or", ["shift", ">=", 3]]]
        ]
      }
    ],
    "finished_reclamation": [
      {
        "info": "finished_reclamation",
        "table": "rcl",
        "rule": [
          ["rcl_state", "<>", 0],
          ["rcl_finished_date", ">=", "param.start_date"],
          ["rcl_finished_date", "<=", "param.end_date"]
        ]
      }
    ],
    "track_time_map": [
      {
        "info": "track_time_map",
        "table": "track_time",
        "rule": [
          ["wpa_date_", ">=", "param.start_date"],
          ["wpa_date_", "<=", "param.end_date"]
        ]
      }
    ],
    "speed": [
      {
        "info": "no_unproductivity",
        "table": "wpa",
        "rule": [
            ["wpa_type_", "<>", "ET"]
         ]
      },
      {
        "info": "no_fms",
        "use": [
          ["rec.query_name", "==", "no_fms"]
        ],
        "table": "wpa",
        "rule": [
          [["work_time_fms", "==", 0], "or",["wlg_use_automatic_receipt", "<=", 0]]
        ]
      },
      {
        "info": "only_fms",
        "use": [
          ["rec.query_name", "==", "only_fms"]
        ],
        "table": "wpa",
        "rule": [
          [["work_time_fms", "<>", 0], "or",["wlg_use_automatic_receipt", "<=", 0]]
        ]
      },
      {
        "info": "time_period",
        "info2": "shift: yv=1, av=2, iv=3, em=4",
        "info3": "em shift can be within next day, but it isn't next day work shift",
        "info4": "productivity_report.lua - createWpaIdTableWithTimePeriod(...)",
        "table": "wpa",
        "rule": "wpa_time_period"
      }
    ],
    "quality": [
      {
        "info": "time_period",
        "info2": "shift: yv=1, av=2, iv=3, em=4",
        "info3": "em shift can be within next day, but it isn't next day work shift",
        "info4": "productivity_report.lua - createWpaIdTableWithTimePeriod(...)",
        "table": "wpa",
        "rule": "wpa_time_period"
      }
    ]
  }
}
