def main( ): AfaLoggerFunc.tradeInfo('***农信银系统: 往账.回执类操作模板['+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']进入***') try: #=====================初始化返回报文变量================================ TradeContext.tradeResponse=[] #=====================获取系统日期时间================================== TradeContext.BJEDTE=AfaUtilTools.GetHostDate( ) #TradeContext.TRCDAT=AfaUtilTools.GetHostDate( ) #TradeContext.BJEDTE = PL_BJEDTE TradeContext.BJETIM=AfaUtilTools.GetSysTime( ) #TradeContext.TRCDAT = PL_BJEDTE #=====================系统公共校验====================================== if not rccpsFunc.ChkPubInfo(PL_BRSFLG_RCV) : raise AfaFlowControl.flowException( ) #=====================系统状态校验====================================== if not rccpsFunc.ChkSysInfo( 'AFA' ) : raise AfaFlowControl.flowException( ) #=====================机构合法性校验==================================== if not rccpsFunc.ChkUnitInfo(PL_BRSFLG_RCV) : raise AfaFlowControl.flowException( ) #=====================获取中心日期==================================== if not rccpsFunc.GetNCCDate( ) : raise AfaFlowControl.flowException( ) #=====================动态加载交易脚本================================== trxModuleName = 'T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode try: trxModuleHandle=__import__( trxModuleName ) except Exception, e: AfaLoggerFunc.tradeInfo(e) raise AfaFlowControl.flowException( 'A0001', '加载交易脚本失败或交易脚本不存在,执行交易失败' ) #=====================回执个性化处理(本地操作)========================== if not trxModuleHandle.SubModuleDoFst( ) : raise AfaFlowControl.flowException( ) #=====================自动打包========================================== AfaFunc.autoPackData() #=====================退出模板========================================== AfaLoggerFunc.tradeInfo('***农信银系统: 往账.回执类操作模板['+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']退出***')
def exitMainFlow( msgStr='' ): if( not TradeContext.existVariable( "errorCode" ) or msgStr ): TradeContext.errorCode = 'A9999' TradeContext.errorMsg = '系统错误['+msgStr+']' if TradeContext.errorCode != '0000' : AfaLoggerFunc.tradeFatal( 'errorCode=['+TradeContext.errorCode+']' ) AfaLoggerFunc.tradeFatal( 'errorMsg=['+TradeContext.errorMsg+']' ) AfaLoggerFunc.tradeFatal(TradeContext.TransCode+'交易中断') if( not AfaFunc.autoPackData() ): lenContext=len( TradeContext.tradeResponse ) chkFlag=0 for i in range( lenContext ): if( type(TradeContext.tradeResponse[i][0]) is str and (TradeContext.tradeResponse[i][0]=='errorCode' or TradeContext.tradeResponse[i][0]=='errorMsg')): if(TradeContext.tradeResponse[i][0]=='errorCode'): TradeContext.tradeResponse[i][1]=TradeContext.errorCode chkFlag=chkFlag+1 if(TradeContext.tradeResponse[i][0]=='errorMsg'): TradeContext.tradeResponse[i][1]=TradeContext.errorMsg chkFlag=chkFlag+1 if(chkFlag>=2): break elif i==lenContext-1 : TradeContext.tradeResponse.append( [ 'errorCode', TradeContext.errorCode ] ) TradeContext.tradeResponse.append( [ 'errorMsg', TradeContext.errorMsg ] )
def main( ): AfaLoggerFunc.tradeInfo('******代收代付.通用轧帐模板[' + TradeContext.TemplateCode + ']进入******' ) try: #=====================初始化返回报文变量================================ TradeContext.tradeResponse=[] #=====================获取当前系统时间================================== TradeContext.workDate=AfaUtilTools.GetSysDate( ) TradeContext.workTime=AfaUtilTools.GetSysTime( ) #=====================判断应用系统状态================================== #if not AfaFunc.ChkSysStatus( ) : # raise AfaFlowControl.flowException( ) #=====================校验公共节点的有效性============================== if( not TradeContext.existVariable( "statType" ) ): raise AfaFlowControl.flowException( 'A0001', '轧帐类型[statType]值不存在,不能进行轧帐' ) if( not TradeContext.existVariable( "TransType" ) ): raise AfaFlowControl.flowException( 'A0001', '传输类型[TransType]值不存在,不能进行轧帐' ) AfaLoggerFunc.tradeInfo( '>>>statType = ' + TradeContext.statType ) AfaLoggerFunc.tradeInfo( '>>>TransType = ' + TradeContext.TransType) #=====================轧帐操作========================================== if not StatAccountInfo( TradeContext.statType ) : raise AfaFlowControl.flowException( ) #=====================自动打包========================================== TradeContext.tradeResponse.append( ['errorCode', '0000'] ) TradeContext.tradeResponse.append( ['errorMsg', '交易成功'] ) AfaFunc.autoPackData() #=====================退出模板========================================== AfaLoggerFunc.tradeInfo( '******代收代付.通用轧帐模板[' + TradeContext.TemplateCode + ']退出******' ) except AfaFlowControl.flowException, e: AfaFlowControl.exitMainFlow( str(e) )
def main( ): AfaLoggerFunc.tradeInfo('********安徽省新农保.批量模板['+TradeContext.TemplateCode+']进入********') try: #=====================初始化返回报文变量================================ TradeContext.tradeResponse=[] #=====================获取系统日期时间================================== TradeContext.WorkDate=AfaUtilTools.GetSysDate( ) TradeContext.WorkTime=AfaUtilTools.GetSysTime( ) #=====================判断应用系统状态================================== if not AfaFunc.ChkSysStatus( ) : raise AfaFlowControl.flowException( ) #=====================动态加载交易脚本================================== trxModuleName = 'T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode try: trxModuleHandle=__import__( trxModuleName ) except Exception, e: AfaLoggerFunc.tradeInfo(e) raise AfaFlowControl.flowException( 'A0001', '加载交易脚本失败或交易脚本不存在' ) #=====================安徽新农保业务个性化操作========================== if not trxModuleHandle.TrxMain( ) : raise AfaFlowControl.flowException( TradeContext.errorCode,TradeContext.errorMsg) #=====================自动打包========================================== AfaFunc.autoPackData() #=====================退出模板========================================== AfaLoggerFunc.tradeInfo('********安徽省新农保.批量模板['+TradeContext.TemplateCode+']退出********')
def main( ): AfaLoggerFunc.tradeInfo('******柜面对账['+TradeContext.TemplateCode+']进入******') try: #=====================初始化返回报文变量================================ TradeContext.tradeResponse=[] #=====================获取当前系统时间================================== TradeContext.workDate=AfaUtilTools.GetSysDate( ) TradeContext.workTime=AfaUtilTools.GetSysTime( ) #=====================柜面对账处理====================================== admin() #=============自动打包==================== AfaFunc.autoPackData() #=====================退出模板========================================== AfaLoggerFunc.tradeInfo('******柜面对账['+TradeContext.TemplateCode+']退出******') except AfaFlowControl.flowException, e: AfaFlowControl.exitMainFlow( str(e) )
def main( ): AfaLoggerFunc.tradeInfo('********abs.通用模板进入********') try: #=====================初始化返回报文变量================================ TradeContext.tradeResponse=[] #=====================获取系统日期时间================================== TradeContext.TranDate=AfaUtilTools.GetSysDate( ) TradeContext.TranTime=AfaUtilTools.GetSysTime( ) #=====================动态加载交易脚本================================== trxModuleName = 'T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode try: trxModuleHandle=__import__( trxModuleName ) except Exception, e: AfaLoggerFunc.tradeInfo(e) raise AfaFlowControl.flowException( 'A0001', '加载交易脚本失败或交易脚本不存在' ) #=====================批量业务个性化操作================================ if not trxModuleHandle.TrxMain( ) : raise AfaFlowControl.accException( ) #=====================自动打包========================================== AfaFunc.autoPackData() #=====================退出模板========================================== AfaLoggerFunc.tradeInfo('********批量业务.通用模板['+TradeContext.TemplateCode+']退出********')
def main( ): AfaLoggerFunc.tradeInfo('***农信银系统: 往账.主机类操作模板['+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']进入***') try: #=====================初始化返回报文变量================================ TradeContext.tradeResponse=[] #=====================获取系统日期时间================================== TradeContext.BJEDTE=AfaUtilTools.GetHostDate( ) #TradeContext.BJEDTE = PL_BJEDTE TradeContext.BJETIM=AfaUtilTools.GetSysTime( ) #TradeContext.TRCDAT = PL_BJEDTE #关彬捷 20081111 修改委托日期为中心日期 #TradeContext.TRCDAT=AfaUtilTools.GetHostDate( ) #修改结束 #=====================系统公共校验====================================== if not rccpsFunc.ChkPubInfo(PL_BRSFLG_SND) : raise AfaFlowControl.flowException( ) #=====================系统状态校验====================================== if not rccpsFunc.ChkSysInfo( 'RCCPS' ) : raise AfaFlowControl.flowException( ) #=====================机构合法性校验==================================== if not rccpsFunc.ChkUnitInfo( PL_BRSFLG_SND ) : raise AfaFlowControl.flowException( ) #=====================获取中心日期==================================== if not rccpsFunc.GetNCCDate( ) : raise AfaFlowControl.flowException( ) #关彬捷 20081111 修改委托日期为中心日期 TradeContext.TRCDAT=TradeContext.NCCworkDate #修改结束 #=====================获取平台流水号==================================== if rccpsGetFunc.GetSerialno(PL_BRSFLG_SND) == -1 : raise AfaFlowControl.flowException( ) #=====================获取中心流水号==================================== if rccpsGetFunc.GetRccSerialno( ) == -1 : raise AfaFlowControl.flowException( ) #=====================动态加载交易脚本================================== trxModuleName = 'T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode try: trxModuleHandle=__import__( trxModuleName ) except Exception, e: AfaLoggerFunc.tradeInfo(e) raise AfaFlowControl.flowException( 'A0001', '加载交易脚本失败或交易脚本不存在,执行交易失败' ) #=====================交易前处理(登记流水,主机前处理)=================== if not trxModuleHandle.SubModuleDoFst( ) : raise AfaFlowControl.flowException( ) #=====================与主机通讯======================================== rccpsHostFunc.CommHost( TradeContext.HostCode ) #=====================交易中处理(修改流水,主机后处理,中心前处理)======== if not trxModuleHandle.SubModuleDoSnd( ) : raise AfaFlowControl.flowException( ) #=====================与中心通讯(回执)================================== AfaAfeFunc.CommAfe() #=====================交易后处理======================================== if not trxModuleHandle.SubModuleDoTrd(): raise AfaFlowControl.flowException( ) #=====================自动打包========================================== AfaFunc.autoPackData() #=====================退出模板========================================== AfaLoggerFunc.tradeInfo('***农信银系统: 往账.主机类操作模板['+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']退出***')
def main( ): sernoFlag = 0 AfaLoggerFunc.tradeInfo( '******代收代付.查询明细模板['+TradeContext.TemplateCode+']进入******' ) try: #=====================初始化返回报文变量================================ TradeContext.tradeResponse=[] #=====================获取当前系统时间================================== TradeContext.workDate=AfaUtilTools.GetSysDate( ) TradeContext.workTime=AfaUtilTools.GetSysTime( ) #=====================判断应用系统状态================================== if not AfaFunc.ChkSysStatus( ) : raise AfaFlowControl.flowException( ) #=====================校验公共节点的有效性============================== if( not TradeContext.existVariable( "zoneno" ) ): TradeFunc.exitOnError( 'A0001', '地区号[zoneno]值不存在,不能进行查询操作' ) if( not TradeContext.existVariable( "brno" ) ): TradeFunc.exitOnError( 'A0001', '网点号[brno]值不存在,不能进行查询操作' ) if( not TradeContext.existVariable( "tellerno" ) ): TradeFunc.exitOnError( 'A0001', '网点号[tellerno]值不存在,不能进行查询操作' ) if( not TradeContext.existVariable( "transStatus" ) ): TradeFunc.exitOnError( 'A0001', '交易状态[transStatus]值不存在,不能进行查询操作' ) if( not TradeContext.existVariable( "queryMode" ) ): TradeFunc.exitOnError( 'A0001', '查询方式[queryMode]值不存在,不能进行查询操作' ) if( not TradeContext.existVariable( "orderMode" ) ): TradeFunc.exitOnError( 'A0001', '排序方式[orderMode]值不存在,不能进行查询操作' ) if( not TradeContext.existVariable( "queryCount" ) ): TradeFunc.exitOnError( 'A0001', '查询条数[queryCount]值不存在,不能进行查询操作' ) if( not TradeContext.existVariable( "TransType" ) ): TradeFunc.exitOnError( 'A0001', '传输类型[TransType]值不存在,不能进行查询操作' ) AfaLoggerFunc.tradeInfo('>>>transStatus = ' + TradeContext.transStatus) AfaLoggerFunc.tradeInfo('>>>queryMode = ' + TradeContext.queryMode) AfaLoggerFunc.tradeInfo('>>>orderMode = ' + TradeContext.orderMode) AfaLoggerFunc.tradeInfo('>>>queryCount = ' + TradeContext.queryCount) AfaLoggerFunc.tradeInfo('>>>TransType = ' + TradeContext.TransType) AfaLoggerFunc.tradeInfo('>>>tradeDate = ' + TradeContext.tradeDate) #=====================定义每次返回的数据的记录数======================== queryCount = int( TradeContext.queryCount ) #=====================数据打包时使用list================================ names=['agentSerialno', 'sysId', 'unitno', 'subUnitno', 'workDate', 'workTime','agentFlag', 'transCode', 'zoneno', 'brno', 'tellerno', \ 'channelCode', 'accType', 'drAccno', 'crAccno', 'userno', 'subuserno', 'username', 'vouhType', 'vouhno', \ 'vouhDate', 'amount', 'subAmount', 'bankStatus', 'bankSerno', 'corpStatus', 'errormsg', 'note1', \ 'note2', 'note3', 'note4', 'note5', 'note6', 'note7', 'note8', 'note9', 'note10'] # =====================查询字段与数据打包的list一一对应================= SqlStr = "SELECT AGENTSERIALNO,SYSID,UNITNO,SUBUNITNO,WORKDATE,WORKTIME,AGENTFLAG,TRXCODE,ZONENO,BRNO,TELLERNO," SqlStr = SqlStr + "CHANNELCODE,ACCTYPE,DRACCNO,CRACCNO,USERNO,SUBUSERNO,USERNAME,VOUHTYPE,VOUHNO," SqlStr = SqlStr + "VOUHDATE,AMOUNT,SUBAMOUNT,BANKSTATUS,BANKSERNO,CORPSTATUS,ERRORMSG,NOTE1," SqlStr = SqlStr + "NOTE2,NOTE3,NOTE4,NOTE5,NOTE6,NOTE7,NOTE8,NOTE9,NOTE10 FROM AFA_MAINTRANSDTL " #=====================统计总笔数和总金额================================ sql_count = "SELECT COUNT(*),SUM(CAST(AMOUNT AS DECIMAL(17,2))) FROM AFA_MAINTRANSDTL" sql = '' if ( int( TradeContext.queryMode ) == 4 ): #自由查询方式 if( not TradeContext.existVariable( "whereClause" ) ): TradeFunc.exitOnError( 'A0001', '查询条件[whereClause]值不存在,不能进行查询操作' ) sql= sql + TradeContext.whereClause + " AND REVTRANF='0' " AfaLoggerFunc.tradeInfo('>>>whereClause = ' + TradeContext.whereClause) else: if( not TradeContext.existVariable( "tradeDate" ) ): TradeFunc.exitOnError( 'A0001', '交易日期[tradeDate]值不存在,不能进行查询操作' ) if( not TradeContext.existVariable( "channelCode" ) ): TradeFunc.exitOnError( 'A0001', '渠道代码[channelCode]值不存在,不能进行查询操作' ) #日期 sql = sql + " WHERE WORKDATE='" + TradeContext.tradeDate + "'" #地区号 sql = sql + " AND CHANNELCODE='" + TradeContext.channelCode + "'" #地区号 sql = sql + " AND ZONENO='" + TradeContext.zoneno + "'" #网点号 sql = sql + " AND BRNO='" + TradeContext.brno + "'" #柜员 sql = sql + " AND TELLERNO='" + TradeContext.tellerno + "'" #柜员 sql = sql + " AND REVTRANF='" + "0" + "'" #用户 if( TradeContext.existVariable( "userno" ) and len(TradeContext.userno)>0 ): sql = sql + " AND USERNO='" + TradeContext.userno + "'" #金额 if( TradeContext.existVariable( "amount" ) and int(float(TradeContext.amount)*100)!=0 ): sAmount="0.00"; for i in range(0, len(TradeContext.amount)): if TradeContext.amount[i] == '0': continue sAmount = TradeContext.amount[i:] break sql = sql + " AND AMOUNT='" + sAmount + "'" #用户名 if( TradeContext.existVariable( "username" ) and len(TradeContext.username)>0 ): sql = sql + " AND USERNAME='******'" #帐号 if( TradeContext.existVariable( "accno" ) and len(TradeContext.accno)>0 ): sql = sql + " AND (DRACCNO='" + TradeContext.accno + "' OR CRACCNO='" + TradeContext.accno + "')" #transStatus:交易状态(1-正常, 2-未知, 3-全部) if( int( TradeContext.transStatus ) == 1 ): #查询正常交易 sql = sql + " AND BANKSTATUS='0' AND CORPSTATUS='0'" elif( int( TradeContext.transStatus ) == 2 ): #查询未知交易 sql = sql + " AND (AGENTFLAG IN ('01','03') AND (BANKSTATUS='2' OR (BANKSTATUS='0' AND CORPSTATUS IN ('1', '2','3')))) OR" sql = sql + " (AGENTFLAG IN ('02','04') AND (CORPSTATUS='2' OR (CORPSTATUS='0' AND BANKSTATUS IN ('1', '2','3')))) " elif( int( TradeContext.transStatus ) != 3 ): TradeContext.errorCode, TradeContext.errorMsg='A0041', "入口参数条件不符[交易状态]:"+str( TradeContext.transStatus ) raise AfaFlowControl.flowException( ) #queryMode:查询方式(1-按流水号查询, 2-按系统代码查询, 3-查询全部正交易, 4-自由查询方式) if( int( TradeContext.queryMode ) == 1 ): #按流水号查询 if( not TradeContext.existVariable( "agentSerialno" ) ): TradeFunc.exitOnError( 'A0001', '流水号[agentSerialno]值不存在!' ) sql = sql + " AND AGENTSERIALNO='"+TradeContext.agentSerialno + "'" sernoFlag = 1 elif( int( TradeContext.queryMode ) == 2 ): #按系统代码查询 if( not TradeContext.existVariable( "sysId" ) ): TradeFunc.exitOnError( 'A0001', '系统代码[sysId]值不存在!' ) #系统代码 sql = sql + " AND SYSID='" + TradeContext.sysId + "'" #按流水号查询 if( TradeContext.existVariable( "agentSerialno" ) and len(TradeContext.agentSerialno)>0 ): sql = sql + " AND AGENTSERIALNO='"+TradeContext.agentSerialno + "'" sernoFlag = 1 #业务方式 if( TradeContext.existVariable( "agentFlag" ) and len(TradeContext.agentFlag)>0 ): sql=sql + " AND AGENTFLAG='" + TradeContext.agentFlag + "'" #单位代码 if( TradeContext.existVariable( "unitno" ) and len(TradeContext.unitno)>0 ): sql=sql + " AND UNITNO='" + TradeContext.unitno + "'" #子单位代码 if( TradeContext.existVariable( "subUnitno" ) and len(TradeContext.subUnitno)>0 ): sql=sql + " AND SUBUNITNO='" + TradeContext.subUnitno + "'" elif( int( TradeContext.queryMode ) != 3 and int( TradeContext.queryMode ) != 4 ): TradeContext.errorCode, TradeContext.errorMsg='A0041', "入口参数条件不符[查询方式]:"+str( TradeContext.queryMode ) raise AfaFlowControl.flowException( ) sql_count = sql_count + sql #按流水查询应该是单结果集的,没有排序的必要 if( int( TradeContext.queryMode ) != 1 and sernoFlag==0): #orderMode:排序方式:1-正序 2-逆序 if( int( TradeContext.orderMode ) == 1 ): #正序 if( (not TradeContext.existVariable( "agentSerialno" )) or TradeContext.agentSerialno=='' ): TradeContext.agentSerialno='0' sql = sql + " AND AGENTSERIALNO>'" + TradeContext.agentSerialno + "' ORDER BY AGENTSERIALNO ASC" else: #逆序 if( (not TradeContext.existVariable( "agentSerialno" )) or TradeContext.agentSerialno=='' ): TradeContext.agentSerialno='99999999' sql = sql + " AND AGENTSERIALNO<'"+TradeContext.agentSerialno + "' ORDER BY AGENTSERIALNO DESC" #查询数据库 SqlStr = SqlStr + sql AfaLoggerFunc.tradeInfo( '>>>查询明细' ) AfaLoggerFunc.tradeInfo( SqlStr ) records=AfaDBFunc.SelectSql( SqlStr, queryCount ) if( records == None ): #None 查询失败 TradeContext.errorCode, TradeContext.errorMsg='A0025', "数据库操作错误" raise AfaFlowControl.flowException( ) elif( len( records ) == 0 ): #无记录 TradeContext.errorCode, TradeContext.errorMsg='A0025', "没有满足条件的记录" raise AfaFlowControl.flowException( ) AfaLoggerFunc.tradeInfo( '>>>统计总数' ) #统计总数 AfaLoggerFunc.tradeInfo( sql_count ) records_count=AfaDBFunc.SelectSql( sql_count ) if( records_count == None ): TradeContext.errorCode, TradeContext.errorMsg='A0025', "数据库操作错误" raise AfaFlowControl.flowException( ) # 过滤records中的所有None数据 records=AfaUtilTools.ListFilterNone( records ) #总共的返回记录数 total=len( records ) AfaLoggerFunc.tradeInfo( '返回记录数:[' + str(total) + ']' ) #公共部分拼包 TradeContext.tradeResponse=[] TradeContext.tradeResponse.append( ['errorCode', '0000'] ) TradeContext.tradeResponse.append( ['errorMsg', '交易成功'] ) TradeContext.tradeResponse.append( ['retCount', str( total )] ) TradeContext.tradeResponse.append( ['retTotalCount', str( records_count[0][0] )]) TradeContext.tradeResponse.append( ['retTotalAmount',str( records_count[0][1] )]) if ( TradeContext.TransType == '0' ): #按照变量名打包 for i in range( 0, total ): k=0 for name in names: if( int( TradeContext.orderMode ) == 1 ): TradeContext.tradeResponse.append( [name, records[i][k]] ) else: TradeContext.tradeResponse.append( [name, records[total-i-1][k]] ) k=k+1 else: MxFileName = os.environ['AFAP_HOME'] + '/tmp/MX' + TradeContext.zoneno + TradeContext.brno + TradeContext.tellerno + '.TXT' AfaLoggerFunc.tradeInfo('明细文件:['+MxFileName+']') if (os.path.exists(MxFileName) and os.path.isfile(MxFileName)): #文件存在,先删除-再创建 os.system("rm " + MxFileName) #创建明细文件 sfp = open(MxFileName, "w") #将每条记录打包成以竖线分隔的格式 TradeContext.tradeResponse.append(['filename', 'MX' + TradeContext.zoneno + TradeContext.brno + TradeContext.tellerno + '.TXT']) for i in range( 0, total ): tmpBuffer = "" tmpBuffer = tmpBuffer + str(records[i][0]).strip() + "|" #AGENTSERIALNO tmpBuffer = tmpBuffer + str(records[i][1]).strip() + "|" #SYSID tmpBuffer = tmpBuffer + str(records[i][2]).strip() + "|" #UNITNO tmpBuffer = tmpBuffer + str(records[i][3]).strip() + "|" #SUBUNITNO tmpBuffer = tmpBuffer + str(records[i][4]).strip() + "|" #WORKDATE tmpBuffer = tmpBuffer + str(records[i][5]).strip() + "|" #WORKTIME tmpBuffer = tmpBuffer + str(records[i][6]).strip() + "|" #AGENTFLAG tmpBuffer = tmpBuffer + str(records[i][7]).strip() + "|" #TRXCODE tmpBuffer = tmpBuffer + str(records[i][8]).strip() + "|" #ZONENO tmpBuffer = tmpBuffer + str(records[i][9]).strip() + "|" #BRNO tmpBuffer = tmpBuffer + str(records[i][10]).strip() + "|" #TELLERNO tmpBuffer = tmpBuffer + str(records[i][11]).strip() + "|" #CHANNELCODE tmpBuffer = tmpBuffer + str(records[i][12]).strip() + "|" #ACCTYPE tmpBuffer = tmpBuffer + str(records[i][13]).strip() + "|" #DRACCNO tmpBuffer = tmpBuffer + str(records[i][14]).strip() + "|" #CRACCNO tmpBuffer = tmpBuffer + str(records[i][15]).strip() + "|" #USERNO tmpBuffer = tmpBuffer + str(records[i][16]).strip() + "|" #SUBUSERNO tmpBuffer = tmpBuffer + str(records[i][17]).strip() + "|" #USERNAME tmpBuffer = tmpBuffer + str(records[i][18]).strip() + "|" #VOUHTYPE tmpBuffer = tmpBuffer + str(records[i][19]).strip() + "|" #VOUHNO tmpBuffer = tmpBuffer + str(records[i][20]).strip() + "|" #VOUHDATE tmpBuffer = tmpBuffer + str(records[i][21]).strip() + "|" #AMOUNT tmpBuffer = tmpBuffer + str(records[i][22]).strip() + "|" #SUBAMOUNT tmpBuffer = tmpBuffer + str(records[i][23]).strip() + "|" #BANKSTATUS tmpBuffer = tmpBuffer + str(records[i][24]).strip() + "|" #BANKSERNO tmpBuffer = tmpBuffer + str(records[i][25]).strip() + "|" #CORPSTATUS tmpBuffer = tmpBuffer + str(records[i][26]).strip() + "|" #ERRORMSG tmpBuffer = tmpBuffer + str(records[i][27]).strip() + "|" #NOTE1 tmpBuffer = tmpBuffer + str(records[i][28]).strip() + "|" #NOTE2 tmpBuffer = tmpBuffer + str(records[i][29]).strip() + "|" #NOTE3 tmpBuffer = tmpBuffer + str(records[i][30]).strip() + "|" #NOTE4 tmpBuffer = tmpBuffer + str(records[i][31]).strip() + "|" #NOTE5 tmpBuffer = tmpBuffer + str(records[i][32]).strip() + "|" #NOTE6 tmpBuffer = tmpBuffer + str(records[i][33]).strip() + "|" #NOTE7 tmpBuffer = tmpBuffer + str(records[i][34]).strip() + "|" #NOTE8 tmpBuffer = tmpBuffer + str(records[i][35]).strip() + "|" #NOTE9 tmpBuffer = tmpBuffer + str(records[i][36]).strip() + "|" #NOTE10 sfp.write(tmpBuffer + '\n') sfp.close() #=====================自动打包========================================== AfaFunc.autoPackData() #=====================退出模板========================================== AfaLoggerFunc.tradeInfo( '******代收代付.查询明细模板['+TradeContext.TemplateCode+']退出******' ) except AfaFlowControl.flowException, e: AfaFlowControl.exitMainFlow( str(e) )
def main( ): AfaLoggerFunc.tradeInfo('******代收代付.补打发票模板[' + TradeContext.TemplateCode + ']进入******') try: #=====================初始化返回报文变量================================ TradeContext.tradeResponse=[] #=====================获取当前系统时间================================== TradeContext.workDate=AfaUtilTools.GetSysDate( ) TradeContext.workTime=AfaUtilTools.GetSysTime( ) #=====================判断应用系统状态================================== if not AfaFunc.ChkSysStatus( ) : raise AfaFlowControl.flowException( ) #=====================校验公共节点的有效性============================== if( not TradeContext.existVariable( "sysId") ): raise AfaFlowControl.flowException( 'A0001', '系统标识[sysId]值不存在,不能进行补打发票' ) if( not TradeContext.existVariable( "userno") ): raise AfaFlowControl.flowException( 'A0001', '用户号[userno]值不存在,不能进行补打发票' ) #=====================判断应用系统状态================================== if not AfaFunc.ChkSysStatus( ) : raise AfaFlowControl.flowException( ) #=====================判断商户状态====================================== if not AfaFunc.ChkUnitStatus( ) : raise AfaFlowControl.flowException( ) #=====================判断渠道状态====================================== if not AfaFunc.ChkChannelStatus( ) : raise AfaFlowControl.flowException( ) #操作标志(0-查询发票信息 1-修改打印次数 2-从第三方获取发票信息,进行打印) if( not TradeContext.existVariable( "procFlag") ): raise AfaFlowControl.flowException( 'A0001', '操作标志[tradeFlag"]值不存在,不能进行补打发票' ) if(TradeContext.procFlag=="0"): #查询发票信息 sql="SELECT BILLDATA,ITEM1,ITEM2,ITEM3,ITEM4,ITEM5,ITEM6,BILLSERNO,SERIALNO,PRTNUM,WORKDATE,BILLSTATUS FROM AFA_BILLDTL WHERE " sql=sql + " SYSID='" + TradeContext.sysId + "'" sql=sql + " AND UNITNO='" + TradeContext.unitno + "'" if( TradeContext.existVariable( "subUnitno") ): sql=sql + " AND SUBUNITNO='" + TradeContext.subUnitno + "'" if( TradeContext.existVariable( "userno") ): sql=sql + " AND USERNO='" + TradeContext.userno + "'" if( TradeContext.existVariable( "payMonth") ): sql=sql + " AND WORKDATE LIKE '" + TradeContext.payMonth + "%'" if( TradeContext.existVariable( "item1") ): sql=sql + " AND ITEM1='" + TradeContext.item1 + "'" if( TradeContext.existVariable( "item2") ): sql=sql + " AND ITEM2='" + TradeContext.item1 + "'" if( TradeContext.existVariable( "item3") ): sql=sql + " AND ITEM3='" + TradeContext.item1 + "'" if( TradeContext.existVariable( "item4") ): sql=sql + " AND ITEM4='" + TradeContext.item1 + "'" if( TradeContext.existVariable( "item5") ): sql=sql + " AND ITEM5='" + TradeContext.item1 + "'" if( TradeContext.existVariable( "item6") ): sql=sql + " AND ITEM6='" + TradeContext.item1 + "'" sql=sql + " ORDER BY WORKDATE DESC,WORKTIME DESC " AfaLoggerFunc.tradeInfo( sql ) records = AfaDBFunc.SelectSql(sql) if( records == None ): raise AfaFlowControl.flowException( 'A0002', '数据库操作异常:' + AfaDBFunc.sqlErrMsg ) if(len(records)==0): raise AfaFlowControl.flowException( 'A0002', '无符合条件的记录' ) if(int(records[0][9])==3): raise AfaFlowControl.flowException( 'A0002', '最多3次重打' ) if(int(records[0][11])==1): raise AfaFlowControl.flowException( 'A0002', '票据已作废,不允许打印' ) TradeContext.billNum = str(len(records)) #发票数量 if ( TradeContext.TransType=='0' ): #变量初始化 TradeContext.billData = [] #发票信息 TradeContext.item1 = [] #附加项1 TradeContext.item2 = [] #附加项2 TradeContext.item3 = [] #附加项3 TradeContext.item4 = [] #附加项4 TradeContext.item5 = [] #附加项5 TradeContext.item6 = [] #附加项6 TradeContext.billserno= [] #发票序号 TradeContext.serialno = [] #中间业务流水号 TradeContext.prtnum = [] #打印次数 TradeContext.paydate = [] #支付日期 #打包 for i in range( 0, len(records) ): TradeContext.billData.append(records[i][0]) TradeContext.item1.append(records[i][1]) TradeContext.item2.append(records[i][2]) TradeContext.item3.append(records[i][3]) TradeContext.item4.append(records[i][4]) TradeContext.item5.append(records[i][5]) TradeContext.item6.append(records[i][6]) TradeContext.billserno.append(records[i][7]) TradeContext.serialno.append(records[i][8]) TradeContext.prtnum.append(records[i][9]) TradeContext.paydate.append(records[i][10]) else: MxFileName = os.environ['AFAP_HOME'] + '/tmp/MX' + TradeContext.zoneno + TradeContext.brno + TradeContext.tellerno + '.TXT' AfaLoggerFunc.tradeInfo('>>>明细文件:['+MxFileName+']') if (os.path.exists(MxFileName) and os.path.isfile(MxFileName)): #文件存在,先删除-再创建 os.system("rm " + MxFileName) #创建明细文件 sfp = open(MxFileName, "w") for i in range( 0, len(records) ): wBuffer = "" wBuffer = wBuffer + records[i][0] wBuffer = wBuffer + records[i][1] wBuffer = wBuffer + records[i][2] wBuffer = wBuffer + records[i][3] wBuffer = wBuffer + records[i][4] wBuffer = wBuffer + records[i][5] wBuffer = wBuffer + records[i][6] wBuffer = wBuffer + records[i][7] wBuffer = wBuffer + records[i][8] wBuffer = wBuffer + records[i][9] wBuffer = wBuffer + records[i][10] sfp.write(wBuffer + '\n') sfp.close() elif(TradeContext.procFlag=="1"): #从第三方获取发票信息,进行打印 #=====================获取平台流水号==================================== if( not AfaFunc.GetSerialno( ) ): raise AfaFlowControl.flowException( ) #=====================外调接口(前处理)================================== subModuleExistFlag=0 subModuleName = 'T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode try: subModuleHandle=__import__( subModuleName ) except Exception, e: AfaLoggerFunc.tradeInfo( e) else: AfaLoggerFunc.tradeInfo( '执行['+subModuleName+']模块' ) subModuleExistFlag=1 if not subModuleHandle.SubModuleDoFst( ) : raise AfaFlowControl.flowException( ) #与通讯前置交换 AfaAfeFunc.CommAfe() if TradeContext.errorCode!='0000' : raise AfaFlowControl.flowException( ) #发票数量 TradeContext.billNum = Party3Context.billNum if ( TradeContext.TransType=='0' ): #变量初始化 TradeContext.billData = [] #发票信息 TradeContext.item1 = [] #附加项1 TradeContext.item2 = [] #附加项2 TradeContext.item3 = [] #附加项3 TradeContext.item4 = [] #附加项4 TradeContext.item5 = [] #附加项5 TradeContext.item6 = [] #附加项6 TradeContext.billserno= [] #发票序号 TradeContext.serialno = [] #中间业务流水号 TradeContext.prtnum = [] #打印次数 TradeContext.paydate = [] #支付日期 if ( int(Party3Context.billNum) == 1 ): #打包(一张发票) TradeContext.billData = Party3Context.billData TradeContext.item1 = Party3Context.item1 TradeContext.item2 = Party3Context.item2 TradeContext.item3 = Party3Context.item3 TradeContext.item4 = Party3Context.item4 TradeContext.item5 = Party3Context.item5 TradeContext.item6 = Party3Context.item6 TradeContext.billserno = Party3Context.billserno TradeContext.serialno = Party3Context.serialno TradeContext.prtnum = Party3Context.prtnum TradeContext.paydate = Party3Context.paydate else: #打包(多张发票) for i in range( 0, int(Party3Context.billNum) ): TradeContext.billData.append(Party3Context.billData[i]) TradeContext.item1.append(Party3Context.item1[i]) TradeContext.item2.append(Party3Context.item2[i]) TradeContext.item3.append(Party3Context.item3[i]) TradeContext.item4.append(Party3Context.item4[i]) TradeContext.item5.append(Party3Context.item5[i]) TradeContext.item6.append(Party3Context.item6[i]) TradeContext.billserno.append(Party3Context.billserno[i]) TradeContext.serialno.append(Party3Context.serialno[i]) TradeContext.prtnum.append(Party3Context.prtnum[i]) TradeContext.paydate.append(Party3Context.paydate[i]) else: MxFileName = os.environ['AFAP_HOME'] + '/tmp/MX' + TradeContext.zoneno + TradeContext.brno + TradeContext.tellerno + '.TXT' AfaLoggerFunc.tradeInfo('>>>明细文件:['+MxFileName+']') if (os.path.exists(MxFileName) and os.path.isfile(MxFileName)): #文件存在,先删除-再创建 os.system("rm " + MxFileName) #创建明细文件 sfp = open(MxFileName, "w") if ( int(Party3Context.billNum) == 1 ): #打包(一张发票) wBuffer = "" wBuffer = wBuffer + Party3Context.billData wBuffer = wBuffer + Party3Context.item1 wBuffer = wBuffer + Party3Context.item2 wBuffer = wBuffer + Party3Context.item3 wBuffer = wBuffer + Party3Context.item4 wBuffer = wBuffer + Party3Context.item5 wBuffer = wBuffer + Party3Context.item6 wBuffer = wBuffer + Party3Context.billserno wBuffer = wBuffer + Party3Context.serialno wBuffer = wBuffer + Party3Context.prtnum wBuffer = wBuffer + Party3Context.paydate sfp.write(wBuffer + '\n') sfp.close() else: #打包(多张发票) for i in range( 0, int(Party3Context.billNum) ): wBuffer = "" wBuffer = wBuffer + Party3Context.billData[i] wBuffer = wBuffer + Party3Context.item1[i] wBuffer = wBuffer + Party3Context.item2[i] wBuffer = wBuffer + Party3Context.item3[i] wBuffer = wBuffer + Party3Context.item4[i] wBuffer = wBuffer + Party3Context.item5[i] wBuffer = wBuffer + Party3Context.item6[i] wBuffer = wBuffer + Party3Context.billserno[i] wBuffer = wBuffer + Party3Context.serialno[i] wBuffer = wBuffer + Party3Context.prtnum[i] wBuffer = wBuffer + Party3Context.paydate[i] sfp.write(wBuffer + '\n') sfp.close() #=====================外调接口(后处理)================================== if ( subModuleExistFlag==1 ) : if not subModuleHandle.SubModuleDoSnd(): raise AfaFlowControl.flowException( ) #=====================自动打包========================================== TradeContext.errorCode = '0000' TradeContext.errorMsg = '交易成功' AfaFunc.autoPackData() #=====================程序退出========================================== AfaLoggerFunc.tradeInfo('******代收代付.补打发票模板[' + TradeContext.TemplateCode + ']退出******' )
def main( ): AfaLoggerFunc.tradeInfo('=======自助业务自由模板开始=======') try: #=============初始化返回报文变量==================== TradeContext.tradeResponse=[] #=============获取当前系统时间==================== TradeContext.workDate=AfaUtilTools.GetSysDate( ) TradeContext.workTime=AfaUtilTools.GetSysTime( ) HostContext.I1SBNO = TradeContext.PDSBNO #HostContext.I1USID = TradeContext.PDUSID HostContext.I1AUUS = TradeContext.PDAUUS HostContext.I1AUPS = TradeContext.PDAUPS HostContext.I1WSNO = TradeContext.PDWSNO HostContext.I1ACCN = TradeContext.JXACCT AfaLoggerFunc.tradeInfo(HostContext.I1ACCN) #HostContext.I1CCNO = TradeContext.ccno #与主机交换 zzywHostFunc.CommHost() AfaLoggerFunc.tradeInfo('主机通讯结束') if( HostContext.O1MGID !='AAAAAAA'): AfaLoggerFunc.tradeInfo('-----test1-------------') TradeContext.bodyl='' TradeContext.errorCode = HostContext.O1MGID TradeContext.errorMsg = HostContext.O1INFO AfaLoggerFunc.tradeInfo(TradeContext.errorCode) AfaLoggerFunc.tradeInfo(TradeContext.errorMsg) TradeContext.bodyl ='243' TradeContext.CICS ='' TradeContext.INFCOD ='E' TradeContext.Appcode ='' TradeContext.RETNO ='0000' TradeContext.PDTRCD ='831030' TradeContext.PDTRSQ ='' TradeContext.PDWSNO ='' TradeContext.JXACCT ='' TradeContext.JXCESQ ='' TradeContext.INFPAD0 ='' TradeContext.INFPAD1 ='' TradeContext.INFPAD2 ='' TradeContext.PDTRDT ='' TradeContext.PDTRTM ='' TradeContext.PDTLSQ ='' TradeContext.PAMGID =TradeContext.errorCode TradeContext.BEERTX =HostContext.O1INFO AfaLoggerFunc.tradeInfo(HostContext.O1INFO) TradeContext.RecNum ='' TradeContext.JXCKFG ='' TradeContext.JXTRCU ='' else: AfaLoggerFunc.tradeInfo('-----test2-------------') TradeContext.JXTRCU = HostContext.O1NXLN TradeContext.JXCKFG = HostContext.O1MGNO AfaLoggerFunc.tradeInfo(HostContext.O1MGNO) TradeContext.CICS ='' TradeContext.INFCOD ='N' TradeContext.Appcode ='' TradeContext.RETNO ='0000' TradeContext.PDTRCD ='831030' TradeContext.PDTRSQ ='' TradeContext.PDWSNO ='' TradeContext.JXACCT ='' TradeContext.JXCESQ ='' TradeContext.INFPAD0 ='' TradeContext.INFPAD1 ='' TradeContext.INFPAD2 ='' TradeContext.PDTRTM ='' TradeContext.BEERTX ='' TradeContext.RecNum = HostContext.O1ACUR TradeContext.bodyl =str(int(TradeContext.RecNum)*51+243) AfaLoggerFunc.tradeInfo(TradeContext.bodyl) if( HostContext.O1ACUR == '00' and HostContext.O1MGNO != '1' ): TradeContext.errorCode = '0001' TradeContext.errorMsg = "无补登数据" AfaLoggerFunc.tradeInfo(TradeContext.errorCode) AfaLoggerFunc.tradeInfo(TradeContext.errorMsg) TradeContext.PAMGID =TradeContext.errorCode else: TradeContext.JXSGDT = HostContext.O2ORDT #TradeContext.JXCATP = HostContext.O2SMCD #转换摘要代码为汉字 TMP_O2SMCD = [] for i in xrange(0,len(HostContext.O2SMCD)): sum_sql = "select text from craba where smcd = '" + HostContext.O2SMCD[i] + "'" sum_record = AfaDBFunc.SelectSql(sum_sql) if sum_record == None: TMP_O2SMCD.append("未知") elif len(sum_record) <= 0: TMP_O2SMCD.append("未知") else: TMP_O2SMCD.append(sum_record[0][0]) TradeContext.JXCATP = TMP_O2SMCD TradeContext.JXBDST = HostContext.O2AMCD TradeContext.JXTRAM = HostContext.O2TRAM TradeContext.JXACBL = HostContext.O2ACBL TradeContext.JXCAUS = HostContext.O2USID AfaLoggerFunc.tradeInfo(TradeContext.JXSGDT) AfaLoggerFunc.tradeInfo(TradeContext.JXCATP) AfaLoggerFunc.tradeInfo(TradeContext.JXBDST) AfaLoggerFunc.tradeInfo(TradeContext.JXTRAM) AfaLoggerFunc.tradeInfo(TradeContext.JXACBL) AfaLoggerFunc.tradeInfo(TradeContext.JXCAUS) # TradeContext.ordt = HostContext.O2SBSQ # TradeContext.ordt = HostContext.O2VLDT # TradeContext.ordt = HostContext.O2PERD # TradeContext.ordt = HostContext.O2ITCD # TradeContext.ordt = HostContext.O2CYNO # TradeContext.ordt = HostContext.O2INRT #=============自动打包==================== AfaFunc.autoPackData() AfaLoggerFunc.tradeInfo('=======自助业务自由模板结束=======') except AfaFlowControl.flowException, e: #流程异常 AfaFlowControl.exitMainFlow( )
def main(): AfaLoggerFunc.tradeInfo( '凭证中心参数维护['+TradeContext.TemplateCode+']进入' ) #AfaLoggerFunc.afa_InitComp('Tvouh008','凭证中心参数维护') try: #===========检查操作类型是否存在=========== # 1 新增,2 查询, 3 修改, 4 删除 if( not TradeContext.existVariable( "opeType" ) ): tradeExit( 'A005060', '操作类型[opeType]值不存在!' ) raise AfaFlowControl.flowException( ) if TradeContext.opeType == '1': #新增 #==========检查该凭证种类信息是否已经存在============ sqlStr = "select VOUHTYPE from VOUH_PARAMETER \ where VOUHTYPE = '" + TradeContext.sVouhType+ "'\ and ZONENO = '" + TradeContext.sZoneNo+ "'" records = AfaDBFunc.SelectSql( sqlStr ) if( records == None ): tradeExit( 'A005052', '查询[凭证参数维护表]操作异常!' ) raise AfaFlowControl.flowException( ) elif( len( records )!=0 ): tradeExit( 'A005053', '凭证种类已存在!' ) raise AfaFlowControl.flowException( ) #=============初始化返回报文变量==================== TradeContext.tradeResponse=[] sqlStr = "INSERT INTO VOUH_PARAMETER (ZONENO,VOUHTYPE,VOUHNAME,CTRLFLG,COUNTFLG,COUNTUNIT,PAYFLG,\ MOVFLG,SALEFLG,PRICE,HEADLEN,VOUHLEN,ACTIVEDATE) VALUES ('"+TradeContext.sZoneNo+"','"+\ TradeContext.sVouhType+"','"+TradeContext.sVouhName+"','2','0','0','0','0','0','0','"+\ TradeContext.sHeadLen+"','"+TradeContext.sVouhLen+"','0')" records = AfaDBFunc.InsertSqlCmt( sqlStr ) if records==-1 : tradeExit( 'A005054', '新增[凭证号码表]基本信息失败!' ) raise AfaFlowControl.flowException( ) tradeExit('0000', '新建成功') if TradeContext.opeType == '4': #删除 sqlStr = "select * from VOUH_REGISTER \ where VOUHTYPE = '" + TradeContext.sVouhType+ "'\ and VOUHSTATUS != '8'" records = AfaDBFunc.SelectSql( sqlStr ) AfaLoggerFunc.tradeDebug(sqlStr) if( records == None ): tradeExit( 'A005060', '查询[凭证登记表]操作异常!' ) raise AfaFlowControl.flowException( ) elif( len( records ) > 0 ): tradeExit( 'A005061', '不能删除存在有效凭证的凭证参数!' ) raise AfaFlowControl.flowException( ) sqlStr = "DELETE FROM VOUH_PARAMETER WHERE VOUHTYPE = '" + TradeContext.sVouhType+ "'\ and ZONENO = '" + TradeContext.sZoneNo+ "'" AfaLoggerFunc.tradeDebug(sqlStr) records = AfaDBFunc.DeleteSqlCmt( sqlStr ) if records == -1: tradeExit( 'A005055', '删除[凭证参数维护表]操作异常!' ) raise AfaFlowControl.flowException( ) if records == 0: tradeExit( 'A005056', '[凭证参数维护表]内无对应记录可被删除!' ) raise AfaFlowControl.flowException( ) tradeExit('0000', '删除成功') if TradeContext.opeType == '3':#修改 #==============修改凭证参数维护表===================== sqlStr = "select * from VOUH_REGISTER \ where VOUHTYPE = '" + TradeContext.sVouhType+ "'\ and VOUHSTATUS != '8' and length(headstr) = " + TradeContext.sOldHeadLen records = AfaDBFunc.SelectSql( sqlStr ) AfaLoggerFunc.tradeDebug(sqlStr) if( records == None ): tradeExit( 'A005060', '查询[凭证登记表]操作异常!' ) raise AfaFlowControl.flowException( ) elif( len( records ) > 0 ): tradeExit( 'A005061', '不能修改存在有效凭证的凭证参数!' ) raise AfaFlowControl.flowException( ) sqlStr = "UPDATE VOUH_PARAMETER set \ VOUHNAME = '"+ TradeContext.sVouhName + "',VOUHLEN = '"+ TradeContext.sVouhLen+ "',\ HEADLEN = '"+ TradeContext.sHeadLen+ "'" sqlStr = sqlStr +" WHERE VOUHTYPE = '" + TradeContext.oldVOUHTYPE + "'\ and ZONENO = '" + TradeContext.sZoneNo+ "'" records = AfaDBFunc.UpdateSqlCmt( sqlStr ) if records==-1 : tradeExit( 'A005057', '更新[凭证参数维护表]信息异常!' ) raise AfaFlowControl.flowException( ) elif records==0 : tradeExit( 'A005058', '修改[凭证参数维护表]基本信息失败!' ) raise AfaFlowControl.flowException( ) tradeExit('0000', '修改成功') if TradeContext.opeType == '2':#查询 #=============初始化返回报文变量==================== TradeContext.tradeResponse=[] sqlStr = "SELECT VOUHTYPE,VOUHNAME,VOUHLEN,HEADLEN,ZONENO FROM VOUH_PARAMETER WHERE ZONENO = '"+ TradeContext.sZoneNo +"'" if (len(TradeContext.sVouhType)!=0): sqlStr = sqlStr + " AND VOUHTYPE = '" + TradeContext.sVouhType + "'" if (len(TradeContext.sVouhName)!=0): sqlStr = sqlStr + " AND VOUHNAME = '" + TradeContext.sVouhName + "'" if (len(TradeContext.sVouhType)==0 and len(TradeContext.sVouhName)==0 ): sqlStr = sqlStr #sqlStr="SELECT VOUHTYPE,VOUHNAME,VOUHLEN,HEADLEN,ZONENO FROM VOUH_PARAMETER WHERE ZONENO ='000000' AND VOUHTYPE = '0000002343' AND VOUHNAME = 'adfsadf'" AfaLoggerFunc.tradeInfo( 'sqlStr = ' + sqlStr ) records = AfaDBFunc.SelectSql( sqlStr ) if( records == None ): TradeContext.tradeResponse.append( ['retCount','0'] ) tradeExit( 'A005052', '查询[凭证参数维护表]操作异常!' ) raise AfaFlowControl.flowException( ) elif( len( records )==0 ): TradeContext.tradeResponse.append( ['retCount','0'] ) tradeExit( 'A005059', '查询[凭证参数维护表]基本信息不存在!' ) raise AfaFlowControl.flowException( ) else: records=AfaUtilTools.ListFilterNone( records ) baseInfoNames=['sVouhType','sVouhName','sVouhLen','sHeadLen','sZoneNo'] total=len( records ) for i in range( 0, len( records ) ): j=0 for name in baseInfoNames: TradeContext.tradeResponse.append( [name, records[i][j]] ) j=j+1 TradeContext.tradeResponse.append( ['retCount', str( total )] ) TradeContext.tradeResponse.append( ['errorCode', '0000'] ) TradeContext.tradeResponse.append( ['errorMsg', '查询成功'] ) tradeExit('0000', '查询成功') #自动打包 AfaFunc.autoPackData() #=============程序退出========================================= # AfaLoggerFunc.afa_SuccQuit(__name__,'凭证中心参数维护交易') except AfaFlowControl.flowException, e: AfaFlowControl.exitMainFlow( )
def main( ): AfaLoggerFunc.tradeInfo( '凭证号段调整['+TradeContext.TemplateCode+']进入' ) #=============前台上送数据=================================== #TradeContext.sBesbNo 机构代号 #TradeContext.sCur 货币代码 #TradeContext.sTellerNo 柜员号 #TradeContext.sVouhType 凭证种类 #TradeContext.sStartNo 起始号码 #TradeContext.sEndNo 终止号码 #TradeContext.sVouhStatus 凭证状态 #TradeContext.sDepository 库箱标志 #TradeContext.sTellerTailNo 尾箱号 #TradeContext.sWSNO 终端号 try: #=============初始化返回报文变量======================== TradeContext.tradeResponse = [] #=============获取当前系统时间========================== TradeContext.sLstTrxDay = AfaUtilTools.GetSysDate( ) TradeContext.sLstTrxTime = AfaUtilTools.GetSysTime( ) #=============判断输入尾箱号与凭证状态是否符合规则=========== if TradeContext.sTellerTailNo =='000': if TradeContext.sVouhStatus not in ('0','1','2'): AfaLoggerFunc.tradeInfo('输入尾箱号:'+ TradeContext.sTellerTailNo) AfaLoggerFunc.tradeInfo('输入凭证状态:'+ TradeContext.sVouhStatus) tradeExit('A005061', '输入尾箱号与凭证状态不相符!') raise AfaFlowControl.flowException( ) else: if TradeContext.sVouhStatus not in ('3','4','5','6'): AfaLoggerFunc.tradeInfo('输入尾箱号:'+ TradeContext.sTellerTailNo) AfaLoggerFunc.tradeInfo('输入凭证状态:'+ TradeContext.sVouhStatus) tradeExit('A005061', '输入尾箱号与凭证状态不相符!') raise AfaFlowControl.flowException( ) #=============获取机构类型========================== HostContext.I1OTSB = TradeContext.sBesbNo #机构代号 HostContext.I1SBNO = TradeContext.sBesbNo #机构号 HostContext.I1USID = '999996' #柜员号 if(not VouhHostFunc.CommHost('2001')): tradeExit( TradeContext.errorCode, TradeContext.errorMsg ) raise AfaFlowControl.flowException( ) if(TradeContext.errorCode == '0000'): SBNO = HostContext.O1SBCH AfaLoggerFunc.tradeInfo( '机构级别:'+ SBNO ) TradeContext.sDepository='' if(SBNO=='33'): if (TradeContext.sTellerTailNo<>'000' or TradeContext.sVouhStatus not in('0','1')): tradeExit('A005061', '财务机构库管员尾箱号为000,入库状态0,出库状态1') raise AfaFlowControl.flowException( ) if TradeContext.sVouhStatus=='0': TradeContext.sDepository='1' else: TradeContext.sDepository='' elif(SBNO=='31' or SBNO=='40' or SBNO=='32' or SBNO=='41'): if TradeContext.sTellerTailNo=='000': TradeContext.sDepository='2' TradeContext.sVouhStatus='2' else: TradeContext.sDepository='4' elif(SBNO=='50'): if TradeContext.sTellerTailNo=='000': TradeContext.sDepository='3' TradeContext.sVouhStatus='2' else: TradeContext.sDepository='4' else: tradeExit('A005061', '该机构级别不在指定范围内') raise AfaFlowControl.flowException( ) #=============查询数据库中是否存在需要调整的号段========================== sqlStr = "" sqlStr = "select TELLERNO,DEPOSITORY,VOUHSTATUS from VOUH_REGISTER WHERE " sqlStr = sqlStr + "BESBNO ='" + TradeContext.sBesbNo +"'" sqlStr = sqlStr + "AND VOUHTYPE ='" + TradeContext.sVouhType +"'" sqlStr = sqlStr + "AND STARTNO ='" + TradeContext.sStartNo +"'" sqlStr = sqlStr + "AND ENDNO ='" + TradeContext.sEndNo +"'" AfaLoggerFunc.tradeInfo( sqlStr ) records = AfaDBFunc.SelectSql( sqlStr ) if( records == None ): tradeExit('A005061', '查询[凭证登记表]操作异常!') raise AfaFlowControl.flowException( ) elif( len( records ) == 0 ): tradeExit('A005067', '凭证库中不存在此条记录!') else : AfaLoggerFunc.tradeInfo( "原记录尾箱号:" + records[0][0] ) AfaLoggerFunc.tradeInfo( "原记录库箱标识:" + records[0][1] ) AfaLoggerFunc.tradeInfo( "原记录凭证状态:" + records[0][2] ) #将凭证号段调整至正常状态 sql1 = "" sql1 = sql1 + "update vouh_register set " sql1 = sql1 + "TELLERNO ='" + TradeContext.sTellerTailNo +"'," sql1 = sql1 + "DEPOSITORY ='" + TradeContext.sDepository +"'," sql1 = sql1 + "VOUHSTATUS ='" + TradeContext.sVouhStatus +"'" sql1 = sql1 + "where BESBNO ='" + TradeContext.sBesbNo +"'" sql1 = sql1 + " and VOUHTYPE ='" + TradeContext.sVouhType +"'" sql1 = sql1 + " and STARTNO ='" + TradeContext.sStartNo +"'" sql1 = sql1 + " and ENDNO ='" + TradeContext.sEndNo +"'" AfaLoggerFunc.tradeInfo(sql1) if AfaDBFunc.UpdateSqlCmt(sql1)<0: return AfaFlowControl.ExitThisFlow("A005067","凭证号段调整失败!") TradeContext.tradeResponse.append( ['sLstTrxDay',TradeContext.sLstTrxDay] ) TradeContext.tradeResponse.append( ['sLstTrxTime',TradeContext.sLstTrxTime] ) TradeContext.tradeResponse.append( ['sVouhType',TradeContext.sVouhType] ) TradeContext.tradeResponse.append( ['sStartNo',TradeContext.sStartNo] ) TradeContext.tradeResponse.append( ['sEndNo',TradeContext.sEndNo] ) TradeContext.tradeResponse.append( ['errorCode','0000'] ) TradeContext.tradeResponse.append( ['errorMsg','交易成功'] ) #自动打包 AfaFunc.autoPackData() #=============程序退出==================== AfaLoggerFunc.tradeInfo( '凭证号段调整['+TradeContext.TemplateCode+']退出' ) except AfaFlowControl.flowException, e: AfaFlowControl.exitMainFlow( )
def main( ): AfaLoggerFunc.tradeInfo( '凭证柜员交接['+TradeContext.TemplateCode+']进入' ) #=============前台上送数据=================================== #TradeContext.sBesbNo 机构号 #TradeContext.sBesbSty 机构类型 #TradeContext.sCur 货币代码 #TradeContext.sTellerNo 柜员号 #TradeContext.sRivTeller 对方柜员 #TradeContext.sLstTrxDay 最后交易日期 #TradeContext.sLstTrxTime 最后交易时间 try: #=============获取柜员级别========================== HostContext.I1TELR = TradeContext.sTellerNo #柜员号 HostContext.I1SBNO = TradeContext.sBesbNo #机构号 HostContext.I1USID = TradeContext.sTellerNo #柜员号 HostContext.I1WSNO = TradeContext.sWSNO #终端号 if(not VouhHostFunc.CommHost('8809')): tradeExit(TradeContext.errorCode, TradeContext.errorMsg) raise AfaFlowControl.flowException( ) if(TradeContext.errorCode == '0000'): TELLER = HostContext.O1TLRK AfaLoggerFunc.tradeInfo( TELLER ) #=============初始化返回报文变量======================== TradeContext.tradeResponse = [] TradeContext.sRivTeller = TradeContext.sInTellerNo #=============生成流水号======================== TradeContext.sVouhSerial = VouhFunc.GetVouhSerial( ) #=============获取当前系统时间========================== TradeContext.sLstTrxDay = AfaUtilTools.GetSysDate( ) TradeContext.sLstTrxTime = AfaUtilTools.GetSysTime( ) TradeContext.sTransType = '凭证柜员交接' #================判断对方柜员是否有凭证================================== if(len(TradeContext.sInTellerNo) == 0): VouhFunc.tradeExit('A005061', '对方柜员不能为空!') raise AfaFlowControl.flowException( ) #if(TELLER == '01' or TELLER == '02' or TELLER == '03'): # VouhFunc.tradeExit('A005061', '该柜员不能进行此操作!') # raise AfaFlowControl.flowException( ) sqlStr = "select * from VOUH_REGISTER where TELLERNO = '" + TradeContext.sInTellerNo + "' and VOUHSTATUS = '3'" records = AfaDBFunc.SelectSql( sqlStr ) AfaLoggerFunc.tradeDebug(sqlStr) if records==-1 : VouhFunc.tradeExit( 'A005057', '查询[凭证登记表]信息异常!' ) raise AfaFlowControl.flowException( ) elif len(records) > 0 : VouhFunc.tradeExit( 'A005058', '['+TradeContext.sInTellerNo+']柜员不能交接!' ) raise AfaFlowControl.flowException( ) #================判断柜员是否有凭证================================== #if((TradeContext.sTellerNo)[4:] == '01' or (TradeContext.sTellerNo)[4:] == '02' or (TradeContext.sTellerNo)[4:] == '03'): # VouhFunc.tradeExit('A005061', '该柜员不能进行此操作!') # raise AfaFlowControl.flowException( ) sqlStr = "select * from VOUH_REGISTER where TELLERNO = '" + TradeContext.sTellerNo + "' and VOUHSTATUS = '3'" records = AfaDBFunc.SelectSql( sqlStr ) AfaLoggerFunc.tradeDebug(sqlStr) if records==-1 : VouhFunc.tradeExit( 'A005057', '查询[凭证登记表]信息异常!' ) raise AfaFlowControl.flowException( ) elif records==0 : VouhFunc.tradeExit( 'A005058', '无凭证!' ) raise AfaFlowControl.flowException( ) #======================柜员交接===================================== sqlStr = "update VOUH_REGISTER set TELLERNO = '" + TradeContext.sInTellerNo + "' where TELLERNO = '" + TradeContext.sTellerNo + "' and VOUHSTATUS = '3'" records = AfaDBFunc.UpdateSqlCmt( sqlStr ) AfaLoggerFunc.tradeDebug(sqlStr) if records==-1 : VouhFunc.tradeExit( 'A005057', '更新[凭证登记表]信息异常!' ) raise AfaFlowControl.flowException( ) elif records==0 : VouhFunc.tradeExit( 'A005058', '修改[凭证登记表]基本信息失败!' ) raise AfaFlowControl.flowException( ) #更新凭证变更登记表 VouhFunc.VouhModify() #数据库提交 AfaDBFunc.CommitSql( ) #==================查询交接凭证明细================================== #=====李亚杰 20080812 修改凭证查询条件,增加凭证状态为'3'的情况==== #sqlStr = "select distinct t.VOUHTYPE,t1.VOUHNAME,t.STARTNO,t.ENDNO,t.VOUHNUM FROM VOUH_REGISTER t,VOUH_PARAMETER t1 \ # where t.VOUHTYPE = t1.VOUHTYPE AND substr(t.BESBNO,1,6) = substr(t1.BESBNO,1,6) \ # AND t.TELLERNO = '" + TradeContext.sInTellerNo + "'" sqlStr = "select distinct t.VOUHTYPE,t1.VOUHNAME,t.STARTNO,t.ENDNO,t.VOUHNUM FROM VOUH_REGISTER t,VOUH_PARAMETER t1 \ where t.VOUHTYPE = t1.VOUHTYPE AND substr(t.BESBNO,1,6) = substr(t1.BESBNO,1,6) \ AND t.VOUHSTATUS = '3' AND t.TELLERNO = '" + TradeContext.sInTellerNo + "'" AfaLoggerFunc.tradeDebug(sqlStr); #查询数据库并将返回的结果压至对应变量中 records = AfaDBFunc.SelectSql( sqlStr ) if( records == None ): VouhFunc.tradeExit('A005067', '查询[凭证表]操作异常!') raise AfaFlowControl.flowException( ) elif( len( records ) == 0 ): VouhFunc.tradeExit('A005068', '凭证不存在!' ) raise AfaFlowControl.flowException( ) else : record=AfaUtilTools.ListFilterNone( records ) total=len( records ) sVouhType = '' sVouhName = '' sStartNo = '' sEndNo = '' sVouhNum = '' for i in range( 0, total ): if( i <> 0): strSplit = '|' else: strSplit = '' sVouhType = sVouhType + strSplit + records[i][0] sVouhName = sVouhName + strSplit + records[i][1] sStartNo = sStartNo + strSplit + records[i][2] sEndNo = sEndNo + strSplit + records[i][3] sVouhNum = sVouhNum + strSplit + records[i][4] TradeContext.tradeResponse.append( ['sVouhType',sVouhType] ) TradeContext.tradeResponse.append( ['sVouhName',sVouhName] ) TradeContext.tradeResponse.append( ['sTellerNo',TradeContext.sTellerNo] ) TradeContext.tradeResponse.append( ['sInTellerNo',TradeContext.sInTellerNo] ) TradeContext.tradeResponse.append( ['sStartNo',sStartNo] ) TradeContext.tradeResponse.append( ['sEndNo',sEndNo] ) TradeContext.tradeResponse.append( ['sVouhNum',sVouhNum] ) TradeContext.tradeResponse.append( ['sNum',str(total)] ) TradeContext.tradeResponse.append( ['sVouhSerial',TradeContext.sVouhSerial] ) TradeContext.tradeResponse.append( ['sLstTrxDay',TradeContext.sLstTrxDay] ) TradeContext.tradeResponse.append( ['sLstTrxTime',TradeContext.sLstTrxTime] ) TradeContext.tradeResponse.append( ['errorCode','0000'] ) TradeContext.tradeResponse.append( ['errorMsg','交易成功'] ) #自动打包 AfaFunc.autoPackData() #=============程序退出==================== AfaLoggerFunc.tradeInfo( '凭证柜员交接['+TradeContext.TemplateCode+']退出' ) except AfaFlowControl.flowException, e: AfaFlowControl.exitMainFlow( )
def main( ): AfaLoggerFunc.tradeInfo( '打印报表['+TradeContext.TemplateCode+']进入' ) #=============前台上送数据==================== #TradeContext.sTellerNo 柜员号 #TradeContext.sWorkDate 交易日期 #TrddeContext.sBesbNo 机构号 try: #=============获取机构类型========================== HostContext.I1OTSB = TradeContext.sBesbNo #机构号 HostContext.I1SBNO = TradeContext.sBesbNo #机构号 HostContext.I1USID = TradeContext.sTellerNo #柜员号 HostContext.I1WSNO = TradeContext.sWSNO #终端号 if(not VouhHostFunc.CommHost('2001')): tradeExit(TradeContext.errorCode, TradeContext.errorMsg) raise AfaFlowControl.flowException( ) if(TradeContext.errorCode == '0000'): SBNO = HostContext.O1SBCH AfaLoggerFunc.tradeInfo( SBNO ) #=============获取柜员级别========================== HostContext.I1TELR = TradeContext.sTellerNo #柜员号 HostContext.I1SBNO = TradeContext.sBesbNo #机构号 HostContext.I1USID = TradeContext.sTellerNo #柜员号 HostContext.I1WSNO = TradeContext.sWSNO #终端号 if(not VouhHostFunc.CommHost('8809')): tradeExit(TradeContext.errorCode, TradeContext.errorMsg) raise AfaFlowControl.flowException( ) if(TradeContext.errorCode == '0000'): TELLER = HostContext.O1TLRK AfaLoggerFunc.tradeInfo( TELLER ) #=============初始化返回报文变量================== TradeContext.tradeResponse = [] #=================获取机构名称============================== #begin 20100920 蔡永贵修改 避免机构不存在时查询结果为空而抛出错误 #TradeContext.sBesbName = VouhFunc.SelectBesbName(TradeContext.sBesbNo) if not VouhFunc.SelectBesbName(TradeContext.sBesbNo): raise AfaFlowControl.flowException( ) else: TradeContext.sBesbName = VouhFunc.SelectBesbName(TradeContext.sBesbNo) #end #=====================获取机构类型=============================== #TradeContext.sBesbSty = VouhFunc.SelectBesbSty(TradeContext.sBesbNo) #AfaLoggerFunc.tradeInfo('================='+TradeContext.sBesbSty) #=============获取当前系统时间==================== TradeContext.sLstTrxDay = AfaUtilTools.GetSysDate( ) TradeContext.sLstTrxTime = AfaUtilTools.GetSysTime( ) #begin凭证优化更改201109 #=============获取柜员尾箱号=============================== HostContext.I1SBNO = TradeContext.sBesbNo #机构号 HostContext.I1USID = TradeContext.sTellerNo #柜员号 HostContext.I1WSNO = TradeContext.sWSNO #终端号 HostContext.I1EDDT = TradeContext.sLstTrxDay #终止日期 HostContext.I1TELR = TradeContext.sTellerNo #柜员代号 if(not VouhHostFunc.CommHost('0104')): VouhFunc.tradeExit( TradeContext.errorCode, TradeContext.errorMsg ) raise AfaFlowControl.flowException( ) if(TradeContext.errorCode == '0000'): TradeContext.sTellerTailNobak = HostContext.O2CABO TradeContext.sTellerTailNo = TradeContext.sTellerTailNobak[0] AfaLoggerFunc.tradeInfo( '交易柜员尾箱号:' + TradeContext.sTellerTailNo ) #end vouh = [] count1 = 0 count2 = 0 count3 = 0 AfaLoggerFunc.tradeInfo(TradeContext.sTellerTailNo) sqlStr = "select VOUHTYPE,VOUHNAME from VOUH_PARAMETER where substr(BESBNO,1,6) = '" + (TradeContext.sBesbNo)[:6] + "' order by VOUHTYPE" AfaLoggerFunc.tradeInfo(sqlStr) records = AfaDBFunc.SelectSql( sqlStr ) if( records == None ): tradeExit('A005067', '查询[凭证参数表]操作异常!') raise AfaFlowControl.flowException( ) elif( len( records ) == 0 ): tradeExit('A005068', '凭证不存在!' ) raise AfaFlowControl.flowException( ) else : for i in range(len(records)): num1 = 0 num2 = 0 num3 = 0 if(SBNO == '33' and TELLER == "10"): #查询凭证领用数 sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_MODIFY \ where WORKDATE = '" + TradeContext.sWorkDate + "' \ and VOUHTYPE = '" + records[i][0] + "' \ and TELLERNO = '" + TradeContext.sTellerTailNo + "' \ and BESBNO = '" + TradeContext.sBesbNo + "' \ and TRANSTATUS = '0' \ and VOUHSTATUS = '0'" res1 = AfaDBFunc.SelectSql( sqlStr ) AfaLoggerFunc.tradeInfo('sql1 = '+sqlStr) if( res1 == None ): tradeExit('A005067', '查询[凭证表]操作异常!') raise AfaFlowControl.flowException( ) elif( len( res1 ) == 0 ): num1 = 0 else : num1 = res1[0][0] if(num1 == None): num1 = 0 AfaLoggerFunc.tradeInfo(num1) #查询凭证付出数 sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_MODIFY \ where WORKDATE = '" + TradeContext.sWorkDate + "' \ and TELLERNO = '" + TradeContext.sTellerTailNo + "' \ and VOUHTYPE = '" + records[i][0] + "' \ and BESBNO = '" + TradeContext.sBesbNo + "' \ and TRANSTATUS = '0' \ and VOUHSTATUS in ('1','2')" res2 = AfaDBFunc.SelectSql( sqlStr ) AfaLoggerFunc.tradeInfo('sql2 = '+sqlStr) if( res2 == None ): tradeExit('A005067', '查询[凭证表]操作异常!') raise AfaFlowControl.flowException( ) elif( len( res2 ) == 0 ): num2 = 0 else : num2 = res2[0][0] if(num2 == None): num2 = 0 AfaLoggerFunc.tradeInfo(num2) #查询凭证余数 sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_REGISTER \ where VOUHTYPE = '" + records[i][0] + "' \ and TELLERNO = '" + TradeContext.sTellerTailNo + "' \ and BESBNO = '" + TradeContext.sBesbNo + "' \ and VOUHSTATUS = '0'" res3 = AfaDBFunc.SelectSql( sqlStr ) AfaLoggerFunc.tradeInfo('sql3 = '+sqlStr) if( res3 == None ): tradeExit('A005067', '查询[凭证表]操作异常!') raise AfaFlowControl.flowException( ) elif( len( res3 ) == 0 ): num3 = 0 else : num3 = res3[0][0] if(num3 == None): num3 = 0 AfaLoggerFunc.tradeInfo(num3) elif(TELLER == "10"): #查询凭证领用数 sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_MODIFY \ where WORKDATE = '" + TradeContext.sWorkDate + "' \ and VOUHTYPE = '" + records[i][0] + "' \ and (TELLERNO = '" + TradeContext.sTellerTailNo + "' \ or RIVTELLER = '" + TradeContext.sTellerTailNo + "') \ and BESBNO = '" + TradeContext.sBesbNo + "' \ and TRANSTATUS = '0' \ and VOUHSTATUS = '2'" res1 = AfaDBFunc.SelectSql( sqlStr ) AfaLoggerFunc.tradeInfo('sql1 = '+sqlStr) if( res1 == None ): tradeExit('A005067', '查询[凭证表]操作异常!') raise AfaFlowControl.flowException( ) elif( len( res1 ) == 0 ): num1 = 0 else : num1 = res1[0][0] if(num1 == None): num1 = 0 #查询凭证付出数 sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_MODIFY \ where WORKDATE = '" + TradeContext.sWorkDate + "' \ and TELLERNO = '" + TradeContext.sTellerTailNo + "' \ and BESBNO = '" + TradeContext.sBesbNo + "' \ and VOUHTYPE = '" + records[i][0] + "' \ and TRANSTATUS = '0' \ and EXSTATUS = '2' \ and VOUHSTATUS in ('0','3')" res2 = AfaDBFunc.SelectSql( sqlStr ) AfaLoggerFunc.tradeInfo('sql2 = '+sqlStr) if( res2 == None ): tradeExit('A005067', '查询[凭证表]操作异常!') raise AfaFlowControl.flowException( ) elif( len( res2 ) == 0 ): num2 = 0 else : num2 = res2[0][0] if(num2 == None): num2 = 0 #查询凭证余数 sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_REGISTER \ where VOUHTYPE = '" + records[i][0] + "' \ and TELLERNO = '" + TradeContext.sTellerTailNo + "' \ and BESBNO = '" + TradeContext.sBesbNo + "' \ and VOUHSTATUS = '2'" res3 = AfaDBFunc.SelectSql( sqlStr ) AfaLoggerFunc.tradeInfo('sql3 = '+sqlStr) if( res3 == None ): tradeExit('A005067', '查询[凭证表]操作异常!') raise AfaFlowControl.flowException( ) elif( len( res3 ) == 0 ): num3 = 0 else : num3 = res3[0][0] if(num3 == None): num3 = 0 elif(TELLER == "20"): #查询凭证领用数 sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_MODIFY \ where WORKDATE = '" + TradeContext.sWorkDate + "' \ and VOUHTYPE = '" + records[i][0] + "' \ and substr(BESBNO,1,6) = '" + (TradeContext.sBesbNo)[:6] + "' \ and BESBNO = '" + TradeContext.sBesbNo + "' \ and TRANSTATUS = '0' \ and VOUHSTATUS = '2'" res1 = AfaDBFunc.SelectSql( sqlStr ) AfaLoggerFunc.tradeInfo('sql1 = '+sqlStr) if( res1 == None ): tradeExit('A005067', '查询[凭证表]操作异常!') raise AfaFlowControl.flowException( ) elif( len( res1 ) == 0 ): num1 = 0 else : num1 = res1[0][0] if(num1 == None): num1 = 0 #查询凭证付出数 sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_MODIFY \ where WORKDATE = '" + TradeContext.sWorkDate + "' \ and substr(BESBNO,1,6) = '" + (TradeContext.sBesbNo)[:6] + "' \ and BESBNO = '" + TradeContext.sBesbNo + "' \ and VOUHTYPE = '" + records[i][0] + "' \ and TRANSTATUS = '0' \ and EXSTATUS = '3' \ and VOUHSTATUS in ('2','4','5','6')" res2 = AfaDBFunc.SelectSql( sqlStr ) AfaLoggerFunc.tradeInfo('sql2 = '+sqlStr) if( res2 == None ): tradeExit('A005067', '查询[凭证表]操作异常!') raise AfaFlowControl.flowException( ) elif( len( res2 ) == 0 ): num2 = 0 else : num2 = res2[0][0] if(num2 == None): num2 = 0 #查询凭证余数 sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_REGISTER \ where VOUHTYPE = '" + records[i][0] + "' \ and substr(BESBNO,1,6) = '" + (TradeContext.sBesbNo)[:6] + "' \ and BESBNO = '" + TradeContext.sBesbNo + "' \ and VOUHSTATUS in ('2','3')" res3 = AfaDBFunc.SelectSql( sqlStr ) AfaLoggerFunc.tradeInfo('sql3 = '+sqlStr) if( res3 == None ): tradeExit('A005067', '查询[凭证表]操作异常!') raise AfaFlowControl.flowException( ) elif( len( res3 ) == 0 ): num3 = 0 else : num3 = res3[0][0] if(num3 == None): num3 = 0 else: #查询凭证领用数 sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_MODIFY \ where WORKDATE = '" + TradeContext.sWorkDate + "' \ and VOUHTYPE = '" + records[i][0] + "' \ and (TELLERNO = '" + TradeContext.sTellerTailNo + "' \ or RIVTELLER = '" + TradeContext.sTellerTailNo + "') \ and BESBNO = '" + TradeContext.sBesbNo + "' \ and TRANSTATUS = '0' \ and VOUHSTATUS = '3'" res1 = AfaDBFunc.SelectSql( sqlStr ) AfaLoggerFunc.tradeInfo('sql1 = '+sqlStr) if( res1 == None ): tradeExit('A005067', '查询[凭证表]操作异常!') raise AfaFlowControl.flowException( ) elif( len( res1 ) == 0 ): num1 = 0 else : num1 = res1[0][0] if(num1 == None): num1 = 0 #查询凭证付出数 sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_MODIFY \ where WORKDATE = '" + TradeContext.sWorkDate + "' \ and TELLERNO = '" + TradeContext.sTellerTailNo + "' \ and BESBNO = '" + TradeContext.sBesbNo + "' \ and VOUHTYPE = '" + records[i][0] + "' \ and TRANSTATUS = '0' \ and EXSTATUS = '3' \ and VOUHSTATUS in ('2','4','5','6')" res2 = AfaDBFunc.SelectSql( sqlStr ) AfaLoggerFunc.tradeInfo('sql2 = '+sqlStr) if( res2 == None ): tradeExit('A005067', '查询[凭证表]操作异常!') raise AfaFlowControl.flowException( ) elif( len( res2 ) == 0 ): num2 = 0 else : num2 = res2[0][0] if(num2 == None): num2 = 0 #查询凭证余数 sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_REGISTER \ where VOUHTYPE = '" + records[i][0] + "' \ and TELLERNO = '" + TradeContext.sTellerTailNo + "' \ and BESBNO = '" + TradeContext.sBesbNo + "' \ and VOUHSTATUS = '3'" res3 = AfaDBFunc.SelectSql( sqlStr ) AfaLoggerFunc.tradeInfo('sql3 = '+sqlStr) if( res3 == None ): tradeExit('A005067', '查询[凭证表]操作异常!') raise AfaFlowControl.flowException( ) elif( len( res3 ) == 0 ): num3 = 0 else : num3 = res3[0][0] if(num3 == None): num3 = 0 vouh.append([records[i][0],records[i][1],str(num1),str(num2),str(num3)]) count1 = count1 + num1 count2 = count2 + num2 count3 = count3 + num3 rBankFile= os.environ['AFAP_HOME'] + '/data/vouh/vouhtmp.txt' #创建业务报表文件 bFp = open(rBankFile, "w") AfaLoggerFunc.tradeInfo('-----' + TradeContext.sBesbNo) AfaLoggerFunc.tradeInfo('-----' + TradeContext.sBesbName) AfaLoggerFunc.tradeInfo('-----' + TradeContext.sTellerTailNo) AfaLoggerFunc.tradeInfo('-----' + TradeContext.sWorkDate) #写入标题 bFp.write('\n **************** 代理业务凭证余额表 **************** \n\n') bFp.write(' 机构号码:' + TradeContext.sBesbNo + ' 机构名称: ' + TradeContext.sBesbName + '\n') bFp.write(' 柜员号码:' + TradeContext.sTellerTailNo + ' 日期:' + TradeContext.sWorkDate + '\n') bFp.write(' ------------------------------------------------------------------------------------------------------\n') bFp.write(' | 序号 | 凭证种类 | 凭证姓名 | 收方发生额 | 付方发生额 | 余额 |\n') bFp.write(' |----------|----------|------------------------------|---------------|---------------|---------------|\n') AfaLoggerFunc.tradeInfo('------------test5') for i in range( len( vouh ) ): wbuffer = ' |' wbuffer = wbuffer + str(i+1).ljust(10,' ') + '|' wbuffer = wbuffer +(vouh[i][0].strip()).ljust(10, ' ') + '|' wbuffer = wbuffer +(vouh[i][1].strip()).ljust(30, ' ') + '|' wbuffer = wbuffer +(vouh[i][2].strip()).rjust(15, ' ') + '|' wbuffer = wbuffer +(vouh[i][3].strip()).rjust(15, ' ') + '|' wbuffer = wbuffer +(vouh[i][4].strip()).rjust(15, ' ') + '|' #写入报表文件 bFp.write(wbuffer + '\n') bFp.write(' |----------|----------|------------------------------|---------------|---------------|---------------|\n') bFp.write(' | 合计 | | |' + str(count1).rjust(15,' ') + '|' + str(count2).rjust(15,' ') + '|' + str(count3).rjust(15,' ')+ '|\n') bFp.write(' ------------------------------------------------------------------------------------------------------\n') #关闭文件 bFp.close() TradeContext.tradeResponse.append( ['sBesbNo',TradeContext.sBesbNo] ) TradeContext.tradeResponse.append( ['sTellerTailNo',TradeContext.sTellerTailNo] ) TradeContext.tradeResponse.append( ['sTellerNo',TradeContext.sTellerNo] ) #凭证优化更改201109 TradeContext.tradeResponse.append( ['sLstTrxDay',TradeContext.sLstTrxDay] ) TradeContext.tradeResponse.append( ['sLstTrxTime',TradeContext.sLstTrxTime] ) TradeContext.tradeResponse.append( ['sFileName','vouhtmp.txt'] ) TradeContext.tradeResponse.append( ['errorCode','0000'] ) TradeContext.tradeResponse.append( ['errorMsg','交易成功'] ) AfaFunc.autoPackData() #=============程序退出==================== AfaLoggerFunc.tradeInfo( '打印报表['+TradeContext.TemplateCode+']退出' ) except AfaFlowControl.flowException, e: AfaFlowControl.exitMainFlow( )
def main( ): AfaLoggerFunc.tradeInfo( '凭证使用查询['+TradeContext.TemplateCode+']进入' ) #=============前台上送数据=================================== #TradeContext.sVouhNo 凭证号码 #TradeContext.sVouhType 凭证种类 #TradeContext.sBESBNO 机构号 #TradeContext.sTellerNo 柜员号 #TradeContext.sStartNo 起始号码 #TradeContext.sEndNo 终止号码 #TradeContext.sRivTeller 对方柜员 #TradeContext.sVouhStatus 凭证状态 #TradeContext.sVouhNum 凭证数量 #TradeContext.sLstTrxDay 最后交易日期 #TradeContext.sLstTrxTime 最后交易时间 #TradeContext.sDepository 库箱标志 #TradeContext.sVouhName 凭证名称 try: #=============初始化返回报文变量======================== TradeContext.tradeResponse = [] #=============获取当前系统时间========================== TradeContext.sLstTrxDay = AfaUtilTools.GetSysDate( ) TradeContext.sLstTrxTime = AfaUtilTools.GetSysTime( ) #begin凭证优化更改201109 #=============获取柜员尾箱号=============================== HostContext.I1SBNO = TradeContext.sBesbNo #机构号 HostContext.I1USID = TradeContext.sTellerNo #柜员号 HostContext.I1WSNO = TradeContext.sWSNO #终端号 HostContext.I1EDDT = TradeContext.sLstTrxDay #终止日期 HostContext.I1TELR = TradeContext.sTellerNo #柜员代号 if(not VouhHostFunc.CommHost('0104')): VouhFunc.tradeExit( TradeContext.errorCode, TradeContext.errorMsg ) raise AfaFlowControl.flowException( ) if(TradeContext.errorCode == '0000'): TradeContext.sTellerTailNobak = HostContext.O2CABO TradeContext.sTellerTailNo = TradeContext.sTellerTailNobak[0] AfaLoggerFunc.tradeInfo( '交易柜员尾箱号:' + TradeContext.sTellerTailNo ) #end #==============判断凭证状态=========================================== sqlStr = "SELECT VOUHTYPE,VOUHNAME,BESBNO FROM VOUH_PARAMETER WHERE (SUBSTR(BESBNO,1,6) = '"+ (TradeContext.sBesbNo)[:6] +"' \ or BESBNO ='3400008887')" if (len(TradeContext.sVouhType)!=0 and len(TradeContext.sVouhType)!=0): sqlStr = sqlStr + " AND VOUHTYPE = '" + TradeContext.sVouhType + "' AND STATUS = '1'" AfaLoggerFunc.tradeInfo( 'sqlStr = ' + sqlStr ) records = AfaDBFunc.SelectSql( sqlStr ) if( records == None ): TradeContext.tradeResponse.append( ['retCount','0'] ) tradeExit( 'A005052', '查询[凭证参数维护表]操作异常!' ) raise AfaFlowControl.flowException( ) elif( len( records )==0 ): TradeContext.tradeResponse.append( ['retCount','0'] ) tradeExit( 'A005059', '查询[凭证参数维护表]基本信息不存在!' ) raise AfaFlowControl.flowException( ) #===================判断是否为连续号段======================================= sqlStr = "select STARTNO,ENDNO,LSTTRXDAY,LSTTRXTIME,RIVTELLER,TELLERNO \ from VOUH_REGISTER \ where VOUHTYPE = '" + TradeContext.sVouhType+ "' \ and BESBNO = '" + TradeContext.sBesbNo + "'\ and TELLERNO = '" + TradeContext.sTellerTailNo + "'\ and VOUHSTATUS = '3' \ and ( ENDNO >= '" + TradeContext.sEndNo + "' and STARTNO <= '" + TradeContext.sStartNo + "' )" records = AfaDBFunc.SelectSql( sqlStr ) AfaLoggerFunc.tradeDebug(sqlStr) if( records == None ): #查询凭证登记表异常 tradeExit('A005061', '查询[凭证登记表]操作异常!') raise AfaFlowControl.flowException( ) elif( len( records ) == 0 ): #如果凭证登记表中无对应记录 tradeExit('A005067', '凭证操作失败,凭证库中不存在本次操作的凭证!') raise AfaFlowControl.flowException( ) TradeContext.sVouhNo=TradeContext.sStartNo sqlStr = "select STARTNO,ENDNO from VOUH_REGISTER \ where TELLERNO = '" + TradeContext.sTellerTailNo + "' \ and BESBNO = '" + TradeContext.sBesbNo + "'\ and VOUHTYPE = '" + TradeContext.sVouhType + "'\ and VOUHSTATUS = '3' \ and STARTNO = '" + TradeContext.sVouhNo + "'" records = AfaDBFunc.SelectSql( sqlStr ) AfaLoggerFunc.tradeDebug(sqlStr) if( records == None ): #查询凭证登记表异常 tradeExit('A005061', '查询[凭证登记表]操作异常!') raise AfaFlowControl.flowException( ) elif( len( records ) == 0 ): #如果凭证登记表中无对应记录 tradeExit('A005067', '凭证操作失败,凭证库中不存在本次操作的凭证!') sStatus = '1' #raise AfaFlowControl.flowException( ) else : vouhNos = [] for i in range(len(records)): vouhNos.append(int(records[i][0])) if(int(TradeContext.sVouhNo)== min(vouhNos)): tradeExit('0000', '凭证号码确认无误!') sStatus = '0' else: tradeExit('A005061', '凭证号码错误!!') sStatus = '1' #raise AfaFlowControl.flowException( ) TradeContext.tradeResponse.append( ['sVouhType',TradeContext.sVouhType] ) TradeContext.tradeResponse.append( ['sVouhName',''] ) TradeContext.tradeResponse.append( ['sStartNo',TradeContext.sVouhNo] ) TradeContext.tradeResponse.append( ['sEndNo',TradeContext.sVouhNo] ) TradeContext.tradeResponse.append( ['sVouhNum','1'] ) TradeContext.tradeResponse.append( ['sStatus',sStatus] ) TradeContext.tradeResponse.append( ['sLstTrxDay',TradeContext.sLstTrxDay] ) TradeContext.tradeResponse.append( ['sLstTrxTime',TradeContext.sLstTrxTime] ) TradeContext.tradeResponse.append( ['sNum','1'] ) TradeContext.tradeResponse.append( ['errorCode','0000'] ) TradeContext.tradeResponse.append( ['errorMsg','交易成功'] ) #自动打包 AfaFunc.autoPackData() #=============程序退出========================================= AfaLoggerFunc.tradeInfo( '凭证使用查询['+TradeContext.TemplateCode+']退出' ) except AfaFlowControl.flowException, e: AfaFlowControl.exitMainFlow( )
def main(): AfaLoggerFunc.tradeInfo( '凭证中心参数维护['+TradeContext.TemplateCode+']进入' ) #=============前台上送数据=================================== #TradeContext.sBesbNo 机构号 #TradeContext.sTellerNo 柜员号 #TradeContext.opeType 操作类型 #TradeContext.sVouhType 凭证种类 #TradeContext.sVouhName 凭证名称 #TradeContext.sNum 重复次数 #=============获取当前系统时间========================== TradeContext.sLstTrxDay = AfaUtilTools.GetSysDate( ) TradeContext.sLstTrxTime = AfaUtilTools.GetSysTime( ) try: #=============获取机构类型========================== HostContext.I1OTSB = TradeContext.sBesbNo #机构号 HostContext.I1SBNO = TradeContext.sBesbNo #机构号 HostContext.I1USID = TradeContext.sTellerNo #柜员号 HostContext.I1WSNO = TradeContext.sWSNO #终端号 if(not VouhHostFunc.CommHost('2001')): VouhFunc.tradeExit( TradeContext.errorCode, TradeContext.errorMsg ) raise AfaFlowControl.flowException( ) if(TradeContext.errorCode == '0000'): SBNO = HostContext.O1SBCH AfaLoggerFunc.tradeInfo( SBNO ) #begin凭证优化更改LLJ 201109 #=============获取柜员尾箱号=============================== HostContext.I1SBNO = TradeContext.sBesbNo #机构号 HostContext.I1USID = TradeContext.sTellerNo #柜员号 HostContext.I1WSNO = TradeContext.sWSNO #终端号 HostContext.I1EDDT = TradeContext.sLstTrxDay #终止日期 HostContext.I1TELR = TradeContext.sTellerNo #柜员代号 if(not VouhHostFunc.CommHost('0104')): VouhFunc.tradeExit( TradeContext.errorCode, TradeContext.errorMsg ) raise AfaFlowControl.flowException( ) if(TradeContext.errorCode == '0000'): TradeContext.sTellerTailNobak = HostContext.O2CABO TradeContext.sTellerTailNo = TradeContext.sTellerTailNobak[0] #柜员尾箱号TradeContext.sTellerTailNo AfaLoggerFunc.tradeInfo( '柜员尾箱号:' + TradeContext.sTellerTailNo ) #end #=============初始化返回报文变量======================== TradeContext.tradeResponse = [] #================拆包======================== if(TradeContext.existVariable("sVouhType")): TradeContext.sVouhType = VouhFunc.DelSpace(TradeContext.sVouhType.split("|")) TradeContext.sNum = len(TradeContext.sVouhType) if(TradeContext.existVariable("sVouhName")): TradeContext.sVouhName = VouhFunc.DelSpace(TradeContext.sVouhName.split("|")) AfaLoggerFunc.tradeInfo( '=================='+str(TradeContext.sNum) ) #===========检查操作类型是否存在=========== # 1 新增,2 删除, 3 修改, 4 查询 if( not TradeContext.existVariable( "opeType" ) ): tradeExit( 'A005060', '操作类型[opeType]值不存在!' ) raise AfaFlowControl.flowException( ) if TradeContext.opeType == '1': #新增 if(SBNO <> '33' and SBNO <> '02' ): tradeExit( 'A0001', '该机构柜员不能进行此操作!' ) raise AfaFlowControl.flowException( ) n=0 for i in range(TradeContext.sNum): n=n+1 #==========检查该凭证种类信息是否已经存在============ sqlStr = "select VOUHTYPE from VOUH_PARAMETER \ where VOUHTYPE = '" + TradeContext.sVouhType[i] + "'\ and BESBNO = '" + TradeContext.sBesbNo + "'" AfaLoggerFunc.tradeInfo( 'sql = ' + sqlStr ) records = AfaDBFunc.SelectSql( sqlStr ) if( records == None ): if(n>1): AfaLoggerFunc.tradeInfo( '数据库回滚' ) AfaDBFunc.RollbackSql( ) tradeExit( 'A005052', '查询[凭证参数维护表]操作异常!' ) raise AfaFlowControl.flowException( ) elif( len( records )!=0 ): if(n>1): AfaLoggerFunc.tradeInfo( '数据库回滚' ) AfaDBFunc.RollbackSql( ) tradeExit( 'A005053', '凭证种类已存在!' ) raise AfaFlowControl.flowException( ) #==========检查该凭证名称信息是否已经存在============ sqlStr = "select VOUHNAME from VOUH_PARAMETER \ where trim(VOUHNAME) = trim('" + TradeContext.sVouhName[i] + "')\ and BESBNO = '" + TradeContext.sBesbNo + "'" AfaLoggerFunc.tradeInfo( 'sql = ' + sqlStr ) records = AfaDBFunc.SelectSql( sqlStr ) if( records == None ): if(n>1): AfaLoggerFunc.tradeInfo( '数据库回滚' ) AfaDBFunc.RollbackSql( ) tradeExit( 'A005052', '查询[凭证参数维护表]操作异常!' ) raise AfaFlowControl.flowException( ) elif( len( records )!=0 ): if(n>1): AfaLoggerFunc.tradeInfo( '数据库回滚' ) AfaDBFunc.RollbackSql( ) tradeExit( 'A005053', '凭证名称已存在!' ) raise AfaFlowControl.flowException( ) #=============初始化返回报文变量==================== TradeContext.tradeResponse=[] sqlStr = "INSERT INTO VOUH_PARAMETER (BESBNO,VOUHTYPE,VOUHNAME,TELLERNO,ACTIVEDATE,STATUS) VALUES ('"+TradeContext.sBesbNo+"','"+\ TradeContext.sVouhType[i]+"','"+TradeContext.sVouhName[i]+"','"+TradeContext.sTellerTailNo+"','"+TradeContext.sLstTrxDay+"','1')" AfaLoggerFunc.tradeInfo( sqlStr ) records = AfaDBFunc.InsertSql( sqlStr ) if records < 0 : AfaLoggerFunc.tradeInfo( '数据库回滚' ) AfaDBFunc.RollbackSql( ) tradeExit( 'A005054', '新增[凭证号码表]基本信息失败!' ) raise AfaFlowControl.flowException( ) #数据库提交 AfaLoggerFunc.tradeInfo( '------------数据库提交' ) AfaDBFunc.CommitSql( ) TradeContext.tradeResponse.append( ['sNum',str(TradeContext.sNum)] ) TradeContext.tradeResponse.append( ['sLstTrxDay',TradeContext.sLstTrxDay] ) TradeContext.tradeResponse.append( ['sLstTrxTime',TradeContext.sLstTrxTime] ) TradeContext.tradeResponse.append( ['errorCode','0000'] ) TradeContext.tradeResponse.append( ['errorMsg','交易成功'] ) if TradeContext.opeType == '3': #删除 if(SBNO <> '33' and SBNO <> '02' ): tradeExit( 'A0001', '该机构柜员不能进行此操作!' ) raise AfaFlowControl.flowException( ) n = 0 for i in range(TradeContext.sNum): n=n+1 sqlStr = "select * from VOUH_REGISTER \ where VOUHTYPE = '" + TradeContext.sVouhType[i]+ "' \ and VOUHSTATUS <> '6' \ and BESBNO = '"+TradeContext.sBesbNo+"'" records = AfaDBFunc.SelectSql( sqlStr ) AfaLoggerFunc.tradeDebug(sqlStr) if( records == None ): if(n>1): AfaLoggerFunc.tradeInfo( '数据库回滚' ) AfaDBFunc.RollbackSql( ) tradeExit( 'A005060', '查询[凭证登记表]操作异常!' ) raise AfaFlowControl.flowException( ) elif( len( records ) > 0 ): if(n>1): AfaLoggerFunc.tradeInfo( '数据库回滚' ) AfaDBFunc.RollbackSql( ) tradeExit( 'A005061', '不能删除存在有效凭证的凭证参数!' ) raise AfaFlowControl.flowException( ) sqlStr = "DELETE FROM VOUH_PARAMETER WHERE VOUHTYPE = '" + TradeContext.sVouhType[i]+ "'\ and BESBNO = '" + TradeContext.sBesbNo+ "'" AfaLoggerFunc.tradeDebug(sqlStr) records = AfaDBFunc.DeleteSql( sqlStr ) if records == -1: AfaLoggerFunc.tradeInfo( '数据库回滚' ) AfaDBFunc.RollbackSql( ) tradeExit( 'A005055', '删除[凭证参数维护表]操作异常!' ) raise AfaFlowControl.flowException( ) if records == 0: AfaLoggerFunc.tradeInfo( '数据库回滚' ) AfaDBFunc.RollbackSql( ) tradeExit( 'A005056', '[凭证参数维护表]内无对应记录可被删除!' ) raise AfaFlowControl.flowException( ) #数据库提交 AfaLoggerFunc.tradeInfo( '------------数据库提交' ) AfaDBFunc.CommitSql( ) TradeContext.tradeResponse.append( ['sNum',str(TradeContext.sNum)] ) TradeContext.tradeResponse.append( ['sLstTrxDay',TradeContext.sLstTrxDay] ) TradeContext.tradeResponse.append( ['sLstTrxTime',TradeContext.sLstTrxTime] ) TradeContext.tradeResponse.append( ['errorCode','0000'] ) TradeContext.tradeResponse.append( ['errorMsg','交易成功'] ) if TradeContext.opeType == '2':#修改 if(SBNO <> '33' and SBNO <> '02' ): tradeExit( 'A0001', '该机构柜员不能进行此操作!' ) raise AfaFlowControl.flowException( ) n=0 #==============修改凭证参数维护表===================== for i in range(TradeContext.sNum): n=n+1 #==========检查该凭证名称信息是否已经存在============ sqlStr = "select VOUHNAME from VOUH_PARAMETER \ where trim(VOUHNAME) = trim('" + TradeContext.sVouhName[i] + "')\ and BESBNO = '" + TradeContext.sBesbNo + "'" AfaLoggerFunc.tradeInfo( 'sql = ' + sqlStr ) records = AfaDBFunc.SelectSql( sqlStr ) if( records == None ): if(n>1): AfaLoggerFunc.tradeInfo( '数据库回滚' ) AfaDBFunc.RollbackSql( ) tradeExit( 'A005052', '查询[凭证参数维护表]操作异常!' ) raise AfaFlowControl.flowException( ) elif( len( records )!=0 ): if(n>1): AfaLoggerFunc.tradeInfo( '数据库回滚' ) AfaDBFunc.RollbackSql( ) tradeExit( 'A005053', '凭证名称已存在!' ) raise AfaFlowControl.flowException( ) sqlStr = "UPDATE VOUH_PARAMETER set \ VOUHNAME = '"+ TradeContext.sVouhName[i] + "'" sqlStr = sqlStr +" WHERE VOUHTYPE = '" + TradeContext.sVouhType[i] + "'\ and BESBNO = '" + TradeContext.sBesbNo+ "'" records = AfaDBFunc.UpdateSql( sqlStr ) if records==-1 : AfaLoggerFunc.tradeInfo( '数据库回滚' ) AfaDBFunc.RollbackSql( ) tradeExit( 'A005057', '更新[凭证参数维护表]信息异常!' ) raise AfaFlowControl.flowException( ) elif records==0 : AfaLoggerFunc.tradeInfo( '数据库回滚' ) AfaDBFunc.RollbackSql( ) tradeExit( 'A005058', '修改[凭证参数维护表]基本信息失败!' ) raise AfaFlowControl.flowException( ) #数据库提交 AfaLoggerFunc.tradeInfo( '------------数据库提交' ) AfaDBFunc.CommitSql( ) TradeContext.tradeResponse.append( ['sNum',str(TradeContext.sNum)] ) TradeContext.tradeResponse.append( ['sLstTrxDay',TradeContext.sLstTrxDay] ) TradeContext.tradeResponse.append( ['sLstTrxTime',TradeContext.sLstTrxTime] ) TradeContext.tradeResponse.append( ['errorCode','0000'] ) TradeContext.tradeResponse.append( ['errorMsg','交易成功'] ) if TradeContext.opeType == '4':#查询 TradeContext.tradeResponse=[] sqlStr = "SELECT VOUHTYPE,VOUHNAME,BESBNO FROM VOUH_PARAMETER WHERE (SUBSTR(BESBNO,1,6) = '"+ (TradeContext.sBesbNo)[:6] +"' \ or BESBNO ='3400008887')" if (len(TradeContext.sVouhType)!=0 and len(TradeContext.sVouhType[0])!=0): sqlStr = sqlStr + " AND VOUHTYPE = '" + TradeContext.sVouhType[0] + "' AND STATUS = '1'" AfaLoggerFunc.tradeInfo( 'sqlStr = ' + sqlStr ) records = AfaDBFunc.SelectSql( sqlStr ) if( records == None ): TradeContext.tradeResponse.append( ['retCount','0'] ) tradeExit( 'A005052', '查询[凭证参数维护表]操作异常!' ) raise AfaFlowControl.flowException( ) elif( len( records )==0 ): TradeContext.tradeResponse.append( ['retCount','0'] ) tradeExit( 'A005059', '查询[凭证参数维护表]基本信息不存在!' ) raise AfaFlowControl.flowException( ) else: records=AfaUtilTools.ListFilterNone( records ) sTotal=len( records ) sVouhType = '' sVouhName = '' sBESBNO = '' for i in range( 0, len( records ) ): if( i <> 0): strSplit = '|' else: strSplit = '' sVouhType = sVouhType + strSplit + records[i][0] sVouhName = sVouhName + strSplit + records[i][1] sBESBNO = sBESBNO + strSplit + records[i][2] TradeContext.tradeResponse.append( ['sVouhType',sVouhType] ) TradeContext.tradeResponse.append( ['sVouhName',sVouhName] ) TradeContext.tradeResponse.append( ['sBESBNO',sBESBNO] ) TradeContext.tradeResponse.append( ['sLstTrxDay',TradeContext.sLstTrxDay] ) TradeContext.tradeResponse.append( ['sLstTrxTime',TradeContext.sLstTrxTime] ) TradeContext.tradeResponse.append( ['sTotal',str(sTotal)] ) TradeContext.tradeResponse.append( ['errorCode','0000'] ) TradeContext.tradeResponse.append( ['errorMsg','查询成功'] ) tradeExit('0000', '查询成功') #自动打包 AfaFunc.autoPackData() #=============程序退出========================================= AfaLoggerFunc.tradeInfo( '凭证中心参数维护['+TradeContext.TemplateCode+']退出' ) except AfaFlowControl.flowException, e: AfaFlowControl.exitMainFlow( )
def main( ): AfaLoggerFunc.tradeInfo( '凭证调配['+TradeContext.TemplateCode+']进入' ) #=============前台上送数据=================================== #TradeContext.sBesbNo 机构号 #TradeContext.sBesbSty 机构类型 #TradeContext.sCur 货币代码 #TradeContext.sTellerNo 柜员号 #TradeContext.sVouhType 凭证种类 #TradeContext.sInBesbNo 领用机构号 #TradeContext.sInBesbSty 领用机构类型 #TradeContext.sInTellerNo 领用柜员号 #TradeContext.sStartNo 起始号码 #TradeContext.sEndNo 终止号码 #TradeContext.sRivTeller 对方柜员 #TradeContext.sVouhStatus 凭证状态 #TradeContext.sVouhNum 凭证数量 #TradeContext.sLstTrxDay 最后交易日期 #TradeContext.sLstTrxTime 最后交易时间 #TradeContext.sDepository 库箱标志 try: #=============获取当前系统时间========================== TradeContext.sLstTrxDay = AfaUtilTools.GetSysDate( ) TradeContext.sLstTrxTime = AfaUtilTools.GetSysTime( ) #=============获取机构类型========================== HostContext.I1OTSB = TradeContext.sBesbNo #机构号 HostContext.I1SBNO = TradeContext.sBesbNo #机构号 HostContext.I1USID = TradeContext.sTellerNo #柜员号 HostContext.I1WSNO = TradeContext.sWSNO #终端号 if(not VouhHostFunc.CommHost('2001')): tradeExit(TradeContext.errorCode, TradeContext.errorMsg) raise AfaFlowControl.flowException( ) if(TradeContext.errorCode == '0000'): SBNO = HostContext.O1SBCH AfaLoggerFunc.tradeInfo( '交易机构类型' ) AfaLoggerFunc.tradeInfo( SBNO ) #begin凭证优化更改201109 #=============获取柜员尾箱号=============================== HostContext.I1SBNO = TradeContext.sBesbNo #机构号 HostContext.I1USID = TradeContext.sTellerNo #柜员号 HostContext.I1WSNO = TradeContext.sWSNO #终端号 HostContext.I1EDDT = TradeContext.sLstTrxDay #终止日期 HostContext.I1TELR = TradeContext.sTellerNo #柜员代号 if(not VouhHostFunc.CommHost('0104')): VouhFunc.tradeExit( TradeContext.errorCode, TradeContext.errorMsg ) raise AfaFlowControl.flowException( ) if(TradeContext.errorCode == '0000'): TradeContext.sTellerTailNobak = HostContext.O2CABO TradeContext.sTellerTailNo = TradeContext.sTellerTailNobak[0] AfaLoggerFunc.tradeInfo( '交易柜员尾箱号:' + TradeContext.sTellerTailNo ) #end #=============获取领用机构类型========================== HostContext.I1OTSB = TradeContext.sInBesbNo #领用机构号 HostContext.I1SBNO = TradeContext.sInBesbNo #机构号 HostContext.I1USID = TradeContext.sTellerNo #柜员号 HostContext.I1WSNO = TradeContext.sWSNO #终端号 if(not VouhHostFunc.CommHost('2001')): return VouhFunc.ExitThisFlow( TradeContext.errorCode, TradeContext.errorMsg ) if(TradeContext.errorCode == '0000'): INSBNO = HostContext.O1SBCH AfaLoggerFunc.tradeInfo( '领用机构类型' ) AfaLoggerFunc.tradeInfo( INSBNO ) #begin凭证优化更改201109 #=============获取领用柜员尾箱号=============================== HostContext.I1SBNO = TradeContext.sBesbNo #机构号 机构号送交易机构号 #HostContext.I1USID = TradeContext.sInTellerNo #柜员号 HostContext.I1USID = '999996' #柜员号 柜员号送自动柜员 HostContext.I1WSNO = TradeContext.sWSNO #终端号 HostContext.I1EDDT = TradeContext.sLstTrxDay #终止日期 HostContext.I1TELR = TradeContext.sInTellerNo #柜员代号 if(not VouhHostFunc.CommHost('0104')): VouhFunc.tradeExit( TradeContext.errorCode, TradeContext.errorMsg ) raise AfaFlowControl.flowException( ) if(TradeContext.errorCode == '0000'): TradeContext.sInTellerTailNobak = HostContext.O2CABO TradeContext.sInTellerTailNo = TradeContext.sInTellerTailNobak[0] AfaLoggerFunc.tradeInfo( '领用柜员尾箱号:' + TradeContext.sInTellerTailNo ) #end #================拆包======================== TradeContext.sVouhType = VouhFunc.DelSpace(TradeContext.sVouhType.split("|")) TradeContext.sVouhName = VouhFunc.DelSpace(TradeContext.sVouhName.split("|")) TradeContext.sStartNo = VouhFunc.DelSpace(TradeContext.sStartNo.split("|")) TradeContext.sEndNo = VouhFunc.DelSpace(TradeContext.sEndNo.split("|")) TradeContext.sVouhNum = VouhFunc.DelSpace(TradeContext.sVouhNum.split("|")) TradeContext.sNum = len(TradeContext.sVouhType) #==================暂存================================== TradeContext.rVouhType = VouhFunc.AddSplit(TradeContext.sVouhType) TradeContext.rVouhName = VouhFunc.AddSplit(TradeContext.sVouhName) TradeContext.rStartNo = VouhFunc.AddSplit(TradeContext.sStartNo) TradeContext.rEndNo = VouhFunc.AddSplit(TradeContext.sEndNo) TradeContext.rVouhNum = VouhFunc.AddSplit(TradeContext.sVouhNum) #=============初始化返回报文变量======================== TradeContext.tradeResponse = [] TradeContext.sRivTeller = TradeContext.sInTellerTailNo #=============生成流水号======================== TradeContext.sVouhSerial = VouhFunc.GetVouhSerial( ) #=============定义变量============================================================= #31联社清算中心 32联社营业部 33联社财务部 40信用社/支行 50分社/分理处/储蓄所 #1.分行管理库 2.支行管理库 3.网点管理库 4.柜员凭证箱 if(SBNO=='33'): TradeContext.sExDepos = '1' #原库箱标志 elif(SBNO=='31' or SBNO=='40' or SBNO=='32' or SBNO=='41'): TradeContext.sExDepos = '2' #原库箱标志 elif(SBNO=='50'): TradeContext.sExDepos = '3' #原库箱标志 else: VouhFunc.tradeExit('A005061', '该机构柜员不能进行此操作!') raise AfaFlowControl.flowException( ) if(INSBNO=='33'): TradeContext.sDepository = '1' #库箱标志 elif(INSBNO=='31' or INSBNO=='40' or INSBNO=='32' or INSBNO=='41'): TradeContext.sDepository = '2' #库箱标志 elif(INSBNO=='50'): TradeContext.sDepository = '3' #库箱标志 else: VouhFunc.tradeExit('A005061', '该机构柜员不能进行此操作!') raise AfaFlowControl.flowException( ) if(INSBNO=='33'): TradeContext.sVouhStatus = '0' #状态 0.已入未发 2.已发未领 TradeContext.sExStatus = '2' #原状态 elif(SBNO=='33'): TradeContext.sVouhStatus = '2' #状态 0.已入未发 2.已发未领 TradeContext.sExStatus = '0' #原状态 else: TradeContext.sVouhStatus = '2' #状态 0.已入未发 2.已发未领 TradeContext.sExStatus = '2' #原状态 TradeContext.sTransType = '凭证调配' #================判断是否隔级机构调配=================================================== if((SBNO =='33' and INSBNO=='50') or (SBNO =='50' and INSBNO=='33') or (SBNO =='31' and INSBNO=='50') or (SBNO =='50' and INSBNO=='31') or (SBNO =='50' and INSBNO=='50') or (SBNO =='32' and INSBNO=='32') or (SBNO =='31' and INSBNO=='31') or (SBNO =='41' and INSBNO=='41') or (SBNO =='40' and INSBNO=='40')): VouhFunc.tradeExit('A005061', '该机构柜员不能进行此操作!') raise AfaFlowControl.flowException( ) #================判断是否同级机构=================================================== if((SBNO =='31' and INSBNO=='40') or (SBNO =='40' and INSBNO=='31') or (SBNO =='31' and INSBNO=='32') or (SBNO =='32' and INSBNO=='31') or (SBNO =='40' and INSBNO=='32') or (SBNO =='32' and INSBNO=='40') or (SBNO =='41' and INSBNO=='32') or (SBNO =='41' and INSBNO=='31') or (SBNO =='32' and INSBNO=='41') or (SBNO =='31' and INSBNO=='41')): VouhFunc.tradeExit('A005061', '该机构柜员不能进行此操作!') raise AfaFlowControl.flowException( ) #================判断领用机构的清算上级是否是调拨凭证的机构号========================= if((SBNO =='40' and INSBNO=='50') or (SBNO =='32' and INSBNO=='50') or (SBNO =='41' and INSBNO=='50')): if(TradeContext.sBesbNo <> VouhFunc.SelectSBTPAC(TradeContext.sInBesbNo)): VouhFunc.tradeExit('A005061', '该机构柜员不能进行此操作!') raise AfaFlowControl.flowException( ) #================机构号的清算上级是否是领用机构号===================================== if((SBNO =='50' and INSBNO=='40') or (SBNO =='50' and INSBNO=='32') or (SBNO =='50' and INSBNO=='41')): if(TradeContext.sInBesbNo <> VouhFunc.SelectSBTPAC(TradeContext.sBesbNo)): VouhFunc.tradeExit('A005061', '该机构柜员不能进行此操作!') raise AfaFlowControl.flowException( ) if((TradeContext.sBesbNo)[:6] <> (TradeContext.sInBesbNo)[:6]): VouhFunc.tradeExit('A005061', '该机构柜员不能进行此操作!') raise AfaFlowControl.flowException( ) #交易公共部分 AfaLoggerFunc.tradeInfo( TradeContext.sExDepos ) VouhFunc.VouhTrans() #更新凭证变更登记薄 VouhFunc.VouhModify() #数据库提交 AfaDBFunc.CommitSql( ) #主机记账 AfaLoggerFunc.tradeInfo( '------------主机记账' ) TradeContext.sOperSty = '2' VouhHostFunc.VouhCommHost() TradeContext.sTranStatus = '0' AfaLoggerFunc.tradeInfo( '=======================12'+TradeContext.errorCode ) if(TradeContext.errorCode <> '0000'): tmpErrorCode= TradeContext.errorCode tmpErrorMsg = TradeContext.errorMsg #冲正 #=============置凭证操作状态及库箱标志==================== tmpDepos = TradeContext.sDepository TradeContext.sDepository = TradeContext.sExDepos TradeContext.sExDepos = tmpDepos tmpStatus = TradeContext.sVouhStatus TradeContext.sVouhStatus = TradeContext.sExStatus TradeContext.sExStatus = tmpStatus TradeContext.sRivTeller = ' ' #对方柜员 TradeContext.sTransType = '冲正' tmpTeller = TradeContext.sInTellerTailNo TradeContext.sInTellerTailNo = TradeContext.sTellerTailNo TradeContext.sTellerTailNo = tmpTeller tmpBesbNo = TradeContext.sInBesbNo TradeContext.sInBesbNo = TradeContext.sBesbNo TradeContext.sBesbNo = tmpBesbNo #交易公共部分 VouhFunc.VouhTrans() AfaDBFunc.CommitSql( ) TradeContext.sTranStatus = '1' if(not TradeContext.existVariable( "HostSerno" )): TradeContext.HostSerno = '' #更新流水表 VouhFunc.ModifyVouhModify() AfaLoggerFunc.tradeInfo( '============================自动冲正!' ) VouhFunc.tradeExit(tmpErrorCode, tmpErrorMsg) raise AfaFlowControl.flowException( ) #更新流水表 VouhFunc.ModifyVouhModify() TradeContext.tradeResponse.append( ['sVouhSerial',TradeContext.sVouhSerial] ) TradeContext.tradeResponse.append( ['sVouhType',TradeContext.rVouhType] ) TradeContext.tradeResponse.append( ['sVouhName',TradeContext.rVouhName] ) TradeContext.tradeResponse.append( ['sStartNo',TradeContext.rStartNo] ) TradeContext.tradeResponse.append( ['sEndNo',TradeContext.rEndNo] ) TradeContext.tradeResponse.append( ['sVouhNum',TradeContext.rVouhNum] ) TradeContext.tradeResponse.append( ['sLstTrxDay',TradeContext.sLstTrxDay] ) TradeContext.tradeResponse.append( ['sLstTrxTime',TradeContext.sLstTrxTime] ) TradeContext.tradeResponse.append( ['sNum',str(TradeContext.sNum)] ) TradeContext.tradeResponse.append( ['errorCode','0000'] ) TradeContext.tradeResponse.append( ['errorMsg','交易成功'] ) #自动打包 AfaFunc.autoPackData() #=============程序退出========================================= AfaLoggerFunc.tradeInfo( '凭证调配['+TradeContext.TemplateCode+']退出' ) except AfaFlowControl.flowException, e: AfaFlowControl.exitMainFlow( )
def main( ): AfaLoggerFunc.tradeInfo( '查询明细交易根据流水号['+TradeContext.TemplateCode+']进入' ) #=============前台上送数据==================== #TradeContext.oVouhSerial 原流水号 #TradeContext.sVouhType 凭证种类 #TradeContext.sStartNo 起始号码 #TradeContext.sEndNo 终止号码 #TradeContext.sVouhNum 凭证数量 try: #=============初始化返回报文变量================== TradeContext.tradeResponse = [] #=============获取当前系统时间==================== TradeContext.sLstTrxDay = AfaUtilTools.GetSysDate( ) TradeContext.sLstTrxTime = AfaUtilTools.GetSysTime( ) #根据前台输入的凭证种类进行查询并返回前台 sqlStr = "select distinct t.VOUHTYPE,t1.VOUHNAME,t.TELLERNO,t.STARTNO,t.ENDNO,t.VOUHNUM FROM VOUH_MODIFY t,VOUH_PARAMETER t1 \ where VOUHSERIAL='"+TradeContext.sVouhSerial+"' AND t.VOUHTYPE = t1.VOUHTYPE AND substr(t.BESBNO,1,6) = substr(t1.BESBNO,1,6) \ AND TRANSTYPE not like '%撤销' AND TRANSTATUS = '0'" AfaLoggerFunc.tradeDebug(sqlStr); #查询数据库并将返回的结果压至对应变量中 records = AfaDBFunc.SelectSql( sqlStr ) if( records == None ): tradeExit('A005067', '查询[凭证变更登记表]操作异常!') raise AfaFlowControl.flowException( ) elif( len( records ) == 0 ): tradeExit('A005068', '凭证不存在!' ) raise AfaFlowControl.flowException( ) else : record=AfaUtilTools.ListFilterNone( records ) total=len( records ) sVouhType = '' sVouhName = '' sTellerNo = '' sStartNo = '' sEndNo = '' sVouhNum = '' for i in range( 0, total ): if( i <> 0): strSplit = '|' else: strSplit = '' sVouhType = sVouhType + strSplit + records[i][0] sVouhName = sVouhName + strSplit + records[i][1] sTellerNo = sTellerNo + strSplit + records[i][2] sStartNo = sStartNo + strSplit + records[i][3] sEndNo = sEndNo + strSplit + records[i][4] sVouhNum = sVouhNum + strSplit + records[i][5] TradeContext.tradeResponse.append( ['oVouhSerial',TradeContext.sVouhSerial] ) TradeContext.tradeResponse.append( ['sVouhType',sVouhType] ) TradeContext.tradeResponse.append( ['sVouhName',sVouhName] ) TradeContext.tradeResponse.append( ['oTellerNo',sTellerNo] ) TradeContext.tradeResponse.append( ['sStartNo',sStartNo] ) TradeContext.tradeResponse.append( ['sEndNo',sEndNo] ) TradeContext.tradeResponse.append( ['sVouhNum',sVouhNum] ) TradeContext.tradeResponse.append( ['sLstTrxDay',TradeContext.sLstTrxDay] ) TradeContext.tradeResponse.append( ['sLstTrxTime',TradeContext.sLstTrxTime] ) TradeContext.tradeResponse.append( ['sNum',str(total)] ) TradeContext.tradeResponse.append( ['errorCode','0000'] ) TradeContext.tradeResponse.append( ['errorMsg','交易成功'] ) AfaFunc.autoPackData() #=============程序退出==================== AfaLoggerFunc.tradeInfo( '查询明细交易根据流水号['+TradeContext.TemplateCode+']退出' ) except AfaFlowControl.flowException, e: AfaFlowControl.exitMainFlow( )
def main( ): AfaLoggerFunc.tradeInfo('******代收代付.报表处理模板['+TradeContext.TemplateCode+']进入******' ) try: #=====================初始化返回报文变量================================ TradeContext.tradeResponse=[] #=====================获取当前系统时间================================== TradeContext.workDate=AfaUtilTools.GetSysDate( ) TradeContext.workTime=AfaUtilTools.GetSysTime( ) #=====================校验公共节点的有效性============================== if( not TradeContext.existVariable( "rptType" ) ): raise AfaFlowControl.flowException( 'A0001', '报表类型[rptType]值不存在,不能报表打印操作' ) if( not TradeContext.existVariable( "zoneno" ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '地区号[zoneno]值不存在,不能报表打印操作' ) if( not TradeContext.existVariable( "brno" ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '网点号[brno]值不存在,不能报表打印操作' ) if( not TradeContext.existVariable( "tellerno" ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '柜员号[tellerno]值不存在,不能报表打印操作' ) if( not TradeContext.existVariable( "beginDate" ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '起始日期[beginDate]值不存在,不能报表打印操作' ) if( not TradeContext.existVariable( "endDate" ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '截至日期[endDate]值不存在,不能报表打印操作' ) #判断汇总类型(1-按柜员汇总 2-按网点汇总 3-按支行汇总 4-按总行汇总) if( int( TradeContext.rptType )<1 or int( TradeContext.rptType )>4 ): return AfaFlowControl.ExitThisFlow( 'A0019', '非法的汇总类型' ) #=====================按总行汇总======================================== if (int( TradeContext.rptType )==4): AfaLoggerFunc.tradeInfo( '按总行汇总') #=====================按支行汇总======================================== if(int( TradeContext.rptType )==3): AfaLoggerFunc.tradeInfo( '按支行汇总') #=====================按网点汇总======================================== if (int( TradeContext.rptType )==2): AfaLoggerFunc.tradeInfo( '按网点汇总') #=====================按柜员汇总======================================== if (int( TradeContext.rptType )==1): AfaLoggerFunc.tradeInfo( '按柜员汇总') #=====================自动打包========================================== TradeContext.errorCode='0000' TradeContext.errorMsg='交易成功' AfaFunc.autoPackData() #=====================程序退出========================================== AfaLoggerFunc.tradeInfo('******代收代付.报表处理模板['+TradeContext.TemplateCode+']退出******' ) except AfaFlowControl.flowException, e: AfaFlowControl.exitMainFlow( str(e) )
def main( ): AfaLoggerFunc.tradeInfo( '凭证作废撤销['+TradeContext.TemplateCode+']进入' ) #=============前台上送数据=================================== #TradeContext.sBesbNo 机构号 #TradeContext.sBesbSty 机构类型 #TradeContext.sCur 货币代码 #TradeContext.sTellerNo 柜员号 #TradeContext.sVouhType 凭证种类 #TradeContext.sStartNo 起始号码 #TradeContext.sEndNo 终止号码 #TradeContext.sRivTeller 对方柜员 #TradeContext.sVouhStatus 凭证状态 #TradeContext.sVouhNum 凭证数量 #TradeContext.sLstTrxDay 最后交易日期 #TradeContext.sLstTrxTime 最后交易时间 #TradeContext.sDepository 库箱标志 #TradeContext.sVouhName 凭证名称 try: #================拆包======================== TradeContext.sVouhType = VouhFunc.DelSpace(TradeContext.sVouhType.split("|")) TradeContext.sVouhName = VouhFunc.DelSpace(TradeContext.sVouhName.split("|")) TradeContext.sStartNo = VouhFunc.DelSpace(TradeContext.sStartNo.split("|")) TradeContext.sEndNo = VouhFunc.DelSpace(TradeContext.sEndNo.split("|")) TradeContext.sVouhNum = VouhFunc.DelSpace(TradeContext.sVouhNum.split("|")) TradeContext.sNum = len(TradeContext.sVouhType) #==================暂存================================== TradeContext.rVouhType = VouhFunc.AddSplit(TradeContext.sVouhType) TradeContext.rVouhName = VouhFunc.AddSplit(TradeContext.sVouhName) TradeContext.rStartNo = VouhFunc.AddSplit(TradeContext.sStartNo) TradeContext.rEndNo = VouhFunc.AddSplit(TradeContext.sEndNo) TradeContext.rVouhNum = VouhFunc.AddSplit(TradeContext.sVouhNum) #=============初始化返回报文变量======================== TradeContext.tradeResponse = [] #=============生成流水号======================== TradeContext.sVouhSerial = VouhFunc.GetVouhSerial( ) #=============获取当前系统时间========================== TradeContext.sLstTrxDay = AfaUtilTools.GetSysDate( ) TradeContext.sLstTrxTime = AfaUtilTools.GetSysTime( ) #begin凭证优化更改201109 #=============获取柜员尾箱号=============================== HostContext.I1SBNO = TradeContext.sBesbNo #机构号 HostContext.I1USID = TradeContext.sTellerNo #柜员号 HostContext.I1WSNO = TradeContext.sWSNO #终端号 HostContext.I1EDDT = TradeContext.sLstTrxDay #终止日期 HostContext.I1TELR = TradeContext.sTellerNo #柜员代号 if(not VouhHostFunc.CommHost('0104')): VouhFunc.tradeExit( TradeContext.errorCode, TradeContext.errorMsg ) raise AfaFlowControl.flowException( ) if(TradeContext.errorCode == '0000'): TradeContext.sTellerTailNobak = HostContext.O2CABO TradeContext.sTellerTailNo = TradeContext.sTellerTailNobak[0] AfaLoggerFunc.tradeInfo( '交易柜员尾箱号:' + TradeContext.sTellerTailNo ) #end #=============置凭证操作状态及库箱标志==================== TradeContext.sDepository = '4' #库箱标志 1.分行管理库 2.支行管理库 3.网点管理库 4.柜员凭证箱 TradeContext.sExDepos = '4' #原库箱标志 TradeContext.sVouhStatus = '3' #状态 3.已领未用 6.已作废 TradeContext.sExStatus = '6' #原状态 TradeContext.sRivTeller = ' ' #对方柜员 TradeContext.sTransType = '凭证作废撤销' TradeContext.sInTellerTailNo = TradeContext.sTellerTailNo TradeContext.sInBesbNo = TradeContext.sBesbNo #交易公共部分 VouhFunc.VouhTrans() #更新凭证变更登记表 VouhFunc.VouhModify() #数据库提交 AfaDBFunc.CommitSql( ) #主机记账 AfaLoggerFunc.tradeInfo( '------------主机记账' ) TradeContext.sOperSty = '0' VouhHostFunc.VouhCommHost() TradeContext.sTranStatus = '0' AfaLoggerFunc.tradeInfo( '=======================12'+TradeContext.errorCode ) #TradeContext.errorCode = '0000' if(TradeContext.errorCode <> '0000'): tmpErrorCode= TradeContext.errorCode tmpErrorMsg = TradeContext.errorMsg #冲正 #=============置凭证操作状态及库箱标志==================== tmpDepos = TradeContext.sDepository TradeContext.sDepository = TradeContext.sExDepos TradeContext.sExDepos = tmpDepos tmpStatus = TradeContext.sVouhStatus TradeContext.sVouhStatus = TradeContext.sExStatus TradeContext.sExStatus = tmpStatus TradeContext.sRivTeller = ' ' #对方柜员 TradeContext.sTransType = '冲正' #交易公共部分 VouhFunc.VouhTrans() AfaDBFunc.CommitSql( ) TradeContext.sTranStatus = '1' if(not TradeContext.existVariable( "HostSerno" )): TradeContext.HostSerno = '' #更新流水表 VouhFunc.ModifyVouhModify() AfaLoggerFunc.tradeInfo( '============================自动冲正!' ) VouhFunc.tradeExit(tmpErrorCode, tmpErrorMsg) raise AfaFlowControl.flowException( ) #更新流水表 VouhFunc.ModifyVouhModify() TradeContext.tradeResponse.append( ['sVouhSerial',TradeContext.sVouhSerial] ) TradeContext.tradeResponse.append( ['sVouhType',TradeContext.rVouhType] ) TradeContext.tradeResponse.append( ['sVouhName',TradeContext.rVouhName] ) TradeContext.tradeResponse.append( ['sStartNo',TradeContext.rStartNo] ) TradeContext.tradeResponse.append( ['sEndNo',TradeContext.rEndNo] ) TradeContext.tradeResponse.append( ['sVouhNum',TradeContext.rVouhNum] ) TradeContext.tradeResponse.append( ['sLstTrxDay',TradeContext.sLstTrxDay] ) TradeContext.tradeResponse.append( ['sLstTrxTime',TradeContext.sLstTrxTime] ) TradeContext.tradeResponse.append( ['sNum',str(TradeContext.sNum)] ) TradeContext.tradeResponse.append( ['errorCode','0000'] ) TradeContext.tradeResponse.append( ['errorMsg','交易成功'] ) #自动打包 AfaFunc.autoPackData() #=============程序退出==================== AfaLoggerFunc.tradeInfo( '凭证作废撤销['+TradeContext.TemplateCode+']退出' ) except AfaFlowControl.flowException, e: AfaFlowControl.exitMainFlow( )
def main( ): AfaLoggerFunc.tradeInfo( '查询凭证结存交易['+TradeContext.TemplateCode+']进入' ) #=============前台上送数据==================== #TradeContext.sBESBNO 机构号 #TradeContext.sTellerNo 柜员号 #TradeContext.sVouhType 凭证种类 #TradeCoutext.sVouhStatus 凭证状态 #TradeCoutext.sStartDate 起始日期 #TradeCoutext.sEndDate 终止日期 #TradeContext.sStart 起始记录数 #TradeContext.arraySize 查询条数 try: #=============初始化返回报文变量================== TradeContext.tradeResponse = [] #=============获取当前系统时间==================== TradeContext.sLstTrxDay = AfaUtilTools.GetSysDate( ) TradeContext.sLstTrxTime = AfaUtilTools.GetSysTime( ) #begin凭证优化更改201109 #=============获取柜员尾箱号=============================== HostContext.I1SBNO = TradeContext.sBesbNo #机构号 HostContext.I1USID = TradeContext.sTellerNo #柜员号 HostContext.I1WSNO = TradeContext.sWSNO #终端号 HostContext.I1EDDT = TradeContext.sLstTrxDay #终止日期 HostContext.I1TELR = TradeContext.sTellerNo #柜员代号 if(not VouhHostFunc.CommHost('0104')): VouhFunc.tradeExit( TradeContext.errorCode, TradeContext.errorMsg ) raise AfaFlowControl.flowException( ) if(TradeContext.errorCode == '0000'): TradeContext.sTellerTailNobak = HostContext.O2CABO TradeContext.sTellerTailNo = TradeContext.sTellerTailNobak[0] AfaLoggerFunc.tradeInfo( '交易柜员尾箱号:' + TradeContext.sTellerTailNo ) #end wheresql="substr(t1.BESBNO,1,6) = substr(t.BESBNO,1,6) AND t1.VOUHTYPE = t.VOUHTYPE AND t.VOUHSTATUS = '3'" #==============设机构号===================== if (TradeContext.existVariable("sSelBesbNo") and len(TradeContext.sSelBesbNo) <> 0 ): wheresql = wheresql + " and t.BESBNO = '" + TradeContext.sSelBesbNo + "'" #==============设凭证种类===================== if (TradeContext.existVariable("sVouhType") and len(TradeContext.sVouhType) <> 0 ): wheresql = wheresql + " and t.VOUHTYPE = '" + TradeContext.sVouhType+"'" #begin凭证优化更改201109 #==============设尾箱号===================== if (TradeContext.existVariable("sTellerTailNo") and len(TradeContext.sTellerTailNo) <> 0 ): wheresql = wheresql + " and t.TELLERNO = '" + TradeContext.sTellerTailNo + "'" #end sqlStr = "\ SELECT TELLERNO,VOUHTYPE,STARTNO,ENDNO,VOUHNUM,VOUHNAME \ FROM ( \ SELECT row_number() over() as rowid,t.TELLERNO,t.VOUHTYPE,t.STARTNO,t.ENDNO,t.VOUHNUM,t1.VOUHNAME \ FROM VOUH_REGISTER t,VOUH_PARAMETER t1 \ WHERE " + wheresql + " \ ) as tab1 \ where tab1.rowid >= " + str(TradeContext.sStart) AfaLoggerFunc.tradeDebug(sqlStr); #查询数据库并将返回的结果压至对应变量中 records = AfaDBFunc.SelectSql( sqlStr, int(TradeContext.arraySize)) if( records == None ): AfaLoggerFunc.tradeError(AfaDBFunc.sqlErrMsg) tradeExit('A005067', '查询[凭证登记表]操作异常!') raise AfaFlowControl.flowException( ) elif( len( records ) == 0 ): tradeExit('A005068', '凭证不存在!' ) raise AfaFlowControl.flowException( ) else : record=AfaUtilTools.ListFilterNone( records ) total=len( records ) sTellerTailNo = '' sVouhType = '' sStartNo = '' sEndNo = '' sVouhNum = '' sVouhName = '' for i in range( 0, total ): if( i <> 0): strSplit = '|' else: strSplit = '' sTellerTailNo = sTellerTailNo + strSplit + records[i][0] sVouhType = sVouhType + strSplit + records[i][1] sStartNo = sStartNo + strSplit + records[i][2] sEndNo = sEndNo + strSplit + records[i][3] sVouhNum = sVouhNum + strSplit + records[i][4] sVouhName = sVouhName + strSplit + records[i][5] TradeContext.tradeResponse.append( ['sTellerTailNo',sTellerTailNo] ) TradeContext.tradeResponse.append( ['sTellerNo',TradeContext.sTellerNo] ) #凭证优化更改201109 TradeContext.tradeResponse.append( ['sVouhType',sVouhType] ) TradeContext.tradeResponse.append( ['sVouhName',sVouhName] ) TradeContext.tradeResponse.append( ['sStartNo',sStartNo] ) TradeContext.tradeResponse.append( ['sEndNo',sEndNo] ) TradeContext.tradeResponse.append( ['sVouhNum',sVouhNum] ) TradeContext.tradeResponse.append( ['sLstTrxDay',TradeContext.sLstTrxDay] ) TradeContext.tradeResponse.append( ['sLstTrxTime',TradeContext.sLstTrxTime] ) TradeContext.tradeResponse.append( ['sNum',str(total)] ) TradeContext.tradeResponse.append( ['errorCode','0000'] ) TradeContext.tradeResponse.append( ['errorMsg','交易成功'] ) AfaFunc.autoPackData() #=============程序退出==================== AfaLoggerFunc.tradeInfo( '查询凭证结存交易['+TradeContext.TemplateCode+']退出' ) except AfaFlowControl.flowException, e: AfaFlowControl.exitMainFlow( )
raise AfaFlowControl.flowException( ) #=====================外调接口(后处理)================================== if subModuleExistFlag==1 : if not subModuleHandle.SubModuleDoSnd(): raise AfaFlowControl.flowException( ) #=====================发票信息处理====================================== if TradeContext.errorCode=='0000' and TradeContext.existVariable( "billData" ): if not ( TransBillFunc.InsertBill( TradeContext.billData ) ) : raise AfaFlowControl.flowException( ) #=====================自动打包========================================== AfaFunc.autoPackData() #=====================退出模板========================================== AfaLoggerFunc.tradeInfo('******代收代付.模板1.缴费模板['+TradeContext.TemplateCode+']退出******') except AfaFlowControl.flowException, e: AfaFlowControl.exitMainFlow( str(e) ) except AfaFlowControl.accException: AfaFlowControl.exitMainFlow( ) except Exception, e: AfaFlowControl.exitMainFlow( str(e) )
def main( ): AfaLoggerFunc.tradeInfo( '凭证入库['+TradeContext.TemplateCode+']进入' ) #=============前台上送数据=================================== #TradeContext.sBesbNo 机构号 #TradeContext.sCur 货币代码 #TradeContext.sTellerNo 柜员号 #TradeContext.sVouhType 凭证种类 #TradeContext.sVouhName 凭证名称 #TradeContext.sStartNo 起始号码 #TradeContext.sEndNo 终止号码 #TradeContext.sRivTeller 对方柜员 #TradeContext.sVouhStatus 凭证状态 #TradeContext.sVouhNum 凭证数量 #TradeContext.sLstTrxDay 最后交易日期 #TradeContext.sLstTrxTime 最后交易时间 #TradeContext.sDepository 库箱标志 #TradeContext.sVouhName 凭证名称 try: #================拆包======================== TradeContext.sVouhType = VouhFunc.DelSpace(TradeContext.sVouhType.split("|")) TradeContext.sVouhName = VouhFunc.DelSpace(TradeContext.sVouhName.split("|")) TradeContext.sStartNo = VouhFunc.DelSpace(TradeContext.sStartNo.split("|")) TradeContext.sEndNo = VouhFunc.DelSpace(TradeContext.sEndNo.split("|")) TradeContext.sVouhNum = VouhFunc.DelSpace(TradeContext.sVouhNum.split("|")) TradeContext.sNum = len(TradeContext.sVouhType) #==================暂存================================== TradeContext.rVouhType = VouhFunc.AddSplit(TradeContext.sVouhType) TradeContext.rVouhName = VouhFunc.AddSplit(TradeContext.sVouhName) TradeContext.rStartNo = VouhFunc.AddSplit(TradeContext.sStartNo) TradeContext.rEndNo = VouhFunc.AddSplit(TradeContext.sEndNo) TradeContext.rVouhNum = VouhFunc.AddSplit(TradeContext.sVouhNum) #=============初始化返回报文变量======================== TradeContext.tradeResponse = [] #=============生成流水号======================== TradeContext.sVouhSerial = VouhFunc.GetVouhSerial( ) #=============获取当前系统时间========================== TradeContext.sLstTrxDay = AfaUtilTools.GetSysDate( ) TradeContext.sLstTrxTime = AfaUtilTools.GetSysTime( ) #=============置凭证操作状态及库箱标志==================== TradeContext.sDepository = '1' #库箱标志 1.分行管理库 2.支行管理库 3.网点管理库 4.柜员凭证箱 TradeContext.sExDepos = ' ' #原库箱标志 TradeContext.sVouhStatus = '0' #状态 0.已入未发 TradeContext.sExStatus = ' ' #原状态 TradeContext.sRivTeller = ' ' #对方柜员 TradeContext.sTransType = '凭证入库' #begin凭证优化更改201109 #=============获取柜员尾箱号=============================== HostContext.I1SBNO = TradeContext.sBesbNo #机构号 HostContext.I1USID = TradeContext.sTellerNo #柜员号 HostContext.I1WSNO = TradeContext.sWSNO #终端号 HostContext.I1EDDT = TradeContext.sLstTrxDay #终止日期 HostContext.I1TELR = TradeContext.sTellerNo #柜员代号 if(not VouhHostFunc.CommHost('0104')): VouhFunc.tradeExit( TradeContext.errorCode, TradeContext.errorMsg ) raise AfaFlowControl.flowException( ) if(TradeContext.errorCode == '0000'): TradeContext.sTellerTailNobak = HostContext.O2CABO TradeContext.sTellerTailNo = TradeContext.sTellerTailNobak[0] AfaLoggerFunc.tradeInfo( '柜员尾箱号:' + TradeContext.sTellerTailNo ) #end #判断是否回滚 n=0 for i in range(TradeContext.sNum): #=============定义变量========================== sFlagBack = '0' #入库凭证终止号码与库中凭证的起始号码是否存在连续关系,'1':是;'0':否 sFlagFront = '0' #入库凭证起始号码与库中凭证的终止号码是否存在连续关系,'1':是;'0':否 n=n+1 #============= 判断入库的起始号码是否小于等于终止号码============================ if(int(TradeContext.sStartNo[i]) > int(TradeContext.sEndNo[i]) ): tradeExit('A005066', '入库起始号码不能大于终止号码!') raise AfaFlowControl.flowException( ) #凭证优化更改201108 #============= 查询分行凭证库中的凭证号段============================ #sqlStr = "select STARTNO,ENDNO,VOUHSTATUS from VOUH_REGISTER WHERE VOUHTYPE = '"\ #+ TradeContext.sVouhType[i] + "' and BESBNO = '" + TradeContext.sBesbNo + "' and CUR = '" + TradeContext.sCur+"'" sqlStr = "select STARTNO,ENDNO ,VOUHSTATUS from VOUH_REGISTER where VOUHTYPE ='" + TradeContext.sVouhType[i] + "'" sqlStr = sqlStr + " and VOUHSTATUS != '1' and BESBNO = '" + TradeContext.sBesbNo + "' and CUR = '" + TradeContext.sCur+"'" #end AfaLoggerFunc.tradeDebug(sqlStr) records = AfaDBFunc.SelectSql( sqlStr ) AfaLoggerFunc.tradeInfo(records) if( records == None ): tradeExit('A005061', '查询[凭证登记表]操作异常!') raise AfaFlowControl.flowException( ) elif( len( records ) == 0 ): #如果数据库中无对应记录则直接插入 sqlStr = "insert into VOUH_REGISTER \ (BESBNO,TELLERNO,DEPOSITORY,CUR,VOUHTYPE,STARTNO,ENDNO,RIVTELLER,VOUHSTATUS,\ VOUHNUM,LSTTRXDAY,LSTTRXTIME) \ values \ ('"+TradeContext.sBesbNo+"','"+TradeContext.sTellerTailNo+"',\ '"+TradeContext.sDepository+"','"+TradeContext.sCur+"','"+TradeContext.sVouhType[i]+"',\ '"+TradeContext.sStartNo[i]+"','"+TradeContext.sEndNo[i]+"','"+TradeContext.sRivTeller+"',\ '"+TradeContext.sVouhStatus+"','"+TradeContext.sVouhNum[i]+"',\ '"+TradeContext.sLstTrxDay+"','"+TradeContext.sLstTrxTime+"')" AfaLoggerFunc.tradeDebug(sqlStr) records = AfaDBFunc.InsertSql( sqlStr ) if records == -1 : AfaLoggerFunc.tradeInfo( '数据库回滚' ) AfaDBFunc.RollbackSql( ) tradeExit('A005062', '凭证入库失败,凭证数据库操作失败!') raise AfaFlowControl.flowException( ) else: tradeExit('0000', '凭证入库成功') else : #判断入库的凭证起止号码与已入库的凭证号码是否有交集,其中records[x][0] #为已入库的终止号码;records[x][1]为已入库的起始号码,判断为有交集的情况为: #1.入库的终止号码大于等于已入库的起始号码,并且小于等于已入库的终止号码; #2.入库的起始号码大于等于已入库的起始号码,并且小于等于已入库的终止号码; #3.入库的终止号码大于等于已入库的终止号码,并且入库的起始号码小于等于已入库的起始号码 for x in range( len(records) ): sTmpStartNo = records[x][0] sTmpEndNo = records[x][1] sTmpVouhStat = records[x][2] if ((int(TradeContext.sEndNo[i])<=int(sTmpEndNo) and int(TradeContext.sEndNo[i])>=int(sTmpStartNo)) \ or (int(TradeContext.sStartNo[i])>=int(sTmpStartNo) and int(TradeContext.sStartNo[i])<=int(sTmpEndNo)) \ or ( int(TradeContext.sEndNo[i])>=int(sTmpEndNo) and int(TradeContext.sStartNo[i])<=int(sTmpStartNo))): if( n > 1 ): AfaLoggerFunc.tradeInfo( '数据库回滚' ) AfaDBFunc.RollbackSql( ) tradeExit('A005063', '凭证入库失败,凭证库中存在本次入库的凭证!') raise AfaFlowControl.flowException( ) elif ((int(TradeContext.sEndNo[i]) == (int(sTmpStartNo)-1)) and sTmpVouhStat == '0'): sFlagBack = '1' #无交集且后连续,置后连续标识 sOperDelNo = records[x][0] sOperEndNo = records[x][1] elif ((int(TradeContext.sStartNo[i]) == (int(sTmpEndNo)+1)) and sTmpVouhStat == '0'): sFlagFront = '1' #无交集且前连续,置前连续标识 sOperStartNo = records[x][0] #输入的凭证号码与库中同类型凭证存在后连续关系,则与相应的记录进行归并 if ( sFlagBack == '1' and sFlagFront == '0'): sTmpVouhNum = str( int(sTmpEndNo) - int(TradeContext.sStartNo[i]) + 1 ) sqlStr = "update VOUH_REGISTER set \ STARTNO = '" + TradeContext.sStartNo[i] + "', \ VOUHNUM = '"+ sTmpVouhNum + "',\ TELLERNO = '" + TradeContext.sTellerTailNo + "',\ LSTTRXDAY = '"+ TradeContext.sLstTrxDay + "',\ LSTTRXTIME = '" + TradeContext.sLstTrxTime + "'\ where ENDNO = '" + sOperEndNo + "' AND VOUHSTATUS = '"+TradeContext.sVouhStatus+"' \ AND VOUHTYPE = '" + TradeContext.sVouhType[i]+ "' AND BESBNO = '" + TradeContext.sBesbNo+ "' \ AND CUR = '" + TradeContext.sCur+"'" AfaLoggerFunc.tradeDebug(sqlStr) records = AfaDBFunc.UpdateSql( sqlStr ) if records == -1 : AfaLoggerFunc.tradeInfo( '数据库回滚' ) #回滚 AfaDBFunc.RollbackSql( ) tradeExit('A005064', '凭证入库失败,凭证数据库操作异常!') raise AfaFlowControl.flowException( ) elif records == 0 : AfaLoggerFunc.tradeInfo( '数据库回滚' ) #回滚 AfaDBFunc.RollbackSql( ) tradeExit('A005062', '凭证入库失败,凭证数据库操作失败!') raise AfaFlowControl.flowException( ) else: tradeExit('0000', '凭证入库成功') #输入的凭证号码与库中同类型凭证存在前连续关系,则与相应的记录进行归并 elif ( sFlagFront == '1' and sFlagBack == '0' ): sTmpVouhNum = str( int(TradeContext.sEndNo[i]) - int(sOperStartNo) + 1 ) sqlStr = "update VOUH_REGISTER set \ ENDNO = '" + TradeContext.sEndNo[i] + "', \ VOUHNUM = '" + sTmpVouhNum + "',\ TELLERNO = '" + TradeContext.sTellerTailNo+ "',\ LSTTRXDAY = '" + TradeContext.sLstTrxDay + "',\ LSTTRXTIME = '" + TradeContext.sLstTrxTime + "'\ where STARTNO = '" + sOperStartNo + "' AND VOUHSTATUS = '"+TradeContext.sVouhStatus+"' \ AND VOUHTYPE = '" + TradeContext.sVouhType[i]+ "' AND BESBNO = '" + TradeContext.sBesbNo + "' \ AND CUR ='"+ TradeContext.sCur+"'" AfaLoggerFunc.tradeDebug(sqlStr) records = AfaDBFunc.UpdateSql( sqlStr ) if records == -1 : AfaLoggerFunc.tradeInfo( '数据库回滚' ) #回滚 AfaDBFunc.RollbackSql( ) tradeExit('A005064', '凭证入库失败,凭证数据库操作异常!') raise AfaFlowControl.flowException( ) elif records == 0 : AfaLoggerFunc.tradeInfo( '数据库回滚' ) #回滚 AfaDBFunc.RollbackSql( ) tradeExit('A005062', '凭证入库失败,凭证数据库操作失败!') raise AfaFlowControl.flowException( ) else: tradeExit('0000', '凭证入库成功') #输入的凭证号码与库中同类型凭证存在前/后连续关系,则与相应的记录进行归并 elif ( sFlagBack == '1' and sFlagFront == '1' ): sTmpVouhNum = str( int(sOperEndNo) - int(sOperStartNo) + 1 ) sqlStr = "update VOUH_REGISTER set \ ENDNO = '" + sOperEndNo + "', VOUHNUM = '" + sTmpVouhNum + "',\ TELLERNO = '" + TradeContext.sTellerTailNo + "',\ LSTTRXDAY = '" + TradeContext.sLstTrxDay + "',\ LSTTRXTIME = '" + TradeContext.sLstTrxTime + "'\ where STARTNO = '" + sOperStartNo + "' AND VOUHSTATUS = '"+TradeContext.sVouhStatus+"' \ AND VOUHTYPE = '" + TradeContext.sVouhType[i]+ "' AND BESBNO = '" + TradeContext.sBesbNo + "' \ AND CUR = '"+ TradeContext.sCur+"'" AfaLoggerFunc.tradeDebug(sqlStr) records = AfaDBFunc.UpdateSql( sqlStr ) if records == -1 or records == 0 : AfaLoggerFunc.tradeInfo( '数据库回滚' ) #回滚 AfaDBFunc.RollbackSql( ) tradeExit('A005062', '凭证入库失败,凭证数据库操作失败!') raise AfaFlowControl.flowException( ) else: #归并成功后,删除归并后其余一条 sqlDel = "delete from VOUH_REGISTER \ where STARTNO = '" + sOperDelNo + "' AND VOUHSTATUS = '"+TradeContext.sVouhStatus+"' \ AND VOUHTYPE = '" + TradeContext.sVouhType[i]+ "' AND BESBNO ='"+ TradeContext.sBesbNo+"' \ AND CUR = '"+ TradeContext.sCur+"'" AfaLoggerFunc.tradeDebug(sqlDel) record = AfaDBFunc.DeleteSql( sqlDel ) if record == -1 or record == 0 : AfaLoggerFunc.tradeInfo( '数据库回滚' ) record = AfaDBFunc.RollbackSql( ) tradeExit('A005062', '凭证入库失败,凭证数据库操作失败!') raise AfaFlowControl.flowException( ) else: tradeExit('0000', '凭证入库成功') #输入的凭证号码与库中同类型凭证不存在任何连续关系,则直接插入 else: sqlStr = "insert into VOUH_REGISTER \ (BESBNO,TELLERNO,DEPOSITORY,CUR,VOUHTYPE,STARTNO,ENDNO,RIVTELLER,VOUHSTATUS,\ VOUHNUM,LSTTRXDAY,LSTTRXTIME) \ values \ ('" + TradeContext.sBesbNo + "','" + TradeContext.sTellerTailNo + "',\ '"+TradeContext.sDepository+ "','" + TradeContext.sCur+"','"+ TradeContext.sVouhType[i]+"',\ '" + TradeContext.sStartNo[i] + "','" + TradeContext.sEndNo[i] + "','" + TradeContext.sRivTeller +"',\ '"+TradeContext.sVouhStatus+"','" + TradeContext.sVouhNum[i] + "',\ '" + TradeContext.sLstTrxDay + "','" + TradeContext.sLstTrxTime + "')" AfaLoggerFunc.tradeDebug(sqlStr) records = AfaDBFunc.InsertSql( sqlStr ) if records == -1 : AfaLoggerFunc.tradeInfo( '数据库回滚' ) AfaDBFunc.RollbackSql( ) tradeExit('A005062', '凭证入库失败,凭证数据库操作失败!') raise AfaFlowControl.flowException( ) else: tradeExit('0000', '凭证入库成功') AfaLoggerFunc.tradeInfo( '------------更新凭证变更登记表' ) #更新凭证变更登记表 VouhFunc.VouhModify() #数据库提交 AfaLoggerFunc.tradeInfo( '------------数据库提交' ) AfaDBFunc.CommitSql( ) #主机记账 AfaLoggerFunc.tradeInfo( '------------主机记账' ) TradeContext.sOperSty = '0' VouhHostFunc.VouhCommHost() TradeContext.sTranStatus = '0' AfaLoggerFunc.tradeInfo( '=======================12'+TradeContext.errorCode ) #TradeContext.errorCode = '0000' if(TradeContext.errorCode <> '0000'): tmpErrorCode= TradeContext.errorCode tmpErrorMsg = TradeContext.errorMsg #冲正 #=============置凭证操作状态及库箱标志==================== TradeContext.sDepository = '1' #库箱标志 1.分行管理库 2.支行管理库 3.网点管理库 4.柜员凭证箱 TradeContext.sExDepos = '1' #原库箱标志 TradeContext.sVouhStatus = '9' #状态 0.已入未发 9.欲出库 TradeContext.sExStatus = '0' #原状态 TradeContext.sRivTeller = ' ' #对方柜员 TradeContext.sTransType = '冲正' TradeContext.sInTellerTailNo = TradeContext.sTellerTailNo TradeContext.sInBesbNo = TradeContext.sBesbNo #交易公共部分 VouhFunc.VouhTrans() AfaDBFunc.CommitSql( ) sqlDel = "delete from VOUH_REGISTER where VOUHSTATUS = '9'" AfaLoggerFunc.tradeDebug(sqlDel) record = AfaDBFunc.DeleteSqlCmt( sqlDel ) if record == -1 or record == 0 : tradeExit('A005062', '冲正失败,凭证数据库操作失败!') raise AfaFlowControl.flowException( ) else: AfaLoggerFunc.tradeInfo( '============================自动冲正!' ) TradeContext.sTranStatus = '1' if(not TradeContext.existVariable( "HostSerno" )): TradeContext.HostSerno = '' #更新流水表 VouhFunc.ModifyVouhModify() tradeExit(tmpErrorCode, tmpErrorMsg) raise AfaFlowControl.flowException( ) #更新流水表 VouhFunc.ModifyVouhModify() TradeContext.tradeResponse.append( ['sVouhSerial',TradeContext.sVouhSerial] ) TradeContext.tradeResponse.append( ['sVouhType',TradeContext.rVouhType] ) TradeContext.tradeResponse.append( ['sVouhName',TradeContext.rVouhName] ) TradeContext.tradeResponse.append( ['sStartNo',TradeContext.rStartNo] ) TradeContext.tradeResponse.append( ['sEndNo',TradeContext.rEndNo] ) TradeContext.tradeResponse.append( ['sVouhNum',TradeContext.rVouhNum] ) TradeContext.tradeResponse.append( ['sLstTrxDay',TradeContext.sLstTrxDay] ) TradeContext.tradeResponse.append( ['sLstTrxTime',TradeContext.sLstTrxTime] ) TradeContext.tradeResponse.append( ['sNum',str(TradeContext.sNum)] ) TradeContext.tradeResponse.append( ['errorCode','0000'] ) TradeContext.tradeResponse.append( ['errorMsg','查询成功'] ) #自动打包 AfaFunc.autoPackData() #=============程序退出==================== AfaLoggerFunc.tradeInfo( '凭证入库['+TradeContext.TemplateCode+']退出' ) except AfaFlowControl.flowException, e: AfaLoggerFunc.tradeInfo( '数据库回滚' ) AfaDBFunc.RollbackSql( ) AfaFlowControl.exitMainFlow( )