: !/bin/sh # T21BATCHNAME wb2 # T21BATCHDESC Generate Web Billing (Phase2) # ALLOWBLANKDATES false # CUSTOMDESC # CUSTOMDEF # T21BATCHVAR1DESC retroBDL # T21BATCHVAR1VALU # T21BATCHVAR2DESC Enter distid ID (Blank for ALL) # T21BATCHVAR2VALU # T21BATCHVAR3DESC # T21BATCHVAR3VALU # T21BATCHVAR4DESC # T21BATCHVAR4VALU # T21BATCHVAR5DESC # T21BATCHVAR5VALU # T21BATCHENDARGS ######################################################################## # usage: wb2 SDATE EDATE STIME ETIME SITEID thisCENTRE SDATE=$1; EDATE=$2; STIME=$3; ETIME=$4 if [ -n "$5" ]; then SITEID=$5 else SITEID="ALL" fi if [ -n "$6" ]; then thisCENTRE="$6" else thisCENTRE="all" fi #----- # from doex3web if [ -n "$7" ]; then RESTcde="$7" else RESTcde="1" fi if [ -n "$8" ]; then platinumBATCH="$8" else platinumBATCH="all" fi #----- if [ -n "$T21BATCHVAR1VALU" ]; then retroBDL="$T21BATCHVAR1VALU" else retroBDL="0" fi if [ -n "$T21BATCHVAR2VALU" ]; then thisDISTID="$T21BATCHVAR2VALU" else thisDISTID="all" fi export retroBDL if [ "$retroBDL" != "1" ]; then exfnprefix="ex2_" wbfnprefix="wb2_" else exfnprefix="ex2r_" wbfnprefix="wb2r_" fi ################################### # from env if [ -z "$switchboardcallcost" ]; then switchboardcallcost="0" fi if [ -z "$voicemailcallcost" ]; then voicemailcallcost="0" fi ################################### MMYYYY=`SDATEtoMMYYYY $SDATE` echo "MMYYYY = [$MMYYYY]" billperiod=`MMYYYYtobillperiod $MMYYYY _` echo "$MMYYYY - billperiod = [$billperiod]" #batchtag="${billperiod}_${platinumBATCH}_${thisDIVID}" batchtag="${thisCENTRE}" ##################################### # save output #logfile="${wbfnprefix}${thisCENTRE}_log.rtf" logfile="${wbfnprefix}${batchtag}_log.rtf" exec 2>&1 >"$logfile" echo "$0: SDATE=[$SDATE] EDATE=[$EDATE] thisCENTRE=[$thisCENTRE]" echo " retroBDL=[$retroBDL]" echo " thisDISTID=[$thisDISTID]" export SDATE EDATE thisCENE ######################################################### ## for Back Billing #savedir="indata/${billperiod}/TELMAX21" # #edd=`echo $EDATE | sed -e 's/\/..\/....$//g'` #emm=`echo $EDATE | sed -e 's/^..\///g;s/\/....$//g'` #eyyyy=`echo $EDATE | sed -e 's/^..\/..\///g'` #eyyyymmdd="${eyyyy}${emm}${edd}" # #if [ "$retroBDL" != "1" ]; then # # init bb1 files # bb1file="TIMS_${eyyyy}${emm}${edd}.txt" # invfile="TIMS_${eyyyy}${emm}${edd}_invoice.csv" # othfile="TIMS_${eyyyy}${emm}${edd}.other" # # remove any remnants and create empty files before starting # # (wb2.awk will append to these files) # > "$bb1file" # > "$invfile" # > "$othfile" # # > "old$bb1file" # > "old$invfile" # > "old$othfile" #fi ################################### # assumes wb2a has already been run # which creates the follow files.... acccodeconffile="indata/${billperiod}/t21acccodeconf.unl" t21rtfile="indata/${billperiod}/t21rt.unl" mobconffile="indata/${billperiod}/mobconf.unl" chargecatfile="indata/${billperiod}/chargecat.unl" dataplanfile="indata/${billperiod}/dataplan.unl" t21extrangesfile="indata/${billperiod}/t21extranges.unl" t21groups4file="indata/${billperiod}/t21groups4.unl" t21dircsvfile="indata/${billperiod}/T21E.csv" if [ "$retroBDL" != "1" ]; then t21WBDLfile="indata/${billperiod}/t21WBDL.unl" else t21WBDLfile="indata/${billperiod}/t21WBDLr.unl" fi t21wbdexcludefile="indata/${billperiod}/t21wbdexclude.unl" #tblCustomerfile="indata/${billperiod}/tblCustomer.unl" #tblTASSEMapfile="indata/${billperiod}/tblTASSEMap.unl" ################################### # get new copy of mobile conf rm -f $mobconffile echo "Creating mobile conf file: $mobconffile" ##getmobconf "$mobconffile" #getSIDMAINTconf "$mobconffile" "" "mobile_phones" $SDATE $EDATE # get mobconf info from tbs data gettbsmobconf cp $mobconffile "mobconf.unl" ################################### # get exwebconf - should always get new copy incase of changes exwebconffile="exwebconf.csv" runisql <&1 unload to /tmp/$exwebconffile delimiter "," select * from exwebconf order by parent; SQLCMD0 cp /tmp/$exwebconffile $exwebconffile ## save to indata cp $exwebconffile "indata/${billperiod}" ################################### # get tbs data # always get new copy for each batch run tbsCustomerfile="indata/${billperiod}/tCustomer.unl" tbsServiceTypefile="indata/${billperiod}/tServiceType.unl" tbsElementfile="indata/${billperiod}/tElement.unl" tbsSupplierfile="indata/${billperiod}/tSupplier.unl" tbsPersonServiceListfile="indata/${billperiod}/tbspersonservicelist.unl" # get tbs config data gettbs tCustomer $tbsCustomerfile gettbs tServiceType $tbsServiceTypefile gettbs tElement $tbsElementfile gettbs tSupplier $tbsSupplierfile # get tbs person serverice list gettbspersonservicelist $tbsPersonServiceListfile # get invoice and CDE data from TBSdata # - should always get new copy platinvfile="platinv_${batchtag}.unl" cdefile="cde_${batchtag}.cde" # get invoice number exclusion sqlbit if [ -f "invcde.excl_${billperiod}" ]; then . invcde.excl_${billperiod} fi #Testing #getinvcde5 "$SDATE" "$EDATE" "$platinvfile" "$cdefile" ###detailodir="${logdir}/detail_${batchtag}" ###detailodir="detail_${MMYYYY}" #detailodir="detail_dir" ##time getinvcdedetail5 "$SDATE" "$EDATE" "$platinvfile" "$cdefile" "$detailodir" #save cp $platinvfile "indata/${billperiod}" cp $cdefile "indata/${billperiod}" ######################################################## if [ "$retroBDL" != "1" ]; then if [ "$thisCENTRE" = "all" ]; then echo "rm -fr topdat/${billperiod}" rm -fr topdat/${billperiod} fi fi ########################## # t21 account code call file created by wb2a t21acccodecallsfile="indata/${billperiod}/TELMAX21/cda_${MMYYYY}.in" ########################## # t21 overheads file created by wb2a t21ovhfile="indata/${billperiod}/TELMAX21/ovh_${MMYYYY}.in" ########################## # t21 call file created by wb2a t21callsfile="indata/${billperiod}/TELMAX21/c9_${MMYYYY}.in" # t21 SWITCHBOARD call file created by wb3a - swb9 t21swcallsfile="indata/${billperiod}/VICTRACK/s9_${MMYYYY}.in" # t21 VOICEMAIL call file created by wb3a - vml9 t21vmcallsfile="indata/${billperiod}/VICTRACK/v9_${MMYYYY}.in" # t21 TEC (rent) file created by wb3a - tec9 t21tecfile="indata/${billperiod}/VICTRACK/r9_${MMYYYY}.in" ########################## # remove tmp t21callsfile # Testing # (for testing dont rm after first run ok) #rm -f ${t21callsfile}.tmp ############################## # create mobile calls file mobcallsfile="indata/${billperiod}/TELMAX21/wb2_m11_${MMYYYY}.in" if [ "$retroBDL" != "1" ]; then # always redo rm -f "$mobcallsfile" if [ ! -f "$mobcallsfile" ]; then echo "Creating mobile calls file: $mobcallsfile" domob $SDATE $EDATE wb2_m11.in mv wb2_m11.in "$mobcallsfile" else echo "Using existing mobile calls file: $mobcallsfile" fi fi ########################### # create web billing # #gawk --dump-variable awk \ -f wb2.awk -v "MMYYYY=$MMYYYY" -v"sdate=$SDATE" -v"edate=$EDATE" \ -v "dot21verify=0" \ -v "retroBDL=$retroBDL" \ -v "thisDISTID=$thisDISTID" \ -v "thisCENTRE=$thisCENTRE" \ -v "RESTcde=$RESTcde" \ -v "platinumBATCH=$platinumBATCH" \ -v "switchboardcallcost=$switchboardcallcost" \ -v "voicemailcallcost=$voicemailcallcost" \ -v "platinvfile=$platinvfile" \ -v "cdefile=$cdefile" \ -v "detailodir=$detailodir" \ -v "t21acccodecallsfile=$t21acccodecallsfile" \ -v "t21ovhfile=$t21ovhfile" \ -v "t21callsfile=$t21callsfile" \ -v "t21swcallsfile=$t21swcallsfile" \ -v "t21vmcallsfile=$t21vmcallsfile" \ -v "t21tecfile=$t21tecfile" \ -v "mobcallsfile=$mobcallsfile" \ -v "acccodeconffile=$acccodeconffile" \ -v "exwebconffile=$exwebconffile" \ -v "mobconffile=$mobconffile" \ -v "chargecatfile=$chargecatfile" \ -v "t21rtfile=$t21rtfile" \ -v "t21extrangesfile=$t21extrangesfile" \ -v "t21groups4file=$t21groups4file" \ -v "t21dircsvfile=$t21dircsvfile" \ -v "t21WBDLfile=$t21WBDLfile" \ -v "t21wbdexcludefile=$t21wbdexcludefile" \ -v "tbsCustomerfile=$tbsCustomerfile" \ -v "tbsServiceTypefile=$tbsServiceTypefile" \ -v "tbsElementfile=$tbsElementfile" \ -v "tbsSupplierfile=$tbsSupplierfile" -v "tbsPersonServiceListfile=$tbsPersonServiceListfile" # run allmobilescsv allmobilescsv $billperiod $platinumBATCH $thisDIVID All if [ "$retroBDL" != "1" ]; then # create index files mkind "topdat/$billperiod" fi # rename HIERIEDx file if [ "$retroBDL" != "1" ]; then HIERIDxrtffile="HIERIDx_${thisCENTRE}_lst.rtf" mv HIERIDx.lst "$HIERIDxrtffile" else HIERIDxrtffile="HIERIDx_${thisCENTRE}_rlst.rtf" mv HIERIDx.rlst "$HIERIDxrtffile" fi ## save totals files #if [ "$retroBDL" != "1" ]; then # mv ex2_totrep.txt ex2_totrep_${thisCENTRE}.txt # mv ex2_totcsv*.csv ex2_totcsv_${thisCENTRE}.csv #else # mv ${exfnprefix}totrep.txt ${exfnprefix}totrep_${thisCENTRE}.txt # mv ${exfnprefix}totcsv*.csv ${exfnprefix}totcsv_${thisCENTRE}.csv #fi #rjswb3 ## check target #if [ -d "${targdir}" -o -L "${targdir}" ]; then # # if lok exists # if [ -e "${targdir}.lok" ]; then # echo "ERROR: already Running targdir ${targdir}" # showlink="" # else # echo "INFO: Created targdir ${targdir}" # showlink="SHOWLINK" # fi #else # echo "ERROR: ${targdir} NOT created" # showlink="" #fi # #if [ -e "${targdir}.lok" ]; then # showlink="" #fi # ## rename logs with ok fileext's #mv ${logdir}/HIERIDx_${batchtag}.lst ${logdir}/HIERIDx_${batchtag}_lst.rtf #mv ${logdir}/sundrys_${batchtag}.uniq ${logdir}/sundrys_${batchtag}_uniq.rtf #mv ${logdir}/DEPTID_${batchtag}.lst ${logdir}/DEPTID_${batchtag}_lst.rtf #mv ${logdir}/SID_${batchtag}.dup ${logdir}/SID_${batchtag}_dup.rtf # ## remove / archive processed mobile detail data #if [ "$thisDIVID" = "all" -a "$platinumBATCH" = "all" ]; then # # save if all run # basegsmcallsfile=`basename $gsmcallsfile` # #rm -f "indata/${billperiod}/VICTRACK/$basegsmcallsfile" # #mv "$gsmcallsfile" "indata/${billperiod}/VICTRACK" #else # remove it # rm -f "$gsmcallsfile" #fi #-rjswb3 #################### # Testing #exit 0 #################### # get warnings errwarnlogfile="${exfnprefix}ERROR_WARNING_${thisCENTRE}.rtf" rm -f $errwarnlogfile echo "" >>$errwarnlogfile echo "Warning / Error LOG" >>$errwarnlogfile echo "------------------------------------------" >>$errwarnlogfile echo "" >>$errwarnlogfile head -3 "$logfile" >>$errwarnlogfile echo "" >>$errwarnlogfile if [ "$retroBDL" != "1" ]; then egrep "FATAL|WARNING|ERROR" "$logfile" | sort -u >>$errwarnlogfile else egrep "FATAL|BMRETRO" "$logfile" >>$errwarnlogfile fi echo "" >>$errwarnlogfile if [ -s ${wbfnprefix}${batchtag}.out ]; then cat ${wbfnprefix}${batchtag}.out >>$errwarnlogfile echo "" >>$errwarnlogfile fi # zip log files ex2zip="${exfnprefix}${thisCENTRE}_LOGS.zip" rm -f "ex2zip" zip -9 "$ex2zip" \ $errwarnlogfile \ $logfile \ $HIERIDxrtffile ######################## # archive topdat #( time arctopdat 2>&1 ) 2>&1 >arctopdat.log #mv arctopdat.log arctopdat_log.rtf #zip -9 arctopdat_log.zip arctopdat_log.rtf #touch arctopdat_log.zip #rjswb3 ######################################################################### ## wb3.awk makes sym link if platinumBATCH is an invoice or div/sundry ## get actual platinumbatch file name / DIVID #actual_platinumBATCH_DIVID=`basename \`(cd "$targdir"; pwd)\`` #export actual_platinumBATCH_DIVID #echo "actual_platinumBATCH_DIVID = [$actual_platinumBATCH_DIVID]" # #actual_platinumBATCH=`basename \`(cd "$targdir"; pwd)\` | sed -e "s/_${thisDIVI}$//"` #export actual_platinumBATCH #echo "actual_platinumBATCH = [$actual_platinumBATCH]" # ######################################################################### ## email wb3 totals/csv #emailex3tot "${logdir}/ex3" "$billperiod" "$thisDIVID" "$platinumBATCH" "" "$shwlink" #-rjswb3 ####################### ## email wb2 totals/csv ##emailex2tot ${exfnprefix} $thisCENTRE arctopdat_log.zip #emailex2tot ${exfnprefix} $thisCENTRE ######################################################### # achive logs #logdir="topdat/${billperiod}/log" logdir="logs/$billperiod" rm -rf "$logdir" mkdir -p "$logdir" ls HIERIDx_${batchtag}_lst.rtf \ ex2_totcsv_${thisCENTRE}_mobiles.csv \ ex2_totcsv_${thisCENTRE}.csv \ ex2_totrep_${thisCENTRE}.txt \ ex2_ERROR_WARNING_${batchtag}.rtf \ $ex2zip \ exwebconf.csv \ wb2_${batchtag}_log.rtf \ wb2_${batchtag}.out \ nohup.out \ | cpio -pvdum "$logdir" #-------- exit 0