示例: 规则集名称:通用规则 规则集默认输出:-1 规则集: 规则1: 变量:年龄 age 逻辑:年龄小于18或大于等于65 输出:1 结果备注: 1代表好 规则2: 变量:欠税总额 qsze 逻辑:欠税总额大于500 输出:3 结果备注: 3代表一般 规则3: 变量:非银行机构未结清贷款机构数 fyjgwjqs 逻辑:非银行机构未结清贷款机构数大于10 输出:2 输出: def handle_general_rules(data:dict): # 通用规则 # 输出结果备注: # 1代表好 # 3代表一般 age = data.get("age") qsze = data.get("qsze") fyjgwjqs = data.get("fyjgwjqs") if age is not None: if age < 18 or age >= 65: return 1 if qsze is not None: if qsze > 500: return 3 if fyjgwjqs is not None: if fyjgwjqs > 10: return 2 return -1 ``` 待处理规则: 规则集名称:极优质客户 规则集默认输出:接受 规则集: 规则1: 变量:年龄 age 性别 sex 逻辑:男性客户年龄小于22岁或大于60岁,普通女性客户小于22岁或大于55岁 输出:拒绝 变量备注: 性别为男或者女 规则2: 变量:是否本行关系人 sfbhgxr 逻辑:sfbhgxr=1 输出:拒绝 规则3: 变量:配偶在黑名单中 pozhmdz 逻辑:pozhmdz=1 输出:拒绝 规则4: 变量:行内审慎客户 hnsskh 逻辑:hnsskh=1 输出:拒绝 规则5: 变量:呆账信息汇总、资产处置信息汇总、保证人代偿信息汇总数据中有记录的 ydzhzccz 逻辑:ydzhzccz=1 输出:拒绝 规则6: 变量:资产处置信息余额的zcczye 逻辑:zcczye>0 输出:拒绝 规则7: 变量:保证人代偿信息余额的 bzrdcye 逻辑:bzrdcye>0 输出:拒绝 规则8: 变量:呆账贷记卡是记录dzdjkjl_cnt 逻辑:dzdjkjl_cnt>0 输出:拒绝 规则9: 变量:对外担保信息中担保贷款五级分类 dbxxwjfl 逻辑:对外担保信息中担保贷款五级分类是“次级”或“可疑”或“损失” 输出:拒绝 规则10: 变量:当前逾期金额 dqyqje 逻辑:dqyqje>0 输出:拒绝 规则11: 变量:客户存在公安负面信息 gafmxx_cnt 逻辑:gafmxx_cnt>0 输出:拒绝 规则12: 变量:客户存在失信被执行人信息 ssxrzxxx_cnt 逻辑:ssxrzxxx_cnt>0 输出:拒绝 规则13: 变量:公积金缴至年月距申请时的月份数gjjjfyffs 逻辑:公积金缴至年月距申请时的月份数大于3 输出:拒绝 规则14: 变量:公积金近1年累计缴纳次数 gjjjncs_l122m 逻辑:公积金近1年累计缴纳次数小于6 输出:拒绝 规则15: 变量:贷记卡最近24个月的还款记录中逾期天数 djkyqts_l24m 逾期金额 yqje 逻辑:贷记卡或贷记卡最近24个月的还款记录中逾期天数(3-7、D、Z、G字符)且逾期金额500元以上 输出:拒绝 规则16: 变量:借款人最近24个月最大连续逾期期数jkrzdlxyqqs_l24m 累计逾期次数 ljyqqs 逻辑:借款人最近24个月最大连续逾期期数>3或累计逾期次数>6 输出:拒绝 规则17: 变量:非银行机构未结清贷款笔数 fyjgwjqdkbs 逻辑:非银行机构未结清贷款笔数>=3 输出:拒绝 规则18: 变量:近一个月非本行审批查询机构数 fbhspcxs_l1m 近3个月非本月审批查询机构数 fbhspcxs_l3m 近6个月非本行审批查询机构数 fbhspcxs_l6m 逻辑:近一个月非本行审批查询机构数>3或近3个月非本月审批查询机构数>5或近6个月非本行审批查询机构数>8 输出:拒绝 规则19: 变量:一代模型评分 ydmxpf 逻辑:一代模型评分>0.766 输出:拒绝 请根据```内的示例以及待处理规则中的变量、计算逻辑及输出,用Python语言生成功能函数代码。 返回结果要求: 1、只返回功能函数代码,不要多余的输出。 2、代码逻辑应严格按照待处理要求中的条件,不要自行添加多余的逻辑。 3、代码的语法要符合python的语法规范,返回的代码应该是可执行的。 4、规则里有 结果备注 的请在函数中的 输出结果备注 处进行备注,没有的则无输出结果备注 # 角色 你是一个专业的Python代码生成器,能够根据给定的流程图和函数内容,用Python语言生成完整的流程执行代码。 给定的函数内容: def handle_general_rules(data:dict): # 通用规则 # 输出结果备注: # 0代表拒绝,1代表接受 sex = data.get("sex") age = data.get("age") pboc_score = data.get("pboc_score") incomeM = data.get("incomeM") qzzxbjz = data.get("qzzxbjz") yzxbje = data.get("yzxbje") wjqxedkbss = data.get("wjqxedkbss") xedkjgs = data.get("xedkjgs") if sex is not None and age is not None: if (sex == "男" and (22 <= age <= 60)) or (sex == "女" and (22 <= age <= 55)): return 1 if pboc_score is not None: if pboc_score > 0.523: return 0 if incomeM is not None: if incomeM < 2000: return 0 if qzzxbjz is not None and yzxbje is not None: if (qzzxbjz - yzxbje) > 20000: return 0 if wjqxedkbss is not None or xedkjgs is not None: if (wjqxedkbss is not None and wjqxedkbss > 4) or (xedkjgs is not None and xedkjgs > 2): return 0 return 1.0 def handle_kequn_rules(data:dict): # 客群规则 # 输出结果备注: # 公积金单位较优客户 # 金融资产较优客户 # 房贷客户 gjjdwlx = data.get("gjjdwlx") sex = data.get("sex") age = data.get("age") gjjkhsj = data.get("gjjkhsj") gjjjncs_l12m = data.get("gjjjncs_l12m") nrjjrzc = data.get("nrjjrzc") rjzc_l3m = data.get("rjzc_l3m") whkkhsj = data.get("whkkhsj") xymxpf = data.get("xymxpf") wjqfdyyhke = data.get("wjqfdyyhke") yhkqs = data.get("yhkqs") zcyqts = data.get("zcyqts") yqcs_l24m = data.get("yqcs_l24m") if gjjdwlx is not None and sex is not None and age is not None and gjjkhsj is not None and gjjjncs_l12m is not None: if (gjjdwlx in ("国家机关", "事业单位", "国企", "医院") and ((sex == "男" and 22 <= age <= 60) or (sex == "女" and 22 <= age <= 55)) and gjjkhsj >= 1 and gjjjncs_l12m >= 6): return "公积金单位较优客户" if nrjjrzc is not None and rjzc_l3m is not None and whkkhsj is not None and xymxpf is not None: if (nrjjrzc > 10 and rjzc_l3m >= 1 and whkkhsj >= 1 and (xymxpf > 0.397 or xymxpf == -1)): return "金融资产较优客户" if wjqfdyyhke is not None and yhkqs is not None and zcyqts is not None and yqcs_l24m is not None: if ((wjqfdyyhke > 4000 and yhkqs > 12 and yqcs_l24m <= 2 and zcyqts <= 30) or (0 < wjqfdyyhke <= 4000 and yhkqs > 24 and yqcs_l24m <= 2 and zcyqts <= 30)): return "房贷客户" return "其它" def handle_extremely_high_quality_customer_rules(data:dict): # 极优质客户规则 # 输出结果备注: age = data.get("age") sex = data.get("sex") sfbhgxr = data.get("sfbhgxr") pozhmdz = data.get("pozhmdz") hnsskh = data.get("hnsskh") ydzhzccz = data.get("ydzhzccz") zcczye = data.get("zcczye") bzrdcye = data.get("bzrdcye") dzdjkjl_cnt = data.get("dzdjkjl_cnt") dbxxwjfl = data.get("dbxxwjfl") dqyqje = data.get("dqyqje") gafmxx_cnt = data.get("gafmxx_cnt") ssxrzxxx_cnt = data.get("ssxrzxxx_cnt") gjjjfyffs = data.get("gjjjfyffs") gjjjncs_l122m = data.get("gjjjncs_l122m") djkyqts_l24m = data.get("djkyqts_l24m") yqje = data.get("yqje") jkrzdlxyqqs_l24m = data.get("jkrzdlxyqqs_l24m") ljyqqs = data.get("ljyqqs") fyjgwjqdkbs = data.get("fyjgwjqdkbs") fbhspcxs_l1m = data.get("fbhspcxs_l1m") fbhspcxs_l3m = data.get("fbhspcxs_l3m") fbhspcxs_l6m = data.get("fbhspcxs_l6m") ydmxpf = data.get("ydmxpf") if age is not None and sex is not None: if (sex == "男" and (age < 22 or age > 60)) or (sex == "女" and (age < 22 or age > 55)): return "拒绝" if sfbhgxr is not None: if sfbhgxr == 1: return "拒绝" if pozhmdz is not None: if pozhmdz == 1: return "拒绝" if hnsskh is not None: if hnsskh == 1: return "拒绝" if ydzhzccz is not None: if ydzhzccz == 1: return "拒绝" if zcczye is not None: if zcczye > 0: return "拒绝" if bzrdcye is not None: if bzrdcye > 0: return "拒绝" if dzdjkjl_cnt is not None: if dzdjkjl_cnt > 0: return "拒绝" if dbxxwjfl is not None: if dbxxwjfl in ["次级", "可疑", "损失"]: return "拒绝" if dqyqje is not None: if dqyqje > 0: return "拒绝" if gafmxx_cnt is not None: if gafmxx_cnt > 0: return "拒绝" if ssxrzxxx_cnt is not None: if ssxrzxxx_cnt > 0: return "拒绝" if gjjjfyffs is not None: if gjjjfyffs > 3: return "拒绝" if gjjjncs_l122m is not None: if gjjjncs_l122m < 6: return "拒绝" if djkyqts_l24m is not None and yqje is not None: if (djkyqts_l24m in ["3", "4", "5", "6", "7", "D", "Z", "G"] and yqje > 500): return "拒绝" if jkrzdlxyqqs_l24m is not None and ljyqqs is not None: if jkrzdlxyqqs_l24m > 3 or ljyqqs > 6: return "拒绝" if fyjgwjqdkbs is not None: if fyjgwjqdkbs >= 3: return "拒绝" if fbhspcxs_l1m is not None and fbhspcxs_l3m is not None and fbhspcxs_l6m is not None: if fbhspcxs_l1m > 3 or fbhspcxs_l3m > 5 or fbhspcxs_l6m > 8: return "拒绝" if ydmxpf is not None: if ydmxpf > 0.766: return "拒绝" return "接受" def handle_important_customer_rules(data:dict): # 要客规则 # 输出结果备注: 无 bhgxr = data.get("bhgxr") dqyqje = data.get("dqyqje") wbhdkhxykyqye = data.get("wbhdkhxykyqye") if bhgxr is not None: if bhgxr == 1: return "拒绝" if dqyqje is not None: if dqyqje > 0: return "拒绝" if wbhdkhxykyqye is not None: if wbhdkhxykyqye == 1: return "拒绝" return "拒绝" def handle_gov_vip_rules(data:dict): # 是否要客 # 输出结果备注: # 1代表是要客 # 0代表不是要客 GovVip = data.get("GovVip") if GovVip is not None: if GovVip == 1: return 1 elif GovVip == 0: return 0 return 0.0 def handle_high_quality_customer_credit(data:dict): # 极优质客户额度 # 输出结果备注: 无 dwlx = data.get("dwlx") incomeM = data.get("incomeM") if dwlx is not None and incomeM is not None: if dwlx == "国家机关" and 0 < incomeM < 5000: return 60000 if dwlx == "国家机关" and 5000 <= incomeM < 12000: return 180000 if dwlx == "国家机关" and 12000 <= incomeM < 15000: return 250000 if dwlx == "国家机关" and incomeM > 15000: return 300000 if (dwlx == "三甲医院" or dwlx == "优质学校" or dwlx == "国网") and 0 < incomeM < 6000: return 50000 if dwlx == "国家机关" and 6000 <= incomeM < 14000: return 150000 if (dwlx == "三甲医院" or dwlx == "优质学校" or dwlx == "国网") and 14000 <= incomeM < 16000: return 220000 if (dwlx == "三甲医院" or dwlx == "优质学校" or dwlx == "国网") and incomeM > 16000: return 300000 return 0.0 def handle_customer_credit(data:dict): # 客群额度 # 输出结果备注: 无 kqlx = data.get("kqlx") incomeM = data.get("incomeM") if kqlx is not None and incomeM is not None: if kqlx == "公积金单位较优客户": if 0 < incomeM < 5000: return 60000 elif 5000 <= incomeM < 12000: return 180000 elif 12000 <= incomeM < 15000: return 250000 elif incomeM > 15000: return 300000 elif kqlx == "房贷客户": if 0 < incomeM < 6000: return 50000 elif 6000 <= incomeM < 14000: return 150000 elif 14000 <= incomeM < 16000: return 220000 elif incomeM > 16000: return 300000 return 0.0 函数与节点对应关系: 通用规则: handle_general_rules 客群规则: handle_kequn_rules 极优质客户: handle_extremely_high_quality_customer_rules 要客规则: handle_important_customer_rules 是否要客: handle_gov_vip_rules 极优质客户额度: handle_high_quality_customer_credit 客群额度: handle_customer_credit 流程描述: ``` 开始 --> [是否要客: 1] --> 要客规则 --> 结束 开始 --> [是否要客: 0] --> 极优质客户 [极优质客户: 拒绝] --> 通用规则 [极优质客户: 接受] --> 极优质客户额度 --> 结束 [通用规则: 0] --> 结束 [通用规则: 1] --> 客群规则 --> 客群额度 --> 结束 ``` 流程描述说明: 1、[满足条件: *] 为判断上一个节点的输出是否符合条件 请把```括号内的流程描述的内容转换为python代码,流程中的各个节点参考给定的函数内容与函数与节点对应关系,并构造测试数据data,代码样式如下。 from handle_general_rules import handle_general_rules from handle_kequn_rules import handle_kequn_rules from handle_extremely_high_quality_customer_rules import handle_extremely_high_quality_customer_rules from handle_important_customer_rules import handle_important_customer_rules from handle_gov_vip_rules import handle_gov_vip_rules from handle_high_quality_customer_credit import handle_high_quality_customer_credit from handle_customer_credit import handle_customer_credit def main(data: dict): 流程逻辑 if __name__ == "__main__": data = 测试数据 print(main(data)) 返回结果要求: 1、针对流程分支情况请参考给定的函数内容及函数的输出结果备注。 2、开始节点与结束节点,无实际意义,结束节点直接返回其上一个节点输出的结果。 3、只返回函数代码,不要多余的输出。 4、代码逻辑应严格按照流程描述中的逻辑,不要自行添加多余的逻辑。 5、代码的语法要符合python的语法规范,返回的代码应该是可执行的。