供应商同步,多语言化检查,labelhtmlUtils编写

dev
IT-xiaoXiong 2021-12-13 12:00:39 +08:00
parent 7efbec9808
commit 062fc0466d
7 changed files with 3052 additions and 2708 deletions

View File

@ -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<String, Object> 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 + " )(?<label>(\\w*|\\W*|[\\u4e00-\\u9fa5]*))(`~`)";
Pattern compile = Pattern.compile(pattern);
Matcher matcher = compile.matcher(languageStr);
if (matcher.find()) {
return matcher.group("label");
}
return languageStr;
}
/**
*
*
* @param key
*/
public Map<String, Object> getHtmlLabelMap(String key) {
if (this.htmlLabel == null) {
throw new RuntimeException("请初始化以读取配置信息调用方法init(String prefix)");
}
Map<String, Object> map;
try {
map = (Map<String, Object>) this.htmlLabel.get(key);
} catch (Exception e) {
throw new RuntimeException("配置文件异常,请检查配置文件结构是否符合要求!");
}
return map;
}
/**
*
*
* @param key
* @return Map
*/
public Map<String, String> getHtmlLabel(String key) {
if (this.htmlLabel == null) {
throw new RuntimeException("请初始化以读取配置信息调用方法init(String prefix)");
}
Map<String, String> map;
try {
map = (Map<String, String>) this.htmlLabel.get(key);
} catch (Exception e) {
throw new RuntimeException("配置文件异常,请检查配置文件结构是否符合要求!");
}
return map;
}
/**
*
*
* @param key
* @return
*/
public LabelHtmlIndex getLabelHtmlIndex(String key) {
if (this.htmlLabel == null) {
throw new RuntimeException("请初始化以读取配置信息调用方法init(String prefix)");
}
Map<String, Object> map;
LabelHtmlIndex labelHtmlIndex;
try {
map = (Map<String, Object>) this.htmlLabel.get(key);
labelHtmlIndex = Util.mapToObject(map, LabelHtmlIndex.class);
} catch (Exception e) {
throw new RuntimeException("配置文件异常,请检查配置文件结构是否符合要求!");
}
return labelHtmlIndex;
}
/**
*
*
* @param map
* @return
*/
public LabelHtmlIndex getLabelHtmlIndex(Map<String, Object> map, String key) {
LabelHtmlIndex labelHtmlIndex;
Map<String, Object> resultMap;
try {
resultMap = (Map<String, Object>) map.get(key);
labelHtmlIndex = Util.mapToObject(resultMap, LabelHtmlIndex.class);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("map转换异常");
}
return labelHtmlIndex;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,39 @@
package aiyh.utils.entity;
/**
* @author EBU7-dev1-ayh
* create 2021/12/13 0013 11:19
*/
public class LabelHtmlIndex {
private Integer labelIndex;
private String defaultStr;
public LabelHtmlIndex() {
}
public LabelHtmlIndex(Integer labelIndex, String defaultStr) {
this.labelIndex = labelIndex;
this.defaultStr = defaultStr;
}
public Integer getLabelIndex() {
return labelIndex;
}
public String getDefaultStr() {
return defaultStr;
}
@Override
public String toString() {
return "LabelHtmlIndex{" +
"labelIndex='" + labelIndex + '\'' +
", defaultStr='" + defaultStr + '\'' +
'}';
}
}

View File

@ -1,10 +1,10 @@
package com.api.aiyh_pcn.copy_attachment.service; package com.api.aiyh_pcn.copy_attachment.service;
import aiyh.utils.ApiResult;
import aiyh.utils.zwl.common.ToolUtil; import aiyh.utils.zwl.common.ToolUtil;
import com.api.aiyh_pcn.copy_attachment.dao.DocTemplateDao;
import com.api.workflow.constant.RequestAuthenticationConstant; import com.api.workflow.constant.RequestAuthenticationConstant;
import com.engine.workflow.biz.requestForm.FileBiz; import com.engine.workflow.biz.requestForm.FileBiz;
import aiyh.utils.ApiResult;
import com.api.aiyh_pcn.copy_attachment.dao.DocTemplateDao;
import weaver.general.Util; import weaver.general.Util;
import weaver.hrm.User; import weaver.hrm.User;
@ -19,80 +19,81 @@ import java.util.Map;
*/ */
public class CopyAttachmentService { public class CopyAttachmentService {
public static String copyFile(User user, Map<String, Object> params){ public static String copyFile(User user, Map<String, Object> params) {
ToolUtil toolUtil = new ToolUtil(); ToolUtil toolUtil = new ToolUtil();
// 建模表名称 // 建模表名称
String tableName = String.valueOf(params.get("tableName")); String tableName = String.valueOf(params.get("tableName"));
// 建模字段名 // 建模字段名
String fieldName = String.valueOf(params.get("fieldName")); String fieldName = String.valueOf(params.get("fieldName"));
// 附件字段id // 附件字段id
String fileFieldId = String.valueOf(params.get("fileFieldId")); String fileFieldId = String.valueOf(params.get("fileFieldId"));
// 配置id // 配置id
String configId = String.valueOf(params.get("configId")); String configId = String.valueOf(params.get("configId"));
// 流程id // 流程id
String workflowId = String.valueOf(params.get("workflowId")); String workflowId = String.valueOf(params.get("workflowId"));
DocTemplateDao docTemplateDao = new DocTemplateDao(); DocTemplateDao docTemplateDao = new DocTemplateDao();
int[] docIds = null; int[] docIds = null;
try{ try {
// docIds = docTemplateDao.copyFile(user.getUID(), tableName, fieldName, configId); // docIds = docTemplateDao.copyFile(user.getUID(), tableName, fieldName, configId);
docIds = docTemplateDao.copyFile(user, tableName, fieldName, configId,workflowId,fileFieldId); docIds = docTemplateDao.copyFile(user, tableName, fieldName, configId, workflowId, fileFieldId);
}catch(Exception e){ } catch (Exception e) {
toolUtil.writeErrorLog("复制文件出错: " + e); toolUtil.writeErrorLog("复制文件出错: " + e);
return null; return ApiResult.error("复制文件出错!");
} }
if(docIds == null){ if (docIds == null) {
return ApiResult.error("未查询到附件模板!"); return ApiResult.error("未查询到附件模板!");
} }
/*try{ /*try{
docTemplateDao.updateFileInfo(workflowId,fileFieldId,docIds); docTemplateDao.updateFileInfo(workflowId,fileFieldId,docIds);
}catch(Exception e){ }catch(Exception e){
toolUtil.writeErrorLog("复制文件更新权限和目录出错: " + e); toolUtil.writeErrorLog("复制文件更新权限和目录出错: " + e);
return null; return null;
}*/ }*/
toolUtil.writeDebuggerLog("数据更新成功!" + Arrays.toString(docIds)); toolUtil.writeDebuggerLog("数据更新成功!" + Arrays.toString(docIds));
return ApiResult.success(docIds); return ApiResult.success(docIds);
} }
public static String deleteFile(String docIdStr) { public static String deleteFile(String docIdStr) {
String[] docIds = docIdStr.split(","); String[] docIds = docIdStr.split(",");
DocTemplateDao docTemplateDao = new DocTemplateDao(); DocTemplateDao docTemplateDao = new DocTemplateDao();
int[] array = Arrays.stream(docIds).mapToInt(Integer::parseInt).toArray(); int[] array = Arrays.stream(docIds).mapToInt(Integer::parseInt).toArray();
try { try {
docTemplateDao.deleteFile(array); docTemplateDao.deleteFile(array);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return ApiResult.error("删除失败!"); return ApiResult.error("删除失败!");
} }
return ApiResult.success(array,"删除成功!"); return ApiResult.success(array, "删除成功!");
} }
/** /**
* *
* @param user user *
* @param params * @param user user
* @return * @param params
*/ * @return
public static String queryFilesData(User user, Map<String, Object> params){ */
String listType = Util.null2String(String.valueOf(params.get("listType")),"list"); public static String queryFilesData(User user, Map<String, Object> params) {
int requestid = Util.getIntValue(Util.null2String(String.valueOf(params.get("requestid"))), -1); String listType = Util.null2String(String.valueOf(params.get("listType")), "list");
int desrequestid = Util.getIntValue(Util.null2String(String.valueOf(params.get("desrequestid"))), -1); int requestid = Util.getIntValue(Util.null2String(String.valueOf(params.get("requestid"))), -1);
int isprint = Util.getIntValue(Util.null2String(String.valueOf(params.get("isprint"))), 0); int desrequestid = Util.getIntValue(Util.null2String(String.valueOf(params.get("desrequestid"))), -1);
int workflowid = Util.getIntValue(Util.null2String(String.valueOf(params.get("workflowid"))), 0); int isprint = Util.getIntValue(Util.null2String(String.valueOf(params.get("isprint"))), 0);
String f_weaver_belongto_userid = Util.null2String(String.valueOf(params.get("f_weaver_belongto_userid"))); int workflowid = Util.getIntValue(Util.null2String(String.valueOf(params.get("workflowid"))), 0);
String f_weaver_belongto_usertype = Util.null2String(String.valueOf(params.get("f_weaver_belongto_usertype"))); String f_weaver_belongto_userid = Util.null2String(String.valueOf(params.get("f_weaver_belongto_userid")));
String authStr = Util.null2String(String.valueOf(params.get(RequestAuthenticationConstant.AUTHORITY_STRING))); String f_weaver_belongto_usertype = Util.null2String(String.valueOf(params.get("f_weaver_belongto_usertype")));
String authSignatureStr = Util.null2String(String.valueOf(params.get(RequestAuthenticationConstant.AUTHORITY_SIGNATURESTRING))); String authStr = Util.null2String(String.valueOf(params.get(RequestAuthenticationConstant.AUTHORITY_STRING)));
Map<String,Object> paramsMap = new HashMap<>(); String authSignatureStr = Util.null2String(String.valueOf(params.get(RequestAuthenticationConstant.AUTHORITY_SIGNATURESTRING)));
paramsMap.put("user",user); Map<String, Object> paramsMap = new HashMap<>();
Map<String,Object> retobj; paramsMap.put("user", user);
try { Map<String, Object> retobj;
retobj = FileBiz.getFileDatas(Util.null2String(params.get("docIds")),listType,requestid,desrequestid, try {
isprint,f_weaver_belongto_userid,f_weaver_belongto_usertype,true,false,authStr,authSignatureStr,paramsMap); retobj = FileBiz.getFileDatas(Util.null2String(params.get("docIds")), listType, requestid, desrequestid,
} catch (Exception e) { isprint, f_weaver_belongto_userid, f_weaver_belongto_usertype, true, false, authStr, authSignatureStr, paramsMap);
e.printStackTrace(); } catch (Exception e) {
return ApiResult.error("查询附件信息失败:" + e); e.printStackTrace();
} return ApiResult.error("查询附件信息失败:" + e);
return ApiResult.success(retobj); }
} return ApiResult.success(retobj);
}
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,8 @@
package customization.test; package customization.test;
import aiyh.utils.LabelHtmlUtils;
import aiyh.utils.Util; import aiyh.utils.Util;
import aiyh.utils.entity.LabelHtmlIndex;
import aiyh.utils.fileUtil.ProperUtil; import aiyh.utils.fileUtil.ProperUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.api.aiyh_pcn.patentWall.service.PatentWallService; import com.api.aiyh_pcn.patentWall.service.PatentWallService;
@ -28,380 +30,396 @@ import java.util.regex.Pattern;
public class NewUtilTest { public class NewUtilTest {
@Before @Before
public void before() throws Exception { public void before() throws Exception {
GCONST.setServerName("ecology"); GCONST.setServerName("ecology");
GCONST.setRootPath("H:\\e-cology-dev\\web\\"); GCONST.setRootPath("H:\\e-cology-dev\\web\\");
} }
@AfterClass @AfterClass
public static void after() { public static void after() {
System.out.println("单元测试结束!"); System.out.println("单元测试结束!");
} }
@Test @Test
public void testKey() { public void testKey() {
String key = "aiyh.patent.config[11].public"; String key = "aiyh.patent.config[11].public";
String pattern = "^(aiyh.patent\\.)(?<key>(\\w+))$"; String pattern = "^(aiyh.patent\\.)(?<key>(\\w+))$";
String pattern1 = "^(aiyh.patent\\.)(?<key>(?<objKey>(\\w+))\\.(\\S)+(?!\\[))"; String pattern1 = "^(aiyh.patent\\.)(?<key>(?<objKey>(\\w+))\\.(\\S)+(?!\\[))";
String pattern2 = "^(aiyh.patent\\.)(?<key>(\\w+))(\\[([0-9])+])$"; String pattern2 = "^(aiyh.patent\\.)(?<key>(\\w+))(\\[([0-9])+])$";
String pattern3 = "^(aiyh.patent\\.)(?<key>(\\w+))(\\[(?<index>([0-9])+)])\\.(?<objKey>(\\S)+)$"; String pattern3 = "^(aiyh.patent\\.)(?<key>(\\w+))(\\[(?<index>([0-9])+)])\\.(?<objKey>(\\S)+)$";
Pattern compile = Pattern.compile(pattern); Pattern compile = Pattern.compile(pattern);
Matcher matcher = compile.matcher(key); Matcher matcher = compile.matcher(key);
while (matcher.find()) { while (matcher.find()) {
System.out.println("单一值"); System.out.println("单一值");
System.out.println(matcher.group("key")); System.out.println(matcher.group("key"));
} }
compile = Pattern.compile(pattern2); compile = Pattern.compile(pattern2);
matcher = compile.matcher(key); matcher = compile.matcher(key);
while (matcher.find()) { while (matcher.find()) {
System.out.println("数组"); System.out.println("数组");
System.out.println(matcher.group("key")); System.out.println(matcher.group("key"));
} }
compile = Pattern.compile(pattern3); compile = Pattern.compile(pattern3);
matcher = compile.matcher(key); matcher = compile.matcher(key);
while (matcher.find()) { while (matcher.find()) {
System.out.println("对象数组"); System.out.println("对象数组");
System.out.println(matcher.group("key")); System.out.println(matcher.group("key"));
System.out.println(matcher.group("objKey")); System.out.println(matcher.group("objKey"));
System.out.println(matcher.group("index")); System.out.println(matcher.group("index"));
} }
compile = Pattern.compile(pattern1); compile = Pattern.compile(pattern1);
matcher = compile.matcher(key); matcher = compile.matcher(key);
while (matcher.find()) { while (matcher.find()) {
System.out.println("多个"); System.out.println("多个");
System.out.println(matcher.group("key")); System.out.println(matcher.group("key"));
System.out.println(matcher.group("objKey")); System.out.println(matcher.group("objKey"));
} }
} }
@Test @Test
public void testGetPro() { public void testGetPro() {
String key = "aiyh.patent.config[0]"; String key = "aiyh.patent.config[0]";
String prefix = "aiyh.patent"; String prefix = "aiyh.patent";
String value = "第一个元素"; String value = "第一个元素";
getPro(prefix, key, value); getPro(prefix, key, value);
} }
public void getPro(String prefix, String key, Object value) { public void getPro(String prefix, String key, Object value) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
// result = keyHandler(prefix, key, value, result); // result = keyHandler(prefix, key, value, result);
String key2 = "aiyh.patent.config[1]"; String key2 = "aiyh.patent.config[1]";
// result = keyHandler(prefix, key2, "第二个元素", result); // result = keyHandler(prefix, key2, "第二个元素", result);
System.out.println(JSON.toJSONString(result)); System.out.println(JSON.toJSONString(result));
} }
@Test @Test
public void redPro() { public void redPro() {
String fileName = "test"; String fileName = "test";
String prefix = "aiyh.patentWall"; String prefix = "aiyh.patentWall";
Map<String, Object> result = Util.readProperties2Map(fileName, prefix); Map<String, Object> result = Util.readProperties2Map(fileName, prefix);
System.out.println(JSON.toJSONString(result)); System.out.println(JSON.toJSONString(result));
} }
public Map<String, Object> getProperties2Map(String fileName, String prefix) { public Map<String, Object> getProperties2Map(String fileName, String prefix) {
String propertyPath = GCONST.getPropertyPath(); String propertyPath = GCONST.getPropertyPath();
if (StringUtil.isNullOrEmpty(fileName)) { if (StringUtil.isNullOrEmpty(fileName)) {
return null; return null;
} }
if (fileName.contains(".properties")) { if (fileName.contains(".properties")) {
fileName.replace(".properties", ""); fileName.replace(".properties", "");
} }
String path = propertyPath + "prop2map" + File.separator + fileName + ".properties"; String path = propertyPath + "prop2map" + File.separator + fileName + ".properties";
ProperUtil prop = new ProperUtil(); ProperUtil prop = new ProperUtil();
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
InputStream inputStream = null; InputStream inputStream = null;
try { try {
inputStream = new BufferedInputStream(new FileInputStream(path)); inputStream = new BufferedInputStream(new FileInputStream(path));
prop.load(inputStream); prop.load(inputStream);
// Enumeration<?> enumeration = prop.propertyNames(); // Enumeration<?> enumeration = prop.propertyNames();
// 顺序读取 // 顺序读取
Enumeration<?> enumeration = prop.keys(); Enumeration<?> enumeration = prop.keys();
while (enumeration.hasMoreElements()) { while (enumeration.hasMoreElements()) {
String key = (String) enumeration.nextElement(); String key = (String) enumeration.nextElement();
String value = prop.getProperty(key); String value = prop.getProperty(key);
System.out.println(key); System.out.println(key);
keyHandler(prefix, key, value, map); keyHandler(prefix, key, value, map);
; ;
} }
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException("找不到文件:" + path); throw new RuntimeException("找不到文件:" + path);
} finally { } finally {
try { try {
if (inputStream != null) { if (inputStream != null) {
inputStream.close(); inputStream.close();
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
return map; return map;
} }
public Map<String, Object> keyHandler(String prePrefix, String key, Object value, Map<String, Object> preResult) { public Map<String, Object> keyHandler(String prePrefix, String key, Object value, Map<String, Object> preResult) {
String objRegex = "^(" + prePrefix + "\\.)(?<key>(\\w+))$"; String objRegex = "^(" + prePrefix + "\\.)(?<key>(\\w+))$";
Pattern compile = Pattern.compile(objRegex); Pattern compile = Pattern.compile(objRegex);
Matcher matcher = compile.matcher(key); Matcher matcher = compile.matcher(key);
if (matcher.find()) { if (matcher.find()) {
// 只匹配前缀.key=value模式的 // 只匹配前缀.key=value模式的
String resultKey = matcher.group("key"); String resultKey = matcher.group("key");
preResult.put(resultKey, prop2MapPutValue(value)); preResult.put(resultKey, prop2MapPutValue(value));
} }
String moreKey = "^(" + prePrefix + "\\.)(?<key>(?<objKey>(\\w+))\\.(\\S)+(?!\\[))"; String moreKey = "^(" + prePrefix + "\\.)(?<key>(?<objKey>(\\w+))\\.(\\S)+(?!\\[))";
compile = Pattern.compile(moreKey); compile = Pattern.compile(moreKey);
matcher = compile.matcher(key); matcher = compile.matcher(key);
if (matcher.find()) { if (matcher.find()) {
// 匹配前缀.key1.key2=value模式的 // 匹配前缀.key1.key2=value模式的
String objKey = matcher.group("objKey"); String objKey = matcher.group("objKey");
String prefixStr = prePrefix + "." + objKey; String prefixStr = prePrefix + "." + objKey;
Map<String, Object> valueMap; Map<String, Object> valueMap;
if (preResult.containsKey(objKey)) { if (preResult.containsKey(objKey)) {
valueMap = (Map<String, Object>) preResult.get(objKey); valueMap = (Map<String, Object>) preResult.get(objKey);
keyHandler(prefixStr, key, value, valueMap); keyHandler(prefixStr, key, value, valueMap);
return null; return null;
} }
valueMap = new HashMap<>(); valueMap = new HashMap<>();
keyHandler(prefixStr, key, value, valueMap); keyHandler(prefixStr, key, value, valueMap);
preResult.put(objKey, valueMap); preResult.put(objKey, valueMap);
return null; return null;
} }
String strList = "^(" + prePrefix + "\\.)(?<key>(\\w+))(\\[(?<index>([0-9])+)])$"; String strList = "^(" + prePrefix + "\\.)(?<key>(\\w+))(\\[(?<index>([0-9])+)])$";
compile = Pattern.compile(strList); compile = Pattern.compile(strList);
matcher = compile.matcher(key); matcher = compile.matcher(key);
if (matcher.find()) { if (matcher.find()) {
// 匹配前缀.key[0]=value模式的 // 匹配前缀.key[0]=value模式的
String objKey = matcher.group("key"); String objKey = matcher.group("key");
int index = Integer.parseInt(matcher.group("index")); int index = Integer.parseInt(matcher.group("index"));
if (preResult.containsKey(objKey)) { if (preResult.containsKey(objKey)) {
// 存在值 // 存在值
List<Object> valueList = (List<Object>) preResult.get(objKey); List<Object> valueList = (List<Object>) preResult.get(objKey);
if (index >= valueList.size()) { if (index >= valueList.size()) {
valueList.add(prop2MapPutValue(value)); valueList.add(prop2MapPutValue(value));
} else { } else {
valueList.set(index, prop2MapPutValue(value)); valueList.set(index, prop2MapPutValue(value));
} }
return null; return null;
} }
List<Object> valueList = new ArrayList<>(); List<Object> valueList = new ArrayList<>();
valueList.add(prop2MapPutValue(value)); valueList.add(prop2MapPutValue(value));
preResult.put(objKey, valueList); preResult.put(objKey, valueList);
return null; return null;
} }
String objArray = "^(" + prePrefix + "\\.)(?<arrKey>(\\w+))(\\[(?<index>([0-9])+)])\\.(?<objKey>(\\S)+)$"; String objArray = "^(" + prePrefix + "\\.)(?<arrKey>(\\w+))(\\[(?<index>([0-9])+)])\\.(?<objKey>(\\S)+)$";
// String objArray = "^("+prePrefix+"\\.)(?<arrKey>(\\w+))(\\[(?<index>([0-9])+)])(\\.(?<objKey>(\\S)+))+"; // String objArray = "^("+prePrefix+"\\.)(?<arrKey>(\\w+))(\\[(?<index>([0-9])+)])(\\.(?<objKey>(\\S)+))+";
compile = Pattern.compile(objArray); compile = Pattern.compile(objArray);
matcher = compile.matcher(key); matcher = compile.matcher(key);
if (matcher.find()) { if (matcher.find()) {
// 匹配前缀.key[0].name=value的模式 // 匹配前缀.key[0].name=value的模式
String arrKey = matcher.group("arrKey"); String arrKey = matcher.group("arrKey");
String objKey = matcher.group("objKey"); String objKey = matcher.group("objKey");
int index = Integer.parseInt(matcher.group("index")); int index = Integer.parseInt(matcher.group("index"));
List<Map<String, Object>> mapList; List<Map<String, Object>> mapList;
if (preResult.containsKey(arrKey)) { if (preResult.containsKey(arrKey)) {
// 存在 // 存在
mapList = (List<Map<String, Object>>) preResult.get(arrKey); mapList = (List<Map<String, Object>>) preResult.get(arrKey);
// mapList // mapList
Map<String, Object> valueMap; Map<String, Object> valueMap;
if (index >= mapList.size()) { if (index >= mapList.size()) {
valueMap = new HashMap<>(); valueMap = new HashMap<>();
valueMap.put(objKey, prop2MapPutValue(value)); valueMap.put(objKey, prop2MapPutValue(value));
mapList.add(valueMap); mapList.add(valueMap);
return null; return null;
} }
valueMap = mapList.get(index); valueMap = mapList.get(index);
String arrMoreKey = "(?<key>(\\w+))\\.(\\S)+(?!\\[)"; String arrMoreKey = "(?<key>(\\w+))\\.(\\S)+(?!\\[)";
Pattern arrMoreKeyCompile = Pattern.compile(arrMoreKey); Pattern arrMoreKeyCompile = Pattern.compile(arrMoreKey);
Matcher arrMoreKeyMatcher = arrMoreKeyCompile.matcher(objKey); Matcher arrMoreKeyMatcher = arrMoreKeyCompile.matcher(objKey);
if (arrMoreKeyMatcher.find()) { if (arrMoreKeyMatcher.find()) {
String arrMoreObjKey = arrMoreKeyMatcher.group("key"); String arrMoreObjKey = arrMoreKeyMatcher.group("key");
Map<String, Object> arrMoreValue; Map<String, Object> arrMoreValue;
if (valueMap.containsKey(arrMoreObjKey)) { if (valueMap.containsKey(arrMoreObjKey)) {
arrMoreValue = (Map<String, Object>) valueMap.get(arrMoreObjKey); arrMoreValue = (Map<String, Object>) valueMap.get(arrMoreObjKey);
keyHandler(arrMoreObjKey, objKey, value, arrMoreValue); keyHandler(arrMoreObjKey, objKey, value, arrMoreValue);
return null; return null;
} }
arrMoreValue = new HashMap<>(); arrMoreValue = new HashMap<>();
keyHandler(arrMoreObjKey, objKey, value, arrMoreValue); keyHandler(arrMoreObjKey, objKey, value, arrMoreValue);
valueMap.put(arrMoreObjKey, arrMoreValue); valueMap.put(arrMoreObjKey, arrMoreValue);
return null; return null;
} }
arrMoreKey = "(?<key>(\\w+))(\\[(?<index>([0-9])+)])$"; arrMoreKey = "(?<key>(\\w+))(\\[(?<index>([0-9])+)])$";
arrMoreKeyCompile = Pattern.compile(arrMoreKey); arrMoreKeyCompile = Pattern.compile(arrMoreKey);
arrMoreKeyMatcher = arrMoreKeyCompile.matcher(objKey); arrMoreKeyMatcher = arrMoreKeyCompile.matcher(objKey);
if (arrMoreKeyMatcher.find()) { if (arrMoreKeyMatcher.find()) {
String arrMoreArrKey = arrMoreKeyMatcher.group("key"); String arrMoreArrKey = arrMoreKeyMatcher.group("key");
int arrMoreIndex = Integer.parseInt(arrMoreKeyMatcher.group("index")); int arrMoreIndex = Integer.parseInt(arrMoreKeyMatcher.group("index"));
List<Object> arrMoreListValue; List<Object> arrMoreListValue;
if (valueMap.containsKey(arrMoreArrKey)) { if (valueMap.containsKey(arrMoreArrKey)) {
// 存在值 // 存在值
arrMoreListValue = (List<Object>) valueMap.get(arrMoreArrKey); arrMoreListValue = (List<Object>) valueMap.get(arrMoreArrKey);
if (arrMoreIndex >= arrMoreListValue.size()) { if (arrMoreIndex >= arrMoreListValue.size()) {
arrMoreListValue.add(prop2MapPutValue(value)); arrMoreListValue.add(prop2MapPutValue(value));
} else { } else {
arrMoreListValue.set(arrMoreIndex, prop2MapPutValue(value)); arrMoreListValue.set(arrMoreIndex, prop2MapPutValue(value));
} }
return null; return null;
} }
arrMoreListValue = new ArrayList<>(); arrMoreListValue = new ArrayList<>();
arrMoreListValue.add(prop2MapPutValue(value)); arrMoreListValue.add(prop2MapPutValue(value));
valueMap.put(arrMoreArrKey, arrMoreListValue); valueMap.put(arrMoreArrKey, arrMoreListValue);
return null; return null;
} }
// 直接添加 // 直接添加
valueMap.put(objKey, prop2MapPutValue(value)); valueMap.put(objKey, prop2MapPutValue(value));
return null; return null;
} }
// 不存在 // 不存在
mapList = new ArrayList<>(); mapList = new ArrayList<>();
Map<String, Object> valueMap = new HashMap<>(); Map<String, Object> valueMap = new HashMap<>();
valueMap.put(objKey, prop2MapPutValue(value)); valueMap.put(objKey, prop2MapPutValue(value));
mapList.add(valueMap); mapList.add(valueMap);
preResult.put(arrKey, mapList); preResult.put(arrKey, mapList);
} }
return null; return null;
} }
public Object prop2MapPutValue(Object value) { public Object prop2MapPutValue(Object value) {
if (value == null) { if (value == null) {
return null; return null;
} }
String valueStr = String.valueOf(value).trim(); String valueStr = String.valueOf(value).trim();
if (valueStr.startsWith("\"") && valueStr.endsWith("\"")) { if (valueStr.startsWith("\"") && valueStr.endsWith("\"")) {
return valueStr.substring(1, valueStr.length() - 1); return valueStr.substring(1, valueStr.length() - 1);
} }
if (valueStr.contains(",")) { if (valueStr.contains(",")) {
return valueStr.split(","); return valueStr.split(",");
} }
return value; return value;
} }
@Test @Test
public void testSubstr() { public void testSubstr() {
System.out.println("\"这个是文本框\"".trim().substring(1, "\"这个是文本框\"".trim().length() - 1)); System.out.println("\"这个是文本框\"".trim().substring(1, "\"这个是文本框\"".trim().length() - 1));
} }
@Test @Test
public void testSplit() { public void testSplit() {
String str = "12,343,89\\,99"; String str = "12,343,89\\,99";
String str1 = "abcd'efg'hig?'klmn"; String str1 = "abcd'efg'hig?'klmn";
String[] data = str1.split("(?<!\\?)'"); String[] data = str1.split("(?<!\\?)'");
System.out.println(Arrays.toString(data)); System.out.println(Arrays.toString(data));
String[] split = str.split("(?<!\\\\),"); String[] split = str.split("(?<!\\\\),");
System.out.println(Arrays.toString(split)); System.out.println(Arrays.toString(split));
for (int i = 0; i < split.length; i++) { for (int i = 0; i < split.length; i++) {
split[i] = split[i].replaceAll("\\\\,", ","); split[i] = split[i].replaceAll("\\\\,", ",");
} }
for (String s : split) { for (String s : split) {
System.out.println(s); System.out.println(s);
} }
} }
@Test @Test
public void testLanguage() { public void testLanguage() {
String selectName = "~`~`7 其它 不知道 管他呢,阿斯顿发的`~`8 other`~`9 其它`~`~"; String selectName = "~`~`7 其它 不知道 管他呢,阿斯顿发的`~`8 other`~`9 其它`~`~";
String showName = selectName; String showName = selectName;
if (selectName.startsWith("~`~`") && selectName.endsWith("`~`~")) { if (selectName.startsWith("~`~`") && selectName.endsWith("`~`~")) {
String pattern = "(`~`7 )(?<lable>(\\w*|\\W*|[\\u4e00-\\u9fa5]*))(`~`)"; String pattern = "(`~`7 )(?<lable>(\\w*|\\W*|[\\u4e00-\\u9fa5]*))(`~`)";
Pattern compile = Pattern.compile(pattern); Pattern compile = Pattern.compile(pattern);
Matcher matcher = compile.matcher(selectName); Matcher matcher = compile.matcher(selectName);
if (matcher.find()) { if (matcher.find()) {
showName = matcher.group("lable"); showName = matcher.group("lable");
} }
} }
System.out.println(showName); System.out.println(showName);
} }
@Test @Test
public void testPatentServer() { public void testPatentServer() {
PatentWallService patentWallService = new PatentWallService(); PatentWallService patentWallService = new PatentWallService();
List<SearchInputVO> inputList = patentWallService.getSearchList("patentWall", 8); List<SearchInputVO> inputList = patentWallService.getSearchList("patentWall", 8);
System.out.println(JSON.toJSONString(inputList)); System.out.println(JSON.toJSONString(inputList));
List<PatentVO> patentWallList = patentWallService.getList(null, "patentWall"); List<PatentVO> patentWallList = patentWallService.getList(null, "patentWall");
System.out.println(JSON.toJSONString(patentWallList)); System.out.println(JSON.toJSONString(patentWallList));
} }
@Test @Test
public void testRegx() { public void testRegx() {
String pattern = "\\$\\{(?<field>(\\s|\\S)+?)}"; String pattern = "\\$\\{(?<field>(\\s|\\S)+?)}";
Pattern compile = Pattern.compile(pattern); Pattern compile = Pattern.compile(pattern);
Matcher matcher = compile.matcher("${id}"); Matcher matcher = compile.matcher("${id}");
if (matcher.find()) { if (matcher.find()) {
System.out.println(matcher.group("field")); System.out.println(matcher.group("field"));
} }
} }
@Test @Test
public void testSplic() { public void testSplic() {
List<Integer> list = new ArrayList<>(); List<Integer> list = new ArrayList<>();
list.add(0); list.add(0);
list.add(1); list.add(1);
list.add(2); list.add(2);
list.add(3); list.add(3);
list.add(4); list.add(4);
list.add(5); list.add(5);
list.add(6); list.add(6);
System.out.println(list); System.out.println(list);
System.out.println(list.subList(0, 2)); System.out.println(list.subList(0, 2));
list.removeAll(list.subList(0, 2)); list.removeAll(list.subList(0, 2));
System.out.println(list); System.out.println(list);
} }
@Test @Test
public void test() { public void test() {
String bizContent = "{\"contractExtension\":\".pdf\",\"contractTitle\":\"PCN Template - Non-Disclosure Agreement (Corporate).pdf\",\"uploadType\":1,\"customerNo\":\"ecef845ba95a409393cb66271a41b0a6\"}"; String bizContent = "{\"contractExtension\":\".pdf\",\"contractTitle\":\"PCN Template - Non-Disclosure Agreement (Corporate).pdf\",\"uploadType\":1,\"customerNo\":\"ecef845ba95a409393cb66271a41b0a6\"}";
System.out.println(cn.hutool.core.util.URLUtil.encodeAll(bizContent, Charset.forName("UTF-8"))); System.out.println(cn.hutool.core.util.URLUtil.encodeAll(bizContent, Charset.forName("UTF-8")));
} }
@Test @Test
public void testReg() { public void testReg() {
String var15 = "<html> \n" + String var15 = "<html> \n" +
" <head> \n" + " <head> \n" +
" <title></title> \n" + " <title></title> \n" +
" <link href=\"/cloudstore/resource/pc/ckeditor-4.6.2/weaver/contents.css\" rel=\"stylesheet\" type=\"text/css\" /> \n" + " <link href=\"/cloudstore/resource/pc/ckeditor-4.6.2/weaver/contents.css\" rel=\"stylesheet\" type=\"text/css\" /> \n" +
" <link href=\"/cloudstore/resource/pc/ckeditor-4.6.2/plugins/copyformatting/styles/copyformatting.css\" rel=\"stylesheet\" type=\"text/css\" /> \n" + " <link href=\"/cloudstore/resource/pc/ckeditor-4.6.2/plugins/copyformatting/styles/copyformatting.css\" rel=\"stylesheet\" type=\"text/css\" /> \n" +
" <link href=\"/cloudstore/resource/pc/ckeditor-4.6.2/plugins/tableselection/styles/tableselection.css\" rel=\"stylesheet\" type=\"text/css\" /> \n" + " <link href=\"/cloudstore/resource/pc/ckeditor-4.6.2/plugins/tableselection/styles/tableselection.css\" rel=\"stylesheet\" type=\"text/css\" /> \n" +
" <link href=\"/cloudstore/resource/pc/ckeditor-4.6.2/plugins/image2/styles/image2.css\" rel=\"stylesheet\" type=\"text/css\" /> \n" + " <link href=\"/cloudstore/resource/pc/ckeditor-4.6.2/plugins/image2/styles/image2.css\" rel=\"stylesheet\" type=\"text/css\" /> \n" +
" <link href=\"/cloudstore/resource/pc/ckeditor-4.6.2/plugins/widget/styles/widget.css\" rel=\"stylesheet\" type=\"text/css\" /> \n" + " <link href=\"/cloudstore/resource/pc/ckeditor-4.6.2/plugins/widget/styles/widget.css\" rel=\"stylesheet\" type=\"text/css\" /> \n" +
" </head> \n" + " </head> \n" +
" <body style=\"height: 747px;\"> \n" + " <body style=\"height: 747px;\"> \n" +
" <p>< img alt=\"\" src=\"/weaver/weaver.file.FileDownload?fileid=acdde79d8027d30e809be35a885a28eb184a3d7609b33666049ac12a48c5c8c3c10908eae8d1f6d650bfffce6db986fb5069726005eaf18c1\" /></p > \n" + " <p>< img alt=\"\" src=\"/weaver/weaver.file.FileDownload?fileid=acdde79d8027d30e809be35a885a28eb184a3d7609b33666049ac12a48c5c8c3c10908eae8d1f6d650bfffce6db986fb5069726005eaf18c1\" /></p > \n" +
" </body> \n" + " </body> \n" +
" </html> \n" + " </html> \n" +
" "; " ";
ArrayList var17 = Util.matchAll(var15, "/weaver/weaver.file.FileDownload\\?fileid=([a-z0-9]+)", 1, 1); ArrayList var17 = Util.matchAll(var15, "/weaver/weaver.file.FileDownload\\?fileid=([a-z0-9]+)", 1, 1);
System.out.println(var17.size()); System.out.println(var17.size());
System.out.println(var17); System.out.println(var17);
} }
@Test @Test
public void testMessage() { public void testMessage() {
Set<String> userIdList = new HashSet<>(); //接收人id Set<String> userIdList = new HashSet<>(); //接收人id
userIdList.add("22"); userIdList.add("22");
userIdList.add("1"); userIdList.add("1");
String linkUrl = "/spa/cube/index.html#/main/cube/search?customid=36"; //PC端链接 String linkUrl = "/spa/cube/index.html#/main/cube/search?customid=36"; //PC端链接
String linkMobileUrl = ""; //移动端链接 String linkMobileUrl = ""; //移动端链接
String title = "我是标题淦"; String title = "我是标题淦";
String context = "我是内容啊啊啊"; String context = "我是内容啊啊啊";
try { try {
MessageBean messageBean = Util_Message.createMessage(MessageType.newInstance(1146), userIdList, title, context, linkUrl, linkMobileUrl); MessageBean messageBean = Util_Message.createMessage(MessageType.newInstance(1146), userIdList, title, context, linkUrl, linkMobileUrl);
messageBean.setCreater(1);//创建人id messageBean.setCreater(1);//创建人id
Util_Message.store(messageBean); Util_Message.store(messageBean);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@Test
public void testGetTime() {
System.out.println(System.currentTimeMillis());
System.out.println(System.currentTimeMillis());
}
@Test
public void testPro() {
LabelHtmlUtils labelHtmlUtils = new LabelHtmlUtils("aiyh.htmlLabel.porsche");
Map<String, Object> faDDContractController = labelHtmlUtils.getHtmlLabelMap("FaDDContractController");
System.out.println(faDDContractController);
LabelHtmlIndex labelHtmlIndex = labelHtmlUtils.getLabelHtmlIndex(faDDContractController, "singedErr");
System.out.println(labelHtmlIndex);
}
} }

View File

@ -117,13 +117,15 @@ public class AddCustomer_Action extends ToolUtil implements Action {
} }
} catch (LoginIdRepeatException e) { } catch (LoginIdRepeatException e) {
this.writeErrorLog(e + "\n"); this.writeErrorLog(e + "\n");
this.request.getRequestManager().setMessagecontent("登录名重复,请重新输入登录名"); this.request.getRequestManager().setMessagecontent(aiyh.utils.Util.getHtmlLabelName(-91703,
this.request.getRequestManager().setMessageid("登录名重复"); request.getRequestManager().getUser().getLanguage(), "登录名重复,请重新输入登录名"));
this.request.getRequestManager().setMessageid("1");
return Action.FAILURE_AND_CONTINUE; return Action.FAILURE_AND_CONTINUE;
} catch (Exception e) { } catch (Exception e) {
this.writeDebuggerLog("insert customer error!"); this.writeDebuggerLog("insert customer error!");
this.writeDebuggerLog(e + "\n"); this.writeDebuggerLog(e + "\n");
this.request.getRequestManager().setMessagecontent("生成外部用户错误,请联系管理员!"); this.request.getRequestManager().setMessagecontent(aiyh.utils.Util.getHtmlLabelName(-91704,
request.getRequestManager().getUser().getLanguage(), "生成外部用户错误,请联系管理员!"));
this.request.getRequestManager().setMessageid("2"); this.request.getRequestManager().setMessageid("2");
} finally { } finally {
this.writeDebuggerLog(className, "------------" + className + " End -----------------"); this.writeDebuggerLog(className, "------------" + className + " End -----------------");