From ff5df9b25db93c73bd29ba2b1f67426102c88993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=B4=B5=E5=BC=BA?= Date: Thu, 27 Feb 2025 16:57:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF-2.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repmd/template/AreaDataImportPlugin.java | 12 +- .../template/util/ExportTemplateUtil.java | 449 ++++++++++-------- 2 files changed, 249 insertions(+), 212 deletions(-) diff --git a/main/java/shkd/repc/repmd/template/AreaDataImportPlugin.java b/main/java/shkd/repc/repmd/template/AreaDataImportPlugin.java index 15b2f14..f0fa507 100644 --- a/main/java/shkd/repc/repmd/template/AreaDataImportPlugin.java +++ b/main/java/shkd/repc/repmd/template/AreaDataImportPlugin.java @@ -66,17 +66,22 @@ public class AreaDataImportPlugin extends AbstractFormPlugin implements Plugin { Long id = Long.parseLong(returnData.get(i).getString("qeug_id")); DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(id, "qeug_areatemplate"); if (null!=dynamicObject){ + String templateName = dynamicObject.getString("qeug_remark"); DynamicObjectCollection areaEntry = dynamicObject.getDynamicObjectCollection("qeug_entryentity"); Control productView= this.getView().getControl("productentry"); Control areaView= this.getView().getControl("qeug_subentryentity"); StringBuilder message =new StringBuilder(); - String url; + String url=null; if (areaEntry.size()!=0){ //导出自定义模板 - url = ExportTemplateUtil.exportTemplate(areaEntry, message, productView, areaView); + url = ExportTemplateUtil.exportTemplate(areaEntry, message, productView, areaView,templateName); }else { //导出默认模板 - url = ExportTemplateUtil.exportTemplate(message, productView, areaView); + url = ExportTemplateUtil.exportTemplate(message, productView, areaView,templateName); + } + // 展示消息 + if (message.length() > 0) { + this.getView().showMessage(message.toString()); } if (null!=url){ this.getView().openUrl(url); @@ -84,7 +89,6 @@ public class AreaDataImportPlugin extends AbstractFormPlugin implements Plugin { } } } - } } diff --git a/main/java/shkd/repc/repmd/template/util/ExportTemplateUtil.java b/main/java/shkd/repc/repmd/template/util/ExportTemplateUtil.java index 1f65211..e55f3a0 100644 --- a/main/java/shkd/repc/repmd/template/util/ExportTemplateUtil.java +++ b/main/java/shkd/repc/repmd/template/util/ExportTemplateUtil.java @@ -4,6 +4,9 @@ import kd.bos.context.RequestContext; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.dataentity.entity.LocaleString; +import kd.bos.dataentity.utils.StringUtils; +import kd.bos.entity.ValueMapItem; +import kd.bos.entity.property.ComboProp; import kd.bos.fileservice.FileItem; import kd.bos.fileservice.FileService; import kd.bos.fileservice.FileServiceFactory; @@ -11,13 +14,12 @@ import kd.bos.form.control.Control; import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; -import org.apache.poi.ss.usermodel.FillPatternType; -import org.apache.poi.ss.usermodel.HorizontalAlignment; -import org.apache.poi.ss.usermodel.IndexedColors; -import org.apache.poi.ss.usermodel.VerticalAlignment; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddressList; import org.apache.poi.xssf.usermodel.*; import java.awt.*; +import java.awt.Color; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; @@ -32,143 +34,142 @@ public class ExportTemplateUtil { /** * 导出默认模板 * - * @param message 消息收集 + * @param message 消息收集 + * @param productView 产品构成视图 + * @param areaView 数据面积视图 + * @param templateName 模板名称 */ - public static String exportTemplate(StringBuilder message, Control productView, Control areaView){ + public static String exportTemplate(StringBuilder message, Control productView, Control areaView, String templateName) { QFilter number = new QFilter("number", QCP.equals, "repmd_projectbill_IMPT_ENTRY"); DynamicObject templateObj = BusinessDataServiceHelper.loadSingle("bos_importentry_template", number.toArray()); - if (null==templateObj){ - message.append("请先维护引入模板"); + if (templateObj == null) { + message.append("请先维护系统引入模板\n"); + return null; + } + + // 读取系统模板参数 + List