unload_rpt_table.sh

#!/bin/ksh
##########################################################################################
#程序名称:unload_rpt_table.sh
#作者姓名:

#开发时间:2010-7-8
#功能说明:

##########################################################################################
cd $HOME/smp_run/smpser/bin
. public.sh.rc

####################################################################
# 函数:getlastday
# 目的:得到前N天的日期
# 输入: 要得到前几天的日期
# 返回: 前N天的日期 YYYYMMDD形式
####################################################################
getlastday()
{
    RDAY=${1}
    INPUTDATE=${2}
    YEAR=`echo $INPUTDATE|cut -c 1-4`
    MONTH=`echo $INPUTDATE|cut -c 5-6`
    DAY=`echo $INPUTDATE|cut -c 7-8`
    DAY=`expr $DAY - $RDAY`
    if [ "$DAY" -le 0 ] ; then
        MONTH=`expr $MONTH - 1`
        case $MONTH in
        1|3|5|7|8|10)
            DAY=`expr $DAY + 31`
            ;;
        4|6|9|11)
            DAY=`expr $DAY + 30`
            ;;
        2)
            #闰年计算
            DAY=`expr $DAY + 28`
            if [ `expr $YEAR % 400` -eq 0 ] ; then
                DAY=`expr $DAY + 1`
            elif [ `expr $YEAR % 100` -ne 0 -a `expr $YEAR % 4` -eq 0 ] ; then
                DAY=`expr $DAY + 1`
            fi
            ;;
        0)
            YEAR=`expr $YEAR - 1`
            MONTH="12"
            DAY=`expr $DAY + 31`
        esac
        if [ $MONTH -lt 10 ] ; then     #保证月份为MM形式
            MONTH="0"$MONTH
        fi
    fi
    if [ $DAY -lt 10 ] ; then           #保证天为DD形式
        DAY="0"$DAY
    fi
    LASTDATE=$YEAR$MONTH$DAY
}

# ======   main   ==============================================
ProgName=`basename $0`

if [ "-$#" = "-1" ]; then
    processdate="$1"
elif [ "-$#" = "-0" ]; then
    processdate=`date '+%Y%m%d'`
else
    echo "please usage : $ProgName or $ProgName date"
    exit 1
fi

getlastday 1 $processdate
yesdate=$LASTDATE

#日志文件
LogFile=${LogDir}/unload_table.log

#程序启动日志
LogStart $ProgName

#每天只能运行一次
Flagfile=$HOME/smp_run/smpser/flag/unload_table_${processdate}.unl
if [ -f ${Flagfile} ]; then
    Log "Can't run ${ProgName} again today!"
    LogEnd $ProgName
    exit 1
fi

touch $Flagfile

#下载的文件存放目录
tempdir=${HOME}/smp_run/smpser/temp

Log "#################DBSERVERTYPE is ${DBSERVERTYPE}.."

Log "#################start unload bmpdbnode.."
filefirst=${tempdir}/${processdate}_bmpdbnode.list
if [ "-$DBSERVERTYPE" = "-INFORMIX" ]; then
    echo "unload to ${filefirst} SELECT BMPDBNODE,NODETYPE,DATASOURCE,VERSION FROM RPT_TB_BMPDBNODE WHERE NODETYPE = 0"  | dbaccess $SMPDBNAME
elif [ "-$DBSERVERTYPE" = "-ORACLE" ]; then
    echo "set   heading   off
set linesize 260
set   pagesize   0
set   feedback   off
set   echo   off
set   VERIFY   off
set   trimout   on
set   trimspool   on
set   termout   off
spool   ${filefirst}
select BMPDBNODE||'|'||NODETYPE||'|'||DATASOURCE||'|'||VERSION||'|' FROM RPT_TB_BMPDBNODE WHERE NODETYPE = 0;
spool   off  " > bmpdbnode.sql
echo "@bmpdbnode.sql" | sqlplus $SMPDBNAME/$SMP_ORA_DB_PASS@$ORACLE_INSTANCE >/dev/null 2>&1
fi
compress -cf ${filefirst} > "${filefirst}.Z"
Log "#################end unload bmpdbnode.."


Log "#################start unload bmpuserdbnode.."
filesecond=${tempdir}/${processdate}_bmpuserdbnode.list
if [ "-$DBSERVERTYPE" = "-INFORMIX" ]; then
    echo "unload to ${filesecond} SELECT BMPDBNODE,NODETYPE,DATASOURCE,VERSION FROM RPT_TB_BMPDBNODE WHERE NODETYPE = 1"  | dbaccess $SMPDBNAME
elif [ "-$DBSERVERTYPE" = "-ORACLE" ]; then
    echo "set   heading   off
set linesize 260
set   pagesize   0
set   feedback   off
set   echo   off
set   VERIFY   off
set   trimout   on
set   trimspool   on
set   termout   off
spool   ${filesecond}
select BMPDBNODE||'|'||NODETYPE||'|'||DATASOURCE||'|'||VERSION||'|' FROM RPT_TB_BMPDBNODE WHERE NODETYPE = 1;
spool   off  " > bmpuserdbnode.sql
echo "@bmpuserdbnode.sql" | sqlplus $SMPDBNAME/$SMP_ORA_DB_PASS@$ORACLE_INSTANCE >/dev/null 2>&1
fi
compress -cf ${filesecond} > "${filesecond}.Z"
Log "#################end unload bmpuserdbnode.."

Log "#################start unload bmpwithcbp.."
filethird=${tempdir}/${processdate}_bmpwithcbp.list
if [ "-$DBSERVERTYPE" = "-INFORMIX" ]; then
    echo "unload to ${filethird} SELECT RPT_TB_BMPDBNODE.BMPDBNODE, RPT_TB_BMPWITHCBP.CBP_NODE FROM RPT_TB_BMPWITHCBP,RPT_TB_BMPDBNODE WHERE RPT_TB_BMPDBNODE.NODETYPE = 0"  | dbaccess $SMPDBNAME
elif [ "-$DBSERVERTYPE" = "-ORACLE" ]; then
    echo "set   heading   off
set linesize 260
set   pagesize   0
set   feedback   off
set   echo   off
set   VERIFY   off
set   trimout   on
set   trimspool   on
set   termout   off
spool   ${filethird}
select RPT_TB_BMPDBNODE.BMPDBNODE||'|'||RPT_TB_BMPWITHCBP.CBP_NODE||'|' FROM RPT_TB_BMPWITHCBP,RPT_TB_BMPDBNODE WHERE RPT_TB_BMPDBNODE.NODETYPE = 0;
spool   off  " > bmpwithcbp.sql
echo "@bmpwithcbp.sql" | sqlplus $SMPDBNAME/$SMP_ORA_DB_PASS@$ORACLE_INSTANCE >/dev/null 2>&1
fi
compress -cf ${filethird} > "${filethird}.Z"
Log "#################end unload bmpwithcbp.."


Log "#################start unload cbp_inter_node.."
filefouth=${tempdir}/${processdate}_cbp_inter_node.list
if [ "-$DBSERVERTYPE" = "-INFORMIX" ]; then
    echo "unload to ${filefouth} SELECT CBP_INTER_NODE,CBP_HOME_NODE,SUBNODETYPE,PRIMARYFLOATIP,SECONDARYFLOATIP,ROUTE_INTER_NODE FROM RPT_CBP_INTER_NODE"  | dbaccess $SMPDBNAME
elif [ "-$DBSERVERTYPE" = "-ORACLE" ]; then
    echo "set   heading   off
set linesize 260
set   pagesize   0
set   feedback   off
set   echo   off
set   VERIFY   off
set   trimout   on
set   trimspool   on
set   termout   off
spool   ${filefouth}
select CBP_INTER_NODE||'|'||CBP_HOME_NODE||'|'||SUBNODETYPE||'|'||PRIMARYFLOATIP||'|'||SECONDARYFLOATIP||'|'||ROUTE_INTER_NODE||'|' FROM RPT_CBP_INTER_NODE;
spool   off  " > cbp_inter_node.sql
echo "@cbp_inter_node.sql" | sqlplus $SMPDBNAME/$SMP_ORA_DB_PASS@$ORACLE_INSTANCE >/dev/null 2>&1
fi
compress -cf ${filefouth} > "${filefouth}.Z"
Log "#################end unload cbp_inter_node.."


Log "#################start unload cbp_node.."
filefive=${tempdir}/${processdate}_cbp_node.list
if [ "-$DBSERVERTYPE" = "-INFORMIX" ]; then
    echo "unload to ${filefive} SELECT CBP_NODE,NODETYPE,PRIMARYFLOATIP,SECONDARYFLOATIP,DIAMETER_HOST,DIAMETER_REALM,VERSION,NAME_LANG1 FROM RPT_CBP_NODE"  | dbaccess $SMPDBNAME
elif [ "-$DBSERVERTYPE" = "-ORACLE" ]; then
    echo "set   heading   off
set linesize 260
set   pagesize   0
set   feedback   off
set   echo   off
set   VERIFY   off
set   trimout   on
set   trimspool   on
set   termout   off
spool   ${filefive}
select CBP_NODE||'|'||NODETYPE||'|'||PRIMARYFLOATIP||'|'||SECONDARYFLOATIP||'|'||DIAMETER_HOST||'|'||DIAMETER_REALM||'|'||VERSION||'|'||NAME_LANG1||'|' FROM RPT_CBP_Node;
spool   off  " > cbp_node.sql
echo "@cbp_node.sql" | sqlplus $SMPDBNAME/$SMP_ORA_DB_PASS@$ORACLE_INSTANCE >/dev/null 2>&1
fi
compress -cf ${filefive} > "${filefive}.Z"
Log "#################end unload cbp_node.."

rm *.sql >/dev/null 2>&1
rm ${tempdir}/*.list >/dev/null 2>&1

#结束日志
LogEnd $ProgName

exit 0

BEGIN REGION Servo Power //Servo Power IF "AlwaysTRUE" AND "Control Voltage On" THEN "Robot1 Power for Servo 1-2" := "Robot2 Power for Servo 3-4" := "Robot3 Power for Servo 5-6" := "Robot4 Power for Travelling Servo 7-8" := "Robot5 Power for Travelling Servo 9-10" := true; ELSE "Robot1 Power for Servo 1-2" := "Robot2 Power for Servo 3-4" := "Robot3 Power for Servo 5-6" := "Robot4 Power for Travelling Servo 7-8" := "Robot5 Power for Travelling Servo 9-10" := FALSE; END_IF; //Servo Limit Sensor - 启用硬限位 IF "AlwaysTRUE" AND NOT "Buzzer Stop Button" THEN "DB1002_Control Status Epos".Robot1.X.CamAct := "DB1002_Control Status Epos".Robot1.Z.CamAct := "DB1002_Control Status Epos".Robot2.X.CamAct := "DB1002_Control Status Epos".Robot2.Z.CamAct := "DB1002_Control Status Epos".Robot3.X.CamAct := "DB1002_Control Status Epos".Robot3.Z.CamAct := "DB1002_Control Status Epos".Robot4.X.CamAct := "DB1002_Control Status Epos".Robot4.Z.CamAct := "DB1002_Control Status Epos".Robot5.X.CamAct := "DB1002_Control Status Epos".Robot5.Z.CamAct := "DB1002_Control Status Epos".Load.X.CamAct := "DB1002_Control Status Epos".UnLoad.X.CamAct := TRUE; ELSE "DB1002_Control Status Epos".Robot1.X.CamAct := "DB1002_Control Status Epos".Robot1.Z.CamAct := "DB1002_Control Status Epos".Robot2.X.CamAct := "DB1002_Control Status Epos".Robot2.Z.CamAct := "DB1002_Control Status Epos".Robot3.X.CamAct := "DB1002_Control Status Epos".Robot3.Z.CamAct := "DB1002_Control Status Epos".Robot4.X.CamAct := "DB1002_Control Status Epos".Robot4.Z.CamAct := "DB1002_Control Status Epos".Robot5.X.CamAct := "DB1002_Control Status Epos".Robot5.Z.CamAct := "DB1002_Control Status Epos".Load.X.CamAct := "DB1002_Control Status Epos".UnLoad.X.CamAct := false; END_IF; //Robot1 X Power And Reset "FC192_Robot_Power"("E-Stop" := "DB1002_Control Status Epos".Robot1.X."E-Stop", Fault := "DB1001_Actual Status Epos".Robot1.X.Fault, Ready := "DB1001_Actual Status Epos".Robot1.X.OFF1_Ready, "Alarm Reset" := "Alarm Reset", Off1 => "DB1002_Control Status Epos".Robot1.X.Off1, "Enable Temp" := "DB1003_Servo Button"."Robot1 X"."Servo enabled Temp", "Enable Reset" := "DB1003_Servo Button"."Robot1 X"."Servo enabled Reset", "Time" := "DB3_Time".Robot1.T65);
07-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值