Merge remote-tracking branch 'origin/dev' into test

yun-zuoyi
汪云昊 5 years ago
commit 1bdd1c50f6

@ -164,7 +164,7 @@ public class MessageMailQueueReceiver {
mailUtil.cleanAttachmentList();
}
}
sysMessageService.updateSysMessage(msg);
//信息已处理
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (Exception e) {

@ -90,8 +90,8 @@ public class SysMessageService implements ISysMessageService {
sysMessageRDao.update(sysMessage);
// 更新附件信息
sysFileAttachRDao.deleteByProperty("refId",sysMessage.getId());
if(sysMessage.getSysFileAttachList() != null){
sysFileAttachRDao.deleteByProperty("refId",sysMessage.getId());
SysFile sysFile;
for (SysFileAttach sysFileAttach : sysMessage.getSysFileAttachList()) {
sysFile = sysFileRDao.getById(sysFileAttach.getFileId());

@ -1,7 +1,7 @@
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.core.api.iservice.busi.ISysOrderNoRuleService;
import cn.estsh.i3plus.core.apiservice.util.CloneTool;
import cn.estsh.i3plus.platform.common.tool.CloneTool;
import cn.estsh.i3plus.core.apiservice.util.OrderNoMakeUtil;
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
import cn.estsh.i3plus.platform.common.tool.StringTool;

@ -1,231 +0,0 @@
package cn.estsh.i3plus.core.apiservice.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.*;
/**
* @Description :
* @Reference :
* @Author : yunhao
* @CreateDate : 2020-08-12 13:44
* @Modify:
**/
public class CloneTool {
public static final Logger LOGGER = LoggerFactory.getLogger(CloneTool.class);
/**
*
*/
static Class[] needlessCloneClasses = new Class[]{String.class,Boolean.class,Character.class,Byte.class,Short.class,
Integer.class,Long.class,Float.class,Double.class,Void.class,Object.class,Class.class
};
/**
*
* @param c
* @return
*/
private static boolean isNeedlessClone(Class c){
if(c.isPrimitive()){//基本类型
return true;
}
for(Class tmp:needlessCloneClasses){//是否在无需复制类型数组里
if(c.equals(tmp)){
return true;
}
}
return false;
}
/**
*
* @param value
* @return
* @throws IllegalAccessException
*/
private static Object createObject(Object value) throws IllegalAccessException{
try {
return value.getClass().newInstance();
} catch (InstantiationException e) {
return null;
} catch (IllegalAccessException e) {
throw e;
}
}
/**
*
* @param value
* @param level 0Object
* 00
* @return
* @throws IllegalAccessException
* @throws InstantiationException
*/
public static Object clone(Object value,int level) throws IllegalAccessException, InstantiationException {
if(value==null){
return null;
}
if(level==0){
return value;
}
Class c = value.getClass();
if(isNeedlessClone(c)){
return value;
}
level--;
if(value instanceof Collection){//复制新的集合
Collection tmp = (Collection)c.newInstance();
for(Object v:(Collection)value){
tmp.add(clone(v,level));//深度复制
}
value = tmp;
}
else if(c.isArray()){//复制新的Array
//首先判断是否为基本数据类型
if(c.equals(int[].class)){
int[] old = (int[])value;
value = (int[]) Arrays.copyOf(old, old.length);
}
else if(c.equals(short[].class)){
short[] old = (short[])value;
value = (short[])Arrays.copyOf(old, old.length);
}
else if(c.equals(char[].class)){
char[] old = (char[])value;
value = (char[])Arrays.copyOf(old, old.length);
}
else if(c.equals(float[].class)){
float[] old = (float[])value;
value = (float[])Arrays.copyOf(old, old.length);
}
else if(c.equals(double[].class)){
double[] old = (double[])value;
value = (double[])Arrays.copyOf(old, old.length);
}
else if(c.equals(long[].class)){
long[] old = (long[])value;
value = (long[])Arrays.copyOf(old, old.length);
}
else if(c.equals(boolean[].class)){
boolean[] old = (boolean[])value;
value = (boolean[])Arrays.copyOf(old, old.length);
}
else if(c.equals(byte[].class)){
byte[] old = (byte[])value;
value = (byte[])Arrays.copyOf(old, old.length);
}
else {
Object[] old = (Object[])value;
Object[] tmp = (Object[])Arrays.copyOf(old, old.length, old.getClass());
for(int i = 0;i<old.length;i++){
tmp[i] = clone(old[i],level);
}
value = tmp;
}
}
else if(value instanceof Map){//复制新的MAP
Map tmp = (Map)c.newInstance();
Map org = (Map)value;
for(Object key:org.keySet()){
tmp.put(key, clone(org.get(key),level));//深度复制
}
value = tmp;
}
else {
Object tmp = createObject(value);
if(tmp==null){//无法创建新实例则返回对象本身,没有克隆
return value;
}
Set<Field> fields = new HashSet<Field>();
while(c!=null&&!c.equals(Object.class)){
fields.addAll(Arrays.asList(c.getDeclaredFields()));
c = c.getSuperclass();
}
for(Field field:fields){
if(!Modifier.isFinal(field.getModifiers())){//仅复制非final字段
field.setAccessible(true);
field.set(tmp, clone(field.get(value),level));//深度复制
}
}
value = tmp;
}
return value;
}
/**
*
* @param value
* @return
* @throws IllegalAccessException
* @throws InstantiationException
*/
public static <T> T clone(T value) throws IllegalAccessException, InstantiationException {
return (T) clone(value,1);
}
/**
*
* @param value
* @return
* @throws IllegalAccessException
* @throws InstantiationException
*/
public static <T> T deepClone(T value) throws IllegalAccessException, InstantiationException {
return (T) clone(value,-1);
}
//数据100 深度10 测试
//======普通赋值======
//数据100 深度10
//普通赋值耗时:4~8
//======克隆工具1======
//数据100 深度10
//克隆工具1耗时:1272~1987
//======克隆工具2-1======
//数据100 深度10
//克隆工具2-1耗时:5~7
//======克隆工具2-2======
//数据100 深度10
//克隆工具2-2耗时:15~19
//
//数据100 深度20 测试
//======普通赋值======
//数据100 深度20
//普通赋值耗时:6
//======克隆工具1======
//数据100 深度20
//克隆工具1耗时:1772
//======克隆工具2-1======
//数据100 深度20
//克隆工具2-1耗时:71
//======克隆工具2-2======
//数据100 深度20
//克隆工具2-2耗时:216
// 性能低
// public static <T> T clone(Object cloneObj) {
// ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
// ObjectOutputStream out;
// try {
// out = new ObjectOutputStream(byteOut);
// out.writeObject(cloneObj);
//
// ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());
//
// ObjectInputStream in = new ObjectInputStream(byteIn);
//
// T retObj = (T) in.readObject();
//
// return retObj;
// } catch (IOException | ClassNotFoundException e) {
// LOGGER.error("对象" + cloneObj.getClass().getName() + "克隆异常:", e);
// }
// return null;
// }
}

@ -2,14 +2,12 @@ package cn.estsh.i3plus.core.apiservice.util;
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
import cn.estsh.i3plus.platform.common.tool.StringTool;
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
import cn.estsh.i3plus.platform.common.util.FileContentTypeTool;
import cn.estsh.i3plus.platform.common.util.PlatformConstWords;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.MailConfig;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ImppRedis;
import cn.estsh.impp.framework.boot.util.RedisCacheTool;
import com.sun.mail.smtp.SMTPAddressFailedException;
import org.slf4j.Logger;
@ -19,7 +17,6 @@ import org.springframework.stereotype.Component;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.annotation.Resource;
import javax.mail.*;
import javax.mail.internet.*;
import javax.mail.util.ByteArrayDataSource;
@ -58,9 +55,6 @@ public class MailUtil {
private boolean isAuthenticationSMTP = false;
private final List<BodyPart> attachmentList = new ArrayList<>();
@Resource(name = CommonConstWords.IMPP_REDIS_RES)
private ImppRedis redisRes;
/**
*
*

Loading…
Cancel
Save