Mongo-js-20141126, JavaScript
#! /Bin/sh
# Create a 0-byte document. If yes, clear it.
:> SubsidiaryCode.txt
Tlist = 'cat./AccountGuid.txt ';
For I in $ tlist
Do
TEMP_LIST = $ I;
# Print the value obtained from $ TEMP_LIST.
# Printf "AccountGuid: $ TEMP_LIST \ n ";
Mysql-h 172.24.0.220-uquery-pquery che001-NB <EOF> Referal_user_Id.txt
Select ReferalGuid, UserGuid from KyPayAccounts where AccountGuid = '$ TEMP_LIST ';
EOF
# Get Referal_user_Id
Referal_user_Id = 'cat./Referal_user_Id.txt ';
# Determine whether Referal_user_Id is null
If ["$ Referal_user_Id" x = x]
Then
Echo "Error: failed to get AccountGuid $ TEMP_LIST date, Referal_user_Id in not exist! ";
# Exit-1
Fi
ReferalId = 'echo "$ Referal_user_Id" | awk '{print $1 }'';
UserId = 'echo "$ Referal_user_Id" | awk '{print $2 }'';
Mongo -- quiet localhost: 27020/che001-uquery-pquery <EOF> subsidiaryCode.txt
// Mongo -- quiet localhost: 27020/che001-uquery-pquery <EOF
Var subsidiaryCode = "";
Var employee = db. employee. find ({"userId": '$ ReferalId'}, {"store": 1, "logicalDel": 1 })
While (employee. hasNext ()){
Var employee2 = employee. next ();
// Print ("sroteId:" + employee2.store );
If (typeof (employee2.store )! = "Undefined ")
{
Var t_store = employee2.store;
Var logicalDel = employee2.logicalDel;
} Else {
// Print ('$ TEMP_LIST' + "," + '$ ReferalId' + ", employee. store in not exist! ");
Break;
}
Var store = db. store. find ({"id": t_store}, {"subsidiaryInfo. subsidiaryCode": 1 })
While (store. hasNext ()){
Var store2 = store. next ();
// Print ("subsidiaryCode:" + store2.subsidiaryInfo. subsidiaryCode );
Var subsidiaryCode = store2.subsidiaryInfo. subsidiaryCode;
}
Var contract = db. contract. find ({"userId": '$ userid '})
While (contract. hasNext ()){
Var contract2 = contract. next ();
// Print(contract2.data.doc _ cnt_number );
Var doc_cnt_numberw.contract2.data.doc _ cnt_number
}
Var user = db. user. find ({"id": '$ userid '})
While (user. hasNext ()){
Var user2 = user. next ();
// Print (user2.username );
Var username = user2.username
}
Var serviceAccount = db. serviceAccount. find ({"userId": '$ userid '})
While (serviceAccount. hasNext ()){
Var serviceAccount2 = serviceAccount. next ();
// Print (serviceAccount2.fullName );
Var fullName = serviceAccount2.fullName
}
Print ("" + '$ TEMP_LIST' + "," + subsidiaryCode + ", logicalDel:" + logicalDel + "," + doc_cnt_number + "," + username + ", "+ fullName );
}
EOF
Done