引入依赖
< dependency> < groupId> com. github. hongwen1993< / groupId> < artifactId> fast- drools- spring- boot- starter< / artifactId> < version> 8.0 .8 < / version> < scope> compile< / scope>
< / dependency>
yml配置
spring: drools: # 指定规则文件文件夹,会自动扫描该目录下所有规则文件,决策表,以及CSV文件path: D : / / # 也可以指定全局的mode,选择stream或cloudmode: streamauto- update: on# 指定规则文件自动更新的周期,单位秒,默认30 秒扫描一次update: 10 listener: onverify: off
代码
@Autowired private KieTemplate kieTemplate; KieSession session = kieTemplate. getKieSession ( itemTemplateName+ ".drl" ) ; session. setGlobal ( "res_list" , res_list) ; for ( int i = 0 ; i < recordDetaillist. size ( ) ; i++ ) { session. insert ( recordDetaillist. get ( i) ) ; } session. fireAllRules ( ) ;
规则文件
package rules import com. wpmt. ons. domain. ByRecordStyleDetail ;
import com. wpmt. ons. domain. ByRecordTypeDict ;
import com. wpmt. ons. domain. BySurgicalIncision ;
import com. wpmt. ons. domain. BySignRecordV2 ;
import com. wpmt. framework. system. shly. RecordCheckVo ;
import java. util. ArrayList ;
import java. util. List ; global java. util. List res_list;
rule "sshl_shly_nurse_a01"
when$s : ByRecordStyleDetail ( fieldKey == "sshl_shly_nurse_a01" && fieldValue == "" )
then
end
rule "sshl_shly_nurse_a02"
when$s : ByRecordStyleDetail ( fieldKey == "sshl_shly_nurse_a02" && fieldValue == "" ) ;
then RecordCheckVo vo = new RecordCheckVo ( "sshl_shly_nurse_a02" , "压力:未填写 " ) ; res_list. add ( vo) ;
endrule "sshl_shly_nurse_a13"
when$s : ByRecordStyleDetail ( fieldKey == "sshl_shly_nurse_a13" && fieldValue == "" ) ;
then RecordCheckVo vo = new RecordCheckVo ( "sshl_shly_nurse_a13" , "患者体内植入物 未填写" ) ; res_list. add ( vo) ;
endrule "sshl_shly_nurse_a14"
when$s : ByRecordStyleDetail ( fieldKey == "sshl_shly_nurse_a13" && fieldValue == "0" ) ; $s1 : ByRecordStyleDetail ( fieldKey == "sshl_shly_nurse_a14" && fieldValue == "" ) ;
then RecordCheckVo vo = new RecordCheckVo ( "sshl_shly_nurse_a14" , "患者体内植入物-详情 未填写" ) ; res_list. add ( vo) ;
endrule "sshl192021" when$recordDetaillist : List ( size > 0 ) ; $sshl_shly_nurse_a19: ByRecordStyleDetail ( fieldKey == "sshl_shly_nurse_a19" ) from $recordDetaillist; $sshl_shly_nurse_a20: ByRecordStyleDetail ( fieldKey == "sshl_shly_nurse_a20" ) from $recordDetaillist; $sshl_shly_nurse_a21: ByRecordStyleDetail ( fieldKey == "sshl_shly_nurse_a21" ) from $recordDetaillist; then System . out. println ( "$sshl_shly_nurse_a19.getFieldValue()=" + $sshl_shly_nurse_a19. getFieldValue ( ) ) ; System . out. println ( "$sshl_shly_nurse_a21.getFieldValue()=" + $sshl_shly_nurse_a21. getFieldValue ( ) ) ; System . out. println ( "$sshl_shly_nurse_a20.getFieldValue()=" + $sshl_shly_nurse_a20. getFieldValue ( ) ) ; RecordCheckVo vo = new RecordCheckVo ( "sshl_shly_nurse_a19" , "双极 未填写" ) ; res_list. add ( vo) ; end