DBSTR="ccad/abc@crm"
lastday=$(perl -e "use POSIX qw(strftime); print strftime '%Y%m%d' , localtime( time()-3600*24*1) ")
curday=$(perl -e "use POSIX qw(strftime); print strftime '%Y%m%d' , localtime( time()) ")
FILES="/product1/port/bin/ocs_subscriber_import/back/GXalluserinfo_V_${lastday}_*.unl"
send_sms()
{
PCOUNT=0
for phone in $PHONELIST
do
TIME="EPY"`date +'%y%m%d%H%M%S'`
COMM_SN="${TIME}$1${PCOUNT}"
echo "COMM_SN=${COMM_SN}"
SQL="insert into vvv.log_sms_pay values('"$COMM_SN"','alarm','"$phone"',to_char(sysdate,'YYYYMMDDHH24MISS'),'IOC_ALARM','2',to_char(sysdate,'YYYYMMDDHH24MISS'),'"$2"',0,0,0)"
exesql "$SQL"
SQL="insert into vvv.sms_pay values('"$COMM_SN"','alarm','"$phone"',to_char(sysdate,'YYYYMMDDHH24MISS'),'IOC_ALARM','2',to_char(sysdate,'YYYYMMDDHH24MISS'),'"$2"',0,0,0)"
exesql "$SQL"
PCOUNT=`expr $PCOUNT + 1`
echo "PCOUNT=${PCOUNT}"
sleep 1
done
}
exesql()
{
sqlplus -s $DBSTR <<EOF
set autocommit off;
$1;
commit;
exit;
EOF
}
for file in $FILES
do
if [ -f "${file}" ]; then
echo "[${file}]存在"
fail_count=`cat ${file}|wc -l`
echo "fail_count=${fail_count}"
tabrow=`sqlplus -S $DBSTR <<EOF1
set heading off;
set feedback off;
set pagesize 0;
set verify off;
set echo off;
select count(*) from log_ocs_info_user where insert_date='${curday}';
exit;
EOF1`
echo "tabrow=${tabrow}"
if [ "$tabrow" -ne "$fail_count" ]; then
msg="ocs账本导入时文件行数与log_ocs_info_user表记录行数不匹配"
echo $msg;
send_sms "01" "$msg"
fi
else
msg="ocs账本导入的文件[${file}]没有生成,请检查"
echo $msg
send_sms "02" "$msg"
fi
done
echo "结束!"
lastday=$(perl -e "use POSIX qw(strftime); print strftime '%Y%m%d' , localtime( time()-3600*24*1) ")
curday=$(perl -e "use POSIX qw(strftime); print strftime '%Y%m%d' , localtime( time()) ")
FILES="/product1/port/bin/ocs_subscriber_import/back/GXalluserinfo_V_${lastday}_*.unl"
PHONELIST="1233344444
545435435
"send_sms()
{
PCOUNT=0
for phone in $PHONELIST
do
TIME="EPY"`date +'%y%m%d%H%M%S'`
COMM_SN="${TIME}$1${PCOUNT}"
echo "COMM_SN=${COMM_SN}"
SQL="insert into vvv.log_sms_pay values('"$COMM_SN"','alarm','"$phone"',to_char(sysdate,'YYYYMMDDHH24MISS'),'IOC_ALARM','2',to_char(sysdate,'YYYYMMDDHH24MISS'),'"$2"',0,0,0)"
exesql "$SQL"
SQL="insert into vvv.sms_pay values('"$COMM_SN"','alarm','"$phone"',to_char(sysdate,'YYYYMMDDHH24MISS'),'IOC_ALARM','2',to_char(sysdate,'YYYYMMDDHH24MISS'),'"$2"',0,0,0)"
exesql "$SQL"
PCOUNT=`expr $PCOUNT + 1`
echo "PCOUNT=${PCOUNT}"
sleep 1
done
}
exesql()
{
sqlplus -s $DBSTR <<EOF
set autocommit off;
$1;
commit;
exit;
EOF
}
for file in $FILES
do
if [ -f "${file}" ]; then
echo "[${file}]存在"
fail_count=`cat ${file}|wc -l`
echo "fail_count=${fail_count}"
tabrow=`sqlplus -S $DBSTR <<EOF1
set heading off;
set feedback off;
set pagesize 0;
set verify off;
set echo off;
select count(*) from log_ocs_info_user where insert_date='${curday}';
exit;
EOF1`
echo "tabrow=${tabrow}"
if [ "$tabrow" -ne "$fail_count" ]; then
msg="ocs账本导入时文件行数与log_ocs_info_user表记录行数不匹配"
echo $msg;
send_sms "01" "$msg"
fi
else
msg="ocs账本导入的文件[${file}]没有生成,请检查"
echo $msg
send_sms "02" "$msg"
fi
done
echo "结束!"