From 062fc0466d1f652f525fe3acae79b13dd34c4907 Mon Sep 17 00:00:00 2001 From: IT-xiaoXiong <774495953@qq.com> Date: Mon, 13 Dec 2021 12:00:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=EF=BC=8C=E5=A4=9A=E8=AF=AD=E8=A8=80=E5=8C=96=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=EF=BC=8ClabelhtmlUtils=E7=BC=96=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aiyh/utils/LabelHtmlUtils.java | 170 + aiyh/utils/Util.java | 3072 +++++++++-------- aiyh/utils/entity/LabelHtmlIndex.java | 39 + .../service/CopyAttachmentService.java | 129 +- .../service/impl/FaDDContractService.java | 1664 ++++----- customization/test/NewUtilTest.java | 678 ++-- .../AddCustomer_Action.java | 8 +- 7 files changed, 3052 insertions(+), 2708 deletions(-) create mode 100644 aiyh/utils/LabelHtmlUtils.java create mode 100644 aiyh/utils/entity/LabelHtmlIndex.java diff --git a/aiyh/utils/LabelHtmlUtils.java b/aiyh/utils/LabelHtmlUtils.java new file mode 100644 index 0000000..4aea6b9 --- /dev/null +++ b/aiyh/utils/LabelHtmlUtils.java @@ -0,0 +1,170 @@ +package aiyh.utils; + +import aiyh.utils.entity.LabelHtmlIndex; +import aiyh.utils.service.UtilService; +import weaver.systeminfo.SystemEnv; + +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author EBU7-dev1-ayh + * create 2021/12/13 0013 10:29 + * 多语言工具类 + */ + + +public class LabelHtmlUtils { + + private final UtilService utilService = new UtilService(); + private Map htmlLabel = null; + + public LabelHtmlUtils(String prefix) { + if (!this.init(prefix)) { + throw new RuntimeException("配置文件异常,请检查配置文件结构是否符合要求!"); + } + } + + public LabelHtmlUtils() { + } + + /** + * 初始化配置信息 + * + * @param prefix 前缀 + * @return 是否初始化成功 + */ + public synchronized boolean init(String prefix) { + if (this.htmlLabel != null) { + return true; + } + try { + this.htmlLabel = Util.readProperties2Map("htmlLabelIndex", prefix); + return this.htmlLabel != null; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 获取指定语言id的自定义标签 + * + * @param id 自定义标签id + * @param languageId 语言id + * @param defaultStr 默认字符串 + * @return 自定义标签对应的语言字符串,或者默认字符串 + */ + public String getHtmlLabelName(int id, int languageId, String defaultStr) { + String htmlLabelName = SystemEnv.getHtmlLabelName(id, languageId); + return htmlLabelName == null ? defaultStr : htmlLabelName; + } + + /** + * 获取指定语言id的自定义标签 + * + * @param id 标签id + * @param languageId 语言id + * @return 自定义标签的语言字符串 + */ + public String getHtmlLabelName(int id, int languageId) { + return SystemEnv.getHtmlLabelName(id, languageId); + } + + + /** + * 通过语言id截取多语言字符串 + * + * @param languageId 语言id + * @param languageStr 多语言字符串 + * @return 截取后的字符串 + */ + public String getHtmlLabelNameByStr(int languageId, String languageStr) { + String pattern = "(`~`" + languageId + " )(?