From e0e234e2cf791881931620f55e1dc047615f7aae Mon Sep 17 00:00:00 2001 From: liubiren Date: Tue, 16 Dec 2025 01:25:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=B8=B8=E6=9B=B4=E6=96=B0=20from=20m?= =?UTF-8?q?ac=20mini(m1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 票据理赔自动化/main.py | 102 +++++++++++------------ 票据理赔自动化/rules/影像件识别使能.json | 52 ++++++------ 2 files changed, 77 insertions(+), 77 deletions(-) diff --git a/票据理赔自动化/main.py b/票据理赔自动化/main.py index 1472235..cfecd14 100644 --- a/票据理赔自动化/main.py +++ b/票据理赔自动化/main.py @@ -318,7 +318,7 @@ if __name__ == "__main__": # noinspection PyShadowingNames def query_individual_policy( - self, insurance_branch: str, certificate_type: str, certificate_number: str + self, insurer_company: str, certificate_type: str, certificate_number: str ) -> Optional[List[Dict[str, Any]]]: pass @@ -530,57 +530,53 @@ if __name__ == "__main__": # noinspection PyShadowingNames def image_recognize( - image_index, - image_guid, - image_format, - image_base64, - insurance_branch, - image_type, + image, + insurance_company, + insurer_company, ) -> None: """ 影像件识别并整合至赔案档案 - :param image_index: 影像件编号 - :param image_guid: 影像件唯一标识 - :param image_format: 影像件格式 - :param image_base64: 影像件BASE64编码 - :param insurance_branch: 保险分公司 - :param image_type: 影像件类型 + :param image: 影像件 + :param insurance_company: 投保公司 + :param insurer_company: 保险分公司 :return: 空 """ # TODO: 后续添加居民身份证(国徽面)和居民身份证(头像面)合并 # noinspection PyShadowingNames - def idcard_recognize( - image_guid, image_format, image_base64, image_type - ) -> None: + def identity_card_recognize(image, insurance_company, insurer_company) -> None: """ 居民身份证识别并整合至赔案档案 - :param image_guid: 影像件唯一标识 - :param image_format: 影像件格式 - :param image_base64: 影像件BASE64编码 - :param image_type: 影像件类型 + :param image: 影像件 + :param insurance_company: 投保公司 + :param insurer_company: 保险分公司 :return: 空 """ # 请求深圳快瞳居民身份证识别接口 response = http_client.post( url=(url := "https://ai.inspirvision.cn/s/api/ocr/identityCard"), headers={ - "X-RequestId-Header": image_guid + "X-RequestId-Header": image["影像件唯一标识"] }, # 以影像件唯一标识作为请求唯一标识,用于双方联查 data={ "token": authenticator.get_token( servicer="szkt" ), # 获取深圳快瞳访问令牌 - "imgBase64": f"data:image/{image_format.lstrip(".")};base64,{image_base64}", + "imgBase64": f"data:image/{image["影像件格式"].lstrip(".")};base64,{image["影像件BASE64编码"]}", }, # 深圳快瞳支持同时识别居民国徽面和头像面 - guid=md5((url + image_guid).encode("utf-8")).hexdigest().upper(), + guid=md5((url + image["影像件唯一标识"]).encode("utf-8")) + .hexdigest() + .upper(), ) # 若响应非成功则抛出异常 # TODO: 若响应非成功则流转至人工处理 if not (response.get("status") == 200 and response.get("code") == 0): raise RuntimeError("请求深圳快瞳居民身份证识别接口发生异常") - if image_type in ["居民身份证(国徽、头像面)", "居民身份证(国徽面)"]: + if image["影像件类型"] in [ + "居民身份证(国徽、头像面)", + "居民身份证(国徽面)", + ]: # noinspection PyTypeChecker dossier["出险人层"].update( { @@ -597,7 +593,10 @@ if __name__ == "__main__": } ) - if image_type in ["居民身份证(国徽、头像面)", "居民身份证(头像面)"]: + if image["影像件类型"] in [ + "居民身份证(国徽、头像面)", + "居民身份证(头像面)", + ]: # noinspection PyTypeChecker dossier["出险人层"].update( { @@ -620,9 +619,12 @@ if __name__ == "__main__": ) # 查询 + print(dossier["报案层"]) + print(1) + exit() # noinspection PyShadowingNames - def bankcard_recognize(image_guid, image_format, image_base64) -> None: + def bank_card_recognize(image_guid, image_format, image_base64) -> None: """ 银行卡识别并整合至赔案档案 :param image_guid: 影像件唯一标识 @@ -1363,14 +1365,14 @@ if __name__ == "__main__": # 影像件识别使能检查,若影像件不识别则跳过 if not recognition_enable.evaluate( { - "insurance_branch": insurance_branch, - "image_type": image_type, + "insurer_company": insurer_company, + "image_type": image["影像件类型"], } )["result"]["recognition_enable"]: return # 根据影像件类型匹配影像件识别方法 - match image_type: + match image["影像件类型"]: # TODO: 后续添加居民户口簿识别和整合方法 case "居民户口簿": raise RuntimeError("暂不支持居民户口簿") @@ -1378,27 +1380,32 @@ if __name__ == "__main__": "居民身份证(国徽、头像面)" | "居民身份证(国徽面)" | "居民身份证(头像面)" ): # 居民身份证识别并整合至赔案档案 - idcard_recognize(image_guid, image_format, image_base64, image_type) + identity_card_recognize(image, insurance_company, insurer_company) # TODO: 后续添加居民户口簿识别和整合方法 case "中国港澳台地区及境外护照": raise RuntimeError("暂不支持中国港澳台地区及境外护照") case "银行卡": # 银行卡识别并整合至赔案档案 - bankcard_recognize(image_guid, image_format, image_base64) - # TODO: 暂仅支持增值税发票识别和购药及就医类型为药店购药整合至赔案档案,后续逐步添加 + bank_card_recognize(image_guid, image_format, image_base64) + # TODO: 暂仅支持增值税发票识别且购药及就医类型为药店购药整合至赔案档案,后续逐步添加 case "增值税发票" | "医疗门诊收费票据" | "医疗住院收费票据": # 票据识别并整合至赔案档案 receipt_recognize(image_guid, image_format, image_base64, image_type) # 遍历工作目录中赔案目录并创建赔案档案(模拟自动化域就待自动化任务创建理赔档案) for case_path in [x for x in directory_path.iterdir() if x.is_dir()]: - # 初始化赔案档案(实际报案层包括保险分公司名称、报案渠道、批次号、报案号和报案时间等) - # 报案渠道包括:保司定义,例如中银项目包括总行和各地分行驻场报案和普康宝自助报案等 + # 初始化赔案档案(保险公司将提供投保公司、保险分公司和报案时间等,TPA作业系统签收后生成赔案号) dossier = { "报案层": { + "投保公司": ( + insurance_company := "中国银行股份有限公司昆山分行" + ), # 指定投保公司 "保险分公司": ( - insurance_branch := "中银保险有限公司广东分公司" - ), # 设定:保险分公司为中银保险有限公司广东分公司 + insurer_company := "中银保险有限公司苏州分公司" + ), # 指定保险分公司 + "报案时间": datetime(2025, 7, 25, 12, 0, 0).strftime( + "%Y-%m-%d %H:%M:%S" + ), # 指定报案时间 "赔案号": (case_number := case_path.stem), # 设定:赔案目录名称为赔案号 }, "影像件层": [], @@ -1406,7 +1413,7 @@ if __name__ == "__main__": "受益人层": {}, } - # 遍历赔案目录中影像件路径对象 + # 遍历赔案目录中影像件 for image_index, image_path in enumerate( sorted( [ @@ -1422,7 +1429,7 @@ if __name__ == "__main__": image = { "影像件编号": image_index, "影像件地址": image_path.as_posix(), # 将影像件路径对象转为字符串 - "影像件名称": (image_name := image_path.stem), + "影像件名称": image_path.stem, "影像件格式": (image_format := image_path.suffix.lower()), } @@ -1444,7 +1451,7 @@ if __name__ == "__main__": dossier["影像件层"].append(image) - # 就影像件层按照影像件类型排序 + # 就影像件按照影像件类型排序 dossier["影像件层"].sort( key=lambda x: [ "居民户口簿", @@ -1460,22 +1467,15 @@ if __name__ == "__main__": "银行卡", "其它", ].index(x["影像件类型"]) - ) - - print(dossier) - exit() + ) # 优先居民户口簿、居民身份证、中国港澳台地区及境外护照和理赔申请书以查询被保人信息 + # 遍历影像件层中影像件 for image in dossier["影像件层"]: - pass - # 影像件识别并整合至赔案档案 image_recognize( - image_index, - image_guid, - image_format, - image_base64, - insurance_branch, - image_type, + image, + insurance_company, + insurer_company, ) """ diff --git a/票据理赔自动化/rules/影像件识别使能.json b/票据理赔自动化/rules/影像件识别使能.json index 7338f35..9b46e0a 100644 --- a/票据理赔自动化/rules/影像件识别使能.json +++ b/票据理赔自动化/rules/影像件识别使能.json @@ -2,117 +2,118 @@ "contentType": "application/vnd.gorules.decision", "nodes": [ { + "id": "a56fc802-839b-4310-999e-054fcfdac452", + "name": "request", "type": "inputNode", "content": { "schema": "" }, - "id": "a56fc802-839b-4310-999e-054fcfdac452", - "name": "request", "position": { "x": 110, "y": 114 } }, { + "id": "47992630-e8f6-4475-8307-437dc2b93acd", + "name": "response", "type": "outputNode", "content": { "schema": "" }, - "id": "47992630-e8f6-4475-8307-437dc2b93acd", - "name": "response", "position": { "x": 750, "y": 114 } }, { + "id": "a1146fe1-b0dd-4efd-b0b7-11e000bc569f", + "name": "decisionTable", "type": "decisionTableNode", "content": { - "hitPolicy": "first", "rules": [ { "_id": "8e5bf894-22b5-429c-ab9d-1ed541cc562b", "_description": "", "88d06a40-06ea-472b-9f8f-f4daf6468c52": "\"居民户口簿\"", "a2fc744f-930d-43e0-b5cf-824a5928c7f1": "true", - "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司广东分公司\"" + "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司苏州分公司\"" }, { "_id": "14b4347e-2d98-4e7f-80c6-2c1f70db7f38", "_description": "", "88d06a40-06ea-472b-9f8f-f4daf6468c52": "\"居民身份证(国徽、头像面)\"", "a2fc744f-930d-43e0-b5cf-824a5928c7f1": "true", - "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司广东分公司\"" + "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司苏州分公司\"" }, { "_id": "f01654f5-fa1a-480b-bfbe-a6dc13120aa9", "_description": "", "88d06a40-06ea-472b-9f8f-f4daf6468c52": "\"居民身份证(国徽面)\"", "a2fc744f-930d-43e0-b5cf-824a5928c7f1": "true", - "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司广东分公司\"" + "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司苏州分公司\"" }, { "_id": "25cf23fb-c150-4f2a-b896-8ca25f6107e0", "_description": "", "88d06a40-06ea-472b-9f8f-f4daf6468c52": "\"居民身份证(头像面)\"", "a2fc744f-930d-43e0-b5cf-824a5928c7f1": "true", - "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司广东分公司\"" + "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司苏州分公司\"" }, { "_id": "87984822-cd34-4819-b83f-78741b5b0b6a", "_description": "", "88d06a40-06ea-472b-9f8f-f4daf6468c52": "\"中国港澳台地区及境外护照\"", "a2fc744f-930d-43e0-b5cf-824a5928c7f1": "true", - "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司广东分公司\"" + "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司苏州分公司\"" }, { "_id": "8f414db5-1f47-4814-9c81-7e036f0da92a", "_description": "中银保险有限公司广东分公司就银行卡不识别", "88d06a40-06ea-472b-9f8f-f4daf6468c52": "\"银行卡\"", "a2fc744f-930d-43e0-b5cf-824a5928c7f1": "false", - "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司广东分公司\"" + "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司苏州分公司\"" }, { "_id": "f64b5e4c-74e3-41ae-96d3-eec72fa512dd", "_description": "", "88d06a40-06ea-472b-9f8f-f4daf6468c52": "\"增值税发票\"", "a2fc744f-930d-43e0-b5cf-824a5928c7f1": "true", - "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司广东分公司\"" + "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司苏州分公司\"" }, { "_id": "ffdfd273-2c0a-4d49-86f0-a4f20572d522", "_description": "", "88d06a40-06ea-472b-9f8f-f4daf6468c52": "\"医疗费用清单\"", "a2fc744f-930d-43e0-b5cf-824a5928c7f1": "true", - "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司广东分公司\"" + "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司苏州分公司\"" }, { "_id": "6120b722-abd9-4f17-a97b-45eaa854961f", "_description": "", "88d06a40-06ea-472b-9f8f-f4daf6468c52": "\"门诊收费票据\"", "a2fc744f-930d-43e0-b5cf-824a5928c7f1": "true", - "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司广东分公司\"" + "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司苏州分公司\"" }, { "_id": "3048396c-b175-44ee-9bcf-8e83aea55280", "_description": "", "88d06a40-06ea-472b-9f8f-f4daf6468c52": "\"住院收费票据\"", "a2fc744f-930d-43e0-b5cf-824a5928c7f1": "true", - "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司广东分公司\"" + "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司苏州分公司\"" }, { "_id": "9ff5abf3-516e-4b13-a353-b47b4ee29107", "_description": "", "88d06a40-06ea-472b-9f8f-f4daf6468c52": "\"理赔申请书\"", "a2fc744f-930d-43e0-b5cf-824a5928c7f1": "true", - "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司广东分公司\"" + "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司苏州分公司\"" }, { "_id": "f0d20445-48f1-4980-8d3d-0173fc906293", "_description": "中银保险有限公司就其它影像件类型不识别", "88d06a40-06ea-472b-9f8f-f4daf6468c52": "\"其它\"", "a2fc744f-930d-43e0-b5cf-824a5928c7f1": "false", - "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司广东分公司\"" + "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b": "\"中银保险有限公司苏州分公司\"" }, { "_id": "9ed5dfc9-85c9-4617-9e54-dfdb8c0c2049", @@ -125,8 +126,8 @@ "inputs": [ { "id": "edfeddf0-41bd-4cb7-8cb2-a3c4afa7fc3b", - "name": "保险总公司", - "field": "insurance_branch" + "name": "保险分公司", + "field": "insurer_company" }, { "id": "88d06a40-06ea-472b-9f8f-f4daf6468c52", @@ -141,13 +142,12 @@ "field": "recognition_enable" } ], - "passThrough": true, + "hitPolicy": "first", "inputField": null, "outputPath": null, + "passThrough": true, "executionMode": "single" }, - "id": "a1146fe1-b0dd-4efd-b0b7-11e000bc569f", - "name": "decisionTable", "position": { "x": 430, "y": 114 @@ -157,15 +157,15 @@ "edges": [ { "id": "62727c6a-05e8-48c7-997d-f49de0f5334b", + "type": "edge", "sourceId": "a1146fe1-b0dd-4efd-b0b7-11e000bc569f", - "targetId": "47992630-e8f6-4475-8307-437dc2b93acd", - "type": "edge" + "targetId": "47992630-e8f6-4475-8307-437dc2b93acd" }, { "id": "cdd9b38a-928e-4169-bb07-4a1edfecd11b", + "type": "edge", "sourceId": "a56fc802-839b-4310-999e-054fcfdac452", - "targetId": "a1146fe1-b0dd-4efd-b0b7-11e000bc569f", - "type": "edge" + "targetId": "a1146fe1-b0dd-4efd-b0b7-11e000bc569f" } ] } \ No newline at end of file