5b03edef
孙向锦
更新协议
|
1
2
3
4
5
6
7
8
9
10
|
package com.fh.controller.sunvote.student;
import java.io.PrintWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
|
7d60b75e
孙向锦
添加班级-1
|
11
|
|
5b03edef
孙向锦
更新协议
|
12
|
import javax.annotation.Resource;
|
7d60b75e
孙向锦
添加班级-1
|
13
|
|
5b03edef
孙向锦
更新协议
|
14
15
16
17
18
|
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
|
b5cf92b7
孙向锦
批量上传学生名单
|
19
|
import org.springframework.web.bind.annotation.RequestParam;
|
5b03edef
孙向锦
更新协议
|
20
|
import org.springframework.web.bind.annotation.ResponseBody;
|
b5cf92b7
孙向锦
批量上传学生名单
|
21
|
import org.springframework.web.multipart.MultipartFile;
|
5b03edef
孙向锦
更新协议
|
22
|
import org.springframework.web.servlet.ModelAndView;
|
7d60b75e
孙向锦
添加班级-1
|
23
|
|
5b03edef
孙向锦
更新协议
|
24
25
26
|
import com.fh.controller.base.BaseController;
import com.fh.entity.Page;
import com.fh.util.AppUtil;
|
b5cf92b7
孙向锦
批量上传学生名单
|
27
28
29
|
import com.fh.util.Const;
import com.fh.util.FileUpload;
import com.fh.util.ObjectExcelRead;
|
5b03edef
孙向锦
更新协议
|
30
31
32
|
import com.fh.util.ObjectExcelView;
import com.fh.util.PageData;
import com.fh.util.Jurisdiction;
|
b5cf92b7
孙向锦
批量上传学生名单
|
33
|
import com.fh.util.PathUtil;
|
5b03edef
孙向锦
更新协议
|
34
|
import com.fh.util.Tools;
|
7d60b75e
孙向锦
添加班级-1
|
35
|
import com.fh.service.sunvote.classroster.ClassRosterManager;
|
5b03edef
孙向锦
更新协议
|
36
|
import com.fh.service.sunvote.student.StudentManager;
|
a479f295
孙向锦
添加了报表逻辑
|
37
|
import com.fh.service.sunvote.term.TermManager;
|
5b03edef
孙向锦
更新协议
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
/**
* 说明:学生管理
* 创建人:Elvis
* 创建时间:2018-04-28
*/
@Controller
@RequestMapping(value="/student")
public class StudentController extends BaseController {
String menuUrl = "student/list.do"; //菜单地址(权限用)
@Resource(name="studentService")
private StudentManager studentService;
|
7d60b75e
孙向锦
添加班级-1
|
52
53
54
|
@Resource(name="classrosterService")
private ClassRosterManager classrosterService;
|
a479f295
孙向锦
添加了报表逻辑
|
55
56
57
|
@Resource(name="termService")
private TermManager termService;
|
5b03edef
孙向锦
更新协议
|
58
59
60
61
62
63
64
|
/**保存
* @param
* @throws Exception
*/
@RequestMapping(value="/save")
public ModelAndView save() throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"新增Student");
|
5b03edef
孙向锦
更新协议
|
65
66
|
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
|
053a45fd
孙向锦
解析excel bug,去掉空行
|
67
|
pd = this.getPageData();
|
5b03edef
孙向锦
更新协议
|
68
69
70
71
72
73
|
studentService.save(pd);
mv.addObject("msg","success");
mv.setViewName("save_result");
return mv;
}
|
7d60b75e
孙向锦
添加班级-1
|
74
75
76
77
78
79
80
|
/**保存
* @param
* @throws Exception
*/
@RequestMapping(value="/save2")
public ModelAndView save2() throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"新增Student");
|
7d60b75e
孙向锦
添加班级-1
|
81
82
|
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
|
253c2bb1
孙向锦
班级学生管理
|
83
|
pd = this.getPageData();
|
7d60b75e
孙向锦
添加班级-1
|
84
85
|
String studentID = this.get32UUID();
pd.put("ID", studentID);
|
253c2bb1
孙向锦
班级学生管理
|
86
|
pd.put("STUDENT_ID", studentID);
|
a479f295
孙向锦
添加了报表逻辑
|
87
|
pd.put("SNO", pd.get("NUMBER"));
|
7d60b75e
孙向锦
添加班级-1
|
88
89
90
91
92
|
studentService.save(pd);
String termID = pd.getString("TERM_ID");
String classID = pd.getString("CLASS_ID");
pd.put("CLASSROSTER_ID", get32UUID());
|
253c2bb1
孙向锦
班级学生管理
|
93
|
pd.put("TEAMID", termID);
|
7d60b75e
孙向锦
添加班级-1
|
94
95
96
97
98
99
|
pd.put("SCLASS_ID", classID);
classrosterService.save(pd);
mv.addObject("msg","success");
|
6429ab88
孙向锦
remove
|
100
|
mv.setViewName("save_result2");
|
7d60b75e
孙向锦
添加班级-1
|
101
102
103
|
return mv;
}
|
b5cf92b7
孙向锦
批量上传学生名单
|
104
105
106
107
108
109
110
111
112
113
|
/**打开上传EXCEL页面
* @return
* @throws Exception
*/
@RequestMapping(value="/goUploadExcel")
public ModelAndView goUploadExcel()throws Exception{
ModelAndView mv = this.getModelAndView();
mv.addObject("pd", getPageData());
|
053a45fd
孙向锦
解析excel bug,去掉空行
|
114
|
|
fd0087a8
孙向锦
添加英语语言
|
115
116
117
118
119
|
if(isChineseLanguageClient()){
mv.setViewName("sunvote/student/uploadexcel");
}else{
mv.setViewName("sunvote/student/en_uploadexcel");
}
|
b5cf92b7
孙向锦
批量上传学生名单
|
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
return mv;
}
/**从EXCEL导入到数据库
* @param file
* @return
* @throws Exception
*/
@RequestMapping(value="/readExcel")
public ModelAndView readExcel(
@RequestParam(value="excel",required=false) MultipartFile file
) throws Exception{
logBefore(logger,Jurisdiction.getUsername() + "从EXCEL导入到数据库");
ModelAndView mv = this.getModelAndView();
PageData tpd = getPageData();
PageData pd = new PageData();
String termID = tpd.getString("TERM_ID");
String classID = tpd.getString("CLASS_ID");
if (null != file && !file.isEmpty()) {
String filePath = PathUtil.getClasspath() + Const.FILEPATHFILE; //文件上传路径
String fileName = FileUpload.fileUp(file, filePath, "userexcel"); //执行上传
List<PageData> listPd = (List)ObjectExcelRead.readExcel(filePath, fileName, 0, 0, 0); //执行读EXCEL操作,读出的数据导入List 2:从第3行开始;0:从第A列开始;0:第0个sheet
if(listPd.size() > 0 ){
pd= listPd.get(0);
for(int i = 1 ; i < listPd.size();i++){
PageData savePd = new PageData();
PageData temp = listPd.get(i);
for(int j = 0 ; ;j++){
if(temp.get("var" + j) == null){
break ;
}
|
053a45fd
孙向锦
解析excel bug,去掉空行
|
152
153
154
|
if(temp.get("var" + j) != null && !"".equals(temp.get("var" + j).toString())){
savePd.put(pd.getString("var" + j).toUpperCase(), temp.get("var" + j));
}
|
b5cf92b7
孙向锦
批量上传学生名单
|
155
156
|
}
if(!savePd.containsKey("ID")){
|
053a45fd
孙向锦
解析excel bug,去掉空行
|
157
158
159
160
161
162
163
164
165
166
167
168
|
if (savePd.values().size() > 0) {
String studentId = this.get32UUID();
savePd.put("ID", studentId);
studentService.save(savePd);
if (classID != null && termID != null) {
savePd.put("STUDENT_ID", studentId);
savePd.put("CLASSROSTER_ID", get32UUID());
savePd.put("TEAMID", termID);
savePd.put("SCLASS_ID", classID);
classrosterService.save(savePd);
}
|
b5cf92b7
孙向锦
批量上传学生名单
|
169
170
171
172
173
174
175
176
177
178
|
}
}else{
studentService.edit(savePd);
}
}
}
}
mv.addObject("msg","success");
|
3371dbc6
孙向锦
0720 版本
|
179
|
mv.setViewName("save_result2");
|
b5cf92b7
孙向锦
批量上传学生名单
|
180
181
182
183
|
return mv;
}
|
5b03edef
孙向锦
更新协议
|
184
185
186
187
188
189
190
|
/**删除
* @param out
* @throws Exception
*/
@RequestMapping(value="/delete")
public void delete(PrintWriter out) throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"删除Student");
|
5b03edef
孙向锦
更新协议
|
191
192
193
|
PageData pd = new PageData();
pd = this.getPageData();
studentService.delete(pd);
|
b5cf92b7
孙向锦
批量上传学生名单
|
194
195
|
pd.put("STUDENT_ID", pd.get("ID"));
classrosterService.delete(pd);
|
5b03edef
孙向锦
更新协议
|
196
197
198
199
200
201
202
203
204
205
206
|
out.write("success");
out.close();
}
/**修改
* @param
* @throws Exception
*/
@RequestMapping(value="/edit")
public ModelAndView edit() throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"修改Student");
|
5b03edef
孙向锦
更新协议
|
207
208
209
210
211
212
213
214
215
|
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
studentService.edit(pd);
mv.addObject("msg","success");
mv.setViewName("save_result");
return mv;
}
|
67dfaf5c
孙向锦
提交代码
|
216
|
|
8942b440
孙向锦
提交code
|
217
218
219
220
221
222
223
224
225
226
227
|
/**修改
* @param
* @throws Exception
*/
@RequestMapping(value="/edit2")
public ModelAndView edit2() throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"修改Student");
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
studentService.edit(pd);
|
3371dbc6
孙向锦
0720 版本
|
228
229
|
mv.addObject("msg","success");
mv.setViewName("save_result2");
|
8942b440
孙向锦
提交code
|
230
231
232
|
return mv;
}
|
5b03edef
孙向锦
更新协议
|
233
234
235
236
237
238
239
|
/**列表
* @param page
* @throws Exception
*/
@RequestMapping(value="/list")
public ModelAndView list(Page page) throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"列表Student");
|
5b03edef
孙向锦
更新协议
|
240
241
242
|
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
|
b5cf92b7
孙向锦
批量上传学生名单
|
243
|
String keywords = pd.getString("KEYWORDS"); //关键词检索条件
|
5b03edef
孙向锦
更新协议
|
244
245
246
247
248
249
250
251
252
253
254
255
|
if(null != keywords && !"".equals(keywords)){
pd.put("keywords", keywords.trim());
}
page.setPd(pd);
List<PageData> varList = studentService.list(page); //列出Student列表
mv.setViewName("sunvote/student/student_list");
mv.addObject("varList", varList);
mv.addObject("pd", pd);
mv.addObject("QX",Jurisdiction.getHC()); //按钮权限
return mv;
}
|
7d60b75e
孙向锦
添加班级-1
|
256
257
258
259
260
261
262
|
/**列表
* @param page
* @throws Exception
*/
@RequestMapping(value="/listcs")
public ModelAndView listClassStudent(Page page) throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"列表Student");
|
7d60b75e
孙向锦
添加班级-1
|
263
264
265
266
267
|
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
page.setPd(pd);
List<PageData> varList = studentService.datalistclassPage(page); //列出Student列表
|
fd0087a8
孙向锦
添加英语语言
|
268
269
270
271
272
273
|
page.setLangIsChina(isChineseLanguageClient());
if(isChineseLanguageClient()){
mv.setViewName("sunvote/student/student_list2");
}else{
mv.setViewName("sunvote/student/en_student_list2");
}
|
7d60b75e
孙向锦
添加班级-1
|
274
275
276
277
278
279
|
mv.addObject("varList", varList);
mv.addObject("pd", pd);
mv.addObject("QX",Jurisdiction.getHC()); //按钮权限
return mv;
}
|
5b03edef
孙向锦
更新协议
|
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
/**去新增页面
* @param
* @throws Exception
*/
@RequestMapping(value="/goAdd")
public ModelAndView goAdd()throws Exception{
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
mv.setViewName("sunvote/student/student_edit");
mv.addObject("msg", "save");
mv.addObject("pd", pd);
return mv;
}
|
7d60b75e
孙向锦
添加班级-1
|
295
296
297
298
299
300
301
302
303
|
/**去新增页面
* @param
* @throws Exception
*/
@RequestMapping(value="/goAdd2")
public ModelAndView goAdd2()throws Exception{
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
|
a479f295
孙向锦
添加了报表逻辑
|
304
|
pd.put("TERM_ID", getTermId());
|
fd0087a8
孙向锦
添加英语语言
|
305
306
307
308
309
|
if(isChineseLanguageClient()){
mv.setViewName("sunvote/student/student_edit2");
}else{
mv.setViewName("sunvote/student/en_student_edit2");
}
|
7d60b75e
孙向锦
添加班级-1
|
310
311
312
313
314
|
mv.addObject("msg", "save2");
mv.addObject("pd", pd);
return mv;
}
|
5b03edef
孙向锦
更新协议
|
315
316
317
318
319
320
321
|
/**去修改页面
* @param
* @throws Exception
*/
@RequestMapping(value="/goEdit")
public ModelAndView goEdit()throws Exception{
ModelAndView mv = this.getModelAndView();
|
7d60b75e
孙向锦
添加班级-1
|
322
323
324
325
326
327
328
329
330
331
332
333
334
335
|
PageData pd = this.getPageData();
pd = studentService.findById(pd); //根据ID读取
mv.setViewName("sunvote/student/student_edit");
mv.addObject("msg", "edit");
mv.addObject("pd", pd);
return mv;
}
/**去修改页面
* @param
* @throws Exception
*/
@RequestMapping(value="/goEdit2")
public ModelAndView goEdit2()throws Exception{
ModelAndView mv = this.getModelAndView();
|
5b03edef
孙向锦
更新协议
|
336
337
|
PageData pd = new PageData();
pd = this.getPageData();
|
5b03edef
孙向锦
更新协议
|
338
|
pd = studentService.findById(pd); //根据ID读取
|
fd0087a8
孙向锦
添加英语语言
|
339
340
341
342
343
|
if(isChineseLanguageClient()){
mv.setViewName("sunvote/student/student_edit2");
}else{
mv.setViewName("sunvote/student/en_student_edit2");
}
|
8942b440
孙向锦
提交code
|
344
|
mv.addObject("msg", "edit2");
|
5b03edef
孙向锦
更新协议
|
345
346
347
348
349
350
351
352
353
354
355
356
|
mv.addObject("pd", pd);
return mv;
}
/**批量删除
* @param
* @throws Exception
*/
@RequestMapping(value="/deleteAll")
@ResponseBody
public Object deleteAll() throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"批量删除Student");
|
5b03edef
孙向锦
更新协议
|
357
358
359
360
361
362
363
364
|
PageData pd = new PageData();
Map<String,Object> map = new HashMap<String,Object>();
pd = this.getPageData();
List<PageData> pdList = new ArrayList<PageData>();
String DATA_IDS = pd.getString("DATA_IDS");
if(null != DATA_IDS && !"".equals(DATA_IDS)){
String ArrayDATA_IDS[] = DATA_IDS.split(",");
studentService.deleteAll(ArrayDATA_IDS);
|
b5cf92b7
孙向锦
批量上传学生名单
|
365
|
classrosterService.deleteAllByStudentID(ArrayDATA_IDS);
|
5b03edef
孙向锦
更新协议
|
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
|
pd.put("msg", "ok");
}else{
pd.put("msg", "no");
}
pdList.add(pd);
map.put("list", pdList);
return AppUtil.returnObject(pd, map);
}
/**导出到excel
* @param
* @throws Exception
*/
@RequestMapping(value="/excel")
public ModelAndView exportExcel() throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"导出Student到excel");
|
5b03edef
孙向锦
更新协议
|
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
|
ModelAndView mv = new ModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
Map<String,Object> dataMap = new HashMap<String,Object>();
List<String> titles = new ArrayList<String>();
titles.add("学生姓名"); //1
titles.add("学籍号"); //2
titles.add("学号"); //3
titles.add("性别"); //4
titles.add("组号"); //5
titles.add("签到码"); //6
titles.add("家长姓名"); //7
titles.add("家长手机号"); //8
titles.add("键盘ID"); //9
titles.add("备注"); //10
dataMap.put("titles", titles);
List<PageData> varOList = studentService.listAll(pd);
List<PageData> varList = new ArrayList<PageData>();
for(int i=0;i<varOList.size();i++){
PageData vpd = new PageData();
vpd.put("var1", varOList.get(i).getString("NAME")); //1
vpd.put("var2", varOList.get(i).getString("SNO")); //2
vpd.put("var3", varOList.get(i).getString("NUMBER")); //3
vpd.put("var4", varOList.get(i).get("SEX").toString()); //4
vpd.put("var5", varOList.get(i).getString("GROUP")); //5
vpd.put("var6", varOList.get(i).getString("SIGN_NO")); //6
vpd.put("var7", varOList.get(i).getString("PARENT_NAME")); //7
vpd.put("var8", varOList.get(i).getString("PARENT_PHONE")); //8
vpd.put("var9", varOList.get(i).getString("KEYPAD_ID")); //9
vpd.put("var10", varOList.get(i).getString("REMARK")); //10
varList.add(vpd);
}
dataMap.put("varList", varList);
ObjectExcelView erv = new ObjectExcelView();
mv = new ModelAndView(erv,dataMap);
return mv;
}
|
a479f295
孙向锦
添加了报表逻辑
|
420
421
422
423
424
425
426
427
|
public String getTermId() throws Exception{
PageData pd = termService.findCurrentId();
if(pd != null){
return pd.getString("TERM_ID");
}
return null;
}
|
5b03edef
孙向锦
更新协议
|
428
429
430
431
432
433
|
@InitBinder
public void initBinder(WebDataBinder binder){
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
binder.registerCustomEditor(Date.class, new CustomDateEditor(format,true));
}
}
|