...
代码块 |
---|
class DynamicCondition(object): def execute(self, analysis_id, org, current_date, param,appoint_date=None): emp_category_id_list = [] # EmpCategoryPower为人员用工类型功能的存储模型 emp_category_power_list = \ CustomerUtil.call_open_api("hcm.model.list", param={"model": "EmpCategoryPower", "filter_dict": { "employee_id": CustomerUtil.get_current_context().employee.id}})['list'] # 获取EmpCategoryPower模型中于当前用户有关的相关信息 for item in emp_category_power_list: if item.get("employee_category_id") not in emp_category_id_list: emp_category_id_list.append(item.get("employee_category_id")) # 获取当前用户允许访问的用工类型id if emp_category_id_list and len(emp_category_id_list)>0:#为空的话不过滤 # 添加过滤条件到人力洞察的分析参数中 param['filter'].append({"key":"emp.s_employee_category","name":"用工类型","selected_text":"","value":emp_category_id_list}) logging.info("insight_plugin:{}:{}".format(emp_category_id_list,param)) return param |
如果有多个过滤条件, 可以继续通过param['filter'].append()的方式将过滤条件添加到param中
总结: 该功能实际上就是将人力洞察的某些分析维度的过滤条件提前添加到所有分析模型中, filter中添加的过滤条件的格式和人力洞察前端传递的格式相同