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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
import com.fh.service.sunvote.student.StudentManager;
/**
* 说明:学生管理
* 创建人: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
|
51
52
53
|
@Resource(name="classrosterService")
private ClassRosterManager classrosterService;
|
5b03edef
孙向锦
更新协议
|
54
55
56
57
58
59
60
|
/**保存
* @param
* @throws Exception
*/
@RequestMapping(value="/save")
public ModelAndView save() throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"新增Student");
|
5b03edef
孙向锦
更新协议
|
61
62
|
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
|
053a45fd
孙向锦
解析excel bug,去掉空行
|
63
|
pd = this.getPageData();
|
5b03edef
孙向锦
更新协议
|
64
65
66
67
68
69
|
studentService.save(pd);
mv.addObject("msg","success");
mv.setViewName("save_result");
return mv;
}
|
7d60b75e
孙向锦
添加班级-1
|
70
71
72
73
74
75
76
|
/**保存
* @param
* @throws Exception
*/
@RequestMapping(value="/save2")
public ModelAndView save2() throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"新增Student");
|
7d60b75e
孙向锦
添加班级-1
|
77
78
|
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
|
253c2bb1
孙向锦
班级学生管理
|
79
|
pd = this.getPageData();
|
7d60b75e
孙向锦
添加班级-1
|
80
81
|
String studentID = this.get32UUID();
pd.put("ID", studentID);
|
253c2bb1
孙向锦
班级学生管理
|
82
|
pd.put("STUDENT_ID", studentID);
|
7d60b75e
孙向锦
添加班级-1
|
83
84
85
86
87
|
studentService.save(pd);
String termID = pd.getString("TERM_ID");
String classID = pd.getString("CLASS_ID");
pd.put("CLASSROSTER_ID", get32UUID());
|
253c2bb1
孙向锦
班级学生管理
|
88
|
pd.put("TEAMID", termID);
|
7d60b75e
孙向锦
添加班级-1
|
89
90
91
92
93
94
|
pd.put("SCLASS_ID", classID);
classrosterService.save(pd);
mv.addObject("msg","success");
|
6429ab88
孙向锦
remove
|
95
|
mv.setViewName("save_result2");
|
7d60b75e
孙向锦
添加班级-1
|
96
97
98
|
return mv;
}
|
b5cf92b7
孙向锦
批量上传学生名单
|
99
100
101
102
103
104
105
106
107
108
|
/**打开上传EXCEL页面
* @return
* @throws Exception
*/
@RequestMapping(value="/goUploadExcel")
public ModelAndView goUploadExcel()throws Exception{
ModelAndView mv = this.getModelAndView();
mv.addObject("pd", getPageData());
|
053a45fd
孙向锦
解析excel bug,去掉空行
|
109
110
|
|
b5cf92b7
孙向锦
批量上传学生名单
|
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
mv.setViewName("sunvote/student/uploadexcel");
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,去掉空行
|
144
145
146
|
if(temp.get("var" + j) != null && !"".equals(temp.get("var" + j).toString())){
savePd.put(pd.getString("var" + j).toUpperCase(), temp.get("var" + j));
}
|
b5cf92b7
孙向锦
批量上传学生名单
|
147
148
|
}
if(!savePd.containsKey("ID")){
|
053a45fd
孙向锦
解析excel bug,去掉空行
|
149
150
151
152
153
154
155
156
157
158
159
160
|
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
孙向锦
批量上传学生名单
|
161
162
163
164
165
166
167
168
169
170
|
}
}else{
studentService.edit(savePd);
}
}
}
}
mv.addObject("msg","success");
|
3371dbc6
孙向锦
0720 版本
|
171
|
mv.setViewName("save_result2");
|
b5cf92b7
孙向锦
批量上传学生名单
|
172
173
174
175
|
return mv;
}
|
5b03edef
孙向锦
更新协议
|
176
177
178
179
180
181
182
|
/**删除
* @param out
* @throws Exception
*/
@RequestMapping(value="/delete")
public void delete(PrintWriter out) throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"删除Student");
|
5b03edef
孙向锦
更新协议
|
183
184
185
|
PageData pd = new PageData();
pd = this.getPageData();
studentService.delete(pd);
|
b5cf92b7
孙向锦
批量上传学生名单
|
186
187
|
pd.put("STUDENT_ID", pd.get("ID"));
classrosterService.delete(pd);
|
5b03edef
孙向锦
更新协议
|
188
189
190
191
192
193
194
195
196
197
198
|
out.write("success");
out.close();
}
/**修改
* @param
* @throws Exception
*/
@RequestMapping(value="/edit")
public ModelAndView edit() throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"修改Student");
|
5b03edef
孙向锦
更新协议
|
199
200
201
202
203
204
205
206
207
|
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
studentService.edit(pd);
mv.addObject("msg","success");
mv.setViewName("save_result");
return mv;
}
|
8942b440
孙向锦
提交code
|
208
209
210
211
212
213
214
215
216
217
218
|
/**修改
* @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 版本
|
219
220
|
mv.addObject("msg","success");
mv.setViewName("save_result2");
|
8942b440
孙向锦
提交code
|
221
222
223
|
return mv;
}
|
5b03edef
孙向锦
更新协议
|
224
225
226
227
228
229
230
|
/**列表
* @param page
* @throws Exception
*/
@RequestMapping(value="/list")
public ModelAndView list(Page page) throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"列表Student");
|
5b03edef
孙向锦
更新协议
|
231
232
233
|
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
|
b5cf92b7
孙向锦
批量上传学生名单
|
234
|
String keywords = pd.getString("KEYWORDS"); //关键词检索条件
|
5b03edef
孙向锦
更新协议
|
235
236
237
238
239
240
241
242
243
244
245
246
|
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
|
247
248
249
250
251
252
253
|
/**列表
* @param page
* @throws Exception
*/
@RequestMapping(value="/listcs")
public ModelAndView listClassStudent(Page page) throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"列表Student");
|
7d60b75e
孙向锦
添加班级-1
|
254
255
256
257
258
259
260
261
262
263
264
265
|
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
page.setPd(pd);
List<PageData> varList = studentService.datalistclassPage(page); //列出Student列表
mv.setViewName("sunvote/student/student_list2");
mv.addObject("varList", varList);
mv.addObject("pd", pd);
mv.addObject("QX",Jurisdiction.getHC()); //按钮权限
return mv;
}
|
5b03edef
孙向锦
更新协议
|
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
/**去新增页面
* @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
|
281
282
283
284
285
286
287
288
289
|
/**去新增页面
* @param
* @throws Exception
*/
@RequestMapping(value="/goAdd2")
public ModelAndView goAdd2()throws Exception{
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
|
253c2bb1
孙向锦
班级学生管理
|
290
|
mv.setViewName("sunvote/student/student_edit2");
|
7d60b75e
孙向锦
添加班级-1
|
291
292
293
294
295
|
mv.addObject("msg", "save2");
mv.addObject("pd", pd);
return mv;
}
|
5b03edef
孙向锦
更新协议
|
296
297
298
299
300
301
302
|
/**去修改页面
* @param
* @throws Exception
*/
@RequestMapping(value="/goEdit")
public ModelAndView goEdit()throws Exception{
ModelAndView mv = this.getModelAndView();
|
7d60b75e
孙向锦
添加班级-1
|
303
304
305
306
307
308
309
310
311
312
313
314
315
316
|
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
孙向锦
更新协议
|
317
318
|
PageData pd = new PageData();
pd = this.getPageData();
|
7d60b75e
孙向锦
添加班级-1
|
319
|
String classID = pd.getString("CLASS_ID");
|
5b03edef
孙向锦
更新协议
|
320
|
pd = studentService.findById(pd); //根据ID读取
|
7d60b75e
孙向锦
添加班级-1
|
321
322
|
pd.put("CLASS_ID", classID);
mv.setViewName("sunvote/student/student_edit2");
|
8942b440
孙向锦
提交code
|
323
|
mv.addObject("msg", "edit2");
|
5b03edef
孙向锦
更新协议
|
324
325
326
327
328
329
330
331
332
333
334
335
|
mv.addObject("pd", pd);
return mv;
}
/**批量删除
* @param
* @throws Exception
*/
@RequestMapping(value="/deleteAll")
@ResponseBody
public Object deleteAll() throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"批量删除Student");
|
5b03edef
孙向锦
更新协议
|
336
337
338
339
340
341
342
343
|
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
孙向锦
批量上传学生名单
|
344
|
classrosterService.deleteAllByStudentID(ArrayDATA_IDS);
|
5b03edef
孙向锦
更新协议
|
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
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
孙向锦
更新协议
|
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
|
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;
}
@InitBinder
public void initBinder(WebDataBinder binder){
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
binder.registerCustomEditor(Date.class, new CustomDateEditor(format,true));
}
}
|