工单后端开发实践
标准业务工单流程图
工单引擎公共业务包
<!--业务通用依赖-->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>cn.flyrise</groupId>
<artifactId>pai-fe-bom</artifactId>
<version>1.0.1-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<!--消息监听依赖-->
<dependency>
<groupId>cn.flyrise</groupId>
<artifactId>pai-common-mq</artifactId>
</dependency>
<!--工单引擎-->
<dependency>
<groupId>cn.flyrise</groupId>
<artifactId>pai-fe-common-work-engine</artifactId>
</dependency>
工单引擎状态解释
status == 0 –> 待受理
status == 1 –> 待确认
status == 2 –> 待派单
status == 3 –> 待接单
status == 4 –> 待处理
status == 5 –> 待提交
status == 6 –> 待验收
status == 7 –> 结束
status == 7 && isClose == 1 –> 工单被关闭
status == 7 && isReject == 1 –> 工单被驳回
status == 7 && isRevocation == 1 –> 工单被撤回(发起方撤回)
isReject == 2 –> 工单被退回(仅退回至上一节点时所展示的状态)
MQ消费者编写
import cn.flyrise.common.work.engine.order.model.NotifyMqVO;
import cn.flyrise.mq.core.annotation.PaiMqListener;
import cn.flyrise.mq.core.model.PaiMqMessageBean;
import cn.flyrise.pai.servicepropertyrepairs.factory.OrderMessageFactory;
import cn.flyrise.pai.servicepropertyrepairs.service.IMessageConsumerService;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import org.springframework.stereotype.Component;
//${pai.mq.tag} --> cn.flyrise.work.order
//${pai.mq.topic} --> work_order_notify
//建议配置在nacos的配置文件中
@Component
public class WorkOrderConsumer {
@PaiMqListener(suiteCode = "${pai.mq.tag}", topic = "${pai.mq.topic}")
public void workEngineMsgHandler(String msg) {
PaiMqMessageBean<String> bean = JSON
.parseObject(msg, new TypeReference<PaiMqMessageBean<String>>() {
});
NotifyMqVO notifyMqVo = JSONUtil.toBean(bean.getData(), NotifyMqVO.class);
try {
// 业务处理逻辑
} catch (Exception e) {
// 异常处理逻辑
}
}
}
拓展接口描述
查看客户评价
内部接口调用方式: IRemoteWorkOrderService#selectCustomerEvaluate(String id)
接口地址:/work-engine-api/work/order/v1/inner/customer/evaluate
请求方式:GET
请求数据类型:application/x-www-form-urlencoded
响应数据类型:*/*
接口描述:
请求参数:
参数名称 | 参数说明 | in | 是否必须 | 数据类型 | schema |
---|---|---|---|---|---|
bizId | bizId | query | false | string |
响应状态:
状态码 | 说明 | schema |
---|---|---|
200 | OK | Reply«CustomerEvaluateVO» |
401 | Unauthorized | |
403 | Forbidden | |
404 | Not Found |
响应参数:
参数名称 | 参数说明 | 类型 | schema |
---|---|---|---|
annex | object | ||
code | string | ||
data | CustomerEvaluateVO | CustomerEvaluateVO | |
bizId | 业务ID | string | |
createTime | 评价时间 | string | |
evaluate | 评价 | string | |
parkId | 园区ID | string | |
score | 评分 | integer | |
msg | string | ||
success | boolean | ||
time | integer(int64) | integer(int64) |
响应示例:
{
"annex": {},
"code": "",
"data": {
"bizId": "",
"createTime": "",
"evaluate": "",
"parkId": "",
"score": 0
},
"msg": "",
"success": true,
"time": 0
}
客户评价
内部接口调用方式: IRemoteWorkOrderService#customerEvaluate(CustomerEvaluateVO vo)
接口地址:/work-engine-api/work/order/v1/inner/customer/evaluate
请求方式:POST
请求数据类型:application/json
响应数据类型:*/*
接口描述:
请求示例:
{
"bizId": "",
"createTime": "",
"evaluate": "",
"parkId": "",
"score": 0
}
请求参数:
参数名称 | 参数说明 | in | 是否必须 | 数据类型 | schema |
---|---|---|---|---|---|
vo | vo | body | true | CustomerEvaluateVO | CustomerEvaluateVO |
bizId | 业务ID | false | string | ||
createTime | 评价时间 | false | string | ||
evaluate | 评价 | false | string | ||
parkId | 园区ID | false | string | ||
score | 评分 | false | integer |
响应状态:
状态码 | 说明 | schema |
---|---|---|
200 | OK | Reply«boolean» |
201 | Created | |
401 | Unauthorized | |
403 | Forbidden | |
404 | Not Found |
响应参数:
参数名称 | 参数说明 | 类型 | schema |
---|---|---|---|
annex | object | ||
code | string | ||
data | boolean | ||
msg | string | ||
success | boolean | ||
time | integer(int64) | integer(int64) |
响应示例:
{
"annex": {},
"code": "",
"data": true,
"msg": "",
"success": true,
"time": 0
}
撤回工单
内部接口调用方式: IRemoteWorkOrderService#revocation(RevocationVO vo)
接口地址:/work-engine-api/work/order/v1/inner/revocation
请求方式:POST
请求数据类型:application/json
响应数据类型:*/*
接口描述:
请求示例:
{
"bizId": "",
"reason": ""
}
请求参数:
参数名称 | 参数说明 | in | 是否必须 | 数据类型 | schema |
---|---|---|---|---|---|
vo | vo | body | true | 撤回请求实体 | 撤回请求实体 |
bizId | 业务ID | false | string | ||
reason | 撤回原因 | false | string |
响应状态:
状态码 | 说明 | schema |
---|---|---|
200 | OK | Reply«boolean» |
201 | Created | |
401 | Unauthorized | |
403 | Forbidden | |
404 | Not Found |
响应参数:
参数名称 | 参数说明 | 类型 | schema |
---|---|---|---|
annex | object | ||
code | string | ||
data | boolean | ||
msg | string | ||
success | boolean | ||
time | integer(int64) | integer(int64) |
响应示例:
{
"annex": {},
"code": "",
"data": true,
"msg": "",
"success": true,
"time": 0
}
NotifyMqVO实体(MQ消息数据实体)
public class NotifyMqVO implements Serializable {
@ApiModelProperty("工单业务主键")
private String bizId;
@ApiModelProperty("PC表单链接")
private String formLink;
@ApiModelProperty("APP表单链接")
private String appFormLink;
@ApiModelProperty("工单实例ID")
private String instanceId;
@ApiModelProperty("工单状态")
private Integer status;
@ApiModelProperty("园区ID")
private String parkId;
@ApiModelProperty("工单KEY")
private String orderKey;
@ApiModelProperty("工单标题")
private String title;
@ApiModelProperty("工单紧急程度")
private Integer priority;
@ApiModelProperty("工单类型")
private String orderType;
@ApiModelProperty("企业ID")
private String enterprise;
@ApiModelProperty("操作类型")
private String operation;
@ApiModelProperty("是否关闭")
private Integer isClose;
@ApiModelProperty("是否驳回")
private Integer isReject;
@ApiModelProperty("关闭原因")
private String closeReason;
@ApiModelProperty("驳回原因")
private String rejectReason;
@ApiModelProperty("是否撤回")
private Integer isRevocation;
@ApiModelProperty("撤回原因")
private String revocationReason;
@ApiModelProperty("租户ID")
private String tenantId;
}