yun-zuoyi
gragon.xu 6 years ago
commit 85d3463348

@ -1,7 +1,21 @@
package cn.estsh.i3plus.pojo.base.dynamic;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @Description :
@ -10,24 +24,46 @@ import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
* @CreateDate : 2019-01-24 15:56
* @Modify:
**/
public class DynamicEntity extends BaseBean {
public class DynamicEntity extends BaseBean implements Serializable {
public static final Logger LOGGER = LoggerFactory.getLogger(DynamicEntity.class);
public String tableName;
/*private String uri;
private String method;
private String uri;
private Object[] args;
private Object result;
private String operator;
private String appName;
private String appName;*/
public List<String> propertyList;
public DynamicEntity(){
try {
this.setPropertyList(new ArrayList<>());
initDynamic();
} catch (Exception e) {
e.printStackTrace();
}
}
public DynamicEntity(String tableName){
this.tableName = tableName;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
/**
*
*
* @param method
* @param uri
* @param args
* @param result
* @return
*/
*//*
public DynamicEntity get(String method, String uri, Object[] args, Object result, String operator, String appName) {
setMethod(method);
setUri(uri);
@ -84,10 +120,160 @@ public class DynamicEntity extends BaseBean {
public void setAppName(String appName) {
this.appName = appName;
}*/
/**
* 便
* @throws InvocationTargetException
* @throws IllegalAccessException
* @throws NoSuchMethodException
*/
public void initDynamic() {
Field[] fields = this.getClass().getDeclaredFields();
Method setMethod = null;
String setMethodName,propName;
Object fieldVal = null;
for(Field f : fields) {
propName = f.getName().replace("$cglib_prop_", "");
if(!"LOGGER".equals(propName) && !"propertyList".equals(propName)) {
this.getPropertyList().add(propName); //添加到属性list中
setMethodName = "set" + propName.substring(0,1).toUpperCase() + propName.substring(1);
f.setAccessible(true);
try {
fieldVal = f.get(this);
} catch (IllegalAccessException e) {
fieldVal = null;
}
if(fieldVal == null) {
if (f.getType() == Integer.class) {
fieldVal = 0;
} else if (f.getType() == Long.class) {
fieldVal = 0L;
} else if (f.getType() == Float.class) {
fieldVal = 0.0f;
} else if (f.getType() == Double.class) {
fieldVal = 0.0d;
} else {
fieldVal = "";
}
}
try {
setMethod = this.getClass().getDeclaredMethod(setMethodName, new Class[]{f.getType()});
setMethod.invoke(this, fieldVal);
} catch (NoSuchMethodException e) {
LOGGER.error("没有方法:{}", setMethodName, e);
} catch (IllegalAccessException e) {
LOGGER.error("入参出错:{}:{}:{}", f, f.getType(), fieldVal, e);
} catch (InvocationTargetException e) {
LOGGER.error("方法返回出错:{}", setMethodName, e);
}
}
}
}
@Override
public String toString() {
return ReflectionToStringBuilder.toString(this);
String result = "{";
Object fieldVal = null;
Field[] fields = this.getClass().getDeclaredFields();
String fieldName;
for(Field f : fields) {
fieldName = f.getName().replace("$cglib_prop_", "");
if(!"LOGGER".equals(fieldName) && !"propertyList".equals(fieldName)) {
f.setAccessible(true);
fieldVal = new Object();
try {
fieldVal = f.get(this);
} catch (IllegalAccessException e) {
fieldVal = null;
}
if (fieldVal == null) {
if (f.getType() == Integer.class || f.getType() == Long.class) {
fieldVal = 0;
} else if (f.getType() == Float.class || f.getType() == Double.class) {
fieldVal = 0.0;
} else {
fieldVal = "";
}
}
result += "\"" + fieldName + "\":\"" + fieldVal + "\",";
}
}
if(fields.length > 0) {
result = result.substring(0,result.length()-1);
}
result += "}";
return result;
}
/**
*
* @param propName
* @param val
* @throws InvocationTargetException
* @throws IllegalAccessException
* @throws NoSuchMethodException
*/
public void setDynProperty(String propName,Object val){
//初始化set方法
String setMethodName = "set" + propName.substring(0, 1).toUpperCase() + propName.substring(1);
//获取方法
Method setMethod = null;
try {
setMethod = this.getClass().getDeclaredMethod(setMethodName, new Class[]{val.getClass()});
setMethod.invoke(this, val);
} catch (NoSuchMethodException e) {
LOGGER.error("没有方法:{}",setMethodName,e);
} catch (IllegalAccessException e) {
LOGGER.error("入参出错:{}:{}",val,val.getClass(),e);
} catch (InvocationTargetException e) {
LOGGER.error("方法返回出错:{}",setMethodName,e);
}
}
/**
*
* @param propName
* @return
* @throws NoSuchMethodException
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
public Object getDynProperty(String propName){
//初始化set方法
String setMethodName = "get" + propName.substring(0,1).toUpperCase() + propName.substring(1);
try {
//获取方法
Method getMethod = this.getClass().getDeclaredMethod(setMethodName);
//实现方法
return getMethod.invoke(this);
} catch (NoSuchMethodException e) {
LOGGER.error("没有方法:{}:{}",setMethodName,propName,e);
} catch (IllegalAccessException e) {
LOGGER.error("没有方法:{}:{}",setMethodName,propName,e);
} catch (InvocationTargetException e) {
LOGGER.error("方法返回出错:{}",setMethodName,e);
}
return null;
}
public List<String> getPropertyList() {
return propertyList;
}
public void setPropertyList(List<String> propertyList) {
this.propertyList = propertyList;
}
}

@ -1847,6 +1847,16 @@ public class WmsEnumUtil {
return code;
}
public static String valueOf(int val) {
String tmp = null;
for (int i = 0; i < values().length; i++) {
if (values()[i].value == val) {
tmp = values()[i].description;
}
}
return tmp;
}
public String getDescription() {
return description;
}
@ -1883,6 +1893,16 @@ public class WmsEnumUtil {
public String getDescription() {
return description;
}
public static String valueOf(int val) {
String tmp = null;
for (int i = 0; i < values().length; i++) {
if (values()[i].value == val) {
tmp = values()[i].description;
}
}
return tmp;
}
}
/**

@ -0,0 +1,45 @@
package cn.estsh.i3plus.pojo.form.bean;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* @Description :
* @Reference :
* @Author : alwaysfrin
* @CreateDate : 2019-02-27 10:53
* @Modify:
**/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="bf_data_object")
@Api(value="数据对象表",description = "用来存储动态对象的相关属性")
public class BfDataObject extends BaseBean {
@Column(name="NAME")
@ApiParam(value ="中文名称")
private String objectName;
@Column(name="TABLE_NAME")
@ApiParam(value ="表名")
private String tableName;
@Column(name="is_view")
@ApiParam(value ="是否视图",access = "判断是否是视图,如果不是视图,则是表名")
//EnunmUtil.TRUE_OR_FALSE
private int isView;
}

@ -0,0 +1,53 @@
package cn.estsh.i3plus.pojo.form.bean;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* @Description :
* @Reference :
* @Author : alwaysfrin
* @CreateDate : 2019-02-27 10:53
* @Modify:
**/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="bf_data_object_property")
@Api(value="数据对象属性表",description = "数据对象的属性明细表")
public class BfDataObjectProperty extends BaseBean {
@Column(name="DATA_OBJECT_ID")
@ApiParam(value ="数据对象ID" , example = "-1")
@JsonSerialize(using = ToStringSerializer.class)
//外键关联数据对象主键
private Long dataObjectId;
@Column(name="PROP_NAME")
@ApiParam(value ="属性中文名称")
private String propName;
@Column(name="PROP_OBJECT_NAME")
@ApiParam(value ="对象中的属性名")
//在动态对象中的属性名
private String propObjectName;
@Column(name="PROP_COLUMN_NAME")
@ApiParam(value ="属性字段名")
//属性在数据库中的字段名
private String propColumnName;
}

@ -0,0 +1,43 @@
package cn.estsh.i3plus.pojo.form.bean;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* @Description :
* @Reference :
* @Author : alwaysfrin
* @CreateDate : 2019-02-27 10:53
* @Modify:
**/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="bf_data_object")
@Api(value="数据对象表",description = "用来存储动态对象的相关属性")
public class BfDataObjectRefer extends BaseBean {
@Column(name="NAME")
@ApiParam(value ="中文名称")
private String objectName;
@Column(name="TABLE_NAME")
@ApiParam(value ="表名")
private String tableName;
@Column(name="is_view")
@ApiParam(value ="是否视图",access = "判断是否是视图,如果不是视图,则是表名")
//EnunmUtil.TRUE_OR_FALSE
private int isView;
}
Loading…
Cancel
Save