cglfx.ec

来自「在SCO UNIX制定界面程序 可根据文件配制菜单,而不必修改源程序,非常方便」· EC 代码 · 共 230 行

EC
230
字号
/*******************************************************
 *	成功率分析
 *
 * 最后修改:	周国祥 2001/08/19
 * 最后修改:	Wubin 2001/09/04
 *******************************************************/
#include <curses.h>
#include <tool.h>
#include "mytools.h"
#include "analysis.h"
$include "db_struct.h";
$include sqlca;

/* another used by fkhfx.ec and sdhfx.ec (extern) */
struct {
	char	bankid[12];
	char	hostid[3];
	int	count;
	double	amount;
}	bankids[400];

double calc_double(char *);
int	cglfx ()
{
WINDOW	*my_win;
$char	sqlstr[400], sqlstr2[400];
$int	i, bank_num, succ_count, count, total_succ_count, total_count;
char    ddcount[20],dd_total_count[20],dd_total_succ_count[20];
char    dd_rest1[20],dd_rest2[20],dd_succ_count[20]; 
$short	indi;
$char	bankid[18], hostid[3], bankname[50];
double	succ_rate;
char	table[30], date1[15], date2[15], str[100];
char	in_date1[15], in_date2[15];
char	scr_dump_file[80];

    strcpy(audit_title, "成功率分析");
	sprintf( scr_dump_file, "/tmp/.screen_dump.%d", getpid() );
	scr_dump ( scr_dump_file );
	disp_below ( "成功率分析" );
	clear_wline ( stdscr, LINES-1 );
	h_prompt(LINES-1, 1, "                                                                 < ESC 退出 > ", 0, 0);
	h_prompt(LINES-1, 1, "成功率分析", 0, 0);
	my_win = newwin(19,80,3,0);
	mvwprintw(my_win,0,0,"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
	set_prompt(PROMPT_OFF);
	wrefresh(my_win);

	bank_num = succ_count = count = total_succ_count = total_count = 0;
	if ( get2date( my_win, 2, 20, in_date1, in_date2, table ) < 0 ) {
		delwin ( my_win );
		scr_restore ( scr_dump_file );
		unlink ( scr_dump_file );
		return ( -1 );
	}

	date2str(in_date1, date1, "");
	date2str(in_date2, date2, "");

	mvwprintw(my_win, 4, 22, "处理中, 请稍候 ...");
	wrefresh(my_win);

	sprintf(sqlstr,
		"select distinct iss_bank_id, count(*) \
		from his_tran_ls where iss_bank_id != \'VOID\' \
		and local_sys_date >= \'%s\' and local_sys_date <= \'%s\' \
		group by iss_bank_id ",
		date1, date2 );
	$prepare s_comm0 from $sqlstr;
	$declare cglfx_cur0 cursor for s_comm0;
	$open cglfx_cur0;
	if ( SQLCODE ) {
		errcall ( ERROR, "open cglfx_cur err[%d]",SQLCODE );
		delwin ( my_win );
		scr_restore ( scr_dump_file );
		unlink ( scr_dump_file );
		return ( -1 );
	}

	while ( bank_num < 400 ) {
		$fetch cglfx_cur0 into $bankid, $count:indi;
		if ( SQLCODE == SQLNOTFOUND )
			break;
		if ( SQLCODE ) {
			$close cglfx_cur0;
			errcall ( ERROR, "fetch cglfx_cur err[%d]",SQLCODE );
			delwin ( my_win );
			scr_restore ( scr_dump_file );
			unlink ( scr_dump_file );
			return ( -1 );
		}
		if ( indi != -1 && count ) {
			DelSpace(bankid);
			strcpy ( bankids[bank_num].bankid, bankid );
			strcpy ( bankids[bank_num].hostid, "00" );
			bankids[bank_num].count = count;
			bank_num ++;
		}
	}
	$close cglfx_cur0;

	sprintf(sqlstr,
		"select distinct iss_bank_id, count(*) \
		from cur_tran_ls where iss_bank_id != \'VOID\' \
		and local_sys_date >= \'%s\' and local_sys_date <= \'%s\' \
		group by iss_bank_id ",
		date1, date2 );
	$prepare s_comm1 from $sqlstr;
	$declare cglfx_cur1 cursor for s_comm1;
	$open cglfx_cur1;
	if ( SQLCODE ) {
		errcall ( ERROR, "open cglfx_cur1 err[%d]",SQLCODE );
		delwin ( my_win );
		scr_restore ( scr_dump_file );
		unlink ( scr_dump_file );
		return ( -1 );
	}

	while ( bank_num < 400 ) {
		$fetch cglfx_cur1 into $bankid, $count:indi;
		if ( SQLCODE == SQLNOTFOUND )
			break;
		if ( SQLCODE ) {
			$close cglfx_cur1;
			errcall ( ERROR, "fetch cglfx_cur err[%d]",SQLCODE );
			delwin ( my_win );
			scr_restore ( scr_dump_file );
			unlink ( scr_dump_file );
			return ( -1 );
		}
		if ( indi != -1 && count ) {
			DelSpace(bankid);
			for ( i=0; i<bank_num; i++ )
				if ( !strcmp ( bankids[i].bankid, bankid ) )
					break;
			if ( i >= bank_num ) {
				strcpy ( bankids[bank_num].bankid, bankid );
				strcpy ( bankids[bank_num].hostid, "00" );
				bankids[bank_num].count = count;
				bank_num ++;
			} else
				bankids[i].count += count;
		}
	}
	$close cglfx_cur1;

	sprintf(str,"%-7.7s%-18.18s%9s%9s%9s%9s",
	"发卡行","发卡行名称","成功笔数","失败笔数","总笔数","成功率");
	CreateList(16, 80, 6, 0, str);

     for ( i=0; i<bank_num; i++ ) {

	strcpy ( bankid, bankids[i].bankid );
	count = bankids[i].count;
	total_count += count;	/* total_count总笔数 count发卡行交易笔数*/

	/* 根据行号(没有主机号)取行名 in dbprg/bank.ec */
	get_bank_name1(bankid, bankname);

	sprintf(sqlstr2,
		"select count(*) from cur_tran_ls \
		where resp_code = \'00\' \
		and iss_bank_id = \'%s\' \
		and local_sys_date >= \'%s\' and local_sys_date <= \'%s\' ",
		bankid, date1, date2 );
	succ_count = query_count ( sqlstr2 );

	sprintf(sqlstr2,
		"select count(*) from his_tran_ls \
		where resp_code = \'00\' \
		and iss_bank_id = \'%s\' \
		and local_sys_date >= \'%s\' and local_sys_date <= \'%s\' ",
		bankid, date1, date2 );
	succ_count += query_count ( sqlstr2 );

	total_succ_count += succ_count;

	succ_rate = (double)succ_count*100/(double)(count);


/* add by dongyi */

        rtrim(bankname);
        mystruct.type=DDINT;
        mystruct.ddnum.intnum=succ_count;
        strcpy(dd_succ_count,add_demical(mystruct));
        mystruct.type=DDINT;
        mystruct.ddnum.intnum=count;
        strcpy(ddcount,add_demical(mystruct));
        mystruct.type=DDINT;
        mystruct.ddnum.intnum=count-succ_count;
        strcpy(dd_rest1,add_demical(mystruct));

/* add end */
	sprintf(str,"%-7.7s%-18.18s%9s%9s%9s  %6.2f%%",
		bankid,bankname,dd_succ_count,dd_rest1 ,
                ddcount,succ_rate);
	AddListItem( str, 0 );
    }

/* add by dongyi */
        mystruct.type=DDINT;
        mystruct.ddnum.intnum=total_count;
        strcpy(dd_total_count,add_demical(mystruct));
        mystruct.type=DDINT;
        mystruct.ddnum.intnum=total_succ_count;
        strcpy(dd_total_succ_count,add_demical(mystruct));
        mystruct.type=DDINT;
        mystruct.ddnum.intnum=total_count-total_succ_count;
        strcpy(dd_rest2,add_demical(mystruct));
/* add end */
	if ( total_count )
		succ_rate = (double)total_succ_count*100/(double)(total_count);
	else
		succ_rate = 100;
	AddListItem( " ", 0 );
	sprintf(str,"%-25s%9s%9s%9s  %6.2lf%%",
		"总计", dd_total_succ_count, dd_rest2,
		dd_total_count, succ_rate);
	AddListItem( str, 0 );
	h_wpromptr(stdscr, LINES-1, "上移: Home PgUp ↑ 下移: End PgDn ↓打印:CTRL_P  返回: ESC", 0, 0);
	DispList(0);
	FreeList();
	delwin ( my_win );
	clear_wline ( stdscr, LINES-1 );
	scr_restore ( scr_dump_file );
	unlink ( scr_dump_file );
	return ( 0 );
}

⌨️ 快捷键说明

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