@ -64,20 +64,37 @@ public interface ErpProductMapper extends BaseMapperX<ErpProductDO> {
. orderByDesc ( ErpProductDO : : getId ) ;
if ( Boolean . TRUE . equals ( reqVO . getStockNotZero ( ) ) ) {
StringBuilder stockExistsSql = new StringBuilder ( "SELECT 1 FROM erp_stock s WHERE s.deleted = b'0' AND s.product_id = erp_product.id AND s.count != 0" ) ;
if ( reqVO . getWarehouseId ( ) ! = null ) {
stockExistsSql . append ( " AND s.warehouse_id = " ) . append ( reqVO . getWarehouseId ( ) ) ;
}
if ( reqVO . getAreaId ( ) ! = null ) {
stockExistsSql . append ( " AND s.area_id = " ) . append ( reqVO . getAreaId ( ) ) ;
}
queryWrapper . exists ( stockExistsSql . toString ( ) ) ;
queryWrapper . exists ( Integer . valueOf ( 1 ) . equals ( reqVO . getCategoryType ( ) )
? buildPalletProductCountExistsSql ( reqVO )
: buildStockCountExistsSql ( reqVO ) ) ;
}
return selectPage ( reqVO , queryWrapper ) ;
}
default String buildStockCountExistsSql ( ErpProductPageReqVO reqVO ) {
StringBuilder stockExistsSql = new StringBuilder ( "SELECT 1 FROM erp_stock s WHERE s.deleted = b'0' AND s.product_id = erp_product.id AND s.count != 0" ) ;
if ( reqVO . getWarehouseId ( ) ! = null ) {
stockExistsSql . append ( " AND s.warehouse_id = " ) . append ( reqVO . getWarehouseId ( ) ) ;
}
if ( reqVO . getAreaId ( ) ! = null ) {
stockExistsSql . append ( " AND s.area_id = " ) . append ( reqVO . getAreaId ( ) ) ;
}
return stockExistsSql . toString ( ) ;
}
default String buildPalletProductCountExistsSql ( ErpProductPageReqVO reqVO ) {
StringBuilder palletExistsSql = new StringBuilder ( "SELECT 1 FROM erp_pallet p WHERE p.deleted = b'0' AND p.product_id = erp_product.id AND p.product_count != 0" ) ;
if ( reqVO . getWarehouseId ( ) ! = null ) {
palletExistsSql . append ( " AND p.warehouse_id = " ) . append ( reqVO . getWarehouseId ( ) ) ;
}
if ( reqVO . getAreaId ( ) ! = null ) {
palletExistsSql . append ( " AND p.area_id = " ) . append ( reqVO . getAreaId ( ) ) ;
}
return palletExistsSql . toString ( ) ;
}
default List < Long > selectCategoryIdsByType ( Integer categoryType ) {
if ( categoryType = = null ) {
return null ;