@ -3,8 +3,8 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.rulematch;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesNumberRuleMatchDispatchService ;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblyNosortContext ;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblySortContext ;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords ;
import cn.estsh.i3plus.pojo.mes.bean.MesProdRuleNosortCfg ;
import cn.estsh.i3plus.pojo.mes.bean.MesProdRuleSortCfg ;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil ;
import cn.estsh.impp.framework.boot.util.SpringContextsUtil ;
import lombok.extern.slf4j.Slf4j ;
@ -14,7 +14,9 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils ;
import java.util.ArrayList ;
import java.util.HashMap ;
import java.util.List ;
import java.util.Map ;
@Slf4j
@Primary
@ -28,23 +30,63 @@ public class MesNumberRuleMatchDispatchService implements IMesNumberRuleMatchDis
List < Object > resultList = new ArrayList < > ( ) ;
if ( numberRuleList . get ( 0 ) instanceof MesProdRuleNosortCfg ) numberRuleList . forEach ( o - > matchNumberRule ( organizeCode , sn , resultList , "mesNumberRuleMatchRegularExpressionService" , o , ( ( MesProdRuleNosortCfg ) o ) . getInPartNoRule ( ) ) ) ;
if ( numberRuleList . get ( 0 ) instanceof MesProdRuleNosortCfg ) numberRuleList . forEach ( o - > matchNumberRule BackList ( organizeCode , sn , resultList , MesExtEnumUtil . ASSEMBLY_MATCH_TYPE . MATCH_TYPE_20 . getStrategyClass ( ) , o , ( ( MesProdRuleNosortCfg ) o ) . getInPartNoRule ( ) ) ) ;
if ( numberRuleList . get ( 0 ) instanceof MesProductionAssemblyNosortContext ) numberRuleList . forEach ( o - > matchNumberRule ( organizeCode , sn , resultList , MesExtEnumUtil . ASSEMBLY_MATCH_TYPE . valueOfStrategyClass ( ( ( MesProductionAssemblyNosortContext ) o ) . getMatchType ( ) ) , o , ( ( MesProductionAssemblyNosortContext ) o ) . getMatchRule ( ) ) ) ;
if ( numberRuleList . get ( 0 ) instanceof MesProductionAssemblyNosortContext ) numberRuleList . forEach ( o - > matchNumberRule BackList ( organizeCode , sn , resultList , MesExtEnumUtil . ASSEMBLY_MATCH_TYPE . valueOfStrategyClass ( ( ( MesProductionAssemblyNosortContext ) o ) . getMatchType ( ) ) , o , ( ( MesProductionAssemblyNosortContext ) o ) . getMatchRule ( ) ) ) ;
if ( numberRuleList . get ( 0 ) instanceof MesProductionAssemblySortContext ) numberRuleList . forEach ( o - > matchNumberRule ( organizeCode , sn , resultList , "mesNumberRuleMatchRegularExpressionService" , o , ( ( MesProductionAssemblySortContext ) o ) . getMatchRule ( ) ) ) ;
if ( numberRuleList . get ( 0 ) instanceof MesProductionAssemblySortContext ) numberRuleList . forEach ( o - > matchNumberRule BackList ( organizeCode , sn , resultList , MesExtEnumUtil . ASSEMBLY_MATCH_TYPE . valueOfStrategyClass ( ( ( MesProductionAssemblySortContext ) o ) . getMatchType ( ) ) , o , ( ( MesProductionAssemblySortContext ) o ) . getMatchRule ( ) ) ) ;
return resultList ;
}
private void matchNumberRule ( String organizeCode , String sn , List < Object > resultList , String strategyClass , Object . . . params ) {
private List < Object > matchNumberRuleBackList ( String organizeCode , String sn , List < Object > resultList , String strategyClass , Object . . . params ) {
if ( StringUtils . isEmpty ( organizeCode ) | | StringUtils . isEmpty ( sn ) | | StringUtils . isEmpty ( strategyClass ) | | null = = params [ 0 ] ) return ;
if ( StringUtils . isEmpty ( organizeCode ) | | StringUtils . isEmpty ( sn ) | | StringUtils . isEmpty ( strategyClass ) | | null = = params [ 0 ] ) return resultList ;
Boolean result = ( ( IMesNumberRuleMatchDispatchService ) SpringContextsUtil . getBean ( strategyClass ) ) . matchNumberRule ( organizeCode , sn , params ) ;
Map< String , Object > result = ( ( IMesNumberRuleMatchDispatchService ) SpringContextsUtil . getBean ( strategyClass ) ) . matchNumberRule ( organizeCode , sn , params ) ;
if ( result ) resultList . add ( params [ 0 ] ) ;
if ( ( Boolean ) result . get ( MesPcnExtConstWords . RESULT ) ) resultList . add ( params [ 0 ] ) ;
return resultList ;
}
@Override
public Map < String , Object > matchNumberRule ( String organizeCode , String sn , Object numberRuleObj ) {
Map < String , Object > result = new HashMap < > ( ) ;
result . put ( MesPcnExtConstWords . RESULT , false ) ;
if ( StringUtils . isEmpty ( organizeCode ) | | StringUtils . isEmpty ( sn ) | | null = = numberRuleObj ) {
result . put ( MesPcnExtConstWords . MESSAGE , String . format ( "请检查必要参数:工厂[%s]条码[%s]及规则匹配信息!" , organizeCode , sn ) ) ;
return result ;
}
if ( numberRuleObj instanceof MesProdRuleNosortCfg ) return matchNumberRuleBackMap ( organizeCode , sn , result , MesExtEnumUtil . ASSEMBLY_MATCH_TYPE . MATCH_TYPE_20 . getStrategyClass ( ) , numberRuleObj , ( ( MesProdRuleNosortCfg ) numberRuleObj ) . getInPartNoRule ( ) ) ;
if ( numberRuleObj instanceof MesProductionAssemblyNosortContext ) return matchNumberRuleBackMap ( organizeCode , sn , result , MesExtEnumUtil . ASSEMBLY_MATCH_TYPE . valueOfStrategyClass ( ( ( MesProductionAssemblyNosortContext ) numberRuleObj ) . getMatchType ( ) ) , numberRuleObj , ( ( MesProductionAssemblyNosortContext ) numberRuleObj ) . getMatchRule ( ) ) ;
if ( numberRuleObj instanceof MesProductionAssemblySortContext ) return matchNumberRuleBackMap ( organizeCode , sn , result , MesExtEnumUtil . ASSEMBLY_MATCH_TYPE . valueOfStrategyClass ( ( ( MesProductionAssemblySortContext ) numberRuleObj ) . getMatchType ( ) ) , numberRuleObj , ( ( MesProductionAssemblySortContext ) numberRuleObj ) . getMatchRule ( ) ) ;
return result ;
}
private Map < String , Object > matchNumberRuleBackMap ( String organizeCode , String sn , Map < String , Object > resultMap , String strategyClass , Object . . . params ) {
if ( StringUtils . isEmpty ( strategyClass ) ) {
resultMap . put ( MesPcnExtConstWords . MESSAGE , "规则匹配信息的匹配确认方式配置错误,未找到相应的匹配策略!" ) ;
return resultMap ;
}
Map < String , Object > result = ( ( IMesNumberRuleMatchDispatchService ) SpringContextsUtil . getBean ( strategyClass ) ) . matchNumberRule ( organizeCode , sn , params ) ;
if ( ( Boolean ) result . get ( MesPcnExtConstWords . RESULT ) ) result . put ( MesPcnExtConstWords . DATA , params [ 0 ] ) ;
return result ;
}
}