码迷,mamicode.com
首页 > Web开发 > 详细

mongo-js-20141126

时间:2014-12-15 20:22:51      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:ar   os   sp   for   on   2014   log   bs   ef   

#!/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

mongo-js-20141126

标签:ar   os   sp   for   on   2014   log   bs   ef   

原文地址:http://blog.csdn.net/a3470194/article/details/41947631

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!