From 5e873863bc7324894c89b0a0fc77a6202c91cd64 Mon Sep 17 00:00:00 2001 From: wzp <516075396@qq.com> Date: 星期二, 06 四月 2021 10:35:42 +0800 Subject: [PATCH] 20210406 --- src/main/java/com/ots/project/exam/controller/TExamReportController.java | 606 ++++++++++++++++++------------------------------------ 1 files changed, 206 insertions(+), 400 deletions(-) diff --git a/src/main/java/com/ots/project/exam/controller/TExamReportController.java b/src/main/java/com/ots/project/exam/controller/TExamReportController.java index 320f3df..ce1df23 100644 --- a/src/main/java/com/ots/project/exam/controller/TExamReportController.java +++ b/src/main/java/com/ots/project/exam/controller/TExamReportController.java @@ -1,5 +1,4 @@ package com.ots.project.exam.controller; - import cn.hutool.core.collection.CollUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.ArrayUtil; @@ -64,6 +63,7 @@ import org.apache.commons.collections.map.HashedMap; import org.apache.poi.ss.usermodel.BorderStyle; import org.apache.poi.ss.usermodel.IndexedColors; +import org.apache.poi.xssf.streaming.SXSSFSheet; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; @@ -77,7 +77,6 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; - import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; @@ -94,15 +93,8 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; - import static com.ots.project.tool.report.reportCalculation.request.CalculationTypeEnum.JAQ; -/** - * 璇勬祴鎶ュ憡Controller - * - * @author ots - * @date 2019-12-26 - */ @Controller @RequestMapping("/exam/report") public class TExamReportController extends BaseController { @@ -122,63 +114,46 @@ private IExamUtilService iExamUtilService; @Autowired private IEntTestPackageService entTestPackageService; - @Autowired private ITExamPaperService itExamPaperService; - @Autowired private IEntDemographyInfoService entDemographyInfoService; - @Autowired ReportCalculationServices calculationServices; - @Autowired MemberService memberService; - @Autowired ITQuestionService itQuestionService; - @Autowired private TExamPaperServiceImpl examPaperService; - @Autowired private ISysUserExtendService sysUserExtendService; - /** - * 浼佷笟鎶ュ憡鎺堟潈锛屽鎵规姤琛� - * - * @return - */ + @RequiresPermissions("exam:report:viewVerify") @GetMapping("/viewVerify") public String reportVerify() { return prefix + "/verifyReport"; } - - /** - * 鏌ヨ璇勬祴鎶ュ憡鍒楄〃 - */ + @RequiresPermissions("exam:report:viewVerify") @PostMapping("/verifyList") @ResponseBody public TableDataInfo verifyList(TExamReport tExamReport) { startPage(); - tExamReport.setStatus("1");//娴嬭瘯鍖呯姸鎬� + tExamReport.setStatus("1"); List<TExamReport> list = tExamReportService.selectTExamReportList(tExamReport); - // 澶氳瑷� + String langType = dictService.getLangType(LocaleContextHolder.getLocale().toString()); for (TExamReport tExamReportTemp : list) { tExamReportTemp.setProductName(ExamUtil.getLangString(langType, tExamReportTemp.getProductName())); } return getDataTable(list); } - - @RequiresPermissions("exam:report:view") @GetMapping() public String report() { return prefix + "/report"; } - @RequiresPermissions("exam:test_package:testreport") @GetMapping("/reportView/{testId}/{prodId}") public String reportView(@PathVariable String testId, @PathVariable String prodId, ModelMap mmap) { @@ -186,7 +161,6 @@ mmap.put("testId", testId); return prefix + "/report"; } - @RequiresPermissions("exam:test_package:testreport") @GetMapping("/member/reportView/{testId}/{memberId}") public String memberReportView(@PathVariable Long testId, @PathVariable String memberId, ModelMap mmap) { @@ -196,10 +170,7 @@ mmap.put("memberId", memberId); return prefix + "/report"; } - - /** - * 鏌ヨ璇勬祴鎶ュ憡鍒楄〃(澶撮儴) - */ + @RequiresPermissions("exam:hrEmailReport:view") @PostMapping("/hrLog") @ResponseBody @@ -208,10 +179,7 @@ List<TExamReport> tExamReports = tExamReportService.selectTExamReportList(tExamReport); return getDataTable(tExamReports); } - - /** - * 鏌ヨ璇勬祴鎶ュ憡鍒楄〃(澶撮儴) - */ + @RequiresPermissions("exam:report:list") @PostMapping("/list") @ResponseBody @@ -221,15 +189,12 @@ if (Objects.isNull(tExamReport.getProductId())) { return getDataTable(list); } - - // 澶氳瑷�鍙栨湰鍦伴偅绉� + String langType = dictService.getLangType(LocaleContextHolder.getLocale().toString()); list = tExamReportService.selectTExamReportList(tExamReport); - if (Objects.isNull(list) || list.isEmpty()) { return getDataTable(list); } - Map<String, String> filed = JSON.parseObject(list.get(0).getContent(), LinkedHashMap.class); Map<String, String> title = new LinkedHashMap<>(); int i = 0; @@ -248,18 +213,11 @@ } title.put("娴嬭瘯鍖呯紪鐮�", String.valueOf(i++)); title.put("绛斿嵎缂栫爜", String.valueOf(i++)); - List<Map<String, String>> filedList = new ArrayList<>(); filedList.add(title); return getDataTable(filedList); } - - /** - * 鏌ヨ璇勬祴鎶ュ憡鍒楄〃(鏁版嵁鍒�) - * - * @param tExamReport - * @return - */ + @RequiresPermissions("exam:report:list") @PostMapping("/listData") @ResponseBody @@ -269,20 +227,16 @@ return getDataTable(list); } startPage(); - // 瀹屾垚鐨� + tExamReport.setFinish(1); list = tExamReportService.selectViewReportList(tExamReport); - // 澶氳瑷�缈昏瘧 + for (TExamReport tExamReportTemp : list) { tExamReportTemp.setProductName(examUtilService.getLangOrLocalLangString("", tExamReportTemp.getProductName())); } - return getDataTable(list); } - - /** - * 瀵煎嚭璇勬祴鎶ュ憡鍒楄〃 - */ + @RequiresPermissions("exam:report:export") @PostMapping("/export") @ResponseBody @@ -291,172 +245,148 @@ ExcelUtil<TExamReport> util = new ExcelUtil<TExamReport>(TExamReport.class); return util.exportExcel(list, "report"); } + - /** - * 瀵煎嚭璇勬祴浜哄憳鐢ㄦ埛绛旈璁板綍 - * - * @param tExamReport - * @return - */ -// @RequiresPermissions("exam:report:export") -// @PostMapping("/exportReport") -// @ResponseBody -// public AjaxResult exportReport(TExamReport tExamReport) { -// DataMap<Integer, Object[]> dataMap = new DataMap<>(); -// List<TExamReport> list = tExamReportService.selectTExamReportList(tExamReport); -// -// // 鎷兼帴鐢熸垚report鐨勯敭鍊煎 -// User sysUser = ShiroUtils.getSysUser(); -// boolean isRight = Objects.equals(UserTypeEnum.SYS_USER.getUserType(), sysUser.getUserType()); -// -// int keyPosition = -1; -// int keySize = 0; -// List<DataMap> reportList = new ArrayList<>(); -// List<DataMap> reportTaiList = new ArrayList<>(); -// List<DataMap> reportLocalList = new ArrayList<>(); -// Map<String, String> mapPara = new HashedMap(); -// Set<String> langTypeSet = new HashSet<>(); -// for (TExamReport it : list) { -// List<DataReport> dataReportList = new ArrayList<>(); -// -// // 璇诲嚭浜哄彛瀛﹀彉閲� -// setLocalDataReportByParamId(mapPara, it, dataReportList); -// -// // 寰楀埌浜哄彛瀛︽湁澶氬皯绉嶈瑷� -// setDataReportLangSet(mapPara, langTypeSet); -// -// // 鍙栨渶澶氬�奸偅涓� -// if (dataReportList.size() > keySize) { -// keySize = dataReportList.size(); -// keyPosition++; -// } -// -// DataMap<String, String> dataReportMap = new DataMap<>(); -// -// // 闈炴嘲鍥藉洟闃熺殑鍐呭 -// setContentMap(it, dataReportList, dataReportMap, reportLocalList); -// -// // 娉板浗鍥㈤槦鐨勫唴瀹� -// setTaiInterfaceContentMap(it, dataReportMap, isRight, reportTaiList); -// -// reportList.add(dataReportMap); -// } -// -// // 鍙杒ey鏈�澶氱殑锛岄槻姝㈡墦涔� -// Object[] keys = reportTaiList.get(keyPosition).getKeys().toArray(); -// -// Object[] keysAll = reportList.get(keyPosition).getKeys().toArray(); -// -// List<Object[]> keyDemography = new ArrayList<>(); -// -// // 3琛岋紝3绉嶈瑷� -// setAllLangLocalDataValue(keyPosition, reportLocalList, mapPara, langTypeSet, keyDemography); -// -// int position = 0; -// for (;position < keyDemography.size(); position++) { -// // 琛ㄥご鍙﹀鐨勪笢瑗匡紝绛旈涓嶄竴鑷寸瓑绛夛紝濡備腑鏂囪嚜澶竉T1 -// setExtracHead(dataMap, keys, keyDemography, position); -// } -// -// for (int i = 0; i < reportList.size(); i++) { -// DataMap<String,String> valueDataMap = reportList.get(i); -// List<String> valueList = new ArrayList<>(); -// for (Object key : keysAll) { -// valueList.add(valueDataMap.get(key.toString())); -// } -// dataMap.put(i + position, valueList.toArray()); -// } -// -// ExcelUtil<DataMap> util = new ExcelUtil<DataMap>(DataMap.class); -// // 瀵煎嚭鏁版嵁鎶ュ憡鍙�変竴涓祴璇曞寘 -// return util.exportExcelByDataMap(dataMap, examUtilService.getLangOrLocalLangString("", list.get(0).getProductName()) + "_DateReport"); -// } - // 瀵煎嚭鏁版嵁鎶ュ憡 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @RequiresPermissions("exam:report:export") @PostMapping("/exportDataReport/{ids}") @ResponseBody public AjaxResult exportReport(TExamReport tExamReport, @PathVariable("ids") String[] ids) throws IOException { List<TExamReport> tExamReportList = tExamReportService.selectTExamReportByIds(ids); - - // 鎷兼帴鐢熸垚report鐨勯敭鍊煎 + User sysUser = ShiroUtils.getSysUser(); boolean isRight = Objects.equals(UserTypeEnum.SYS_USER.getUserType(), sysUser.getUserType()); - // 浜哄彛瀛﹀彉閲� - // 涓夎 + + DataReportHead dataReportHead = new DataReportHead(); String fileNameResult = EssConfig.getDownloadPath() + examUtilService.getLangOrLocalLangString("", tExamReportList.get(0).getProductName()) + "_DateReport.xlsx"; - - // 鎶妔heet鏀惧湪map閲岄潰 + Map<String, List<List<Object>>> reportResultMap = new HashMap<>(); - Map<String, Map<String, String>> demograpyMap = new HashMap<>(); - - // 浜哄彛瀛� + setDemograyMap(tExamReportList, dataReportHead, demograpyMap); - - // 鎶ュ憡绫诲瀷 + String reportType = getReportType(tExamReport); - - // 妯$増鐨勫唴瀹� + setDataReportHeader(dataReportHead, reportResultMap, reportType, isRight); - - // Map<sheet鍚�, Map<濮撳悕, Map<key, value>>> 鏁版嵁 + Map<String, Map<String, Map<String, String>>> sheetExcelMap = new HashMap<>(); - - // 濡傛灉鏄疛AQ瑕佽皟鐢ㄦ嘲鍥藉洟闃熺殑鎺ュ彛锛屽鏋滀笉鏄紝鍘昏〃閲岄潰鎵� + setDealTaiData(ids, tExamReportList, reportType, sheetExcelMap); - - // 鏋勯�犲�� + setRportListValue(reportResultMap, demograpyMap, sheetExcelMap, reportType); - - // 寮勬垚鍜屼粬浠師鏉ヤ竴鏍� + setSysHeadToEnglish(tExamReportList, reportResultMap, reportType); - - // 鍐欐枃浠� - writeFile(fileNameResult, reportResultMap); - - // 杩斿洖涓嬭浇 + + + writeMutiFile(fileNameResult, reportResultMap); + return AjaxResult.success(examUtilService.getLangOrLocalLangString("", tExamReportList.get(0).getProductName()) + "_DateReport.xlsx"); } - private void setDealTaiData(@PathVariable("ids") String[] ids, List<TExamReport> tExamReportList, String reportType, Map<String, Map<String, Map<String, String>>> sheetExcelMap) throws IOException { if (Objects.equals(reportType, ReportTypeEnum.JAQ.getCode())) { - // 瑕佸垹闄ょ殑鏂囦欢 + List<TExamReport> tExamReports = tExamReportService.selectTExamReportByIds(ids); Map<String, TExamReport> tokenReportMap = new HashMap<>(); for (TExamReport tExamReport : tExamReports) { tokenReportMap.put(tExamReport.getTokenId(), tExamReport); } - - // JAQ 璋冪敤娉板浗鍥㈤槦鏁版嵁 + ReportAPIResult reportAPIResult = getThaiJAQData(tExamReports); - - // 娉板浗鏁版嵁 - // JAQ Output Data + + Map<String, String> thaiData = reportAPIResult.getData(); Map<String, Map<String, String>> excelOutPutMap = new HashMap<>(); excelOutPutMap.put("JAQ", thaiData); sheetExcelMap.put("JAQ Output Data", excelOutPutMap); - - // JAQ Input Data + Map<String, Map<String, String>> excelInputMap = new HashMap<>(); List<JAQPersons> persons = (List<JAQPersons>) reportAPIResult.getAnswerData().get("persons"); for (JAQPersons jaqPersons : persons) { Map<String, String> personInfo = jaqPersons.getPersonInfo(); Map<String, String> personPoints = jaqPersons.getPersonPoints(); String name = personInfo.get("fullName"); - Map<String, String> excelValueMap = new HashMap<>(); excelValueMap.putAll(personInfo); excelValueMap.putAll(personPoints); excelValueMap.put("Name", name); excelInputMap.put(name, excelValueMap); tExamReportService.setExcelMapextraValue(tokenReportMap.get(excelValueMap.get("accessCode")), excelValueMap); - tExamReportService.setExcelMapextraValue(tokenReportMap.get(excelValueMap.get("accessCode")), thaiData); // 涓烘柟渚垮紑鍙戯紝涓嶇鎬ц兘 + tExamReportService.setExcelMapextraValue(tokenReportMap.get(excelValueMap.get("accessCode")), thaiData); } - - // 杈撳嚭sheet鐨勯澶栧�� + sheetExcelMap.put("JAQ Input Data", excelInputMap); } else { Map<String, Map<String, String>> excelMap = new HashMap<>(); @@ -464,21 +394,19 @@ sheetExcelMap.put("Sheet1", excelMap); } } - private void setSysHeadToEnglish(List<TExamReport> tExamReportList, Map<String, List<List<Object>>> reportResultMap, String reportType) { Set<String> heavyDischargeDemography = new HashSet<>(); Map<String, String> systemEnglisMap = new HashMap<>(); for (TExamReport tExamReportIt : tExamReportList) { - // 璇诲嚭浜哄彛瀛﹀彉閲�,闄嶇淮 + List<DemographyDataReportDto> demographyDataReportDtoList = setLocalDataReportByParamId(tExamReportIt); for (DemographyDataReportDto demographyDataReportDto : demographyDataReportDtoList) { - // 鎺掗噸鐢� + if (heavyDischargeDemography.contains(demographyDataReportDto.getParamId())) { continue; } else { heavyDischargeDemography.add(demographyDataReportDto.getParamId()); } - List<DemographyDto> demographyDtoList = JsonUtil.parseArray(demographyDataReportDto.getLangCode(), DemographyDto.class); for (DemographyDto demographyDto : demographyDtoList) { if (Objects.equals(demographyDto.getLangType(), "English")) { @@ -487,7 +415,6 @@ } } } - for (Map.Entry<String, List<List<Object>>> entryReport : reportResultMap.entrySet()) { List<Object> headSystem = entryReport.getValue().get(0); for (int i = 0; i < headSystem.size(); i++) { @@ -497,13 +424,11 @@ } } } - private void setRportListValue(Map<String, List<List<Object>>> reportResultMap, Map<String, Map<String, String>> demograpyMap, Map<String, Map<String, Map<String, String>>> sheetExcelMap, String reportType) { for (Map.Entry<String, Map<String, Map<String, String>>> sheetEntry : sheetExcelMap.entrySet()) { for (Map.Entry<String, Map<String, String>> entry : sheetEntry.getValue().entrySet()) { - // 鎺ュ彛 + ReportResultData resultData = getReportResultData(reportType, entry); - Map<String, Object> textMap = new HashMap<>(); textMap.putAll(resultData.getTextMap()); textMap.putAll(demograpyMap.get(textMap.get("reportId"))); @@ -511,20 +436,36 @@ } } } - private void writeFile(String fileNameResult, Map<String, List<List<Object>>> reportResultMap) { for (Map.Entry<String, List<List<Object>>> entryReport : reportResultMap.entrySet()) { - ExcelWriter writer = cn.hutool.poi.excel.ExcelUtil.getWriter(fileNameResult, entryReport.getKey()); + ExcelWriter writer = cn.hutool.poi.excel.ExcelUtil.getBigWriter(fileNameResult, entryReport.getKey()); StyleSet styleSet = writer.getStyleSet(); styleSet.setBorder(BorderStyle.NONE, IndexedColors.OLIVE_GREEN); writer.write(entryReport.getValue(), true); + SXSSFSheet sheet = (SXSSFSheet) writer.getSheet(); + sheet.trackAllColumnsForAutoSizing(); + writer.autoSizeColumnAll(); writer.close(); } - } - + private void writeMutiFile(String fileNameResult, Map<String, List<List<Object>>> reportResultMap) { + FileUtil.del(fileNameResult); + ExcelWriter writer = null; + for (Map.Entry<String, List<List<Object>>> entryReport : reportResultMap.entrySet()) { + if (Objects.isNull(writer)) { + writer = new ExcelWriter(fileNameResult,entryReport.getKey()); + } + writer.setSheet(entryReport.getKey()); + StyleSet styleSet = writer.getStyleSet(); + styleSet.setBorder(BorderStyle.NONE, IndexedColors.OLIVE_GREEN); + writer.write(entryReport.getValue(), true); + writer.autoSizeColumnAll(); + writer.setSheet(entryReport.getKey()); + } + writer.close(); + } private void setReportResultList(List<Object> demographyHeadSystem, List<List<Object>> reportResultList, Map<String, Object> textMap) { - // 寮�濮嬪彇鍊� + List<Object> reportValue = new ArrayList<>(); for (Object key : demographyHeadSystem) { Object value = textMap.get(key.toString().trim().replace("%", "")); @@ -534,17 +475,14 @@ reportValue.add(""); } } - reportResultList.add(reportValue); } - private ReportResultData getReportResultData(String reportType, Map.Entry<String, Map<String, String>> entry) { TExamReport tExamQueryReport = new TExamReport(); String langType = examUtilService.getLocalLangType(""); ReportResultData resultData = tExamReportService.getReportResultData(reportType, langType, entry, tExamQueryReport); return resultData; } - private Map<String, LangTypeEnum> getStringLangTypeEnumMap() { Map<String, LangTypeEnum> langTypeEnumMap = new HashMap<>(); for (LangTypeEnum langTypeEnumTemp : LangTypeEnum.values()) { @@ -552,30 +490,28 @@ } return langTypeEnumMap; } - private String getReportType(TExamReport tExamReport) { String reportType = ReportTypeEnum.RuiLin.getCode(); TExamPaper tExamPaper = itExamPaperService.selectTExamPaperById(tExamReport.getProductId()); + tExamPaper.getName(); + if (tExamPaper.getName().indexOf("鐫块偦")>0 || tExamPaper.getName().indexOf("RuiLin")>0 ) { + return reportType; + } List<TReportTemplate> tReportTemplateList = itReportTemplateService.selectTReportTemplates(tExamPaper.getReportTemplateId()); for (TReportTemplate tReportTemplate : tReportTemplateList) { if (Objects.isNull(tReportTemplate.getReportType())) { continue; } - - // 鍙栫涓�涓ā鐗堢殑閰嶇疆 + reportType = ReportTypeEnum.valueOf(tReportTemplate.getReportType()).getCode(); - - // 濡傛灉鏄疭AQ璧癝AQ鐨勬ā鐗� + if (Objects.equals(tReportTemplate.getTemplateType(), "SAQ")) { reportType = ReportTypeEnum.valueOf(tReportTemplate.getTemplateType()).getCode(); } - break; - } return reportType; } - private void setDataReportHeader(DataReportHead dataReportHead, Map<String, List<List<Object>>> reportResultMap, String reportType, boolean isRight) { if (Objects.equals(reportType, ReportTypeEnum.RuiLin.getCode())) { setDataReportHeaderRuilin(dataReportHead, reportResultMap, isRight); @@ -589,7 +525,6 @@ setDataReportHeadMaq(dataReportHead, reportResultMap, isRight); } } - private void setDataReportHeadMaq(DataReportHead dataReportHead, Map<String, List<List<Object>>> reportResultMap, boolean isRight) { ExcelReader reader = cn.hutool.poi.excel.ExcelUtil.getReader(FileUtil.file(EssConfig.getReportTemplates() + "MAQHead.xlsx")); List<String> sheetNames = reader.getSheetNames(); @@ -610,7 +545,6 @@ deleteNoRightKeys(dataReportHead, isRight, readList, i); } } - private void setDataReportHeadSaq(DataReportHead dataReportHead, Map<String, List<List<Object>>> reportResultMap, boolean isRight) { ExcelReader reader = cn.hutool.poi.excel.ExcelUtil.getReader(FileUtil.file(EssConfig.getReportTemplates() + "SAQHead.xlsx")); List<String> sheetNames = reader.getSheetNames(); @@ -631,20 +565,18 @@ deleteNoRightKeys(dataReportHead, isRight, readList, i); } } - private void setDataReportHeadJaq(DataReportHead dataReportHead, Map<String, List<List<Object>>> reportResultMap) { ExcelReader reader = cn.hutool.poi.excel.ExcelUtil.getReader(FileUtil.file(EssConfig.getReportTemplates() + "JAQHead.xlsx")); List<String> sheetNames = reader.getSheetNames(); - // JAQ涓嶈浜哄彛瀛︼紝鎵�浠ヨclear + List<Object> headSystem = dataReportHead.getHeadSystem(); List<Object> headEnglish = dataReportHead.getHeadEnglish(); for (String sheetName : sheetNames) { ExcelReader readerSheet = cn.hutool.poi.excel.ExcelUtil.getReader(FileUtil.file(EssConfig.getReportTemplates() + "JAQHead.xlsx"), sheetName); List<List<Object>> readList = readerSheet.read(); if (Objects.equals("JAQ Input Data", sheetName)) { - List<Object> head = readList.get(0); - // Name AccessCode Phone Department + 浜哄彛瀛� + String[] heads = {"Name", "AccessCode", "Phone", "Department"}; List<Object> headList = CollUtil.toList(heads); Set headExtends = new HashSet(headList); @@ -653,7 +585,6 @@ headList.add(headSystem.get(i)); } } - head.addAll(0, headList); } List<List<Object>> reportResultList = new ArrayList<>(); @@ -662,17 +593,14 @@ reportResultList.add(readList.get(i++)); } } - private void setDataReportHeadCaq(DataReportHead dataReportHead, Map<String, List<List<Object>>> reportResultMap, boolean isRight) { ExcelReader reader = cn.hutool.poi.excel.ExcelUtil.getReader(FileUtil.file(EssConfig.getReportTemplates() + "CAQHead.xlsx")); - List<String> sheetNames = reader.getSheetNames(); for (String sheetName : sheetNames) { ExcelReader readerSheet = cn.hutool.poi.excel.ExcelUtil.getReader(FileUtil.file(EssConfig.getReportTemplates() + "CAQHead.xlsx"), sheetName); List<List<Object>> readList = readerSheet.read(); List<List<Object>> reportResultList = new ArrayList<>(); reportResultMap.put(sheetName, reportResultList); - int i = 0; dataReportHead.getHeadSystem().addAll(readList.get(i++)); reportResultList.add(dataReportHead.getHeadSystem()); @@ -683,7 +611,6 @@ deleteNoRightKeys(dataReportHead, isRight, readList, i); } } - private void setDataReportHeaderRuilin(DataReportHead dataReportHead, Map<String, List<List<Object>>> reportResultMap, boolean isRight) { ExcelReader reader = cn.hutool.poi.excel.ExcelUtil.getReader(FileUtil.file(EssConfig.getReportTemplates() + "RuiLinHead.xlsx")); List<String> sheetNames = reader.getSheetNames(); @@ -699,14 +626,11 @@ deleteNoRightKeys(dataReportHead, isRight, readList, i); reportResultMap.put(sheetName, reportResultList); } - - } - private void deleteNoRightKeys(DataReportHead dataReportHead, boolean isRight, List<List<Object>> readList, int i) { if (!isRight) { -// if (true) { - // 闇�瑕佸墧闄ょ殑琛� + + Set<Object> rightSet = new HashSet(); for (; i < readList.size(); i++) { List<Object> objects = readList.get(i); @@ -720,7 +644,6 @@ deleteNoRight(rightSet, dataReportHead.getHeadThai()); } } - private void deleteNoRight(Set<Object> rightSet, List<Object> headSystem) { if (CollUtil.isEmpty(headSystem)) { return; @@ -732,32 +655,27 @@ } } } - private void setDemograyMap(List<TExamReport> tExamReportList, DataReportHead dataReportHead, Map<String, Map<String, String>> demograpyMap) { Set<String> heavyDischargeDemography = new HashSet<>(); for (TExamReport tExamReportIt : tExamReportList) { - // 璇诲嚭浜哄彛瀛﹀彉閲�,闄嶇淮 + List<DemographyDataReportDto> demographyDataReportDtoList = setLocalDataReportByParamId(tExamReportIt); Map<String, String> demograpyValueMap = new HashMap<>(); for (DemographyDataReportDto demographyDataReportDto : demographyDataReportDtoList) { demograpyValueMap.put(demographyDataReportDto.getParamId(), demographyDataReportDto.getParamValue()); - - // 鎺掗噸鐢� + if (heavyDischargeDemography.contains(demographyDataReportDto.getParamId())) { continue; } else { heavyDischargeDemography.add(demographyDataReportDto.getParamId()); } - - // 娣诲姞鍚勭璇█鐨勮〃澶� + setDataReportDemography(dataReportHead, demographyDataReportDto); } - - // 浜哄彛瀛﹂敭鍜屽�� + demograpyMap.put(tExamReportIt.getId().toString(), demograpyValueMap); } } - private void setDataReportDemography(DataReportHead dataReportHead, DemographyDataReportDto demographyDataReportDto) { dataReportHead.getHeadSystem().add(demographyDataReportDto.getParamId()); List<DemographyDto> demographyDtoList = JsonUtil.parseArray(demographyDataReportDto.getLangCode(), DemographyDto.class); @@ -765,9 +683,8 @@ findLandCode(dataReportHead.getHeadEnglish(), demographyDtoList, "English"); findLandCode(dataReportHead.getHeadThai(), demographyDtoList, "Thai"); } - private void findLandCode(List<Object> demographyHeadLang, List<DemographyDto> demographyDtoList, String lang) { - // 鎵惧嚭涓枃鐨� + boolean isLang = false; for (DemographyDto demographyDto : demographyDtoList) { if (Objects.equals(demographyDto.getLangType(), lang)) { @@ -775,20 +692,17 @@ isLang = true; } } - if (!isLang) { demographyHeadLang.add(""); } } - private void setExtracHead(DataMap<Integer, Object[]> dataMap, Object[] keys, List<Object[]> keyDemography, int position) { - // ISP_T1 IM_T1 Inconsistency_T1 + if (position == 1) { keys[0] = "ISP_T1"; keys[1] = "IM_T1"; keys[2] = "Inconsistency_T1"; } - if (position == 2) { keys[0] = "鑷じ_T1"; keys[1] = "鍗拌薄绠$悊_T1"; @@ -797,18 +711,15 @@ } dataMap.put(position, ArrayUtil.addAll(keyDemography.get(position), keys)); } - private void setAllLangLocalDataValue(int keyPosition, List<DataMap> reportLocalList, Map<String, String> mapPara, Set<String> langTypeSet, List<Object[]> keyDemography) { - // 绯荤粺鍙橀噺鍚嶅摢涓�琛�,绗竴琛� + setAllLangLocalRowValue(keyPosition, reportLocalList, mapPara, keyDemography, langTypeSet.iterator().next(), "绯荤粺鍐呭彉閲忓悕"); - Map<String, Map<String, String>> multiLanguageMap = new HashedMap(); setLangSystemV(multiLanguageMap); for (String langType : langTypeSet) { setAllLangLocalRowValue(keyPosition, reportLocalList, mapPara, keyDemography, langType, multiLanguageMap.get("Chinese").get(langType)); } } - private void setLangSystemV(Map<String, Map<String, String>> multiLanguageMap) { Map<String, String> langTypeChineseMap = new HashedMap(); langTypeChineseMap.put("English", "瀵煎嚭鍚庡彉閲忓悕锛堣嫳鏂囷級"); @@ -816,25 +727,22 @@ langTypeChineseMap.put("Thai", "瀵煎嚭鍚庡彉閲忓悕锛堟嘲鏂囷級"); multiLanguageMap.put("Chinese", langTypeChineseMap); } - private void setClientV(Map<String, String> langTypeChineseMap) { langTypeChineseMap.put("English", "Client"); langTypeChineseMap.put("Chinese", "浼佷笟瀹㈡埛鍚嶇О"); langTypeChineseMap.put("Thai", "Client"); } - private void setAllLangLocalRowValue(int keyPosition, List<DataMap> reportLocalList, Map<String, String> mapPara, List<Object[]> keyDemography, String langType, String systemVariable) { DataMap<String, String> reportLocalMap = reportLocalList.get(keyPosition); - // 涓�琛�,琛岀殑paramid + List<String> rowList = reportLocalMap.getKeys(); List<String> rowValues = new ArrayList<>(); - // rowValues.add("绯荤粺鍙橀噺"); + rowValues.add(systemVariable); - for (String row : rowList) { - // json涓� + String rows = mapPara.get(row); - // 鍋氭垚map + List<Map<String, String>> langMapList = JsonUtil.parseObject(rows, ArrayList.class); String langCode = ""; for (Map<String, String> langMap : langMapList) { @@ -844,14 +752,12 @@ } rowValues.add(langCode); } - - // 浼佷笟鐢ㄦ埛 + Map<String, String> clientLangMap = new HashedMap(); setClientV(clientLangMap); rowValues.add(clientLangMap.get(langType)); keyDemography.add(rowValues.toArray()); } - private void setDataReportLangSet(Map<String, String> mapPara, Set<String> langTypeSet) { for (Map.Entry<String, String> entry : mapPara.entrySet()) { List<Map<String, String>> langMapList = JsonUtil.parseObject(entry.getValue(), ArrayList.class); @@ -860,7 +766,6 @@ } } } - private List<DemographyDataReportDto> setLocalDataReportByParamId(TExamReport it) { EntDemographyInfo entDemographyInfoAsParam = new EntDemographyInfo(); entDemographyInfoAsParam.setMemberId(it.getMemberId().longValue()); @@ -876,32 +781,25 @@ } return demographyDataReportDtoList; } - private void setTaiInterfaceContentMap(TExamReport it, DataMap<String, String> dataReportMap, boolean isRight, List<DataMap> reportTaiList) { try { DataMap<String, String> dataReportTaiMap = new DataMap<>(); List<ReportAPIResult> reportAPIResultList = JsonUtil.parseArray(it.getInterfaceContent(), ReportAPIResult.class); DataReport dataReportTai = new DataReport(); - - // 绗竴娈� + set1PartDataReport(dataReportMap, dataReportTaiMap, isRight, reportAPIResultList, dataReportTai); - - // 绗簩娈�,涓嶈鏉冮檺, + setNoRightPart(dataReportMap, dataReportTaiMap, reportAPIResultList, dataReportTai); - - // 绗簩娈�,瑕佹潈闄� + set2PartDataReport(dataReportMap, dataReportTaiMap, isRight, reportAPIResultList, dataReportTai); - - // 瑕佹潈闄�,鏈�鍚庨偅涓�鐐筊eport + setEndPartDataReport(dataReportMap, dataReportTaiMap, reportAPIResultList, dataReportTai, isRight); - - // 娉板浗鍥㈤槦鐨勬暟鎹� + reportTaiList.add(dataReportTaiMap); } catch (Exception e) { logger.error(" id:" + it.getId() + " memberName" + it.getMemberName() + " " + it.getInterfaceContent()); } } - private void setEndPartDataReport(DataMap<String, String> dataReportMap, DataMap<String, String> dataReportTaiMap, List<ReportAPIResult> reportAPIResultList, DataReport dataReportTai, boolean isRight) { if (!isRight) { return; @@ -916,7 +814,6 @@ setDataReportValueMap(dataReportTaiMap, dataReportTai); } } - private void set2PartDataReport(DataMap<String, String> dataReportMap, DataMap<String, String> dataReportTaiMap, boolean isRight, List<ReportAPIResult> reportAPIResultList, DataReport dataReportTai) { if (isRight) { List<String> keepPartOrderList = new ArrayList<>(); @@ -928,7 +825,7 @@ setDataReportValueMap(dataReportMap, dataReportTai); setDataReportValueMap(dataReportTaiMap, dataReportTai); } - // 鐒跺悗棰樼洰 + Map<String, String> answerDataMap = new LinkedHashMap<>(); Map<String, String> answerDataNoOrder = reportAPIResultList.get(1).getAnswerData(); answerDataNoOrder.entrySet().stream().sorted(Map.Entry.comparingByKey()) @@ -941,7 +838,6 @@ } } } - private void setNoRightPart(DataMap<String, String> dataReportMap, DataMap<String, String> dataReportTaiMap, List<ReportAPIResult> reportAPIResultList, DataReport dataReportTai) { List<String> keepPartOrderList = new ArrayList<>(); keepPartOrderList.addAll(Arrays.asList("P_Flex01,P_Creat02,P_Analyt03,P_Indep04,P_Achiev05,P_Initi06,P_Persis07,P_Thorou08,P_Depend09,P_Plan10,P_Integr11,P_Energy12,P_Social13,P_Lead14,P_Influ15,P_Team16,P_Empath17,P_Polite18,P_Regula19,P_ManStr,P_Confid21,P_Mind22,P_SDE23,P_IM24,P_INCON25,P_Open26,P_Consci27,P_Extro28,P_Agree29,P_EmSt30,P_Task31,P_People32,P_Judg33,STDA,DA,SLDA,SLAG,AG,STAG".split(","))); @@ -953,22 +849,20 @@ setDataReportValueMap(dataReportTaiMap, dataReportTai); } } - private void set1PartDataReport(DataMap<String, String> dataReportMap, DataMap<String, String> dataReportTaiMap, boolean isRight, List<ReportAPIResult> reportAPIResultList, DataReport dataReportTai) { if (isRight) { - // 瑕佹潈闄愶紝绗竴娈� + List<String> keepPartOrderList = new ArrayList<>(); keepPartOrderList.addAll(Arrays.asList("P_SDE_T1,P_IM_T1,P_INCON_T1,Signal,INC1T1,INC2T1,INC3T1,INC4T1,INC5T1,INC6T1,INC7T1,INC8T1".split(","))); Map<String, String> taiDataMap = reportAPIResultList.get(0).getData(); taiDataMap.put("Signal", reportAPIResultList.get(0).getSignal()); - // 绗竴娈电殑娉板浗杩斿洖 + for (String keepPartOrder : keepPartOrderList) { dataReportTai.setField(keepPartOrder); dataReportTai.setValue(taiDataMap.get(keepPartOrder)); setDataReportValueMap(dataReportMap, dataReportTai); setDataReportValueMap(dataReportTaiMap, dataReportTai); } - Map<String, String> answerDataMap = new LinkedHashMap<>(); Map<String, String> answerDataNoOrder = reportAPIResultList.get(0).getAnswerData(); answerDataNoOrder.entrySet().stream().sorted( @@ -977,11 +871,10 @@ public int compare(Map.Entry<String, String> o1, Map.Entry<String, String> o2) { int key1 = Integer.valueOf(o1.getKey().substring(3)); int key2 = Integer.valueOf(o2.getKey().substring(3)); - return key1 - key2; // 闄嶅簭鎺掑簭锛屽鏋滄兂鍗囧簭灏卞弽杩囨潵 + return key1 - key2; } } ).forEachOrdered(x -> answerDataMap.put(x.getKey(), x.getValue())); - for (Map.Entry<String, String> entry : answerDataMap.entrySet()) { dataReportTai.setField(entry.getKey()); dataReportTai.setValue(entry.getValue()); @@ -990,52 +883,43 @@ } } } - private void setContentMap(TExamReport it, List<DataReport> dataReportList, DataMap<String, String> dataReportMap, List<DataMap> reportLocalList) { DataMap<String, String> dataReportLocalMap = new DataMap<>(); - // 绯荤粺鍙橀噺 + dataReportMap.put("variableNamesInTheSystem", ""); dataReportList.stream().forEach(dataReport -> { - // 鍒ゆ柇鏉冮檺 + if (StringUtils.isNotEmpty(dataReport.getRight())) { if (StringUtils.equals((UserTypeEnum.SYS_USER.getUserType()), dataReport.getRight())) { setDataReportMap(dataReportMap, dataReport); setDataReportMap(dataReportLocalMap, dataReport); - } } else { setDataReportMap(dataReportMap, dataReport); setDataReportMap(dataReportLocalMap, dataReport); } }); - dataReportMap.put("Client", it.getUserName()); reportLocalList.add(dataReportLocalMap); } - private void setDataReportMap(DataMap<String, String> filed, DataReport dataReport) { filed.put(dataReport.getField(), iExamUtilService.getLangOrLocalLangString(dataReport.getLangType(), dataReport.getValue())); } - private void setDataReportValueMap(DataMap<String, String> filed, DataReport dataReport) { filed.put(dataReport.getField(), dataReport.getValue()); } - - // 绠�鍗曟姤鍛� + @RequiresPermissions("exam:report:basisExport") @PostMapping("/exportBasisReport/{ids}/{langType}") @ResponseBody public AjaxResult exportBasisReport(@PathVariable("ids") String[] ids, @PathVariable("langType") String langType) { List<TExamReport> tExamReportList = tExamReportService.selectTExamReportByIds(ids); - List<TReportTemplate> tReportTemplateList = itReportTemplateService.selectTReportTemplates(tExamReportList.get(0).getReportTemplateId()); - Map<String, ReportTypeEnum> reportTypeEnumMap = new HashMap<>(); for (com.ots.common.enums.ReportTypeEnum reportTypeEnumTemp : ReportTypeEnum.values()) { reportTypeEnumMap.put(reportTypeEnumTemp.getCode(), reportTypeEnumTemp); } - - // 瀵煎嚭鍩虹鐗堟湰 + String questionTemplateId = tExamReportList.get(0).getQuestionTemplateId(); String templateType = "Brief"; String reportType = ""; @@ -1043,7 +927,7 @@ String fileName = ""; TReportTemplate tReportTemplate = tExamReportService.getReportTemplate(questionTemplateId, langType, templateType); try { - // 澶勭悊鐫块偦 + for (TReportTemplate tReportTemplateTemp : tReportTemplateList) { if (Objects.equals(tReportTemplateTemp.getReportType(), "RuiLin")) { tReportTemplate = tReportTemplateTemp; @@ -1052,7 +936,6 @@ break; } } - reportType = tReportTemplate.getReportType(); path = itReportTemplateService.selectTReportTemplateFilePath(tReportTemplate); if (StringUtils.isEmpty(path)) { @@ -1062,7 +945,6 @@ e.printStackTrace(); return AjaxResult.error(MessageUtils.message("jsp.exam.report.noTemplate")); } - List<String> deleteFileStrList = new ArrayList<>(); List<String> deleteStrList = new ArrayList<>(); List<String> fileNameList = new ArrayList<>(); @@ -1070,8 +952,7 @@ tExamReportService.setExportBaseOrDetailReportData(tExamReportList, deleteStrList, fileNameList, tReportTemplate); return wordUtil.exportBaseOrDetailReport(path, deleteFileStrList, fileNameList); } - - // 璇︾粏鎶ュ憡 + @RequiresPermissions("exam:report:detailReportexport") @PostMapping("/exportDetailedReport/{ids}/{langType}") @ResponseBody @@ -1082,47 +963,39 @@ tExamReport.setId(Long.valueOf(id)); tExamReportList.add(tExamReport); } - - - // 闄勪欢鐨勪綅缃�,鍏蜂綋閭欢闄勪欢鐨勪綅缃� + List<String> fileNameResult = new ArrayList<>(); - // 瑕佸垹闄ょ殑鏂囦欢 + List<String> deleteStrList = new ArrayList<>(); - List<String> exportFileList = new ArrayList<>(); - List<TExamReport> tExamReports = tExamReportService.selectTExamReportByIds(ids); TExamReport tExamReport = tExamReports.get(0); String reportType = getReportType(tExamReport); if (Objects.equals("JAQ", reportType)) { dealJAQReport(deleteStrList, exportFileList, tExamReports); } else { - // MAQ,SAQ,CAQ + dealReprotFile(tExamReportList, fileNameResult, deleteStrList, exportFileList, reportType); } - WordUtil wordUtil = new WordUtil(); return wordUtil.exportBaseOrDetailReport("DataReport", deleteStrList, exportFileList); } - - // jaq鎶ュ憡 dealJAQReport + private void dealJAQReport(List<String> deleteStrList, List<String> exportFileList, List<TExamReport> tExamReports) throws IOException { TExamReport tExamReport = tExamReports.get(0); ReportAPIResult reportAPIResult = getThaiJAQData(tExamReports); - // 娉板浗鏁版嵁 + Map<String, String> thaiData = reportAPIResult.getData(); - - // 鐢熸垚JAQ鎶ュ憡 + List<TReportTemplate> tReportTemplateList = itReportTemplateService.selectTReportTemplates(tExamReport.getReportTemplateId()); Map<String, Object> textMap = new HashMap<>(); - - // 鏋勯�犺〃 + textMap.putAll(thaiData); WordUtil wordUtil = new WordUtil(); textMap.put("sendEmailFileName", "JAQ"); RelatedParty relatedParty = memberService.queryProdidByToken(tExamReport.getTokenId()); for (TReportTemplate tReportTemplate : tReportTemplateList) { - // 瀵圭涓�寮犺〃鐨勬枃瀛楄繘琛岀炕璇� + Map<String, String> jaqMap = getJaqQuestionByPermanentIdMap(tReportTemplate, tExamReport); changTable1(textMap, tReportTemplate, thaiData); changTable2(textMap, tReportTemplate, thaiData); @@ -1135,14 +1008,12 @@ textMap.put("superiorPosition", relatedParty.getSuperiorPosition()); String zipFileName = wordUtil.makeReportFile(tReportTemplate.getLocation(), tReportTemplate, textMap, null, deleteStrList); exportFileList.add(zipFileName); - - // 鍒犻櫎瑕佸垹鐨� + wordUtil.deleteFileByStr(deleteStrList); } } - private void changTable4(Map<String, Object> textMap, TReportTemplate tReportTemplate, Map<String, String> jaqMap, Map<String, String> thaiData) { - // 鏇挎崲鍊� + for (Integer i = 1; i <= 3; i++) { textMap.put("T4com1item" + i.toString(), ExamUtil.getLangString(tReportTemplate.getLangType(), jaqMap.get(thaiData.get("T4com1item" + i.toString())))); textMap.put("T4com2item" + i.toString(), ExamUtil.getLangString(tReportTemplate.getLangType(), jaqMap.get(thaiData.get("T4com2item" + i.toString())))); @@ -1153,32 +1024,25 @@ textMap.put("T4com7item" + i.toString(), ExamUtil.getLangString(tReportTemplate.getLangType(), jaqMap.get(thaiData.get("T4com7item" + i.toString())))); textMap.put("T4com8item" + i.toString(), ExamUtil.getLangString(tReportTemplate.getLangType(), jaqMap.get(thaiData.get("T4com8item" + i.toString())))); } - Map<String, String> tagMap = getTranslationCapability(); - - // 鏇挎崲鍊� + for (Integer i = 1; i <= 12; i++) { textMap.put("T4com" + i.toString(), ExamUtil.getLangString(tReportTemplate.getLangType(), tagMap.get(thaiData.get("T4com" + i.toString())))); } } - private void changTable3(Map<String, Object> textMap, TReportTemplate tReportTemplate, Map<String, String> jaqMap, Map<String, String> thaiData) { - - // 鏇挎崲鍊� + for (Integer i = 1; i <= 25; i++) { textMap.put("T3item" + i.toString(), ExamUtil.getLangString(tReportTemplate.getLangType(), jaqMap.get(thaiData.get("T3item" + i.toString())))); } - WordUtil.changeJAQStyle(textMap, 2, 25, "T3Line"); - - // 鑳滀换鍔涢偅涓�鍒楁浛鎹� + Map<String, String> tagMap = getTranslationCapability(); - // 鏇挎崲鍊� + for (Integer i = 1; i <= 25; i++) { textMap.put("T3com" + i.toString(), ExamUtil.getLangString(tReportTemplate.getLangType(), tagMap.get(thaiData.get("T3com" + i.toString())))); } } - @NotNull private Map<String, String> getJaqQuestionByPermanentIdMap(TReportTemplate tReportTemplate, TExamReport tExamReport) { List<QuestionReport> questionReports = JsonUtil.toJsonListObject(tExamReport.getQuestionReport(), QuestionReport.class); @@ -1186,27 +1050,22 @@ for (QuestionReport questionReport : questionReports) { jaqMap.put(questionReport.getPermanentId(), questionReport.getQuestionTitle()); } - - // 鍙栫壒瀹氱殑閭g璇█鐢熸垚鎶ュ憡 + List<TQuestion> tQuestions = itQuestionService.selectTQuestionByPermanentIds(new ArrayList<>(jaqMap.keySet())); - for (TQuestion tQuestion : tQuestions) { QuestionObject questionObject = JsonUtil.parseObject(tQuestion.getContent(), QuestionObject.class); jaqMap.put(tQuestion.getPermanentId(), ExamUtil.getLangString(tReportTemplate.getLangType(), questionObject.getTitleContent())); } return jaqMap; } - private void changTable1(Map<String, Object> textMap, TReportTemplate tReportTemplate, Map<String, String> thaiData) { Map<String, String> tagMap = getTranslationCapability(); - - // 鏇挎崲鍊� + for (Integer i = 1; i <= 12; i++) { String textValue = thaiData.get("T1com" + i.toString()); textMap.put("T1com" + i.toString(), ExamUtil.getLangString(tReportTemplate.getLangType(), tagMap.get(textValue))); } } - private Map<String, String> getTranslationCapability() { ExcelReader reader = cn.hutool.poi.excel.ExcelUtil.getReader(FileUtil.file(EssConfig.getReportTemplates() + "JAQTable1Tag.xlsx")); List<List<Object>> readList = reader.read(); @@ -1221,37 +1080,30 @@ } return tagMap; } - private void changTable2(Map<String, Object> textMap, TReportTemplate tReportTemplate, Map<String, String> thaiData) { Map<String, String> tagMap = getTranslationCapability(); - - //JAQ涓婇鑹� + WordUtil.changeJAQStyle(textMap, 1, 12, "T2Line"); - - // 鏇挎崲鍊� + for (Integer i = 1; i <= 12; i++) { textMap.put("T2com" + i.toString(), ExamUtil.getLangString(tReportTemplate.getLangType(), tagMap.get(thaiData.get("T2com" + i.toString())))); } } - private ReportAPIResult getThaiJAQData(List<TExamReport> tExamReports) { List<JAQPersons> persons = new ArrayList<>(); Integer personCout = 0; for (TExamReport tExamReport : tExamReports) { - // 浜虹殑淇℃伅 + Map<String, String> personInfo = new LinkedHashMap<>(); personInfo.put("accessCode", tExamReport.getTokenId()); personInfo.put("fullName", tExamReport.getMemberName()); - // 绛旈鐨勪汉 + JAQPersons person = new JAQPersons(); person.setPersonInfo(personInfo); - - // 绛旈鐨勯�夐」 + Map<String, String> personPoints = new LinkedHashMap<>(); person.setPersonPoints(personPoints); - - // 閫犳暟鎹�,璁板緱灞忚斀锛岄�爅aq鏁版嵁 -// makeJAQData(personPoints); + List<QuestionReport> questionReportList = JsonUtil.parseArray(tExamReport.getQuestionReport(), QuestionReport.class); for (QuestionReport questionReport : questionReportList) { @@ -1263,7 +1115,6 @@ persons.add(person); personCout++; } - Map<String, List<JAQPersons>> data = new LinkedHashMap<>(); data.put("persons", persons); HolderInfo info = new HolderInfo(); @@ -1283,7 +1134,6 @@ reportAPIResult.setAnswerData(data); return reportAPIResult; } - private void makeJAQData(Map<String, String> personPoints) { String topics = "JAQ0001a,JAQ0001b,JAQ0002a,JAQ0002b,JAQ0003a,JAQ0003b,JAQ0004a,JAQ0004b,JAQ0005a,JAQ0005b,JAQ0006a,JAQ0006b,JAQ0007a,JAQ0007b,JAQ0008a,JAQ0008b,JAQ0009a,JAQ0009b,JAQ0010a,JAQ0010b,JAQ0011a,JAQ0011b,JAQ0012a,JAQ0012b,JAQ0013a,JAQ0013b,JAQ0014a,JAQ0014b,JAQ0015a,JAQ0015b,JAQ0016a,JAQ0016b,JAQ0017a,JAQ0017b,JAQ0018a,JAQ0018b,JAQ0019a,JAQ0019b,JAQ0020a,JAQ0020b,JAQ0021a,JAQ0021b,JAQ0022a,JAQ0022b,JAQ0023a,JAQ0023b,JAQ0024a,JAQ0024b,JAQ0025a,JAQ0025b,JAQ0026a,JAQ0026b,JAQ0027a,JAQ0027b,JAQ0028a,JAQ0028b,JAQ0029a,JAQ0029b,JAQ0030a,JAQ0030b,JAQ0031a,JAQ0031b,JAQ0032a,JAQ0032b,JAQ0033a,JAQ0033b,JAQ0034a,JAQ0034b,JAQ0035a,JAQ0035b,JAQ0036a,JAQ0036b,JAQ0037a,JAQ0037b,JAQ0038a,JAQ0038b,JAQ0039a,JAQ0039b,JAQ0040a,JAQ0040b,JAQ0041a,JAQ0041b,JAQ0042a,JAQ0042b,JAQ0043a,JAQ0043b,JAQ0044a,JAQ0044b,JAQ0045a,JAQ0045b,JAQ0046a,JAQ0046b,JAQ0047a,JAQ0047b,JAQ0048a,JAQ0048b,JAQ0049a,JAQ0049b,JAQ0050a,JAQ0050b,JAQ0051a,JAQ0051b,JAQ0052a,JAQ0052b,JAQ0053a,JAQ0053b,JAQ0054a,JAQ0054b,JAQ0055a,JAQ0055b,JAQ0056a,JAQ0056b,JAQ0057a,JAQ0057b,JAQ0058a,JAQ0058b,JAQ0059a,JAQ0059b,JAQ0060a,JAQ0060b,JAQ0061a,JAQ0061b,JAQ0062a,JAQ0062b,JAQ0063a,JAQ0063b,JAQ0064a,JAQ0064b,JAQ0065a,JAQ0065b,JAQ0066a,JAQ0066b,JAQ0067a,JAQ0067b,JAQ0068a,JAQ0068b,JAQ0069a,JAQ0069b,JAQ0070a,JAQ0070b,JAQ0071a,JAQ0071b,JAQ0072a,JAQ0072b,JAQ0073a,JAQ0073b,JAQ0074a,JAQ0074b,JAQ0075a,JAQ0075b,JAQ0076a,JAQ0076b,JAQ0077a,JAQ0077b,JAQ0078a,JAQ0078b,JAQ0079a,JAQ0079b,JAQ0080a,JAQ0080b,JAQ0081a,JAQ0081b,JAQ0082a,JAQ0082b,JAQ0083a,JAQ0083b,JAQ0084a,JAQ0084b,JAQ0085a,JAQ0085b,JAQ0086a,JAQ0086b,JAQ0087a,JAQ0087b,JAQ0088a,JAQ0088b,JAQ0089a,JAQ0089b,JAQ0090a,JAQ0090b,JAQ0091a,JAQ0091b,JAQ0092a,JAQ0092b,JAQ0093a,JAQ0093b,JAQ0094a,JAQ0094b,JAQ0095a,JAQ0095b,JAQ0096a,JAQ0096b,JAQ0097a,JAQ0097b,JAQ0098a,JAQ0098b,JAQ0099a,JAQ0099b,JAQ0100a,JAQ0100b,JAQ0101a,JAQ0101b,JAQ0102a,JAQ0102b,JAQ0103a,JAQ0103b,JAQ0104a,JAQ0104b,JAQ0105a,JAQ0105b,JAQ0106a,JAQ0106b,JAQ0107a,JAQ0107b,JAQ0108a,JAQ0108b,JAQ0109a,JAQ0109b,JAQ0110a,JAQ0110b,JAQ0111a,JAQ0111b,JAQ0112a,JAQ0112b,JAQ0113a,JAQ0113b,JAQ0114a,JAQ0114b,JAQ0115a,JAQ0115b,JAQ0116a,JAQ0116b,JAQ0117a,JAQ0117b,JAQ0118a,JAQ0118b,JAQ0119a,JAQ0119b,JAQ0120a,JAQ0120b,JAQ0121a,JAQ0121b,JAQ0122a,JAQ0122b,JAQ0123a,JAQ0123b,JAQ0124a,JAQ0124b,JAQ0125a,JAQ0125b,JAQ0126a,JAQ0126b,JAQ0127a,JAQ0127b,JAQ0128a,JAQ0128b,JAQ0129a,JAQ0129b,JAQ0130a,JAQ0130b,JAQ0131a,JAQ0131b,JAQ0132a,JAQ0132b,JAQ0133a,JAQ0133b,JAQ0134a,JAQ0134b,JAQ0135a,JAQ0135b"; String[] split = topics.split(","); @@ -1291,17 +1141,14 @@ personPoints.put(item, "2"); }); } - private void dealReprotFile(List<TExamReport> tExamReportList, List<String> fileNameResult, List<String> deleteStrList, List<String> exportFileList, String reportType) { for (TExamReport tExamReport : tExamReportList) { fileNameResult.clear(); - // 閲嶆柊璋冪敤娉板浗鍥㈤槦鐨勬帴鍙o紝閲岄潰浼氭洿鏂版暟鎹簱 + TExamReport tExamReportComplete = tExamReportService.selectTExamReportById(tExamReport.getId()); itExamPaperService.recallThaiInterface(tExamReportComplete, reportType); - - // 寮�濮嬬敓鎴愭姤鍛� + TExamReport tExamReportResult = tExamReportService.getReportFromTemplate(tExamReport, fileNameResult, deleteStrList); - if (tExamReportResult == null) { continue; } @@ -1309,41 +1156,31 @@ String[] exportFiles = exportFile.split("/"); exportFileList.add(exportFiles[exportFiles.length - 1]); } - - // 鏇存柊鍘嗗彶鍦板潃 + updateHisReportAddress(fileNameResult, deleteStrList, tExamReportResult); } } - private void updateHisReportAddress(List<String> fileNameResult, List<String> deleteStrList, TExamReport tExamReportResult) { - // 涓嬭浇鍘嗗彶鏂囦欢 + if (StringUtils.isEmpty(tExamReportResult.getReportAddress())) { return; } - TExamReport tExamReportUpdate = new TExamReport(); tExamReportUpdate.setId(tExamReportResult.getId()); tExamReportUpdate.setReportAddress(JsonUtil.toJSONString(fileNameResult)); tExamReportUpdate.setReportAddressNew(JsonUtil.toJSONString(fileNameResult)); tExamReportService.updateTExamReport(tExamReportUpdate); } - private Map<String, Map<String, String>> getDataFromExcel() { ExcelUtil<String> excelUtil = new ExcelUtil<>(String.class); return excelUtil.getMAQFromExcel(); } - - /** - * 鏂板璇勬祴鎶ュ憡 - */ + @GetMapping("/add") public String add() { return prefix + "/add"; } - - /** - * 鏂板淇濆瓨璇勬祴鎶ュ憡 - */ + @RequiresPermissions("exam:report:add") @Log(title = "璇勬祴鎶ュ憡", businessType = BusinessType.INSERT) @PostMapping("/add") @@ -1351,20 +1188,14 @@ public AjaxResult addSave(TExamReport tExamReport) { return toAjax(tExamReportService.insertTExamReport(tExamReport)); } - - /** - * 淇敼璇勬祴鎶ュ憡 - */ + @GetMapping("/edit/{id}") public String edit(@PathVariable("id") Long id, ModelMap mmap) { TExamReport tExamReport = tExamReportService.selectTExamReportById(id); mmap.put("tExamReport", tExamReport); return prefix + "/edit"; } - - /** - * 淇敼淇濆瓨璇勬祴鎶ュ憡 - */ + @RequiresPermissions("exam:report:edit") @Log(title = "璇勬祴鎶ュ憡", businessType = BusinessType.UPDATE) @PostMapping("/edit") @@ -1372,10 +1203,7 @@ public AjaxResult editSave(TExamReport tExamReport) { return toAjax(tExamReportService.updateTExamReport(tExamReport)); } - - /** - * 鍒犻櫎璇勬祴鎶ュ憡 - */ + @RequiresPermissions("exam:report:remove") @Log(title = "璇勬祴鎶ュ憡", businessType = BusinessType.DELETE) @PostMapping("/remove") @@ -1383,10 +1211,7 @@ public AjaxResult remove(String ids) { return toAjax(tExamReportService.deleteTExamReportByIds(ids)); } - - /** - * 瀹℃壒鐘舵�佷慨鏀� - */ + @Log(title = "浼佷笟鐢ㄦ埛瀹℃壒", businessType = BusinessType.UPDATE) @RequiresPermissions("exam:report:edit") @PostMapping("/changeStatus") @@ -1394,10 +1219,7 @@ public AjaxResult changeStatus(TExamReport tExamReport) { return toAjax(tExamReportService.changeStatus(tExamReport)); } - - /** - * 鎵归噺鏇存柊瀹℃壒鐘舵�� - */ + @RequiresPermissions("exam:report:edit") @Log(title = "鎵归噺鏇存柊瀹℃壒鐘舵��", businessType = BusinessType.DELETE) @PostMapping("/batchVerify") @@ -1405,14 +1227,13 @@ public AjaxResult batchVerify(String ids) { return toAjax(tExamReportService.updateTexamReportByIds(ids, "1")); } - @GetMapping("/langType/{userIds}/{productId}") public String getLangType(@PathVariable("userIds") Long[] userIds, @PathVariable("productId") Long productId, ModelMap mmap) { List<DictData> dictDataList = tExamReportService.getType(userIds[0]); try { TExamPaper tExamPaper = itExamPaperService.selectTExamPaperById(productId); List<TReportTemplate> tReportTemplateList = itReportTemplateService.selectTReportTemplates(tExamPaper.getReportTemplateId()); - // 鐫块偦鐨勫彧鏈変腑鏂� + for (TReportTemplate tReportTemplate : tReportTemplateList) { if ("RuiLin".equals(tReportTemplate.getReportType())) { for (DictData dictData : dictDataList) { @@ -1426,39 +1247,31 @@ } } } catch (Exception e) { - } - mmap.put("dictDatas", dictDataList); return prefix + "/report::langTypeDiv"; } - @PostMapping("/testerReport/{memberId}") @ResponseBody public AjaxResult getTesterReport(@PathVariable Integer memberId) { TExamReport tExamReport = new TExamReport(); tExamReport.setMemberId(memberId); - // 闄勪欢鐨勪綅缃�,鍏蜂綋閭欢闄勪欢鐨勪綅缃� + List<String> fileNameResult = new ArrayList<>(); - // 瑕佸垹闄ょ殑鏂囦欢 + List<String> deleteStrList = new ArrayList<>(); - WordUtil wordUtil = new WordUtil(); - TExamReport tExamReportResult = tExamReportService.getReportFromTemplate(tExamReport, fileNameResult, deleteStrList); if (tExamReportResult == null) { return AjaxResult.success("绛旈鏈畬鎴愶紒"); } - List<String> exportFileList = new ArrayList<>(); for (String exportFile : fileNameResult) { String[] exportFiles = exportFile.split("/"); exportFileList.add(exportFiles[exportFiles.length - 1]); } - return wordUtil.exportBaseOrDetailReport(tExamReportResult.getMemberName(), deleteStrList, exportFileList); } - @PostMapping("/exportSendedReport/{ids}") @ResponseBody public AjaxResult getTesterReport(@PathVariable String[] ids) { @@ -1473,7 +1286,6 @@ fileNameList.add(addresses[addresses.length - 1]); } } - return wordUtil.exportZipKeepFiles(MessageUtils.message("jsp.exam.report.sendedReport"), new ArrayList<>(), fileNameList); } catch (FileNotFoundException e) { e.printStackTrace(); @@ -1482,10 +1294,7 @@ } return AjaxResult.error(MessageUtils.message("jsp.exam.report.noHisReport")); } - - /** - * 鏌ヨ璇勬祴閭�璇峰彂閫佷换鍔″垪琛� - */ + @RequiresPermissions("exam:hrEmailReport:view") @PostMapping("/hrSendlogList") @ResponseBody @@ -1493,13 +1302,12 @@ startPage(); tExamReport.setFinish(1); tExamReport.setSendHrStatusList(Arrays.asList(1, 3)); - User sysUser = ShiroUtils.getSysUser(); String userType = sysUser.getUserType(); if (UserTypeEnum.ENT_USER.getUserType().equals(userType)) { tExamReport.setUserId(sysUser.getUserId()); } - //鍒嗛攢鍟嗗彲浠ョ湅鍒板垎閿�鍟嗕笅鐨勪紒涓氫俊鎭� + if (UserTypeEnum.DIS_USER.getUserType().equals(userType)) { SysUserExtend sysUserExtend = new SysUserExtend(); sysUserExtend.setParentUserId(sysUser.getUserId()); @@ -1511,14 +1319,12 @@ List<TExamReport> list = tExamReportService.selectTExamReportList(tExamReport); return getDataTable(list); } - @RequiresPermissions("exam:hrEmailReport:view") @GetMapping("/hrSendlog/{testId}") public String hrSendlog(@PathVariable Long testId,ModelMap mmap) { mmap.put("testId",testId); return "exam/hrSendlog/hrSendlog"; } - @RequiresPermissions("exam:hremail:reissue") @GetMapping("/sendEmail/{id}") @ResponseBody -- Gitblit v1.9.1