Blame view

src/com/fh/controller/api/V1.java 40.4 KB
bed6e1fc   孙向锦   添加其他功能
1
2
  package com.fh.controller.api;
  
338594c8   孙向锦   添加教师端页面
3
  import java.util.ArrayList;
bed6e1fc   孙向锦   添加其他功能
4
5
6
7
  import java.util.Date;
  import java.util.List;
  
  import javax.annotation.Resource;
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
8
  import javax.servlet.http.HttpServletRequest;
bed6e1fc   孙向锦   添加其他功能
9
  
338594c8   孙向锦   添加教师端页面
10
  import org.apache.commons.lang.StringUtils;
d3d7b2ca   孙向锦   修改表格固定
11
  import org.apache.shiro.crypto.hash.SimpleHash;
bed6e1fc   孙向锦   添加其他功能
12
  import org.springframework.stereotype.Controller;
bed6e1fc   孙向锦   添加其他功能
13
14
15
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.ResponseBody;
  
338594c8   孙向锦   添加教师端页面
16
17
  import com.fh.bean.Paper;
  import com.fh.bean.Question;
91a745c9   孙向锦   完善后台功能
18
19
20
  import com.fh.bean.StudentAnswer;
  import com.fh.bean.TestPaper;
  import com.fh.bean.TestPaperInfo;
bed6e1fc   孙向锦   添加其他功能
21
  import com.fh.controller.base.BaseController;
338594c8   孙向锦   添加教师端页面
22
  import com.fh.controller.sunvote.Myelfun;
bed6e1fc   孙向锦   添加其他功能
23
24
25
26
  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;
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
27
  import com.fh.service.software.softwareversion.SoftwareVersionManager;
9f161055   孙向锦   修改高斯客户反馈
28
  import com.fh.service.sunvote.attachkeyboard.AttachKeyboardManager;
bed6e1fc   孙向锦   添加其他功能
29
30
31
32
33
34
  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;
9338b563   孙向锦   添加报表
35
  import com.fh.service.sunvote.event.EventManager;
bed6e1fc   孙向锦   添加其他功能
36
37
38
39
40
  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;
9338b563   孙向锦   添加报表
41
  import com.fh.service.sunvote.networkstatistics.NetworkStatisticsManager;
bed6e1fc   孙向锦   添加其他功能
42
43
44
45
46
47
48
49
50
51
  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   孙向锦   完善后台功能
52
  import com.fh.service.sunvote.studenttest.StudentTestManager;
bed6e1fc   孙向锦   添加其他功能
53
54
  import com.fh.service.sunvote.subject.SubjectManager;
  import com.fh.service.sunvote.teacher.TeacherManager;
91a745c9   孙向锦   完善后台功能
55
  import com.fh.service.sunvote.testpaper.TestPaperManager;
bed6e1fc   孙向锦   添加其他功能
56
  import com.fh.service.sunvote.testpaperinfo.TestPaperInfoManager;
d3d7b2ca   孙向锦   修改表格固定
57
58
  import com.fh.service.system.user.UserManager;
  import com.fh.util.Jurisdiction;
bed6e1fc   孙向锦   添加其他功能
59
60
61
62
63
64
  import com.fh.util.PageData;
  import com.fh.util.Tools;
  
  @Controller
  @RequestMapping(value = "/api/v1")
  public class V1 extends BaseController {
91a745c9   孙向锦   完善后台功能
65
  
bed6e1fc   孙向锦   添加其他功能
66
67
68
69
70
  	@Resource(name = "schoolService")
  	private SchoolManager schoolService;
  
  	@Resource(name = "basestationService")
  	private BasestationManager basestationService;
91a745c9   孙向锦   完善后台功能
71
72
  
  	@Resource(name = "chapterService")
bed6e1fc   孙向锦   添加其他功能
73
  	private ChapterManager chapterService;
91a745c9   孙向锦   完善后台功能
74
75
  
  	@Resource(name = "classbasetationService")
bed6e1fc   孙向锦   添加其他功能
76
  	private ClassBasetationManager classbasetationService;
91a745c9   孙向锦   完善后台功能
77
78
  
  	@Resource(name = "classrosterService")
bed6e1fc   孙向锦   添加其他功能
79
  	private ClassRosterManager classrosterService;
91a745c9   孙向锦   完善后台功能
80
81
  
  	@Resource(name = "classtypeService")
bed6e1fc   孙向锦   添加其他功能
82
  	private ClassTypeManager classtypeService;
91a745c9   孙向锦   完善后台功能
83
84
  
  	@Resource(name = "gradeService")
bed6e1fc   孙向锦   添加其他功能
85
  	private GradeManager gradeService;
91a745c9   孙向锦   完善后台功能
86
87
  
  	@Resource(name = "coursemanagementService")
bed6e1fc   孙向锦   添加其他功能
88
89
90
91
  	private CourseManagementManager coursemanagementService;
  
  	@Resource(name = "keypadService")
  	private KeypadManager keypadService;
91a745c9   孙向锦   完善后台功能
92
93
  
  	@Resource(name = "keypadcheckService")
bed6e1fc   孙向锦   添加其他功能
94
  	private KeypadCheckManager keypadcheckService;
91a745c9   孙向锦   完善后台功能
95
96
  
  	@Resource(name = "knowledgeService")
bed6e1fc   孙向锦   添加其他功能
97
  	private KnowledgeManager knowledgeService;
91a745c9   孙向锦   完善后台功能
98
99
  
  	@Resource(name = "knowledgechapterService")
bed6e1fc   孙向锦   添加其他功能
100
  	private KnowledgeChapterManager knowledgechapterService;
91a745c9   孙向锦   完善后台功能
101
102
  
  	@Resource(name = "paperService")
bed6e1fc   孙向锦   添加其他功能
103
  	private PaperManager paperService;
91a745c9   孙向锦   完善后台功能
104
105
  
  	@Resource(name = "paperclassteacherService")
bed6e1fc   孙向锦   添加其他功能
106
  	private PaperClassTeacherManager paperclassteacherService;
91a745c9   孙向锦   完善后台功能
107
108
  
  	@Resource(name = "paperquestionService")
bed6e1fc   孙向锦   添加其他功能
109
  	private PaperQuestionManager paperquestionService;
91a745c9   孙向锦   完善后台功能
110
111
  
  	@Resource(name = "papertypeService")
bed6e1fc   孙向锦   添加其他功能
112
  	private PaperTypeManager papertypeService;
91a745c9   孙向锦   完善后台功能
113
114
  
  	@Resource(name = "questionService")
bed6e1fc   孙向锦   添加其他功能
115
  	private QuestionManager questionService;
91a745c9   孙向锦   完善后台功能
116
117
  
  	@Resource(name = "questiontypeService")
bed6e1fc   孙向锦   添加其他功能
118
  	private QuestionTypeManager questiontypeService;
91a745c9   孙向锦   完善后台功能
119
120
  
  	@Resource(name = "schoolgradesubjectService")
bed6e1fc   孙向锦   添加其他功能
121
  	private SchoolGradeSubjectManager schoolgradesubjectService;
91a745c9   孙向锦   完善后台功能
122
123
  
  	@Resource(name = "sclassService")
bed6e1fc   孙向锦   添加其他功能
124
  	private SClassManager sclassService;
91a745c9   孙向锦   完善后台功能
125
126
  
  	@Resource(name = "studentService")
bed6e1fc   孙向锦   添加其他功能
127
  	private StudentManager studentService;
91a745c9   孙向锦   完善后台功能
128
129
  
  	@Resource(name = "subjectService")
bed6e1fc   孙向锦   添加其他功能
130
  	private SubjectManager subjectService;
91a745c9   孙向锦   完善后台功能
131
132
  
  	@Resource(name = "teacherService")
bed6e1fc   孙向锦   添加其他功能
133
  	private TeacherManager teacherService;
91a745c9   孙向锦   完善后台功能
134
135
  
  	@Resource(name = "testpaperinfoService")
bed6e1fc   孙向锦   添加其他功能
136
137
  	private TestPaperInfoManager testpaperinfoService;
  
91a745c9   孙向锦   完善后台功能
138
139
140
141
142
143
  	@Resource(name = "testpaperService")
  	private TestPaperManager testpaperService;
  
  	@Resource(name = "studenttestService")
  	private StudentTestManager studenttestService;
  
bed6e1fc   孙向锦   添加其他功能
144
145
146
147
148
  	@Resource(name = "feedbackService")
  	private FeedbackManager feedbackService;
  
  	@Resource(name = "problemphenomenonService")
  	private ProblemPhenomenonManager problemphenomenonService;
91a745c9   孙向锦   完善后台功能
149
  
bed6e1fc   孙向锦   添加其他功能
150
  	@Resource(name = "v1Service")
91a745c9   孙向锦   完善后台功能
151
  	private V1Manager v1Service;
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
152
153
154
  	
  	@Resource(name="softwareversionService")
  	private SoftwareVersionManager softwareversionService;
9f161055   孙向锦   修改高斯客户反馈
155
156
157
  	
  	@Resource(name="attachkeyboardService")
  	private AttachKeyboardManager attachkeyboardService;
9338b563   孙向锦   添加报表
158
159
160
161
162
163
  	
  	@Resource(name="networkstatisticsService")
  	private NetworkStatisticsManager networkstatisticsService;
  	
  	@Resource(name="eventService")
  	private EventManager eventService;
d3d7b2ca   孙向锦   修改表格固定
164
165
166
  	
  	@Resource(name="userService")
  	private UserManager userService;
91a745c9   孙向锦   完善后台功能
167
  
bed6e1fc   孙向锦   添加其他功能
168
169
170
  	@RequestMapping(value = "/login", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object login() throws Exception {
3371dbc6   孙向锦   0720 版本
171
  		event("apilogin");
bed6e1fc   孙向锦   添加其他功能
172
173
  		PageData pd = this.getPageData();
  		ResponseGson<PageData> res = new ResponseGson();
91a745c9   孙向锦   完善后台功能
174
  		if (!pd.containsKey("ACCOUT")) {
bed6e1fc   孙向锦   添加其他功能
175
176
  			pd.put("ACCOUT", pd.get("USERNAME"));
  		}
b5cf92b7   孙向锦   批量上传学生名单
177
  		if (((pd.containsKey("USERNAME") || (pd.containsKey("ACCOUT") && pd.get("ACCOUT") != null)) && pd
91a745c9   孙向锦   完善后台功能
178
  				.containsKey("PASSWORD")) || pd.containsKey("KEYPAD_ID")) {
bed6e1fc   孙向锦   添加其他功能
179
  			PageData pageData = teacherService.getUserInfo(pd);
91a745c9   孙向锦   完善后台功能
180
181
  			if (pageData != null && pageData.getString("ID") != null) {
  				pageData.put("PASSWORD", "");// 返回参数中不返回密码
bed6e1fc   孙向锦   添加其他功能
182
183
184
  				PageData pt = new PageData();
  				pt.put("TEACHER_ID", pageData.get("ID"));
  				// 在任课表中查找老师教哪些班级,然后查出班级信息
91a745c9   孙向锦   完善后台功能
185
186
187
  				List<PageData> classInfoList = v1Service
  						.getTeacherClassInfo(pt);
  
bed6e1fc   孙向锦   添加其他功能
188
189
  				pageData.put("classInfoList", classInfoList);
  				// 在认可表中查找老师教哪些科目,然后查出科目信息
91a745c9   孙向锦   完善后台功能
190
191
  				List<PageData> subjectList = v1Service
  						.getTeacherSubjectInfo(pt);
bed6e1fc   孙向锦   添加其他功能
192
193
  				// 一个sql语句完成。
  				pageData.put("subjectList", subjectList);
91a745c9   孙向锦   完善后台功能
194
  
bed6e1fc   孙向锦   添加其他功能
195
  				pageData.remove("SUBJECT_IDS");
9338b563   孙向锦   添加报表
196
197
198
199
200
201
202
203
204
205
206
207
208
209
  				
  				PageData eventPd = new PageData();
  				eventPd.put("EVENT_ID", get32UUID());
  				eventPd.put("EVENT_NAME", "login");
  				eventPd.put("EVENT_USER", pageData.getString("ID"));
  				eventPd.put("EVENT_TYPE", "0");
  				eventPd.put("EVENT_START_TIME",Tools.date2Str(new Date()));
  				if(pd.getString("CLIENT_ID") != null){
  					eventPd.put("CLIENT_ID", pd.getString("CLIENT_ID"));
  				}else{
  					eventPd.put("CLIENT_ID", "CLIENT");
  				}
  				eventPd.put("EVENT_IP",getRemoteIp());
  				eventService.save(eventPd);
91a745c9   孙向锦   完善后台功能
210
  
bed6e1fc   孙向锦   添加其他功能
211
212
  				res.setData(pageData);
  				// 填充数据到返回数据中
91a745c9   孙向锦   完善后台功能
213
  			} else {
bed6e1fc   孙向锦   添加其他功能
214
215
  				res.set1Error();
  			}
91a745c9   孙向锦   完善后台功能
216
  		} else {
bed6e1fc   孙向锦   添加其他功能
217
218
  			res.set1Error();
  		}
91a745c9   孙向锦   完善后台功能
219
  
bed6e1fc   孙向锦   添加其他功能
220
221
  		return res.toJson();
  	}
91a745c9   孙向锦   完善后台功能
222
  
bed6e1fc   孙向锦   添加其他功能
223
224
225
  	@RequestMapping(value = "/class", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object sclass() throws Exception {
3371dbc6   孙向锦   0720 版本
226
  		event("sclass");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
227
  		long cur = System.currentTimeMillis();
bed6e1fc   孙向锦   添加其他功能
228
  		PageData pd = this.getPageData();
bed6e1fc   孙向锦   添加其他功能
229
  		if (pd.containsKey("ID")) {
4fd2e08c   孙向锦   修复接口中的bug
230
  			ResponseGson<PageData> res = new ResponseGson();
bed6e1fc   孙向锦   添加其他功能
231
232
233
234
  			PageData pageData = sclassService.findById(pd);
  			if (pageData != null && pageData.containsKey("ID")) {
  				PageData pt = new PageData();
  				pt.put("SCLASS_ID", pageData.get("ID"));
91a745c9   孙向锦   完善后台功能
235
  				List<PageData> studentList = v1Service.getClassStudent(pt);
bed6e1fc   孙向锦   添加其他功能
236
  				pageData.put("studentList", studentList);
9f161055   孙向锦   修改高斯客户反馈
237
238
239
  				pt.put("CLASS_ID", pageData.get("ID"));
  				List<PageData> keyboards = attachkeyboardService.listAllClassId(pt);
  				pageData.put("keyboards", keyboards);
bed6e1fc   孙向锦   添加其他功能
240
241
242
243
  				res.setData(pageData);
  			} else {
  				res.set2Error();
  			}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
244
  			logger.info("class cost time : " + (System.currentTimeMillis() - cur));
4fd2e08c   孙向锦   修复接口中的bug
245
246
247
248
249
  			return res.toJson();
  		} else {
  			ResponseGson<List<PageData>> res = new ResponseGson();
  			List<PageData> list = sclassService.listAll(pd);
  			res.setData(list);
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
250
  			logger.info("class cost time : " + (System.currentTimeMillis() - cur));
4fd2e08c   孙向锦   修复接口中的bug
251
  			return res.toJson();
4fd2e08c   孙向锦   修复接口中的bug
252
253
254
255
256
257
  		}
  	}
  	
  	@RequestMapping(value = "/questiontype", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object questiontype() throws Exception {
3371dbc6   孙向锦   0720 版本
258
  		event("questiontype");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
259
  		long cur = System.currentTimeMillis();
4fd2e08c   孙向锦   修复接口中的bug
260
261
262
263
  		PageData pd = this.getPageData();
  		ResponseGson<List<PageData>> res = new ResponseGson();
  		List<PageData> list = questiontypeService.listAll(pd);
  		res.setData(list);
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
264
  		logger.info("questiontype cost time : " + (System.currentTimeMillis() - cur));
4fd2e08c   孙向锦   修复接口中的bug
265
266
267
268
269
270
  		return res.toJson();
  	}
  	
  	@RequestMapping(value = "/classtype", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object classtype() throws Exception {
3371dbc6   孙向锦   0720 版本
271
  		event("classtype");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
272
  		long cur = System.currentTimeMillis();
4fd2e08c   孙向锦   修复接口中的bug
273
274
275
276
  		PageData pd = this.getPageData();
  		ResponseGson<List<PageData>> res = new ResponseGson();
  		List<PageData> list = classtypeService.listAll(pd);
  		res.setData(list);
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
277
  		logger.info("classtype cost time : " + (System.currentTimeMillis() - cur));
4fd2e08c   孙向锦   修复接口中的bug
278
279
280
281
282
283
  		return res.toJson();
  	}
  	
  	@RequestMapping(value = "/grade", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object grade() throws Exception {
3371dbc6   孙向锦   0720 版本
284
  		event("grade");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
285
  		long cur = System.currentTimeMillis();
4fd2e08c   孙向锦   修复接口中的bug
286
287
288
289
290
  		PageData pd = this.getPageData();
  		ResponseGson<List<PageData>> res = new ResponseGson();
  		if (!pd.containsKey("SCHOOL_ID")) {
  			List<PageData> list = gradeService.listAll(pd);
  			res.setData(list);
91a745c9   孙向锦   完善后台功能
291
  		} else {
4fd2e08c   孙向锦   修复接口中的bug
292
293
  			List<PageData> list = schoolgradesubjectService.listAllGrade(pd);
  			res.setData(list);
bed6e1fc   孙向锦   添加其他功能
294
  		}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
295
  		logger.info("class cost time : " + (System.currentTimeMillis() - cur));
bed6e1fc   孙向锦   添加其他功能
296
297
  		return res.toJson();
  	}
4fd2e08c   孙向锦   修复接口中的bug
298
299
300
301
  	
  	@RequestMapping(value = "/subject", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object subject() throws Exception {
3371dbc6   孙向锦   0720 版本
302
  		event("subject");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
303
  		long cur = System.currentTimeMillis();
4fd2e08c   孙向锦   修复接口中的bug
304
305
306
307
308
309
310
311
312
  		PageData pd = this.getPageData();
  		ResponseGson<List<PageData>> res = new ResponseGson();
  		if (!pd.containsKey("SCHOOL_ID")) {
  			List<PageData> list = subjectService.listAll(pd);
  			res.setData(list);
  		} else {
  			List<PageData> list = schoolgradesubjectService.listAllSubject(pd);
  			res.setData(list);
  		}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
313
  		logger.info("subject cost time : " + (System.currentTimeMillis() - cur));
4fd2e08c   孙向锦   修复接口中的bug
314
315
316
317
  		return res.toJson();
  	}
  	
  	
91a745c9   孙向锦   完善后台功能
318
  
bed6e1fc   孙向锦   添加其他功能
319
320
321
  	@RequestMapping(value = "/keypadscan", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object keypadScan() throws Exception {
3371dbc6   孙向锦   0720 版本
322
  		event("keypadScan");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
323
  		long cur = System.currentTimeMillis();
bed6e1fc   孙向锦   添加其他功能
324
  		PageData pd = this.getPageData();
91a745c9   孙向锦   完善后台功能
325
326
327
328
329
  		ResponseGson<String> res = new ResponseGson();
  		String ID = get32UUID();
  		pd.put("KEYPADCHECK_ID", ID); // 主键
  		pd.put("CREATE_DATE", Tools.date2Str(new Date())); // 创建时间
  		try {
bed6e1fc   孙向锦   添加其他功能
330
  			keypadcheckService.save(pd);
91a745c9   孙向锦   完善后台功能
331
  			res.setData(ID);
bed6e1fc   孙向锦   添加其他功能
332
  			res.setSuccess();
91a745c9   孙向锦   完善后台功能
333
  		} catch (Exception ex) {
bed6e1fc   孙向锦   添加其他功能
334
335
  			res.setDataError();
  		}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
336
  		logger.info("keypadScan cost time : " + (System.currentTimeMillis() - cur));
bed6e1fc   孙向锦   添加其他功能
337
338
  		return res.toJson();
  	}
91a745c9   孙向锦   完善后台功能
339
  
bed6e1fc   孙向锦   添加其他功能
340
341
342
  	@RequestMapping(value = "/paper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object paper() throws Exception {
3371dbc6   孙向锦   0720 版本
343
  		event("paper");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
344
  		long cur = System.currentTimeMillis();
bed6e1fc   孙向锦   添加其他功能
345
346
  		PageData pd = this.getPageData();
  		ResponseGson<List<PageData>> res = new ResponseGson<List<PageData>>();
91a745c9   孙向锦   完善后台功能
347
  		if (pd.containsKey("PAPER_TYPE") && pd.containsKey("USER_ID")) {
bed6e1fc   孙向锦   添加其他功能
348
349
350
  			Page page = new Page();
  			page.getPd().put("PAPER_TYPE", pd.get("PAPER_TYPE"));
  			page.getPd().put("USER_ID", pd.get("USER_ID"));
f8d83f1f   孙向锦   添加学校界面
351
  			page.getPd().put("SUBJECT_ID", pd.get("SUBJECT_ID"));
91a745c9   孙向锦   完善后台功能
352
  			if (pd.containsKey("CURRENTPAGE")) {
bed6e1fc   孙向锦   添加其他功能
353
  				String curpage = pd.getString("CURRENTPAGE");
91a745c9   孙向锦   完善后台功能
354
  				try {
bed6e1fc   孙向锦   添加其他功能
355
  					page.setCurrentPage(Integer.parseInt(curpage));
91a745c9   孙向锦   完善后台功能
356
357
  				} catch (Exception ex) {
  				}
bed6e1fc   孙向锦   添加其他功能
358
  			}
91a745c9   孙向锦   完善后台功能
359
  			if (pd.containsKey("SHOWCOUNT")) {
bed6e1fc   孙向锦   添加其他功能
360
  				String showCount = pd.getString("SHOWCOUNT");
91a745c9   孙向锦   完善后台功能
361
  				try {
bed6e1fc   孙向锦   添加其他功能
362
  					page.setShowCount(Integer.parseInt(showCount));
91a745c9   孙向锦   完善后台功能
363
364
365
  				} catch (Exception ex) {
  				}
  			} else {
bed6e1fc   孙向锦   添加其他功能
366
367
368
369
  				page.setShowCount(100);
  			}
  			List<PageData> pageList = paperService.listAllByType(page);
  			res.setData(pageList);
91a745c9   孙向锦   完善后台功能
370
  		} else {
338594c8   孙向锦   添加教师端页面
371
  			res.setParmError();
bed6e1fc   孙向锦   添加其他功能
372
  		}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
373
  		logger.info("paper cost time : " + (System.currentTimeMillis() - cur));
bed6e1fc   孙向锦   添加其他功能
374
375
  		return res.toJson();
  	}
91a745c9   孙向锦   完善后台功能
376
377
  
  	@RequestMapping(value = "/paperinfo", produces = "application/json;charset=UTF-8")
bed6e1fc   孙向锦   添加其他功能
378
  	@ResponseBody
91a745c9   孙向锦   完善后台功能
379
  	public Object paperInfo() throws Exception {
3371dbc6   孙向锦   0720 版本
380
  		event("paperInfo");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
381
  		long cur = System.currentTimeMillis();
bed6e1fc   孙向锦   添加其他功能
382
  		PageData pd = this.getPageData();
338594c8   孙向锦   添加教师端页面
383
  		ResponseGson<Paper> res = new ResponseGson<Paper>();
91a745c9   孙向锦   完善后台功能
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
  		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"));
4fd2e08c   孙向锦   修复接口中的bug
420
421
422
423
  							question.setScore(qpd.getString("SCORE"));
  							question.setPart_score(qpd
  									.getString("PART_SCORE"));
  							question.setQuestionType(qpd.getString("PROBLEM_TYPE_ID"));
91a745c9   孙向锦   完善后台功能
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
  							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"));
4fd2e08c   孙向锦   修复接口中的bug
451
452
453
454
  									qq.setScore(q.getString("SCORE"));
  									qq.setPart_score(q
  											.getString("PART_SCORE"));
  									qq.setQuestionType(qpd.getString("PROBLEM_TYPE_ID"));
91a745c9   孙向锦   完善后台功能
455
456
457
458
459
460
461
462
463
  									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   孙向锦   添加教师端页面
464
  						}
91a745c9   孙向锦   完善后台功能
465
466
467
468
  						// pd.put("JSON", paper.toJson());
  						res.setData(paper);
  						logger.info(paper.toJson());
  
338594c8   孙向锦   添加教师端页面
469
  					}
91a745c9   孙向锦   完善后台功能
470
471
  				} catch (Exception ex) {
  					ex.printStackTrace();
338594c8   孙向锦   添加教师端页面
472
  				}
91a745c9   孙向锦   完善后台功能
473
  			} catch (Exception ex) {
338594c8   孙向锦   添加教师端页面
474
475
  				ex.printStackTrace();
  				res.setError();
bed6e1fc   孙向锦   添加其他功能
476
  			}
91a745c9   孙向锦   完善后台功能
477
  		} else {
bed6e1fc   孙向锦   添加其他功能
478
479
  			res.setOtherError();
  		}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
480
  		logger.info("paperInfo cost time : " + (System.currentTimeMillis() - cur));
bed6e1fc   孙向锦   添加其他功能
481
482
  		return res.toJson();
  	}
91a745c9   孙向锦   完善后台功能
483
  
bed6e1fc   孙向锦   添加其他功能
484
485
486
  	@RequestMapping(value = "/paperquestion", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object paperQuestion() throws Exception {
3371dbc6   孙向锦   0720 版本
487
  		event("paperQuestion");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
488
  		long cur = System.currentTimeMillis();
bed6e1fc   孙向锦   添加其他功能
489
490
  		PageData pd = this.getPageData();
  		ResponseGson<PageData> res = new ResponseGson();
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
491
  		logger.info("paperquestion cost time : " + (System.currentTimeMillis() - cur));
bed6e1fc   孙向锦   添加其他功能
492
493
  		return res.toJson();
  	}
4fd2e08c   孙向锦   修复接口中的bug
494
495
496
497
  	
  	@RequestMapping(value = "/question", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object question() throws Exception {
3371dbc6   孙向锦   0720 版本
498
  		event("question");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
499
  		long cur = System.currentTimeMillis();
4fd2e08c   孙向锦   修复接口中的bug
500
501
502
503
504
505
506
507
508
  		PageData pd = this.getPageData();
  		ResponseGson<PageData> res = new ResponseGson();
  		if(pd.containsKey("ID")){
  			pd.put("QUESTION_ID", pd.get("ID"));
  			PageData data = questionService.findById(pd);
  			res.setData(data);
  		}else{
  			res.setDataError();
  		}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
509
  		logger.info("question cost time : " + (System.currentTimeMillis() - cur));
4fd2e08c   孙向锦   修复接口中的bug
510
511
512
513
514
515
  		return res.toJson();
  	}
  	
  	@RequestMapping(value = "/question/add", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object questionAdd() throws Exception {
3371dbc6   孙向锦   0720 版本
516
  		event("questionAdd");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
517
  		long cur = System.currentTimeMillis();
4fd2e08c   孙向锦   修复接口中的bug
518
519
520
521
  		PageData pd = this.getPageData();
  		ResponseGson<PageData> res = new ResponseGson();
  		pd.put("QUESTION_ID", this.get32UUID());
  		questionService.save(pd);
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
522
  		logger.info("questionAdd cost time : " + (System.currentTimeMillis() - cur));
4fd2e08c   孙向锦   修复接口中的bug
523
524
525
  		return res.toJson();
  	}
  	
338594c8   孙向锦   添加教师端页面
526
527
528
  	@RequestMapping(value = "/uploadpaper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object uploadpaper() throws Exception {
3371dbc6   孙向锦   0720 版本
529
  		event("uploadpaper");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
530
  		long cur = System.currentTimeMillis();
338594c8   孙向锦   添加教师端页面
531
532
  		PageData pd = this.getPageData();
  		ResponseGson<String> res = new ResponseGson();
91a745c9   孙向锦   完善后台功能
533
534
  
  		if (!StringUtils.isEmpty(pd.getJsonString())) {
4fd2e08c   孙向锦   修复接口中的bug
535
  			logger.info(pd.getJsonString());
338594c8   孙向锦   添加教师端页面
536
537
538
539
  			Paper paper = Paper.parse(pd.getJsonString());
  			PageData paperPd = new PageData();
  			String paperID = this.get32UUID();
  			res.setData(paperID);
91a745c9   孙向锦   完善后台功能
540
541
542
543
544
545
546
547
548
549
  			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   孙向锦   添加教师端页面
550
551
  			String schoolID = Myelfun.getUserID(paper.getUser_id());
  			paperPd.put("SCHOOL_ID", schoolID);
91a745c9   孙向锦   完善后台功能
552
553
554
  			paperPd.put("CREATE_DATE", Tools.date2Str(new Date()));
  			paperPd.put("MODIFY_DATE", Tools.date2Str(new Date()));
  
4fd2e08c   孙向锦   修复接口中的bug
555
556
  			int questionNum = 0 ;
  			
91a745c9   孙向锦   完善后台功能
557
  
338594c8   孙向锦   添加教师端页面
558
  			List<Question> questions = paper.getQuestions();
91a745c9   孙向锦   完善后台功能
559
560
  			if (questions != null) {
  				for (Question question : questions) {
338594c8   孙向锦   添加教师端页面
561
562
563
  					String questionID = this.get32UUID();
  					PageData qPd = new PageData();
  					qPd.put("QUESTION_ID", questionID);
91a745c9   孙向锦   完善后台功能
564
565
  					if (question.getQuestions() != null
  							&& question.getQuestions().size() > 0) {
338594c8   孙向锦   添加教师端页面
566
  						qPd.put("P_ID", "-1");
91a745c9   孙向锦   完善后台功能
567
  					} else {
4fd2e08c   孙向锦   修复接口中的bug
568
  						questionNum ++ ;
338594c8   孙向锦   添加教师端页面
569
570
571
572
  						qPd.put("P_ID", "0");
  					}
  					qPd.put("SUBJECT_ID", paper.getSubject_id());
  					qPd.put("CHAPTER_ID", question.getChapter_id());
4fd2e08c   孙向锦   修复接口中的bug
573
  					qPd.put("PROBLEM_TYPE_ID", question.getProblem_type_id() == null ? "1" :  question.getProblem_type_id());
338594c8   孙向锦   添加教师端页面
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
  					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   孙向锦   完善后台功能
590
  
338594c8   孙向锦   添加教师端页面
591
  					PageData pqPd = new PageData();
91a745c9   孙向锦   完善后台功能
592
593
594
595
596
597
598
  					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   孙向锦   添加教师端页面
599
  					paperquestionService.save(pqPd);
91a745c9   孙向锦   完善后台功能
600
601
  
  					if (question.getQuestions() != null) {
338594c8   孙向锦   添加教师端页面
602
  						List<Question> qs = question.getQuestions();
91a745c9   孙向锦   完善后台功能
603
  						for (Question q : qs) {
338594c8   孙向锦   添加教师端页面
604
605
606
607
608
609
  							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());
4fd2e08c   孙向锦   修复接口中的bug
610
  							cqPd.put("PROBLEM_TYPE_ID", question.getProblem_type_id() == null ? "1" :  question.getProblem_type_id());
338594c8   孙向锦   添加教师端页面
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
  							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   孙向锦   完善后台功能
626
  
338594c8   孙向锦   添加教师端页面
627
  							questionService.save(cqPd);
91a745c9   孙向锦   完善后台功能
628
  
338594c8   孙向锦   添加教师端页面
629
  							PageData cpqPd = new PageData();
91a745c9   孙向锦   完善后台功能
630
631
632
633
634
635
636
637
  							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   孙向锦   添加教师端页面
638
  							paperquestionService.save(cpqPd);
4fd2e08c   孙向锦   修复接口中的bug
639
  							questionNum ++ ;
338594c8   孙向锦   添加教师端页面
640
641
642
643
  						}
  					}
  				}
  			}
4fd2e08c   孙向锦   修复接口中的bug
644
645
  			paperPd.put("QUESTION_NUM", "" + questionNum);
  			paperService.save(paperPd);
91a745c9   孙向锦   完善后台功能
646
647
  
  		} else {
338594c8   孙向锦   添加教师端页面
648
649
  			res.setDataError();
  		}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
650
  		logger.info("uploadpaper cost time : " + (System.currentTimeMillis() - cur));
91a745c9   孙向锦   完善后台功能
651
652
653
654
655
656
657
  		return res.toJson();
  	}
  
  	// 上传测验成绩
  	@RequestMapping(value = "/uploadtestpaper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object uploadTestpaper() {
3371dbc6   孙向锦   0720 版本
658
  		event("uploadTestpaper");
4fd2e08c   孙向锦   修复接口中的bug
659
  		long cur = System.currentTimeMillis();
91a745c9   孙向锦   完善后台功能
660
661
662
  		PageData pd = this.getPageData();
  		ResponseGson<String> res = new ResponseGson();
  		if (!StringUtils.isEmpty(pd.getJsonString())) {
4fd2e08c   孙向锦   修复接口中的bug
663
  			logger.info(pd.getJsonString());
91a745c9   孙向锦   完善后台功能
664
665
666
667
  			TestPaper testPaper = TestPaper.parse(pd.getJsonString());
  			try {
  				PageData testPd = new PageData();
  				String testPaperId = this.get32UUID();
91a745c9   孙向锦   完善后台功能
668
  				testPd.put("TEACHER_ID", testPaper.getTeacherId());
91a745c9   孙向锦   完善后台功能
669
670
  				testPd.put("PAPER_ID", testPaper.getPaperId());
  				testPd.put("SCLASS_ID", testPaper.getClassId());
91a745c9   孙向锦   完善后台功能
671
672
673
674
675
  				testPd.put(
  						"CREATE_DATE",
  						testPaper.getCreateDate() == null ? Tools
  								.date2Str(new Date()) : testPaper
  								.getCreateDate());
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
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
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
  				List<PageData> listData = testpaperService.listAll(testPd);
  				if (!(listData != null && listData.size() > 0)) {
  					testPd.put("START_DATE", testPaper.getStartDate());
  					testPd.put("END_DATE", testPaper.getEndDate());
  					testPd.put("NAME", testPaper.getName());
  					testPd.put("TESTPAPER_ID", testPaperId);
  					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) {
  						List<PageData> testInfoPdList = new ArrayList();
  						PageData testInfoPd = 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()) {
  									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() == null ? "1"
  															: 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());
  									testInfoPdList.add(testInfoPd);
  								}
  							}
  						}
  						testpaperinfoService.batchSave(testInfoPdList);
  					}
  				}else{
  					testPaperId = listData.get(0).getString("TESTPAPER_ID");
  				}
  				res.setData(testPaperId);
  			} catch (Exception e) {
  				e.printStackTrace();
  				res.setError();
  				res.setMessage(e.getMessage());
  			}
  		} else {
  			res.setDataError();
  		}
  		logger.info("uploadtestpaper cost time:" + (System.currentTimeMillis() - cur));
  
  		return res.toJson();
  
  	}
  	
  	
  	// 上传测验成绩
  	@RequestMapping(value = "/uploadupdatetestpaper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object uploadupdateTestpaper() {
3371dbc6   孙向锦   0720 版本
773
  		event("uploadupdateTestpaper");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
  		long cur = System.currentTimeMillis();
  		PageData pd = this.getPageData();
  		ResponseGson<String> res = new ResponseGson();
  		if (!StringUtils.isEmpty(pd.getJsonString())) {
  			logger.info(pd.getJsonString());
  			TestPaper testPaper = TestPaper.parse(pd.getJsonString());
  			try {
  				PageData testPd = new PageData();
  				String testPaperId = this.get32UUID();
  				testPd.put("TEACHER_ID", testPaper.getTeacherId());
  				testPd.put("PAPER_ID", testPaper.getPaperId());
  				testPd.put("SCLASS_ID", testPaper.getClassId());
  				testPd.put(
  						"CREATE_DATE",
  						testPaper.getCreateDate() == null ? Tools
  								.date2Str(new Date()) : testPaper
  								.getCreateDate());
  				List<PageData> listData = testpaperService.listAll(testPd);
  				if ((listData != null && listData.size() > 0)) {
  					testPaperId = listData.get(0).getString("TESTPAPER_ID");
  					testpaperService.deleteList(testPd);
  					testPd.put("TEST_ID", testPaperId);
  					testpaperinfoService.delete(testPd);
  					studenttestService.delete(testPd);
  				}
  				testPd.put("START_DATE", testPaper.getStartDate());
  				testPd.put("END_DATE", testPaper.getEndDate());
  				testPd.put("NAME", testPaper.getName());
  				testPd.put("TESTPAPER_ID", testPaperId);
91a745c9   孙向锦   完善后台功能
803
804
805
806
  				testPd.put("OTHER_SCORE", testPaper.getOtherScore());
  				testPd.put("HIGHT_SCORE", testPaper.getHighScore());
  				testPd.put("LOW_SCORE", testPaper.getLowScore());
  				testPd.put("AVG_SCORE", testPaper.getAvgScore());
03a14c0e   孙向锦   更新报表
807
  				testPd.put("TOTAL_SCORE", testPaper.getTotalScore());
91a745c9   孙向锦   完善后台功能
808
809
810
  				testPd.put("REMARK", testPaper.getRemark());
  				testpaperService.save(testPd);
  				if (testPaper.getStudents() != null) {
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
811
812
  					List<PageData> testInfoPdList = new ArrayList();
  					PageData testInfoPd = null;
91a745c9   孙向锦   完善后台功能
813
814
815
  					for (StudentAnswer studentAnswer : testPaper.getStudents()) {
  						if (studentAnswer.getQuestions() != null) {
  							PageData studentPageData = new PageData();
91a745c9   孙向锦   完善后台功能
816
817
818
819
820
821
822
823
824
  							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());
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
825
  							studentPageData.put("STUDENTTEST_ID", get32UUID());
91a745c9   孙向锦   完善后台功能
826
827
828
829
  							studenttestService.save(studentPageData);
  
  							for (TestPaperInfo testPaperInfo : studentAnswer
  									.getQuestions()) {
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
830
  								testInfoPd = new PageData();
91a745c9   孙向锦   完善后台功能
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
  								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());
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
848
849
850
  								testInfoPd.put("ANSWER_TYPE", testPaperInfo
  										.getAnswerType() == null ? "1"
  										: testPaperInfo.getAnswerType());
91a745c9   孙向锦   完善后台功能
851
852
853
854
855
856
857
858
859
  								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());
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
860
  								testInfoPdList.add(testInfoPd);
91a745c9   孙向锦   完善后台功能
861
862
863
  							}
  						}
  					}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
864
  					testpaperinfoService.batchSave(testInfoPdList);
91a745c9   孙向锦   完善后台功能
865
866
867
868
869
870
871
872
873
874
  				}
  				res.setData(testPaperId);
  			} catch (Exception e) {
  				e.printStackTrace();
  				res.setError();
  				res.setMessage(e.getMessage());
  			}
  		} else {
  			res.setDataError();
  		}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
875
876
  		logger.info("uploadtestpaper cost time:"
  				+ (System.currentTimeMillis() - cur));
91a745c9   孙向锦   完善后台功能
877
878
879
880
881
882
883
884
885
  
  		return res.toJson();
  
  	}
  
  	// 下载测验成绩
  	@RequestMapping(value = "/downloadtestpaper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object downloadTestpaper() {
3371dbc6   孙向锦   0720 版本
886
  		event("downloadTestpaper");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
887
  		long cur = System.currentTimeMillis();
91a745c9   孙向锦   完善后台功能
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
  		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();
  			}
  		}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
963
  		logger.info("downloadtestpaper cost time:" + (System.currentTimeMillis() - cur));
338594c8   孙向锦   添加教师端页面
964
  		return res.toJson();
91a745c9   孙向锦   完善后台功能
965
  
338594c8   孙向锦   添加教师端页面
966
967
  	}
  
91a745c9   孙向锦   完善后台功能
968
969
970
971
  	// 下载测验成绩
  	@RequestMapping(value = "/testpaper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object testpaper() {
3371dbc6   孙向锦   0720 版本
972
  		event("testpaper");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
973
  		long cur = System.currentTimeMillis();
91a745c9   孙向锦   完善后台功能
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
  		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();
  		}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1005
  		logger.info("testpaper cost time:" + (System.currentTimeMillis() - cur));
91a745c9   孙向锦   完善后台功能
1006
1007
1008
  		return res.toJson();
  
  	}
4fd2e08c   孙向锦   修复接口中的bug
1009
1010
1011
1012
1013
  	
  	
  	@RequestMapping(value = "/schooladmin", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public void schoolAdmin(){
3371dbc6   孙向锦   0720 版本
1014
  		event("schoolAdmin");
4fd2e08c   孙向锦   修复接口中的bug
1015
1016
  		PageData pd = this.getPageData();
  		this.getUserID();
4fd2e08c   孙向锦   修复接口中的bug
1017
1018
  	}
  	
9338b563   孙向锦   添加报表
1019
1020
1021
1022
  	
  	@RequestMapping(value = "/network", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object network() throws Exception{
3371dbc6   孙向锦   0720 版本
1023
  		event("network");
9338b563   孙向锦   添加报表
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
  		PageData pd = this.getPageData();
  		ResponseGson<PageData> res = new ResponseGson();
  		PageData spd = networkstatisticsService.findByClientID(pd);
  		String seqStr = pd.getString("SEQ");
  		if (seqStr != null && pd.getString("CLIENT_ID") != null
  				&& pd.getString("SESSION_ID") != null) {
  			int seq = Integer.parseInt(seqStr);
  			if (spd != null) {
  				int successCount = Integer.parseInt(spd
  						.getString("SUCCESS_COUNT"));
  				spd.put("SUCCESS_COUNT", ++successCount + "");
  				int fail = seq - successCount;
  				if(fail < 0 ){
  					fail = 0;
  				}
  				spd.put("FAIL_COUNT", fail + "");
  				networkstatisticsService.edit(spd);
  				spd.remove("NETWORKSTATISTICS_ID");
  				spd.remove("CLIENT_ID");
  				spd.remove("SESSION_ID");
  				res.setData(spd);
  			} else {
  				pd.put("NETWORKSTATISTICS_ID", get32UUID());
  				pd.put("SUCCESS_COUNT", "1");
  				pd.put("CLIENT_IP", getRemoteIp());
  				int fail = seq - 1;
  				if(fail < 0 ){
  					fail = 0;
  				}
  				pd.put("FAIL_COUNT", fail + "");
  				networkstatisticsService.save(pd);
  				pd.remove("JSON");
  				pd.remove("CLIENT_ID");
  				pd.remove("SESSION_ID");
  				pd.remove("SEQ");
  				pd.remove("NETWORKSTATISTICS_ID");
  				res.setData(pd);
  			}
  		}else{
  			res.setDataError();
  		}
  		return res.toJson();
  	}
  	
  	
  	public String getRemoteIp(){
  		HttpServletRequest request = getRequest();
  		String ip = "";
  		if (request.getHeader("x-forwarded-for") == null) {
  			ip = request.getRemoteAddr();
  		} else {
  			ip = request.getHeader("x-forwarded-for");
  		}
  		return ip;
  	}
  	
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1080
1081
1082
  	@RequestMapping(value = "/newversion", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object getNewVersion(HttpServletRequest request) throws Exception{
3371dbc6   孙向锦   0720 版本
1083
  		event("getNewVersion");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
  		PageData pd = this.getPageData();
  		String softId = pd.getString("SOFTID");
  		String path = request.getContextPath();
  		String basePath = request.getScheme() + "://"
  				+ request.getServerName() + ":" + request.getServerPort()
  				+ path + "/";
  		ResponseGson<PageData> res = new ResponseGson();
  		if(softId != null && !"".equals(softId)){
  			pd.put("SOFTWARE_ID", softId);
  			PageData result = softwareversionService.findNewVersion(pd);
  			if(result != null){
  				result.remove("SOFTWAREVERSION_ID");
  				result.remove("SOFTWARE_ID");
9452be31   孙向锦   添加高斯的客户反馈
1097
  				result.put("VERSION_PATH",basePath + "uploadFiles/uploadFile/" + result.getString("VERSION_PATH"));
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
  				res.setData(result);
  			}else{
  				res.setDataError();
  			}
  		}else{
  			res.setDataError();
  		}
  		return res.toJson();
  	}
  	
d3d7b2ca   孙向锦   修改表格固定
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
  	@RequestMapping(value = "/tempcreateUser", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object tempCreateUser() throws Exception{
  		PageData pd = new PageData();
  		pd = this.getPageData();
  		pd.put("ID", this.get32UUID());
  		teacherService.save(pd);
  		pd.put("USER_ID", pd.getString("ID"));	//ID 主键
  		pd.put("LAST_LOGIN", "");				//最后登录时间
  		pd.put("IP", "");						//IP
  		pd.put("STATUS", "0");					//状态
  		pd.put("SKIN", "default");
  		pd.put("RIGHTS", "");		
  		pd.put("USERNAME", pd.getString("ACCOUT"));
  		pd.put("ROLE_ID", "57bb1e6f138247a0b05cc721a5da1b64");		
  		pd.put("PASSWORD", new SimpleHash("SHA-1", pd.getString("ACCOUT"), pd.getString("PASSWORD")).toString());	//密码加密
  		
  		if(null == userService.findByUsername(pd)){	//判断用户名是否存在
  			userService.saveU(pd); 					//执行保存
  		}
  		
  		//ID, TEACHER_ID, CLASS_ID, SUBJECT_ID, START_DATE, END_DATE, GRADE_ID, TERM_ID, REMARK
  		pd.put("TEACHER_ID", pd.get("ID"));
  		pd.put("CLASS_ID", "bc33389101ec46e6b7d47daa8adf58ac");
  		pd.put("SUBJECT_ID", "1");
  		pd.put("GRADE_ID", "1");
  		pd.put("TERM_ID","0d8ea2efdef74accbd0d00e9bc07dfbb");
  		coursemanagementService.save(pd);
  		
  		return "{'res':'success'}";
  	}
  	
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1140
1141
  	
  
3371dbc6   孙向锦   0720 版本
1142
1143
1144
1145
1146
  	private void event(String apiName){
  		PageData eventPd = new PageData();
  		eventPd.put("EVENT_ID", get32UUID());
  		eventPd.put("EVENT_NAME", apiName);
  		eventPd.put("EVENT_USER", getUsername());
67dfaf5c   孙向锦   提交代码
1147
  		eventPd.put("EVENT_TYPE", "-1");
3371dbc6   孙向锦   0720 版本
1148
1149
1150
1151
1152
1153
1154
1155
1156
  		eventPd.put("EVENT_START_TIME", Tools.date2Str(new Date()));
  		eventPd.put("CLIENT_ID", "SERVER");
  		eventPd.put("EVENT_IP", getRemoteIp());
  		try{
  			eventService.save(eventPd);
  		}catch(Exception e){
  			
  		}
  	}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1157
  	
bed6e1fc   孙向锦   添加其他功能
1158
  }