⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setparse.java

📁 SAP这个系统的一个转换器
💻 JAVA
字号:
package com.idoc.logic;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Vector;
import javax.swing.JOptionPane;
import com.idoc.face.InterfaceParse;
import com.idoc.util.Operate;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * <p>Title: IDOC Interface</p>
 * <p>Description: IDOC 转换器</p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: SiChuan XinHua</p>
 * @author zjc
 * @version 1.0
 */

/**
 *<p>套装商品解析类</p>
 */

public class SetParse
    implements InterfaceParse {

  Vector Tv = new Vector(); //容纳解析后拼装的欲插入中间数据库的sql语句
  public SetParse() {
  }

  /**
   *<p>parseData()方法解析idoc文件</p>
   */
  /**@todo Implement this com.idoc.face.InterfaceParse method*/
  public boolean parseData(File file) {
    Operate Operate1 = new Operate();
    int Count = 0; //记录idoc文件的行号
    String stype = ""; //容纳每一行idoc数据的字符串
    String FILIALE = ""; //门店号
    String SETNR = ""; //套装商品编码
    String SETNRBAK = ""; //上一次套装商品编码
    boolean flag = false;
    String ARTIKELNR = ""; //单一商品编码
    String MENGE = ""; //单一商品数量
    String AENDKENNZ = ""; //修改标识
    String Tsql = "";
    int modi = -1;
    BufferedReader br = null;
    InputStream bin = null;
    InputStreamReader ir = null;
    FileInputStream fis = null;
    boolean sflag = false;

    try {
      fis = new FileInputStream(file);
      byte[] buff = new byte[ (int) file.length()];
      int len = 0, pos = 0;
      while ( (len = fis.read(buff, pos, buff.length - pos)) > -1 &&
             pos < buff.length) {
        pos += len;
      }
      bin = new java.io.ByteArrayInputStream(buff);
      ir = new InputStreamReader(bin);
      br = new BufferedReader(ir);
      stype = new String();
      while ( (stype = br.readLine()) != null) {
        Count++;
        if (Count == 1) {
          stype = stype.substring(39, 69).trim();
          if (!stype.equals("WPDSET01")) {
            if (br != null)
              br.close();
            if (ir != null)
              ir.close();
            if (bin != null)
              bin.close();
            if (fis != null)
              fis.close();
            sflag = false;
          }
        }
        else {

          if (Operate1.getsubString(stype, 0, 30).equalsIgnoreCase("E2WPS01")) {
            FILIALE = Operate1.getsubString(stype, 69, 73);
            FILIALE = FILIALE.trim();
            AENDKENNZ = Operate1.getsubString(stype, 73, 77);
            AENDKENNZ = AENDKENNZ.trim();
            if (AENDKENNZ.equalsIgnoreCase("MODI")) {
              modi = 0;
            }
            else {
              modi = 1;
            }
            SETNR = Operate1.getsubString(stype, 103, 128);
            SETNR = SETNR.trim();
            if (SETNR.equalsIgnoreCase(SETNRBAK)) {
              flag = true;
              continue;
            }
            flag = false;
            SETNRBAK = SETNR;

          }
          if (Operate1.getsubString(stype, 0, 30).equalsIgnoreCase("E2WPS02")) {
            if (flag) {
              continue;
            }
            ARTIKELNR = Operate1.getsubString(stype, 63, 88);
            ARTIKELNR = ARTIKELNR.trim();
            MENGE = Operate1.getsubString(stype, 113, 123);
            MENGE = MENGE.trim();
            float imenge = 0;
            imenge = Float.parseFloat(MENGE);
            if ( (FILIALE.equalsIgnoreCase("")) || (SETNR.equalsIgnoreCase("")) ||
                (ARTIKELNR.equalsIgnoreCase(""))) {
              continue;
            }
            Tsql = "insert into T_SAPIN_SY_MASTER_SUIT(STORECODE,SUIT_CODE,SINGLE_CODE,SINGLE_QUAN,canuse_flag)"
                + "values('" + FILIALE + "','" + SETNR + "','" + ARTIKELNR +
                "'," + imenge + "," + modi + ") ";
            Tv.addElement(Tsql);
          }
        }
      }
      sflag = true;
    }
    catch (FileNotFoundException e) {
      e.printStackTrace();

    }
    catch (IOException e) {
      e.printStackTrace();

    }
    catch (Exception e) {
      e.printStackTrace();

    }
    finally {
      try {
        if (br != null)
          br.close();
        if (ir != null)
          ir.close();
        if (bin != null)
          bin.close();
        if (fis != null)
          fis.close();
        return flag;
      }
      catch (Exception ex) {
        System.out.println("Set' finally!");
        ex.printStackTrace();
        return false;
      }
    }
  }

  /**
   *<p>调TempTableDispose类的dealData()方法</p>
   *<p>处理解析出的数据并传入处理后须删除的文件</p>
   */
  public boolean disposeData(File file) {
    boolean flag1 = false;
    parseData(file);
    TempTableDispose TTDSET = new TempTableDispose();

    flag1 = TTDSET.disposeData(Tv, file, "set");
    return flag1;
  }
}

⌨️ 快捷键说明

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