@ -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.common.Pager ;
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.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.hibernate.NonUniqueResultException ;
import org.hibernate.SQLQuery ;
import org.hibernate.transform.Transformers ;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
import org.springframework.data.jpa.repository.support.SimpleJpaRepository ;
@ -219,6 +224,7 @@ public class BaseRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRep
/ * *
* 更 新 参 数 汇 总 方 法
*
* @param conditionName 条 件 属 性 名
* @param conditionValue 条 件 属 性 值
* @param propertyName 更 新 属 性 名
@ -412,6 +418,37 @@ public class BaseRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRep
}
@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 ) {
if ( propertyNames . length ! = 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 ;
}
}