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

📄 pcs_snd_ys1.pc

📁 unix 下用pro*c tuxedo 开发的东西
💻 PC
字号:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*	File name		: PCS_Snd_YS1.x	                   		    *				
*	Module ID		:				               *
*	Module Name	:                                                      *
*	Purpose		: Convert YS data's format,record them in database 	*
*	Author             :                                                   *
*	Date Created	: 1999,07,14                                           *
*	Version		: Version 1.0                                          *
*	Environment	: Digital UNIX                                         *
*	Portability	: UNIX Platform                                        *
*	Warnings		:                                              *
*	References	:                                                      *
*	Calling Syntax	:                                                      *
*	Parameters	: None                                                 *
*	Returns		: void                                                 *
*	Calling Function:                                                      *
*	Called Functions: When system startup                                  *
*	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 "sqlca.h"
#include "sqlcpr.h"
#include <fcntl.h>
#include <signal.h>
#include "/usr/bkfx/include/Pcs_Snd_YS1/Pcs_Snd_YS1.h"
#include "/usr/bkfx/include/Pcs_Snd_YS1/ys1api.h"

int freect(void)
{
	if( buf1 != NULL )
	free(buf1);
	if( buf2 != NULL )
	free(buf2);
	EXEC SQL ROLLBACK WORK RELEASE;
	if( fp!= NULL )
	fclose(fp);
/*	CloseErrLogObj();
*/	return(0);
}

/* the functions above are for PDYSSM and for PDYSSJ */

int mainfunction(char *arg,char *produce_err_str)
{	
	char tempstring[SHORT_NUM];
	char filename[SHORT_NUM];
	int typeflag;
	int flag;
	int CountYSSM;
	char cLine[MAX];
	long int YS_Len;
	int i,k;
	int retcode=0;
	char *PID = "Client Txn Clt_Mpt Process(Port 7111)";
	struct stZDYSSMDBRec stZDYSSMDB;
	struct stPDYSSMDBRec stPDYSSMDB;
	int m,n,count_zfj_zz,count_yssj_zz;
	char flag_ZXBF;
	int error_when_show_msg=0;	/*when this flag is 1, errlog will receive the message about error record*/

	m=0;n=0;
	flag_ZXBF='6';
	
	ERROR=0;
	signal(SIGTERM,freect);
	
	typeflag=InitPcsSnd_YS1();
	if(typeflag!=0)
	{
		ProcessError(LOG_ERROR,"PCS_Snd_YS1: Init error", END);
		return(-1);
	}
	
	fp = fopen( arg,"r" );
	if( fp == NULL )
	{
		ProcessError(LOG_ERROR,"PCS_Snd_YS1: Error in function cannot open ", arg);
		exec sql rollback work release;
		return(-1);
	}
	trimpath( arg,filename );
	
	for( CountYSSM=0;CountYSSM<MAX;CountYSSM++ )
	{
		flag=myapi_ReadALinefromF( cLine,fp );
		if( flag!=1 )
		{
			fclose(fp);
			ProcessError(LOG_ERROR,"PCS_Snd_YS1: Error when read a line from ",arg);
			exec sql rollback work release;
			return(-1);
		}
		if( cLine[0]=='X'&&cLine[1]=='0'&&cLine[2]=='X'&&cLine[3]=='0')
			break;
	}
	rewind(fp);
	buf1= (char *) malloc ((YSSM_LEN+1)*CountYSSM+1);
	if( buf1==NULL )
	{
		ProcessError(LOG_ERROR,"PCS_Snd_YS1: Error in function no space in memory",END);
		exec sql rollback work release;
		fclose(fp);
		return(-1);
	}
	flag=fread( buf1,sizeof(char),(YSSM_LEN+1)*CountYSSM,fp);
	if( flag!=(YSSM_LEN+1)*CountYSSM )
	{
		ProcessError(LOG_ERROR,"PCS_Snd_YS1: Error in function when fread yssm to buffer",END);
		exec sql rollback work release;
		free(buf1);
		fclose(fp);
		return(-1);
	}
	buf1[(YSSM_LEN+1)*CountYSSM]='\0';
	flag=myapi_ReadALinefromF(cLine,fp);
	if( flag!=1 )
	{
		ProcessError(LOG_ERROR,"PCS_Snd_YS1: Error when read a line from ", arg);
		exec sql rollback work release;
		free(buf1);
		fclose(fp);
		return(-1);
	}
	YS_Len= ftell(fp);
	
	fseek(fp,0,2);
	YS_Len=ftell(fp)-YS_Len;
	buf2= (char *)malloc(YS_Len+1);
	if( buf2==NULL )
	{
		ProcessError(LOG_ERROR,"PCS_Snd_YS1: no space in memory",END);
		exec sql rollback work release;
		free(buf1);
		fclose(fp);
		return(-1);
	}
	fseek(fp,(YSSM_LEN+1)*CountYSSM,0);
	flag=myapi_ReadALinefromF(cLine,fp);
	if( flag!=1 )
	{
		ProcessError(LOG_ERROR,"PCS_Snd_YS1: Error when read a line from ", arg);
		errorEndPcsSndYS1(buf1,buf2);
		fclose(fp);
		return(-1);
	}
	flag=fread(buf2,sizeof(char),YS_Len,fp);
	if( flag!=YS_Len )
	{
		ProcessError(LOG_ERROR,"PCS_Snd_YS1: Error when read string to buffer from ", arg);
		errorEndPcsSndYS1(buf1,buf2);
		fclose(fp);
		return(-1);
	}
	fclose(fp); /** modified in 2000.3 **/
	
	if( filename[1]=='Z' )
	{
		for( i=0;i<CountYSSM;i++ )
		{
			flag=myapi_ReadALine(cLine,buf1,&m);	
			if( flag!=1 )
			{
				ProcessError(LOG_ERROR,"PCS_Snd_YS1: Error when read a line from buffer",END);
				errorEndPcsSndYS1(buf1,buf2);
				return(-1);
			}
			tmp_fsxh=0;
			typeflag=ConvertZDYSSMFormat( cLine,filename,&stZDYSSMDB );
			if(typeflag!=0)
			{
				strcpy(produce_err_str,stZDYSSMDB.bkdh);
				ProcessError(LOG_ERROR,"PCS_Snd_YS1: Error when convert string to struct ", "stZDYSSMDB");
				errorEndPcsSndYS1(buf1,buf2);
				ProcessError(LOG_ERROR,"PCS_Snd_YS1: the error line is:",cLine);
				return(-1);
			}
			flag=myapi_ReadALine(cLine,buf2,&n);
			if( flag!=1 )
			{
				ProcessError(LOG_ERROR,"PCS_Snd_YS1: Error when read a line from buffer",END);
				errorEndPcsSndYS1(buf1,buf2);
				ProcessError(LOG_ERROR,"PCS_Snd_YS1: the error msg bkdh is :" ,stZDYSSMDB.bkdh);
				return(-1);
			}
			for( k=0;k<SHORT_NUM;k++ )
			{
				tempstring[k]=cLine[2+k];
				if( cLine[3+k]=='.')
				{
					tempstring[k+1]='\0';
					break;
				}
			}
			if(strcmp(tempstring,stZDYSSMDB.bkdh)!=0)
			{
				strcpy(produce_err_str,stZDYSSMDB.bkdh);
				ProcessError(LOG_ERROR,"PCS_Snd_YS1: Error yssj may be not corresponding with yssm",END);
				errorEndPcsSndYS1(buf1,buf2);
				ProcessError(LOG_ERROR,"PCS_Snd_YS1: the error msg bkdh is :" ,stZDYSSMDB.bkdh);
				return(-1);
			}
			
			CHECK_TOTAL_YSSJ=0;
			typeflag=ConvRecDBZDYS( cLine,stZDYSSMDB,buf2,filename,&n );
			if(typeflag!=0)
			{
				strcpy(produce_err_str,stZDYSSMDB.bkdh);
				ProcessError(LOG_ERROR,"PCS_Snd_YS1: Error when handle with zdyssm or zdyssj",END);
				errorEndPcsSndYS1(buf1,buf2);
				ProcessError(LOG_ERROR,"PCS_Snd_YS1: the error msg bkdh is :" ,stZDYSSMDB.bkdh);
				return(-1);
			}	
			count_zfj_zz=0;
			count_yssj_zz=0;
			if( stZDYSSMDB.yslx[0]=='1' ||stZDYSSMDB.yslx[0]=='7' )
			{
				EXEC SQL SELECT count(*) INTO :count_zfj_zz FROM t_zfj WHERE sjbh=t_bsbh.bsbh AND yxnf=:stZDYSSMDB.nf;
				EXEC SQL SELECT count(*) INTO :count_yssj_zz FROM t_fszdyssj WHERE fsxh=:stZDYSSMDB.xh;
			}
			if( ((stZDYSSMDB.dyzs+stZDYSSMDB.lszs)!=CHECK_TOTAL_YSSJ) || (count_zfj_zz!=count_yssj_zz) )
			{
				ProcessError(LOG_ERROR,"PCS_Snd_YS1: the dyzs is not equal to sum(yffs), please check it! ",END);
				EXEC SQL UPDATE t_fsrz SET sjzt=:flag_ZXBF WHERE fsxh=:tmp_fsxh;
			}
		}
		EndPcsSndYS1(buf1,buf2);	
		return(0);
	}
	else if ( filename[1]=='P' )
	{
		for( i=0;i<CountYSSM;i++ )
		{
			flag=myapi_ReadALine(cLine,buf1,&m);
			if( flag!=1 )
			{
				ProcessError(LOG_ERROR,"PCS_Snd_YS1: Error when read a line from buffer",END);
				errorEndPcsSndYS1(buf1,buf2);
				return(-1);
			}
			tmp_fsxh=0;
			typeflag=ConvertPDYSSMFormat( cLine,filename,&stPDYSSMDB );
			
			if(typeflag!=0)
			{
				strcpy(produce_err_str,stPDYSSMDB.bkdh);
				ProcessError(LOG_ERROR,"PCS_Snd_YS1: Error when convert string to struct ", "stPDYSSMDB");
				errorEndPcsSndYS1(buf1,buf2);
				ProcessError(LOG_ERROR,"PCS_Snd_YS1: the error line is:",cLine);
				return(-1);
			}
			flag=myapi_ReadALine(cLine,buf2,&n);
			if( flag!=1 )
			{
				ProcessError(LOG_ERROR,"PCS_Snd_YS1: Error when read a line from buffer",END);
				errorEndPcsSndYS1(buf1,buf2);
				ProcessError(LOG_ERROR,"PCS_Snd_YS1: the error msg bkdh is :" ,stPDYSSMDB.bkdh);
				return(-1);
			}
			tempstring[0]='\0';
			for( k=0;k<SHORT_NUM;k++ )
			{
				tempstring[k]=cLine[2+k];
				if( cLine[3+k]=='.')
				{
					tempstring[k+1]='\0';
					break;
				}
			}
			if(strcmp(tempstring,stPDYSSMDB.bkdh)!=0)
			{
				strcpy(produce_err_str,stPDYSSMDB.bkdh);
				ProcessError(LOG_ERROR,"PCS_Snd_YS1: Error yssj may be not corresponding with yssm",END);
				errorEndPcsSndYS1(buf1,buf2);
				ProcessError(LOG_ERROR,"PCS_Snd_YS1: the error msg bkdh is :" ,stPDYSSMDB.bkdh);
				return(-1);
			}
			
			CHECK_TOTAL_YSSJ=0;
			typeflag=ConvRecDBPDYS( cLine,stPDYSSMDB,buf2,filename,&n );
			if(typeflag!=0)
			{
				strcpy(produce_err_str,stPDYSSMDB.bkdh);
				ProcessError(LOG_ERROR,"PCS_Snd_YS1: Error when handle with pdyssm or pdyssj",END);
				errorEndPcsSndYS1(buf1,buf2);
				ProcessError(LOG_ERROR,"PCS_Snd_YS1: the error msg bkdh is :" ,stPDYSSMDB.bkdh);
				return(-1);
			}
			if( (stPDYSSMDB.dyzs+stPDYSSMDB.lszs)!=CHECK_TOTAL_YSSJ )
			{
				EXEC SQL UPDATE t_fsrz SET sjzt=:flag_ZXBF WHERE fsxh=:tmp_fsxh;
				ProcessError(LOG_ERROR,"PCS_Snd_YS1: the dyzs is not equal to sum(zjfs), please check it! ",END);
			}
		}
		EndPcsSndYS1(buf1,buf2);
		return(0);
	}
	else 
	{
		errorEndPcsSndYS1(buf1,buf2);
		ProcessError(LOG_ERROR,"PCS_Snd_YS1: the filename may be not right,it is :",filename);
		return(-1);
	}
	/* delete the temp YS file now */
}

void main(int argc,char *arg[])
{
	int flag=0;
	char tmpstr[100];
	char produce_err_str[10];
	if( argc < 2 )
	{
		ProcessError(LOG_ERROR,"PCS_Snd_YS1: Error in function tempfile needed",END);
		return;
	}

	strcpy(produce_err_str,"");
	YS_PC_INT=atoi(arg[2]);
	flag=mainfunction(arg[1],produce_err_str);
	if(flag!=0)
	{
		sprintf(tmpstr,"%s bkdh is %s",arg[1],produce_err_str);
		ProcessError(LOG_ERROR,"PCS_Snd_YS1: error msg may be given above, operator need check it and send the file again! the file is",tmpstr);
		sprintf(tmpstr,"mv %s %s",arg[1],"/usr/bkfx/data/rcv/backup/.");
		system(tmpstr);
	}
	else 
	{
		sprintf(tmpstr,"rm %s",arg[1]);
		system(tmpstr);
	}
	exit(0);
}

⌨️ 快捷键说明

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