Blame view

src/com/fh/controller/api/V1.java 24.6 KB
bed6e1fc   孙向锦   添加其他功能
1
2
  package com.fh.controller.api;
  
338594c8   孙向锦   添加教师端页面
3
  import java.util.ArrayList;
bed6e1fc   孙向锦   添加其他功能
4
5
6
7
8
  import java.util.Date;
  import java.util.List;
  
  import javax.annotation.Resource;
  
338594c8   孙向锦   添加教师端页面
9
  import org.apache.commons.lang.StringUtils;
bed6e1fc   孙向锦   添加其他功能
10
11
12
13
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.ResponseBody;
  
338594c8   孙向锦   添加教师端页面
14
15
  import com.fh.bean.Paper;
  import com.fh.bean.Question;
91a745c9   孙向锦   完善后台功能
16
17
18
  import com.fh.bean.StudentAnswer;
  import com.fh.bean.TestPaper;
  import com.fh.bean.TestPaperInfo;
bed6e1fc   孙向锦   添加其他功能
19
  import com.fh.controller.base.BaseController;
338594c8   孙向锦   添加教师端页面
20
  import com.fh.controller.sunvote.Myelfun;
bed6e1fc   孙向锦   添加其他功能
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
  import com.fh.entity.Page;
  import com.fh.service.api.V1Manager;
  import com.fh.service.feedback.feedback.FeedbackManager;
  import com.fh.service.feedback.problemphenomenon.ProblemPhenomenonManager;
  import com.fh.service.sunvote.basestation.BasestationManager;
  import com.fh.service.sunvote.chapter.ChapterManager;
  import com.fh.service.sunvote.classbasetation.ClassBasetationManager;
  import com.fh.service.sunvote.classroster.ClassRosterManager;
  import com.fh.service.sunvote.classtype.ClassTypeManager;
  import com.fh.service.sunvote.coursemanagement.CourseManagementManager;
  import com.fh.service.sunvote.grade.GradeManager;
  import com.fh.service.sunvote.keypad.KeypadManager;
  import com.fh.service.sunvote.keypadcheck.KeypadCheckManager;
  import com.fh.service.sunvote.knowledge.KnowledgeManager;
  import com.fh.service.sunvote.knowledgechapter.KnowledgeChapterManager;
  import com.fh.service.sunvote.paper.PaperManager;
  import com.fh.service.sunvote.paperclassteacher.PaperClassTeacherManager;
  import com.fh.service.sunvote.paperquestion.PaperQuestionManager;
  import com.fh.service.sunvote.papertype.PaperTypeManager;
  import com.fh.service.sunvote.question.QuestionManager;
  import com.fh.service.sunvote.questiontype.QuestionTypeManager;
  import com.fh.service.sunvote.school.SchoolManager;
  import com.fh.service.sunvote.schoolgradesubject.SchoolGradeSubjectManager;
  import com.fh.service.sunvote.sclass.SClassManager;
  import com.fh.service.sunvote.student.StudentManager;
91a745c9   孙向锦   完善后台功能
46
  import com.fh.service.sunvote.studenttest.StudentTestManager;
bed6e1fc   孙向锦   添加其他功能
47
48
  import com.fh.service.sunvote.subject.SubjectManager;
  import com.fh.service.sunvote.teacher.TeacherManager;
91a745c9   孙向锦   完善后台功能
49
  import com.fh.service.sunvote.testpaper.TestPaperManager;
bed6e1fc   孙向锦   添加其他功能
50
51
52
53
54
55
56
  import com.fh.service.sunvote.testpaperinfo.TestPaperInfoManager;
  import com.fh.util.PageData;
  import com.fh.util.Tools;
  
  @Controller
  @RequestMapping(value = "/api/v1")
  public class V1 extends BaseController {
91a745c9   孙向锦   完善后台功能
57
  
bed6e1fc   孙向锦   添加其他功能
58
59
60
61
62
  	@Resource(name = "schoolService")
  	private SchoolManager schoolService;
  
  	@Resource(name = "basestationService")
  	private BasestationManager basestationService;
91a745c9   孙向锦   完善后台功能
63
64
  
  	@Resource(name = "chapterService")
bed6e1fc   孙向锦   添加其他功能
65
  	private ChapterManager chapterService;
91a745c9   孙向锦   完善后台功能
66
67
  
  	@Resource(name = "classbasetationService")
bed6e1fc   孙向锦   添加其他功能
68
  	private ClassBasetationManager classbasetationService;
91a745c9   孙向锦   完善后台功能
69
70
  
  	@Resource(name = "classrosterService")
bed6e1fc   孙向锦   添加其他功能
71
  	private ClassRosterManager classrosterService;
91a745c9   孙向锦   完善后台功能
72
73
  
  	@Resource(name = "classtypeService")
bed6e1fc   孙向锦   添加其他功能
74
  	private ClassTypeManager classtypeService;
91a745c9   孙向锦   完善后台功能
75
76
  
  	@Resource(name = "gradeService")
bed6e1fc   孙向锦   添加其他功能
77
  	private GradeManager gradeService;
91a745c9   孙向锦   完善后台功能
78
79
  
  	@Resource(name = "coursemanagementService")
bed6e1fc   孙向锦   添加其他功能
80
81
82
83
  	private CourseManagementManager coursemanagementService;
  
  	@Resource(name = "keypadService")
  	private KeypadManager keypadService;
91a745c9   孙向锦   完善后台功能
84
85
  
  	@Resource(name = "keypadcheckService")
bed6e1fc   孙向锦   添加其他功能
86
  	private KeypadCheckManager keypadcheckService;
91a745c9   孙向锦   完善后台功能
87
88
  
  	@Resource(name = "knowledgeService")
bed6e1fc   孙向锦   添加其他功能
89
  	private KnowledgeManager knowledgeService;
91a745c9   孙向锦   完善后台功能
90
91
  
  	@Resource(name = "knowledgechapterService")
bed6e1fc   孙向锦   添加其他功能
92
  	private KnowledgeChapterManager knowledgechapterService;
91a745c9   孙向锦   完善后台功能
93
94
  
  	@Resource(name = "paperService")
bed6e1fc   孙向锦   添加其他功能
95
  	private PaperManager paperService;
91a745c9   孙向锦   完善后台功能
96
97
  
  	@Resource(name = "paperclassteacherService")
bed6e1fc   孙向锦   添加其他功能
98
  	private PaperClassTeacherManager paperclassteacherService;
91a745c9   孙向锦   完善后台功能
99
100
  
  	@Resource(name = "paperquestionService")
bed6e1fc   孙向锦   添加其他功能
101
  	private PaperQuestionManager paperquestionService;
91a745c9   孙向锦   完善后台功能
102
103
  
  	@Resource(name = "papertypeService")
bed6e1fc   孙向锦   添加其他功能
104
  	private PaperTypeManager papertypeService;
91a745c9   孙向锦   完善后台功能
105
106
  
  	@Resource(name = "questionService")
bed6e1fc   孙向锦   添加其他功能
107
  	private QuestionManager questionService;
91a745c9   孙向锦   完善后台功能
108
109
  
  	@Resource(name = "questiontypeService")
bed6e1fc   孙向锦   添加其他功能
110
  	private QuestionTypeManager questiontypeService;
91a745c9   孙向锦   完善后台功能
111
112
  
  	@Resource(name = "schoolgradesubjectService")
bed6e1fc   孙向锦   添加其他功能
113
  	private SchoolGradeSubjectManager schoolgradesubjectService;
91a745c9   孙向锦   完善后台功能
114
115
  
  	@Resource(name = "sclassService")
bed6e1fc   孙向锦   添加其他功能
116
  	private SClassManager sclassService;
91a745c9   孙向锦   完善后台功能
117
118
  
  	@Resource(name = "studentService")
bed6e1fc   孙向锦   添加其他功能
119
  	private StudentManager studentService;
91a745c9   孙向锦   完善后台功能
120
121
  
  	@Resource(name = "subjectService")
bed6e1fc   孙向锦   添加其他功能
122
  	private SubjectManager subjectService;
91a745c9   孙向锦   完善后台功能
123
124
  
  	@Resource(name = "teacherService")
bed6e1fc   孙向锦   添加其他功能
125
  	private TeacherManager teacherService;
91a745c9   孙向锦   完善后台功能
126
127
  
  	@Resource(name = "testpaperinfoService")
bed6e1fc   孙向锦   添加其他功能
128
129
  	private TestPaperInfoManager testpaperinfoService;
  
91a745c9   孙向锦   完善后台功能
130
131
132
133
134
135
  	@Resource(name = "testpaperService")
  	private TestPaperManager testpaperService;
  
  	@Resource(name = "studenttestService")
  	private StudentTestManager studenttestService;
  
bed6e1fc   孙向锦   添加其他功能
136
137
138
139
140
  	@Resource(name = "feedbackService")
  	private FeedbackManager feedbackService;
  
  	@Resource(name = "problemphenomenonService")
  	private ProblemPhenomenonManager problemphenomenonService;
91a745c9   孙向锦   完善后台功能
141
  
bed6e1fc   孙向锦   添加其他功能
142
  	@Resource(name = "v1Service")
91a745c9   孙向锦   完善后台功能
143
144
  	private V1Manager v1Service;
  
bed6e1fc   孙向锦   添加其他功能
145
146
147
148
149
  	@RequestMapping(value = "/login", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object login() throws Exception {
  		PageData pd = this.getPageData();
  		ResponseGson<PageData> res = new ResponseGson();
91a745c9   孙向锦   完善后台功能
150
  		if (!pd.containsKey("ACCOUT")) {
bed6e1fc   孙向锦   添加其他功能
151
152
  			pd.put("ACCOUT", pd.get("USERNAME"));
  		}
91a745c9   孙向锦   完善后台功能
153
154
  		if (((pd.containsKey("USERNAME") || pd.containsKey("ACCOUT")) && pd
  				.containsKey("PASSWORD")) || pd.containsKey("KEYPAD_ID")) {
bed6e1fc   孙向锦   添加其他功能
155
  			PageData pageData = teacherService.getUserInfo(pd);
91a745c9   孙向锦   完善后台功能
156
157
  			if (pageData != null && pageData.getString("ID") != null) {
  				pageData.put("PASSWORD", "");// 返回参数中不返回密码
bed6e1fc   孙向锦   添加其他功能
158
159
160
  				PageData pt = new PageData();
  				pt.put("TEACHER_ID", pageData.get("ID"));
  				// 在任课表中查找老师教哪些班级,然后查出班级信息
91a745c9   孙向锦   完善后台功能
161
162
163
  				List<PageData> classInfoList = v1Service
  						.getTeacherClassInfo(pt);
  
bed6e1fc   孙向锦   添加其他功能
164
165
  				pageData.put("classInfoList", classInfoList);
  				// 在认可表中查找老师教哪些科目,然后查出科目信息
91a745c9   孙向锦   完善后台功能
166
167
  				List<PageData> subjectList = v1Service
  						.getTeacherSubjectInfo(pt);
bed6e1fc   孙向锦   添加其他功能
168
169
  				// 一个sql语句完成。
  				pageData.put("subjectList", subjectList);
91a745c9   孙向锦   完善后台功能
170
  
bed6e1fc   孙向锦   添加其他功能
171
  				pageData.remove("SUBJECT_IDS");
91a745c9   孙向锦   完善后台功能
172
  
bed6e1fc   孙向锦   添加其他功能
173
174
  				res.setData(pageData);
  				// 填充数据到返回数据中
91a745c9   孙向锦   完善后台功能
175
  			} else {
bed6e1fc   孙向锦   添加其他功能
176
177
  				res.set1Error();
  			}
91a745c9   孙向锦   完善后台功能
178
  		} else {
bed6e1fc   孙向锦   添加其他功能
179
180
  			res.set1Error();
  		}
91a745c9   孙向锦   完善后台功能
181
  
bed6e1fc   孙向锦   添加其他功能
182
183
  		return res.toJson();
  	}
91a745c9   孙向锦   完善后台功能
184
  
bed6e1fc   孙向锦   添加其他功能
185
186
187
188
189
190
191
192
193
194
  	@RequestMapping(value = "/class", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object sclass() throws Exception {
  		PageData pd = this.getPageData();
  		ResponseGson<PageData> res = new ResponseGson();
  		if (pd.containsKey("ID")) {
  			PageData pageData = sclassService.findById(pd);
  			if (pageData != null && pageData.containsKey("ID")) {
  				PageData pt = new PageData();
  				pt.put("SCLASS_ID", pageData.get("ID"));
91a745c9   孙向锦   完善后台功能
195
  				List<PageData> studentList = v1Service.getClassStudent(pt);
bed6e1fc   孙向锦   添加其他功能
196
197
198
199
200
  				pageData.put("studentList", studentList);
  				res.setData(pageData);
  			} else {
  				res.set2Error();
  			}
91a745c9   孙向锦   完善后台功能
201
  		} else {
bed6e1fc   孙向锦   添加其他功能
202
203
204
205
  			res.set2Error();
  		}
  		return res.toJson();
  	}
91a745c9   孙向锦   完善后台功能
206
  
bed6e1fc   孙向锦   添加其他功能
207
208
209
210
  	@RequestMapping(value = "/keypadscan", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object keypadScan() throws Exception {
  		PageData pd = this.getPageData();
91a745c9   孙向锦   完善后台功能
211
212
213
214
215
  		ResponseGson<String> res = new ResponseGson();
  		String ID = get32UUID();
  		pd.put("KEYPADCHECK_ID", ID); // 主键
  		pd.put("CREATE_DATE", Tools.date2Str(new Date())); // 创建时间
  		try {
bed6e1fc   孙向锦   添加其他功能
216
  			keypadcheckService.save(pd);
91a745c9   孙向锦   完善后台功能
217
  			res.setData(ID);
bed6e1fc   孙向锦   添加其他功能
218
  			res.setSuccess();
91a745c9   孙向锦   完善后台功能
219
  		} catch (Exception ex) {
bed6e1fc   孙向锦   添加其他功能
220
221
222
223
  			res.setDataError();
  		}
  		return res.toJson();
  	}
91a745c9   孙向锦   完善后台功能
224
  
bed6e1fc   孙向锦   添加其他功能
225
226
227
228
229
  	@RequestMapping(value = "/paper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object paper() throws Exception {
  		PageData pd = this.getPageData();
  		ResponseGson<List<PageData>> res = new ResponseGson<List<PageData>>();
91a745c9   孙向锦   完善后台功能
230
  		if (pd.containsKey("PAPER_TYPE") && pd.containsKey("USER_ID")) {
bed6e1fc   孙向锦   添加其他功能
231
232
233
  			Page page = new Page();
  			page.getPd().put("PAPER_TYPE", pd.get("PAPER_TYPE"));
  			page.getPd().put("USER_ID", pd.get("USER_ID"));
91a745c9   孙向锦   完善后台功能
234
  			if (pd.containsKey("CURRENTPAGE")) {
bed6e1fc   孙向锦   添加其他功能
235
  				String curpage = pd.getString("CURRENTPAGE");
91a745c9   孙向锦   完善后台功能
236
  				try {
bed6e1fc   孙向锦   添加其他功能
237
  					page.setCurrentPage(Integer.parseInt(curpage));
91a745c9   孙向锦   完善后台功能
238
239
  				} catch (Exception ex) {
  				}
bed6e1fc   孙向锦   添加其他功能
240
  			}
91a745c9   孙向锦   完善后台功能
241
  			if (pd.containsKey("SHOWCOUNT")) {
bed6e1fc   孙向锦   添加其他功能
242
  				String showCount = pd.getString("SHOWCOUNT");
91a745c9   孙向锦   完善后台功能
243
  				try {
bed6e1fc   孙向锦   添加其他功能
244
  					page.setShowCount(Integer.parseInt(showCount));
91a745c9   孙向锦   完善后台功能
245
246
247
  				} catch (Exception ex) {
  				}
  			} else {
bed6e1fc   孙向锦   添加其他功能
248
249
250
251
  				page.setShowCount(100);
  			}
  			List<PageData> pageList = paperService.listAllByType(page);
  			res.setData(pageList);
91a745c9   孙向锦   完善后台功能
252
  		} else {
338594c8   孙向锦   添加教师端页面
253
  			res.setParmError();
bed6e1fc   孙向锦   添加其他功能
254
255
256
  		}
  		return res.toJson();
  	}
91a745c9   孙向锦   完善后台功能
257
258
  
  	@RequestMapping(value = "/paperinfo", produces = "application/json;charset=UTF-8")
bed6e1fc   孙向锦   添加其他功能
259
  	@ResponseBody
91a745c9   孙向锦   完善后台功能
260
  	public Object paperInfo() throws Exception {
bed6e1fc   孙向锦   添加其他功能
261
  		PageData pd = this.getPageData();
338594c8   孙向锦   添加教师端页面
262
  		ResponseGson<Paper> res = new ResponseGson<Paper>();
91a745c9   孙向锦   完善后台功能
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
  		if (pd.containsKey("PAPER_ID")) {
  			try {
  				try {
  					Paper paper = new Paper();
  					PageData ppd = paperService.findById(pd);
  					if (ppd != null) {
  						paper.setTitle(ppd.getString("TITLE"));
  						paper.setExam_time(ppd.getString("EXAM_TIME"));
  						paper.setUser_id(ppd.getString("USER_ID"));
  						paper.setPaper_type(ppd.getString("PAPER_TYPE"));
  						paper.setSubject_id(ppd.getString("SUBJECT_ID"));
  						paper.setGrade_id(ppd.getString("GRADE_ID"));
  						paper.setScore(ppd.getString("SCORE"));
  						paper.setQuestions(new ArrayList<Question>());
  
  						List<PageData> questList = v1Service
  								.getTestPaperInfo(pd);
  						for (PageData qpd : questList) {
  							Question question = new Question();
  							question.setAnswer(qpd.getString("ANSWER"));
  							question.setQuestion_id(qpd
  									.getString("QUESTION_ID"));
  							question.setSubject_id(qpd.getString("SUBJECT_ID"));
  							question.setChapter_id(qpd.getString("CHAPTER_ID"));
  							question.setProblem_type_id(qpd
  									.getString("PROBLEM_TYPE_ID"));
  							question.setKnowledge_id(qpd
  									.getString("KNOWLEDGE_ID"));
  							question.setContent(qpd.getString("CONTENT"));
  							question.setOption_num(qpd.getString("OPTION_NUM"));
  							question.setOption_content(qpd
  									.getString("OPTION_CONTENT"));
  							question.setDifficulty(qpd.getString("DIFFICULTY"));
  							question.setAnalysis(qpd.getString("ANALYSIS"));
  							question.setQuestion_from(qpd
  									.getString("QUESTION_FROM"));
  							question.setSug_score(qpd.getString("SUG_SCORE"));
  							question.setSug_part_score(qpd
  									.getString("SUG_PART_SCORE"));
  							question.setRank(qpd.getString("RANK"));
  							question.setNo_name(qpd.getString("NO_NAME"));
  							if ("-1".equals("" + qpd.getString("P_ID"))) {
  								PageData pidPd = new PageData();
  								pidPd.put("PID", question.getQuestion_id());
  								question.setQuestions(new ArrayList<Question>());
  								List<PageData> qs = v1Service
  										.getQuestionsByPID(pidPd);
  								for (PageData q : qs) {
  									Question qq = new Question();
  									qq.setAnswer(q.getString("ANSWER"));
  									qq.setQuestion_id(q
  											.getString("QUESTION_ID"));
  									qq.setSubject_id(q.getString("SUBJECT_ID"));
  									qq.setChapter_id(q.getString("CHAPTER_ID"));
  									qq.setProblem_type_id(q
  											.getString("PROBLEM_TYPE_ID"));
  									qq.setKnowledge_id(q
  											.getString("KNOWLEDGE_ID"));
  									qq.setContent(q.getString("CONTENT"));
  									qq.setOption_num(q.getString("OPTION_NUM"));
  									qq.setOption_content(q
  											.getString("OPTION_CONTENT"));
  									qq.setDifficulty(q.getString("DIFFICULTY"));
  									qq.setAnalysis(q.getString("ANALYSIS"));
  									qq.setQuestion_from(q
  											.getString("QUESTION_FROM"));
  									qq.setSug_score(q.getString("SUG_SCORE"));
  									qq.setSug_part_score(q
  											.getString("SUG_PART_SCORE"));
  									qq.setRank(q.getString("RANK"));
  									qq.setNo_name(q.getString("NO_NAME"));
  									question.getQuestions().add(qq);
  								}
  							}
  							if ("-1".equals(qpd.getString("P_ID"))
  									|| "0".equals(qpd.getString("P_ID"))) {
  								paper.getQuestions().add(question);
  							}
338594c8   孙向锦   添加教师端页面
341
  						}
91a745c9   孙向锦   完善后台功能
342
343
344
345
  						// pd.put("JSON", paper.toJson());
  						res.setData(paper);
  						logger.info(paper.toJson());
  
338594c8   孙向锦   添加教师端页面
346
  					}
91a745c9   孙向锦   完善后台功能
347
348
  				} catch (Exception ex) {
  					ex.printStackTrace();
338594c8   孙向锦   添加教师端页面
349
  				}
91a745c9   孙向锦   完善后台功能
350
  			} catch (Exception ex) {
338594c8   孙向锦   添加教师端页面
351
352
  				ex.printStackTrace();
  				res.setError();
bed6e1fc   孙向锦   添加其他功能
353
  			}
91a745c9   孙向锦   完善后台功能
354
  		} else {
bed6e1fc   孙向锦   添加其他功能
355
356
357
358
  			res.setOtherError();
  		}
  		return res.toJson();
  	}
91a745c9   孙向锦   完善后台功能
359
  
bed6e1fc   孙向锦   添加其他功能
360
361
362
363
364
  	@RequestMapping(value = "/paperquestion", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object paperQuestion() throws Exception {
  		PageData pd = this.getPageData();
  		ResponseGson<PageData> res = new ResponseGson();
91a745c9   孙向锦   完善后台功能
365
  
bed6e1fc   孙向锦   添加其他功能
366
367
368
  		return res.toJson();
  	}
  
338594c8   孙向锦   添加教师端页面
369
370
371
372
373
  	@RequestMapping(value = "/uploadpaper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object uploadpaper() throws Exception {
  		PageData pd = this.getPageData();
  		ResponseGson<String> res = new ResponseGson();
91a745c9   孙向锦   完善后台功能
374
375
  
  		if (!StringUtils.isEmpty(pd.getJsonString())) {
338594c8   孙向锦   添加教师端页面
376
377
378
379
  			Paper paper = Paper.parse(pd.getJsonString());
  			PageData paperPd = new PageData();
  			String paperID = this.get32UUID();
  			res.setData(paperID);
91a745c9   孙向锦   完善后台功能
380
381
382
383
384
385
386
387
388
389
  			paperPd.put("PAPER_ID", paperID);
  			paperPd.put("TITLE", paper.getTitle());
  			paperPd.put("USER_ID", paper.getUser_id());
  			paperPd.put("PAPER_TYPE", paper.getPaper_type());
  			paperPd.put("SUBJECT_ID", paper.getSubject_id());
  			paperPd.put("GRADE_ID", paper.getGrade_id());
  			paperPd.put("EXAM_TIME", paper.getExam_time());
  			paperPd.put("SCORE", paper.getScore());
  			paperPd.put("PAPER_STATE", "0");
  			paperPd.put("REMARK", "");
338594c8   孙向锦   添加教师端页面
390
391
  			String schoolID = Myelfun.getUserID(paper.getUser_id());
  			paperPd.put("SCHOOL_ID", schoolID);
91a745c9   孙向锦   完善后台功能
392
393
394
  			paperPd.put("CREATE_DATE", Tools.date2Str(new Date()));
  			paperPd.put("MODIFY_DATE", Tools.date2Str(new Date()));
  
338594c8   孙向锦   添加教师端页面
395
  			paperService.save(paperPd);
91a745c9   孙向锦   完善后台功能
396
  
338594c8   孙向锦   添加教师端页面
397
  			List<Question> questions = paper.getQuestions();
91a745c9   孙向锦   完善后台功能
398
399
  			if (questions != null) {
  				for (Question question : questions) {
338594c8   孙向锦   添加教师端页面
400
401
402
  					String questionID = this.get32UUID();
  					PageData qPd = new PageData();
  					qPd.put("QUESTION_ID", questionID);
91a745c9   孙向锦   完善后台功能
403
404
  					if (question.getQuestions() != null
  							&& question.getQuestions().size() > 0) {
338594c8   孙向锦   添加教师端页面
405
  						qPd.put("P_ID", "-1");
91a745c9   孙向锦   完善后台功能
406
  					} else {
338594c8   孙向锦   添加教师端页面
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
  						qPd.put("P_ID", "0");
  					}
  					qPd.put("SUBJECT_ID", paper.getSubject_id());
  					qPd.put("CHAPTER_ID", question.getChapter_id());
  					qPd.put("PROBLEM_TYPE_ID", question.getProblem_type_id());
  					qPd.put("TEACHER_ID", paper.getUser_id());
  					qPd.put("SCHOOL_ID", schoolID);
  					qPd.put("KNOWLEDGE_ID", question.getKnowledge_id());
  					qPd.put("CONTENT", question.getContent());
  					qPd.put("OPTION_NUM", question.getOption_num());
  					qPd.put("OPTION_CONTENT", question.getOption_content());
  					qPd.put("ANSWER", question.getAnswer());
  					qPd.put("DIFFICULTY", question.getDifficulty());
  					qPd.put("ANALYSIS", question.getAnalysis());
  					qPd.put("QUESTION_FROM", question.getQuestion_from());
  					qPd.put("SUG_SCORE", question.getScore());
  					qPd.put("SUG_PART_SCORE", question.getPart_score());
  					qPd.put("USER_ID", paper.getUser_id());
  					qPd.put("CREATE_DATE", Tools.date2Str(new Date()));
  					qPd.put("REMARK", "");
  					questionService.save(qPd);
91a745c9   孙向锦   完善后台功能
428
  
338594c8   孙向锦   添加教师端页面
429
  					PageData pqPd = new PageData();
91a745c9   孙向锦   完善后台功能
430
431
432
433
434
435
436
  					pqPd.put("PAPER_ID", paperID);
  					pqPd.put("QUESTION_ID", questionID);
  					pqPd.put("SCORE", question.getScore());
  					pqPd.put("PART_SCORE", "0");
  					pqPd.put("RANK", question.getRank());
  					pqPd.put("NO_NAME", question.getNo_name());
  					pqPd.put("PAPERQUESTION_ID", this.get32UUID());
338594c8   孙向锦   添加教师端页面
437
  					paperquestionService.save(pqPd);
91a745c9   孙向锦   完善后台功能
438
439
  
  					if (question.getQuestions() != null) {
338594c8   孙向锦   添加教师端页面
440
  						List<Question> qs = question.getQuestions();
91a745c9   孙向锦   完善后台功能
441
  						for (Question q : qs) {
338594c8   孙向锦   添加教师端页面
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
  							String qID = this.get32UUID();
  							PageData cqPd = new PageData();
  							cqPd.put("QUESTION_ID", qID);
  							cqPd.put("P_ID", questionID);
  							cqPd.put("SUBJECT_ID", paper.getSubject_id());
  							cqPd.put("CHAPTER_ID", q.getChapter_id());
  							cqPd.put("PROBLEM_TYPE_ID", q.getProblem_type_id());
  							cqPd.put("TEACHER_ID", paper.getUser_id());
  							cqPd.put("SCHOOL_ID", schoolID);
  							cqPd.put("KNOWLEDGE_ID", q.getKnowledge_id());
  							cqPd.put("CONTENT", q.getContent());
  							cqPd.put("OPTION_NUM", q.getOption_num());
  							cqPd.put("OPTION_CONTENT", q.getOption_content());
  							cqPd.put("ANSWER", q.getAnswer());
  							cqPd.put("DIFFICULTY", q.getDifficulty());
  							cqPd.put("ANALYSIS", q.getAnalysis());
  							cqPd.put("QUESTION_FROM", q.getQuestion_from());
  							cqPd.put("SUG_SCORE", q.getScore());
  							cqPd.put("SUG_PART_SCORE", q.getSug_part_score());
  							cqPd.put("USER_ID", paper.getUser_id());
  							cqPd.put("CREATE_DATE", Tools.date2Str(new Date()));
  							cqPd.put("REMARK", "");
91a745c9   孙向锦   完善后台功能
464
  
338594c8   孙向锦   添加教师端页面
465
  							questionService.save(cqPd);
91a745c9   孙向锦   完善后台功能
466
  
338594c8   孙向锦   添加教师端页面
467
  							PageData cpqPd = new PageData();
91a745c9   孙向锦   完善后台功能
468
469
470
471
472
473
474
475
  							cpqPd.put("PAPER_ID", paperID);
  							cpqPd.put("QUESTION_ID", qID);
  							cpqPd.put("SCORE", q.getScore());
  							cpqPd.put("PART_SCORE", "0");
  							cpqPd.put("RANK", q.getRank());
  							cpqPd.put("NO_NAME", q.getNo_name());
  							cpqPd.put("PAPERQUESTION_ID", this.get32UUID());
  
338594c8   孙向锦   添加教师端页面
476
477
478
479
480
  							paperquestionService.save(cpqPd);
  						}
  					}
  				}
  			}
91a745c9   孙向锦   完善后台功能
481
482
  
  		} else {
338594c8   孙向锦   添加教师端页面
483
484
  			res.setDataError();
  		}
91a745c9   孙向锦   完善后台功能
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
  
  		return res.toJson();
  	}
  
  	// 上传测验成绩
  	@RequestMapping(value = "/uploadtestpaper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object uploadTestpaper() {
  		PageData pd = this.getPageData();
  		ResponseGson<String> res = new ResponseGson();
  		if (!StringUtils.isEmpty(pd.getJsonString())) {
  			TestPaper testPaper = TestPaper.parse(pd.getJsonString());
  			try {
  				PageData testPd = new PageData();
  				String testPaperId = this.get32UUID();
  				testPd.put("TESTPAPER_ID", testPaperId);
  				testPd.put("TEACHER_ID", testPaper.getTeacherId());
  				testPd.put("NAME", testPaper.getName());
  				testPd.put("PAPER_ID", testPaper.getPaperId());
  				testPd.put("SCLASS_ID", testPaper.getClassId());
  				testPd.put("START_DATE", testPaper.getStartDate());
  				testPd.put("END_DATE", testPaper.getEndDate());
  				testPd.put(
  						"CREATE_DATE",
  						testPaper.getCreateDate() == null ? Tools
  								.date2Str(new Date()) : testPaper
  								.getCreateDate());
  				testPd.put("OTHER_SCORE", testPaper.getOtherScore());
  				testPd.put("HIGHT_SCORE", testPaper.getHighScore());
  				testPd.put("LOW_SCORE", testPaper.getLowScore());
  				testPd.put("AVG_SCORE", testPaper.getAvgScore());
  				testPd.put("REMARK", testPaper.getRemark());
  				testpaperService.save(testPd);
  				if (testPaper.getStudents() != null) {
  					for (StudentAnswer studentAnswer : testPaper.getStudents()) {
  						if (studentAnswer.getQuestions() != null) {
  							PageData studentPageData = new PageData();
  							studentPageData.put("STUDENTTEST_ID", get32UUID());
  							studentPageData.put("STUDENT_ID",
  									studentAnswer.getStudentId());
  							studentPageData.put("TEST_ID", testPaperId);
  							studentPageData.put("PAPER_ID",
  									testPaper.getPaperId());
  							studentPageData.put("SCORE",
  									studentAnswer.getScore());
  							studentPageData.put("CLASS_ID",
  									testPaper.getClassId());
  							studenttestService.save(studentPageData);
  
  							for (TestPaperInfo testPaperInfo : studentAnswer
  									.getQuestions()) {
  								PageData testInfoPd = new PageData();
  								testInfoPd.put("TESTPAPERINFO_ID",
  										this.get32UUID());
  								testInfoPd.put("PAPER_ID",
  										testPaper.getPaperId());
  								testInfoPd.put("STUDENT_ID",
  										studentAnswer.getStudentId());
  								testInfoPd.put("TEST_ID", testPaperId);
  								testInfoPd.put("QUESTION_ID",
  										testPaperInfo.getQuestionId());
  								testInfoPd.put("ANSWER",
  										testPaperInfo.getAnswer());
  								testInfoPd.put("RIGHT",
  										testPaperInfo.getRight());
  								testInfoPd.put("SCORE",
  										testPaperInfo.getScore());
  								testInfoPd.put("LIKES",
  										testPaperInfo.getLikes());
  								testInfoPd.put("ANSWER_TYPE",
  										testPaperInfo.getAnswerType());
  								testInfoPd.put("PRESS_TIME",
  										testPaperInfo.getPressTime());
  								testInfoPd.put("RECEIVER_DATE",
  										testPaperInfo.getReceiverDate());
  								testInfoPd.put("SUBJECTIVE",
  										testPaperInfo.getSubjective());
  								testInfoPd.put("NOTE", testPaperInfo.getNote());
  								testInfoPd.put("MARK_NO",
  										testPaperInfo.getMarkNo());
  								testpaperinfoService.save(testInfoPd);
  							}
  						}
  					}
  				}
  				res.setData(testPaperId);
  			} catch (Exception e) {
  				e.printStackTrace();
  				res.setError();
  				res.setMessage(e.getMessage());
  			}
  		} else {
  			res.setDataError();
  		}
  
  		return res.toJson();
  
  	}
  
  	// 下载测验成绩
  	@RequestMapping(value = "/downloadtestpaper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object downloadTestpaper() {
  		PageData pd = this.getPageData();
  		ResponseGson<TestPaper> res = new ResponseGson();
  
  		String paperId = pd.getString("ID");
  
  		if (!StringUtils.isEmpty(paperId)) {
  			TestPaper testPaper = new TestPaper();
  			try {
  				pd.put("TESTPAPER_ID", paperId);
  				PageData testPd = testpaperService.findById(pd);
  				if (testPd != null) {
  					testPaper.setTestpaperId(paperId);
  					testPaper.setTeacherId(testPd.getString("TEACHER_ID"));
  					testPaper.setName(testPd.getString("NAME"));
  					testPaper.setPaperId(testPd.getString("PAPER_ID"));
  					testPaper.setClassId(testPd.getString("SCLASS_ID"));
  					testPaper.setStartDate(testPd.getString("START_DATE"));
  					testPaper.setEndDate(testPd.getString("END_DATE"));
  					testPaper.setCreateDate(testPd.getString("CREATE_DATE"));
  					testPaper.setOtherScore(testPd.getString("OTHER_SCORE"));
  					testPaper.setHighScore(testPd.getString("HIGHT_SCORE"));
  					testPaper.setLowScore(testPd.getString("LOW_SCORE"));
  					testPaper.setAvgScore(testPd.getString("AVG_SCORE"));
  					testPaper.setRemark(testPd.getString("REMARK"));
  					PageData testInfof = new PageData();
  					testInfof.put("TEST_ID", paperId);
  
  					List<PageData> studentList = studenttestService
  							.listAll(testInfof);
  
  					for (PageData sPageData : studentList) {
  						StudentAnswer studentAnswer = new StudentAnswer();
  						testInfof.put("STDUENT_ID",
  								sPageData.getString("STDUENT_ID"));
  						studentAnswer.setScore(sPageData.getString("SCORE"));
  						List<PageData> list = testpaperinfoService
  								.listAll(testInfof);
  						for (PageData testInfoPd : list) {
  							TestPaperInfo testPaperInfo = new TestPaperInfo();
  							testPaperInfo.setTestPaperInfoId(testInfoPd
  									.getString("TESTPAPERINFO_ID"));
  							testPaperInfo.setQuestionId(testInfoPd
  									.getString("QUESTION_ID"));
  							testPaperInfo.setAnswer(testInfoPd
  									.getString("ANSWER"));
  							testPaperInfo.setRight(testInfoPd
  									.getString("RIGHT"));
  							testPaperInfo.setScore(testInfoPd
  									.getString("SCORE"));
  							testPaperInfo.setLikes(testInfoPd
  									.getString("LIKES"));
  							testPaperInfo.setAnswerType(testInfoPd
  									.getString("ANSWER_TYPE"));
  							testPaperInfo.setPressTime(testInfoPd
  									.getString("PRESS_TIME"));
  							testPaperInfo.setReceiverDate(testInfoPd
  									.getString("RECEIVER_DATE"));
  							testPaperInfo.setSubjective(testInfoPd
  									.getString("SUBJECTIVE"));
  							testPaperInfo.setNote(testInfoPd.getString("NOTE"));
  							testPaperInfo.setMarkNo(testInfoPd
  									.getString("MARK_NO"));
  							testPaperInfo.setRank(testInfoPd.getString("RANK"));
  							studentAnswer.getQuestions().add(testPaperInfo);
  						}
  						testPaper.getStudents().add(studentAnswer);
  					}
  				}
  
  				res.setData(testPaper);
  			} catch (Exception e) {
  				e.printStackTrace();
  				res.setError();
  			}
  		}
  
338594c8   孙向锦   添加教师端页面
664
  		return res.toJson();
91a745c9   孙向锦   完善后台功能
665
  
338594c8   孙向锦   添加教师端页面
666
667
  	}
  
91a745c9   孙向锦   完善后台功能
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
  	// 下载测验成绩
  	@RequestMapping(value = "/testpaper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object testpaper() {
  		PageData pd = this.getPageData();
  		ResponseGson<List<TestPaper>> res = new ResponseGson();
  		pd.put("TEACHER_ID", pd.getString("USER_ID"));
  		try {
  			List<PageData> pageList = testpaperService.listAll(pd);
  			List<TestPaper> list = new ArrayList<TestPaper>();
  			if (pageList != null) {
  				for (PageData testPd : pageList) {
  					TestPaper testPaper = new TestPaper();
  					testPaper.setTestpaperId(testPd.getString("TESTPAPER_ID"));
  					testPaper.setTeacherId(testPd.getString("TEACHER_ID"));
  					testPaper.setName(testPd.getString("NAME"));
  					testPaper.setPaperId(testPd.getString("PAPER_ID"));
  					testPaper.setClassId(testPd.getString("SCLASS_ID"));
  					testPaper.setStartDate(testPd.getString("START_DATE"));
  					testPaper.setEndDate(testPd.getString("END_DATE"));
  					testPaper.setCreateDate(testPd.getString("CREATE_DATE"));
  					testPaper.setOtherScore(testPd.getString("OTHER_SCORE"));
  					testPaper.setHighScore(testPd.getString("HIGHT_SCORE"));
  					testPaper.setLowScore(testPd.getString("LOW_SCORE"));
  					testPaper.setAvgScore(testPd.getString("AVG_SCORE"));
  					testPaper.setRemark(testPd.getString("REMARK"));
  					list.add(testPaper);
  				}
  			}
  			res.setData(list);
  		} catch (Exception e) {
  			res.setError();
  			res.setMessage(e.getMessage());
  			e.printStackTrace();
  		}
  
  		return res.toJson();
  
  	}
bed6e1fc   孙向锦   添加其他功能
707
  }