diff --git a/com/api/aiyh_pcn/patentWall/service/PatentWallService.java b/com/api/aiyh_pcn/patentWall/service/PatentWallService.java index 3e3d658..2e6caea 100644 --- a/com/api/aiyh_pcn/patentWall/service/PatentWallService.java +++ b/com/api/aiyh_pcn/patentWall/service/PatentWallService.java @@ -5,11 +5,17 @@ import aiyh.utils.zwl.common.ToolUtil; import com.alibaba.fastjson.JSON; import com.api.aiyh_pcn.patentWall.dao.PatentWallMapping; import com.api.aiyh_pcn.patentWall.dto.FilterWhere; +import com.api.aiyh_pcn.patentWall.vo.LinkUrlVO; import com.api.aiyh_pcn.patentWall.vo.PatentVO; import com.api.aiyh_pcn.patentWall.vo.SearchInputVO; import com.api.aiyh_pcn.patentWall.vo.SelectOptionsVo; import weaver.conn.RecordSet; +import java.beans.BeanInfo; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -144,38 +150,57 @@ public class PatentWallService { Map config = new HashMap<>(patentWallConf); for (Map.Entry entry : patentWallConf.entrySet()) { String patentVoField = entry.getKey(); - String parsing = String.valueOf(entry.getValue()); -// TODO 值解析 -// 解析 ${}类型的参数,直接替换 - String pattern = "\\$\\{(?(\\s|\\S)+?)}"; - Pattern compile = Pattern.compile(pattern); - Matcher matcher = compile.matcher(parsing); - while (matcher.find()) { - parsing = parsing.replaceFirst(pattern, Util.null2String(data.get(matcher.group("field")))); +// linkList + String parsing = null; +// 值解析 + if("linkList".equals(patentVoField)){ + List linkUrlVOS = new ArrayList<>(); + List> linkUrlList = (List>) entry.getValue(); + for (Map linkUrlMap : linkUrlList) { + LinkUrlVO linkUrlVO = new LinkUrlVO(); + BeanInfo beanInfo = null; + try { + beanInfo = Introspector.getBeanInfo(LinkUrlVO.class, Object.class); + } catch (IntrospectionException e) { + e.printStackTrace(); + toolUtil.writeDebuggerLog("获取beanInfo错误"); + continue; + } + PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); + for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { + String keyName = propertyDescriptor.getName(); + String parsingValue = String.valueOf(linkUrlMap.get(keyName)); + parsingValue = handleParsingConf(parsingValue,data,args); + // 清除参数信息 + args.clear(); + if(propertyDescriptor.getPropertyType().equals(Integer.class)){ + try { + propertyDescriptor.getWriteMethod().invoke(linkUrlVO,Integer.valueOf(parsingValue)); + } catch (IllegalAccessException | InvocationTargetException e) { + toolUtil.writeErrorLog("设置值失败,调用beanInfo的set方法错误"); + e.printStackTrace(); + } + }else { + try { + propertyDescriptor.getWriteMethod().invoke(linkUrlVO,parsingValue); + } catch (IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + toolUtil.writeErrorLog("设置值失败,调用beanInfo的set方法错误"); + } + } + } + linkUrlVOS.add(linkUrlVO); + } + config.replace(patentVoField, linkUrlVOS); + }else{ + parsing = String.valueOf(entry.getValue()); + parsing = handleParsingConf(parsing,data,args); + // 修改数据 + config.replace(patentVoField, parsing); + // 清除参数信息 + args.clear(); } -// 解析#{}类型的参数,替换为?并按照顺序收集args - pattern = "#\\{(?(\\s|\\S)+?)}"; - compile = Pattern.compile(pattern); - matcher = compile.matcher(parsing); - while (matcher.find()) { - parsing = parsing.replaceFirst(pattern, "?"); - args.add(Util.null2String(data.get(matcher.group("field")))); - } -// 解析#sql{}类型的参数,并执行SQL,获取到SQL的值 - pattern = "#sql\\{(?([\\s\\S])+?)}"; - compile = Pattern.compile(pattern); - matcher = compile.matcher(parsing); - while (matcher.find()) { - String sqlStr = matcher.group("sqlStr"); - toolUtil.writeDebuggerLog(String.format("执行SQL: {%s} ---> 参数: {%s}", sqlStr, args)); - rs.executeQuery(sqlStr, args); - rs.next(); - parsing = parsing.replaceFirst(pattern, Util.null2String(rs.getString(1)));; - } -// 清除参数信息 - args.clear(); -// 修改数据 - config.replace(patentVoField, parsing); + } PatentVO patentVO = null; try { @@ -189,6 +214,37 @@ public class PatentWallService { return list; } + public String handleParsingConf(String parsing, Map data,List args){ + // TODO 值解析 +// 解析 ${}类型的参数,直接替换 + String pattern = "\\$\\{(?(\\s|\\S)+?)}"; + Pattern compile = Pattern.compile(pattern); + Matcher matcher = compile.matcher(parsing); + while (matcher.find()) { + parsing = parsing.replaceFirst(pattern, Util.null2String(data.get(matcher.group("field")))); + } +// 解析#{}类型的参数,替换为?并按照顺序收集args + pattern = "#\\{(?(\\s|\\S)+?)}"; + compile = Pattern.compile(pattern); + matcher = compile.matcher(parsing); + while (matcher.find()) { + parsing = parsing.replaceFirst(pattern, "?"); + args.add(Util.null2String(data.get(matcher.group("field")))); + } +// 解析#sql{}类型的参数,并执行SQL,获取到SQL的值 + pattern = "#sql\\{(?([\\s\\S])+?)}"; + compile = Pattern.compile(pattern); + matcher = compile.matcher(parsing); + while (matcher.find()) { + String sqlStr = matcher.group("sqlStr"); + toolUtil.writeDebuggerLog(String.format("执行SQL: {%s} ---> 参数: {%s}", sqlStr, args)); + rs.executeQuery(sqlStr, args); + rs.next(); + parsing = parsing.replaceFirst(pattern, Util.null2String(rs.getString(1)));; + } + return parsing; + } + public List> handleFilterWhere(List filterWheres, String tableName) { StringBuilder whereBuilder = new StringBuilder(" where "); diff --git a/com/api/aiyh_pcn/patentWall/vo/LinkUrlVO.java b/com/api/aiyh_pcn/patentWall/vo/LinkUrlVO.java new file mode 100644 index 0000000..15b4a74 --- /dev/null +++ b/com/api/aiyh_pcn/patentWall/vo/LinkUrlVO.java @@ -0,0 +1,19 @@ +package com.api.aiyh_pcn.patentWall.vo; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * @author EBU7-dev1-ayh + * @create 2021/12/6 0006 10:59 + */ + +@Getter +@Setter +@ToString +public class LinkUrlVO { + private String labelName; + private Integer labelIndex; + private String linkUrl; +} diff --git a/com/api/aiyh_pcn/patentWall/vo/PatentVO.java b/com/api/aiyh_pcn/patentWall/vo/PatentVO.java index a9d3cd3..fa49504 100644 --- a/com/api/aiyh_pcn/patentWall/vo/PatentVO.java +++ b/com/api/aiyh_pcn/patentWall/vo/PatentVO.java @@ -4,6 +4,8 @@ import lombok.Getter; import lombok.Setter; import lombok.ToString; +import java.util.List; + /** * @author EBU7-dev1-ayh * @create 2021/11/25 0025 15:31 @@ -16,7 +18,8 @@ public class PatentVO { private String id; private String icon; private String activeIcon; - private String linkUrl; +// private String linkUrl; + private List linkList; private String title; private String docId; private String imageFileId; diff --git a/customization/test/NewTest.java b/customization/test/NewTest.java index c00f170..1b7fdaf 100644 --- a/customization/test/NewTest.java +++ b/customization/test/NewTest.java @@ -16,6 +16,7 @@ import com.alibaba.fastjson.JSONObject; import com.api.aiyh_pcn.fadada.dao.FaDDServiceMapping; import com.api.aiyh_pcn.fadada.service.impl.FaDDServiceImpl; import com.api.aiyh_pcn.fadada.util.FaDDRequestUtils; +import com.api.aiyh_pcn.patentWall.vo.LinkUrlVO; import com.weaver.general.TimeUtil; import org.apache.axiom.util.base64.Base64Utils; import org.apache.commons.codec.binary.Hex; @@ -33,7 +34,13 @@ import weaver.hrm.User; import weaver.soa.workflow.FileProcessor; import weaver.workflow.workflow.WorkflowVersion; +import java.beans.BeanInfo; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; import java.io.*; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; @@ -497,12 +504,23 @@ public class NewTest extends BaseTest { } @Test - public void tesetLong(){ -// SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook(); -// Sheet sheet = sxssfWorkbook.createSheet("人员信息"); -// Row desc = sheet.createRow(0); -// desc.createCell(1).setCellValue(null); -// System.out.println(i); + public void tesetLong() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, IntrospectionException { + LinkUrlVO linkUrlVO = new LinkUrlVO(); + String linkUrl = "linkUrl"; + BeanInfo beanInfo = Introspector.getBeanInfo(LinkUrlVO.class,Object.class); + PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); + for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { + System.out.println(propertyDescriptor.getName()); + if (propertyDescriptor.getPropertyType().equals(Integer.class)){ + propertyDescriptor.getWriteMethod().invoke(linkUrlVO,1); + }else{ + propertyDescriptor.getWriteMethod().invoke(linkUrlVO,propertyDescriptor.getName()); + } + } +// Class aClass = linkUrlVO.getClass(); +// Method method = aClass.getMethod("set" + linkUrl.substring(0, 1).toUpperCase() + linkUrl.substring(1)); +// method.invoke(linkUrlVO,"https://baidu.com"); + System.out.println(linkUrlVO); } } diff --git a/customization/test/NewUtilTest.java b/customization/test/NewUtilTest.java index 46922c9..6ba52e6 100644 --- a/customization/test/NewUtilTest.java +++ b/customization/test/NewUtilTest.java @@ -360,4 +360,28 @@ public class NewUtilTest { 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 = " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "

< img alt=\"\" src=\"/weaver/weaver.file.FileDownload?fileid=acdde79d8027d30e809be35a885a28eb184a3d7609b33666049ac12a48c5c8c3c10908eae8d1f6d650bfffce6db986fb5069726005eaf18c1\" />

\n" + + " \n" + + " \n" + + " "; + + ArrayList var17 = Util.matchAll(var15, "/weaver/weaver.file.FileDownload\\?fileid=([a-z0-9]+)", 1, 1); + + System.out.println(var17.size()); + System.out.println(var17); + } }