From f810e358732ad9cd4c4cde63cdada2d4af6301a8 Mon Sep 17 00:00:00 2001 From: "wei.peng" Date: Thu, 11 Apr 2019 09:22:11 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=20=E6=95=B0=E6=8D=AE=E6=93=8D=E4=BD=9C=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20DAO=20=E5=B1=82=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/estsh/i3plus/pojo/base/dynamic/DynamicEntity.java | 2 +- .../java/cn/estsh/i3plus/pojo/base/enumutil/CommonEnumUtil.java | 4 ++++ .../cn/estsh/i3plus/pojo/form/bean/BfElementPropertyVirtual.java | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/dynamic/DynamicEntity.java b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/dynamic/DynamicEntity.java index 1e82aa4..95cb885 100644 --- a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/dynamic/DynamicEntity.java +++ b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/dynamic/DynamicEntity.java @@ -221,7 +221,7 @@ public class DynamicEntity extends BaseBean implements Serializable { */ public Object getDynProperty(String propName){ //初始化set方法 - String setMethodName = "get" + propName.substring(0,1).toUpperCase() + propName.substring(1); + String setMethodName = "get" + CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, propName); try { //获取方法 diff --git a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/enumutil/CommonEnumUtil.java b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/enumutil/CommonEnumUtil.java index 104f18e..6c19f95 100644 --- a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/enumutil/CommonEnumUtil.java +++ b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/enumutil/CommonEnumUtil.java @@ -521,6 +521,10 @@ public class CommonEnumUtil { return value; } + public String getValueStr() { + return value + ""; + } + public String getDescription() { return description; } diff --git a/modules/i3plus-pojo-form/src/main/java/cn/estsh/i3plus/pojo/form/bean/BfElementPropertyVirtual.java b/modules/i3plus-pojo-form/src/main/java/cn/estsh/i3plus/pojo/form/bean/BfElementPropertyVirtual.java index 604535d..f52cb1b 100644 --- a/modules/i3plus-pojo-form/src/main/java/cn/estsh/i3plus/pojo/form/bean/BfElementPropertyVirtual.java +++ b/modules/i3plus-pojo-form/src/main/java/cn/estsh/i3plus/pojo/form/bean/BfElementPropertyVirtual.java @@ -38,6 +38,10 @@ public class BfElementPropertyVirtual extends BaseBean { @JsonSerialize(using = ToStringSerializer.class) private Long elementId; + @Column(name="PROPERTY_CODE") + @ApiParam(value ="类属性名称") + private String propertyCode; + @Column(name="PROPERTY_NAME") @ApiParam(value ="元素名称") private String propertyName; @@ -71,6 +75,10 @@ public class BfElementPropertyVirtual extends BaseBean { private List propertyList; @Transient + @ApiParam(value = "虚拟属性列表") + private List detailList; + + @Transient @ApiParam(value = "虚拟属性ID列表") @JsonSerialize(using = ToStringSerializer.class) private List propertyIdList; From cc3b1a741c66858453a40ba7bdafe61e3b666b35 Mon Sep 17 00:00:00 2001 From: "wei.peng" Date: Thu, 11 Apr 2019 15:28:20 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=85=83=E7=B4=A0=E8=99=9A=E6=8B=9F?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../i3plus/pojo/base/dynamic/DynamicEntity.java | 179 +++++++-------------- .../pojo/base/enumutil/BlockFormEnumUtil.java | 92 +++++++++++ 2 files changed, 153 insertions(+), 118 deletions(-) diff --git a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/dynamic/DynamicEntity.java b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/dynamic/DynamicEntity.java index 95cb885..99771c9 100644 --- a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/dynamic/DynamicEntity.java +++ b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/dynamic/DynamicEntity.java @@ -1,12 +1,6 @@ package cn.estsh.i3plus.pojo.base.dynamic; import cn.estsh.i3plus.pojo.base.bean.BaseBean; -import com.google.common.base.CaseFormat; -import lombok.Getter; -import lombok.Setter; -import lombok.val; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -14,8 +8,6 @@ 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.Date; import java.util.List; @@ -32,14 +24,9 @@ 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 Object[] args; - private Object result; - private String operator; - private String appName;*/ + private static final String ATTR_PREFIX = "$cglib_prop_"; + public String tableName; public List propertyList; public DynamicEntity(){ @@ -71,67 +58,14 @@ public class DynamicEntity extends BaseBean implements Serializable { */ 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) && !"dynProperty".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 if (f.getType() == String.class) { - fieldVal = ""; - }else if (f.getType() == Character.class) { - fieldVal = ""; - }else if (f.getType() == Boolean.class) { - fieldVal = true; - }else if (f.getType() == Byte.class) { - fieldVal = 0; - }else if (f.getType() == Date.class) { - fieldVal = new Date(); - }else { - fieldVal = ""; - } - } - - try { - setMethod = this.getClass().getDeclaredMethod(setMethodName, new Class[]{f.getType()}); -// System.out.println("Method Name:" + setMethod.getName() + "\t\t Value : " + fieldVal); - setMethod.invoke(this, fieldVal); - } catch (ClassCastException e) { - e.printStackTrace(); - LOGGER.error("ClassCastException :{}", setMethodName, e); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - LOGGER.error("IllegalArgumentException :{}", setMethodName, e); - } catch (NoSuchMethodException e) { - LOGGER.error("没有方法:{}", setMethodName, e); - } catch (IllegalAccessException e) { - LOGGER.error("入参出错:{}:{}:{}", f, f.getType(), fieldVal, e); - } catch (InvocationTargetException e) { - LOGGER.error("方法返回出错:{}", setMethodName, e); - }catch (RuntimeException e) { - LOGGER.error("RuntimeException :{}", setMethodName, e); - }catch (Exception e) { - LOGGER.error("Exception :{}", setMethodName, e); - } + String propName = f.getName().replace(ATTR_PREFIX, ""); + if(!"LOGGER".equals(propName) && !"ATTR_PREFIX".equals(propName) + && !"propertyList".equals(propName) && !"dynProperty".equals(propName) ) { + // 添加到属性list中 + this.getPropertyList().add(propName); + // 属性初始化 + setDynProperty(propName,getDynProperty(propName)); } } } @@ -140,31 +74,13 @@ public class DynamicEntity extends BaseBean implements Serializable { public String toString() { 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 = ""; - } - } + String fieldName = f.getName().replace(ATTR_PREFIX, ""); + if (!"LOGGER".equals(fieldName) && !"ATTR_PREFIX".equals(fieldName) + && !"propertyList".equals(fieldName) && !"dynProperty".equals(fieldName)) { - result += "\"" + fieldName + "\":\"" + fieldVal + "\","; + result += "\"" + fieldName + "\":\"" + getDynProperty(fieldName) + "\","; } } if(fields.length > 0) { @@ -187,7 +103,6 @@ public class DynamicEntity extends BaseBean implements Serializable { /** * 根据属性名,设置属性值 - * //TODO wei.peng 设置为空时会无效 * @param propName * @param val * @throws InvocationTargetException @@ -195,12 +110,10 @@ public class DynamicEntity extends BaseBean implements Serializable { * @throws NoSuchMethodException */ public void setDynProperty(String propName,Object val){ - //初始化set方法 - String setMethodName = "set" + CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, propName); - //获取方法 - Method setMethod = null; + String setMethodName = "set" + propName.substring(0,1).toUpperCase() + propName.substring(1); try { - setMethod = this.getClass().getDeclaredMethod(setMethodName, new Class[]{val.getClass()}); + val = getValue(propName,val); + Method setMethod = this.getClass().getDeclaredMethod(setMethodName, new Class[]{val.getClass()}); setMethod.invoke(this, val); } catch (NoSuchMethodException e) { LOGGER.error("没有方法:{}",setMethodName,e); @@ -211,23 +124,12 @@ public class DynamicEntity extends BaseBean implements Serializable { } } - /** - * 获取属性值 - * @param propName - * @return - * @throws NoSuchMethodException - * @throws InvocationTargetException - * @throws IllegalAccessException - */ public Object getDynProperty(String propName){ - //初始化set方法 - String setMethodName = "get" + CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, propName); - + String setMethodName = "get" + propName.substring(0,1).toUpperCase() + propName.substring(1); + Object result = null; try { - //获取方法 Method getMethod = this.getClass().getDeclaredMethod(setMethodName); - //实现方法 - return getMethod.invoke(this); + result = getMethod.invoke(this); } catch (NoSuchMethodException e) { LOGGER.error("没有方法:{}:{}",setMethodName,propName,e); } catch (IllegalAccessException e) { @@ -235,7 +137,7 @@ public class DynamicEntity extends BaseBean implements Serializable { } catch (InvocationTargetException e) { LOGGER.error("方法返回出错:{}",setMethodName,e); } - return null; + return getValue(propName,result); } public List getPropertyList() { @@ -245,4 +147,45 @@ public class DynamicEntity extends BaseBean implements Serializable { public void setPropertyList(List propertyList) { this.propertyList = propertyList; } + + /** + * 获取默认值 + * @param propName + * @param val + * @return + */ + public Object getValue(String propName,Object val){ + if(val == null){ + try { + Field field = this.getClass().getDeclaredField(ATTR_PREFIX + propName); + if (field.getType() == Integer.class) { + val = 0; + } else if (field.getType() == Long.class) { + val = 0L; + } else if (field.getType() == Float.class) { + val = 0.0f; + } else if (field.getType() == Double.class) { + val = 0.0d; + } else if (field.getType() == String.class) { + val = ""; + }else if (field.getType() == Character.class) { + val = ""; + }else if (field.getType() == Boolean.class) { + val = true; + }else if (field.getType() == Byte.class) { + val = 0; + }else if (field.getType() == Date.class) { + val = new Date(); + }else { + val = ""; + } + }catch (NoSuchFieldException e){ + LOGGER.error("没有指定属性:{}:{}",propName,e); + }catch (SecurityException e){ + LOGGER.error("获取属性安全错误:{}",propName,e); + } + } + return val; + } + } diff --git a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/enumutil/BlockFormEnumUtil.java b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/enumutil/BlockFormEnumUtil.java index 53777c6..f470c2d 100644 --- a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/enumutil/BlockFormEnumUtil.java +++ b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/enumutil/BlockFormEnumUtil.java @@ -1055,7 +1055,99 @@ public class BlockFormEnumUtil { return tmp; } + public Object getPropertyVirtual(Object ... objs){ + if(this.getValue() == STRING_SPLICE.getValue()){ + return getPropertyVirtualString(objs); + }else if(this.getValue() == NUM_ADD.getValue()){ + return getPropertyVirtualDoubleAdd(objs); + }else if(this.getValue() == NUM_LESS.getValue()){ + return getPropertyVirtualDoubleLess(objs); + }else if(this.getValue() == NUM_MAKE.getValue()){ + return getPropertyVirtualDoubleMake(objs); + }else if(this.getValue() == NUM_DIVISION.getValue()){ + return getPropertyVirtualDoubleDivision(objs); + } + return objs; + } + + private String getPropertyVirtualString(Object ... objs){ + if(objs != null && objs.length > 0){ + StringBuffer result = new StringBuffer(); + for (Object o : objs) { + result.append(o == null ? "" : o.toString()); + } + return result.toString(); + } + return null; + } + + private Double getPropertyVirtualDoubleAdd(Object ... objs){ + if(objs != null && objs.length > 0){ + Double result = new Double(0); + for (Object o : objs) { + try { + if(o != null){ + result += Double.parseDouble(o.toString()); + } + }catch (Exception e){ + e.printStackTrace(); + } + } + return result; + } + return null; + } + + private Double getPropertyVirtualDoubleLess(Object ... objs){ + if(objs != null && objs.length > 0){ + Double result = new Double(0); + for (Object o : objs) { + try { + if(o != null){ + result -= Double.parseDouble(o.toString()); + } + }catch (Exception e){ + e.printStackTrace(); + } + } + return result; + } + return null; + } + private Double getPropertyVirtualDoubleMake(Object ... objs){ + if(objs != null && objs.length > 0){ + Double result = new Double(0); + for (Object o : objs) { + try { + if(o != null){ + result *= Double.parseDouble(o.toString()); + } + }catch (Exception e){ + e.printStackTrace(); + } + } + return result; + } + return null; + } + + private Double getPropertyVirtualDoubleDivision(Object ... objs){ + if(objs != null && objs.length > 0){ + Double result = new Double(0); + for (Object o : objs) { + try { + if(o != null){ + result /= Double.parseDouble(o.toString()); + } + }catch (Exception e){ + e.printStackTrace(); + } + } + return result; + } + return null; + } } /** From 7020b1a53405a0be3628eeace9566a46dedbe002 Mon Sep 17 00:00:00 2001 From: "gragon.xu" Date: Thu, 11 Apr 2019 21:58:47 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=89=8D=E7=AB=AF=EF=BC=9A=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E4=BA=A4=E6=98=93=E8=AE=B0=E5=BD=95=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E5=8D=95=E5=8F=B7=E4=BD=9C=E4=B8=BA=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=9D=A1=E4=BB=B6=EF=BC=9B=20=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=EF=BC=9A=E6=B7=BB=E5=8A=A0=E5=B8=B8=E9=87=8FTASK=5FJOB,TRANS?= =?UTF-8?q?=5FAM=20+=20=E5=BA=93=E5=AD=98=E4=BA=A4=E6=98=93=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=B7=BB=E5=8A=A0=E7=A7=BB=E5=8A=A8=E5=8D=95=E5=8F=B7?= =?UTF-8?q?=E4=BD=9C=E4=B8=BA=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6=20+=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=BB=E5=8A=A1=E7=94=9F=E6=88=90component?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E5=91=BD=E5=90=8D=20+=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=86=BB=E7=BB=93=E6=95=B0=E9=87=8FHQL=20+?= =?UTF-8?q?=20=E4=BA=A4=E6=98=93=E5=8F=8D=E5=90=91=E5=A4=84=E7=90=86?= =?UTF-8?q?=EF=BC=9A=E4=BA=A4=E6=98=93=E8=BF=87=E6=9C=9F=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=EF=BC=8C=E6=95=B0=E9=87=8F=E6=AF=94=E8=BE=83=E8=A6=81=E7=94=A8?= =?UTF-8?q?.doubleValue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/estsh/i3plus/pojo/wms/sqlpack/WmsHqlPack.java | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/i3plus-pojo-wms/src/main/java/cn/estsh/i3plus/pojo/wms/sqlpack/WmsHqlPack.java b/modules/i3plus-pojo-wms/src/main/java/cn/estsh/i3plus/pojo/wms/sqlpack/WmsHqlPack.java index 839fb10..d240f9d 100644 --- a/modules/i3plus-pojo-wms/src/main/java/cn/estsh/i3plus/pojo/wms/sqlpack/WmsHqlPack.java +++ b/modules/i3plus-pojo-wms/src/main/java/cn/estsh/i3plus/pojo/wms/sqlpack/WmsHqlPack.java @@ -917,6 +917,7 @@ public class WmsHqlPack { //查询参数封装 HqlPack.getStringEqualPack(wmsTransQuan.getWhNo(), "whNo", result); HqlPack.getStringEqualPack(wmsTransQuan.getZoneNo(), "zoneNo", result); + HqlPack.getStringEqualPack(wmsTransQuan.getMoveNo(), "moveNo", result); HqlPack.getStringEqualPack(wmsTransQuan.getPartNo(), "partNo", result); HqlPack.getStringEqualPack(wmsTransQuan.getLocateNo(), "locateNo", result);