Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
17 kB
1
Indexable
Never
package bank.FileAnalyser;

import bank.Beans.DataBeans;
import bank.CardsCalculSimu.Calculation;
import bank.Commission.GridCommision;
import bank.Commission.LoadCommision;
import bank.Setting.Prop;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;

import java.io.File;
import java.io.FileReader;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.input.SAXBuilder;

public class Splitter {

    String[] path;
    int[] Template;
     Prop _Prop =  new Prop();

    public Splitter(String[] fileName, boolean Backup) throws Exception {       
        init(fileName, Backup);
    }

    public Splitter(String fileName, boolean Backup) throws Exception {
        path = new String[]{fileName};
        init(path, Backup);
    }

    private void init(String[] fileName, boolean Backup) throws Exception {
        path = new String[fileName.length];
        Template = new int[fileName.length];
        System.out.println("Template Size: "+fileName[0]);

        for (int i = 0; i < fileName.length; i++) {
            path[i] = fullfilePath(fileName[i], Backup);
        }
    }

    private String fullfilePath(String fileName, boolean Backup) throws Exception {
        if (Backup) {
            return new fileSeeker(
                    _Prop.getPath(),
                    fileName,
                    _Prop.getPath2()).NewfileXMLNameFromBackup();
        } else {
            
         
            
            return new fileSeeker(
                    _Prop.getPath(),
                    fileName,
                    _Prop.getPath2()).NewfileXMLName();
        }

    }

    public int[] ShowAdvancedRort() {
        return this.Template;
    }

    public List<DataBeans> XMLReader() throws Exception {
        List<DataBeans> listjrbean = new LinkedList<DataBeans>();

        for (int i = 0; i < path.length; i++) {
            listjrbean.add(XMLReader(path[i], i));
        }
        return listjrbean;
    }

    public DataBeans XMLReader(String FileName, int index) throws Exception {

        // Load File ...................
        //   String data="<root>";
        String data = "";
        String eachLine = "";

        File f = new File(FileName);
        FileReader fr = new FileReader(f);
        BufferedReader br = new BufferedReader(fr);

        eachLine = br.readLine();
        while (eachLine != null) {
            data += eachLine.toString();
            eachLine = br.readLine();
        }
        // data+="</root>"  ;

        br.close();
        fr.close();

        data.replace('ý', ';');

        // define Fields .......................
        HashMap<String, String> values = new HashMap<String, String>();

        SAXBuilder builder = new SAXBuilder();
        Document document = builder.build(new ByteArrayInputStream(data.getBytes()));
        Element root = document.getRootElement();

        List rows = root.getChildren("xmlTransaction");
        for (int i = 0; i < rows.size(); i++) {
            Element row = (Element) rows.get(i);

            List transactionId = row.getChildren("transactionId");
            Element txnId = (Element) transactionId.get(0);
            String _transactionId = txnId.getText();

            values.put("transactionId", _transactionId);

            List columns = row.getChildren("field");
            int count = 0;

            for (int j = 0; j < columns.size(); j++) {
                Element column = (Element) columns.get(j);
                String key = RemoveNull(column.getAttribute("name").getValue());

                key = key.replace('.', '_');

                String value = RemoveNull(column.getText());

                if (key.equals("LOCAL_REF")) {

                    if (values.containsKey("LOCAL_REF")) {
                        values.put(key + "_" + count, value);
                        count++;
                        continue;
                    }

                    // normal one
                    values.put(key, value);
                    count++;
                    continue;

                }

                if (values.containsKey(key)) {
                    values.put(key, values.get(key) + ", " + value);
                    continue;
                }
                values.put(key, value);

            }
        }

        return fillData(values, index);
    }

    /**
     * Remove Null spaces
     *
     * @param value
     * @return
     */
    private String RemoveNull(String value) {

        if (value == null && value.length() == 0) {
            return " ";
        }
        return value.trim();
    }

    private DataBeans fillData(HashMap<String, String> map, int index) {

        DataBeans MyData = new DataBeans();

        MyData.setFATHER_NAME(map.get("FATHER_NAME"));
        MyData.setCU_TITLE(map.get("CU_TITLE"));
        MyData.setCU_FULL_NAME(map.get("CU_FULL_NAME"));
        MyData.setGENDER(map.get("GENDER"));
        MyData.setMOTHER_NAME(map.get("MOTHER_NAME"));
        MyData.setCU_DATE_OF_BIRTH(map.get("CU_DATE_OF_BIRTH"));
        MyData.setCU_NATIONALITY(map.get("CU_NATIONALITY"));
        MyData.setPASSPORT(map.get("PASSPORT"));
        MyData.setCIVIL_NO_TOWN(map.get("CIVIL_NO_TOWN"));
        MyData.setBIRTH_PLACE(map.get("BIRTH_PLACE"));
        MyData.setEDUCATION(map.get("EDUCATION"));
        MyData.setMARITAL_STAT(map.get("MARITAL_STAT"));
        MyData.setNO_DEPEN(map.get("NO_DEPEN"));
        MyData.setNO_CHILD(map.get("NO_CHILD"));
        MyData.setRES_STREET(map.get("RES_STREET"));
        MyData.setRES_CITY(map.get("RES_CITY"));
        MyData.setRES_LAND_MARK(map.get("RES_LAND_MARK"));
        MyData.setRES_TEL(map.get("RES_TEL"));
        MyData.setRES_MOB(map.get("RES_MOB"));
        MyData.setEMAIL(map.get("EMAIL"));
        MyData.setRES_MAIL_BOX(map.get("RES_MAIL_BOX"));
        MyData.setCOMP_NME(map.get("COMP_NME"));
        MyData.setCO_BUILDING_NAME(map.get("CO_BUILDING_NAME"));
        MyData.setCO_STREET_NME(map.get("CO_STREET_NME"));
        MyData.setCO_CITY(map.get("CO_CITY"));
        MyData.setCO_COUNTRY(map.get("CO_COUNTRY"));
        MyData.setCO_LANDMARK(map.get("CO_LANDMARK"));
        MyData.setOFFICE_TEL1(map.get("OFFICE_TEL1"));
        MyData.setOFFICE_TEL_2(map.get("OFFICE_TEL_2"));
        MyData.setO_FAX(map.get("O_FAX"));
        MyData.setO_PO_BOX(map.get("O_PO_BOX"));
        MyData.setEMPL_STATUS(map.get("EMPL_STATUS"));
        MyData.setLINE_OF_BUSINESS(map.get("LINE_OF_BUSINESS"));
        MyData.setMNTLY_FIXED_SAL(map.get("MNTLY_FIXED_SAL"));
        MyData.setOTHR_INCOME(map.get("OTHR_INCOME"));
        MyData.setSPOUSE_NAME(map.get("SPOUSE_NAME"));
        MyData.setNET_MNTLY_INCOME(map.get("NET_MNTLY_INCOME"));
        MyData.setOTHER_BANK_CODE(map.get("OTHER_BANK_CODE"));
        MyData.setMAIN_CARD(map.get("MAIN_CARD"));
        MyData.setCUSTOMER(map.get("CUSTOMER"));
        MyData.setTITLE(map.get("TITLE"));
        MyData.setDATE_OF_BIRTH(map.get("DATE_OF_BIRTH"));
        MyData.setNAME_ON_CARD(map.get("NAME_ON_CARD"));
        MyData.setNATIONALITY(map.get("NATIONALITY"));
        MyData.setFULL_NAME(map.get("FULL_NAME"));
        MyData.setRELATIONSHIP(map.get("RELATIONSHIP"));
        MyData.setMAIN_CA(map.get("MAIN_CA"));
        MyData.setCARD_PRODUCT_TYPE(map.get("CARD_PRODUCT_TYPE"));
        MyData.setCARD_TYPE(map.get("CARD_TYPE"));
        MyData.setCARD_PROD_DEF(map.get("CARD_PROD_DEF"));

        MyData.setLIMIT_REQUESTED(map.get("LIMIT_REQUESTED"));
        MyData.setMNTLY_PYMT_MTD(map.get("MNTLY_PYMT_MTD"));
        MyData.setEMBOSS_LINE_1(map.get("EMBOSS_LINE_1"));
        MyData.setEMBOSS_LINE_2(map.get("EMBOSS_LINE_2"));
        MyData.setHOUSE_NO_FLOOR_NO(map.get("HOUSE_NO_FLOOR_NO"));
        MyData.setBUILDING_NAME(map.get("BUILDING_NAME"));
        MyData.setYRS_AT_CUR_ADR(map.get("YRS_AT_CUR_ADR"));
        MyData.setRESIDENCE_TYPE(map.get("RESIDENCE_TYPE"));
        MyData.setLEGAL_FORM(map.get("LEGAL_FORM"));
        MyData.setAPT_NO_FLOOR(map.get("APT_NO_FLOOR"));
        MyData.setJOB_TITL_DSG(map.get("JOB_TITL_DSG"));
        MyData.setYRS_IN_CUR_JOB(map.get("YRS_IN_CUR_JOB"));
        MyData.setSINCE(map.get("SINCE"));
        MyData.setTOTAL_YEARS_OF_EXP(map.get("TOTAL_YEARS_OF_EXP"));
        MyData.setSALARY_DOMICILATED(map.get("SALARY_DOMICILATED"));
        MyData.setCOMPANY_NAME(map.get("COMPANY_NAME"));
        MyData.setYRS_IN_PRV_JOB(map.get("YRS_IN_PRV_JOB"));
        MyData.setSINCE_IN_YEARS(map.get("SINCE_IN_YEARS"));
        MyData.setDESIGNATION(map.get("DESIGNATION"));
        MyData.setNATURE_OF_BUSINESS(map.get("NATURE_OF_BUSINESS"));
        MyData.setCMP_WR_SPOUS_WRK(map.get("CMP_WR_SPOUS_WRK"));
        MyData.setOCCUP_POS(map.get("OCCUP_POS"));
        MyData.setYRS_OF_EMPYMNT(map.get("YRS_OF_EMPYMNT"));
        MyData.setBUSINESS_NATURE(map.get("BUSINESS_NATURE"));
        MyData.setSPOUS_TOT_MNT_PMS(map.get("SPOUS_TOT_MNT_PMS"));
        MyData.setACCOUNT_NO(map.get("ACCOUNT_NO"));
        MyData.setOTHER_BANK_REF(map.get("OTHER_BANK_REF"));
        MyData.setYRS_WITH_BANK(map.get("YRS_WITH_BANK"));
        MyData.setYOUR_LIABILITIES(map.get("YOUR_LIABILITIES"));
        MyData.setLOAN_TYPE(map.get("LOAN_TYPE"));
        MyData.setBNK_CMP_NME(map.get("BNK_CMP_NME"));
        MyData.setLOAN_AMOUNT(map.get("LOAN_AMOUNT"));
        MyData.setMNT_ISTLMT(map.get("MNT_ISTLMT"));
        MyData.setREM_ISTLMT(map.get("REM_ISTLMT"));
        MyData.setCR_BANK_NAME(map.get("CR_BANK_NAME"));
        MyData.setCR_TYPE(map.get("CR_TYPE"));
        MyData.setCR_PAYMENT(map.get("CR_PAYMENT"));
        MyData.setCR_LIMIT(map.get("CR_LIMIT"));
        MyData.setCR_OUT_BAL(map.get("CR_OUT_BAL"));
        MyData.setNATURE_OF_ASSET(map.get("NATURE_OF_ASSET"));
        MyData.setOWNERSHIP(map.get("OWNERSHIP"));
        MyData.setVALUE(map.get("VALUE"));
        MyData.setMAIL_ADDRESS(map.get("MAIL_ADDRESS"));
        MyData.setGSM_NO(map.get("GSM_NO"));
        MyData.setPIC_BE_DISPLD(map.get("PIC_BE_DISPLD"));
        MyData.setPIC_RECEIVED(map.get("PIC_RECEIVED"));
        MyData.setCPY_ID_PASPRT(map.get("CPY_ID_PASPRT"));
        MyData.setEMPLOYMENT_LETTER(map.get("EMPLOYMENT_LETTER"));
        MyData.setPROOF_OF_RESIDENCE(map.get("PROOF_OF_RESIDENCE"));
        MyData.setCOPY_OF_CAR_REG(map.get("COPY_OF_CAR_REG"));
        MyData.setCARD_COND_SET(map.get("CARD_COND_SET"), map.get("CARD_COND_SET_DESC"));
        MyData.setCARD_ACCT_NUMBER(map.get("CARD_ACCT_NUMBER"));
        MyData.setCRD_APPRV_RSN(map.get("CRD_APPRV_RSN"));
        MyData.setCARD_STATUS(map.get("CARD_STATUS"));
        MyData.setCSC_ACCT_NO(map.get("CSC_ACCT_NO"));
        MyData.setCARD_NUMBER(map.get("CARD_NUMBER"));
        MyData.setINST_NUMBER(map.get("INST_NUMBER"));
        MyData.setCARD_EXP_DATE(map.get("CARD_EXP_DATE"));
        MyData.setPARNT_CLNT_NO(map.get("PARNT_CLNT_NO"));
        MyData.setCONTRACT_REF(map.get("CONTRACT_REF"));
        MyData.setCARD_CSC_STATUS(map.get("CARD_CSC_STATUS"));
        MyData.setCARD_EVENT(map.get("CARD_EVENT"));
        MyData.setLIMIT_ID(map.get("LIMIT_ID"));
        MyData.setLCKD_AMNT_ID(map.get("LCKD_AMNT_ID"));
        MyData.setLCKD_AMNT(map.get("LCKD_AMNT"));
        MyData.setNO_SUPPL_CARD(map.get("NO_SUPPL_CARD"));
        MyData.setBRANCH_NO(map.get("BRANCH_NO"));
        MyData.setSAL_DOM_BNK(map.get("SAL_DOM_BNK"));
        MyData.setSAL_DOM_BRCH(map.get("SAL_DOM_BRCH"));
        MyData.setCARD_MDFY_DTE(map.get("CARD_MDFY_DTE"));
        MyData.setLOCAL_REF(map.get("LOCAL_REF"));
        MyData.setRECORD_STATUS(map.get("RECORD_STATUS"));
        MyData.setCURR_NO(map.get("CURR_NO"));
        MyData.setINPUTTER(map.get("INPUTTER"));
        MyData.setDATE_TIME(map.get("DATE_TIME"));
        MyData.setAUTHORISER(map.get("AUTHORISER"));
        MyData.setCO_CODE(map.get("CO_CODE"));
        MyData.setDEPT_CODE(map.get("DEPT_CODE"));

        MyData.setLOCAL_REF_1(map.get("LOCAL_REF_1"));
        MyData.setLOCAL_REF_2(map.get("LOCAL_REF_2"));
        MyData.setLOCAL_REF_3(map.get("LOCAL_REF_3"));

        MyData.setLOCAL_REF_4(map.get("LOCAL_REF_4"));
        MyData.setLOCAL_REF_5(map.get("LOCAL_REF_5"));
        MyData.setLOCAL_REF_6(map.get("LOCAL_REF_6"));

        MyData.setLOCAL_REF_7(map.get("LOCAL_REF_7"));
        MyData.setLOCAL_REF_8(map.get("LOCAL_REF_8"));
        MyData.setLOCAL_REF_9(map.get("LOCAL_REF_9"));

        MyData.setCAxxxxxxxxxx(map.get("CAxxxxxxxxxx"));
        MyData.setTransactionId(map.get("transactionId"));

        MyData.setCARD_PRICE(map.get("CARD_PRICE"));

        MyData.setHLDR_FATHER(map.get("HLDR_FATHER"));
        MyData.setCRDHLDR_DOB(map.get("CRDHLDR_DOB"));

        MyData.setCMO_STATUS(map.get("CMO_STATUS"));
        MyData.setCMO_GSM(map.get("CMO_GSM"));
        MyData.setTAG_STATUS(map.get("TAG_STATUS"));

        // ------ ------ Load  Commision values Section -------------------
        MyData.setCARD_PROD_DEF_CODE(map.get("CARD_PROD_DEF_CODE"));
        LoadCommision ls = new LoadCommision();
        GridCommision _GridCommision;
        try {
            
         MyData =  byPassForConditions_Excel(MyData);
            
            _GridCommision = ls.getFor(MyData.getCARD_PROD_DEF_CODE(),
                    MyData.getCARD_COND_SET());
        } catch (Exception ex) {
            _GridCommision = new GridCommision();
        }

        MyData.setGLOBUS_DEF(_GridCommision.getGLOBUS_DEF());
        MyData.setBYBLOS_BANK_CREDIT_CARDS(_GridCommision.getBYBLOS_BANK_CREDIT_CARDS());
        MyData.setCASH_WITHDRAWAL_COMMISSION_ON_ATM(_GridCommision.getCASH_WITHDRAWAL_COMMISSION_ON_ATM());
        MyData.setCARD_RENEWAL_FEE(_GridCommision.getCARD_RENEWAL_FEE());
        MyData.setCARD_REPLA_ISSUANCE_FEE(_GridCommision.getCARD_REPLA_ISSUANCE_FEE());
        MyData.setPIN_REPLACEMENT_REISSUANCE_FEE(_GridCommision.getPIN_REPLACEMENT_REISSUANCE_FEE());
        MyData.setLATE_PAYMENT_FEE_PER_MONTH(_GridCommision.getLATE_PAYMENT_FEE_PER_MONTH());
        MyData.setOVERLIMIT_FEE(_GridCommision.getOVERLIMIT_FEE());
        MyData.setFOREX_MARKUP(_GridCommision.getFOREX_MARKUP());
        MyData.setSMS_FEE(_GridCommision.getSMS_FEE());

        MyData.setBYBLOS_BANK_CREDIT_CARDS_AR(_GridCommision.getBYBLOS_BANK_CREDIT_CARDS_AR());
        MyData.setCASH_WITHDRAWAL_COMMISSION_ON_ATM_AR(_GridCommision.getCASH_WITHDRAWAL_COMMISSION_ON_ATM_AR());
        MyData.setCARD_RENEWAL_FEE_AR(_GridCommision.getCARD_RENEWAL_FEE_AR());
        MyData.setCARD_REPLA_ISSUANCE_FEE_AR(_GridCommision.getCARD_REPLA_ISSUANCE_FEE_AR());
        MyData.setPIN_REPLACEMENT_REISSUANCE_FEE_AR(_GridCommision.getPIN_REPLACEMENT_REISSUANCE_FEE_AR());
        MyData.setLATE_PAYMENT_FEE_PER_MONTH_AR(_GridCommision.getLATE_PAYMENT_FEE_PER_MONTH_AR());
        MyData.setOVERLIMIT_FEE_AR(_GridCommision.getOVERLIMIT_FEE_AR());
        MyData.setFOREX_MARKUP_AR(_GridCommision.getFOREX_MARKUP_AR());
        MyData.setSMS_FEE_AR(_GridCommision.getSMS_FEE_AR());
        // ------ END ------ Load  Commision values Section -------------------

        MyData.Reformat();

        this.Template[index] = 0;

        if ((map.get("CARD_PROD_DEF") != null)
                && (map.get("CARD_PRICE") != null)
                && (map.get("INT_POS") != null)
                && (map.get("INT_ATM") != null)
                && (map.get("PER_POS") != null)
                && (map.get("LIMIT_REQUESTED") != null)
                && (map.get("MNTLY_PYMT_MTD") != null)
                && (map.get("MIN_PAYMNT") != null)
                && (map.get("ACCT_MNT") != null)
                && (map.get("CASH_TRF_FEE") != null)) {

            if (map.get("CARD_PRODUCT_TYPE").trim().equals("REVO")) {

                if (map.get("MNTLY_PYMT_MTD") != null
                        && map.get("MNTLY_PYMT_MTD").trim().equals("100%")) {
                    MyData = new Calculation(MyData, map).Calculate2();
                    this.Template[index] = 2;
                } else if (map.get("MNTLY_PYMT_MTD") != null
                        && map.get("MNTLY_PYMT_MTD").contains("%")) {
                    MyData = new Calculation(MyData, map).Calculate();
                    this.Template[index] = 1;
                } else {
                    this.Template[index] = 0;
                }
            }

            if (map.get("MNTLY_PYMT_MTD") != null
                    && map.get("CARD_PRODUCT_TYPE").trim().equals("CHAR")) {
                MyData = new Calculation(MyData, map).Calculate3();
                this.Template[index] = 3;
            }

        }
        return MyData;
    }
    
    
    private  DataBeans byPassForConditions_Excel(DataBeans MyData) {
        if(!MyData.getCARD_PROD_DEF_CODE().trim().equals("0004")){
         MyData.setCARD_COND_SET("","");          
        }
        
    return MyData;}
}
Leave a Comment