一些工具的开发
parent
3e4971c2d4
commit
d161236561
|
@ -25,11 +25,11 @@
|
|||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="classbean" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.22" level="project" />
|
||||
<orderEntry type="library" name="Maven: cn.hutool:hutool-all:5.7.12" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.drewnoakes:metadata-extractor:2.16.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.adobe.xmp:xmpcore:6.1.11" level="project" />
|
||||
<orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi-excelant:3.12" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi:3.12" level="project" />
|
||||
|
@ -43,6 +43,5 @@
|
|||
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:3.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:2.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: stax:stax-api:1.0.1" level="project" />
|
||||
<orderEntry type="library" name="classbean" level="project" />
|
||||
</component>
|
||||
</module>
|
15
pom.xml
15
pom.xml
|
@ -50,6 +50,7 @@
|
|||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- 图片efi信息,识别ps,贵酒-->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.drewnoakes</groupId>
|
||||
<artifactId>metadata-extractor</artifactId>
|
||||
|
@ -95,13 +96,13 @@
|
|||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
<annotationProcessors>
|
||||
<annotationProcessor>
|
||||
<groupId>org.projectors</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</annotationProcessor>
|
||||
</annotationProcessors>
|
||||
<!-- <annotationProcessors>-->
|
||||
<!-- <annotationProcessor>-->
|
||||
<!-- <groupId>org.projectors</groupId>-->
|
||||
<!-- <artifactId>lombok</artifactId>-->
|
||||
<!-- <version>${lombok.version}</version>-->
|
||||
<!-- </annotationProcessor>-->
|
||||
<!-- </annotationProcessors>-->
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
|
|
@ -6,6 +6,7 @@ import aiyh.utils.fileUtil.ProperUtil;
|
|||
import aiyh.utils.logger.LoggerUtil;
|
||||
import aiyh.utils.mapUtil.UtilHashMap;
|
||||
import aiyh.utils.mapUtil.UtilLinkedHashMap;
|
||||
import aiyh.utils.mapper.UtilMapper;
|
||||
import aiyh.utils.recordset.RecordsetUtil;
|
||||
import aiyh.utils.service.UtilService;
|
||||
import aiyh.utils.sqlUtil.builderSql.impl.BuilderSqlImpl;
|
||||
|
@ -16,7 +17,7 @@ import aiyh.utils.zwl.common.ToolUtil;
|
|||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.ibm.icu.text.SimpleDateFormat;
|
||||
import org.apache.dubbo.common.utils.CollectionUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.*;
|
||||
import org.h2.util.StringUtils;
|
||||
import weaver.common.util.string.StringUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
|
@ -64,10 +65,10 @@ public class Util extends weaver.general.Util {
|
|||
private static final String LOGGER_NAME = "cusAYH";
|
||||
static ToolUtil toolUtil = new ToolUtil();
|
||||
private static RecordsetUtil recordsetUtil = new RecordsetUtil();
|
||||
private static final UtilMapper mapper = getMapper(UtilMapper.class);
|
||||
private static LoggerUtil loggerUtil = new LoggerUtil();
|
||||
private static volatile Logger log = null;
|
||||
|
||||
|
||||
/**
|
||||
* 获取指定格式的当前时间
|
||||
*
|
||||
|
@ -1888,17 +1889,47 @@ public class Util extends weaver.general.Util {
|
|||
loggerUtil.error(message, exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日志对象
|
||||
*
|
||||
* @return 日志对象
|
||||
*/
|
||||
public static Logger getLogger() {
|
||||
if (log == null) {
|
||||
synchronized (Util.class) {
|
||||
if (log == null) {
|
||||
log = org.apache.log4j.Logger.getLogger(LOGGER_NAME);
|
||||
// log = org.apache.log4j.Logger.getLogger(LOGGER_NAME);
|
||||
DailyRollingFileAppender appender = new DailyRollingFileAppender();
|
||||
log = Logger.getLogger("aiyh_cus");
|
||||
appender.setName("aiyh_cus");
|
||||
appender.setEncoding("UTF-8");
|
||||
appender.setDatePattern("'_'yyyyMMdd'.log'");
|
||||
appender.setFile(weaver.general.GCONST.getLogPath() + "cus" + File.separator + "util_cus" + File.separator + "cus.log");
|
||||
appender.setThreshold(Priority.DEBUG);
|
||||
appender.setLayout(new PatternLayout("[%-5p] [%d{yyyy-MM-dd HH:mm:ss,SSS}] [%r] [Thread:%t][%F.%M:%L] ==> : %m %x %n"));
|
||||
appender.setAppend(true);
|
||||
appender.activateOptions();
|
||||
log.addAppender(appender);
|
||||
Boolean enableDebug = mapper.selectLogLevel();
|
||||
if (!enableDebug) {
|
||||
log.setLevel(Level.INFO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return log;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询自定义配置参数值
|
||||
*
|
||||
* @param onlyMark 唯一标识
|
||||
* @return 参数值
|
||||
*/
|
||||
public static String getCusConfigValue(String onlyMark) {
|
||||
return mapper.selectCusConfigParam(onlyMark);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将list转化为树形list
|
||||
|
@ -1920,6 +1951,7 @@ public class Util extends weaver.general.Util {
|
|||
return buildTree(dataList, new HashMap<>(dataList.size()), new HashMap<>(dataList.size()), 0,
|
||||
getIdFn, getParentId, setChildFn, predicate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将list转化为树形list
|
||||
*
|
||||
|
@ -1933,14 +1965,14 @@ public class Util extends weaver.general.Util {
|
|||
* @param <K> 元数据id的泛型
|
||||
* @return 树形的list
|
||||
*/
|
||||
public static <T,K> List<T> listToTree(List<T> dataList, Function<T, K> getIdFn,
|
||||
public static <T, K> List<T> listToTree(List<T> dataList, Function<T, K> getIdFn,
|
||||
Function<T, K> getParentId, Function<T, List<T>> getChildFn,
|
||||
BiConsumer<T, List<T>> setChildFn, Predicate<K> predicate){
|
||||
BiConsumer<T, List<T>> setChildFn, Predicate<K> predicate) {
|
||||
if (dataList == null || dataList.isEmpty() || dataList.size() == 1) {
|
||||
return dataList;
|
||||
}
|
||||
return buildTree(dataList,new HashMap<>(dataList.size()),new HashMap<>(dataList.size()),
|
||||
0,getIdFn,getParentId,getChildFn,setChildFn,predicate);
|
||||
return buildTree(dataList, new HashMap<>(dataList.size()), new HashMap<>(dataList.size()),
|
||||
0, getIdFn, getParentId, getChildFn, setChildFn, predicate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2085,17 +2117,18 @@ public class Util extends weaver.general.Util {
|
|||
|
||||
/**
|
||||
* 复制java bean中的基本属性,引用类型除外
|
||||
*
|
||||
* @param source 原对象
|
||||
* @param target 目标对象
|
||||
* @param <T> 原对象泛型
|
||||
* @param <K> 目标对象泛型
|
||||
* @return 复制后的目标对象
|
||||
*/
|
||||
public static <T,K> K copyBeanBaseField(T source, K target){
|
||||
if(Objects.isNull(source)){
|
||||
public static <T, K> K copyBeanBaseField(T source, K target) {
|
||||
if (Objects.isNull(source)) {
|
||||
return target;
|
||||
}
|
||||
if(Objects.isNull(target)){
|
||||
if (Objects.isNull(target)) {
|
||||
throw new RuntimeException("target is null, You cannot pass a null bean");
|
||||
}
|
||||
BeanInfo beanInfo = null;
|
||||
|
@ -2104,7 +2137,7 @@ public class Util extends weaver.general.Util {
|
|||
} catch (IntrospectionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(Objects.isNull(beanInfo)){
|
||||
if (Objects.isNull(beanInfo)) {
|
||||
throw new RuntimeException("无法获取对象信息!can not get bean info");
|
||||
}
|
||||
Class<?> sourceClass = source.getClass();
|
||||
|
@ -2116,14 +2149,14 @@ public class Util extends weaver.general.Util {
|
|||
Field sourceClassField = sourceClass.getDeclaredField(name);
|
||||
Class<?> propertyType = propertyDescriptor.getPropertyType();
|
||||
Class<?> classFieldType = sourceClassField.getType();
|
||||
if(propertyType.equals(classFieldType)){
|
||||
if (propertyType.equals(classFieldType)) {
|
||||
Method getMethod = sourceClass.getMethod("get" + name.substring(0, 1).toUpperCase() + name.substring(1));
|
||||
Object invoke = getMethod.invoke(source);
|
||||
writeMethod.invoke(target,invoke);
|
||||
writeMethod.invoke(target, invoke);
|
||||
}
|
||||
} catch (NoSuchFieldException | IllegalAccessException | InvocationTargetException ignored) {
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException("invoke method err, cant not invoke method set" + name.substring(0,1).toUpperCase() + name.substring(1));
|
||||
throw new RuntimeException("invoke method err, cant not invoke method set" + name.substring(0, 1).toUpperCase() + name.substring(1));
|
||||
}
|
||||
}
|
||||
// TODO 复制bean
|
||||
|
|
|
@ -17,6 +17,7 @@ import weaver.workflow.workflow.WorkflowVersion;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>数据来源为流程的处理方法实现</p>
|
||||
|
@ -36,12 +37,15 @@ public class WorkflowDataHandler implements IDataSourceHandler {
|
|||
String workflowId = apiRequestMain.getWorkflowType();
|
||||
String workflowVersionIds = WorkflowVersion.getVersionStringByWfid(workflowId);
|
||||
String workflowTable = mapper.selectWorkflowTableById(workflowVersionIds.split(","));
|
||||
if("".equals(apiRequestMain.getRequestId()) || Objects.isNull(apiRequestMain.getRequestId())){
|
||||
throw new RuntimeException("数据来源为流程时,流程的requestId为必要参数!");
|
||||
}
|
||||
Map<String, Object> mainData = mapper.selectMainData(workflowTable, apiRequestMain.getRequestId());
|
||||
ParamConfigInfo paramConfigInfo = Util.copyBeanBaseField(apiRequestMain, new ParamConfigInfo());
|
||||
List<ApiRequestParamDetail> paramDetailList = apiRequestMain.getParamDetailList();
|
||||
// 明细请求模式,单挑明细 当做请求参数进行一次请求
|
||||
if (apiRequestMain.getParamRequestType() == 1) {
|
||||
|
||||
List<List<ParamInfo>> lists = parseValueForDetail(apiRequestMain, mainData);
|
||||
} else {
|
||||
// 默认模式
|
||||
|
||||
|
|
|
@ -13,6 +13,6 @@ import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
|||
public class BooleanTypeHandler implements IParamTypeHandler {
|
||||
@Override
|
||||
public Boolean getValue(Object value) {
|
||||
return Boolean.valueOf(String.valueOf(value));
|
||||
return Boolean.parseBoolean(String.valueOf(value));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,6 @@ import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
|||
public class DoubleTypeHandler implements IParamTypeHandler {
|
||||
@Override
|
||||
public Double getValue(Object value) {
|
||||
return Double.valueOf(String.valueOf(value));
|
||||
return Double.parseDouble(String.valueOf(value));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,6 @@ import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
|||
public class LongTypeHandler implements IParamTypeHandler {
|
||||
@Override
|
||||
public Long getValue(Object value) {
|
||||
return Long.valueOf(String.valueOf(value));
|
||||
return Long.parseLong(String.valueOf(value));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package aiyh.utils.apirequest.core.typehandler.paramvalue;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
||||
import aiyh.utils.apirequest.mapper.ParamValueParseMapper;
|
||||
import aiyh.utils.apirequest.pojo.ApiRequestParamDetail;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>自定义SQL处理器</p>
|
||||
* <p>create 2022/1/26 0026 16:30</p>
|
||||
*
|
||||
* @author EBU7-dev1-ayh
|
||||
*/
|
||||
|
||||
|
||||
public class CustomerSqlRuleHandler implements IParamValueRuleHandler {
|
||||
private final ParamValueParseMapper mapper = Util.getMapper(ParamValueParseMapper.class);
|
||||
@Override
|
||||
public Object getValue(ApiRequestParamDetail paramInfo, Map<String, Object> dataMap) {
|
||||
String customerSql = paramInfo.getCustomerValue();
|
||||
if(customerSql.toLowerCase().trim().startsWith("select ".toLowerCase())){
|
||||
return mapper.selectCustomerSql(customerSql, dataMap);
|
||||
}else {
|
||||
throw new RuntimeException("违规SQL,自定义SQL只支持查询SQL,不支持其他SQL操作!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,6 +17,6 @@ public class FixedValueRuleHandle implements IParamValueRuleHandler {
|
|||
|
||||
@Override
|
||||
public Object getValue(ApiRequestParamDetail paramInfo, Map<String, Object> dataMap) {
|
||||
return null;
|
||||
return paramInfo.getCustomerValue();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package aiyh.utils.apirequest.core.typehandler.paramvalue;
|
||||
|
||||
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
||||
import aiyh.utils.apirequest.pojo.ApiRequestParamDetail;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>系统字段值处理</p>
|
||||
* <p>create 2022/1/26 0026 16:25</p>
|
||||
*
|
||||
* @author EBU7-dev1-ayh
|
||||
*/
|
||||
|
||||
|
||||
public class SystemFieldValueRuleHandle implements IParamValueRuleHandler {
|
||||
@Override
|
||||
public Object getValue(ApiRequestParamDetail paramInfo, Map<String, Object> dataMap) {
|
||||
Map<String,Object> main = (Map<String, Object>) dataMap.get("main");
|
||||
return main.get(paramInfo.getSystemFieldName());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package aiyh.utils.apirequest.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.CaseConversion;
|
||||
import aiyh.utils.annotation.recordset.Select;
|
||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||
import aiyh.utils.annotation.recordset.SqlString;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>参数值解析查询操作</p>
|
||||
* <p>create 2022/1/26 0026 16:32</p>
|
||||
*
|
||||
* @author EBU7-dev1-ayh
|
||||
*/
|
||||
|
||||
@SqlMapper
|
||||
public interface ParamValueParseMapper {
|
||||
|
||||
/**
|
||||
* 查询自定义SQL
|
||||
* @param sql 自定义SQL字符串
|
||||
* @param map 参数
|
||||
* @return 查询到的数据
|
||||
*/
|
||||
@Select(custom = true)
|
||||
@CaseConversion(false)
|
||||
public String selectCustomerSql(@SqlString String sql, Map<String,Object> map);
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package aiyh.utils.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.ParamMapper;
|
||||
import aiyh.utils.annotation.recordset.Select;
|
||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||
|
||||
/**
|
||||
* <p>工具类查询SQL</p>
|
||||
* <p>create 2022/1/27 0027 12:01</p>
|
||||
*
|
||||
* @author EBU7-dev1-ayh
|
||||
*/
|
||||
|
||||
@SqlMapper
|
||||
public interface UtilMapper {
|
||||
|
||||
/**
|
||||
* 查询日志级别是否开启Debug模式
|
||||
* @return 是否开启Debug模式
|
||||
*/
|
||||
@Select("select param_value from uf_cus_dev_config where only_mark = 'enableDebugLog'")
|
||||
public Boolean selectLogLevel();
|
||||
|
||||
|
||||
/**
|
||||
* 根据唯一标识查询参数值
|
||||
* @param onlyMark 唯一标识
|
||||
* @return 参数值
|
||||
*/
|
||||
@Select("select param_value from uf_cus_dev_config where only_mark = #{onlyMark} and enable_param = 1")
|
||||
public String selectCusConfigParam(@ParamMapper("onlyMark") String onlyMark);
|
||||
}
|
|
@ -16,9 +16,12 @@ import com.drew.metadata.Directory;
|
|||
import com.drew.metadata.Metadata;
|
||||
import com.drew.metadata.Tag;
|
||||
import com.engine.doc.cmd.secCategoryList.DocSecCategoryAddCmd;
|
||||
import com.weaver.general.GCONST;
|
||||
import entity.ImageInfo;
|
||||
import mybatisTest.mapper.IMapperTest;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.*;
|
||||
import org.apache.log4j.spi.Configurator;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import utilTest.entity.TestTreeEntity;
|
||||
|
@ -493,8 +496,17 @@ public class UtilTest {
|
|||
apiRequestMain.setParamRequestType(2);
|
||||
apiRequestMain.setOnlyMark("onlyMark");
|
||||
ParamConfigInfo paramConfigInfo = new ParamConfigInfo();
|
||||
paramConfigInfo = Util.copyBeanBaseField(apiRequestMain, paramConfigInfo);
|
||||
Util.copyBeanBaseField(apiRequestMain, paramConfigInfo);
|
||||
System.out.println(paramConfigInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLog(){
|
||||
Logger log= Util.getLogger();
|
||||
log.info("我是info --------------------->");
|
||||
log.debug("我是debug---------------------------------->");
|
||||
log.error("我是错误---------------->");
|
||||
log.warn("我是警告-------------->");
|
||||
System.out.println(log.getEffectiveLevel());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue