DBeaver-查询工单

选择这个数据库

image

打开,选择这个进行连接

image

选择这个

image

按照图片进行连接

image

image

设为活动对象

image

工单是这个

image

选择下面这个 可以建立SQL编辑窗口

image

输入

select count(*) from tb_work_order where is_delete=0 and company_id= '602531310603714560';

然后就能显示出来

image

如果查看所有工单的详情则

#所有工单
select * from tb_work_order where is_delete=0 and company_id= '602531310603714560';

image

数据库中is_delete,0代表未删除,1代表删除,默认值为0

已完成工单

image

#已完成工单
select * from tb_work_order where is_delete=0 and order_status=6 and company_id= '602531310603714560';

image

order_status各个值的意思

image

待完成工单总数统计(除去已完成和已终止)

#待完成工单总数统计
select * from tb_work_order where is_delete=0 and order_status!=7 and order_status!=6 and company_id= '602531310603714560';

image

例行维保和应急维保

image

待完成应急维保工单总数统计(除去已完成和已终止)

#待完成应急工单总数统计
select * from tb_work_order where is_delete=0 and order_status!=7 and order_status!=6 and company_id= '602531310603714560' and type=2;

image

每日应急工单数量统计

#每日应急工单数量统计
select * from tb_work_order where is_delete=0 and company_id= '602531310603714560' and type=2 and create_time > '2021-06-09 00:00:00' and 
create_time < '2021-06-09 23:59:59';

image

每日例行工单数量统计

#每日例行工单数量统计
select * from tb_work_order where is_delete=0 and company_id= '602531310603714560' and type=1 and create_time > '2021-06-09 00:00:00' and 
create_time < '2021-06-09 23:59:59';

image

运行商 服务单位

company_id为运营商yk
unit_id为服务单位
image

工单完成率统计(以康师傅为例)

#康师傅工单完成率统计
select count(*) as a from tb_work_order where is_delete=0 and company_id= '602531310603714560'  and unit_id=603957085827612672 and (order_status=7 or order_status=6);
select count(*) as b from tb_work_order where is_delete=0 and company_id= '602531310603714560'  and unit_id=603957085827612672;
select 1.0/2;

image

近30天的所有工单

#近30天的所有工单
select * from tb_work_order where is_delete=0 and company_id= '602531310603714560' and start_date > '2021-05-10 00:00:00' and 
start_date < '2021-06-10 23:59:59';

image

近30天的待完成工单

#近30天的待完成工单
select * from tb_work_order where is_delete=0 and company_id= '602531310603714560' and start_date > '2021-05-10 00:00:00' and 
start_date < '2021-06-10 23:59:59' and order_status!=7 and order_status!=6;

image

近30天的待完成应急工单

#近30天的待完成应急工单
select * from tb_work_order where is_delete=0 and company_id= '602531310603714560' and start_date > '2021-05-10 00:00:00' and 
start_date < '2021-06-10 23:59:59' and order_status!=7 and order_status!=6 and type=2;

image

字段说明:

image

posted @ 2021-06-08 11:48  司砚章  阅读(293)  评论(0编辑  收藏  举报