正在查看旧版本。 查看 当前版本.

与当前比较 查看页面历史记录

« 前一个 版本 25 当前 »


原理

依赖于列表取数(即开篇讲的hcm.model.list、hcm.model.count体系取数)或OpenApi(其他个性化接口或个性化云函数)的取数方式取数、形成一个个数据块(源)、然后将获取的数据整合到excel模版公式上、形成报表进行展示。

由过滤条件、Excel表样、数据块组成


配置大体步骤:

配置步骤

本节以下图所示做一个常规的统计分析表

演示案例环境 (hcmcloud.com)



新建报表

1. 报表平台中点击新增-新建报表

报表类别请选择分析报表、按要求填入必要的基本信息

2. 点击上传模版

将excel表样上传到系统中

点击过滤设置

点击过滤设置、添加报表过滤条件

数据源设置

制作前分析:

此报表规则:选择某个单位,展示这个单位的下一级单位或者部门里面的人员情况,我们需要至少2个数据源,两个数据源通过组织的origin_id相关联。

数据源一:展示某个单位下一级部门。

新建数据源,类型选择自定义,取数选择列表,字段设置origin_id 和名称,基于排序码做排序,是否分页为是,过滤条件是日期和部门

注意:如果你的项目用到了多级排序码,那么需要关联“DepartmentOrderNO”这个模型

元数据参数如下:

关联设置如下:

{
  "key": "dept_list",
  "data": {
    "type": "list",
    "field": [
      {
        "key": "origin_id",
        "align": "right",
        "field": [
          "origin_id"
        ],
        "label": "ORIGIN_ID",
        "state": null,
        "width": 100,
        "format": null,
        "object": null,
        "is_blur": false,
        "sequence": 10,
        "data_type": "integer",
        "fieldFunc": null
      },
      {
        "key": "name",
        "align": "left",
        "field": [
          "name"
        ],
        "label": "名称",
        "state": null,
        "width": 250,
        "format": null,
        "object": null,
        "is_blur": true,
        "sequence": 20,
        "data_type": "string",
        "fieldFunc": null
      }
    ]
  },
  "name": "组织",
  "class": "list",
  "sorts": [
    {
      "key": "orderno",
      "type": "asc",
      "label": "排序码"
    }
  ],
  "source": {
    "meta": {
      "model": "DepartmentHistory",
      "relations": [],
      "conditions": {
        "enabled": 1,
        "end_date": {
          "gt": "=date_"
        },
        "org_type": {
          "neq": 40
        },
        "parent_id": "=depart_id",
        "begin_date": {
          "lte": "=date_"
        }
      },
      "relation_mode": null,
      "static_filters": [
        {
          "key": "date_",
          "label": "日期"
        },
        {
          "key": "depart_id",
          "label": "上级组织"
        }
      ]
    },
    "type": "meta"
  },
  "page_count": true,
  "filter_dict": {
    "date_": "=CURR_DATE",
    "depart_id": "=CURR_DEPARTMENT"
  },
  "total_include": false
}

数据源二:基于此表需要的条件做分组。

注意点:1:基于人员做统计分析,主模型是JobInformation  内关联到:Employee,OrgPositionHistory,OrgDepartmentHistory,DepartmentHierarchy

               2、系统的人员是在最末级部门,这里需要用到组织层级 DepartmentHierarchy 这个模型

               3、因为要关联最高学历,防止出现某个人无学历信息的情况,这里的关联类型要选外连接。(内连接外连接相当于数据库的inner join和left join的区别)

               4、第二个数据源的分页一定要选否。

数据源关联配置:

{
    "key": "emp_count",
    "data": {
        "dim": [{
            "dim": {
                "field": "dept_level.l1_id"
            },
            "key": "dept_",
            "align": "left",
            "field": ["dept_level_l1_id_5", "name"],
            "label": "二级部门",
            "state": null,
            "width": 160,
            "format": null,
            "object": "OrgDepartment",
            "is_blur": false,
            "sequence": 10,
            "data_type": "integer",
            "fieldFunc": null
        }, {
            "dim": {
                "field": "employee_category_id"
            },
            "key": "category",
            "align": "left",
            "field": ["master_employee_category_id_b", "name"],
            "label": "用工类型",
            "state": null,
            "width": 160,
            "format": null,
            "object": "EmployeeCategory",
            "is_blur": false,
            "sequence": 20,
            "data_type": "integer",
            "fieldFunc": null
        }, {
            "dim": {
                "field": "employee.age_count"
            },
            "key": "employee_age_count",
            "align": "right",
            "field": ["employee_age_count"],
            "label": "年龄",
            "state": null,
            "width": 100,
            "format": null,
            "object": null,
            "is_blur": null,
            "sequence": null,
            "data_type": "integer",
            "fieldFunc": null
        }, {
            "dim": {
                "field": "edu.education"
            },
            "key": "edu_education",
            "align": "left",
            "field": ["edu_education"],
            "label": "学历",
            "refer": "common_basic_item_data.学历代码",
            "state": null,
            "width": 300,
            "format": null,
            "object": null,
            "is_blur": false,
            "sequence": 30,
            "data_type": "string",
            "fieldFunc": null
        }, {
            "dim": {
                "field": "employee.gender"
            },
            "key": "employee_gender",
            "align": "left",
            "field": ["employee_gender"],
            "label": "性别",
            "refer": "common_basic_item_data.性别",
            "state": null,
            "width": 300,
            "format": null,
            "object": null,
            "is_blur": false,
            "sequence": null,
            "data_type": "string",
            "fieldFunc": null
        }],
        "aggr": [{
            "key": "count",
            "aggr": {
                "ag": "count",
                "field": "employee_id"
            },
            "align": "left",
            "field": ["master_employee_id_dvli"],
            "label": "员工",
            "state": null,
            "width": 160,
            "format": null,
            "object": "Employee",
            "is_blur": true,
            "sequence": 10,
            "data_type": "integer",
            "fieldFunc": null
        }],
        "type": "aggr"
    },
    "name": "全员用工类型",
    "class": "list",
    "source": {
        "meta": {
            "model": "JobInformation",
            "relations": [{
                "key": "employee",
                "name": "人员基础信息",
                "model": "Employee",
                "filter": {
                    "employee.id": ":employee_id"
                }
            }, {
                "key": "position",
                "name": "岗位信息",
                "type": "outer",
                "model": "OrgPositionHistory",
                "filter": {
                    "position.end_date": {
                        "gt": "=date_"
                    },
                    "position.origin_id": ":position_id",
                    "position.begin_date": {
                        "lte": "=date_"
                    }
                }
            }, {
                "key": "department",
                "name": "部门信息",
                "type": "outer",
                "model": "OrgDepartmentHistory",
                "filter": {
                    "department.end_date": {
                        "gt": "=date_"
                    },
                    "department.origin_id": ":position.parent_id",
                    "department.begin_date": {
                        "lte": "=date_"
                    }
                }
            }, {
                "key": "dept_level",
                "name": "组织层级",
                "type": "inner",
                "model": "DepartmentHierarchy",
                "filter": {
                    "dept_level.l0_id": "=depart_id",
                    "dept_level.end_date": {
                        "gt": "=date_"
                    },
                    "dept_level.begin_date": {
                        "lte": "=date_"
                    },
                    "dept_level.department_id": ":department.origin_id"
                },
                "field_context": {
                    "date_": "=date_",
                    "root_id": "=depart_id",
                    "is_relative_level": true
                }
            }, {
                "key": "edu",
                "name": "教育",
                "type": "outer",
                "model": "EmployeeEducation",
                "filter": {
                    "edu.is_highest": "1",
                    "edu.employee_id": ":employee_id"
                },
                "field_context": {
                    "is_relative_level": false
                }
            }],
            "conditions": {
                "on_job": 1,
                "end_date": {
                    "gt": "=date_"
                },
                "begin_date": {
                    "lte": "=date_"
                },
                "position_type": 1
            },
            "relation_mode": null,
            "static_filters": [{
                "key": "date_",
                "label": "日期"
            }, {
                "key": "depart_id",
                "label": "上级组织"
            }]
        },
        "type": "meta"
    },
    "page_count": false,
    "filter_dict": {
        "date_": "=CURR_DATE",
        "depart_id": "=CURR_DEPARTMENT"
    },
    "total_include": false
}


配置excel公式

此模版用到了两个excel公式、还有很多其他公式我们后面会有详细介绍。

公式一:部门名称,基于“dept_list”的name 向下扩展。(HCM 只支持向下扩展)

[list:dept_list:{name}]

公式二:emp_count 是人员分析模型的标识,两个模型基于dept_ 和 origin_id  两个字段关联,其中origin_id 来源于dept_list 所以要加{}。

注意:这里的”count”是人数的字段名,不是计数的意思,多个条件用;区分。

人员总数:[VLOOKSTAT(emp_count,'dept_:eq:{origin_id}','sum','count',default='0')]  这里只需要将部门作为关联条件

性别:[VLOOKSTAT(emp_count,'dept_:eq:{origin_id};employee_gender:eq:男','sum','count',default='0')] 通过employee_gender:eq:男 过滤男性

用工类型:[VLOOKSTAT(emp_count,'dept_:eq:{origin_id};category:in:1717','sum','count',default='0')]  通过category:in:1717 过滤劳动合同制的人员,这里1717 是该用工类型的ID

本科以上:[VLOOKSTAT(emp_count,'dept_:eq:{origin_id};edu_education:in:本科-硕士研究生-博士研究生','sum','count',default='0')] 通过edu_education:in:本科-硕士研究生-博士研究生 多个条件通过- 关联

35岁以下:[VLOOKSTAT(emp_count,'dept_:eq:{origin_id};employee_age_count:lte:35','sum','count',default='0')] 通过lte 获取年龄小于35的人员

公式三:合计公式,意思是汇总 B5这个指定单元格和(0,-1)这个动态单元格的和

[RANGE_SUM('B5',(0,-1))] 

报表标题公式:[DEPART_NAME(CURR_DEPARTMENT)+"统计分析表"]

注意:DEPART_NAME 可以获取 CURR_DEPARTMENT 的部门名称

点击计算、完成此报表制作

常见的分析报表公式

VLOOKUP:常用于直接查找。

VLOOKSTAT:查找符合条件的数据后并对数据进行分析,支持分析的方式有汇总类型 count:合计数, sum:汇总数,avg:平均值, max:最大值,min:最小值

VLOOKCUBE:查找的内容后在做组合

CELL:获取指定坐标的值,常用于分析报表里的计算,通过CELL获取部分单元格的值之后相加减。

RANGE_SUM:合计

常用报表的小技巧

一、单个报表设置默认显示行

报表->设计->高级设置->
       configs:{
       "paging_config":

       { "default_page_size":10 }

       }

二、有些模型的字段在选择报表字段的时候选不到

找到模型最底层元数据,修改is_logic 属性为true

三、公式的计算顺序

相关地址:https://mingcloud.hcmcloud.com/#/flex_report?report=emp01



  • 无标签