Search in sources :

Example 36 with User

use of com.zyf.bean.User 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 37 with User

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

the class ExaminationServlet method emEdit.

public void emEdit(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    ExaminationDao dao = new ExaminationDao();
    HttpSession session = request.getSession();
    int id = MyTools.strToint(request.getParameter("id"));
    User user = (User) session.getAttribute("user");
    int uid = user.getUid();
    Examination em = dao.emSingle(id, uid);
    request.setAttribute("em", em);
    // System.out.print(em.getDate());
    RequestDispatcher rd = request.getRequestDispatcher("examinationmodify.jsp");
    // RequestDispatcher rd = request.getRequestDispatcher("homepage.jsp");
    rd.forward(request, response);
}
Also used : User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) ExaminationDao(com.zyf.dao.ExaminationDao) Examination(com.zyf.bean.Examination) RequestDispatcher(javax.servlet.RequestDispatcher)

Example 38 with User

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

the class ExaminationServlet method emModify.

public void emModify(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    ExaminationDao dao = new ExaminationDao();
    HttpSession session = request.getSession();
    int id = MyTools.strToint(request.getParameter("id"));
    User user = (User) session.getAttribute("user");
    int uid = user.getUid();
    Examination em = new Examination();
    em.setId(id);
    em.setUid(uid);
    em.setName(request.getParameter("name"));
    em.setGender(request.getParameter("gender"));
    int age = MyTools.strToint(request.getParameter("age"));
    em.setAge(age);
    em.setDate(request.getParameter("date"));
    em.setHospital(request.getParameter("hospital"));
    em.setHeight(request.getParameter("height"));
    em.setWeight(request.getParameter("weight"));
    em.setShousuoya(request.getParameter("shousuoya"));
    em.setShuzhangya(request.getParameter("shuzhangya"));
    em.setTizhiCon(request.getParameter("tizhicon"));
    int neike1 = MyTools.strToint(request.getParameter("neike1"));
    em.setNeike1(neike1);
    em.setNeike2(request.getParameter("neike2"));
    em.setNeike3(request.getParameter("neike3"));
    em.setNeike4(request.getParameter("neike4"));
    em.setNeike5(request.getParameter("neike5"));
    em.setNeike6(request.getParameter("neike6"));
    em.setNeike7(request.getParameter("neike7"));
    em.setNeike8(request.getParameter("neike8"));
    em.setNeike9(request.getParameter("neike9"));
    em.setNeike10(request.getParameter("neike10"));
    em.setNeike11(request.getParameter("neike11"));
    em.setNeike12(request.getParameter("neike12"));
    em.setNeikeCon(request.getParameter("neikecon"));
    em.setWaike1(request.getParameter("waike1"));
    em.setWaike2(request.getParameter("waike2"));
    em.setWaike3(request.getParameter("waike3"));
    em.setWaike4(request.getParameter("waike4"));
    em.setWaike5(request.getParameter("waike5"));
    em.setWaike6(request.getParameter("waike6"));
    em.setWaike7(request.getParameter("waike7"));
    em.setWaike8(request.getParameter("waike8"));
    em.setWaike9(request.getParameter("waike9"));
    em.setWaike10(request.getParameter("waike10"));
    em.setWaike11(request.getParameter("waike11"));
    em.setWaike12(request.getParameter("waike12"));
    em.setWaikeCon(request.getParameter("waikecon"));
    em.setYanke1(request.getParameter("yanke1"));
    em.setYanke2(request.getParameter("yanke2"));
    em.setYanke3(request.getParameter("yanke3"));
    em.setYanke4(request.getParameter("yanke4"));
    em.setYanke5(request.getParameter("yanke5"));
    em.setYanke6(request.getParameter("yanke6"));
    em.setYanke7(request.getParameter("yanke7"));
    em.setYanke8(request.getParameter("yanke8"));
    em.setYanke9(request.getParameter("yanke9"));
    em.setYanke10(request.getParameter("yanke10"));
    em.setYankeCon(request.getParameter("yankecon"));
    em.setEr(request.getParameter("er"));
    em.setBi(request.getParameter("bi"));
    em.setYan(request.getParameter("yan"));
    em.setBiantaoti(request.getParameter("biantaoti"));
    em.setHou(request.getParameter("hou"));
    em.setErbihouCon(request.getParameter("erbihoucon"));
    em.setOral1(request.getParameter("oral1"));
    em.setOral2(request.getParameter("oral2"));
    em.setOral3(request.getParameter("oral3"));
    em.setOralCon(request.getParameter("oralcon"));
    em.setEcg1(request.getParameter("ecg1"));
    em.setEcg2(request.getParameter("ecg2"));
    em.setEcg3(request.getParameter("ecg3"));
    em.setEcg4(request.getParameter("ecg4"));
    em.setEcgCon(request.getParameter("ecgcon"));
    em.setBchaoCon(request.getParameter("bchaocon"));
    em.setFangshe1(request.getParameter("fangshe1"));
    em.setFangsheCon(request.getParameter("fangshecon"));
    em.setCancer1(request.getParameter("cancer1"));
    em.setCancer2(request.getParameter("cancer2"));
    em.setCancer3(request.getParameter("cancer3"));
    em.setCancer4(request.getParameter("cancer4"));
    em.setCancer5(request.getParameter("cancer5"));
    em.setCancer6(request.getParameter("cancer6"));
    em.setCancerCon(request.getParameter("cancercon"));
    em.setBlood1(request.getParameter("blood1"));
    em.setBlood2(request.getParameter("blood2"));
    em.setBlood3(request.getParameter("blood3"));
    em.setBlood4(request.getParameter("blood4"));
    em.setBlood5(request.getParameter("blood5"));
    em.setBlood6(request.getParameter("blood6"));
    em.setBlood7(request.getParameter("blood7"));
    em.setBlood8(request.getParameter("blood8"));
    em.setBlood9(request.getParameter("blood9"));
    em.setBlood10(request.getParameter("blood10"));
    em.setBlood11(request.getParameter("blood11"));
    em.setBlood12(request.getParameter("blood12"));
    em.setBlood13(request.getParameter("blood13"));
    em.setBlood14(request.getParameter("blood14"));
    em.setBlood15(request.getParameter("blood15"));
    em.setBlood16(request.getParameter("blood16"));
    em.setBlood17(request.getParameter("blood17"));
    em.setBlood18(request.getParameter("blood18"));
    em.setBlood19(request.getParameter("blood19"));
    em.setBloodCon(request.getParameter("bloodcon"));
    em.setUrine1(request.getParameter("urine1"));
    em.setUrine2(request.getParameter("urine2"));
    em.setUrine3(request.getParameter("urine3"));
    em.setUrine4(request.getParameter("urine4"));
    em.setUrine5(request.getParameter("urine5"));
    em.setUrine6(request.getParameter("urine6"));
    em.setUrine7(request.getParameter("urine7"));
    em.setUrine8(request.getParameter("urine8"));
    em.setUrine9(request.getParameter("urine9"));
    em.setUrine10(request.getParameter("urine10"));
    em.setUrine11(request.getParameter("urine11"));
    em.setUrine12(request.getParameter("urine12"));
    em.setUrine13(request.getParameter("urine13"));
    em.setUrine14(request.getParameter("urine14"));
    em.setUrine15(request.getParameter("urine15"));
    em.setUrine16(request.getParameter("urine16"));
    em.setUrineCon(request.getParameter("urinecon"));
    em.setLiver1(request.getParameter("liver1"));
    em.setLiver2(request.getParameter("liver2"));
    em.setLiver3(request.getParameter("liver3"));
    em.setLiver4(request.getParameter("liver4"));
    em.setLiver5(request.getParameter("liver5"));
    em.setLiver6(request.getParameter("liver6"));
    em.setLiver7(request.getParameter("liver7"));
    em.setLiver8(request.getParameter("liver8"));
    em.setLiver9(request.getParameter("liver9"));
    em.setLiver10(request.getParameter("liver10"));
    em.setLiver11(request.getParameter("liver11"));
    em.setLiver12(request.getParameter("liver12"));
    em.setLiverCon(request.getParameter("livercon"));
    em.setBloodfat1(request.getParameter("bloodfat1"));
    em.setBloodfat2(request.getParameter("bloodfat2"));
    em.setBloodfat3(request.getParameter("bloodfat3"));
    em.setBloodfat4(request.getParameter("bloodfat4"));
    em.setBloodfatCon(request.getParameter("bloodfatcon"));
    em.setKidney1(request.getParameter("kidney1"));
    em.setKidney2(request.getParameter("kidney2"));
    em.setKidney3(request.getParameter("kidney3"));
    em.setKidneyCon(request.getParameter("kidneycon"));
    em.setXuetang1(request.getParameter("xuetang1"));
    em.setXuetangCon(request.getParameter("xuetangcon"));
    em.setSummary(request.getParameter("summary"));
    boolean rs = dao.emModify(em);
    if (rs) {
        response.setCharacterEncoding("UTF-8");
        PrintWriter out = response.getWriter();
        out.print("<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "    <meta charset=\"UTF-8\">\n" + "    <link href=\"css/sweet-alert.css\" rel=\"stylesheet\">\n" + "</head>\n" + "<body>\n" + "<script src=\"js/jquery-3.1.1.js\"></script>\n" + "<script src=\"js/sweet-alert.min.js\"></script>\n" + "<script type=\"text/javascript\">\n" + "    $(document).ready(function(){\n" + "        swal({\n" + "            type:\"success\",\n" + "            title: \"修改成功\",\n" + "            text: '<a href=\"examination.jsp\" role=\"button\"><font size=\"5\" color=\"green\"> 点此返回</font></a>。<br>3秒后自动返回。',\n" + "            animation:\"slide-from-top\",\n" + "            html: true,\n" + "            timer: 3000,\n" + "            showConfirmButton: false\n" + "        });\n" + "    })\n" + "    window.onload = function(){\n" + "        setTimeout(fun,3000);\n" + "    }\n" + "    function fun(){\n" + "        window.location=\"examination.jsp\"\n" + "        }\n" + "</script>\n" + "</body>\n" + "</html>");
        out.flush();
        out.close();
    } else {
        response.setCharacterEncoding("UTF-8");
        PrintWriter out = response.getWriter();
        out.print("<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "    <meta charset=\"UTF-8\">\n" + "    <link href=\"css/sweet-alert.css\" rel=\"stylesheet\">\n" + "</head>\n" + "<body>\n" + "<script src=\"js/jquery-3.1.1.js\"></script>\n" + "<script src=\"js/sweet-alert.min.js\"></script>\n" + "<script type=\"text/javascript\">\n" + "    $(document).ready(function(){\n" + "        swal({\n" + "            type:\"error\",\n" + "            title: \"修改失败\",\n" + "            text: '<a href=\"examination.jsp\" role=\"button\"><font size=\"5\" color=\"green\"> 点此返回</font></a>。<br>3秒后自动返回。',\n" + "            animation:\"slide-from-top\",\n" + "            html: true,\n" + "            timer: 3000,\n" + "            showConfirmButton: false\n" + "        });\n" + "    })\n" + "    window.onload = function(){\n" + "        setTimeout(fun,3000);\n" + "    }\n" + "    function fun(){\n" + "        window.location=\"examination.jsp\"\n" + "        }\n" + "</script>\n" + "</body>\n" + "</html>");
        out.flush();
        out.close();
    }
}
Also used : User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) ExaminationDao(com.zyf.dao.ExaminationDao) Examination(com.zyf.bean.Examination) PrintWriter(java.io.PrintWriter)

Example 39 with User

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

the class FileServlet method addFile.

public void addFile(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // String filePath = "upload\\\\file\\\\";
    String filePath = "upload/file/";
    String messages = "";
    String forward = "";
    String href = "";
    FileDao fileDao = new FileDao();
    FileBean fileBean = new FileBean();
    SmartUpload su = new SmartUpload();
    long maxsize = 2097152L;
    HttpSession session = request.getSession();
    User user = (User) session.getAttribute("user");
    int id = user.getUid();
    try {
        su.initialize(this.getServletConfig(), request, response);
        su.setMaxFileSize(maxsize);
        su.setAllowedFilesList("jpg,gif,png,txt,doc,pdf,docx");
        su.upload();
        String fileinfo = su.getRequest().getParameter("info");
        if (fileinfo != null && !fileinfo.equals("")) {
            com.jspsmart.upload.File file = su.getFiles().getFile(0);
            if (!file.isMissing()) {
                String fileAddr = filePath + id + "_" + fileDao.queryMaxId() + "." + file.getFileExt();
                System.out.println(fileAddr);
                String now = MyTools.changeTime(new Date());
                fileBean.setUid(id);
                fileBean.setFileAddr(fileAddr);
                fileBean.setFileDate(now);
                fileBean.setFileInfo(fileinfo);
                boolean mark = fileDao.operationFile("upload", fileBean);
                if (mark) {
                    try {
                        file.saveAs(fileAddr, 1);
                        messages = "上传文件成功!";
                        forward = "tishi.jsp";
                        href = "fileupload.jsp";
                    } catch (SmartUploadException var18) {
                        messages = "上传文件失败!";
                        forward = "tishi.jsp";
                        href = "fileupload.jsp";
                        var18.printStackTrace();
                    }
                } else {
                    messages = "保存文件信息失败!";
                    forward = "tishi.jsp";
                    href = "fileupload.jsp";
                }
            } else {
                messages = "请选择要上传的文件!";
                forward = "tishi.jsp";
                href = "fileupload.jsp";
            }
        } else {
            messages = "请输入照片描述信息!";
            forward = "tishi.jsp";
            href = "fileupload.jsp";
        }
    } catch (SecurityException var19) {
        messages = "<li>上传文件失败!上传的文件类型只允许为:jpg,gif,png,txt,doc,docx,pdf;且文件大小不超过2MB</li>";
        forward = "tishi.jsp";
        href = "fileupload.jsp";
    } catch (SmartUploadException var20) {
        messages = "上传文件失败!";
        forward = "tishi.jsp";
        href = "fileupload.jsp";
        var20.printStackTrace();
    }
    request.setAttribute("message", messages);
    request.setAttribute("href", href);
    RequestDispatcher requestDispatcher1 = request.getRequestDispatcher(forward);
    requestDispatcher1.forward(request, response);
}
Also used : User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) Date(java.util.Date) RequestDispatcher(javax.servlet.RequestDispatcher) SmartUpload(com.jspsmart.upload.SmartUpload) SmartUploadException(com.jspsmart.upload.SmartUploadException) FileBean(com.zyf.bean.FileBean) FileDao(com.zyf.dao.FileDao)

Example 40 with User

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

the class FileServlet method deleteFile.

public void deleteFile(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String messages = "";
    String forward = "";
    String href = "";
    RequestDispatcher rd = null;
    FileDao fileDao = new FileDao();
    int id = MyTools.strToint(request.getParameter("id"));
    HttpSession session = request.getSession();
    User user = (User) session.getAttribute("user");
    int uid = user.getUid();
    String fileAddr = fileDao.queryFileSingle(id, uid).getFileAddr();
    String fileDir = request.getSession().getServletContext().getRealPath("/");
    System.out.println(fileDir);
    String delFile = fileDir + fileAddr;
    System.out.println(delFile);
    File file = new File(delFile);
    FileBean fileBean = new FileBean();
    fileBean.setId(id);
    if (fileDao.operationFile("delete", fileBean)) {
        boolean result = file.delete();
        if (result) {
            messages = "<li>删除文件成功!</li>";
            forward = "tishi.jsp";
            href = "FileServlet?action=list";
        } else {
            messages = "<li>删除文件失败!</li>";
            forward = "tishi.jsp";
            href = "FileServlet?action=list";
        }
    } else {
        messages = "<li>删除文件信息失败!</li>";
        forward = "tishi.jsp";
        href = "FileServlet?action=list";
    }
    request.setAttribute("message", messages);
    request.setAttribute("href", href);
    rd = request.getRequestDispatcher(forward);
    rd.forward(request, response);
}
Also used : User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) FileBean(com.zyf.bean.FileBean) FileDao(com.zyf.dao.FileDao) File(java.io.File) RequestDispatcher(javax.servlet.RequestDispatcher)

Aggregations

User (com.zyf.bean.User)53 HttpSession (javax.servlet.http.HttpSession)51 RequestDispatcher (javax.servlet.RequestDispatcher)28 List (java.util.List)18 PrintWriter (java.io.PrintWriter)17 JsonObject (com.google.gson.JsonObject)12 JsonArray (com.google.gson.JsonArray)11 InfoDao (com.zyf.dao.InfoDao)9 Info (com.zyf.bean.Info)7 ExaminationDao (com.zyf.dao.ExaminationDao)7 Info24 (com.zyf.bean.Info24)6 Info24Dao (com.zyf.dao.Info24Dao)6 RelaDao (com.zyf.dao.RelaDao)6 UserDao (com.zyf.dao.UserDao)6 Examination (com.zyf.bean.Examination)5 MedicalhistoryDao (com.zyf.dao.MedicalhistoryDao)5 Medicalhistory (com.zyf.bean.Medicalhistory)4 Urine (com.zyf.bean.Urine)4 FileDao (com.zyf.dao.FileDao)4 UrineDao (com.zyf.dao.UrineDao)4