{
	"name": "query/manager/product/product_work/actual/productivity_report/old/time_period_old.json",
	"table": [
		{
			"record_type": ["actual"],
			"table": "product_work"
		}
	],
	"database": "4d",
	"parameter": {
		"end_date2": "",
		"load_group": [
				
			],
		"show_sql": true,
		"start_date2": "",
		"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}}))",
		"track_time_type": "OA"
	},
	"field": [
		"prwo.resource_id",
		"prwo.production_lot",
		"prwo.work_phase_number",
		"prwo.work_phase_type",
		"prwo.json_data.start_work_shift",
		"prwo.json_data.work_shift",
		"prwo.work_hours",
		"prwo.machine_hours",
		"prwo.json_data.target_time",
		"prwo.produced_amount",
		"prwo.failed_amount",
		"prwo.json_data.start_date",
		"prwo.json_data.start_time",
		"prwo.json_data.end_date",
		"prwo.json_data.end_time",
		"prwo.json_data.track_time_status",
		"prwo.json_data.measured_track_time",
		"prwo.record_id",
		"res.resource_name",
		"res.json_data.follow_track_time",
		"pro.drawing_number",
		"pro.json_data.work__position_num_id",
		"pro.row_number",
		"pr.name",
		"res.json_data.use_automatic_receipt",
		"prwo.person_id"
	],
	"order": [
		"prwo.production_lot",
		">",
		"prwo.work_phase_number",
		">"
	],
	"query": [
		["prwo.json_data.end_date", ">=", "start_date2"],
		"and",
		["prwo.json_data.end_date", "<=", "end_date2"],
		"and",
		["prwo.work_phase_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",
		["prwo.resource_id", "in", "load_group"]
	],
	"set": {
		"remove_end_day_shift": [
				["prwo.json_data.end_date", "<>", "end_date"],
				"or",
				["prwo.json_data.end_time", "<", "12:00:00"],
				"or",
				["prwo.json_data.work_shift", ">", 1]
			],
		"remove_start_day_shift": [
				["prwo.json_data.end_date", "<>", "start_date"],
				"or",
				["prwo.json_data.end_time", ">=", "12:00:00"],
				"or",
				["prwo.json_data.work_shift", "<", 3]
			],
		"shift_in_next_day": [
				["prwo.json_data.end_time", "<", "12:00:00"],
				"and",
				["prwo.json_data.work_shift", ">=", 3]
			],
		"shift_in_previous_day": [
				["prwo.json_data.end_time", ">=", "12:00:00"],
				"and",
				["prwo.json_data.work_shift", "=", 1]
			],
		"take_shift_in_next_day": [
				["prwo.json_data.end_date", "<>", "end_date2"],
				"or",
				"shift_in_next_day"
			],
		"take_shift_in_previous_day": [
				["prwo.json_data.end_date", "<>", "start_date2"],
				"or",
				"shift_in_previous_day"
			]
	}
}