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

File diff suppressed because it is too large Load Diff

View File

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