示例#1
0
  public List<MersVO> mersData() {
    List<MersVO> list = new ArrayList<MersVO>();
    Date date = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d");
    StringTokenizer st = new StringTokenizer(sdf.format(date), "-");
    int year = Integer.parseInt(st.nextToken());
    int month = Integer.parseInt(st.nextToken());
    int day = Integer.parseInt(st.nextToken());
    try {
      Document doc = Jsoup.connect("http://www.cdc.go.kr/CDC/cms/content/15/63315_view.html").get();
      // System.out.println(doc);
      Elements trs = doc.select("table tbody tr");
      // System.out.println(trs);
      String data = "";
      String[] temp = {"panel panel-primary", "panel panel-green", "panel panel-yellow"};
      int i = 0;
      for (Element tr : trs) {
        Iterator<Element> it = tr.getElementsByTag("td").iterator();

        // if(i==2) break;
        while (it.hasNext()) {

          MersVO vo = new MersVO();
          vo.setType(it.next().text());
          vo.setMers(it.next().text().replace("*", ""));
          /*vo.setYsum(it.next().text().replace(",", ""));
          vo.setPlus(it.next().text());
          vo.setMinus(it.next().text());*/

          if (data.equals("")) {
            data = it.next().text();
            vo.setIng(data);
          } else {
            vo.setIng(data);
          }
          vo.setNsum(it.next().text().replace(",", ""));
          vo.setHouse(it.next().text());
          vo.setOffice(it.next().text());
          vo.setDis(it.next().text().replace(",", ""));
          vo.setDiv1(temp[i]);
          vo.setYear(year);
          vo.setMonth(month);
          if (i == 2) {
            vo.setDay(day - 1);
          } else {
            vo.setDay(day);
          }
          list.add(vo);
          i++;
        }
      }
    } catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
    return list;
  }
示例#2
0
 /** If RESTRICT_BROWSING = true this method checks, whether the path is allowed or not */
 public static boolean isAllowed(File path, boolean write) throws IOException {
   if (READ_ONLY && write) return false;
   if (RESTRICT_BROWSING) {
     StringTokenizer stk = new StringTokenizer(RESTRICT_PATH, ";");
     while (stk.hasMoreTokens()) {
       if (path != null && path.getCanonicalPath().startsWith(stk.nextToken()))
         return RESTRICT_WHITELIST;
     }
     return !RESTRICT_WHITELIST;
   } else return true;
 }
示例#3
0
  /* look for the rate in te account file for the time in the login string */
  public RateEntry getRate(String login) {
    int logday = 0, rateday = 0;
    //    System.out.println("getRate: login='******'");
    String day, time, rate = null;
    StringTokenizer st = new StringTokenizer(login);
    // frits     pts/21       flash            Fri Mar 18 13:46 - 14:30 (6+00:44)
    //                                        ^              ^
    day = st.nextToken();
    time = st.nextToken();
    time = st.nextToken();
    time = st.nextToken().substring(0, 5);
    // System.out.println(login+" "+day+" "+time);
    // Get the international names of the days and which day is (1,2,3...
    // Then find day of each rate entry, (1,2,3,4
    // Now we can compare, independent of the language used for the days
    // Finally use the time to compare as well
    DateFormatSymbols dfs = new DateFormatSymbols();
    String[] days = dfs.getShortWeekdays();
    for (int j = 1; j < days.length; j++) {
      if (day.compareTo(days[j]) == 0) {
        logday = j;
        break;
      }
    }
    // logday -> the day given in the gorecords.xml file (the log)

    int n = rates.size();
    // the last rate applies if before the first entry
    // Init to last rate given in the account
    RateEntry tmpRE, saveRE = rates(n - 1);
    //    System.out.println("n="+n);
    for (int i = 0; i < n; i++) {
      tmpRE = rates(i);
      for (int j = 1; j < days.length; j++) {
        if (tmpRE.day.compareTo(days[j]) == 0) {
          rateday = j;
          break;
        }
      }
      //    System.out.println("j="+jday+" k="+kday+" "+tmpRE.time+" "+tmpRE.loginhr);
      // the last rate applies if before the first entry
      if (logday > rateday) {
        saveRE = tmpRE;
      }
      if ((logday == rateday) && (time.compareTo(tmpRE.time) >= 0)) {
        saveRE = tmpRE;
      }
    }
    return saveRE;
  }
示例#4
0
 public Object stringToValue(String text) throws ParseException {
   StringTokenizer tokenizer = new StringTokenizer(text, ".");
   byte[] a = new byte[4];
   for (int i = 0; i < 4; i++) {
     int b = 0;
     if (!tokenizer.hasMoreTokens()) throw new ParseException("Too few bytes", 0);
     try {
       b = Integer.parseInt(tokenizer.nextToken());
     } catch (NumberFormatException e) {
       throw new ParseException("Not an integer", 0);
     }
     if (b < 0 || b >= 256) throw new ParseException("Byte out of range", 0);
     a[i] = (byte) b;
   }
   if (tokenizer.hasMoreTokens()) throw new ParseException("Too many bytes", 0);
   return a;
 }
示例#5
0
  protected static double[] parseGapScalingFactorMultipliersString(
      String gapScalingFactorMultipliersString) {
    StringTokenizer tok =
        new StringTokenizer(gapScalingFactorMultipliersString, GSFM_PARAMETER_DELIMITER);
    Vector<Double> vec = new Vector<Double>();
    while (tok.hasMoreTokens()) {
      Double gsfm = new Double(Double.parseDouble(tok.nextToken()));
      vec.add(gsfm);
    }

    double[] result = new double[vec.size()];
    for (int i = 0; i < result.length; i++) {
      result[i] = ((Double) (vec.get(i))).doubleValue();
    }

    return (result);
  }
示例#6
0
  // only for use in this class
  // parse out other parameters in affine distance measure string
  // no - only 1 pair of gap penalties per affine distance measure instance!!!
  // too complicated to match up output files otherwise
  protected static GapPenalties parseAffineDistanceMeasureStringParameters(
      String affineDistanceMeasureString) {
    GapPenalties gp = new GapPenalties();
    StringTokenizer tok =
        new StringTokenizer(
            affineDistanceMeasureString, DISTANCE_MEASURE_STRING_PARAMETER_DELIMITER);
    try {
      // first should be distance measure name
      tok.nextToken();
      // second token should be gap open penalty
      gp.gapOpenPenalty = Double.parseDouble(tok.nextToken());
      // third token should be gap extend penalty
      gp.gapExtendPenalty = Double.parseDouble(tok.nextToken());
    } catch (Exception e) {
      System.err.println(e);
      System.err.println(
          "ERROR: improperly formatted affine distance measure string! Recheck parameter list for affine distance measure!");
    }

    return (gp);
  }
示例#7
0
  public Chart(String filename) {
    try {
      // Get Stock Symbol
      this.stockSymbol = filename.substring(0, filename.indexOf('.'));

      // Create time series
      TimeSeries open = new TimeSeries("Open Price", Day.class);
      TimeSeries close = new TimeSeries("Close Price", Day.class);
      TimeSeries high = new TimeSeries("High", Day.class);
      TimeSeries low = new TimeSeries("Low", Day.class);
      TimeSeries volume = new TimeSeries("Volume", Day.class);

      BufferedReader br = new BufferedReader(new FileReader(filename));
      String key = br.readLine();
      String line = br.readLine();
      while (line != null && !line.startsWith("<!--")) {
        StringTokenizer st = new StringTokenizer(line, ",", false);
        Day day = getDay(st.nextToken());
        double openValue = Double.parseDouble(st.nextToken());
        double highValue = Double.parseDouble(st.nextToken());
        double lowValue = Double.parseDouble(st.nextToken());
        double closeValue = Double.parseDouble(st.nextToken());
        long volumeValue = Long.parseLong(st.nextToken());

        // Add this value to our series'
        open.add(day, openValue);
        close.add(day, closeValue);
        high.add(day, highValue);
        low.add(day, lowValue);

        // Read the next day
        line = br.readLine();
      }

      // Build the datasets
      dataset.addSeries(open);
      dataset.addSeries(close);
      dataset.addSeries(low);
      dataset.addSeries(high);
      datasetOpenClose.addSeries(open);
      datasetOpenClose.addSeries(close);
      datasetHighLow.addSeries(high);
      datasetHighLow.addSeries(low);

      JFreeChart summaryChart = buildChart(dataset, "Summary", true);
      JFreeChart openCloseChart = buildChart(datasetOpenClose, "Open/Close Data", false);
      JFreeChart highLowChart = buildChart(datasetHighLow, "High/Low Data", true);
      JFreeChart highLowDifChart =
          buildDifferenceChart(datasetHighLow, "High/Low Difference Chart");

      // Create this panel
      this.setLayout(new GridLayout(2, 2));
      this.add(new ChartPanel(summaryChart));
      this.add(new ChartPanel(openCloseChart));
      this.add(new ChartPanel(highLowChart));
      this.add(new ChartPanel(highLowDifChart));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
示例#8
0
文件: STRQ.java 项目: jmankhan/ACM
  public void solve() throws Exception {
    String str = in.readLine();
    int n = str.length();

    int t = Integer.parseInt(in.readLine());

    int[][] dp = new int[26][n];

    dp[str.charAt(0) - 'a'][0] = 1;

    for (int i = 1; i < n; i++) {
      for (int j = 0; j < 26; j++) {
        if (str.charAt(i) == 'a' + j) {
          dp[j][i] = dp[j][i - 1] + 1;
        } else {
          dp[j][i] = dp[j][i - 1];
        }
      }
    }

    while (t-- > 0) {
      st = new StringTokenizer(in.readLine());
      char a = st.nextToken().toCharArray()[0];
      char b = st.nextToken().toCharArray()[0];

      int l = parseInt(st.nextToken()) - 1;
      int r = parseInt(st.nextToken()) - 1;

      int ans = 0;
      for (int i = l; i <= r; i++) {
        if (str.charAt(i) == a) {
          ans += dp[b - 'a'][r] - dp[b - 'a'][i];
        }
      }

      out.println(ans);
    }
  }
示例#9
0
 // 建立文件夹
 public boolean MakeDir(String s_dir) {
   // 转换为UNIX下的标准目录
   StringTokenizer tokens = new StringTokenizer(s_dir, "\\");
   s_dir = "";
   while (tokens.hasMoreTokens()) {
     s_dir = s_dir + tokens.nextToken().trim() + "/";
   }
   s_dir = s_dir.substring(0, s_dir.length() - 1);
   tokens = new StringTokenizer(s_dir, "/");
   s_dir = "";
   while (tokens.hasMoreTokens()) {
     s_dir = s_dir + tokens.nextToken().trim() + "/";
     System.out.println(s_dir);
     File fileFolder = new File(s_dir);
     if (!fileFolder.exists()) {
       if (!fileFolder.mkdir()) {
         System.err.println("create " + s_dir + " Fail!");
         return false;
       }
     }
   }
   return true;
 }
 public static void main(String[] args) throws Exception {
   BufferedReader st = new BufferedReader(new InputStreamReader(System.in));
   StringTokenizer s;
   s = new StringTokenizer(st.readLine());
   int n = Integer.parseInt(s.nextToken());
   int r = Integer.parseInt(s.nextToken()) - 1;
   visited = new int[n];
   int i, a, b;
   for (i = 0; i < n; i++) {
     adjList.add(new ArrayList<Integer>());
   }
   for (i = 0; i < n - 1; i++) {
     s = new StringTokenizer(st.readLine());
     a = Integer.parseInt(s.nextToken());
     b = Integer.parseInt(s.nextToken());
     adjList.get(a - 1).add(b - 1);
     adjList.get(b - 1).add(a - 1);
     visited[a - 1] = 0;
     visited[b - 1] = 0;
   }
   dfs(r, 0);
   System.out.println(maxh + " " + minh);
 }
示例#11
0
  public static void main(String[] args) throws FileNotFoundException, IOException {
    JOptionPane myWindow;
    myWindow = new JOptionPane();
    String fileName;
    fileName = myWindow.showInputDialog("Enter External Text File to Open;");
    Scanner scanner = new Scanner(new File(fileName));
    JTextArea outputOriginalFile = new JTextArea();
    outputOriginalFile.setText("The Original File was:\n");
    JTextArea outputTextArea = new JTextArea();
    while (scanner.hasNext()) {
      String fullName = scanner.nextLine();
      outputOriginalFile.append(fullName + "\n");
    }
    myWindow.showMessageDialog(
        null, outputOriginalFile, "Opened file....", myWindow.INFORMATION_MESSAGE);

    PrintWriter pw = new PrintWriter(new File("outputOfFile.txt"));
    String firstName, middleName, lastName;
    JTextArea outputTextArea1 = new JTextArea();
    outputTextArea1.setText("The Modified Text File is:\n");
    Scanner scanner2 = new Scanner(new File(fileName));
    while (scanner2.hasNext()) {
      String fullName = scanner2.nextLine();
      StringTokenizer st = new StringTokenizer(fullName, " ");
      firstName = st.nextToken();
      middleName = st.nextToken();
      lastName = st.nextToken();
      pw.println(lastName + ", " + firstName + " " + middleName.substring(0, 1) + ".");
      outputTextArea1.append(
          lastName + ", " + firstName + " " + middleName.substring(0, 1) + "." + "\n");
    }
    myWindow.showMessageDialog(null, outputTextArea1, "Results....", myWindow.INFORMATION_MESSAGE);

    scanner.close();
    scanner2.close();
    pw.close();
  }
示例#12
0
 public Hashtable processData(
     ServletInputStream is, String boundary, String saveInDir, int clength)
     throws IllegalArgumentException, IOException {
   if (is == null) throw new IllegalArgumentException("InputStream");
   if (boundary == null || boundary.trim().length() < 1)
     throw new IllegalArgumentException("\"" + boundary + "\" is an illegal boundary indicator");
   boundary = "--" + boundary;
   StringTokenizer stLine = null, stFields = null;
   FileInfo fileInfo = null;
   Hashtable dataTable = new Hashtable(5);
   String line = null, field = null, paramName = null;
   boolean saveFiles = (saveInDir != null && saveInDir.trim().length() > 0);
   boolean isFile = false;
   if (saveFiles) { // Create the required directory (including parent dirs)
     File f = new File(saveInDir);
     f.mkdirs();
   }
   line = getLine(is);
   if (line == null || !line.startsWith(boundary))
     throw new IOException("Boundary not found; boundary = " + boundary + ", line = " + line);
   while (line != null) {
     if (line == null || !line.startsWith(boundary)) return dataTable;
     line = getLine(is);
     if (line == null) return dataTable;
     stLine = new StringTokenizer(line, ";\r\n");
     if (stLine.countTokens() < 2) throw new IllegalArgumentException("Bad data in second line");
     line = stLine.nextToken().toLowerCase();
     if (line.indexOf("form-data") < 0)
       throw new IllegalArgumentException("Bad data in second line");
     stFields = new StringTokenizer(stLine.nextToken(), "=\"");
     if (stFields.countTokens() < 2)
       throw new IllegalArgumentException("Bad data in second line");
     fileInfo = new FileInfo();
     stFields.nextToken();
     paramName = stFields.nextToken();
     isFile = false;
     if (stLine.hasMoreTokens()) {
       field = stLine.nextToken();
       stFields = new StringTokenizer(field, "=\"");
       if (stFields.countTokens() > 1) {
         if (stFields.nextToken().trim().equalsIgnoreCase("filename")) {
           fileInfo.name = paramName;
           String value = stFields.nextToken();
           if (value != null && value.trim().length() > 0) {
             fileInfo.clientFileName = value;
             isFile = true;
           } else {
             line = getLine(is); // Skip "Content-Type:" line
             line = getLine(is); // Skip blank line
             line = getLine(is); // Skip blank line
             line = getLine(is); // Position to boundary line
             continue;
           }
         }
       } else if (field.toLowerCase().indexOf("filename") >= 0) {
         line = getLine(is); // Skip "Content-Type:" line
         line = getLine(is); // Skip blank line
         line = getLine(is); // Skip blank line
         line = getLine(is); // Position to boundary line
         continue;
       }
     }
     boolean skipBlankLine = true;
     if (isFile) {
       line = getLine(is);
       if (line == null) return dataTable;
       if (line.trim().length() < 1) skipBlankLine = false;
       else {
         stLine = new StringTokenizer(line, ": ");
         if (stLine.countTokens() < 2)
           throw new IllegalArgumentException("Bad data in third line");
         stLine.nextToken(); // Content-Type
         fileInfo.fileContentType = stLine.nextToken();
       }
     }
     if (skipBlankLine) {
       line = getLine(is);
       if (line == null) return dataTable;
     }
     if (!isFile) {
       line = getLine(is);
       if (line == null) return dataTable;
       dataTable.put(paramName, line);
       // If parameter is dir, change saveInDir to dir
       if (paramName.equals("dir")) saveInDir = line;
       line = getLine(is);
       continue;
     }
     try {
       UplInfo uplInfo = new UplInfo(clength);
       UploadMonitor.set(fileInfo.clientFileName, uplInfo);
       OutputStream os = null;
       String path = null;
       if (saveFiles)
         os = new FileOutputStream(path = getFileName(saveInDir, fileInfo.clientFileName));
       else os = new ByteArrayOutputStream(ONE_MB);
       boolean readingContent = true;
       byte previousLine[] = new byte[2 * ONE_MB];
       byte temp[] = null;
       byte currentLine[] = new byte[2 * ONE_MB];
       int read, read3;
       if ((read = is.readLine(previousLine, 0, previousLine.length)) == -1) {
         line = null;
         break;
       }
       while (readingContent) {
         if ((read3 = is.readLine(currentLine, 0, currentLine.length)) == -1) {
           line = null;
           uplInfo.aborted = true;
           break;
         }
         if (compareBoundary(boundary, currentLine)) {
           os.write(previousLine, 0, read - 2);
           line = new String(currentLine, 0, read3);
           break;
         } else {
           os.write(previousLine, 0, read);
           uplInfo.currSize += read;
           temp = currentLine;
           currentLine = previousLine;
           previousLine = temp;
           read = read3;
         } // end else
       } // end while
       os.flush();
       os.close();
       if (!saveFiles) {
         ByteArrayOutputStream baos = (ByteArrayOutputStream) os;
         fileInfo.setFileContents(baos.toByteArray());
       } else fileInfo.file = new File(path);
       dataTable.put(paramName, fileInfo);
       uplInfo.currSize = uplInfo.totalSize;
     } // end try
     catch (IOException e) {
       throw e;
     }
   }
   return dataTable;
 }
  public synchronized void service(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    HttpSession dbSession = request.getSession();
    JspFactory _jspxFactory = JspFactory.getDefaultFactory();
    PageContext pageContext =
        _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
    ServletContext dbApplication = dbSession.getServletContext();
    try {
      HttpSession session = request.getSession();
      PrintWriter out = response.getWriter();
      nseer_db_backup1 fund_db = new nseer_db_backup1(dbApplication);
      nseer_db_backup1 fund_db1 = new nseer_db_backup1(dbApplication);
      if (fund_db.conn((String) dbSession.getAttribute("unit_db_name"))
          && fund_db1.conn((String) dbSession.getAttribute("unit_db_name"))) {
        counter count = new counter(dbApplication);
        ValidataRecordNumber vrn = new ValidataRecordNumber();
        ValidataTag vt = new ValidataTag();
        ValidataNumber validata = new ValidataNumber();
        try {
          String time = "";
          java.util.Date now = new java.util.Date();
          SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
          time = formatter.format(now);

          String apply_pay_ID = request.getParameter("apply_pay_ID");
          String register_time = request.getParameter("register_time");
          String register = request.getParameter("register");
          String register_ID = request.getParameter("register_ID");
          String bodyc = new String(request.getParameter("remark").getBytes("UTF-8"), "UTF-8");
          String remark = exchange.toHtml(bodyc);
          String amount = request.getParameter("amount");
          String[] file_kind = request.getParameterValues("file_kind");
          String[] cost_price_subtotal = request.getParameterValues("cost_price_subtotal");
          int p = 0;
          String file_kinda = ",";
          for (int j = 1; j < file_kind.length; j++) {
            file_kinda += file_kind[j] + ",";
            if (cost_price_subtotal[j].equals("")) cost_price_subtotal[j] = "0";
            StringTokenizer tokenTO4 = new StringTokenizer(cost_price_subtotal[j], ",");
            String cost_price_subtotal1 = "";
            while (tokenTO4.hasMoreTokens()) {
              cost_price_subtotal1 += tokenTO4.nextToken();
            }
            if (!validata.validata(cost_price_subtotal1)) {
              p++;
            }
          }
          int n = 0;
          for (int i = 1; i <= Integer.parseInt(amount); i++) {
            String tem_file_kind = "file_kind" + i;
            String file_kind2 = request.getParameter(tem_file_kind);
            if (file_kinda.indexOf(file_kind2) != -1) n++;
          }
          if (n == 0) {
            if (p == 0) {
              if (vt.validata(
                          (String) dbSession.getAttribute("unit_db_name"),
                          "fund_apply_pay",
                          "apply_pay_ID",
                          apply_pay_ID,
                          "check_tag")
                      .equals("5")
                  || vt.validata(
                          (String) dbSession.getAttribute("unit_db_name"),
                          "fund_apply_pay",
                          "apply_pay_ID",
                          apply_pay_ID,
                          "check_tag")
                      .equals("9")) {
                String currency_name = "";
                String personal_unit = "";
                String chain_ID = "";
                String chain_name = "";
                String funder = "";
                String funder_ID = "";
                String sql11 =
                    "select * from fund_apply_pay where apply_pay_ID='" + apply_pay_ID + "'";
                ResultSet rs11 = fund_db.executeQuery(sql11);
                while (rs11.next()) {
                  chain_ID = rs11.getString("chain_ID");
                  chain_name = rs11.getString("chain_name");
                  funder = rs11.getString("human_name");
                  funder_ID = rs11.getString("human_ID");
                  currency_name = rs11.getString("currency_name");
                  personal_unit = rs11.getString("personal_unit");
                }
                int expenses_amount = 0;
                String sql6 =
                    "select count(*) from fund_apply_pay_details where apply_pay_ID='"
                        + apply_pay_ID
                        + "'";
                ResultSet rs6 = fund_db.executeQuery(sql6);
                if (rs6.next()) {
                  expenses_amount = rs6.getInt("count(*)");
                }
                double demand_cost_price_sum = 0.0d;
                for (int i = 1; i <= expenses_amount; i++) {
                  String tem_cost_price_subtotal = "cost_price_subtotal" + i;
                  String cost_price_subtotal2 = request.getParameter(tem_cost_price_subtotal);
                  demand_cost_price_sum += Double.parseDouble(cost_price_subtotal2);
                  sql6 =
                      "update fund_apply_pay_details set cost_price_subtotal='"
                          + cost_price_subtotal2
                          + "' where apply_pay_ID='"
                          + apply_pay_ID
                          + "' and details_number='"
                          + i
                          + "'";
                  fund_db.executeUpdate(sql6);
                }
                for (int i = 1; i < file_kind.length; i++) {
                  StringTokenizer tokenTO1 = new StringTokenizer(file_kind[i], "/");
                  String file_chain_ID = "";
                  String file_chain_name = "";
                  while (tokenTO1.hasMoreTokens()) {
                    file_chain_ID = tokenTO1.nextToken();
                    file_chain_name = tokenTO1.nextToken();
                  }
                  StringTokenizer tokenTO4 = new StringTokenizer(cost_price_subtotal[i], ",");
                  String cost_price_subtotal1 = "";
                  while (tokenTO4.hasMoreTokens()) {
                    cost_price_subtotal1 += tokenTO4.nextToken();
                  }
                  demand_cost_price_sum += Double.parseDouble(cost_price_subtotal1);
                  expenses_amount++;
                  String sql1 =
                      "insert into fund_apply_pay_details(apply_pay_ID,details_number,file_chain_ID,file_chain_name,cost_price_subtotal) values ('"
                          + apply_pay_ID
                          + "','"
                          + expenses_amount
                          + "','"
                          + file_chain_ID
                          + "','"
                          + file_chain_name
                          + "','"
                          + cost_price_subtotal1
                          + "')";
                  fund_db.executeUpdate(sql1);
                }

                String sql =
                    "update fund_apply_pay set demand_cost_price_sum='"
                        + demand_cost_price_sum
                        + "',check_tag='2',register_time='"
                        + register_time
                        + "',register='"
                        + register
                        + "',remark='"
                        + remark
                        + "' where apply_pay_ID='"
                        + apply_pay_ID
                        + "'";
                fund_db.executeUpdate(sql);

                response.sendRedirect("draft/fund/applyPayExpenses_ok.jsp?finished_tag=2");
              } else {
                response.sendRedirect("draft/fund/applyPayExpenses_ok.jsp?finished_tag=3");
              }
            } else {
              response.sendRedirect("draft/fund/applyPayExpenses_ok.jsp?finished_tag=6");
            }
          } else {
            response.sendRedirect("draft/fund/applyPayExpenses_ok.jsp?finished_tag=7");
          }
        } catch (Exception ex) {
          ex.printStackTrace();
        }
        fund_db.commit();
        fund_db1.commit();
        fund_db.close();
        fund_db1.close();
      } else {
        response.sendRedirect("error_conn.htm");
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
示例#14
0
 String next() throws IOException {
   while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine().trim());
   return st.nextToken();
 }
示例#15
0
  /**
   * This is a test for compute depth of genome and compute if has a path from two nodes (is a test
   * for new version of method is_recur()) --> has_a_path(..) is not necessary for network
   * simulation
   */
  public static void Experiment5(String xFileName, int potin, int potout) {
    StringTokenizer st;
    String curword;
    String xline;
    String fnamebuf;
    IOseq xFile;
    int id;
    Genome g1 = null;
    Network net = null;

    xFile = new IOseq(xFileName);
    boolean ret = xFile.IOseqOpenR();

    if (ret) {

      try {
        System.out.println("------ Start experiment 5 -------");
        // read genome A

        System.out.println(" Read start genome..");

        xline = xFile.IOseqRead();

        st = new StringTokenizer(xline);
        // skip
        curword = st.nextToken();
        // id of genome can be readed
        curword = st.nextToken();
        id = Integer.parseInt(curword);
        g1 = new Genome(id, xFile);

        // generate	a link mutation
        g1.mutate_link_weight(Neat.p_weight_mut_power, 1.0, NeatConstant.GAUSSIAN);
        // generate from genome the phenotype
        g1.genesis(id);

        // view genotype
        g1.op_view();

        // assign reference to genotype
        net = g1.phenotype;

        // compute first the 'teorical' depth
        int lx = net.max_depth();
        // compute . after, the 'pratical' depth passing
        // the virtual depth;
        int dx = net.is_stabilized(lx);

        System.out.print("\n Max depth virtuale=" + lx);
        System.out.print(", max depth reale=" + dx);

        // search the inode
        NNode inode = null;
        NNode onode = null;
        NNode curnode = null;
        boolean rc = false;
        int cnt = 0;

        for (int ix = 0; (ix < net.allnodes.size()) && (cnt < 2); ix++) {
          curnode = (NNode) net.allnodes.elementAt(ix);
          if (curnode.node_id == potin) {
            inode = curnode;
            cnt++;
          }

          if (curnode.node_id == potout) {
            onode = curnode;
            cnt++;
          }
        }

        // if exist , point to exitsting version
        if (cnt < 2) {

          System.out.print("\n ERROR :nodes in e/o out wrong's : retype!");
        } else {

          net.status = 0;
          rc = net.has_a_path(inode, onode, 0, 30);
          System.out.print("\n Result for  example " + xFileName + " for ipotetic path ");
          System.out.print(
              "\n   inode[" + potin + "] ---> onode[" + potout + "]  is  return code=" + rc);
          System.out.print(", status = " + net.status);
        }

        // after reset all value of net
        net.flush();

        // ok : the propagation is completed
      } catch (Throwable e) {
        System.err.println(e + " : error during read " + xFileName);
      }

      xFile.IOseqCloseR();

    } else System.err.print("\n : error during open " + xFileName);

    System.out.println("\n\n End of experiment");
  }
示例#16
0
  /**
   * This is a test for viewing the result of mate or other operation can be executed from two
   * genome the first genome is xFileNameA and second genome is xFileNameB
   */
  public static void Experiment4(String xFileNameA, String xFileNameB) {
    StringTokenizer st;
    String curword;
    String xline;
    String fnamebuf;
    IOseq xFile;
    int id;
    Genome gA = null;
    Genome gB = null;

    System.out.println("------ Start experiment 4 -------");
    // read genome A
    //
    xFile = new IOseq(xFileNameA);
    boolean ret = xFile.IOseqOpenR();

    if (ret) {

      try {
        System.out.println(" Read genome-A");
        xline = xFile.IOseqRead();
        st = new StringTokenizer(xline);
        // skip
        curword = st.nextToken();
        // id of genome can be readed
        curword = st.nextToken();
        id = Integer.parseInt(curword);
        gA = new Genome(id, xFile);
        // view genotype A
      } catch (Throwable e) {
        System.err.println(e + " : error during read " + xFileNameA);
      }

      xFile.IOseqCloseR();
    } else System.err.print("\n : error during openA " + xFileNameA);

    //
    // read genome B
    //
    xFile = new IOseq(xFileNameB);
    ret = xFile.IOseqOpenR();

    if (ret) {

      try {
        System.out.println("\n Read genome-B");
        xline = xFile.IOseqRead();
        st = new StringTokenizer(xline);
        // skip
        curword = st.nextToken();
        // id of genome can be readed
        curword = st.nextToken();
        id = Integer.parseInt(curword);
        gB = new Genome(id, xFile);
        // view genotype A
      } catch (Throwable e) {
        System.err.println(e + " : error during open " + xFileNameB);
      }

      xFile.IOseqCloseR();
    } else System.err.print("\n : error during openB " + xFileNameB);

    //   	Genome gC = gA.mate_multipoint(gB,3,0.6,0.3);
    //   	Genome gC = gA.mate_multipoint_avg(gB,3,0.6,0.3);

    System.out.println("\n ----genome-A----------");
    gA.op_view();
    System.out.println("\n ----genome-B----------");
    gB.op_view();

    //	gA.DEBUGmate_singlepoint(gB,3);

    System.out.println("\n ----genome-RESULT----------");
    Genome gC = gA.mate_singlepoint(gB, 999);

    // this step is for verify if correct genome
    gC.verify();
    // this step is for verify the phenotype created
    gC.genesis(999);
    // the step print the result genome
    gC.op_view();

    // for viewing the imagine of two genome input and the genome output

    System.out.println("\n *******  D I S P L A Y      G R A P H   *********");
    gA.View_mate_singlepoint(gB, 999);
    System.out.println("\n *************************************************");

    System.out.println("\n\n End of experiment");
  }
示例#17
0
  /**
   * This is a test for compute depth of genome and trace all debug information for viewing all
   * signal flowing is not necessary for network simulation
   */
  public static void Experiment2(String xFileName) {
    StringTokenizer st;
    String curword;
    String xline;
    String fnamebuf;
    IOseq xFile;
    int id;
    Genome g1 = null;
    Network net = null;

    System.out.println("------ Start experiment 2 -------");

    xFile = new IOseq(xFileName);

    boolean ret = xFile.IOseqOpenR();

    if (ret) {

      try {

        System.out.println(" Start experiment 2");
        System.out.println(" Read start genome..");

        xline = xFile.IOseqRead();

        st = new StringTokenizer(xline);
        // skip
        curword = st.nextToken();
        // id of genome can be readed
        curword = st.nextToken();
        id = Integer.parseInt(curword);
        g1 = new Genome(id, xFile);

        // generate	a link mutation
        g1.mutate_link_weight(Neat.p_weight_mut_power, 1.0, NeatConstant.GAUSSIAN);
        // generate from genome the phenotype
        g1.genesis(id);
        // view genotype
        g1.op_view();

        // assign reference to genotype
        net = g1.phenotype;

        // compute first the 'teorical' depth
        int lx = net.max_depth();

        // compute . after, the 'pratical' depth passing
        // the virtual depth;
        int dx = net.is_stabilized(lx);
        // after reset all value of net
        net.flush();

        System.out.print("\n For genome : " + xFileName + " : max depth virtuale=" + lx);
        System.out.print(", max depth reale=" + dx);

        if (dx != lx) System.out.print("\n  *ALERT*  This net is   NOT   S T A B L E ");

        net.flush();

        double errorsum = 0.0;
        double[] out = new double[4]; // The four outputs

        int numnodes = 0;
        int net_depth = 0; // The max depth of the network to be activated
        int count = 0;
        boolean success = false;

        double in[] = {1.0, 1.0, 1.0};

        count = 0;
        // first activation from sensor to first next level of neurons
        net.load_sensors(in);

        // first activation....
        success = net.activate();

        // next activation while last level is reached !
        // use depth to ensure relaxation

        for (int relax = 1; relax <= dx; relax++) {
          success = net.activate();
          //		  	System.out.print("\n -----TIME <"+relax+"> -----");
        }

        // ok : the propagation is completed
      } catch (Throwable e) {
        System.err.println(e + " : error during open " + xFileName);
      }

      xFile.IOseqCloseR();

    } else System.err.print("\n : error during open " + xFileName);

    System.out.println("\n\n End of experiment");
  }
示例#18
0
  /**
   * this is a standard experiment for XOR emulation; is passed a name of a started genome and a
   * number of times can be execute this experiment;
   */
  public static void Experiment1(String xFileName, int gens) {

    String fname_prefix = "c:\\jneat\\dati\\population.natural";
    Population pop = null;
    StringTokenizer st;
    String curword;
    String xline;
    String fnamebuf;
    int gen;
    IOseq xFile;
    int id;
    int expcount = 0;
    String mask6 = "000000";
    DecimalFormat fmt6 = new DecimalFormat(mask6);

    System.out.println("------ Start experiment 1 -------");

    xFile = new IOseq(xFileName);
    boolean ret = xFile.IOseqOpenR();
    if (ret) {

      try {

        System.out.println(" Start XOR experiment");
        System.out.println("  .read start genome..");

        xline = xFile.IOseqRead();

        st = new StringTokenizer(xline);
        // skip
        curword = st.nextToken();
        // id of genome can be readed
        curword = st.nextToken();
        id = Integer.parseInt(curword);

        System.out.println("  .create genome id " + id);

        Genome start_genome = new Genome(id, xFile);
        // backup this 'initial' genome (is only for test
        // if the read & write are correct
        start_genome.print_to_filename("c:\\jneat\\dati\\genome.readed");

        for (expcount = 0; expcount < Neat.p_num_runs; expcount++) {
          System.out.println(" Spawned population off genome");
          pop = new Population(start_genome, Neat.p_pop_size);
          System.out.print("\n\n Verifying Spawned Pop");
          pop.verify();

          System.out.print("\n");

          for (gen = 1; gen <= gens; gen++) {
            System.out.print("\n---------------- E P O C H  < " + gen + " >--------------");

            fnamebuf = "g_" + fmt6.format(gen);
            boolean esito = xor_epoch(pop, gen, fnamebuf);
          }

          System.out.print("\n  Population : innov num   = " + pop.getCur_innov_num());
          System.out.print("\n             : cur_node_id = " + pop.getCur_node_id());

          pop.print_to_filename(fname_prefix);
        }
      } catch (Throwable e) {
        System.err.println(e + " : error during read " + xFileName);
      }

      xFile.IOseqCloseR();

    } else System.err.print("\n : error during open " + xFileName);

    System.out.println("\n\n End of experiment");
  }
示例#19
0
  public synchronized void doPost(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    HttpSession dbSession = request.getSession();
    JspFactory _jspxFactory = JspFactory.getDefaultFactory();
    PageContext pageContext =
        _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
    ServletContext dbApplication = dbSession.getServletContext();

    try {
      PrintWriter out = response.getWriter();

      nseer_db_backup1 stock_db = new nseer_db_backup1(dbApplication);
      nseer_db_backup1 crm_db = new nseer_db_backup1(dbApplication);
      if (stock_db.conn((String) dbSession.getAttribute("unit_db_name"))
          && crm_db.conn((String) dbSession.getAttribute("unit_db_name"))) {

        FileKind FileKind = new FileKind();
        ValidataNumber validata = new ValidataNumber();
        ValidataRecord vr = new ValidataRecord();

        counter count = new counter(dbApplication);
        ValidataTag vt = new ValidataTag();
        String register_ID = (String) dbSession.getAttribute("human_IDD");
        String config_id = request.getParameter("config_id");
        String pay_ID = request.getParameter("pay_ID");
        String product_amount = request.getParameter("product_amount");
        int num = Integer.parseInt(product_amount);
        String payer_name = request.getParameter("payer_name");
        String payer_ID = request.getParameter("payer_ID");
        String reason = request.getParameter("reason");
        String not_return_tag = request.getParameter("not_return_tag");
        String register = request.getParameter("register");
        String register_time = request.getParameter("register_time");
        String demand_return_time = request.getParameter("demand_return_time");
        String sales_name = request.getParameter("sales_name");
        String sales_ID = request.getParameter("sales_ID");
        String bodyc = new String(request.getParameter("remark").getBytes("UTF-8"), "UTF-8");
        String remark = exchange.toHtml(bodyc);
        String time = "";
        java.util.Date now = new java.util.Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
        time = formatter.format(now);
        String[] product_IDn = request.getParameterValues("product_ID");
        String[] amountn = request.getParameterValues("amount");
        if (num == 0 && product_IDn.length == 1) {
          response.sendRedirect("draft/crm/credit_ok_a.jsp?pay_ID=" + pay_ID);
        } else {
          int p = 0;
          for (int i = 1; i <= num; i++) {
            String tem_amount = "amount" + i;
            String amount = request.getParameter(tem_amount);
            if (amount.equals("")) amount = "0";
            if (!validata.validata(amount)) {
              p++;
            }
          }
          int n = 0;
          String product_ID_group = "";
          for (int j = 1; j < product_IDn.length; j++) {
            product_ID_group += product_IDn[j] + ",";
            if (amountn[j].equals("")) amountn[j] = "0";
            if (!validata.validata(amountn[j])) {
              p++;
            }
          }
          for (int i = 1; i <= num; i++) {
            String tem_product_ID = "product_ID" + i;
            String product_ID = request.getParameter(tem_product_ID);
            if (product_ID_group.indexOf(product_ID) != -1) n++;
          }
          if (vt.validata(
                      (String) dbSession.getAttribute("unit_db_name"),
                      "stock_apply_pay",
                      "pay_ID",
                      pay_ID,
                      "check_tag")
                  .equals("9")
              || vt.validata(
                      (String) dbSession.getAttribute("unit_db_name"),
                      "stock_apply_pay",
                      "pay_ID",
                      pay_ID,
                      "check_tag")
                  .equals("5")) {

            if (p == 0) {
              try {
                if (n == 0) {
                  boolean flag = false;
                  List rsList = GetWorkflow.getList(crm_db, "crm_config_workflow", "05");
                  String[] elem = new String[3];
                  if (rsList.size() == 0) {
                    flag = true;
                  }
                  String sqll = "";
                  String[] aaa1 =
                      FileKind.getKind(
                          (String) dbSession.getAttribute("unit_db_name"),
                          "crm_file",
                          "customer_ID",
                          payer_ID);

                  String stock_pay_ID =
                      NseerId.getId("stock/pay", (String) dbSession.getAttribute("unit_db_name"));
                  double demand_amount = 0.0d;
                  double list_price_sum = 0.0d;
                  double cost_price_sum = 0.0d;

                  for (int i = 1; i <= num; i++) {
                    String tem_product_name = "product_name" + i;
                    String tem_product_ID = "product_ID" + i;
                    String tem_available_amount = "available_amount" + i;
                    String tem_amount = "amount" + i;
                    String tem_list_price = "list_price" + i;
                    String tem_cost_price = "cost_price" + i;
                    String tem_type = "type" + i;
                    String tem_amount_unit = "amount_unit" + i;
                    String product_name = request.getParameter(tem_product_name);
                    String product_ID = request.getParameter(tem_product_ID);
                    String available_amount = request.getParameter(tem_available_amount);
                    String amount = request.getParameter(tem_amount);
                    if (amount.equals("")) amount = "0";
                    String list_price2 = request.getParameter(tem_list_price);
                    String cost_price = request.getParameter(tem_cost_price);
                    String type = request.getParameter(tem_type);
                    StringTokenizer tokenTO3 = new StringTokenizer(list_price2, ",");
                    String list_price = "";
                    while (tokenTO3.hasMoreTokens()) {
                      String list_price1 = tokenTO3.nextToken();
                      list_price += list_price1;
                    }
                    String amount_unit = request.getParameter(tem_amount_unit);
                    double list_price_subtotal =
                        Double.parseDouble(list_price) * Double.parseDouble(amount);
                    list_price_sum += list_price_subtotal;
                    double cost_price_subtotal =
                        Double.parseDouble(cost_price) * Double.parseDouble(amount);
                    cost_price_sum += cost_price_subtotal;
                    demand_amount += Double.parseDouble(amount);
                    String sql1 =
                        "update stock_apply_pay_details set amount='"
                            + amount
                            + "',list_price='"
                            + list_price
                            + "',list_price_subtotal='"
                            + list_price_subtotal
                            + "',cost_price='"
                            + cost_price
                            + "',subtotal='"
                            + cost_price_subtotal
                            + "' where pay_ID='"
                            + pay_ID
                            + "' and details_number='"
                            + i
                            + "'";
                    stock_db.executeUpdate(sql1);
                    if (flag) {
                      if (type.equals("物料") || type.equals("外购商品")) {
                        String sql2 =
                            "insert into stock_pay_details(pay_ID,details_number,product_ID,product_name,type,list_price,list_price_subtotal,cost_price,subtotal,amount,unpay_amount,apply_manufacture_amount,apply_purchase_amount) values('"
                                + stock_pay_ID
                                + "','"
                                + i
                                + "','"
                                + product_ID
                                + "','"
                                + product_name
                                + "','"
                                + type
                                + "','"
                                + list_price
                                + "','"
                                + list_price_subtotal
                                + "','"
                                + cost_price
                                + "','"
                                + cost_price_subtotal
                                + "','"
                                + amount
                                + "','"
                                + amount
                                + "','0','"
                                + amount
                                + "')";
                        stock_db.executeUpdate(sql2);
                      } else if (type.equals("商品") || type.equals("部件") || type.equals("委外部件")) {
                        String sql2 =
                            "insert into stock_pay_details(pay_ID,details_number,product_ID,product_name,type,list_price,list_price_subtotal,cost_price,subtotal,amount,unpay_amount,apply_manufacture_amount,apply_purchase_amount) values('"
                                + stock_pay_ID
                                + "','"
                                + i
                                + "','"
                                + product_ID
                                + "','"
                                + product_name
                                + "','"
                                + type
                                + "','"
                                + list_price
                                + "','"
                                + list_price_subtotal
                                + "','"
                                + cost_price
                                + "','"
                                + cost_price_subtotal
                                + "','"
                                + amount
                                + "','"
                                + amount
                                + "','"
                                + amount
                                + "','0')";
                        stock_db.executeUpdate(sql2);
                      }

                      String sql97 =
                          "select * from crm_salecredit_balance_details where crediter_ID='"
                              + payer_ID
                              + "' and product_ID='"
                              + product_ID
                              + "'";
                      ResultSet rs97 = crm_db.executeQuery(sql97);
                      if (rs97.next()) {
                        double balance_amount =
                            rs97.getDouble("amount") + Double.parseDouble(amount);
                        double balance_cost_price_subtotal =
                            rs97.getDouble("subtotal") + cost_price_subtotal;
                        double balance_list_price_subtotal =
                            rs97.getDouble("list_price_subtotal") + list_price_subtotal;

                        String sql96 =
                            "update crm_salecredit_balance_details set amount='"
                                + balance_amount
                                + "',check_tag='1',subtotal='"
                                + balance_cost_price_subtotal
                                + "',list_price_subtotal='"
                                + balance_list_price_subtotal
                                + "' where crediter_ID='"
                                + payer_ID
                                + "' and product_ID='"
                                + product_ID
                                + "'";
                        crm_db.executeUpdate(sql96);
                      } else {
                        String[] aaa =
                            FileKind.getKind(
                                (String) dbSession.getAttribute("unit_db_name"),
                                "design_file",
                                "product_ID",
                                product_ID);
                        String sql95 =
                            "insert into crm_salecredit_balance_details(chain_ID,chain_name,crediter_chain_ID,crediter_chain_name,product_ID,product_name,list_price,list_price_subtotal,cost_price,subtotal,amount,crediter_ID,crediter_name) values('"
                                + aaa[0]
                                + "','"
                                + aaa[1]
                                + "','"
                                + aaa1[0]
                                + "','"
                                + aaa1[1]
                                + "','"
                                + product_ID
                                + "','"
                                + product_name
                                + "','"
                                + list_price
                                + "','"
                                + list_price_subtotal
                                + "','"
                                + cost_price
                                + "','"
                                + cost_price_subtotal
                                + "','"
                                + amount
                                + "','"
                                + payer_ID
                                + "','"
                                + payer_name
                                + "')";
                        crm_db.executeUpdate(sql95);
                      }
                    }
                  }
                  String[] cost_pricen = request.getParameterValues("cost_price");
                  String[] list_pricen = request.getParameterValues("list_price");
                  String[] product_namen = request.getParameterValues("product_name");
                  String[] product_describen = request.getParameterValues("product_describe");
                  String[] amount_unitn = request.getParameterValues("amount_unit");
                  String[] typen = request.getParameterValues("type");
                  for (int i = 1; i < product_IDn.length; i++) {
                    StringTokenizer tokenTO3 = new StringTokenizer(list_pricen[i], ",");
                    String list_price = "";
                    while (tokenTO3.hasMoreTokens()) {
                      String list_price1 = tokenTO3.nextToken();
                      list_price += list_price1;
                    }
                    if (!amountn[i].equals("") && Double.parseDouble(amountn[i]) != 0) {
                      double list_price_subtotal =
                          Double.parseDouble(list_price) * Double.parseDouble(amountn[i]);
                      list_price_sum += list_price_subtotal;
                      double subtotal =
                          Double.parseDouble(cost_pricen[i]) * Double.parseDouble(amountn[i]);
                      cost_price_sum += subtotal;
                      demand_amount += Double.parseDouble(amountn[i]);
                      num++;
                      String sql1 =
                          "insert into stock_apply_pay_details(payer_chain_ID,payer_chain_name,sales_ID,sales_name,payer_ID,payer_name,payer_type,pay_ID,details_number,product_ID,product_name,product_describe,amount,amount_unit,list_price,list_price_subtotal,cost_price,subtotal,type) values ('"
                              + aaa1[0]
                              + "','"
                              + aaa1[1]
                              + "','"
                              + sales_ID
                              + "','"
                              + sales_name
                              + "','"
                              + payer_ID
                              + "','"
                              + payer_name
                              + "','销售赊货','"
                              + pay_ID
                              + "','"
                              + num
                              + "','"
                              + product_IDn[i]
                              + "','"
                              + product_namen[i]
                              + "','"
                              + product_describen[i]
                              + "','"
                              + amountn[i]
                              + "','"
                              + amount_unitn[i]
                              + "','"
                              + list_price
                              + "','"
                              + list_price_subtotal
                              + "','"
                              + cost_pricen[i]
                              + "','"
                              + subtotal
                              + "','"
                              + typen[i]
                              + "')";
                      stock_db.executeUpdate(sql1);
                      // **********************
                      if (rsList.size() == 0) {
                        if (typen[i].equals("物料") || typen[i].equals("外购商品")) {
                          String sql2 =
                              "insert into stock_pay_details(pay_ID,details_number,product_ID,product_name,type,list_price,list_price_subtotal,cost_price,subtotal,amount,unpay_amount,apply_manufacture_amount,apply_purchase_amount) values('"
                                  + stock_pay_ID
                                  + "','"
                                  + num
                                  + "','"
                                  + product_IDn[i]
                                  + "','"
                                  + product_namen[i]
                                  + "','"
                                  + typen[i]
                                  + "','"
                                  + list_price
                                  + "','"
                                  + list_price_subtotal
                                  + "','"
                                  + cost_pricen[i]
                                  + "','"
                                  + subtotal
                                  + "','"
                                  + amountn[i]
                                  + "','"
                                  + amountn[i]
                                  + "','0','"
                                  + amountn[i]
                                  + "')";
                          stock_db.executeUpdate(sql2);
                        } else if (typen[i].equals("商品")
                            || typen[i].equals("部件")
                            || typen[i].equals("委外部件")) {
                          String sql2 =
                              "insert into stock_pay_details(pay_ID,details_number,product_ID,product_name,type,list_price,list_price_subtotal,cost_price,subtotal,amount,unpay_amount,apply_manufacture_amount,apply_purchase_amount) values('"
                                  + stock_pay_ID
                                  + "','"
                                  + num
                                  + "','"
                                  + product_IDn[i]
                                  + "','"
                                  + product_namen[i]
                                  + "','"
                                  + typen[i]
                                  + "','"
                                  + list_price
                                  + "','"
                                  + list_price_subtotal
                                  + "','"
                                  + cost_pricen[i]
                                  + "','"
                                  + subtotal
                                  + "','"
                                  + amountn[i]
                                  + "','"
                                  + amountn[i]
                                  + "','"
                                  + amountn[i]
                                  + "','0')";
                          stock_db.executeUpdate(sql2);
                        }

                        String sql97 =
                            "select * from crm_salecredit_balance_details where crediter_ID='"
                                + payer_ID
                                + "' and product_ID='"
                                + product_IDn[i]
                                + "'";
                        ResultSet rs97 = crm_db.executeQuery(sql97);
                        if (rs97.next()) {
                          double balance_amount =
                              rs97.getDouble("amount") + Double.parseDouble(amountn[i]);
                          double balance_cost_price_subtotal =
                              rs97.getDouble("subtotal") + subtotal;
                          double balance_list_price_subtotal =
                              rs97.getDouble("list_price_subtotal") + list_price_subtotal;

                          String sql96 =
                              "update crm_salecredit_balance_details set amount='"
                                  + balance_amount
                                  + "',check_tag='1',subtotal='"
                                  + balance_cost_price_subtotal
                                  + "',list_price_subtotal='"
                                  + balance_list_price_subtotal
                                  + "' where crediter_ID='"
                                  + payer_ID
                                  + "' and product_ID='"
                                  + product_IDn[i]
                                  + "'";
                          crm_db.executeUpdate(sql96);
                        } else {
                          String[] aaa =
                              FileKind.getKind(
                                  (String) dbSession.getAttribute("unit_db_name"),
                                  "design_file",
                                  "product_ID",
                                  product_IDn[i]);
                          String sql95 =
                              "insert into crm_salecredit_balance_details(chain_ID,chain_name,crediter_chain_ID,crediter_chain_name,product_ID,product_name,list_price,list_price_subtotal,cost_price,subtotal,amount,crediter_ID,crediter_name) values('"
                                  + aaa[0]
                                  + "','"
                                  + aaa[1]
                                  + "','"
                                  + aaa1[0]
                                  + "','"
                                  + aaa1[1]
                                  + "','"
                                  + product_IDn[i]
                                  + "','"
                                  + product_namen[i]
                                  + "','"
                                  + list_price
                                  + "','"
                                  + list_price_subtotal
                                  + "','"
                                  + cost_pricen[i]
                                  + "','"
                                  + subtotal
                                  + "','"
                                  + amountn[i]
                                  + "','"
                                  + payer_ID
                                  + "','"
                                  + payer_name
                                  + "')";
                          crm_db.executeUpdate(sql95);
                        }
                      }
                      // ***************************
                    }
                  }
                  String sql =
                      "update stock_apply_pay set reason='"
                          + reason
                          + "',register='"
                          + register
                          + "',register_time='"
                          + register_time
                          + "',demand_return_time='"
                          + demand_return_time
                          + "',register_time='"
                          + register_time
                          + "',register='"
                          + register
                          + "',remark='"
                          + remark
                          + "',demand_amount='"
                          + demand_amount
                          + "',list_price_sum='"
                          + list_price_sum
                          + "',cost_price_sum='"
                          + cost_price_sum
                          + "',not_return_tag='"
                          + not_return_tag
                          + "' where pay_ID='"
                          + pay_ID
                          + "'";
                  stock_db.executeUpdate(sql);
                  if (flag) {
                    sql = "update stock_apply_pay set check_tag='1' where pay_ID='" + pay_ID + "'";
                    stock_db.executeUpdate(sql);
                    if (!vr.validata(
                        (String) dbSession.getAttribute("unit_db_name"),
                        "stock_pay",
                        "reasonexact",
                        pay_ID)) {
                      String sql4 =
                          "insert into stock_pay(pay_ID,reason,reasonexact,reasonexact_details,demand_amount,list_price_sum,cost_price_sum,register,register_time) values('"
                              + stock_pay_ID
                              + "','"
                              + reason
                              + "','"
                              + pay_ID
                              + "','"
                              + payer_name
                              + "','"
                              + demand_amount
                              + "','"
                              + list_price_sum
                              + "','"
                              + cost_price_sum
                              + "','"
                              + register
                              + "','"
                              + register_time
                              + "')";
                      stock_db.executeUpdate(sql4);
                    }

                    String sql98 = "select * from crm_file where customer_ID='" + payer_ID + "'";
                    ResultSet rs98 = crm_db.executeQuery(sql98);
                    if (rs98.next()) {
                      double salecredit_list_price_sum =
                          rs98.getDouble("salecredit_list_price_sum") + list_price_sum;
                      double salecredit_cost_price_sum =
                          rs98.getDouble("salecredit_cost_price_sum") + cost_price_sum;

                      String sql99 =
                          "update crm_file set credit_yes_or_not_tag='1',salecredit_list_price_sum='"
                              + salecredit_list_price_sum
                              + "',salecredit_cost_price_sum='"
                              + salecredit_cost_price_sum
                              + "' where customer_ID='"
                              + payer_ID
                              + "' ";
                      crm_db.executeUpdate(sql99);
                    }
                  } else {
                    sql = "update stock_apply_pay set check_tag='0' where pay_ID='" + pay_ID + "'";
                    stock_db.executeUpdate(sql);
                    Iterator ite = rsList.iterator();
                    while (ite.hasNext()) {
                      elem = (String[]) ite.next();
                      sql =
                          "insert into crm_workflow(config_id,object_ID,describe1,describe2) values ('"
                              + elem[0]
                              + "','"
                              + pay_ID
                              + "','"
                              + elem[1]
                              + "','"
                              + elem[2]
                              + "')";
                      crm_db.executeUpdate(sql);
                    }
                  }

                  response.sendRedirect("draft/crm/credit_ok.jsp?finished_tag=8");
                } else {

                  response.sendRedirect(
                      "draft/crm/credit_ok.jsp?finished_tag=7&pay_ID=" + pay_ID + "");
                }
              } catch (Exception ex) {
                ex.printStackTrace();
              }
            } else {

              response.sendRedirect("draft/crm/credit_ok.jsp?finished_tag=6&pay_ID=" + pay_ID + "");
            }
          } else {

            response.sendRedirect("draft/crm/credit_ok.jsp?finished_tag=9");
          }
        }
        stock_db.commit();
        crm_db.commit();
        stock_db.close();
        crm_db.close();
      } else {
        response.sendRedirect("error_conn.htm");
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
示例#20
0
  Double getCharge(String date, double howLong) {
    int jday = 0;
    Double nMins;
    String day, time, rate = null;
    double remain = howLong;
    StringTokenizer st = new StringTokenizer(date);
    day = st.nextToken();
    time = st.nextToken();
    time = st.nextToken();
    time = st.nextToken().substring(0, 5);
    nMins = AProps.getInstance().toMinutes(time);
    DateFormatSymbols dfs = new DateFormatSymbols();
    String[] days = dfs.getShortWeekdays();
    for (int j = 1; j < days.length; j++) {
      if (day.compareTo(days[j]) == 0) {
        jday = j;
        break;
      }
    }
    int n = rates.size(), tableNMin;
    // One Rate for the entire Login session
    if (n == 1) { // only one flat rate
      // Get time in hours
      Double howLongHr = howLong / 60.0;
      // Calc cost of logon time
      Double cost = new Double(rates(0).loginhr).doubleValue() * howLongHr;
      // Cost of each login
      Double login = new Double(rates(0).login).doubleValue();
      cost = cost + login;
      return (cost);
    }
    // Multiple Rates for this login session
    // Default to last rate in list so that if last rate is eg., Fri and
    // the current day is Sun, it will still use Friday.
    iRE = n - 1;
    RateEntry tmpRE, saveRE = rates(n - 1);
    for (int i = 0; i < n; i++) {
      tmpRE = rates(i);
      if (tmpRE.dayOfWeek() < jday) {
        saveRE = tmpRE;
        iRE = i;
      }
      tableNMin = (AProps.getInstance().toMinutes(tmpRE.time())).intValue();
      if ((tmpRE.dayOfWeek() == jday) && (nMins.intValue() > tableNMin)) {
        saveRE = tmpRE;
        iRE = i;
      }
    }
    tRE = iRE + 1; // iRE set rate, tRE set time until
    if (tRE >= n) tRE = 0;
    Double charge;
    int ndays;
    double diffMins;
    if (tRE == 0) {
      ndays = rates(0).dayOfWeek() + (7 - jday);
    } else {
      ndays = rates(tRE).dayOfWeek() - jday;
    }
    if (ndays > 7) ndays = ndays - 7;
    int nmin = AProps.getInstance().toMinutes(rates(tRE).time()).intValue() - nMins.intValue();
    diffMins = ndays * 24 * 60 + nmin;
    if (remain < diffMins) {
      diffMins = remain;
    }
    // Calc charge for the first period of time up to the next rate change
    Double hours = new Double(diffMins / 60.0);
    charge = new Double(hours * new Double(rates(iRE).loginhr()));
    // Add in the per session login rate
    charge += new Double(rates(iRE).login());
    remain -= diffMins;

    // now we have the charge for the first increment including the login,
    // calculate changes for remaining periods using their rates
    while (remain > 0.0) {

      if ((remain - rates(tRE).nMinutes()) >= 0) {

        charge += rates(tRE).nMinutes() * new Double(rates(tRE).loginhr()) / 60.0;
      } else {

        charge += remain * new Double(rates(tRE).loginhr()) / 60.0;
      }
      remain -= rates(tRE).nMinutes();
      iRE++;
      if (iRE >= n) iRE = 0;
      tRE++;
      if (tRE >= n) tRE = 0;
    }

    return (charge);
  }