⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pcs_snd_pdys_p.pc

📁 unix 下用pro*c tuxedo 开发的东西
💻 PC
字号:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*	File name		: Pcs_Snd_PDYS_P.x	                   		*
*	Module ID		:				          	*
*	Module Name	:                                                 	*
*	Purpose		: send PDYS to MQ whose fszt=2		 	*
*	Author             	: lix                                       	*
*	Date Created	: 1999,07,26                                       	*
*	Version		: Version 1.0                                      	*
*	Environment	: Digital UNIX                                     	*
*	Portability	: UNIX Platform                                    	*
*	Warnings		:                                              *
*	References	:                                                      *
*	Calling Syntax	:                                                      *
*	Parameters	: None                                                 *
*	Returns		: void                                                 *
*	Calling Function	:                                                      *
*	Called Functions	: timely	                                  *
*	Datastores and usages:                                                 *     
*        	   (a) Input                                                   *
* 	   (b) OutPut                                                          *       
*	Report		: None                                                 *
*	Screens		: None                                                 *
*	Messages Files	: None                                                 *
*	Change Log	:                                                      *
*	Change No. 	Date	Author	Reason For Change                 *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
*/

#include "stdio.h"
#include "stdlib.h"
#include "sqlcpr.h"
#include "/usr/bkfx/include/Pcs_Snd_YS_P/Pcs_Snd_YS_P.h"
#include <fcntl.h>
#include <signal.h>
#include "/usr/bkfx/include/myapi.h"

int UpdateHZRec( long int lg_Key );
int PcsSndMQPDYS(long int key);
void freect(void);

/*update the table to locate the relative flag*/
int UpdateHZRec( long int lg_Key )
{
	char hzzt = HZ_SENDED;
	
	EXEC SQL WHENEVER SQLERROR DO sqlerror();
	EXEC SQL UPDATE T_HZ SET HZZT = :hzzt, HZJSSJ = SYSDATE
		WHERE FSXH = :lg_Key;
	EXEC SQL COMMIT WORK;
	return(1);
} 

/* composing pdys MQ string and put then to MQ */

int PcsSndMQPDYS(long int key)
{
	long int fsxh;
	int zjfs,lszjfs;
	char zfjbh[9];
	int count_rec;
	char *message;
	char tempstring[MID_LEN];
	char datatype[SHORT_LEN];
	char wjbh[SHORT_LEN];
	char jsfbh[3];
	int year;
	int i;
	int retcode=0;
	struct stPDYSSMDBRec PDYSSMDB;
	struct stPDYSSMDBRec_id st_id;
	struct stPDYSDBRec PDYSDB;
	char str_zdqa[3],str_zdqb[3];
	
	ERROR=0;
	EXEC SQL WHENEVER SQLERROR DO sqlerror();
	EXEC SQL SELECT count(*) INTO :count_rec FROM t_fspdyssj WHERE fsxh=:key;
	if( count_rec==0 )
	{
		ProcessError(LOG_ERROR,"PCS_Snd_PDYS_P: Error cannot found yssj ",END);
		return(-1);
	}
	
	message=(char *)malloc((YSSM_MSG_LEN+YSSJ_MSG_LEN*count_rec+1)*sizeof(char));
	if( message==NULL )
	{
		ProcessError(LOG_ERROR,"PCS_Snd_PDYS_P: Error No space in memory",END );
		return(-1);
	}
	message[0]='\0';
	EXEC SQL SELECT * INTO 
		  :PDYSSMDB.bkdh,
		  :PDYSSMDB.yslx,
		  :PDYSSMDB.wjbh,
		  :PDYSSMDB.qdqa,
		  :PDYSSMDB.qdqb :st_id.qdqb,
		  :PDYSSMDB.zdqa :st_id.zdqa,
		  :PDYSSMDB.zdqb :st_id.zdqb,
		  :PDYSSMDB.kq,
		  :PDYSSMDB.dingj :st_id.dingj,
		  :PDYSSMDB.dyzs  :st_id.dyzs,
		  :PDYSSMDB.dyk   :st_id.dyk,
		  :PDYSSMDB.lszs  :st_id.lszs,
		  :PDYSSMDB.lsk   :st_id.lsk,
		  :PDYSSMDB.nf,
		  :PDYSSMDB.xh
		 FROM t_fspdyssm WHERE fsxh=:key;
/*	PDYSSMDB.bkdh[7]='\0';
	PDYSSMDB.yslx[1]='\0';
	PDYSSMDB.wjbh[2]='\0';
	PDYSSMDB.kq[6]='\0';
*/
/*	itoa(key,tempstring,11);
	strcat(message,tempstring);
*/
	EXEC SQL SELECT sjbh INTO :jsfbh FROM t_hz WHERE fsxh=:key;
/*	strcat(message,jsfbh);
	
	strcat(message,BSBH);
	str_format(PDYSSMDB.bkdh,8);
	strcat(message,PDYSSMDB.bkdh);
	str_format(PDYSSMDB.yslx,2);
	strcat(message,PDYSSMDB.yslx);
	str_format(PDYSSMDB.wjbh,3);
	strcat(message,PDYSSMDB.wjbh);
	itoa(PDYSSMDB.qdqa,tempstring,3);
	strcat(message,tempstring);
	itoa(PDYSSMDB.qdqb,tempstring,3);
	strcat(message,tempstring);
	itoa(PDYSSMDB.zdqa,tempstring,3);
	strcat(message,tempstring);


	itoa(PDYSSMDB.zdqb,tempstring,3);
	strcat(message,tempstring);
	strcat(message,PDYSSMDB.kq);
	ftoa(PDYSSMDB.dingj,tempstring,2,8);
	strcat(message,tempstring);
	itoa(PDYSSMDB.dyzs,tempstring,11);
	strcat(message,tempstring);
	ftoa(PDYSSMDB.dyk,tempstring,2,12);
	strcat(message,tempstring);
	itoa(PDYSSMDB.lszs,tempstring,11);
	strcat(message,tempstring);
	ftoa(PDYSSMDB.lsk,tempstring,2,12);
	strcat(message,tempstring);
	itoa(PDYSSMDB.nf,tempstring,5);
	strcat(message,tempstring);
*/
	if( st_id.zdqa < 0 )
		strcpy(str_zdqa,"  ");
	else 
		sprintf(str_zdqa,"%2d",PDYSSMDB.zdqa);
	if( st_id.zdqb < 0 )
		strcpy(str_zdqb,"  ");
	else
		sprintf(str_zdqb,"%2d",PDYSSMDB.zdqb);

	sprintf(message,"%10ld%2s%2s%7s%1s%2s%2d%2d%2s%2s%6s%7.2f%10ld%11.2f%10ld%11.2f%4d",\
		key,jsfbh,BSBH,PDYSSMDB.bkdh,PDYSSMDB.yslx,PDYSSMDB.wjbh,\
		PDYSSMDB.qdqa,PDYSSMDB.qdqb,str_zdqa,str_zdqb,
		PDYSSMDB.kq,PDYSSMDB.dingj,PDYSSMDB.dyzs,PDYSSMDB.dyk,\
		PDYSSMDB.lszs,PDYSSMDB.lsk,PDYSSMDB.nf);

	EXEC SQL DECLARE cur_yssj CURSOR FOR 
		SELECT zjfs,zfjbh,fsxh FROM t_fspdyssj WHERE fsxh=:key;
		
	EXEC SQL OPEN cur_yssj;
	for( i=0;i<count_rec;i++ )
	{
		
		EXEC SQL FETCH cur_yssj INTO :zjfs,:zfjbh,:fsxh;
		
/*		strcat(message,zfjbh);
		itoa(zjfs,tempstring,8);
		strcat(message,tempstring);
		itoa(lszjfs,tempstring,8);
		strcat(message,tempstring);
*/
	sprintf(message,"%s%8s%7d%7s",message,zfjbh,zjfs,"       ");
/*	printf("%s\n",message);
*/	}
	EXEC SQL CLOSE cur_yssj;
/*	printf("%s\n",message);
*/

#ifdef	DEBUG
	PutintoF(message);
#endif
	if(MQBKSend_Syn(strlen(message) ,message, 0,"YS") < 0)
	{
		MQBKBack();
		EXEC SQL ROLLBACK WORK;
		ProcessError(LOG_ERROR,"PCS_Snd_PDYS_P: Error when send pdys to mq",END );
		return(-1);
	}
	else	
	{
		if( MQBKCmit() < 0 )
		{
			EXEC SQL ROLLBACK WORK;
			ProcessError(LOG_ERROR,"PCS_Snd_PDYS_P: Error commit send mq",END );
			return(-1);
		}
	}
	
	UpdateSndLogRecStatus( fsxh );
	UpdateHZRec( fsxh );
	
	free(message);
	return(0);
}

void freect(void)
{
	if( message!=NULL )
	free(message);
	EXEC SQL ROLLBACK WORK RELEASE;
	exit(0);
}

void main()
{
	long int xh;
	int i,j,flag;
	int count_rec;
	char waitforsnd='2';
	char PDdatatype='2';
	int  retcode=0;
	char *PID = "Client Txn Clt_Mpt Process(Port 7111)";
	char produce_err_str[20];

	signal(SIGTERM,freect);

	ProcessError(LOG_NORMAL,"PCS_Snd_PDYS_P: this is NORMAL message", END);
	
	flag=InitPcsSndYSP();
	if ( flag<0 )
	{
		ProcessError(LOG_ERROR,"PCS_Snd_PDYS_P: error when init function",END);
		exit(0);
	}
	iTInterval=0;
	iTInterval=GetTimeInterval("PCS_SND_YS_P");
	ERROR=0;
	EXEC SQL WHENEVER SQLERROR DO sqlerror();
	EXEC SQL SELECT bsbh INTO :BSBH FROM T_BSBH;

begin:	
	ERROR=0;count_rec=0;
	EXEC SQL SELECT count(*) INTO :count_rec FROM t_fsrz WHERE sjzt=:waitforsnd AND sjfl=:PDdatatype;
	if( count_rec == 0 || ERROR!=0 )
	{
		ERROR=0;
		goto End;
	}
	EXEC SQL DECLARE cur_fsrz CURSOR FOR
		SELECT fsxh FROM t_fsrz WHERE sjzt=:waitforsnd AND sjfl=:PDdatatype;
	EXEC SQL OPEN cur_fsrz;
	
	retcode=MQBKInit("CSYW");
	if( retcode<0 )
	{
		ProcessError(LOG_ERROR,"PCS_Snd_PDYS_P: Error when init mq ys",END);
		EXEC SQL CLOSE cur_fsrz;
		goto End;
	}
	
	for( i=0;i<count_rec;i++ )
	{
		EXEC SQL FETCH cur_fsrz INTO :xh;
		if ( ERROR!=0 )
		{
			ERROR=0;
			ProcessError(LOG_ERROR,"PCS_Snd_PDYS_P: fetch xh error",END);
			continue;
		}
		flag=PcsSndMQPDYS(xh);
		if( flag!=0 )
		{
			sprintf(produce_err_str,"%10d",xh);
			ProcessError(LOG_ERROR,"PCS_Snd_PDYS_P: Error when use pcssndmqzdys fsxh is: ",produce_err_str);
			EXEC SQL ROLLBACK WORK;
			continue;
		}
		EXEC SQL COMMIT WORK;
	}
	flag=MQBKClear();
	if( flag<0 )
	{
		ProcessError(LOG_ERROR,"PCS_Snd_PDYS_P: error when mqbk clear",END);
	}
	
	EXEC SQL CLOSE cur_fsrz;

End:
	

#ifdef DEBUG
	exit(0);
#endif

	sleep(iTInterval);
	goto begin;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -