分享一个应用实例https://www.ibm.com/developerworks/cn/java/j-drools/
自己在项目中用到的案例
项目场景介绍
法律业务,分为律师端和用户端,用户下单咨询,律师解答。律师有自己的擅长领域(对应用户下单的业务类型),
律师有工作地点,对应用户的地址。用了下了一条订单,系统会根据业务类型匹配和地址匹配,分配给特定的律师,
律师看得订单可以进行解答。
一 jar包
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.10</version>
</dependency>
<!-- drools 规则引擎 -->
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>${drools.version}</version>
</dependency>
二 表结构
订单表
CREATE TABLE `constant_message_order` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`order_no` varchar(50) DEFAULT NULL COMMENT '订单号',
`out_order_no` varchar(50) DEFAULT NULL COMMENT '外部系统订单号',
`out_order_type` tinyint(3) DEFAULT NULL COMMENT '外部订单分类',
`order_status` tinyint(3) DEFAULT '0' COMMENT '订单状态(0:待解答,2:解答中, 3:已回答待审核,4:审核通过待评价,5:审核失败待评价,6:服务完成(用户评价完成))',
`isolation_status` tinyint(3) DEFAULT '0' COMMENT '隔离状态(0:未隔离,1:已隔离)',
`front_status` tinyint(3) DEFAULT '1' COMMENT '前端状态(0:不显示,1:显示)',
`title` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
`consult_content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
`consult_datetime` datetime DEFAULT NULL COMMENT '咨询时间',
`answer_content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
`answer_datetime` datetime DEFAULT NULL COMMENT '答复时间',
`first_submit_time` datetime DEFAULT NULL COMMENT '首次提交时间',
`answer_template_id` int(11) DEFAULT NULL COMMENT '回答模板id',
`consult_user_id` int(11) DEFAULT NULL COMMENT '咨询用户id',
`product_id` int(11) DEFAULT NULL COMMENT '产品id',
`channel_id` int(11) DEFAULT NULL COMMENT '渠道id',
`is_open` tinyint(3) DEFAULT '1' COMMENT '是否公开到互联网(0:不公开,1:公开)',
`service_personal_id` int(11) DEFAULT NULL COMMENT '服务人员id(资源)',
`process_mode` tinyint(3) DEFAULT NULL COMMENT '处理方式(预留)',
`grap_order_datetime` datetime DEFAULT NULL COMMENT '接单时间',
`business_id` int(11) DEFAULT NULL COMMENT '业务类型id',
`isolation_warning_cause` tinyint(3) DEFAULT NULL COMMENT '隔离预警原因',
`isolation_warning_remark` varchar(2000) DEFAULT '' COMMENT '举报原因备注',
`isolation_datetime` datetime DEFAULT NULL COMMENT '隔离时间',
`check_status` tinyint(3) DEFAULT '0' COMMENT '审核状态(0:待审核,1:审核通过,2:审核失败)',
`check_opinion` varchar(2000) DEFAULT NULL COMMENT '审核意见',
`check_people_id` int(11) DEFAULT NULL COMMENT '审核人员id',
`check_datetime` datetime DEFAULT NULL COMMENT '审核时间',
`order_issue` varchar(1000) DEFAULT '' COMMENT