助力工业物联网,工业大数据之工业大数据之油站维度设计【十四】

news/2024/10/18 10:28:28/

文章目录

    • 01:油站维度设计
    • 02:油站维度构建

01:油站维度设计

  • 目标:掌握油站维度的需求与设计

  • 路径

    • step1:需求
    • step2:设计
  • 实施

    • 需求:构建油站维度表,得到油站id、油站名称、油站所属的地理区域、所属公司、油站状态等

      image-20211003095335316

    • 设计

      • 数据来源

        • ciss_base_oilstation:油站信息表

          selectid, name, code,customer_id, customer_name,province, city, region, township,status, customer_classify, dt
          from one_make_dwd.ciss_base_oilstation
          where id != '' and name is not null and name != 'null' and customer_id is not null;
          
        • eos_dict_type:字典状态类别表,记录所有需要使用字典标记的表

          select * from eos_dict_type where dicttypename = '油站状态';
          
        • eos_dict_entry:字典状态明细表,记录所有具体的状态或者类别信息

          select * from eos_dict_entry where dicttypeid = 'BUSS_OILSTATION_STATUS';
          
        • ciss_base_baseinfo:客户公司信息表【公司ID、公司名称】

          select ygcode, companyname from one_make_dwd.ciss_base_baseinfo group by ygcode, companyname;
          
          • 数据有重复,做个去重
        • ciss_base_customer:客户信息表【客户id、客户省份名称、所属公司ID】

          select code, province, company from one_make_dwd.ciss_base_customer;
          
        • ciss_base_areas:行政地区信息表

          • 通过具体的id关联所有地区信息
      • 实现设计

        • 所有表按照对应字段关联,获取对应的属性字段
  • 小结

    • 掌握油站维度的需求与设计

02:油站维度构建

  • 目标实现油站维度的构建

  • 实施

    • 建维度表

      -- 创建油站维度表
      create external table if not exists one_make_dws.dim_oilstation(id string comment '油站ID', name string comment '油站名称', code string comment '油站编码', customer_id string comment '客户ID', customer_name string comment '客户名称', province_id int comment '省份id', province_name string comment '省份名称', city_id int comment '城市id', city_name string comment '城市名称', county_id int comment '县城ID', county_name string comment '县城名称', area_id int comment '区域id', area_name string comment '区域名称', customer_classify_id string comment '客户分类ID', customer_classify_name string comment '客户分类名称', status int comment '油站状态(1、2)', status_name string comment '油站状态名(正常、停用)', company_id int comment '所属公司ID', company_name string comment '所属公司名称', customer_province_id int comment '客户所属省份ID', customer_province_name string comment '客户所属省份'
      ) COMMENT '油站维度表'
      PARTITIONED BY (dt STRING)
      STORED AS TEXTFILE
      LOCATION '/data/dw/dws/one_make/dim_oilstation';
      
    • 抽取数据

      insert overwrite table one_make_dws.dim_oilstation partition (dt ='20210101')
      select oil.id, oil.name, oil.code, customer_id, customer_name, oil.province province_id, p.areaname province_name, oil.city city_id, c.areaname city_name, oil.region county_id, county.areaname county_name, oil.township area_id, a.areaname area_name, oil.customer_classify customer_classify_id, ede.dictname customer_classify_name, oil.status status, eosde.dictname status_name, cbc.company company_id, binfo.companyname company_name, proname.id customer_province_id, proname.areaname customer_province_name
      from (select id, name, code, customer_id, customer_name, province, city, region, township, status, customer_classify, dtfrom one_make_dwd.ciss_base_oilstation where id != '' and name is not null and name != 'null' and customer_id is not null) oilleft join (select id, areaname, parentid from one_make_dwd.ciss_base_areas where rank = 1) p on oil.province = p.idleft join (select id, areaname, parentid from one_make_dwd.ciss_base_areas where rank = 2) c on oil.city = c.idleft join (select id, areaname, parentid from one_make_dwd.ciss_base_areas where rank = 3) county on oil.region = county.idleft join (select id, areaname, parentid from one_make_dwd.ciss_base_areas where rank = 4) a on oil.township = a.idleft join (select dictid, dictname  from one_make_dwd.eos_dict_entry) ede on oil.customer_classify = ede.dictidleft join (select dictid, dictname from one_make_dwd.eos_dict_entry t1  left join one_make_dwd.eos_dict_type t2 on t1.dicttypeid = t2.dicttypeid where t2.dicttypename = '油站状态') eosde on oil.status = eosde.dictid-- 客户所属公司id,所属公司名称,所属省份id,所属省份名称left join (select code, province, company from one_make_dwd.ciss_base_customer) cbc on oil.customer_id = cbc.codeleft join (select id, areaname from one_make_dwd.ciss_base_areas where rank = 1 and id != 83) proname on cbc.province = proname.areanameleft join (select ygcode, companyname from one_make_dwd.ciss_base_baseinfo group by ygcode, companyname) binfo on cbc.company = binfo.ygcode where dt = '20210101';
      
    • 查看结果

      image-20211010152211120

  • 小结

    • 实现油站维度的构建

http://www.ppmy.cn/news/107248.html

相关文章

生产环境之负载均衡LVS+keepalived方案(3)_KeepAlived介绍

keepalived简介 Keepalived 软件起初是专为LVS负载均衡软件设计的,用来管理并监控LVS集群系统中各个服务节点的状态,加入了可以实现高可用的VRRP(Virtual Router RedundancyProtocol(虚拟路由器冗余协议))功能&#x…

Django实现接口自动化平台(二)认证授权【持续更新中】

上一章: Django实现接口自动化平台(一)日志功能【持续更新中】_做测试的喵酱的博客-CSDN博客 下一章: 一、认证与授权配置 1、认证:获取权限的方式 2、授权:通过认证之后,可以获取哪些权限 …

论文解读 | ICRA2022:用深度贝叶斯算法来估计ICP的协方差

原创 | 文 BFT机器人 01 研究背景 在点云处理中,ICP算法是一种常用的点云配准方法,通过将两个或多个点云对齐,可以进行后续的建模、识别和跟踪等处理。 然而,在ICP算法中,协方差估计起着非常重要的作用,它…

JDK相关知识

查看是否安装了jdk java -version 将输出当前系统上默认 Java 环境的版本信息,其中包括 JDK 的位数(64 位或 32 位)。如果输出中包括 “64-Bit” 或 “x64” ,则表示你的 JDK 是 64 位的;否则,它就是 32 位…

基于vue3.0简单的页面使用

基于vue3.0简单的页面使用 项目效果图项目文件图package.jsonmain.jsApp.vueviews/Tutorial.vueviews/TS.vueviews/Docs.vueviews/Community.vueviews/Blog.vueviews/About.vueutils/create.jsxutils/defineCom.jsutils/DragIcon.jsutils/someName.tsutils/TS.tsstores/client.…

支付宝 小程序 抽奖组件 大转盘

介绍 使用支付宝原有的大转盘营销组件进行改造的,由于背景使用的图片,目前只支持 6 个奖品,一般情况下的大转盘都是这个规格。 转盘停止:之前使用的是计算角度来完成的,没有那种缓慢停止的动画。现在加了一个缓慢停止…

【测试开发】第四节.测试开发(测试分类)

作者简介:大家好,我是未央; 博客首页:未央.303 系列专栏:Java测试开发 每日一句:人的一生,可以有所作为的时机只有一次,那就是现在!!! 文章目录 前…

iOS 性能优化方案

一、启动优化 1、冷启动(从零开始的启动) 冷启动三个阶段 1.1 Main函数执行前 加载可执行文件(mach-o文件)加载动态链接库,进行rebase指针调整和bind符号绑定Objc运行时的初始化处理,包括Objc相关类的注…