📄 dial_stat.c
字号:
/****************************************************
* 一段时间内的呼损率的统计
*
* 最后修改: 周国祥 2001/08/23
****************************************************/
#include <curses.h>
#include "mytools.h"
#include "tool.h"
int dial_stat()
{
WINDOW *my_win;
char start_date[11], end_date[11];
char merchant_id[16], name[41], terminal_id[9];
char condition[300], buffer[300], filename[128];
long succ_times, fail_times, total_times;
double result;
int i;
sprintf(filename, "/tmp/.dial_stat.%d", getpid());
scr_dump(filename);
disp_below("EDC 呼损率");
h_prompt(LINES-1, 1, " < ESC 退出 > ", 0, 0);
h_prompt(LINES-1, 1, "EDC 呼损率", 0, 0);
my_win = newwin(19, 80, 3, 0);
mvwprintw(my_win, 0, 0, "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
wrefresh(my_win);
set_prompt(PROMPT_OFF);
getdatef(start_date, "");
strcpy(end_date, start_date);
mvwprintw(my_win, 2, 14, "日 期: [ ] 到 [ ]");
if (in_item(my_win, "", 2, 25, start_date, 8, NULL, NULL, 0, 0) !=
ENTER) goto end;
if (in_item(my_win, "", 2, 39, end_date, 8, NULL, NULL, 0, 0) !=
ENTER) goto end;
sprintf(condition, "chk_date >= \'%s\' and chk_date <= \'%s\'",
start_date, end_date);
merchant_id[0] = 0;
mvwprintw(my_win, 3, 14, "商户编号: [%15s] [%40s]", "", "");
if (in_item(my_win, "", 3, 25, merchant_id, 15, NULL, NULL, 0, 0) !=
ENTER) goto end;
i = get_merchant_name(merchant_id, name);
if (!is_blank_str(merchant_id) && i) {
h_winprompt(my_win, 17, 4, "无此商户编号!", 1, 0);
goto end;
}
mvwprintw(my_win, 3, 43, "%-40.40s", name);
terminal_id[0] = 0;
mvwprintw(my_win, 4, 14, "EDC 编号: [%8s] [%30s]", "", "");
if (in_item(my_win, "", 4, 25, terminal_id, 8, NULL, NULL, 0, 0) !=
ENTER) goto end;
i = get_terminal_name(terminal_id, name);
if (!is_blank_str(terminal_id) && i) {
h_winprompt(my_win, 17, 4, "无此 EDC 编号!", 1, 0);
goto end;
}
mvwprintw(my_win, 4, 36, "%-30.30s", name);
mvwprintw(my_win, 6, 14, "处理中, 请稍候 ...");
wrefresh(my_win);
if (!is_blank_str(merchant_id)) {
sprintf(buffer, " and merchant_id = \'%s\'", merchant_id);
strcat(condition, buffer);
}
if (!is_blank_str(terminal_id)) {
sprintf(buffer, " and terminal_id = \'%s\'", terminal_id);
strcat(condition, buffer);
}
sprintf(buffer, "select sum(succ_times) from dial_record where %s",
condition);
succ_times = calc_long(buffer);
sprintf(buffer, "select sum(fail_times) from dial_record where %s",
condition);
fail_times = calc_long(buffer);
total_times = succ_times + fail_times;
clear_wline(my_win, 6);
wrefresh(my_win);
mvwprintw(my_win, 8, 14, "拨号次数: %8ld", total_times);
if (total_times == 0) result = 100;
else result = 100 * (double) succ_times / total_times;
mvwprintw(my_win, 9, 14, "成功次数: %8ld 百分比: %6.2f%%",
succ_times, result);
result = 100 - result;
mvwprintw(my_win, 10, 14, "失败次数: %8ld 百分比: %6.2f%%",
fail_times, result);
wgetch(my_win);
end:
delwin(my_win);
scr_restore(filename);
unlink(filename);
return(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -