示例#1
0
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    WebApplicationContext wac =
        WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());

    StudAffairManager sm = (StudAffairManager) wac.getBean("studAffairManager");
    ScoreManager scm = (ScoreManager) wac.getBean("scoreManager");

    HttpSession session = request.getSession(false);

    CourseManager manager = (CourseManager) wac.getBean("courseManager");
    // UserCredential credential =
    // (UserCredential)session.getAttribute("Credential");

    // String studentNo = credential.getMember().getAccount();

    String studentNo = request.getParameter("studentno");
    String sterm = Toolket.getSysParameter("School_term");
    /*
     * if(studentNo == null) { studentNo =
     * credential.getStudent().getStudentNo(); } else
     * if(studentNo.trim().equals("")) { studentNo =
     * credential.getStudent().getStudentNo(); }
     */
    response.setContentType("text/xml; charset=UTF-8");
    PrintWriter out = response.getWriter();

    if (!studentNo.trim().equals("")) {
      Student student = scm.findStudentByStudentNo(studentNo);
      if (student != null) {
        String studentName = student.getStudentName();
        String departClass = student.getDepartClass();
        String deptClassName = student.getDepartClass2();
        String daynite = sm.chkStudentDepart(studentNo);

        String mode = request.getParameter("mode");
        if (mode.equals("")) mode = "all";
        log.info("GetTimeOff has been called! and Mode=" + mode);

        // Leo 20120321 將下列79~83行遮蔽,改取85~90行程式執行
        // int elearnSum = 0;
        // List<Seld> elearnList= sm.findDilgByStudentNo(studentNo,"elearn");
        // for (Seld seld : elearnList) {
        //	elearnSum += seld.getElearnDilg();
        // }
        String elcnt;

        elcnt =
            manager.ezGetString(
                "Select SUM(s.`elearn_dilg`) "
                    + "From Seld s, Dtime d "
                    + "Where s.`student_no` like '"
                    + studentNo
                    + "' "
                    + "  And s.`Dtime_oid`=d.`Oid` "
                    + "  And d.`Sterm`='"
                    + sterm
                    + "' ");

        int elearnSum;

        if (elcnt == null) {
          elearnSum = 0;
        } else {
          elearnSum = Integer.parseInt(elcnt);
        }

        List dilgList = sm.getDilgByStudentNo(studentNo, mode);
        Dilg dilg;
        // ===========================Leo
        // Start====================================================================================================
        List desdList = sm.findDesdByStudentNo(studentNo);
        Desd desd;
        // ===========================Leo
        // End======================================================================================================
        String weekday = "";

        // Map result = new HashMap();
        out.println("<dilgPrompt>");
        out.println("<mode>" + mode + "</mode>");
        out.println("<studentNo>" + studentNo + "</studentNo>");
        out.println("<studentName>" + studentName + "</studentName>");
        out.println("<departClass>" + departClass + "</departClass>");
        out.println("<deptClassName>" + deptClassName + "</deptClassName>");
        out.println("<daynite>" + daynite + "</daynite>");
        out.println("<elearnSum>" + elearnSum + "</elearnSum>");

        if (mode.equals("all")) {
          if (dilgList.size() > 0) {
            for (Iterator<Dilg> dilgIter = dilgList.iterator(); dilgIter.hasNext(); ) {
              dilg = dilgIter.next();
              out.println("<dilgInfo>");
              out.println(
                  "<ddate>"
                      + Toolket.printNativeDate(dilg.getDdate())
                      + "("
                      + weekTran(dilg.getWeekDay())
                      + ")"
                      + "</ddate>");
              out.println("<abs0>" + dilg.getAbsName0() + "</abs0>");
              out.println("<abs1>" + dilg.getAbsName1() + "</abs1>");
              out.println("<abs2>" + dilg.getAbsName2() + "</abs2>");
              out.println("<abs3>" + dilg.getAbsName3() + "</abs3>");
              out.println("<abs4>" + dilg.getAbsName4() + "</abs4>");
              out.println("<abs5>" + dilg.getAbsName5() + "</abs5>");
              out.println("<abs6>" + dilg.getAbsName6() + "</abs6>");
              out.println("<abs7>" + dilg.getAbsName7() + "</abs7>");
              out.println("<abs8>" + dilg.getAbsName8() + "</abs8>");
              out.println("<abs9>" + dilg.getAbsName9() + "</abs9>");
              out.println("<abs10>" + dilg.getAbsName10() + "</abs10>");
              out.println("<abs11>" + dilg.getAbsName11() + "</abs11>");
              out.println("<abs12>" + dilg.getAbsName12() + "</abs12>");
              out.println("<abs13>" + dilg.getAbsName13() + "</abs13>");
              out.println("<abs14>" + dilg.getAbsName14() + "</abs14>");
              out.println("<abs15>" + dilg.getAbsName15() + "</abs15>");
              out.println("</dilgInfo>");
            }
          } else {
            out.println("<dilgInfo></dilgInfo>");
          }

        } else if (mode.equals("subject")) {
          if (dilgList.size() > 0) {
            for (Iterator dilgIter = dilgList.iterator(); dilgIter.hasNext(); ) {
              Map dilgMap = (Map) dilgIter.next();
              out.println("<dilgInfo>");
              out.println("<subjectName>" + dilgMap.get("subjectName") + "</subjectName>");
              out.println("<period>" + dilgMap.get("period") + "</period>");
              out.println("<tfLimit>" + dilgMap.get("tfLimit") + "</tfLimit>");
              out.println("<timeOff>" + dilgMap.get("timeOff") + "</timeOff>");
              out.println("<elearnDilg>" + dilgMap.get("elearnDilg") + "</elearnDilg>");
              out.println("<warnning>" + dilgMap.get("warnning") + "</warnning>");
              out.println("<dtimeClass>" + dilgMap.get("dtimeClass") + "</dtimeClass>");
              out.println("<absType>" + dilgMap.get("absType") + "</absType>");
              out.println("</dilgInfo>");
            }
          } else {
            out.println("<dilgInfo></dilgInfo>");
          }

          // ===========================Leo
          // Start====================================================================================================
        } else if (mode.equals("desd")) {
          if (desdList.size() > 0) {
            // System.out.println(desdList.size());

            for (Iterator<Desd> desdIter = desdList.iterator(); desdIter.hasNext(); ) {
              desd = desdIter.next();
              Map Reason =
                  manager.ezGetMap("SELECT name FROM code2 WHERE no='" + desd.getReason() + "'");
              // System.out.println(Reason.get("name"));
              out.println("<dilgInfo>");
              out.println("<ddate>" + desd.getDdate() + "</ddate>");
              out.println("<no>" + desd.getNo() + "</no>");
              out.println("<reason>" + Reason.get("name") + "</reason>");
              out.println("<kind1>" + desd.getKind1() + "</kind1>");
              out.println("<cnt1>" + desd.getCnt1() + "</cnt1>");
              out.println("<kind2>" + desd.getKind2() + "</kind2>");
              out.println("<cnt2>" + desd.getCnt2() + "</cnt2>");
              out.println("</dilgInfo>");
            }
          } else {
            out.println("<dilgInfo></dilgInfo>");
          }
        }
        // ===========================Leo
        // End======================================================================================================

        out.println("</dilgPrompt>");
        out.close();
      } else {
        out.println("<dilgPrompt>");
        out.println("<dilgInfo>");
        out.println("<mode>notfound</mode>");
        out.println("</dilgInfo>");
        out.println("</dilgPrompt>");
        out.close();
      }
    } else {
      out.println("<dilgPrompt>");
      out.println("<dilgInfo>");
      out.println("<mode>notfound</mode>");
      out.println("</dilgInfo>");
      out.println("</dilgPrompt>");
      out.close();
    }
  }
示例#2
0
  public ActionForward save(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    DynaActionForm aForm = (DynaActionForm) form;
    HttpSession session = request.getSession(false);
    Map initMap = (Map) session.getAttribute("TchScoreUploadInfo");

    String scoretype = aForm.getString("scoretype");
    String departClass = initMap.get("departClass").toString();
    String cscode = initMap.get("cscode").toString();
    String teacherId = initMap.get("teacherId").toString();
    int dtimeoid = 0;

    ActionMessages messages = validateInputForUpdate(aForm, Toolket.getBundle(request));

    if (!messages.isEmpty()) {
      saveErrors(request, messages);
      // request.removeAttribute("ScoreInputInit");
      // log.debug("=======> Teacher Input score ValidateError='");

      session.setAttribute("TchScoreUploadFormMap", aForm.getMap());
      // session.setAttribute("ScoreInput", aForm.getStrings("scrinput"));
      return mapping.findForward("Main");
    } else {
      ActionMessages errors = new ActionMessages();
      try {
        List<Regs> regs = (List<Regs>) session.getAttribute("TchScoreInEdit");
        ScoreManager sm = (ScoreManager) getBean("scoreManager");
        dtimeoid = regs.get(0).getDtimeOid();

        Map calscore = new HashMap();
        // log.debug("ScoreMidTermEdit1Action->scr19f.size():" + scr19f.length);
        calscore.put("scr23f", scr23f);

        // errors = sm.updateScoreInput(aForm.getMap(), scores);
        errors = sm.updateTchScoreInput(aForm.getMap(), regs, calscore);
        if (!errors.isEmpty()) {

          saveErrors(request, errors);
          // request.removeAttribute("ScoreInputInit");

          session.setAttribute("TchScoreUploadFormMap", aForm.getMap());
          // session.setAttribute("ScoreInput", aForm.getStrings("scrinput"));
          return mapping.findForward("Main");
        }
        Calendar now = Calendar.getInstance();
        String nows =
            ""
                + (now.get(Calendar.YEAR) - 1911)
                + "/"
                + (now.get(Calendar.MONTH) + 1)
                + "/"
                + now.get(Calendar.DATE)
                + " "
                + now.get(Calendar.HOUR_OF_DAY)
                + ":"
                + now.get(Calendar.MINUTE)
                + ":"
                + now.get(Calendar.SECOND);

        errors = sm.updateRegsTime(dtimeoid, departClass, cscode, teacherId, scoretype, nows);
        if (!errors.isEmpty()) {

          saveErrors(request, errors);
        }

        int count = 0;
        String[] studentNames = new String[regs.size()];
        Regs myregs;
        String[] score = (String[]) aForm.getMap().get("scr23");
        String[] studentNos = (String[]) aForm.getMap().get("studentNo");
        int scoresint = 0;
        int totalscore = 0;
        int totalstu = score.length;
        int nopass = 0;

        for (Iterator regsIter = regs.iterator(); regsIter.hasNext(); ) {
          myregs = (Regs) regsIter.next();
          studentNames[count++] = myregs.getStudentName();
        }

        for (int i = 0; i < score.length; i++) {
          scoresint = Integer.parseInt(score[i]);
          totalscore = totalscore + scoresint;
          if (scoresint < 60) {
            nopass++;
            score[i] = score[i] + "*";
          }
        }

        messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.CreateSuccessful"));
        saveMessages(request, messages);
        aForm.initialize(mapping);
        Map pmap = new HashMap();
        pmap.put("scoretype", scoretype);
        pmap.put("opmode", "Print");
        pmap.put("schoolYear", Toolket.getSysParameter("School_year"));
        pmap.put("schoolTerm", Toolket.getSysParameter("School_term"));
        pmap.put("departClass", departClass);
        pmap.put("depClassName", initMap.get("depClassName").toString());
        pmap.put("teacherName", initMap.get("teacherName").toString());
        pmap.put("cscode", cscode);
        pmap.put("cscodeName", initMap.get("cscodeName").toString());
        pmap.put("studentNo", studentNos);
        pmap.put("studentName", studentNames);
        pmap.put("score", score);
        pmap.put("totalstu", totalstu);
        pmap.put("totalscore", totalscore);
        pmap.put("avgscore", Math.round(totalscore / totalstu));
        pmap.put("nopass", nopass);
        pmap.put("pass", (totalstu - nopass));
        pmap.put("now", nows);
        session.setAttribute("TchScoreUploadPrint", pmap);

        // session.removeAttribute("TchScoreMidInfo");
        session.removeAttribute("TchScoreInEdit");
        session.removeAttribute("TchScoreUploadFormMap");
        setContentPage(session, "teacher/TeachClassChoose.jsp");
        return mapping.findForward("Main");
      } catch (Exception e) {
        e.printStackTrace();
        errors.add(
            ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Exception.generic", e.getMessage()));
        saveErrors(request, errors);
        session.setAttribute("TchScoreUploadFormMap", aForm.getMap());
        return mapping.findForward("Main");
      }
    }
  }
示例#3
0
  public ActionForward unspecified(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    DynaActionForm aForm = (DynaActionForm) form;

    HttpSession session = request.getSession(false);
    UserCredential credential = (UserCredential) session.getAttribute("Credential");
    String classInCharge = credential.getClassInChargeSqlFilterT();
    String idenType = aForm.getString("idenType").trim();

    StudAffairManager sm = (StudAffairManager) getBean("studAffairManager");
    MemberManager mm = (MemberManager) getBean("memberManager");

    Map<String, String> counselType = new HashMap<String, String>();
    counselType.put("L", "學習輔導");
    counselType.put("T", "職涯輔導");

    String schoolYear = Toolket.getSysParameter(IConstants.PARAMETER_SCHOOL_YEAR);
    String schoolTerm = Toolket.getSysParameter(IConstants.PARAMETER_SCHOOL_TERM);
    Map<String, String> CounselingReportInit = new HashMap<String, String>();
    CounselingReportInit.put("idenType", idenType);
    CounselingReportInit.put("schoolYear", schoolYear);
    CounselingReportInit.put("schoolTerm", schoolTerm);

    List<CounselingCode> codesL = sm.findCounselingCode("L");
    List<CounselingCode> codesT = sm.findCounselingCode("T");

    session.setAttribute("StudCounselCodeL", codesL);
    session.setAttribute("StudCounselCodeT", codesT);
    session.setAttribute("StudCounselType", counselType);
    session.setAttribute("CounselingReportInit", CounselingReportInit);

    String[][] repType =
        new String[][] {
          {"1", "學習輔導記錄(導師)"},
          {"2", "職涯輔導記錄(導師)"},
          {"3", "學習輔導記錄(老師)"},
          {"4", "學生接受輔導記錄"},
          {"5", "輔導次數統計(導師)"},
          {"6", "輔導次數統計(老師)"}
        };
    session.setAttribute("CounselReportType", repType);

    List<Map> depts = Toolket.getCollegeDepartment(true);
    session.setAttribute("depts", depts);

    /*
    if(idenType.equals("T")){	//Tutor
    	setContentPage(session, "studaffair/CounselingReportT.jsp");
    }else if(idenType.equals("L")){		//Teacher
    	setContentPage(session, "studaffair/CounselingReportL.jsp");
    }else if(idenType.equals("C")){		//department chief or assistance
    	setContentPage(session, "studaffair/CounselingReportC.jsp");
    }else if(idenType.equals("A")){		//student affair officer
    	setContentPage(session, "studaffair/CounselingReportA.jsp");
    }else if(idenType.equals("S")){		//execution manager
    	//int empOid = credential.getMember().getOid();
    	List<Empl> empls = mm.findEmplByGroup("S1");
    	for(Empl empl:empls){
    		if(empl.getIdno().equalsIgnoreCase(credential.getMember().getIdno())){
    			setContentPage(session, "studaffair/CounselingReportS.jsp");
    			break;
    		}
    	}

    }
    */
    session.removeAttribute("CounselingReoport");
    setContentPage(session, "studaffair/CounselingReport.jsp");
    return mapping.findForward("Main");
  }