{
	"name": "dialog/productivity_report/map.json",
	"definition": {
		"develop_chart": {
			"new_rec": true,
			"map": [
				["category", "=", ["substring", ["year_month", 3]]],
				["if", ["param.i", "==", 1],
					[
						["availability", "=", ["percent", ["actual_hour", "planned_hour"]]],
						["speed", "=", ["percent", ["std_time", "work_time"]]],
						["quality", "=", ["percent", ["not_failed", "produced"]]],
						["oee", "=", ["multiPercent", ["availability", "speed", "quality"]]],
						["amount", "=", ["round", ["oee", 0]]]
					], "elseif", ["param.i", "==", 2],
					[
						["availability", "=", ["percent", ["actual_hour", "planned_hour"]]],
						["amount", "=", ["round", ["availability", 0]]]
					], "elseif", ["param.i", "==", 3],
					[
						["speed", "=", ["percent", ["std_time", "work_time"]]],
						["amount", "=", ["round", ["speed", 0]]]
					], "else", [
						["quality", "=", ["percent", ["not_failed", "produced"]]],
						["amount", "=", ["round", ["quality", 0]]]
					]
				]
			]
		},
		"wlg_header": {
			"filter": {
				"name": "dialog/productivity_report/filter.json",
				"definition": "wlg_load_group"
			},
			"map": [
				["wlg_header", "=", ["concat", [", ", "wlg_name"]]]
			]
		},
		"reclamation": {
			"filter": {
				"name": "dialog/productivity_report/filter.json",
				"definition": "reclamation_load_group"
			},
			"map": [
				["reclamation_row_dimmed", "=", [
					["rcl_state", "==", 0],
					"or", ["rcl_finished_date", "<", "param.start_date"],
					"or", ["rcl_finished_date", ">", "param.end_date"]
				]]
			]
		},
		"track_time": {
			"filter": {
				"name": "dialog/productivity_report/filter.json",
				"definition": "track_time_map"
			},
			"map": [
				["track_time_asked", "=", [
					["wpa_track_time_status", ">=", 1], "and", ["wpa_track_time_status", "<=", 4]
				]],
				["track_time_measured", "=", [
					["wpa_track_time_status", ">=", 2], "and", ["wpa_track_time_status", "<=", 3]
				]],
				["track_time_change", "=", ["wpa_measured_track_time", "-", "previous_measured_track_time"]],
				["track_time_change_percent", "=", [
					["track_time_change", "/", "previous_measured_track_time"], "*", 100
				]]
			]
		},
		"speed": {
			"filter": {
				"name": "dialog/productivity_report/filter.json",
				"definition": "speed"
			},
			"map": [
				["if", ["rec.query_name", "==", "no_fms"],
					[
						["wpa_work_time__amount", "=", ["work_time_not_fms_machine", "+", "work_time_other"]],
						["work_time_all", "=", ["all_work_time_not_fms_machine", "+", "all_work_time_other"]],
						["before_time_period_sum", "=", ["before_time_period_sum_not_fms_machine", "+", "before_time_period_sum_other"]],
						["after_time_period_sum", "=", ["after_time_period_sum_not_fms_machine", "+", "after_time_period_sum_other"]]
					], "elseif", ["rec.query_name", "==", "only_fms"],
					[
						["wpa_work_time__amount", "=", ["work_time_not_fms_machine", "+", "work_time_fms"]],
						["work_time_all", "=", ["all_work_time_not_fms_machine", "+", "all_work_time_fms"]],
						["before_time_period_sum", "=", ["before_time_period_sum_not_fms_machine", "+", "before_time_period_sum_fms"]],
						["after_time_period_sum", "=", ["after_time_period_sum_not_fms_machine", "+", "after_time_period_sum_fms"]]
					], "else", [
						["wpa_work_time__amount", "=", ["work_time_not_fms_machine", "+", ["work_time_fms", "+", "work_time_other"]]],
						["work_time_all", "=", ["all_work_time_not_fms_machine", "+", ["all_work_time_fms", "+", "all_work_time_other"]]],
						["before_time_period_sum", "=", ["before_time_period_sum_not_fms_machine", "+", ["before_time_period_sum_fms", "+", "before_time_period_sum_other"]]],
						["after_time_period_sum", "=", ["after_time_period_sum_not_fms_machine", "+", ["after_time_period_sum_fms", "+", "after_time_period_sum_other"]]]
					]
				],
				["work_time", "=", ["wpa_work_time__amount", "/", ["wos_produced", "+", "wos_failed"]]],
				["if", ["wpa_work_phase_est_id", "<>", 99],
					[
						["std_time", "=", [
							["wpa_work_time__amount", "/", "work_time_all"], "*", "wpa_target_time"
						]]
					], "else", [
						["std_time", "=", 0]
					]
				],
				["estimated_work_time", "=", ["estimated_work_time__unit", "*", ["wos_produced", "+", "wos_failed"]]],
				["finished_work_time", "=", ["wpa_work_time__amount", "*", "wos_finished"]],
				["finished_std_time", "=", ["std_time", "*", "wos_finished"]],
				["finished_estimated_work_time", "=", ["estimated_work_time", "*", "wos_finished"]],
				["finished_estimated_work_time__unit", "=", ["estimated_work_time__unit", "*", "wos_finished"]],
				["if", [
						["wos_finished", "<>", 0], "and", ["std_time", "<>", 0], "and", ["wpa_work_time__amount", "<>", 0]
					],
					[
						["estimated_speed_percent", "=", [
							["estimated_work_time", "/", "work_time_all"], "*", 100
						]],
						["std_speed_percent", "=", [
							["std_time", "/", "wpa_work_time__amount"], "*", 100
						]]
					], "else", [
						["estimated_speed_percent", "=", 0],
						["std_speed_percent", "=", 0]
					]
				]
			],
			"mapX": [
				["if", ["rec.report_type", "==", "report_type_speed"],
					[]
				],

				["if", ["wos_finished", "==", 0],
					[
						["info", "=", "avoin"]
					], "elseif", ["wpa_work_time__amount", "==", 0],
					[
						["info", "=", "ei työaikaa"]
					], "elseif", ["std_time", "==", 0],
					[
						["info", "=", "ei std-aikaa"]
					], "elseif", [
						["before_time_period_sum", ">", 0], "and", ["after_time_period_sum", ">", 0]
					],
					[
						["info", "=", "A - L"]
					], "elseif", ["before_time_period_sum", ">", 0],
					[
						["info", "=", "A -"]
					], "elseif", ["after_time_period_sum", ">", 0],
					[
						["info", "=", "- L"]
					], "else", [
						["info", "=", ""]
					]
				],
				["work_time_all", "=", ["work_time_time_period", "+", ["work_time_before", "+", "work_time_after"]]],
				["work_time__unit", "=", ["wpa_work_time__amount", "/", ["wos_produced", "+", "wos_failed"]]],
				["estimated_speed_percent", "=", [
					["estimated_work_time__unit", "/", "work_time__unit"], "*", 100
				]],
				["finished_work_time", "=", ["wpa_work_time__amount", "*", "wos_finished"]],
				["finished_std_time", "=", ["std_time", "*", "wos_finished"]],
				["finished_work_time__unit", "=", ["work_time__unit", "*", "wos_finished"]],
				["finished_estimated_work_time__unit", "=", ["estimated_work_time__unit", "*", "wos_finished"]]
			]
		}
	}
}