Helping the Industrial Internet of Things, the division of factual subject indicators of industrial big data [Eighteen]

01: Division of factual subject indicators

  • Objective : Master the division of business themes and the design of theme indicators in one-stop manufacturing

  • implement

    • basic process
      • Petrol station: needs for installation, maintenance, inspection and renovation
      • Call: Make a call to the call center to place a work order
        • The call center can solve it directly: no new work order will be generated: seek consultation
        • Call center can't solve it directly: build a ticket
      • Outlets: The call center assigns work orders to outlets
      • Work order: the assigned engineer confirms the work order
      • Gas station: implement specific work order requirements
      • Warehousing materials: apply for warehouse scheduling spare parts, there are spare parts costs
      • Travel expenses: transportation expenses, accommodation expenses, refueling expenses, subsidy expenses
      • Return visit: the call center will conduct a telephone return visit for the completed order
    • Call Center Fact Indicators: The number of calls accepted, the number of dispatched work orders
    • Gas Station Facts Indicators: number of gas stations, number of gas stations out of service, number of gas station equipment
    • Ticket Fact Indicators: Single number of installation workers, single number of maintenance workers
    • Installation fact indicators : number of installations, installation cost
    • Maintenance fact indicators : number of dimensions, maintenance cost
    • Customer return visit fact index: Number of satisfied, unsatisfied, satisfied with attitude, satisfied with response speed, satisfied with technology
    • cost fact indicator: Reimbursement fee, differential rate fee, subsidy fee
    • Travel Facts : Fuel, Lodging, Transportation
    • Actual indicator of outlet material : the number of spare parts
    • ……
  • summary

    • Master the division of business topics and the design of topic indicators in one-stop manufacturing

02: Demand analysis of call center fact indicators

  • Objective : To master the requirements of the DWB layer call center fact index table

  • path

    • step1: target requirements
    • step2: data source
  • implement

    • Target requirements : based on the basic time, acceptance method, call type and other factual dimensions to count the number of work orders, the number of calls, the number of return visits, the number of complaints, etc.

      image-20211003132754810

    • Data Sources

      • ciss_service_callaccept : Customer service center call details table

        image-20211003132152326 image-20211003132225976
      • eos_dict_type : dictionary status category table, records all tables that need to be marked with dictionaries

        select * from eos_dict_type where dicttypename = '来电类型';
        select * from eos_dict_type where dicttypename = '来电受理单--处理方式';
        
      • eos_dict_entry : Dictionary status list, recording all specific status or category information

        select * from eos_dict_entry where dicttypeid = 'BUSS_CALL_TYPE';
        select * from eos_dict_entry where dicttypeid = 'BUSS_PROCESS_WAY';
        
      • ciss_service_workorder : work order status list

        select callaccept_id,status from ciss_service_workorder;
        -- 查看每个状态的含义
        select * from eos_dict_type where dicttypename = '派工单状态';
        select * from eos_dict_entry where dicttypeid = 'BUSS_WORKORDER_STATUS';
        
    • summary

      • Grasp the requirements of the DWB layer call center fact index table

03: Construction of call center fact indicators

  • Goal : Realize the construction of DWB layer call center fact index table

  • implement

    • Build database

      create database if not exists one_make_dwb;
      
    • build table

      -- 创建呼叫中心 | 来电受理事实表
      -- 如果interval进不去,用`interval`圈起来,指明是字段
      drop table if exists one_make_dwb.fact_call_service;
      create table if not exists one_make_dwb.fact_call_service(
          id string comment '受理id(唯一标识)' 
          , code string comment '受理单唯一编码'
          , call_date string comment '来电日期(日期id)' 
          , call_hour int comment '来电时间(小时)(事实维度)'
          , call_type_id string comment '来电类型(事实维度)'
          , call_type_name string comment '来电类型名称(事实维度)'
          , process_way_id string comment '受理方式(事实维度)' 
          , process_way_name string comment '受理方式(事实维度)' 
          , oil_station_id string comment '油站id' 
          , userid string comment '受理人员id'
          , cnt int comment '单据数量(指标列)'
          , dispatch_cnt int comment '派工数量'
          , cancellation_cnt int comment '派工单作废数量' 
          , chargeback_cnt int comment '派工单退单数量'
          , interval int comment '受理时长(单位:秒)' 
          , tel_spt_cnt int comment '电话支持数量'
          , on_site_spt_cnt int comment '现场安装、维修、改造、巡检数量' 
          , custm_visit_cnt int comment '回访单据数量' 
         , complain_cnt int comment '投诉单据数量' 
         , other_cnt int
      comment '其他业务单据数量')
      partitioned by (dt string)
      stored as orc
      location '/data/dw/dwb/one_make/fact_call_service';
      
      
    • Build a data dictionary table [It is troublesome to associate two tables every time, and merge them into one table]

      create table if not exists one_make_dwb.tmp_dict
      stored as orc
      as
      select
          dict_t.dicttypename             -- 类型名称
          , dict_e.dictid                 -- 字典编号
          , dict_e.dictname               -- 字典名称
      from  one_make_dwd.eos_dict_type dict_t
      left join  one_make_dwd.eos_dict_entry dict_e
         on dict_t.dt = '20210101' and dict_e.dt = '20210101' and dict_t.dicttypeid = dict_e.dicttypeid
      order by  dict_t.dicttypename, dict_e.dictid;
      
      select * from one_make_dwb.tmp_dict where dicttypename = '来电类型';
      select * from one_make_dwb.tmp_dict where dicttypename = '来电受理单--处理方式';
      
    • Extraction (this writing method has bugs in time processing, pay attention to the floor function)

      insert overwrite table one_make_dwb.fact_call_service partition (dt = '20210101')
      select
          call.id     --来电受理唯一id
          , call.code -- 受理单唯一编码
          , date_format(timestamp(call.call_time), 'yyyymmdd') as call_date -- 来电日期(日期id)
          , hour(timestamp(call.call_time))  -- 来电时间(小时)(事实维度)
          , call.call_type -- 来电类型(事实维度)
          , call_dict.dictname -- 来电类型名称(事实维度)
          , call.process_way -- 受理方式(事实维度)
          , process_dict.dictname -- 受理方式(事实维度)
          , call.call_oilstation_id -- 油站id
          , call.accept_userid -- 受理人员id
          , 1 -- 单据数量(指标列)
          , case when call.process_way = 5  then 1 else 0 end -- 派工数量:0-自己处理,1-产生派工
          , case when workorder.status = -1 then 1 else 0 end -- 派工单作废数量
          , case when workorder.status = -2 then 1 else 0 end -- 派工单退单数量
      	, floor(to_unix_timestamp(timestamp(call.process_time),'yyyy-mm-dd hh:mm:ss') - to_unix_timestamp(timestamp(call.call_time), 'yyyy-mm-dd hh:mm:ss') / 1000.0) -- 受理时长(单位:秒)
          , case when call.call_type = 5 then 1 else 0 end -- 电话支持数量
          , case when call.call_type in (1, 2, 3, 4) then 1 else 0 end -- 现场安装、维修、改造、巡检数量
          , case when call.call_type = 7 then 1 else 0 end -- 回访单据数量
          , case when call.call_type = 8 then 1 else 0 end -- 投诉单据数量
          , case when call.call_type = 9 or call.call_type = 6 then 1 else 0 end -- 其他业务单据数量
      -- 来电详情表
      from one_make_dwd.ciss_service_callaccept call
      -- 字典信息表:得到来电类型名称
      left join one_make_dwb.tmp_dict call_dict on call.call_type = call_dict.dictid  and call_dict.dicttypename = '来电类型'
      -- 字典信息表:受理方式名称
      left join one_make_dwb.tmp_dict process_dict on call.process_way = process_dict.dictid and process_dict.dicttypename = '来电受理单--处理方式'
      -- 工单信息表:得到工单状态:-2:退单,-1:作废
      left join one_make_dwd.ciss_service_workorder workorder on workorder.dt = '20210101' and workorder.callaccept_id = call.id
      where call.dt = '20210101' and call.code != 'null' and call.call_time is not null;
      
  • Considering that there is no problem writing this way

    insert overwrite table one_make_dwb.fact_call_service partition (dt='20210101')
    select
        call.id     --来电受理唯一id
        , call.code -- 受理单唯一编码
        , date_format(timestamp(call.call_time), 'yyyymmdd') as call_date -- 来电日期(日期id)
        , hour(timestamp(call.call_time))  -- 来电时间(小时)(事实维度)
        , call.call_type -- 来电类型(事实维度)
        , call_dict.dictname -- 来电类型名称(事实维度)
        , call.process_way -- 受理方式(事实维度)
        , process_dict.dictname -- 受理方式(事实维度)
        , call.call_oilstation_id -- 油站id
        , call.accept_userid -- 受理人员id
        , 1 -- 单据数量(指标列)
        , case when call.process_way = 5  then 1 else 0 end -- 派工数量:0-自己处理,1-产生派工(状态码调整为0和1)
        , case when workorder.status = -1 then 1 else 0 end -- 派工单作废数量,如果是-1说明工单作废,则计数为1,为后面聚合准备
        , case when workorder.status = -2 then 1 else 0 end -- 派工单退单数量,如果是-2说明工单退单,则计数为1,为后面聚合准备
    	, to_unix_timestamp(timestamp(call.process_time),'yyyy-mm-dd hh:mm:ss') - to_unix_timestamp(timestamp(call.call_time), 'yyyy-mm-dd hh:mm:ss')-- 受理时长(单位:秒)处理时间戳-受理时间戳
        , case when call.call_type = 5 then 1 else 0 end -- 电话支持数量,如果是5说明电话支持,则计数为1,为后面聚合准备
        , case when call.call_type in (1, 2, 3, 4) then 1 else 0 end -- 现场安装、维修、改造、巡检数量,如果是(1,2,3,4),则计数为1,为后面聚合准备
        , case when call.call_type = 7 then 1 else 0 end -- 回访单据数量,如果是7,则计数为1,为后面聚合准备
        , case when call.call_type = 8 then 1 else 0 end -- 投诉单据数量,如果是8,则计数为1,为后面聚合准备
        , case when call.call_type = 9 or call.call_type = 6 then 1 else 0 end -- 其他业务单据数量,如果是9或者6,则计数为1,为后面聚合准备
    -- 来电详情表
    from one_make_dwd.ciss_service_callaccept call
    -- 字典信息表:得到来电类型名称
    left join one_make_dwb.tmp_dict call_dict on call.call_type = call_dict.dictid  and call_dict.dicttypename = '来电类型'
    -- 字典信息表:受理方式名称
    left join one_make_dwb.tmp_dict process_dict on call.process_way = process_dict.dictid and process_dict.dicttypename = '来电受理单--处理方式'
    -- 工单信息表:得到工单状态:-2:退单,-1:作废
    left join one_make_dwd.ciss_service_workorder workorder on workorder.dt = '20210101' and workorder.callaccept_id = call.id
    where call.dt = '20210101' and call.code != 'null' and call.call_time is not null;
    
  • summary

    • Realize the construction of DWB layer call center fact index table

Guess you like

Origin blog.csdn.net/xianyu120/article/details/131959610
Recommended