许鹏程
2023-08-08 a2cfd417f673603633c6d46713d320bb1501f88c
src/main/java/com/product/print/service/PrintRealizeService.java
@@ -10,6 +10,8 @@
import com.deepoove.poi.config.ConfigureBuilder;
import com.deepoove.poi.data.TextRenderData;
import com.deepoove.poi.data.style.Style;
import com.deepoove.poi.render.RenderContext;
import com.deepoove.poi.util.RegexUtils;
import com.product.common.lang.StringUtils;
import com.product.core.cache.DataPoolCacheImpl;
import com.product.core.config.Global;
@@ -23,16 +25,21 @@
import com.product.print.config.CmnConst;
import com.product.print.service.ide.IPrintRealizeService;
import com.product.print.util.DynamicTableRenderPolicy;
import com.product.print.util.FlowOpinionRenderPolicy;
import com.product.print.util.TableEmptyHandler;
import com.product.tool.flow.service.FlowDetailService;
import com.product.util.BaseUtil;
import com.product.util.SystemParamReplace;
import org.apache.poi.xwpf.usermodel.XWPFTable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -57,7 +64,7 @@
   public static void dataConvertCheckedData(FieldSetEntity fse) {
      TextRenderData selSymbol = new TextRenderData(CmnConst.PRINT_CHECKED_CHAR, new Style(CmnConst.PRINT_FONT, 14));
      TextRenderData unselSymbol = new TextRenderData(CmnConst.PRINT_UNCHECKED_CHAR, new Style(CmnConst.PRINT_FONT, 14));
      TextRenderData unselSymbol = new TextRenderData(CmnConst.PRINT_UNCHECKED_CHAR, new Style(CmnConst.PRINT_FONT, 18));
      //获取表单字段
      Object[] fields = fse.getMeta().getFields();
@@ -186,6 +193,9 @@
      for (int i = 0; i < fields.length; i++) {
         String field = fields[i].toString();
         FieldSetEntity metaEntity = fse.getMeta().getFieldMeta(field);
         if (metaEntity == null) {
            continue;
         }
         String fieldType = metaEntity.getString("field_type");
         //判断是否拥有流程标识
         if ("flowsign".equals(fieldType)) {
@@ -217,7 +227,7 @@
      replaceWord(localTempPathWord, file.getPath(), fse);
      file.delete();
      String replaceParams = SystemParamReplace.replaceParams(printConf.getString(CmnConst.PRINT_FILE_NAME), fse);
      String replaceParams = SystemParamReplace.replaceParams(Optional.ofNullable(printConf.getString(CmnConst.PRINT_FILE_NAME)).orElse(printConf.getString(CmnConst.PRINT_NAME)), fse);
      printConf.setValue(CmnConst.PRINT_FILE_NAME, replaceParams);
      if (isConvertPdf) {
         try {
@@ -261,16 +271,36 @@
      //获取子表数据
      Map<String, DataTableEntity> subDataMap = dataFse.getSubData();
      ConfigureBuilder config = Configure.createDefault().builder();
      config.addPlugin('@', new FlowOpinionRenderPolicy(flowOpinion));
      config.addPlugin('$', new com.deepoove.poi.policy.DynamicTableRenderPolicy() {
         @Override
         public void doRender(RenderContext<Object> context) throws Exception {
            return;
         }
         @Override
         public void render(XWPFTable table, Object data) throws Exception {
            return;
         }
      });
      config.buildGrammerRegex("(#)?([\\w\\u4e00-\\u9fa5]+)(\\.?[\\w\\u4e00-\\u9fa5\\|]*)*(#)?");
      TableEmptyHandler tableEmptyHandler = new TableEmptyHandler();
      if (!CollectionUtil.isEmpty(subDataMap)) {
         for (Map.Entry<String, DataTableEntity> entry : subDataMap.entrySet()) {
            cloneValues.put(entry.getKey(), entry.getValue().getData().stream().map(item -> (Map<String, Object>) ((Map) item.getValues())).collect(Collectors.toList()));
            config.bind(entry.getKey(), new DynamicTableRenderPolicy(entry.getKey()));
            tableEmptyHandler.addTag(entry.getKey());
         }
      }
      if(flowOpinion!=null && flowOpinion.size()>0){
         cloneValues.put("lx_flow_opinion", flowOpinion);
         config.bind("lx_flow_opinion", new DynamicTableRenderPolicy("lx_flow_opinion"));
      if (flowOpinion != null) {
         if (!CollectionUtil.isEmpty(flowOpinion)) {
            cloneValues.put("lx_flow_opinion", flowOpinion);
            config.bind("lx_flow_opinion", new DynamicTableRenderPolicy("lx_flow_opinion"));
         }
         tableEmptyHandler.addTag("lx_flow_opinion");
      }
      config.setValidErrorHandler(tableEmptyHandler);
      try {
         //检查输出文件是否存在,不存在则创建
         FileUtil.touch(outPath);