@ -10,8 +10,14 @@ import com.win.framework.common.pojo.PageResult;
import com.win.framework.datapermission.core.util.DataPermissionUtils ;
import com.win.module.wms.controller.rule.vo.* ;
import com.win.module.wms.convert.rule.RuleConvert ;
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO ;
import com.win.module.wms.dal.dataobject.location.LocationDO ;
import com.win.module.wms.dal.dataobject.rule.RuleDO ;
import com.win.module.wms.dal.dataobject.supplier.SupplierDO ;
import com.win.module.wms.dal.mysql.itembasic.ItembasicMapper ;
import com.win.module.wms.dal.mysql.location.LocationMapper ;
import com.win.module.wms.dal.mysql.rule.RuleMapper ;
import com.win.module.wms.dal.mysql.supplier.SupplierMapper ;
import org.springframework.stereotype.Service ;
import org.springframework.validation.annotation.Validated ;
@ -33,6 +39,12 @@ public class RuleServiceImpl implements RuleService {
@Resource
private RuleMapper ruleMapper ;
@Resource
private ItembasicMapper itembasicMapper ;
@Resource
private SupplierMapper supplierMapper ;
@Resource
private LocationMapper locationMapper ;
@Override
public Long createRule ( RuleCreateReqVO createReqVO ) {
@ -76,6 +88,7 @@ public class RuleServiceImpl implements RuleService {
// 删除
ruleMapper . deleteById ( id ) ;
}
@Override
public PageResult < RuleDO > getRuleSenior ( CustomConditions conditions ) {
return ruleMapper . selectSenior ( conditions ) ;
@ -96,10 +109,12 @@ public class RuleServiceImpl implements RuleService {
public PageResult < RuleDO > getRulePage ( RulePageReqVO pageReqVO ) {
return ruleMapper . selectPage ( pageReqVO ) ;
}
@Override
public List < RuleDO > getRuleList ( CustomConditions conditions ) {
return ruleMapper . selectSeniorList ( conditions ) ;
}
private void validateRuleForCreateOrUpdate ( Long id , String strategyCode , Integer priority ) {
// 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确
DataPermissionUtils . executeIgnore ( ( ) - > {
@ -109,6 +124,7 @@ public class RuleServiceImpl implements RuleService {
validatePriority ( priority ) ;
} ) ;
}
@VisibleForTesting
private void validateRuleExists ( Long id ) {
if ( id = = null ) {
@ -125,6 +141,7 @@ public class RuleServiceImpl implements RuleService {
throw exception ( RULE_STRATEGYCODE_NOT_EXISTS ) ;
}
}
@VisibleForTesting
private void validatePriority ( Integer priority ) {
if ( priority = = null ) {
@ -133,7 +150,7 @@ public class RuleServiceImpl implements RuleService {
}
@Override
public RuleRespVO deliverGoods ( String supplierType , String supplier Code , String weekday ) {
public RuleRespVO deliverGoods ( String supplierCode , String weekday ) {
QueryWrapper < RuleDO > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( "strategy_code" , "S001" ) ;
queryWrapper . orderByDesc ( "priority" ) ;
@ -146,9 +163,6 @@ public class RuleServiceImpl implements RuleService {
}
JSONArray conditionArray = JSONUtil . parseArray ( condition ) ;
Map < String , String > params = new HashMap < > ( ) ;
if ( supplierType ! = null & & ! supplierType . isEmpty ( ) ) {
params . put ( "SupplierType" , supplierType ) ;
}
if ( supplierCode ! = null & & ! supplierCode . isEmpty ( ) ) {
params . put ( "SupplierCode" , supplierCode ) ;
}
@ -163,7 +177,7 @@ public class RuleServiceImpl implements RuleService {
}
@Override
public RuleRespVO deliveryGoods ( String supplierType , String supplier Code ) {
public RuleRespVO deliveryGoods ( String supplierCode ) {
QueryWrapper < RuleDO > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( "strategy_code" , "S002" ) ;
queryWrapper . orderByDesc ( "priority" ) ;
@ -176,9 +190,6 @@ public class RuleServiceImpl implements RuleService {
}
JSONArray conditionArray = JSONUtil . parseArray ( condition ) ;
Map < String , String > params = new HashMap < > ( ) ;
if ( supplierType ! = null & & ! supplierType . isEmpty ( ) ) {
params . put ( "SupplierType" , supplierType ) ;
}
if ( supplierCode ! = null & & ! supplierCode . isEmpty ( ) ) {
params . put ( "SupplierCode" , supplierCode ) ;
}
@ -214,7 +225,7 @@ public class RuleServiceImpl implements RuleService {
}
@Override
public RuleRespVO inspectSplit ( String supplierType , String item Code ) {
public RuleRespVO inspectSplit ( String supplierCode ) {
QueryWrapper < RuleDO > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( "strategy_code" , "S004" ) ;
queryWrapper . orderByDesc ( "priority" ) ;
@ -226,11 +237,8 @@ public class RuleServiceImpl implements RuleService {
}
JSONArray conditionArray = JSONUtil . parseArray ( condition ) ;
Map < String , String > params = new HashMap < > ( ) ;
if ( supplierType ! = null & & ! supplierType . isEmpty ( ) ) {
params . put ( "SupplierType" , supplierType ) ;
}
if ( itemCode ! = null & & ! itemCode . isEmpty ( ) ) {
params . put ( "ItemCode" , itemCode ) ;
if ( supplierCode ! = null & & ! supplierCode . isEmpty ( ) ) {
params . put ( "SupplierCode" , supplierCode ) ;
}
if ( this . forEachParams ( params , conditionArray ) ) {
return RuleConvert . INSTANCE . convert ( ruleDO ) ;
@ -240,7 +248,7 @@ public class RuleServiceImpl implements RuleService {
}
@Override
public RuleRespVO grounding ( String supplierCode , String customerCode , String abcClass , String itemType , String itemGroup , String project , String itemCode , String inventoryStatus , String storageType , String transactionType , String weight , String area , String volume ) {
public RuleRespVO grounding ( String supplierCode , String customerCode , String itemCode , String inventoryStatus , String storageType , String transactionType , String weight , String area , String volume ) {
QueryWrapper < RuleDO > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( "strategy_code" , "S005" ) ;
queryWrapper . orderByDesc ( "priority" ) ;
@ -258,18 +266,6 @@ public class RuleServiceImpl implements RuleService {
if ( customerCode ! = null & & ! customerCode . isEmpty ( ) ) {
params . put ( "CustomerCode" , customerCode ) ;
}
if ( abcClass ! = null & & ! abcClass . isEmpty ( ) ) {
params . put ( "AbcClass" , abcClass ) ;
}
if ( itemType ! = null & & ! itemType . isEmpty ( ) ) {
params . put ( "ItemType" , itemType ) ;
}
if ( itemGroup ! = null & & ! itemGroup . isEmpty ( ) ) {
params . put ( "ItemGroup" , itemGroup ) ;
}
if ( project ! = null & & ! project . isEmpty ( ) ) {
params . put ( "Project" , project ) ;
}
if ( itemCode ! = null & & ! itemCode . isEmpty ( ) ) {
params . put ( "ItemCode" , itemCode ) ;
}
@ -299,7 +295,7 @@ public class RuleServiceImpl implements RuleService {
}
@Override
public RuleRespVO storageCapacity ( String itemGroup , String project , String itemCode , String warehouseCode , String areaCode , String locationGroup Code , String locationCode ) {
public RuleRespVO storageCapacity ( String itemCode , String locationCode ) {
QueryWrapper < RuleDO > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( "strategy_code" , "S006" ) ;
queryWrapper . orderByDesc ( "priority" ) ;
@ -311,24 +307,9 @@ public class RuleServiceImpl implements RuleService {
}
JSONArray conditionArray = JSONUtil . parseArray ( condition ) ;
Map < String , String > params = new HashMap < > ( ) ;
if ( itemGroup ! = null & & ! itemGroup . isEmpty ( ) ) {
params . put ( "ItemGroup" , itemGroup ) ;
}
if ( project ! = null & & ! project . isEmpty ( ) ) {
params . put ( "Project" , project ) ;
}
if ( itemCode ! = null & & ! itemCode . isEmpty ( ) ) {
params . put ( "ItemCode" , itemCode ) ;
}
if ( warehouseCode ! = null & & ! warehouseCode . isEmpty ( ) ) {
params . put ( "WarehouseCode" , warehouseCode ) ;
}
if ( areaCode ! = null & & ! areaCode . isEmpty ( ) ) {
params . put ( "AreaCode" , areaCode ) ;
}
if ( locationGroupCode ! = null & & ! locationGroupCode . isEmpty ( ) ) {
params . put ( "LocationGroupCode" , locationGroupCode ) ;
}
if ( locationCode ! = null & & ! locationCode . isEmpty ( ) ) {
params . put ( "LocationCode" , locationCode ) ;
}
@ -340,7 +321,7 @@ public class RuleServiceImpl implements RuleService {
}
@Override
public RuleRespVO offShelf ( String supplierCode , String customerCode , String abcClass , String itemType , String itemGroup , String project , String itemCode , String inventoryStatus , String storageType , String transactionType ) {
public RuleRespVO offShelf ( String supplierCode , String customerCode , String itemCode , String inventoryStatus , String storageType , String transactionType ) {
QueryWrapper < RuleDO > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( "strategy_code" , "S007" ) ;
queryWrapper . orderByDesc ( "priority" ) ;
@ -358,18 +339,6 @@ public class RuleServiceImpl implements RuleService {
if ( customerCode ! = null & & ! customerCode . isEmpty ( ) ) {
params . put ( "CustomerCode" , customerCode ) ;
}
if ( abcClass ! = null & & ! abcClass . isEmpty ( ) ) {
params . put ( "AbcClass" , abcClass ) ;
}
if ( itemType ! = null & & ! itemType . isEmpty ( ) ) {
params . put ( "ItemType" , itemType ) ;
}
if ( itemGroup ! = null & & ! itemGroup . isEmpty ( ) ) {
params . put ( "ItemGroup" , itemGroup ) ;
}
if ( project ! = null & & ! project . isEmpty ( ) ) {
params . put ( "Project" , project ) ;
}
if ( itemCode ! = null & & ! itemCode . isEmpty ( ) ) {
params . put ( "ItemCode" , itemCode ) ;
}
@ -390,7 +359,7 @@ public class RuleServiceImpl implements RuleService {
}
@Override
public RuleRespVO replenishment ( String itemGroup , String project , String itemCode , String warehouseCode , String areaCode , String locationGroup Code , String locationCode ) {
public RuleRespVO replenishment ( String itemCode , String locationCode ) {
QueryWrapper < RuleDO > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( "strategy_code" , "S008" ) ;
queryWrapper . orderByDesc ( "priority" ) ;
@ -402,21 +371,9 @@ public class RuleServiceImpl implements RuleService {
}
JSONArray conditionArray = JSONUtil . parseArray ( condition ) ;
Map < String , String > params = new HashMap < > ( ) ;
if ( project ! = null & & ! project . isEmpty ( ) ) {
params . put ( "Project" , project ) ;
}
if ( itemCode ! = null & & ! itemCode . isEmpty ( ) ) {
params . put ( "ItemCode" , itemCode ) ;
}
if ( warehouseCode ! = null & & ! warehouseCode . isEmpty ( ) ) {
params . put ( "WarehouseCode" , warehouseCode ) ;
}
if ( areaCode ! = null & & ! areaCode . isEmpty ( ) ) {
params . put ( "AreaCode" , areaCode ) ;
}
if ( locationGroupCode ! = null & & ! locationGroupCode . isEmpty ( ) ) {
params . put ( "LocationGroupCode" , locationGroupCode ) ;
}
if ( locationCode ! = null & & ! locationCode . isEmpty ( ) ) {
params . put ( "LocationCode" , locationCode ) ;
}
@ -428,7 +385,7 @@ public class RuleServiceImpl implements RuleService {
}
@Override
public RuleRespVO management ( String supplierCode , String customerCode , String abcClass , String itemType , String itemGroup , String project , String itemCode , String warehouseCode , String areaCode , String locationGroup Code , String locationCode , String ignoreListOfItem , String ignoreListOfLocation ) {
public RuleRespVO management ( String supplierCode , String customerCode , String itemCode , String locationCode , String ignoreListOfItem , String ignoreListOfLocation ) {
QueryWrapper < RuleDO > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( "strategy_code" , "S009" ) ;
queryWrapper . orderByDesc ( "priority" ) ;
@ -446,30 +403,9 @@ public class RuleServiceImpl implements RuleService {
if ( customerCode ! = null & & ! customerCode . isEmpty ( ) ) {
params . put ( "CustomerCode" , customerCode ) ;
}
if ( abcClass ! = null & & ! abcClass . isEmpty ( ) ) {
params . put ( "AbcClass" , abcClass ) ;
}
if ( itemType ! = null & & ! itemType . isEmpty ( ) ) {
params . put ( "ItemType" , itemType ) ;
}
if ( itemGroup ! = null & & ! itemGroup . isEmpty ( ) ) {
params . put ( "ItemGroup" , itemGroup ) ;
}
if ( project ! = null & & ! project . isEmpty ( ) ) {
params . put ( "Project" , project ) ;
}
if ( itemCode ! = null & & ! itemCode . isEmpty ( ) ) {
params . put ( "ItemCode" , itemCode ) ;
}
if ( warehouseCode ! = null & & ! warehouseCode . isEmpty ( ) ) {
params . put ( "WarehouseCode" , warehouseCode ) ;
}
if ( areaCode ! = null & & ! areaCode . isEmpty ( ) ) {
params . put ( "AreaCode" , areaCode ) ;
}
if ( locationGroupCode ! = null & & ! locationGroupCode . isEmpty ( ) ) {
params . put ( "LocationGroupCode" , locationGroupCode ) ;
}
if ( locationCode ! = null & & ! locationCode . isEmpty ( ) ) {
params . put ( "LocationCode" , locationCode ) ;
}
@ -487,7 +423,7 @@ public class RuleServiceImpl implements RuleService {
}
@Override
public RuleRespVO batch ( String supplierCode , String customerCode , String abcClass , String itemType , String itemGroup , String project , String itemCode ) {
public RuleRespVO batch ( String supplierCode , String customerCode , String itemCode ) {
QueryWrapper < RuleDO > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( "strategy_code" , "S010" ) ;
queryWrapper . orderByDesc ( "priority" ) ;
@ -505,18 +441,6 @@ public class RuleServiceImpl implements RuleService {
if ( customerCode ! = null & & ! customerCode . isEmpty ( ) ) {
params . put ( "CustomerCode" , customerCode ) ;
}
if ( abcClass ! = null & & ! abcClass . isEmpty ( ) ) {
params . put ( "AbcClass" , abcClass ) ;
}
if ( itemType ! = null & & ! itemType . isEmpty ( ) ) {
params . put ( "ItemType" , itemType ) ;
}
if ( itemGroup ! = null & & ! itemGroup . isEmpty ( ) ) {
params . put ( "ItemGroup" , itemGroup ) ;
}
if ( project ! = null & & ! project . isEmpty ( ) ) {
params . put ( "Project" , project ) ;
}
if ( itemCode ! = null & & ! itemCode . isEmpty ( ) ) {
params . put ( "ItemCode" , itemCode ) ;
}
@ -529,7 +453,7 @@ public class RuleServiceImpl implements RuleService {
}
@Override
public RuleRespVO warehouseStorage ( String warehouseCode , String areaCode , String locationGroupCode , String locationCode ) {
public RuleRespVO warehouseStorage ( String locationCode ) {
QueryWrapper < RuleDO > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( "strategy_code" , "S011" ) ;
queryWrapper . orderByDesc ( "priority" ) ;
@ -541,15 +465,6 @@ public class RuleServiceImpl implements RuleService {
}
JSONArray conditionArray = JSONUtil . parseArray ( condition ) ;
Map < String , String > params = new HashMap < > ( ) ;
if ( warehouseCode ! = null & & ! warehouseCode . isEmpty ( ) ) {
params . put ( "WarehouseCode" , warehouseCode ) ;
}
if ( areaCode ! = null & & ! areaCode . isEmpty ( ) ) {
params . put ( "AreaCode" , areaCode ) ;
}
if ( locationGroupCode ! = null & & ! locationGroupCode . isEmpty ( ) ) {
params . put ( "LocationGroupCode" , locationGroupCode ) ;
}
if ( locationCode ! = null & & ! locationCode . isEmpty ( ) ) {
params . put ( "LocationCode" , locationCode ) ;
}
@ -561,7 +476,7 @@ public class RuleServiceImpl implements RuleService {
}
@Override
public RuleRespVO applianceCapacity ( String containerType , String itemGroup , String projectCode , String item Code ) {
public RuleRespVO applianceCapacity ( String containerType , String itemCode ) {
QueryWrapper < RuleDO > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( "strategy_code" , "S012" ) ;
queryWrapper . orderByDesc ( "priority" ) ;
@ -574,12 +489,6 @@ public class RuleServiceImpl implements RuleService {
JSONArray conditionArray = JSONUtil . parseArray ( condition ) ;
Map < String , String > params = new HashMap < > ( ) ;
params . put ( "ContainerType" , containerType ) ;
if ( itemGroup ! = null & & ! itemGroup . isEmpty ( ) ) {
params . put ( "ItemGroup" , itemGroup ) ;
}
if ( projectCode ! = null & & ! projectCode . isEmpty ( ) ) {
params . put ( "ProjectCode" , projectCode ) ;
}
if ( itemCode ! = null & & ! itemCode . isEmpty ( ) ) {
params . put ( "ItemCode" , itemCode ) ;
}
@ -595,8 +504,7 @@ public class RuleServiceImpl implements RuleService {
List < HashMap < String , Object > > list = new ArrayList < > ( ) ;
for ( String code : reqVO . getItemCodes ( ) ) {
HashMap < String , Object > map = new HashMap < > ( ) ;
RuleRespVO RespVO = management ( null , null , null , null , null , null , code , null , null ,
null , reqVO . getLocationCode ( ) , null , null ) ;
RuleRespVO RespVO = management ( null , null , code , reqVO . getLocationCode ( ) , null , null ) ;
JSONObject entries = JSONUtil . parseObj ( RespVO . getConfiguration ( ) ) ;
map . put ( "ManagementPrecision" , entries . get ( "ManagementPrecision" ) ) ;
map . put ( "itemCode" , code ) ;
@ -607,15 +515,36 @@ public class RuleServiceImpl implements RuleService {
/ * *
* 循环校验参数
*
* @param params 参数
* @param conditionArray 条件json数组
* @return
* /
private boolean forEachParams ( Map < String , String > params , JSONArray conditionArray ) {
Map < String , String > paramsMap = new HashMap < > ( ) ;
boolean result1 = false ;
//填充参数
for ( String key : params . keySet ( ) ) {
if ( "SupplierCode" . equals ( key ) ) {
SupplierDO supplierDO = supplierMapper . selectByCode ( params . get ( key ) ) ;
paramsMap . put ( "SupplierType" , supplierDO . getType ( ) ) ;
} else if ( "ItemCode" . equals ( key ) ) {
ItembasicDO itembasicDO = itembasicMapper . selectByCode ( params . get ( key ) ) ;
paramsMap . put ( "AbcClass" , itembasicDO . getAbcClass ( ) ) ;
paramsMap . put ( "ItemType" , itembasicDO . getType ( ) ) ;
paramsMap . put ( "ItemGroup" , itembasicDO . getItemGroup ( ) ) ;
paramsMap . put ( "Project" , itembasicDO . getProject ( ) ) ;
} else if ( "LocationCode" . equals ( key ) ) {
LocationDO locationDO = locationMapper . selectByCode ( params . get ( key ) ) ;
paramsMap . put ( "WarehouseCode" , locationDO . getWarehouseCode ( ) ) ;
paramsMap . put ( "AreaCode" , locationDO . getAreaCode ( ) ) ;
paramsMap . put ( "LocationGroupCode" , locationDO . getLocationGroupCode ( ) ) ;
}
paramsMap . put ( key , params . get ( key ) ) ;
}
for ( int i = 0 ; i < conditionArray . size ( ) ; i + + ) {
JSONObject conditionObject = conditionArray . getJSONObject ( i ) ;
for ( String key : params . keySet ( ) ) {
for ( String key : paramsMap . keySet ( ) ) {
if ( key . equals ( conditionObject . get ( "ParamCode" ) ) & & conditionObject . get ( "ParamCode" ) ! = null ) {
boolean result2 = this . checkCondition ( conditionObject , key , params . get ( key ) ) ;
if ( ! result2 ) {
@ -632,6 +561,7 @@ public class RuleServiceImpl implements RuleService {
/ * *
* 判断条件
*
* @param conditionObject 条件json
* @param paramCode 条件key
* @param paramValue 条件value