/*
 *========================================================================
 *
 *   시스템명 : 요금징수 시스템
 *   파 일 명 : ft_basictbl.pc
 *   작 성 자 : 오효섭 (catacath@neighbor21.co.kr)
 *   작 성 일 : 2012.10.10
 *   수 정 일 :
 *   설    명 : 기초상태테이블의 파일/테이블간 변환처리
 *
 *========================================================================
*/

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>

#include "bas_tbl.h"
#include "lane_stat_info.h"
#include "chg_struc.h"
#include "file_nm.h"
#include "file_no.h"
#include "dir_path.h"
#include "ora_sql.h"
#include "ipc_def.h"
#include "file_lb.h"
#include "tcs_db_def.h"
#include "hr_dc_extr.h"

static    struct    write_info         wi;
static    struct    bas_tbl         bas_tbl_f;
static    struct    hr_dc_extr_tbl  hr_dc_extr_tbl_f;
static    T_REVM_BASICINFO       revm_basicinfo;
static    T_REVM_LANEINFO        revm_laneinfo;
static    T_REVM_CARDRATE        revm_cardrate;
static    T_REVM_TABLENO         revm_tableno;
static    T_REVM_SCRATECAR       revm_scratecar;
static    T_REVM_RATE            revm_rate;
static    T_EXTM_LSAMMAXMIN      extm_lsammaxmin;
static    T_EXTM_LOADRATE        extm_loadrate;
static    T_EXTM_LOADMAX         extm_loadmax;
static    T_PUBM_DCCARTYPE       pubm_dccartype;
static    T_REVM_OBURATE         revm_oburate;
static    T_REVM_FAREINFO        revm_fareinfo;

int main()
{
    int     isfd, isrc;
    int     ii, jj, kk, mm;
    struct  lo_lane_ctrl_cmd   llcc;                /* 제어요청 info        */
    struct  lo_lane_ctrl_reply   llcr;                /* 제어반환 info        */
    char    path[128];
    char    temp[3+1];
    char    msg[128];
    char    plz_id[4];

    memset(&hr_dc_extr_tbl_f, 0, sizeof(struct hr_dc_extr_tbl));

    isfd = lb_fopen(&wi, FNO_HR_DC_EXTR_TBL, FINPUT+FC_MANULOCK);
    if(isfd < 0)
    {
        printf("open error\n");
        exit(0);
    }

    ii=0;
    jj=0;
    kk=0;
    mm=0;
    if (isfd > 0)
    {
            isrc = lb_fread(isfd, FNO_HR_DC_EXTR_TBL, &hr_dc_extr_tbl_f);
			if(isrc<0) exit(0);

            printf("영업소명 : [%.03s]\n", hr_dc_extr_tbl_f.plz_id);
			printf("시간별 할인제도 적용일자 : %04d/%02d/%02d\n", hr_dc_extr_tbl_f.hr_dc_apl_year, hr_dc_extr_tbl_f.hr_dc_apl_mon, hr_dc_extr_tbl_f.hr_dc_apl_day);
			printf("신정보 적용일시 : %04d/%02d/%02d %02d:%02d\n", hr_dc_extr_tbl_f.nw_apl_year, hr_dc_extr_tbl_f.nw_apl_mon, hr_dc_extr_tbl_f.nw_apl_day, hr_dc_extr_tbl_f.nw_apl_hr, hr_dc_extr_tbl_f.nw_apl_min);
			printf("지불매체별 제도적용여부(현금) : %d\n", hr_dc_extr_tbl_f.pay_media_csh_ecrd1);
			printf("지불매체별 제도적용여부(전자카드) : %d\n", hr_dc_extr_tbl_f.pay_media_tcrd_rsv1);
			printf("지불매체별 제도적용여부(교통카드) : %d\n", hr_dc_extr_tbl_f.pay_media_csh_ecrd2);
			printf("지불매체별 제도적용여부(예비) : %d\n", hr_dc_extr_tbl_f.pay_media_tcrd_rsv2);

            for (ii = 0; ii < 4 ; ii++)
            {
                for(jj = 0; jj < 12; jj++)
                {
					printf("=============신정보%d=============\n", jj);
					printf("할인 시작시간 : %02d:%02d\n", hr_dc_extr_tbl_f.new_dcinfo[ii][jj].dc_div[0].dc_hr, hr_dc_extr_tbl_f.new_dcinfo[ii][jj].dc_div[0].dc_min);
					printf("할인 종료시간 : %02d:%02d\n", hr_dc_extr_tbl_f.new_dcinfo[ii][jj].dc_div[1].dc_hr, hr_dc_extr_tbl_f.new_dcinfo[ii][jj].dc_div[1].dc_min);
					for(kk=0; kk<8; kk++)
					{
						printf("할인율 차종%d : %d\n", kk+1, hr_dc_extr_tbl_f.new_dcinfo[ii][jj].dcrte[kk]);
					}
                }
            }
            for (ii = 0; ii < 4 ; ii++)
            {
                for(jj = 0; jj < 12; jj++)
                {
					printf("=============구정보%d==============\n", jj);
					printf("할인 시작시간 : %02d:%02d\n", hr_dc_extr_tbl_f.old_dcinfo[ii][jj].dc_div[0].dc_hr, hr_dc_extr_tbl_f.old_dcinfo[ii][jj].dc_div[0].dc_min);
					printf("할인 종료시간 : %02d:%02d\n", hr_dc_extr_tbl_f.old_dcinfo[ii][jj].dc_div[1].dc_hr, hr_dc_extr_tbl_f.old_dcinfo[ii][jj].dc_div[1].dc_min);
					for(kk=0; kk<8; kk++)
					{
						printf("할인율 차종%d : %d\n", kk+1, hr_dc_extr_tbl_f.old_dcinfo[ii][jj].dcrte[kk]);
					}
                }
            }

    }
    lb_close(isfd);
}
