FoundationfinancialInfoRender.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //package com.yaoyicloud.render.foundation;
  2. //
  3. //import java.io.IOException;
  4. //import java.io.InputStream;
  5. //import java.util.ArrayList;
  6. //import java.util.Arrays;
  7. //import java.util.List;
  8. //import java.util.Map;
  9. //
  10. //import com.deepoove.poi.config.Configure;
  11. //import com.deepoove.poi.config.ConfigureBuilder;
  12. //import com.fasterxml.jackson.core.type.TypeReference;
  13. //import com.fasterxml.jackson.databind.ObjectMapper;
  14. //import com.google.protobuf.util.JsonFormat;
  15. //import com.yaoyicloud.config.CommonDataCache;
  16. //import com.yaoyicloud.config.FilerepoProperties;
  17. //import com.yaoyicloud.message.FxyProtos;
  18. //import com.yaoyicloud.factory.FXYAbstractRender;
  19. //
  20. //import lombok.extern.slf4j.Slf4j;
  21. //import org.apache.commons.collections4.CollectionUtils;
  22. //import org.apache.commons.collections4.MapUtils;
  23. //
  24. //
  25. ///**
  26. // * FinancialInfo渲染器
  27. // *
  28. // */
  29. //@Slf4j
  30. //public final class FoundationfinancialInfoRender extends FXYAbstractRender {
  31. // private final FilerepoProperties filerepoProperties;
  32. // private final CommonDataCache commonDataCache;
  33. // public FoundationfinancialInfoRender(String cwd, FilerepoProperties filerepoProperties, CommonDataCache commonDataCache) {
  34. // super(cwd);
  35. // this.filerepoProperties = filerepoProperties;
  36. // this.commonDataCache = commonDataCache;
  37. // }
  38. // @Override
  39. // protected String getBasicPath() throws IOException {
  40. // return filerepoProperties.getBasePath();
  41. // }
  42. //
  43. // @Override
  44. // protected String getReportImagePath() {
  45. // return filerepoProperties.getReportImagePath();
  46. // }
  47. //
  48. // /**
  49. // * Docx 渲染
  50. // *
  51. // * @param info 数据
  52. // * @param inputStream 模板内容
  53. // * @return 本地文件目录
  54. // * @throws IOException
  55. // */
  56. //
  57. // public String renderDocx(String info, InputStream inputStream, String relationId) throws IOException {
  58. // log.info("开始渲染基金会财务模块,relationId: {}", relationId);
  59. //
  60. // // 配置POI-TL渲染器
  61. // ConfigureBuilder builder = Configure.builder();
  62. // builder.useSpringEL();
  63. //
  64. // builder.bind("indicators", new LoopRowIncludeStatisticsTableRenderPolicy("values"));
  65. // builder.bind("financialDataSeq", new LoopColumnStaticTableRenderPolicy("[", "]", false, true, 2));
  66. // builder.bind("financialCheckDetails", new LoopRowCutAndMergeFirstColTableRenderPolicy());
  67. // FxyProtos.FinancialInfo.Builder basicInfoBuilder = FxyProtos.FinancialInfo.newBuilder();
  68. // JsonFormat.parser().merge(info, basicInfoBuilder);
  69. //
  70. // FxyProtos.FinancialInfo defaultInstance = FxyProtos.FinancialInfo.getDefaultInstance();
  71. // FxyProtos.FinancialInfo mergedProto = defaultInstance.toBuilder()
  72. // .mergeFrom(basicInfoBuilder.build())
  73. // .build();
  74. //
  75. // String completeJson = JsonFormat.printer()
  76. // .includingDefaultValueFields()
  77. // .print(mergedProto);
  78. // ObjectMapper objectMapper = new ObjectMapper();
  79. // Map<String, Object> data = objectMapper.readValue(completeJson, new TypeReference<Map<String, Object>>() {});
  80. // data.replaceAll((k, v) -> v.equals("") ? "-" : v);
  81. //
  82. // fillBasicDefaultValues(data);
  83. // Map<String, Object> commonDataCacheData = commonDataCache.getData(relationId);
  84. // if (MapUtils.isNotEmpty(commonDataCacheData)) {
  85. // data.putAll(commonDataCacheData);
  86. // }
  87. // try {
  88. // // 渲染文档
  89. // String resultPath = this.renderDocx(data, inputStream, builder, relationId, "financialInfo");
  90. // log.info("渲染基金会财务模块成功,文件路径: {}", resultPath);
  91. // return resultPath;
  92. // } catch (Exception e) {
  93. // log.error("渲染基金会财务模块失败,relationId: {}", relationId, e);
  94. // throw new IOException("文档渲染失败", e);
  95. // }
  96. // }
  97. //
  98. // /**
  99. // * 填充默认值,确保所有必要字段都存在
  100. // */
  101. // private void fillBasicDefaultValues(Map<String, Object> data) {
  102. // Map<String, Object> basicInfoSummary = (Map<String, Object>) data.get("financialSummary");
  103. // basicInfoSummary.replaceAll((k, v) -> v.equals("") ? "-" : v);
  104. //
  105. // List<Map<String, Object>> financialDataSeq = (List<Map<String, Object>>) data.get("financialDataSeq");
  106. // for (Map<String, Object> stringObjectMap : financialDataSeq) {
  107. // stringObjectMap.replaceAll((k, v) -> v.equals("") ? "-" : v);
  108. // }
  109. //
  110. // List<Map<String, Object>> indicators = (List<Map<String, Object>>) data.get("indicators");
  111. // for (Map<String, Object> indicator : indicators) {
  112. // ArrayList<String> strings = (ArrayList<String>) indicator.get("values");
  113. // if (CollectionUtils.isEmpty(strings)) {
  114. // indicator.put("values", Arrays.asList("-", "-", "-"));
  115. //
  116. // }
  117. // }
  118. // }
  119. //
  120. //
  121. //
  122. //}