Merge branch 'dev' into test

yun-zuoyi
王杰 6 years ago
commit 18bc35f60d

@ -0,0 +1,13 @@
package cn.estsh.i3plus.pojo.aps.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface RippleAnnotation {
String[] dependence() default {};
String method() default "";
}

@ -1,5 +1,6 @@
package cn.estsh.i3plus.pojo.aps.bean; package cn.estsh.i3plus.pojo.aps.bean;
import cn.estsh.i3plus.pojo.aps.annotation.RippleAnnotation;
import cn.estsh.i3plus.pojo.aps.common.BaseCode; import cn.estsh.i3plus.pojo.aps.common.BaseCode;
import cn.estsh.i3plus.pojo.aps.common.BeanRelation; import cn.estsh.i3plus.pojo.aps.common.BeanRelation;
import cn.estsh.i3plus.pojo.aps.enums.MATERIAL_TYPE; import cn.estsh.i3plus.pojo.aps.enums.MATERIAL_TYPE;
@ -66,6 +67,7 @@ public class Material extends BaseCode {
@Column(name="LEVEL") @Column(name="LEVEL")
@ApiParam(value ="低阶码") @ApiParam(value ="低阶码")
@RippleAnnotation(dependence = {"OperOutputs.Operation.ProductRouting.Material"}, method = "calcLevel")
private Integer level; private Integer level;
@Column(name="IS_AUTO_FIX_PEGGING") @Column(name="IS_AUTO_FIX_PEGGING")

@ -24,7 +24,7 @@ import java.util.List;
**/ **/
@Data @Data
@Entity @Entity
@Table(name = "APS_PRODUCTROUTING") @Table(name = "APS_PRODUCT_ROUTING")
@Api("物料") @Api("物料")
public class ProductRouting extends BaseCode { public class ProductRouting extends BaseCode {
@Column(name="VALID_START") @Column(name="VALID_START")

@ -155,13 +155,13 @@ public class Work extends BaseCode {
} }
@JsonBackReference @JsonBackReference
public List<WorkRelation> getWorkRelationInputs() { public List<WorkRelation> getPrevRelations() {
return BeanRelation.list(this, EWork.WorkRelationInputs); return BeanRelation.list(this, EWork.PrevRelations);
} }
@JsonBackReference @JsonBackReference
public List<WorkRelation> getWorkRelationOutputs() { public List<WorkRelation> getPostRelations() {
return BeanRelation.list(this, EWork.WorkRelationOutputs); return BeanRelation.list(this, EWork.PostRelations);
} }
@JsonBackReference @JsonBackReference

@ -117,6 +117,17 @@ public class BeanRelation {
return result; return result;
} }
public static <T extends BaseBean> List<T> listByClass(BaseBean bean, Class<T> cls, Enum<?> holder, Enum<?>... args) {
List<T> beans = new ArrayList<>();
List<BaseBean> nextBeans = list(bean, holder, args);
for (BaseBean nextBean : nextBeans) {
if (nextBean.getClass() == cls) {
beans.add((T)nextBean);
}
}
return beans;
}
private static <T extends BaseBean> void listImpl(List<T> result, BaseBean bean, Predicate<T> pred, Enum<?>[] holders, int index) { private static <T extends BaseBean> void listImpl(List<T> result, BaseBean bean, Predicate<T> pred, Enum<?>[] holders, int index) {
if (index >= holders.length) { if (index >= holders.length) {
if (pred == null || pred.test((T)bean)) { if (pred == null || pred.test((T)bean)) {
@ -191,7 +202,7 @@ public class BeanRelation {
* @param holder * @param holder
*/ */
private static void remove(BaseBean bean, Enum<?> holder) { private static void remove(BaseBean bean, Enum<?> holder) {
if (holder == null) { if (bean == null || holder == null) {
return; return;
} }
BeanInfo beanInfo = BeanInfo.getBeanInfo(bean.getClass()); BeanInfo beanInfo = BeanInfo.getBeanInfo(bean.getClass());
@ -215,7 +226,7 @@ public class BeanRelation {
* @param relaBean * @param relaBean
*/ */
private static void remove(BaseBean bean, Enum<?> holder, BaseBean relaBean) { private static void remove(BaseBean bean, Enum<?> holder, BaseBean relaBean) {
if (bean == null) { if (bean == null || holder == null) {
return; return;
} }
BeanInfo beanInfo = BeanInfo.getBeanInfo(bean.getClass()); BeanInfo beanInfo = BeanInfo.getBeanInfo(bean.getClass());

@ -6,8 +6,8 @@ public enum EWork {
WorkResources, WorkResources,
WorkInputs, WorkInputs,
WorkOutputs, WorkOutputs,
WorkRelationInputs, PrevRelations,
WorkRelationOutputs, PostRelations,
Operation, Operation,
PlanFeedbacks PlanFeedbacks
} }

@ -4,8 +4,8 @@
</Relation> </Relation>
<Relation field="Works" name="Work" reverse="Order" type="ONE_TO_MULTI" owner="true"> <Relation field="Works" name="Work" reverse="Order" type="ONE_TO_MULTI" owner="true">
</Relation> </Relation>
<Relation field="PrevRelations" name="WorkRelation" reverse="PrevOrder" type="ONE_TO_MULTI" owner="false"> <Relation field="PostRelations" name="WorkRelation" reverse="PrevOrder" type="ONE_TO_MULTI" owner="false">
</Relation> </Relation>
<Relation field="PostRelations" name="WorkRelation" reverse="PostOrder" type="ONE_TO_MULTI" owner="false"> <Relation field="PrevRelations" name="WorkRelation" reverse="PostOrder" type="ONE_TO_MULTI" owner="false">
</Relation> </Relation>
</Class> </Class>

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Class name="OperResource"> <Class name="OperResource">
<Relation field="Resource" name="Resource" reverse="OperResources" type="MULTI_TO_ONE" owner="false"> <Relation field="Resource" name="Resource" type="MULTI_TO_ONE" owner="false">
</Relation> </Relation>
</Class> </Class>

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Class name="Operation"> <Class name="Operation">
<Relation field="StandOperation" name="StandOperation" type="MULTI_TO_ONE" owner="false">
</Relation>
<Relation field="OperInputs" name="OperInput" reverse="Operation" type="ONE_TO_MULTI" owner="true"> <Relation field="OperInputs" name="OperInput" reverse="Operation" type="ONE_TO_MULTI" owner="true">
</Relation> </Relation>
<Relation field="OperOutputs" name="OperOutput" reverse="Operation" type="ONE_TO_MULTI" owner="true"> <Relation field="OperOutputs" name="OperOutput" reverse="Operation" type="ONE_TO_MULTI" owner="true">

@ -1,5 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Class name="StandOperation"> <Class name="StandOperation">
<Relation field="Operations" name="Operation" reverse="StandOperation" type="ONE_TO_MULTI" owner="false">
</Relation>
</Class> </Class>

@ -6,9 +6,9 @@
</Relation> </Relation>
<Relation field="WORK_RESOURCES" name="WorkResource" reverse="Work" type="ONE_TO_MULTI" owner="true"> <Relation field="WORK_RESOURCES" name="WorkResource" reverse="Work" type="ONE_TO_MULTI" owner="true">
</Relation> </Relation>
<Relation field="WorkRelationOutputs" name="WorkRelation" reverse="PrevWork" type="ONE_TO_MULTI" owner="false"> <Relation field="PostRelations" name="WorkRelation" reverse="PrevWork" type="ONE_TO_MULTI" owner="false">
</Relation> </Relation>
<Relation field="WorkRelationInputs" name="WorkRelation" reverse="PostWork" type="ONE_TO_MULTI" owner="false"> <Relation field="PrevRelations" name="WorkRelation" reverse="PostWork" type="ONE_TO_MULTI" owner="false">
</Relation> </Relation>
<Relation field="Operation" name="Operation" type="MULTI_TO_ONE" owner="false"> <Relation field="Operation" name="Operation" type="MULTI_TO_ONE" owner="false">
</Relation> </Relation>

@ -215,6 +215,8 @@ public interface BaseRepository <T, ID extends Serializable> extends JpaReposito
List<T> findByProperty(String propertyName, Object value); List<T> findByProperty(String propertyName, Object value);
List<Map<String,Object>> findByWasProperty(String[] propertyNames, Object[] values);
List<T> findByProperty(String[] propertyNames, Object[] values); List<T> findByProperty(String[] propertyNames, Object[] values);
List<T> findByProperty(String propertyName, Object value,String orderByStuff); List<T> findByProperty(String propertyName, Object value,String orderByStuff);

@ -3,10 +3,15 @@ package cn.estsh.i3plus.pojo.base.jpa.daoimpl;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.common.Pager; import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.WmsEnumUtil;
import cn.estsh.i3plus.pojo.base.jpa.dao.BaseRepository; import cn.estsh.i3plus.pojo.base.jpa.dao.BaseRepository;
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker; import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
import cn.estsh.i3plus.pojo.base.util.BeanMapUtils;
import cn.estsh.i3plus.pojo.base.util.StringCastUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.hibernate.NonUniqueResultException; import org.hibernate.NonUniqueResultException;
import org.hibernate.SQLQuery;
import org.hibernate.transform.Transformers;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.data.jpa.repository.support.SimpleJpaRepository; import org.springframework.data.jpa.repository.support.SimpleJpaRepository;
@ -219,6 +224,7 @@ public class BaseRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRep
/** /**
* *
*
* @param conditionName * @param conditionName
* @param conditionValue * @param conditionValue
* @param propertyName * @param propertyName
@ -412,6 +418,37 @@ public class BaseRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRep
} }
@Override @Override
public List<Map<String,Object>> findByWasProperty(String[] propertyNames, Object[] values) {
if (propertyNames.length != values.length) {
throw new IllegalArgumentException("参数名的数量和参数值不匹配!propertyNames:" + propertyNames.length + ",values:" + values.length);
}
StringBuffer queryString = new StringBuffer();
queryString.append(" SELECT \n" +
" a.sn_status AS snStatus,\n" +
" a.wh_no AS whNo,\n" +
" a.locate_no AS locateNo,\n" +
" a.part_no AS partNo,\n" +
" a.part_name_rdd AS partNameRdd,\n" +
" a.lot_no AS lotNo,\n" +
" CAST(IFNULL(SUM(a.qty), 0) AS DOUBLE) AS qty \n" +
"FROM\n" +
" `wms_stock_sn` a ");
int size = propertyNames.length;
if (size > 0) {
queryString.append("where 1=1 and a.sn_status in ('"+ WmsEnumUtil.STOCK_SN_STATUS.PRE_INSTOCK.getValue()+"', '"+WmsEnumUtil.STOCK_SN_STATUS.INSTOCKED.getValue()+"','"+WmsEnumUtil.STOCK_SN_STATUS.PICKED.getValue()+"','"+WmsEnumUtil.STOCK_SN_STATUS.QUALITY_CONTROL.getValue()+"') ");
}
for (int i = 0; i < size; i++) {
if (values[i] != null) {
queryString.append(" and a." + StringCastUtils.upperCharToUnderLine(propertyNames[i]) + "= " + values[i]);
}
}
queryString.append(" group by a.lot_no,a.date_code");
return entityManager.createNativeQuery(queryString.toString()).unwrap(SQLQuery.class).setResultTransformer(
Transformers.ALIAS_TO_ENTITY_MAP).getResultList();
}
@Override
public List<T> findByProperty(String[] propertyNames, Object[] values) { public List<T> findByProperty(String[] propertyNames, Object[] values) {
if(propertyNames.length != values.length){ if(propertyNames.length != values.length){
throw new IllegalArgumentException("参数名的数量和参数值不匹配!propertyNames:" + propertyNames.length + ",values:" + values.length); throw new IllegalArgumentException("参数名的数量和参数值不匹配!propertyNames:" + propertyNames.length + ",values:" + values.length);
@ -1529,4 +1566,6 @@ public class BaseRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRep
} }
return num; return num;
} }
} }

@ -0,0 +1,33 @@
package cn.estsh.i3plus.pojo.base.util;
import org.springframework.cglib.beans.BeanMap;
import java.util.HashMap;
import java.util.Map;
public class BeanMapUtils {
/**
* map
*/
public static <T> Map<String, Object> beanToMap(T bean) {
Map<String, Object> map = new HashMap<>();
if (bean != null) {
BeanMap beanMap = BeanMap.create(bean);
for (Object key : beanMap.keySet()) {
map.put(key + "", beanMap.get(key));
}
}
return map;
}
/**
* map
*/
public static <T> T mapToBean(Map<String, Object> map, Class<T> clazz) throws Exception {
T bean = clazz.newInstance();
BeanMap beanMap = BeanMap.create(bean);
beanMap.putAll(map);
return bean;
}
}

@ -0,0 +1,38 @@
package cn.estsh.i3plus.pojo.base.util;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 线
*/
public class StringCastUtils {
public static String upperCharToUnderLine(String param) {
Pattern p= Pattern.compile("[A-Z]");
if(param==null ||param.equals("")){
return "";
}
StringBuilder builder=new StringBuilder(param);
Matcher mc=p.matcher(param);
int i=0;
while (mc.find()) {
System.out.println(builder.toString());
System.out.println("mc.start():" + mc.start() + ", i: " + i);
System.out.println("mc.end():" + mc.start() + ", i: " + i);
builder.replace(mc.start()+i, mc.end()+i, "_"+mc.group().toLowerCase());
i++;
}
if('_' == builder.charAt(0)){
builder.deleteCharAt(0);
}
System.out.println(builder.toString());
return builder.toString();
}
public static void main(String[] args) {
upperCharToUnderLine("snStatus");
}
}

@ -5,7 +5,6 @@ import cn.estsh.i3plus.pojo.softswitch.bean.*;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.Data; import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.Serializable; import java.io.Serializable;

@ -298,4 +298,15 @@ public class WmsStockSn extends BaseBean {
this.isDeleted = isDeleted; this.isDeleted = isDeleted;
this.isValid = isValid; this.isValid = isValid;
} }
public WmsStockSn(Integer snStatus,String whNo,String locateNo,String partNo,String partNameRdd,String lotNo,Double qty){
this.snStatus=snStatus;
this.whNo = whNo;
this.locateNo = locateNo;
this.partNo = partNo;
this.partNameRdd = partNameRdd;
this.lotNo = lotNo;
this.qty = qty;
}
} }

Loading…
Cancel
Save