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
|
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");
|
00af725f
孙向锦
修复bug
|
138
139
140
|
if(termID == null || "".equals(termID.trim())){
termID = getTermId();
}
|
b5cf92b7
孙向锦
批量上传学生名单
|
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
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,去掉空行
|
155
156
157
|
if(temp.get("var" + j) != null && !"".equals(temp.get("var" + j).toString())){
savePd.put(pd.getString("var" + j).toUpperCase(), temp.get("var" + j));
}
|
b5cf92b7
孙向锦
批量上传学生名单
|
158
159
|
}
if(!savePd.containsKey("ID")){
|
053a45fd
孙向锦
解析excel bug,去掉空行
|
160
161
162
|
if (savePd.values().size() > 0) {
String studentId = this.get32UUID();
savePd.put("ID", studentId);
|
00af725f
孙向锦
修复bug
|
163
164
|
savePd.put("CLASS_ID", classID);
|
053a45fd
孙向锦
解析excel bug,去掉空行
|
165
166
167
168
169
170
171
172
173
|
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
孙向锦
批量上传学生名单
|
174
175
176
177
178
179
180
181
182
183
|
}
}else{
studentService.edit(savePd);
}
}
}
}
mv.addObject("msg","success");
|
3371dbc6
孙向锦
0720 版本
|
184
|
mv.setViewName("save_result2");
|
b5cf92b7
孙向锦
批量上传学生名单
|
185
186
187
188
|
return mv;
}
|
5b03edef
孙向锦
更新协议
|
189
190
191
192
193
194
195
|
/**删除
* @param out
* @throws Exception
*/
@RequestMapping(value="/delete")
public void delete(PrintWriter out) throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"删除Student");
|
5b03edef
孙向锦
更新协议
|
196
197
198
|
PageData pd = new PageData();
pd = this.getPageData();
studentService.delete(pd);
|
b5cf92b7
孙向锦
批量上传学生名单
|
199
200
|
pd.put("STUDENT_ID", pd.get("ID"));
classrosterService.delete(pd);
|
5b03edef
孙向锦
更新协议
|
201
202
203
204
205
206
207
208
209
210
211
|
out.write("success");
out.close();
}
/**修改
* @param
* @throws Exception
*/
@RequestMapping(value="/edit")
public ModelAndView edit() throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"修改Student");
|
5b03edef
孙向锦
更新协议
|
212
213
214
215
216
217
218
219
220
|
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
孙向锦
提交代码
|
221
|
|
8942b440
孙向锦
提交code
|
222
223
224
225
226
227
228
229
230
231
232
|
/**修改
* @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 版本
|
233
234
|
mv.addObject("msg","success");
mv.setViewName("save_result2");
|
8942b440
孙向锦
提交code
|
235
236
237
|
return mv;
}
|
5b03edef
孙向锦
更新协议
|
238
239
240
241
242
243
244
|
/**列表
* @param page
* @throws Exception
*/
@RequestMapping(value="/list")
public ModelAndView list(Page page) throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"列表Student");
|
5b03edef
孙向锦
更新协议
|
245
246
247
|
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
|
b5cf92b7
孙向锦
批量上传学生名单
|
248
|
String keywords = pd.getString("KEYWORDS"); //关键词检索条件
|
5b03edef
孙向锦
更新协议
|
249
250
251
252
253
254
255
256
257
258
259
260
|
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
|
261
262
263
264
265
266
267
|
/**列表
* @param page
* @throws Exception
*/
@RequestMapping(value="/listcs")
public ModelAndView listClassStudent(Page page) throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"列表Student");
|
7d60b75e
孙向锦
添加班级-1
|
268
269
270
271
272
|
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
page.setPd(pd);
List<PageData> varList = studentService.datalistclassPage(page); //列出Student列表
|
fd0087a8
孙向锦
添加英语语言
|
273
274
275
276
277
278
|
page.setLangIsChina(isChineseLanguageClient());
if(isChineseLanguageClient()){
mv.setViewName("sunvote/student/student_list2");
}else{
mv.setViewName("sunvote/student/en_student_list2");
}
|
7d60b75e
孙向锦
添加班级-1
|
279
280
281
282
283
284
|
mv.addObject("varList", varList);
mv.addObject("pd", pd);
mv.addObject("QX",Jurisdiction.getHC()); //按钮权限
return mv;
}
|
5b03edef
孙向锦
更新协议
|
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
|
/**去新增页面
* @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
|
300
301
302
303
304
305
306
307
308
|
/**去新增页面
* @param
* @throws Exception
*/
@RequestMapping(value="/goAdd2")
public ModelAndView goAdd2()throws Exception{
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
|
a479f295
孙向锦
添加了报表逻辑
|
309
|
pd.put("TERM_ID", getTermId());
|
fd0087a8
孙向锦
添加英语语言
|
310
311
312
313
314
|
if(isChineseLanguageClient()){
mv.setViewName("sunvote/student/student_edit2");
}else{
mv.setViewName("sunvote/student/en_student_edit2");
}
|
7d60b75e
孙向锦
添加班级-1
|
315
316
317
318
319
|
mv.addObject("msg", "save2");
mv.addObject("pd", pd);
return mv;
}
|
5b03edef
孙向锦
更新协议
|
320
321
322
323
324
325
326
|
/**去修改页面
* @param
* @throws Exception
*/
@RequestMapping(value="/goEdit")
public ModelAndView goEdit()throws Exception{
ModelAndView mv = this.getModelAndView();
|
7d60b75e
孙向锦
添加班级-1
|
327
328
329
330
331
332
333
334
335
336
337
338
339
340
|
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
孙向锦
更新协议
|
341
342
|
PageData pd = new PageData();
pd = this.getPageData();
|
5b03edef
孙向锦
更新协议
|
343
|
pd = studentService.findById(pd); //根据ID读取
|
fd0087a8
孙向锦
添加英语语言
|
344
345
346
347
348
|
if(isChineseLanguageClient()){
mv.setViewName("sunvote/student/student_edit2");
}else{
mv.setViewName("sunvote/student/en_student_edit2");
}
|
8942b440
孙向锦
提交code
|
349
|
mv.addObject("msg", "edit2");
|
5b03edef
孙向锦
更新协议
|
350
351
352
353
354
355
356
357
358
359
360
361
|
mv.addObject("pd", pd);
return mv;
}
/**批量删除
* @param
* @throws Exception
*/
@RequestMapping(value="/deleteAll")
@ResponseBody
public Object deleteAll() throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"批量删除Student");
|
5b03edef
孙向锦
更新协议
|
362
363
364
365
366
367
368
369
|
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
孙向锦
批量上传学生名单
|
370
|
classrosterService.deleteAllByStudentID(ArrayDATA_IDS);
|
5b03edef
孙向锦
更新协议
|
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
|
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
孙向锦
更新协议
|
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
420
421
422
423
424
|
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
孙向锦
添加了报表逻辑
|
425
426
427
428
429
430
431
432
|
public String getTermId() throws Exception{
PageData pd = termService.findCurrentId();
if(pd != null){
return pd.getString("TERM_ID");
}
return null;
}
|
5b03edef
孙向锦
更新协议
|
433
434
435
436
437
438
|
@InitBinder
public void initBinder(WebDataBinder binder){
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
binder.registerCustomEditor(Date.class, new CustomDateEditor(format,true));
}
}
|