Blame view

src/com/fh/controller/api/V1.java 63.5 KB
bed6e1fc   孙向锦   添加其他功能
1
2
  package com.fh.controller.api;
  
338594c8   孙向锦   添加教师端页面
3
  import java.util.ArrayList;
bed6e1fc   孙向锦   添加其他功能
4
  import java.util.Date;
ce70231e   孙向锦   增加接口
5
  import java.util.Iterator;
bed6e1fc   孙向锦   添加其他功能
6
  import java.util.List;
ce70231e   孙向锦   增加接口
7
  import java.util.Map;
bed6e1fc   孙向锦   添加其他功能
8
9
  
  import javax.annotation.Resource;
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
10
  import javax.servlet.http.HttpServletRequest;
bed6e1fc   孙向锦   添加其他功能
11
  
338594c8   孙向锦   添加教师端页面
12
  import org.apache.commons.lang.StringUtils;
d3d7b2ca   孙向锦   修改表格固定
13
  import org.apache.shiro.crypto.hash.SimpleHash;
bed6e1fc   孙向锦   添加其他功能
14
  import org.springframework.stereotype.Controller;
bed6e1fc   孙向锦   添加其他功能
15
16
17
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.ResponseBody;
  
338594c8   孙向锦   添加教师端页面
18
  import com.fh.bean.Paper;
ce70231e   孙向锦   增加接口
19
  import com.fh.bean.Point;
338594c8   孙向锦   添加教师端页面
20
  import com.fh.bean.Question;
91a745c9   孙向锦   完善后台功能
21
22
23
  import com.fh.bean.StudentAnswer;
  import com.fh.bean.TestPaper;
  import com.fh.bean.TestPaperInfo;
bed6e1fc   孙向锦   添加其他功能
24
  import com.fh.controller.base.BaseController;
338594c8   孙向锦   添加教师端页面
25
  import com.fh.controller.sunvote.Myelfun;
bed6e1fc   孙向锦   添加其他功能
26
27
28
29
  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   孙向锦   添加软件管理模块。对软件形成统一的管理
30
  import com.fh.service.software.softwareversion.SoftwareVersionManager;
9f161055   孙向锦   修改高斯客户反馈
31
  import com.fh.service.sunvote.attachkeyboard.AttachKeyboardManager;
bed6e1fc   孙向锦   添加其他功能
32
  import com.fh.service.sunvote.basestation.BasestationManager;
ce70231e   孙向锦   增加接口
33
  import com.fh.service.sunvote.cache.CacheManager;
bed6e1fc   孙向锦   添加其他功能
34
35
36
37
38
  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   孙向锦   添加报表
39
  import com.fh.service.sunvote.event.EventManager;
bed6e1fc   孙向锦   添加其他功能
40
41
42
43
44
  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   孙向锦   添加报表
45
  import com.fh.service.sunvote.networkstatistics.NetworkStatisticsManager;
bed6e1fc   孙向锦   添加其他功能
46
47
48
49
50
51
52
53
54
55
  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   孙向锦   完善后台功能
56
  import com.fh.service.sunvote.studenttest.StudentTestManager;
bed6e1fc   孙向锦   添加其他功能
57
58
  import com.fh.service.sunvote.subject.SubjectManager;
  import com.fh.service.sunvote.teacher.TeacherManager;
ce70231e   孙向锦   增加接口
59
  import com.fh.service.sunvote.teachingmaterial.TeachingMaterialManager;
91a745c9   孙向锦   完善后台功能
60
  import com.fh.service.sunvote.testpaper.TestPaperManager;
bed6e1fc   孙向锦   添加其他功能
61
  import com.fh.service.sunvote.testpaperinfo.TestPaperInfoManager;
d3d7b2ca   孙向锦   修改表格固定
62
  import com.fh.service.system.user.UserManager;
bed6e1fc   孙向锦   添加其他功能
63
64
65
66
67
68
  import com.fh.util.PageData;
  import com.fh.util.Tools;
  
  @Controller
  @RequestMapping(value = "/api/v1")
  public class V1 extends BaseController {
91a745c9   孙向锦   完善后台功能
69
  
bed6e1fc   孙向锦   添加其他功能
70
71
72
73
74
  	@Resource(name = "schoolService")
  	private SchoolManager schoolService;
  
  	@Resource(name = "basestationService")
  	private BasestationManager basestationService;
91a745c9   孙向锦   完善后台功能
75
76
  
  	@Resource(name = "chapterService")
bed6e1fc   孙向锦   添加其他功能
77
  	private ChapterManager chapterService;
91a745c9   孙向锦   完善后台功能
78
79
  
  	@Resource(name = "classbasetationService")
bed6e1fc   孙向锦   添加其他功能
80
  	private ClassBasetationManager classbasetationService;
91a745c9   孙向锦   完善后台功能
81
82
  
  	@Resource(name = "classrosterService")
bed6e1fc   孙向锦   添加其他功能
83
  	private ClassRosterManager classrosterService;
91a745c9   孙向锦   完善后台功能
84
85
  
  	@Resource(name = "classtypeService")
bed6e1fc   孙向锦   添加其他功能
86
  	private ClassTypeManager classtypeService;
91a745c9   孙向锦   完善后台功能
87
88
  
  	@Resource(name = "gradeService")
bed6e1fc   孙向锦   添加其他功能
89
  	private GradeManager gradeService;
91a745c9   孙向锦   完善后台功能
90
91
  
  	@Resource(name = "coursemanagementService")
bed6e1fc   孙向锦   添加其他功能
92
93
94
95
  	private CourseManagementManager coursemanagementService;
  
  	@Resource(name = "keypadService")
  	private KeypadManager keypadService;
91a745c9   孙向锦   完善后台功能
96
97
  
  	@Resource(name = "keypadcheckService")
bed6e1fc   孙向锦   添加其他功能
98
  	private KeypadCheckManager keypadcheckService;
91a745c9   孙向锦   完善后台功能
99
100
  
  	@Resource(name = "knowledgeService")
bed6e1fc   孙向锦   添加其他功能
101
  	private KnowledgeManager knowledgeService;
91a745c9   孙向锦   完善后台功能
102
103
  
  	@Resource(name = "knowledgechapterService")
bed6e1fc   孙向锦   添加其他功能
104
  	private KnowledgeChapterManager knowledgechapterService;
91a745c9   孙向锦   完善后台功能
105
106
  
  	@Resource(name = "paperService")
bed6e1fc   孙向锦   添加其他功能
107
  	private PaperManager paperService;
91a745c9   孙向锦   完善后台功能
108
109
  
  	@Resource(name = "paperclassteacherService")
bed6e1fc   孙向锦   添加其他功能
110
  	private PaperClassTeacherManager paperclassteacherService;
91a745c9   孙向锦   完善后台功能
111
112
  
  	@Resource(name = "paperquestionService")
bed6e1fc   孙向锦   添加其他功能
113
  	private PaperQuestionManager paperquestionService;
91a745c9   孙向锦   完善后台功能
114
115
  
  	@Resource(name = "papertypeService")
bed6e1fc   孙向锦   添加其他功能
116
  	private PaperTypeManager papertypeService;
91a745c9   孙向锦   完善后台功能
117
118
  
  	@Resource(name = "questionService")
bed6e1fc   孙向锦   添加其他功能
119
  	private QuestionManager questionService;
91a745c9   孙向锦   完善后台功能
120
121
  
  	@Resource(name = "questiontypeService")
bed6e1fc   孙向锦   添加其他功能
122
  	private QuestionTypeManager questiontypeService;
91a745c9   孙向锦   完善后台功能
123
124
  
  	@Resource(name = "schoolgradesubjectService")
bed6e1fc   孙向锦   添加其他功能
125
  	private SchoolGradeSubjectManager schoolgradesubjectService;
91a745c9   孙向锦   完善后台功能
126
127
  
  	@Resource(name = "sclassService")
bed6e1fc   孙向锦   添加其他功能
128
  	private SClassManager sclassService;
91a745c9   孙向锦   完善后台功能
129
130
  
  	@Resource(name = "studentService")
bed6e1fc   孙向锦   添加其他功能
131
  	private StudentManager studentService;
91a745c9   孙向锦   完善后台功能
132
133
  
  	@Resource(name = "subjectService")
bed6e1fc   孙向锦   添加其他功能
134
  	private SubjectManager subjectService;
91a745c9   孙向锦   完善后台功能
135
136
  
  	@Resource(name = "teacherService")
bed6e1fc   孙向锦   添加其他功能
137
  	private TeacherManager teacherService;
91a745c9   孙向锦   完善后台功能
138
139
  
  	@Resource(name = "testpaperinfoService")
bed6e1fc   孙向锦   添加其他功能
140
141
  	private TestPaperInfoManager testpaperinfoService;
  
91a745c9   孙向锦   完善后台功能
142
143
144
145
146
147
  	@Resource(name = "testpaperService")
  	private TestPaperManager testpaperService;
  
  	@Resource(name = "studenttestService")
  	private StudentTestManager studenttestService;
  
bed6e1fc   孙向锦   添加其他功能
148
149
150
151
152
  	@Resource(name = "feedbackService")
  	private FeedbackManager feedbackService;
  
  	@Resource(name = "problemphenomenonService")
  	private ProblemPhenomenonManager problemphenomenonService;
91a745c9   孙向锦   完善后台功能
153
  
bed6e1fc   孙向锦   添加其他功能
154
  	@Resource(name = "v1Service")
91a745c9   孙向锦   完善后台功能
155
  	private V1Manager v1Service;
ce70231e   孙向锦   增加接口
156
157
  
  	@Resource(name = "softwareversionService")
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
158
  	private SoftwareVersionManager softwareversionService;
ce70231e   孙向锦   增加接口
159
160
  
  	@Resource(name = "attachkeyboardService")
9f161055   孙向锦   修改高斯客户反馈
161
  	private AttachKeyboardManager attachkeyboardService;
ce70231e   孙向锦   增加接口
162
163
  
  	@Resource(name = "networkstatisticsService")
9338b563   孙向锦   添加报表
164
  	private NetworkStatisticsManager networkstatisticsService;
ce70231e   孙向锦   增加接口
165
166
  
  	@Resource(name = "eventService")
9338b563   孙向锦   添加报表
167
  	private EventManager eventService;
ce70231e   孙向锦   增加接口
168
169
  
  	@Resource(name = "userService")
d3d7b2ca   孙向锦   修改表格固定
170
  	private UserManager userService;
91a745c9   孙向锦   完善后台功能
171
  
ce70231e   孙向锦   增加接口
172
173
  	@Resource(name = "teachingmaterialService")
  	private TeachingMaterialManager teachingmaterialService;
2ad7ca45   孙向锦   试卷bug修改
174
175
  
  	@Resource(name = "cacheService")
ce70231e   孙向锦   增加接口
176
177
  	private CacheManager cacheService;
  
2ad7ca45   孙向锦   试卷bug修改
178
179
180
181
182
183
184
  	/**
  	 * 登录
  	 * 可以通过账号密码登录、
  	 * 可以通过教师卡登录
  	 * @return
  	 * @throws Exception
  	 */
bed6e1fc   孙向锦   添加其他功能
185
186
187
  	@RequestMapping(value = "/login", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object login() throws Exception {
3371dbc6   孙向锦   0720 版本
188
  		event("apilogin");
bed6e1fc   孙向锦   添加其他功能
189
190
  		PageData pd = this.getPageData();
  		ResponseGson<PageData> res = new ResponseGson();
91a745c9   孙向锦   完善后台功能
191
  		if (!pd.containsKey("ACCOUT")) {
bed6e1fc   孙向锦   添加其他功能
192
193
  			pd.put("ACCOUT", pd.get("USERNAME"));
  		}
ce70231e   孙向锦   增加接口
194
195
196
  		if (((pd.containsKey("USERNAME") || (pd.containsKey("ACCOUT") && pd
  				.get("ACCOUT") != null)) && pd.containsKey("PASSWORD"))
  				|| pd.containsKey("KEYPAD_ID")) {
bed6e1fc   孙向锦   添加其他功能
197
  			PageData pageData = teacherService.getUserInfo(pd);
91a745c9   孙向锦   完善后台功能
198
199
  			if (pageData != null && pageData.getString("ID") != null) {
  				pageData.put("PASSWORD", "");// 返回参数中不返回密码
bed6e1fc   孙向锦   添加其他功能
200
201
202
  				PageData pt = new PageData();
  				pt.put("TEACHER_ID", pageData.get("ID"));
  				// 在任课表中查找老师教哪些班级,然后查出班级信息
91a745c9   孙向锦   完善后台功能
203
204
205
  				List<PageData> classInfoList = v1Service
  						.getTeacherClassInfo(pt);
  
bed6e1fc   孙向锦   添加其他功能
206
207
  				pageData.put("classInfoList", classInfoList);
  				// 在认可表中查找老师教哪些科目,然后查出科目信息
91a745c9   孙向锦   完善后台功能
208
209
  				List<PageData> subjectList = v1Service
  						.getTeacherSubjectInfo(pt);
bed6e1fc   孙向锦   添加其他功能
210
211
  				// 一个sql语句完成。
  				pageData.put("subjectList", subjectList);
91a745c9   孙向锦   完善后台功能
212
  
bed6e1fc   孙向锦   添加其他功能
213
  				pageData.remove("SUBJECT_IDS");
ce70231e   孙向锦   增加接口
214
  
9338b563   孙向锦   添加报表
215
216
217
218
219
  				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");
ce70231e   孙向锦   增加接口
220
221
  				eventPd.put("EVENT_START_TIME", Tools.date2Str(new Date()));
  				if (pd.getString("CLIENT_ID") != null) {
9338b563   孙向锦   添加报表
222
  					eventPd.put("CLIENT_ID", pd.getString("CLIENT_ID"));
ce70231e   孙向锦   增加接口
223
  				} else {
9338b563   孙向锦   添加报表
224
225
  					eventPd.put("CLIENT_ID", "CLIENT");
  				}
ce70231e   孙向锦   增加接口
226
  				eventPd.put("EVENT_IP", getRemoteIp());
9338b563   孙向锦   添加报表
227
  				eventService.save(eventPd);
91a745c9   孙向锦   完善后台功能
228
  
bed6e1fc   孙向锦   添加其他功能
229
230
  				res.setData(pageData);
  				// 填充数据到返回数据中
91a745c9   孙向锦   完善后台功能
231
  			} else {
bed6e1fc   孙向锦   添加其他功能
232
233
  				res.set1Error();
  			}
91a745c9   孙向锦   完善后台功能
234
  		} else {
bed6e1fc   孙向锦   添加其他功能
235
236
  			res.set1Error();
  		}
91a745c9   孙向锦   完善后台功能
237
  
bed6e1fc   孙向锦   添加其他功能
238
239
  		return res.toJson();
  	}
91a745c9   孙向锦   完善后台功能
240
  
2ad7ca45   孙向锦   试卷bug修改
241
242
243
244
245
246
  	/**
  	 * 查询班级
  	 * 班级及班级学生详细信息
  	 * @return
  	 * @throws Exception
  	 */
bed6e1fc   孙向锦   添加其他功能
247
248
249
  	@RequestMapping(value = "/class", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object sclass() throws Exception {
3371dbc6   孙向锦   0720 版本
250
  		event("sclass");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
251
  		long cur = System.currentTimeMillis();
bed6e1fc   孙向锦   添加其他功能
252
  		PageData pd = this.getPageData();
bed6e1fc   孙向锦   添加其他功能
253
  		if (pd.containsKey("ID")) {
4fd2e08c   孙向锦   修复接口中的bug
254
  			ResponseGson<PageData> res = new ResponseGson();
bed6e1fc   孙向锦   添加其他功能
255
256
257
258
  			PageData pageData = sclassService.findById(pd);
  			if (pageData != null && pageData.containsKey("ID")) {
  				PageData pt = new PageData();
  				pt.put("SCLASS_ID", pageData.get("ID"));
91a745c9   孙向锦   完善后台功能
259
  				List<PageData> studentList = v1Service.getClassStudent(pt);
bed6e1fc   孙向锦   添加其他功能
260
  				pageData.put("studentList", studentList);
9f161055   孙向锦   修改高斯客户反馈
261
  				pt.put("CLASS_ID", pageData.get("ID"));
ce70231e   孙向锦   增加接口
262
263
  				List<PageData> keyboards = attachkeyboardService
  						.listAllClassId(pt);
9f161055   孙向锦   修改高斯客户反馈
264
  				pageData.put("keyboards", keyboards);
bed6e1fc   孙向锦   添加其他功能
265
266
267
268
  				res.setData(pageData);
  			} else {
  				res.set2Error();
  			}
ce70231e   孙向锦   增加接口
269
270
  			logger.info("class cost time : "
  					+ (System.currentTimeMillis() - cur));
4fd2e08c   孙向锦   修复接口中的bug
271
272
273
274
275
  			return res.toJson();
  		} else {
  			ResponseGson<List<PageData>> res = new ResponseGson();
  			List<PageData> list = sclassService.listAll(pd);
  			res.setData(list);
ce70231e   孙向锦   增加接口
276
277
  			logger.info("class cost time : "
  					+ (System.currentTimeMillis() - cur));
4fd2e08c   孙向锦   修复接口中的bug
278
  			return res.toJson();
4fd2e08c   孙向锦   修复接口中的bug
279
280
  		}
  	}
ce70231e   孙向锦   增加接口
281
  
2ad7ca45   孙向锦   试卷bug修改
282
283
284
285
286
  	/**
  	 * 问题类型
  	 * @return
  	 * @throws Exception
  	 */
4fd2e08c   孙向锦   修复接口中的bug
287
288
289
  	@RequestMapping(value = "/questiontype", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object questiontype() throws Exception {
3371dbc6   孙向锦   0720 版本
290
  		event("questiontype");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
291
  		long cur = System.currentTimeMillis();
4fd2e08c   孙向锦   修复接口中的bug
292
293
294
295
  		PageData pd = this.getPageData();
  		ResponseGson<List<PageData>> res = new ResponseGson();
  		List<PageData> list = questiontypeService.listAll(pd);
  		res.setData(list);
ce70231e   孙向锦   增加接口
296
297
  		logger.info("questiontype cost time : "
  				+ (System.currentTimeMillis() - cur));
4fd2e08c   孙向锦   修复接口中的bug
298
299
  		return res.toJson();
  	}
ce70231e   孙向锦   增加接口
300
  
2ad7ca45   孙向锦   试卷bug修改
301
302
303
304
305
  	/**
  	 * 班级类型
  	 * @return
  	 * @throws Exception
  	 */
4fd2e08c   孙向锦   修复接口中的bug
306
307
308
  	@RequestMapping(value = "/classtype", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object classtype() throws Exception {
3371dbc6   孙向锦   0720 版本
309
  		event("classtype");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
310
  		long cur = System.currentTimeMillis();
4fd2e08c   孙向锦   修复接口中的bug
311
312
313
314
  		PageData pd = this.getPageData();
  		ResponseGson<List<PageData>> res = new ResponseGson();
  		List<PageData> list = classtypeService.listAll(pd);
  		res.setData(list);
ce70231e   孙向锦   增加接口
315
316
  		logger.info("classtype cost time : "
  				+ (System.currentTimeMillis() - cur));
4fd2e08c   孙向锦   修复接口中的bug
317
318
  		return res.toJson();
  	}
ce70231e   孙向锦   增加接口
319
  
2ad7ca45   孙向锦   试卷bug修改
320
321
322
323
324
325
  	/**
  	 *  年级
  	 *  年级类型
  	 * @return
  	 * @throws Exception
  	 */
4fd2e08c   孙向锦   修复接口中的bug
326
327
328
  	@RequestMapping(value = "/grade", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object grade() throws Exception {
3371dbc6   孙向锦   0720 版本
329
  		event("grade");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
330
  		long cur = System.currentTimeMillis();
4fd2e08c   孙向锦   修复接口中的bug
331
332
333
334
335
  		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   孙向锦   完善后台功能
336
  		} else {
4fd2e08c   孙向锦   修复接口中的bug
337
338
  			List<PageData> list = schoolgradesubjectService.listAllGrade(pd);
  			res.setData(list);
bed6e1fc   孙向锦   添加其他功能
339
  		}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
340
  		logger.info("class cost time : " + (System.currentTimeMillis() - cur));
bed6e1fc   孙向锦   添加其他功能
341
342
  		return res.toJson();
  	}
ce70231e   孙向锦   增加接口
343
  
2ad7ca45   孙向锦   试卷bug修改
344
345
346
347
348
  	/**
  	 * 科目
  	 * @return
  	 * @throws Exception
  	 */
4fd2e08c   孙向锦   修复接口中的bug
349
350
351
  	@RequestMapping(value = "/subject", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object subject() throws Exception {
3371dbc6   孙向锦   0720 版本
352
  		event("subject");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
353
  		long cur = System.currentTimeMillis();
4fd2e08c   孙向锦   修复接口中的bug
354
355
356
357
358
359
360
361
362
  		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   孙向锦   添加软件管理模块。对软件形成统一的管理
363
  		logger.info("subject cost time : " + (System.currentTimeMillis() - cur));
4fd2e08c   孙向锦   修复接口中的bug
364
365
  		return res.toJson();
  	}
91a745c9   孙向锦   完善后台功能
366
  
2ad7ca45   孙向锦   试卷bug修改
367
368
369
370
371
  	/**
  	 * 键盘扫描
  	 * @return
  	 * @throws Exception
  	 */
bed6e1fc   孙向锦   添加其他功能
372
373
374
  	@RequestMapping(value = "/keypadscan", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object keypadScan() throws Exception {
3371dbc6   孙向锦   0720 版本
375
  		event("keypadScan");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
376
  		long cur = System.currentTimeMillis();
bed6e1fc   孙向锦   添加其他功能
377
  		PageData pd = this.getPageData();
91a745c9   孙向锦   完善后台功能
378
379
380
381
382
  		ResponseGson<String> res = new ResponseGson();
  		String ID = get32UUID();
  		pd.put("KEYPADCHECK_ID", ID); // 主键
  		pd.put("CREATE_DATE", Tools.date2Str(new Date())); // 创建时间
  		try {
bed6e1fc   孙向锦   添加其他功能
383
  			keypadcheckService.save(pd);
91a745c9   孙向锦   完善后台功能
384
  			res.setData(ID);
bed6e1fc   孙向锦   添加其他功能
385
  			res.setSuccess();
91a745c9   孙向锦   完善后台功能
386
  		} catch (Exception ex) {
bed6e1fc   孙向锦   添加其他功能
387
388
  			res.setDataError();
  		}
ce70231e   孙向锦   增加接口
389
390
  		logger.info("keypadScan cost time : "
  				+ (System.currentTimeMillis() - cur));
bed6e1fc   孙向锦   添加其他功能
391
392
  		return res.toJson();
  	}
91a745c9   孙向锦   完善后台功能
393
  
2ad7ca45   孙向锦   试卷bug修改
394
395
396
397
398
399
  	/**
  	 * showcount 数量 currentpage 当前页码
  	 * 
  	 * @return
  	 * @throws Exception
  	 */
bed6e1fc   孙向锦   添加其他功能
400
401
402
  	@RequestMapping(value = "/paper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object paper() throws Exception {
3371dbc6   孙向锦   0720 版本
403
  		event("paper");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
404
  		long cur = System.currentTimeMillis();
bed6e1fc   孙向锦   添加其他功能
405
406
  		PageData pd = this.getPageData();
  		ResponseGson<List<PageData>> res = new ResponseGson<List<PageData>>();
91a745c9   孙向锦   完善后台功能
407
  		if (pd.containsKey("PAPER_TYPE") && pd.containsKey("USER_ID")) {
bed6e1fc   孙向锦   添加其他功能
408
409
410
  			Page page = new Page();
  			page.getPd().put("PAPER_TYPE", pd.get("PAPER_TYPE"));
  			page.getPd().put("USER_ID", pd.get("USER_ID"));
f8d83f1f   孙向锦   添加学校界面
411
  			page.getPd().put("SUBJECT_ID", pd.get("SUBJECT_ID"));
91a745c9   孙向锦   完善后台功能
412
  			if (pd.containsKey("CURRENTPAGE")) {
bed6e1fc   孙向锦   添加其他功能
413
  				String curpage = pd.getString("CURRENTPAGE");
91a745c9   孙向锦   完善后台功能
414
  				try {
bed6e1fc   孙向锦   添加其他功能
415
  					page.setCurrentPage(Integer.parseInt(curpage));
91a745c9   孙向锦   完善后台功能
416
417
  				} catch (Exception ex) {
  				}
bed6e1fc   孙向锦   添加其他功能
418
  			}
91a745c9   孙向锦   完善后台功能
419
  			if (pd.containsKey("SHOWCOUNT")) {
bed6e1fc   孙向锦   添加其他功能
420
  				String showCount = pd.getString("SHOWCOUNT");
91a745c9   孙向锦   完善后台功能
421
  				try {
bed6e1fc   孙向锦   添加其他功能
422
  					page.setShowCount(Integer.parseInt(showCount));
91a745c9   孙向锦   完善后台功能
423
424
425
  				} catch (Exception ex) {
  				}
  			} else {
bed6e1fc   孙向锦   添加其他功能
426
427
428
429
  				page.setShowCount(100);
  			}
  			List<PageData> pageList = paperService.listAllByType(page);
  			res.setData(pageList);
91a745c9   孙向锦   完善后台功能
430
  		} else {
338594c8   孙向锦   添加教师端页面
431
  			res.setParmError();
bed6e1fc   孙向锦   添加其他功能
432
  		}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
433
  		logger.info("paper cost time : " + (System.currentTimeMillis() - cur));
bed6e1fc   孙向锦   添加其他功能
434
435
  		return res.toJson();
  	}
91a745c9   孙向锦   完善后台功能
436
  
2ad7ca45   孙向锦   试卷bug修改
437
438
439
440
441
  	/**
  	 * 试卷详细信息
  	 * @return
  	 * @throws Exception
  	 */
91a745c9   孙向锦   完善后台功能
442
  	@RequestMapping(value = "/paperinfo", produces = "application/json;charset=UTF-8")
bed6e1fc   孙向锦   添加其他功能
443
  	@ResponseBody
91a745c9   孙向锦   完善后台功能
444
  	public Object paperInfo() throws Exception {
3371dbc6   孙向锦   0720 版本
445
  		event("paperInfo");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
446
  		long cur = System.currentTimeMillis();
bed6e1fc   孙向锦   添加其他功能
447
  		PageData pd = this.getPageData();
338594c8   孙向锦   添加教师端页面
448
  		ResponseGson<Paper> res = new ResponseGson<Paper>();
91a745c9   孙向锦   完善后台功能
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
  		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
485
  							question.setScore(qpd.getString("SCORE"));
ce70231e   孙向锦   增加接口
486
487
488
  							question.setPart_score(qpd.getString("PART_SCORE"));
  							question.setQuestionType(qpd
  									.getString("PROBLEM_TYPE_ID"));
91a745c9   孙向锦   完善后台功能
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
  							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
516
  									qq.setScore(q.getString("SCORE"));
ce70231e   孙向锦   增加接口
517
518
519
  									qq.setPart_score(q.getString("PART_SCORE"));
  									qq.setQuestionType(qpd
  											.getString("PROBLEM_TYPE_ID"));
91a745c9   孙向锦   完善后台功能
520
521
522
523
524
525
526
527
528
  									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   孙向锦   添加教师端页面
529
  						}
91a745c9   孙向锦   完善后台功能
530
531
532
533
  						// pd.put("JSON", paper.toJson());
  						res.setData(paper);
  						logger.info(paper.toJson());
  
338594c8   孙向锦   添加教师端页面
534
  					}
91a745c9   孙向锦   完善后台功能
535
536
  				} catch (Exception ex) {
  					ex.printStackTrace();
338594c8   孙向锦   添加教师端页面
537
  				}
91a745c9   孙向锦   完善后台功能
538
  			} catch (Exception ex) {
338594c8   孙向锦   添加教师端页面
539
540
  				ex.printStackTrace();
  				res.setError();
bed6e1fc   孙向锦   添加其他功能
541
  			}
91a745c9   孙向锦   完善后台功能
542
  		} else {
bed6e1fc   孙向锦   添加其他功能
543
544
  			res.setOtherError();
  		}
ce70231e   孙向锦   增加接口
545
546
  		logger.info("paperInfo cost time : "
  				+ (System.currentTimeMillis() - cur));
bed6e1fc   孙向锦   添加其他功能
547
548
  		return res.toJson();
  	}
91a745c9   孙向锦   完善后台功能
549
  
2ad7ca45   孙向锦   试卷bug修改
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
  	/**
  	 * 试卷简要信息
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/paperbriefinfo", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object paperBriefInfo() throws Exception {
  		event("paperBriefInfo");
  		long cur = System.currentTimeMillis();
  		PageData pd = this.getPageData();
  		ResponseGson<Paper> res = new ResponseGson<Paper>();
  		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.setQuestion_id(qpd
  									.getString("QUESTION_ID"));
  							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.setQuestion_id(q
  											.getString("QUESTION_ID"));
  									question.getQuestions().add(qq);
  								}
  							}
  							if ("-1".equals(qpd.getString("P_ID"))
  									|| "0".equals(qpd.getString("P_ID"))) {
  								paper.getQuestions().add(question);
  							}
  						}
  						// pd.put("JSON", paper.toJson());
  						res.setData(paper);
  						logger.info(paper.toJson());
  
  					}
  				} catch (Exception ex) {
  					ex.printStackTrace();
  				}
  			} catch (Exception ex) {
  				ex.printStackTrace();
  				res.setError();
  			}
  		} else {
  			res.setOtherError();
  		}
  		logger.info("paperInfo cost time : "
  				+ (System.currentTimeMillis() - cur));
  		return res.toBrifJson();
  	}
  
  	
  	/**
  	 * 试卷问题
  	 * @return
  	 * @throws Exception
  	 */
bed6e1fc   孙向锦   添加其他功能
627
628
629
  	@RequestMapping(value = "/paperquestion", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object paperQuestion() throws Exception {
3371dbc6   孙向锦   0720 版本
630
  		event("paperQuestion");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
631
  		long cur = System.currentTimeMillis();
bed6e1fc   孙向锦   添加其他功能
632
633
  		PageData pd = this.getPageData();
  		ResponseGson<PageData> res = new ResponseGson();
ce70231e   孙向锦   增加接口
634
635
  		logger.info("paperquestion cost time : "
  				+ (System.currentTimeMillis() - cur));
bed6e1fc   孙向锦   添加其他功能
636
637
  		return res.toJson();
  	}
ce70231e   孙向锦   增加接口
638
  
2ad7ca45   孙向锦   试卷bug修改
639
640
641
642
643
  	/**
  	 * 问题
  	 * @return
  	 * @throws Exception
  	 */
4fd2e08c   孙向锦   修复接口中的bug
644
645
646
  	@RequestMapping(value = "/question", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object question() throws Exception {
3371dbc6   孙向锦   0720 版本
647
  		event("question");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
648
  		long cur = System.currentTimeMillis();
4fd2e08c   孙向锦   修复接口中的bug
649
  		PageData pd = this.getPageData();
2ad7ca45   孙向锦   试卷bug修改
650
651
  		ResponseGson<List<PageData>> res = new ResponseGson();
  		List<PageData> list = new ArrayList<PageData>();
ce70231e   孙向锦   增加接口
652
  		if (pd.containsKey("ID")) {
2ad7ca45   孙向锦   试卷bug修改
653
654
655
656
657
658
659
660
661
662
  			String ids = pd.getString("ID");
  			String[] id = ids.split(",");
  			for (String i : id) {
  				pd.put("QUESTION_ID", i);
  				PageData data = questionService.findById(pd);
  				if (data != null) {
  					list.add(data);
  				}
  			}
  			res.setData(list);
ce70231e   孙向锦   增加接口
663
  		} else {
4fd2e08c   孙向锦   修复接口中的bug
664
665
  			res.setDataError();
  		}
ce70231e   孙向锦   增加接口
666
667
  		logger.info("question cost time : "
  				+ (System.currentTimeMillis() - cur));
4fd2e08c   孙向锦   修复接口中的bug
668
669
  		return res.toJson();
  	}
ce70231e   孙向锦   增加接口
670
  
2ad7ca45   孙向锦   试卷bug修改
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
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
  	/**
  	 * 查询知识点名称
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/knowledgename", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object knowledgename() throws Exception {
  		ResponseGson<List<PageData>> res = new ResponseGson();
  		List<PageData> list = new ArrayList<PageData>();
  		PageData pd = getPageData();
  		if (pd.get("ID") != null) {
  			String ids = pd.getString("ID");
  			String[] id = ids.split(",");
  			for (String i : id) {
  				pd.put("KNOWLEDGE_ID", i);
  				PageData data = knowledgeService.findById(pd);
  				if (data != null) {
  					PageData t = new PageData();
  					t.put("KNOWLEDGE_ID", data.get("KNOWLEDGE_ID"));
  					t.put("NAME", data.get("NAME"));
  					list.add(t);
  				}
  			}
  			res.setData(list);
  		}
  		;
  		return res;
  	}
  
  	/**
  	 * 章节名称
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/chaptername", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object chaptername() throws Exception {
  		ResponseGson<List<PageData>> res = new ResponseGson();
  		List<PageData> list = new ArrayList<PageData>();
  		PageData pd = getPageData();
  		if (pd.get("ID") != null) {
  			String ids = pd.getString("ID");
  			String[] id = ids.split(",");
  			for (String i : id) {
  				pd.put("ID", i);
  				PageData data = chapterService.findById(pd);
  				if (data != null) {
  					PageData t = new PageData();
  					t.put("ID", data.get("ID"));
  					t.put("NAME", data.get("NAME"));
  					list.add(t);
  				}
  			}
  			res.setData(list);
  		}
  		;
  		return res;
  	}
  
  	/**
  	 * 试题添加
  	 * @return
  	 * @throws Exception
  	 */
4fd2e08c   孙向锦   修复接口中的bug
736
737
738
  	@RequestMapping(value = "/question/add", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object questionAdd() throws Exception {
3371dbc6   孙向锦   0720 版本
739
  		event("questionAdd");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
740
  		long cur = System.currentTimeMillis();
4fd2e08c   孙向锦   修复接口中的bug
741
742
743
744
  		PageData pd = this.getPageData();
  		ResponseGson<PageData> res = new ResponseGson();
  		pd.put("QUESTION_ID", this.get32UUID());
  		questionService.save(pd);
ce70231e   孙向锦   增加接口
745
746
  		logger.info("questionAdd cost time : "
  				+ (System.currentTimeMillis() - cur));
4fd2e08c   孙向锦   修复接口中的bug
747
748
  		return res.toJson();
  	}
ce70231e   孙向锦   增加接口
749
  
2ad7ca45   孙向锦   试卷bug修改
750
751
752
753
754
  	/***
  	 * 上传试卷
  	 * @return
  	 * @throws Exception
  	 */
338594c8   孙向锦   添加教师端页面
755
756
757
  	@RequestMapping(value = "/uploadpaper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object uploadpaper() throws Exception {
3371dbc6   孙向锦   0720 版本
758
  		event("uploadpaper");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
759
  		long cur = System.currentTimeMillis();
338594c8   孙向锦   添加教师端页面
760
761
  		PageData pd = this.getPageData();
  		ResponseGson<String> res = new ResponseGson();
91a745c9   孙向锦   完善后台功能
762
763
  
  		if (!StringUtils.isEmpty(pd.getJsonString())) {
4fd2e08c   孙向锦   修复接口中的bug
764
  			logger.info(pd.getJsonString());
338594c8   孙向锦   添加教师端页面
765
766
767
768
  			Paper paper = Paper.parse(pd.getJsonString());
  			PageData paperPd = new PageData();
  			String paperID = this.get32UUID();
  			res.setData(paperID);
91a745c9   孙向锦   完善后台功能
769
770
771
772
773
774
775
776
777
778
  			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   孙向锦   添加教师端页面
779
780
  			String schoolID = Myelfun.getUserID(paper.getUser_id());
  			paperPd.put("SCHOOL_ID", schoolID);
91a745c9   孙向锦   完善后台功能
781
782
783
  			paperPd.put("CREATE_DATE", Tools.date2Str(new Date()));
  			paperPd.put("MODIFY_DATE", Tools.date2Str(new Date()));
  
ce70231e   孙向锦   增加接口
784
  			int questionNum = 0;
91a745c9   孙向锦   完善后台功能
785
  
338594c8   孙向锦   添加教师端页面
786
  			List<Question> questions = paper.getQuestions();
91a745c9   孙向锦   完善后台功能
787
788
  			if (questions != null) {
  				for (Question question : questions) {
338594c8   孙向锦   添加教师端页面
789
790
791
  					String questionID = this.get32UUID();
  					PageData qPd = new PageData();
  					qPd.put("QUESTION_ID", questionID);
91a745c9   孙向锦   完善后台功能
792
793
  					if (question.getQuestions() != null
  							&& question.getQuestions().size() > 0) {
338594c8   孙向锦   添加教师端页面
794
  						qPd.put("P_ID", "-1");
91a745c9   孙向锦   完善后台功能
795
  					} else {
ce70231e   孙向锦   增加接口
796
  						questionNum++;
338594c8   孙向锦   添加教师端页面
797
798
799
800
  						qPd.put("P_ID", "0");
  					}
  					qPd.put("SUBJECT_ID", paper.getSubject_id());
  					qPd.put("CHAPTER_ID", question.getChapter_id());
ce70231e   孙向锦   增加接口
801
802
803
  					qPd.put("PROBLEM_TYPE_ID",
  							question.getProblem_type_id() == null ? "1"
  									: question.getProblem_type_id());
338594c8   孙向锦   添加教师端页面
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
  					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   孙向锦   完善后台功能
820
  
338594c8   孙向锦   添加教师端页面
821
  					PageData pqPd = new PageData();
91a745c9   孙向锦   完善后台功能
822
823
824
825
826
827
828
  					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   孙向锦   添加教师端页面
829
  					paperquestionService.save(pqPd);
91a745c9   孙向锦   完善后台功能
830
831
  
  					if (question.getQuestions() != null) {
338594c8   孙向锦   添加教师端页面
832
  						List<Question> qs = question.getQuestions();
91a745c9   孙向锦   完善后台功能
833
  						for (Question q : qs) {
338594c8   孙向锦   添加教师端页面
834
835
836
837
838
839
  							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());
ce70231e   孙向锦   增加接口
840
841
842
  							cqPd.put("PROBLEM_TYPE_ID", question
  									.getProblem_type_id() == null ? "1"
  									: question.getProblem_type_id());
338594c8   孙向锦   添加教师端页面
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
  							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   孙向锦   完善后台功能
858
  
338594c8   孙向锦   添加教师端页面
859
  							questionService.save(cqPd);
91a745c9   孙向锦   完善后台功能
860
  
338594c8   孙向锦   添加教师端页面
861
  							PageData cpqPd = new PageData();
91a745c9   孙向锦   完善后台功能
862
863
864
865
866
867
868
869
  							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   孙向锦   添加教师端页面
870
  							paperquestionService.save(cpqPd);
ce70231e   孙向锦   增加接口
871
  							questionNum++;
338594c8   孙向锦   添加教师端页面
872
873
874
875
  						}
  					}
  				}
  			}
4fd2e08c   孙向锦   修复接口中的bug
876
877
  			paperPd.put("QUESTION_NUM", "" + questionNum);
  			paperService.save(paperPd);
91a745c9   孙向锦   完善后台功能
878
879
  
  		} else {
338594c8   孙向锦   添加教师端页面
880
881
  			res.setDataError();
  		}
ce70231e   孙向锦   增加接口
882
883
884
885
886
  		logger.info("uploadpaper cost time : "
  				+ (System.currentTimeMillis() - cur));
  		return res.toJson();
  	}
  
2ad7ca45   孙向锦   试卷bug修改
887
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
  	/**
  	 * 上传试卷,不上传试题详细信息。试题从已有数据库中组卷
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/publishpaper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object publishPaper() throws Exception {
  		event("publishpaper");
  		long cur = System.currentTimeMillis();
  		PageData pd = this.getPageData();
  		ResponseGson<String> res = new ResponseGson();
  
  		if (!StringUtils.isEmpty(pd.getJsonString())) {
  			logger.info(pd.getJsonString());
  			Paper paper = Paper.parse(pd.getJsonString());
  			PageData paperPd = new PageData();
  			String paperID = this.get32UUID();
  			res.setData(paperID);
  			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", "");
  			String schoolID = Myelfun.getUserID(paper.getUser_id());
  			paperPd.put("SCHOOL_ID", schoolID);
  			paperPd.put("CREATE_DATE", Tools.date2Str(new Date()));
  			paperPd.put("MODIFY_DATE", Tools.date2Str(new Date()));
  			int questionNum = 0;
  			List<Question> questions = paper.getQuestions();
  			if (questions != null) {
  				for (Question question : questions) {
  					PageData pqPd = new PageData();
  					pqPd.put("PAPER_ID", paperID);
  					pqPd.put("QUESTION_ID", question.getQuestion_id());
  					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());
  					paperquestionService.save(pqPd);
  
  				}
  			}
  			paperPd.put("QUESTION_NUM", "" + questionNum);
  			paperService.save(paperPd);
  
  		} else {
  			res.setDataError();
  		}
  		logger.info("uploadpaper cost time : "
  				+ (System.currentTimeMillis() - cur));
  		return res.toJson();
  	}
  
  	/**
  	 * 上传知识点
  	 * @return
  	 * @throws Exception
  	 */
ce70231e   孙向锦   增加接口
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
  	@RequestMapping(value = "/uploadpoint", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object uploadpoint() throws Exception {
  		event("uploadpoint");
  		long cur = System.currentTimeMillis();
  		PageData pd = this.getPageData();
  		ResponseGson<String> res = new ResponseGson();
  
  		if (!StringUtils.isEmpty(pd.getJsonString())) {
  			try {
  				ResponseGson<List<Point>> req = ResponseGson.parse(
  						pd.getJsonString(), Point.class);
  				List<Point> list = req.getData();
  				if (list != null && list.size() > 0) {
  					for (Point point : list) {
  						savePoint(point, null);
  					}
  				}
  			} catch (Exception e) {
  				res.setError();
  			}
  		} else {
  			res.setDataError();
  		}
  		logger.info("uploadpoint cost time : "
  				+ (System.currentTimeMillis() - cur));
91a745c9   孙向锦   完善后台功能
978
979
980
  		return res.toJson();
  	}
  
2ad7ca45   孙向锦   试卷bug修改
981
982
983
984
  	/**
  	 *  上传测验成绩
  	 * @return
  	 */
91a745c9   孙向锦   完善后台功能
985
986
987
  	@RequestMapping(value = "/uploadtestpaper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object uploadTestpaper() {
3371dbc6   孙向锦   0720 版本
988
  		event("uploadTestpaper");
4fd2e08c   孙向锦   修复接口中的bug
989
  		long cur = System.currentTimeMillis();
91a745c9   孙向锦   完善后台功能
990
991
992
  		PageData pd = this.getPageData();
  		ResponseGson<String> res = new ResponseGson();
  		if (!StringUtils.isEmpty(pd.getJsonString())) {
4fd2e08c   孙向锦   修复接口中的bug
993
  			logger.info(pd.getJsonString());
91a745c9   孙向锦   完善后台功能
994
995
996
997
  			TestPaper testPaper = TestPaper.parse(pd.getJsonString());
  			try {
  				PageData testPd = new PageData();
  				String testPaperId = this.get32UUID();
91a745c9   孙向锦   完善后台功能
998
  				testPd.put("TEACHER_ID", testPaper.getTeacherId());
91a745c9   孙向锦   完善后台功能
999
1000
  				testPd.put("PAPER_ID", testPaper.getPaperId());
  				testPd.put("SCLASS_ID", testPaper.getClassId());
91a745c9   孙向锦   完善后台功能
1001
1002
1003
1004
1005
  				testPd.put(
  						"CREATE_DATE",
  						testPaper.getCreateDate() == null ? Tools
  								.date2Str(new Date()) : testPaper
  								.getCreateDate());
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
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
  				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);
  					}
ce70231e   孙向锦   增加接口
1080
  				} else {
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
  					testPaperId = listData.get(0).getString("TESTPAPER_ID");
  				}
  				res.setData(testPaperId);
  			} catch (Exception e) {
  				e.printStackTrace();
  				res.setError();
  				res.setMessage(e.getMessage());
  			}
  		} else {
  			res.setDataError();
  		}
ce70231e   孙向锦   增加接口
1092
1093
  		logger.info("uploadtestpaper cost time:"
  				+ (System.currentTimeMillis() - cur));
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1094
1095
1096
1097
  
  		return res.toJson();
  
  	}
ce70231e   孙向锦   增加接口
1098
  
2ad7ca45   孙向锦   试卷bug修改
1099
1100
1101
1102
  	/**
  	 *  上传测验成绩
  	 * @return
  	 */
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1103
1104
1105
  	@RequestMapping(value = "/uploadupdatetestpaper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object uploadupdateTestpaper() {
3371dbc6   孙向锦   0720 版本
1106
  		event("uploadupdateTestpaper");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1107
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
  		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   孙向锦   完善后台功能
1136
1137
1138
1139
  				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   孙向锦   更新报表
1140
  				testPd.put("TOTAL_SCORE", testPaper.getTotalScore());
91a745c9   孙向锦   完善后台功能
1141
1142
1143
  				testPd.put("REMARK", testPaper.getRemark());
  				testpaperService.save(testPd);
  				if (testPaper.getStudents() != null) {
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1144
1145
  					List<PageData> testInfoPdList = new ArrayList();
  					PageData testInfoPd = null;
91a745c9   孙向锦   完善后台功能
1146
1147
1148
  					for (StudentAnswer studentAnswer : testPaper.getStudents()) {
  						if (studentAnswer.getQuestions() != null) {
  							PageData studentPageData = new PageData();
91a745c9   孙向锦   完善后台功能
1149
1150
1151
1152
1153
1154
1155
1156
1157
  							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   孙向锦   添加软件管理模块。对软件形成统一的管理
1158
  							studentPageData.put("STUDENTTEST_ID", get32UUID());
91a745c9   孙向锦   完善后台功能
1159
1160
1161
1162
  							studenttestService.save(studentPageData);
  
  							for (TestPaperInfo testPaperInfo : studentAnswer
  									.getQuestions()) {
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1163
  								testInfoPd = new PageData();
91a745c9   孙向锦   完善后台功能
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
  								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   孙向锦   添加软件管理模块。对软件形成统一的管理
1181
1182
1183
  								testInfoPd.put("ANSWER_TYPE", testPaperInfo
  										.getAnswerType() == null ? "1"
  										: testPaperInfo.getAnswerType());
91a745c9   孙向锦   完善后台功能
1184
1185
1186
1187
1188
1189
1190
1191
1192
  								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   孙向锦   添加软件管理模块。对软件形成统一的管理
1193
  								testInfoPdList.add(testInfoPd);
91a745c9   孙向锦   完善后台功能
1194
1195
1196
  							}
  						}
  					}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1197
  					testpaperinfoService.batchSave(testInfoPdList);
91a745c9   孙向锦   完善后台功能
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
  				}
  				res.setData(testPaperId);
  			} catch (Exception e) {
  				e.printStackTrace();
  				res.setError();
  				res.setMessage(e.getMessage());
  			}
  		} else {
  			res.setDataError();
  		}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1208
1209
  		logger.info("uploadtestpaper cost time:"
  				+ (System.currentTimeMillis() - cur));
91a745c9   孙向锦   完善后台功能
1210
1211
1212
1213
1214
  
  		return res.toJson();
  
  	}
  
2ad7ca45   孙向锦   试卷bug修改
1215
1216
1217
1218
1219
  	/**
  	 * 查询知识点
  	 * @return
  	 * @throws Exception
  	 */
ce70231e   孙向锦   增加接口
1220
1221
1222
1223
  	@RequestMapping(value = "/point", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object point() throws Exception {
  		ResponseGson<List<PageData>> res = new ResponseGson();
2ad7ca45   孙向锦   试卷bug修改
1224
  
ce70231e   孙向锦   增加接口
1225
  		PageData pd = getPageData();
2ad7ca45   孙向锦   试卷bug修改
1226
  		String key = this.getRequestKey(pd, "point");
ce70231e   孙向锦   增加接口
1227
1228
  		PageData pagedata = new PageData();
  		pagedata.put("KEY", key);
2ad7ca45   孙向锦   试卷bug修改
1229
  		if (!"".equals(key.trim())) {
ce70231e   孙向锦   增加接口
1230
  			PageData ret = cacheService.findById(pagedata);
2ad7ca45   孙向锦   试卷bug修改
1231
  			if (ret != null && ret.get("CACHE") != null) {
ce70231e   孙向锦   增加接口
1232
1233
1234
1235
1236
  				return ret.get("CACHE");
  			}
  		}
  		List<PageData> list = knowledgeService.listAllknowledge(pd);
  		String depth = pd.getString("DEPTH");
2ad7ca45   孙向锦   试卷bug修改
1237
1238
1239
  		int end = 3;
  		if (depth != null) {
  			try {
ce70231e   孙向锦   增加接口
1240
  				end = Integer.parseInt(depth);
2ad7ca45   孙向锦   试卷bug修改
1241
1242
  			} catch (Exception e) {
  
ce70231e   孙向锦   增加接口
1243
1244
  			}
  		}
2ad7ca45   孙向锦   试卷bug修改
1245
  		roundPointData(list, 1, end);
ce70231e   孙向锦   增加接口
1246
1247
  		res.setData(list);
  		String str = res.toJson();
2ad7ca45   孙向锦   试卷bug修改
1248
  		str = str.replaceAll("[^\\u0000-\\uFFFF]", "");
ce70231e   孙向锦   增加接口
1249
1250
1251
1252
1253
  		pagedata.put("CACHE", str);
  		cacheService.save(pagedata);
  		return str;
  	}
  
2ad7ca45   孙向锦   试卷bug修改
1254
1255
1256
1257
1258
1259
1260
1261
1262
  	/**
  	 * 知识点递归查询
  	 * @param list 查询知识点及子知识点
  	 * @param dept 深度
  	 * @param end 层深
  	 * @throws Exception
  	 */
  	private void roundPointData(List<PageData> list, int dept, int end)
  			throws Exception {
ce70231e   孙向锦   增加接口
1263
1264
1265
1266
1267
1268
1269
  		if (list != null) {
  			for (PageData pd : list) {
  				pd.put("P_ID", pd.getString("KNOWLEDGE_ID"));
  				if (pd.getString("P_ID") != null
  						&& !"".equals(pd.getString("P_ID")) && dept < end) {
  					List<PageData> ret = knowledgeService.listAllknowledge(pd);
  					if (ret != null && ret.size() > 0) {
2ad7ca45   孙向锦   试卷bug修改
1270
  						roundPointData(ret, dept + 1, end);
ce70231e   孙向锦   增加接口
1271
1272
1273
1274
1275
1276
1277
  						pd.put("CHILDREN", ret);
  					}
  				}
  				pd.remove("P_ID");
  			}
  		}
  	}
2ad7ca45   孙向锦   试卷bug修改
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
  
  	/**
  	 * 章节递归查询
  	 * @param list 章节
  	 * @param dept 深度
  	 * @param end 递归深度
  	 * @throws Exception
  	 */
  	private void roundChapterData(List<PageData> list, int dept, int end)
  			throws Exception {
  		if (list != null) {
ce70231e   孙向锦   增加接口
1289
1290
  			for (PageData pd : list) {
  				pd.put("P_ID", pd.getString("ID"));
2ad7ca45   孙向锦   试卷bug修改
1291
1292
1293
1294
1295
1296
1297
1298
  				if (dept < end) {
  					if (pd.getString("P_ID") != null
  							&& !"".equals(pd.getString("P_ID"))) {
  						List<PageData> ret = chapterService.listAllChapter(pd);
  						if (ret != null && ret.size() > 0) {
  							roundChapterData(ret, dept + 1, end);
  							pd.put("CHILDREN", ret);
  						}
ce70231e   孙向锦   增加接口
1299
1300
1301
  					}
  				}
  				pd.remove("P_ID");
2ad7ca45   孙向锦   试卷bug修改
1302
  				pd.remove("TEACHINGMATERIAL_ID");
ce70231e   孙向锦   增加接口
1303
1304
1305
1306
  			}
  		}
  	}
  
2ad7ca45   孙向锦   试卷bug修改
1307
1308
1309
1310
  	/**
  	 *  下载测验成绩
  	 * @return
  	 */
91a745c9   孙向锦   完善后台功能
1311
1312
1313
  	@RequestMapping(value = "/downloadtestpaper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object downloadTestpaper() {
3371dbc6   孙向锦   0720 版本
1314
  		event("downloadTestpaper");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1315
  		long cur = System.currentTimeMillis();
91a745c9   孙向锦   完善后台功能
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
  		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();
  			}
  		}
ce70231e   孙向锦   增加接口
1391
1392
  		logger.info("downloadtestpaper cost time:"
  				+ (System.currentTimeMillis() - cur));
338594c8   孙向锦   添加教师端页面
1393
  		return res.toJson();
91a745c9   孙向锦   完善后台功能
1394
  
338594c8   孙向锦   添加教师端页面
1395
1396
  	}
  
2ad7ca45   孙向锦   试卷bug修改
1397
1398
1399
1400
1401
  	/**
  	 * 
  	 *  下载测验成绩
  	 * @return
  	 */
91a745c9   孙向锦   完善后台功能
1402
1403
1404
  	@RequestMapping(value = "/testpaper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object testpaper() {
3371dbc6   孙向锦   0720 版本
1405
  		event("testpaper");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1406
  		long cur = System.currentTimeMillis();
91a745c9   孙向锦   完善后台功能
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
  		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   孙向锦   添加软件管理模块。对软件形成统一的管理
1438
  		logger.info("testpaper cost time:" + (System.currentTimeMillis() - cur));
91a745c9   孙向锦   完善后台功能
1439
1440
1441
  		return res.toJson();
  
  	}
ce70231e   孙向锦   增加接口
1442
  
2ad7ca45   孙向锦   试卷bug修改
1443
1444
1445
  	/***
  	 * 
  	 */
4fd2e08c   孙向锦   修复接口中的bug
1446
1447
  	@RequestMapping(value = "/schooladmin", produces = "application/json;charset=UTF-8")
  	@ResponseBody
ce70231e   孙向锦   增加接口
1448
  	public void schoolAdmin() {
3371dbc6   孙向锦   0720 版本
1449
  		event("schoolAdmin");
4fd2e08c   孙向锦   修复接口中的bug
1450
1451
  		PageData pd = this.getPageData();
  		this.getUserID();
4fd2e08c   孙向锦   修复接口中的bug
1452
  	}
ce70231e   孙向锦   增加接口
1453
  
2ad7ca45   孙向锦   试卷bug修改
1454
1455
1456
1457
1458
1459
  	
  	/***
  	 * 网络
  	 * @return
  	 * @throws Exception
  	 */
9338b563   孙向锦   添加报表
1460
1461
  	@RequestMapping(value = "/network", produces = "application/json;charset=UTF-8")
  	@ResponseBody
ce70231e   孙向锦   增加接口
1462
  	public Object network() throws Exception {
3371dbc6   孙向锦   0720 版本
1463
  		event("network");
9338b563   孙向锦   添加报表
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
  		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;
ce70231e   孙向锦   增加接口
1476
  				if (fail < 0) {
9338b563   孙向锦   添加报表
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
  					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;
ce70231e   孙向锦   增加接口
1490
  				if (fail < 0) {
9338b563   孙向锦   添加报表
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
  					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);
  			}
ce70231e   孙向锦   增加接口
1502
  		} else {
9338b563   孙向锦   添加报表
1503
1504
1505
1506
  			res.setDataError();
  		}
  		return res.toJson();
  	}
ce70231e   孙向锦   增加接口
1507
  
2ad7ca45   孙向锦   试卷bug修改
1508
1509
1510
1511
  	/**
  	 * 获取远端ip地址
  	 * @return
  	 */
ce70231e   孙向锦   增加接口
1512
  	public String getRemoteIp() {
9338b563   孙向锦   添加报表
1513
1514
1515
1516
1517
1518
1519
1520
1521
  		HttpServletRequest request = getRequest();
  		String ip = "";
  		if (request.getHeader("x-forwarded-for") == null) {
  			ip = request.getRemoteAddr();
  		} else {
  			ip = request.getHeader("x-forwarded-for");
  		}
  		return ip;
  	}
ce70231e   孙向锦   增加接口
1522
  
2ad7ca45   孙向锦   试卷bug修改
1523
1524
1525
1526
1527
1528
  	/**
  	 * 查询新版本信息
  	 * @param request
  	 * @return
  	 * @throws Exception
  	 */
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1529
1530
  	@RequestMapping(value = "/newversion", produces = "application/json;charset=UTF-8")
  	@ResponseBody
ce70231e   孙向锦   增加接口
1531
  	public Object getNewVersion(HttpServletRequest request) throws Exception {
3371dbc6   孙向锦   0720 版本
1532
  		event("getNewVersion");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1533
1534
1535
  		PageData pd = this.getPageData();
  		String softId = pd.getString("SOFTID");
  		String path = request.getContextPath();
ce70231e   孙向锦   增加接口
1536
1537
  		String basePath = request.getScheme() + "://" + request.getServerName()
  				+ ":" + request.getServerPort() + path + "/";
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1538
  		ResponseGson<PageData> res = new ResponseGson();
ce70231e   孙向锦   增加接口
1539
  		if (softId != null && !"".equals(softId)) {
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1540
1541
  			pd.put("SOFTWARE_ID", softId);
  			PageData result = softwareversionService.findNewVersion(pd);
ce70231e   孙向锦   增加接口
1542
  			if (result != null) {
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1543
1544
  				result.remove("SOFTWAREVERSION_ID");
  				result.remove("SOFTWARE_ID");
ce70231e   孙向锦   增加接口
1545
1546
  				result.put("VERSION_PATH", basePath + "uploadFiles/uploadFile/"
  						+ result.getString("VERSION_PATH"));
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1547
  				res.setData(result);
ce70231e   孙向锦   增加接口
1548
  			} else {
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1549
1550
  				res.setDataError();
  			}
ce70231e   孙向锦   增加接口
1551
  		} else {
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1552
1553
1554
1555
  			res.setDataError();
  		}
  		return res.toJson();
  	}
ce70231e   孙向锦   增加接口
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
  
  	/**
  	 * 获取教材版本
  	 * 
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/teachingmaterial", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object teachingmaterial() throws Exception {
  		PageData pd = getPageData();
  		ResponseGson<List<PageData>> ret = new ResponseGson<List<PageData>>();
  		List<PageData> lpd = new ArrayList<PageData>();
  		List<PageData> list = teachingmaterialService.listAll(pd);
  		String subjectID = pd.getString("SUBJECT_ID");
  		if (subjectID != null && !"".equals(subjectID)) {
  			for (PageData pad : list) {
  				String subis = pad.getString("SUBJECT_ID");
  				if (subis != null) {
  					String[] subs = subis.split(",");
  					if (subs != null) {
  						for (String sub : subs) {
  							if (subjectID.trim().equals(sub.trim())) {
  								pad.remove("SUBJECT_ID");
2ad7ca45   孙向锦   试卷bug修改
1580
1581
  								pad.put("VERSION_CODE",
  										pad.getString("VERSION_CODE"));
ce70231e   孙向锦   增加接口
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
  								lpd.add(pad);
  								break;
  							}
  						}
  					}
  				}
  			}
  		} else {
  			for (PageData pad : list) {
  				pad.remove("SUBJECT_ID");
  				pad.put("VERSION_CODE", pad.getString("VERSION_CODE"));
  				lpd.add(pad);
  			}
  		}
  		ret.setData(lpd);
  		return ret.toJson();
  	}
2ad7ca45   孙向锦   试卷bug修改
1599
  
ce70231e   孙向锦   增加接口
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
  	/**
  	 * 获取教材版本
  	 * 
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/chapter", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object chapter() throws Exception {
  		PageData pd = getPageData();
2ad7ca45   孙向锦   试卷bug修改
1610
  		String key = this.getRequestKey(pd, "chapter");
ce70231e   孙向锦   增加接口
1611
1612
  		PageData pagedata = new PageData();
  		pagedata.put("KEY", key);
2ad7ca45   孙向锦   试卷bug修改
1613
  		if (!"".equals(key.trim())) {
ce70231e   孙向锦   增加接口
1614
  			PageData ret = cacheService.findById(pagedata);
2ad7ca45   孙向锦   试卷bug修改
1615
  			if (ret != null && ret.get("CACHE") != null) {
ce70231e   孙向锦   增加接口
1616
1617
1618
1619
1620
1621
  				return ret.get("CACHE");
  			}
  		}
  		ResponseGson<List<PageData>> res = new ResponseGson<List<PageData>>();
  		List<PageData> list = chapterService.listAllChapter(pd);
  		String depth = pd.getString("DEPTH");
2ad7ca45   孙向锦   试卷bug修改
1622
1623
1624
  		int end = 3;
  		if (depth != null) {
  			try {
ce70231e   孙向锦   增加接口
1625
  				end = Integer.parseInt(depth);
2ad7ca45   孙向锦   试卷bug修改
1626
1627
  			} catch (Exception e) {
  
ce70231e   孙向锦   增加接口
1628
1629
  			}
  		}
2ad7ca45   孙向锦   试卷bug修改
1630
  		roundChapterData(list, 1, end);
ce70231e   孙向锦   增加接口
1631
1632
  		res.setData(list);
  		String str = res.toJson();
ce70231e   孙向锦   增加接口
1633
1634
1635
1636
  		pagedata.put("CACHE", str);
  		cacheService.save(pagedata);
  		return str;
  	}
2ad7ca45   孙向锦   试卷bug修改
1637
  
ce70231e   孙向锦   增加接口
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
  	/**
  	 * 获取试题
  	 * 
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/questions", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object questions() throws Exception {
  		PageData pd = getPageData();
  		ResponseGson<List<PageData>> res = new ResponseGson<List<PageData>>();
  		String teachingmaterialId = pd.getString("TEACHINGMATERIAL_ID");
  		String chapterId = pd.getString("CHAPTER_ID");
2ad7ca45   孙向锦   试卷bug修改
1651
1652
  		if (teachingmaterialId != null && !teachingmaterialId.equals("")
  				&& chapterId == null) {
ce70231e   孙向锦   增加接口
1653
1654
  			PageData chapterPd = new PageData();
  			chapterPd.put("TEACHINGMATERIAL_ID", teachingmaterialId);
2ad7ca45   孙向锦   试卷bug修改
1655
1656
  			List<PageData> chapterList = chapterService
  					.listAllChapter(chapterPd);
ce70231e   孙向锦   增加接口
1657
  			roundChapterData(chapterList, 1, 3);
2ad7ca45   孙向锦   试卷bug修改
1658
  			List<String> ids = getIds(chapterList, "ID");
ce70231e   孙向锦   增加接口
1659
  			pd.put("CHAPTER_IDS", ids);
2ad7ca45   孙向锦   试卷bug修改
1660
  		} else {
ce70231e   孙向锦   增加接口
1661
  			List<String> ids = new ArrayList<String>();
2ad7ca45   孙向锦   试卷bug修改
1662
  			if (chapterId != null && !"".equals(chapterId.trim())) {
ce70231e   孙向锦   增加接口
1663
1664
1665
1666
1667
1668
  				ids.add(chapterId);
  			}
  			pd.put("CHAPTER_IDS", ids);
  		}
  		pd.remove("CHAPTER_ID");
  		String knowledge = pd.getString("KNOWLEDGE_ID");
2ad7ca45   孙向锦   试卷bug修改
1669
  		if (knowledge != null && !"".equals(knowledge.trim())) {
ce70231e   孙向锦   增加接口
1670
1671
1672
1673
  			PageData knowPd = new PageData();
  			knowPd.put("P_ID", knowledge);
  			List<PageData> knowlist = knowledgeService.listAllknowledge(knowPd);
  			roundPointData(knowlist, 1, 3);
2ad7ca45   孙向锦   试卷bug修改
1674
  			List<String> ids = getIds(knowlist, "KNOWLEDGE_ID");
ce70231e   孙向锦   增加接口
1675
  			ids.add(knowledge);
2ad7ca45   孙向锦   试卷bug修改
1676
  			pd.put("KNOWLEDGE_IDS", ids);
ce70231e   孙向锦   增加接口
1677
1678
1679
1680
1681
1682
  			pd.remove("KNOWLEDGE_ID");
  		}
  		List<PageData> list = questionService.listAllquestion(pd);
  		res.setData(list);
  		return res.toJson();
  	}
2ad7ca45   孙向锦   试卷bug修改
1683
  
ce70231e   孙向锦   增加接口
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
  	/**
  	 * 随机获取试题
  	 * 
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/randquestions", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object randquestions() throws Exception {
  		PageData pd = getPageData();
  		ResponseGson<List<PageData>> res = new ResponseGson<List<PageData>>();
  		String teachingmaterialId = pd.getString("TEACHINGMATERIAL_ID");
  		String chapterId = pd.getString("CHAPTER_ID");
2ad7ca45   孙向锦   试卷bug修改
1697
1698
  		if (teachingmaterialId != null && !teachingmaterialId.equals("")
  				&& chapterId == null) {
ce70231e   孙向锦   增加接口
1699
1700
  			PageData chapterPd = new PageData();
  			chapterPd.put("TEACHINGMATERIAL_ID", teachingmaterialId);
2ad7ca45   孙向锦   试卷bug修改
1701
1702
  			List<PageData> chapterList = chapterService
  					.listAllChapter(chapterPd);
ce70231e   孙向锦   增加接口
1703
  			roundChapterData(chapterList, 1, 3);
2ad7ca45   孙向锦   试卷bug修改
1704
  			List<String> ids = getIds(chapterList, "ID");
ce70231e   孙向锦   增加接口
1705
  			pd.put("CHAPTER_IDS", ids);
2ad7ca45   孙向锦   试卷bug修改
1706
  		} else {
ce70231e   孙向锦   增加接口
1707
  			List<String> ids = new ArrayList<String>();
2ad7ca45   孙向锦   试卷bug修改
1708
  			if (chapterId != null && !"".equals(chapterId.trim())) {
ce70231e   孙向锦   增加接口
1709
1710
1711
1712
1713
1714
  				ids.add(chapterId);
  			}
  			pd.put("CHAPTER_IDS", ids);
  		}
  		pd.remove("CHAPTER_ID");
  		String knowledge = pd.getString("KNOWLEDGE_ID");
2ad7ca45   孙向锦   试卷bug修改
1715
  		if (knowledge != null && !"".equals(knowledge.trim())) {
ce70231e   孙向锦   增加接口
1716
1717
1718
1719
  			PageData knowPd = new PageData();
  			knowPd.put("P_ID", knowledge);
  			List<PageData> knowlist = knowledgeService.listAllknowledge(knowPd);
  			roundPointData(knowlist, 1, 3);
2ad7ca45   孙向锦   试卷bug修改
1720
  			List<String> ids = getIds(knowlist, "KNOWLEDGE_ID");
ce70231e   孙向锦   增加接口
1721
  			ids.add(knowledge);
2ad7ca45   孙向锦   试卷bug修改
1722
  			pd.put("KNOWLEDGE_IDS", ids);
ce70231e   孙向锦   增加接口
1723
1724
1725
1726
1727
1728
  			pd.remove("KNOWLEDGE_ID");
  		}
  		List<PageData> list = questionService.listAllRandquestion(pd);
  		res.setData(list);
  		return res.toJson();
  	}
2ad7ca45   孙向锦   试卷bug修改
1729
1730
1731
1732
1733
1734
1735
1736
  
  	/**
  	 * 
  	 * @param chapterList
  	 * @param key
  	 * @return
  	 */
  	public List<String> getIds(List<PageData> chapterList, String key) {
ce70231e   孙向锦   增加接口
1737
  		List<String> ids = new ArrayList<String>();
2ad7ca45   孙向锦   试卷bug修改
1738
1739
  		if (chapterList != null && chapterList.size() > 0) {
  			for (PageData pd : chapterList) {
ce70231e   孙向锦   增加接口
1740
  				String chapterid = pd.getString(key);
2ad7ca45   孙向锦   试卷bug修改
1741
  				if (chapterid != null && !"".equals(chapterid)) {
ce70231e   孙向锦   增加接口
1742
1743
1744
  					ids.add(chapterid);
  				}
  				Object obj = pd.get("CHILDREN");
2ad7ca45   孙向锦   试卷bug修改
1745
  				if (obj != null && (obj instanceof List)) {
ce70231e   孙向锦   增加接口
1746
  					@SuppressWarnings("unchecked")
2ad7ca45   孙向锦   试卷bug修改
1747
1748
1749
  					List<PageData> list = (List<PageData>) obj;
  					List<String> ret = getIds(list, key);
  					if (ret != null && ret.size() > 0) {
ce70231e   孙向锦   增加接口
1750
1751
1752
1753
1754
  						ids.addAll(ret);
  					}
  				}
  			}
  		}
2ad7ca45   孙向锦   试卷bug修改
1755
  
ce70231e   孙向锦   增加接口
1756
  		return ids;
2ad7ca45   孙向锦   试卷bug修改
1757
  
ce70231e   孙向锦   增加接口
1758
1759
  	}
  
2ad7ca45   孙向锦   试卷bug修改
1760
1761
1762
1763
1764
1765
  	
  	/**
  	 * 
  	 * @return
  	 * @throws Exception
  	 */
d3d7b2ca   孙向锦   修改表格固定
1766
1767
  	@RequestMapping(value = "/tempcreateUser", produces = "application/json;charset=UTF-8")
  	@ResponseBody
ce70231e   孙向锦   增加接口
1768
  	public Object tempCreateUser() throws Exception {
d3d7b2ca   孙向锦   修改表格固定
1769
1770
1771
1772
  		PageData pd = new PageData();
  		pd = this.getPageData();
  		pd.put("ID", this.get32UUID());
  		teacherService.save(pd);
ce70231e   孙向锦   增加接口
1773
1774
1775
1776
  		pd.put("USER_ID", pd.getString("ID")); // ID 主键
  		pd.put("LAST_LOGIN", ""); // 最后登录时间
  		pd.put("IP", ""); // IP
  		pd.put("STATUS", "0"); // 状态
d3d7b2ca   孙向锦   修改表格固定
1777
  		pd.put("SKIN", "default");
ce70231e   孙向锦   增加接口
1778
  		pd.put("RIGHTS", "");
d3d7b2ca   孙向锦   修改表格固定
1779
  		pd.put("USERNAME", pd.getString("ACCOUT"));
ce70231e   孙向锦   增加接口
1780
1781
1782
1783
1784
1785
1786
  		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); // 执行保存
d3d7b2ca   孙向锦   修改表格固定
1787
  		}
ce70231e   孙向锦   增加接口
1788
1789
1790
  
  		// ID, TEACHER_ID, CLASS_ID, SUBJECT_ID, START_DATE, END_DATE, GRADE_ID,
  		// TERM_ID, REMARK
d3d7b2ca   孙向锦   修改表格固定
1791
1792
1793
1794
  		pd.put("TEACHER_ID", pd.get("ID"));
  		pd.put("CLASS_ID", "bc33389101ec46e6b7d47daa8adf58ac");
  		pd.put("SUBJECT_ID", "1");
  		pd.put("GRADE_ID", "1");
ce70231e   孙向锦   增加接口
1795
  		pd.put("TERM_ID", "0d8ea2efdef74accbd0d00e9bc07dfbb");
d3d7b2ca   孙向锦   修改表格固定
1796
  		coursemanagementService.save(pd);
ce70231e   孙向锦   增加接口
1797
  
d3d7b2ca   孙向锦   修改表格固定
1798
1799
  		return "{'res':'success'}";
  	}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1800
  
2ad7ca45   孙向锦   试卷bug修改
1801
1802
1803
1804
  	/**
  	 * 
  	 * @param apiName
  	 */
ce70231e   孙向锦   增加接口
1805
  	private void event(String apiName) {
3371dbc6   孙向锦   0720 版本
1806
1807
1808
1809
  		PageData eventPd = new PageData();
  		eventPd.put("EVENT_ID", get32UUID());
  		eventPd.put("EVENT_NAME", apiName);
  		eventPd.put("EVENT_USER", getUsername());
67dfaf5c   孙向锦   提交代码
1810
  		eventPd.put("EVENT_TYPE", "-1");
3371dbc6   孙向锦   0720 版本
1811
1812
1813
  		eventPd.put("EVENT_START_TIME", Tools.date2Str(new Date()));
  		eventPd.put("CLIENT_ID", "SERVER");
  		eventPd.put("EVENT_IP", getRemoteIp());
ce70231e   孙向锦   增加接口
1814
  		try {
3371dbc6   孙向锦   0720 版本
1815
  			eventService.save(eventPd);
ce70231e   孙向锦   增加接口
1816
1817
1818
1819
1820
1821
1822
  		} catch (Exception e) {
  
  		}
  	}
  
  	static int index = 0;
  
2ad7ca45   孙向锦   试卷bug修改
1823
1824
1825
1826
1827
  	/**
  	 * 
  	 * @param point
  	 * @param pid
  	 */
ce70231e   孙向锦   增加接口
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
  	private void savePoint(Point point, String pid) {
  		List<Point> children = point.getChildren();
  		if (children != null && children.size() > 0) {
  			for (Point p : children) {
  				savePoint(p, point.getCode());
  			}
  		}
  		PageData pageData = new PageData();
  		pageData.put("KNOWLEDGE_ID", point.getCode());
  		pageData.put("NAME", point.getName());
  		pageData.put("P_ID", pid);
  		pageData.put("RANK", ++index);
  		try {
  			knowledgeService.save(pageData);
  		} catch (Exception e) {
  			e.printStackTrace();
  		}
  	}
  
2ad7ca45   孙向锦   试卷bug修改
1847
1848
1849
1850
1851
  	/**
  	 * 
  	 * @return
  	 * @throws Exception
  	 */
ce70231e   孙向锦   增加接口
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
  	@RequestMapping(value = "/uploadbook", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object uploadbook() throws Exception {
  		event("uploadbook");
  		long cur = System.currentTimeMillis();
  		PageData pd = this.getPageData();
  		ResponseGson<String> res = new ResponseGson();
  
  		if (!StringUtils.isEmpty(pd.getJsonString())) {
  			try {
  				ResponseGson<List<Point>> req = ResponseGson.parse(
  						pd.getJsonString(), Point.class);
  				List<Point> list = req.getData();
  				if (list != null && list.size() > 0) {
  					for (Point point : list) {
  						saveBook(point);
  					}
  				}
  			} catch (Exception e) {
  				res.setError();
  			}
  		} else {
  			res.setDataError();
  		}
  		logger.info("uploadpoint cost time : "
  				+ (System.currentTimeMillis() - cur));
  		return res.toJson();
  	}
  
2ad7ca45   孙向锦   试卷bug修改
1881
1882
1883
1884
  	/**
  	 * 
  	 * @param point
  	 */
ce70231e   孙向锦   增加接口
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
  	private void saveBook(Point point) {
  
  		PageData pd = new PageData();
  		pd.put("ID", point.getCode());
  		pd.put("NAME", point.getName());
  		pd.put("SUBJECT_ID", point.getSubjectCode());
  		try {
  			teachingmaterialService.save(pd);
  		} catch (Exception e) {
  			// TODO Auto-generated catch block
  			e.printStackTrace();
  		}
  	}
2ad7ca45   孙向锦   试卷bug修改
1898
1899
1900
1901
1902
1903
  
  	/**
  	 * 
  	 * @return
  	 * @throws Exception
  	 */
ce70231e   孙向锦   增加接口
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
  	@RequestMapping(value = "/uploadyuncelianquestion", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object uploadyuncelianquestion() throws Exception {
  		event("uploadyuncelianquestion");
  		long cur = System.currentTimeMillis();
  		PageData pd = this.getPageData();
  		ResponseGson<Object> res = new ResponseGson();
  
  		if (!StringUtils.isEmpty(pd.getJsonString())) {
  			try {
2ad7ca45   孙向锦   试卷bug修改
1914
1915
  				ResponseGson<Object> req = ResponseGson.parse(pd
  						.getJsonString());
ce70231e   孙向锦   增加接口
1916
  				Object data = req.getData();
2ad7ca45   孙向锦   试卷bug修改
1917
1918
1919
1920
1921
1922
  				if (data instanceof List) {
  					List<Object> list = (List) data;
  					for (Object obj : list) {
  						if (obj instanceof Map) {
  							Map map = (Map) obj;
  
ce70231e   孙向锦   增加接口
1923
1924
1925
  							PageData pageData = new PageData();
  							pageData.put("QUESTION_ID", map.get("id"));
  							Object cateObj = map.get("cate");
2ad7ca45   孙向锦   试卷bug修改
1926
  							if (cateObj != null) {
ce70231e   孙向锦   增加接口
1927
1928
  								String cate = cateObj.toString();
  								float catef = Float.parseFloat(cate);
2ad7ca45   孙向锦   试卷bug修改
1929
  								pageData.put("QUESTION_TYPE_ID", (int) catef);
ce70231e   孙向锦   增加接口
1930
1931
  							}
  							Object contentObj = map.get("content");
2ad7ca45   孙向锦   试卷bug修改
1932
  							if (contentObj != null) {
ce70231e   孙向锦   增加接口
1933
1934
1935
1936
1937
  								String content = contentObj.toString();
  								content = replaceWebUrl(content);
  								pageData.put("CONTENT", content);
  							}
  							Object subjectCodeObj = map.get("subjectCode");
2ad7ca45   孙向锦   试卷bug修改
1938
  							if (subjectCodeObj != null) {
ce70231e   孙向锦   增加接口
1939
  								String subjectCode = subjectCodeObj.toString();
2ad7ca45   孙向锦   试卷bug修改
1940
  								pageData.put("SUBJECT_ID", subjectCode);
ce70231e   孙向锦   增加接口
1941
1942
  							}
  							Object optionsObj = map.get("options");
2ad7ca45   孙向锦   试卷bug修改
1943
1944
1945
1946
  							if (optionsObj instanceof List) {
  								List ss = (List) optionsObj;
  								pageData.put("OPTION_CONTENT",
  										optionsObj.toString());
ce70231e   孙向锦   增加接口
1947
1948
1949
  								pageData.put("OPTION_NUM", "" + ss.size());
  							}
  							Object answersObj = map.get("answers");
2ad7ca45   孙向锦   试卷bug修改
1950
1951
  							if (answersObj instanceof List) {
  								List answers = (List) answersObj;
ce70231e   孙向锦   增加接口
1952
  								StringBuilder sb = new StringBuilder();
2ad7ca45   孙向锦   试卷bug修改
1953
  								for (Object as : answers) {
ce70231e   孙向锦   增加接口
1954
1955
1956
1957
  									sb.append(as.toString());
  								}
  								pageData.put("ANSWER", sb.toString());
  							}
2ad7ca45   孙向锦   试卷bug修改
1958
1959
  							Object difficulty = map.get("difficulty");
  							try {
ce70231e   孙向锦   增加接口
1960
1961
1962
1963
1964
1965
  								if (difficulty != null) {
  									float fdifficulty = Float
  											.parseFloat(difficulty.toString());
  									pageData.put("DIFFICULTY",
  											(int) fdifficulty);
  								}
2ad7ca45   孙向锦   试卷bug修改
1966
  							} catch (Exception ex) {
ce70231e   孙向锦   增加接口
1967
1968
1969
  								ex.printStackTrace();
  							}
  							Object discussObj = map.get("discuss");
2ad7ca45   孙向锦   试卷bug修改
1970
  							if (discussObj != null) {
ce70231e   孙向锦   增加接口
1971
1972
1973
1974
1975
  								String discuss = discussObj.toString();
  								discuss = replaceWebUrl(discuss);
  								pageData.put("REMARK", discuss);
  							}
  							Object analyseObj = map.get("analyse");
2ad7ca45   孙向锦   试卷bug修改
1976
  							if (analyseObj != null) {
ce70231e   孙向锦   增加接口
1977
1978
1979
1980
1981
  								String analyse = analyseObj.toString();
  								analyse = replaceWebUrl(analyse);
  								pageData.put("ANALYSIS", analyse);
  							}
  							Object methodObj = map.get("method");
2ad7ca45   孙向锦   试卷bug修改
1982
  							if (methodObj != null) {
ce70231e   孙向锦   增加接口
1983
1984
1985
1986
1987
1988
  								String method = methodObj.toString();
  								method = replaceWebUrl(method);
  								pageData.put("METHOD", method);
  							}
  							Object points = map.get("points");
  							StringBuilder sb = new StringBuilder();
2ad7ca45   孙向锦   试卷bug修改
1989
1990
1991
1992
1993
  							if (points instanceof List) {
  								List pointsList = (List) points;
  								for (Object pObject : pointsList) {
  									if (pObject instanceof Map) {
  										Map pMap = (Map) pObject;
ce70231e   孙向锦   增加接口
1994
1995
1996
  										sb.append(pMap.get("code")).append(",");
  									}
  								}
2ad7ca45   孙向锦   试卷bug修改
1997
1998
  
  								if (sb.toString().length() > 1) {
ce70231e   孙向锦   增加接口
1999
2000
2001
2002
2003
  									sb.deleteCharAt(sb.length() - 1);
  								}
  								pageData.put("KNOWLEDGE_ID", sb.toString());
  							}
  							pageData.put("QUESTION_FROM", "101");
2ad7ca45   孙向锦   试卷bug修改
2004
  							try {
ce70231e   孙向锦   增加接口
2005
  								questionService.save(pageData);
2ad7ca45   孙向锦   试卷bug修改
2006
2007
  							} catch (Exception e) {
  								logger.error("save fail:" + map.get("id"), e);
ce70231e   孙向锦   增加接口
2008
2009
2010
2011
2012
2013
2014
2015
2016
  							}
  						}
  					}
  				}
  			} catch (Exception e) {
  				res.setError();
  			}
  		} else {
  			res.setDataError();
3371dbc6   孙向锦   0720 版本
2017
  		}
ce70231e   孙向锦   增加接口
2018
2019
2020
  		logger.info("uploadyuncelianquestion cost time : "
  				+ (System.currentTimeMillis() - cur));
  		return res.toJson();
3371dbc6   孙向锦   0720 版本
2021
  	}
ce70231e   孙向锦   增加接口
2022
  
2ad7ca45   孙向锦   试卷bug修改
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
  	/**
  	 * 
  	 * @param content
  	 * @return
  	 */
  	private String replaceWebUrl(String content) {
  		if (content != null) {
  			content = content.replaceAll(
  					"http://image.yuncelian.com/1/analysis/",
  					"http://image.yuncelian.com/1/analysis/");
ce70231e   孙向锦   增加接口
2033
2034
2035
  		}
  		return content;
  	}
2ad7ca45   孙向锦   试卷bug修改
2036
2037
2038
2039
2040
2041
2042
2043
2044
  
  	/**
  	 * 
  	 * @param pd
  	 * @param methodName
  	 * @return
  	 */
  	public String getRequestKey(PageData pd, String methodName) {
  		StringBuilder key = new StringBuilder();
ce70231e   孙向锦   增加接口
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
  		key.append(methodName).append("{");
  		if (pd != null) {
  			Iterator iterator = pd.keySet().iterator();
  			while (iterator.hasNext()) {
  				Object obj = iterator.next();
  				key.append(obj.toString()).append(":")
  						.append(pd.get(obj).toString()).append(";");
  			}
  		}
  		key.append("}");
2ad7ca45   孙向锦   试卷bug修改
2055
  
ce70231e   孙向锦   增加接口
2056
2057
  		return key.toString();
  	}
bed6e1fc   孙向锦   添加其他功能
2058
  }