I have two Documents of type booking and type details.
-
Booking Document
[ { "booking_details": { "project": "w" }, "booking_disp_id": "LT/FY18-19/B-1", "booking_id": "booking::1", "work_disp_id": "LT/FY18-19/W-1", "work_order_id": "work_order::1", "document_type": "booking", "samples": [ { "product_details_data": { "product_detail::291": "Detail 1" }, "product_disp_code": "BM-1", "product_feasibility_data": {}, "product_id": "product::45", "tests": [ { "res_id": "res_1" }, { "res_id": "res_2" }, { "res_id": "res_3" } ] } ] }, { "booking_details": { "project": "PN" }, "booking_disp_id": "LT/FY18-19/B-2", "booking_id": "booking::2", "work_disp_id": "LT/FY18-19/W-2", "work_order_id": "work_order::2", "document_type": "booking", "samples": [ { "approved": true, "product_details_data": { "product_detail::4": "Source", "product_detail::5": "Type" }, "product_disp_code": "SM-1", "product_feasibility_data": { }, "product_id": "product::2", "tests": [ { "res_id": "res_4" } ] } ] }, { "booking_details": { "project": "ABC" }, "booking_disp_id": "LT/FY18-19/B-3", "booking_id": "booking::3", "work_disp_id": "LT/FY18-19/W-3", "work_order_id": "work_order::3", "document_type": "booking", "samples": [ { "product_details_data": { "product_detail::291": "1", "product_detail::292": "2" }, "product_disp_code": "BM-2", "product_feasibility_data": { }, "product_id": "product::45", "tests": [ { "res_id": "res_5" }, { "res_id": "res_6" } ] } ] } ]
-
Details Document
[ { "work_order_id": "work_order::1", "detail_id": "detail::1", "document_type": "details", "tests": [ { "remarks": "", "time": "2018-10-09T10:09:57.831Z", "user_id": "user::1", "calc": { "sheet_1": "1", "sheet_2": "2", "sheet_3": "3", "sheet_4": "4" }, "expected_end": "2018-10-10", "data": {}, "product_disp_code": "BM-1", "product_id": "product::45", "res_id": "res_1", "attachment": [], "images": [], "start": "2018-10-09", "status": 1, }, { "remarks": "", "time": "2018-10-09T10:09:57.831Z", "user_id": "user::1", "calc": { "sheet_5": "5", "sheet_6": "6", "sheet_7": "7", "sheet_8": "8" }, "expected_end": "2018-10-10", "data": {}, "product_disp_code": "BM-1", "product_id": "product::45", "res_id": "res_2", "attachment": [], "images": [], "start": "2018-10-09", "status": 1, } ] }, { "work_order_id": "work_order::1", "detail_id": "detail::2", "document_type": "details", "tests": [ { "remarks": "", "time": "2018-10-09T10:09:57.831Z", "user_id": "user::1", "calc": { "sheet_1": "1", "sheet_3": "3", "sheet_5": "5", "sheet_9": "9" }, "expected_end": "2018-10-10", "data": {}, "product_disp_code": "BM-1", "product_id": "product::45", "res_id": "res_3", "attachment": [], "images": [], "start": "2018-10-09", "status": 1, } ] }, { "work_order_id": "work_order::2", "detail_id": "detail::3", "document_type": "details", "tests": [ { "remarks": "", "time": "2018-10-09T10:09:57.831Z", "user_id": "user::1", "calc": { "sheet_1": "0", "sheet_3": "0", "sheet_5": "0", "sheet_9": "0" }, "expected_end": "2018-10-10", "data": {}, "product_disp_code": "SM-1", "product_id": "product::2", "res_id": "res_4", "attachment": [], "images": [], "start": "2018-10-09", "status": 0, } ] }, { "work_order_id": "work_order::2", "detail_id": "detail::4", "document_type": "details", "tests": [ { "remarks": "", "time": "2018-10-09T10:09:57.831Z", "user_id": "user::1", "calc": { "sheet_1": "1", "sheet_3": "3", "sheet_5": "5", "sheet_9": "9" }, "expected_end": "2018-10-10", "data": {}, "product_disp_code": "SM-1", "product_id": "product::2", "res_id": "res_4", "attachment": [], "images": [], "start": "2018-10-09", "status": 1, } ] }, { "work_order_id": "work_order::3", "detail_id": "detail::5", "document_type": "details", "tests": [ { "remarks": "", "time": "2018-10-09T10:09:57.831Z", "user_id": "user::1", "calc": { "sheet_10": "10", "sheet_20": "20", "sheet_30": "30", "sheet_40": "40" }, "expected_end": "2018-10-10", "data": {}, "product_disp_code": "BM-2", "product_id": "product::45", "res_id": "res_5", "attachment": [], "images": [], "start": "2018-10-09", "status": 1, } ], } ]
-
Final Output
Select all booking Details and get res_ids and find if it has its corresponding details in details document with res_ids and status =1 and return full details in the booking details.
[
{
"booking_details": {
"project": "w"
},
"booking_disp_id": "LT/FY18-19/B-1",
"booking_id": "booking::1",
"work_disp_id": "LT/FY18-19/W-1",
"work_order_id": "work_order::1",
"document_type": "booking",
"samples": [
{
"product_details_data": {
"product_detail::291": "Detail 1"
},
"product_disp_code": "BM-1",
"product_feasibility_data": {},
"product_id": "product::45",
"tests": [
{
"remarks": "",
"time": "2018-10-09T10:09:57.831Z",
"user_id": "user::1",
"calc": {
"sheet_1": "1",
"sheet_2": "2",
"sheet_3": "3",
"sheet_4": "4"
},
"expected_end": "2018-10-10",
"data": {},
"product_disp_code": "BM-1",
"product_id": "product::45",
"res_id": "res_1",
"attachment": [],
"images": [],
"start": "2018-10-09",
"status": 1,
},
{
"remarks": "",
"time": "2018-10-09T10:09:57.831Z",
"user_id": "user::1",
"calc": {
"sheet_5": "5",
"sheet_6": "6",
"sheet_7": "7",
"sheet_8": "8"
},
"expected_end": "2018-10-10",
"data": {},
"product_disp_code": "BM-1",
"product_id": "product::45",
"res_id": "res_2",
"attachment": [],
"images": [],
"start": "2018-10-09",
"status": 1,
},
{
"remarks": "",
"time": "2018-10-09T10:09:57.831Z",
"user_id": "user::1",
"calc": {
"sheet_1": "1",
"sheet_3": "3",
"sheet_5": "5",
"sheet_9": "9"
},
"expected_end": "2018-10-10",
"data": {},
"product_disp_code": "BM-1",
"product_id": "product::45",
"res_id": "res_3",
"attachment": [],
"images": [],
"start": "2018-10-09",
"status": 1,
}
]
}
]
},
{
"booking_details": {
"project": "PN"
},
"booking_disp_id": "LT/FY18-19/B-2",
"booking_id": "booking::2",
"work_disp_id": "LT/FY18-19/W-2",
"work_order_id": "work_order::2",
"document_type": "booking",
"samples": [
{
"approved": true,
"product_details_data": {
"product_detail::4": "Source",
"product_detail::5": "Type"
},
"product_disp_code": "SM-1",
"product_feasibility_data": {
},
"product_id": "product::2",
"tests": [
{
"remarks": "",
"time": "2018-10-09T10:09:57.831Z",
"user_id": "user::1",
"calc": {
"sheet_1": "1",
"sheet_3": "3",
"sheet_5": "5",
"sheet_9": "9"
},
"expected_end": "2018-10-10",
"data": {},
"product_disp_code": "SM-1",
"product_id": "product::2",
"res_id": "res_4",
"attachment": [],
"images": [],
"start": "2018-10-09",
"status": 1,
}
]
}
]
},
{
"booking_details": {
"project": "ABC"
},
"booking_disp_id": "LT/FY18-19/B-3",
"booking_id": "booking::3",
"work_disp_id": "LT/FY18-19/W-3",
"work_order_id": "work_order::3",
"document_type": "booking",
"samples": [
{
"product_details_data": {
"product_detail::291": "1",
"product_detail::292": "2"
},
"product_disp_code": "BM-2",
"product_feasibility_data": {
},
"product_id": "product::45",
"tests": [
{
"remarks": "",
"time": "2018-10-09T10:09:57.831Z",
"user_id": "user::1",
"calc": {
"sheet_10": "10",
"sheet_20": "20",
"sheet_30": "30",
"sheet_40": "40"
},
"expected_end": "2018-10-10",
"data": {},
"product_disp_code": "BM-2",
"product_id": "product::45",
"res_id": "res_5",
"attachment": [],
"images": [],
"start": "2018-10-09",
"status": 1,
},
{
"res_id": "res_6"
}
]
}
]
}
]