List of usage examples for org.apache.commons.lang3 StringUtils INDEX_NOT_FOUND
int INDEX_NOT_FOUND
To view the source code for org.apache.commons.lang3 StringUtils INDEX_NOT_FOUND.
Click Source Link
From source file:com.feilong.core.lang.StringUtilTemp.java
/** * ? .//from w w w.j a va 2 s. c o m * * <pre class="code"> * StringUtil.searchTimes("xin", "xin") = 1 * StringUtil.searchTimes("xiiiin", "ii") = 2 * </pre> * * @param source * ? * @param target * ? * @return count of target string in source * @see org.apache.commons.lang3.StringUtils#countMatches(CharSequence, CharSequence) * @since 1.0.2 * @deprecated {@link org.apache.commons.lang3.StringUtils#countMatches(CharSequence, CharSequence)} */ @Deprecated private static int searchTimes(String source, String target) { Validate.notNull(source, "source can't be null!"); Validate.notNull(target, "target can't be null!"); // times int count = 0; // while int j = 0; // ?? int fromIndex = 0; int sourceLength = source.length(); // 0 while (j != sourceLength) { // ? int i = source.indexOf(target, fromIndex); if (i != StringUtils.INDEX_NOT_FOUND) { int targetLength = target.length(); // ? , // j = i + targetLength; fromIndex = i + targetLength; count++; } else { // ?? break; } } return count; }
From source file:com.feilong.core.lang.StringUtilTemp.java
/** * [?]:?(?)??,shift?????./*from w w w. j a v a 2s.c om*/ * * <h3>:</h3> * * <blockquote> * * <pre class="code"> * StringUtil.substring("jinxin.feilong",".",0) = ".feilong" * StringUtil.substring("jinxin.feilong",".",1) = "feilong" * </pre> * * </blockquote> * * @param text * text * @param beginString * beginString * @param shift * ??,??,0?? * @return <code>text</code> nullempty, {@link StringUtils#EMPTY}<br> * <code>beginString</code> nullempty, {@link StringUtils#EMPTY}<br> * text.indexOf(beginString)==-1, {@link StringUtils#EMPTY}<br> * {@code beginIndex + shift < 0}, {@link IllegalArgumentException}<br> * {@code beginIndex + shift > text.length()}, {@link StringUtils#EMPTY}<br> * ? text.substring(beginIndex + shift)<br> * @see org.apache.commons.lang3.StringUtils#substringAfter(String, String) */ public static String substring(final String text, String beginString, int shift) { if (isNullOrEmpty(text) || isNullOrEmpty(beginString)) { return EMPTY; } int beginIndex = text.indexOf(beginString); if (beginIndex == StringUtils.INDEX_NOT_FOUND) {// ? return EMPTY; } //**************************************************** int startIndex = beginIndex + shift; Validate.isTrue(startIndex >= 0, Slf4jUtil.format("[{}] index[{}]+shift[{}]<0,text[{}]", beginString, beginIndex, shift, text)); int textLength = text.length(); if (startIndex > textLength) { LOGGER.warn("beginString [{}] index[{}]+shift[{}]>text[{}].length()[{}]", beginString, beginIndex, shift, text, textLength); return EMPTY; } return text.substring(startIndex);// 0 }
From source file:com.discovery.darchrow.net.URIUtil.java
/** * queryString.//from w ww. jav a 2s.c om * * <h3>:</h3> * <blockquote> * * <pre class="code"> * URIUtil.getQueryString({@code "http://127.0.0.1/cmens/t-b-f-a-c-s-f-p-g-e-i-o.htm?a=1&a=2"}) * </pre> * * : {@code a=1&a=2} * </blockquote> * * @param uriString * the uri * @return ? <code>uriString</code> isNullOrEmpty, {@link StringUtils#EMPTY};<br> * ? <code>uriString</code> ???, {@link StringUtils#EMPTY};<br> * ????? * @since 1.4.0 */ public static String getQueryString(String uriString) { if (Validator.isNullOrEmpty(uriString)) { return StringUtils.EMPTY; } // url??? XXX int index = uriString.indexOf(URIComponents.QUESTIONMARK); return index == StringUtils.INDEX_NOT_FOUND ? StringUtils.EMPTY : StringUtil.substring(uriString, index + 1); }
From source file:com.discovery.darchrow.net.URIUtil.java
/** * ??queryStringpath,????( <span style="color:red">???</span>). * * @param uriString/*from w w w. j a va 2 s . c om*/ * the uri * @return isNullOrEmpty(url), {@link StringUtils#EMPTY} * @since 1.4.0 */ public static String getFullPathWithoutQueryString(String uriString) { if (Validator.isNullOrEmpty(uriString)) { return StringUtils.EMPTY; } // url??? XXX int index = uriString.indexOf(URIComponents.QUESTIONMARK); return index == StringUtils.INDEX_NOT_FOUND ? uriString : uriString.substring(0, index); }
From source file:tw.edu.chit.struts.action.registration.ReportPrintAction.java
/** * ???// w w w .ja va 2 s . c o m * * @param mapping org.apache.struts.action.ActionMapping object * @param form org.apache.struts.action.ActionForm object * @param request request javax.servlet.http.HttpServletRequest object * @param response response javax.servlet.http.HttpServletResponse object * @param sterm */ @SuppressWarnings("unchecked") private void printClassStudentsScoreHistory(ActionMapping mapping, DynaActionForm form, HttpServletRequest request, HttpServletResponse response, String sterm) throws Exception { HttpSession session = request.getSession(false); MemberManager mm = (MemberManager) getBean(IConstants.MEMBER_MANAGER_BEAN_NAME); CourseManager cm = (CourseManager) getBean(IConstants.COURSE_MANAGER_BEAN_NAME); ScoreManager sm = (ScoreManager) getBean(IConstants.SCORE_MANAGER_BEAN_NAME); StudAffairManager sam = (StudAffairManager) getBean(IConstants.STUD_AFFAIR_MANAGER_BEAN_NAME); boolean isIncludeThisTermScore = "true".equalsIgnoreCase(request.getParameter("tt")); // String year = cm.getNowBy("School_year"); // String term = form.getString("sterm"); String studentNo = null; Clazz clazz = null; ScoreHist scoreHist = null, hist = null; List<Student> students = null; List<Clazz> clazzes = sm.findClassBy(new Clazz(processClassInfo(form)), getUserCredential(session).getClassInChargeAry(), false); if (!clazzes.isEmpty() && clazzes.size() > 1) { ActionMessages messages = new ActionMessages(); messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("", "")); saveMessages(request, messages); // return mapping.findForward(IConstants.ACTION_MAIN_NAME); ServletContext context = request.getSession().getServletContext(); Map<String, String> parameters = new HashMap<String, String>(); File image = new File(context.getRealPath("/pages/reports/2002chitS.jpg")); parameters.put("IMAGE", image.getAbsolutePath()); byte[] bytes = JasperRunManager.runReportToPdf(JasperReportUtils.getNoResultReport(context), parameters, new JREmptyDataSource()); JasperReportUtils.printPdfToFrontEnd(response, bytes); } else { clazz = clazzes.get(0); students = mm.findStudentsByClassNo(clazz.getClassNo()); if (!students.isEmpty()) { ServletContext context = request.getSession().getServletContext(); String[] excep = { "11G332" }; // ??+1 String[] formYear = { "", "", "", "", "", "", "", "", "?" }; short firstYear = 0; short lastYear = 0; double justScore = 0.0D; int sheetIndex = 0; int k = 0, j = 0, rowIndex = 0, nextPageRowIndex = 0; int kk = 0, rowIndexx = 0; String departClass = clazz.getClassNo(); String departCode = "", title = "", evgrType = "", historyDepartCode = "", opt = "", cscode = ""; // ?70? float passScore = Toolket.getPassScoreByDepartClass(departClass); Graduate graduate = null; MasterData md = null; Just just = null; ScoreHist target = null; Dtime dtime = null; List csnos = null; Csno csno = null; Gmark gmark = null; Map<String, String> position = null; Float passCreditsSum = 0.0F; Float totalPassCredits = 0.0F; List<Seld> selds = null; List<ScoreHist> scoreHistList = null; List<Stavg> stavgs = null; List<Gmark> gmarks = null; boolean isOver = false; // (lastYear - firstYear + 1) > 4; boolean isDelay = Toolket.isDelayClass(departClass); boolean isSpringClass = false; // boolean isDoubleMajor = false; boolean isAssist = false; // 9608???Show????,?Show'',?????Show boolean is96Entrance = false; boolean isMaster = Toolket.isMasterClass(departClass); boolean nextPage = false, hasPassRecord = false, rowOver = false; boolean isNotExemptAndMend = false; // ??? boolean isExempt = false; // ??? boolean isMend = false; // ?? boolean isAppend = false; // ??? boolean isNotSameDepartCode = false; boolean isOver15Char = false, isOver10Char = false; int studentCounts = students.size(); String fileName = ""; DecimalFormat df = new DecimalFormat(",##0.0"); File templateXLS = null; if (!isMaster) { if (studentCounts <= 30) fileName = "ClassStudentsScoreHistoryOver30.xls"; else if (studentCounts > 31 && studentCounts <= 40) fileName = "ClassStudentsScoreHistoryOver40.xls"; else if (studentCounts > 40 && studentCounts <= 45) fileName = "ClassStudentsScoreHistoryOver45.xls"; else if (studentCounts > 45 && studentCounts <= 50) fileName = "ClassStudentsScoreHistoryOver50.xls"; else if (studentCounts > 51 && studentCounts <= 55) fileName = "ClassStudentsScoreHistoryOver55.xls"; else fileName = "ClassStudentsScoreHistoryOver60.xls"; title = Toolket.getSchoolFormalName(departClass); if (isDelay) { // Only 20 Sheets templateXLS = new File( context.getRealPath("/WEB-INF/reports/ClassStudentsScoreHistoryOver.xls")); } else { templateXLS = new File(context.getRealPath("/WEB-INF/reports/" + fileName)); } } else { if (studentCounts <= 15) fileName = "ClassStudentsScoreHistoryMaster15.xls"; else if (studentCounts > 15 && studentCounts <= 20) fileName = "ClassStudentsScoreHistoryMaster20.xls"; else fileName = "ClassStudentsScoreHistoryMaster25.xls"; String masterId = StringUtils.substring(departClass, 1, 3); if ("1G".equals(masterId)) title = "?"; else title = "??"; templateXLS = new File(context.getRealPath("/WEB-INF/reports/" + fileName)); } HSSFWorkbook workbook = Toolket.getHSSFWorkbook(templateXLS); HSSFFont colorFont = workbook.createFont(); colorFont.setColor(HSSFColor.RED.index); colorFont.setFontHeightInPoints((short) 12); colorFont.setFontName("Arial Unicode MS"); HSSFFont fontSize12 = workbook.createFont(); fontSize12.setFontHeightInPoints((short) 12); fontSize12.setFontName("Arial Unicode MS"); HSSFFont fontSize10 = workbook.createFont(); fontSize10.setFontHeightInPoints((short) 10); fontSize10.setFontName("Arial Unicode MS"); HSSFFont fontSize9 = workbook.createFont(); fontSize9.setFontHeightInPoints((short) 9); fontSize9.setFontName("Arial Unicode MS"); HSSFSheet sheet = null; for (Student student : students) { studentNo = student.getStudentNo(); if (sheetIndex > 59) sheetIndex = 59; sheet = workbook.getSheetAt(sheetIndex); workbook.setSheetName(sheetIndex++, studentNo.toUpperCase()); if (student == null) { graduate = mm.findGraduateByStudentNo(studentNo); student = new Student(); BeanUtils.copyProperties(student, graduate); } // isDoubleMajor = "".equals(student.getExtraStatus()); isAssist = "".equals(student.getExtraStatus()); // departClass = student.getDepartClass(); // 9608???Show????,?Show'',?????Show is96Entrance = student.getEntrance() == null ? false : student.getEntrance() >= (short) 9608; scoreHist = new ScoreHist(studentNo); scoreHistList = sm.findScoreHistBy(scoreHist); if (scoreHistList.isEmpty()) { ActionMessages messages = new ActionMessages(); messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Course.messageN1", "?")); saveErrors(request, messages); log.error("No Score History... " + studentNo); sheetIndex--; continue; } else { firstYear = Short.parseShort(scoreHistList.get(0).getSchoolYear().toString()); lastYear = Short .parseShort(scoreHistList.get(scoreHistList.size() - 1).getSchoolYear().toString()); isOver = (lastYear - firstYear + 1) > 4; if (isOver) ; // log.error("It is Over... " + studentNo); departCode = ""; Toolket.setCellValue(sheet, 0, 0, "?" + title + "?"); Toolket.setCellValue(sheet, 1, 1, "" + studentNo); Toolket.setCellValue(sheet, 1, 7, "??" + student.getStudentName()); Toolket.setCellValue(sheet, 1, 9, "" + (isMaster ? Toolket.getMasterDepartName(departClass) : Toolket.getDepartName(departClass)) + (isDoubleMajor || isAssist ? "(" + student.getExtraStatus() + ":" + student.getExtraDept() + ")" : "")); Toolket.setCellValue(sheet, 1, 19, "" + student.getIdno()); // ?2,?code Toolket.setCellValue(sheet, 43, 0, "?" + title + "?"); Toolket.setCellValue(sheet, 44, 1, "" + studentNo); Toolket.setCellValue(sheet, 44, 7, "??" + student.getStudentName()); Toolket.setCellValue(sheet, 44, 9, "" + (isMaster ? Toolket.getMasterDepartName(departClass) : Toolket.getDepartName(departClass)) + (isDoubleMajor || isAssist ? "(" + student.getExtraStatus() + ":" + student.getExtraDept() + ")" : "")); Toolket.setCellValue(sheet, 44, 19, "" + student.getIdno()); if (isDelay) { Toolket.setCellValue(sheet, 43, 0, "?" + title + "?"); Toolket.setCellValue(sheet, 44, 1, "" + studentNo); Toolket.setCellValue(sheet, 44, 7, "??" + student.getStudentName()); Toolket.setCellValue(sheet, 44, 9, "" + (isMaster ? Toolket.getMasterDepartName(departClass) : Toolket.getDepartName(departClass)) + (isDoubleMajor || isAssist ? "(" + student.getExtraStatus() + ":" + student.getExtraDept() + ")" : "")); Toolket.setCellValue(sheet, 44, 19, "" + student.getIdno()); } if (isDoubleMajor || isAssist) { Toolket.setCellValue(sheet, 42, 0, " => *:?? #: &: "); departCode = StringUtils.substring(student.getDepartClass(), 3, 4); } if (isOver) { Toolket.setCellValue(sheet, 43, 0, "?" + title + "?"); Toolket.setCellValue(sheet, 44, 1, "" + studentNo); Toolket.setCellValue(sheet, 44, 7, "??" + student.getStudentName()); Toolket.setCellValue(sheet, 44, 9, "" + (isMaster ? Toolket.getMasterDepartName(departClass) : Toolket.getDepartName(departClass))); Toolket.setCellValue(sheet, 44, 19, "" + student.getIdno()); if (isDoubleMajor || isAssist) Toolket.setCellValue(sheet, 85, 0, " => *:?? #: &: "); } if (isMaster) { md = sm.findMasterByStudentNo(studentNo); if (md != null) { Toolket.setCellValue(sheet, 38, 0, "" + md.getThesesChiname()); Toolket.setCellValue(sheet, 39, 0, " " + md.getThesesEngname()); Toolket.setCellValue(sheet, 38, 17, md.getRemark()); Toolket.setCellValue(sheet, 40, 0, "??" + md.getThesesScore()); Toolket.setCellValue(sheet, 40, 4, "??(50%)" + md.getThesesScore() / 2); Toolket.setCellValue(sheet, 40, 8, "??" + md.getEvgr1Score()); Toolket.setCellValue(sheet, 40, 14, "??(50%)" + md.getEvgr1Score() / 2); Toolket.setCellValue(sheet, 40, 19, "?" + md.getGraduateScore()); } } if (Arrays.binarySearch(excep, departClass) >= 0) { lastYear++; isSpringClass = true; Toolket.setCellValue(sheet, 39, 17, "" + (lastYear + 1) + ".1"); } k = 0; j = 0; rowIndex = 6; nextPageRowIndex = 43; passCreditsSum = 0.0F; nextPage = false; hasPassRecord = false; rowOver = false; // List<Stavg> stavgs = null; // Just just = null; // String[] formYear = { "", "", "", "", "", "", // "", "" }; for (short year = firstYear; year <= lastYear; year++) { // ???9316D078 // ??? scoreHist.setSchoolYear(year); scoreHist.setSchoolTerm("1"); hasPassRecord = !sm.findScoreHistBy(scoreHist).isEmpty(); if (!hasPassRecord) { scoreHist.setSchoolTerm("2"); hasPassRecord = !sm.findScoreHistBy(scoreHist).isEmpty(); if (!hasPassRecord) continue; } if (isSpringClass && year == lastYear) { just = sam.findJustByStudentNo(studentNo); justScore = 0.0D; if (just == null || just.getTotalScore() == 0.0D) { target = new ScoreHist(studentNo); target.setSchoolYear(new Short(year)); target.setSchoolTerm("2"); target.setCscode("99999"); scoreHistList = sm.findScoreHistBy(target); if (!scoreHistList.isEmpty()) { scoreHist = sm.findScoreHistBy(scoreHist).get(0); justScore = scoreHist.getScore(); } } else justScore = just.getTotalScore(); Toolket.setCellValue(sheet, 35 + (isMaster ? -2 : 0), k * 6 + 3, justScore == 0.0D ? "" : String.valueOf(Math.round(justScore))); } if (rowOver) { Toolket.setCellValue(workbook, sheet, 2 + (nextPage ? nextPageRowIndex : 0), k * 6, " " + formYear[(nextPage ? k + 4 : k)] + " ", fontSize12, HSSFCellStyle.ALIGN_CENTER, true, null); } else Toolket.setCellValue(sheet, 2 + (nextPage ? nextPageRowIndex : 0), k * 6, " " + formYear[(nextPage ? k + 4 : k)] + " "); position = new HashMap<String, String>(); for (int term = 1; term <= 2; term++) { scoreHist.setSchoolYear(year); scoreHist.setSchoolTerm(String.valueOf(term)); // scoreHist.setEvgrType("1"); // ? scoreHistList = sm.findScoreHistBy(scoreHist); if (!scoreHistList.isEmpty()) { Toolket.setCellValue(sheet, 3 + (nextPage ? nextPageRowIndex : 0), k * 6, "" + year + " 9 " + (year + 1) + " 7 "); stavgs = sm.findStavgBy(new Stavg(studentNo, year, String.valueOf(term))); totalPassCredits = 0.0F; // for (ScoreHist hist : scoreHistList) { // i != scoreHistList.size() - // 1???,?? for (int i = 0; i < scoreHistList.size(); i++) { hist = scoreHistList.get(i); if (rowIndex == 32 && i != scoreHistList.size() - 1) { rowIndex = 6; k++; Toolket.setCellValue(sheet, 2 + (nextPage ? nextPageRowIndex : 0), k * 6, " " + formYear[k - 1] + " "); Toolket.setCellValue(sheet, 3 + (nextPage ? nextPageRowIndex : 0), k * 6, "" + year + " 9 " + (year + 1) + " 7 "); rowOver = true; } evgrType = hist.getEvgrType(); isNotExemptAndMend = !"6".equals(evgrType) && !"5".equals(evgrType); // ??? isExempt = "6".equals(evgrType); // ??? isMend = "5".equals(evgrType); // ?? isAppend = "2".equals(evgrType); // ??? historyDepartCode = StringUtils.isBlank(hist.getStdepartClass()) ? "" : StringUtils.substring(hist.getStdepartClass(), 3, 4); isNotSameDepartCode = !departCode.equals(historyDepartCode) && !historyDepartCode.equals("0"); opt = ""; if ("3".equals(evgrType)) opt = ""; else opt = StringUtils.substring(Toolket.getCourseOpt(hist.getOpt()), 0, 1) + (isAppend ? "" : (isMend ? "" : (!isNotExemptAndMend ? "" : ""))); cscode = hist.getCscode(); if ("GA035".equals(cscode) || "".equals("GB033")) continue; // 2? isOver15Char = false; isOver10Char = false; if (!"99999".equals(cscode)) { // ? String courseName = cm.findCourseInfoByCscode(cscode) == null ? "??" : cm.findCourseInfoByCscode(cscode).getChiName().trim(); isOver15Char = courseName.length() > 15; isOver10Char = courseName.length() > 10; Float credit = hist.getCredit(); Float score = hist.getScore(); boolean pass = (score == null ? 0.0F : score) >= passScore; // ((?&&?)||?)&&? if (((isNotExemptAndMend && pass) || isExempt) && !isMend) // if (!isNotExemptAndMend || // !isMend || // bFlag1) // if (!isMend && bFlag1) if (isMaster && "G".equalsIgnoreCase( StringUtils.substring(hist.getStdepartClass(), 2, 3))) { // ???,? totalPassCredits += credit; } else totalPassCredits += credit; if (1 == term) { if (opt.length() == 1 || is96Entrance) Toolket.setCellValue(sheet, rowIndex, k * 6, (is96Entrance ? StringUtils.substring(opt, 0, 1) : opt)); else Toolket.setCellValue(workbook, sheet, rowIndex, k * 6, opt, fontSize12, HSSFCellStyle.ALIGN_CENTER, true, null); if (isOver15Char) Toolket.setCellValue(workbook, sheet, rowIndex, k * 6 + 1, courseName, fontSize9, HSSFCellStyle.ALIGN_LEFT, true, null); else if (isOver10Char) Toolket.setCellValue(workbook, sheet, rowIndex, k * 6 + 1, courseName, fontSize10, HSSFCellStyle.ALIGN_LEFT, true, null); else Toolket.setCellValue(sheet, rowIndex, k * 6 + 1, courseName); position.put(courseName, String.valueOf(rowIndex)); if (isNotExemptAndMend) { // ? String creditStr = credit.toString(); if (!isMend && !isExempt) creditStr = pass ? creditStr : creditStr + "*"; if (isDoubleMajor && isNotSameDepartCode) creditStr += "&"; if (isAssist && isNotSameDepartCode) creditStr += "#"; if (StringUtils.indexOf(creditStr, "*") == StringUtils.INDEX_NOT_FOUND) Toolket.setCellValue(sheet, rowIndex, k * 6 + 2, creditStr); else Toolket.setCellValue(workbook, sheet, rowIndex, k * 6 + 2, creditStr, colorFont, HSSFCellStyle.ALIGN_CENTER, true, null); // ?? Toolket.setCellValue(sheet, rowIndex++, k * 6 + 3, (isMend ? "" : (score == null ? "" : StringUtils.substringBefore(score.toString(), ".")))); // ?? Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 3, (stavgs.isEmpty() ? "" : df.format( stavgs.get(0).getScore() + 0.001D))); } else { // ? String creditStr = credit.toString(); Toolket.setCellValue(sheet, rowIndex, k * 6 + 2, creditStr); if (is96Entrance) Toolket.setCellValue(sheet, rowIndex++, k * 6 + 3, (isMend ? "" : "")); else { // ?? Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 3, (stavgs.isEmpty() ? "" : df.format(stavgs.get(0).getScore() + 0.001D))); Toolket.setCellValue(sheet, rowIndex++, k * 6 + 3, score == null ? "" : StringUtils.substringBefore( score.toString(), ".")); } } } else { String endString = StringUtils.substring(courseName, courseName.length() - 1); boolean duplicatedCourseName = "".equals(endString); boolean duplicatedCourseName1 = "".equals(endString); boolean duplicatedCourseName2 = "".equals(endString); if (duplicatedCourseName || duplicatedCourseName1 || duplicatedCourseName2) { String courseIndex = StringUtils.substring(courseName, 0, courseName.length() - 1); String row = "", maybeSameCourseNameOptInfo = ""; if (duplicatedCourseName) { row = position.get(courseIndex + ""); if (row != null) maybeSameCourseNameOptInfo = Toolket.getCellValue(sheet, Integer.parseInt(row), (rowOver ? k - 1 : k) * 6); } else if (duplicatedCourseName1) { row = position.get(courseIndex + ""); if (row != null) maybeSameCourseNameOptInfo = Toolket.getCellValue(sheet, Integer.parseInt(row), (rowOver ? k - 1 : k) * 6); } else if (duplicatedCourseName2) { row = position.get(courseIndex + ""); if (row != null) maybeSameCourseNameOptInfo = Toolket.getCellValue(sheet, Integer.parseInt(row), (rowOver ? k - 1 : k) * 6); } // ????? boolean isAllowMerge = (StringUtils.contains(opt, "") && StringUtils.contains(maybeSameCourseNameOptInfo, "")) || (StringUtils.contains(opt, "?") && StringUtils .contains(maybeSameCourseNameOptInfo, "?")); if (row != null && isAllowMerge) { int rowNum = Integer.parseInt(row); Toolket.setCellValue(sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 1, Toolket.getCellValue(sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 1) + "?" + (duplicatedCourseName ? "" : duplicatedCourseName1 ? "" : "")); if (isNotExemptAndMend) { // ? String creditStr = credit.toString(); if (!isMend && !isExempt) creditStr = pass ? creditStr : creditStr + "*"; if (isDoubleMajor && isNotSameDepartCode) creditStr += "&"; if (isAssist && isNotSameDepartCode) creditStr += "#"; if (StringUtils.indexOf(creditStr, "*") == StringUtils.INDEX_NOT_FOUND) Toolket.setCellValue(sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 4, creditStr); else Toolket.setCellValue(workbook, sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 4, creditStr, colorFont, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 5, (isMend ? "" : (score == null ? "" : StringUtils.substringBefore( score.toString(), ".")))); Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), (rowOver ? k - 1 : k) * 6 + 5, (stavgs.isEmpty() ? "" : df.format(stavgs.get(0).getScore() + 0.001D))); } else { // ? String creditStr = credit.toString(); Toolket.setCellValue(sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 4, creditStr); if (is96Entrance) Toolket.setCellValue(sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 5, (isMend ? "" : "")); else { Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0), (rowOver ? k - 1 : k) * 6 + 5, (stavgs.isEmpty() ? "" : df.format(stavgs.get(0).getScore() + 0.001D))); Toolket.setCellValue(sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 5, score == null ? "" : StringUtils.substringBefore( score.toString(), ".")); } } } else { if (opt.length() == 1 || is96Entrance) Toolket.setCellValue(sheet, rowIndex, k * 6, (is96Entrance ? StringUtils.substring(opt, 0, 1) : opt)); else Toolket.setCellValue(workbook, sheet, rowIndex, k * 6, opt, fontSize12, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(sheet, rowIndex, k * 6 + 1, courseName); position.put(courseName, String.valueOf(rowIndex)); if (isNotExemptAndMend) { // ? String creditStr = credit.toString(); if (!isMend && !isExempt) creditStr = pass ? creditStr : creditStr + "*"; if (isDoubleMajor && isNotSameDepartCode) creditStr += "&"; if (isAssist && isNotSameDepartCode) creditStr += "#"; if (StringUtils.indexOf(creditStr, "*") == StringUtils.INDEX_NOT_FOUND) Toolket.setCellValue(sheet, rowIndex, k * 6 + 4, creditStr); else Toolket.setCellValue(workbook, sheet, rowIndex, k * 6 + 4, creditStr, colorFont, HSSFCellStyle.ALIGN_CENTER, true, null); // ?? Toolket.setCellValue(sheet, rowIndex++, k * 6 + 5, (isMend ? "" : (score == null ? "" : StringUtils.substringBefore( score.toString(), ".")))); // ?? Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0), k * 6 + 5, (stavgs.isEmpty() ? "" : df.format(stavgs.get(0).getScore() + 0.001D))); } else { // ? String creditStr = credit.toString(); Toolket.setCellValue(sheet, rowIndex, k * 6 + 4, creditStr); if (is96Entrance) Toolket.setCellValue(sheet, rowIndex++, k * 6 + 5, (isMend ? "" : "")); else { // ?? Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0), k * 6 + 5, (stavgs.isEmpty() ? "" : df.format(stavgs.get(0).getScore() + 0.001D))); Toolket.setCellValue(sheet, rowIndex++, k * 6 + 5, score == null ? "" : StringUtils.substringBefore( score.toString(), ".")); } } } } else { if (opt.length() == 1 || is96Entrance) Toolket.setCellValue(sheet, rowIndex, k * 6, (is96Entrance ? StringUtils.substring(opt, 0, 1) : opt)); else Toolket.setCellValue(workbook, sheet, rowIndex, k * 6, opt, fontSize12, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(sheet, rowIndex, k * 6 + 1, courseName); // ? String creditStr = credit.toString(); if (!isMend && !isExempt) creditStr = pass ? creditStr : creditStr + "*"; if (isDoubleMajor && isNotSameDepartCode) creditStr += "&"; if (isAssist && isNotSameDepartCode) creditStr += "#"; if (StringUtils.indexOf(creditStr, "*") == StringUtils.INDEX_NOT_FOUND) Toolket.setCellValue(sheet, rowIndex, k * 6 + 4, creditStr); else Toolket.setCellValue(workbook, sheet, rowIndex, k * 6 + 4, creditStr, colorFont, HSSFCellStyle.ALIGN_CENTER, true, null); if (isNotExemptAndMend) { Toolket.setCellValue(sheet, rowIndex++, k * 6 + 5, (isMend ? "" : (score == null ? "" : StringUtils.substringBefore( score.toString(), ".")))); Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0), k * 6 + 5, (stavgs.isEmpty() ? "" : df.format(stavgs.get(0).getScore() + 0.001D))); } else { if (is96Entrance) Toolket.setCellValue(sheet, rowIndex++, k * 6 + 5, (isMend ? "" : "")); else { Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0), k * 6 + 5, (stavgs.isEmpty() ? "" : df.format(stavgs.get(0).getScore() + 0.001D))); Toolket.setCellValue(sheet, rowIndex++, k * 6 + 5, score == null ? "" : StringUtils.substringBefore( score.toString(), ".")); } } } } } else { // ? if (1 == term) { if (isNotExemptAndMend) { Toolket.setCellValue(sheet, 35 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 3, String.valueOf(Math.round(hist.getScore()))); } else { if (!is96Entrance) Toolket.setCellValue(sheet, 35 + (isMaster ? -2 : 0), k * 6 + 3, hist.getScore() == null ? "" : String.valueOf( Math.round((hist.getScore())))); } } else { if (isNotExemptAndMend) { Toolket.setCellValue(sheet, 35 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 5, String.valueOf(Math.round(hist.getScore()))); } else { if (!is96Entrance) Toolket.setCellValue(sheet, 35 + (isMaster ? -2 : 0), k * 6 + 5, hist.getScore() == null ? "" : String.valueOf( Math.round(hist.getScore()))); } } } } // ? if (1 == term) { Toolket.setCellValue(sheet, 33 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 2, totalPassCredits.toString()); Toolket.setCellValue(sheet, 34 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 2, (passCreditsSum += totalPassCredits).toString()); } else { Toolket.setCellValue(sheet, 33 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 4, totalPassCredits.toString()); Toolket.setCellValue(sheet, 34 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 4, (passCreditsSum += totalPassCredits).toString()); } } // k--; } gmark = new Gmark(); gmark.setSchoolYear(year); gmark.setStudentNo(studentNo); gmarks = cm.findGMarkBy(gmark); if (!gmarks.isEmpty()) { StringBuilder builder = new StringBuilder(); for (Gmark gm : gmarks) builder.append(gm.getRemark()).append("\n "); int remarkCols = 0; switch (k) { case 0: remarkCols = 0; break; case 1: remarkCols = 6; break; case 2: remarkCols = 12; break; case 3: remarkCols = 18; break; } Toolket.setCellValue(sheet, 36, remarkCols, "" + builder.toString()); } if (rowOver) { Toolket.setCellValue(sheet, 32, (k - 1) * 6 + 5, ""); Toolket.setCellValue(sheet, 35, k * 6 + 5, Toolket.getCellValue(sheet, 35, (k - 1) * 6 + 5)); Toolket.setCellValue(sheet, 35, (k - 1) * 6 + 5, ""); } kk = k; rowIndexx = rowIndex; k++; j++; rowIndex = j >= 4 ? 49 : 6; // rowIndexx = j >= 4 ? 49 : 6; if (j == 4) { // rowIndex = 49; k = 0; nextPage = true; } } } if (isIncludeThisTermScore) { // Exception Students : 92148059, 92146011, 93148066, // 9144037, 914C009, 96164016, 9214D093 AdminManager am = (AdminManager) getBean(ADMIN_MANAGER_BEAN_NAME); Integer year = Integer.valueOf(am.findTermBy(PARAMETER_SCHOOL_YEAR)); boolean isSameYear = lastYear == year; // 2010.04.02isNeedCheck1true?false // ??false,??154D41931AD026??? // ?true boolean isNeedCheck = true, isNeedCheck1 = true; if (!isSameYear) { isNeedCheck1 = false; kk++; if (nextPage) { if (kk == 4) kk = 0; } Toolket.setCellValue(sheet, (nextPage ? 45 : 2), kk * 6, " " + formYear[(nextPage ? k + 4 : k)] + " "); Toolket.setCellValue(sheet, (nextPage ? 46 : 3), kk * 6, "" + year + " 9 " + (year + 1) + " 7 "); rowIndexx = nextPage ? 49 : 6; } if (!nextPage && rowIndexx >= 32) { // ?,:96164016 Toolket.setCellValue(sheet, (nextPage ? 45 : 2), (kk + 1) * 6, " " + formYear[(nextPage ? kk + 4 : kk)] + " "); Toolket.setCellValue(sheet, (nextPage ? 46 : 3), (kk + 1) * 6, "" + year + " 9 " + (year + 1) + " 7 "); rowIndexx = nextPage ? 49 : 6; kk++; } isNeedCheck = true; // passCreditsSum = 0.0F; totalPassCredits = 0.0F; selds = cm.findSeldByStudentNoAndTerm(studentNo, sterm); // boolean isNewSchoolYear = "1".equals(sterm); if (!selds.isEmpty()) { for (Seld seld : selds) { dtime = cm.findDtimeBy(seld.getDtimeOid()); csnos = cm.getCsnameBy(dtime.getCscode()); if (!csnos.isEmpty()) csno = (Csno) csnos.get(0); Toolket.setCellValue(sheet, rowIndexx, kk * 6, StringUtils.substring(Toolket.getCourseOpt(dtime.getOpt()), 0, 1)); Toolket.setCellValue(sheet, rowIndexx, kk * 6 + 1, csno == null ? "" : csno.getChiName()); totalPassCredits += dtime.getCredit(); if ("1".equals(sterm)) { Toolket.setCellValue(sheet, rowIndexx, kk * 6 + 2, dtime.getCredit().toString()); Toolket.setCellValue(sheet, rowIndexx++, kk * 6 + 3, String.valueOf(passScore)); } else { Toolket.setCellValue(sheet, rowIndexx, kk * 6 + 4, dtime.getCredit().toString()); Toolket.setCellValue(sheet, rowIndexx++, kk * 6 + 5, String.valueOf(Math.round(passScore))); } if (isNeedCheck && isNeedCheck1 && !isSameYear && rowIndexx >= 32) { isNeedCheck = false; kk++; if (kk % 4 == 0) { kk = 0; rowIndexx = nextPage ? 49 : 6; } // Toolket.setCellValue(sheet, 43, 0, // "?" // + title + "?"); // Toolket.setCellValue(sheet, 44, 1, "" // + studentNo); // Toolket.setCellValue(sheet, 44, 7, "??" // + student.getStudentName()); // Toolket // .setCellValue( // sheet, // 44, // 9, // "" // + (isMaster ? Toolket // .getMasterDepartName(departClass) // : Toolket // .getDepartName(departClass)) // + (isDoubleMajor // || isAssist ? "(" // + student // .getExtraStatus() // + ":" // + student // .getExtraDept() // + ")" // : "")); // Toolket.setCellValue(sheet, 44, 19, // "" // + student.getIdno()); Toolket.setCellValue(sheet, (nextPage ? 45 : 2), kk * 6, " " + formYear[(nextPage ? kk + 4 : kk)] + " "); Toolket.setCellValue(sheet, (nextPage ? 46 : 3), kk * 6, "" + year + " 9 " + (year + 1) + " 7 "); // rowIndexx = 6; // kk++; } } passCreditsSum += totalPassCredits; if ("1".equals(sterm)) { Toolket.setCellValue(sheet, (nextPage && j >= 4 && rowIndexx >= 49 ? 76 : 33) + (isMaster ? -2 : 0), kk * 6 + 2, totalPassCredits.toString()); Toolket.setCellValue(sheet, (nextPage && j >= 4 && rowIndexx >= 49 ? 77 : 34) + (isMaster ? -2 : 0), kk * 6 + 2, passCreditsSum.toString()); } else { Toolket.setCellValue(sheet, (nextPage && j >= 4 && rowIndexx >= 49 ? 76 : 33) + (isMaster ? -2 : 0), kk * 6 + 4, totalPassCredits.toString()); Toolket.setCellValue(sheet, (nextPage && j >= 4 && rowIndexx >= 49 ? 77 : 34) + (isMaster ? -2 : 0), kk * 6 + 4, passCreditsSum.toString()); } gmark = new Gmark(); gmark.setSchoolYear(Short.valueOf(year.toString())); gmark.setStudentNo(studentNo); gmarks = cm.findGMarkBy(gmark); if (!gmarks.isEmpty()) { StringBuilder builder = new StringBuilder(); for (Gmark gm : gmarks) builder.append(gm.getRemark()).append("\n "); int remarkCols = 0; switch (k) { case 0: remarkCols = 0; break; case 1: remarkCols = 6; break; case 2: remarkCols = 12; break; case 3: remarkCols = 18; break; } Toolket.setCellValue(sheet, 36, remarkCols, "" + builder.toString()); } String[] excluded = { "15", "64", "54", "A4", "B4" }; boolean hasInclude = ArrayUtils.contains(excluded, StringUtils.substring(departClass, 1, 3)); if (!isDelay && !hasInclude && rowIndexx <= 42) Toolket.removeRow(sheet, 43, 45); } } else { String[] excluded = { "15", "64", "54", "A4", "B4" }; boolean hasInclude = ArrayUtils.contains(excluded, StringUtils.substring(departClass, 1, 3)); if (!isDelay && !hasInclude && rowIndexx <= 42) Toolket.removeRow(sheet, 43, 45); } } File tempDir = new File(context .getRealPath("/WEB-INF/reports/temp/" + getUserCredential(session).getMember().getIdno() + (new SimpleDateFormat("yyyyMMdd").format(new Date())))); if (!tempDir.exists()) tempDir.mkdirs(); File output = new File(tempDir, departClass + ".xls"); FileOutputStream fos = new FileOutputStream(output); workbook.write(fos); fos.close(); JasperReportUtils.printXlsToFrontEnd(response, output); output.delete(); tempDir.delete(); // return null; } else { ServletContext context = request.getSession().getServletContext(); Map<String, String> parameters = new HashMap<String, String>(); File image = new File(context.getRealPath("/pages/reports/2002chitS.jpg")); parameters.put("IMAGE", image.getAbsolutePath()); byte[] bytes = JasperRunManager.runReportToPdf(JasperReportUtils.getNoResultReport(context), parameters, new JREmptyDataSource()); JasperReportUtils.printPdfToFrontEnd(response, bytes); } } }
From source file:tw.edu.chit.struts.action.registration.ReportPrintAction.java
/** * ???96/*w w w.ja v a 2s .co m*/ * * @param mapping org.apache.struts.action.ActionMapping object * @param form org.apache.struts.action.ActionForm object * @param request request javax.servlet.http.HttpServletRequest object * @param response response javax.servlet.http.HttpServletResponse object * @param sterm */ @SuppressWarnings("unchecked") protected void printClassStudentsScoreHistory4CreditClass(ActionMapping mapping, DynaActionForm form, HttpServletRequest request, HttpServletResponse response, String sterm) throws Exception { HttpSession session = request.getSession(false); MemberManager mm = (MemberManager) getBean(IConstants.MEMBER_MANAGER_BEAN_NAME); CourseManager cm = (CourseManager) getBean(IConstants.COURSE_MANAGER_BEAN_NAME); ScoreManager sm = (ScoreManager) getBean(IConstants.SCORE_MANAGER_BEAN_NAME); StudAffairManager sam = (StudAffairManager) getBean(IConstants.STUD_AFFAIR_MANAGER_BEAN_NAME); boolean isIncludeThisTermScore = "true".equalsIgnoreCase(request.getParameter("tt")); // String year = cm.getNowBy("School_year"); // String term = form.getString("sterm"); String studentNo = null; Clazz clazz = null; ScoreHist scoreHist = null, hist = null; List<Student> students = null; List<Clazz> clazzes = sm.findClassBy(new Clazz(processClassInfo(form)), getUserCredential(session).getClassInChargeAry(), false); if (!clazzes.isEmpty() && clazzes.size() > 1) { ActionMessages messages = new ActionMessages(); messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("", "")); saveMessages(request, messages); // return mapping.findForward(IConstants.ACTION_MAIN_NAME); ServletContext context = request.getSession().getServletContext(); Map<String, String> parameters = new HashMap<String, String>(); File image = new File(context.getRealPath("/pages/reports/2002chitS.jpg")); parameters.put("IMAGE", image.getAbsolutePath()); byte[] bytes = JasperRunManager.runReportToPdf(JasperReportUtils.getNoResultReport(context), parameters, new JREmptyDataSource()); JasperReportUtils.printPdfToFrontEnd(response, bytes); } else { clazz = clazzes.get(0); students = mm.findStudentsByClassNo(clazz.getClassNo()); if (!students.isEmpty()) { ServletContext context = request.getSession().getServletContext(); String[] excep = { "11G332" }; // ??+1 String[] formYear = { "", "", "", "", "", "", "", "" }; short firstYear = 0; short lastYear = 0; double justScore = 0.0D; int sheetIndex = 0; int k = 0, j = 0, rowIndex = 0, nextPageRowIndex = 0; int kk = 0, rowIndexx = 0; String departClass = clazz.getClassNo(); String departCode = "", title = "", evgrType = "", historyDepartCode = "", opt = "", cscode = ""; // ?70? float passScore = Toolket.getPassScoreByDepartClass(departClass); Graduate graduate = null; MasterData md = null; Just just = null; ScoreHist target = null; Dtime dtime = null; List csnos = null; Csno csno = null; Gmark gmark = null; Map<String, String> position = null; Float passCreditsSum = 0.0F; Float totalPassCredits = 0.0F; List<Seld> selds = null; List<ScoreHist> scoreHistList = null; List<Stavg> stavgs = null; List<Gmark> gmarks = null; boolean isOver = false; // (lastYear - firstYear + 1) > 4; boolean isDelay = Toolket.isDelayClass(departClass); boolean isSpringClass = false; // boolean isDoubleMajor = false; boolean isAssist = false; // 9608???Show????,?Show'',?????Show boolean is96Entrance = false; boolean isMaster = Toolket.isMasterClass(departClass); boolean nextPage = false, hasPassRecord = false, rowOver = false; boolean isNotExemptAndMend = false; // ??? boolean isExempt = false; // ??? boolean isMend = false; // ?? boolean isAppend = false; // ??? boolean isNotSameDepartCode = false; int studentCounts = students.size(); String fileName = ""; DecimalFormat df = new DecimalFormat(",##0.0"); File templateXLS = null; if (!isMaster) { if (studentCounts <= 30) fileName = "ClassStudentsScoreHistoryOver30.xls"; else if (studentCounts > 31 && studentCounts <= 40) fileName = "ClassStudentsScoreHistoryOver40.xls"; else if (studentCounts > 40 && studentCounts <= 45) fileName = "ClassStudentsScoreHistoryOver45.xls"; else if (studentCounts > 45 && studentCounts <= 50) fileName = "ClassStudentsScoreHistoryOver50.xls"; else if (studentCounts > 51 && studentCounts <= 55) fileName = "ClassStudentsScoreHistoryOver55.xls"; else fileName = "ClassStudentsScoreHistoryOver60.xls"; title = Toolket.getSchoolFormalName(departClass); if (isDelay) { // Only 20 Sheets templateXLS = new File( context.getRealPath("/WEB-INF/reports/ClassStudentsScoreHistoryOver.xls")); } else { templateXLS = new File(context.getRealPath("/WEB-INF/reports/" + fileName)); } } else { if (studentCounts <= 15) fileName = "ClassStudentsScoreHistoryMaster15.xls"; else if (studentCounts > 15 && studentCounts <= 20) fileName = "ClassStudentsScoreHistoryMaster20.xls"; else fileName = "ClassStudentsScoreHistoryMaster25.xls"; String masterId = StringUtils.substring(departClass, 1, 3); if ("1G".equals(masterId)) title = "?"; else title = "??"; templateXLS = new File(context.getRealPath("/WEB-INF/reports/" + fileName)); } HSSFWorkbook workbook = Toolket.getHSSFWorkbook(templateXLS); HSSFFont colorFont = workbook.createFont(); colorFont.setColor(HSSFColor.RED.index); colorFont.setFontHeightInPoints((short) 12); colorFont.setFontName("Arial Unicode MS"); HSSFFont fontSize12 = workbook.createFont(); fontSize12.setFontHeightInPoints((short) 12); fontSize12.setFontName("Arial Unicode MS"); HSSFSheet sheet = null; HSSFFont fontSize10 = workbook.createFont(); fontSize10.setFontHeightInPoints((short) 10); fontSize10.setFontName("Arial Unicode MS"); for (Student student : students) { studentNo = student.getStudentNo(); sheet = workbook.getSheetAt(sheetIndex); workbook.setSheetName(sheetIndex++, studentNo.toUpperCase()); if (student == null) { graduate = mm.findGraduateByStudentNo(studentNo); student = new Student(); BeanUtils.copyProperties(student, graduate); } // isDoubleMajor = "".equals(student.getExtraStatus()); isAssist = "".equals(student.getExtraStatus()); // departClass = student.getDepartClass(); // 9608???Show????,?Show'',?????Show is96Entrance = student.getEntrance() == null ? false : student.getEntrance() >= (short) 9608; scoreHist = new ScoreHist(studentNo); scoreHistList = sm.findScoreHistBy(scoreHist); if (scoreHistList.isEmpty()) { ActionMessages messages = new ActionMessages(); messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Course.messageN1", "?")); saveErrors(request, messages); log.error("No Score History... " + studentNo); sheetIndex--; continue; } else { firstYear = Short.parseShort(scoreHistList.get(0).getSchoolYear().toString()); lastYear = Short .parseShort(scoreHistList.get(scoreHistList.size() - 1).getSchoolYear().toString()); isOver = (lastYear - firstYear + 1) > 4; if (isOver) ; // log.error("It is Over... " + studentNo); departCode = ""; Toolket.setCellValue(sheet, 0, 0, "?" + title + "?"); Toolket.setCellValue(sheet, 1, 1, "" + studentNo); Toolket.setCellValue(sheet, 1, 7, "??" + student.getStudentName()); Toolket.setCellValue(sheet, 1, 9, "" + (isMaster ? Toolket.getMasterDepartName(departClass) : Toolket.getDepartName(departClass)) + (isDoubleMajor || isAssist ? "(" + student.getExtraStatus() + ":" + student.getExtraDept() + ")" : "")); Toolket.setCellValue(sheet, 1, 19, "" + student.getIdno()); // ?2,?code Toolket.setCellValue(sheet, 43, 0, "?" + title + "?"); Toolket.setCellValue(sheet, 44, 1, "" + studentNo); Toolket.setCellValue(sheet, 44, 7, "??" + student.getStudentName()); Toolket.setCellValue(sheet, 44, 9, "" + (isMaster ? Toolket.getMasterDepartName(departClass) : Toolket.getDepartName(departClass)) + (isDoubleMajor || isAssist ? "(" + student.getExtraStatus() + ":" + student.getExtraDept() + ")" : "")); Toolket.setCellValue(sheet, 44, 19, "" + student.getIdno()); if (isDelay) { Toolket.setCellValue(sheet, 43, 0, "?" + title + "?"); Toolket.setCellValue(sheet, 44, 1, "" + studentNo); Toolket.setCellValue(sheet, 44, 7, "??" + student.getStudentName()); Toolket.setCellValue(sheet, 44, 9, "" + (isMaster ? Toolket.getMasterDepartName(departClass) : Toolket.getDepartName(departClass)) + (isDoubleMajor || isAssist ? "(" + student.getExtraStatus() + ":" + student.getExtraDept() + ")" : "")); Toolket.setCellValue(sheet, 44, 19, "" + student.getIdno()); } if (isDoubleMajor || isAssist) { Toolket.setCellValue(sheet, 42, 0, " => *:?? #: &: "); departCode = StringUtils.substring(student.getDepartClass(), 3, 4); } if (isOver) { Toolket.setCellValue(sheet, 43, 0, "?" + title + "?"); Toolket.setCellValue(sheet, 44, 1, "" + studentNo); Toolket.setCellValue(sheet, 44, 7, "??" + student.getStudentName()); Toolket.setCellValue(sheet, 44, 9, "" + (isMaster ? Toolket.getMasterDepartName(departClass) : Toolket.getDepartName(departClass))); Toolket.setCellValue(sheet, 44, 19, "" + student.getIdno()); if (isDoubleMajor || isAssist) Toolket.setCellValue(sheet, 85, 0, " => *:?? #: &: "); } if (isMaster) { md = sm.findMasterByStudentNo(studentNo); if (md != null) { Toolket.setCellValue(sheet, 38, 0, "" + md.getThesesChiname()); Toolket.setCellValue(sheet, 39, 0, " " + md.getThesesEngname()); Toolket.setCellValue(sheet, 38, 17, md.getRemark()); Toolket.setCellValue(sheet, 40, 0, "??" + md.getThesesScore()); Toolket.setCellValue(sheet, 40, 4, "??(50%)" + md.getThesesScore() / 2); Toolket.setCellValue(sheet, 40, 8, "??" + md.getEvgr1Score()); Toolket.setCellValue(sheet, 40, 14, "??(50%)" + md.getEvgr1Score() / 2); Toolket.setCellValue(sheet, 40, 19, "?" + md.getGraduateScore()); } } if (Arrays.binarySearch(excep, departClass) >= 0) { lastYear++; isSpringClass = true; Toolket.setCellValue(sheet, 39, 17, "" + (lastYear + 1) + ".1"); } k = 0; j = 0; rowIndex = 6; nextPageRowIndex = 43; passCreditsSum = 0.0F; nextPage = false; hasPassRecord = false; rowOver = false; // List<Stavg> stavgs = null; // Just just = null; // String[] formYear = { "", "", "", "", "", "", // "", "" }; // ?Show scoreHist.setEvgrType("6"); scoreHistList = sm.findScoreHistBy(scoreHist); Float creditSum1 = 0.0F, creditSum2 = 0.0F; String courseName = null; if (!scoreHistList.isEmpty()) { rowIndex = 6; // position = new HashMap<String, String>(); // position1 = new HashMap<String, String>(); Toolket.setCellValue(sheet, 2 + (nextPage ? nextPageRowIndex : 0), k * 6, " ? ? "); for (int i = 0; i < scoreHistList.size(); i++) { hist = scoreHistList.get(i); Toolket.setCellValue(sheet, rowIndex, 0, StringUtils.substring(Toolket.getCourseOpt(hist.getOpt()), 0, 1)); courseName = cm.findCourseInfoByCscode(hist.getCscode()) == null ? "??" : cm.findCourseInfoByCscode(hist.getCscode()).getChiName().trim(); if (courseName.length() > 10) Toolket.setCellValue(workbook, sheet, rowIndex, 1, courseName, fontSize10, HSSFCellStyle.ALIGN_LEFT, true, null); else Toolket.setCellValue(sheet, rowIndex, 1, courseName); if (hist.getSchoolTerm().equals("1")) { Toolket.setCellValue(sheet, rowIndex, 2, hist.getCredit().toString()); creditSum1 += hist.getCredit(); Toolket.setCellValue(sheet, rowIndex, 3, ""); } else { Toolket.setCellValue(sheet, rowIndex, 4, hist.getCredit().toString()); creditSum2 += hist.getCredit(); Toolket.setCellValue(sheet, rowIndex, 5, ""); } rowIndex++; } Toolket.setCellValue(sheet, 33, 2, String.valueOf(creditSum1)); Toolket.setCellValue(sheet, 33, 4, String.valueOf(creditSum2)); Toolket.setCellValue(sheet, 34, 2, String.valueOf(creditSum1)); Toolket.setCellValue(sheet, 34, 4, String.valueOf(creditSum1 + creditSum2)); } rowIndex = 6; passCreditsSum = creditSum1 + creditSum2; scoreHist.setEvgrType(null); // ??? k = 1; // ?2 for (short year = firstYear; year <= lastYear; year++) { // ???9316D078 // ??? scoreHist.setSchoolYear(year); scoreHist.setSchoolTerm("1"); hasPassRecord = !sm.findScoreHistBy(scoreHist).isEmpty(); if (!hasPassRecord) { scoreHist.setSchoolTerm("2"); hasPassRecord = !sm.findScoreHistBy(scoreHist).isEmpty(); if (!hasPassRecord) continue; } if (isSpringClass && year == lastYear) { just = sam.findJustByStudentNo(studentNo); justScore = 0.0D; if (just == null || just.getTotalScore() == 0.0D) { target = new ScoreHist(studentNo); target.setSchoolYear(new Short(year)); target.setSchoolTerm("2"); target.setCscode("99999"); scoreHistList = sm.findScoreHistBy(target); if (!scoreHistList.isEmpty()) { scoreHist = sm.findScoreHistBy(scoreHist).get(0); justScore = scoreHist.getScore(); } } else justScore = just.getTotalScore(); Toolket.setCellValue(sheet, 35 + (isMaster ? -2 : 0), k * 6 + 3, justScore == 0.0D ? "" : String.valueOf(Math.round(justScore))); } if (rowOver) { Toolket.setCellValue(workbook, sheet, 2 + (nextPage ? nextPageRowIndex : 0), k * 6, " " + formYear[(nextPage ? k + 4 : k)] + " ", fontSize12, HSSFCellStyle.ALIGN_CENTER, true, null); } else Toolket.setCellValue(sheet, 2 + (nextPage ? nextPageRowIndex : 0), k * 6, " " + formYear[(nextPage ? k + 4 : k)] + " "); position = new HashMap<String, String>(); for (int term = 1; term <= 2; term++) { scoreHist.setSchoolYear(year); scoreHist.setSchoolTerm(String.valueOf(term)); // scoreHist.setEvgrType("1"); // ? scoreHistList = sm.findScoreHistBy(scoreHist); if (!scoreHistList.isEmpty()) { Toolket.setCellValue(sheet, 3 + (nextPage ? nextPageRowIndex : 0), k * 6, "" + year + " 9 " + (year + 1) + " 7 "); stavgs = sm.findStavgBy(new Stavg(studentNo, year, String.valueOf(term))); totalPassCredits = 0.0F; // for (ScoreHist hist : scoreHistList) { // i != scoreHistList.size() - // 1???,?? for (int i = 0; i < scoreHistList.size(); i++) { hist = scoreHistList.get(i); if (hist.getEvgrType().equals("6")) continue; // ??? if (rowIndex == 32 && i != scoreHistList.size() - 1) { rowIndex = 6; k++; Toolket.setCellValue(sheet, 2 + (nextPage ? nextPageRowIndex : 0), k * 6, " " + formYear[k - 1] + " "); Toolket.setCellValue(sheet, 3 + (nextPage ? nextPageRowIndex : 0), k * 6, "" + year + " 9 " + (year + 1) + " 7 "); rowOver = true; } evgrType = hist.getEvgrType(); isNotExemptAndMend = !"6".equals(evgrType) && !"5".equals(evgrType); // ??? isExempt = "6".equals(evgrType); // ??? isMend = "5".equals(evgrType); // ?? isAppend = "2".equals(evgrType); // ??? historyDepartCode = StringUtils.isBlank(hist.getStdepartClass()) ? "" : StringUtils.substring(hist.getStdepartClass(), 3, 4); isNotSameDepartCode = !departCode.equals(historyDepartCode) && !historyDepartCode.equals("0"); opt = ""; if ("3".equals(evgrType)) opt = ""; else opt = StringUtils.substring(Toolket.getCourseOpt(hist.getOpt()), 0, 1) + (isAppend ? "" : (isMend ? "" : (!isNotExemptAndMend ? "" : ""))); cscode = hist.getCscode(); if ("GA035".equals(cscode) || "".equals("GB033")) continue; // 2? if (!"99999".equals(cscode)) { // ? courseName = cm.findCourseInfoByCscode(cscode) == null ? "??" : cm.findCourseInfoByCscode(cscode).getChiName().trim(); Float credit = hist.getCredit(); Float score = hist.getScore(); boolean pass = (score == null ? 0.0F : score) >= passScore; // ((?&&?)||?)&&? if (((isNotExemptAndMend && pass) || isExempt) && !isMend) // if (!isNotExemptAndMend || // !isMend || // bFlag1) // if (!isMend && bFlag1) if (isMaster && "G".equalsIgnoreCase( StringUtils.substring(hist.getStdepartClass(), 2, 3))) { // ???,? totalPassCredits += credit; } else totalPassCredits += credit; if (1 == term) { if (opt.length() == 1 || is96Entrance) Toolket.setCellValue(sheet, rowIndex, k * 6, (is96Entrance ? StringUtils.substring(opt, 0, 1) : opt)); else Toolket.setCellValue(workbook, sheet, rowIndex, k * 6, opt, fontSize12, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(sheet, rowIndex, k * 6 + 1, courseName); position.put(courseName, String.valueOf(rowIndex)); if (isNotExemptAndMend) { // ? String creditStr = credit.toString(); if (!isMend && !isExempt) creditStr = pass ? creditStr : creditStr + "*"; if (isDoubleMajor && isNotSameDepartCode) creditStr += "&"; if (isAssist && isNotSameDepartCode) creditStr += "#"; if (StringUtils.indexOf(creditStr, "*") == StringUtils.INDEX_NOT_FOUND) Toolket.setCellValue(sheet, rowIndex, k * 6 + 2, creditStr); else Toolket.setCellValue(workbook, sheet, rowIndex, k * 6 + 2, creditStr, colorFont, HSSFCellStyle.ALIGN_CENTER, true, null); // ?? Toolket.setCellValue(sheet, rowIndex++, k * 6 + 3, (isMend ? "" : (score == null ? "" : StringUtils.substringBefore(score.toString(), ".")))); // ?? Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 3, (stavgs.isEmpty() ? "" : df.format( stavgs.get(0).getScore() + 0.001D))); } else { // ? String creditStr = credit.toString(); Toolket.setCellValue(sheet, rowIndex, k * 6 + 2, creditStr); if (is96Entrance) Toolket.setCellValue(sheet, rowIndex++, k * 6 + 3, (isMend ? "" : "")); else { // ?? Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 3, (stavgs.isEmpty() ? "" : df.format(stavgs.get(0).getScore() + 0.001D))); Toolket.setCellValue(sheet, rowIndex++, k * 6 + 3, score == null ? "" : StringUtils.substringBefore( score.toString(), ".")); } } } else { String endString = StringUtils.substring(courseName, courseName.length() - 1); boolean duplicatedCourseName = "".equals(endString); boolean duplicatedCourseName1 = "".equals(endString); boolean duplicatedCourseName2 = "".equals(endString); if (duplicatedCourseName || duplicatedCourseName1 || duplicatedCourseName2) { String courseIndex = StringUtils.substring(courseName, 0, courseName.length() - 1); String row = "", maybeSameCourseNameOptInfo = ""; if (duplicatedCourseName) { row = position.get(courseIndex + ""); if (row != null) maybeSameCourseNameOptInfo = Toolket.getCellValue(sheet, Integer.parseInt(row), (rowOver ? k - 1 : k) * 6); } else if (duplicatedCourseName1) { row = position.get(courseIndex + ""); if (row != null) maybeSameCourseNameOptInfo = Toolket.getCellValue(sheet, Integer.parseInt(row), (rowOver ? k - 1 : k) * 6); } else if (duplicatedCourseName2) { row = position.get(courseIndex + ""); if (row != null) maybeSameCourseNameOptInfo = Toolket.getCellValue(sheet, Integer.parseInt(row), (rowOver ? k - 1 : k) * 6); } // ????? boolean isAllowMerge = (StringUtils.contains(opt, "") && StringUtils.contains(maybeSameCourseNameOptInfo, "")) || (StringUtils.contains(opt, "?") && StringUtils .contains(maybeSameCourseNameOptInfo, "?")); if (row != null && isAllowMerge) { int rowNum = Integer.parseInt(row); Toolket.setCellValue(sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 1, Toolket.getCellValue(sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 1) + "?" + (duplicatedCourseName ? "" : duplicatedCourseName1 ? "" : "")); if (isNotExemptAndMend) { // ? String creditStr = credit.toString(); if (!isMend && !isExempt) creditStr = pass ? creditStr : creditStr + "*"; if (isDoubleMajor && isNotSameDepartCode) creditStr += "&"; if (isAssist && isNotSameDepartCode) creditStr += "#"; if (StringUtils.indexOf(creditStr, "*") == StringUtils.INDEX_NOT_FOUND) Toolket.setCellValue(sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 4, creditStr); else Toolket.setCellValue(workbook, sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 4, creditStr, colorFont, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 5, (isMend ? "" : (score == null ? "" : StringUtils.substringBefore( score.toString(), ".")))); Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), (rowOver ? k - 1 : k) * 6 + 5, (stavgs.isEmpty() ? "" : df.format(stavgs.get(0).getScore() + 0.001D))); } else { // ? String creditStr = credit.toString(); Toolket.setCellValue(sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 4, creditStr); if (is96Entrance) Toolket.setCellValue(sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 5, (isMend ? "" : "")); else { Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0), (rowOver ? k - 1 : k) * 6 + 5, (stavgs.isEmpty() ? "" : df.format(stavgs.get(0).getScore() + 0.001D))); Toolket.setCellValue(sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 5, score == null ? "" : StringUtils.substringBefore( score.toString(), ".")); } } } else { if (opt.length() == 1 || is96Entrance) Toolket.setCellValue(sheet, rowIndex, k * 6, (is96Entrance ? StringUtils.substring(opt, 0, 1) : opt)); else Toolket.setCellValue(workbook, sheet, rowIndex, k * 6, opt, fontSize12, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(sheet, rowIndex, k * 6 + 1, courseName); position.put(courseName, String.valueOf(rowIndex)); if (isNotExemptAndMend) { // ? String creditStr = credit.toString(); if (!isMend && !isExempt) creditStr = pass ? creditStr : creditStr + "*"; if (isDoubleMajor && isNotSameDepartCode) creditStr += "&"; if (isAssist && isNotSameDepartCode) creditStr += "#"; if (StringUtils.indexOf(creditStr, "*") == StringUtils.INDEX_NOT_FOUND) Toolket.setCellValue(sheet, rowIndex, k * 6 + 4, creditStr); else Toolket.setCellValue(workbook, sheet, rowIndex, k * 6 + 4, creditStr, colorFont, HSSFCellStyle.ALIGN_CENTER, true, null); // ?? Toolket.setCellValue(sheet, rowIndex++, k * 6 + 5, (isMend ? "" : (score == null ? "" : StringUtils.substringBefore( score.toString(), ".")))); // ?? Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0), k * 6 + 5, (stavgs.isEmpty() ? "" : df.format(stavgs.get(0).getScore() + 0.001D))); } else { // ? String creditStr = credit.toString(); Toolket.setCellValue(sheet, rowIndex, k * 6 + 4, creditStr); if (is96Entrance) Toolket.setCellValue(sheet, rowIndex++, k * 6 + 5, (isMend ? "" : "")); else { // ?? Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0), k * 6 + 5, (stavgs.isEmpty() ? "" : df.format(stavgs.get(0).getScore() + 0.001D))); Toolket.setCellValue(sheet, rowIndex++, k * 6 + 5, score == null ? "" : StringUtils.substringBefore( score.toString(), ".")); } } } } else { if (opt.length() == 1 || is96Entrance) Toolket.setCellValue(sheet, rowIndex, k * 6, (is96Entrance ? StringUtils.substring(opt, 0, 1) : opt)); else Toolket.setCellValue(workbook, sheet, rowIndex, k * 6, opt, fontSize12, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(sheet, rowIndex, k * 6 + 1, courseName); // ? String creditStr = credit.toString(); if (!isMend && !isExempt) creditStr = pass ? creditStr : creditStr + "*"; if (isDoubleMajor && isNotSameDepartCode) creditStr += "&"; if (isAssist && isNotSameDepartCode) creditStr += "#"; if (StringUtils.indexOf(creditStr, "*") == StringUtils.INDEX_NOT_FOUND) Toolket.setCellValue(sheet, rowIndex, k * 6 + 4, creditStr); else Toolket.setCellValue(workbook, sheet, rowIndex, k * 6 + 4, creditStr, colorFont, HSSFCellStyle.ALIGN_CENTER, true, null); if (isNotExemptAndMend) { Toolket.setCellValue(sheet, rowIndex++, k * 6 + 5, (isMend ? "" : (score == null ? "" : StringUtils.substringBefore( score.toString(), ".")))); Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0), k * 6 + 5, (stavgs.isEmpty() ? "" : df.format(stavgs.get(0).getScore() + 0.001D))); } else { if (is96Entrance) Toolket.setCellValue(sheet, rowIndex++, k * 6 + 5, (isMend ? "" : "")); else { Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0), k * 6 + 5, (stavgs.isEmpty() ? "" : df.format(stavgs.get(0).getScore() + 0.001D))); Toolket.setCellValue(sheet, rowIndex++, k * 6 + 5, score == null ? "" : StringUtils.substringBefore( score.toString(), ".")); } } } } } else { // ? if (1 == term) { if (isNotExemptAndMend) { Toolket.setCellValue(sheet, 35 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 3, String.valueOf(Math.round(hist.getScore()))); } else { if (!is96Entrance) Toolket.setCellValue(sheet, 35 + (isMaster ? -2 : 0), k * 6 + 3, hist.getScore() == null ? "" : String.valueOf( Math.round((hist.getScore())))); } } else { if (isNotExemptAndMend) { Toolket.setCellValue(sheet, 35 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 5, String.valueOf(Math.round(hist.getScore()))); } else { if (!is96Entrance) Toolket.setCellValue(sheet, 35 + (isMaster ? -2 : 0), k * 6 + 5, hist.getScore() == null ? "" : String.valueOf( Math.round(hist.getScore()))); } } } } // ? if (1 == term) { Toolket.setCellValue(sheet, 33 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 2, totalPassCredits.toString()); Toolket.setCellValue(sheet, 34 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 2, (passCreditsSum += totalPassCredits).toString()); } else { Toolket.setCellValue(sheet, 33 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 4, totalPassCredits.toString()); Toolket.setCellValue(sheet, 34 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 4, (passCreditsSum += totalPassCredits).toString()); } } // k--; } gmark = new Gmark(); gmark.setSchoolYear(year); gmark.setStudentNo(studentNo); gmarks = cm.findGMarkBy(gmark); if (!gmarks.isEmpty()) { StringBuilder builder = new StringBuilder(); for (Gmark gm : gmarks) builder.append(gm.getRemark()).append("\n "); int remarkCols = 0; switch (k) { case 0: remarkCols = 0; break; case 1: remarkCols = 6; break; case 2: remarkCols = 12; break; case 3: remarkCols = 18; break; } Toolket.setCellValue(sheet, 36, remarkCols, "" + builder.toString()); } if (rowOver) { Toolket.setCellValue(sheet, 32, (k - 1) * 6 + 5, ""); Toolket.setCellValue(sheet, 35, k * 6 + 5, Toolket.getCellValue(sheet, 35, (k - 1) * 6 + 5)); Toolket.setCellValue(sheet, 35, (k - 1) * 6 + 5, ""); } kk = k; rowIndexx = rowIndex; k++; j++; rowIndex = j >= 4 ? 49 : 6; // rowIndexx = j >= 4 ? 49 : 6; if (j == 4) { // rowIndex = 49; k = 0; nextPage = true; } } } if (isIncludeThisTermScore) { // Exception Students : 92148059, 92146011, 93148066, // 9144037, 914C009, 96164016, 9214D093 AdminManager am = (AdminManager) getBean(ADMIN_MANAGER_BEAN_NAME); Integer year = Integer.valueOf(am.findTermBy(PARAMETER_SCHOOL_YEAR)); boolean isSameYear = lastYear == year; boolean isNeedCheck = true, isNeedCheck1 = true; if (!isSameYear) { isNeedCheck1 = false; kk++; if (nextPage) { if (kk == 4) kk = 0; } Toolket.setCellValue(sheet, (nextPage ? 45 : 2), kk * 6, " " + formYear[(nextPage ? k + 4 : k)] + " "); Toolket.setCellValue(sheet, (nextPage ? 46 : 3), kk * 6, "" + year + " 9 " + (year + 1) + " 7 "); rowIndexx = nextPage ? 49 : 6; } if (!nextPage && rowIndexx >= 32) { // ?,:96164016 Toolket.setCellValue(sheet, (nextPage ? 45 : 2), (kk + 1) * 6, " " + formYear[(nextPage ? kk + 4 : kk)] + " "); Toolket.setCellValue(sheet, (nextPage ? 46 : 3), (kk + 1) * 6, "" + year + " 9 " + (year + 1) + " 7 "); rowIndexx = nextPage ? 49 : 6; kk++; } isNeedCheck = true; // passCreditsSum = 0.0F; totalPassCredits = 0.0F; selds = cm.findSeldByStudentNoAndTerm(studentNo, sterm); // boolean isNewSchoolYear = "1".equals(sterm); if (!selds.isEmpty()) { for (Seld seld : selds) { dtime = cm.findDtimeBy(seld.getDtimeOid()); csnos = cm.getCsnameBy(dtime.getCscode()); if (!csnos.isEmpty()) csno = (Csno) csnos.get(0); Toolket.setCellValue(sheet, rowIndexx, kk * 6, StringUtils.substring(Toolket.getCourseOpt(dtime.getOpt()), 0, 1)); Toolket.setCellValue(sheet, rowIndexx, kk * 6 + 1, csno == null ? "" : csno.getChiName()); totalPassCredits += dtime.getCredit(); if ("1".equals(sterm)) { Toolket.setCellValue(sheet, rowIndexx, kk * 6 + 2, dtime.getCredit().toString()); Toolket.setCellValue(sheet, rowIndexx++, kk * 6 + 3, String.valueOf(passScore)); } else { Toolket.setCellValue(sheet, rowIndexx, kk * 6 + 4, dtime.getCredit().toString()); Toolket.setCellValue(sheet, rowIndexx++, kk * 6 + 5, String.valueOf(Math.round(passScore))); } if (isNeedCheck && isNeedCheck1 && rowIndexx >= 32) { isNeedCheck = false; kk++; if (kk % 4 == 0) { kk = 0; rowIndexx = nextPage ? 49 : 6; } // Toolket.setCellValue(sheet, 43, 0, // "?" // + title + "?"); // Toolket.setCellValue(sheet, 44, 1, "" // + studentNo); // Toolket.setCellValue(sheet, 44, 7, "??" // + student.getStudentName()); // Toolket // .setCellValue( // sheet, // 44, // 9, // "" // + (isMaster ? Toolket // .getMasterDepartName(departClass) // : Toolket // .getDepartName(departClass)) // + (isDoubleMajor // || isAssist ? "(" // + student // .getExtraStatus() // + ":" // + student // .getExtraDept() // + ")" // : "")); // Toolket.setCellValue(sheet, 44, 19, // "" // + student.getIdno()); Toolket.setCellValue(sheet, (nextPage ? 45 : 2), kk * 6, " " + formYear[(nextPage ? kk + 4 : kk)] + " "); Toolket.setCellValue(sheet, (nextPage ? 46 : 3), kk * 6, "" + year + " 9 " + (year + 1) + " 7 "); // rowIndexx = 6; // kk++; } } passCreditsSum += totalPassCredits; if ("1".equals(sterm)) { Toolket.setCellValue(sheet, (nextPage && j >= 4 && rowIndexx >= 49 ? 76 : 33) + (isMaster ? -2 : 0), kk * 6 + 2, totalPassCredits.toString()); Toolket.setCellValue(sheet, (nextPage && j >= 4 && rowIndexx >= 49 ? 77 : 34) + (isMaster ? -2 : 0), kk * 6 + 2, passCreditsSum.toString()); } else { Toolket.setCellValue(sheet, (nextPage && j >= 4 && rowIndexx >= 49 ? 76 : 33) + (isMaster ? -2 : 0), kk * 6 + 4, totalPassCredits.toString()); Toolket.setCellValue(sheet, (nextPage && j >= 4 && rowIndexx >= 49 ? 77 : 34) + (isMaster ? -2 : 0), kk * 6 + 4, passCreditsSum.toString()); } String[] excluded = { "15", "64", "54", "A4", "B4" }; boolean hasInclude = ArrayUtils.contains(excluded, StringUtils.substring(departClass, 1, 3)); if (!isDelay && !hasInclude && rowIndexx <= 42) Toolket.removeRow(sheet, 43, 45); } } else { String[] excluded = { "15", "64", "54", "A4", "B4" }; boolean hasInclude = ArrayUtils.contains(excluded, StringUtils.substring(departClass, 1, 3)); if (!isDelay && !hasInclude && rowIndexx <= 42) Toolket.removeRow(sheet, 43, 45); } } File tempDir = new File(context .getRealPath("/WEB-INF/reports/temp/" + getUserCredential(session).getMember().getIdno() + (new SimpleDateFormat("yyyyMMdd").format(new Date())))); if (!tempDir.exists()) tempDir.mkdirs(); File output = new File(tempDir, departClass + ".xls"); FileOutputStream fos = new FileOutputStream(output); workbook.write(fos); fos.close(); JasperReportUtils.printXlsToFrontEnd(response, output); output.delete(); tempDir.delete(); // return null; } else { ServletContext context = request.getSession().getServletContext(); Map<String, String> parameters = new HashMap<String, String>(); File image = new File(context.getRealPath("/pages/reports/2002chitS.jpg")); parameters.put("IMAGE", image.getAbsolutePath()); byte[] bytes = JasperRunManager.runReportToPdf(JasperReportUtils.getNoResultReport(context), parameters, new JREmptyDataSource()); JasperReportUtils.printPdfToFrontEnd(response, bytes); } } }
From source file:tw.edu.chit.struts.action.registration.ReportPrintAction.java
/** * ???96/*from www . jav a 2 s . co m*/ * * @param mapping org.apache.struts.action.ActionMapping object * @param form org.apache.struts.action.ActionForm object * @param request request javax.servlet.http.HttpServletRequest object * @param response response javax.servlet.http.HttpServletResponse object * @param sterm */ @SuppressWarnings("unchecked") protected void printClassStudentsScoreHistory1(ActionMapping mapping, DynaActionForm form, HttpServletRequest request, HttpServletResponse response, String sterm) throws Exception { HttpSession session = request.getSession(false); MemberManager mm = (MemberManager) getBean(IConstants.MEMBER_MANAGER_BEAN_NAME); CourseManager cm = (CourseManager) getBean(IConstants.COURSE_MANAGER_BEAN_NAME); ScoreManager sm = (ScoreManager) getBean(IConstants.SCORE_MANAGER_BEAN_NAME); StudAffairManager sam = (StudAffairManager) getBean(IConstants.STUD_AFFAIR_MANAGER_BEAN_NAME); boolean isIncludeThisTermScore = "true".equalsIgnoreCase(request.getParameter("tt")); String studentNo = null; Clazz clazz = null; ScoreHist scoreHist = null, hist = null; List<Student> students = null; List<Graduate> graduates = null; List<Clazz> clazzes = sm.findClassBy(new Clazz(processClassInfo(form)), getUserCredential(session).getClassInChargeAry(), false); if (!clazzes.isEmpty() && clazzes.size() > 1) { ActionMessages messages = new ActionMessages(); messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("", "")); saveMessages(request, messages); ServletContext context = request.getSession().getServletContext(); Map<String, String> parameters = new HashMap<String, String>(); File image = new File(context.getRealPath("/pages/reports/2002chitS.jpg")); parameters.put("IMAGE", image.getAbsolutePath()); byte[] bytes = JasperRunManager.runReportToPdf(JasperReportUtils.getNoResultReport(context), parameters, new JREmptyDataSource()); JasperReportUtils.printPdfToFrontEnd(response, bytes); } else { clazz = clazzes.get(0); graduates = mm.findGraduatesByClassNo(clazz.getClassNo()); // ?96.2 String no = StringUtils.substring(clazz.getClassNo(), 0, 4) + (Integer.parseInt(StringUtils.substring(clazz.getClassNo(), 4)) + 10); students = mm.findStudentsByClassNo(no); for (Student student : students) { Graduate g = new Graduate(); BeanUtils.copyProperties(g, student); graduates.add(g); } if (!graduates.isEmpty()) { ServletContext context = request.getSession().getServletContext(); String[] excep = { "11G332" }; // ??+1 String[] formYear = { "", "", "", "", "", "", "", "" }; short firstYear = 0; short lastYear = 0; double justScore = 0.0D; int sheetIndex = 0; int k = 0, j = 0, rowIndex = 0, nextPageRowIndex = 0; int kk = 0, rowIndexx = 0; String departClass = clazz.getClassNo(); String departCode = "", title = "", evgrType = "", historyDepartCode = "", opt = "", cscode = ""; // ?70? float passScore = Toolket.getPassScoreByDepartClass(departClass); MasterData md = null; Just just = null; ScoreHist target = null; Dtime dtime = null; List csnos = null; Csno csno = null; Gmark gmark = null; Map<String, String> position = null; Float passCreditsSum = 0.0F; Float totalPassCredits = 0.0F; List<Seld> selds = null; List<ScoreHist> scoreHistList = null; List<Stavg> stavgs = null; List<Gmark> gmarks = null; boolean isOver = false; // (lastYear - firstYear + 1) > 4; boolean isDelay = Toolket.isDelayClass(departClass); boolean isSpringClass = false; // boolean isDoubleMajor = false; boolean isAssist = false; // 9608???Show????,?Show'',?????Show boolean is96Entrance = false; boolean isMaster = Toolket.isMasterClass(departClass); boolean nextPage = false, hasPassRecord = false, rowOver = false; boolean isNotExemptAndMend = false; // ??? boolean isExempt = false; // ??? boolean isMend = false; // ?? boolean isAppend = false; // ??? boolean isNotSameDepartCode = false; int studentCounts = graduates.size(); String fileName = ""; DecimalFormat df = new DecimalFormat(",##0.0"); File templateXLS = null; if (!isMaster) { if (studentCounts <= 30) fileName = "ClassStudentsScoreHistoryOver30.xls"; else if (studentCounts > 31 && studentCounts <= 40) fileName = "ClassStudentsScoreHistoryOver40.xls"; else if (studentCounts > 40 && studentCounts <= 45) fileName = "ClassStudentsScoreHistoryOver45.xls"; else if (studentCounts > 45 && studentCounts <= 50) fileName = "ClassStudentsScoreHistoryOver50.xls"; else if (studentCounts > 51 && studentCounts <= 55) fileName = "ClassStudentsScoreHistoryOver55.xls"; else fileName = "ClassStudentsScoreHistoryOver60.xls"; title = Toolket.getSchoolFormalName(departClass); if (isDelay) { // Only 20 Sheets templateXLS = new File( context.getRealPath("/WEB-INF/reports/ClassStudentsScoreHistoryOver.xls")); } else { templateXLS = new File(context.getRealPath("/WEB-INF/reports/" + fileName)); } } else { if (studentCounts <= 15) fileName = "ClassStudentsScoreHistoryMaster15.xls"; else if (studentCounts > 15 && studentCounts <= 20) fileName = "ClassStudentsScoreHistoryMaster20.xls"; else fileName = "ClassStudentsScoreHistoryMaster25.xls"; String masterId = StringUtils.substring(departClass, 1, 3); if ("1G".equals(masterId)) title = "?"; else title = "??"; templateXLS = new File(context.getRealPath("/WEB-INF/reports/" + fileName)); } HSSFWorkbook workbook = Toolket.getHSSFWorkbook(templateXLS); HSSFFont colorFont = workbook.createFont(); colorFont.setColor(HSSFColor.RED.index); colorFont.setFontHeightInPoints((short) 12); colorFont.setFontName("Arial Unicode MS"); HSSFFont fontSize12 = workbook.createFont(); fontSize12.setFontHeightInPoints((short) 12); fontSize12.setFontName("Arial Unicode MS"); HSSFSheet sheet = null; for (Graduate graduate : graduates) { studentNo = graduate.getStudentNo(); sheet = workbook.getSheetAt(sheetIndex); workbook.setSheetName(sheetIndex++, studentNo.toUpperCase()); // if (student == null) { // graduate = mm.findGraduateByStudentNo(studentNo); // student = new Student(); // BeanUtils.copyProperties(student, graduate); // } // isDoubleMajor = "".equals(graduate.getExtraStatus()); isAssist = "".equals(graduate.getExtraStatus()); // departClass = student.getDepartClass(); // 9608???Show????,?Show'',?????Show is96Entrance = graduate.getEntrance() == null ? false : graduate.getEntrance() >= (short) 9608; scoreHist = new ScoreHist(studentNo); scoreHistList = sm.findScoreHistBy(scoreHist); if (scoreHistList.isEmpty()) { ActionMessages messages = new ActionMessages(); messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Course.messageN1", "?")); saveErrors(request, messages); log.error("No Score History... " + studentNo); sheetIndex--; continue; } else { firstYear = Short.parseShort(scoreHistList.get(0).getSchoolYear().toString()); lastYear = Short .parseShort(scoreHistList.get(scoreHistList.size() - 1).getSchoolYear().toString()); isOver = (lastYear - firstYear + 1) > 4; if (isOver) ; // log.error("It is Over... " + studentNo); departCode = ""; Toolket.setCellValue(sheet, 0, 0, "?" + title + "?"); Toolket.setCellValue(sheet, 1, 1, "" + studentNo); Toolket.setCellValue(sheet, 1, 7, "??" + graduate.getStudentName()); Toolket.setCellValue(sheet, 1, 9, "" + (isMaster ? Toolket.getMasterDepartName(departClass) : Toolket.getDepartName(departClass)) + (isDoubleMajor || isAssist ? "(" + graduate.getExtraStatus() + ":" + graduate.getExtraDept() + ")" : "")); Toolket.setCellValue(sheet, 1, 19, "" + graduate.getIdno()); // ?2,?code Toolket.setCellValue(sheet, 43, 0, "?" + title + "?"); Toolket.setCellValue(sheet, 44, 1, "" + studentNo); Toolket.setCellValue(sheet, 44, 7, "??" + graduate.getStudentName()); Toolket.setCellValue(sheet, 44, 9, "" + (isMaster ? Toolket.getMasterDepartName(departClass) : Toolket.getDepartName(departClass)) + (isDoubleMajor || isAssist ? "(" + graduate.getExtraStatus() + ":" + graduate.getExtraDept() + ")" : "")); Toolket.setCellValue(sheet, 44, 19, "" + graduate.getIdno()); if (isDelay) { Toolket.setCellValue(sheet, 43, 0, "?" + title + "?"); Toolket.setCellValue(sheet, 44, 1, "" + studentNo); Toolket.setCellValue(sheet, 44, 7, "??" + graduate.getStudentName()); Toolket.setCellValue(sheet, 44, 9, "" + (isMaster ? Toolket.getMasterDepartName(departClass) : Toolket.getDepartName(departClass)) + (isDoubleMajor || isAssist ? "(" + graduate.getExtraStatus() + ":" + graduate.getExtraDept() + ")" : "")); Toolket.setCellValue(sheet, 44, 19, "" + graduate.getIdno()); } if (isDoubleMajor || isAssist) { Toolket.setCellValue(sheet, 42, 0, " => *:?? #: &: "); departCode = StringUtils.substring(graduate.getDepartClass(), 3, 4); } if (isOver) { Toolket.setCellValue(sheet, 43, 0, "?" + title + "?"); Toolket.setCellValue(sheet, 44, 1, "" + studentNo); Toolket.setCellValue(sheet, 44, 7, "??" + graduate.getStudentName()); Toolket.setCellValue(sheet, 44, 9, "" + (isMaster ? Toolket.getMasterDepartName(departClass) : Toolket.getDepartName(departClass))); Toolket.setCellValue(sheet, 44, 19, "" + graduate.getIdno()); if (isDoubleMajor || isAssist) Toolket.setCellValue(sheet, 85, 0, " => *:?? #: &: "); } if (isMaster) { md = sm.findMasterByStudentNo(studentNo); if (md != null) { Toolket.setCellValue(sheet, 38, 0, "" + md.getThesesChiname()); Toolket.setCellValue(sheet, 39, 0, " " + md.getThesesEngname()); Toolket.setCellValue(sheet, 38, 17, md.getRemark()); Toolket.setCellValue(sheet, 40, 0, "??" + md.getThesesScore()); Toolket.setCellValue(sheet, 40, 4, "??(50%)" + md.getThesesScore() / 2); Toolket.setCellValue(sheet, 40, 8, "??" + md.getEvgr1Score()); Toolket.setCellValue(sheet, 40, 14, "??(50%)" + md.getEvgr1Score() / 2); Toolket.setCellValue(sheet, 40, 19, "?" + md.getGraduateScore()); } } if (Arrays.binarySearch(excep, departClass) >= 0) { lastYear++; isSpringClass = true; Toolket.setCellValue(sheet, 39, 17, "" + (lastYear + 1) + ".1"); } k = 0; j = 0; rowIndex = 6; nextPageRowIndex = 43; passCreditsSum = 0.0F; nextPage = false; hasPassRecord = false; rowOver = false; // List<Stavg> stavgs = null; // Just just = null; // String[] formYear = { "", "", "", "", "", "", // "", "" }; for (short year = firstYear; year <= lastYear; year++) { // ???9316D078 // ??? scoreHist.setSchoolYear(year); scoreHist.setSchoolTerm("1"); hasPassRecord = !sm.findScoreHistBy(scoreHist).isEmpty(); if (!hasPassRecord) { scoreHist.setSchoolTerm("2"); hasPassRecord = !sm.findScoreHistBy(scoreHist).isEmpty(); if (!hasPassRecord) continue; } if (isSpringClass && year == lastYear) { just = sam.findJustByStudentNo(studentNo); justScore = 0.0D; if (just == null || just.getTotalScore() == 0.0D) { target = new ScoreHist(studentNo); target.setSchoolYear(new Short(year)); target.setSchoolTerm("2"); target.setCscode("99999"); scoreHistList = sm.findScoreHistBy(target); if (!scoreHistList.isEmpty()) { scoreHist = sm.findScoreHistBy(scoreHist).get(0); justScore = scoreHist.getScore(); } } else justScore = just.getTotalScore(); Toolket.setCellValue(sheet, 35 + (isMaster ? -2 : 0), k * 6 + 3, justScore == 0.0D ? "" : String.valueOf(Math.round(justScore))); } if (rowOver) { Toolket.setCellValue(workbook, sheet, 2 + (nextPage ? nextPageRowIndex : 0), k * 6, " " + formYear[(nextPage ? k + 4 : k)] + " ", fontSize12, HSSFCellStyle.ALIGN_CENTER, true, null); } else Toolket.setCellValue(sheet, 2 + (nextPage ? nextPageRowIndex : 0), k * 6, " " + formYear[(nextPage ? k + 4 : k)] + " "); position = new HashMap<String, String>(); for (int term = 1; term <= 2; term++) { scoreHist.setSchoolYear(year); scoreHist.setSchoolTerm(String.valueOf(term)); // scoreHist.setEvgrType("1"); // ? scoreHistList = sm.findScoreHistBy(scoreHist); if (!scoreHistList.isEmpty()) { Toolket.setCellValue(sheet, 3 + (nextPage ? nextPageRowIndex : 0), k * 6, "" + year + " 9 " + (year + 1) + " 7 "); stavgs = sm.findStavgBy(new Stavg(studentNo, year, String.valueOf(term))); totalPassCredits = 0.0F; // for (ScoreHist hist : scoreHistList) { // i != scoreHistList.size() - // 1???,?? for (int i = 0; i < scoreHistList.size(); i++) { hist = scoreHistList.get(i); if (rowIndex == 32 && i != scoreHistList.size() - 1) { rowIndex = 6; k++; Toolket.setCellValue(sheet, 2 + (nextPage ? nextPageRowIndex : 0), k * 6, " " + formYear[k - 1] + " "); Toolket.setCellValue(sheet, 3 + (nextPage ? nextPageRowIndex : 0), k * 6, "" + year + " 9 " + (year + 1) + " 7 "); rowOver = true; } evgrType = hist.getEvgrType(); isNotExemptAndMend = !"6".equals(evgrType) && !"5".equals(evgrType); // ??? isExempt = "6".equals(evgrType); // ??? isMend = "5".equals(evgrType); // ?? isAppend = "2".equals(evgrType); // ??? historyDepartCode = StringUtils.isBlank(hist.getStdepartClass()) ? "" : StringUtils.substring(hist.getStdepartClass(), 3, 4); isNotSameDepartCode = !departCode.equals(historyDepartCode) && !historyDepartCode.equals("0"); opt = ""; if ("3".equals(evgrType)) opt = ""; else opt = StringUtils.substring(Toolket.getCourseOpt(hist.getOpt()), 0, 1) + (isAppend ? "" : (isMend ? "" : (!isNotExemptAndMend ? "" : ""))); cscode = hist.getCscode(); if ("GA035".equals(cscode) || "".equals("GB033")) continue; // 2? if (!"99999".equals(cscode)) { // ? String courseName = cm.findCourseInfoByCscode(cscode) == null ? "??" : cm.findCourseInfoByCscode(cscode).getChiName().trim(); Float credit = hist.getCredit(); Float score = hist.getScore(); boolean pass = (score == null ? 0.0F : score) >= passScore; // ((?&&?)||?)&&? if (((isNotExemptAndMend && pass) || isExempt) && !isMend) // if (!isNotExemptAndMend || // !isMend || // bFlag1) // if (!isMend && bFlag1) if (isMaster && "G".equalsIgnoreCase( StringUtils.substring(hist.getStdepartClass(), 2, 3))) { // ???,? totalPassCredits += credit; } else totalPassCredits += credit; if (1 == term) { if (opt.length() == 1 || is96Entrance) Toolket.setCellValue(sheet, rowIndex, k * 6, (is96Entrance ? StringUtils.substring(opt, 0, 1) : opt)); else Toolket.setCellValue(workbook, sheet, rowIndex, k * 6, opt, fontSize12, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(sheet, rowIndex, k * 6 + 1, courseName); position.put(courseName, String.valueOf(rowIndex)); if (isNotExemptAndMend) { // ? String creditStr = credit.toString(); if (!isMend && !isExempt) creditStr = pass ? creditStr : creditStr + "*"; if (isDoubleMajor && isNotSameDepartCode) creditStr += "&"; if (isAssist && isNotSameDepartCode) creditStr += "#"; if (StringUtils.indexOf(creditStr, "*") == StringUtils.INDEX_NOT_FOUND) Toolket.setCellValue(sheet, rowIndex, k * 6 + 2, creditStr); else Toolket.setCellValue(workbook, sheet, rowIndex, k * 6 + 2, creditStr, colorFont, HSSFCellStyle.ALIGN_CENTER, true, null); // ?? Toolket.setCellValue(sheet, rowIndex++, k * 6 + 3, (isMend ? "" : (score == null ? "" : StringUtils.substringBefore(score.toString(), ".")))); // ?? Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 3, (stavgs.isEmpty() ? "" : df.format( stavgs.get(0).getScore() + 0.001D))); } else { // ? String creditStr = credit.toString(); Toolket.setCellValue(sheet, rowIndex, k * 6 + 2, creditStr); if (is96Entrance) Toolket.setCellValue(sheet, rowIndex++, k * 6 + 3, (isMend ? "" : "")); else { // ?? Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 3, (stavgs.isEmpty() ? "" : df.format(stavgs.get(0).getScore() + 0.001D))); Toolket.setCellValue(sheet, rowIndex++, k * 6 + 3, score == null ? "" : StringUtils.substringBefore( score.toString(), ".")); } } } else { String endString = StringUtils.substring(courseName, courseName.length() - 1); boolean duplicatedCourseName = "".equals(endString); boolean duplicatedCourseName1 = "".equals(endString); boolean duplicatedCourseName2 = "".equals(endString); if (duplicatedCourseName || duplicatedCourseName1 || duplicatedCourseName2) { String courseIndex = StringUtils.substring(courseName, 0, courseName.length() - 1); String row = "", maybeSameCourseNameOptInfo = ""; if (duplicatedCourseName) { row = position.get(courseIndex + ""); if (row != null) maybeSameCourseNameOptInfo = Toolket.getCellValue(sheet, Integer.parseInt(row), (rowOver ? k - 1 : k) * 6); } else if (duplicatedCourseName1) { row = position.get(courseIndex + ""); if (row != null) maybeSameCourseNameOptInfo = Toolket.getCellValue(sheet, Integer.parseInt(row), (rowOver ? k - 1 : k) * 6); } else if (duplicatedCourseName2) { row = position.get(courseIndex + ""); if (row != null) maybeSameCourseNameOptInfo = Toolket.getCellValue(sheet, Integer.parseInt(row), (rowOver ? k - 1 : k) * 6); } // ????? boolean isAllowMerge = (StringUtils.contains(opt, "") && StringUtils.contains(maybeSameCourseNameOptInfo, "")) || (StringUtils.contains(opt, "?") && StringUtils .contains(maybeSameCourseNameOptInfo, "?")); if (row != null && isAllowMerge) { int rowNum = Integer.parseInt(row); Toolket.setCellValue(sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 1, Toolket.getCellValue(sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 1) + "?" + (duplicatedCourseName ? "" : duplicatedCourseName1 ? "" : "")); if (isNotExemptAndMend) { // ? String creditStr = credit.toString(); if (!isMend && !isExempt) creditStr = pass ? creditStr : creditStr + "*"; if (isDoubleMajor && isNotSameDepartCode) creditStr += "&"; if (isAssist && isNotSameDepartCode) creditStr += "#"; if (StringUtils.indexOf(creditStr, "*") == StringUtils.INDEX_NOT_FOUND) Toolket.setCellValue(sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 4, creditStr); else Toolket.setCellValue(workbook, sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 4, creditStr, colorFont, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 5, (isMend ? "" : (score == null ? "" : StringUtils.substringBefore( score.toString(), ".")))); Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), (rowOver ? k - 1 : k) * 6 + 5, (stavgs.isEmpty() ? "" : df.format(stavgs.get(0).getScore() + 0.001D))); } else { // ? String creditStr = credit.toString(); Toolket.setCellValue(sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 4, creditStr); if (is96Entrance) Toolket.setCellValue(sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 5, (isMend ? "" : "")); else { Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0), (rowOver ? k - 1 : k) * 6 + 5, (stavgs.isEmpty() ? "" : df.format(stavgs.get(0).getScore() + 0.001D))); Toolket.setCellValue(sheet, rowNum, (rowOver ? k - 1 : k) * 6 + 5, score == null ? "" : StringUtils.substringBefore( score.toString(), ".")); } } } else { if (opt.length() == 1 || is96Entrance) Toolket.setCellValue(sheet, rowIndex, k * 6, (is96Entrance ? StringUtils.substring(opt, 0, 1) : opt)); else Toolket.setCellValue(workbook, sheet, rowIndex, k * 6, opt, fontSize12, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(sheet, rowIndex, k * 6 + 1, courseName); position.put(courseName, String.valueOf(rowIndex)); if (isNotExemptAndMend) { // ? String creditStr = credit.toString(); if (!isMend && !isExempt) creditStr = pass ? creditStr : creditStr + "*"; if (isDoubleMajor && isNotSameDepartCode) creditStr += "&"; if (isAssist && isNotSameDepartCode) creditStr += "#"; if (StringUtils.indexOf(creditStr, "*") == StringUtils.INDEX_NOT_FOUND) Toolket.setCellValue(sheet, rowIndex, k * 6 + 4, creditStr); else Toolket.setCellValue(workbook, sheet, rowIndex, k * 6 + 4, creditStr, colorFont, HSSFCellStyle.ALIGN_CENTER, true, null); // ?? Toolket.setCellValue(sheet, rowIndex++, k * 6 + 5, (isMend ? "" : (score == null ? "" : StringUtils.substringBefore( score.toString(), ".")))); // ?? Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0), k * 6 + 5, (stavgs.isEmpty() ? "" : df.format(stavgs.get(0).getScore() + 0.001D))); } else { // ? String creditStr = credit.toString(); Toolket.setCellValue(sheet, rowIndex, k * 6 + 4, creditStr); if (is96Entrance) Toolket.setCellValue(sheet, rowIndex++, k * 6 + 5, (isMend ? "" : "")); else { // ?? Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0), k * 6 + 5, (stavgs.isEmpty() ? "" : df.format(stavgs.get(0).getScore() + 0.001D))); Toolket.setCellValue(sheet, rowIndex++, k * 6 + 5, score == null ? "" : StringUtils.substringBefore( score.toString(), ".")); } } } } else { if (opt.length() == 1 || is96Entrance) Toolket.setCellValue(sheet, rowIndex, k * 6, (is96Entrance ? StringUtils.substring(opt, 0, 1) : opt)); else Toolket.setCellValue(workbook, sheet, rowIndex, k * 6, opt, fontSize12, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(sheet, rowIndex, k * 6 + 1, courseName); // ? String creditStr = credit.toString(); if (!isMend && !isExempt) creditStr = pass ? creditStr : creditStr + "*"; if (isDoubleMajor && isNotSameDepartCode) creditStr += "&"; if (isAssist && isNotSameDepartCode) creditStr += "#"; if (StringUtils.indexOf(creditStr, "*") == StringUtils.INDEX_NOT_FOUND) Toolket.setCellValue(sheet, rowIndex, k * 6 + 4, creditStr); else Toolket.setCellValue(workbook, sheet, rowIndex, k * 6 + 4, creditStr, colorFont, HSSFCellStyle.ALIGN_CENTER, true, null); if (isNotExemptAndMend) { Toolket.setCellValue(sheet, rowIndex++, k * 6 + 5, (isMend ? "" : (score == null ? "" : StringUtils.substringBefore( score.toString(), ".")))); Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0), k * 6 + 5, (stavgs.isEmpty() ? "" : df.format(stavgs.get(0).getScore() + 0.001D))); } else { if (is96Entrance) Toolket.setCellValue(sheet, rowIndex++, k * 6 + 5, (isMend ? "" : "")); else { Toolket.setCellValue(sheet, 32 + (isMaster ? -2 : 0), k * 6 + 5, (stavgs.isEmpty() ? "" : df.format(stavgs.get(0).getScore() + 0.001D))); Toolket.setCellValue(sheet, rowIndex++, k * 6 + 5, score == null ? "" : StringUtils.substringBefore( score.toString(), ".")); } } } } } else { // ? if (1 == term) { if (isNotExemptAndMend) { Toolket.setCellValue(sheet, 35 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 3, String.valueOf(Math.round(hist.getScore()))); } else { if (!is96Entrance) Toolket.setCellValue(sheet, 35 + (isMaster ? -2 : 0), k * 6 + 3, hist.getScore() == null ? "" : String.valueOf( Math.round((hist.getScore())))); } } else { if (isNotExemptAndMend) { Toolket.setCellValue(sheet, 35 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 5, String.valueOf(Math.round(hist.getScore()))); } else { if (!is96Entrance) Toolket.setCellValue(sheet, 35 + (isMaster ? -2 : 0), k * 6 + 5, hist.getScore() == null ? "" : String.valueOf( Math.round(hist.getScore()))); } } } } // ? if (1 == term) { Toolket.setCellValue(sheet, 33 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 2, totalPassCredits.toString()); Toolket.setCellValue(sheet, 34 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 2, (passCreditsSum += totalPassCredits).toString()); } else { Toolket.setCellValue(sheet, 33 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 4, totalPassCredits.toString()); Toolket.setCellValue(sheet, 34 + (isMaster ? -2 : 0) + (nextPage ? nextPageRowIndex : 0), k * 6 + 4, (passCreditsSum += totalPassCredits).toString()); } } // k--; } gmark = new Gmark(); gmark.setSchoolYear(year); gmark.setStudentNo(studentNo); gmarks = cm.findGMarkBy(gmark); if (!gmarks.isEmpty()) { StringBuilder builder = new StringBuilder(); for (Gmark gm : gmarks) builder.append(gm.getRemark()).append("\n "); int remarkCols = 0; switch (k) { case 0: remarkCols = 0; break; case 1: remarkCols = 6; break; case 2: remarkCols = 12; break; case 3: remarkCols = 18; break; } Toolket.setCellValue(sheet, 36, remarkCols, "" + builder.toString()); } if (rowOver) { Toolket.setCellValue(sheet, 32, (k - 1) * 6 + 5, ""); Toolket.setCellValue(sheet, 35, k * 6 + 5, Toolket.getCellValue(sheet, 35, (k - 1) * 6 + 5)); Toolket.setCellValue(sheet, 35, (k - 1) * 6 + 5, ""); } kk = k; rowIndexx = rowIndex; k++; j++; rowIndex = j >= 4 ? 49 : 6; // rowIndexx = j >= 4 ? 49 : 6; if (j == 4) { // rowIndex = 49; k = 0; nextPage = true; } } } if (isIncludeThisTermScore) { // Exception Students : 92148059, 92146011, 93148066, // 9144037, 914C009, 96164016, 9214D093 AdminManager am = (AdminManager) getBean(ADMIN_MANAGER_BEAN_NAME); Integer year = Integer.valueOf(am.findTermBy(PARAMETER_SCHOOL_YEAR)); boolean isSameYear = lastYear == year; boolean isNeedCheck = true, isNeedCheck1 = true; if (!isSameYear) { isNeedCheck1 = false; if (nextPage) { kk++; if (kk == 4) kk = 0; } Toolket.setCellValue(sheet, (nextPage ? 45 : 2), kk * 6, " " + formYear[(nextPage ? k + 4 : k)] + " "); Toolket.setCellValue(sheet, (nextPage ? 46 : 3), kk * 6, "" + year + " 9 " + (year + 1) + " 7 "); rowIndexx = nextPage ? 49 : 6; // kk++; } if (!nextPage && rowIndexx >= 32) { // ?,:96164016 Toolket.setCellValue(sheet, (nextPage ? 45 : 2), (kk + 1) * 6, " " + formYear[(nextPage ? kk + 4 : kk)] + " "); Toolket.setCellValue(sheet, (nextPage ? 46 : 3), (kk + 1) * 6, "" + year + " 9 " + (year + 1) + " 7 "); rowIndexx = nextPage ? 49 : 6; kk++; } isNeedCheck = true; // passCreditsSum = 0.0F; totalPassCredits = 0.0F; selds = cm.findSeldByStudentNoAndTerm(studentNo, sterm); // boolean isNewSchoolYear = "1".equals(sterm); if (!selds.isEmpty()) { for (Seld seld : selds) { dtime = cm.findDtimeBy(seld.getDtimeOid()); csnos = cm.getCsnameBy(dtime.getCscode()); if (!csnos.isEmpty()) csno = (Csno) csnos.get(0); Toolket.setCellValue(sheet, rowIndexx, kk * 6, StringUtils.substring(Toolket.getCourseOpt(dtime.getOpt()), 0, 1)); Toolket.setCellValue(sheet, rowIndexx, kk * 6 + 1, csno == null ? "" : csno.getChiName()); totalPassCredits += dtime.getCredit(); if ("1".equals(sterm)) { Toolket.setCellValue(sheet, rowIndexx, kk * 6 + 2, dtime.getCredit().toString()); Toolket.setCellValue(sheet, rowIndexx++, kk * 6 + 3, String.valueOf(passScore)); } else { Toolket.setCellValue(sheet, rowIndexx, kk * 6 + 4, dtime.getCredit().toString()); Toolket.setCellValue(sheet, rowIndexx++, kk * 6 + 5, String.valueOf(Math.round(passScore))); } if (isNeedCheck && isNeedCheck1 && rowIndexx >= 32) { isNeedCheck = false; kk++; if (kk % 4 == 0) { kk = 0; rowIndexx = nextPage ? 49 : 6; } // Toolket.setCellValue(sheet, 43, 0, // "?" // + title + "?"); // Toolket.setCellValue(sheet, 44, 1, "" // + studentNo); // Toolket.setCellValue(sheet, 44, 7, "??" // + student.getStudentName()); // Toolket // .setCellValue( // sheet, // 44, // 9, // "" // + (isMaster ? Toolket // .getMasterDepartName(departClass) // : Toolket // .getDepartName(departClass)) // + (isDoubleMajor // || isAssist ? "(" // + student // .getExtraStatus() // + ":" // + student // .getExtraDept() // + ")" // : "")); // Toolket.setCellValue(sheet, 44, 19, // "" // + student.getIdno()); Toolket.setCellValue(sheet, (nextPage ? 45 : 2), kk * 6, " " + formYear[(nextPage ? kk + 4 : kk)] + " "); Toolket.setCellValue(sheet, (nextPage ? 46 : 3), kk * 6, "" + year + " 9 " + (year + 1) + " 7 "); // rowIndexx = 6; // kk++; } } passCreditsSum += totalPassCredits; if ("1".equals(sterm)) { Toolket.setCellValue(sheet, (nextPage && j >= 4 && rowIndexx >= 49 ? 76 : 33) + (isMaster ? -2 : 0), kk * 6 + 2, totalPassCredits.toString()); Toolket.setCellValue(sheet, (nextPage && j >= 4 && rowIndexx >= 49 ? 77 : 34) + (isMaster ? -2 : 0), kk * 6 + 2, passCreditsSum.toString()); } else { Toolket.setCellValue(sheet, (nextPage && j >= 4 && rowIndexx >= 49 ? 76 : 33) + (isMaster ? -2 : 0), kk * 6 + 4, totalPassCredits.toString()); Toolket.setCellValue(sheet, (nextPage && j >= 4 && rowIndexx >= 49 ? 77 : 34) + (isMaster ? -2 : 0), kk * 6 + 4, passCreditsSum.toString()); } String[] excluded = { "15", "64", "54", "A4", "B4" }; boolean hasInclude = ArrayUtils.contains(excluded, StringUtils.substring(departClass, 1, 3)); if (!isDelay && !hasInclude && rowIndexx <= 42) Toolket.removeRow(sheet, 43, 45); } } else { String[] excluded = { "15", "64", "54", "A4", "B4" }; boolean hasInclude = ArrayUtils.contains(excluded, StringUtils.substring(departClass, 1, 3)); if (!isDelay && !hasInclude && rowIndexx <= 42) Toolket.removeRow(sheet, 43, 45); } } File tempDir = new File(context .getRealPath("/WEB-INF/reports/temp/" + getUserCredential(session).getMember().getIdno() + (new SimpleDateFormat("yyyyMMdd").format(new Date())))); if (!tempDir.exists()) tempDir.mkdirs(); File output = new File(tempDir, departClass + ".xls"); FileOutputStream fos = new FileOutputStream(output); workbook.write(fos); fos.close(); JasperReportUtils.printXlsToFrontEnd(response, output); output.delete(); tempDir.delete(); // return null; } else { ServletContext context = request.getSession().getServletContext(); Map<String, String> parameters = new HashMap<String, String>(); File image = new File(context.getRealPath("/pages/reports/2002chitS.jpg")); parameters.put("IMAGE", image.getAbsolutePath()); byte[] bytes = JasperRunManager.runReportToPdf(JasperReportUtils.getNoResultReport(context), parameters, new JREmptyDataSource()); JasperReportUtils.printPdfToFrontEnd(response, bytes); } } }