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

📄 pcs_snd_zdys_p.pc

📁 unix 下用pro*c tuxedo 开发的东西
💻 PC
字号:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*	File name		: Pcs_Snd_ZDYS_P.x	                   		*
*	Module ID		:				          	*
*	Module Name	:                                                 	*
*	Purpose		: send ZDYS 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 "unistd.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 PcsSndMQZDYS(long int key);
int UpdateHZRec( long int lg_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 zdys MQ string and put then to MQ */
int PcsSndMQZDYS(long int key)
{
	long int fsxh;
	int yffs,qzlss;
	int count_rec;
	char tempstring[MID_LEN];
	char datatype[SHORT_LEN];
	char wjbh[SHORT_LEN];
	char jsfbh[3];
	int year;
	int i;
	int retcode=0;
	char zfjbh[9];
	struct stZDYSSMDBRec ZDYSSMDB;
	struct stZDYSSMDBRec_id st_id;
	struct stZDYSDBRec ZDYSDB;
	
	ERROR=0;
	EXEC SQL WHENEVER SQLERROR DO sqlerror();
	EXEC SQL SELECT count(*) INTO :count_rec FROM t_fszdyssj WHERE fsxh=:key;
	if( count_rec==0 )
	{
		ProcessError(LOG_ERROR,"PCS_Snd_ZDYS_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_ZDYS_P: No space in memory",END);
		return(-1);
	}
	
	message[0]='\0';
	EXEC SQL SELECT * INTO 
		  :ZDYSSMDB.bkdh,
		  :ZDYSSMDB.yslx,
		  :ZDYSSMDB.wjbh,
		  :ZDYSSMDB.qdqa,
		  :ZDYSSMDB.kq,
		  :ZDYSSMDB.dingj :st_id.dingj,
		  :ZDYSSMDB.dyzs  :st_id.dyzs,
		  :ZDYSSMDB.dyk   :st_id.dyk,
		  :ZDYSSMDB.lszs  :st_id.lszs,
		  :ZDYSSMDB.lsk   :st_id.lsk,
		  :ZDYSSMDB.nf,
		  :ZDYSSMDB.xh
		FROM t_fszdyssm WHERE fsxh=:key;
/*	ZDYSSMDB.bkdh[7]='\0';
	ZDYSSMDB.yslx[1]='\0';
	ZDYSSMDB.wjbh[2]='\0';
	ZDYSSMDB.kq[6]='\0';
		
	itoa(key,tempstring,11);
	strcat(message,tempstring);
*/
	sprintf(message,"%10ld",key);	
	EXEC SQL SELECT sjbh INTO :jsfbh FROM t_hz WHERE fsxh=:key;
/*	strcat(message,jsfbh);
	strcat(message,BSBH);
	str_format(ZDYSSMDB.bkdh,8);
	strcat(message,ZDYSSMDB.bkdh);
	str_format(ZDYSSMDB.yslx,2);
	strcat(message,ZDYSSMDB.yslx);
	str_format(ZDYSSMDB.wjbh,3);
	strcat(message,ZDYSSMDB.wjbh);
*/
	sprintf(message,"%s%2s%2s%7s%1s%2s",message,jsfbh,BSBH,ZDYSSMDB.bkdh,ZDYSSMDB.yslx,ZDYSSMDB.wjbh);

/*	itoa(ZDYSSMDB.qdqa,tempstring,3);
	strcat(message,tempstring);
	strcat(message,ZDYSSMDB.kq);
	ftoa(ZDYSSMDB.dingj,tempstring,2,8);
	strcat(message,tempstring);
	itoa(ZDYSSMDB.dyzs,tempstring,11);
	strcat(message,tempstring);
	ftoa(ZDYSSMDB.dyk,tempstring,2,12);
	strcat(message,tempstring);
	itoa(ZDYSSMDB.lszs,tempstring,11);
	strcat(message,tempstring);
	ftoa(ZDYSSMDB.lsk,tempstring,2,12);
	strcat(message,tempstring);
	itoa(ZDYSSMDB.nf,tempstring,5);
	strcat(message,tempstring);
*/
	sprintf(message,"%s%2d%6s%7.2f%10ld%11.2f%10d%11.2f%4d",message,\
		ZDYSSMDB.qdqa,ZDYSSMDB.kq,ZDYSSMDB.dingj,ZDYSSMDB.dyzs,ZDYSSMDB.dyk,\
		ZDYSSMDB.lszs,ZDYSSMDB.lsk,ZDYSSMDB.nf);

	EXEC SQL DECLARE cur_yssj CURSOR FOR 
		SELECT yffs,zfjbh,fsxh FROM t_fszdyssj WHERE fsxh=:key;
		
	EXEC SQL OPEN cur_yssj;
	for( i=0;i<count_rec;i++ )
	{
		
		EXEC SQL FETCH cur_yssj INTO :yffs,:zfjbh,:fsxh;
/*		zfjbh[8]='\0';
		strcat(message,zfjbh);
		itoa(yffs,tempstring,8);
		strcat(message,tempstring);
		itoa(qzlss,tempstring,8);
		strcat(message,tempstring);
*/
		sprintf(message,"%s%8s%7d%7s",message,zfjbh,yffs,"       ");

	}
	
	EXEC SQL CLOSE cur_yssj;

#ifdef	DEBUG
	PutintoF(message);
#endif

	if(MQBKSend_Syn(strlen(message) ,message, 0,"YS") < 0)
	{
		MQBKBack();
		free(message);
		EXEC SQL ROLLBACK WORK;
		return(-1);
	}
	else	
	{
		if(MQBKCmit()<0)
		{
			free(message);
			return(-1);
		}
		
	}
/*	printf("msg len is %ld\n",strlen(message));
*/	UpdateSndLogRecStatus( fsxh );
	UpdateHZRec( fsxh );
	
	free(message);
	return(0);
}

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

void main()
{
	long int xh;
	int i,j;
	int count_rec;
	char waitforsnd='2';
	char ZDdatatype='1';
	int flag;
	int  retcode=0;
	char *PID = "Client Txn Clt_Mpt Process(Port 7111)";
	char produce_err_str[20];
	
	signal(SIGTERM,freect);
	flag=InitPcsSndYSP();
	if ( flag!=0 ) 
	{
		ProcessError(LOG_ERROR,"PCS_Snd_ZDYS_P: error when init function",END);
		exit(0);
	}
	
 	ProcessError(LOG_NORMAL,"PCS_Snd_ZDYS_P: Test this is NORMAL message",END);
	
	iTInterval=0;
	iTInterval=GetTimeInterval("PCS_SND_YS_P");
	
	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=:ZDdatatype;
	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=:ZDdatatype;
	EXEC SQL OPEN cur_fsrz;
/*	printf("count , zt,fl=%d,%c,%c\n",count_rec,waitforsnd,ZDdatatype);
*/	retcode=MQBKInit("CSYW");
	if( retcode<0 )
	{
		ProcessError(LOG_ERROR,"PCS_Snd_ZDYS_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==1 )
		{
			ERROR=0;
			ProcessError(LOG_ERROR,"PCS_Snd_ZDYS_P: Error when fetch xh",END);
			continue;
		}
		flag=PcsSndMQZDYS(xh);
		if( flag!=0 )
		{
			sprintf(produce_err_str,"%10d",xh);
			ProcessError(LOG_ERROR,"PCS_Snd_ZDYS_P: Error when use pcssndmqzdys fsxh is: ",produce_err_str);
			EXEC SQL ROLLBACK WORK;
			continue;
		}
		
		EXEC SQL COMMIT WORK;
	}
	
	MQBKClear();
	
	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 + -