|
@@ -1,13 +1,20 @@
|
|
|
package cn.hmsoft.ses.control.pl;
|
|
|
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
|
+
|
|
|
import org.apache.commons.io.FilenameUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -15,10 +22,16 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import cn.hmsoft.frame.control.FrameControl;
|
|
|
+import cn.hmsoft.frame.data.model.FrameDict;
|
|
|
import cn.hmsoft.frame.data.model.FrameOptr;
|
|
|
import cn.hmsoft.frame.exception.web.BusinessException;
|
|
|
+import cn.hmsoft.frame.util.FrameDictUtil;
|
|
|
import cn.hmsoft.frame.util.RequestContextUtil;
|
|
|
+import cn.hmsoft.helper.LogHelper;
|
|
|
import cn.hmsoft.helper.StringHelper;
|
|
|
+import cn.hmsoft.jdbc.entity.Pager;
|
|
|
+import cn.hmsoft.jdbc.entity.QueryOrder;
|
|
|
+import cn.hmsoft.jdbc.entity.QueryOrderType;
|
|
|
import cn.hmsoft.office.excel.Excel2007Writer;
|
|
|
import cn.hmsoft.office.excel.ExcelReaderHelper;
|
|
|
import cn.hmsoft.ses.common.constants.PlConst.LogOperateType;
|
|
@@ -66,13 +79,20 @@ public class PlTextbookControl extends FrameControl{
|
|
|
* 分页查询教材信息
|
|
|
*/
|
|
|
@RequestMapping("pl/plTextbook/page")
|
|
|
- public Ajax pagePlTextbook(String query, Integer limit, Integer start, String order, String type,Integer status,Integer exam_time_id) {
|
|
|
+ public Ajax pagePlTextbook(String query, Integer limit, Integer start, String order, String type,Integer status,Integer exam_time_id,Integer is_unified) {
|
|
|
this.getFrameOptr();
|
|
|
- if (StringHelper.isEmpty(order)) {
|
|
|
- order = "et.year_code";
|
|
|
- type = "desc";
|
|
|
- }
|
|
|
- return new Ajax(this.plTextbookService.pagePlTextbook(query, start, limit, order, type,status,exam_time_id));
|
|
|
+ QueryOrder queryOrder = null;
|
|
|
+ if (StringHelper.isEmpty(order)) {
|
|
|
+ LinkedHashMap<String, QueryOrderType> fields = new LinkedHashMap<String, QueryOrderType>();
|
|
|
+ fields.put("et.year_code", QueryOrderType.DESC);
|
|
|
+ fields.put("c.course_code", QueryOrderType.ASC);
|
|
|
+ new QueryOrder(fields);
|
|
|
+ queryOrder = new QueryOrder(fields);
|
|
|
+ } else {
|
|
|
+ queryOrder = this.getQueryOrder(order, type);
|
|
|
+ }
|
|
|
+
|
|
|
+ return new Ajax(this.plTextbookService.pagePlTextbook(query, start, limit, queryOrder,status,exam_time_id, is_unified));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -80,25 +100,32 @@ public class PlTextbookControl extends FrameControl{
|
|
|
* 新增教材
|
|
|
*/
|
|
|
@RequestMapping("pl/plTextbook/add")
|
|
|
- public Ajax addPlTextbook(final PlTextbook plTextbook,String course_ids,String course_exam_times) {
|
|
|
+ public Ajax addPlTextbook(final PlTextbook plTextbook) {
|
|
|
this.getFrameOptr();
|
|
|
- List<PlTextbook> bookList = this.plTextbookService.list("textbook_code", plTextbook.getTextbook_code());
|
|
|
- if(bookList != null && bookList.size()>0) {
|
|
|
- throw new BusinessException("教材代码已经存在,请不要录入相同的教材代码");
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(plTextbook.getTextbook_name())){
|
|
|
+ throw new BusinessException("教材名称不允许为空。");
|
|
|
}
|
|
|
- Integer tex_tbook_id=this.plTextbookService.insert(plTextbook);
|
|
|
- if (course_ids!=null) {
|
|
|
- String[] courses=course_ids.split(",");
|
|
|
- String[] exam_times=course_exam_times.split(",");
|
|
|
- for (int i = 0; i < courses.length; i++) {
|
|
|
- PlCourseTextbook courseTextbook=new PlCourseTextbook();
|
|
|
- courseTextbook.setTextbook_id(tex_tbook_id);
|
|
|
- courseTextbook.setCourse_id(Integer.valueOf(courses[i]));
|
|
|
- courseTextbook.setExam_time_id(Integer.valueOf(exam_times[i]));
|
|
|
- addPlTextbookCourse(courseTextbook);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+
|
|
|
+ if(null == plTextbook.getCourse_id()){
|
|
|
+ throw new BusinessException("关联课程不允许为空。");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(null == plTextbook.getExam_time_id()){
|
|
|
+ throw new BusinessException("考试批次不允许为空。");
|
|
|
+ }
|
|
|
+
|
|
|
+ PlTextbook temp = this.plTextbookService.queryPlTextBookByCourseAndExamYear(plTextbook.getCourse_id(), plTextbook.getExam_time_id());
|
|
|
+
|
|
|
+ if(null != temp){
|
|
|
+ throw new BusinessException("当前考试批次,当前课程已经存在教材信息,请不要重复添加。");
|
|
|
+ }
|
|
|
+
|
|
|
+ //PlCourse plCourse = this.courseService.find(plTextbook.getCourse_id());
|
|
|
+ //plTextbook.setTextbook_code("0"+plCourse.getCourse_code());
|
|
|
+
|
|
|
+ this.plTextbookService.insert(plTextbook);
|
|
|
+
|
|
|
|
|
|
return new Ajax();
|
|
|
}
|
|
@@ -110,6 +137,36 @@ public class PlTextbookControl extends FrameControl{
|
|
|
@RequestMapping("pl/plTextbook/edit")
|
|
|
public Ajax editPlTextbook(final PlTextbook plTextbook) {
|
|
|
this.getFrameOptr();
|
|
|
+ if(StringUtils.isEmpty(plTextbook.getTextbook_name())){
|
|
|
+ throw new BusinessException("教材名称不允许为空。");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(null == plTextbook.getCourse_id()){
|
|
|
+ throw new BusinessException("关联课程不允许为空。");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(null == plTextbook.getExam_time_id()){
|
|
|
+ throw new BusinessException("考试批次不允许为空。");
|
|
|
+ }
|
|
|
+
|
|
|
+ PlTextbook temp = this.plTextbookService.find(plTextbook.getId());
|
|
|
+ if(null == temp){
|
|
|
+ throw new BusinessException("教材信息为空,编辑失败。");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(null != temp.getExam_time_id() && temp.getExam_time_id().intValue() != plTextbook.getExam_time_id().intValue()){
|
|
|
+ throw new BusinessException("不允许修改考试批次。");
|
|
|
+ }
|
|
|
+
|
|
|
+ PlTextbook temp_PlTextbook = this.plTextbookService.queryPlTextBookByCourseAndExamYear(plTextbook.getCourse_id(), plTextbook.getExam_time_id());
|
|
|
+
|
|
|
+ if(null != temp_PlTextbook && plTextbook.getId().intValue() != temp_PlTextbook.getId().intValue()){
|
|
|
+ throw new BusinessException("当前考试批次,当前课程已经存在教材信息,请不要修改关联课程。");
|
|
|
+ }
|
|
|
+
|
|
|
+ //PlCourse plCourse = this.courseService.find(plTextbook.getCourse_id());
|
|
|
+ //plTextbook.setTextbook_code("0"+plCourse.getCourse_code());
|
|
|
+
|
|
|
this.plTextbookService.edit(plTextbook);
|
|
|
return new Ajax();
|
|
|
}
|
|
@@ -118,14 +175,24 @@ public class PlTextbookControl extends FrameControl{
|
|
|
@RequestMapping("pl/plTextbook/deleteBatch")
|
|
|
public Ajax deletePlTextbook(final Integer[] ids) {
|
|
|
this.getFrameOptr();
|
|
|
+ PlTextbook plTextbook = null;
|
|
|
+ for (Integer id : ids) {
|
|
|
+ plTextbook = this.plTextbookService.find(id);
|
|
|
+ if(null != plTextbook && null != plTextbook.getStatus() && plTextbook.getStatus().intValue() == 1){
|
|
|
+ throw new BusinessException("教材已经发布,不允许删除。");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
for (Integer id : ids) {
|
|
|
- List<PlCourseTextbook> list = this.courseTextbookService.list("textbook_id", id);
|
|
|
+ /*List<PlCourseTextbook> list = this.courseTextbookService.list("textbook_id", id);
|
|
|
if (list != null && list.size() > 0) {
|
|
|
for(PlCourseTextbook book :list){
|
|
|
// 删除关联关系,但不删除历史关联关系
|
|
|
this.courseTextbookService.delete(book.getId());
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
+
|
|
|
this.plTextbookService.delete(id);
|
|
|
}
|
|
|
return new Ajax();
|
|
@@ -208,6 +275,7 @@ public class PlTextbookControl extends FrameControl{
|
|
|
return new Ajax();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 模板下载
|
|
|
*/
|
|
@@ -253,85 +321,164 @@ public class PlTextbookControl extends FrameControl{
|
|
|
|
|
|
try {
|
|
|
List<List<String>> uploadList = ExcelReaderHelper.readSheet(file.getOriginalFilename(),
|
|
|
- file.getInputStream(), 0, 10);
|
|
|
+ file.getInputStream(), 0, 11);
|
|
|
List<List<Object>> errList = getTitle(uploadList);
|
|
|
- List<PlCourseTextbook> result = new ArrayList<>();// 插入数据库中的数据
|
|
|
+ List<PlTextbook> result = new ArrayList<PlTextbook>();// 插入数据库中的数据
|
|
|
+
|
|
|
for(int i=1; i<uploadList.size(); i++) {
|
|
|
+ Integer exam_time_id = null;
|
|
|
+ Integer course_id = null;
|
|
|
+ PlTextbook temp = null;
|
|
|
+ PlCourse course = null;
|
|
|
+
|
|
|
List<String> list = uploadList.get(i);
|
|
|
StringBuffer errMsg = new StringBuffer();
|
|
|
String index = list.get(0);
|
|
|
- String courseName = list.get(1);
|
|
|
- String courseCode = getCourseCode(list.get(2));
|
|
|
- String score = list.get(3);
|
|
|
+ String courseCode = list.get(1);
|
|
|
+ String courseName = getCourseCode(list.get(2));
|
|
|
+ String textbookName = list.get(3);
|
|
|
String outLine = list.get(4);
|
|
|
- String textbookName = list.get(5);
|
|
|
- String writer = list.get(6);
|
|
|
- String publisher = list.get(7);
|
|
|
- String revision = list.get(8);
|
|
|
- String time = list.get(9);
|
|
|
+ String writer = list.get(5);
|
|
|
+ String publisher = list.get(6);
|
|
|
+ String revision = list.get(7);
|
|
|
+ String time = list.get(8);
|
|
|
|
|
|
- //课程存在判断
|
|
|
- List<PlCourse> courseList = this.courseService.list("course_code", courseCode);
|
|
|
- if(courseList == null || courseList.size() == 0) {
|
|
|
- errMsg.append("课程不存在;");
|
|
|
+ String file_name = null;
|
|
|
+ String file_path = null;
|
|
|
+
|
|
|
+ if(list.size()>9){
|
|
|
+ file_name = list.get(9);
|
|
|
+ file_path = list.get(10);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
//教材存在判断
|
|
|
textbookName = (textbookName != null) ? textbookName.trim() : textbookName;
|
|
|
writer = (writer != null) ? writer.trim() : writer;
|
|
|
publisher = (publisher != null) ? publisher.trim() : publisher;
|
|
|
- List<PlTextbook> bookList = this.plTextbookService.listTextbook(textbookName, writer, publisher);
|
|
|
- if(bookList == null || bookList.size() == 0) {
|
|
|
- errMsg.append("教材不存在;");
|
|
|
+ courseCode = (courseCode != null) ? courseCode.trim() : courseCode;
|
|
|
+ outLine = (outLine != null) ? outLine.trim() : outLine;
|
|
|
+ revision = (revision != null) ? revision.trim() : revision;
|
|
|
+
|
|
|
+ file_name = (file_name != null) ? file_name.trim() : file_name;
|
|
|
+ file_path = (file_path != null) ? file_path.trim() : file_path;
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(courseCode)){
|
|
|
+ errMsg.append("课程代码不允许为空;");
|
|
|
+ }else{
|
|
|
+ //课程存在判断
|
|
|
+ List<PlCourse> courseList = this.courseService.list("course_code", courseCode);
|
|
|
+ if(courseList == null || courseList.size() == 0) {
|
|
|
+ errMsg.append("课程代码在系统中不存在;");
|
|
|
+ }else{
|
|
|
+ course_id = courseList.get(0).getId();
|
|
|
+ course = courseList.get(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(textbookName)){
|
|
|
+ errMsg.append("教材名称不允许为空;");
|
|
|
+ }else if(textbookName.length() >200){
|
|
|
+ errMsg.append("教材名称长度不允许超过200字节;");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!StringUtils.isEmpty(writer) && writer.length()>90){
|
|
|
+ errMsg.append("编著长度不允许超过90字节;");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!StringUtils.isEmpty(publisher) && publisher.length()>90){
|
|
|
+ errMsg.append("出版社长度不允许超过90字节;");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!StringUtils.isEmpty(outLine) && outLine.length()>100){
|
|
|
+ errMsg.append("教材大纲长度不允许超过100字节;");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!StringUtils.isEmpty(revision) && revision.length()>32){
|
|
|
+ errMsg.append("版次长度不允许超过32字节;");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
//批次码(启用时间)判断
|
|
|
List<PlExamTime> timeList = new ArrayList<>();
|
|
|
if (StringHelper.isNotEmpty(time)) {
|
|
|
if (time.trim().length() != 6) {
|
|
|
- errMsg.append("启用时间填写6位批次码;");
|
|
|
+ errMsg.append("考试批次填写6位批次码;");
|
|
|
}
|
|
|
timeList = this.timeService.list("year_code", time);
|
|
|
if (timeList == null || timeList.size() == 0) {
|
|
|
- errMsg.append("请配置年度码和考试时间;");
|
|
|
+ errMsg.append("请先配置年度码和考试时间;");
|
|
|
+ }else{
|
|
|
+ exam_time_id = timeList.get(0).getId();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if(null != course_id && null != exam_time_id){
|
|
|
+ temp = this.plTextbookService.queryPlTextBookByCourseAndExamYear(course_id, exam_time_id);
|
|
|
+
|
|
|
+ if(null != temp){
|
|
|
+ errMsg.append("课程对应的考试批次已经存在教材,不允许重复添加;");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!StringUtils.isEmpty(file_path)){
|
|
|
+ File temp_file = new File(file_path);
|
|
|
+ if(!temp_file.exists()){
|
|
|
+ errMsg.append("教材大纲文件在系统中不存在,请清空教材大纲文件路径或者修改教材大纲文件路径;");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(file_name)){
|
|
|
+ errMsg.append("请填写教材大纲文件名称;");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
// 保存所有错误
|
|
|
List<Object> objList = new ArrayList<Object>();
|
|
|
objList.add(index);
|
|
|
objList.add(courseName);
|
|
|
objList.add(courseCode);
|
|
|
- objList.add(score);
|
|
|
objList.add(outLine);
|
|
|
objList.add(textbookName);
|
|
|
objList.add(writer);
|
|
|
objList.add(publisher);
|
|
|
objList.add(revision);
|
|
|
objList.add(time);
|
|
|
+ objList.add(file_name);
|
|
|
+ objList.add(file_path);
|
|
|
objList.add(errMsg);// 错误描述列
|
|
|
errList.add(objList);
|
|
|
|
|
|
//无误数据导入
|
|
|
if (errMsg.length() == 0) {
|
|
|
- PlCourse course = courseList.get(0);
|
|
|
- PlTextbook book = bookList.get(0);
|
|
|
- PlExamTime examTime = new PlExamTime();
|
|
|
- if (StringHelper.isEmpty(time)) {
|
|
|
- List<PlExamTime> curList = this.timeService.list("year_code",
|
|
|
- YearCodeHelper.getCurrentYearCode());
|
|
|
- examTime = (curList != null && curList.size() > 0) ? curList.get(0) : new PlExamTime();
|
|
|
- } else {
|
|
|
- examTime = timeList.get(0);
|
|
|
+ PlTextbook plTextbook = new PlTextbook();
|
|
|
+ plTextbook.setTextbook_code("0"+course.getCourse_code());
|
|
|
+ plTextbook.setTextbook_name(textbookName);
|
|
|
+ plTextbook.setTextbook_writer(writer);
|
|
|
+ plTextbook.setTextbook_publisher(publisher);
|
|
|
+ plTextbook.setTextbook_revision(revision);
|
|
|
+ plTextbook.setTextbook_outline(outLine);
|
|
|
+
|
|
|
+ if(!StringUtils.isEmpty(file_path)){
|
|
|
+ plTextbook.setFile_path(file_path);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!StringUtils.isEmpty(file_name)){
|
|
|
+ plTextbook.setFile_name(file_name);
|
|
|
}
|
|
|
- PlCourseTextbook ctBook = new PlCourseTextbook();
|
|
|
- ctBook.setCourse_id(course.getId());
|
|
|
- ctBook.setTextbook_id(book.getId());
|
|
|
- ctBook.setExam_time_id(examTime.getId());
|
|
|
- result.add(ctBook);
|
|
|
+
|
|
|
+ plTextbook.setStatus(0);
|
|
|
+ plTextbook.setExam_time_id(exam_time_id);
|
|
|
+ plTextbook.setCourse_id(course_id);
|
|
|
+
|
|
|
+ result.add(plTextbook);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (result.size() == uploadList.size() - 1) {
|
|
|
- this.courseTextbookService.addCourseTextbook(result);
|
|
|
+ this.plTextbookService.addPlTextbook(result);
|
|
|
} else {
|
|
|
ajax.setErrorCode(-1);
|
|
|
ajax.setErrorMsg("存在不合规记录,请下载查看.");
|
|
@@ -365,7 +512,7 @@ public class PlTextbookControl extends FrameControl{
|
|
|
List<List<Object>> errList = new ArrayList<>();
|
|
|
if (uploadList != null && uploadList.size() > 0) {
|
|
|
List<String> data = uploadList.get(0);
|
|
|
- List<Object> list = getOrigData(data, 10);
|
|
|
+ List<Object> list = getOrigData(data, 11);
|
|
|
list.add("错误提示");
|
|
|
errList.add(list);
|
|
|
}
|
|
@@ -447,5 +594,213 @@ public class PlTextbookControl extends FrameControl{
|
|
|
this.downloadFile(this.courseTextbookService.exportCtbook(exam_year), fileName,true);
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping("pl/plTextbook/downloadFile")
|
|
|
+ public void downloadFile(Integer id) {
|
|
|
+ PlTextbook plTextbook = this.plTextbookService.find(id);
|
|
|
+ File file = new File(plTextbook.getFile_path());
|
|
|
+ this.downloadFile(file, file.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("pl/plTextbook/uploadFile")
|
|
|
+ public Ajax uploadFile(Integer exam_time_id, MultipartFile file) {
|
|
|
+ Ajax ajax = new Ajax();
|
|
|
+
|
|
|
+ String extension = FilenameUtils.getExtension(file.getOriginalFilename());
|
|
|
+ // 转换小写
|
|
|
+ extension = extension.toLowerCase();
|
|
|
+
|
|
|
+ // 校验文件类型
|
|
|
+ if (!"jpg".equals(extension) && !"jpeg".equals(extension) && !"png".equals(extension)&& !"gif".equals(extension)&& !"bmp".equals(extension)&&!"xlsx".equals(extension) && !"xls".equals(extension) && !"doc".equals(extension)&& !"docx".equals(extension)&& !"pdf".equals(extension) && !"txt".equals(extension)&& !"zip".equals(extension)) {
|
|
|
+ ajax.setSuccess(false);
|
|
|
+ ajax.setErrorCode(-1);
|
|
|
+ ajax.setErrorMsg("上传文件必须是JPG/JPEG/PNG/xls/xlsx/doc/docx/pdf/txt/zip格式!");
|
|
|
+ return ajax;
|
|
|
+ }
|
|
|
+
|
|
|
+ String yearCode = null;
|
|
|
+ PlExamTime plExamTime = this.timeService.find(exam_time_id);
|
|
|
+ if(null == plExamTime){
|
|
|
+ yearCode = YearCodeHelper.getCurrentYearCode();
|
|
|
+ }else{
|
|
|
+ yearCode = plExamTime.getYear_code()+"";
|
|
|
+ }
|
|
|
+
|
|
|
+ String fileDir = SysConst.getPlTextbookPath(yearCode);
|
|
|
+ File dir = new File(fileDir);
|
|
|
+ if (!dir.exists()) {
|
|
|
+ dir.mkdirs();
|
|
|
+ }
|
|
|
+ File desFile = new File(fileDir + file.getOriginalFilename());
|
|
|
+ try {
|
|
|
+ file.transferTo(desFile);
|
|
|
+ Map<String, String> map = new HashMap<String, String>();
|
|
|
+ map.put("file_path", desFile.toString());
|
|
|
+ map.put("file_name", file.getOriginalFilename());
|
|
|
+ ajax.setMap(map);
|
|
|
+ } catch (IllegalStateException e) {
|
|
|
+ LogHelper.error(e);
|
|
|
+ } catch (IOException e) {
|
|
|
+ LogHelper.error(e);
|
|
|
+ }
|
|
|
+ return ajax;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @RequestMapping("pl/plTextbook/downxls")
|
|
|
+ public void downxls(String query, Integer limit, Integer start, String order, String type,Integer status,Integer exam_time_id,Integer is_unified) {
|
|
|
+ QueryOrder queryOrder = null;
|
|
|
+ if (StringHelper.isEmpty(order)) {
|
|
|
+ LinkedHashMap<String, QueryOrderType> fields = new LinkedHashMap<String, QueryOrderType>();
|
|
|
+ fields.put("et.year_code", QueryOrderType.DESC);
|
|
|
+ fields.put("c.course_code", QueryOrderType.ASC);
|
|
|
+ new QueryOrder(fields);
|
|
|
+ queryOrder = new QueryOrder(fields);
|
|
|
+ } else {
|
|
|
+ queryOrder = this.getQueryOrder(order, type);
|
|
|
+ }
|
|
|
+
|
|
|
+ Pager pager = this.plTextbookService.pagePlTextbook(query, 0, Integer.MAX_VALUE, queryOrder,status,exam_time_id, is_unified);
|
|
|
+
|
|
|
+ List<List<Object>> values = new ArrayList<List<Object>>();
|
|
|
+ List<Object> headerList = new ArrayList<Object>();
|
|
|
+ headerList.add("序号");
|
|
|
+ headerList.add("课程代码");
|
|
|
+ headerList.add("课程名称");
|
|
|
+ headerList.add("教材名称");
|
|
|
+ headerList.add("教材大纲");
|
|
|
+
|
|
|
+ headerList.add("编著");
|
|
|
+ headerList.add("出版社");
|
|
|
+ headerList.add("版次");
|
|
|
+ headerList.add("考试批次");
|
|
|
+ headerList.add("教材大纲文件名称");
|
|
|
+ headerList.add("教材大纲文件路径");
|
|
|
+
|
|
|
+ values.add(headerList);
|
|
|
+
|
|
|
+ int i=1;
|
|
|
+ List<Map<String, Object>> list = (List<Map<String, Object>>)pager.getRecords();
|
|
|
+ for (Map<String, Object> map: list) {
|
|
|
+ List<Object> rowList = new ArrayList<Object>();
|
|
|
+ rowList.add(i);
|
|
|
+ rowList.add(map.get("course_code"));
|
|
|
+ rowList.add(map.get("course_name"));
|
|
|
+ rowList.add(map.get("textbook_name"));
|
|
|
+ rowList.add(map.get("textbook_outline"));
|
|
|
+ rowList.add(map.get("textbook_writer"));
|
|
|
+ rowList.add(map.get("textbook_publisher"));
|
|
|
+ rowList.add(map.get("textbook_revision"));
|
|
|
+ rowList.add(map.get("year_code"));
|
|
|
+ rowList.add(map.get("file_name"));
|
|
|
+ rowList.add(map.get("file_path"));
|
|
|
+
|
|
|
+ values.add(rowList);
|
|
|
+
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ ServletOutputStream outStream = null;
|
|
|
+ try {
|
|
|
+ String fileName = "教材信息" + ".xlsx";
|
|
|
+ fileName = URLEncoder.encode(fileName, "UTF-8");
|
|
|
+ fileName = new String(fileName.getBytes(), "ISO-8859-1");
|
|
|
+ XSSFWorkbook wb = Excel2007Writer.createExcel(values);
|
|
|
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
|
+ wb.write(os);
|
|
|
+ this.getResponse().reset();
|
|
|
+ this.getResponse().setContentType("application/x-msdownload");
|
|
|
+ this.getResponse().setHeader("Content-Disposition", "attachment; filename=" + fileName);
|
|
|
+ outStream = this.getResponse().getOutputStream();
|
|
|
+ outStream.write(os.toByteArray());
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if(outStream != null) {
|
|
|
+ try {
|
|
|
+ outStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @RequestMapping("pl/plTextbook/downXlsForUnified")
|
|
|
+ public void downXlsForUnified(Integer limit, Integer start, String order, String type,Integer exam_time_id) {
|
|
|
+ QueryOrder queryOrder = null;
|
|
|
+ if (StringHelper.isEmpty(order)) {
|
|
|
+ LinkedHashMap<String, QueryOrderType> fields = new LinkedHashMap<String, QueryOrderType>();
|
|
|
+ fields.put("c.course_code", QueryOrderType.ASC);
|
|
|
+ new QueryOrder(fields);
|
|
|
+ queryOrder = new QueryOrder(fields);
|
|
|
+ } else {
|
|
|
+ queryOrder = this.getQueryOrder(order, type);
|
|
|
+ }
|
|
|
+
|
|
|
+ Pager pager = this.plTextbookService.pagePlTextbookForUnified(0, Integer.MAX_VALUE, queryOrder, exam_time_id);
|
|
|
+
|
|
|
+ List<List<Object>> values = new ArrayList<List<Object>>();
|
|
|
+ List<Object> headerList = new ArrayList<Object>();
|
|
|
+ headerList.add("序号");
|
|
|
+ headerList.add("课程代码");
|
|
|
+ headerList.add("课程名称");
|
|
|
+ headerList.add("教材名称");
|
|
|
+ headerList.add("教材大纲");
|
|
|
+
|
|
|
+ headerList.add("编著");
|
|
|
+ headerList.add("出版社");
|
|
|
+ headerList.add("版次");
|
|
|
+ headerList.add("考试批次");
|
|
|
+ headerList.add("教材大纲文件名称");
|
|
|
+ headerList.add("教材大纲文件路径");
|
|
|
+
|
|
|
+ values.add(headerList);
|
|
|
+
|
|
|
+ int i=1;
|
|
|
+ List<Map<String, Object>> list = (List<Map<String, Object>>)pager.getRecords();
|
|
|
+ for (Map<String, Object> map: list) {
|
|
|
+ List<Object> rowList = new ArrayList<Object>();
|
|
|
+ rowList.add(i);
|
|
|
+ rowList.add(map.get("course_code"));
|
|
|
+ rowList.add(map.get("course_name"));
|
|
|
+ rowList.add(map.get("textbook_name"));
|
|
|
+ rowList.add(map.get("textbook_outline"));
|
|
|
+ rowList.add(map.get("textbook_writer"));
|
|
|
+ rowList.add(map.get("textbook_publisher"));
|
|
|
+ rowList.add(map.get("textbook_revision"));
|
|
|
+ rowList.add(map.get("year_code"));
|
|
|
+ rowList.add(map.get("file_name"));
|
|
|
+ rowList.add(map.get("file_path"));
|
|
|
+
|
|
|
+
|
|
|
+ values.add(rowList);
|
|
|
+
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ ServletOutputStream outStream = null;
|
|
|
+ try {
|
|
|
+ String fileName = "考试计划未完善的教材信息" + ".xlsx";
|
|
|
+ fileName = URLEncoder.encode(fileName, "UTF-8");
|
|
|
+ fileName = new String(fileName.getBytes(), "ISO-8859-1");
|
|
|
+ XSSFWorkbook wb = Excel2007Writer.createExcel(values);
|
|
|
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
|
+ wb.write(os);
|
|
|
+ this.getResponse().reset();
|
|
|
+ this.getResponse().setContentType("application/x-msdownload");
|
|
|
+ this.getResponse().setHeader("Content-Disposition", "attachment; filename=" + fileName);
|
|
|
+ outStream = this.getResponse().getOutputStream();
|
|
|
+ outStream.write(os.toByteArray());
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if(outStream != null) {
|
|
|
+ try {
|
|
|
+ outStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|