日本を来た初めてのプロジェクト

 初めてのプロジェクトはバッチ処理です、CSVファイルのデータをDBに書き込みします、DBのデータをCSVファイルに書き込みします。学到的一个重要东西是DAOGenerator,这是IBM自己的一个插件,对DAO的操作非常方便,最终能产生两种类型的数据集,List或Map型数据集。这样对数据库的操作就很容易。这次的项目最复杂的是把多个CSV文件中的数据写入一个表中。


import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/*
 * 作成日: 2006/12/13
 *
 *
 * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート
 */

/**
 * @author bsolZhang
 *
 *
 * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート
 */
public class Test {

    /**
     * <code>NUM_SRJKN_FRM_TXNKG</code> のコメント
     */
    private static final int NUM_SRJKN_FRM_TXNKG = 0;
    /**
     * <code>NUM_SRJKN_TO_TXNKG</code> のコメント
     */
    private static final int NUM_SRJKN_TO_TXNKG = 1;
    /**
     * <code>NUM_SRY</code> のコメント
     */
    private static final int NUM_SRY = 2;
    /**
     * <code>TM2030Map</code> のコメント
     */
    private static final TestBean TM2030Map = null;


    /**
     * @param args
     */
    public static void main(String[] args){
       
        int lCnt  = 0;
        int count = 0;
        int flag = 0;
        int lErrCntWrk = 0;
        String[][] iiSry = new String[5][3];
       
       
        String strKtrhcd = "";
        String strDokbn = "";
       
        TestBean tempMap =  null;
       
        TestBean testBean1 = new  TestBean("13","u","1","1","1");
        TestBean testBean2 = new  TestBean("13","u","2","2","2");
        TestBean testBean3 = new  TestBean("13","u","3","3","3");
        TestBean testBean4 = new  TestBean("14","u","4","4","4");
        TestBean testBean5 = new  TestBean("13","u","5","5","5");
        TestBean testBean6 = new  TestBean("13","u","6","6","6");
        TestBean testBean7 = new  TestBean("13","u","7","7","7");
        TestBean testBean11 = new  TestBean("13","u","11","11","11");
        TestBean testBean12 = new  TestBean("13","u","12","12","12");
        TestBean testBean13 = new  TestBean("13","u","13","13","13");
        TestBean testBean14 = new  TestBean("13","u","14","14","14");
        TestBean testBean15 = new  TestBean("13","u","15","15","15");
        TestBean testBean16 = new  TestBean("12","u","16","16","16");
        TestBean testBean17 = new  TestBean("13","u","17","17","17");
       
        List beforelist = new ArrayList();
       
        beforelist.add(testBean1);
        beforelist.add(testBean2);
        beforelist.add(testBean3);
        beforelist.add(testBean4);
        beforelist.add(testBean5);
        beforelist.add(testBean6);
        beforelist.add(testBean7);
        beforelist.add(testBean11);
        beforelist.add(testBean12);
        beforelist.add(testBean13);
        beforelist.add(testBean14);
        beforelist.add(testBean15);
        beforelist.add(testBean16);
        beforelist.add(testBean17);
       
        for (Iterator ite = beforelist.iterator(); ite.hasNext();
                        lCnt = lCnt + 1) {
            // データ取得
            TestBean TM2030Map = (TestBean) ite.next();
           
           
            //2.4.1. 前レコードとPK、処理区分を比較
            if ( lCnt == 0 || (strKtrhcd.equals(TM2030Map.getA())
                    && strDokbn.equals(TM2030Map.getB()))) {                   
               
                if(count == 5 || flag == 1){                   
                    lErrCntWrk = lErrCntWrk + 1;
                    System.out.println("エラー件数:" + lErrCntWrk);
                    flag = 1;
                    continue;
                }
               
                //----------------------------------------------------------
                //② 送料セット
                //----------------------------------------------------------         
                 //  送料条件FROM税抜金額
                iiSry[count][NUM_SRJKN_FRM_TXNKG]=(String)TM2030Map.getC();
                //  送料条件TO税抜金額
                iiSry[count][NUM_SRJKN_TO_TXNKG]=(String)TM2030Map.getD();                
                //  送料S
                iiSry[count][NUM_SRY]=(String)TM2030Map.getE();
               
                count = count + 1;
               
            }else{    
                if (flag == 0){
                    for (int i = count; i < 5; i++) {
                        //  送料条件FROM税抜金額
                        iiSry[i][NUM_SRJKN_FRM_TXNKG]=",";
                        //  送料条件TO税抜金額
                        iiSry[i][NUM_SRJKN_TO_TXNKG]=",";
                        //  送料
                        iiSry[i][NUM_SRY]=",";
                    }         
                    System.out.print((String) ((TestBean) tempMap).getA());
                    System.out.print((String) ((TestBean) tempMap).getB());
                    for (int i = 0; i < 5; i++) {
                        //  送料条件FROM税抜金額
                        System.out.print(iiSry[i][NUM_SRJKN_FRM_TXNKG]);
                        //  送料条件TO税抜金額
                        System.out.print(iiSry[i][NUM_SRJKN_TO_TXNKG]);
                        //  送料
                        System.out.print(iiSry[i][NUM_SRY]);
                    }               
                    System.out.println();
                }
                
                 //  送料条件FROM税抜金額
                iiSry[0][NUM_SRJKN_FRM_TXNKG]=(String)TM2030Map.getC();
                //  送料条件TO税抜金額
                iiSry[0][NUM_SRJKN_TO_TXNKG]=(String)TM2030Map.getD();                
                //  送料S
                iiSry[0][NUM_SRY]=(String)TM2030Map.getE();
                count = 1;
                flag = 0;                
            }
           
            tempMap =(TestBean) TM2030Map;           
            strKtrhcd = (String) ((TestBean) tempMap).getA();
            strDokbn  = (String) ((TestBean) tempMap).getB();

        }
         if (flag == 0){
             for (int i = count; i < 5; i++) {
                //  送料条件FROM税抜金額
                iiSry[i][NUM_SRJKN_FRM_TXNKG]=",";
                //  送料条件TO税抜金額
                iiSry[i][NUM_SRJKN_TO_TXNKG]=",";
                //  送料
                iiSry[i][NUM_SRY]=",";
            }         
            System.out.print((String) ((TestBean) tempMap).getA());
            System.out.print((String) ((TestBean) tempMap).getB());
            for (int i = 0; i < 5; i++) {
                //  送料条件FROM税抜金額
                System.out.print(iiSry[i][NUM_SRJKN_FRM_TXNKG]);
                //  送料条件TO税抜金額
                System.out.print(iiSry[i][NUM_SRJKN_TO_TXNKG]);
                //  送料
                System.out.print(iiSry[i][NUM_SRY]);
            }               
            System.out.println();
        }
}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值