From 8dc0d7adde2336fbef9a8a8b7e54e86c6b3f98b7 Mon Sep 17 00:00:00 2001
From: jefferyzhao <375696853@qq.com>
Date: Fri, 1 Aug 2025 10:19:51 +0800
Subject: [PATCH] first commit
---
.idea/.gitignore | 8 +
.../inspectionProfiles/profiles_settings.xml | 6 +
.idea/misc.xml | 4 +
.idea/modules.xml | 8 +
.idea/撤案程序.iml | 8 +
README.md | 0
__pycache__/config.cpython-37.pyc | Bin 0 -> 603 bytes
__pycache__/utils.cpython-37.pyc | Bin 0 -> 5043 bytes
config.py | 20 ++
logs/withdrawcase.log | 131 ++++++++++++
utils.py | 201 ++++++++++++++++++
withdrawcase.py | 97 +++++++++
12 files changed, 483 insertions(+)
create mode 100644 .idea/.gitignore
create mode 100644 .idea/inspectionProfiles/profiles_settings.xml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/撤案程序.iml
create mode 100644 README.md
create mode 100644 __pycache__/config.cpython-37.pyc
create mode 100644 __pycache__/utils.cpython-37.pyc
create mode 100644 config.py
create mode 100644 logs/withdrawcase.log
create mode 100644 utils.py
create mode 100644 withdrawcase.py
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..081b737
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 数据源本地存储已忽略文件
+/dataSources/
+/dataSources.local.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..a2e120d
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..fdb355c
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/撤案程序.iml b/.idea/撤案程序.iml
new file mode 100644
index 0000000..d0876a7
--- /dev/null
+++ b/.idea/撤案程序.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e69de29
diff --git a/__pycache__/config.cpython-37.pyc b/__pycache__/config.cpython-37.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..236d7f5ba6c8881ac15c838e5b74c23eb1c4b345
GIT binary patch
literal 603
zcmZ9K&ubGw6vsDdnqSgNd-5XmT7PVJX0kt0L^Qezg%(LlB|{+0ug&gev)OhxNq6sp
z;z95q5Wzz|=w1C!a+NfHfp=$9#p0Wp$9vxoZyvmv*2YF%k#>Hk;^LyB{LGWTR*=CX
zdE$H0aRn>9fD62ci+l~Q@e(fab-d2YxXdfK!mGH-Yq-Yi9cA}McH2#oDBj=Oo6Tmb
z@1+wG4n^#eaG
z3(^1tZanZamp6&q>Q2ew(aGbGb-V2$web$rAkqwIq+aNIBm@YV8nBv{WnT5pHh~7z
z22!DBsi2|bTZY-x7y*X7+ccU&2#0DAIxr_3HL2W$F|J$8Fm%o24qp)}EK2_oW@v_>
zSA;SPT_Zp@b&?Z78<06XFBGy7hbBS}I@+zzYm~&IACbhx<&OQNZ6D9eB=UwL#kDEw
z|B;Gbl*>`yEM8qKe|%Ve`PRF9|LOAM>*dAU#rJnTHVz$c
aphoGu`d~EXlR!L_Uq*?yr7IQxU%vrR!?p7O
literal 0
HcmV?d00001
diff --git a/__pycache__/utils.cpython-37.pyc b/__pycache__/utils.cpython-37.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..af9b784685e7605be71be28a52ea809a7433b9c4
GIT binary patch
literal 5043
zcmc&&+ix7@6`%Xg&aT(%OAetXP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@ -0,0 +1,20 @@
+# 调用域名
+base_path = 'https://www.jiyuankeshang.com'
+# 密钥
+SECRET = '8jSj7EF1J6P1zzDeqzMxc-1c4EV3tTGyB5yljB2RWtk'
+# apikey
+apikey = '82bl1lhsgjzhd9ahBYvaMNVAncYYRkbE'
+# APIv3密钥
+v3_SECRET = '20230626yinjian13370189887jiyuan'
+# 服务器IP
+ip = '101.43.208.145'
+# 应用ID
+app_id = "6790ca1682b769eeefb022f2"
+# 车损任务表单ID
+vehicle_damage_id = "67d39b39baccd58c66507dfd"
+# 物损表单ID
+item_damage_id = "67dbe8bbbaccd58c66c606eb"
+# 人伤表单ID
+human_injury_id = "67dbbc83baccd58c66c1575a"
+# 车损任务表单ID
+lossseqcategory_id = "67eb42cfde8bbe9eed2733f3"
\ No newline at end of file
diff --git a/logs/withdrawcase.log b/logs/withdrawcase.log
new file mode 100644
index 0000000..c4e9e55
--- /dev/null
+++ b/logs/withdrawcase.log
@@ -0,0 +1,131 @@
+2025-04-22 17:36:14,732 - __main__ - INFO - 开始处理撤案请求 - 报案号: L2504180094
+2025-04-22 17:36:15,436 - utils - INFO - 任务处理完成 - lossseqno: L250418009402
+2025-04-22 17:36:15,529 - utils - INFO - 任务处理完成 - lossseqno: L250418009401
+2025-04-22 17:36:15,529 - aiohttp.access - INFO - 127.0.0.1 [22/Apr/2025:09:36:14 +0000] "POST /withdrawACase HTTP/1.1" 200 178 "-" "PostmanRuntime-ApipostRuntime/1.1.0"
+2025-04-22 17:53:29,557 - __main__ - INFO - 开始处理撤案请求 - 报案号: Z2504190142
+2025-04-22 17:53:29,711 - aiohttp.access - INFO - 127.0.0.1 [22/Apr/2025:09:53:29 +0000] "POST /withdrawACase HTTP/1.1" 200 178 "-" "PostmanRuntime-ApipostRuntime/1.1.0"
+2025-04-22 17:53:44,293 - __main__ - WARNING - 撤案请求不符合条件
+2025-04-22 17:53:44,294 - aiohttp.access - INFO - 127.0.0.1 [22/Apr/2025:09:53:44 +0000] "POST /withdrawACase HTTP/1.1" 200 247 "-" "PostmanRuntime-ApipostRuntime/1.1.0"
+2025-04-22 17:53:55,272 - __main__ - WARNING - 撤案请求不符合条件
+2025-04-22 17:53:55,272 - aiohttp.access - INFO - 127.0.0.1 [22/Apr/2025:09:53:55 +0000] "POST /withdrawACase HTTP/1.1" 200 247 "-" "PostmanRuntime-ApipostRuntime/1.1.0"
+2025-04-22 18:06:58,727 - __main__ - WARNING - 撤案请求不符合条件
+2025-04-22 18:06:58,727 - aiohttp.access - INFO - 127.0.0.1 [22/Apr/2025:10:06:58 +0000] "POST /withdrawACase HTTP/1.1" 200 247 "-" "PostmanRuntime-ApipostRuntime/1.1.0"
+2025-04-22 18:07:29,861 - __main__ - INFO - 开始处理撤案请求 - 报案号: L2504190105
+2025-04-22 18:07:30,592 - utils - INFO - 任务处理完成 - lossseqno: L250419010501
+2025-04-22 18:07:30,593 - aiohttp.access - INFO - 127.0.0.1 [22/Apr/2025:10:07:29 +0000] "POST /withdrawACase HTTP/1.1" 200 178 "-" "PostmanRuntime-ApipostRuntime/1.1.0"
+2025-04-22 18:09:47,633 - __main__ - INFO - 开始处理撤案请求 - 报案号: Z2504190104
+2025-04-22 18:09:47,737 - __main__ - ERROR - 撤案请求处理失败: cannot reuse already awaited coroutine
+Traceback (most recent call last):
+ File "E:/YinJian/安全统筹/撤案程序/withdrawcase.py", line 52, in withdraw_case
+ await async_withdraw_a_case(reportno, withdrawal_reason)
+ File "E:\YinJian\安全统筹\撤案程序\utils.py", line 143, in async_withdraw_a_case
+ lossseqcategory = await get_lossseqcategory_info(lossseq["lossseqtype"])
+RuntimeError: cannot reuse already awaited coroutine
+2025-04-22 18:09:47,738 - aiohttp.access - INFO - 127.0.0.1 [22/Apr/2025:10:09:47 +0000] "POST /withdrawACase HTTP/1.1" 400 238 "-" "PostmanRuntime-ApipostRuntime/1.1.0"
+2025-04-22 18:13:53,786 - __main__ - INFO - App started
+2025-04-22 18:13:53,803 - werkzeug - INFO - * Restarting with stat
+2025-04-22 18:13:54,593 - __main__ - INFO - App started
+2025-04-22 18:13:54,601 - werkzeug - WARNING - * Debugger is active!
+2025-04-22 18:13:54,608 - werkzeug - INFO - * Debugger PIN: 982-694-284
+2025-04-22 18:13:54,789 - werkzeug - INFO - * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
+2025-04-22 18:13:58,362 - __main__ - INFO - 收到请求 - withdrawal_opinion: 是, withdrawal_type: 重复报案,withdrawal_reason: 测试撤回,reportno: Z2504190104
+2025-04-22 18:13:58,362 - __main__ - INFO - 案件 Z2504190104开始撤案
+2025-04-22 18:13:59,269 - utils - INFO - 撤回成功,回写成功 - 报案号: Z2504190104, 流程实例ID: 6801e9b358967d5d3cf55df3
+2025-04-22 18:13:59,805 - utils - INFO - 撤回成功,回写成功 - 报案号: Z2504190104, 流程实例ID: 6801f5dfd62a2ed3b30c7697
+2025-04-22 18:13:59,806 - werkzeug - INFO - 127.0.0.1 - - [22/Apr/2025 18:13:59] "POST /withdrawACase HTTP/1.1" 200 -
+2025-04-22 18:15:40,337 - __main__ - INFO - App started
+2025-04-22 18:15:40,347 - werkzeug - INFO - * Restarting with stat
+2025-04-22 18:15:41,135 - __main__ - INFO - App started
+2025-04-22 18:15:41,142 - werkzeug - WARNING - * Debugger is active!
+2025-04-22 18:15:41,145 - werkzeug - INFO - * Debugger PIN: 982-694-284
+2025-04-22 18:15:41,265 - werkzeug - INFO - * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
+2025-04-22 18:16:02,715 - __main__ - INFO - 收到请求 - withdrawal_opinion: 是, withdrawal_type: 重复报案,withdrawal_reason: 测试撤回,reportno: Z2504190104
+2025-04-22 18:16:02,715 - __main__ - INFO - 案件 Z2504190104开始撤案
+2025-04-22 18:16:03,525 - werkzeug - INFO - 127.0.0.1 - - [22/Apr/2025 18:16:03] "POST /withdrawACase HTTP/1.1" 200 -
+2025-04-22 18:18:15,632 - __main__ - INFO - App started
+2025-04-22 18:18:15,641 - werkzeug - INFO - * Restarting with stat
+2025-04-22 18:18:16,467 - __main__ - INFO - App started
+2025-04-22 18:18:16,476 - werkzeug - WARNING - * Debugger is active!
+2025-04-22 18:18:16,480 - werkzeug - INFO - * Debugger PIN: 982-694-284
+2025-04-22 18:18:16,610 - werkzeug - INFO - * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
+2025-04-22 18:18:19,070 - __main__ - INFO - 收到请求 - withdrawal_opinion: 是, withdrawal_type: 重复报案,withdrawal_reason: 测试撤回,reportno: Z2504190104
+2025-04-22 18:18:19,071 - __main__ - INFO - 案件 Z2504190104开始撤案
+2025-04-22 18:18:19,795 - werkzeug - INFO - 127.0.0.1 - - [22/Apr/2025 18:18:19] "POST /withdrawACase HTTP/1.1" 200 -
+2025-04-22 18:21:24,854 - __main__ - INFO - App started
+2025-04-22 18:21:24,862 - werkzeug - INFO - * Restarting with stat
+2025-04-22 18:21:25,717 - __main__ - INFO - App started
+2025-04-22 18:21:25,725 - werkzeug - WARNING - * Debugger is active!
+2025-04-22 18:21:25,729 - werkzeug - INFO - * Debugger PIN: 982-694-284
+2025-04-22 18:21:25,865 - werkzeug - INFO - * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
+2025-04-22 18:21:27,954 - __main__ - INFO - 收到请求 - withdrawal_opinion: 是, withdrawal_type: 重复报案,withdrawal_reason: 测试撤回,reportno: Z2504190104
+2025-04-22 18:21:27,955 - __main__ - INFO - 案件 Z2504190104开始撤案
+2025-04-22 18:21:28,657 - werkzeug - INFO - 127.0.0.1 - - [22/Apr/2025 18:21:28] "POST /withdrawACase HTTP/1.1" 200 -
+2025-04-22 18:24:57,048 - werkzeug - INFO - * Detected change in 'E:\\YinJian\\安全统筹\\撤案程序\\utils.py', reloading
+2025-04-22 18:24:57,096 - werkzeug - INFO - * Restarting with stat
+2025-04-22 18:24:57,997 - __main__ - INFO - App started
+2025-04-22 18:24:58,007 - werkzeug - WARNING - * Debugger is active!
+2025-04-22 18:24:58,011 - werkzeug - INFO - * Debugger PIN: 982-694-284
+2025-04-22 18:24:58,157 - werkzeug - INFO - * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
+2025-04-22 18:25:32,374 - __main__ - INFO - 收到请求 - withdrawal_opinion: 是, withdrawal_type: 重复报案,withdrawal_reason: 测试撤回,reportno: Z2504190104
+2025-04-22 18:25:32,374 - __main__ - INFO - 案件 Z2504190104开始撤案
+2025-04-22 18:25:34,230 - utils - INFO - 撤回成功,回写成功 - 报案号: Z2504190104, 流程实例ID: 680311c258967d5d3c242231
+2025-04-22 18:25:34,231 - werkzeug - INFO - 127.0.0.1 - - [22/Apr/2025 18:25:34] "POST /withdrawACase HTTP/1.1" 200 -
+2025-04-22 18:29:23,156 - __main__ - INFO - App started
+2025-04-22 18:29:23,167 - werkzeug - INFO - * Restarting with stat
+2025-04-22 18:29:24,143 - __main__ - INFO - App started
+2025-04-22 18:29:24,152 - werkzeug - WARNING - * Debugger is active!
+2025-04-22 18:29:24,157 - werkzeug - INFO - * Debugger PIN: 982-694-284
+2025-04-22 18:29:24,306 - werkzeug - INFO - * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
+2025-04-22 18:29:56,980 - __main__ - INFO - App started
+2025-04-22 18:29:56,990 - werkzeug - INFO - * Restarting with stat
+2025-04-22 18:29:57,829 - __main__ - INFO - App started
+2025-04-22 18:29:57,836 - werkzeug - WARNING - * Debugger is active!
+2025-04-22 18:29:57,841 - werkzeug - INFO - * Debugger PIN: 982-694-284
+2025-04-22 18:29:57,979 - werkzeug - INFO - * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
+2025-04-22 18:30:00,458 - __main__ - INFO - 收到请求 - withdrawal_opinion: 是, withdrawal_type: 重复报案,withdrawal_reason: 测试撤回,reportno: Z2504190104
+2025-04-22 18:30:00,458 - __main__ - INFO - 案件 Z2504190104开始撤案
+2025-04-22 18:30:00,920 - utils - INFO - 完成流程查询
+status:0, instance_id:680311c258967d5d3c242231, workflow_entry_id:67d39b39baccd58c66507dfd
+2025-04-22 18:30:01,027 - utils - INFO - update_data请求 - url: https://www.jiyuankeshang.com/api/v5/app/entry/data/update, update_data_info: {'app_id': '6790ca1682b769eeefb022f2', 'entry_id': '67d39b39baccd58c66507dfd', 'data_id': '680311c258967d5d3c242231', 'is_start_trigger': True, 'data': {'withdrawal_opinion': '是', 'withdrawal_reason': '测试撤回'}}
+2025-04-22 18:30:02,262 - utils - INFO - 撤回成功,回写成功 - 报案号: Z2504190104, 流程实例ID: 680311c258967d5d3c242231
+2025-04-22 18:30:02,263 - werkzeug - INFO - 127.0.0.1 - - [22/Apr/2025 18:30:02] "POST /withdrawACase HTTP/1.1" 200 -
+2025-04-22 18:32:11,795 - __main__ - INFO - App started
+2025-04-22 18:32:11,804 - werkzeug - INFO - * Restarting with stat
+2025-04-22 18:32:12,724 - __main__ - INFO - App started
+2025-04-22 18:32:12,733 - werkzeug - WARNING - * Debugger is active!
+2025-04-22 18:32:12,736 - werkzeug - INFO - * Debugger PIN: 982-694-284
+2025-04-22 18:32:12,877 - werkzeug - INFO - * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
+2025-04-22 18:32:27,982 - __main__ - INFO - 收到请求 - withdrawal_opinion: 是, withdrawal_type: 重复报案,withdrawal_reason: 测试撤回,reportno: Z2504190104
+2025-04-22 18:32:27,982 - __main__ - INFO - 案件 Z2504190104开始撤案
+2025-04-22 18:32:28,408 - utils - INFO - 完成流程查询
+status:0, instance_id:680311c258967d5d3c242231, workflow_entry_id:67d39b39baccd58c66507dfd
+2025-04-22 18:32:28,521 - utils - INFO - update_data请求 - url: https://www.jiyuankeshang.com/api/v5/app/entry/data/update, update_data_info: {'app_id': '6790ca1682b769eeefb022f2', 'entry_id': '67d39b39baccd58c66507dfd', 'data_id': '680311c258967d5d3c242231', 'is_start_trigger': True, 'data': {'withdrawal_opinion': '是', 'withdrawal_reason': '测试撤回'}}
+2025-04-22 18:32:28,796 - utils - INFO - 撤回成功,回写成功 - 报案号: Z2504190104, 流程实例ID: 680311c258967d5d3c242231
+2025-04-22 18:32:28,797 - werkzeug - INFO - 127.0.0.1 - - [22/Apr/2025 18:32:28] "POST /withdrawACase HTTP/1.1" 200 -
+2025-04-22 18:33:40,426 - werkzeug - INFO - * Detected change in 'E:\\YinJian\\安全统筹\\撤案程序\\utils.py', reloading
+2025-04-22 18:33:40,472 - werkzeug - INFO - * Restarting with stat
+2025-04-22 18:33:41,377 - __main__ - INFO - App started
+2025-04-22 18:33:41,388 - werkzeug - WARNING - * Debugger is active!
+2025-04-22 18:33:41,395 - werkzeug - INFO - * Debugger PIN: 982-694-284
+2025-04-22 18:33:41,543 - werkzeug - INFO - * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
+2025-04-22 18:34:03,477 - __main__ - INFO - App started
+2025-04-22 18:34:03,486 - werkzeug - INFO - * Restarting with stat
+2025-04-22 18:34:04,310 - __main__ - INFO - App started
+2025-04-22 18:34:04,317 - werkzeug - WARNING - * Debugger is active!
+2025-04-22 18:34:04,321 - werkzeug - INFO - * Debugger PIN: 982-694-284
+2025-04-22 18:34:04,463 - werkzeug - INFO - * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
+2025-04-22 18:34:57,729 - __main__ - INFO - App started
+2025-04-22 18:34:57,738 - werkzeug - INFO - * Restarting with stat
+2025-04-22 18:34:58,573 - __main__ - INFO - App started
+2025-04-22 18:34:58,581 - werkzeug - WARNING - * Debugger is active!
+2025-04-22 18:34:58,585 - werkzeug - INFO - * Debugger PIN: 982-694-284
+2025-04-22 18:34:58,721 - werkzeug - INFO - * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
+2025-04-22 18:35:01,146 - __main__ - INFO - 收到请求 - withdrawal_opinion: 是, withdrawal_type: 重复报案,withdrawal_reason: 测试撤回,reportno: Z2504190104
+2025-04-22 18:35:01,146 - __main__ - INFO - 案件 Z2504190104开始撤案
+2025-04-22 18:35:01,609 - utils - INFO - 完成流程查询
+status:0, instance_id:680311c258967d5d3c242231, workflow_entry_id:67d39b39baccd58c66507dfd
+2025-04-22 18:35:01,751 - utils - INFO - update_data请求 - url: https://www.jiyuankeshang.com/api/v5/app/entry/data/update, update_data_info: {'app_id': '6790ca1682b769eeefb022f2', 'entry_id': '67d39b39baccd58c66507dfd', 'data_id': '680311c258967d5d3c242231', 'is_start_trigger': True, 'data': {'withdrawal_opinion': {'value': '是'}, 'withdrawal_reason': {'value': '测试撤回'}}}
+2025-04-22 18:35:02,007 - utils - INFO - 更新数据完成
+update_data_res: {'data': {'creator': {'name': '孙晓光', 'username': '990427', 'status': 1, 'type': 0, 'departments': [694], 'integrate_id': '990427'}, 'updater': {'name': '赵学敏', 'username': '#admin', 'status': 1, 'type': 0}, 'deleter': None, 'createTime': '2025-04-19T03:00:18.500Z', 'updateTime': '2025-04-22T10:35:02.241Z', 'deleteTime': None, 'flowState': 2, '_widget_1744270056982': '', '_widget_1744694460750': '', 'reportno': 'Z2504190104', 'lossseqno': 'Z250419010401', 'lossseqname': '吉文龙', 'lossseqtype': '三者车损任务', '_widget_1743147106474': '京BDB8933', '_widget_1743147106475': '金建', '_widget_1743147106476': 'J102车队', '_widget_1743147106477': '王培良', '_widget_1743147106478': '142702198705233032', '_widget_1743147106480': '2025-04-19T02:54:11.000Z', '_widget_1743493083737': '北京市丰台区', '_widget_1743147106479': '北京市丰台区西道口大门', '_widget_1744008719853': '', 'withdrawal_opinion': '是', 'withdrawal_reason': '测试撤回', '_widget_1743414161791': 'Z2504190104', '_widget_1742456058292': '', '_widget_1742459442618': '京BDB8933', '_widget_1742459442617': '', '_widget_1742459442616': 'LNBSC2GK8PD987911', '_widget_1742459442614': '', '_widget_1744008719854': None, '_widget_1742459442621': '', '_widget_1742459442622': '', '_widget_1742459442623': '', '_widget_1742459442624': '北汽EU52022款EVE-SGT网约出行版', '_widget_1742459442628': None, '_widget_1742459442629': None, '_widget_1742459442630': '无责', '_widget_1742459442631': 0, '_widget_1742459442632': '常规流程定损', '_widget_1742459442635': '王培良', '_widget_1743138813100': '', '_widget_1742459442636': 'C1', '_widget_1742459442642': '2014-07-21T16:00:00.000Z', '_widget_1742459442643': '2020-07-21T16:00:00.000Z', '_widget_1742459442644': '2030-07-21T16:00:00.000Z', '_widget_1742459442637': '17316258761', '_widget_1742459442638': '否', '_widget_1742459442639': '否', '_widget_1742459442640': '否', '_widget_1742459442649': '否', '_widget_1742459442650': '', '_widget_1742459442651': '', '_widget_1742459442652': '', '_widget_1742459442653': '', '_widget_1742459442654': '', '_widget_1742982074408': '', '_widget_1744075487453': [], '_widget_1742459442659': [{'_id': '680311c258967d5d3c242259', '_widget_1742784292228': '', '_widget_1742459442662': '', '_widget_1742459442663': '', '_widget_1742459442684': None, '_widget_1742459442683': None, '_widget_1742459442685': None, '_widget_1742459442686': None, '_widget_1742459442687': 0, '_widget_1742459442688': 1, '_widget_1742459442689': 0, '_widget_1742459442690': None, '_widget_1742459442691': 0, '_widget_1742459442692': 1, '_widget_1742459442693': 0, '_widget_1742459442694': None, '_widget_1742524502909': 0, '_widget_1742524502910': 1, '_widget_1742524502911': 0, '_widget_1742524502912': None, '_widget_1742459442748': '', '_widget_1742784292229': ''}], '_widget_1742459442732': [{'_id': '680311c258967d5d3c24225a', '_widget_1742780421492': '', '_widget_1742459442733': '', '_widget_1742459442735': None, '_widget_1742459442736': None, '_widget_1742459442737': None, '_widget_1742459442738': None, '_widget_1742459442739': 0, '_widget_1742459442740': 1, '_widget_1742459442741': 0, '_widget_1742459442742': None, '_widget_1742459442743': 0, '_widget_1742459442744': 1, '_widget_1742459442745': 0, '_widget_1742459442746': None, '_widget_1742524502946': 0, '_widget_1742524502947': 1, '_widget_1742524502948': 0, '_widget_1742524502949': None, '_widget_1742459442749': '', '_widget_1742780421493': ''}], '_widget_1742459442700': [], '_widget_1742459442679': [], '_widget_1742459442755': [], '_widget_1742465670210': None, '_widget_1742465670211': None, '_widget_1742465670212': None, '_widget_1742465670213': None, '_widget_1742465670214': None, '_widget_1742465670221': None, '_widget_1743125090423': '', '_widget_1743125090440': '', '_widget_1743125090428': None, '_widget_1743125090442': None, '_widget_1742465670216': None, '_widget_1742465670217': None, '_widget_1742465670218': None, '_widget_1742465670219': None, '_widget_1742465670220': None, '_widget_1742465670215': None, '_widget_1743125090438': '', '_widget_1744008720179': '', '_widget_1743125090425': '', '_widget_1743125090441': None, '_widget_1743125090447': None, '_widget_1742465670222': None, '_widget_1742465670223': None, '_widget_1742465670224': None, '_widget_1742465670225': None, '_widget_1742465670226': None, '_widget_1742465670227': None, '_widget_1743125090443': '', '_widget_1743125090445': '', '_widget_1743125090446': None, '_widget_1743125090429': None, '_widget_1742524502956': None, '_widget_1742524502957': None, '_widget_1742524502958': None, '_widget_1742524502959': None, '_widget_1742524502960': None, '_widget_1742524502961': None, '_widget_1742542371221': '', '_widget_1742780421482': '', '_widget_1742780421483': '', '_widget_1742780421520': '', '_widget_1742784292230': '', '_widget_1742966049705': '', '_widget_1744270794431': '', '_widget_1742465670199': '', '_widget_1742465670201': '', '_widget_1742465670202': None, '_widget_1742465670203': None, '_widget_1742465670204': None, '_widget_1742465670206': None, '_widget_1742465670205': None, '_widget_1742465670207': None, '_widget_1742465670208': None, '_widget_1742465670209': None, '_widget_1744273988054': [], '_widget_1742781620678': [], '_widget_1744008719851': None, '_widget_1744008719852': None, '_widget_1743147870991': {'name': '郭蕾', 'username': '665083', 'status': 1, 'type': 0, 'departments': [1776504], 'integrate_id': '665083'}, '_widget_1743061878354': None, '_widget_1743992751161': '未完成', '_widget_1744079933806': '', '_widget_1744079933826': '', '_widget_1744861379072': '', '_id': '680311c258967d5d3c242231', 'appId': '6790ca1682b769eeefb022f2', 'entryId': '67d39b39baccd58c66507dfd'}}
+2025-04-22 18:35:02,041 - utils - INFO - 撤回成功,回写成功 - 报案号: Z2504190104, 流程实例ID: 680311c258967d5d3c242231
+2025-04-22 18:35:02,042 - werkzeug - INFO - 127.0.0.1 - - [22/Apr/2025 18:35:02] "POST /withdrawACase HTTP/1.1" 200 -
diff --git a/utils.py b/utils.py
new file mode 100644
index 0000000..2209e57
--- /dev/null
+++ b/utils.py
@@ -0,0 +1,201 @@
+import time
+import requests
+import os
+import json
+from config import *
+import base64
+import urllib.parse
+from urllib.parse import urlparse, parse_qs
+import logging
+
+logger = logging.getLogger(__name__)
+
+def req_tool_jdy(url, data):
+ #调用简道云接口
+ headers = {"Authorization": f"Bearer {apikey}"}
+ while 1:
+ try:
+ res = requests.post(url, headers=headers, json=data, timeout=15, verify=False).json()
+ if "code" in res.keys():
+ logger.info(f"req_tool_jdy请求错误 - url: {url}, "
+ f"请求参数: {data}, 返回结果: {res}")
+ time.sleep(2)
+ continue
+ return res
+ except Exception as e:
+ print(e)
+
+
+def query_data(query_data_info):
+ #调用批量查询数据接口
+ query_data_url = f'{base_path}/api/v5/app/entry/data/list'
+ try:
+ query_data_res = req_tool_jdy(query_data_url, query_data_info)
+ return query_data_res
+ except Exception as e:
+ logger.error(f"query_data请求异常 - url: {query_data_url}, "
+ f"请求参数: {query_data_info}, 异常信息: {e}")
+ return None
+
+
+def update_data(instance_id, workflow_entry_id, withdrawal_reason):
+ # 调用更新数据接口
+ update_data_url = f'{base_path}/api/v5/app/entry/data/update'
+ update_data_info = {
+ "app_id": app_id,
+ "entry_id": workflow_entry_id,
+ "data_id": instance_id,
+ "is_start_trigger": True,
+ "data": {
+ "withdrawal_opinion": {"value": "是"},
+ "withdrawal_reason": {"value": withdrawal_reason}
+ }
+ }
+ try:
+ logger.info(f"update_data请求 - url: {update_data_url}, update_data_info: {update_data_info} ")
+ update_data_res = req_tool_jdy(update_data_url, update_data_info)
+ logger.info(f"更新数据完成\nupdate_data_res: {update_data_res}")
+ return update_data_res
+ except Exception as e:
+ logger.error(f"update_data请求异常 - url: {update_data_url}, "
+ f"请求参数: {update_data_info}, 异常信息: {e}")
+ return None
+
+
+def get_workflow(lossseqno, lossseqcategory):
+ # 调用查询流程信息接口
+ get_workflow_url = f'{base_path}/api/v6/workflow/instance/get'
+ if lossseqcategory == "车损":
+ workflow_entry_id = vehicle_damage_id
+ elif lossseqcategory == "物损":
+ workflow_entry_id = item_damage_id
+ elif lossseqcategory == "人伤":
+ workflow_entry_id = human_injury_id
+ else:
+ logger.error(f"未知的损失类别: {lossseqcategory}")
+ return None
+ query_data_info = {
+ "app_id": app_id,
+ "entry_id": workflow_entry_id,
+ "limit": 100,
+ "fields": ["_id", "appId", "entryId", "reportno", "lossseqno", "lossseqname", "lossseqtype"],
+ "filter": {
+ "rel": "and",
+ "cond": [
+ {
+ "field": "lossseqno",
+ "method": "eq",
+ "value": [lossseqno]
+ }
+ ]
+ }
+ }
+ try:
+ query_result = query_data(query_data_info)
+ instance_id = query_result['data'][0]['_id']
+ get_workflow_info = {
+ "instance_id": instance_id,
+ "tasks_type":1
+ }
+ get_workflow_res = req_tool_jdy(get_workflow_url, get_workflow_info)
+ logger.info(f"完成流程查询\nstatus:{get_workflow_res['status']}, instance_id:{instance_id}, workflow_entry_id:{workflow_entry_id}")
+ return {"status":get_workflow_res['status'], "instance_id":instance_id, "workflow_entry_id":workflow_entry_id}
+ except Exception as e:
+ logger.error(f"get_workflow请求异常 - url: {get_workflow_url}, "
+ f"请求参数: {query_data_info}, 异常信息: {e}")
+ return None
+
+
+def close_workflow(close_workflow_info):
+ # 调用结束流程接口
+ close_workflow_url = f'{base_path}/api/v1/workflow/instance/close'
+ try:
+ query_data_res = req_tool_jdy(close_workflow_url, close_workflow_info)
+ return query_data_res
+ except Exception as e:
+ logger.error(f"query_data请求异常 - url: {close_workflow_url}, "
+ f"请求参数: {close_workflow_info}, 异常信息: {e}")
+ return None
+
+
+def get_lossseqcategory_info(lossseqtype):
+ # 调用查询损失类别信息接口
+ get_lossseqcategory_info_url = f'{base_path}/api/v5/app/entry/data/list'
+ get_lossseqcategory_info_data = {
+ "app_id": app_id,
+ "entry_id": lossseqcategory_id,
+ "limit": 100,
+ "fields": ["_id", "appId", "entryId", "lossseqtype", "lossseqcategory"],
+ "filter": {
+ "rel": "and",
+ "cond": [
+ {
+ "field": "lossseqtype",
+ "method": "eq",
+ "value": [lossseqtype]
+ }
+ ]
+ }
+ }
+ query_data_res = req_tool_jdy(get_lossseqcategory_info_url, get_lossseqcategory_info_data)
+ if not query_data_res.get('data'):
+ logger.error("查询结果为空")
+ return None
+ lossseqcategory = query_data_res['data'][0]['lossseqcategory']
+ return lossseqcategory
+
+
+def withdraw_a_case(reportno, withdrawal_reason):
+ query_data_info = {
+ "app_id": app_id,
+ "entry_id": "67ab117682b769eeef2549df",
+ "limit": 100,
+ "fields": ["_id", "appId", "entryId", "reportno", "lossseq_info"],
+ "filter": {
+ "rel": "and",
+ "cond": [
+ {
+ "field": "reportno",
+ "method": "eq",
+ "value": [reportno]
+ }
+ ]
+ }
+ }
+ querydata = query_data(query_data_info)
+ # 提取所有 lossseqno 和 lossseqtype
+ query_result = []
+ for item in querydata['data']:
+ if not item.get('lossseq_info'):
+ logger.info(f"没有任务信息: {item}")
+ return 1
+ for lossseq in item['lossseq_info']:
+ lossseqcategory = get_lossseqcategory_info(lossseq['lossseqtype'])
+ query_result.append({
+ 'lossseqno': lossseq['lossseqno'],
+ 'lossseqtype': lossseq['lossseqtype'],
+ 'lossseqcategory': lossseqcategory
+ })
+
+ for task in query_result:
+ workflow_res = get_workflow(task['lossseqno'], task['lossseqcategory'])
+ if workflow_res['status'] == 0:
+ instance_id = workflow_res['instance_id']
+ workflow_entry_id = workflow_res['workflow_entry_id']
+ close_workflow_info = {
+ "instance_id": instance_id
+ }
+ close_workflow_res = close_workflow(close_workflow_info)
+ if close_workflow_res['status'] == "success":
+ update_data_res = update_data(instance_id, workflow_entry_id , withdrawal_reason)
+ if update_data_res['data'] :
+ logger.info(f"撤回成功,回写成功 - 报案号: {reportno}, 流程实例ID: {instance_id}")
+ return 1
+ else:
+ logger.error(f"撤回成功,回写失败 - 报案号: {reportno}, 流程实例ID: {instance_id}")
+ return 1
+ else:
+ logger.error(f"撤回失败 - 报案号: {reportno}, 流程实例ID: {instance_id}")
+ return 0
+
+
diff --git a/withdrawcase.py b/withdrawcase.py
new file mode 100644
index 0000000..413a10c
--- /dev/null
+++ b/withdrawcase.py
@@ -0,0 +1,97 @@
+from flask import Flask, request, redirect, abort, session, jsonify, json
+from utils import *
+import os, _thread, urllib, re
+from flask_cors import CORS
+import logging
+from logging.handlers import TimedRotatingFileHandler
+import datetime
+
+# 初始化Flask应用
+app = Flask(__name__)
+app.config['SECRET_KEY'] = os.urandom(24)
+CORS(app, supports_credentials=True)
+
+def setup_logging():
+ """配置日志系统,按天分割日志文件"""
+ # 创建日志目录
+ log_dir = "logs"
+ os.makedirs(log_dir, exist_ok=True)
+
+ # 设置日志格式
+ log_format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
+ formatter = logging.Formatter(log_format)
+
+ # 创建按天轮转的文件处理器
+ file_handler = TimedRotatingFileHandler(
+ filename=os.path.join(log_dir, 'withdrawcase.log'),
+ when='midnight', # 每天午夜轮转
+ interval=1, # 每天一个文件
+ backupCount=30, # 保留30天的日志
+ encoding='utf-8'
+ )
+ file_handler.setFormatter(formatter)
+ file_handler.setLevel(logging.INFO)
+
+ # 创建控制台处理器
+ console_handler = logging.StreamHandler()
+ console_handler.setFormatter(formatter)
+ console_handler.setLevel(logging.DEBUG)
+
+ # 获取根logger并配置
+ logger = logging.getLogger()
+ logger.setLevel(logging.DEBUG)
+ logger.addHandler(file_handler)
+ logger.addHandler(console_handler)
+
+
+# 初始化日志配置
+setup_logging()
+
+# 获取当前模块的 logger
+logger = logging.getLogger(__name__)
+logger.info("App started") # 会输出到文件和控制台
+
+@app.route('/withdrawACase', methods=['POST'])
+def withdrawCase():
+ try:
+ # 直接解析二进制数据为 JSON(不需要手动 decode + loads)
+ data = request.get_json() # Flask 提供的便捷方法
+ if data is None:
+ raise ValueError("Request data is not valid JSON")
+
+ # 安全获取 'data' 字段
+ result = data.get('data')
+ if result is None:
+ raise ValueError("Missing 'data' field in JSON")
+ withdrawal_opinion =result['withdrawal_opinion']
+ withdrawal_type = result['withdrawal_type']
+ withdrawal_reason = result['withdrawal_reason']
+ leader_opinion = result['leader_opinion']
+ reportno = result['reportno']
+
+ logger.info(f"收到请求 - withdrawal_opinion: {withdrawal_opinion}, "
+ f"withdrawal_type: {withdrawal_type},withdrawal_reason: {withdrawal_reason},reportno: {reportno}")
+
+ if withdrawal_opinion == "同意" and withdrawal_type:
+ # 调用函数
+ if withdrawal_type == "超出统筹服务范围" and leader_opinion in ("内保理赔", "机构审批统筹处理"):
+ # 处理超出统筹服务范围的撤案
+ logger.info(f"案件 {reportno}超出统筹服务范围,{leader_opinion}")
+ return jsonify({"status": "success", "message": "Case withdrawn successfully."})
+ else:
+ logger.info(f"案件 {reportno}开始撤案")
+ if withdraw_a_case(reportno, withdrawal_reason) ==1:
+ return jsonify({"status": "success", "message": "Case withdrawn successfully."})
+ else:
+ return jsonify({"status": "fail", "message": "Case mismatch."})
+
+ else:
+ logger.warning("案件不匹配 - withdrawal conditions not met")
+ return jsonify({"status": "success", "message": "Case mismatch."})
+ except Exception as e:
+ logger.error(f"Error in withdrawCase: {str(e)}", exc_info=True)
+ return jsonify({"status": "error", "message": str(e)})
+
+
+if __name__ == '__main__':
+ app.run(host="0.0.0.0", port=3012, processes=True)
\ No newline at end of file