|
@@ -1,141 +1,319 @@
|
|
|
-//package com.yaoyicloud.render;
|
|
|
-//
|
|
|
-//import java.io.IOException;
|
|
|
-//import java.nio.file.Paths;
|
|
|
-//import java.util.List;
|
|
|
-//import java.util.Map;
|
|
|
-//import java.util.UUID;
|
|
|
-//import java.util.stream.Collectors;
|
|
|
-//
|
|
|
-//import com.deepoove.poi.config.Configure;
|
|
|
-//import com.deepoove.poi.config.ConfigureBuilder;
|
|
|
-//import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
|
|
|
-//import com.fasterxml.jackson.core.JsonGenerator;
|
|
|
-//import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
-//import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
-//import com.fasterxml.jackson.databind.SerializerProvider;
|
|
|
-//import com.fasterxml.jackson.databind.module.SimpleModule;
|
|
|
-//import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
|
|
-//import com.google.protobuf.InvalidProtocolBufferException;
|
|
|
-//import com.google.protobuf.MessageOrBuilder;
|
|
|
-//import com.google.protobuf.util.JsonFormat;
|
|
|
-//import com.yaoyicloud.message.FxyProtos.PublicRecord;
|
|
|
-//
|
|
|
-///**
|
|
|
-// * PublicRecord渲染器
|
|
|
-// *
|
|
|
-// */
|
|
|
-//public final class PublicRecordRender extends AbstractRender {
|
|
|
-//
|
|
|
-// public PublicRecordRender(String cwd) {
|
|
|
-// super(cwd);
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * Docx 渲染
|
|
|
-// *
|
|
|
-// * @param info 数据
|
|
|
-// * @param templateFileContent 模板内容
|
|
|
-// * @return 本地文件目录
|
|
|
-// * @throws IOException
|
|
|
-// */
|
|
|
-//// public String renderDocx(PublicRecord info, Map<String, Object> addtionalMap, byte[] templateFileContent) throws IOException {
|
|
|
-//// // TODO: let mapper be package static
|
|
|
-//// ObjectMapper mapper = new ObjectMapper();
|
|
|
-//// SimpleModule module = new SimpleModule();
|
|
|
-//// module.addSerializer(new PublicRecordSerializer(PublicRecord.class));
|
|
|
-//// mapper.registerModule(module);
|
|
|
-////
|
|
|
-//// String jsonStr = mapper.writeValueAsString(info);
|
|
|
-////
|
|
|
-//// // 注: 报告模板的模板变量按照json序列化的结果命名
|
|
|
-//// // 注: 目前的实现假设:一个session对应一个cwd目录
|
|
|
-//// ConfigureBuilder builder = Configure.builder();
|
|
|
-//// builder.bind("dishonestPersons", new LoopRowTableRenderPolicy());
|
|
|
-//// builder.bind("businessAbnormals", new LoopRowTableRenderPolicy());
|
|
|
-//// builder.bind("penaltyRecords", new LoopRowTableRenderPolicy());
|
|
|
-//// builder.bind("taxPenalties", new LoopRowTableRenderPolicy());
|
|
|
-//// builder.bind("severeViolations", new LoopRowTableRenderPolicy());
|
|
|
-//// this.docxResultPath =
|
|
|
-//// this.renderDocx(jsonStr, addtionalMap, templateFileContent, builder,
|
|
|
-//// Paths.get(cwd, UUID.randomUUID().toString() + ".docx").toString());
|
|
|
-//// return this.docxResultPath;
|
|
|
-//// }
|
|
|
-//
|
|
|
-// /*
|
|
|
-// * 通过序列化和反序列化
|
|
|
-// * 1. 进行默认显示规则的数据转换
|
|
|
-// * 2. 避免POI-TL处理模板面对复杂数据类型
|
|
|
-// */
|
|
|
-// public class PublicRecordSerializer extends StdSerializer<PublicRecord> {
|
|
|
-//
|
|
|
-// public PublicRecordSerializer() {
|
|
|
-// this(null);
|
|
|
-// }
|
|
|
-//
|
|
|
-// public PublicRecordSerializer(Class<PublicRecord> t) {
|
|
|
-// super(t);
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 为了增加*Count的数值,定制了序列化方法。 TODO: 可能更简单的方法是使用POI-TL的Spring表达式能力
|
|
|
-// */
|
|
|
-// @Override
|
|
|
-// public void serialize(PublicRecord value, JsonGenerator jgen, SerializerProvider provider)
|
|
|
-// throws IOException, JsonProcessingException {
|
|
|
-//
|
|
|
-// jgen.writeStartObject();
|
|
|
-//
|
|
|
-// jgen.writeArrayFieldStart("dishonestPersons");
|
|
|
-// writeRawArray(
|
|
|
-// value.getDishonestPersonsList().stream().map(o -> (MessageOrBuilder) o).collect(Collectors.toList()),
|
|
|
-// jgen);
|
|
|
-// jgen.writeEndArray();
|
|
|
-// jgen.writeNumberField("dishonestPersonsCount", value.getDishonestPersonsCount());
|
|
|
-//
|
|
|
-// jgen.writeArrayFieldStart("businessAbnormals");
|
|
|
-// writeRawArray(
|
|
|
-// value.getBusinessAbnormalsList().stream().map(o -> (MessageOrBuilder) o).collect(Collectors.toList()),
|
|
|
-// jgen);
|
|
|
-// jgen.writeEndArray();
|
|
|
-// jgen.writeNumberField("businessAbnormalsCount", value.getBusinessAbnormalsCount());
|
|
|
-//
|
|
|
-// jgen.writeArrayFieldStart("penaltyRecords");
|
|
|
-// writeRawArray(
|
|
|
-// value.getPenaltyRecordsList().stream().map(o -> (MessageOrBuilder) o).collect(Collectors.toList()),
|
|
|
-// jgen);
|
|
|
-// jgen.writeEndArray();
|
|
|
-// jgen.writeNumberField("penaltyRecordsCount", value.getPenaltyRecordsCount());
|
|
|
-//
|
|
|
-// jgen.writeArrayFieldStart("taxPenalties");
|
|
|
-// writeRawArray(
|
|
|
-// value.getTaxPenaltiesList().stream().map(o -> (MessageOrBuilder) o).collect(Collectors.toList()), jgen);
|
|
|
-// jgen.writeEndArray();
|
|
|
-// jgen.writeNumberField("taxPenaltiesCount", value.getTaxPenaltiesCount());
|
|
|
-//
|
|
|
-// jgen.writeArrayFieldStart("severeViolations");
|
|
|
-// writeRawArray(
|
|
|
-// value.getSevereViolationsList().stream().map(o -> (MessageOrBuilder) o).collect(Collectors.toList()),
|
|
|
-// jgen);
|
|
|
-// jgen.writeEndArray();
|
|
|
-// jgen.writeNumberField("severeViolationsCount", value.getSevereViolationsCount());
|
|
|
-//
|
|
|
-// jgen.writeRaw(", \"publicRecordSummary\": " + JsonFormat.printer().print(value.getPublicRecordSummary()));
|
|
|
-//
|
|
|
-// jgen.writeEndObject();
|
|
|
-// }
|
|
|
-//
|
|
|
-// private void writeRawArray(List<MessageOrBuilder> values, JsonGenerator jgen)
|
|
|
-// throws IOException, InvalidProtocolBufferException {
|
|
|
-// String comma = null;
|
|
|
-// for (MessageOrBuilder item : values) {
|
|
|
-// if (comma != null) {
|
|
|
-// jgen.writeRaw(comma);
|
|
|
-// } else {
|
|
|
-// comma = ",";
|
|
|
-// }
|
|
|
-// jgen.writeRaw(JsonFormat.printer().print(item));
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//}
|
|
|
+package com.yaoyicloud.render;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import com.deepoove.poi.config.Configure;
|
|
|
+import com.deepoove.poi.config.ConfigureBuilder;
|
|
|
+import com.deepoove.poi.policy.RenderPolicy;
|
|
|
+import com.fasterxml.jackson.core.JsonGenerator;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.fasterxml.jackson.databind.SerializerProvider;
|
|
|
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
|
|
+import com.google.protobuf.InvalidProtocolBufferException;
|
|
|
+import com.google.protobuf.MessageOrBuilder;
|
|
|
+import com.google.protobuf.util.JsonFormat;
|
|
|
+import com.yaoyicloud.config.FilerepoProperties;
|
|
|
+
|
|
|
+import com.yaoyicloud.message.FxyProtos.PublicRecord;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+
|
|
|
+/**
|
|
|
+ * PublicRecord渲染器
|
|
|
+ *
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+public final class PublicRecordRender extends AbstractRender {
|
|
|
+ private final FilerepoProperties filerepoProperties;
|
|
|
+
|
|
|
+ public PublicRecordRender(String cwd, FilerepoProperties filerepoProperties) {
|
|
|
+ super(cwd);
|
|
|
+ this.filerepoProperties = filerepoProperties;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected String getBasicPath() throws IOException {
|
|
|
+ return filerepoProperties.getBasePath();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected String getReportImagePath() {
|
|
|
+ return filerepoProperties.getReportImagePath();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Docx 渲染
|
|
|
+ *
|
|
|
+ * @param info 数据
|
|
|
+ * @param templateFileContent 模板内容
|
|
|
+ * @return 本地文件目录
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+
|
|
|
+ public String renderDocx(String info, Map<String, Object> addtionalMap, byte[] templateFileContent,
|
|
|
+ String relationId) throws IOException {
|
|
|
+ log.info("开始渲染公共模块,relationId: {}", relationId);
|
|
|
+
|
|
|
+ // 配置POI-TL渲染器
|
|
|
+ ConfigureBuilder builder = Configure.builder();
|
|
|
+ RenderPolicy indicatorsRenderPolicy = this.indicatorsRenderPolicy();
|
|
|
+
|
|
|
+ builder.bind("dishonestPersons", indicatorsRenderPolicy);
|
|
|
+ builder.bind("businessAbnormals", indicatorsRenderPolicy);
|
|
|
+ builder.bind("penaltyRecords", indicatorsRenderPolicy);
|
|
|
+ builder.bind("taxPenalties", indicatorsRenderPolicy);
|
|
|
+ builder.bind("severeViolations", indicatorsRenderPolicy);
|
|
|
+
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ Map<String, Object> data = objectMapper.readValue(info, new TypeReference<Map<String, Object>>() {});
|
|
|
+ data.replaceAll((k, v) -> v.equals("") ? "-" : v);
|
|
|
+
|
|
|
+ if (addtionalMap != null) {
|
|
|
+ data.putAll(addtionalMap);
|
|
|
+ }
|
|
|
+ fillBasicDefaultValues(data);
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 渲染文档
|
|
|
+ String resultPath = this.renderDocx(data, templateFileContent, builder, relationId, "publicRecord");
|
|
|
+ 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("publicRecordSummary");
|
|
|
+
|
|
|
+ // 如果存在 summary 对象,则处理其字段
|
|
|
+ if (basicInfoSummary != null) {
|
|
|
+ // 确保所有需要的字段都有默认值
|
|
|
+ setDefaultIfNull(basicInfoSummary, "score", "-");
|
|
|
+ setDefaultIfNull(basicInfoSummary, "riskSummary", "-");
|
|
|
+ setDefaultIfNull(basicInfoSummary, "suggestion", "-");
|
|
|
+ } else {
|
|
|
+ // 如果 summary 对象不存在,则创建并设置默认值
|
|
|
+ Map<String, Object> defaultSummary = new HashMap<>();
|
|
|
+ defaultSummary.put("score", "-");
|
|
|
+ defaultSummary.put("riskSummary", "-");
|
|
|
+ defaultSummary.put("suggestion", "-");
|
|
|
+ data.put("publicRecordSummary", defaultSummary);
|
|
|
+ }
|
|
|
+ basicInfoSummary.replaceAll((k, v) -> v.equals("") ? "-" : v);
|
|
|
+
|
|
|
+ Map<String, Object> dishonestPersonsMap = (Map<String, Object>) data.get("dishonestPersons");
|
|
|
+ if (dishonestPersonsMap != null) {
|
|
|
+ dishonestPersonsMap.replaceAll((k, v) -> v.equals("") ? "-" : v);
|
|
|
+ data.put("dishonestPersonsCount", dishonestPersonsMap.size());
|
|
|
+ } else {
|
|
|
+ Map<String, Object> defaultDishonestPerson = new HashMap<>();
|
|
|
+ defaultDishonestPerson.put("id", "1");
|
|
|
+ defaultDishonestPerson.put("inDate", "-");
|
|
|
+ defaultDishonestPerson.put("caseNumber", "-");
|
|
|
+ defaultDishonestPerson.put("amount", "-");
|
|
|
+ defaultDishonestPerson.put("executionDesc", "-");
|
|
|
+ defaultDishonestPerson.put("executionStatus", "-");
|
|
|
+ defaultDishonestPerson.put("court", "-");
|
|
|
+ defaultDishonestPerson.put("disabled", "-");
|
|
|
+
|
|
|
+ List<Map<String, Object>> defaultDishonestPersonList = Collections.singletonList(defaultDishonestPerson);
|
|
|
+
|
|
|
+ data.put("dishonestPersons", defaultDishonestPersonList);
|
|
|
+ data.put("dishonestPersonsCount", 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> businessAbnormalsMap = (Map<String, Object>) data.get("businessAbnormals");
|
|
|
+ if (businessAbnormalsMap != null) {
|
|
|
+ businessAbnormalsMap.replaceAll((k, v) -> v.equals("") ? "-" : v);
|
|
|
+ data.put("businessAbnormalsCount", businessAbnormalsMap.size());
|
|
|
+ } else {
|
|
|
+ Map<String, Object> defaultBusinessAbnormal = new HashMap<>();
|
|
|
+ defaultBusinessAbnormal.put("id", "1");
|
|
|
+ defaultBusinessAbnormal.put("inDate", "-");
|
|
|
+ defaultBusinessAbnormal.put("department", "-");
|
|
|
+ defaultBusinessAbnormal.put("inReason", "-");
|
|
|
+ defaultBusinessAbnormal.put("disabled", "-");
|
|
|
+ List<Map<String, Object>> defaultBusinessAbnormalList = Collections.singletonList(defaultBusinessAbnormal);
|
|
|
+
|
|
|
+ data.put("businessAbnormals", defaultBusinessAbnormalList);
|
|
|
+ data.put("businessAbnormalsCount", 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> penaltyRecordsMap = (Map<String, Object>) data.get("penaltyRecords");
|
|
|
+ if (penaltyRecordsMap != null) {
|
|
|
+ penaltyRecordsMap.replaceAll((k, v) -> v.equals("") ? "-" : v);
|
|
|
+ data.put("penaltyRecordsCount", penaltyRecordsMap.size());
|
|
|
+ } else {
|
|
|
+ Map<String, Object> defaultPenaltyRecord = new HashMap<>();
|
|
|
+ defaultPenaltyRecord.put("id", "1");
|
|
|
+ defaultPenaltyRecord.put("seqNo", "-");
|
|
|
+ defaultPenaltyRecord.put("number", "-");
|
|
|
+ defaultPenaltyRecord.put("penaltyData", "-");
|
|
|
+ defaultPenaltyRecord.put("content", "-");
|
|
|
+ defaultPenaltyRecord.put("punishAmnt", "-");
|
|
|
+ defaultPenaltyRecord.put("department", "-");
|
|
|
+ defaultPenaltyRecord.put("description", "-");
|
|
|
+ List<Map<String, Object>> defaultPenaltyRecordList = Collections.singletonList(defaultPenaltyRecord);
|
|
|
+
|
|
|
+ data.put("penaltyRecords", defaultPenaltyRecordList);
|
|
|
+ data.put("penaltyRecordsCount", 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> taxPenaltiesMap = (Map<String, Object>) data.get("taxPenalties");
|
|
|
+ if (taxPenaltiesMap != null) {
|
|
|
+ taxPenaltiesMap.replaceAll((k, v) -> v.equals("") ? "-" : v);
|
|
|
+ data.put("taxPenaltiesCount", taxPenaltiesMap.size());
|
|
|
+ } else {
|
|
|
+ Map<String, Object> defaultTaxPenalty = new HashMap<>();
|
|
|
+ defaultTaxPenalty.put("id", "1");
|
|
|
+ defaultTaxPenalty.put("time", "-");
|
|
|
+ defaultTaxPenalty.put("type", "-");
|
|
|
+ defaultTaxPenalty.put("result", "-");
|
|
|
+ List<Map<String, Object>> defaultTaxPenaltyList = Collections.singletonList(defaultTaxPenalty);
|
|
|
+
|
|
|
+ data.put("taxPenalties", defaultTaxPenaltyList);
|
|
|
+ data.put("taxPenaltiesCount", 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> severeViolationsMap = (Map<String, Object>) data.get("severeViolations");
|
|
|
+ if (severeViolationsMap != null) {
|
|
|
+ severeViolationsMap.replaceAll((k, v) -> v.equals("") ? "-" : v);
|
|
|
+ data.put("severeViolationsCount", severeViolationsMap.size());
|
|
|
+ } else {
|
|
|
+ Map<String, Object> defaultSevereViolation = new HashMap<>();
|
|
|
+ defaultSevereViolation.put("id", "1");
|
|
|
+ defaultSevereViolation.put("time", "-");
|
|
|
+ defaultSevereViolation.put("decisionDept", "-");
|
|
|
+ defaultSevereViolation.put("inReason", "-");
|
|
|
+ defaultSevereViolation.put("isHistory", "-");
|
|
|
+ List<Map<String, Object>> defaultSevereViolationList = Collections.singletonList(defaultSevereViolation);
|
|
|
+ data.put("severeViolations", defaultSevereViolationList);
|
|
|
+ data.put("severeViolationsCount", 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setDefaultIfNull(Map<String, Object> map, String key, Object defaultValue) {
|
|
|
+ if (!map.containsKey(key) || map.get(key) == null) {
|
|
|
+ map.put(key, defaultValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // /**
|
|
|
+ // * Docx 渲染
|
|
|
+ // *
|
|
|
+ // * @param info 数据
|
|
|
+ // * @param templateFileContent 模板内容
|
|
|
+ // * @return 本地文件目录
|
|
|
+ // * @throws IOException
|
|
|
+ // */
|
|
|
+ // public String renderDocx(PublicRecord info, Map<String, Object> addtionalMap, byte[] templateFileContent) throws IOException {
|
|
|
+ // // TODO: let mapper be package static
|
|
|
+ // ObjectMapper mapper = new ObjectMapper();
|
|
|
+ // SimpleModule module = new SimpleModule();
|
|
|
+ // module.addSerializer(new PublicRecordSerializer(PublicRecord.class));
|
|
|
+ // mapper.registerModule(module);
|
|
|
+ //
|
|
|
+ // String jsonStr = mapper.writeValueAsString(info);
|
|
|
+ //
|
|
|
+ // // 注: 报告模板的模板变量按照json序列化的结果命名
|
|
|
+ // // 注: 目前的实现假设:一个session对应一个cwd目录
|
|
|
+ // ConfigureBuilder builder = Configure.builder();
|
|
|
+ // builder.bind("dishonestPersons", new LoopRowTableRenderPolicy());
|
|
|
+ // builder.bind("businessAbnormals", new LoopRowTableRenderPolicy());
|
|
|
+ // builder.bind("penaltyRecords", new LoopRowTableRenderPolicy());
|
|
|
+ // builder.bind("taxPenalties", new LoopRowTableRenderPolicy());
|
|
|
+ // builder.bind("severeViolations", new LoopRowTableRenderPolicy());
|
|
|
+ // this.docxResultPath =
|
|
|
+ // this.renderDocx(jsonStr, addtionalMap, templateFileContent, builder,
|
|
|
+ // Paths.get(cwd, UUID.randomUUID().toString() + ".docx").toString());
|
|
|
+ // return this.docxResultPath;
|
|
|
+ // }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 通过序列化和反序列化
|
|
|
+ * 1. 进行默认显示规则的数据转换
|
|
|
+ * 2. 避免POI-TL处理模板面对复杂数据类型
|
|
|
+ */
|
|
|
+ public class PublicRecordSerializer extends StdSerializer<PublicRecord> {
|
|
|
+
|
|
|
+ public PublicRecordSerializer() {
|
|
|
+ this(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ public PublicRecordSerializer(Class<PublicRecord> t) {
|
|
|
+ super(t);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 为了增加*Count的数值,定制了序列化方法。 TODO: 可能更简单的方法是使用POI-TL的Spring表达式能力
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void serialize(PublicRecord value, JsonGenerator jgen, SerializerProvider provider)
|
|
|
+ throws IOException, JsonProcessingException {
|
|
|
+
|
|
|
+ jgen.writeStartObject();
|
|
|
+
|
|
|
+ jgen.writeArrayFieldStart("dishonestPersons");
|
|
|
+ writeRawArray(
|
|
|
+ value.getDishonestPersonsList().stream().map(o -> (MessageOrBuilder) o).collect(Collectors.toList()),
|
|
|
+ jgen);
|
|
|
+ jgen.writeEndArray();
|
|
|
+ jgen.writeNumberField("dishonestPersonsCount", value.getDishonestPersonsCount());
|
|
|
+
|
|
|
+ jgen.writeArrayFieldStart("businessAbnormals");
|
|
|
+ writeRawArray(
|
|
|
+ value.getBusinessAbnormalsList().stream().map(o -> (MessageOrBuilder) o).collect(Collectors.toList()),
|
|
|
+ jgen);
|
|
|
+ jgen.writeEndArray();
|
|
|
+ jgen.writeNumberField("businessAbnormalsCount", value.getBusinessAbnormalsCount());
|
|
|
+
|
|
|
+ jgen.writeArrayFieldStart("penaltyRecords");
|
|
|
+ writeRawArray(
|
|
|
+ value.getPenaltyRecordsList().stream().map(o -> (MessageOrBuilder) o).collect(Collectors.toList()),
|
|
|
+ jgen);
|
|
|
+ jgen.writeEndArray();
|
|
|
+ jgen.writeNumberField("penaltyRecordsCount", value.getPenaltyRecordsCount());
|
|
|
+
|
|
|
+ jgen.writeArrayFieldStart("taxPenalties");
|
|
|
+ writeRawArray(
|
|
|
+ value.getTaxPenaltiesList().stream().map(o -> (MessageOrBuilder) o).collect(Collectors.toList()), jgen);
|
|
|
+ jgen.writeEndArray();
|
|
|
+ jgen.writeNumberField("taxPenaltiesCount", value.getTaxPenaltiesCount());
|
|
|
+
|
|
|
+ jgen.writeArrayFieldStart("severeViolations");
|
|
|
+ writeRawArray(
|
|
|
+ value.getSevereViolationsList().stream().map(o -> (MessageOrBuilder) o).collect(Collectors.toList()),
|
|
|
+ jgen);
|
|
|
+ jgen.writeEndArray();
|
|
|
+ jgen.writeNumberField("severeViolationsCount", value.getSevereViolationsCount());
|
|
|
+
|
|
|
+ jgen.writeRaw(", \"publicRecordSummary\": " + JsonFormat.printer().print(value.getPublicRecordSummary()));
|
|
|
+
|
|
|
+ jgen.writeEndObject();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void writeRawArray(List<MessageOrBuilder> values, JsonGenerator jgen)
|
|
|
+ throws IOException, InvalidProtocolBufferException {
|
|
|
+ String comma = null;
|
|
|
+ for (MessageOrBuilder item : values) {
|
|
|
+ if (comma != null) {
|
|
|
+ jgen.writeRaw(comma);
|
|
|
+ } else {
|
|
|
+ comma = ",";
|
|
|
+ }
|
|
|
+ jgen.writeRaw(JsonFormat.printer().print(item));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|