Drools4:对Ticket示范的分析
Drools4:对Ticket示例的分析?#?显示增加的门票情况 ??rule?New?Ticket??????salience?10??????when ????
Drools4:对Ticket示例的分析
?
- #?显示增加的门票情况 ??
- rule?"New?Ticket"??
- ????salience?10??
- ????when ??
- ????????customer?:?CustomerEx(?)???? ??
- ????????ticket?:?Ticket(?customer?==?customer,?status?==?"New"?)???? ??
- ????then ??
- ????????System.out.println(?"New?:?"?+?ticket?);???????? ??
- end ??
- ??
- #?找到银卡会员,设置电影票状态 ??
- rule?"Silver?Priority"??
- ????duration?3000??
- ????when ??
- ????????customer?:?CustomerEx(?subscription?==?"Silver"?)??? ??
- ????????ticket?:?Ticket(?customer?==?customer,?status?==?"New"?)???? ??
- ????then ??
- ????????ticket.setStatus(?"Escalate"?); ??
- ????????update(?ticket?);??????? ??
- end ??
- ??
- #?找到白金卡会员,设置电影票状态 ??
- rule?"Platinum?Priority"??
- ????when ??
- ????????customer?:?CustomerEx(?subscription?==?"Platinum"?)? ??
- ????????ticket?:?Ticket(?customer?==?customer,?status?==?"New"?)???? ??
- ????then; ??
- ????????ticket.setStatus(?"Escalate"?); ??
- ????????update(?ticket?); ??
- end ??
- ??
- #?找到金卡会员,设置电影票状态 ??
- rule?"Gold?Priority"??
- ????duration?1000??
- ????when ??
- ????????customer?:?CustomerEx(?subscription?==?"Gold"?)? ??
- ????????ticket?:?Ticket(?customer?==?customer,?status?==?"New"?)???? ??
- ????then ??
- ????????ticket.setStatus(?"Escalate"?);? ??
- ????????update(?ticket?);??? ??
- end ??
- ??
- #?对于被设置状态为Escalate的电影票发送邮件 ??
- rule?"Escalate"??
- ????when ??
- ????????customer?:?CustomerEx(?)???? ??
- ????????ticket?:?Ticket(?customer?==?customer,?status?==?"Escalate"?)??? ??
- ????then ??
- ????????sendEscalationEmail(?customer,?ticket?); ??
- end ??
- ??
- #?显示状态设置为Done的电影票情况 ??
- rule?"Done"??
- ????when ??
- ????????customer?:?CustomerEx(?)???? ??
- ????????ticket?:?Ticket(?customer?==?customer,?status?==?"Done"?)??? ??
- ????then ??
- ????????System.out.println(?"Done?:?"?+?ticket?);??????? ??
- end ??
- ??
- #?模拟发送邮件的函数 ??
- function?void?sendEscalationEmail(?CustomerEx?customer,?Ticket?ticket?)?{ ??
- ????System.out.println(?"Email?:?"?+?ticket?); ??
- }??
1 楼 江南白衣 2007-08-06 给分,兄弟为drools4推广出力良多。 2 楼 chinapr 2007-08-25 辛苦