当前位置: 首页 > news >正文

助力工业物联网,工业大数据之ST层的设计【二十五】

文章目录

    • 04:ST层的设计
    • 05:服务域:工单主题分析
    • 06:服务域:工单主题实现

04:ST层的设计

  • 目标掌握ST层的设计

  • 路径

    • step1:功能
    • step2:来源
    • step3:需求
  • 实施

    • 功能:数据应用层,用于支撑对外所有主题的报表应用数据的结果

      • 对外提供整个公司所有运营的报表
    • 来源:对DWB层的主题事实数据关联DWS层的维度表进行最终聚合

      • DWS:维度表:时间、地区、油站、组织机构

        维度id	维度值
        
      • DWB:工单、呼叫中心、费用

        维度id	指标
        
    • 需求:按照一站制造的业务主题的划分需求,构建每个主题的ST层的数据

      维度id	维度值		聚合指标
      
  • 小结

    • 掌握ST层的设计

05:服务域:工单主题分析

  • 目标掌握工单主题的需求分析

  • 路径

    • step1:需求
    • step2:分析
  • 实施

    • 需求:统计不同维度下的工单主题指标的结果

      字段名称字段说明来源
      owner_process派工方式-自己处理数量one_make_dwb.fact_call_service
      tran_process派工方式-转派工数量one_make_dwb.fact_call_service
      wokerorder_num工单总数one_make_dwb.fact_worker_order
      wokerorder_num_max工单总数最大值one_make_dwb.fact_worker_order
      wokerorder_num_min工单总数最小值one_make_dwb.fact_worker_order
      wokerorder_num_avg工单总数平均值one_make_dwb.fact_worker_order
      install_sumnum派工类型-安装总数one_make_dwb.fact_worker_order
      repair_sumnum派工类型-维修总数one_make_dwb.fact_worker_order
      remould_sumnum派工类型-巡检总数one_make_dwb.fact_worker_order
      inspection_sumnum派工类型-改造总数one_make_dwb.fact_worker_order
      alread_complete_sumnum完工总数one_make_dwb.fact_worker_order
      customer_classify_zsh客户类型-中石化数量one_make_dws.dim_oilstation
      customer_classify_jxs客户类型-经销商数量one_make_dws.dim_oilstation
      customer_classify_qtzx客户类型-其他直销数量one_make_dws.dim_oilstation
      customer_classify_zsy客户类型-中石油数量one_make_dws.dim_oilstation
      customer_classify_qtwlh客户类型-其他往来户数量one_make_dws.dim_oilstation
      customer_classify_zhjt客户类型-中化集团数量one_make_dws.dim_oilstation
      customer_classify_zhy客户类型-中海油数量one_make_dws.dim_oilstation
      customer_classify_gys客户类型-供应商数量one_make_dws.dim_oilstation
      customer_classify_onemake客户类型-一站制造**数量one_make_dws.dim_oilstation
      customer_classify_fwy客户类型-服务员数量one_make_dws.dim_oilstation
      customer_classify_zt客户类型-中铁数量one_make_dws.dim_oilstation
      customer_classify_hzgs客户类型-合资公司数量one_make_dws.dim_oilstation
      customer_classify_jg客户类型-军供数量one_make_dws.dim_oilstation
      customer_classify_zhhangy客户类型-中航油数量one_make_dws.dim_oilstation
      dws_day string日期维度-按天one_make_dws.dim_date
      dws_week string日期维度-按周one_make_dws.dim_date
      dws_month string日期维度-按月one_make_dws.dim_date
      oil_type string油站类型one_make_dws.dim_oilstation
      oil_province油站所属省one_make_dws.dim_oilstation
      oil_city string油站所属市one_make_dws.dim_oilstation
      oil_county string油站所属区one_make_dws.dim_oilstation
      customer_classify客户类型one_make_dws.dim_oilstation
      customer_province客户所属省one_make_dws.dim_oilstation
      • 呼叫中心主题事实
    • 分析

      • 指标

        • 工单自处理个数、工单转派工个数
        • 工单总数、最大值、最小值、平均值
        • 安装总数、维修总数、巡检总数、改造总数、完工总数
        • 中石化数量、经销商数量、其他直销数量、中石油数量、其他往来户数量、中化集团数量、中海油数量
        • 供应商数量、一站制造数量、服务工程师数量、中铁数量、合资公司数量、军供数量、中航油数量
      • 维度

        • 日期维度:天、周、月
        • 油站维度:类型、省份、城市、地区
        • 客户维度:类型、省份
      • 数据表

        • 事实表

          • fact_worker_order:工单事实表

            selectwo_num, --工单数量callaccept_id,--来电受理单idoil_station_id, --油站iddt --日期
            from fact_worker_order;
            
          • fact_call_service:呼叫中心事实表

          select      
          id,--来电受理单id    
          process_way_name --处理方式  
          from fact_call_service;  
          

          image-20211013101145353

        • 维度表

          • dim_oilstation:油站维度表

            selectid,--油站idcompany_name,--公司名称province_name,--省份名称city_name,--城市名称county_name,--区域名称customer_classify_name,--客户名称customer_province_name--客户省份
            from dim_oilstation;
            
          • dim_date:时间维度表

            selectdate_id,--天week_in_year_id,--周year_month_id --月
            from dim_date;
            

            image-20211013101244275

          • 实现分析

          -- 工单事实表
          select
          sum(case when b.process_way_name = '自己处理' then 1 else 0
          end) as own,
          sum(case when b.process_way_name = '转派工' then 1 else 0
          end) as other,
          sum(a.wo_num), --工单数量
          max(a.wo_num),
          min(a.wo_num),
          avg(a.wo_num),
          sum(a.install_num),
          sum(a.repair_num),
          sum(a.remould_num),
          sum(a.inspection_num),
          sum(a.alread_complete_num),
          sum(case when c.customer_classify_name = '中石化' then 1
          else 0 end) as zsy_count,
          ……
          a.callaccept_id,--来电受理单id
          c.id, --油站id
          c.company_name,--公司名称
          c.province_name,--省份名称
          c.city_name,--城市名称
          c.county_name,--区域名称
          c.customer_classify_name,--客户名称
          c.customer_province_name ,--客户省份
          d.date_id,--天
          d.week_in_year_id,--周
          d.year_month_id --月
          from fact_worker_order a
          left join fact_call_service b on a.callaccept_id = b.id
          left join one_make_dws.dim_oilstation c on a.oil_station_id =
          c.id
          left join one_make_dws.dim_date d on a.dt = d.date_id
          group by
          c.id, --油站id
          c.company_name,--公司名称
          c.province_name,--省份名称
          c.city_name,--城市名称
          c.county_name,--区域名称
          c.customer_classify_name,--客户名称
          c.customer_province_name ,--客户省份
          d.date_id,--天
          d.week_in_year_id,--周
          d.year_month_id; --月;
          
  • 小结

    • 掌握工单主题的需求分析

06:服务域:工单主题实现

  • 目标实现工单主题表的维度指标构建

  • 实施

    • 建库

      create database if not exists one_make_st;
      
    • 建表

      -- 创建工单主题表
      drop table if exists one_make_st.subj_worker_order;
      create table if not exists one_make_st.subj_worker_order(owner_process bigint comment '派工方式-自己处理数量',tran_process bigint comment '派工方式-转派工数量',wokerorder_num bigint comment '工单总数',wokerorder_num_max int comment '工单总数最大值',wokerorder_num_min int comment '工单总数最小值',wokerorder_num_avg int comment '工单总数平均值',install_sumnum bigint comment '派工类型-安装总数',repair_sumnum bigint comment '派工类型-维修总数',remould_sumnum bigint comment '派工类型-巡检总数',inspection_sumnum bigint comment '派工类型-改造总数',alread_complete_sumnum bigint comment '完工总数',customer_classify_zsh bigint comment '客户类型-中石化数量',customer_classify_jxs bigint comment '客户类型-经销商数量',customer_classify_qtzx bigint comment '客户类型-其他直销数量',customer_classify_zsy bigint comment '客户类型-中石油数量',customer_classify_qtwlh bigint comment '客户类型-其他往来户数量',customer_classify_zhjt bigint comment '客户类型-中化集团数量',customer_classify_zhy bigint comment '客户类型-中海油数量',customer_classify_gys bigint comment '客户类型-供应商数量',customer_classify_onemake bigint comment '客户类型-一站制造**数量',customer_classify_fwy bigint comment '客户类型-服务员数量',customer_classify_zt bigint comment '客户类型-中铁数量',customer_classify_hzgs bigint comment '客户类型-合资公司数量',customer_classify_jg bigint comment '客户类型-军供数量',customer_classify_zhhangy bigint comment '客户类型-中航油数量',dws_day string comment '日期维度-按天',dws_week string comment '日期维度-按周',dws_month string comment '日期维度-按月',oil_type string comment '油站维度-油站类型',oil_province string comment '油站维度-油站所属省',oil_city string comment '油站维度-油站所属市',oil_county string comment '油站维度-油站所属区',customer_classify string comment '客户维度-客户类型',customer_province string comment '客户维度-客户所属省'
      ) comment '工单主题表'
      partitioned by (month String, week String, day String)
      stored as orc
      location '/data/dw/st/one_make/subj_worker_order'
      ;
      
    • 构建

      insert overwrite table one_make_st.subj_worker_order partition(month = '202101', week='2021W1', day='20210101')
      selectsum(case when fcs.process_way_name = '自己处理' then 1 else 0 end) owner_process, --工单自处理个数sum(case when fcs.process_way_name = '转派工' then 1 else 0 end) tran_process,    --工单转派工个数sum(fwo.wo_num) wokerorder_num,                                      --工单总数max(fwo.wo_num) wokerorder_num_max,                                  --最大值min(fwo.wo_num) wokerorder_num_min,                                  --最小值avg(fwo.wo_num) wokerorder_num_avg,                                  --平均值sum(fwo.install_num) install_sumnum,                                     --安装总数sum(fwo.repair_num) repair_sumnum,                                       --维修总数sum(fwo.remould_num) remould_sumnum,                                     --巡检总数sum(fwo.inspection_num) inspection_sumnum,                               --改造总数sum(fwo.alread_complete_num) alread_complete_sumnum,                     --完工总数sum(case when oil.customer_classify_name ='中石化' then 1 else 0 end) customer_classify_zsh,       --中石化数量sum(case when oil.customer_classify_name ='经销商' then 1 else 0 end) customer_classify_jxs,       --经销商数量sum(case when oil.customer_classify_name ='其他直销' then 1 else 0 end) customer_classify_qtzx,      --其他直销数量sum(case when oil.customer_classify_name ='中石油' then 1 else 0 end) customer_classify_zsy,       --中石油数量sum(case when oil.customer_classify_name ='其他往来户' then 1 else 0 end) customer_classify_qtwlh,     --其他往来户数量sum(case when oil.customer_classify_name ='中化集团' then 1 else 0 end) customer_classify_zhjt,      --中化集团数量sum(case when oil.customer_classify_name ='中海油' then 1 else 0 end) customer_classify_zhy,       --中海油数量sum(case when oil.customer_classify_name ='供应商' then 1 else 0 end) customer_classify_gys,        --供应商数量sum(case when oil.customer_classify_name ='一站制造**' then 1 else 0 end) customer_classify_onemake,     --一站制造数量sum(case when oil.customer_classify_name ='服务工程师' then 1 else 0 end) customer_classify_fwy,          --服务工程师数量sum(case when oil.customer_classify_name ='中铁' then 1 else 0 end) customer_classify_zt,           --中铁数量sum(case when oil.customer_classify_name ='合资公司' then 1 else 0 end) customer_classify_hzgs,         --合资公司数量sum(case when oil.customer_classify_name ='军供' then 1 else 0 end) customer_classify_jg,             --军供数量sum(case when oil.customer_classify_name ='中航油' then 1 else 0 end) customer_classify_zhhangy,         --中航油数量dd.date_id dws_day,                                                  --时间天dd.week_in_year_id dws_week,                                         --时间周dd.year_month_id dws_month,                                          --时间月oil.company_name oil_type,                                           --油站类型oil.province_name oil_province,                                      --油站省份oil.city_name oil_city,                                              --油站城市oil.county_name oil_county,                                          --油站地区oil.customer_classify_name customer_classify,                        --客户类型oil.customer_province_name customer_province                         --客户省份
      --工单事务事实表
      from one_make_dwb.fact_worker_order fwo
      --获取自处理个数,转派单个数
      left join one_make_dwb.fact_call_service fcs on fwo.callaccept_id = fcs.id
      --关联日期维度
      left join one_make_dws.dim_date dd on fwo.dt = dd.date_id
      --关联油站维度
      left join one_make_dws.dim_oilstation oil on fwo.oil_station_id = oil.id
      where dd.year_month_id = '202101'and dd.week_in_year_id = '2021W1' and  dd.date_id = '20210101'
      --按照维度字段分组
      group by dd.date_id, dd.week_in_year_id, dd.year_month_id, oil.company_name, oil.province_name, oil.city_name, oil.county_name,oil.customer_classify_name, oil.customer_province_name
      ;
      
  • 小结

    • 实现工单主题表的维度指标构建
http://www.lryc.cn/news/106991.html

相关文章:

  • MySQL实践——参数SQL_SLAVE_SKIP_COUNTER的奥秘
  • 小程序面试题
  • 微信小程序接入腾讯云天御验证码
  • Docker build 命令详解
  • 基于Translators的多语言翻译解决方案
  • Unity 性能优化五:渲染模块压力
  • Redis数据库 | 事务、持久化
  • 浅析大数据时代下的视频技术发展趋势以及AI加持下视频场景应用
  • TensorRT学习笔记--基于YoloV8检测图片和视频
  • 【C++】开源:matplotlib-cpp静态图表库配置与使用
  • 香港IT软件开发服务公司Alpha Technology 申请纳斯达克IPO上市
  • JavaScript:数组深拷贝
  • 干翻Dubbo系列第七篇:@EnableDubbo、@DubboService、@DubboReference注解的作用
  • clickhouse断电重启故障解决方案
  • Spring学习笔记之Bean的实例化方式
  • JVM-类加载器
  • ChatGPT在法律行业的市场潜力
  • Python编程从入门到实践练习第三章:列表简介
  • 【Spring Boot】请求参数传json数组,后端采用(pojo)新增案例(103)
  • Redis 持久化RDB和AOF
  • 【ThinkPHP】PHP实现分页功能
  • chrome 插件开发
  • 开源MinDoc wiki系统搭建
  • pytest.ini 文件说明
  • 遥感、GIS、GPS在土壤空间数据分析、适应性评价、制图、土壤普查中怎样应用?
  • git | git使用心得记录
  • java策略模式三种实现方案
  • VMWare虚拟系统上网设置及VMWare虚拟机三种工作模式详解
  • 计算机网络(3) --- 网络套接字TCP
  • 大数据技术之Hadoop(二)