@ -12,16 +12,14 @@ import com.win.framework.common.pojo.PageResult;
import com.win.framework.datapermission.core.util.DataPermissionUtils ;
import com.win.module.wms.controller.location.vo.* ;
import com.win.module.wms.controller.rule.vo.RuleRespVO ;
import com.win.module.wms.convert.bom.BomConvert ;
import com.win.module.wms.convert.location.LocationConvert ;
import com.win.module.wms.dal.dataobject.bom.Bom DO ;
import com.win.module.wms.dal.dataobject.itembasic.Itembasic DO ;
import com.win.module.wms.dal.dataobject.location.LocationDO ;
import com.win.module.wms.dal.mysql.balance.BalanceMapper ;
import com.win.module.wms.dal.mysql.expectout.ExpectoutMapper ;
import com.win.module.wms.dal.mysql.location.LocationMapper ;
import com.win.module.wms.service.rule.RuleService ;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.interceptor.TransactionAspectSupport ;
import org.springframework.validation.annotation.Validated ;
import javax.annotation.Resource ;
@ -306,38 +304,99 @@ public class LocationServiceImpl implements LocationService {
//{"WarehouseCode":"W1","AreaCode":"A1","LocationGroupCode":"LG1","LocationCode":"H01","EmptyLocationFirst":"FALSE","NotEmptyLocationFirst":"FALSE",
// "EnableMixItem":"TRUE","EnableMixLot":"TRUE","EnableMixStatus":"TRUE"}
@Override
public LocationDO inspectLocation ( RuleRespVO ruleRespVO , String packingNumber , String itemCode , String batch ) {
public LocationDO inspectLocation ( RuleRespVO ruleRespVO , ItembasicDO itembasicDO ) {
JSONObject jsonObject = JSONUtil . parseObj ( ruleRespVO . getConfiguration ( ) ) ;
Object locationCode = jsonObject . get ( "LocationCode" ) ;
//设置了库位直接返回
if ( locationCode ! = null ) {
return this . selectLocation ( String . valueOf ( locationCode ) ) ;
}
//增加过滤条件
QueryWrapper < LocationDO > queryWrapper = new QueryWrapper < > ( ) ;
List < String > locationTypeList = new ArrayList < > ( ) ;
locationTypeList . add ( "RAW" ) ;
locationTypeList . add ( "SEMI" ) ;
locationTypeList . add ( "FG" ) ;
queryWrapper . in ( "`type`" , locationTypeList ) ;
Object warehouseCode = String . valueOf ( jsonObject . get ( "WarehouseCode" ) ) ;
if ( ! warehouseCode . equals ( "" ) ) {
Object warehouseCode = jsonObject . get ( "WarehouseCode" ) ;
if ( ! "" . equals ( warehouseCode ) ) {
queryWrapper . eq ( "warehouse_code" , warehouseCode ) ;
}
Object areaCode = jsonObject . get ( "AreaCode" ) ;
if ( ! areaCode . equals ( "" ) ) {
if ( ! "" . equals ( areaCode ) ) {
queryWrapper . eq ( "area_code" , areaCode ) ;
}
Object locationGroupCode = String . valueOf ( jsonObject . get ( "LocationGroupCode" ) ) ;
if ( ! locationGroupCode . equals ( "" ) ) {
Object locationGroupCode = jsonObject . get ( "LocationGroupCode" ) ;
if ( ! "" . equals ( locationGroupCode ) ) {
queryWrapper . eq ( "location_group_code" , locationGroupCode ) ;
}
String emptyLocationFirst = String . valueOf ( jsonObject . get ( "EmptyLocationFirst" ) ) ;
if ( "TRUE" . equals ( emptyLocationFirst ) ) {
queryWrapper . notExists ( "SELECT id FROM transaction_balance WHERE packing_number=? AND item_code=? AND batch=? AND QTY > 0" , packingNumber , itemCode , batch ) ;
//排序
Object aisleOrder = jsonObject . get ( "AisleOrder" ) ;
if ( "DESC" . equals ( aisleOrder ) ) {
queryWrapper . orderByDesc ( "aisle" ) ;
} else {
queryWrapper . orderByAsc ( "aisle" ) ;
}
Object shelfOrder = jsonObject . get ( "ShelfOrder" ) ;
if ( "DESC" . equals ( shelfOrder ) ) {
queryWrapper . orderByDesc ( "shelf" ) ;
} else {
queryWrapper . exists ( "SELECT id FROM transaction_balance WHERE packing_number=? AND item_code=? AND batch=?" , packingNumber , itemCode , batch ) ;
queryWrapper . orderByAsc ( "shelf" ) ;
}
queryWrapper . last ( "LIMIT 1" ) ;
return locationMapper . selectOne ( queryWrapper ) ;
Object rowOrder = jsonObject . get ( "RowOrder" ) ;
if ( "DESC" . equals ( rowOrder ) ) {
queryWrapper . orderByDesc ( "location_row" ) ;
} else {
queryWrapper . orderByAsc ( "location_row" ) ;
}
Object columOrder = jsonObject . get ( "ColumOrder" ) ;
if ( "DESC" . equals ( columOrder ) ) {
queryWrapper . orderByDesc ( "location_colum" ) ;
} else {
queryWrapper . orderByAsc ( "location_colum" ) ;
}
List < LocationDO > locationDOList = locationMapper . selectList ( queryWrapper ) ;
//查询符合条件的库位之后过滤
//优先空库位
Object emptyLocationFirst = jsonObject . get ( "EmptyLocationFirst" ) ;
//优先非空库位
Object notEmptyLocationFirst = jsonObject . get ( "NotEmptyLocationFirst" ) ;
//可以混物品
Object enableMixItem = jsonObject . get ( "EnableMixItem" ) ;
//可以混批次
Object enableMixLot = jsonObject . get ( "EnableMixLot" ) ;
//可以混状态
Object enableMixStatus = jsonObject . get ( "EnableMixStatus" ) ;
if ( "TRUE" . equals ( emptyLocationFirst ) ) {
locationDOList = this . emptyLocationFirst ( locationDOList , enableMixItem , enableMixLot , enableMixStatus ) ;
} else if ( "TRUE" . equals ( notEmptyLocationFirst ) ) {
locationDOList = this . notEmptyLocationFirst ( locationDOList , enableMixItem , enableMixLot , enableMixStatus ) ;
}
return locationDOList . get ( 0 ) ;
}
/ * *
* 优先空库位过滤
* @param locationDOList 库位list
* @param enableMixItem 可以混物品
* @param enableMixLot 可以混批次
* @param enableMixStatus 可以混状态
* @return 过滤之后的库位list
* /
private List < LocationDO > emptyLocationFirst ( List < LocationDO > locationDOList , Object enableMixItem , Object enableMixLot , Object enableMixStatus ) {
return locationDOList ;
}
/ * *
* 优先非空库位过滤
* @param locationDOList 库位list
* @param enableMixItem 可以混物品
* @param enableMixLot 可以混批次
* @param enableMixStatus 可以混状态
* @return 过滤之后的库位list
* /
private List < LocationDO > notEmptyLocationFirst ( List < LocationDO > locationDOList , Object enableMixItem , Object enableMixLot , Object enableMixStatus ) {
return locationDOList ;
}
}