#!/bin/sh# 创建一个0字节文档,如果存在,则清空。:subsidiaryCode.txttlist=`cat ./AccountGuid.txt`;for i in $tlistdoTEMP_LIST=$i;# 打印出$TEMP_LIST取到的值# printf AccountGuid:$TEMP_LIST\n;mysql -h 172.24.0.220 -uquery -pquery che001 -NB EOF
#!/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