Blame view

src/com/fh/controller/api/V1.java 112 KB
bed6e1fc   孙向锦   添加其他功能
1
2
  package com.fh.controller.api;
  
757dfed6   孙向锦   样例报表
3
  import java.io.File;
107fa3a0   孙向锦   修改试卷单选多远混合出题
4
5
6
  import java.sql.Connection;
  import java.sql.ResultSet;
  import java.sql.Statement;
338594c8   孙向锦   添加教师端页面
7
  import java.util.ArrayList;
757dfed6   孙向锦   样例报表
8
9
  import java.util.Collections;
  import java.util.Comparator;
bed6e1fc   孙向锦   添加其他功能
10
  import java.util.Date;
ce70231e   孙向锦   增加接口
11
  import java.util.Iterator;
bed6e1fc   孙向锦   添加其他功能
12
  import java.util.List;
ce70231e   孙向锦   增加接口
13
  import java.util.Map;
bed6e1fc   孙向锦   添加其他功能
14
15
  
  import javax.annotation.Resource;
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
16
  import javax.servlet.http.HttpServletRequest;
bed6e1fc   孙向锦   添加其他功能
17
  
338594c8   孙向锦   添加教师端页面
18
  import org.apache.commons.lang.StringUtils;
d3d7b2ca   孙向锦   修改表格固定
19
  import org.apache.shiro.crypto.hash.SimpleHash;
bed6e1fc   孙向锦   添加其他功能
20
  import org.springframework.stereotype.Controller;
bed6e1fc   孙向锦   添加其他功能
21
  import org.springframework.web.bind.annotation.RequestMapping;
757dfed6   孙向锦   样例报表
22
  import org.springframework.web.bind.annotation.RequestParam;
bed6e1fc   孙向锦   添加其他功能
23
  import org.springframework.web.bind.annotation.ResponseBody;
757dfed6   孙向锦   样例报表
24
  import org.springframework.web.multipart.MultipartFile;
bed6e1fc   孙向锦   添加其他功能
25
  
338594c8   孙向锦   添加教师端页面
26
  import com.fh.bean.Paper;
ce70231e   孙向锦   增加接口
27
  import com.fh.bean.Point;
338594c8   孙向锦   添加教师端页面
28
  import com.fh.bean.Question;
a479f295   孙向锦   添加了报表逻辑
29
30
  import com.fh.bean.ResultHomework;
  import com.fh.bean.ResultHomework.ResultStudent;
91a745c9   孙向锦   完善后台功能
31
  import com.fh.bean.StudentAnswer;
c34a91ee   Elvis   添加学生成绩接口
32
  import com.fh.bean.StudentPaper;
91a745c9   孙向锦   完善后台功能
33
34
  import com.fh.bean.TestPaper;
  import com.fh.bean.TestPaperInfo;
bed6e1fc   孙向锦   添加其他功能
35
  import com.fh.controller.base.BaseController;
338594c8   孙向锦   添加教师端页面
36
  import com.fh.controller.sunvote.Myelfun;
bed6e1fc   孙向锦   添加其他功能
37
38
39
  import com.fh.service.api.V1Manager;
  import com.fh.service.feedback.feedback.FeedbackManager;
  import com.fh.service.feedback.problemphenomenon.ProblemPhenomenonManager;
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
40
  import com.fh.service.software.softwareversion.SoftwareVersionManager;
9f161055   孙向锦   修改高斯客户反馈
41
  import com.fh.service.sunvote.attachkeyboard.AttachKeyboardManager;
bed6e1fc   孙向锦   添加其他功能
42
  import com.fh.service.sunvote.basestation.BasestationManager;
ce70231e   孙向锦   增加接口
43
  import com.fh.service.sunvote.cache.CacheManager;
bed6e1fc   孙向锦   添加其他功能
44
45
46
47
48
  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   孙向锦   添加报表
49
  import com.fh.service.sunvote.event.EventManager;
bed6e1fc   孙向锦   添加其他功能
50
  import com.fh.service.sunvote.grade.GradeManager;
48d44272   孙向锦   添加一些action
51
  import com.fh.service.sunvote.headmaster.HeadmasterManager;
694fbd54   孙向锦   添加作业管理模块
52
  import com.fh.service.sunvote.homework.HomeworkManager;
a479f295   孙向锦   添加了报表逻辑
53
  import com.fh.service.sunvote.homework.HomeworkReportManager;
416902b7   孙向锦   添加课后作业部分API
54
  import com.fh.service.sunvote.homeworkproblem.HomeworkProblemManager;
bed6e1fc   孙向锦   添加其他功能
55
56
57
58
  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   孙向锦   添加报表
59
  import com.fh.service.sunvote.networkstatistics.NetworkStatisticsManager;
bed6e1fc   孙向锦   添加其他功能
60
61
62
63
64
65
66
67
68
  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;
bed6e1fc   孙向锦   添加其他功能
69
  import com.fh.service.sunvote.student.StudentManager;
91a745c9   孙向锦   完善后台功能
70
  import com.fh.service.sunvote.studenttest.StudentTestManager;
bed6e1fc   孙向锦   添加其他功能
71
  import com.fh.service.sunvote.subject.SubjectManager;
bed6e1fc   孙向锦   添加其他功能
72
  import com.fh.service.sunvote.teacher.TeacherManager;
ce70231e   孙向锦   增加接口
73
  import com.fh.service.sunvote.teachingmaterial.TeachingMaterialManager;
91a745c9   孙向锦   完善后台功能
74
  import com.fh.service.sunvote.testpaper.TestPaperManager;
bed6e1fc   孙向锦   添加其他功能
75
  import com.fh.service.sunvote.testpaperinfo.TestPaperInfoManager;
c617106f   孙向锦   添加即时测功能
76
  import com.fh.service.sunvote.textbook.TextbookManager;
d3d7b2ca   孙向锦   修改表格固定
77
  import com.fh.service.system.user.UserManager;
107fa3a0   孙向锦   修改试卷单选多远混合出题
78
  import com.fh.util.DbFH;
bed6e1fc   孙向锦   添加其他功能
79
  import com.fh.util.PageData;
bed6e1fc   孙向锦   添加其他功能
80
81
82
83
84
  import com.fh.util.Tools;
  
  @Controller
  @RequestMapping(value = "/api/v1")
  public class V1 extends BaseController {
91a745c9   孙向锦   完善后台功能
85
  
bed6e1fc   孙向锦   添加其他功能
86
87
88
89
90
  	@Resource(name = "schoolService")
  	private SchoolManager schoolService;
  
  	@Resource(name = "basestationService")
  	private BasestationManager basestationService;
91a745c9   孙向锦   完善后台功能
91
92
  
  	@Resource(name = "chapterService")
bed6e1fc   孙向锦   添加其他功能
93
  	private ChapterManager chapterService;
91a745c9   孙向锦   完善后台功能
94
95
  
  	@Resource(name = "classbasetationService")
bed6e1fc   孙向锦   添加其他功能
96
  	private ClassBasetationManager classbasetationService;
91a745c9   孙向锦   完善后台功能
97
98
  
  	@Resource(name = "classrosterService")
bed6e1fc   孙向锦   添加其他功能
99
  	private ClassRosterManager classrosterService;
91a745c9   孙向锦   完善后台功能
100
101
  
  	@Resource(name = "classtypeService")
c34a91ee   Elvis   添加学生成绩接口
102
  	private ClassTypeManager classtypeService;
91a745c9   孙向锦   完善后台功能
103
104
  
  	@Resource(name = "gradeService")
bed6e1fc   孙向锦   添加其他功能
105
  	private GradeManager gradeService;
91a745c9   孙向锦   完善后台功能
106
107
  
  	@Resource(name = "coursemanagementService")
bed6e1fc   孙向锦   添加其他功能
108
109
110
111
  	private CourseManagementManager coursemanagementService;
  
  	@Resource(name = "keypadService")
  	private KeypadManager keypadService;
91a745c9   孙向锦   完善后台功能
112
113
  
  	@Resource(name = "keypadcheckService")
bed6e1fc   孙向锦   添加其他功能
114
  	private KeypadCheckManager keypadcheckService;
91a745c9   孙向锦   完善后台功能
115
116
  
  	@Resource(name = "knowledgeService")
bed6e1fc   孙向锦   添加其他功能
117
  	private KnowledgeManager knowledgeService;
91a745c9   孙向锦   完善后台功能
118
119
  
  	@Resource(name = "knowledgechapterService")
bed6e1fc   孙向锦   添加其他功能
120
  	private KnowledgeChapterManager knowledgechapterService;
91a745c9   孙向锦   完善后台功能
121
122
  
  	@Resource(name = "paperService")
bed6e1fc   孙向锦   添加其他功能
123
  	private PaperManager paperService;
91a745c9   孙向锦   完善后台功能
124
125
  
  	@Resource(name = "paperclassteacherService")
bed6e1fc   孙向锦   添加其他功能
126
  	private PaperClassTeacherManager paperclassteacherService;
91a745c9   孙向锦   完善后台功能
127
128
  
  	@Resource(name = "paperquestionService")
bed6e1fc   孙向锦   添加其他功能
129
  	private PaperQuestionManager paperquestionService;
91a745c9   孙向锦   完善后台功能
130
131
  
  	@Resource(name = "papertypeService")
bed6e1fc   孙向锦   添加其他功能
132
  	private PaperTypeManager papertypeService;
91a745c9   孙向锦   完善后台功能
133
134
  
  	@Resource(name = "questionService")
bed6e1fc   孙向锦   添加其他功能
135
  	private QuestionManager questionService;
91a745c9   孙向锦   完善后台功能
136
137
  
  	@Resource(name = "questiontypeService")
bed6e1fc   孙向锦   添加其他功能
138
  	private QuestionTypeManager questiontypeService;
91a745c9   孙向锦   完善后台功能
139
140
  
  	@Resource(name = "schoolgradesubjectService")
bed6e1fc   孙向锦   添加其他功能
141
  	private SchoolGradeSubjectManager schoolgradesubjectService;
91a745c9   孙向锦   完善后台功能
142
143
  
  	@Resource(name = "sclassService")
bed6e1fc   孙向锦   添加其他功能
144
  	private SClassManager sclassService;
c34a91ee   Elvis   添加学生成绩接口
145
146
  
  	@Resource(name = "homeworkService")
694fbd54   孙向锦   添加作业管理模块
147
  	private HomeworkManager homeworkService;
c34a91ee   Elvis   添加学生成绩接口
148
  
91a745c9   孙向锦   完善后台功能
149
  	@Resource(name = "studentService")
bed6e1fc   孙向锦   添加其他功能
150
  	private StudentManager studentService;
91a745c9   孙向锦   完善后台功能
151
152
  
  	@Resource(name = "subjectService")
bed6e1fc   孙向锦   添加其他功能
153
  	private SubjectManager subjectService;
91a745c9   孙向锦   完善后台功能
154
155
  
  	@Resource(name = "teacherService")
bed6e1fc   孙向锦   添加其他功能
156
  	private TeacherManager teacherService;
c34a91ee   Elvis   添加学生成绩接口
157
158
  
  	@Resource(name = "headmasterService")
48d44272   孙向锦   添加一些action
159
  	private HeadmasterManager headmasterService;
91a745c9   孙向锦   完善后台功能
160
161
  
  	@Resource(name = "testpaperinfoService")
bed6e1fc   孙向锦   添加其他功能
162
163
  	private TestPaperInfoManager testpaperinfoService;
  
91a745c9   孙向锦   完善后台功能
164
165
166
167
168
169
  	@Resource(name = "testpaperService")
  	private TestPaperManager testpaperService;
  
  	@Resource(name = "studenttestService")
  	private StudentTestManager studenttestService;
  
bed6e1fc   孙向锦   添加其他功能
170
171
172
173
174
  	@Resource(name = "feedbackService")
  	private FeedbackManager feedbackService;
  
  	@Resource(name = "problemphenomenonService")
  	private ProblemPhenomenonManager problemphenomenonService;
91a745c9   孙向锦   完善后台功能
175
  
bed6e1fc   孙向锦   添加其他功能
176
  	@Resource(name = "v1Service")
91a745c9   孙向锦   完善后台功能
177
  	private V1Manager v1Service;
ce70231e   孙向锦   增加接口
178
179
  
  	@Resource(name = "softwareversionService")
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
180
  	private SoftwareVersionManager softwareversionService;
ce70231e   孙向锦   增加接口
181
182
  
  	@Resource(name = "attachkeyboardService")
9f161055   孙向锦   修改高斯客户反馈
183
  	private AttachKeyboardManager attachkeyboardService;
ce70231e   孙向锦   增加接口
184
185
  
  	@Resource(name = "networkstatisticsService")
9338b563   孙向锦   添加报表
186
  	private NetworkStatisticsManager networkstatisticsService;
ce70231e   孙向锦   增加接口
187
188
  
  	@Resource(name = "eventService")
9338b563   孙向锦   添加报表
189
  	private EventManager eventService;
ce70231e   孙向锦   增加接口
190
191
  
  	@Resource(name = "userService")
d3d7b2ca   孙向锦   修改表格固定
192
  	private UserManager userService;
91a745c9   孙向锦   完善后台功能
193
  
ce70231e   孙向锦   增加接口
194
195
  	@Resource(name = "teachingmaterialService")
  	private TeachingMaterialManager teachingmaterialService;
107fa3a0   孙向锦   修改试卷单选多远混合出题
196
  
c617106f   孙向锦   添加即时测功能
197
198
  	@Resource(name = "textbookService")
  	private TextbookManager textbookService;
2ad7ca45   孙向锦   试卷bug修改
199
200
  
  	@Resource(name = "cacheService")
ce70231e   孙向锦   增加接口
201
  	private CacheManager cacheService;
c34a91ee   Elvis   添加学生成绩接口
202
203
  
  	@Resource(name = "homeworkproblemService")
416902b7   孙向锦   添加课后作业部分API
204
  	private HomeworkProblemManager homeworkproblemService;
c34a91ee   Elvis   添加学生成绩接口
205
206
  
  	@Resource(name = "homeworkReporService")
a479f295   孙向锦   添加了报表逻辑
207
  	private HomeworkReportManager homeworkReporkService;
c34a91ee   Elvis   添加学生成绩接口
208
  
2ad7ca45   孙向锦   试卷bug修改
209
  	/**
107fa3a0   孙向锦   修改试卷单选多远混合出题
210
211
  	 * 登录 可以通过账号密码登录、 可以通过教师卡登录
  	 * 
2ad7ca45   孙向锦   试卷bug修改
212
213
214
  	 * @return
  	 * @throws Exception
  	 */
bed6e1fc   孙向锦   添加其他功能
215
216
217
  	@RequestMapping(value = "/login", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object login() throws Exception {
3371dbc6   孙向锦   0720 版本
218
  		event("apilogin");
bed6e1fc   孙向锦   添加其他功能
219
220
  		PageData pd = this.getPageData();
  		ResponseGson<PageData> res = new ResponseGson();
91a745c9   孙向锦   完善后台功能
221
  		if (!pd.containsKey("ACCOUT")) {
bed6e1fc   孙向锦   添加其他功能
222
223
  			pd.put("ACCOUT", pd.get("USERNAME"));
  		}
ce70231e   孙向锦   增加接口
224
225
226
  		if (((pd.containsKey("USERNAME") || (pd.containsKey("ACCOUT") && pd
  				.get("ACCOUT") != null)) && pd.containsKey("PASSWORD"))
  				|| pd.containsKey("KEYPAD_ID")) {
48d44272   孙向锦   添加一些action
227
228
229
230
231
232
233
234
235
236
237
238
239
  			PageData eventPd = new PageData();
  			eventPd.put("EVENT_ID", get32UUID());
  			eventPd.put("EVENT_NAME", "login");
  			eventPd.put("EVENT_USER", pd.getString("USERNAME"));
  			eventPd.put("EVENT_TYPE", "0");
  			eventPd.put("EVENT_START_TIME", Tools.date2Str(new Date()));
  			if (pd.getString("CLIENT_ID") != null) {
  				eventPd.put("CLIENT_ID", pd.getString("CLIENT_ID"));
  			} else {
  				eventPd.put("CLIENT_ID", "CLIENT");
  			}
  			eventPd.put("EVENT_IP", getRemoteIp());
  			eventService.save(eventPd);
c34a91ee   Elvis   添加学生成绩接口
240
  
bed6e1fc   孙向锦   添加其他功能
241
  			PageData pageData = teacherService.getUserInfo(pd);
c34a91ee   Elvis   添加学生成绩接口
242
  			if (pageData == null) {
d8407bb2   孙向锦   修复部分bug
243
244
245
246
247
  				pd.put("PASSWORD",
  						new SimpleHash("SHA-1", pd.getString("ACCOUT"), pd
  								.getString("PASSWORD")).toString());
  				pageData = teacherService.getUserInfo(pd);
  			}
c34a91ee   Elvis   添加学生成绩接口
248
249
  			PageData headerMaster = headmasterService
  					.findByUsenameAndPassword(pd);
91a745c9   孙向锦   完善后台功能
250
251
  			if (pageData != null && pageData.getString("ID") != null) {
  				pageData.put("PASSWORD", "");// 返回参数中不返回密码
bed6e1fc   孙向锦   添加其他功能
252
253
254
  				PageData pt = new PageData();
  				pt.put("TEACHER_ID", pageData.get("ID"));
  				// 在任课表中查找老师教哪些班级,然后查出班级信息
91a745c9   孙向锦   完善后台功能
255
256
257
  				List<PageData> classInfoList = v1Service
  						.getTeacherClassInfo(pt);
  
bed6e1fc   孙向锦   添加其他功能
258
259
  				pageData.put("classInfoList", classInfoList);
  				// 在认可表中查找老师教哪些科目,然后查出科目信息
91a745c9   孙向锦   完善后台功能
260
261
  				List<PageData> subjectList = v1Service
  						.getTeacherSubjectInfo(pt);
bed6e1fc   孙向锦   添加其他功能
262
263
  				// 一个sql语句完成。
  				pageData.put("subjectList", subjectList);
91a745c9   孙向锦   完善后台功能
264
  
bed6e1fc   孙向锦   添加其他功能
265
  				pageData.remove("SUBJECT_IDS");
ce70231e   孙向锦   增加接口
266
  
48d44272   孙向锦   添加一些action
267
  				pageData.put("role", "teacher");
bed6e1fc   孙向锦   添加其他功能
268
269
  				res.setData(pageData);
  				// 填充数据到返回数据中
c34a91ee   Elvis   添加学生成绩接口
270
271
  			} else if (headerMaster != null
  					&& headerMaster.get("HEADMASTER_ID") != null) {
48d44272   孙向锦   添加一些action
272
  				headerMaster.put("role", "headermaster");
c34a91ee   Elvis   添加学生成绩接口
273
274
275
  				List<PageData> classInfoList = sclassService
  						.listAll(headerMaster);
  				for (PageData pttd : classInfoList) {
015d5970   孙向锦   更新删除接口
276
277
278
279
280
281
  					pttd.put("CLASS_ID", pttd.get("ID"));
  					pttd.remove("ID");
  					pttd.remove("HEADMASTER_ID");
  					pttd.remove("SCHOOL_ID");
  					pttd.remove("CLASS_TYPE");
  				}
48d44272   孙向锦   添加一些action
282
  				headerMaster.put("classInfoList", classInfoList);
015d5970   孙向锦   更新删除接口
283
284
  				headerMaster.remove("USERNAME");
  				headerMaster.remove("PASSWORD");
a479f295   孙向锦   添加了报表逻辑
285
  				res.setData(headerMaster);
c34a91ee   Elvis   添加学生成绩接口
286
287
  
  			} else {
bed6e1fc   孙向锦   添加其他功能
288
289
  				res.set1Error();
  			}
91a745c9   孙向锦   完善后台功能
290
  		} else {
bed6e1fc   孙向锦   添加其他功能
291
292
  			res.set1Error();
  		}
91a745c9   孙向锦   完善后台功能
293
  
bed6e1fc   孙向锦   添加其他功能
294
295
  		return res.toJson();
  	}
107fa3a0   孙向锦   修改试卷单选多远混合出题
296
  
c617106f   孙向锦   添加即时测功能
297
  	/**
107fa3a0   孙向锦   修改试卷单选多远混合出题
298
299
  	 * 登录 可以通过账号密码登录、 可以通过教师卡登录
  	 * 
c617106f   孙向锦   添加即时测功能
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/userinfo", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object userinfo() throws Exception {
  		event("userinfo");
  		PageData pd = this.getPageData();
  		ResponseGson<PageData> res = new ResponseGson();
  		PageData pageData = teacherService.findById(pd);
  		if (pageData != null && pageData.getString("ID") != null) {
  			pageData.put("PASSWORD", "");// 返回参数中不返回密码
  			PageData pt = new PageData();
  			pt.put("TEACHER_ID", pageData.get("ID"));
  			// 在任课表中查找老师教哪些班级,然后查出班级信息
107fa3a0   孙向锦   修改试卷单选多远混合出题
315
316
  			List<PageData> classInfoList = v1Service.getTeacherClassInfo(pt);
  
c617106f   孙向锦   添加即时测功能
317
318
  			pageData.put("classInfoList", classInfoList);
  			// 在认可表中查找老师教哪些科目,然后查出科目信息
107fa3a0   孙向锦   修改试卷单选多远混合出题
319
  			List<PageData> subjectList = v1Service.getTeacherSubjectInfo(pt);
c617106f   孙向锦   添加即时测功能
320
321
  			// 一个sql语句完成。
  			pageData.put("subjectList", subjectList);
107fa3a0   孙向锦   修改试卷单选多远混合出题
322
  
c617106f   孙向锦   添加即时测功能
323
  			pageData.remove("SUBJECT_IDS");
107fa3a0   孙向锦   修改试卷单选多远混合出题
324
  
c617106f   孙向锦   添加即时测功能
325
326
327
328
329
330
331
332
333
334
335
336
337
  			PageData eventPd = new PageData();
  			eventPd.put("EVENT_ID", get32UUID());
  			eventPd.put("EVENT_NAME", "login");
  			eventPd.put("EVENT_USER", pageData.getString("ID"));
  			eventPd.put("EVENT_TYPE", "0");
  			eventPd.put("EVENT_START_TIME", Tools.date2Str(new Date()));
  			if (pd.getString("CLIENT_ID") != null) {
  				eventPd.put("CLIENT_ID", pd.getString("CLIENT_ID"));
  			} else {
  				eventPd.put("CLIENT_ID", "CLIENT");
  			}
  			eventPd.put("EVENT_IP", getRemoteIp());
  			eventService.save(eventPd);
107fa3a0   孙向锦   修改试卷单选多远混合出题
338
  
c617106f   孙向锦   添加即时测功能
339
340
341
342
343
  			res.setData(pageData);
  			// 填充数据到返回数据中
  		} else {
  			res.set1Error();
  		}
107fa3a0   孙向锦   修改试卷单选多远混合出题
344
  
c617106f   孙向锦   添加即时测功能
345
346
  		return res.toJson();
  	}
91a745c9   孙向锦   完善后台功能
347
  
2ad7ca45   孙向锦   试卷bug修改
348
  	/**
107fa3a0   孙向锦   修改试卷单选多远混合出题
349
350
  	 * 查询班级 班级及班级学生详细信息
  	 * 
2ad7ca45   孙向锦   试卷bug修改
351
352
353
  	 * @return
  	 * @throws Exception
  	 */
bed6e1fc   孙向锦   添加其他功能
354
355
356
  	@RequestMapping(value = "/class", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object sclass() throws Exception {
3371dbc6   孙向锦   0720 版本
357
  		event("sclass");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
358
  		long cur = System.currentTimeMillis();
bed6e1fc   孙向锦   添加其他功能
359
  		PageData pd = this.getPageData();
bed6e1fc   孙向锦   添加其他功能
360
  		if (pd.containsKey("ID")) {
4fd2e08c   孙向锦   修复接口中的bug
361
  			ResponseGson<PageData> res = new ResponseGson();
bed6e1fc   孙向锦   添加其他功能
362
363
364
365
  			PageData pageData = sclassService.findById(pd);
  			if (pageData != null && pageData.containsKey("ID")) {
  				PageData pt = new PageData();
  				pt.put("SCLASS_ID", pageData.get("ID"));
91a745c9   孙向锦   完善后台功能
366
  				List<PageData> studentList = v1Service.getClassStudent(pt);
bed6e1fc   孙向锦   添加其他功能
367
  				pageData.put("studentList", studentList);
9f161055   孙向锦   修改高斯客户反馈
368
  				pt.put("CLASS_ID", pageData.get("ID"));
ce70231e   孙向锦   增加接口
369
370
  				List<PageData> keyboards = attachkeyboardService
  						.listAllClassId(pt);
9f161055   孙向锦   修改高斯客户反馈
371
  				pageData.put("keyboards", keyboards);
bed6e1fc   孙向锦   添加其他功能
372
373
374
375
  				res.setData(pageData);
  			} else {
  				res.set2Error();
  			}
ce70231e   孙向锦   增加接口
376
377
  			logger.info("class cost time : "
  					+ (System.currentTimeMillis() - cur));
4fd2e08c   孙向锦   修复接口中的bug
378
379
380
381
382
  			return res.toJson();
  		} else {
  			ResponseGson<List<PageData>> res = new ResponseGson();
  			List<PageData> list = sclassService.listAll(pd);
  			res.setData(list);
ce70231e   孙向锦   增加接口
383
384
  			logger.info("class cost time : "
  					+ (System.currentTimeMillis() - cur));
4fd2e08c   孙向锦   修复接口中的bug
385
  			return res.toJson();
4fd2e08c   孙向锦   修复接口中的bug
386
387
  		}
  	}
ce70231e   孙向锦   增加接口
388
  
2ad7ca45   孙向锦   试卷bug修改
389
390
  	/**
  	 * 问题类型
107fa3a0   孙向锦   修改试卷单选多远混合出题
391
  	 * 
2ad7ca45   孙向锦   试卷bug修改
392
393
394
  	 * @return
  	 * @throws Exception
  	 */
4fd2e08c   孙向锦   修复接口中的bug
395
396
397
  	@RequestMapping(value = "/questiontype", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object questiontype() throws Exception {
3371dbc6   孙向锦   0720 版本
398
  		event("questiontype");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
399
  		long cur = System.currentTimeMillis();
4fd2e08c   孙向锦   修复接口中的bug
400
401
402
403
  		PageData pd = this.getPageData();
  		ResponseGson<List<PageData>> res = new ResponseGson();
  		List<PageData> list = questiontypeService.listAll(pd);
  		res.setData(list);
ce70231e   孙向锦   增加接口
404
405
  		logger.info("questiontype cost time : "
  				+ (System.currentTimeMillis() - cur));
4fd2e08c   孙向锦   修复接口中的bug
406
407
  		return res.toJson();
  	}
ce70231e   孙向锦   增加接口
408
  
2ad7ca45   孙向锦   试卷bug修改
409
410
  	/**
  	 * 班级类型
107fa3a0   孙向锦   修改试卷单选多远混合出题
411
  	 * 
2ad7ca45   孙向锦   试卷bug修改
412
413
414
  	 * @return
  	 * @throws Exception
  	 */
4fd2e08c   孙向锦   修复接口中的bug
415
416
417
  	@RequestMapping(value = "/classtype", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object classtype() throws Exception {
3371dbc6   孙向锦   0720 版本
418
  		event("classtype");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
419
  		long cur = System.currentTimeMillis();
4fd2e08c   孙向锦   修复接口中的bug
420
421
422
423
  		PageData pd = this.getPageData();
  		ResponseGson<List<PageData>> res = new ResponseGson();
  		List<PageData> list = classtypeService.listAll(pd);
  		res.setData(list);
ce70231e   孙向锦   增加接口
424
425
  		logger.info("classtype cost time : "
  				+ (System.currentTimeMillis() - cur));
4fd2e08c   孙向锦   修复接口中的bug
426
427
  		return res.toJson();
  	}
ce70231e   孙向锦   增加接口
428
  
2ad7ca45   孙向锦   试卷bug修改
429
  	/**
107fa3a0   孙向锦   修改试卷单选多远混合出题
430
431
  	 * 年级 年级类型
  	 * 
2ad7ca45   孙向锦   试卷bug修改
432
433
434
  	 * @return
  	 * @throws Exception
  	 */
4fd2e08c   孙向锦   修复接口中的bug
435
436
437
  	@RequestMapping(value = "/grade", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object grade() throws Exception {
3371dbc6   孙向锦   0720 版本
438
  		event("grade");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
439
  		long cur = System.currentTimeMillis();
4fd2e08c   孙向锦   修复接口中的bug
440
441
442
443
444
  		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   孙向锦   完善后台功能
445
  		} else {
4fd2e08c   孙向锦   修复接口中的bug
446
447
  			List<PageData> list = schoolgradesubjectService.listAllGrade(pd);
  			res.setData(list);
bed6e1fc   孙向锦   添加其他功能
448
  		}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
449
  		logger.info("class cost time : " + (System.currentTimeMillis() - cur));
bed6e1fc   孙向锦   添加其他功能
450
451
  		return res.toJson();
  	}
ce70231e   孙向锦   增加接口
452
  
2ad7ca45   孙向锦   试卷bug修改
453
454
  	/**
  	 * 科目
107fa3a0   孙向锦   修改试卷单选多远混合出题
455
  	 * 
2ad7ca45   孙向锦   试卷bug修改
456
457
458
  	 * @return
  	 * @throws Exception
  	 */
4fd2e08c   孙向锦   修复接口中的bug
459
460
461
  	@RequestMapping(value = "/subject", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object subject() throws Exception {
3371dbc6   孙向锦   0720 版本
462
  		event("subject");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
463
  		long cur = System.currentTimeMillis();
4fd2e08c   孙向锦   修复接口中的bug
464
465
466
467
468
469
470
471
472
  		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   孙向锦   添加软件管理模块。对软件形成统一的管理
473
  		logger.info("subject cost time : " + (System.currentTimeMillis() - cur));
4fd2e08c   孙向锦   修复接口中的bug
474
475
  		return res.toJson();
  	}
107fa3a0   孙向锦   修改试卷单选多远混合出题
476
  
c617106f   孙向锦   添加即时测功能
477
478
  	/**
  	 * 科目
107fa3a0   孙向锦   修改试卷单选多远混合出题
479
  	 * 
c617106f   孙向锦   添加即时测功能
480
481
482
483
484
485
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/subjectname", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object subjectName() throws Exception {
757dfed6   孙向锦   样例报表
486
  		event("subjectName");
c617106f   孙向锦   添加即时测功能
487
488
489
490
491
492
493
494
495
496
497
498
499
  		long cur = System.currentTimeMillis();
  		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);
  		}
  		logger.info("subject cost time : " + (System.currentTimeMillis() - cur));
  		return res.toJson();
  	}
91a745c9   孙向锦   完善后台功能
500
  
2ad7ca45   孙向锦   试卷bug修改
501
502
  	/**
  	 * 键盘扫描
107fa3a0   孙向锦   修改试卷单选多远混合出题
503
  	 * 
2ad7ca45   孙向锦   试卷bug修改
504
505
506
  	 * @return
  	 * @throws Exception
  	 */
bed6e1fc   孙向锦   添加其他功能
507
508
509
  	@RequestMapping(value = "/keypadscan", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object keypadScan() throws Exception {
3371dbc6   孙向锦   0720 版本
510
  		event("keypadScan");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
511
  		long cur = System.currentTimeMillis();
bed6e1fc   孙向锦   添加其他功能
512
  		PageData pd = this.getPageData();
91a745c9   孙向锦   完善后台功能
513
514
515
516
517
  		ResponseGson<String> res = new ResponseGson();
  		String ID = get32UUID();
  		pd.put("KEYPADCHECK_ID", ID); // 主键
  		pd.put("CREATE_DATE", Tools.date2Str(new Date())); // 创建时间
  		try {
bed6e1fc   孙向锦   添加其他功能
518
  			keypadcheckService.save(pd);
91a745c9   孙向锦   完善后台功能
519
  			res.setData(ID);
bed6e1fc   孙向锦   添加其他功能
520
  			res.setSuccess();
91a745c9   孙向锦   完善后台功能
521
  		} catch (Exception ex) {
bed6e1fc   孙向锦   添加其他功能
522
523
  			res.setDataError();
  		}
ce70231e   孙向锦   增加接口
524
525
  		logger.info("keypadScan cost time : "
  				+ (System.currentTimeMillis() - cur));
bed6e1fc   孙向锦   添加其他功能
526
527
  		return res.toJson();
  	}
91a745c9   孙向锦   完善后台功能
528
  
2ad7ca45   孙向锦   试卷bug修改
529
530
531
532
533
534
  	/**
  	 * showcount 数量 currentpage 当前页码
  	 * 
  	 * @return
  	 * @throws Exception
  	 */
bed6e1fc   孙向锦   添加其他功能
535
536
537
  	@RequestMapping(value = "/paper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object paper() throws Exception {
3371dbc6   孙向锦   0720 版本
538
  		event("paper");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
539
  		long cur = System.currentTimeMillis();
bed6e1fc   孙向锦   添加其他功能
540
541
  		PageData pd = this.getPageData();
  		ResponseGson<List<PageData>> res = new ResponseGson<List<PageData>>();
4b6a5239   孙向锦   管理员界面
542
  		if (pd.containsKey("PAPER_TYPE")) {
757dfed6   孙向锦   样例报表
543
544
  			String CURRENTPAGE = pd.getString("CURRENTPAGE");
  			String SHOWCOUNT = pd.getString("SHOWCOUNT");
107fa3a0   孙向锦   修改试卷单选多远混合出题
545
546
547
  			if (CURRENTPAGE != null && SHOWCOUNT != null
  					&& !"".equals(CURRENTPAGE.trim())
  					&& !"".equals(SHOWCOUNT.trim())) {
757dfed6   孙向锦   样例报表
548
549
  				int currentPage = Integer.parseInt(CURRENTPAGE);
  				int showcount = Integer.parseInt(SHOWCOUNT);
107fa3a0   孙向锦   修改试卷单选多远混合出题
550
551
  				currentPage = (currentPage > 0 ? currentPage - 1 : 0)
  						* showcount;
ddbc622f   孙向锦   0829版本
552
  				pd.put("CURRENTPAGE", "" + currentPage);
bed6e1fc   孙向锦   添加其他功能
553
  			}
d7525cae   jack   1.学生老师导入导出
554
  			PageData p = teacherService.findById2(pd.get("USER_ID").toString());
c34a91ee   Elvis   添加学生成绩接口
555
  			if (p != null) {
d7525cae   jack   1.学生老师导入导出
556
  				pd.put("SCHOOL_ID", p.get("SCHOOL_ID"));
c34a91ee   Elvis   添加学生成绩接口
557
558
  				// pd.remove("USER_ID");
  			} else {
d7525cae   jack   1.学生老师导入导出
559
560
  				pd.put("SCHOOL_ID", "");
  			}
c34a91ee   Elvis   添加学生成绩接口
561
  			if (pd.getString("PAPER_TYPE").equals("2")) {
f4a73594   jack   1.增加班级统计报表和导出
562
563
  				pd.remove("USER_ID");
  			}
757dfed6   孙向锦   样例报表
564
  			List<PageData> pageList = paperService.listAllByType(pd);
bed6e1fc   孙向锦   添加其他功能
565
  			res.setData(pageList);
91a745c9   孙向锦   完善后台功能
566
  		} else {
757dfed6   孙向锦   样例报表
567
  			res.setDataError();
bed6e1fc   孙向锦   添加其他功能
568
  		}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
569
  		logger.info("paper cost time : " + (System.currentTimeMillis() - cur));
bed6e1fc   孙向锦   添加其他功能
570
571
  		return res.toJson();
  	}
91a745c9   孙向锦   完善后台功能
572
  
2ad7ca45   孙向锦   试卷bug修改
573
574
  	/**
  	 * 试卷详细信息
107fa3a0   孙向锦   修改试卷单选多远混合出题
575
  	 * 
2ad7ca45   孙向锦   试卷bug修改
576
577
578
  	 * @return
  	 * @throws Exception
  	 */
91a745c9   孙向锦   完善后台功能
579
  	@RequestMapping(value = "/paperinfo", produces = "application/json;charset=UTF-8")
bed6e1fc   孙向锦   添加其他功能
580
  	@ResponseBody
91a745c9   孙向锦   完善后台功能
581
  	public Object paperInfo() throws Exception {
3371dbc6   孙向锦   0720 版本
582
  		event("paperInfo");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
583
  		long cur = System.currentTimeMillis();
bed6e1fc   孙向锦   添加其他功能
584
  		PageData pd = this.getPageData();
757dfed6   孙向锦   样例报表
585
586
587
588
589
590
591
592
593
594
595
596
597
598
  		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"));
4b6a5239   孙向锦   管理员界面
599
  						paper.setSchool_id(ppd.getString("SCHOOL_ID"));
757dfed6   孙向锦   样例报表
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
  						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"));
a0eff87f   孙向锦   修改课后练bug
615
  							String ttcontent = qpd.getString("CONTENT");
c34a91ee   Elvis   添加学生成绩接口
616
617
  							ttcontent = ttcontent.replaceAll("<fill></fill>",
  									"______");
a0eff87f   孙向锦   修改课后练bug
618
  							question.setContent(ttcontent);
757dfed6   孙向锦   样例报表
619
620
621
622
623
624
625
626
627
628
629
630
631
  							question.setOption_num(qpd.getString("OPTION_NUM"));
  							question.setOption_content(qpd
  									.getString("OPTION_CONTENT"));
  							question.setDifficulty(qpd.getString("DIFFICULTY"));
  							question.setAnalysis(qpd.getString("ANALYSIS"));
  							question.setQuestion_from(qpd
  									.getString("QUESTION_FROM"));
  							question.setScore(qpd.getString("SCORE"));
  							question.setPart_score(qpd.getString("PART_SCORE"));
  							question.setQuestionType(qpd
  									.getString("PROBLEM_TYPE_ID"));
  							question.setRank(qpd.getString("RANK"));
  							question.setNo_name(qpd.getString("NO_NAME"));
bda221f4   孙向锦   0830版本
632
  							question.setQuestions(new ArrayList<Question>());
757dfed6   孙向锦   样例报表
633
634
635
  							if ("-1".equals("" + qpd.getString("P_ID"))) {
  								PageData pidPd = new PageData();
  								pidPd.put("PID", question.getQuestion_id());
757dfed6   孙向锦   样例报表
636
637
638
639
640
641
642
643
644
645
646
647
648
  								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"));
c34a91ee   Elvis   添加学生成绩接口
649
650
651
  									qq.setContent(q.getString("CONTENT")
  											.replaceAll("<fill></fill>",
  													"______"));
757dfed6   孙向锦   样例报表
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
  									qq.setOption_num(q.getString("OPTION_NUM"));
  									qq.setOption_content(q
  											.getString("OPTION_CONTENT"));
  									qq.setDifficulty(q.getString("DIFFICULTY"));
  									qq.setAnalysis(q.getString("ANALYSIS"));
  									qq.setQuestion_from(q
  											.getString("QUESTION_FROM"));
  									qq.setScore(q.getString("SCORE"));
  									qq.setPart_score(q.getString("PART_SCORE"));
  									qq.setQuestionType(qpd
  											.getString("PROBLEM_TYPE_ID"));
  									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);
  							}
  						}
  						// 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.toJson();
  	}
107fa3a0   孙向锦   修改试卷单选多远混合出题
692
693
  
  	/*	*//**
757dfed6   孙向锦   样例报表
694
  	 * 试卷详细信息
107fa3a0   孙向锦   修改试卷单选多远混合出题
695
  	 * 
757dfed6   孙向锦   样例报表
696
697
  	 * @return
  	 * @throws Exception
107fa3a0   孙向锦   修改试卷单选多远混合出题
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
  	 */
  	/*
  	 * @RequestMapping(value = "/paperinfo", produces =
  	 * "application/json;charset=UTF-8")
  	 * 
  	 * @ResponseBody public Object paperInfo() throws Exception {
  	 * event("paperInfo"); long cur = System.currentTimeMillis(); PageData pd =
  	 * this.getPageData(); ResponseGson<PageData> res = new
  	 * ResponseGson<PageData>(); if (pd.containsKey("PAPER_ID")) { try { try {
  	 * PageData ppd = paperService.findById(pd); if (ppd != null) {
  	 * List<PageData> questList = v1Service .getTestPaperInfo(pd);
  	 * ppd.put("QUESTIONS", questList); for (PageData qpd : questList) {
  	 * 
  	 * String optionContent = qpd .getString("OPTION_CONTENT"); if
  	 * (optionContent != null && optionContent.startsWith("[") &&
  	 * optionContent.endsWith("]")) { String[] options =
  	 * optionContent.substring(1, optionContent.length() - 1).split(",");
  	 * qpd.put("OPTION_CONTENT", options); } else { qpd.put("OPTION_CONTENT",
  	 * new String[] { optionContent }); } if ("-1".equals("" +
  	 * qpd.getString("P_ID"))) { PageData pidPd = new PageData();
  	 * pidPd.put("PID", qpd.getString("QUESTION_ID")); List<PageData> qs =
  	 * v1Service .getQuestionsByPID(pidPd); for (PageData pcd : qs) { String
  	 * optionContent1 = pcd .getString("OPTION_CONTENT"); if (optionContent1 !=
  	 * null && optionContent1.startsWith("[") && optionContent1.endsWith("]")) {
  	 * String[] options = optionContent1 .substring( 1, optionContent1.length()
  	 * - 1) .split(","); pcd.put("OPTION_CONTENT", options); } else {
  	 * pcd.put("OPTION_CONTENT", new String[] { optionContent1 }); } String[]
  	 * keys = new String[pcd.keySet().size()]; pcd.keySet().toArray(keys);
  	 * Iterator map1it = pcd.entrySet().iterator(); for (String key : keys) {
  	 * pcd.put(key.toLowerCase(),pcd.get(key)); pcd.remove(key.toUpperCase()); }
  	 * } qpd.put("QUESTIONS", qs); }
  	 * 
  	 * String[] keys = new String[qpd.keySet().size()];
  	 * qpd.keySet().toArray(keys); for (String key : keys) {
  	 * qpd.put(key.toLowerCase(), qpd.get(key)); qpd.remove(key.toUpperCase());
  	 * }
  	 * 
  	 * } String[] keys = new String[ppd.keySet().size()];
  	 * ppd.keySet().toArray(keys); for (String key : keys) {
  	 * ppd.put(key.toLowerCase(), ppd.get(key)); ppd.remove(key.toUpperCase());
  	 * } // pd.put("JSON", paper.toJson()); res.setData(ppd);
  	 * logger.info(res.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.toJson(); }
  	 *//**
757dfed6   孙向锦   样例报表
746
  	 * 试卷详细信息
107fa3a0   孙向锦   修改试卷单选多远混合出题
747
  	 * 
757dfed6   孙向锦   样例报表
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/paperinfo2", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object paperInfo2() throws Exception {
  		event("paperInfo2");
  		long cur = System.currentTimeMillis();
  		PageData pd = this.getPageData();
  		ResponseGson<PageData> res = new ResponseGson<PageData>();
  		if (pd.containsKey("PAPER_ID")) {
  			try {
  				try {
  					PageData ppd = paperService.findById(pd);
  					if (ppd != null) {
  						List<PageData> questList = v1Service
  								.getTestPaperInfo(pd);
  						ppd.put("QUESTIONS", questList);
  						for (PageData qpd : questList) {
107fa3a0   孙向锦   修改试卷单选多远混合出题
767
  
757dfed6   孙向锦   样例报表
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
  							String optionContent = qpd
  									.getString("OPTION_CONTENT");
  							if (optionContent != null
  									&& optionContent.startsWith("[")
  									&& optionContent.endsWith("]")) {
  								String[] options = optionContent.substring(1,
  										optionContent.length() - 1).split(",");
  								qpd.put("OPTION_CONTENT", options);
  							} else {
  								qpd.put("OPTION_CONTENT",
  										new String[] { optionContent });
  							}
  							if ("-1".equals("" + qpd.getString("P_ID"))) {
  								PageData pidPd = new PageData();
  								pidPd.put("PID", qpd.getString("QUESTION_ID"));
  								List<PageData> qs = v1Service
  										.getQuestionsByPID(pidPd);
  								for (PageData pcd : qs) {
  									String optionContent1 = pcd
  											.getString("OPTION_CONTENT");
  									if (optionContent1 != null
  											&& optionContent1.startsWith("[")
  											&& optionContent1.endsWith("]")) {
  										String[] options = optionContent1
  												.substring(
  														1,
  														optionContent1.length() - 1)
107fa3a0   孙向锦   修改试卷单选多远混合出题
795
  												.split(",");
757dfed6   孙向锦   样例报表
796
797
798
799
800
801
802
803
  										pcd.put("OPTION_CONTENT", options);
  									} else {
  										pcd.put("OPTION_CONTENT",
  												new String[] { optionContent1 });
  									}
  								}
  								qpd.put("QUESTIONS", qs);
  							}
107fa3a0   孙向锦   修改试卷单选多远混合出题
804
  
757dfed6   孙向锦   样例报表
805
806
807
  						}
  						res.setData(ppd);
  						logger.info(res.toJson());
107fa3a0   孙向锦   修改试卷单选多远混合出题
808
  
338594c8   孙向锦   添加教师端页面
809
  					}
91a745c9   孙向锦   完善后台功能
810
811
  				} catch (Exception ex) {
  					ex.printStackTrace();
338594c8   孙向锦   添加教师端页面
812
  				}
91a745c9   孙向锦   完善后台功能
813
  			} catch (Exception ex) {
338594c8   孙向锦   添加教师端页面
814
815
  				ex.printStackTrace();
  				res.setError();
bed6e1fc   孙向锦   添加其他功能
816
  			}
91a745c9   孙向锦   完善后台功能
817
  		} else {
bed6e1fc   孙向锦   添加其他功能
818
819
  			res.setOtherError();
  		}
ce70231e   孙向锦   增加接口
820
821
  		logger.info("paperInfo cost time : "
  				+ (System.currentTimeMillis() - cur));
bed6e1fc   孙向锦   添加其他功能
822
823
  		return res.toJson();
  	}
107fa3a0   孙向锦   修改试卷单选多远混合出题
824
  
c617106f   孙向锦   添加即时测功能
825
826
  	/**
  	 * 试卷详细信息
107fa3a0   孙向锦   修改试卷单选多远混合出题
827
  	 * 
c617106f   孙向锦   添加即时测功能
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/testpaperinfo", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object testpaperinfo() throws Exception {
  		event("testpaperinfo");
  		long cur = System.currentTimeMillis();
  		PageData pd = this.getPageData();
  		ResponseGson<PageData> res = new ResponseGson();
  		String paperId = pd.getString("ID");
  		if (!StringUtils.isEmpty(paperId)) {
  			try {
  				pd.put("TESTPAPER_ID", paperId);
  				PageData testPd = testpaperService.findById(pd);
  				if (testPd != null) {
  					PageData testInfof = new PageData();
  					testInfof.put("PAPER_ID", testPd.getString("PAPER_ID"));
  					testInfof.put("TEST_ID", paperId);
107fa3a0   孙向锦   修改试卷单选多远混合出题
847
848
849
  					List<PageData> list = testpaperinfoService
  							.listTestPaperQuestionIDs(testInfof);
  					for (PageData pqd : list) {
c617106f   孙向锦   添加即时测功能
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
  						PageData tpqd = questionService.findById(pqd);
  						pqd.putAll(tpqd);
  						pqd.remove("P_ID");
  						pqd.remove("SUBJECT_ID");
  						pqd.remove("PROBLEM_TYPE_ID");
  						pqd.remove("CHAPTER_ID");
  						pqd.remove("TEACHER_ID");
  						pqd.remove("SCHOOL_ID");
  						pqd.remove("SUG_SCORE");
  						pqd.remove("SUG_PART_SCORE");
  						pqd.remove("USER_ID");
  						pqd.remove("CREATE_DATE");
  						pqd.remove("QUESTION_FROM");
  						pqd.remove("REMARK");
  						pqd.put("TEST_ID", paperId);
107fa3a0   孙向锦   修改试卷单选多远混合出题
865
866
  						List<PageData> listinfo = testpaperinfoService
  								.listTestPaperQuestionIDinfo(pqd);
c617106f   孙向锦   添加即时测功能
867
  						List<PageData> answerInfos = new ArrayList<PageData>();
757dfed6   孙向锦   样例报表
868
  						List<String> answerList = new ArrayList<String>();
107fa3a0   孙向锦   修改试卷单选多远混合出题
869
  						for (PageData pid : listinfo) {
c617106f   孙向锦   添加即时测功能
870
871
  							String answer = pid.getString("ANSWER");
  							PageData answerPd = null;
107fa3a0   孙向锦   修改试卷单选多远混合出题
872
873
874
875
876
  							if (answerInfos.size() > 0) {
  								answerPd = answerInfos
  										.get(answerInfos.size() - 1);
  								if (!answer
  										.equals(answerPd.getString("ANSWER"))) {
c617106f   孙向锦   添加即时测功能
877
878
  									answerPd = new PageData();
  									answerPd.put("ANSWER", answer);
107fa3a0   孙向锦   修改试卷单选多远混合出题
879
880
  									answerPd.put("ISRIGHT",
  											pid.getString("RIGHT"));
c617106f   孙向锦   添加即时测功能
881
  									answerInfos.add(answerPd);
757dfed6   孙向锦   样例报表
882
  									answerList.add(answer);
c617106f   孙向锦   添加即时测功能
883
  								}
107fa3a0   孙向锦   修改试卷单选多远混合出题
884
  							} else {
c617106f   孙向锦   添加即时测功能
885
886
887
888
  								answerPd = new PageData();
  								answerPd.put("ANSWER", answer);
  								answerPd.put("ISRIGHT", pid.getString("RIGHT"));
  								answerInfos.add(answerPd);
757dfed6   孙向锦   样例报表
889
  								answerList.add(answer);
c617106f   孙向锦   添加即时测功能
890
891
  							}
  							String strCount = answerPd.getString("COUNT");
107fa3a0   孙向锦   修改试卷单选多远混合出题
892
893
894
895
896
897
  							int count = 0;
  							if (strCount != null) {
  								try {
  									count = Integer.parseInt(strCount);
  								} catch (NumberFormatException ex) {
  								}
c617106f   孙向锦   添加即时测功能
898
  							}
107fa3a0   孙向锦   修改试卷单选多远混合出题
899
  							count++;
c617106f   孙向锦   添加即时测功能
900
901
  							answerPd.put("COUNT", count);
  						}
757dfed6   孙向锦   样例报表
902
903
  						String questionNumStr = pqd.getString("OPTION_NUM");
  						int questionNum = Integer.parseInt(questionNumStr);
107fa3a0   孙向锦   修改试卷单选多远混合出题
904
905
906
907
  						for (int i = 0; i < questionNum; i++) {
  							if ((!answerList.contains("" + (char) ('A' + i)))
  									&& !(answerList.contains(""
  											+ (char) ('a' + i)))) {
757dfed6   孙向锦   样例报表
908
  								PageData answerPd = new PageData();
107fa3a0   孙向锦   修改试卷单选多远混合出题
909
910
911
  								answerPd.put("ANSWER", "" + (char) ('A' + i));
  								answerPd.put("ISRIGHT", pqd.get("ANSWER")
  										.equals(('A' + i)) ? "1" : "0");
757dfed6   孙向锦   样例报表
912
913
914
915
  								answerPd.put("COUNT", 0);
  								answerInfos.add(answerPd);
  							}
  						}
107fa3a0   孙向锦   修改试卷单选多远混合出题
916
917
918
919
920
921
922
923
924
  						Collections.sort(answerInfos,
  								new Comparator<PageData>() {
  
  									@Override
  									public int compare(PageData p1, PageData p2) {
  										return p1.getString("ANSWER")
  												.compareToIgnoreCase(
  														p2.getString("ANSWER"));
  									}
757dfed6   孙向锦   样例报表
925
  
107fa3a0   孙向锦   修改试卷单选多远混合出题
926
  								});
c617106f   孙向锦   添加即时测功能
927
928
929
  						pqd.put("ANSWERINFO", answerInfos);
  						pqd.remove("TEST_ID");
  					}
107fa3a0   孙向锦   修改试卷单选多远混合出题
930
  					for (PageData pad : list) {
757dfed6   孙向锦   样例报表
931
  						String optionContent = pad.getString("OPTION_CONTENT");
107fa3a0   孙向锦   修改试卷单选多远混合出题
932
933
934
935
936
  						if (optionContent != null
  								&& optionContent.startsWith("[")
  								&& optionContent.endsWith("]")) {
  							String[] options = optionContent.substring(1,
  									optionContent.length() - 1).split(",");
757dfed6   孙向锦   样例报表
937
  							pad.put("OPTION_CONTENT", options);
107fa3a0   孙向锦   修改试卷单选多远混合出题
938
939
940
  						} else {
  							pad.put("OPTION_CONTENT",
  									new String[] { optionContent });
757dfed6   孙向锦   样例报表
941
942
  						}
  					}
c617106f   孙向锦   添加即时测功能
943
  					testPd.put("QUESTIONS", list);
107fa3a0   孙向锦   修改试卷单选多远混合出题
944
  
c617106f   孙向锦   添加即时测功能
945
946
947
948
949
950
951
952
953
954
955
956
  				}
  
  				res.setData(testPd);
  			} catch (Exception e) {
  				e.printStackTrace();
  				res.setError();
  			}
  		}
  		logger.info("testpaperinfo cost time:"
  				+ (System.currentTimeMillis() - cur));
  		return res.toJson();
  	}
107fa3a0   孙向锦   修改试卷单选多远混合出题
957
  
c617106f   孙向锦   添加即时测功能
958
959
  	/**
  	 * 试卷详细信息
107fa3a0   孙向锦   修改试卷单选多远混合出题
960
  	 * 
c617106f   孙向锦   添加即时测功能
961
962
963
964
965
966
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/questionintestreportinfo", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object questionInTestReportInfo() throws Exception {
757dfed6   孙向锦   样例报表
967
  		event("questionInTestReportInfo");
c617106f   孙向锦   添加即时测功能
968
969
970
971
972
973
974
975
  		long cur = System.currentTimeMillis();
  		PageData pd = this.getPageData();
  		ResponseGson<PageData> res = new ResponseGson();
  		if (pd.getString("QUESTION_ID") != null) {
  			String questionId = pd.getString("QUESTION_ID");
  			PageData pqd = new PageData();
  			pqd.put("QUESTION_ID", questionId);
  			PageData tpqd = questionService.findById(pqd);
757dfed6   孙向锦   样例报表
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
  			if (tpqd != null) {
  				pqd.putAll(tpqd);
  				pqd.remove("P_ID");
  				pqd.remove("SUBJECT_ID");
  				pqd.remove("PROBLEM_TYPE_ID");
  				pqd.remove("CHAPTER_ID");
  				pqd.remove("TEACHER_ID");
  				pqd.remove("SCHOOL_ID");
  				pqd.remove("SUG_SCORE");
  				pqd.remove("SUG_PART_SCORE");
  				pqd.remove("USER_ID");
  				pqd.remove("CREATE_DATE");
  				pqd.remove("QUESTION_FROM");
  				pqd.remove("REMARK");
  				String optionContent = pqd.getString("OPTION_CONTENT");
  				if (optionContent != null && optionContent.startsWith("[")
  						&& optionContent.endsWith("]")) {
  					String[] options = optionContent.substring(1,
  							optionContent.length() - 1).split(",");
  					pqd.put("OPTION_CONTENT", options);
  				} else {
  					pqd.put("OPTION_CONTENT", new String[] { optionContent });
  				}
  				if (pd.getString("TEST_ID") != null) {
  					pqd.put("TEST_ID", pd.getString("TEST_ID"));
  				}
  				List<PageData> listinfo = testpaperinfoService
  						.listTestPaperQuestionIDinfo(pqd);
  				List<PageData> answerInfos = new ArrayList<PageData>();
  				for (PageData pid : listinfo) {
  					String answer = pid.getString("ANSWER");
  					PageData answerPd = null;
  					if (answerInfos.size() > 0) {
  						answerPd = answerInfos.get(answerInfos.size() - 1);
  						if (!answer.equals(answerPd.getString("ANSWER"))) {
  							answerPd = new PageData();
  							answerPd.put("ANSWER", answer);
  							answerPd.put("ISRIGHT", pid.getString("RIGHT"));
  							answerInfos.add(answerPd);
  						}
  					} else {
c617106f   孙向锦   添加即时测功能
1017
1018
1019
1020
1021
  						answerPd = new PageData();
  						answerPd.put("ANSWER", answer);
  						answerPd.put("ISRIGHT", pid.getString("RIGHT"));
  						answerInfos.add(answerPd);
  					}
757dfed6   孙向锦   样例报表
1022
1023
1024
1025
1026
1027
1028
  					String strCount = answerPd.getString("COUNT");
  					int count = 0;
  					if (strCount != null) {
  						try {
  							count = Integer.parseInt(strCount);
  						} catch (NumberFormatException ex) {
  						}
c617106f   孙向锦   添加即时测功能
1029
  					}
757dfed6   孙向锦   样例报表
1030
1031
  					count++;
  					answerPd.put("COUNT", count);
c617106f   孙向锦   添加即时测功能
1032
  				}
757dfed6   孙向锦   样例报表
1033
1034
  				pqd.put("ANSWERINFO", answerInfos);
  				res.setData(pqd);
107fa3a0   孙向锦   修改试卷单选多远混合出题
1035
  			} else {
757dfed6   孙向锦   样例报表
1036
  				res.setDataError();
c617106f   孙向锦   添加即时测功能
1037
  			}
107fa3a0   孙向锦   修改试卷单选多远混合出题
1038
  		} else {
c617106f   孙向锦   添加即时测功能
1039
1040
  			res.setDataError();
  		}
757dfed6   孙向锦   样例报表
1041
  		logger.info("questionInTestReportInfo cost time:"
c617106f   孙向锦   添加即时测功能
1042
1043
1044
  				+ (System.currentTimeMillis() - cur));
  		return res.toJson();
  	}
91a745c9   孙向锦   完善后台功能
1045
  
2ad7ca45   孙向锦   试卷bug修改
1046
1047
  	/**
  	 * 试卷简要信息
107fa3a0   孙向锦   修改试卷单选多远混合出题
1048
  	 * 
2ad7ca45   孙向锦   试卷bug修改
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
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
  	 * @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();
  		}
757dfed6   孙向锦   样例报表
1113
  		logger.info("paperBriefInfo cost time : "
2ad7ca45   孙向锦   试卷bug修改
1114
1115
1116
1117
  				+ (System.currentTimeMillis() - cur));
  		return res.toBrifJson();
  	}
  
2ad7ca45   孙向锦   试卷bug修改
1118
1119
  	/**
  	 * 试卷问题
107fa3a0   孙向锦   修改试卷单选多远混合出题
1120
  	 * 
2ad7ca45   孙向锦   试卷bug修改
1121
1122
1123
  	 * @return
  	 * @throws Exception
  	 */
bed6e1fc   孙向锦   添加其他功能
1124
1125
1126
  	@RequestMapping(value = "/paperquestion", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object paperQuestion() throws Exception {
3371dbc6   孙向锦   0720 版本
1127
  		event("paperQuestion");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1128
  		long cur = System.currentTimeMillis();
bed6e1fc   孙向锦   添加其他功能
1129
1130
  		PageData pd = this.getPageData();
  		ResponseGson<PageData> res = new ResponseGson();
ce70231e   孙向锦   增加接口
1131
1132
  		logger.info("paperquestion cost time : "
  				+ (System.currentTimeMillis() - cur));
bed6e1fc   孙向锦   添加其他功能
1133
1134
  		return res.toJson();
  	}
ce70231e   孙向锦   增加接口
1135
  
2ad7ca45   孙向锦   试卷bug修改
1136
1137
  	/**
  	 * 问题
107fa3a0   孙向锦   修改试卷单选多远混合出题
1138
  	 * 
2ad7ca45   孙向锦   试卷bug修改
1139
1140
1141
  	 * @return
  	 * @throws Exception
  	 */
4fd2e08c   孙向锦   修复接口中的bug
1142
1143
1144
  	@RequestMapping(value = "/question", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object question() throws Exception {
3371dbc6   孙向锦   0720 版本
1145
  		event("question");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1146
  		long cur = System.currentTimeMillis();
4fd2e08c   孙向锦   修复接口中的bug
1147
  		PageData pd = this.getPageData();
2ad7ca45   孙向锦   试卷bug修改
1148
1149
  		ResponseGson<List<PageData>> res = new ResponseGson();
  		List<PageData> list = new ArrayList<PageData>();
ce70231e   孙向锦   增加接口
1150
  		if (pd.containsKey("ID")) {
2ad7ca45   孙向锦   试卷bug修改
1151
1152
1153
1154
1155
  			String ids = pd.getString("ID");
  			String[] id = ids.split(",");
  			for (String i : id) {
  				pd.put("QUESTION_ID", i);
  				PageData data = questionService.findById(pd);
c617106f   孙向锦   添加即时测功能
1156
  				String optionContent = data.getString("OPTION_CONTENT");
107fa3a0   孙向锦   修改试卷单选多远混合出题
1157
1158
1159
1160
  				if (optionContent != null && optionContent.startsWith("[")
  						&& optionContent.endsWith("]")) {
  					String[] options = optionContent.substring(1,
  							optionContent.length() - 1).split(",");
c617106f   孙向锦   添加即时测功能
1161
  					data.put("OPTION_CONTENT", options);
107fa3a0   孙向锦   修改试卷单选多远混合出题
1162
1163
  				} else {
  					data.put("OPTION_CONTENT", new String[] { optionContent });
c617106f   孙向锦   添加即时测功能
1164
  				}
2ad7ca45   孙向锦   试卷bug修改
1165
1166
1167
1168
1169
  				if (data != null) {
  					list.add(data);
  				}
  			}
  			res.setData(list);
ce70231e   孙向锦   增加接口
1170
  		} else {
4fd2e08c   孙向锦   修复接口中的bug
1171
1172
  			res.setDataError();
  		}
ce70231e   孙向锦   增加接口
1173
1174
  		logger.info("question cost time : "
  				+ (System.currentTimeMillis() - cur));
4fd2e08c   孙向锦   修复接口中的bug
1175
1176
  		return res.toJson();
  	}
ce70231e   孙向锦   增加接口
1177
  
2ad7ca45   孙向锦   试卷bug修改
1178
1179
  	/**
  	 * 查询知识点名称
107fa3a0   孙向锦   修改试卷单选多远混合出题
1180
  	 * 
2ad7ca45   孙向锦   试卷bug修改
1181
1182
1183
1184
1185
1186
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/knowledgename", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object knowledgename() throws Exception {
757dfed6   孙向锦   样例报表
1187
  		event("knowledgename");
2ad7ca45   孙向锦   试卷bug修改
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
  		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;
  	}
  
  	/**
  	 * 章节名称
107fa3a0   孙向锦   修改试卷单选多远混合出题
1212
  	 * 
2ad7ca45   孙向锦   试卷bug修改
1213
1214
1215
1216
1217
1218
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/chaptername", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object chaptername() throws Exception {
757dfed6   孙向锦   样例报表
1219
  		event("chaptername");
2ad7ca45   孙向锦   试卷bug修改
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
  		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;
  	}
  
  	/**
  	 * 试题添加
107fa3a0   孙向锦   修改试卷单选多远混合出题
1244
  	 * 
2ad7ca45   孙向锦   试卷bug修改
1245
1246
1247
  	 * @return
  	 * @throws Exception
  	 */
4fd2e08c   孙向锦   修复接口中的bug
1248
1249
1250
  	@RequestMapping(value = "/question/add", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object questionAdd() throws Exception {
3371dbc6   孙向锦   0720 版本
1251
  		event("questionAdd");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1252
  		long cur = System.currentTimeMillis();
4fd2e08c   孙向锦   修复接口中的bug
1253
1254
1255
1256
  		PageData pd = this.getPageData();
  		ResponseGson<PageData> res = new ResponseGson();
  		pd.put("QUESTION_ID", this.get32UUID());
  		questionService.save(pd);
ce70231e   孙向锦   增加接口
1257
1258
  		logger.info("questionAdd cost time : "
  				+ (System.currentTimeMillis() - cur));
4fd2e08c   孙向锦   修复接口中的bug
1259
1260
  		return res.toJson();
  	}
ce70231e   孙向锦   增加接口
1261
  
2ad7ca45   孙向锦   试卷bug修改
1262
1263
  	/***
  	 * 上传试卷
107fa3a0   孙向锦   修改试卷单选多远混合出题
1264
  	 * 
2ad7ca45   孙向锦   试卷bug修改
1265
1266
1267
  	 * @return
  	 * @throws Exception
  	 */
338594c8   孙向锦   添加教师端页面
1268
1269
1270
  	@RequestMapping(value = "/uploadpaper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object uploadpaper() throws Exception {
3371dbc6   孙向锦   0720 版本
1271
  		event("uploadpaper");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1272
  		long cur = System.currentTimeMillis();
338594c8   孙向锦   添加教师端页面
1273
1274
  		PageData pd = this.getPageData();
  		ResponseGson<String> res = new ResponseGson();
91a745c9   孙向锦   完善后台功能
1275
1276
  
  		if (!StringUtils.isEmpty(pd.getJsonString())) {
4fd2e08c   孙向锦   修复接口中的bug
1277
  			logger.info(pd.getJsonString());
338594c8   孙向锦   添加教师端页面
1278
1279
1280
1281
  			Paper paper = Paper.parse(pd.getJsonString());
  			PageData paperPd = new PageData();
  			String paperID = this.get32UUID();
  			res.setData(paperID);
91a745c9   孙向锦   完善后台功能
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
  			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   孙向锦   添加教师端页面
1292
  			String schoolID = Myelfun.getUserID(paper.getUser_id());
c34a91ee   Elvis   添加学生成绩接口
1293
1294
  			paperPd.put("SCHOOL_ID", paper.getSchool_id() == null ? schoolID
  					: paper.getSchool_id());
91a745c9   孙向锦   完善后台功能
1295
1296
1297
  			paperPd.put("CREATE_DATE", Tools.date2Str(new Date()));
  			paperPd.put("MODIFY_DATE", Tools.date2Str(new Date()));
  
ce70231e   孙向锦   增加接口
1298
  			int questionNum = 0;
91a745c9   孙向锦   完善后台功能
1299
  
338594c8   孙向锦   添加教师端页面
1300
  			List<Question> questions = paper.getQuestions();
91a745c9   孙向锦   完善后台功能
1301
1302
  			if (questions != null) {
  				for (Question question : questions) {
338594c8   孙向锦   添加教师端页面
1303
1304
1305
  					String questionID = this.get32UUID();
  					PageData qPd = new PageData();
  					qPd.put("QUESTION_ID", questionID);
91a745c9   孙向锦   完善后台功能
1306
1307
  					if (question.getQuestions() != null
  							&& question.getQuestions().size() > 0) {
338594c8   孙向锦   添加教师端页面
1308
  						qPd.put("P_ID", "-1");
91a745c9   孙向锦   完善后台功能
1309
  					} else {
ce70231e   孙向锦   增加接口
1310
  						questionNum++;
338594c8   孙向锦   添加教师端页面
1311
1312
1313
1314
  						qPd.put("P_ID", "0");
  					}
  					qPd.put("SUBJECT_ID", paper.getSubject_id());
  					qPd.put("CHAPTER_ID", question.getChapter_id());
ce70231e   孙向锦   增加接口
1315
1316
1317
  					qPd.put("PROBLEM_TYPE_ID",
  							question.getProblem_type_id() == null ? "1"
  									: question.getProblem_type_id());
338594c8   孙向锦   添加教师端页面
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
  					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   孙向锦   完善后台功能
1334
  
338594c8   孙向锦   添加教师端页面
1335
  					PageData pqPd = new PageData();
91a745c9   孙向锦   完善后台功能
1336
1337
1338
1339
1340
1341
1342
  					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   孙向锦   添加教师端页面
1343
  					paperquestionService.save(pqPd);
91a745c9   孙向锦   完善后台功能
1344
1345
  
  					if (question.getQuestions() != null) {
338594c8   孙向锦   添加教师端页面
1346
  						List<Question> qs = question.getQuestions();
91a745c9   孙向锦   完善后台功能
1347
  						for (Question q : qs) {
338594c8   孙向锦   添加教师端页面
1348
1349
1350
1351
1352
1353
  							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   孙向锦   增加接口
1354
1355
1356
  							cqPd.put("PROBLEM_TYPE_ID", question
  									.getProblem_type_id() == null ? "1"
  									: question.getProblem_type_id());
338594c8   孙向锦   添加教师端页面
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
  							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   孙向锦   完善后台功能
1372
  
338594c8   孙向锦   添加教师端页面
1373
  							questionService.save(cqPd);
91a745c9   孙向锦   完善后台功能
1374
  
338594c8   孙向锦   添加教师端页面
1375
  							PageData cpqPd = new PageData();
91a745c9   孙向锦   完善后台功能
1376
1377
1378
1379
1380
1381
1382
1383
  							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   孙向锦   添加教师端页面
1384
  							paperquestionService.save(cpqPd);
ce70231e   孙向锦   增加接口
1385
  							questionNum++;
338594c8   孙向锦   添加教师端页面
1386
1387
1388
1389
  						}
  					}
  				}
  			}
4fd2e08c   孙向锦   修复接口中的bug
1390
1391
  			paperPd.put("QUESTION_NUM", "" + questionNum);
  			paperService.save(paperPd);
91a745c9   孙向锦   完善后台功能
1392
1393
  
  		} else {
338594c8   孙向锦   添加教师端页面
1394
1395
  			res.setDataError();
  		}
ce70231e   孙向锦   增加接口
1396
1397
1398
1399
1400
  		logger.info("uploadpaper cost time : "
  				+ (System.currentTimeMillis() - cur));
  		return res.toJson();
  	}
  
2ad7ca45   孙向锦   试卷bug修改
1401
1402
  	/**
  	 * 上传试卷,不上传试题详细信息。试题从已有数据库中组卷
107fa3a0   孙向锦   修改试卷单选多远混合出题
1403
  	 * 
2ad7ca45   孙向锦   试卷bug修改
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
  	 * @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());
757dfed6   孙向锦   样例报表
1428
  			paperPd.put("CLASS_ID", paper.getClass_id());
2ad7ca45   孙向锦   试卷bug修改
1429
1430
1431
1432
1433
1434
1435
  			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()));
2ad7ca45   孙向锦   试卷bug修改
1436
  			List<Question> questions = paper.getQuestions();
757dfed6   孙向锦   样例报表
1437
  			int questionNum = questions.size();
2ad7ca45   孙向锦   试卷bug修改
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
  			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());
c617106f   孙向锦   添加即时测功能
1448
  					pqPd.put("P_ID", "0");
227dbfbb   孙向锦   添加知识点id
1449
  					pqPd.put("KNOWLEDGE_ID", question.getKnowledge_id());//
2ad7ca45   孙向锦   试卷bug修改
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
  					paperquestionService.save(pqPd);
  
  				}
  			}
  			paperPd.put("QUESTION_NUM", "" + questionNum);
  			paperService.save(paperPd);
  
  		} else {
  			res.setDataError();
  		}
757dfed6   孙向锦   样例报表
1460
  		logger.info("publishpaper cost time : "
2ad7ca45   孙向锦   试卷bug修改
1461
1462
1463
1464
1465
1466
  				+ (System.currentTimeMillis() - cur));
  		return res.toJson();
  	}
  
  	/**
  	 * 上传知识点
107fa3a0   孙向锦   修改试卷单选多远混合出题
1467
  	 * 
2ad7ca45   孙向锦   试卷bug修改
1468
1469
1470
  	 * @return
  	 * @throws Exception
  	 */
ce70231e   孙向锦   增加接口
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
  	@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   孙向锦   完善后台功能
1497
1498
1499
  		return res.toJson();
  	}
  
2ad7ca45   孙向锦   试卷bug修改
1500
  	/**
107fa3a0   孙向锦   修改试卷单选多远混合出题
1501
1502
  	 * 上传测验成绩
  	 * 
2ad7ca45   孙向锦   试卷bug修改
1503
1504
  	 * @return
  	 */
91a745c9   孙向锦   完善后台功能
1505
1506
1507
  	@RequestMapping(value = "/uploadtestpaper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object uploadTestpaper() {
3371dbc6   孙向锦   0720 版本
1508
  		event("uploadTestpaper");
4fd2e08c   孙向锦   修复接口中的bug
1509
  		long cur = System.currentTimeMillis();
91a745c9   孙向锦   完善后台功能
1510
1511
1512
  		PageData pd = this.getPageData();
  		ResponseGson<String> res = new ResponseGson();
  		if (!StringUtils.isEmpty(pd.getJsonString())) {
4fd2e08c   孙向锦   修复接口中的bug
1513
  			logger.info(pd.getJsonString());
91a745c9   孙向锦   完善后台功能
1514
1515
1516
1517
  			TestPaper testPaper = TestPaper.parse(pd.getJsonString());
  			try {
  				PageData testPd = new PageData();
  				String testPaperId = this.get32UUID();
91a745c9   孙向锦   完善后台功能
1518
  				testPd.put("TEACHER_ID", testPaper.getTeacherId());
91a745c9   孙向锦   完善后台功能
1519
1520
  				testPd.put("PAPER_ID", testPaper.getPaperId());
  				testPd.put("SCLASS_ID", testPaper.getClassId());
91a745c9   孙向锦   完善后台功能
1521
1522
1523
1524
1525
  				testPd.put(
  						"CREATE_DATE",
  						testPaper.getCreateDate() == null ? Tools
  								.date2Str(new Date()) : testPaper
  								.getCreateDate());
107fa3a0   孙向锦   修改试卷单选多远混合出题
1526
1527
1528
1529
  				testPd.put(
  						"TEST_TYPE",
  						testPaper.getTest_type() != null ? testPaper
  								.getTest_type() : "1");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
  				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());
579f3266   jack   1.studenttest增加增加...
1576
  
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
  									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);
  								}
579f3266   jack   1.studenttest增加增加...
1601
  
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1602
1603
  							}
  						}
c34a91ee   Elvis   添加学生成绩接口
1604
  						if (testInfoPdList != null && testInfoPdList.size() > 0) {
1c817fc8   孙向锦   修改一些bug信息
1605
1606
  							testpaperinfoService.batchSave(testInfoPdList);
  						}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1607
  					}
ce70231e   孙向锦   增加接口
1608
  				} else {
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
  					testPaperId = listData.get(0).getString("TESTPAPER_ID");
  				}
  				res.setData(testPaperId);
  			} catch (Exception e) {
  				e.printStackTrace();
  				res.setError();
  				res.setMessage(e.getMessage());
  			}
  		} else {
  			res.setDataError();
  		}
757dfed6   孙向锦   样例报表
1620
  		logger.info("uploadTestpaper cost time:"
ce70231e   孙向锦   增加接口
1621
  				+ (System.currentTimeMillis() - cur));
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1622
1623
1624
  
  		return res.toJson();
  
107fa3a0   孙向锦   修改试卷单选多远混合出题
1625
  	}
ce70231e   孙向锦   增加接口
1626
  
2ad7ca45   孙向锦   试卷bug修改
1627
  	/**
107fa3a0   孙向锦   修改试卷单选多远混合出题
1628
1629
  	 * 上传测验成绩
  	 * 
2ad7ca45   孙向锦   试卷bug修改
1630
1631
  	 * @return
  	 */
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1632
1633
1634
  	@RequestMapping(value = "/uploadupdatetestpaper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object uploadupdateTestpaper() {
3371dbc6   孙向锦   0720 版本
1635
  		event("uploadupdateTestpaper");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1636
  		long cur = System.currentTimeMillis();
d9b2b420   孙向锦   提交数据 使用多线程
1637
  		final PageData pd = this.getPageData();
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1638
1639
  		ResponseGson<String> res = new ResponseGson();
  		if (!StringUtils.isEmpty(pd.getJsonString())) {
d9b2b420   孙向锦   提交数据 使用多线程
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
  			new Thread() {
  				public void run() {
  					logger.info(pd.getJsonString());
  					TestPaper testPaper = TestPaper.parse(pd.getJsonString());
  					try {
  						PageData testPd = new PageData();
  						String testPaperId = 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());
  						testPd.put(
  								"TEST_TYPE",
  								testPaper.getTest_type() != null ? testPaper
  										.getTest_type() : "1");
  						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);
  						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("TOTAL_SCORE", testPaper.getTotalScore());
  						testPd.put("SUBJECT_ID", testPaper.getSubject_id());
  						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("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());
  									studentPageData.put("STUDENTTEST_ID",
  											get32UUID());
  
  									String flag = "";
  									for (TestPaperInfo testPaperInfo : studentAnswer
  											.getQuestions()) {
  										testInfoPd = new PageData();
  										testInfoPd.put("TESTPAPERINFO_ID",
  												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());
  										flag = StringUtils.isEmpty(testPaperInfo
  												.getAnswer())
  												 ? ""
  												+ flag : 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);
  									}
c34a91ee   Elvis   添加学生成绩接口
1746
  
d9b2b420   孙向锦   提交数据 使用多线程
1747
1748
1749
1750
1751
1752
1753
1754
1755
  									if (flag.equals("")) {
  										studentPageData.put("LOST_TEST", "1");
  									}
  									studenttestService.save(studentPageData);
  								}
  							}
  							if (testInfoPdList != null
  									&& testInfoPdList.size() > 0) {
  								testpaperinfoService.batchSave(testInfoPdList);
579f3266   jack   1.studenttest增加增加...
1756
  							}
91a745c9   孙向锦   完善后台功能
1757
  						}
d9b2b420   孙向锦   提交数据 使用多线程
1758
1759
  					} catch (Exception e) {
  						e.printStackTrace();
1c817fc8   孙向锦   修改一些bug信息
1760
  					}
91a745c9   孙向锦   完善后台功能
1761
  				}
d9b2b420   孙向锦   提交数据 使用多线程
1762
  			}.start();
91a745c9   孙向锦   完善后台功能
1763
1764
1765
  		} else {
  			res.setDataError();
  		}
757dfed6   孙向锦   样例报表
1766
  		logger.info("uploadupdatetestpaper cost time:"
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
1767
  				+ (System.currentTimeMillis() - cur));
91a745c9   孙向锦   完善后台功能
1768
1769
1770
1771
  
  		return res.toJson();
  
  	}
107fa3a0   孙向锦   修改试卷单选多远混合出题
1772
  
757dfed6   孙向锦   样例报表
1773
  	/**
c34a91ee   Elvis   添加学生成绩接口
1774
1775
1776
1777
1778
1779
1780
  	 * 上传学生测验成绩
  	 * 
  	 * @return
  	 */
  	@RequestMapping(value = "/uploadstudenttest", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object uploadstudenttest() {
e6f8f1e9   孙向锦   修复不能更新的bug
1781
  		event("uploadstudenttest");
c34a91ee   Elvis   添加学生成绩接口
1782
  		long cur = System.currentTimeMillis();
d9b2b420   孙向锦   提交数据 使用多线程
1783
  		final PageData pd = this.getPageData();
c34a91ee   Elvis   添加学生成绩接口
1784
1785
  		ResponseGson<String> res = new ResponseGson();
  		if (!StringUtils.isEmpty(pd.getJsonString())) {
d9b2b420   孙向锦   提交数据 使用多线程
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
  			new Thread(){
  				public void run() {
  					logger.info(pd.getJsonString());
  					
  					try {
  						StudentPaper studentPaper = StudentPaper.parse(pd
  								.getJsonString());
  
  						PageData testPd = new PageData();
  						testPd.put("PAPER_ID", studentPaper.getPaperId());
  						List<PageData> oldList = testpaperService.listAll(testPd);
  						if (oldList == null || oldList.size() == 0) {
  							testPd.put("TEACHER_ID", "");
  							testPd.put("SCLASS_ID", "");
  							testPd.put(
  									"CREATE_DATE",
  									studentPaper.getCreateDate() == null ? Tools
  											.date2Str(new Date()) : studentPaper
  											.getCreateDate());
  							testPd.put("TEST_TYPE", "1");
  							testPd.put("START_DATE",studentPaper.getStartDate());
  							testPd.put("END_DATE", studentPaper.getEndDate());
  							testPd.put("TESTPAPER_ID", studentPaper.getPaperId());
  							testPd.put("OTHER_SCORE", "");
  							testPd.put("HIGHT_SCORE", "");
  							testPd.put("LOW_SCORE", "");
  							testPd.put("AVG_SCORE", "");
  							testPd.put("TOTAL_SCORE", "");
  							testPd.put("SUBJECT_ID", studentPaper.getSubject_id());
  							testPd.put("REMARK", "");
  							testPd.put("NAME", studentPaper.getName());
  							testpaperService.save(testPd);
  						}else{
  							boolean find = false;
  							for(PageData pda: oldList){
  								if(pda != null && studentPaper.getPaperId().equals(pda.get("TESTPAPER_ID"))){
  									find = true;
  									break;
  								}
  							}
  							if(!find){
  								testPd.put("TEACHER_ID", "");
  								testPd.put("SCLASS_ID", "");
  								testPd.put(
  										"CREATE_DATE",
  										studentPaper.getCreateDate() == null ? Tools
  												.date2Str(new Date()) : studentPaper
  												.getCreateDate());
  								testPd.put("TEST_TYPE", "1");
  								testPd.put("START_DATE",studentPaper.getStartDate());
  								testPd.put("END_DATE", studentPaper.getEndDate());
  								testPd.put("TESTPAPER_ID", studentPaper.getPaperId());
  								testPd.put("OTHER_SCORE", "");
  								testPd.put("HIGHT_SCORE", "");
  								testPd.put("LOW_SCORE", "");
  								testPd.put("AVG_SCORE", "");
  								testPd.put("TOTAL_SCORE", "");
  								testPd.put("SUBJECT_ID", studentPaper.getSubject_id());
  								testPd.put("REMARK", "");
  								testPd.put("NAME", studentPaper.getName());
  								testpaperService.save(testPd);
  							}
931af053   孙向锦   添加二级排序
1848
  						}
982c0384   孙向锦   更新接口
1849
  
d9b2b420   孙向锦   提交数据 使用多线程
1850
1851
  						List<StudentPaper.StudentAnswer> list = studentPaper
  								.getStudents();
982c0384   孙向锦   更新接口
1852
  
d9b2b420   孙向锦   提交数据 使用多线程
1853
1854
  						for (StudentPaper.StudentAnswer studentAnswer : list) {
  							PageData stestPd = new PageData();
982c0384   孙向锦   更新接口
1855
  
d9b2b420   孙向锦   提交数据 使用多线程
1856
1857
  							String studentId = studentAnswer.getStudentId();
  							String classId = "";
982c0384   孙向锦   更新接口
1858
  
d9b2b420   孙向锦   提交数据 使用多线程
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
  							// 通过学号id 查找学生信息
  							if (StringUtils.isEmpty(studentId)) {
  								PageData ptd = new PageData();
  								ptd.put("NUMBER", studentAnswer.getNumber());
  								ptd.put("SCHOOL_ID", studentPaper.getSchoolId());
  								PageData stPd =   v1Service.findStudentBySchoolIdAndNumber(ptd); //
  								if(stPd == null){
  									stPd = studentService.findByNumber(ptd);
  								}
  								if (stPd != null) {
  									studentId = stPd.getString("ID");
  									classId = stPd.getString("CLASS_ID");
  								}
  							} else {
  								PageData ptd = new PageData();
  								ptd.put("ID", studentAnswer.getStudentId());
  								PageData stPd = studentService.findById(ptd);
  								if (stPd != null) {
  									studentId = stPd.getString("ID");
  									classId = stPd.getString("CLASS_ID");
  								}
  							}
  							if (StringUtils.isEmpty(studentId)) {
  								continue;
  							}
  							stestPd.put("STUDENT_ID", studentId);
  							stestPd.put("CLASS_ID", classId);
  							stestPd.put("PAPER_ID", studentPaper.getPaperId());
  							stestPd.put("TEST_ID", studentPaper.getPaperId());
  							stestPd.put("SCORE", studentAnswer.getScore());
  							stestPd.put("LOST_TEST", studentAnswer.getLosttest());
  							List<PageData> liste = studenttestService.listAll(stestPd);
  							if (liste == null || liste.size() == 0) {
  								stestPd.put("STUDENTTEST_ID", get32UUID());
  								studenttestService.save(stestPd);
  							} else {
  								PageData ptd = liste.get(0);
  								stestPd.put("STUDENTTEST_ID", ptd.get("STUDENTTEST_ID"));
  								studenttestService.edit(stestPd);
  							}
c34a91ee   Elvis   添加学生成绩接口
1899
  
d9b2b420   孙向锦   提交数据 使用多线程
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
  							List<PageData> testInfoPdList = new ArrayList();
  							List<StudentPaper.Question> questions = studentAnswer
  									.getQuestions();
  							for (StudentPaper.Question question : questions) {
  								PageData testInfoPd = new PageData();
  								testInfoPd.put("TESTPAPERINFO_ID", get32UUID());
  								testInfoPd.put("TEST_ID", studentPaper.getPaperId());
  								testInfoPd.put("PAPER_ID", studentPaper.getPaperId());
  								testInfoPd.put("STUDENT_ID", studentId);
  								testInfoPd.put("QUESTION_ID", question.getQuestionId());
  								testInfoPd.put("ANSWER", question.getAnswer());
  								testInfoPd.put("RIGHT", question.getRight());
  								testInfoPd.put("SCORE", question.getScore());
  								testInfoPd.put("ANSWER_TYPE", question.getAnswerType());
  								List<PageData> listse = testpaperinfoService
  										.listAll(testInfoPd);
  								if (listse == null || listse.size() == 0) {
  									testInfoPdList.add(testInfoPd);
  								} else {
  									PageData ptd = listse.get(0);
  									testInfoPd.put("TESTPAPERINFO_ID",
  											testInfoPd.get("TESTPAPERINFO_ID"));
  									testpaperinfoService.edit(testInfoPd);
  								}
  							}
c34a91ee   Elvis   添加学生成绩接口
1925
  
d9b2b420   孙向锦   提交数据 使用多线程
1926
1927
1928
  							if (testInfoPdList.size() > 0) {
  								testpaperinfoService.batchSave(testInfoPdList);
  							}
c34a91ee   Elvis   添加学生成绩接口
1929
  
d9b2b420   孙向锦   提交数据 使用多线程
1930
1931
1932
1933
1934
1935
1936
  						}
  					}catch(Exception e){
  						e.printStackTrace();
  					}
  				};
  			}.start();
  		}else{
c34a91ee   Elvis   添加学生成绩接口
1937
1938
  			res.setDataError();
  		}
d9b2b420   孙向锦   提交数据 使用多线程
1939
  			
e6f8f1e9   孙向锦   修复不能更新的bug
1940
  		logger.info("uploadstudenttest cost time:"
c34a91ee   Elvis   添加学生成绩接口
1941
1942
1943
1944
1945
1946
1947
  				+ (System.currentTimeMillis() - cur));
  
  		return res.toJson();
  
  	}
  
  	/**
107fa3a0   孙向锦   修改试卷单选多远混合出题
1948
1949
  	 * 上传测验成绩
  	 * 
757dfed6   孙向锦   样例报表
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
  	 * @return
  	 */
  	@RequestMapping(value = "/uploadupdatetestpaper2", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object uploadupdateTestpaper2() {
  		event("uploadupdateTestpaper2");
  		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);
  				}
107fa3a0   孙向锦   修改试卷单选多远混合出题
1981
1982
1983
1984
  				testPd.put(
  						"TEST_TYPE",
  						testPaper.getTest_type() != null ? testPaper
  								.getTest_type() : "101");
757dfed6   孙向锦   样例报表
1985
1986
1987
1988
1989
1990
1991
1992
1993
  				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("TOTAL_SCORE", testPaper.getTotalScore());
3a163205   孙向锦   报表优化
1994
  				testPd.put("SUBJECT_ID", testPaper.getSubject_id());
757dfed6   孙向锦   样例报表
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
  				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("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());
  							studentPageData.put("STUDENTTEST_ID", get32UUID());
  							studenttestService.save(studentPageData);
107fa3a0   孙向锦   修改试卷单选多远混合出题
2014
  
757dfed6   孙向锦   样例报表
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
  							for (TestPaperInfo testPaperInfo : studentAnswer
  									.getQuestions()) {
  								testInfoPd = new PageData();
  								testInfoPd.put("TESTPAPERINFO_ID",
  										this.get32UUID());
  								testInfoPd.put("PAPER_ID",
  										testPaperInfo.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"
107fa3a0   孙向锦   修改试卷单选多远混合出题
2037
  										: testPaperInfo.getAnswerType());
757dfed6   孙向锦   样例报表
2038
2039
2040
2041
2042
2043
2044
2045
2046
  								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());
107fa3a0   孙向锦   修改试卷单选多远混合出题
2047
2048
  								testInfoPd.put("RANDOM",
  										testPaperInfo.getRandom());
757dfed6   孙向锦   样例报表
2049
2050
2051
2052
2053
  								testInfoPd.put("RANK", testPaperInfo.getRank());
  								testInfoPdList.add(testInfoPd);
  							}
  						}
  					}
c34a91ee   Elvis   添加学生成绩接口
2054
  					if (testInfoPdList.size() > 0) {
eca4feb5   孙向锦   管理员功能完善
2055
2056
  						testpaperinfoService.batchSave(testInfoPdList);
  					}
757dfed6   孙向锦   样例报表
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
  				}
  				res.setData(testPaperId);
  			} catch (Exception e) {
  				e.printStackTrace();
  				res.setError();
  				res.setMessage(e.getMessage());
  			}
  		} else {
  			res.setDataError();
  		}
bda221f4   孙向锦   0830版本
2067
  		logger.info("uploadupdateTestpaper2 cost time:"
757dfed6   孙向锦   样例报表
2068
  				+ (System.currentTimeMillis() - cur));
107fa3a0   孙向锦   修改试卷单选多远混合出题
2069
  
757dfed6   孙向锦   样例报表
2070
  		return res.toJson();
107fa3a0   孙向锦   修改试卷单选多远混合出题
2071
  
757dfed6   孙向锦   样例报表
2072
  	}
91a745c9   孙向锦   完善后台功能
2073
  
2ad7ca45   孙向锦   试卷bug修改
2074
2075
  	/**
  	 * 查询知识点
107fa3a0   孙向锦   修改试卷单选多远混合出题
2076
  	 * 
2ad7ca45   孙向锦   试卷bug修改
2077
2078
2079
  	 * @return
  	 * @throws Exception
  	 */
ce70231e   孙向锦   增加接口
2080
2081
2082
  	@RequestMapping(value = "/point", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object point() throws Exception {
757dfed6   孙向锦   样例报表
2083
  		event("point");
ce70231e   孙向锦   增加接口
2084
  		ResponseGson<List<PageData>> res = new ResponseGson();
2ad7ca45   孙向锦   试卷bug修改
2085
  
ce70231e   孙向锦   增加接口
2086
  		PageData pd = getPageData();
2ad7ca45   孙向锦   试卷bug修改
2087
  		String key = this.getRequestKey(pd, "point");
ce70231e   孙向锦   增加接口
2088
2089
  		PageData pagedata = new PageData();
  		pagedata.put("KEY", key);
2ad7ca45   孙向锦   试卷bug修改
2090
  		if (!"".equals(key.trim())) {
ce70231e   孙向锦   增加接口
2091
  			PageData ret = cacheService.findById(pagedata);
2ad7ca45   孙向锦   试卷bug修改
2092
  			if (ret != null && ret.get("CACHE") != null) {
ce70231e   孙向锦   增加接口
2093
2094
2095
2096
2097
  				return ret.get("CACHE");
  			}
  		}
  		List<PageData> list = knowledgeService.listAllknowledge(pd);
  		String depth = pd.getString("DEPTH");
2ad7ca45   孙向锦   试卷bug修改
2098
2099
2100
  		int end = 3;
  		if (depth != null) {
  			try {
ce70231e   孙向锦   增加接口
2101
  				end = Integer.parseInt(depth);
2ad7ca45   孙向锦   试卷bug修改
2102
2103
  			} catch (Exception e) {
  
ce70231e   孙向锦   增加接口
2104
2105
  			}
  		}
2ad7ca45   孙向锦   试卷bug修改
2106
  		roundPointData(list, 1, end);
ce70231e   孙向锦   增加接口
2107
2108
  		res.setData(list);
  		String str = res.toJson();
2ad7ca45   孙向锦   试卷bug修改
2109
  		str = str.replaceAll("[^\\u0000-\\uFFFF]", "");
ce70231e   孙向锦   增加接口
2110
2111
2112
2113
2114
  		pagedata.put("CACHE", str);
  		cacheService.save(pagedata);
  		return str;
  	}
  
2ad7ca45   孙向锦   试卷bug修改
2115
2116
  	/**
  	 * 知识点递归查询
107fa3a0   孙向锦   修改试卷单选多远混合出题
2117
2118
2119
2120
2121
2122
2123
  	 * 
  	 * @param list
  	 *            查询知识点及子知识点
  	 * @param dept
  	 *            深度
  	 * @param end
  	 *            层深
2ad7ca45   孙向锦   试卷bug修改
2124
2125
2126
2127
  	 * @throws Exception
  	 */
  	private void roundPointData(List<PageData> list, int dept, int end)
  			throws Exception {
ce70231e   孙向锦   增加接口
2128
2129
2130
2131
2132
2133
2134
  		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修改
2135
  						roundPointData(ret, dept + 1, end);
ce70231e   孙向锦   增加接口
2136
2137
2138
2139
2140
2141
2142
  						pd.put("CHILDREN", ret);
  					}
  				}
  				pd.remove("P_ID");
  			}
  		}
  	}
2ad7ca45   孙向锦   试卷bug修改
2143
2144
2145
  
  	/**
  	 * 章节递归查询
107fa3a0   孙向锦   修改试卷单选多远混合出题
2146
2147
2148
2149
2150
2151
2152
  	 * 
  	 * @param list
  	 *            章节
  	 * @param dept
  	 *            深度
  	 * @param end
  	 *            递归深度
2ad7ca45   孙向锦   试卷bug修改
2153
2154
2155
2156
2157
  	 * @throws Exception
  	 */
  	private void roundChapterData(List<PageData> list, int dept, int end)
  			throws Exception {
  		if (list != null) {
ce70231e   孙向锦   增加接口
2158
2159
  			for (PageData pd : list) {
  				pd.put("P_ID", pd.getString("ID"));
2ad7ca45   孙向锦   试卷bug修改
2160
2161
2162
2163
2164
2165
2166
2167
  				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   孙向锦   增加接口
2168
2169
2170
  					}
  				}
  				pd.remove("P_ID");
2ad7ca45   孙向锦   试卷bug修改
2171
  				pd.remove("TEACHINGMATERIAL_ID");
ce70231e   孙向锦   增加接口
2172
2173
2174
2175
  			}
  		}
  	}
  
2ad7ca45   孙向锦   试卷bug修改
2176
  	/**
107fa3a0   孙向锦   修改试卷单选多远混合出题
2177
2178
  	 * 下载测验成绩
  	 * 
2ad7ca45   孙向锦   试卷bug修改
2179
2180
  	 * @return
  	 */
91a745c9   孙向锦   完善后台功能
2181
2182
2183
  	@RequestMapping(value = "/downloadtestpaper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object downloadTestpaper() {
3371dbc6   孙向锦   0720 版本
2184
  		event("downloadTestpaper");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
2185
  		long cur = System.currentTimeMillis();
91a745c9   孙向锦   完善后台功能
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
  		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   孙向锦   增加接口
2261
2262
  		logger.info("downloadtestpaper cost time:"
  				+ (System.currentTimeMillis() - cur));
338594c8   孙向锦   添加教师端页面
2263
  		return res.toJson();
91a745c9   孙向锦   完善后台功能
2264
  
338594c8   孙向锦   添加教师端页面
2265
2266
  	}
  
2ad7ca45   孙向锦   试卷bug修改
2267
2268
  	/**
  	 * 
107fa3a0   孙向锦   修改试卷单选多远混合出题
2269
2270
  	 * 下载测验成绩
  	 * 
2ad7ca45   孙向锦   试卷bug修改
2271
2272
  	 * @return
  	 */
91a745c9   孙向锦   完善后台功能
2273
2274
2275
  	@RequestMapping(value = "/testpaper", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object testpaper() {
3371dbc6   孙向锦   0720 版本
2276
  		event("testpaper");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
2277
  		long cur = System.currentTimeMillis();
91a745c9   孙向锦   完善后台功能
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
  		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   孙向锦   添加软件管理模块。对软件形成统一的管理
2309
  		logger.info("testpaper cost time:" + (System.currentTimeMillis() - cur));
91a745c9   孙向锦   完善后台功能
2310
2311
2312
  		return res.toJson();
  
  	}
ce70231e   孙向锦   增加接口
2313
  
2ad7ca45   孙向锦   试卷bug修改
2314
2315
2316
  	/***
  	 * 
  	 */
4fd2e08c   孙向锦   修复接口中的bug
2317
2318
  	@RequestMapping(value = "/schooladmin", produces = "application/json;charset=UTF-8")
  	@ResponseBody
ce70231e   孙向锦   增加接口
2319
  	public void schoolAdmin() {
3371dbc6   孙向锦   0720 版本
2320
  		event("schoolAdmin");
4fd2e08c   孙向锦   修复接口中的bug
2321
2322
  		PageData pd = this.getPageData();
  		this.getUserID();
4fd2e08c   孙向锦   修复接口中的bug
2323
  	}
ce70231e   孙向锦   增加接口
2324
  
2ad7ca45   孙向锦   试卷bug修改
2325
2326
  	/***
  	 * 网络
107fa3a0   孙向锦   修改试卷单选多远混合出题
2327
  	 * 
2ad7ca45   孙向锦   试卷bug修改
2328
2329
2330
  	 * @return
  	 * @throws Exception
  	 */
9338b563   孙向锦   添加报表
2331
2332
  	@RequestMapping(value = "/network", produces = "application/json;charset=UTF-8")
  	@ResponseBody
ce70231e   孙向锦   增加接口
2333
  	public Object network() throws Exception {
3371dbc6   孙向锦   0720 版本
2334
  		event("network");
9338b563   孙向锦   添加报表
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
  		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   孙向锦   增加接口
2347
  				if (fail < 0) {
9338b563   孙向锦   添加报表
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
  					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   孙向锦   增加接口
2361
  				if (fail < 0) {
9338b563   孙向锦   添加报表
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
  					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   孙向锦   增加接口
2373
  		} else {
9338b563   孙向锦   添加报表
2374
2375
2376
2377
  			res.setDataError();
  		}
  		return res.toJson();
  	}
ce70231e   孙向锦   增加接口
2378
  
2ad7ca45   孙向锦   试卷bug修改
2379
2380
  	/**
  	 * 获取远端ip地址
107fa3a0   孙向锦   修改试卷单选多远混合出题
2381
  	 * 
2ad7ca45   孙向锦   试卷bug修改
2382
2383
  	 * @return
  	 */
ce70231e   孙向锦   增加接口
2384
  	public String getRemoteIp() {
9338b563   孙向锦   添加报表
2385
2386
2387
2388
2389
2390
2391
2392
2393
  		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   孙向锦   增加接口
2394
  
2ad7ca45   孙向锦   试卷bug修改
2395
2396
  	/**
  	 * 查询新版本信息
107fa3a0   孙向锦   修改试卷单选多远混合出题
2397
  	 * 
2ad7ca45   孙向锦   试卷bug修改
2398
2399
2400
2401
  	 * @param request
  	 * @return
  	 * @throws Exception
  	 */
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
2402
2403
  	@RequestMapping(value = "/newversion", produces = "application/json;charset=UTF-8")
  	@ResponseBody
ce70231e   孙向锦   增加接口
2404
  	public Object getNewVersion(HttpServletRequest request) throws Exception {
3371dbc6   孙向锦   0720 版本
2405
  		event("getNewVersion");
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
2406
2407
2408
  		PageData pd = this.getPageData();
  		String softId = pd.getString("SOFTID");
  		String path = request.getContextPath();
ce70231e   孙向锦   增加接口
2409
2410
  		String basePath = request.getScheme() + "://" + request.getServerName()
  				+ ":" + request.getServerPort() + path + "/";
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
2411
  		ResponseGson<PageData> res = new ResponseGson();
ce70231e   孙向锦   增加接口
2412
  		if (softId != null && !"".equals(softId)) {
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
2413
2414
  			pd.put("SOFTWARE_ID", softId);
  			PageData result = softwareversionService.findNewVersion(pd);
ce70231e   孙向锦   增加接口
2415
  			if (result != null) {
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
2416
2417
  				result.remove("SOFTWAREVERSION_ID");
  				result.remove("SOFTWARE_ID");
ce70231e   孙向锦   增加接口
2418
2419
  				result.put("VERSION_PATH", basePath + "uploadFiles/uploadFile/"
  						+ result.getString("VERSION_PATH"));
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
2420
  				res.setData(result);
ce70231e   孙向锦   增加接口
2421
  			} else {
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
2422
2423
  				res.setDataError();
  			}
ce70231e   孙向锦   增加接口
2424
  		} else {
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
2425
2426
2427
2428
  			res.setDataError();
  		}
  		return res.toJson();
  	}
ce70231e   孙向锦   增加接口
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
  
  	/**
  	 * 获取教材版本
  	 * 
  	 * @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修改
2453
2454
  								pad.put("VERSION_CODE",
  										pad.getString("VERSION_CODE"));
ce70231e   孙向锦   增加接口
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
  								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();
  	}
107fa3a0   孙向锦   修改试卷单选多远混合出题
2472
  
c617106f   孙向锦   添加即时测功能
2473
2474
2475
2476
2477
2478
2479
2480
2481
  	@RequestMapping(value = "/textbook", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object textbook() throws Exception {
  		PageData pd = getPageData();
  		ResponseGson<List<PageData>> ret = new ResponseGson<List<PageData>>();
  		List<PageData> list = textbookService.listAll(pd);
  		ret.setData(list);
  		return ret.toJson();
  	}
2ad7ca45   孙向锦   试卷bug修改
2482
  
ce70231e   孙向锦   增加接口
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
  	/**
  	 * 获取教材版本
  	 * 
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/chapter", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public Object chapter() throws Exception {
  		PageData pd = getPageData();
2ad7ca45   孙向锦   试卷bug修改
2493
  		String key = this.getRequestKey(pd, "chapter");
ce70231e   孙向锦   增加接口
2494
2495
  		PageData pagedata = new PageData();
  		pagedata.put("KEY", key);
2ad7ca45   孙向锦   试卷bug修改
2496
  		if (!"".equals(key.trim())) {
ce70231e   孙向锦   增加接口
2497
  			PageData ret = cacheService.findById(pagedata);
2ad7ca45   孙向锦   试卷bug修改
2498
  			if (ret != null && ret.get("CACHE") != null) {
ce70231e   孙向锦   增加接口
2499
2500
2501
2502
2503
2504
  				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修改
2505
2506
2507
  		int end = 3;
  		if (depth != null) {
  			try {
ce70231e   孙向锦   增加接口
2508
  				end = Integer.parseInt(depth);
2ad7ca45   孙向锦   试卷bug修改
2509
2510
  			} catch (Exception e) {
  
ce70231e   孙向锦   增加接口
2511
2512
  			}
  		}
2ad7ca45   孙向锦   试卷bug修改
2513
  		roundChapterData(list, 1, end);
ce70231e   孙向锦   增加接口
2514
2515
  		res.setData(list);
  		String str = res.toJson();
ce70231e   孙向锦   增加接口
2516
2517
2518
2519
  		pagedata.put("CACHE", str);
  		cacheService.save(pagedata);
  		return str;
  	}
2ad7ca45   孙向锦   试卷bug修改
2520
  
ce70231e   孙向锦   增加接口
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
  	/**
  	 * 获取试题
  	 * 
  	 * @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修改
2534
2535
  		if (teachingmaterialId != null && !teachingmaterialId.equals("")
  				&& chapterId == null) {
ce70231e   孙向锦   增加接口
2536
2537
  			PageData chapterPd = new PageData();
  			chapterPd.put("TEACHINGMATERIAL_ID", teachingmaterialId);
2ad7ca45   孙向锦   试卷bug修改
2538
2539
  			List<PageData> chapterList = chapterService
  					.listAllChapter(chapterPd);
ce70231e   孙向锦   增加接口
2540
  			roundChapterData(chapterList, 1, 3);
2ad7ca45   孙向锦   试卷bug修改
2541
  			List<String> ids = getIds(chapterList, "ID");
ce70231e   孙向锦   增加接口
2542
  			pd.put("CHAPTER_IDS", ids);
2ad7ca45   孙向锦   试卷bug修改
2543
  		} else {
ce70231e   孙向锦   增加接口
2544
  			List<String> ids = new ArrayList<String>();
2ad7ca45   孙向锦   试卷bug修改
2545
  			if (chapterId != null && !"".equals(chapterId.trim())) {
ce70231e   孙向锦   增加接口
2546
2547
2548
2549
2550
2551
  				ids.add(chapterId);
  			}
  			pd.put("CHAPTER_IDS", ids);
  		}
  		pd.remove("CHAPTER_ID");
  		String knowledge = pd.getString("KNOWLEDGE_ID");
2ad7ca45   孙向锦   试卷bug修改
2552
  		if (knowledge != null && !"".equals(knowledge.trim())) {
ce70231e   孙向锦   增加接口
2553
2554
2555
2556
  			PageData knowPd = new PageData();
  			knowPd.put("P_ID", knowledge);
  			List<PageData> knowlist = knowledgeService.listAllknowledge(knowPd);
  			roundPointData(knowlist, 1, 3);
2ad7ca45   孙向锦   试卷bug修改
2557
  			List<String> ids = getIds(knowlist, "KNOWLEDGE_ID");
ce70231e   孙向锦   增加接口
2558
  			ids.add(knowledge);
2ad7ca45   孙向锦   试卷bug修改
2559
  			pd.put("KNOWLEDGE_IDS", ids);
ce70231e   孙向锦   增加接口
2560
2561
  			pd.remove("KNOWLEDGE_ID");
  		}
107fa3a0   孙向锦   修改试卷单选多远混合出题
2562
2563
  		int pageNumI = 0;
  		int count = 30;
0aad4b6b   孙向锦   修复试题分页功能
2564
2565
  		String pageNum = pd.getString("PAGENUM");
  		String countStr = pd.getString("COUNT");
107fa3a0   孙向锦   修改试卷单选多远混合出题
2566
2567
  		if (pageNum != null && !"".equals(pageNum) && countStr != null
  				&& !"".equals(countStr)) {
0aad4b6b   孙向锦   修复试题分页功能
2568
2569
  			pageNumI = Integer.parseInt(pageNum);
  			count = Integer.parseInt(countStr);
107fa3a0   孙向锦   修改试卷单选多远混合出题
2570
2571
2572
2573
  			if (pageNumI >= 1) {
  				pageNumI = (pageNumI - 1) * count;
  			} else {
  				pageNumI = 0;
0aad4b6b   孙向锦   修复试题分页功能
2574
2575
2576
2577
  			}
  			pd.put("PAGENUM", "" + pageNumI);
  			pd.put("COUNT", "" + count);
  		}
ce70231e   孙向锦   增加接口
2578
  		List<PageData> list = questionService.listAllquestion(pd);
107fa3a0   孙向锦   修改试卷单选多远混合出题
2579
  		for (PageData pad : list) {
c617106f   孙向锦   添加即时测功能
2580
  			String optionContent = pad.getString("OPTION_CONTENT");
107fa3a0   孙向锦   修改试卷单选多远混合出题
2581
2582
2583
2584
  			if (optionContent != null && optionContent.startsWith("[")
  					&& optionContent.endsWith("]")) {
  				String[] options = optionContent.substring(1,
  						optionContent.length() - 1).split(",");
c617106f   孙向锦   添加即时测功能
2585
  				pad.put("OPTION_CONTENT", options);
107fa3a0   孙向锦   修改试卷单选多远混合出题
2586
2587
  			} else {
  				pad.put("OPTION_CONTENT", new String[] { optionContent });
c617106f   孙向锦   添加即时测功能
2588
  			}
c34a91ee   Elvis   添加学生成绩接口
2589
2590
2591
2592
2593
  
  			if (pad.getString("CONTENT") != null) {
  				pad.put("CONTENT",
  						pad.getString("CONTENT").replaceAll("<fill></fill>",
  								"______"));
a0eff87f   孙向锦   修改课后练bug
2594
  			}
c617106f   孙向锦   添加即时测功能
2595
  		}
ce70231e   孙向锦   增加接口
2596
2597
2598
  		res.setData(list);
  		return res.toJson();
  	}
2ad7ca45   孙向锦   试卷bug修改
2599
  
ce70231e   孙向锦   增加接口
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
  	/**
  	 * 随机获取试题
  	 * 
  	 * @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修改
2613
2614
  		if (teachingmaterialId != null && !teachingmaterialId.equals("")
  				&& chapterId == null) {
ce70231e   孙向锦   增加接口
2615
2616
  			PageData chapterPd = new PageData();
  			chapterPd.put("TEACHINGMATERIAL_ID", teachingmaterialId);
2ad7ca45   孙向锦   试卷bug修改
2617
2618
  			List<PageData> chapterList = chapterService
  					.listAllChapter(chapterPd);
ce70231e   孙向锦   增加接口
2619
  			roundChapterData(chapterList, 1, 3);
2ad7ca45   孙向锦   试卷bug修改
2620
  			List<String> ids = getIds(chapterList, "ID");
ce70231e   孙向锦   增加接口
2621
  			pd.put("CHAPTER_IDS", ids);
2ad7ca45   孙向锦   试卷bug修改
2622
  		} else {
ce70231e   孙向锦   增加接口
2623
  			List<String> ids = new ArrayList<String>();
2ad7ca45   孙向锦   试卷bug修改
2624
  			if (chapterId != null && !"".equals(chapterId.trim())) {
ce70231e   孙向锦   增加接口
2625
2626
2627
2628
2629
2630
  				ids.add(chapterId);
  			}
  			pd.put("CHAPTER_IDS", ids);
  		}
  		pd.remove("CHAPTER_ID");
  		String knowledge = pd.getString("KNOWLEDGE_ID");
2ad7ca45   孙向锦   试卷bug修改
2631
  		if (knowledge != null && !"".equals(knowledge.trim())) {
ce70231e   孙向锦   增加接口
2632
2633
2634
2635
  			PageData knowPd = new PageData();
  			knowPd.put("P_ID", knowledge);
  			List<PageData> knowlist = knowledgeService.listAllknowledge(knowPd);
  			roundPointData(knowlist, 1, 3);
2ad7ca45   孙向锦   试卷bug修改
2636
  			List<String> ids = getIds(knowlist, "KNOWLEDGE_ID");
ce70231e   孙向锦   增加接口
2637
  			ids.add(knowledge);
2ad7ca45   孙向锦   试卷bug修改
2638
  			pd.put("KNOWLEDGE_IDS", ids);
ce70231e   孙向锦   增加接口
2639
2640
2641
  			pd.remove("KNOWLEDGE_ID");
  		}
  		List<PageData> list = questionService.listAllRandquestion(pd);
107fa3a0   孙向锦   修改试卷单选多远混合出题
2642
  		for (PageData pad : list) {
c617106f   孙向锦   添加即时测功能
2643
  			String optionContent = pad.getString("OPTION_CONTENT");
107fa3a0   孙向锦   修改试卷单选多远混合出题
2644
2645
2646
2647
  			if (optionContent != null && optionContent.startsWith("[")
  					&& optionContent.endsWith("]")) {
  				String[] options = optionContent.substring(1,
  						optionContent.length() - 1).split(",");
c617106f   孙向锦   添加即时测功能
2648
  				pad.put("OPTION_CONTENT", options);
107fa3a0   孙向锦   修改试卷单选多远混合出题
2649
2650
  			} else {
  				pad.put("OPTION_CONTENT", new String[] { optionContent });
c617106f   孙向锦   添加即时测功能
2651
2652
  			}
  		}
ce70231e   孙向锦   增加接口
2653
2654
2655
  		res.setData(list);
  		return res.toJson();
  	}
2ad7ca45   孙向锦   试卷bug修改
2656
2657
2658
2659
2660
2661
2662
2663
  
  	/**
  	 * 
  	 * @param chapterList
  	 * @param key
  	 * @return
  	 */
  	public List<String> getIds(List<PageData> chapterList, String key) {
ce70231e   孙向锦   增加接口
2664
  		List<String> ids = new ArrayList<String>();
2ad7ca45   孙向锦   试卷bug修改
2665
2666
  		if (chapterList != null && chapterList.size() > 0) {
  			for (PageData pd : chapterList) {
ce70231e   孙向锦   增加接口
2667
  				String chapterid = pd.getString(key);
2ad7ca45   孙向锦   试卷bug修改
2668
  				if (chapterid != null && !"".equals(chapterid)) {
ce70231e   孙向锦   增加接口
2669
2670
2671
  					ids.add(chapterid);
  				}
  				Object obj = pd.get("CHILDREN");
2ad7ca45   孙向锦   试卷bug修改
2672
  				if (obj != null && (obj instanceof List)) {
ce70231e   孙向锦   增加接口
2673
  					@SuppressWarnings("unchecked")
2ad7ca45   孙向锦   试卷bug修改
2674
2675
2676
  					List<PageData> list = (List<PageData>) obj;
  					List<String> ret = getIds(list, key);
  					if (ret != null && ret.size() > 0) {
ce70231e   孙向锦   增加接口
2677
2678
2679
2680
2681
  						ids.addAll(ret);
  					}
  				}
  			}
  		}
2ad7ca45   孙向锦   试卷bug修改
2682
  
ce70231e   孙向锦   增加接口
2683
  		return ids;
2ad7ca45   孙向锦   试卷bug修改
2684
  
ce70231e   孙向锦   增加接口
2685
2686
  	}
  
2ad7ca45   孙向锦   试卷bug修改
2687
2688
2689
2690
2691
  	/**
  	 * 
  	 * @return
  	 * @throws Exception
  	 */
d3d7b2ca   孙向锦   修改表格固定
2692
2693
  	@RequestMapping(value = "/tempcreateUser", produces = "application/json;charset=UTF-8")
  	@ResponseBody
ce70231e   孙向锦   增加接口
2694
  	public Object tempCreateUser() throws Exception {
d3d7b2ca   孙向锦   修改表格固定
2695
2696
2697
2698
  		PageData pd = new PageData();
  		pd = this.getPageData();
  		pd.put("ID", this.get32UUID());
  		teacherService.save(pd);
ce70231e   孙向锦   增加接口
2699
2700
2701
2702
  		pd.put("USER_ID", pd.getString("ID")); // ID 主键
  		pd.put("LAST_LOGIN", ""); // 最后登录时间
  		pd.put("IP", ""); // IP
  		pd.put("STATUS", "0"); // 状态
d3d7b2ca   孙向锦   修改表格固定
2703
  		pd.put("SKIN", "default");
ce70231e   孙向锦   增加接口
2704
  		pd.put("RIGHTS", "");
d3d7b2ca   孙向锦   修改表格固定
2705
  		pd.put("USERNAME", pd.getString("ACCOUT"));
ce70231e   孙向锦   增加接口
2706
2707
2708
2709
2710
2711
2712
  		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   孙向锦   修改表格固定
2713
  		}
ce70231e   孙向锦   增加接口
2714
2715
2716
  
  		// ID, TEACHER_ID, CLASS_ID, SUBJECT_ID, START_DATE, END_DATE, GRADE_ID,
  		// TERM_ID, REMARK
d3d7b2ca   孙向锦   修改表格固定
2717
2718
2719
2720
  		pd.put("TEACHER_ID", pd.get("ID"));
  		pd.put("CLASS_ID", "bc33389101ec46e6b7d47daa8adf58ac");
  		pd.put("SUBJECT_ID", "1");
  		pd.put("GRADE_ID", "1");
ce70231e   孙向锦   增加接口
2721
  		pd.put("TERM_ID", "0d8ea2efdef74accbd0d00e9bc07dfbb");
d3d7b2ca   孙向锦   修改表格固定
2722
  		coursemanagementService.save(pd);
ce70231e   孙向锦   增加接口
2723
  
d3d7b2ca   孙向锦   修改表格固定
2724
2725
  		return "{'res':'success'}";
  	}
2480c889   孙向锦   添加软件管理模块。对软件形成统一的管理
2726
  
2ad7ca45   孙向锦   试卷bug修改
2727
2728
2729
2730
  	/**
  	 * 
  	 * @param apiName
  	 */
ce70231e   孙向锦   增加接口
2731
  	private void event(String apiName) {
c34a91ee   Elvis   添加学生成绩接口
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
  		// PageData eventPd = new PageData();
  		// eventPd.put("EVENT_ID", get32UUID());
  		// eventPd.put("EVENT_NAME", apiName);
  		// eventPd.put("EVENT_USER", getUsername());
  		// eventPd.put("EVENT_TYPE", "-1");
  		// eventPd.put("EVENT_START_TIME", Tools.date2Str(new Date()));
  		// eventPd.put("CLIENT_ID", "SERVER");
  		// eventPd.put("EVENT_IP", getRemoteIp());
  		// try {
  		// eventService.save(eventPd);
  		// } catch (Exception e) {
  		//
  		// }
ce70231e   孙向锦   增加接口
2745
2746
2747
2748
  	}
  
  	static int index = 0;
  
2ad7ca45   孙向锦   试卷bug修改
2749
2750
2751
2752
2753
  	/**
  	 * 
  	 * @param point
  	 * @param pid
  	 */
ce70231e   孙向锦   增加接口
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
  	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修改
2773
2774
2775
2776
2777
  	/**
  	 * 
  	 * @return
  	 * @throws Exception
  	 */
ce70231e   孙向锦   增加接口
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
  	@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修改
2807
2808
2809
2810
  	/**
  	 * 
  	 * @param point
  	 */
ce70231e   孙向锦   增加接口
2811
2812
2813
2814
2815
2816
2817
2818
2819
  	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) {
ce70231e   孙向锦   增加接口
2820
2821
2822
  			e.printStackTrace();
  		}
  	}
2ad7ca45   孙向锦   试卷bug修改
2823
2824
2825
2826
2827
2828
  
  	/**
  	 * 
  	 * @return
  	 * @throws Exception
  	 */
ce70231e   孙向锦   增加接口
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
  	@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修改
2839
2840
  				ResponseGson<Object> req = ResponseGson.parse(pd
  						.getJsonString());
ce70231e   孙向锦   增加接口
2841
  				Object data = req.getData();
2ad7ca45   孙向锦   试卷bug修改
2842
2843
2844
2845
2846
2847
  				if (data instanceof List) {
  					List<Object> list = (List) data;
  					for (Object obj : list) {
  						if (obj instanceof Map) {
  							Map map = (Map) obj;
  
ce70231e   孙向锦   增加接口
2848
2849
2850
  							PageData pageData = new PageData();
  							pageData.put("QUESTION_ID", map.get("id"));
  							Object cateObj = map.get("cate");
2ad7ca45   孙向锦   试卷bug修改
2851
  							if (cateObj != null) {
ce70231e   孙向锦   增加接口
2852
2853
  								String cate = cateObj.toString();
  								float catef = Float.parseFloat(cate);
2ad7ca45   孙向锦   试卷bug修改
2854
  								pageData.put("QUESTION_TYPE_ID", (int) catef);
ce70231e   孙向锦   增加接口
2855
2856
  							}
  							Object contentObj = map.get("content");
2ad7ca45   孙向锦   试卷bug修改
2857
  							if (contentObj != null) {
ce70231e   孙向锦   增加接口
2858
2859
2860
2861
2862
  								String content = contentObj.toString();
  								content = replaceWebUrl(content);
  								pageData.put("CONTENT", content);
  							}
  							Object subjectCodeObj = map.get("subjectCode");
2ad7ca45   孙向锦   试卷bug修改
2863
  							if (subjectCodeObj != null) {
ce70231e   孙向锦   增加接口
2864
  								String subjectCode = subjectCodeObj.toString();
2ad7ca45   孙向锦   试卷bug修改
2865
  								pageData.put("SUBJECT_ID", subjectCode);
ce70231e   孙向锦   增加接口
2866
2867
  							}
  							Object optionsObj = map.get("options");
2ad7ca45   孙向锦   试卷bug修改
2868
2869
2870
2871
  							if (optionsObj instanceof List) {
  								List ss = (List) optionsObj;
  								pageData.put("OPTION_CONTENT",
  										optionsObj.toString());
ce70231e   孙向锦   增加接口
2872
2873
2874
  								pageData.put("OPTION_NUM", "" + ss.size());
  							}
  							Object answersObj = map.get("answers");
2ad7ca45   孙向锦   试卷bug修改
2875
2876
  							if (answersObj instanceof List) {
  								List answers = (List) answersObj;
ce70231e   孙向锦   增加接口
2877
  								StringBuilder sb = new StringBuilder();
2ad7ca45   孙向锦   试卷bug修改
2878
  								for (Object as : answers) {
ce70231e   孙向锦   增加接口
2879
2880
2881
2882
  									sb.append(as.toString());
  								}
  								pageData.put("ANSWER", sb.toString());
  							}
2ad7ca45   孙向锦   试卷bug修改
2883
2884
  							Object difficulty = map.get("difficulty");
  							try {
ce70231e   孙向锦   增加接口
2885
2886
2887
2888
2889
2890
  								if (difficulty != null) {
  									float fdifficulty = Float
  											.parseFloat(difficulty.toString());
  									pageData.put("DIFFICULTY",
  											(int) fdifficulty);
  								}
2ad7ca45   孙向锦   试卷bug修改
2891
  							} catch (Exception ex) {
ce70231e   孙向锦   增加接口
2892
2893
2894
  								ex.printStackTrace();
  							}
  							Object discussObj = map.get("discuss");
2ad7ca45   孙向锦   试卷bug修改
2895
  							if (discussObj != null) {
ce70231e   孙向锦   增加接口
2896
2897
2898
2899
2900
  								String discuss = discussObj.toString();
  								discuss = replaceWebUrl(discuss);
  								pageData.put("REMARK", discuss);
  							}
  							Object analyseObj = map.get("analyse");
2ad7ca45   孙向锦   试卷bug修改
2901
  							if (analyseObj != null) {
ce70231e   孙向锦   增加接口
2902
2903
2904
2905
2906
  								String analyse = analyseObj.toString();
  								analyse = replaceWebUrl(analyse);
  								pageData.put("ANALYSIS", analyse);
  							}
  							Object methodObj = map.get("method");
2ad7ca45   孙向锦   试卷bug修改
2907
  							if (methodObj != null) {
ce70231e   孙向锦   增加接口
2908
2909
2910
2911
2912
2913
  								String method = methodObj.toString();
  								method = replaceWebUrl(method);
  								pageData.put("METHOD", method);
  							}
  							Object points = map.get("points");
  							StringBuilder sb = new StringBuilder();
2ad7ca45   孙向锦   试卷bug修改
2914
2915
2916
2917
2918
  							if (points instanceof List) {
  								List pointsList = (List) points;
  								for (Object pObject : pointsList) {
  									if (pObject instanceof Map) {
  										Map pMap = (Map) pObject;
ce70231e   孙向锦   增加接口
2919
2920
2921
  										sb.append(pMap.get("code")).append(",");
  									}
  								}
2ad7ca45   孙向锦   试卷bug修改
2922
2923
  
  								if (sb.toString().length() > 1) {
ce70231e   孙向锦   增加接口
2924
2925
2926
2927
2928
  									sb.deleteCharAt(sb.length() - 1);
  								}
  								pageData.put("KNOWLEDGE_ID", sb.toString());
  							}
  							pageData.put("QUESTION_FROM", "101");
2ad7ca45   孙向锦   试卷bug修改
2929
  							try {
ce70231e   孙向锦   增加接口
2930
  								questionService.save(pageData);
2ad7ca45   孙向锦   试卷bug修改
2931
2932
  							} catch (Exception e) {
  								logger.error("save fail:" + map.get("id"), e);
ce70231e   孙向锦   增加接口
2933
2934
2935
2936
2937
2938
2939
2940
2941
  							}
  						}
  					}
  				}
  			} catch (Exception e) {
  				res.setError();
  			}
  		} else {
  			res.setDataError();
3371dbc6   孙向锦   0720 版本
2942
  		}
ce70231e   孙向锦   增加接口
2943
2944
2945
  		logger.info("uploadyuncelianquestion cost time : "
  				+ (System.currentTimeMillis() - cur));
  		return res.toJson();
3371dbc6   孙向锦   0720 版本
2946
  	}
ce70231e   孙向锦   增加接口
2947
  
2ad7ca45   孙向锦   试卷bug修改
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
  	/**
  	 * 
  	 * @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   孙向锦   增加接口
2958
2959
2960
  		}
  		return content;
  	}
2ad7ca45   孙向锦   试卷bug修改
2961
2962
2963
2964
2965
2966
2967
2968
2969
  
  	/**
  	 * 
  	 * @param pd
  	 * @param methodName
  	 * @return
  	 */
  	public String getRequestKey(PageData pd, String methodName) {
  		StringBuilder key = new StringBuilder();
ce70231e   孙向锦   增加接口
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
  		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修改
2980
  
ce70231e   孙向锦   增加接口
2981
2982
  		return key.toString();
  	}
107fa3a0   孙向锦   修改试卷单选多远混合出题
2983
  
c617106f   孙向锦   添加即时测功能
2984
2985
  	/**
  	 * 根据ID,获取科目中文名称
107fa3a0   孙向锦   修改试卷单选多远混合出题
2986
  	 * 
c617106f   孙向锦   添加即时测功能
2987
2988
2989
2990
2991
2992
  	 * @param type
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/subjectename", produces = "application/json;charset=UTF-8")
  	@ResponseBody
107fa3a0   孙向锦   修改试卷单选多远混合出题
2993
  	public String findSubjectEName() throws Exception {
c617106f   孙向锦   添加即时测功能
2994
2995
2996
  		PageData pageData = this.getPageData();
  		ResponseGson<String> res = new ResponseGson<String>();
  		pageData = subjectService.findById(pageData);
107fa3a0   孙向锦   修改试卷单选多远混合出题
2997
  		if (pageData != null) {
c617106f   孙向锦   添加即时测功能
2998
  			res.setData(pageData.getString("ENAME"));
107fa3a0   孙向锦   修改试卷单选多远混合出题
2999
  		} else {
c617106f   孙向锦   添加即时测功能
3000
3001
3002
3003
  			res.setDataError();
  		}
  		return res.toJson();
  	}
107fa3a0   孙向锦   修改试卷单选多远混合出题
3004
  
c617106f   孙向锦   添加即时测功能
3005
3006
  	/**
  	 * 根据ID或者科目英文名称
107fa3a0   孙向锦   修改试卷单选多远混合出题
3007
  	 * 
c617106f   孙向锦   添加即时测功能
3008
3009
3010
3011
3012
3013
  	 * @param type
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/subjectcname", produces = "application/json;charset=UTF-8")
  	@ResponseBody
107fa3a0   孙向锦   修改试卷单选多远混合出题
3014
  	public String findSubjectCName() throws Exception {
c617106f   孙向锦   添加即时测功能
3015
3016
3017
  		ResponseGson<String> res = new ResponseGson<String>();
  		PageData pageData = new PageData();
  		StringBuilder sb = new StringBuilder();
107fa3a0   孙向锦   修改试卷单选多远混合出题
3018
3019
  		String type = this.getPageData().getString("ID");
  		if (type.contains(",")) {
c617106f   孙向锦   添加即时测功能
3020
3021
3022
3023
3024
3025
3026
3027
  			String[] types = type.split(",");
  			for (String t : types) {
  				pageData.put("ID", t);
  				pageData = subjectService.findById(pageData);
  				if (pageData != null) {
  					sb.append(pageData.getString("CNAME") + ";  ");
  				}
  			}
107fa3a0   孙向锦   修改试卷单选多远混合出题
3028
3029
  			sb.delete(sb.length() - 3, sb.length());
  		} else {
c617106f   孙向锦   添加即时测功能
3030
3031
3032
3033
3034
3035
3036
3037
3038
  			pageData.put("ID", type);
  			pageData = subjectService.findById(pageData);
  			if (pageData != null) {
  				sb.append(pageData.getString("CNAME"));
  			}
  		}
  		res.setData(sb.toString());
  		return res.toJson();
  	}
107fa3a0   孙向锦   修改试卷单选多远混合出题
3039
  
c617106f   孙向锦   添加即时测功能
3040
3041
  	/**
  	 * 根据ID班级名称
107fa3a0   孙向锦   修改试卷单选多远混合出题
3042
  	 * 
c617106f   孙向锦   添加即时测功能
3043
3044
3045
3046
3047
3048
  	 * @param id
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/classname", produces = "application/json;charset=UTF-8")
  	@ResponseBody
107fa3a0   孙向锦   修改试卷单选多远混合出题
3049
  	public String findClassName() throws Exception {
c617106f   孙向锦   添加即时测功能
3050
3051
3052
  		ResponseGson<String> res = new ResponseGson<String>();
  		PageData pageData = this.getPageData();
  		pageData = sclassService.findById(pageData);
107fa3a0   孙向锦   修改试卷单选多远混合出题
3053
3054
  		String className = "";
  		if (pageData != null) {
c617106f   孙向锦   添加即时测功能
3055
  			className = pageData.getString("CLASS_NAME");
107fa3a0   孙向锦   修改试卷单选多远混合出题
3056
  		} else {
c617106f   孙向锦   添加即时测功能
3057
3058
3059
3060
  			res.setDataError();
  		}
  		res.setData(className);
  		return res.toJson();
107fa3a0   孙向锦   修改试卷单选多远混合出题
3061
  
c617106f   孙向锦   添加即时测功能
3062
  	}
c34a91ee   Elvis   添加学生成绩接口
3063
  
694fbd54   孙向锦   添加作业管理模块
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
  	/**
  	 * 获取作业列表
  	 * 
  	 * @param id
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/listhomework", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public String listhomework() throws Exception {
  		ResponseGson<List<PageData>> res = new ResponseGson<List<PageData>>();
  		PageData pageData = this.getPageData();
c34a91ee   Elvis   添加学生成绩接口
3076
  		if (pageData.get("COMPLETE_DATE") == null) {
a2414076   孙向锦   修改谢曲提交过来的bug
3077
3078
  			pageData.put("COMPLETE_DATE", pageData.get("COMPLETE"));
  		}
416902b7   孙向锦   添加课后作业部分API
3079
  		List<PageData> list = homeworkService.qlistAll(pageData);
694fbd54   孙向锦   添加作业管理模块
3080
3081
  		res.setData(list);
  		return res.toJson();
c34a91ee   Elvis   添加学生成绩接口
3082
  
694fbd54   孙向锦   添加作业管理模块
3083
  	}
c34a91ee   Elvis   添加学生成绩接口
3084
  
416902b7   孙向锦   添加课后作业部分API
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
  	/**
  	 * 获取作业详情
  	 * 
  	 * @param id
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/homework", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public String homework() throws Exception {
  		ResponseGson<List<PageData>> res = new ResponseGson<List<PageData>>();
  		PageData pageData = this.getPageData();
5162dcee   孙向锦   添加上传作业接口
3097
  		pageData.put("CODE", pageData.get("HOMEWORK_ID"));
416902b7   孙向锦   添加课后作业部分API
3098
  		List<PageData> list = homeworkproblemService.listProblem(pageData);
c34a91ee   Elvis   添加学生成绩接口
3099
3100
3101
3102
  		for (PageData pd : list) {
  			if (pd.get("P_HOMEWORK_PROBLEM_ID") != null) {
  				List<PageData> childList = homeworkproblemService
  						.listProblem(pd);
416902b7   孙向锦   添加课后作业部分API
3103
3104
  				pd.put("PROBLEMS", childList);
  			}
c34a91ee   Elvis   添加学生成绩接口
3105
  
416902b7   孙向锦   添加课后作业部分API
3106
3107
3108
  		}
  		res.setData(list);
  		return res.toJson();
c34a91ee   Elvis   添加学生成绩接口
3109
  
416902b7   孙向锦   添加课后作业部分API
3110
  	}
c34a91ee   Elvis   添加学生成绩接口
3111
  
416902b7   孙向锦   添加课后作业部分API
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
  	/**
  	 * 获取作业详情
  	 * 
  	 * @param id
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/uploadhomework", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public String uploadhomework() throws Exception {
  		ResponseGson<String> res = new ResponseGson<String>();
c34a91ee   Elvis   添加学生成绩接口
3123
  
416902b7   孙向锦   添加课后作业部分API
3124
3125
  		PageData pd = this.getPageData();
  		if (!StringUtils.isEmpty(pd.getJsonString())) {
c34a91ee   Elvis   添加学生成绩接口
3126
3127
  			ResultHomework resultHomework = ResultHomework.parse(pd
  					.getJsonString());
a479f295   孙向锦   添加了报表逻辑
3128
3129
3130
3131
  			PageData homePd = new PageData();
  			homePd.put("HOMEWORK_ID", resultHomework.getHOMEWORK_ID());
  			homePd.put("CLASS_ID", resultHomework.getCLASS_ID());
  			homePd.put("GET_SCORE", resultHomework.getGET_SCORE());
c34a91ee   Elvis   添加学生成绩接口
3132
3133
  			homePd.put("GET_SCORE_PERSENT",
  					resultHomework.getGET_SCORE_PERSENT());
a479f295   孙向锦   添加了报表逻辑
3134
3135
  			homePd.put("COMPLETE_DESC", resultHomework.getCOMPLETE_DESC());
  			homePd.put("GET_MAX_SCORE", resultHomework.getGET_MAX_SCORE());
f7e4dd61   孙向锦   根据客户UI的需求进行修改
3136
  			homePd.put("GET_MIN_SCORE", resultHomework.getGET_MIN_SCORE());
8dccad91   孙向锦   更新学生接口列表
3137
  			homePd.put("ANSWER_PERSENT", resultHomework.getANSWER_PERSENT());
27a15f6c   孙向锦   课后练bug修改
3138
  			homePd.put("COMPLETE_PERSENT", resultHomework.getCOMPLETE_PERSENT());
bd553929   孙向锦   修改接口
3139
  			homePd.put("COMPLETE_COUNT", "1");
a479f295   孙向锦   添加了报表逻辑
3140
  			homeworkService.edit(homePd);
c34a91ee   Elvis   添加学生成绩接口
3141
3142
3143
  			List<PageData> list = homeworkReporkService
  					.findByHomeworkID(homePd);
  			if (list == null || list.size() == 0) {
a479f295   孙向锦   添加了报表逻辑
3144
3145
3146
  				// 初始化班級作业数据
  				// 1. 根据班级id 查询班级学生列表
  				List<PageData> student = studentService.findByClassId(homePd);
c34a91ee   Elvis   添加学生成绩接口
3147
  				for (PageData ptd : student) {
a764d288   孙向锦   修改课后练bug
3148
  					ptd.put("STUDENT_ID", ptd.get("ID"));
a479f295   孙向锦   添加了报表逻辑
3149
  					ptd.put("STUDENT_NAME", ptd.get("NAME"));
bd553929   孙向锦   修改接口
3150
  					ptd.put("HOMEWORK_REPORT_ID", this.get32UUID());
cc36e109   孙向锦   修复课后练bug
3151
  					ptd.put("STUDNET_NO", ptd.get("NUMBER"));
a479f295   孙向锦   添加了报表逻辑
3152
3153
3154
3155
3156
  					ptd.put("RANK", student.size() + "");
  					ptd.put("KEYBOARD", ptd.get("KEYPAD_ID"));
  					ptd.put("RIGHT_PERSENT", "0%");
  					ptd.put("GET_SCORE", "0");
  					ptd.put("ANSWER", "");
e7d09ea7   孙向锦   修改bug
3157
  					ptd.put("COMPLETE_COUNT", "0");
8dccad91   孙向锦   更新学生接口列表
3158
  					ptd.put("WHETHER", "0");
a479f295   孙向锦   添加了报表逻辑
3159
3160
3161
  					ptd.put("HOMEWORK_ID", resultHomework.getHOMEWORK_ID());
  				}
  				// 2. 根据学生列表生成初始化成绩
c34a91ee   Elvis   添加学生成绩接口
3162
  				if (student.size() > 0) {
00af725f   孙向锦   修复bug
3163
3164
  					homeworkReporkService.batchSave(student);
  				}
a479f295   孙向锦   添加了报表逻辑
3165
3166
  			}
  			List<ResultStudent> students = resultHomework.getSTUDENTS();
c34a91ee   Elvis   添加学生成绩接口
3167
  			for (ResultStudent student : students) {
a479f295   孙向锦   添加了报表逻辑
3168
3169
3170
  				// update 学生作业情况
  				PageData tpd = new PageData();
  				tpd.put("STUDENT_NAME", student.getSTUDENT_NAME());
cc36e109   孙向锦   修复课后练bug
3171
  				tpd.put("STUDNET_NO", student.getSTUDENT_NO());
8dccad91   孙向锦   更新学生接口列表
3172
  				tpd.put("STUDENT_ID", student.getSTUDENT_ID());
a479f295   孙向锦   添加了报表逻辑
3173
3174
3175
3176
3177
  				tpd.put("RANK", student.getRANK());
  				tpd.put("KEYBOARD", student.getKEYBOARD());
  				tpd.put("RIGHT_PERSENT", student.getRIGHT_PERSENT());
  				tpd.put("GET_SCORE", student.getGET_SCORE());
  				tpd.put("ANSWER", student.getANSWER());
e7d09ea7   孙向锦   修改bug
3178
  				tpd.put("COMPLETE_COUNT", student.getCOMPLETE_COUNT());
a479f295   孙向锦   添加了报表逻辑
3179
  				tpd.put("HOMEWORK_ID", resultHomework.getHOMEWORK_ID());
a479f295   孙向锦   添加了报表逻辑
3180
3181
3182
  				homeworkReporkService.update(tpd);
  			}
  			res.setData(resultHomework.getHOMEWORK_ID());
c34a91ee   Elvis   添加学生成绩接口
3183
  		} else {
a479f295   孙向锦   添加了报表逻辑
3184
3185
  			res.setDataError();
  		}
c34a91ee   Elvis   添加学生成绩接口
3186
  
a479f295   孙向锦   添加了报表逻辑
3187
  		return res.toJson();
c34a91ee   Elvis   添加学生成绩接口
3188
  
a479f295   孙向锦   添加了报表逻辑
3189
  	}
c34a91ee   Elvis   添加学生成绩接口
3190
  
a479f295   孙向锦   添加了报表逻辑
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
  	/**
  	 * 更新学生详情
  	 * 
  	 * @param id
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/uploadshomework", produces = "application/json;charset=UTF-8")
  	@ResponseBody
  	public String uploadshomework() throws Exception {
  		ResponseGson<String> res = new ResponseGson<String>();
c34a91ee   Elvis   添加学生成绩接口
3202
  
a479f295   孙向锦   添加了报表逻辑
3203
3204
  		PageData pd = this.getPageData();
  		if (!StringUtils.isEmpty(pd.getJsonString())) {
c34a91ee   Elvis   添加学生成绩接口
3205
3206
  			ResultHomework resultHomework = ResultHomework.parse(pd
  					.getJsonString());
a479f295   孙向锦   添加了报表逻辑
3207
3208
3209
3210
  			PageData homePd = new PageData();
  			homePd.put("HOMEWORK_ID", resultHomework.getHOMEWORK_ID());
  			homePd.put("CLASS_ID", resultHomework.getCLASS_ID());
  			homePd.put("GET_SCORE", resultHomework.getGET_SCORE());
c34a91ee   Elvis   添加学生成绩接口
3211
3212
  			homePd.put("GET_SCORE_PERSENT",
  					resultHomework.getGET_SCORE_PERSENT());
a479f295   孙向锦   添加了报表逻辑
3213
3214
3215
  			homePd.put("COMPLETE_DESC", resultHomework.getCOMPLETE_DESC());
  			homePd.put("GET_MAX_SCORE", resultHomework.getGET_MAX_SCORE());
  			homeworkService.edit(homePd);
c34a91ee   Elvis   添加学生成绩接口
3216
3217
3218
  			List<PageData> list = homeworkReporkService
  					.findByHomeworkID(homePd);
  			if (list == null || list.size() == 0) {
a479f295   孙向锦   添加了报表逻辑
3219
3220
3221
  				// 初始化班級作业数据
  				// 1. 根据班级id 查询班级学生列表
  				List<PageData> student = studentService.findByClassId(homePd);
c34a91ee   Elvis   添加学生成绩接口
3222
  				for (PageData ptd : student) {
a479f295   孙向锦   添加了报表逻辑
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
  					ptd.put("STUDENT_NAME", ptd.get("NAME"));
  					ptd.put("STUDENT_NO", ptd.get("SNO"));
  					ptd.put("RANK", student.size() + "");
  					ptd.put("KEYBOARD", ptd.get("KEYPAD_ID"));
  					ptd.put("RIGHT_PERSENT", "0%");
  					ptd.put("GET_SCORE", "0");
  					ptd.put("ANSWER", "");
  					ptd.put("HOMEWORK_ID", resultHomework.getHOMEWORK_ID());
  				}
  				// 2. 根据学生列表生成初始化成绩
c34a91ee   Elvis   添加学生成绩接口
3233
  				if (student != null && student.size() > 0) {
1c817fc8   孙向锦   修改一些bug信息
3234
3235
  					homeworkReporkService.batchSave(student);
  				}
a479f295   孙向锦   添加了报表逻辑
3236
3237
  			}
  			List<ResultStudent> students = resultHomework.getSTUDENTS();
c34a91ee   Elvis   添加学生成绩接口
3238
  			for (ResultStudent student : students) {
a479f295   孙向锦   添加了报表逻辑
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
  				// update 学生作业情况
  				PageData tpd = new PageData();
  				tpd.put("STUDENT_NAME", student.getSTUDENT_NAME());
  				tpd.put("STUDENT_NO", student.getSTUDENT_NO());
  				tpd.put("RANK", student.getRANK());
  				tpd.put("KEYBOARD", student.getKEYBOARD());
  				tpd.put("RIGHT_PERSENT", student.getRIGHT_PERSENT());
  				tpd.put("GET_SCORE", student.getGET_SCORE());
  				tpd.put("ANSWER", student.getANSWER());
  				tpd.put("HOMEWORK_ID", resultHomework.getHOMEWORK_ID());
  				homeworkReporkService.update(tpd);
  			}
  			res.setData(resultHomework.getHOMEWORK_ID());
c34a91ee   Elvis   添加学生成绩接口
3252
  		} else {
a479f295   孙向锦   添加了报表逻辑
3253
  			res.setDataError();
416902b7   孙向锦   添加课后作业部分API
3254
  		}
c34a91ee   Elvis   添加学生成绩接口
3255
  
416902b7   孙向锦   添加课后作业部分API
3256
  		return res.toJson();
c34a91ee   Elvis   添加学生成绩接口
3257
  
416902b7   孙向锦   添加课后作业部分API
3258
  	}
107fa3a0   孙向锦   修改试卷单选多远混合出题
3259
  
757dfed6   孙向锦   样例报表
3260
3261
  	/**
  	 * 根据ID班级名称
107fa3a0   孙向锦   修改试卷单选多远混合出题
3262
  	 * 
757dfed6   孙向锦   样例报表
3263
3264
3265
3266
3267
3268
  	 * @param id
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/qstudentinfo", produces = "application/json;charset=UTF-8")
  	@ResponseBody
107fa3a0   孙向锦   修改试卷单选多远混合出题
3269
  	public String qstudentinfo() throws Exception {
757dfed6   孙向锦   样例报表
3270
3271
3272
3273
3274
3275
  		ResponseGson<List<PageData>> res = new ResponseGson();
  		PageData pageData = this.getPageData();
  		if (pageData.containsKey("TEST_ID")
  				&& pageData.containsKey("QUESTION_ID")) {
  			List<PageData> list = v1Service.getQuestionWrongInfo(pageData);
  			res.setData(list);
107fa3a0   孙向锦   修改试卷单选多远混合出题
3276
  		} else {
757dfed6   孙向锦   样例报表
3277
3278
3279
  			res.setDataError();
  		}
  		return res.toJson();
107fa3a0   孙向锦   修改试卷单选多远混合出题
3280
  
bda221f4   孙向锦   0830版本
3281
  	}
107fa3a0   孙向锦   修改试卷单选多远混合出题
3282
  
bda221f4   孙向锦   0830版本
3283
3284
  	/**
  	 * 根据ID班级名称
107fa3a0   孙向锦   修改试卷单选多远混合出题
3285
  	 * 
bda221f4   孙向锦   0830版本
3286
3287
3288
3289
3290
3291
  	 * @param id
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/wrongquestion", produces = "application/json;charset=UTF-8")
  	@ResponseBody
107fa3a0   孙向锦   修改试卷单选多远混合出题
3292
  	public String wrongquestion() throws Exception {
bda221f4   孙向锦   0830版本
3293
3294
3295
3296
3297
  		ResponseGson<List<PageData>> res = new ResponseGson();
  		PageData pageData = this.getPageData();
  		List<PageData> list = v1Service.getLastWrongQuestionInfo(pageData);
  		res.setData(list);
  		return res.toJson();
107fa3a0   孙向锦   修改试卷单选多远混合出题
3298
  
757dfed6   孙向锦   样例报表
3299
  	}
107fa3a0   孙向锦   修改试卷单选多远混合出题
3300
  
227dbfbb   孙向锦   添加知识点id
3301
3302
  	/**
  	 * 根据ID班级名称
107fa3a0   孙向锦   修改试卷单选多远混合出题
3303
  	 * 
227dbfbb   孙向锦   添加知识点id
3304
3305
3306
3307
3308
3309
  	 * @param id
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/printmsg", produces = "application/json;charset=UTF-8")
  	@ResponseBody
107fa3a0   孙向锦   修改试卷单选多远混合出题
3310
  	public String printmsg() throws Exception {
227dbfbb   孙向锦   添加知识点id
3311
3312
3313
  		ResponseGson<Map> res = new ResponseGson();
  		res.setData(FileUploadProgressListener.map);
  		return res.toJson();
107fa3a0   孙向锦   修改试卷单选多远混合出题
3314
  
37b828b6   孙向锦   速度监测
3315
  	}
107fa3a0   孙向锦   修改试卷单选多远混合出题
3316
  
37b828b6   孙向锦   速度监测
3317
3318
  	/**
  	 * 根据ID班级名称
107fa3a0   孙向锦   修改试卷单选多远混合出题
3319
  	 * 
37b828b6   孙向锦   速度监测
3320
3321
3322
3323
3324
3325
  	 * @param id
  	 * @return
  	 * @throws Exception
  	 */
  	@RequestMapping(value = "/printresult", produces = "application/json;charset=UTF-8")
  	@ResponseBody
107fa3a0   孙向锦   修改试卷单选多远混合出题
3326
  	public String printresult() throws Exception {
37b828b6   孙向锦   速度监测
3327
3328
3329
  		ResponseGson<Map> res = new ResponseGson();
  		res.setData(FileUploadProgressListener.result);
  		return res.toJson();
107fa3a0   孙向锦   修改试卷单选多远混合出题
3330
  
227dbfbb   孙向锦   添加知识点id
3331
  	}
107fa3a0   孙向锦   修改试卷单选多远混合出题
3332
  
757dfed6   孙向锦   样例报表
3333
3334
  	@RequestMapping(value = "/uploadfile", produces = "application/json;charset=UTF-8")
  	@ResponseBody
107fa3a0   孙向锦   修改试卷单选多远混合出题
3335
3336
3337
  	public String uploadFile(
  			@RequestParam(value = "file", required = false) MultipartFile file,
  			HttpServletRequest request) throws Exception {
757dfed6   孙向锦   样例报表
3338
3339
3340
3341
  		ResponseGson<String> res = new ResponseGson<String>();
  		if (file != null) {
  			String path = request.getSession().getServletContext()
  					.getRealPath("/uploadFiles/uploadFile/");
107fa3a0   孙向锦   修改试卷单选多远混合出题
3342
3343
  			String name = System.currentTimeMillis()
  					+ file.getOriginalFilename();
757dfed6   孙向锦   样例报表
3344
3345
3346
  			File pathFile = new File(path);
  			pathFile.mkdirs();
  			File saveFile = new File(path + File.separator + name);
107fa3a0   孙向锦   修改试卷单选多远混合出题
3347
  			if (saveFile.exists()) {
757dfed6   孙向锦   样例报表
3348
3349
3350
3351
3352
  				saveFile.delete();
  			}
  			saveFile.createNewFile();
  			file.transferTo(saveFile);
  			path = request.getContextPath();
107fa3a0   孙向锦   修改试卷单选多远混合出题
3353
3354
3355
  			String basePath = request.getScheme() + "://"
  					+ request.getServerName() + ":" + request.getServerPort()
  					+ path + "/";
757dfed6   孙向锦   样例报表
3356
  			res.setData("/uploadFiles/uploadFile/" + name);
107fa3a0   孙向锦   修改试卷单选多远混合出题
3357
  		} else {
757dfed6   孙向锦   样例报表
3358
3359
3360
3361
  			res.setDataError();
  		}
  		return res.toJson();
  	}
107fa3a0   孙向锦   修改试卷单选多远混合出题
3362
3363
3364
  
  	@RequestMapping(value = "/liuqin", produces = "application/json;charset=UTF-8")
  	@ResponseBody
c34a91ee   Elvis   添加学生成绩接口
3365
  	public String dosunvotedata() /* throws Exception */{
107fa3a0   孙向锦   修改试卷单选多远混合出题
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
  
  		PageData pd = new PageData();
  		pd.put("dbtype", "mysql");
  		pd.put("username", "root");
  		pd.put("password", "admin");
  		pd.put("dbAddress", "120.78.57.84");
  		pd.put("dbport", "3306");
  		pd.put("databaseName", "sunvote");
  		pd.put("dbport", "3306");
  		List<PageData> resultList = new ArrayList<PageData>();
c34a91ee   Elvis   添加学生成绩接口
3376
  
107fa3a0   孙向锦   修改试卷单选多远混合出题
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
  		try {
  			Connection conn = DbFH.getFHCon(pd);
  
  			Statement stmt = conn.createStatement();
  			ResultSet rs = stmt
  					.executeQuery("select reportId,paperName,createTime,paperScore,classAverage,className from t_report where userId = '4000001' and className = 'G205' ");
  			while (rs.next()) {
  				PageData coloumData = new PageData();
  				String reportId = rs.getString("reportId");
  				coloumData.put("PAPER_ID", reportId);
  				coloumData.put("TESTPAPER_ID", reportId);
  				coloumData.put("NAME", rs.getString("paperName"));
  				coloumData.put("START_DATE", rs.getString("createTime"));
  				coloumData.put("END_DATE", rs.getString("createTime"));
  				coloumData.put("CREATE_DATE", rs.getString("createTime"));
  				coloumData.put("REMARK", rs.getString("paperScore"));
  				coloumData.put("TOTAL_SCORE", rs.getString("paperScore"));
  				coloumData.put("AVG_SCORE", rs.getString("classAverage"));
  				String className = rs.getString("className");
  				if ("G201".equals(className)) {
  					coloumData.put("SCLASS_ID",
  							"2af1ca03c40c4acab7b7d0f8243c9849");
  				}
  				if ("G202".equals(className)) {
  					coloumData.put("SCLASS_ID",
  							"49f1b14d10424bb6abc8aed56a4693cf");
  				}
  				if ("G203".equals(className)) {
  					coloumData.put("SCLASS_ID",
  							"80b5dde0138b405bb2bcfc5f33bad649");
  				}
  				if ("G204".equals(className)) {
  					coloumData.put("SCLASS_ID",
  							"f9de4a939ec54d7ba27d1248279a2f95");
  				}
  				if ("G205".equals(className)) {
  					coloumData.put("SCLASS_ID",
  							"0f10ce0a3bf146769213c49825c35feb");
  				}
  				if ("G206".equals(className)) {
  					coloumData.put("SCLASS_ID",
  							"d33edcd7a0f74ca9a0e92ebda9442869");
  				}
  				if ("G207".equals(className)) {
  					coloumData.put("SCLASS_ID",
  							"ffef54ef21c64525831f266b6fae34fc");
  				}
  				coloumData
  						.put("TEACHER_ID", "dbf8b49c641d47a8a811bb6d7480be72");
  				coloumData.put("TEST_TYPE", "1");
  
  				List<PageData> detailList = new ArrayList<PageData>();
  
  				Statement stmt1 = conn.createStatement();
  				ResultSet rs1 = stmt1
  						.executeQuery("select studentName,answerStr,score,totalScore from t_reportdetail where reportId = '"
  								+ reportId + "'");
  				while (rs1.next()) {
  					PageData detailPd = new PageData();
  					detailPd.put("NAME", rs1.getString("studentName"));
  					detailPd.put("answerStr", rs1.getString("answerStr"));
  					detailPd.put("SCORE", rs1.getString("totalScore"));
c34a91ee   Elvis   添加学生成绩接口
3439
  					detailPd.put("totalScore", rs.getString("paperScore"));
107fa3a0   孙向锦   修改试卷单选多远混合出题
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
  					detailList.add(detailPd);
  				}
  				rs1.close();
  				stmt1.close();
  				stmt1 = null;
  				coloumData.put("STUDENT", detailList);
  
  				resultList.add(coloumData);
  			}
  			rs.close();
  			stmt.close();
  			conn.close();
c34a91ee   Elvis   添加学生成绩接口
3452
  		} catch (Exception e) {
107fa3a0   孙向锦   修改试卷单选多远混合出题
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
  			e.printStackTrace();
  		}
  		for (PageData paper : resultList) {
  			PageData testPd = new PageData();
  			testPd.put("TESTPAPER_ID", paper.get("TESTPAPER_ID"));
  			testPd.put("PAPER_ID", paper.get("PAPER_ID"));
  			List<PageData> listData = null;
  			try {
  				listData = testpaperService.listAll(testPd);
  			} catch (Exception e) {
  				e.printStackTrace();
  			}
  			if ((listData != null && listData.size() > 0)) {
  				String testPaperId = listData.get(0).getString("TESTPAPER_ID");
  				try {
  					testpaperService.deleteList(testPd);
  				} catch (Exception e) {
  					e.printStackTrace();
  				}
  				testPd.put("TEST_ID", testPaperId);
  				try {
  					testpaperinfoService.delete(testPd);
  				} catch (Exception e) {
  					e.printStackTrace();
  				}
  				try {
  					studenttestService.delete(testPd);
  				} catch (Exception e) {
  					e.printStackTrace();
  				}
  				listData.clear();
  			}
  			if (!(listData != null && listData.size() > 0)) {
  				logger.info(paper);
  				try {
  					testpaperService.save(paper);
  				} catch (Exception e) {
  					e.printStackTrace();
  				}
c34a91ee   Elvis   添加学生成绩接口
3492
3493
3494
  				logger.info("添加测试名称成功:" + paper.get("TESTPAPER_ID"));
  				List<PageData> detailList = (List<PageData>) paper
  						.get("STUDENT");
107fa3a0   孙向锦   修改试卷单选多远混合出题
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
  				int i = 0;
  				List<PageData> testInfoPdList = new ArrayList();
  				for (PageData student : detailList) {
  					i++;
  					PageData studentDetail = null;
  					try {
  						studentDetail = studentService.findByName(student);
  					} catch (Exception e) {
  						e.printStackTrace();
  					}
  					PageData studentPageData = new PageData();
  					studentPageData.put("STUDENTTEST_ID", get32UUID());
  					studentPageData.put("STUDENT_ID", studentDetail.get("ID"));
  					studentPageData.put("TEST_ID", paper.get("TESTPAPER_ID"));
  					studentPageData.put("PAPER_ID", paper.get("TESTPAPER_ID"));
  					studentPageData.put("SCORE", student.get("SCORE"));
  					studentPageData.put("CLASS_ID", paper.get("SCLASS_ID"));
  					logger.info("学生测试数据");
  					logger.info(studentPageData);
  					try {
  						studenttestService.save(studentPageData);
  					} catch (Exception e) {
  						e.printStackTrace();
  					}
c34a91ee   Elvis   添加学生成绩接口
3519
  					logger.info("添加学生测试成功:" + studentDetail.get("NAME"));
107fa3a0   孙向锦   修改试卷单选多远混合出题
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
  
  					String answerStr = student.getString("answerStr");
  					String[] answerStrs = answerStr.split(";");
  					int j = 0;
  					for (String answers : answerStrs) {
  						j++;
  						PageData testInfoPd = new PageData();
  						testInfoPd.put("TESTPAPERINFO_ID", this.get32UUID());
  						testInfoPd.put("PAPER_ID", paper.get("TESTPAPER_ID"));
  						testInfoPd.put("STUDENT_ID", studentDetail.get("ID"));
  						testInfoPd.put("TEST_ID", paper.get("TESTPAPER_ID"));
c34a91ee   Elvis   添加学生成绩接口
3531
3532
  						testInfoPd.put("QUESTION_ID", paper.get("TESTPAPER_ID")
  								+ "" + i);
107fa3a0   孙向锦   修改试卷单选多远混合出题
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
  						String[] ans = answers.split(",");
  						testInfoPd.put("ANSWER", ans[0]);
  						testInfoPd.put("RIGHT", ans[1]);
  						testInfoPd.put("SCORE", "");
  						testInfoPd.put("LIKES", "");
  						testInfoPd.put("ANSWER_TYPE", "1");
  						testInfoPd.put("PRESS_TIME", "");
  						testInfoPd.put("RECEIVER_DATE", "");
  						testInfoPd.put("SUBJECTIVE", "");
  						testInfoPd.put("MARK_NO", "" + j);
  						testInfoPd.put("RANDOM", "" + j);
  						testInfoPd.put("RANK", "" + j);
  						try {
  							logger.info("学生详细测试数据");
  							logger.info(testInfoPd);
  							testpaperinfoService.save(testInfoPd);
  							logger.info("添加学生详细情况成功:");
  						} catch (Exception e) {
  							// TODO Auto-generated catch block
  							e.printStackTrace();
  						}
c34a91ee   Elvis   添加学生成绩接口
3554
  						// testInfoPdList.add(testInfoPd);
107fa3a0   孙向锦   修改试卷单选多远混合出题
3555
  					}
c34a91ee   Elvis   添加学生成绩接口
3556
3557
  					// logger.info("学生详细测试数据");
  					// logger.info(testInfoPdList);
107fa3a0   孙向锦   修改试卷单选多远混合出题
3558
  					try {
c34a91ee   Elvis   添加学生成绩接口
3559
  						// testpaperinfoService.batchSave(testInfoPdList);
107fa3a0   孙向锦   修改试卷单选多远混合出题
3560
3561
3562
  					} catch (Exception e) {
  						e.printStackTrace();
  					}
c34a91ee   Elvis   添加学生成绩接口
3563
  					// logger.info("添加学生详细情况成功:");
107fa3a0   孙向锦   修改试卷单选多远混合出题
3564
3565
3566
  				}
  			}
  		}
c34a91ee   Elvis   添加学生成绩接口
3567
  
107fa3a0   孙向锦   修改试卷单选多远混合出题
3568
3569
3570
3571
  		ResponseGson<String> res = new ResponseGson<String>();
  		return res.toJson();
  	}
  
bed6e1fc   孙向锦   添加其他功能
3572
  }