liuxiaolong
2019-05-09 0d1d88cdb668e75ea8609417ac18ae19947e9525
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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<Map<String,Object>> list = sql.select().endList();
//
        ExcelWriter w = ExcelWriter.open(//searchDate+
                "到校离校情况");
        w.setSheet("Sheet1");
        
        //序号    年级    班级    姓名    卡号    性别    年龄
        w.setTitle(new String[]{
            "序号", "年级", "班级", 
            "姓名",    
            "卡号",
            "到校时间",
            "离线时间"
        });
        
        int col = 0;
        int row = 1;
        
//        for(Map<String,Object> 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;
//    }
 
}