助力工业物联网,工业大数据之其他维度:组织机构【十六】_组织机构属于什么类型的维度表

收集整理了一份《2024年最新物联网嵌入式全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升的朋友。
img
img

如果你需要这些资料,可以戳这里获取

需要这些体系化资料的朋友,可以加我V获取:vip1024c (备注嵌入式)

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人

都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

	```
	select empid,empcode,empname,userid from org_employee;
	
	```
	- org\_empposition:员工岗位信息表【员工id、岗位id】
	
	 
	```
	select empid,positionid from org_empposition;
	
	```
	- org\_position:岗位信息表【岗位id、岗位编码、岗位名称、部门id】
	
	 
	```
	select positionid,posicode,posiname,orgid from org_position;
	
	```
	- org\_organization:部门信息表【部门id、部门编码、部门名称】
	
	 
	```
	select orgid,orgcode,orgname from org_organization;
	
	```![image-20211010153834323](https://img-blog.csdnimg.cn/img_convert/7d534d40e3b947af31c914cca4d39356.png)
+ **实现**


	- **建维度表**
	
	 
	```
	-- 创建组织机构维度表,组织机构人员是经常变动的,所以按照日期分区
	create external table if not exists one_make_dws.dim_emporg(
	    empid string comment '人员id'   
	    , empcode string comment '人员编码(erp对应的账号id)'
	    , empname string comment '人员姓名'
	    , userid string comment '用户系统id(登录用户名)'
	    , posid string comment '岗位id'
	    , posicode string comment '岗位编码'
	    , posiname string comment '岗位名称'
	    , orgid string comment '部门id'
	    , orgcode string comment '部门编码'
	    , orgname string comment '部门名称'
	) comment '组织机构维度表'
	partitioned by (dt string)
	stored as orc
	location '/data/dw/dws/one\_make/dim\_emporg';
	
	```
	- **抽取数据**
	
	 
	```
	-- 先根据dwd层的表进行关联,然后分别把数据取出来
	insert overwrite table one_make_dws.dim_emporg partition(dt='20210101')
	select
	    emp.empid as empid
	    , emp.empcode as empcode
	    , emp.empname as empname
	    , emp.userid as userid
	    , pos.positionid as posid
	    , pos.posicode as posicode
	    , pos.posiname as posiname
	    , org.orgid as orgid
	    , org.orgcode as orgcode
	    , org.orgname as orgname
	from  one_make_dwd.org_employee emp
	left join one_make_dwd.org_empposition emppos
	    on emp.empid = emppos.empid and emp.dt = '20210101' and emppos.dt = '20210101'
	left join one_make_dwd.org_position pos
	    on emppos.positionid = pos.positionid and pos.dt = '20210101'
	left join one_make_dwd.org_organization org
	    on pos.orgid = org.orgid and org.dt = '20210101';
	
	```
  • 小结

    • 实现组织机构维度的设计及构建

02:其他维度:仓库、物流

  • 目标实现仓库维度、物流维度的构建

  • 路径

    • step1:仓库维度
    • step2:物流维度
  • 实施

    • 仓库维度

      • 建表
      -- 仓库维度表
      create external table if not exists one_make_dws.dim_warehouse(
          code string comment '仓库编码'
          , name string comment '仓库名称'
          , company_id string comment '所属公司'
          , company string comment '公司名称'
          , srv_station_id string comment '所属服务网点ID'
          , srv_station_name string comment '所属服务网点名称'
      )comment '仓库维度表'
      partitioned by (dt string)
      stored as orc
      location '/data/dw/dws/one\_make/dim\_warehouse';
      
      
      • 加载
      insert overwrite table one_make_dws.dim_warehouse partition(dt='20210101')
      select
          warehouse.code as code
          , warehouse.name as name
          , warehouse.company as company_id
          , cmp.compmay as compmay
          , station.id as srv_station_id
          , station.name as srv_station_name
      from
          one_make_dwd.ciss_base_warehouse warehouse
      -- 关联公司信息表
      left join (
           select
                 ygcode as company_id, max(companyname) as compmay
           from one_make_dwd.ciss_base_baseinfo where dt='20210101'
           -- 需要对company信息进行分组去重,里面有一些重复数据 
           group by ygcode) cmp
           on warehouse.dt = '20210101' and cmp.company_id = warehouse.company
      -- 关联服务网点和仓库关系表
      left join one_make_dwd.ciss_r_serstation_warehouse station_r_warehouse
           on station_r_warehouse.dt = '20210101' and station_r_warehouse.warehouse_code = warehouse.code
      -- 关联服务网点表 
      left join one_make_dwd.ciss_base_servicestation station
           on station.dt = '20210101' and station.id = station_r_warehouse.service_station_id;
      
      
    • 物流维度

      • 建表
      -- 物流维度表(和服务属性表类似)
      create external table if not exists one_make_dws.dim_logistics(
          prop_name string comment '字典名称'
          , type_id string comment '属性id'
          , type_name string comment '属性名称'
      )comment '物流维度表'
      partitioned by (dt string)
      stored as orc
      location '/data/dw/dws/one\_make/dim\_logistics';
      
      
      • 加载
      insert overwrite table one_make_dws.dim_logistics partition(dt = '20210101')
      select
          dict_t.dicttypename as prop_name
          , dict_e.dictid as type_id
          , dict_e.dictname as type_name
      from  one_make_dwd.eos_dict_type dict_t
      inner 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
              and dict_t.dicttypename in (
                  '物流公司'
                  , '物流类型'
              )
      order by dict_t.dicttypename, dict_e.dictid;
      
      
      • 使用如下写法会好一些
      insert overwrite table one_make_dws.dim_logistics partition (dt = '20210101')
      select dict_t.dicttypename as prop_name
           , dict_e.dictid       as type_id
           , dict_e.dictname     as type_name
      from one_make_dwd.eos_dict_type dict_t
              inner 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   -- 通过状态字符串进行关联
      
      
      

img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上物联网嵌入式知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、电子书籍、讲解视频,并且后续会持续更新

需要这些体系化资料的朋友,可以加我V获取:vip1024c (备注嵌入式)

如果你需要这些资料,可以戳这里获取

升的进阶课程,涵盖了95%以上物联网嵌入式知识点,真正体系化!**

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、电子书籍、讲解视频,并且后续会持续更新

需要这些体系化资料的朋友,可以加我V获取:vip1024c (备注嵌入式)

如果你需要这些资料,可以戳这里获取

  • 26
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值