ReportExportService.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. package cn.cslg.pas.service;
  2. import cn.cslg.pas.common.dto.PatentColumnDTO;
  3. import cn.cslg.pas.common.dto.PatentDTO;
  4. import cn.cslg.pas.common.dto.PatentDetailDTO;
  5. import cn.cslg.pas.common.dto.es.EsCustomFieldDTO;
  6. import cn.cslg.pas.common.dto.es.EsCustomFieldValueDTO;
  7. import cn.cslg.pas.common.model.SystemMO;
  8. import cn.cslg.pas.common.model.cronModel.PersonnelVO;
  9. import cn.cslg.pas.common.model.request.StringRequest;
  10. import cn.cslg.pas.common.utils.*;
  11. import cn.cslg.pas.common.vo.*;
  12. import cn.cslg.pas.common.vo.business.AllCustomFieldVO;
  13. import cn.cslg.pas.common.vo.business.PatentNoVO;
  14. import cn.cslg.pas.domain.ReportDocument;
  15. import cn.cslg.pas.domain.business.*;
  16. import cn.cslg.pas.domain.es.Text;
  17. import cn.cslg.pas.exception.XiaoShiException;
  18. import cn.cslg.pas.mapper.AvoidDesignMapper;
  19. import cn.cslg.pas.service.business.*;
  20. import cn.cslg.pas.service.business.es.EsFamilyService;
  21. import cn.cslg.pas.service.business.es.EsPatentService;
  22. import cn.cslg.pas.service.business.es.EsQuotePatentService;
  23. import cn.cslg.pas.service.business.es.EsService;
  24. import cn.cslg.pas.service.common.FileManagerService;
  25. import cn.hutool.core.util.IdUtil;
  26. import com.alibaba.fastjson.JSON;
  27. import com.alibaba.fastjson.JSONObject;
  28. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  29. import com.deepoove.poi.XWPFTemplate;
  30. import com.deepoove.poi.config.Configure;
  31. import com.deepoove.poi.data.PictureRenderData;
  32. import com.deepoove.poi.data.PictureType;
  33. import com.deepoove.poi.data.Pictures;
  34. import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
  35. import lombok.extern.slf4j.Slf4j;
  36. import org.apache.commons.lang3.StringUtils;
  37. import org.apache.poi.ss.usermodel.PictureData;
  38. import org.ddr.poi.html.HtmlRenderPolicy;
  39. import org.joda.time.format.FormatUtils;
  40. import org.springframework.beans.factory.annotation.Autowired;
  41. import org.springframework.stereotype.Service;
  42. import java.io.File;
  43. import java.io.FileInputStream;
  44. import java.io.IOException;
  45. import java.util.*;
  46. import java.util.stream.Collectors;
  47. @Slf4j
  48. @Service
  49. public class ReportExportService {
  50. @Autowired
  51. private TempleService templeService;
  52. @Autowired
  53. private FileUtils fileUtils;
  54. @Autowired
  55. private ReportProjectService reportProjectService;
  56. @Autowired
  57. private FileManagerService fileManagerService;
  58. @Autowired
  59. private EsPatentService esPatentService;
  60. @Autowired
  61. private AvoidDesignMapper avoidDesignMapper;
  62. @Autowired
  63. private TemplateConfigService templateConfigService;
  64. @Autowired
  65. private CustomFieldService customFieldService;
  66. @Autowired
  67. private EsService esService;
  68. @Autowired
  69. private FTOCompareRecordService ftoCompareRecordService;
  70. @Autowired
  71. private EsQuotePatentService esQuotePatentService;
  72. @Autowired
  73. private EsFamilyService esFamilyService;
  74. @Autowired
  75. private LoginUtils loginUtils;
  76. @Autowired
  77. private CacheUtils cacheUtils;
  78. /**
  79. * @param projectId
  80. * @param templeId
  81. * @return
  82. * @throws IOException
  83. * @function: 导出报告
  84. */
  85. public String exportReport(Integer projectId, Integer templeId) throws IOException {
  86. //根据模板ID获得模板
  87. ReportTemple reportTemplate = templeService.getById(templeId);
  88. //获得模板路径
  89. String templateFilePath = fileUtils.getPath(reportTemplate.getTemplatePath());
  90. //读取模板后保存生成word的地址
  91. String fileName = IdUtil.simpleUUID() + ".docx";
  92. String directoryName = fileUtils.createDirectory();
  93. String outPath = fileUtils.getSavePath(directoryName) + fileName;
  94. //根据ProjectId 获得报告
  95. LambdaQueryWrapper<ReportProject> queryWrapper = new LambdaQueryWrapper<>();
  96. queryWrapper.eq(ReportProject::getProjectId, projectId);
  97. ReportProject report = reportProjectService.getOne(queryWrapper, false);
  98. if (report == null) {
  99. throw new XiaoShiException("报告不存在");
  100. }
  101. XWPFTemplate template = null;
  102. template = this.avoidDesignTemplate(projectId);
  103. if (report.getReportType() == 0 || report.getReportType() == 2) {
  104. // template = this.getstabilityTemplate(report, filePath);
  105. } else if (report.getReportType() == 3) {
  106. template = this.FTOTemplate(projectId, templateFilePath, templeId);
  107. } else if (report.getReportType() == 4) {
  108. // template = this.Torttemplate(reportId, filePath, templeId);
  109. } else if (report.getReportType() == 5) {
  110. // template = this.avoidDesignTemplate(reportId, filePath);
  111. } else if (report.getReportType() == 1) {
  112. // template = this.getThirdTemplate(report, filePath);
  113. }
  114. // 读取模板、数据并渲染
  115. // 文件是否已存在,则删除
  116. File file = new File(outPath);
  117. // 生成word保存在指定目录
  118. template.writeToFile(outPath);
  119. template.close();
  120. //导出成功后,导出报告记录入库
  121. List<String> ids = fileManagerService.uploadFileGetGuid2(Arrays.asList(file));
  122. if (ids == null || ids.size() == 0) {
  123. throw new XiaoShiException("保存记录失败");
  124. }
  125. // PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
  126. PersonnelVO personnelVO =new PersonnelVO();
  127. personnelVO.setId("1");
  128. ReportDocument reportDocument = new ReportDocument();
  129. reportDocument.setProjectId(projectId);
  130. reportDocument.setFileName(fileName);
  131. reportDocument.setFileGuid(ids.get(0));
  132. reportDocument.setCreateId(personnelVO.getId());
  133. reportDocument.setTemplateId(reportTemplate.getId());
  134. reportDocument.setTemplateName(reportTemplate.getTemplateName());
  135. reportDocument.insert();
  136. if (file.exists()) {
  137. file.delete();
  138. }
  139. return "";
  140. }
  141. // private XWPFTemplate Torttemplate(Integer reportId, String filePath, Integer templateId) throws IOException {
  142. // //根据报告Id查询标的专利号
  143. // ReportProject report = reportProjectService.getById(reportId);
  144. // String patentNo = report.getSignPatentNo();
  145. //// PatentVO patentVO = new PatentVO();
  146. //// patentVO.setPatentNos(Arrays.asList(patentNo));
  147. //// //根据专利号查询专利详细信息
  148. //// String resBody = outInterfaceService.getPatentDTOListForRMS(patentVO);
  149. //// JSONObject jsonObject = JSONObject.parseObject(resBody);
  150. //// List<JSONObject> patentDTOS = JSON.parseArray(jsonObject.get("data").toString(), JSONObject.class);
  151. //// //装载单个专利的信息
  152. // Map<String, Object> patentMap = new HashMap<>();
  153. //// JSONObject patent = patentDTOS.get(0);
  154. //// List<JSONObject> applicantJSONs = JSON.parseArray(patent.get("applicant").toString(), JSONObject.class);
  155. //// StringBuilder applicants = new StringBuilder();
  156. //// StringBuilder rightPerson = new StringBuilder();
  157. //// applicantJSONs.forEach(tem -> {
  158. //// if (Integer.parseInt(tem.get("dataType").toString()) == 1) {
  159. //// applicants.append(tem.get("name") + "\r");
  160. //// } else {
  161. //// rightPerson.append(tem.get("name") + "\r");
  162. //// }
  163. //// });
  164. //// //装载同族信息
  165. //// JSONObject familys = JSONObject.parseObject(patent.get("family").toString());
  166. //// List<String> patSnaps = JSON.parseArray(familys.get("patSnap").toString(), String.class);
  167. //// List<String> simples = JSON.parseArray(familys.get("simple").toString(), String.class);
  168. //// List<String> inpadocs = JSON.parseArray(familys.get("inpadoc").toString(), String.class);
  169. //// patSnaps.addAll(simples);
  170. //// patSnaps.addAll(inpadocs);
  171. //// String familyStr = StringUtils.join(patSnaps, ",");
  172. //// //装载法律状态
  173. //// StringBuilder affair = new StringBuilder();
  174. //// List<JSONObject> affaires = JSON.parseArray(patent.get("affair").toString(), JSONObject.class);
  175. //// affaires.forEach(item -> {
  176. //// affair.append(item.get("status") + "\r");
  177. //// }
  178. //// );
  179. //// //同族专利
  180. //// patentMap.put("simpleFamilys", familyStr);
  181. //// //引用专利
  182. //// patentMap.put("quotePatents", patent.get("quote"));
  183. //// //申请日
  184. //// patentMap.put("applicationDate", patent.get("applicationDate"));
  185. //// //公开日
  186. //// patentMap.put("publicDate", patent.get("publicDate"));
  187. //// //专利号
  188. //// patentMap.put("publicNo", patent.get("publicNo"));
  189. //// patentMap.put("firstPublicDate", patent.get("firstPublicDate"));
  190. //// patentMap.put("applicant", applicants);
  191. //// patentMap.put("rightPerson", rightPerson);
  192. //// patentMap.put("affair", affair);
  193. //// patentMap.put("name", patent.get("name"));
  194. // //图示
  195. // patentMap.put("abstractPath", "");
  196. // //获得专利对比记录的信息
  197. //// Map<String, Object> temMap = compareMessageService.queryforTemplate(patent.get("patentNo").toString(), reportId);
  198. //// List<CompareMessageVO> compareMessageVOS = (List<CompareMessageVO>) temMap.get("compareMessageVOs");
  199. // //装载对比记录的信息
  200. //// patentMap.put("cM", compareMessageVOS);
  201. //// patentMap.put("rightNum", temMap.get("right"));
  202. //// patentMap.put("mainRightNum", temMap.get("mainRight"));
  203. // Map<String, Object> map = new HashMap<>();
  204. // String date = DateUtils.formatDate(new Date(), DateUtils.YYYY_MM_DD);
  205. // String[] ds = date.split("-");
  206. // map.put("sys", new SystemMO(ds[0], ds[1], ds[2], "", "reportName"));
  207. // map.put("patentMap", patentMap);
  208. // map.put("", patentNo);
  209. // // 为表格的显示绑定行循环
  210. // LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
  211. // HtmlRenderPolicy htmlRenderPolicy = new HtmlRenderPolicy();
  212. // // 将bz设置为行循环绑定的数据源的key,即key是bz的value会在模板中的{{bz}}处进行解析
  213. // Configure configure = Configure.builder().bind("cM", policy).bind("targetDescription", htmlRenderPolicy).build();
  214. // XWPFTemplate template = XWPFTemplate.compile(filePath, configure).render(map);
  215. // return template;
  216. // }
  217. private XWPFTemplate avoidDesignTemplate(Integer projectId) throws IOException {
  218. String filePath = fileUtils.getPath("/11.docx");
  219. log.info("开始处理导出规避设计报告,参数为:{}, {}", projectId, filePath);
  220. LambdaQueryWrapper<ReportProject> queryWrapper = new LambdaQueryWrapper<>();
  221. queryWrapper.eq(ReportProject::getProjectId, projectId);
  222. ReportProject report = reportProjectService.getOne(queryWrapper, false);
  223. String signPatentNo = report.getSignPatentNo();
  224. //装载标的专利信息
  225. Map<String, Object> signPatent = this.signPatentMess(report.getSignPatentNo());
  226. System.out.println(signPatent.get(""));
  227. Map<String, Object> map = new HashMap<>();
  228. //装载标的专利信息
  229. map.put("signPatent", signPatent);
  230. map.put("rights", signPatent.get("rights"));
  231. //装载公开/公告号
  232. map.put("patentNo", signPatentNo);
  233. //装载年月日
  234. String date = DateUtils.formatDate(new Date(), DateUtils.YYYY_MM_DD);
  235. String[] dates = date.split("-");
  236. SystemMO systemMO = new SystemMO()
  237. .setYear(dates[0])
  238. .setMonth(dates[1])
  239. .setDay(dates[2]);
  240. map.put("sys", systemMO);
  241. //
  242. //装载特征、解释、回避设计方向、回避设计总体方向
  243. List<AvoidFeaturesVO> features = avoidDesignMapper.selectAvoidDesign(projectId);
  244. // String wholeDirection = avoidDesignWholeDirectionMapper.selectWholeDirectionByReportId(reportId);
  245. map.put("features", features);
  246. // map.put("wholeDirection", wholeDirection);
  247. //
  248. //绑定政策(绑定集合和元素循环遍历)
  249. LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
  250. //把指定元素内容识别传输成html格式
  251. HtmlRenderPolicy htmlRenderPolicy = new HtmlRenderPolicy();
  252. Configure configure = Configure.builder()
  253. .bind("signPatent.rights", policy)
  254. .bind("features", policy)
  255. .bind("explainText", htmlRenderPolicy)
  256. .bind("littleDirection", htmlRenderPolicy)
  257. .bind("wholeDirection", htmlRenderPolicy)
  258. .build();
  259. XWPFTemplate template = XWPFTemplate.compile(filePath, configure).render(map);
  260. return template;
  261. }
  262. public Map<String, Object> signPatentMess(String patentNo) throws IOException {
  263. // PatentNoVO patentVO = new PatentNoVO();
  264. // patentVO.setPatentNo(patentNo);
  265. // //根据专利号查询专利详细信息
  266. // PatentDetailDTO patentDetailDTO = esPatentService.selectPatentDetail(patentVO);
  267. // //装载单个专利的信息
  268. Map<String, Object> patentMap = new HashMap<>();
  269. // StringBuilder applicants = new StringBuilder();
  270. // StringBuilder rightPerson = new StringBuilder();
  271. //
  272. // //申请日
  273. // patentMap.put("applicationDate", patentDetailDTO.getAppDate());
  274. //
  275. // //公开日
  276. // patentMap.put("publicDate", patentDetailDTO.getPublicDate());
  277. // //公开号
  278. // patentMap.put("publicNo", patentDetailDTO.getPublicNo());
  279. // //专利号
  280. // patentMap.put("patentNo", patentDetailDTO.getPatentNo());
  281. // //专利权人
  282. // patentMap.put("rightPerson", rightPerson);
  283. // //图示
  284. // String guid = FormatUtil.getPictureFormat(patentDetailDTO.getAppNo());
  285. // PictureRenderData pictureData = this.guidToStream(guid);
  286. // if (pictureData != null) {
  287. // patentMap.put("abstractPath", pictureData);
  288. // }
  289. // //获得标题
  290. // if (patentDetailDTO.getTitle() != null && patentDetailDTO.getTitle().size() > 0) {
  291. // Text title = patentDetailDTO.getTitle().stream()
  292. // .filter(item -> item.getIfOrigin().equals(true)).findFirst().orElse(null);
  293. // if (title != null) {
  294. // patentMap.put("name", title.getTextContent());
  295. // }
  296. // }
  297. //
  298. // //获得权要
  299. // List<Map<String, Object>> rights= this.getClaimMaps(patentDetailDTO.getClaim(),patentDetailDTO.getPatentNo());
  300. //
  301. // patentMap.put("rights", rights);
  302. return patentMap;
  303. }
  304. private PictureRenderData guidToStream(String guid) {
  305. PictureRenderData pictureRenderData = null;
  306. byte[] bytes = null;
  307. if (bytes != null) {
  308. try {
  309. bytes = fileManagerService.downloadSystemFileFromFMS(guid);
  310. } catch (Exception e) {
  311. }
  312. }
  313. FileInputStream fileInputStream = FileUtils.byteToFile(bytes);
  314. pictureRenderData = Pictures.ofStream(fileInputStream, PictureType.PNG)
  315. .create();
  316. return pictureRenderData;
  317. }
  318. private List<Map<String, Object>> getClaimMaps(List<Text> claims, String patentNo) {
  319. List<Map<String, Object>> rights = new ArrayList<>();
  320. if (claims == null || claims.size() == 0) {
  321. return rights;
  322. }
  323. Text claim = claims.stream().filter(item -> item.getIfOrigin().equals(true)).findFirst().orElse(null);
  324. if (claim == null) {
  325. return rights;
  326. }
  327. PatentRightParams params = new PatentRightParams();
  328. params.setContent(claim.getTextContent());
  329. params.setPatentNo(patentNo);
  330. List<RePatentClaim> patentRights = PatentRightUtils.formatPatentRight(params);
  331. //给权要进行格式更改
  332. patentRights.forEach(item -> {
  333. Map<String, Object> temMap = new HashMap<>();
  334. temMap.put("rightName", "权" + (item.getSort() + 1));
  335. temMap.put("content", item.getContent());
  336. temMap.put("rightNameLong", "权利要求" + (item.getSort() + 1));
  337. temMap.put("parentSort", item.getParentSort());
  338. temMap.put("sort", item.getSort());
  339. rights.add(temMap);
  340. });
  341. return rights;
  342. }
  343. /**
  344. * @param projectId
  345. * @param filePath
  346. * @return
  347. * @description 装载FTO模板
  348. */
  349. private XWPFTemplate FTOTemplate(Integer projectId, String filePath, Integer templateId) throws IOException {
  350. //获得模板的配置信息
  351. LambdaQueryWrapper<TemplateConfig> templateConfigWrapper = new LambdaQueryWrapper<TemplateConfig>();
  352. templateConfigWrapper.eq(TemplateConfig::getTemplateId, templateId);
  353. List<TemplateConfig> templateConfigs = templateConfigService.list(templateConfigWrapper);
  354. List<Map<String, Object>> classifyMaps = new ArrayList<>();
  355. for (TemplateConfig templateConfig : templateConfigs) {
  356. Map<String, Object> classifyMap = new HashMap<>();
  357. String value = templateConfig.getValueName();
  358. //根据value 查询专利
  359. List<EsCustomFieldValueDTO> esCustomFieldDTOS = customFieldService.getCustomFieldByValueName(value, projectId);
  360. if (esCustomFieldDTOS.size() != 0) {
  361. classifyMap.put("classify", templateConfig.getMapName());
  362. StringRequest stringRequest = new StringRequest();
  363. stringRequest.setCustomFields(esCustomFieldDTOS);
  364. stringRequest.setProjectId(projectId);
  365. List<PatentColumnDTO> patentColumnDTOS = new ArrayList<>();
  366. try {
  367. PatentDTO patentDTO = esService.esSearch(stringRequest);
  368. patentColumnDTOS = patentDTO.getPatents();
  369. } catch (Exception e) {
  370. return null;
  371. }
  372. //存放公告专利
  373. List<Map<String, Object>> announcePatents = new ArrayList<>();
  374. //存放公开专利
  375. List<Map<String, Object>> publicPatents = new ArrayList<>();
  376. //存放失效专利信息
  377. List<Map<String, Object>> lapsePatents = new ArrayList<>();
  378. for (PatentColumnDTO patent : patentColumnDTOS) {
  379. String applicants = "";
  380. StringBuilder rightPerson = new StringBuilder();
  381. if (patent.getApplicant() != null && patent.getApplicant().size() != 0) {
  382. applicants = StringUtils.join(patent.getApplicant(), "\r");
  383. }
  384. // //装载法律状态
  385. // StringBuilder affair = new StringBuilder();
  386. // List<JSONObject> affaires = JSON.parseArray(patent.get("affair").toString(), JSONObject.class);
  387. // affaires.forEach(item -> {
  388. // affair.append(item.get("status") + "\r");
  389. // }
  390. //
  391. // );
  392. //装载单个专利的信息
  393. Map<String, Object> patentMap = new HashMap<>();
  394. //同族专利
  395. try {
  396. //装载同族信息
  397. List<Map<String, Object>> familyMaps = esFamilyService.getPatentFamilyByNos(Arrays.asList(patent.getPatentNo()), "inpadoc");
  398. if (familyMaps != null && familyMaps.size() > 0) {
  399. Map<String, Object> familyMap = familyMaps.get(0);
  400. if (familyMap.get("nos") != null) {
  401. List<String> nos = (List<String>) familyMap.get("nos");
  402. if (nos != null && nos.size() > 0) {
  403. String nosStr = StringUtils.join(nos, "\r");
  404. patentMap.put("simpleFamilys", nosStr);
  405. }
  406. }
  407. }
  408. } catch (Exception e) {
  409. }
  410. //引用专利
  411. try {
  412. Map<String, Object> map = esQuotePatentService.getEsQutePatentByNos(patent.getPatentNo());
  413. if (map.get("nos") != null) {
  414. List<String> nos = (List<String>) map.get("nos");
  415. if (nos != null && nos.size() > 0) {
  416. String nosStr = StringUtils.join(nos, "\r");
  417. patentMap.put("quotePatents", nosStr);
  418. }
  419. }
  420. } catch (Exception e) {
  421. }
  422. //申请日
  423. patentMap.put("applicationDate", patent.getAppDate());
  424. //公开日
  425. patentMap.put("publicDate", patent.getPublicDate());
  426. //专利号
  427. patentMap.put("publicNo", patent.getPatentNo());
  428. patentMap.put("firstPublicDate", patent.getPublicDate());
  429. patentMap.put("applicant", applicants);
  430. patentMap.put("rightPerson", rightPerson);
  431. // patentMap.put("affair", affair);
  432. //优先权日
  433. if (patent.getPriorities() != null && patent.getPriorities().size() != 0) {
  434. patentMap.put("priorityDate", patent.getPriorities().get(0).getPriorityDate());
  435. }
  436. //图示
  437. String guid = FormatUtil.getPictureFormat(patent.getAppNo());
  438. PictureRenderData pictureData = this.guidToStream(guid);
  439. if (pictureData != null) {
  440. patentMap.put("abstractPath", pictureData);
  441. }
  442. //获得专利对比记录的信息
  443. Map<String, Object> temMap = ftoCompareRecordService.LoadCompareMessageForExport(projectId, patent.getPatentNo());
  444. List<CompareMessageVO> compareMessageVOS = (List<CompareMessageVO>) temMap.get("compareMessageVOs");
  445. //装载对比记录的信息
  446. patentMap.put("cM", compareMessageVOS);
  447. patentMap.put("rightNum", temMap.get("right"));
  448. patentMap.put("mainRightNum", temMap.get("mainRight"));
  449. Integer status = Integer.parseInt(patent.getSimpleStatus());
  450. if (status == 1 || status == 5 || status == 6) {
  451. announcePatents.add(patentMap);
  452. } else if (status == 2) {
  453. lapsePatents.add(patentMap);
  454. } else if (status == 3) {
  455. publicPatents.add(patentMap);
  456. }
  457. classifyMap.put("publicPatents", publicPatents);
  458. classifyMap.put("lapsePatents", lapsePatents);
  459. classifyMap.put("announcePatents", announcePatents);
  460. }
  461. classifyMaps.add(classifyMap);
  462. }
  463. }
  464. Map<String, Object> map = new HashMap<>();
  465. String date = DateUtils.formatDate(new Date(), DateUtils.YYYY_MM_DD);
  466. String[] ds = date.split("-");
  467. map.put("sys", new SystemMO(ds[0], ds[1], ds[2], "", "reportName"));
  468. map.put("classifys", classifyMaps);
  469. // 为表格的显示绑定行循环
  470. LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
  471. HtmlRenderPolicy htmlRenderPolicy = new HtmlRenderPolicy();
  472. // 将bz设置为行循环绑定的数据源的key,即key是bz的value会在模板中的{{bz}}处进行解析
  473. Configure configure = Configure.builder().bind("cM", policy).bind("targetDescription", htmlRenderPolicy).build();
  474. XWPFTemplate template = XWPFTemplate.compile(filePath, configure).render(map);
  475. return template;
  476. }
  477. }