{
	"name": "form/manager/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": "form/manager/productivity_report/filter.json",
				"definition": "wlg_load_group"
			},
			"map": [["wlg_header", "=", ["concat", [", ", "res.resource_name"]]]]
		},
		"reclamation": {
			"filter": {
				"name": "form/manager/productivity_report/filter.json",
				"definition": "reclamation_load_group"
			},
			"map": [
				[
					"reclamation_row_dimmed",
					"=",
					[
						["rcl.reclamation_state", "==", 0],
						"or",
						["rcl.finished_date", "<", "param.start_date"],
						"or",
						["rcl.finished_date", ">", "param.end_date"]
					]
				]
			]
		},
		"track_time": {
			"filter": {
				"name": "form/manager/productivity_report/filter.json",
				"definition": "track_time_map"
			},
			"map": [
				[
					"track_time_asked",
					"=",
					[["prwo.json_data.track_time_status", ">=", 1], "and", ["prwo.json_data.track_time_status", "<=", 4]]
				],
				[
					"track_time_measured",
					"=",
					[["prwo.json_data.track_time_status", ">=", 2], "and", ["prwo.json_data.track_time_status", "<=", 3]]
				],
				["track_time_change", "=", ["prwo.json_data.measured_track_time", "-", "previous_measured_track_time"]],
				["track_time_change_percent", "=", [["track_time_change", "/", "previous_measured_track_time"], "*", 100]]
			]
		},
		"speed": {
			"filter": {
				"name": "form/manager/productivity_report/filter.json",
				"definition": "speed"
			},
			"map": [
				[
					"if",
					["rec.query_name", "==", "no_fms"],
					[
						["prwo.work_hours", "=", ["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"],
					[
						["prwo.work_hours", "=", ["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",
					[
						["prwo.work_hours", "=", ["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", "=", ["prwo.work_hours", "/", ["wos_produced", "+", "wos_failed"]]],
				[
					"if",
					["prwo.work_phase_number", "<>", 99],
					[["std_time", "=", [["prwo.work_hours", "/", "work_time_all"], "*", "prwo.json_data.target_time"]]],
					"else",
					[["std_time", "=", 0]]
				],
				["estimated_work_time", "=", ["estimated_work_time__unit", "*", ["wos_produced", "+", "wos_failed"]]],
				["finished_work_time", "=", ["prwo.work_hours", "*", "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", ["prwo.work_hours", "<>", 0]],
					[
						["estimated_speed_percent", "=", [["estimated_work_time", "/", "work_time_all"], "*", 100]],
						["std_speed_percent", "=", [["std_time", "/", "prwo.work_hours"], "*", 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",
					["prwo.work_hours", "==", 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", "=", ["prwo.work_hours", "/", ["wos_produced", "+", "wos_failed"]]],
				["estimated_speed_percent", "=", [["estimated_work_time__unit", "/", "work_time__unit"], "*", 100]],
				["finished_work_time", "=", ["prwo.work_hours", "*", "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"]]
			]
		}
	}
}
