package com.zcloud.controller.eduStudy; import com.zcloud.controller.base.BaseController; import com.zcloud.entity.*; import com.zcloud.service.eduStudy.*; import com.zcloud.service.system.UsersService; import com.zcloud.util.*; import fr.opensagres.xdocreport.document.IXDocReport; import fr.opensagres.xdocreport.document.registry.XDocReportRegistry; import fr.opensagres.xdocreport.template.IContext; import fr.opensagres.xdocreport.template.TemplateEngineKind; import fr.opensagres.xdocreport.template.formatter.FieldsMetadata; import fr.opensagres.xdocreport.template.formatter.NullImageBehaviour; import org.apache.tools.ant.Project; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.*; /** * 说明:学员管理 * 作者:zhangyue * 时间:2021-07-03 * 官网:www.zcloudchina.com */ @Controller @RequestMapping("/student") public class StudentController extends BaseController { public static final String fileNumberPrefix = "XYBH-"; @Autowired private UsersService usersService; @Autowired private StudentService studentService; @Autowired private ClassPostService classPostService; @Autowired private InitPageDataUtil initPageDataUtil; @Autowired private StageStudentRelationService stageStudentRelationService; @Autowired private PostPaperService postPaperService; @Autowired private ClassService classService; /** * 新增 * * @param * @throws Exception */ @RequestMapping(value = "/add") // @RequiresPermissions("student:add") @ResponseBody public Object add() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); if (pd.get("userIds") != null && !pd.get("userIds").equals("")) { String userIds[] = pd.get("userIds").toString().split(","); // List userList = Arrays.asList(userIds); for (String data : userIds) { PageData userInfo = new PageData(); userInfo.put("USER_ID", data); userInfo = usersService.findById(userInfo); pd.putAll(userInfo); pd.put("DUTIES", ""); if (!Tools.isEmpty(userInfo.get("DUTIES_NAME"))) { pd.put("DUTIES", userInfo.getString("DUTIES_NAME")); } if (Tools.isEmpty(pd.get("DUTIES")) && !Tools.isEmpty(userInfo.get("TITLE_NAME"))) { pd.put("DUTIES", userInfo.getString("TITLE_NAME")); } pd.put("FILE_NUMBER", fileNumberPrefix + DateUtil.getSdfTimesSSS()); if (pd.get("CLASS_ID") == null || Tools.isEmpty(pd.get("CLASS_ID").toString())) { map.put("result", "error"); //返回结果 map.put("msg", "数据不全,请联系管理员"); return map; } // 查询班级信息 PageData classInfo = classService.findById(pd); // state 不是1 的班级。只允许在 班级内已经有的 部门-工种 下添加学员。 String idCard = (String) userInfo.get("USER_ID_CARD"); PageData info = studentService.findByFileNumber(pd); // 编号如果不为0 那么肯定有记录 user无需添加 身份证比较过了 可以修改班级内的信息 if (!"0".equals(info.get("num").toString())) { // 库里有数据 if (Integer.valueOf(String.valueOf(info.get("num"))) >= 1) { // 查一下 是这个档案编号的人 看是不是这个班级里的 是可修改 PageData userCard = studentService.findUserCardByFileNumber(pd); if (userCard != null && !userCard.get("USER_ID_CARD").toString().equals(idCard)) { map.put("result", "error"); //返回结果 map.put("msg", "档案编号已经存在。"); return map; } } } pd.put("STUDENT_ID", this.get32UUID()); //主键 initPageDataUtil.initSave(pd); // 初始化新建时间等基本信息 pd.put("STATE", "1"); // 查看本班级是否添加过这个学员,若添加过,则编辑,若没有,则新增 List _student = studentService.findByIdCardInClass(pd); if (_student != null && _student.size() >= 2) { map.put("result", "error"); //返回结果 map.put("msg", "本班级存在重复人员,请联系管理员!"); return map; } boolean isClassStart = false; // state 不是1 的班级。只允许在 班级内已经有的 部门-工种 下添加学员。 if (classInfo != null && classInfo.get("STATE") != null && !"1".equals(classInfo.getString("STATE"))) { isClassStart = true; } if (_student == null || _student.size() <= 0) { // 已开班,增加学习记录 if (isClassStart) { saveStageStudent(pd); } studentService.save(pd); List posts = classPostService.findInClass(pd); if (posts == null || posts.size() <= 0) { PageData classPost = new PageData(); classPost.put("CLASSPOST_ID", this.get32UUID()); initPageDataUtil.initSave(classPost); classPost.put("CORPINFO_ID", pd.getString("CORPINFO_ID")); classPost.put("CLASS_ID", pd.getString("CLASS_ID")); classPost.put("POST_ID", pd.getString("POST_ID")); classPost.put("POST_NAME", pd.getString("POST_NAME")); classPost.put("DEPARTMENT_ID", pd.getString("DEPARTMENT_ID")); classPost.put("DEPARTMENT_NAME", pd.getString("DEPARTMENT_NAME")); classPostService.save(classPost); } } else { if (isClassStart) { map.put("result", "error"); //返回结果 map.put("msg", "开班后不能添加重复人员!"); return map; } List posts = classPostService.findInClass(pd); if (posts == null || posts.size() <= 0) { PageData classPost = new PageData(); classPost.put("CLASSPOST_ID", this.get32UUID()); initPageDataUtil.initSave(classPost); classPost.put("CORPINFO_ID", pd.getString("CORPINFO_ID")); classPost.put("CLASS_ID", pd.getString("CLASS_ID")); classPost.put("POST_ID", pd.getString("POST_ID")); classPost.put("POST_NAME", pd.getString("POST_NAME")); classPost.put("DEPARTMENT_ID", pd.getString("DEPARTMENT_ID")); classPost.put("DEPARTMENT_NAME", pd.getString("DEPARTMENT_NAME")); classPostService.save(classPost); // 2、检查旧工种是否有人关联,没人关联则删除 List _post = classPostService.findInClass(_student.get(0)); if (_post != null && _post.size() <= 1) { classPostService.deleteByClassPost(_post.get(0)); } studentService.delete(_student.get(0)); studentService.save(pd); } } } } PageData editClass = new PageData(); editClass.put("CLASS_ID", pd.getString("CLASS_ID")); editClass.put("RELEASE_TYPE", pd.getString("RELEASE_TYPE")); editClass.put("PERSONNEL_TYPES", pd.getString("PERSONNEL_TYPES")); editClass.put("EXAMINATION", pd.getString("EXAMINATION")); classService.edit(editClass); map.put("result", errInfo); return map; } /** * 删除 * * @param * @throws Exception */ @RequestMapping(value = "/deleteStudent") // @RequiresPermissions("student:del") @ResponseBody public Object deleteStudent() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd = studentService.findById(pd); initPageDataUtil.initEdit(pd); // 删除学员信息 studentService.delete(pd); // 查看班级内 是否还有与该学员相同工种的学员,如果没有。则删除班级内工种及相关关系 int samePostCount = studentService.CountByClassPost(pd); if (samePostCount <= 0) { // 此工种没有学员时,删除工种,及工种关联数据 PageData cp = classPostService.findByPostDept(pd); pd.put("CLASSPOST_ID", cp.get("CLASSPOST_ID")); classPostService.delete(pd); } // 删除学习记录 stageStudentRelationService.deleteByStu(pd); map.put("result", errInfo); //返回结果 return map; } /** * 去修改页面获取数据 * * @param * @throws Exception */ @RequestMapping(value = "/goEdit") // @RequiresPermissions("student:edit") @ResponseBody public Object goEdit() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd = studentService.findById(pd); //根据ID读取 map.put("pd", pd); map.put("result", errInfo); return map; } /** * 下载模版 * * @param response * @throws Exception */ @RequestMapping(value = "/downExcel") public void downExcel(HttpServletResponse response) throws Exception { FileDownload.fileDownload(response, PathUtil.getProjectpath() + Const.FILEPATHFILE + "studentExcelTemplate.xls", "学员导入模板.xls"); } /** * 下载模版(职业健康专用) * * @param response * @throws Exception */ @RequestMapping(value = "/downExcelForHealth") public void downExcelForHealth(HttpServletResponse response) throws Exception { FileDownload.fileDownload(response, PathUtil.getProjectpath() + Const.FILEPATHFILE + "studentExcelForHealthTemplate.xls", "学员导入模板.xls"); } public void saveStageStudent(PageData pd) throws Exception { PageData paper = postPaperService.findByClassPost(pd); // 保存班级-学员关系 PageData stageStudent = new PageData(); stageStudent.put("STAGESTUDENTRELATION_ID", this.get32UUID()); initPageDataUtil.initSave(stageStudent); stageStudent.put("USER_ID", pd.get("USER_ID")); PageData c = classService.findById(pd); if ("1".equals(c.get("EXAMINATION").toString())) { stageStudent.put("STAGEEXAMSTATE", "1"); } else { stageStudent.put("STAGEEXAMSTATE", "0"); } stageStudent.put("STAGEEXAMSCORE", "-1"); stageStudent.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); stageStudent.put("COMPLETE_COURSEWARE", "0"); stageStudent.put("COMPLETE_CLASSHOUR", "0"); stageStudent.put("STUDYSTATE", "0"); stageStudent.put("CLASS_ID", pd.get("CLASS_ID")); stageStudent.put("STUDENT_ID", pd.get("STUDENT_ID")); if (paper != null && paper.get("STAGEEXAMPAPERINPUT_ID") != null && Tools.notEmpty(paper.getString("STAGEEXAMPAPERINPUT_ID"))) { stageStudent.put("STAGEEXAMPAPER_ID", paper.get("STAGEEXAMPAPERINPUT_ID")); stageStudent.put("PAPER_ID", paper.get("STAGEEXAMPAPERINPUT_ID")); } stageStudentRelationService.save(stageStudent); } /** * 列表 * * @param page * @throws Exception */ @RequestMapping(value = "/classStudentList") @ResponseBody public Object classStudentList(Page page) throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 if (Tools.notEmpty(KEYWORDS)) pd.put("KEYWORDS", KEYWORDS.trim()); pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); List varList = studentService.list(pd); //列出PostPaper列表 PageData classInfo = classService.findById(pd); map.put("varList", varList); map.put("classInfo", classInfo); map.put("result", errInfo); return map; } /** * 列表 * * @param page * @throws Exception */ @RequestMapping(value = "/classForHealthStudentList") @ResponseBody public Object classForHealthStudentList(Page page) throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 if (Tools.notEmpty(KEYWORDS)) pd.put("KEYWORDS", KEYWORDS.trim()); page.setPd(pd); List varList = studentService.healthlist(page); //列出PostPaper列表 map.put("varList", varList); map.put("page", page); map.put("result", errInfo); return map; } /** * 列表 * * @param * @throws Exception */ @RequestMapping(value = "/exportStudentInfo") @ResponseBody public void exportStudent(HttpServletResponse response) throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 if (Tools.notEmpty(KEYWORDS)) pd.put("KEYWORDS", KEYWORDS.trim()); pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); List varList = studentService.listAllByExoprt(pd); //列出PostPaper列表 Map objMap = new LinkedHashMap<>(); List> list = new ArrayList<>(); if (varList.size() > 0) { int num = 1; for (PageData student : varList) { objMap = new LinkedHashMap<>(); objMap.put("NUMBER", num); objMap.put("USER_ID_CARD",student.getString("USER_ID_CARD")); objMap.put("NAME",student.getString("NAME")); objMap.put("SEX", "1".equals(student.getString("SEX")) ? "男" : "女"); objMap.put("PHONE",student.getString("PHONE")); objMap.put("DEPARTMENT_NAME",student.getString("DEPARTMENT_NAME")); objMap.put("POST_NAME",student.getString("POST_NAME")); objMap.put("ALL_CLASSHOUR",student.getString("ALL_CLASSHOUR")); objMap.put("COMPLETE_CLASSHOUR",student.getString("COMPLETE_CLASSHOUR")); objMap.put("PASSED","0".equals(student.getString("STAGEEXAMSTATE")) ? "不考试" : student.getString("PASSED")); objMap.put("EXAMSCORE",student.getString("EXAMSCORE")); switch (student.getString("STUDYSTATE")) { case "1": objMap.put("STUDYSTATE","学习中"); break; case "2": objMap.put("STUDYSTATE","已学完"); break; case "3": objMap.put("STUDYSTATE","已完成"); break; case "4": objMap.put("STUDYSTATE","未完成"); break; case "5": objMap.put("STUDYSTATE","待评估"); break; case "6": objMap.put("STUDYSTATE","评估未合格"); break; case "0": objMap.put("STUDYSTATE","未学习"); break; } objMap.put("CLASS_NAME",student.getString("CLASS_NAME")); if (Tools.notEmpty(student.getString("SIGNATURE_PATH"))) { objMap.put("IMAGE1", student.getString("SIGNATURE_PATH")); }else { objMap.put("IMAGE1", null); } if (Tools.notEmpty(student.getString("PORTRAIT"))) { objMap.put("IMAGE2", student.getString("PORTRAIT")); }else { objMap.put("IMAGE2", null); } list.add(objMap); num++; } } Object[] objects = objMap.keySet().toArray(); String[] titles = new String[objects.length]; Map titleName = new LinkedHashMap<>(); titleName.put("NUMBER", "序号"); titleName.put("USER_ID_CARD", "身份证号"); titleName.put("NAME", "姓名"); titleName.put("SEX", "性别"); titleName.put("PHONE", "手机号"); titleName.put("DEPARTMENT_NAME", "部门"); titleName.put("POST_NAME", "工种"); titleName.put("ALL_CLASSHOUR", "要求总学时"); titleName.put("COMPLETE_CLASSHOUR", "已完成学时"); titleName.put("PASSED", "是否考试通过"); titleName.put("EXAMSCORE", "考试分数"); titleName.put("STUDYSTATE", "学习状态"); titleName.put("CLASS_NAME", "班级名称"); titleName.put("IMAGE1", "用户签字"); titleName.put("IMAGE2", "人像照片"); for (int i = 0; i < titles.length; i++) { String key = objects[i].toString(); titles[i] = titleName.get(key); } String fileName = "学员学习记录"; response.setContentType("application/vnd.ms-excel"); response.addHeader("Content-Disposition", "attachment; filename=" + fileName); ImageExcelUtil.excelOut(titles, list.size(), list, fileName, response, PathUtil.getProjectpath()); } @RequestMapping("/list") @ResponseBody public Response list(Page page) throws Exception { Response response = Response.getResponse(); try { PageData request = this.getPageData(); request.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); if ("0".equals(Jurisdiction.getIS_MAIN())) { request.put("USER_ID", Jurisdiction.getUSER_ID()); } page.setPd(request); List list = usersService.simplelistPage(page); response.put("list", list); response.put("page", page); return response.OK(); } catch (Exception e) { e.printStackTrace(); return response.error(e.getMessage()); } } @RequestMapping("/getInfo") @ResponseBody public Response getInfo() throws Exception { Response response = Response.getResponse(); try { PageData request = this.getPageData(); PageData info = usersService.getInfo(request); response.put("info", info); return response.OK(); } catch (Exception e) { e.printStackTrace(); return response.errorMessage(e.getMessage()); } } @RequestMapping("/setState") @ResponseBody public Response setState() throws Exception { Response response = Response.getResponse(); try { PageData request = this.getPageData(); usersService.setState(request); return response.OK(); } catch (Exception e) { e.printStackTrace(); return response.errorMessage(e.getMessage()); } } @RequestMapping("getLogs") @ResponseBody public Response getLogs(Page page) throws Exception { Response response = Response.getResponse(); try { PageData request = this.getPageData(); page.setPd(request); List list = studentService.getUserStudyList(page); response.put("list", list); response.put("page", page); return response.OK(); } catch (Exception e) { e.printStackTrace(); return response.errorMessage(e.getMessage()); } } /** * 获取效果评估表 * * @return */ @RequestMapping(value = "/getEvaluation") @ResponseBody public Object getEvaluation() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); PageData pageData = studentService.getEvaluation(pd); map.put("pageData", pageData); map.put("result", errInfo); return map; } @RequestMapping("/hs") public void hs(HttpServletResponse response) throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String now = DateUtil.getSdfTimesSSS(); // 表头 PageData pageData = studentService.getEvaluation(pd); File file = new File(PathUtil.getProjectpath() + Const.FILEPATHWORDTEMPLATE + "student-estimate.docx"); InputStream mbwj = new FileInputStream(file); //注册xdocreport实例并加载FreeMarker模板引擎 IXDocReport report = XDocReportRegistry.getRegistry().loadReport(mbwj, TemplateEngineKind.Freemarker); //创建xdocreport上下文对象 IContext context = report.createContext(); SimpleDateFormat formatdate = new SimpleDateFormat("yyyy年MM月dd日"); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); context.put("value1", Tools.notEmpty(pageData.getString("NAME")) ? pageData.getString("NAME") : ""); context.put("value2", Tools.notEmpty(pageData.getString("USER_ID_CARD")) ? pageData.getString("USER_ID_CARD") : ""); context.put("value3", Tools.notEmpty(pageData.getString("OPERATTIME")) ? formatdate.format(formatter.parse(pageData.getString("OPERATTIME"))) : ""); context.put("value4", Tools.notEmpty(pageData.getString("SEX")) ? pageData.getString("SEX") : ""); context.put("value5", Tools.notEmpty(pageData.getString("DEGREE_OF_EDUCATION")) ? pageData.getString("DEGREE_OF_EDUCATION") : ""); context.put("value6", Tools.notEmpty(pageData.getString("MAJOR")) ? pageData.getString("MAJOR") : ""); context.put("value7", Tools.notEmpty(pageData.getString("DUTIES")) ? pageData.getString("DUTIES") : ""); context.put("value8", Tools.notEmpty(pageData.getString("DEPARTMENT_NAME")) ? pageData.getString("DEPARTMENT_NAME") : ""); context.put("value9", Tools.notEmpty(pageData.getString("POST_NAME")) ? pageData.getString("POST_NAME") : ""); context.put("value10", Tools.notEmpty(pageData.getString("INDUSTRY_ALL_NAME")) ? pageData.getString("INDUSTRY_ALL_NAME") : ""); context.put("value11", Tools.notEmpty(pageData.getString("PHONE")) ? pageData.getString("PHONE") : ""); context.put("value12", Tools.notEmpty(pageData.getString("START_TIME")) ? formatdate.format(formatter.parse(pageData.getString("START_TIME"))) : ""); context.put("value13", Tools.notEmpty(pageData.getString("END_TIME")) ? formatdate.format(formatter.parse(pageData.getString("END_TIME"))) : ""); context.put("value14", Tools.notEmpty(pageData.getString("CLASS_NAME")) ? pageData.getString("CLASS_NAME") : ""); context.put("value15", Tools.notEmpty(pageData.getString("coursewareName")) ? pageData.getString("coursewareName") : ""); context.put("value16", Tools.notEmpty(pageData.getString("STAGEEXAMSCORE")) ? pageData.getString("STAGEEXAMSCORE") : ""); context.put("value17", Tools.notEmpty(pageData.getString("correct")) ? pageData.getString("correct") : ""); context.put("value18", Tools.notEmpty(pageData.getString("error")) ? pageData.getString("error") : ""); context.put("value19", Tools.notEmpty(pageData.getString("errorVideoName")) ? pageData.getString("errorVideoName") : ""); context.put("value20", Tools.notEmpty(pageData.getString("STRENGTHEN_EXAMNAME")) ? pageData.getString("STRENGTHEN_EXAMNAME") : ""); context.put("value21", Tools.notEmpty(pageData.getString("STRENGTHEN_EXAMSCORE")) ? pageData.getString("STRENGTHEN_EXAMSCORE") : ""); context.put("value22", Tools.notEmpty(pageData.getString("STRENGTHEN_OPERATTIME")) ? formatdate.format(formatter.parse(pageData.getString("STRENGTHEN_OPERATTIME"))) : ""); context.put("value23", Tools.notEmpty(pageData.getString("STRENGTHENEXAMSCORE")) ? pageData.getString("STRENGTHENEXAMSCORE") : ""); context.put("value24", Tools.notEmpty(pageData.getString("PERSONNEL_TYPE")) ? pageData.getString("PERSONNEL_TYPE") : ""); List strengthenexamrecord = (List) pageData.get("strengthenexamrecord"); List list1 = new ArrayList<>(); for (int i = 0; i < strengthenexamrecord.size(); i++) { TrainingPlanDao trainingPlanDao = new TrainingPlanDao(); String questiontype = strengthenexamrecord.get(i).getString("QUESTIONTYPE"); if (("1").equals(questiontype)) { trainingPlanDao.setValue1("(单选题)"); trainingPlanDao.setValue5(Tools.notEmpty(strengthenexamrecord.get(i).getString("OPTIONA")) ? "A." + strengthenexamrecord.get(i).getString("OPTIONA") : ""); trainingPlanDao.setValue6(Tools.notEmpty(strengthenexamrecord.get(i).getString("OPTIONB")) ? "B." + strengthenexamrecord.get(i).getString("OPTIONB") : ""); trainingPlanDao.setValue7(Tools.notEmpty(strengthenexamrecord.get(i).getString("OPTIONC")) ? "C." + strengthenexamrecord.get(i).getString("OPTIONC") : ""); trainingPlanDao.setValue8(Tools.notEmpty(strengthenexamrecord.get(i).getString("OPTIOND")) ? "D." + strengthenexamrecord.get(i).getString("OPTIOND") : ""); } else if (("2").equals(questiontype)) { trainingPlanDao.setValue1("(多选题)"); trainingPlanDao.setValue5(Tools.notEmpty(strengthenexamrecord.get(i).getString("OPTIONA")) ? "A." + strengthenexamrecord.get(i).getString("OPTIONA") : ""); trainingPlanDao.setValue6(Tools.notEmpty(strengthenexamrecord.get(i).getString("OPTIONB")) ? "B." + strengthenexamrecord.get(i).getString("OPTIONB") : ""); trainingPlanDao.setValue7(Tools.notEmpty(strengthenexamrecord.get(i).getString("OPTIONC")) ? "C." + strengthenexamrecord.get(i).getString("OPTIONC") : ""); trainingPlanDao.setValue8(Tools.notEmpty(strengthenexamrecord.get(i).getString("OPTIOND")) ? "D." + strengthenexamrecord.get(i).getString("OPTIOND") : ""); } else if (("3").equals(questiontype)) { trainingPlanDao.setValue1("(判断题)"); trainingPlanDao.setValue5(Tools.notEmpty(strengthenexamrecord.get(i).getString("OPTIONA")) ? "A." + strengthenexamrecord.get(i).getString("OPTIONA") : ""); trainingPlanDao.setValue6(Tools.notEmpty(strengthenexamrecord.get(i).getString("OPTIONB")) ? "B." + strengthenexamrecord.get(i).getString("OPTIONB") : ""); trainingPlanDao.setValue7(""); trainingPlanDao.setValue8(""); } else if (("4").equals(questiontype)) { trainingPlanDao.setValue1("(填空题)"); trainingPlanDao.setValue5(""); trainingPlanDao.setValue6(""); trainingPlanDao.setValue7(""); trainingPlanDao.setValue8(""); } else { trainingPlanDao.setValue1(""); trainingPlanDao.setValue5(""); trainingPlanDao.setValue6(""); trainingPlanDao.setValue7(""); trainingPlanDao.setValue8(""); } trainingPlanDao.setValue2(String.valueOf(i + 1)); trainingPlanDao.setValue3(Tools.notEmpty(strengthenexamrecord.get(i).getString("QUESTIONDRY")) ? strengthenexamrecord.get(i).getString("QUESTIONDRY") : ""); trainingPlanDao.setValue4(Tools.notEmpty(strengthenexamrecord.get(i).getString("SCORE")) ? strengthenexamrecord.get(i).getString("SCORE") : ""); trainingPlanDao.setValue9(Tools.notEmpty(strengthenexamrecord.get(i).getString("ANSWER")) ? strengthenexamrecord.get(i).getString("ANSWER") : ""); trainingPlanDao.setValue10(Tools.notEmpty(strengthenexamrecord.get(i).getString("ANSWERRIGHT")) ? strengthenexamrecord.get(i).getString("ANSWERRIGHT") : ""); trainingPlanDao.setValue11(Tools.notEmpty(strengthenexamrecord.get(i).getString("DESCR")) ? strengthenexamrecord.get(i).getString("DESCR") : ""); list1.add(trainingPlanDao); } context.put("list1", list1); FieldsMetadata fm = report.createFieldsMetadata(); fm.load("list1", TrainingPlanDao.class, true); // word模板中图片标签对应关系 pic---word模板中图片标签 item-- word模板中图片列表的遍历项,即模板中«@before-row[#list list2 as item]» 的item item.pic中的pic 为 后台实体类的图片字段名 fm.addFieldAsImage("pic", "item.pic", NullImageBehaviour.RemoveImageTemplate); //Word模板中的表格数据对应的集合类型 FileOutputStream out = new FileOutputStream(new File(PathUtil.getProjectpath() + Const.FILEPATHFILE + "安全生产教育培训动态评估报告-" + now + ".docx")); report.process(context, out); WordToPdfUtil.docToPdf(PathUtil.getProjectpath() + Const.FILEPATHFILE + "安全生产教育培训动态评估报告-" + now + ".docx", PathUtil.getProjectpath() + Const.FILEPATHFILE + "安全生产教育培训动态评估报告-" + now + ".pdf"); FileDownload.fileDownload(response, PathUtil.getProjectpath() + Const.FILEPATHFILE + "安全生产教育培训动态评估报告-" + now + ".pdf", "安全生产教育培训动态评估报告.pdf"); //删除本地word pdf File word = new File(PathUtil.getProjectpath() + Const.FILEPATHFILE + "安全生产教育培训动态评估报告-" + now + ".docx"); word.delete(); File pdf = new File(PathUtil.getProjectpath() + Const.FILEPATHFILE + "安全生产教育培训动态评估报告-" + now + ".pdf"); pdf.delete(); } /** * 学员统计列表 * * @param page * @throws Exception */ @RequestMapping(value = "/studentList") @ResponseBody public Object studentList(Page page) throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 if (Tools.notEmpty(KEYWORDS)) pd.put("KEYWORDS", KEYWORDS.trim()); if (org.apache.commons.lang3.StringUtils.isNotBlank(pd.getString("STARTTIME"))) { pd.put("STARTTIME", pd.getString("STARTTIME") + " 00:00:00"); } if (org.apache.commons.lang3.StringUtils.isNotBlank(pd.getString("ENDTIME"))) { pd.put("ENDTIME", pd.getString("ENDTIME") + " 23:59:59"); } if (org.apache.commons.lang3.StringUtils.isNotBlank(pd.getString("OVERSTARTTIME"))) { pd.put("OVERSTARTTIME", pd.getString("OVERSTARTTIME") + " 00:00:00"); } if (org.apache.commons.lang3.StringUtils.isNotBlank(pd.getString("OVERENDTIME"))) { pd.put("OVERENDTIME", pd.getString("OVERENDTIME") + " 23:59:59"); } if (org.apache.commons.lang3.StringUtils.isNotBlank(pd.getString("CREATESTARTTIME"))) { pd.put("CREATESTARTTIME", pd.getString("CREATESTARTTIME") + " 00:00:00"); } if (org.apache.commons.lang3.StringUtils.isNotBlank(pd.getString("CREATENDTIME"))) { pd.put("CREATENDTIME", pd.getString("CREATENDTIME") + " 23:59:59"); } pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); page.setPd(pd); List varList = studentService.studentlistPage(page); map.put("varList", varList); map.put("page", page); map.put("result", errInfo); return map; } /** * 学员统计列表导出 * * @param * @throws Exception */ @RequestMapping(value = "/derivedRecord") @ResponseBody public Object derivedRecord() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 if (Tools.notEmpty(KEYWORDS)) pd.put("KEYWORDS", KEYWORDS.trim()); if (org.apache.commons.lang3.StringUtils.isNotBlank(pd.getString("STARTTIME"))) { pd.put("STARTTIME", pd.getString("STARTTIME") + " 00:00:00"); } if (org.apache.commons.lang3.StringUtils.isNotBlank(pd.getString("ENDTIME"))) { pd.put("ENDTIME", pd.getString("ENDTIME") + " 23:59:59"); } if (org.apache.commons.lang3.StringUtils.isNotBlank(pd.getString("OVERSTARTTIME"))) { pd.put("OVERSTARTTIME", pd.getString("OVERSTARTTIME") + " 00:00:00"); } if (org.apache.commons.lang3.StringUtils.isNotBlank(pd.getString("OVERENDTIME"))) { pd.put("OVERENDTIME", pd.getString("OVERENDTIME") + " 23:59:59"); } if (org.apache.commons.lang3.StringUtils.isNotBlank(pd.getString("CREATESTARTTIME"))) { pd.put("CREATESTARTTIME", pd.getString("CREATESTARTTIME") + " 00:00:00"); } if (org.apache.commons.lang3.StringUtils.isNotBlank(pd.getString("CREATENDTIME"))) { pd.put("CREATENDTIME", pd.getString("CREATENDTIME") + " 23:59:59"); } pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); List varList = studentService.derivedRecord(pd); map.put("varList", varList); map.put("result", errInfo); return map; } }