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

📄 salesidoc.java

📁 SAP这个系统的一个转换器
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
      }
      boolean f = false;
      boolean suflag = false;
      str = UpDataDispase1.getSyInfo("sales");

      for (int j = 0; j < str.length; j++) {
        try {
          store = str[j][0];
          time = str[j][1];
          endtimebak = time;
          maxtime = null;
          if (time == null || time.equalsIgnoreCase("null") ||
              time.equalsIgnoreCase("")) {
            time = String.valueOf( (int) (Math.random() * 1000));
          }
        }
        catch (Exception e) {
          System.out.println("store,或time " + e.toString());
        }
        maxtime = UpDataDispase1.getMaxTime(store, "SAPOUT_D_SALE_INFO"); // 中间表的最大时间戳
        if (maxtime == null || maxtime.equalsIgnoreCase("null") ||
            maxtime.equalsIgnoreCase("")) {
          continue;
        }
        if (maxtime.equalsIgnoreCase(endtimebak)) {
          continue;
        }
        if (UpDataDispase1.insertSyInfo("sales", store, endtimebak, maxtime) >
            -1) {
          try {
            if (getData(store, endtimebak, maxtime)) {
              f = buildIDOC();
              try {
                if (f) {
                  suflag = UpDataDispase1.deleteData(store, endtimebak, maxtime,
                      Tvserialno);
                }
              }
              catch (Exception e) {
                System.out.println("SalesIDOC's disposeIDOC!");
                e.printStackTrace();
              }
            }
          }
          catch (Exception ex) {
            System.out.println("SalesIDOC's disposeIDOC is Error!");
            ex.printStackTrace();
          }
          finally {
            close();
          }
        }
//        System.out.println("end... SalesIDOCdisposeIDOC = " + j+"--------" + runtime.freeMemory() + " -- > " + runtime.availableProcessors());
      }
      disposeNotFilished();
      UpDataDispase1.delSyInfo("sales");
    }
    catch (Exception ex) {
      System.out.println("SalesIDOC's disposeIDOC is Error!");
      ex.printStackTrace();
    }
    finally {
      close();
      closeconn(conn);
    }
  }

//job是idoc表示只共享目录数据在sap中转成idoc,trigger则是既转成idoc又调任务
  public boolean writeidoc(String job) {
    boolean f = false;
    Vector log_vec2 = new Vector();
    String idoc_message = null;
    num++;
    if (Tv.size() > 0) {
      f = writeSAP.writeTxtData(Tv, "sales" + time + num + ".txt", "sales");
      log_vec2.add(0, store);
      log_vec2.add(1, "sales" + endtimebak);
      log_vec2.add(2, "sales" + time + num + ".txt");
      log_vec2.add(3, "sales");
      log_vec2.add(4, "");
      log_vec2.add(5, "in");
      log_vec2.add(6, "销售上传文件生成失败!");
      log_vec2.add(7, "getDate()");
      log_vec2.add(8, "1"); //String.valueOf(i));
      log_vec2.add(9, "0");
      log_vec2.add(10, "0");
      if (f) {
        log_vec2.setElementAt("1", 9);
        log_vec2.setElementAt("销售上传文件生成成功!", 6);
        try {
          log.WriteLog(log_vec2);
        }
        catch (Exception ex) {
          System.out.println("Sales's writelog is Error!");
          ex.printStackTrace();
        }
      }
      else {
        try {
          log.WriteLog(log_vec2);
          return false;
        }
        catch (Exception ex) {
          System.out.println("Sales's writelog is Error!");
          ex.printStackTrace();
        }
      }

 /*   if (f) {
              if (job.equalsIgnoreCase("idoc")) {
                idoc_message = writeSAP.writeSAPIdoc("sales",
           "sales" + time + num + ".txt",
                                                     "idoc");
                idoc_message = Operate1.escape(idoc_message);
                log_vec2.setElementAt(idoc_message, 6);
                log_vec2.setElementAt("1", 8);
                try {
                  log.WriteLog(log_vec2);
                  if (idoc_message == null||idoc_message.equalsIgnoreCase("null")||idoc_message.equalsIgnoreCase("")) {
                    return false;
                  }
                }
                catch (Exception ex) {
                  System.out.println("Sales's writelogis Error!");
                  ex.printStackTrace();
                }
              }
              else if (job.equalsIgnoreCase("trigger")) {
                // 先把文件写入SAP数据库
                idoc_message = writeSAP.writeSAPIdoc("sales",
           "sales" + time + num + ".txt",
                                                     "idoc");
                idoc_message = Operate1.escape(idoc_message);
                log_vec2.setElementAt(idoc_message, 6);
                log_vec2.setElementAt("1", 8);
                try {
                  log.WriteLog(log_vec2);
                  if (idoc_message == null||idoc_message.equalsIgnoreCase("null")||idoc_message.equalsIgnoreCase("")) {
                    return false;
                  }
                }
                catch (Exception ex) {
                  System.out.println("Sales's writelog is Error!");
                  ex.printStackTrace();
                }
                 // 最后触发
                 idoc_message = writeSAP.writeSAPIdoc("sales",
            "sales" + time + num + ".txt",
                                                      "trigger");
                 idoc_message = Operate1.escape(idoc_message);
                 log_vec2.setElementAt(idoc_message, 6);
                 try {
                   log.WriteLog(log_vec2);
                 if (idoc_message == null||idoc_message.equalsIgnoreCase("null")||idoc_message.equalsIgnoreCase("")) {
                               return false;
                             }
                 }
                 catch (Exception ex) {
                   System.out.println("Sales's writelog is Error!");
                   ex.printStackTrace();
                 }
               }
             }*/
    }
    return f;
  }

  //处理配置表中所有未完成的记录
  public void disposeNotFilished() {
    boolean suflag = false;
    String endtime = null;
    String[][] str = UpDataDispase1.getNotFilishedSyInfo("sales");
    try {
      for (int j = 0; j < str.length; j++) {
        store = str[j][0];
        time = str[j][1];
        endtime = str[j][2];
        endtimebak = time;
        if (endtime == null || endtime.equalsIgnoreCase("null") ||
            endtime.equalsIgnoreCase("")) {
          continue;
        }
        try {
          if (getData(store, endtimebak, endtime)) {
            if (this.buildIDOC()) {
              suflag = UpDataDispase1.deleteData(store, endtimebak, endtime,
                                                 Tvserialno);
            }
          }
        }
        catch (Exception e) {
          System.out.println("disposeNotFilished----"+e.toString());
          e.printStackTrace();
        }
        finally{ close();}
      }
    }
    catch (Exception e) {
      System.out.println("disposeNotFilished----"+e.toString());
      e.printStackTrace();
    }
  }

  public boolean getData(String storecode, String startime, String endtime) {
    LogManager log = new LogManager();
    Vector log_vec2 = new Vector();
    String wheresql = null;
    if (startime.equalsIgnoreCase("") || startime.equalsIgnoreCase("null")) {
      wheresql = " where SAPOUT_D_SALE_INFO.STORECODE='" + storecode +
          "' and convert(bigint,update_time) <= '" + endtime + "'";
    }

    else {
      wheresql = " where SAPOUT_D_SALE_INFO.STORECODE='" + storecode +
          "' and  convert(bigint,update_time) > '" + startime + "'"
          + " and convert(bigint,update_time)<= '" + endtime + "'";
    }
    try {
      stmt1 = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                                   ResultSet.CONCUR_READ_ONLY);
      String sqlsale = "select STORECODE,SerialNo,LIST_NO,Insider_Card,Merch_CODE,Sell_TYPE,Sell_Amount,"
          + "Courtesy_Cate,CONDITION,Sell_Money,Discount_Type,Discount_Rate,Shroff_Code,Shroff_Name,"
          + "Sell_Time,Promotionor,Promotion_CODE,MONEYCODE ,SPACE(4) as type ,0.00 as money1,SPACE(25) as bank from SAPOUT_D_SALE_INFO "
          + wheresql
          + "  and exists(select * from SAPOUT_D_SALE_Payment "
+ " where SAPOUT_D_SALE_Payment.STORECODE=sapout_d_sale_info.STORECODE and SAPOUT_D_SALE_Payment.SerialNo= sapout_d_sale_info.SerialNo)"
        +  "union all select  STORECODE,SerialNo, 0,     '',          ''       ,'',0,"
          + "         '',          '',0.00,'',0.00,'','','','','','',Payment_Type,Payment_Money,Bank_Code"
          +
          " from SAPOUT_D_SALE_Payment  where EXISTS (select * from sapout_d_sale_info"
          + wheresql
          + "  and SAPOUT_D_SALE_Payment.STORECODE=sapout_d_sale_info.STORECODE and SAPOUT_D_SALE_Payment.SerialNo= sapout_d_sale_info.SerialNo) order by storecode,serialno,type,list_no";

      rowSet1 = stmt1.executeQuery(sqlsale);
      rowSet1.last();
      int num = rowSet1.getRow();
      rowSet1.beforeFirst();
      log_vec2.add(0, storecode);
      log_vec2.add(1, "sales" + startime);
      log_vec2.add(2, "");
      log_vec2.add(3, "sales");
      log_vec2.add(4, "SAPOUT_D_SALE_INFO,SAPOUT_D_SALE_Payment");
      log_vec2.add(5, "in");
      log_vec2.add(6, "从表SAPOUT_D_SALE_INFO union SAPOUT_D_SALE_Payment中取数成功");
      log_vec2.add(7, "getDate()");
      log_vec2.add(8, String.valueOf(num));
      log_vec2.add(9, "1");
      log_vec2.add(10, "0");
      log.WriteLog(log_vec2);
    }
    catch (Exception e) {
      close();
      e.printStackTrace();
      log_vec2.setElementAt(
          "从表SAPOUT_D_SALE_INFO union SAPOUT_D_SALE_Payment中取数失败!", 6);
      log_vec2.setElementAt("0", 9);
      log.WriteLog(log_vec2);
      return false;
    }
    return true;
  }

  public void close() {
    try {
      if (rowSet1 != null) {
        rowSet1.close();
        rowSet1 = null;
      }
      if (stmt1 != null) {
        stmt1.close();
        stmt1 = null;
      }
    }
    catch (Exception e) {
      System.out.println("close");
      e.printStackTrace();
    }
  }

  private void closeconn(Connection conn) {
    try {
      if (conn != null) {
        conn.close();
        conn = null;
      }
    }
    catch (Exception ex) {
      System.out.println("closeconn");
      ex.printStackTrace();
    }
  }
}

⌨️ 快捷键说明

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