Пример #1
0
  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();
      businessComment demo = new businessComment();
      demo.setPath(request);
      Email mail = new Email();
      nseer_db_backup1 design_db = new nseer_db_backup1(dbApplication);
      nseer_db_backup1 intrmanufacture_db = new nseer_db_backup1(dbApplication);
      if (design_db.conn((String) dbSession.getAttribute("unit_db_name"))
          && intrmanufacture_db.conn((String) dbSession.getAttribute("unit_db_name"))) {
        String kind_chain = request.getParameter("kind_chain");
        String chain_id = Divide1.getId(kind_chain);
        String chain_name = Divide1.getName(kind_chain);
        String provider_ID =
            NseerId.getId("intrmanufacture/file", (String) dbSession.getAttribute("unit_db_name"));
        String intrmanufacturer = request.getParameter("intrmanufacturer");
        String intrmanufacturer_ID = request.getParameter("intrmanufacturer_ID");
        String provider_name = request.getParameter("provider_name");
        String provider_address = request.getParameter("provider_address");
        String type = request.getParameter("type");
        String provider_class = request.getParameter("class1");
        String used_provider_name = request.getParameter("used_provider_name");
        String provider_bank = request.getParameter("provider_bank");
        String provider_account = request.getParameter("provider_account");
        String provider_web = request.getParameter("provider_web");
        String provider_tel1 = request.getParameter("provider_tel1");
        String provider_fax = request.getParameter("provider_fax");
        String provider_postcode = request.getParameter("provider_postcode");
        String contact_person1 = request.getParameter("contact_person1");
        String contact_person1_department = request.getParameter("contact_person1_department");
        String contact_person1_duty = request.getParameter("contact_person1_duty");
        String contact_person1_sex = request.getParameter("contact_person1_sex");
        String contact_person1_office_tel = request.getParameter("contact_person1_office_tel");
        String contact_person1_home_tel = request.getParameter("contact_person1_home_tel");
        String contact_person1_mobile = request.getParameter("contact_person1_mobile");
        String contact_person1_email = request.getParameter("contact_person1_email");
        String contact_person2 = request.getParameter("contact_person2");
        String contact_person2_department = request.getParameter("contact_person2_department");
        String contact_person2_duty = request.getParameter("contact_person2_duty");
        String contact_person2_sex = request.getParameter("contact_person2_sex");
        String contact_person2_office_tel = request.getParameter("contact_person2_office_tel");
        String contact_person2_home_tel = request.getParameter("contact_person2_home_tel");
        String contact_person2_mobile = request.getParameter("contact_person2_mobile");
        String contact_person2_email = request.getParameter("contact_person2_email");
        String register = request.getParameter("register");
        String register_time = request.getParameter("register_time");
        String bodyc = new String(request.getParameter("invoice_info").getBytes("UTF-8"), "UTF-8");
        String invoice_info = exchange.toHtml(bodyc);
        String bodya =
            new String(request.getParameter("demand_products").getBytes("UTF-8"), "UTF-8");
        String demand_products = exchange.toHtml(bodya);
        try {
          if (!chain_id.equals("")) {
            String sqll =
                "select * from intrmanufacture_file where provider_ID='"
                    + provider_ID
                    + "' and provider_name='"
                    + provider_name
                    + "'";
            ResultSet rset = intrmanufacture_db.executeQuery(sqll);
            if (rset.next()) {
              response.sendRedirect("portal/oem/register1_ok_a.jsp");
            } else {
              String sql =
                  "insert into intrmanufacture_file(chain_id,chain_name,provider_ID,provider_name,provider_address,provider_class,type,provider_bank,provider_account,provider_web,provider_tel1,provider_fax,provider_postcode,used_provider_name,contact_person1,contact_person1_department,contact_person1_duty,contact_person1_sex,contact_person1_office_tel,contact_person1_home_tel,contact_person1_mobile,contact_person1_email,contact_person2,contact_person2_department,contact_person2_duty,contact_person2_sex,contact_person2_office_tel,contact_person2_home_tel,contact_person2_mobile,contact_person2_email,register,register_time,invoice_info,demand_products,check_tag,modify_tag,excel_tag,intrmanufacturer,intrmanufacturer_ID) values ('"
                      + chain_id
                      + "','"
                      + chain_name
                      + "','"
                      + provider_ID
                      + "','"
                      + provider_name
                      + "','"
                      + provider_address
                      + "','"
                      + provider_class
                      + "','"
                      + type
                      + "','"
                      + provider_bank
                      + "','"
                      + provider_account
                      + "','"
                      + provider_web
                      + "','"
                      + provider_tel1
                      + "','"
                      + provider_fax
                      + "','"
                      + provider_postcode
                      + "','"
                      + used_provider_name
                      + "','"
                      + contact_person1
                      + "','"
                      + contact_person1_department
                      + "','"
                      + contact_person1_duty
                      + "','"
                      + contact_person1_sex
                      + "','"
                      + contact_person1_office_tel
                      + "','"
                      + contact_person1_home_tel
                      + "','"
                      + contact_person1_mobile
                      + "','"
                      + contact_person1_email
                      + "','"
                      + contact_person2
                      + "','"
                      + contact_person2_department
                      + "','"
                      + contact_person2_duty
                      + "','"
                      + contact_person2_sex
                      + "','"
                      + contact_person2_office_tel
                      + "','"
                      + contact_person2_home_tel
                      + "','"
                      + contact_person2_mobile
                      + "','"
                      + contact_person2_email
                      + "','"
                      + register
                      + "','"
                      + register_time
                      + "','"
                      + invoice_info
                      + "','"
                      + demand_products
                      + "','0','0','1','"
                      + intrmanufacturer
                      + "','"
                      + intrmanufacturer_ID
                      + "')";
              intrmanufacture_db.executeUpdate(sql);
              String[] email_box = {contact_person1_email};
              mail.send(
                  email_box,
                  "smtp.sina.com.cn",
                  "*****@*****.**",
                  "123456",
                  demo.getLang("erp", "注册信息"),
                  "欢迎您注册成为我们的委外厂商,您的档案编号是:" + provider_ID);

              CdefineUpdate CdefineUpdate = new CdefineUpdate();
              sql =
                  CdefineUpdate.update("intrmanufacture_file", "provider_ID", provider_ID, request);
              intrmanufacture_db.executeUpdate(sql);
              /** ************************************************** */
              List rsList = (List) new java.util.ArrayList();
              String[] elem = new String[3];
              sql =
                  "select id,describe1,describe2 from intrmanufacture_config_workflow where type_id='01'";
              rset = intrmanufacture_db.executeQuery(sql);
              while (rset.next()) {
                elem = new String[3];
                elem[0] = rset.getString("id");
                elem[1] = rset.getString("describe1");
                elem[2] = rset.getString("describe2");
                rsList.add(elem);
              }
              if (rsList.size() == 0) {
                sql =
                    "update intrmanufacture_file set check_tag='1' where provider_ID='"
                        + provider_ID
                        + "'";
                intrmanufacture_db.executeUpdate(sql);
              } else {
                Iterator ite = rsList.iterator();
                while (ite.hasNext()) {
                  elem = (String[]) ite.next();
                  sql =
                      "insert into intrmanufacture_workflow(config_id,object_ID,describe1,describe2) values ('"
                          + elem[0]
                          + "','"
                          + provider_ID
                          + "','"
                          + elem[1]
                          + "','"
                          + elem[2]
                          + "')";
                  intrmanufacture_db.executeUpdate(sql);
                }
              }
              response.sendRedirect(
                  "portal/oem/register1_choose_attachment.jsp?provider_ID=" + provider_ID + "");
            }
          } else {
            response.sendRedirect("portal/oem/register1_ok_b.jsp");
          }
        } catch (Exception ex) {
          out.println("error" + ex);
        }
        intrmanufacture_db.commit();
        design_db.commit();
        intrmanufacture_db.close();
        design_db.close();
      } else {
        response.sendRedirect("error_conn.htm");
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Пример #2
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();
    }
  }
Пример #3
0
  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();

    nseer_db_backup1 finance_db = new nseer_db_backup1(dbApplication);
    getNameFromID getNameFromID = new getNameFromID();
    PrintWriter out = response.getWriter();
    try {
      if (finance_db.conn((String) dbSession.getAttribute("unit_db_name"))) {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        counter count = new counter(dbApplication);
        ValidataNumber validata = new ValidataNumber();

        String file_id = request.getParameter("file_id");
        String file_name = request.getParameter("file_name");
        String start_time = request.getParameter("start_time");
        String specification = request.getParameter("specification");
        String cb_status = request.getParameter("cb_status");
        String ca_status = request.getParameter("ca_status");
        String change_reason = request.getParameter("change_reason");
        String change_time = request.getParameter("change_date");
        String changer = request.getParameter("changer");
        String sql = "";
        ResultSet rs = null;

        String changebill_id =
            NseerId.getId(
                getClass().getResource("").toString(),
                (String) dbSession.getAttribute("unit_db_name"));
        sql =
            "insert into finance_fa_change(changebill_id,file_id,file_name,start_time,specification,cb_status_id,ca_status_id,change_reason,change_time,changer,change_kind) values('"
                + changebill_id
                + "','"
                + file_id
                + "','"
                + file_name
                + "','"
                + start_time
                + "','"
                + specification
                + "','"
                + cb_status
                + "','"
                + ca_status
                + "','"
                + change_reason
                + "','"
                + change_time
                + "','"
                + changer
                + "','使用状态变动')";
        finance_db.executeUpdate(sql);

        sql = "select * from finance_fa_file where file_id='" + file_id + "'";
        rs = finance_db.executeQuery(sql);
        if (rs.next()) {
          sql =
              "insert into finance_fa_file_dig(card_id,type_id,type_name,file_id,file_name,addway_id,addway_name,department_id,department_name,specification,deposit_place,status_id,calway_id,start_time,lifecycle,currency,original_value,remnant_value,remnant_value_rate,caled_month,caled_sum,cal_subtotal,cal_subtotal_rate,net_value,cal_file_name,work_total,work_sum,work_unit,unit_cal,project,sum_presub,sum_re_presub,caled_time,change_time,exchange_rate,reduceway_id,reduceway_name,reduce_time,clear_income,clear_expense,clear_reason,lately_change_time) values('"
                  + rs.getString("card_id")
                  + "','"
                  + rs.getString("type_id")
                  + "','"
                  + rs.getString("type_name")
                  + "','"
                  + rs.getString("file_id")
                  + "','"
                  + rs.getString("file_name")
                  + "','"
                  + rs.getString("addway_id")
                  + "','"
                  + rs.getString("addway_name")
                  + "','"
                  + rs.getString("department_id")
                  + "','"
                  + rs.getString("department_name")
                  + "','"
                  + rs.getString("specification")
                  + "','"
                  + rs.getString("deposit_place")
                  + "','"
                  + rs.getString("status_id")
                  + "','"
                  + rs.getString("calway_id")
                  + "','"
                  + rs.getString("start_time")
                  + "','"
                  + rs.getString("lifecycle")
                  + "','"
                  + rs.getString("currency")
                  + "','"
                  + rs.getString("original_value")
                  + "','"
                  + rs.getString("remnant_value")
                  + "','"
                  + rs.getString("remnant_value_rate")
                  + "','"
                  + rs.getString("caled_month")
                  + "','"
                  + rs.getString("caled_sum")
                  + "','"
                  + rs.getString("cal_subtotal")
                  + "','"
                  + rs.getString("cal_subtotal_rate")
                  + "','"
                  + rs.getString("net_value")
                  + "','"
                  + rs.getString("cal_file_name")
                  + "','"
                  + rs.getString("work_total")
                  + "','"
                  + rs.getString("work_sum")
                  + "','"
                  + rs.getString("work_unit")
                  + "','"
                  + rs.getString("unit_cal")
                  + "','"
                  + rs.getString("project")
                  + "','"
                  + rs.getString("sum_presub")
                  + "','"
                  + rs.getString("sum_re_presub")
                  + "','"
                  + rs.getString("caled_time")
                  + "','"
                  + rs.getString("change_time")
                  + "','"
                  + rs.getString("exchange_rate")
                  + "','"
                  + rs.getString("reduceway_id")
                  + "','"
                  + rs.getString("reduceway_name")
                  + "','"
                  + rs.getString("reduce_time")
                  + "','"
                  + rs.getString("clear_income")
                  + "','"
                  + rs.getString("clear_expense")
                  + "','"
                  + rs.getString("clear_reason")
                  + "','"
                  + change_time
                  + "')";
          finance_db.executeUpdate(sql);

          sql =
              "update finance_fa_file set status_id='"
                  + ca_status
                  + "',change_time='"
                  + change_time
                  + "' where file_id='"
                  + file_id
                  + "'";
          finance_db.executeUpdate(sql);
        }
        finance_db.commit();
        finance_db.close();
        out.println("提交成功");
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }