mongo-js-20141126,mongojs

來源:互聯網
上載者:User

mongo-js-20141126,mongojs
#!/bin/sh
# 建立一個0位元組文檔,如果存在,則清空。
:>subsidiaryCode.txt
tlist=`cat ./AccountGuid.txt`;
for i in $tlist
do
    TEMP_LIST=$i;
   # 列印出$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


#擷取Referal_user_Id
Referal_user_Id=`cat ./Referal_user_Id.txt`;
#判斷Referal_user_Id是否為空白
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_number=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

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.