| | |
| | | package com.ots.project.exam.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.ots.common.enums.LangTypeEnum; |
| | | import com.ots.common.enums.ReportTypeEnum; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import java.awt.*; |
| | | import java.awt.image.BufferedImage; |
| | |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 评测报告Service业务层处理 |
| | | * |
| | | * @author ots |
| | | * @date 2019-12-26 |
| | | */ |
| | | @Service |
| | | public class TExamReportServiceImpl implements ITExamReportService { |
| | | @Autowired |
| | | private TExamReportMapper tExamReportMapper; |
| | | |
| | | @Autowired |
| | | private IDictDataService dictDataService; |
| | | |
| | | @Autowired |
| | | private SysUserExtendMapper sysUserExtendMapper; |
| | | |
| | | @Autowired |
| | | BarChart barChart; |
| | | |
| | | @Autowired |
| | | IEntDemographyInfoService entDemographyInfoService; |
| | | |
| | | @Autowired |
| | | IEntDemographyParamService entDemographyParamService; |
| | | |
| | | @Autowired |
| | | private ITReportTemplateService itReportTemplateService; |
| | | |
| | | @Autowired |
| | | private IEntTestMemberService entTestMemberService; |
| | | |
| | | private static final Logger logger = LoggerFactory.getLogger(Threads.class); |
| | | |
| | | @Autowired |
| | | private MemberService memberService; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询评测报告 |
| | | * |
| | | * @param id 评测报告ID |
| | | * @return 评测报告 |
| | | */ |
| | | @Override |
| | | public TExamReport selectTExamReportById(Long id) { |
| | | return tExamReportMapper.selectTExamReportById(id); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询评测报告列表 |
| | | * |
| | | * @param tExamReport 评测报告 |
| | | * @return 评测报告 |
| | | */ |
| | | @Override |
| | | public List<TExamReport> selectTExamReportList(TExamReport tExamReport) { |
| | | return tExamReportMapper.selectTExamReportList(tExamReport); |
| | | } |
| | | |
| | | @Override |
| | | public List<TExamReport> selectViewReportList(TExamReport tExamReport) { |
| | | return tExamReportMapper.selectViewReportList(tExamReport); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 新增评测报告 |
| | | * |
| | | * @param tExamReport 评测报告 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertTExamReport(TExamReport tExamReport) { |
| | | tExamReport.setCreateTime(DateUtils.getNowDate()); |
| | | return tExamReportMapper.insertTExamReport(tExamReport); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改评测报告 |
| | | * |
| | | * @param tExamReport 评测报告 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateTExamReport(TExamReport tExamReport) { |
| | | tExamReport.setUpdateTime(DateUtils.getNowDate()); |
| | | return tExamReportMapper.updateTExamReport(tExamReport); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public int updateTExamReportStatus(TExamReport tExamReport) { |
| | | tExamReport.setUpdateTime(DateUtils.getNowDate()); |
| | | return tExamReportMapper.updateTExamReportStatus(tExamReport); |
| | | } |
| | | |
| | | @Override |
| | | public int updateTExamReportByTokenId(TExamReport tExamReport) { |
| | | tExamReport.setUpdateTime(DateUtils.getNowDate()); |
| | | return tExamReportMapper.updateTExamReportByTokenId(tExamReport); |
| | | } |
| | | |
| | | @Override |
| | | public int updateTExamReportDeleteLastOneByTokenId(TExamReport tExamReport) { |
| | | tExamReport.setUpdateTime(DateUtils.getNowDate()); |
| | | return tExamReportMapper.updateTExamReportDeleteLastOneByTokenId(tExamReport); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 删除评测报告对象 |
| | | * |
| | | * @param ids 需要删除的数据ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteTExamReportByIds(String ids) { |
| | | return tExamReportMapper.deleteTExamReportByIds(Convert.toStrArray(ids)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除评测报告信息 |
| | | * |
| | | * @param id 评测报告ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteTExamReportById(Long id) { |
| | | return tExamReportMapper.deleteTExamReportById(id); |
| | | } |
| | | |
| | | @Override |
| | | public int changeStatus(TExamReport tExamReport) { |
| | | return tExamReportMapper.updateTExamReport(tExamReport); |
| | | } |
| | | |
| | | @Override |
| | | public int updateTexamReportByIds(String ids, String downloadTimes) { |
| | | Map params = new HashMap<>(); |
| | |
| | | params.put("downloadTimes", downloadTimes); |
| | | return tExamReportMapper.updateTExamReportByIds(params); |
| | | } |
| | | |
| | | @Override |
| | | public List<TExamReport> selectTExamReportByTokenList(String[] tokenIds) { |
| | | return tExamReportMapper.selectTExamReportByTokenList(tokenIds); |
| | | } |
| | | |
| | | @Override |
| | | public List<TExamReport> selectTExamReportByIds(String[] ids) { |
| | | return tExamReportMapper.selectTExamReportByIds(ids); |
| | | } |
| | | |
| | | @Override |
| | | public List<DictData> getType(Long id) { |
| | | |
| | | // 查询字典先 |
| | | List<DictData> dictDataList = dictDataService.selectDictDataByType("lang_type"); |
| | | SysUserExtend sysUserExtend = sysUserExtendMapper.selectSysUserExtendById(id); |
| | | String langType = sysUserExtend.getLangType(); |
| | |
| | | } |
| | | return dictDataListResult; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public TReportTemplate getReportTemplate(String questionTemplateId, String langType, String templateType) { |
| | | TReportTemplate tReportTemplate = new TReportTemplate(); |
| | |
| | | tReportTemplate.setReportType(productTypeMap.get(questionTemplateId)); |
| | | return tReportTemplate; |
| | | } |
| | | |
| | | |
| | | // 模拟调用接口抽取到服务层 |
| | | @Override |
| | | public void setTextPicture(TExamReport tExamReport, ReportResultData reportResultData, List<String> deleteStrList, LangTypeEnum langType, Map<String, Object> textMap) { |
| | | |
| | | |
| | | // begin 调用接口的代码块 |
| | | |
| | | // 这里是put映射,textMap和word文档对应 |
| | | setTextMap(tExamReport, reportResultData, textMap); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // begin 造进度条的数据 |
| | | // setProgressPicture(deleteStrList, langType, thaiCalculationMap, textMap); |
| | | // end 造进度条的数据 |
| | | |
| | | // 处理水滴 |
| | | setWaterDropPicture(reportResultData, deleteStrList, textMap, tExamReport); |
| | | |
| | | |
| | | // 处理url的图片 |
| | | setIconPicture(reportResultData, textMap); |
| | | } |
| | | |
| | | @Override |
| | | public void setExportBaseOrDetailReportData(List<TExamReport> tExamReportList, List<String> deleteStrList, List<String> fileNameList, TReportTemplate tReportTemplate) { |
| | | |
| | | // begin 从excel取数据 |
| | | Map<String, Map<String, String>> excelMap = new HashMap<>(); |
| | | |
| | | |
| | | // end 从excel取数据 |
| | | |
| | | // 处理泰国团队数据 |
| | | dealTaiData(tExamReportList, excelMap); |
| | | |
| | | |
| | | // 生成简单版本和详细版 |
| | | getBaseAndDetailReport(deleteStrList, fileNameList, tReportTemplate, excelMap); |
| | | } |
| | | |
| | | private void getBaseAndDetailReport(List<String> deleteStrList, List<String> fileNameList, TReportTemplate tReportTemplate, Map<String, Map<String, String>> excelMap) { |
| | | List<ReportResultData> reportResultDataList = new ArrayList<>(); |
| | | List<TExamReport> tExamReportList = new ArrayList<>(); |
| | | getBaseAndDetailRportDataList(tReportTemplate, excelMap, reportResultDataList, tExamReportList); |
| | | getReportFile(deleteStrList, fileNameList, tReportTemplate, reportResultDataList, tExamReportList); |
| | | } |
| | | |
| | | private void getReportFile(List<String> deleteStrList, List<String> fileNameList, TReportTemplate tReportTemplate, List<ReportResultData> reportResultDataList, List<TExamReport> tExamReportList) { |
| | | Map<String, Object> textMap = new HashMap<>(); |
| | | String path = itReportTemplateService.selectTReportTemplateFilePath(tReportTemplate); |
| | | for (int i = 0; i < tExamReportList.size(); i++) { |
| | | setTextPicture(tExamReportList.get(i), reportResultDataList.get(i), deleteStrList, LangTypeEnum.codeOf(tReportTemplate.getLangType()), textMap); |
| | | |
| | | |
| | | // 生成报告文件,这个是参考详细版 |
| | | // String fileName = "/2020/04/13/7e57e1cb61e24c7cfc894fa55bf385d5.docx"; |
| | | WordUtil wordUtil = new WordUtil(); |
| | | String zipFileName = wordUtil.makeReportFile(path, tReportTemplate, textMap, new HashMap<>(), deleteStrList); |
| | | fileNameList.add(zipFileName); |
| | | |
| | | wordUtil.deleteFileByStr(deleteStrList); |
| | | textMap.clear(); |
| | | } |
| | | } |
| | | |
| | | public void getBaseAndDetailRportDataList(TReportTemplate tReportTemplate, Map<String, Map<String, String>> excelMap, List<ReportResultData> reportResultDataList, List<TExamReport> tExamQueryReportList) { |
| | | for (Map.Entry<String, Map<String, String>> entry : excelMap.entrySet()) { |
| | | ReportResultData resultData = null; |
| | | TExamReport tExamReport = new TExamReport(); |
| | | |
| | | // if else MAQ SAQ CAQ |
| | | String reportType = tReportTemplate.getReportType(); |
| | | |
| | | // SAQ的报告 |
| | | reportType = getTypeIfIsSAQ(tReportTemplate, reportType); |
| | | String langType = tReportTemplate.getLangType(); |
| | | resultData = getReportResultData(reportType, langType, entry, tExamReport); |
| | |
| | | reportResultDataList.add(resultData); |
| | | } |
| | | } |
| | | |
| | | private String getTypeIfIsSAQ(TReportTemplate tReportTemplate, String reportType) { |
| | | if (Objects.equals(tReportTemplate.getTemplateType(), TemplateTypeEnum.SAQ.getCode())) { |
| | | reportType = TemplateTypeEnum.SAQ.getCode(); |
| | | } |
| | | return reportType; |
| | | } |
| | | |
| | | @Override |
| | | public ReportResultData getReportResultData(String reportType,String langType, Map.Entry<String, Map<String, String>> entry, TExamReport tExamReport) { |
| | | ReportResultData resultData = null; |
| | |
| | | } |
| | | return resultData; |
| | | } |
| | | |
| | | public void dealTaiData(List<TExamReport> tExamReportList, Map<String, Map<String, String>> excelMap) { |
| | | for (TExamReport tExamReport : tExamReportList) { |
| | | List<ReportAPIResult> reportAPIResultList = JsonUtil.parseArray(tExamReport.getInterfaceContent(), ReportAPIResult.class); |
| | | Map dataMap = new HashMap(); |
| | | try { |
| | | reportAPIResultList.stream().forEach(reportAPIResult -> { |
| | | |
| | | // 需要将第一次调用泰国团队和第二次调用的加起来 |
| | | Map<String, String> data = reportAPIResult.getData(); |
| | | for (Map.Entry<String, String> entry : data.entrySet()) { |
| | | try { |
| | |
| | | } catch (Exception e) { |
| | | logger.error("id:" + tExamReport.getId() + " memberName:" + tExamReport.getMemberName() + " " + tExamReport.getInterfaceContent()); |
| | | } |
| | | |
| | | |
| | | // 报告额外值 |
| | | setExcelMapextraValue(tExamReport, dataMap); |
| | | |
| | | |
| | | // 取人口学变量填的那个姓名 |
| | | String name = getDemographicName(tExamReport); |
| | | |
| | | if (StringUtils.isNotEmpty(name)) { |
| | | excelMap.put(name, dataMap); |
| | | } else { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void setExcelMapextraValue(TExamReport tExamReport, Map dataMap) { |
| | | dataMap.put("password", tExamReport.getTokenId()); |
| | | dataMap.put("reportId", tExamReport.getId().toString()); |
| | |
| | | EntTestMember entTestMember = entTestMemberService.selectEntTestMemberById(tExamReport.getMemberId().longValue()); |
| | | dataMap.put("reportGenerationDate", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, entTestMember.getEndTime())); |
| | | List<ReportAPIResult> interfaceContentList = JsonUtil.parseArray(tExamReport.getInterfaceContent(), ReportAPIResult.class); |
| | | |
| | | |
| | | // 遍历报告里面的值放进去 |
| | | setPExtro(dataMap, interfaceContentList); |
| | | |
| | | if (ExamUtil.isListNotEmpty(interfaceContentList)) { |
| | | dataMap.put("Signal", interfaceContentList.get(0).getSignal()); |
| | | } |
| | |
| | | questionReports.stream().forEach(questionReport -> { |
| | | dataMap.put(questionReport.getPermanentId(), questionReport.getAnswer()); |
| | | }); |
| | | |
| | | |
| | | |
| | | // 发邮件的那个名字 |
| | | // 取人口学变量填的那个姓名 |
| | | String name = getDemographicName(tExamReport); |
| | | if (StringUtils.isNotEmpty(name)) { |
| | | dataMap.put("sendEmailFileName", name.replaceAll(" ", "_")); |
| | | } else { |
| | | dataMap.put("sendEmailFileName", tExamReport.getMemberName().replaceAll(" ", "_")); |
| | | } |
| | | |
| | | |
| | | // 测试人员邮箱 |
| | | dataMap.put("testEmail", tExamReport.getMemberEmail()); |
| | | |
| | | |
| | | // 测试开始和结束时间 |
| | | dataMap.put("beginTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, tExamReport.getCreateTime())); |
| | | dataMap.put("endTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, entTestMember.getEndTime())); |
| | | |
| | | RelatedParty relatedParty = memberService.queryProdidByToken(tExamReport.getTokenId()); |
| | | |
| | | |
| | | // 数字表头那里用 |
| | | dataMap.put("Phone", relatedParty.getMemberPhone()); |
| | | dataMap.put("Department", relatedParty.getMemberDept()); |
| | | dataMap.put("AccessCode", tExamReport.getTokenId()); |
| | | dataMap.put("Position", relatedParty.getPosition()); |
| | | dataMap.put("Occupation Category", relatedParty.getProfessionalCategory()); |
| | | dataMap.put("Superior Position", relatedParty.getSuperiorPosition()); |
| | | |
| | | |
| | | // 把null弄掉 |
| | | Set dataKeySet = dataMap.keySet(); |
| | | for (Object dataKey : dataKeySet) { |
| | | if (Objects.isNull(dataMap.get(dataKey))) { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void setPExtro(Map dataMap, List<ReportAPIResult> interfaceContentList) { |
| | | if (CollUtil.isEmpty(interfaceContentList)) { |
| | | return; |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public String getDemographicName(TExamReport tExamReport) { |
| | | EntDemographyInfo entDemographyInfo = new EntDemographyInfo(); |
| | |
| | | if (ExamUtil.isListEmpty(entDemographyInfos)) { |
| | | return ""; |
| | | } |
| | | |
| | | // 人口学的key |
| | | Map<String, String> entDemographyMap = entDemographyInfos.stream().collect( |
| | | Collectors.toMap(EntDemographyInfo::getParamId, EntDemographyInfo::getParamValue)); |
| | | |
| | | |
| | | //企业的那个参数 |
| | | String paramIds = entDemographyInfos.stream().map(it -> { |
| | | return it.getParamId(); |
| | | }).collect(Collectors.joining(",")); |
| | | |
| | | List<EntDemographyParam> entDemographyParams = entDemographyParamService.selectEntDemographyParamListByParamIn(paramIds); |
| | | for (EntDemographyParam entDemographyParam : entDemographyParams) { |
| | | if (Objects.equals(entDemographyParam.getParamCode(), "name")) { |
| | | return entDemographyMap.get(entDemographyParam.getParamId().toString()); |
| | | } |
| | | } |
| | | |
| | | return ""; |
| | | } |
| | | |
| | | public ReportResultData getMAQReportData(String langType, ReportTypeEnum reportTypeEnum, Map.Entry<String, Map<String, String>> entry, TExamReport tExamReport) { |
| | | MAQReport report = new MAQReport(); |
| | | report.setQuestionnaireTaker(entry.getKey()); |
| | |
| | | ReportResultData resultData = report.getTemplateParameters(entry.getValue(), reportTypeEnum, LangTypeEnum.codeOf(langType)); |
| | | return resultData; |
| | | } |
| | | |
| | | public ReportResultData getJAQReportData(Map textMap) { |
| | | ReportResultData reportResultData = new ReportResultData(); |
| | | reportResultData.setTextMap(textMap); |
| | | return reportResultData; |
| | | } |
| | | |
| | | public ReportResultData getSAQReportData(String langType, ReportTypeEnum reportTypeEnum, Map.Entry<String, Map<String, String>> entry, TExamReport tExamReport) { |
| | | SAQReport report = new SAQReport(); |
| | | report.setQuestionnaireTaker(entry.getKey()); |
| | |
| | | ReportResultData resultData = report.getTemplateParameters(entry.getValue(), reportTypeEnum, LangTypeEnum.codeOf(langType)); |
| | | return resultData; |
| | | } |
| | | |
| | | public ReportResultData getCAQReportData(String langType, Map.Entry<String, Map<String, String>> entry, TExamReport tExamReport) { |
| | | ReportResultData resultData = null; |
| | | CAQReport report = new CAQReport(); |
| | |
| | | resultData.setTextMap(templateParameterMap); |
| | | return resultData; |
| | | } |
| | | |
| | | public ReportResultData getRuilinReportData(String langType, Map.Entry<String, Map<String, String>> entry, TExamReport tExamReport) { |
| | | ReportResultData resultData; |
| | | RuilinMAQReport report = new RuilinMAQReport(); |
| | |
| | | resultData.setTextMap(templateParameterMap); |
| | | return resultData; |
| | | } |
| | | |
| | | private void setIconPicture(ReportResultData reportResultData, Map<String, Object> textMap) { |
| | | Map<String, String> iconMap = reportResultData.getIconMap(); |
| | | if (Objects.isNull(iconMap) || iconMap.isEmpty()) { |
| | | return; |
| | | } |
| | | |
| | | for (Map.Entry<String, String> entry : iconMap.entrySet()) { |
| | | WordParam wordParam = new WordParam(); |
| | | wordParam.setContent(EssConfig.getUploadPath() + entry.getValue()); |
| | |
| | | textMap.put(entry.getKey(), wordParam); |
| | | } |
| | | } |
| | | |
| | | public void setTextMap(TExamReport tExamReport, ReportResultData reportResultData, Map<String, Object> textMap) { |
| | | textMap.putAll(reportResultData.getTextMap()); |
| | | textMap.put("reportId", tExamReport.getId().toString()); |
| | | } |
| | | |
| | | private void setWaterDropPicture(ReportResultData reportResultData, List<String> deleteStrList, Map<String, Object> textMap, TExamReport tExamReport) { |
| | | |
| | | // 第二个图片 |
| | | if (Objects.isNull(reportResultData.getImageMap())) { |
| | | return; |
| | | } |
| | | |
| | | Map<String, String> pictureMap = reportResultData.getImageMap(); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // // begin 调试的临时代码 |
| | | // pictureMap.put("Flexibility_1_waterDrops", "100"); |
| | | // pictureMap.put("Creativity_2_waterDrops", "0"); |
| | | // pictureMap.put("ResponseFidelityDiagnosis_waterDrops1", "100"); |
| | | // pictureMap.put("ResponseFidelityDiagnosis_waterDrops2", "0"); |
| | | // System.out.println("--ResponseFidelityDiagnosis_waterDrops1--" + pictureMap.get("ResponseFidelityDiagnosis_waterDrops1")); |
| | | // // end 调试的临时代码 |
| | | for (Map.Entry<String, String> entry : pictureMap.entrySet()) { |
| | | |
| | | setWaterDropCreatePic(textMap, entry, deleteStrList, tExamReport.getId().toString()); |
| | | // setWaterDrop(textMap, entry, deleteStrList); |
| | | setWaterDropCreatePic(textMap, entry, deleteStrList, tExamReport.getId().toString()); // 生成图片的方式 |
| | | } |
| | | } |
| | | |
| | | |
| | | // 设置水滴 |
| | | private void setWaterDrop(Map<String, Object> textMap, Map.Entry<String, String> entry, List<String> deleteStrList) { |
| | | |
| | | String[] strValue = entry.getValue().toString().split("\\."); |
| | | BufferedImage bufferedImage = saveNumberPicture(strValue[0]); |
| | | |
| | | |
| | | // 得到图片地址 |
| | | String path = getUploadPicturePath(entry.getKey()+ "_number.png"); |
| | | |
| | | try { |
| | | File file = new File(path); |
| | | ImageIO.write(bufferedImage, "png", file); |
| | | ImageIO.write(bufferedImage, "png", file);//写入文件 |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | deleteStrList.add(path); |
| | | double retreat = 465; |
| | | |
| | | |
| | | |
| | | // double posistionValue = Double.valueOf(entry.getValue()) * 5 - retreat; |
| | | // 水滴的数字图片 |
| | | double posistionValue = (Double.valueOf(entry.getValue()) / 100) * retreat; |
| | | double offsetNumX = -3; |
| | | double offsetNumY = 2; |
| | | WordParam wordParamWaterDorpNumber = new WordParam(posistionValue > 0 ? posistionValue + offsetNumX : offsetNumX, offsetNumY, 20, 20, path); |
| | | wordParamWaterDorpNumber.setTopPosition(1); |
| | | textMap.put(entry.getKey()+ "_number", wordParamWaterDorpNumber); |
| | | |
| | | WordParam wordParam = new WordParam(); |
| | | wordParam.setX(posistionValue > 0 ? posistionValue : 0); |
| | | |
| | | String[] watherDropPictrues = entry.getKey().split("_"); |
| | | |
| | | |
| | | // 不同颜色的水滴 |
| | | wordParam.setContent(WordUtil.getTemplatePicture(ExamUtil.getWaterDropPictureMap(watherDropPictrues[0]))); |
| | | |
| | | |
| | | // 水滴放大一倍 |
| | | wordParam.setPicWidth(15); |
| | | wordParam.setPicHeight(25); |
| | | textMap.put(entry.getKey(), wordParam); |
| | | } |
| | | |
| | | |
| | | // 设置水滴 |
| | | private void setWaterDropCreatePic(Map<String, Object> textMap, Map.Entry<String, String> entry, List<String> deleteStrList, String id) { |
| | | |
| | | String[] strValue = entry.getValue().toString().split("\\."); |
| | | String key = entry.getKey(); |
| | | |
| | | String[] waterDropPicture = key.split("_"); |
| | | |
| | | |
| | | // 取前缀或者全名 |
| | | String waterDropName =StringUtils.isNotEmpty(ExamUtil.getWaterDropPictureMap(waterDropPicture[0])) ? ExamUtil.getWaterDropPictureMap(waterDropPicture[0]) : ExamUtil.getWaterDropPictureMap(key); |
| | | |
| | | if (StringUtils.isEmpty(waterDropName)) { |
| | | return; |
| | | } |
| | | |
| | | WordParam wordParam = new WordParam(); |
| | | |
| | | Float floatValue = Float.valueOf(strValue[0]); |
| | | |
| | | String suffixDate = DateTimeUtil.dateMillisecondFormat(new Date()); |
| | | |
| | | ImageUtil.creteWaterDropPic(key, waterDropName, floatValue, id, suffixDate); |
| | | |
| | | |
| | | // 因为是同一个目录,用后缀区一下图片 |
| | | wordParam.setContent(EssConfig.getProfile() + "/" + key + "_" + id + "_" + floatValue.toString() + "_" + suffixDate + ".png"); |
| | | |
| | | deleteStrList.add(EssConfig.getProfile() + "/" + key + "_" + id + "_" + floatValue.toString() + "_" + suffixDate + ".png"); |
| | | |
| | | |
| | | // 水滴放大一倍 |
| | | if (StringUtils.equals(key.split("_")[0], "ResponseFidelityDiagnosis")) { |
| | | wordParam.setPicWidth(446); |
| | | wordParam.setPicHeight(33); |
| | | wordParam.setPicHeight(33); // 现在用500/888 其实是445/888 |
| | | } else if (StringUtils.equals(key.split("_")[0], "RuilinTestResultValidityDiagnosisContext")) { |
| | | wordParam.setPicWidth(450); |
| | | wordParam.setPicHeight(35); |
| | |
| | | wordParam.setPicHeight(35); |
| | | wordParam.setX(-13.75); |
| | | } |
| | | |
| | | textMap.put(entry.getKey(), wordParam); |
| | | |
| | | } |
| | | |
| | | private BufferedImage saveNumberPicture(String textNumber) { |
| | | int width = 200; |
| | | int heigth = 150; |
| | | Font font = new Font("", Font.BOLD, 60); |
| | | Font font = new Font("", Font.BOLD, 60);//字体 |
| | | return ImageUtil.waterMarkByText(width, heigth, textNumber, Color.black, font, null, |
| | | 0.8f); |
| | | } |
| | | |
| | | |
| | | // 统一路径 |
| | | private String getUploadPicturePath(String name) { |
| | | return EssConfig.getUploadPath() + name; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public boolean getBaseAndComleteSendMailFile(List<TExamReport> tExamReportList, TExamReport tExamReportResult, List<String> fileNameResult, List<String> deleteStrList, TReportTemplate tReportTemplate) { |
| | | try { |
| | | List<String> fileNameList = new ArrayList<>(); |
| | | |
| | | // setExportBaseOrDetailReportData(tExamReportList, deleteStrList, fileNameList, path, tReportTemplate, tReportTemplate.getLangType(), reportType, reportTypeEnumMap.get(tReportTemplate.getTemplateType())); |
| | | setExportBaseOrDetailReportData(tExamReportList, deleteStrList, fileNameList, tReportTemplate); |
| | | |
| | | for (String fileNameTemp : fileNameList) { |
| | | if (StringUtils.isEmpty(fileNameTemp)) { |
| | | continue; |
| | |
| | | } catch (Exception e) { |
| | | return false; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | // 生成报告的入口 |
| | | @Override |
| | | public TExamReport getReportFromTemplate(TExamReport tExamReport, List<String> fileNameResult, List<String> deleteStrList) { |
| | | List<TExamReport> tExamReportList = selectTExamReportList(tExamReport); |
| | | TExamReport tExamReportResult = tExamReportList.get(0); |
| | | |
| | | |
| | | // 超时 |
| | | if (Objects.isNull(tExamReportResult.getFinish()) || tExamReportResult.getFinish() == 0) { |
| | | return null; |
| | | } |
| | | |
| | | |
| | | // 导出基础版本 |
| | | List<TReportTemplate> tReportTemplateList = itReportTemplateService.selectTReportTemplates(tExamReportResult.getReportTemplateId()); |
| | | for (TReportTemplate tReportTemplate : tReportTemplateList) { |
| | | |
| | | |
| | | |
| | | // 判断不是语言的模版不导出,后来又说要导出 |
| | | // if (!Objects.equals(tReportTemplate.getLangType(), tExamReportResult.getLangType())) { |
| | | // continue; |
| | | // } |
| | | |
| | | getBaseAndComleteSendMailFile(tExamReportList, tExamReportResult, fileNameResult, deleteStrList, tReportTemplate); |
| | | } |
| | | return tExamReportResult; |
| | | } |
| | | |
| | | } |