package com.basic.x01.location; import java.io.File; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.basic.x01.base.BaseController; import framework.util.excel.ExcelWriter; @Controller public class DailyReportExport extends BaseController { @RequestMapping(value="locationReportDownload") public String download() throws Throwable { // String searchDate = c.getString("searchDate"); // if(! c.valid(searchDate)){ // searchDate = TimeUtil.getDate10(); // } // // Sql sql = this.makeSql(c, searchDate); // // List> list = sql.select().endList(); // ExcelWriter w = ExcelWriter.open(//searchDate+ "到校离校情况"); w.setSheet("Sheet1"); //序号 年级 班级 姓名 卡号 性别 年龄 w.setTitle(new String[]{ "序号", "年级", "班级", "姓名", "卡号", "到校时间", "离线时间" }); int col = 0; int row = 1; // for(Map m : list){ // TbSchStudent s = (TbSchStudent)m.get("s"); // // col = 0; // // w.setCellValue(row, col++, row); // w.setCellValue(row, col++, s.getGradeName()); // w.setCellValue(row, col++, s.getClassName()); // w.setCellValue(row, col++, s.getStudentName()+ // (s.getStatus().equals("1")?"":"(挂起)")); // w.setCellValue(row, col++, s.getLocCardNo()); // // w.setCellValue(row, col++, (String)Select.getRowRaw(m, "come_time")); // w.setCellValue(row, col++, (String)Select.getRowRaw(m, "leave_time")); // row++; // } w.freeze(1, 1); w.saveAndClose(); File f = w.getFile(); return this.downloadFile(f, f.getName(), true); } // public Sql makeSql(ActionContext c, String searchDate) throws Throwable { // Integer schoolId = UserUtil.getUserSchoolId(c.getRequest()); // // Sql sql = c.getDao().sql("select") // .select(TbSchStudent.class, "s").get() // // .append(",(select grade_name").from().table(TbSchClass.class) // .append("c where c.school_id=").param(schoolId) // .append("and class_id=s.class_id) as s_grade_name") // // .append(",(select class_name").from().table(TbSchClass.class) // .append("c where c.school_id=").param(schoolId) // .append("and class_id=s.class_id) as s_class_name") // // .append(", (select substr(min(l.loc_time), 1, 16)") // .from().append(LocationUtil.TB_NAME) // .append("l where l.student_id=s.student_id ") // .append("and instr(l.loc_time, '"+searchDate+"')=1") // .append("and l.loc_type=").param(LocationUtil.COME_IN_1) // .append("and l.gate_position='1'") // .append(") as come_time") // .append(", (select substr(max(l.loc_time), 1, 16)") // .from().append(LocationUtil.TB_NAME) // .append("l where l.student_id=s.student_id ") // .append("and instr(l.loc_time, '"+searchDate+"')=1") // .append("and l.loc_type=").param(LocationUtil.LEAVE_OUT_2) // .append("and l.gate_position='1'") // .append(") as leave_time") // // .from().table("s") // .append("where school_id=").param(schoolId); // // String searchName = c.getString("searchName"); // if(c.valid(searchName)){ // sql.append("and (student_name like '%"+searchName.trim()+"%' ") // .append("or loc_card_no like '%"+searchName.trim()+"%' )"); // // c.setAttribute("searchName", searchName); // } // // sql.append("order by class_id, ") // .append("CONVERT(student_name USING gbk ) COLLATE gbk_chinese_ci"); // // return sql; // } }