助力工业物联网,工业大数据之服务域:安装主题分析实现【二十七】

简介: 助力工业物联网,工业大数据之服务域:安装主题分析实现【二十七】

09:服务域:安装主题分析实现

  • 目标掌握安装主题的需求分析及实现
  • 路径
  • step1:需求
  • step2:分析
  • step3:实现
  • 实施
  • 需求:统计不同维度下的安装主题指标的结果

  • 分析
  • 指标:安装数量、支付金额
  • 维度
  • 安装方式
  • 日期维度:天、周、月
  • 油站维度:类型、省份、城市、地区
  • 客户维度:类型、省份
  • 数据
  • 事实表
  • fact_srv_install:安装事务事实表
select
    inst_id, --安装单id
    inst_type_id, --安装方式id 1-设备安装,2-设备联调
    exp_device_money, --安装费用
    dt,--日期
os_id --油站id
from one_make_dwb.fact_srv_install;
  • 维度表
  • dim_oilstation:油站维度表
select
    id,--油站id
    company_name,--公司名称
    province_name,--省份名称
    city_name,--城市名称
    county_name,--区域名称
    customer_classify_name,--客户名称
  customer_province_name--客户省份
from dim_oilstation;
  • dim_date:时间维度表
select
    date_id,--天
    week_in_year_id,--周
  year_month_id --月
from dim_date;
  • 实现
  • 建表
create table if not exists one_make_st.subj_install(
    install_way string comment '安装方式'
    ,install_sum bigint comment '安装数量'
    ,sum_money int 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_install';
  • 构建
insert overwrite table one_make_st.subj_install partition(month = '202101', week='2021W1', day='20210101')
  select
    --安装方式
      max(case when install.inst_type_id = 1 then '设备安装' when install.inst_type_id = 2 then '设备联调' else '未知' end) install_way
      , count(install.inst_id) install_sum                                     --安装数量
    , sum(install.exp_device_money) sum_money                      --支付金额
      , dd.date_id dws_day                                                     --日期天
      , dd.week_in_year_id dws_week                                            --日期周
      , dd.year_month_id dws_month                                             --日期月
      , dimoil.company_name oil_type                                           --油站类型
      , dimoil.province_name oil_province                                      --油站省份
      , dimoil.city_name oil_city                                              --油站城市
      , dimoil.county_name oil_county                                          --油站地区
      , dimoil.customer_classify_name customer_classify                        --客户类型
      , dimoil.customer_province_name customer_province                        --客户省份
  --安装事务事实表
  from one_make_dwb.fact_srv_install install
  --关联日期维度表
  left join one_make_dws.dim_date dd on install.dt = dd.date_id
  --关联油站维度表
  left join one_make_dws.dim_oilstation dimoil on install.os_id = dimoil.id
  where dd.year_month_id = '202101' and dd.week_in_year_id = '2021W1' and dd.date_id = '20210101'
  --按照维度分组
  group by
      inst_type_id,
      dd.date_id, dd.week_in_year_id, dd.year_month_id,
      dimoil.company_name, dimoil.province_name, dimoil.city_name, dimoil.county_name,
      dimoil.customer_classify_name, dimoil.customer_province_name
  ;
  • 小结
  • 掌握安装主题的需求分析及实现

10:服务域:维修主题分析实现

  • 目标掌握维修主题的需求分析及实现
  • 路径
  • step1:需求
  • step2:分析
  • step3:实现
  • 实施
  • 需求:统计不同维度下的维修主题指标的结果

  • 分析
  • 指标
  • 支付费用、工时费用、零部件费用、交通费用
  • 故障总数、最大数量、平均数量
  • 维度
  • 日期维度:天、周、月
  • 油站维度:类型、省份、城市、地区
  • 客户维度:类型、省份
  • 物流公司
  • 数据
  • 事实表
  • fact_srv_repair:维修事务事实表
select
    hour_money,--工时费用
    parts_money,--配件物料费用
    fars_money,--交通费用
    fault_type_ids, --故障id集合
    dt,--日期
    os_id,--油站id
  ss_id --服务网点id
from fact_srv_repair;
  • fact_srv_stn_ma:网点物料事务事实表
select
  ss_id,--服务网点id
  logi_cmp_id --物流公司id
from fact_srv_stn_ma;
  • 维度表
  • dim_oilstation:油站维度表
select
    id,--油站id
    company_name,--公司名称
    province_name,--省份名称
    city_name,--城市名称
    county_name,--区域名称
    customer_classify_name,--客户名称
  customer_province_name--客户省份
from dim_oilstation;
  • dim_date:时间维度表
select
    date_id,--天
    week_in_year_id,--周
  year_month_id --月
from dim_date;
  • dim_logistics:物流维度表
select 
  type_id,  --物流公司id
type_name --物流公司名称
from one_make_dws.dim_logistics where prop_name = '物流公司';
  • 实现
  • 建表
drop table if exists one_make_st.subj_repair;
create table if not exists one_make_st.subj_repair(
    sum_pay_money decimal(20,1) comment '支付费用'
    ,sum_hour_money decimal(20,1) comment '小时费用'
    ,sum_parts_money decimal(20,1) comment '零部件费用'
    ,sum_fars_money decimal(20,1) comment '交通费用'
    ,sum_faulttype_num bigint comment '故障类型总数'
    ,max_faulttype_num int comment '故障类型最大数量'
    ,avg_faulttype_num int 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 '客户维度-客户所属省'
    ,logi_company string comment '物流公司维度-物流公司名称'
) comment '维修主题表'
partitioned by (month String, week String, day String)
stored as orc
location '/data/dw/st/one_make/subj_repair';
  • 构建
insert overwrite table one_make_st.subj_repair partition(month = '202101', week='2021W1', day='20210101')
  select
      sum(pay_money) sum_pay_money,         --支付费用
    sum(hour_money) sum_hour_money,             --工时费用
      sum(parts_money) sum_parts_money,           --物料费用
    sum(fars_money) sum_fars_money,             --交通费用
      sum(fault_type_num) sum_faulttype_num,      --故障类型总数
    max(fault_type_num) max_faulttype_num,      --最大故障数量
      avg(fault_type_num) avg_faulttype_num,      --平均故障数量
    dws_day,                                    --日期天
    dws_week,                                   --日期周
    dws_month,                                  --日期月
    oil_type,                                   --油站类型
      oil_province,                               --油站省份
    oil_city,                                   --油站城市
    oil_county,                                 --油站区域
    customer_classify,                          --客户类型
    customer_province,                          --客户省份
    logi_company                                --物流公司
  from (
       select
         (hour_money + parts_money+fars_money) pay_money,
         hour_money,
         parts_money,
         fars_money,
         case when (size(split(fault_type_ids, ','))) <= 0 then 0 else (size(split(fault_type_ids, ','))) end fault_type_num,
         dd.date_id dws_day,
         dd.week_in_year_id dws_week,
         dd.year_month_id dws_month,
         dimoil.company_name oil_type,
         dimoil.province_name oil_province,
         dimoil.city_name oil_city,
         dimoil.county_name oil_county,
         dimoil.customer_classify_name customer_classify,
         dimoil.customer_province_name customer_province,
         type_name logi_company
       --维修事务事实表
       from one_make_dwb.fact_srv_repair repair
       --关联日期维度表
       left join one_make_dws.dim_date dd on repair.dt = dd.date_id
       --关联油站维度表
       left join one_make_dws.dim_oilstation dimoil on repair.os_id = dimoil.id
       --关联网点物料事实表:获取物流公司id
       left join one_make_dwb.fact_srv_stn_ma fssm on repair.ss_id = fssm.ss_id
       --关联物流维度表:获取物流公司名称
       left join (
            select type_id, type_name from one_make_dws.dim_logistics where prop_name = '物流公司'
                  ) dl on fssm.logi_cmp_id = dl.type_id
       where dd.year_month_id = '202101'and dd.week_in_year_id = '2021W1' and  dd.date_id = '20210101' and exp_rpr_num = 1
      ) repair_tmp
  group by dws_day, dws_week, dws_month, oil_type, oil_province, oil_city, oil_county,customer_classify, customer_province,logi_company;
  • 小结
  • 掌握维修主题的需求分析与实现


相关实践学习
钉钉群中如何接收IoT温控器数据告警通知
本实验主要介绍如何将温控器设备以MQTT协议接入IoT物联网平台,通过云产品流转到函数计算FC,调用钉钉群机器人API,实时推送温湿度消息到钉钉群。
阿里云AIoT物联网开发实战
本课程将由物联网专家带你熟悉阿里云AIoT物联网领域全套云产品,7天轻松搭建基于Arduino的端到端物联网场景应用。 开始学习前,请先开通下方两个云产品,让学习更流畅: IoT物联网平台:https://iot.console.aliyun.com/ LinkWAN物联网络管理平台:https://linkwan.console.aliyun.com/service-open
目录
相关文章
|
23天前
|
存储 消息中间件 监控
【Flume】Flume在大数据分析领域的应用
【4月更文挑战第4天】【Flume】Flume在大数据分析领域的应用
|
1月前
|
Cloud Native 数据处理 云计算
探索云原生技术在大数据分析中的应用
随着云计算技术的不断发展,云原生架构作为一种全新的软件开发和部署模式,正逐渐引起企业的广泛关注。本文将探讨云原生技术在大数据分析领域的应用,介绍其优势与挑战,并探讨如何利用云原生技术提升大数据分析的效率和可靠性。
|
1月前
|
存储 消息中间件 大数据
Go语言在大数据处理中的实际应用与案例分析
【2月更文挑战第22天】本文深入探讨了Go语言在大数据处理中的实际应用,通过案例分析展示了Go语言在处理大数据时的优势和实践效果。文章首先介绍了大数据处理的挑战与需求,然后详细分析了Go语言在大数据处理中的适用性和核心技术,最后通过具体案例展示了Go语言在大数据处理中的实际应用。
|
1月前
|
数据采集 运维 数据挖掘
API电商接口大数据分析与数据挖掘 (商品详情店铺)
API接口、数据分析以及数据挖掘在商品详情和店铺相关的应用中,各自扮演着重要的角色。以下是关于它们各自的功能以及如何在商品详情和店铺分析中协同工作的简要说明。
|
17天前
|
机器学习/深度学习 人工智能 安全
Azure Databricks实战:在云上轻松进行大数据分析与AI开发
【4月更文挑战第8天】Databricks在大数据分析和AI开发中表现出色,简化流程并提高效率。文中列举了三个应用场景:数据湖分析、实时流处理和AI机器学习,并阐述了Databricks的一体化平台、云原生弹性及企业级安全优势。博主认为,Databricks提升了研发效能,无缝集成Azure生态,并具有持续创新潜力,是应对大数据挑战和加速AI创新的理想工具。
41 0
|
30天前
|
机器学习/深度学习 人工智能 数据可视化
基于Python的数据可视化技术在大数据分析中的应用
传统的大数据分析往往注重数据处理和计算,然而数据可视化作为一种重要的技术手段,在大数据分析中扮演着至关重要的角色。本文将介绍如何利用Python语言中丰富的数据可视化工具,结合大数据分析,实现更直观、高效的数据展示与分析。
|
1月前
|
存储 NoSQL 大数据
新型数据库技术在大数据分析中的应用与优势探究
随着大数据时代的到来,传统数据库技术已经无法满足海量数据处理的需求。本文将探讨新型数据库技术在大数据分析中的应用情况及其所带来的优势,为读者解析数据库领域的最新发展趋势。
|
2月前
|
分布式计算 DataWorks IDE
MaxCompute数据问题之忽略脏数据如何解决
MaxCompute数据包含存储在MaxCompute服务中的表、分区以及其他数据结构;本合集将提供MaxCompute数据的管理和优化指南,以及数据操作中的常见问题和解决策略。
47 0
|
2月前
|
SQL 存储 分布式计算
MaxCompute问题之下载数据如何解决
MaxCompute数据包含存储在MaxCompute服务中的表、分区以及其他数据结构;本合集将提供MaxCompute数据的管理和优化指南,以及数据操作中的常见问题和解决策略。
38 0
|
2月前
|
分布式计算 关系型数据库 MySQL
MaxCompute问题之数据归属分区如何解决
MaxCompute数据包含存储在MaxCompute服务中的表、分区以及其他数据结构;本合集将提供MaxCompute数据的管理和优化指南,以及数据操作中的常见问题和解决策略。
36 0

热门文章

最新文章