Beispiel #1
0
  public void saveModify(Connection con, JUser juser, String modify_content) throws Exception {
    java.sql.Timestamp now = new java.sql.Timestamp(System.currentTimeMillis());

    java.sql.PreparedStatement pstmt = null;
    String sql = null;
    String modify_memo = JUtil.convertNull(this.getModify_memo());
    String szMemo = "";

    if (modify_memo.getBytes().length > 950) {
      // 丢弃前100个字符
      modify_memo = "..." + modify_memo.substring(100);
    }
    if (modify_memo.length() > 0) szMemo = "\n------------------------------------------\n";

    szMemo = "\n" + JUtil.formatDate(now, "YYYY-MM-DD HH:mm") + juser.getUserName();
    szMemo += " 修改本团组,以下为本次修改的内容及原因 \r\n";
    szMemo += " 修改内容:\r\n" + modify_content;

    sql =
        " update t_ym_book "
            + " set modify_memo = ? "
            + "	where group_status >= 4 and group_id = ? ";

    pstmt = con.prepareStatement(sql);
    pstmt.setString(1, modify_memo + szMemo);
    pstmt.setString(2, this.getGroup_id());
    pstmt.executeUpdate();
    pstmt.close();
  }
  /**
   * 检查所选关账日期所有收款有没有审核完毕
   *
   * @param request
   * @param response
   * @return
   * @throws ServletException
   * @throws java.io.IOException
   */
  private String finishConfirmSk(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException {
    com.gemway.util.CNHttpServletRequest req = new com.gemway.util.CNHttpServletRequest(request);
    Connection con = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    String sql = null;
    String res = "-1";

    try {
      con = JDatabase.getJDatabase().getConnection();
      String company_code = JUtil.convertNull(req.getParameter("company_code"));
      String close_date = JUtil.convertNull(req.getParameter("close_date"));
      String model_type = JUtil.convertNull(req.getParameter("model_type"));
      if ("1".equals(model_type)) { // 留学
        sql =
            "select count(*) from t_lx_money where  sk_status=0 and sk_date=? "
                + "and sk_con_id in (select sk_con_id from t_lx_contract_sk where company_code=? )";
      } else if ("2".equals(model_type)) { // 出入境
        sql =
            "select count(*) from t_ym_money where  sk_status=0 and sk_date=? "
                + "and sk_con_id in (select sk_con_id from t_ym_contract_sk where company_code=? )";
      } else if ("3".equals(model_type)) { // 外语学校
        sql =
            "select count(*) from t_flSchool_money where  sk_status=0 and sk_date=? "
                + "and stu_id in (select stu_id from t_flschool_student where company_code=? )";
      } else if ("4".equals(model_type)) { // 华文学校
        sql =
            "select count(*) from t_chSchool_money where  sk_status=0 and sk_date=? "
                + "and stu_id in (select stu_id from t_chschool_student where company_code=? )";
      }
      pstmt = con.prepareStatement(sql);
      pstmt.setDate(1, JUtil.str2SQLDate(close_date));
      pstmt.setString(2, company_code);
      rs = pstmt.executeQuery();
      if (rs.next()) {
        if (rs.getInt(1) != 0) {
          res =
              close_date.substring(0, 4)
                  + "年"
                  + close_date.substring(5, 7)
                  + "月"
                  + close_date.substring(8, 10)
                  + "日的收款单还未审批完毕!\n现在要审批吗?";
        }
      }
      rs.close();
      pstmt.close();
    } catch (Exception e) {
      JLog.getLogger().error("", e);
    } finally {
      if (con != null)
        try {
          con.close();
        } catch (Exception e) {
          e.printStackTrace();
        }
    }
    return res;
  }
Beispiel #3
0
  public static Card getCard(Connection con, String card_id) throws Exception {
    Card cardObj = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    String sql = null;
    sql =
        "select valid,a.card_id,a.regdate, a.card_no, a.member_id,  a.card_class, a.op_type, a.moneyPaid, paidOfPro, con_no, class_name, markup "
            + "  from t_card a "
            + " where a.card_id=?";
    pstmt = con.prepareStatement(sql);
    pstmt.setString(1, card_id);
    rs = pstmt.executeQuery();
    if (rs.next()) {
      cardObj = new Card();
      cardObj.card_id = rs.getString("card_id");
      cardObj.regdate = rs.getDate("regdate");
      cardObj.card_no = rs.getString("card_no");
      cardObj.member_id = rs.getString("member_id");
      cardObj.card_class = rs.getString("card_class");
      cardObj.op_type = rs.getInt("op_type");
      cardObj.setMoneypaid(JUtil.convertNull(rs.getString("moneyPaid")));
      cardObj.paidofpro = JUtil.convertNull(rs.getString("paidOfPro"));
      cardObj.con_no = JUtil.convertNull(rs.getString("con_no"));
      cardObj.class_name = JUtil.convertNull(rs.getString("class_name"));
      cardObj.markup = JUtil.convertNull(rs.getString("markup"));
      cardObj.valid = rs.getInt("valid");
    }
    rs.close();
    pstmt.close();

    return cardObj;
  }
Beispiel #4
0
  /**
   * 根据公司ID,获得对外合同申请的合同类别 取公司对应的合同类型 如公司为空,则取所有
   *
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  private String calExterContractApplyType(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    String xml = null;
    String company_id = JUtil.convertNull(request.getParameter("company_id"));
    String defalut_type = JUtil.convertNull(request.getParameter("defalut_type"));
    xml = "<?xml version='1.0' encoding='gbk'?>\n";
    org.jdom.Element eleRoot = new org.jdom.Element("root");
    org.jdom.Element defalutType = new org.jdom.Element("defalut_type");
    defalutType.setAttribute("defalut_type", defalut_type);
    eleRoot.addContent(defalutType);
    org.jdom.Element eleRows = new org.jdom.Element("contract_types");
    eleRoot.addContent(eleRows);
    org.jdom.Element eleRow = null;

    try {
      List<ExterContractType> lsType = ExterContractType.getContractTypeByCompany(company_id);
      for (ExterContractType type : lsType) {
        eleRow = new org.jdom.Element("contract_type");
        eleRow.setAttribute("con_type_id", type.getCon_type_id());
        eleRow.setAttribute("con_type_name", type.getCon_type_name());
        eleRows.addContent(eleRow);
      }
      org.jdom.output.XMLOutputter xmlout = new org.jdom.output.XMLOutputter();
      xml += xmlout.outputString(eleRoot);
      JLog.getLogger().debug("xml=\n" + xml);
      return xml.trim();
    } catch (Exception e) {
      JLog.getLogger().error("", e);
    }
    return "";
  }
Beispiel #5
0
  /**
   * 判断是否需要必须录入合同金额
   *
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  private String calNeedInputMoney(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    String xml = null;
    String company_id = JUtil.convertNull(request.getParameter("company_id"));
    String exter_contract_type = JUtil.convertNull(request.getParameter("exter_contract_type"));
    String need_con_money = "0";
    xml = "<?xml version='1.0' encoding='gbk'?>\n";
    org.jdom.Element eleRoot = new org.jdom.Element("root");
    org.jdom.Element eleNeed = new org.jdom.Element("need_con_money");

    try {
      List<ExterContractType> lsType = ExterContractType.getContractTypeByCompany(company_id);
      for (ExterContractType type : lsType) {
        if (type.getCon_type_id().equals(exter_contract_type)) {
          if (type.getNeed_con_money() == 1) {
            need_con_money = "1";
          }
          break;
        }
      }
      eleNeed.setAttribute("need_con_money", need_con_money);
      eleRoot.addContent(eleNeed);
      org.jdom.output.XMLOutputter xmlout = new org.jdom.output.XMLOutputter();
      xml += xmlout.outputString(eleRoot);
      JLog.getLogger().debug("xml=\n" + xml);
      return xml.trim();
    } catch (Exception e) {
      JLog.getLogger().error("", e);
    }
    return "";
  }
Beispiel #6
0
  /**
   * 获得对外合同申请的默认审批人
   *
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  private String calDefaultExterContractApprover(
      HttpServletRequest request, HttpServletResponse response) throws Exception {
    String xml = null;
    String company_id = JUtil.convertNull(request.getParameter("company_id"));
    String con_type = JUtil.convertNull(request.getParameter("con_type"));
    String con_money_str = JUtil.convertNull(request.getParameter("con_money"));
    String apply_user_id = JUtil.convertNull(request.getParameter("apply_user_id"));
    Double con_money = null;
    if (con_money_str.length() > 0) {
      try {
        con_money = Double.parseDouble(con_money_str);
      } catch (Exception e) {
      }
    }

    xml = "<?xml version='1.0' encoding='gbk'?>\n";
    org.jdom.Element eleRoot = new org.jdom.Element("root");
    org.jdom.Element eleRows = new org.jdom.Element("users");
    eleRoot.addContent(eleRows);
    org.jdom.Element eleRow = null;

    try {
      Map<String, JUser> mapUser = null;
      if (company_id.length() > 0 && con_type.length() > 0) {
        boolean need_con_money = false;
        List<ExterContractType> lsType = ExterContractType.getContractTypeByCompany(company_id);
        for (ExterContractType type : lsType) {
          if (type.getCon_type_id().equals(con_type)) {
            if (type.getNeed_con_money() == 1) {
              need_con_money = true;
            }
            break;
          }
        }
        if (!need_con_money || con_money != null) {
          mapUser =
              ExterContractApply.getDefaultApprover(
                  company_id, con_type, con_money == null ? 0 : con_money, apply_user_id);
        }
      }
      if (mapUser != null) {
        for (String userId : mapUser.keySet()) {
          JUser user = mapUser.get(userId);
          if (user == null) continue;
          eleRow = new org.jdom.Element("user");
          eleRow.setAttribute("user_id", user.getUserId());
          eleRow.setAttribute("user_name", user.getUserName());
          eleRows.addContent(eleRow);
        }
      }
      org.jdom.output.XMLOutputter xmlout = new org.jdom.output.XMLOutputter();
      xml += xmlout.outputString(eleRoot);
      JLog.getLogger().debug("xml=\n" + xml);
      return xml.trim();
    } catch (Exception e) {
      JLog.getLogger().error("", e);
    }
    return "";
  }
Beispiel #7
0
 public void save(Connection con, JUser juser) throws Exception {
   PreparedStatement pstmt = null;
   java.sql.Timestamp now = new java.sql.Timestamp(System.currentTimeMillis());
   String sql = null;
   int idx = 1;
   if (JUtil.convertNull(this.getGroup_id()).equals("")) {
     sql =
         " insert into t_ym_book(group_id, group_name, inquire_date, group_no, contact,"
             + "	 contact_phone, contact_handset, contact_fax, countries, countries_name, group_type, "
             + "	 memo, company_id, zxgw_id, zxgw_name, take_out, creater, createrName, created) "
             + " values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";
     pstmt = con.prepareStatement(sql);
     this.setGroup_id(JUtil.createUNID());
     pstmt.setString(idx++, this.getGroup_id());
     pstmt.setString(idx++, this.getGroup_name());
     pstmt.setDate(idx++, this.getInquire_date());
     pstmt.setString(idx++, this.getGroup_no());
     pstmt.setString(idx++, this.getContact());
     pstmt.setString(idx++, this.getContact_phone());
     pstmt.setString(idx++, this.getContact_handset());
     pstmt.setString(idx++, this.getContact_fax());
     pstmt.setString(idx++, this.getCountries());
     pstmt.setString(idx++, this.getCountries_name());
     pstmt.setInt(idx++, this.getGroup_type());
     pstmt.setString(idx++, this.getMemo());
     pstmt.setString(idx++, this.getCompany_id());
     pstmt.setString(idx++, this.getZxgw_id());
     pstmt.setString(idx++, this.getZxgw_name());
     pstmt.setString(idx++, this.getTake_out());
     pstmt.setString(idx++, juser.getUserId());
     pstmt.setString(idx++, juser.getUserName());
     pstmt.setTimestamp(idx++, now);
     pstmt.executeUpdate();
     pstmt.close();
   } else {
     sql =
         " update t_ym_book set group_name = ?, inquire_date = ?, memo = ?, "
             + " group_no = ?, contact = ?, contact_phone = ?, contact_handset = ?, contact_fax = ?,"
             + " countries = ?, countries_name = ?, zxgw_id = ?, zxgw_name = ?, take_out = ? "
             + " where group_id = ? ";
     pstmt = con.prepareStatement(sql);
     pstmt.setString(idx++, this.getGroup_name());
     pstmt.setDate(idx++, this.getInquire_date());
     pstmt.setString(idx++, this.getMemo());
     pstmt.setString(idx++, this.getGroup_no());
     pstmt.setString(idx++, this.getContact());
     pstmt.setString(idx++, this.getContact_phone());
     pstmt.setString(idx++, this.getContact_handset());
     pstmt.setString(idx++, this.getContact_fax());
     pstmt.setString(idx++, this.getCountries());
     pstmt.setString(idx++, this.getCountries_name());
     pstmt.setString(idx++, this.getZxgw_id());
     pstmt.setString(idx++, this.getZxgw_name());
     pstmt.setString(idx++, this.getTake_out());
     pstmt.setString(idx++, this.getGroup_id());
     pstmt.executeUpdate();
     pstmt.close();
   }
 }
 public void save(Connection con_hr, boolean approverEdit) throws Exception {
   PreparedStatement pstmt = null;
   int indx = 1;
   String sql = null;
   if (JUtil.convertNull(this.term_id).length() == 0) {
     sql = " insert into  t_emp_assess_detail(term_id,assess_id,term_code) values(?,?,?)";
     this.term_id = com.gemway.util.ID.getIDObject("default").create();
     pstmt = con_hr.prepareStatement(sql);
     pstmt.setString(indx++, this.term_id);
     pstmt.setString(indx++, this.assess_id);
     pstmt.setString(indx++, this.term_code);
     pstmt.executeUpdate();
     pstmt.close();
   }
   lsParam = this.getLsParam();
   if (lsParam.size() > 0) {
     for (TermParam paramObj : lsParam) {
       indx = 1;
       if (JUtil.convertNull(paramObj.term_id).length() == 0) {
         sql =
             "insert into t_assess_term_param(term_id,param_name,param_value_emp,param_value_guider) values(?,?,?,?)";
         pstmt = con_hr.prepareStatement(sql);
         pstmt.setString(indx++, this.term_id);
         pstmt.setString(indx++, paramObj.param_name);
         pstmt.setInt(indx++, paramObj.param_value_emp);
         pstmt.setInt(indx++, paramObj.param_value_guider);
         pstmt.executeUpdate();
         pstmt.close();
       } else {
         if (approverEdit) {
           sql =
               "update t_assess_term_param set param_value_emp=? where term_id =? and param_name=? ";
           pstmt = con_hr.prepareStatement(sql);
           pstmt.setInt(indx++, paramObj.param_value_emp);
           pstmt.setString(indx++, paramObj.term_id);
           pstmt.setString(indx++, paramObj.param_name);
         } else {
           sql =
               "update t_assess_term_param set param_value_guider=? where term_id =? and param_name=? ";
           pstmt = con_hr.prepareStatement(sql);
           pstmt.setInt(indx++, paramObj.param_value_guider);
           pstmt.setString(indx++, paramObj.term_id);
           pstmt.setString(indx++, paramObj.param_name);
         }
         pstmt.executeUpdate();
         pstmt.close();
       }
     }
   }
 }
Beispiel #9
0
  public void save(Connection con, JUser user) throws Exception {
    // 判断卡号是否重复

    PreparedStatement pstmt = null;
    ResultSet rs = null;
    String sql = null;

    sql = "select card_id from t_card where card_class=? and card_no=? and valid = 0 ";
    pstmt = con.prepareStatement(sql);
    int colIndex = 1;
    pstmt.setString(colIndex++, this.card_class);
    pstmt.setString(colIndex++, this.card_no);
    rs = pstmt.executeQuery();
    boolean repeat = false;
    while (rs.next()) {
      String cardId = JUtil.convertNull(rs.getString("card_id"));
      if (!cardId.equals(this.card_id)) {
        repeat = true;
      }
    }

    rs.close();
    pstmt.close();

    if (repeat) {
      throw new Exception("卡号重复");
    }

    if (this.card_id.length() == 0) this.insert(con, user);
    else this.update(con, user);
  }
Beispiel #10
0
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException {
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Pragma", "no-cache");
    response.setContentType("text/xml;charset=gbk");

    String cmd = JUtil.convertNull(request.getParameter("cmd"));

    String xml = null;
    try {
      if (cmd.equals("calExterContractApplyType")) {
        // 根据公司ID,获得对外合同申请的合同类别
        xml = this.calExterContractApplyType(request, response);
      } else if (cmd.equals("calDefaultExterContractApprover")) {
        // 获得对外合同申请的默认审批人
        xml = this.calDefaultExterContractApprover(request, response);
      } else if (cmd.equals("calDefaultGnOrgApprover")) {
        // 获得国内合作渠道申请的默认审批人
        xml = this.calDefaultGnOrgApprover(request, response);
      } else if (cmd.equals("calNeedInputMoney")) {
        xml = this.calNeedInputMoney(request, response);
      } else if (cmd.equals("checkRepeatGnOrg")) {
        // 检查国内合作渠道的名称是否有重复
        xml = this.checkRepeatGnOrg(request, response);
      } else {
        xml = "";
      }
    } catch (Throwable e) {
      e.printStackTrace();
    }
    java.io.PrintWriter out = response.getWriter();
    out.write(xml);
  }
Beispiel #11
0
  public ActionForward view(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    Connection con = null;
    try {
      nps.core.User user = (nps.core.User) request.getSession().getAttribute("user");
      if (user != null) {
        String session_order =
            JUtil.convertNull((String) request.getSession().getAttribute("order"));
        con = dbUtil.getNfwlCon();
        boolean falg = OrderUtil.isNewAndSelfOrder(con, session_order, user.getId());
        if (falg) {
          ITG_ORDERRECManager igom = new ITG_ORDERRECManager();
          ITG_ORDERREC igo = (ITG_ORDERREC) igom.get(con, session_order);
          if (igo != null) {

            request.setAttribute("orderrec", igo);
            // 列表信息
            CartManager cm = new CartManager();
            List<Cart> ls = cm.getUserCarts(con, user.getId(), session_order);
            request.setAttribute("list", ls);

            // 地址信息
            ITG_ORDERRECDELIVERYManager iodm = new ITG_ORDERRECDELIVERYManager();
            ITG_ORDERRECDELIVERY iod = iodm.getByOrder(con, session_order);
            request.setAttribute("address", iod);

            // 支付信息
            ITG_PAYManager ipm = new ITG_PAYManager();
            Bean b = ipm.getByOrder(con, session_order);
            if (b != null) {
              request.setAttribute("pay", b);
            }

            TokenManager.saveToken(request);
          }
        } else {
          request.getSession().removeAttribute("order");
          return mapping.findForward("myorder");
        }
      } else {
        return mapping.findForward("nologing");
      }
    } catch (Exception e) {

      JLog.getLogger().error("显示订单信息出错!", e);
      Message ms = new Message();
      ms.setFlag(false);
      ms.setError("显示订单信息出错!");
      request.setAttribute("message", ms);
      return mapping.findForward("orderError");
    } finally {
      if (con != null) con.close();
    }

    return mapping.findForward("viewSuccess");
  }
  /**
   * 检查所选收款日期是否已经关账
   *
   * @param request
   * @param response
   * @return
   * @throws ServletException
   * @throws java.io.IOException
   */
  private String checkCloseSk(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException {
    com.gemway.util.CNHttpServletRequest req = new com.gemway.util.CNHttpServletRequest(request);
    Connection con = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    String sql = null;
    String res = "-1";

    try {
      con = JDatabase.getJDatabase().getConnection();
      String company_code = JUtil.convertNull(req.getParameter("company_code"));
      String close_date = JUtil.convertNull(req.getParameter("close_date"));
      String model_type = JUtil.convertNull(req.getParameter("model_type"));
      sql =
          "select count(*) as count from t_closeSk where company_code=? and model_type=? and close_date=?";
      pstmt = con.prepareStatement(sql);
      pstmt.setString(1, company_code);
      pstmt.setString(2, model_type);
      pstmt.setDate(3, JUtil.str2SQLDate(close_date));
      rs = pstmt.executeQuery();
      if (rs.next()) {
        if (rs.getInt("count") != 0) {
          res =
              close_date.substring(0, 4)
                  + "年"
                  + close_date.substring(5, 7)
                  + "月"
                  + close_date.substring(8, 10)
                  + "日已经关账,\n请重新选择收款日期!";
        }
      }
    } catch (Exception e) {
      JLog.getLogger().error("", e);
    } finally {
      if (con != null)
        try {
          con.close();
        } catch (Exception e) {
          e.printStackTrace();
        }
    }
    return res;
  }
Beispiel #13
0
  public static void format(Connection con, String kq_date, String branch_id) throws Exception {
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    String sql = null;
    StuKqFormatNew stuKqFormatNewObj = null;

    JLog.getLogger().debug("branch_id=" + branch_id);

    java.sql.Timestamp dKqDate = new java.sql.Timestamp(JUtil.str2SQLDate(kq_date).getTime());
    java.sql.Timestamp nextDate = new java.sql.Timestamp(JUtil.relativeDate(dKqDate, 1).getTime());

    sql =
        " select a.* from t_fl_class_schedule a, shinyway.t_fl_class b "
            + " where a.class_id=b.class_id and b.branch_id=?"
            + " and a.begin_time >=? and a.begin_time <?";
    pstmt = con.prepareStatement(sql);
    pstmt.setString(1, branch_id);
    pstmt.setTimestamp(2, dKqDate);
    pstmt.setTimestamp(3, nextDate);
    JLog.getLogger()
        .debug(
            "sql="
                + sql
                + " branch_id="
                + branch_id
                + " dKqDate="
                + dKqDate
                + " nextDate="
                + nextDate);
    rs = pstmt.executeQuery();
    while (rs.next()) {
      ScheduleDate scheduleObj = new ScheduleDate();
      scheduleObj.setLine_id(rs.getString("line_id"));
      scheduleObj.setClass_id(rs.getString("class_id"));
      scheduleObj.setBegin_time(rs.getTimestamp("begin_time"));
      scheduleObj.setEnd_time(rs.getTimestamp("end_time"));
      JLog.getLogger().debug("class_id=" + scheduleObj.getClass_id());
      formatClassSchedule(con, scheduleObj);
    }
    rs.close();
    pstmt.close();
  }
Beispiel #14
0
  /**
   * 获得国内合作渠道申请的默认审批人
   *
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  private String calDefaultGnOrgApprover(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    String xml = null;
    String company_id = JUtil.convertNull(request.getParameter("company_id"));
    String dep_id = JUtil.convertNull(request.getParameter("dep_id"));
    String contract_template = JUtil.convertNull(request.getParameter("contract_template"));
    String hasDomain_name = JUtil.convertNull(request.getParameter("hasDomain_name"));
    xml = "<?xml version='1.0' encoding='gbk'?>\n";
    org.jdom.Element eleRoot = new org.jdom.Element("root");
    org.jdom.Element eleRows = new org.jdom.Element("users");
    eleRoot.addContent(eleRows);
    org.jdom.Element eleRow = null;
    Connection con = null;
    try {
      con = com.gemway.igo.JDatabase.getJDatabase().getConnection();

      Map<String, JUser> mapUser =
          GnOrgApply.getDefaultApprover(con, company_id, dep_id, contract_template, hasDomain_name);
      if (mapUser != null) {
        for (String userId : mapUser.keySet()) {
          JUser user = mapUser.get(userId);
          if (user == null) continue;

          eleRow = new org.jdom.Element("user");
          eleRow.setAttribute("user_id", user.getUserId());
          eleRow.setAttribute("user_name", user.getUserName());
          eleRows.addContent(eleRow);
        }
      }
      org.jdom.output.XMLOutputter xmlout = new org.jdom.output.XMLOutputter();
      xml += xmlout.outputString(eleRoot);
      // JLog.getLogger().debug("xml=\n" + xml);
      return xml.trim();
    } catch (Exception e) {
      JLog.getLogger().error("", e);
    } finally {
      if (con != null) con.close();
    }
    return "";
  }
Beispiel #15
0
  /**
   * @param biz_type 留学、移民、培训、游学。如果为null则全部
   * @return
   */
  public Map<String, List<JCompany>> getCompanysWithBiz(String biz_type) {
    List<JCompany> lsCompany = null;
    biz_type = JUtil.convertNull(biz_type);
    Map<String, List<JCompany>> districtCompany = new LinkedHashMap<String, List<JCompany>>();
    String[] districts = JCompany.getDistricts();
    for (String district : districts) districtCompany.put(district, new ArrayList<JCompany>());
    if (biz_type.equals("lx")) lsCompany = getCompanyListByBiz("留学");
    else if (biz_type.equals("fl")) lsCompany = getCompanyListByBiz("外语");
    else if (biz_type.equals("ym")) lsCompany = getCompanyListByBiz("移民");
    else if (biz_type.equals("yx")) lsCompany = getCompanyListByBiz("游学");
    else lsCompany = getCompanyList();

    for (JCompany company : lsCompany) {
      String district = JUtil.convertNull(company.getCompany_district());
      if (district.length() == 0) district = "总部";
      List<JCompany> companys = districtCompany.get(district);
      companys.add(company);
      districtCompany.put(district, companys);
    }

    return districtCompany;
  }
  /**
   * 保存修改
   *
   * @param con
   * @throws Exception
   */
  public void save(Connection con, JUser juser) throws Exception {
    PreparedStatement pstmt = null;
    String sql = null;
    int idx = 1;
    int updateCount = 0;
    if (JUtil.convertNull(this.getApproval_id()).length() > 0) {
      sql =
          " update t_ym_process_approval set approver = ?, status = 2 where approval_id = ? and status in(1, 3) ";

      pstmt = con.prepareStatement(sql);
      pstmt.setString(idx++, this.getApprover());
      pstmt.setString(idx++, this.getApproval_id());
      updateCount = pstmt.executeUpdate();
      pstmt.close();
      if (updateCount != 1)
        throw new Exception(
            "更新的记录不只一条approval_id=" + this.getApproval_id() + " con_id=" + this.getCon_id());
    } else {
      sql =
          " insert into t_ym_process_approval(approval_id, con_id, approver, status, "
              + " approval_type, approval_type_name, creater, createrName, created) "
              + " values(?, ?, ?,2,  ?, ?, ?, ?, ?) ";

      pstmt = con.prepareStatement(sql);
      this.setApproval_id(JUtil.createUNID());
      pstmt.setString(idx++, this.getApproval_id());
      pstmt.setString(idx++, this.getCon_id());
      pstmt.setString(idx++, this.getApprover());
      pstmt.setString(idx++, this.getApproval_type());
      pstmt.setString(idx++, this.getApproval_type_name());
      pstmt.setString(idx++, juser.getUserId());
      pstmt.setString(idx++, juser.getUserName());
      pstmt.setTimestamp(idx++, new java.sql.Timestamp(System.currentTimeMillis()));
      pstmt.executeUpdate();
      pstmt.close();
    }
  }
  public static String[] getAllCourses(String company_id) {
    List<String> lsAllCourse = new ArrayList<String>();

    for (Item topItem : Item.getTopItems()) {
      java.util.List<Item> lsItem = topItem.getChildren();
      for (Item item : lsItem) {
        if (JUtil.convertNull(item.getCompany_id()).length() > 0
            && !item.getCompany_id().equals(company_id)) continue;

        lsAllCourse.add(item.getItem_name());
      }
    }
    String[] arrAllCourse = new String[lsAllCourse.size()];
    lsAllCourse.toArray(arrAllCourse);

    return arrAllCourse;
  }
Beispiel #18
0
  public void save(Connection con) throws Exception {

    PreparedStatement pstmt = null;
    String sql = null;

    int index = 1;

    sql =
        "update t_team set team_code = ?, type_code = ? ,team_name = ?,  team_desc = ?, team_manager_id = ?, team_manager_name = ? \n"
            + "where team_id = ? ";
    pstmt = con.prepareStatement(sql);
    ;
    pstmt.setString(index++, this.team_code.toUpperCase());
    pstmt.setString(index++, this.type_code);
    pstmt.setString(index++, this.team_name);
    pstmt.setString(index++, this.team_desc);
    pstmt.setString(index++, this.team_manager_id);
    pstmt.setString(index++, this.team_manager_name);
    pstmt.setString(index++, this.team_id);
    int updateCount = pstmt.executeUpdate();
    pstmt.close();

    if (updateCount == 0) {
      sql =
          " insert into t_team(team_id, team_code, type_code, team_name, team_desc, team_manager_id, team_manager_name, creater, created ) \n "
              + " values( ?, ?, ?, ?, ?, ?, ?, ?, ?)";
      pstmt = con.prepareStatement(sql);
      index = 1;
      this.team_id = JUtil.createUNID();
      pstmt.setString(index++, this.team_id);
      pstmt.setString(index++, this.team_code.toUpperCase());
      pstmt.setString(index++, this.type_code);
      pstmt.setString(index++, this.team_name);
      pstmt.setString(index++, this.team_desc);
      pstmt.setString(index++, this.team_manager_id);
      pstmt.setString(index++, this.team_manager_name);
      pstmt.setString(index++, this.creater);
      pstmt.setTimestamp(index++, this.created);
      pstmt.executeUpdate();
      pstmt.close();
    }
  }
  public static java.util.List<String> getLsIntCourse(Connection con, String cstm_id)
      throws Exception {
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    String qry = null;

    java.util.List<String> lsIntCourse = new java.util.Vector<String>();

    qry = " select item_id from t_fl_interest_courses where cstm_id=? ";
    pstmt = con.prepareStatement(qry);
    pstmt.setString(1, cstm_id);
    rs = pstmt.executeQuery();
    while (rs.next()) {
      lsIntCourse.add(JUtil.convertNull(rs.getString("item_id")));
    }
    rs.close();
    pstmt.close();

    return lsIntCourse;
  }
Beispiel #20
0
  /**
   * 通过审批
   *
   * @param con
   * @param user
   * @throws Exception
   */
  public void pass(Connection con, JUser user) throws Exception {
    PreparedStatement pstmt = null;
    String sql = null;

    GroupBook book = GroupBook.getGroupBook(con, this.getGroup_id());

    String subject = null;
    if (JUtil.convertNull(book.getGroup_no()).length() == 0) {
      sql = " update t_ym_book set group_no = ? " + " where group_id = ? and group_status < 4 ";

      pstmt = con.prepareStatement(sql);
      pstmt.setString(1, createGroupNO());
      pstmt.setString(2, this.group_id);
      pstmt.executeUpdate();
      pstmt.close();
    }

    subject =
        book.getGroup_name() + "的" + GroupBasic.getGroupTypeName(this.getGroup_type()) + "审批已已通过";
    sql =
        " update t_ym_book set group_status = 4, pass_date = ? "
            + " where group_id = ? and group_status < 4 ";

    pstmt = con.prepareStatement(sql);
    pstmt.setTimestamp(1, new java.sql.Timestamp(System.currentTimeMillis()));
    pstmt.setString(2, this.group_id);
    pstmt.executeUpdate();
    pstmt.close();

    int msgWay = JMessageEnum.SYSTEM_MESSAGE;

    JMessageAdapter.sendMessage(
        msgWay,
        new String[] {book.getZxgw_id()},
        subject,
        subject,
        "-1",
        "/ym/group/groupBookControl.jsp?cmd=update&group_id=" + this.getGroup_id(),
        1);
  }
  /**
   * 保存修改
   *
   * @param con
   * @throws Exception
   */
  public static void saveWithOutApproval(
      Connection con, JUser juser, String approval_type, String approval_type_name, String con_id)
      throws Exception {
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    String sql = null;
    int idx = 1;
    int approvalCount = 0;

    sql =
        " select count(*) count from t_ym_process_approval where con_id = ? and approval_type = ?  ";

    pstmt = con.prepareStatement(sql);
    pstmt.setString(idx++, con_id);
    pstmt.setString(idx++, approval_type);
    rs = pstmt.executeQuery();
    if (rs.next()) {
      approvalCount = rs.getInt("count");
    }
    rs.close();
    pstmt.close();
    if (approvalCount > 0) return;
    idx = 1;
    sql =
        " insert into t_ym_process_approval(approval_id, con_id, approver, status, "
            + " approval_type, approval_type_name, creater, createrName, created) "
            + " values(?, ?, ?, 4,  ?, ?, ?, ?, ?) ";

    pstmt = con.prepareStatement(sql);
    pstmt.setString(idx++, JUtil.createUNID());
    pstmt.setString(idx++, con_id);
    pstmt.setString(idx++, "-1");
    pstmt.setString(idx++, approval_type);
    pstmt.setString(idx++, approval_type_name);
    pstmt.setString(idx++, juser.getUserId());
    pstmt.setString(idx++, juser.getUserName());
    pstmt.setTimestamp(idx++, new java.sql.Timestamp(System.currentTimeMillis()));
    pstmt.executeUpdate();
    pstmt.close();
  }
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException {
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Pragma", "no-cache");
    response.setContentType("text/xml;charset=gbk");

    String cmd = JUtil.convertNull(request.getParameter("cmd"));
    String xml = null;
    try {
      if (cmd.equals("checkCloseSk")) {
        xml = this.checkCloseSk(request, response);
      } else if (cmd.equals("finishConfirmSk")) {
        xml = this.finishConfirmSk(request, response);
      } else {
        xml = "";
      }
    } catch (Throwable e) {
      e.printStackTrace();
    }
    java.io.PrintWriter out = response.getWriter();
    out.write(xml);
  }
Beispiel #23
0
  private static java.util.List<FLSchoolMoney> getSkList(
      Connection con, String stu_id, String sk_id) throws java.sql.SQLException {
    java.util.List<FLSchoolMoney> ls = new java.util.Vector<FLSchoolMoney>();
    FLSchoolMoney skObj = null;
    String qry = null;

    qry =
        " select a.sk_id,     a.stu_id,     a.sk_pos_id,    a.sk_date,    a.invoice_type, "
            + "        a.is_sk,     a.sk_item,    a.sk_money,     a.currency,   a.course_con_id,  "
            + "        a.sk_status, a.tk_pay_id,  a.df_pay_id,    a.ds_unit_id,   a.sk_memo,   "
            + "        a.created,   a.creater,    a.confirm_date, a.confirmerName, "
            + "        a.modified,  a.modifier,   a.company_code, a.branch_id,  a.sk_type"
            + "  from t_flschool_money a ";
    if (sk_id != null) {
      qry += " where a.sk_id=? ";
    } else {
      qry += " where a.stu_id=? order by sk_date ";
    }
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    pstmt = con.prepareStatement(qry);
    pstmt.setString(1, sk_id);
    rs = pstmt.executeQuery();
    while (rs.next()) {
      skObj = new FLSchoolMoney();
      ls.add(skObj);

      skObj.sk_id = rs.getString("sk_id");
      skObj.stu_id = rs.getString("stu_id");
      skObj.sk_pos_id = rs.getString("sk_pos_id");
      skObj.sk_date = JUtil.formatDate(rs.getDate("sk_date"), "YYYY-MM-DD");
      skObj.invoice_type = JUtil.convertNull(rs.getString("invoice_type"));

      skObj.is_sk = rs.getInt("is_sk");
      skObj.sk_item = JUtil.convertNull(rs.getString("sk_item"));
      skObj.sk_money = JUtil.convertNull(rs.getString("sk_money"));
      skObj.currency = JUtil.convertNull(rs.getString("currency"));
      skObj.course_con_id = JUtil.convertNull(rs.getString("course_con_id"));

      skObj.sk_status = rs.getInt("sk_status");
      skObj.tk_pay_id = JUtil.convertNull(rs.getString("tk_pay_id"));
      skObj.df_pay_id = JUtil.convertNull(rs.getString("df_pay_id"));
      skObj.ds_unit_id = JUtil.convertNull(rs.getString("ds_unit_id"));
      skObj.sk_memo = JUtil.convertNull(rs.getString("sk_memo"));

      skObj.created = rs.getTimestamp("created");
      skObj.creater = rs.getString("creater");

      skObj.confirmerName = JUtil.convertNull(rs.getString("confirmerName"));
      java.sql.Date d = rs.getDate("confirm_date");
      if (d != null) skObj.confirm_date = JUtil.formatDate(d, "YYYY-MM-DD");

      skObj.modified = rs.getTimestamp("modified");
      skObj.modifier = rs.getString("modifier");

      skObj.company_code = rs.getString("company_code");
      skObj.branch_id = JUtil.convertNull(rs.getString("branch_id"));
      skObj.sk_type = JUtil.convertNull(rs.getString("sk_type"));
    }
    rs.close();
    pstmt.close();

    return ls;
  }
  /**
   * 生产checkbox html代码
   *
   * @param chkName checkbox 名字
   * @param checkedValues 以,分隔
   * @param lineValues 一行显示多少个checkbox 0所有
   * @return
   */
  public static String getCheckHtml(
      String company_id, String chkName, List<String> lsChkValues, int lineValues) {
    int showValues = 0; // 已经显示checkbox 数量 断行后 重新计数
    int width = 110;
    String item_id = null;
    String item_name = null;
    StringBuffer buf = new StringBuffer(64);

    buf.append(
        "<table cellspacing='1' cellpadding='2' border='0' class='TblClass' style='width:100%'>\r\n");
    for (Item topItem : Item.getTopItems()) {
      showValues = 0;
      width = 110;
      if (topItem.getItem_state() == 0) continue;

      if (topItem.getItem_id().equals("3")) {
        // continue;
      }

      if (topItem.getItem_id().equals("4") && !company_id.equals("xt_qd")) continue;

      if (topItem.getItem_id().equals("5") && !company_id.equals("xt_kpl")) continue;

      if (topItem.getItem_id().equals("6") && !company_id.equals("xt_sz")) continue;

      if (topItem.getItem_code().equals("PERSONAL")) {
        if (company_id.equals("xiaen")) {
          topItem = Item.getItemByCode("PERSONAL.JF");
        } else {
          topItem = Item.getItemByCode("PERSONAL.CGKS");
        }
      }
      if (topItem.getItem_code().equals("PERSONAL.JF")
          || topItem.getItem_code().equals("PERSONAL.CGKS")
          || topItem.getItem_code().equals("PERSONAL")) {
        int rowIndex = 1;
        buf.append(
            "<tr height='25px'><td align=\"right\" class=\"DetailBar\" width=80 rowspan="
                + topItem.getChildren().size()
                + ">"
                + topItem.getItem_name()
                + "</td>\r\n");
        for (Item item1 : topItem.getChildren()) {
          if (item1.getItem_state() == 0) continue;

          if (rowIndex == 1) {
            buf.append("<td align='right' class='DetailBar'>" + item1.getItem_name() + "</td>\r\n");
          } else {
            buf.append(
                "<tr><td align='right' class='DetailBar'>" + item1.getItem_name() + "</td>\r\n");
          }

          java.util.List<Item> lsItem = item1.getChildren();
          buf.append("<td class='DetailBar' style='width:560px'>");

          for (Item item : lsItem) {
            boolean bChecked = false;
            if (item.getItem_state() == 0) continue;

            item_id = item.getItem_id();
            item_name = item.getItem_name();
            for (int idx = 0; lsChkValues != null && idx < lsChkValues.size(); idx++) {
              String val = lsChkValues.get(idx);
              if (val.equals(item_id)) {
                bChecked = true;
                lsChkValues.remove(idx);
                break;
              }
            }
            buf.append(
                "  <span style=\"width:"
                    + width
                    + "px\"><input type='checkbox' name='"
                    + chkName
                    + "' showName='"
                    + item_name
                    + "' value='"
                    + item_id
                    + "'");
            if (bChecked) buf.append(" checked");
            buf.append(">" + item_name + "</input></span>");
            showValues++;
            if (lineValues > 0 && showValues == lineValues) {
              buf.append("<br>");
              showValues = 0;
            }
          }
          buf.append("</td></tr>\r\n");
          rowIndex++;
        }

      } else {
        boolean has_child = false;
        java.util.List<Item> lsItem = topItem.getChildren();
        for (Item item : lsItem) {
          if (!topItem.getItem_id().equals("3")) {
            has_child = true;
            break;
          }
          if (JUtil.convertNull(item.getCompany_id()).length() > 0
              && item.getCompany_id().equals(company_id)) {
            has_child = true;
            break;
          }
        }

        if (has_child) {
          buf.append(
              "<tr><td align=\"right\" class=\"DetailBar\" width=80>"
                  + topItem.getItem_name()
                  + "</td>\r\n");
          buf.append("<td class=\"DetailBar\" colspan=2>");
          for (Item item : lsItem) {
            boolean bChecked = false;
            item_id = item.getItem_id();
            item_name = item.getItem_name();

            if (JUtil.convertNull(item.getCompany_id()).length() > 0
                && !item.getCompany_id().equals(company_id)) continue;
            for (int idx = 0; lsChkValues != null && idx < lsChkValues.size(); idx++) {
              String val = lsChkValues.get(idx);
              if (val.equals(item_id)) {
                bChecked = true;
                lsChkValues.remove(idx);
                break;
              }
            }
            buf.append(
                "  <span style=\"width:"
                    + width
                    + "px\"><input type='checkbox' name='"
                    + chkName
                    + "' value='"
                    + item_id
                    + "'");
            if (bChecked) buf.append(" checked");
            buf.append(">" + item_name + "</input></span>");
            showValues++;
            if (lineValues > 0 && showValues == lineValues) {
              buf.append("<br>");
              showValues = 0;
            }
          }
          buf.append("</td></tr>\r\n");
        }
      }
    }
    buf.append("</table>");
    /*
    for(int i=0; ls!=null&&i< ls.size(); i++)
    {
    	String szCourse = ls.get(i);
    	if( szCourse.length() ==0) continue;

    	buf.append("  <input type='checkbox' name='" + chkName + "' value='" + szCourse+ "'" );
    	buf.append(" checked>" + szCourse + "</input>");

    	showValues ++;
    	if( lineValues >0 && showValues  == lineValues){buf.append("<br>"); showValues =0;}
    }*/

    return buf.toString();
  }
Beispiel #25
0
  private void loadCompany(Connection con, String unit_code) throws Exception {
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    String qry = null;

    JCompany obj = null;

    qry =
        " select unit_id, unit_code, unit_name, biz_lx, biz_ym, biz_fl, biz_yx, biz_ch, "
            + "        company_fullName, company_addr,company_district,unit_created "
            + "   from t_unit "
            + "  where unit_code=? ";
    pstmt = con.prepareStatement(qry);
    pstmt.setString(1, unit_code.toUpperCase());
    rs = pstmt.executeQuery();
    if (rs.next()) {
      Set<String> bizSet = null;
      String[] bizTypes = null;
      String szId, szCode, szName;

      bizSet = new HashSet<String>();
      szId = rs.getString("unit_id");
      szCode = rs.getString("unit_code");
      szName = JUtil.convertNull(rs.getString("unit_name"));

      {
        if (rs.getInt("biz_lx") == 1) bizSet.add("留学");
        if (rs.getInt("biz_ym") == 1) bizSet.add("移民");
        if (rs.getInt("biz_yx") == 1) bizSet.add("团组");
        if (rs.getInt("biz_fl") == 1) bizSet.add("外语");
        if (rs.getInt("biz_ch") == 1) bizSet.add("华文");
        bizTypes = new String[bizSet.size()];
        int i = 0;
        for (String biz : bizSet) {
          bizTypes[i++] = biz;
        }
      }

      obj = new JCompany(szId, szCode, szName, bizTypes);

      obj.setCompany_fullName(rs.getString("company_fullName"));
      obj.setCompany_address(rs.getString("company_addr"));
      obj.setCompany_district(rs.getString("company_district"));
      obj.setUnit_created(rs.getDate("unit_created"));
      obj.setBranch(getChildBranch(con, szCode));
    }
    rs.close();
    pstmt.close();

    if (obj == null) return;

    /** ******** 放到 列表 中 ****************** */
    String szId = obj.getCompany_id();
    String szCode = obj.getCompany_code();

    lsBizCompany.remove(szId);
    if (!szCode.startsWith("XT_NB.")) lsBizCompany.add(szId);

    lsOACompany.contains(szId);
    lsOACompany.add(szId);

    mapCompany.put(obj.getCompany_code(), obj);
    int idx = lsCompany.size();
    for (int i = 0; i < lsCompany.size(); i++) {
      JCompany com = lsCompany.get(i);
      if (com.getCompany_id().equals(szId)) {
        idx = i;
        lsCompany.remove(i);
        break;
      }
    }
    lsCompany.add(idx, obj);
  }
Beispiel #26
0
  public ActionForward confirm(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    String url = "";
    Connection con = null;
    try {
      if (TokenManager.isTokenValid(request, true)) {
        nps.core.User user = (nps.core.User) request.getSession().getAttribute("user");
        if (user != null) {
          String session_order =
              JUtil.convertNull((String) request.getSession().getAttribute("order"));
          if (session_order.equals("")) {
            JLog.getLogger().info("没有订单可以确认");
            Message ms = new Message();
            ms.setFlag(false);
            ms.setError("没有订单可以确认!");
            request.setAttribute("message", ms);
            return mapping.findForward("orderFailed");
          } else {
            con = dbUtil.getNfwlCon();
            boolean falg = OrderUtil.isNewAndSelfOrder(con, session_order, user.getId());
            if (falg) {
              ITG_PAYManager ipm = new ITG_PAYManager();
              ITG_PAY pay = (ITG_PAY) ipm.getByOrder(con, session_order);
              if (pay != null) {
                ITG_ORDERRECManager igom = new ITG_ORDERRECManager();
                ITG_ORDERREC igo = igom.get(con, session_order);

                String or_memo = JUtil.convertNull(request.getParameter("or_memo"));
                String or_invoicetitle = JUtil.convertNull(request.getParameter("or_invoicetitle"));
                igom.confirmOrder(con, igo, or_memo, or_invoicetitle);
                if (pay.getPay_type().equals(PayTypeEnum.DEFAULT.getCode())) {
                  url = "/order/pay.do?cmd=pay&or_id=" + session_order;
                } else {
                  request.setAttribute("or_id", session_order);
                  url = "/order/alipayto.jsp";
                }
                request.getSession().removeAttribute("order");
              } else {
                JLog.getLogger().info("没有支付信息");
                Message ms = new Message();
                ms.setFlag(false);
                ms.setError("没有支付信息!");
                request.setAttribute("message", ms);
                return mapping.findForward("orderFailed");
              }
            } else {
              request.getSession().removeAttribute("order");
              return mapping.findForward("myorder");
            }
          }

        } else {
          return mapping.findForward("nologing");
        }
      } else {
        JLog.getLogger().info("非法的确认订单");
        Message ms = new Message();
        ms.setFlag(false);
        ms.setError("非法的确认订单!");
        request.setAttribute("message", ms);
        return mapping.findForward("orderFailed");
      }

    } catch (Exception e) {
      JLog.getLogger().error("确认订单信息出错!", e);
      Message ms = new Message();
      ms.setFlag(false);
      ms.setError("显示订单信息出错!");
      request.setAttribute("message", ms);
      return mapping.findForward("orderError");
    } finally {
      if (con != null) con.close();
    }
    return new ActionForward(url);
  }
Beispiel #27
0
  public void save(Connection con, JUser user) throws Exception {
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    String qry = null;
    java.util.Date skDate = JUtil.str2SQLDate(sk_date);
    java.util.Date today = new java.util.Date();
    java.util.Date two_workDate = CommonOptions.getConfirmerCanMoidyDate();

    if (JUtil.daysAfter(skDate, today) < 0) {
      throw new Exception("收款日期不能在今天之后");
    }
    if (JUtil.daysAfter(skDate, two_workDate) > 0) {
      throw new Exception("收款日期不能在" + JUtil.formatDate(two_workDate, "YYYY-MM-DD") + "之前");
    }

    if (this.company_code.length() == 0) throw new Exception("公司代码不能为空");
    if (this.invoice_type.length() == 0) throw new Exception("开票类型不能为空");
    if (this.currency.length() == 0) throw new Exception("币种不能为空");
    SKItem itemObj = SKItem.getSkItem(sk_item);
    if (itemObj.getItem_type() == 1 || itemObj.getItem_type() == 9 || sk_item.equals("fl.yj.htk")) {
      if (branch_id == null || branch_id.length() == 0) throw new Exception("费用归属分校不能为空");
    }

    if (course_con_id == null || course_con_id.length() == 0) {
      qry =
          "select a.emp_id "
              + "  from shinyway.fl_sale_dist a, t_flschool_student b "
              + " where a.cs_stu_id=b.cs_stu_id and b.stu_id=?"
              + " order by a.row_no";
      pstmt = con.prepareStatement(qry);
      pstmt.setString(1, stu_id);
      rs = pstmt.executeQuery();
      if (rs.next()) course_con_id = rs.getString("emp_id");
      rs.close();
      pstmt.close();
    }

    String skPosName = null;
    if (JSkPos.getSkPosById(sk_pos_id) == null) {
      sk_pos_id = null;
    } else {
      skPosName = JSkPos.getSkPosById(sk_pos_id).getPos_name(); // 收款点名称
    }

    if (sk_id.length() > 0) {
      java.util.Date oldSkDate =
          JUtil.str2SQLDate(FLSchoolMoney.getFLSchoolMoney(con, sk_id).getSk_date()); // 修改前的收款日期
      if (JUtil.daysAfter(oldSkDate, two_workDate) > 0) {
        throw new Exception("不能修改一个工作日前的数据");
      }
      qry =
          " update t_flschool_money "
              + "    set company_code=?, branch_id=?, sk_pos_id=?, sk_pos_name=?, "
              + "        sk_date =?, is_sk=?, stu_id=?,   invoice_type=?, sk_money=?, "
              + "        sk_item=?,  currency=?, course_con_id=?, ds_unit_id=?,  "
              + "        sk_memo=?, modified=?, modifier=?, sk_type=?"
              + "  where sk_id=?";
      int colIndex = 1;
      pstmt = con.prepareStatement(qry);

      pstmt.setString(colIndex++, this.company_code);
      pstmt.setString(colIndex++, this.branch_id);
      pstmt.setString(colIndex++, this.sk_pos_id);
      pstmt.setString(colIndex++, skPosName);
      pstmt.setDate(colIndex++, JUtil.str2SQLDate(sk_date));
      pstmt.setInt(colIndex++, this.is_sk);
      pstmt.setString(colIndex++, this.stu_id);
      pstmt.setString(colIndex++, this.invoice_type);
      pstmt.setString(colIndex++, sk_money);
      pstmt.setString(colIndex++, sk_item);
      pstmt.setString(colIndex++, currency);
      pstmt.setString(colIndex++, this.course_con_id);

      if (ds_unit_id.length() == 0) pstmt.setString(colIndex++, null);
      else pstmt.setString(colIndex++, ds_unit_id);
      pstmt.setString(colIndex++, sk_memo);
      pstmt.setTimestamp(colIndex++, new java.sql.Timestamp(System.currentTimeMillis()));
      pstmt.setString(colIndex++, user.getUserId());
      pstmt.setString(colIndex++, this.sk_type);
      pstmt.setString(colIndex++, sk_id);
      pstmt.executeUpdate();
      pstmt.close();
    } else {
      sk_id = com.gemway.util.ID.getIDObject("DEFAULT").create();

      qry =
          " insert into t_flschool_money "
              + "   (sk_id,     company_code,  branch_id, stu_id,    sk_pos_id,    sk_pos_name,  sk_date,      "
              + "    is_sk,     invoice_type,  sk_money,  sk_item,   currency,     course_con_id,  "
              + "    tk_pay_id, df_pay_id, ds_unit_id,    sk_memo,   sk_status,   creater, created, sk_type) "
              + " values(?,?,?,?,?,?,?,   ?,?,?,?,?,?,  ?,?,?,?,0,?,sysdate,?)";

      int colIndex = 1;
      pstmt = con.prepareStatement(qry);
      pstmt.setString(colIndex++, sk_id);
      pstmt.setString(colIndex++, this.company_code);
      pstmt.setString(colIndex++, this.branch_id);
      pstmt.setString(colIndex++, this.stu_id);
      pstmt.setString(colIndex++, this.sk_pos_id);
      pstmt.setString(colIndex++, skPosName);
      pstmt.setDate(colIndex++, JUtil.str2SQLDate(sk_date));

      pstmt.setInt(colIndex++, this.is_sk);
      pstmt.setString(colIndex++, this.invoice_type);
      pstmt.setDouble(colIndex++, Double.parseDouble(sk_money));
      pstmt.setString(colIndex++, sk_item);
      pstmt.setString(colIndex++, currency);
      pstmt.setString(colIndex++, this.course_con_id);

      pstmt.setString(colIndex++, this.tk_pay_id);
      pstmt.setString(colIndex++, this.df_pay_id);
      pstmt.setString(colIndex++, ds_unit_id.length() == 0 ? null : ds_unit_id);
      pstmt.setString(colIndex++, sk_memo);
      pstmt.setString(colIndex++, user.getUserId());
      pstmt.setString(colIndex++, this.sk_type);
      pstmt.executeUpdate();
      pstmt.close();
    }

    com.gemway.igo.fl.kh.SaleDist.distSkSales(con, sk_id);
    FLSchoolStu.setStatData(con, this.stu_id);
  }
Beispiel #28
0
  public static int delete(JUser user, Connection con, String[] sk_ids) throws Exception {
    int delRows = 0; // 删除的行数

    if (sk_ids == null) return delRows;
    PreparedStatement pstmt = null, pstmt1 = null, pstmt2 = null;
    ResultSet rs = null;
    String sql = null;

    // 下个月的 两个工作日内 可以修改
    java.util.Date two_workDate = CommonOptions.getConfirmerCanMoidyDate();

    sql = "delete from shinyway.emp_fl_sales where sk_id=? ";
    pstmt = con.prepareStatement(sql);

    sql = "delete from t_flschool_money where sk_id=? and sk_status !=1";
    pstmt1 = con.prepareStatement(sql);

    sql = "select count(*) from t_flschool_money where stu_id=?";
    pstmt2 = con.prepareStatement(sql);

    Connection con_igo = com.gemway.igo.JDatabase.getJDatabase().getConnection();
    String szOperateCompanyCodes = user.getOperateCompanyCodeClause(con_igo, "money", "fl_confirm");
    con_igo.close();

    for (int i = 0; i < sk_ids.length; i++) {
      boolean canDel = false;
      FLSchoolMoney moneyObj = FLSchoolMoney.getFLSchoolMoney(con, sk_ids[i]);

      java.util.Date oldSkDate = JUtil.str2SQLDate(moneyObj.getSk_date()); // 修改前的收款日期

      if ((moneyObj.getSk_status() == 0 || moneyObj.getSk_status() == 2)
          && JUtil.daysAfter(oldSkDate, two_workDate) <= 0) {
        // 审核状态的数据不能删除
        if (user.HasFunc("fl_confirm", "money")
            && szOperateCompanyCodes.indexOf(moneyObj.getCompany_code()) != -1) {
          canDel = true; // 有审核权限的人只能删除一个工作日之内的数据
        } else if (moneyObj.getCreater().equals(user.getUserId())) {
          canDel = true; // 无审核权限的人只能删除自己录入的一个工作日之内的数据
        }
      }
      if (canDel) {
        int updateCount = 0;

        pstmt.setString(1, sk_ids[i]);
        pstmt.executeUpdate();

        pstmt1.setString(1, sk_ids[i]);
        updateCount = pstmt1.executeUpdate();
        if (updateCount > 1) throw new Exception("删除记录超过一条");
        delRows++;

        String stu_id = moneyObj.getStu_id();

        pstmt2.setString(1, stu_id);
        rs = pstmt2.executeQuery();
        rs.next();
        int count = rs.getInt(1);
        rs.close();

        FLSchoolStu.setStatData(con, stu_id);

        if (count == 0) FLSchoolStu.delete(con, stu_id);
        rs.close();
      }
    }
    pstmt.close();
    pstmt1.close();
    pstmt2.close();

    return delRows;
  }
  /**
   * 审批
   *
   * @param user
   * @param jobId
   * @param agree
   * @param suggest
   */
  public void approve(JUser user, String jobId, boolean agree, String suggest) throws Exception {
    Connection con = null;
    PreparedStatement pstmt = null;
    String sql = null;
    Job job = null;
    java.util.Map<String, Object> context = new java.util.HashMap<String, Object>();
    StringBuffer contextXML = new StringBuffer();

    context.put("user_id", user.getUserId()); // 当前操作人
    context.put("approveFlag", (agree ? "1" : "0")); // 审批标记
    context.put("suggest", suggest); // 审批意见
    boolean end = true;
    try {
      con = JDatabase.getJDatabase().getConnection();
      con.setAutoCommit(false);
      job = Job.getJobById(con, jobId);

      contextXML.append("<ContextData>");
      contextXML.append("<approval><flag>" + (agree ? "1" : "0") + "</flag></approval>");

      if (agree) {
        YmContract contract = YmContract.getYmContractByConId(con, this.getCon_id());
        YmProcessItem item =
            YmProcessItem.getYmProcessItem(contract.getApply_project(), this.getApproval_type());
        if (item != null
            && !user.getUserId().equals(this.getApprover())
            && item.getCon_lead_app() == 1) {
          end = false;
          contextXML.append("<approver>" + this.getApprover() + "</approver>");
        }
        contextXML.append("<Participants>");
        contextXML.append("<Participant type=\"user\">");
        if (item != null
            && !user.getUserId().equals(this.getApprover())
            && item.getCon_lead_app() == 1) {
          contextXML.append("<user>" + this.getApprover() + "</user>");
        }
        contextXML.append("</Participant>");
        contextXML.append("</Participants>");
      }
      contextXML.append("</ContextData>");
      context.put("contextXML", contextXML.toString());
      job.setContext(context);
      job.start(con);

      if (!agree) {
        sql = "update t_ym_process_approval set status = 3 where approval_id = ? ";
        pstmt = con.prepareStatement(sql);
        pstmt.setString(1, this.getApproval_id());
        pstmt.executeUpdate();
        pstmt.close();
        YmContract contract = YmContract.getYmContractByConId(con, this.getCon_id());
        int msgWay = JMessageEnum.SYSTEM_MESSAGE;

        Set<String> set = new HashSet<String>();
        set.add(contract.getCon_visa_con());
        if (!set.contains(contract.getCon_visa_guide())) set.add(contract.getCon_visa_guide());

        String toUserIds[] = new String[set.size()];
        int i = 0;
        for (Iterator<String> iter = set.iterator(); iter.hasNext(); i++) {
          toUserIds[i] = (String) iter.next();
        }

        String subject =
            contract.getCstm_name()
                + "的办理进程"
                + JUtil.convertNull(this.getApproval_type_name())
                + "审核未通过";
        String url = "/ym/processControl.jsp?cmd=update&con_id=" + this.getCon_id();
        JMessageAdapter.sendMessage(msgWay, toUserIds, subject, subject, "-1", url);
      } else if (job.getActivityId().equals("manager") && end) {
        this.pass(con, suggest);
      }
      con.commit();
    } catch (Exception e) {
      throw e;
    } finally {
      if (con != null) con.rollback();
      if (con != null) con.close();
    }
  }
  /**
   * 通过审批
   *
   * @param con
   */
  public void pass(Connection con, String suggest) throws Exception {
    String sql = null;
    PreparedStatement pstmt = null;
    YmContract contract = YmContract.getYmContractByConId(con, this.getCon_id());
    java.sql.Timestamp now = new java.sql.Timestamp(System.currentTimeMillis());
    int updateCount = 0;
    sql =
        "update t_ym_process_approval set status = 4, pass_date = ? where approval_id = ? and status = 2 ";
    pstmt = con.prepareStatement(sql);
    pstmt.setTimestamp(1, now);
    pstmt.setString(2, this.getApproval_id());
    updateCount = pstmt.executeUpdate();
    pstmt.close();
    if (updateCount != 1) throw new Exception("更新记录不是一条");

    int msgWay = JMessageEnum.SYSTEM_MESSAGE;

    Set<String> set = new HashSet<String>();
    set.add(contract.getCon_visa_con());
    if (!set.contains(contract.getCon_visa_guide())) set.add(contract.getCon_visa_guide());

    String toUserIds[] = new String[set.size()];
    int i = 0;
    for (Iterator<String> iter = set.iterator(); iter.hasNext(); i++) {
      toUserIds[i] = (String) iter.next();
    }

    String subject =
        contract.getCstm_name()
            + "的办理进程"
            + JUtil.convertNull(this.getApproval_type_name())
            + "审批已经通过审批!";
    String url = "/ym/processControl.jsp?cmd=update&con_id=" + contract.getCon_id();
    JMessageAdapter.sendMessage(msgWay, toUserIds, subject, subject, "-1", url);

    YmProcessItem item =
        YmProcessItem.getYmProcessItem(contract.getApply_project(), this.getApproval_type());
    if (YmProcess.isNewProcess(contract.getApply_project())) {
      int count = 0;
      sql = " select count(*) item_count from t_ym_process_date where con_id = ? and item_id = ?  ";
      pstmt = con.prepareStatement(sql);
      pstmt.setString(1, contract.getCon_id());
      pstmt.setString(2, item.getItem_id());
      ResultSet rs = pstmt.executeQuery();

      if (rs.next()) {
        count = rs.getInt("item_count");
      }
      rs.close();
      pstmt.close();
      if (count == 0) {
        sql = " insert into t_ym_process_date(con_id, item_id, done_date) values(?, ?, ?) ";
        pstmt = con.prepareStatement(sql);
        pstmt.setString(1, contract.getCon_id());
        pstmt.setString(2, item.getItem_id());
        pstmt.setDate(3, JUtil.str2SQLDate(JUtil.formatDate(now, "YYYY-MM-DD")));
        pstmt.executeUpdate();
        pstmt.close();
      } else {
        sql = " update t_ym_process_date set done_date = ? where con_id = ? and item_id = ? ";
        pstmt = con.prepareStatement(sql);
        pstmt.setDate(1, JUtil.str2SQLDate(JUtil.formatDate(now, "YYYY-MM-DD")));
        pstmt.setString(2, contract.getCon_id());
        pstmt.setString(3, item.getItem_id());
        pstmt.executeUpdate();
        pstmt.close();
      }
    }

    if (item.getShow_approval() == 1 && this.getApproval_type().indexOf("date_item") > -1) {
      // 如果时间点已经录过,则不覆盖
      sql =
          " select "
              + this.getApproval_type()
              + " as type_date from t_ym_process where con_id = ? ";
      pstmt = con.prepareStatement(sql);
      pstmt.setString(1, contract.getCon_id());
      ResultSet rs = pstmt.executeQuery();
      java.sql.Date type_date = null;
      if (rs.next()) {
        type_date = rs.getDate("type_date");
      }
      rs.close();
      pstmt.close();
      if (type_date == null) {
        // 审批时间既为提交时间
        sql = " update t_ym_process set " + this.getApproval_type() + " = ? where con_id = ? ";
        pstmt = con.prepareStatement(sql);
        pstmt.setDate(1, JUtil.str2SQLDate(JUtil.formatDate(now, "YYYY-MM-DD")));
        pstmt.setString(2, contract.getCon_id());
        updateCount = pstmt.executeUpdate();
        pstmt.close();
        if (updateCount == 0) {
          sql = " insert into t_ym_process(" + this.getApproval_type() + ", con_id) values(?,?)";
          pstmt = con.prepareStatement(sql);
          pstmt.setDate(1, JUtil.str2SQLDate(JUtil.formatDate(now, "YYYY-MM-DD")));
          pstmt.setString(2, contract.getCon_id());
          pstmt.executeUpdate();
        }
        KHRecord.saveYjDate(
            con,
            JUtil.str2SQLDate(JUtil.formatDate(now, "YYYY-MM-DD")),
            contract.getCon_no(),
            this.getApproval_type());
      }
    }
    // 生成新流程
    YmProcessEvolve.initEvolveDay1(con, this.getCon_id());
    // 保存办理进程时,修改办理进展
    YmProcessEvolve.autoModifyEvolve(con, this.getCon_id());
    // 保存办理进程时,修改办理进展(针对于新流程)
    YmProcessEvolve.autoModifyEvolve1(con, this.getCon_id());
  }