#!/bin/bash
##################################################################
#主要是动态生成一个新的执行脚本
#再调用这个脚本与数据库中的内容对比
#检查是否有差异
#20090916
###################### 数据库 相关信息 ######################
DATA_SERVER_NAME=XXXX
DATA_USER=XXXX
DATA_PASS=XXXX
###################### 数据库 相关信息 ######################
function lrysqlexec()
{
echo "$ORACLE_HOME/bin/sqlplus -s ${DATA_USER}/${DATA_PASS}@${DATA_SERVER_NAME} <<EOF
set feedback off;
set pagesize 0;
set tab on;
set line 1000;
set echo off;
set trims on;
$1;
quit;
EOF"
}
echo "请输入账务月(eg:20090911)"
read date
cd /settle3/test/ftp
if [ -f ACR_RECORD_${date}.new.gz ]
then
gunzip ACR_RECORD_${date}.new.gz
fi
> exefinddiff.sh
echo "#!/bin/bash" >> exefinddiff.sh
echo "echo /"查找ACR_RECORD_${date}.new文件/"" >> exefinddiff.sh
echo "输入serverkey:"
read serverkey
echo "输入chargemode:"
read chargemode
echo "count1=/`grep '( 0 , $serverkey , $chargemode' ACR_RECORD_${date}.new | wc -l/`" >> exefinddiff.sh
echo 'echo "count1等于$count1"' >> exefinddiff.sh
echo "cd /settle3/test" >> exefinddiff.sh
echo "count2=/`grep '( 0 , $serverkey , $chargemode' ACR_RECORD_${date}.old | wc -l/`" >> exefinddiff.sh
echo 'echo "count2等于$count2"' >> exefinddiff.sh
tmp=`echo "$date" | awk '{print substr($1,7,2)'}`
echo $tmp
echo "count3=/`grep '( 0 , $serverkey , $chargemode' ${tmp}app.sql | wc -l/`" >> exefinddiff.sh
echo 'echo "count3等于$count3"' >> exefinddiff.sh
echo 'total=`expr $count1 + $count2 + $count3`' >> exefinddiff.sh
echo 'echo "原始数据总共有:$total"' >> exefinddiff.sh
echo 'echo 查看数据库中的数据'
lrysqlcount="SELECT y.count FROM ywl_check_count y WHERE y.service_key=$serverkey AND y.charge_mode=$chargemode and y.data_date=$date";
lrycount=`lrysqlexec "$lrysqlcount" | sh | awk '{print $1}'`
echo "数据库中的信息为:$lrycount"
echo "dbcount=$lrycount" >> exefinddiff.sh
echo 'diff=`expr ${total} - ${dbcount}`' >> exefinddiff.sh
echo "echo -e /"数据库的数据/t原始数据/t差异/"" >> exefinddiff.sh
echo 'echo -e "${dbcount}/t/t$total/t/t$diff"' >> exefinddiff.sh
echo "echo /"end subfunction/"" >> exefinddiff.sh
pwd
chmod +x exefinddiff.sh
exefinddiff.sh
echo "end ALL"