首页 > 代码库 > 《BI项目笔记》报到信息分析Cube

《BI项目笔记》报到信息分析Cube

数据源设置:

数据处理逻辑:

--处理丢失外键关系数据SELECT  *FROM    T_ReportLeafGradeWHERE   FSubFID NOT IN ( SELECT FID                         FROM   T_RaceLeafReport )                         DELETE  FROM T_ReportLeafGradeWHERE   FSubFID NOT IN ( SELECT FID                         FROM   T_RaceLeafReport )                                               --处理供应商关系SELECT  *FROM    T_RaceLeafReportWHERE   V_Customer NOT IN ( SELECT  C_CustCode                            FROM    T_ProviderInfo )                            --更改字段类型                            ALTER TABLE T_RaceLeafReport ALTER COLUMN V_Customer INT --设置主键为NOT NULLALTER TABLE T_ProviderInfo ALTER COLUMN C_CustCode INT NOT NULL--设置主键ALTER TABLE T_ProviderInfoADD CONSTRAINT PK_CustCode PRIMARY KEY(C_CustCode)--承运单位SELECT  *FROM    T_RaceLeafReportWHERE   I_CarryID NOT IN ( SELECT   I_CarryID                           FROM     T_RaceCarryUnitInfo )--运输工具SELECT  *FROM    T_RaceLeafReportWHERE   I_ConveyanceID NOT IN ( SELECT  I_ConveyanceID                                FROM    T_RaceConveyance )                                --收购类型                                SELECT  *FROM    T_RaceLeafReportWHERE   I_PurchaseTypeID NOT IN ( SELECT    I_PurchaseID                                  FROM      T_PurchaseType )                                          --加工类型--新增I_TLProcTypeCode字段ALTER TABLE T_RaceLeafReport ADD I_TLProcTypeCode INT NULLUPDATE  T_RaceLeafReportSET     T_RaceLeafReport.I_TLProcTypeCode = T_TLProcType.I_TLProcTypeCodeFROM    T_TLProcTypeWHERE   T_RaceLeafReport.V_TLProcType = T_TLProcType.V_TLProcTypeDELETE  FROM T_RaceLeafReportWHERE   I_TLProcTypeCode IS NULL--提交标志\删除标记DELETE  FROM T_RaceLeafReportWHERE   V_IsSubmit = 未提交DELETE  FROM T_RaceLeafReportWHERE   I_DeleteFlag IN ( 1, 2 )--新增业务日期BusinessDate字段ALTER TABLE T_RaceLeafReport ADD BusinessDate INT NULL--将datetime转为intUPDATE  T_RaceLeafReportSET     BusinessDate = CAST(REPLACE(CONVERT(CHAR(10), D_ReportDate, 120), -,                                    ‘‘) AS INT)                                                                        --产地处理DELETE  FROM T_ReportLeafGradeWHERE   I_ShapeCode NOT IN ( SELECT I_OriginID                             FROM   T_Origin )

需要抽取的维度表:

序号

表名

说明

备注

1

T_ProviderInfo

供货商

 

2

T_RaceCarryUnitInfo

承运单位

 

3

T_RaceConveyance

运输工具

 

4

T_GBGradeCode

烟叶级别

 

5

T_Distinction

烟叶等级

 

6

T_Origin

产地

 

7

T_PurchaseType

收购类型

 

8

T_TLProcType

加工类型

 

 

需要抽取的事实表:

序号

表名

说明

备注

1

T_RaceLeafReport

报到主表

 

2

T_ReportLeafGrade

报到子表

 

主要指标:
I_PieceCount 件数_合计
I_Weight 重量_合计

《BI项目笔记》报到信息分析Cube