Example #1
0
  public static void format(String kq_date) throws Exception {
    Connection con = null;
    try {
      con = com.gemway.igo.JDatabase.getPkJDatabase().getConnection();
      con.setAutoCommit(false);
      for (JCompany comObj : JCompany.getFlCompanyList()) {
        java.util.List<Branch> lsBranch =
            com.gemway.igo.fl.Branch.getBranches(comObj.getCompany_id());

        for (int i = 0; lsBranch != null && i < lsBranch.size(); i++) {
          format(con, kq_date, lsBranch.get(i).getBranch_id());
        }
      }
      con.commit();
    } catch (Throwable e) {
      JLog.getLogger().error("自动生成日度考勤服务出错:", e);
    } finally {
      if (con != null) {
        try {
          con.rollback();
          con.close();
          con = null;
        } catch (Exception e) {
        }
      }
    }
  }
Example #2
0
 public void loadCompany(String unit_code) throws Exception {
   Connection con = null;
   try {
     con = com.gemway.igo.JDatabase.getJDatabase().getConnection();
     loadCompany(con, unit_code);
   } catch (Exception e) {
     JLog.getLogger().error("", e);
   } finally {
     if (con != null)
       try {
         con.close();
       } catch (Exception e) {
       }
   }
 }
Example #3
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;
  }
Example #4
0
  /**
   * 格式化某位员工 某一天的 考勤信息
   *
   * @param con
   * @param schedule_id 某节课ID t_fl_class_schedule.line_id
   * @throws Exception
   */
  private static void formatClassSchedule(Connection con, ScheduleDate scheduleObj)
      throws Exception {
    Connection con_igo = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    String sql = null;
    StuKqFormatNew stuKqFormatNewObj = null;
    String class_id = null;
    java.sql.Timestamp begin_time = null;

    class_id = scheduleObj.getClass_id();
    begin_time = scheduleObj.getBegin_time();

    String szClassDate = JUtil.formatDate(begin_time, "YYYY-MM-DD");

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

    java.util.List<StuKqFormatNew> lsStuKqFormatNew = new java.util.ArrayList<StuKqFormatNew>();
    try {
      // 附加学生基本信息
      con_igo = com.gemway.igo.JDatabase.getJDatabase().getConnection();

      sql =
          "	select a.stu_id, b.stu_no, b.company_id, b.father_phone, c.cstm_name, c.cstm_phone, c.cstm_handset  "
              + " from t_fl_course_stu a, t_fl_student b, t_custom c "
              + " where a.cstm_id=b.cstm_id and b.cstm_id = c.cstm_id and a.course_id=?";
      pstmt = con_igo.prepareStatement(sql);
      pstmt.setString(1, class_id);
      rs = pstmt.executeQuery();
      while (rs.next()) {
        stuKqFormatNewObj = new StuKqFormatNew();
        stuKqFormatNewObj.setKq_id(com.gemway.util.ID.getIDObject("DEFAULT").create());
        stuKqFormatNewObj.setKq_date(JUtil.str2SQLDate(szClassDate));
        stuKqFormatNewObj.setClass_id(scheduleObj.getClass_id());
        stuKqFormatNewObj.setLine_id(scheduleObj.getLine_id());
        stuKqFormatNewObj.setStu_name(rs.getString("cstm_name"));
        stuKqFormatNewObj.setStu_no(rs.getString("stu_no"));
        stuKqFormatNewObj.setIs_late(0);
        stuKqFormatNewObj.setEarlygo(0);
        stuKqFormatNewObj.setAbsenteeism(0);
        stuKqFormatNewObj.setLeave_out(0);
        stuKqFormatNewObj.setFather_phone(rs.getString("father_phone"));
        lsStuKqFormatNew.add(stuKqFormatNewObj);
      }
      rs.close();
      pstmt.close();
    } catch (Exception e) {
      throw e;
    } finally {
      if (con_igo != null) con_igo.close();
    }

    // 格式化前删除原来信息
    sql = "delete from t_fl_stu_kq_format_new where line_id=?";
    pstmt = con.prepareStatement(sql);
    pstmt.setString(1, scheduleObj.getLine_id());
    pstmt.executeUpdate();
    pstmt.close();

    for (int i = 0; i < lsStuKqFormatNew.size(); i++) {
      stuKqFormatNewObj = lsStuKqFormatNew.get(i);
      sql =
          " insert into t_fl_stu_kq_format_new "
              + " (kq_id, kq_date, class_id, line_id, stu_name, stu_no, is_late, "
              + "  earlygo, absenteeism, leave_out, father_phone, created) "
              + " values(?,?,?,?,?,?,?,?,?,?,?,?)";
      pstmt = con.prepareStatement(sql);
      int rowIndex = 1;
      pstmt.setString(rowIndex++, stuKqFormatNewObj.getKq_id());
      pstmt.setDate(rowIndex++, stuKqFormatNewObj.getKq_date());
      pstmt.setString(rowIndex++, stuKqFormatNewObj.getClass_id());
      pstmt.setString(rowIndex++, stuKqFormatNewObj.getLine_id());
      pstmt.setString(rowIndex++, stuKqFormatNewObj.getStu_name());
      pstmt.setString(rowIndex++, stuKqFormatNewObj.getStu_no());
      pstmt.setInt(rowIndex++, stuKqFormatNewObj.getIs_late());
      pstmt.setInt(rowIndex++, stuKqFormatNewObj.getEarlygo());
      pstmt.setInt(rowIndex++, stuKqFormatNewObj.getAbsenteeism());
      pstmt.setInt(rowIndex++, stuKqFormatNewObj.getLeave_out());
      pstmt.setString(rowIndex++, stuKqFormatNewObj.getFather_phone());
      pstmt.setTimestamp(rowIndex++, new java.sql.Timestamp(System.currentTimeMillis()));
      pstmt.executeUpdate();
      pstmt.close();
    }
  }