📄 pcs_snd_yx1.pc
字号:
/********************************************************************************
* File Name : PCSSndYX1.pc *
* Module ID : MD_P05_01 *
* Module Name : PCSSNDYX1.pc *
* Purpose : Read YX file,write YX DB *
* Auther : lix *
* Date Created : 07/20/1999 *
* Version : Version 1.0 *
* Environment : OSF1 Compaq V4.0 (Alpha) *
* Portability : Unix platform *
* Warnings : *
* References : *
* Calling Syntax : *
* Parameters : *
* Returns : integer *
* 0 success *
* -1 failure *
* Calling Functions : *
* InitPCSSndYX1() *
* OpenYXFileForRead() *
* ReadYXFileForData() *
* getyxfilelen() *
* CreateSndLogAndHZRec() *
* UpdateSndLogStatus() *
* InsertSndYXDBRec() *
* InsertSndTMPDBRec() *
* Called Functions : Forked by PCSFileDepart.xx *
* Data Stores and Usages : *
* (a) Input : *
* (b) Output : T_FSRZ,T_HZ,T_FSYXSJ,T_ZCFSSJ *
* Report : none *
* Screens : none *
* Message Files : none *
* *
* Change Log : *
* Change No. Date Auther Reason for Change *
*******************************************************************************/
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <sqlca.h>
#include <sqlcpr.h>
#include <signal.h>
#include "/usr/bkfx/include/Pcs_Snd_YX1/cmYXStr.h"
#include "/usr/bkfx/include/Pcs_Snd_YX1/cmdef.h"
#include "/usr/bkfx/include/Pcs_Snd_YX1/Pcs_Snd_YX1.h"
#include "/usr/bkfx/include/Pcs_Snd_YX1/yx1api.h"
int freect(void)
{
if( fp!=NULL )
fclose(fp);
EXEC SQL ROLLBACK WORK RELEASE;
exit(0);
}
/* Usage : PCSSndYX1.x filename */
int mainfunction(char *arg)
{
long ptr;
char *charpoint;
char yx_Data[LEN_YX_REC];
struct stYXDBRec rec_YX_DB;
char *buf_data;
char datatype[2];
char rcv_province_code[3]="00\0";
char subtype[4];
char snd_city[3];
char fno[3];
long serial_no;
char status;
int flag,round_conl;
int gid=1,count=0;
float avrg;
int mod_y;
int retcode=0;
char *PID = "Client Txn Clt_Mpt Process(Port 7111)";
ERROR=0;
rtncode=0;
signal(SIGTERM,freect);
/* Get filename, subtype,snd_city,fno */
filename[0]='\0';
FILENAME[0]='\0';
strcpy(FILENAME,arg);
trimpath(FILENAME,filename);
charpoint = &filename[0];
charpoint+= 2;
strncpy(subtype,charpoint,3);
subtype[3] = '\0';
charpoint += 3;
strncpy(snd_city,charpoint,2);
snd_city[2]='\0';
charpoint += 3;
strncpy(fno,charpoint,2);
fno[2] = '\0';
status = FSRZ_UNDER_RCV;
datatype[0] = SJFL_YX;
datatype[1] = '\0';
flag=InitPCSSndYX1();
if( flag!=0 )
{
EXEC SQL ROLLBACK WORK RELEASE;
ProcessError(LOG_ERROR,"PCS_Snd_YX1: init error",END);
return(-1);
}
flag=OpenYXFileForRead();
if( flag!=0 )
{
EXEC SQL ROLLBACK WORK RELEASE;
ProcessError(LOG_ERROR,"PCS_Snd_YX1: open yx file error",END);
return(-1);
}
flag=CreateSndLogAndHZRec(&serial_no,datatype,rcv_province_code,status);
if( flag!=0 )
{
EXEC SQL ROLLBACK WORK RELEASE;
return(-1);
}
rec_YX_DB.serial_no = serial_no;
strcpy(rec_YX_DB.wjbh,fno);
strcpy(rec_YX_DB.yxxl,subtype);
/* Insert a record of T_FSYXSJ */
flag=InsertSndYXDBRec(rec_YX_DB);
if( flag!=0 )
{
EXEC SQL ROLLBACK WORK RELEASE;
ProcessError(LOG_ERROR,"PCS_Snd_YX1: insert yx record error",END);
return(-1);
}
EXEC SQL COMMIT WORK;
/* Get length of input YX file */
filelen = getyxfilelen();
total_zh= filelen/LEN_YX_REC;
if( total_zh>998 )
{
ProcessError(LOG_ERROR,"PCS_Snd_YX1: yx filelen is too long",END);
EXEC SQL ROLLBACK WORK RELEASE;
return(-1);
}
if( filelen > (total_zh*LEN_YX_REC) )
total_zh=total_zh+1;
/* A loop to read fixed length data from YX file and write to T_ZCFSSJ record */
rtncode = 1;
for ( ; ; )
{
round_conl=ReadYXFileData(yx_Data);
#ifdef DEBUG
PutintoF(yx_Data);
printf("yxdata len is %d\n",strlen(yx_Data));
#endif
ERROR=0;
flag=InsertSndTMPDBRec(serial_no,gid++,yx_Data);
if( flag!=0 )
{
EXEC SQL ROLLBACK WORK RELEASE;
ProcessError(LOG_ERROR,"PCS_Snd_YX1: insert yx data to t_zcfssj error",END);
fclose(fp);
return(-1);
}
if( round_conl )
break;
}
/* Update T_FSRZ with new status : waiting for send */
status = FSRZ_WAITFOR_SND;
UpdateSndLogStatus(serial_no, status);
EXEC SQL COMMIT WORK;
return(0);
}
void main(int argc,char *arg[])
{
char tmpstr[100];
int ret_code;
if (argc <= 1)
{
ProcessError(LOG_ERROR,"PCS_Snd_YX1: follow usage: program_name filename",END);
return;
}
YX_PC_INT=atoi(arg[2]);
ret_code=mainfunction(arg[1]);
if( ret_code!=0 )
{
ProcessError(LOG_ERROR,"PCS_SND_YX1: error found when put into database by file ", arg[1]);
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 + -