I want to use Java MongoDB aggregation to combine two collections and prioritize the records based on following rules in two collections.
Please suggest some code snippet on how to achieve this.I’ve used MongoDB play ground toachive the result but looking at some code snippet to improve better.
Prioritization Rules
1.Urgent
2.Aged Days
3.udlStatus
4.contentReceivedTimestamp
5.percentExecuted
LetterTemplateCollection
{
"lob": "AUTO",
"templateId": "RT-000004",
"remediationID": "CR-100002",
"templateContent": "CUSTOMER_NAME_1",
"templatePrinter": "ASVS",
"templateStatus": "Approved",
"urgent": "Yes",
"agedDays": 102
}
ContentCollection
{
"contentReceivedTimestamp": "2024-01-02T04:48:02.582225",
"templateId": "RT-000004",
"lob": "AUTO",
"remediationID": "CR-100002",
"remediationTransactionID": "128",
"remediationType": "Content",
"contentStatus": "Loaded",
"udlStatus": "Rejected-Ready to Reprint",
"percentageExecuted": 95,
"accountInfo": {
"accountID": "9230028467",
"accountType": "AUTOLN"
},
"remediationContentInfo": {
"phaseNumber": "1",
"remediationActionType": "LTR",
"partySequenceNumber": "1",
"checkPayeeName": "John Wright",
"financialImpactAmount": "100",
"interestAmount": "300",
"loufAmount": "0",
"minPayDiffAmount": "0",
"rollupAccounts": "4.50"
},
"customerInfo": {
"partyID": "779622269",
"partyTypeID": "SSN",
"impactType": "OTHER",
"ssn": "779622269",
"ecn": "",
"epic": "CUST",
"partySequence": "1",
"customerDetails": {
"firstName": "Joesph",
"middleName": "Ross",
"lastName": "Biden",
"suffix": "Test2",
"dateOfBirth": "06-20-1981",
"email": "test@gmail.com",
"phone": "612-382-9723"
},
"addressDetails": {
"addressType": "MAIL",
"addressLine1": "1234",
"addressLine2": "Mint Street",
"addressLine3": "Test2",
"city": "Bridgville",
"state": "PA",
"zip5": "15017",
"zip4": "1534",
"country": "US"
}
}
}