Search in sources :

Example 1 with BloodPressure

use of com.zyf.bean.BloodPressure in project HeartWatchdogJsp by Viczyf.

the class BloodpressureServlet method select_time_bloodpressure.

private void select_time_bloodpressure(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    BloodPressureDao bloodPressureDao = new BloodPressureDao();
    String startdate = request.getParameter("startdate");
    String enddate = request.getParameter("enddate");
    HttpSession session = request.getSession();
    User user = (User) session.getAttribute("user");
    int uid = user.getUid();
    System.out.println("uid" + uid);
    List bpList = bloodPressureDao.queryTimeBloodPressure(uid, startdate, enddate);
    System.out.println(bpList.size());
    JsonArray array = new JsonArray();
    for (int i = 0; i < bpList.size(); i++) {
        BloodPressure bp = (BloodPressure) bpList.get(i);
        JsonObject ob = new JsonObject();
        ob.addProperty("id", i + 1);
        ob.addProperty("date", bp.getDate());
        ob.addProperty("highPressure", bp.getHighpressure());
        ob.addProperty("lowPressure", bp.getLowpressure());
        ob.addProperty("xinlv", bp.getXinlv());
        array.add(ob);
    }
    System.out.println(array);
    PrintWriter out = response.getWriter();
    out.print(array);
}
Also used : JsonArray(com.google.gson.JsonArray) BloodPressure(com.zyf.bean.BloodPressure) User(com.zyf.bean.User) BloodPressureDao(com.zyf.dao.BloodPressureDao) HttpSession(javax.servlet.http.HttpSession) JsonObject(com.google.gson.JsonObject) List(java.util.List) PrintWriter(java.io.PrintWriter)

Example 2 with BloodPressure

use of com.zyf.bean.BloodPressure in project HeartWatchdogJsp by Viczyf.

the class BloodPressureDao method queryBloodPressure.

public List queryBloodPressure(int uid) {
    String sql = "";
    ;
    sql = "select * from bloodpressure where uid ='" + uid + "' order by id desc";
    ArrayList list = null;
    BloodPressure bp = null;
    ResultSet rs = this.connection.executeQuery(sql);
    if (rs != null) {
        list = new ArrayList();
        try {
            while (rs.next()) {
                bp = new BloodPressure();
                bp.setId(rs.getInt(1));
                bp.setUid(rs.getInt(2));
                bp.setDate(rs.getString(3));
                bp.setHighpressure(rs.getInt(4));
                bp.setLowpressure(rs.getInt(5));
                bp.setXinlv(rs.getInt(6));
                list.add(bp);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
    return list;
}
Also used : BloodPressure(com.zyf.bean.BloodPressure) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet)

Example 3 with BloodPressure

use of com.zyf.bean.BloodPressure in project HeartWatchdogJsp by Viczyf.

the class BloodpressureServlet method selectBloodpressure.

private void selectBloodpressure(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    BloodPressureDao bloodPressureDao = new BloodPressureDao();
    HttpSession session = request.getSession();
    User user = (User) session.getAttribute("user");
    int uid = user.getUid();
    List bpList = bloodPressureDao.queryBloodPressure(uid);
    JsonArray array = new JsonArray();
    for (int i = 0; i < bpList.size(); i++) {
        BloodPressure bp = (BloodPressure) bpList.get(i);
        JsonObject ob = new JsonObject();
        ob.addProperty("id", i + 1);
        ob.addProperty("date", bp.getDate());
        ob.addProperty("highPressure", bp.getHighpressure());
        ob.addProperty("lowPressure", bp.getLowpressure());
        ob.addProperty("xinlv", bp.getXinlv());
        array.add(ob);
    }
    System.out.println(array);
    PrintWriter out = response.getWriter();
    out.print(array);
}
Also used : JsonArray(com.google.gson.JsonArray) BloodPressure(com.zyf.bean.BloodPressure) User(com.zyf.bean.User) BloodPressureDao(com.zyf.dao.BloodPressureDao) HttpSession(javax.servlet.http.HttpSession) JsonObject(com.google.gson.JsonObject) List(java.util.List) PrintWriter(java.io.PrintWriter)

Example 4 with BloodPressure

use of com.zyf.bean.BloodPressure in project HeartWatchdogJsp by Viczyf.

the class BloodPressureDao method queryTimeBloodPressure.

public List queryTimeBloodPressure(int uid, String startdate, String enddate) {
    String sql = "";
    ;
    sql = "select * from bloodpressure where uid ='" + uid + "'" + "and to_days(date)>=to_days('" + startdate + "') and to_days(date)<=to_days('" + enddate + "') order by id desc";
    ArrayList list = null;
    BloodPressure bp = null;
    ResultSet rs = this.connection.executeQuery(sql);
    if (rs != null) {
        list = new ArrayList();
        try {
            while (rs.next()) {
                bp = new BloodPressure();
                bp.setId(rs.getInt(1));
                bp.setUid(rs.getInt(2));
                bp.setDate(rs.getString(3));
                bp.setHighpressure(rs.getInt(4));
                bp.setLowpressure(rs.getInt(5));
                bp.setXinlv(rs.getInt(6));
                list.add(bp);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
    return list;
}
Also used : BloodPressure(com.zyf.bean.BloodPressure) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet)

Aggregations

BloodPressure (com.zyf.bean.BloodPressure)4 JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 User (com.zyf.bean.User)2 BloodPressureDao (com.zyf.dao.BloodPressureDao)2 PrintWriter (java.io.PrintWriter)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 HttpSession (javax.servlet.http.HttpSession)2