123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- //package com.yaoyicloud.render.foundation;
- //
- //import java.io.IOException;
- //import java.io.InputStream;
- //import java.util.ArrayList;
- //import java.util.Arrays;
- //import java.util.List;
- //import java.util.Map;
- //
- //import com.deepoove.poi.config.Configure;
- //import com.deepoove.poi.config.ConfigureBuilder;
- //import com.fasterxml.jackson.core.type.TypeReference;
- //import com.fasterxml.jackson.databind.ObjectMapper;
- //import com.google.protobuf.util.JsonFormat;
- //import com.yaoyicloud.config.CommonDataCache;
- //import com.yaoyicloud.config.FilerepoProperties;
- //import com.yaoyicloud.message.FxyProtos;
- //import com.yaoyicloud.factory.FXYAbstractRender;
- //
- //import lombok.extern.slf4j.Slf4j;
- //import org.apache.commons.collections4.CollectionUtils;
- //import org.apache.commons.collections4.MapUtils;
- //
- //
- ///**
- // * FinancialInfo渲染器
- // *
- // */
- //@Slf4j
- //public final class FoundationfinancialInfoRender extends FXYAbstractRender {
- // private final FilerepoProperties filerepoProperties;
- // private final CommonDataCache commonDataCache;
- // public FoundationfinancialInfoRender(String cwd, FilerepoProperties filerepoProperties, CommonDataCache commonDataCache) {
- // super(cwd);
- // this.filerepoProperties = filerepoProperties;
- // this.commonDataCache = commonDataCache;
- // }
- // @Override
- // protected String getBasicPath() throws IOException {
- // return filerepoProperties.getBasePath();
- // }
- //
- // @Override
- // protected String getReportImagePath() {
- // return filerepoProperties.getReportImagePath();
- // }
- //
- // /**
- // * Docx 渲染
- // *
- // * @param info 数据
- // * @param inputStream 模板内容
- // * @return 本地文件目录
- // * @throws IOException
- // */
- //
- // public String renderDocx(String info, InputStream inputStream, String relationId) throws IOException {
- // log.info("开始渲染基金会财务模块,relationId: {}", relationId);
- //
- // // 配置POI-TL渲染器
- // ConfigureBuilder builder = Configure.builder();
- // builder.useSpringEL();
- //
- // builder.bind("indicators", new LoopRowIncludeStatisticsTableRenderPolicy("values"));
- // builder.bind("financialDataSeq", new LoopColumnStaticTableRenderPolicy("[", "]", false, true, 2));
- // builder.bind("financialCheckDetails", new LoopRowCutAndMergeFirstColTableRenderPolicy());
- // FxyProtos.FinancialInfo.Builder basicInfoBuilder = FxyProtos.FinancialInfo.newBuilder();
- // JsonFormat.parser().merge(info, basicInfoBuilder);
- //
- // FxyProtos.FinancialInfo defaultInstance = FxyProtos.FinancialInfo.getDefaultInstance();
- // FxyProtos.FinancialInfo mergedProto = defaultInstance.toBuilder()
- // .mergeFrom(basicInfoBuilder.build())
- // .build();
- //
- // String completeJson = JsonFormat.printer()
- // .includingDefaultValueFields()
- // .print(mergedProto);
- // ObjectMapper objectMapper = new ObjectMapper();
- // Map<String, Object> data = objectMapper.readValue(completeJson, new TypeReference<Map<String, Object>>() {});
- // data.replaceAll((k, v) -> v.equals("") ? "-" : v);
- //
- // fillBasicDefaultValues(data);
- // Map<String, Object> commonDataCacheData = commonDataCache.getData(relationId);
- // if (MapUtils.isNotEmpty(commonDataCacheData)) {
- // data.putAll(commonDataCacheData);
- // }
- // try {
- // // 渲染文档
- // String resultPath = this.renderDocx(data, inputStream, builder, relationId, "financialInfo");
- // log.info("渲染基金会财务模块成功,文件路径: {}", resultPath);
- // return resultPath;
- // } catch (Exception e) {
- // log.error("渲染基金会财务模块失败,relationId: {}", relationId, e);
- // throw new IOException("文档渲染失败", e);
- // }
- // }
- //
- // /**
- // * 填充默认值,确保所有必要字段都存在
- // */
- // private void fillBasicDefaultValues(Map<String, Object> data) {
- // Map<String, Object> basicInfoSummary = (Map<String, Object>) data.get("financialSummary");
- // basicInfoSummary.replaceAll((k, v) -> v.equals("") ? "-" : v);
- //
- // List<Map<String, Object>> financialDataSeq = (List<Map<String, Object>>) data.get("financialDataSeq");
- // for (Map<String, Object> stringObjectMap : financialDataSeq) {
- // stringObjectMap.replaceAll((k, v) -> v.equals("") ? "-" : v);
- // }
- //
- // List<Map<String, Object>> indicators = (List<Map<String, Object>>) data.get("indicators");
- // for (Map<String, Object> indicator : indicators) {
- // ArrayList<String> strings = (ArrayList<String>) indicator.get("values");
- // if (CollectionUtils.isEmpty(strings)) {
- // indicator.put("values", Arrays.asList("-", "-", "-"));
- //
- // }
- // }
- // }
- //
- //
- //
- //}
|