20251114
This commit is contained in:
1 parent
f3a7c981d5
commit
48f119d087
5 files changed
+1196
-131
No files matched your search
+22
-6
@@ -2222,9 +2222,17 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 13,
|
||||||
"id": "6f9768ce-2ef5-4253-9fc6-49dbdcf00a19",
|
"id": "6f9768ce-2ef5-4253-9fc6-49dbdcf00a19",
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-11-14T05:36:30.068876Z",
|
||||||
|
"iopub.status.busy": "2025-11-14T05:36:30.068084Z",
|
||||||
|
"iopub.status.idle": "2025-11-14T05:36:30.079053Z",
|
||||||
|
"shell.execute_reply": "2025-11-14T05:36:30.078052Z",
|
||||||
|
"shell.execute_reply.started": "2025-11-14T05:36:30.068800Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import json\n",
|
"import json\n",
|
||||||
@@ -2576,15 +2584,23 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 14,
|
||||||
"id": "9ecd3ad8-c8af-4f3e-90e5-1618fea905a4",
|
"id": "9ecd3ad8-c8af-4f3e-90e5-1618fea905a4",
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-11-14T05:36:39.675837Z",
|
||||||
|
"iopub.status.busy": "2025-11-14T05:36:39.675165Z",
|
||||||
|
"iopub.status.idle": "2025-11-14T05:36:39.706916Z",
|
||||||
|
"shell.execute_reply": "2025-11-14T05:36:39.706427Z",
|
||||||
|
"shell.execute_reply.started": "2025-11-14T05:36:39.675772Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import openpyxl\n",
|
"import openpyxl\n",
|
||||||
"\n",
|
"\n",
|
||||||
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp']\n",
|
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp']\n",
|
||||||
"filename = 'data/result_南京化工-3.json'\n",
|
"filename = 'data/result_新疆油田采油工艺研究院2511.json'\n",
|
||||||
"with open(filename,'r') as fl:\n",
|
"with open(filename,'r') as fl:\n",
|
||||||
" dict1 = json.load(fl) \n",
|
" dict1 = json.load(fl) \n",
|
||||||
"data_list = []\n",
|
"data_list = []\n",
|
||||||
@@ -2666,7 +2682,7 @@
|
|||||||
" list6.append('')\n",
|
" list6.append('')\n",
|
||||||
" i+=1\n",
|
" i+=1\n",
|
||||||
" data_list.append(list6)\n",
|
" data_list.append(list6)\n",
|
||||||
"filename = 'data/南京化工中医情况明细表(202510).xlsx'\n",
|
"filename = 'data/新疆油田采油工艺研究院情况明细表(202511).xlsx'\n",
|
||||||
"wb = openpyxl.Workbook()\n",
|
"wb = openpyxl.Workbook()\n",
|
||||||
"sheet = wb.active\n",
|
"sheet = wb.active\n",
|
||||||
"#sheet.append(title)\n",
|
"#sheet.append(title)\n",
|
||||||
|
|||||||
+238
-12
@@ -3186,10 +3186,26 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 57,
|
||||||
"id": "7b79c7bb-ce87-44b2-95b1-01e9cb66d5f0",
|
"id": "7b79c7bb-ce87-44b2-95b1-01e9cb66d5f0",
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
"outputs": [],
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-11-13T05:44:27.934101Z",
|
||||||
|
"iopub.status.busy": "2025-11-13T05:44:27.933541Z",
|
||||||
|
"iopub.status.idle": "2025-11-13T05:44:27.991293Z",
|
||||||
|
"shell.execute_reply": "2025-11-13T05:44:27.990805Z",
|
||||||
|
"shell.execute_reply.started": "2025-11-13T05:44:27.934053Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"759\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"import json\n",
|
"import json\n",
|
||||||
"import datetime\n",
|
"import datetime\n",
|
||||||
@@ -3200,7 +3216,7 @@
|
|||||||
"filename = 'data/北海炼化人员2025.json'\n",
|
"filename = 'data/北海炼化人员2025.json'\n",
|
||||||
"with open(filename,'r') as fl:\n",
|
"with open(filename,'r') as fl:\n",
|
||||||
" dict1 = json.load(fl) \n",
|
" dict1 = json.load(fl) \n",
|
||||||
"filename = 'data/marks_20251110.csv'\n",
|
"filename = 'data/marks_20251113.csv'\n",
|
||||||
"re_ta = My.get_result(filename,dict1)\n",
|
"re_ta = My.get_result(filename,dict1)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
@@ -3210,6 +3226,58 @@
|
|||||||
"print(len(re_ta))"
|
"print(len(re_ta))"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "a7d2b973-cc05-4f06-9be8-54268a29dd84",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 导入手工数据"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 60,
|
||||||
|
"id": "458725a6-3b5b-48a1-af90-cd4d0bda3635",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-11-13T05:51:01.753768Z",
|
||||||
|
"iopub.status.busy": "2025-11-13T05:51:01.752925Z",
|
||||||
|
"iopub.status.idle": "2025-11-13T05:51:01.812931Z",
|
||||||
|
"shell.execute_reply": "2025-11-13T05:51:01.812381Z",
|
||||||
|
"shell.execute_reply.started": "2025-11-13T05:51:01.753692Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"ok\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import openpyxl\n",
|
||||||
|
"import json\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"wb = openpyxl.load_workbook('data/北海炼化俯卧撑手工数据(2025年).xlsx')\n",
|
||||||
|
"sheet = wb.active\n",
|
||||||
|
"# sheets = wb.sheetnames\n",
|
||||||
|
"filename = 'data/result_北海2025.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl) \n",
|
||||||
|
"\n",
|
||||||
|
"for n in range(2, sheet.max_row+1):\n",
|
||||||
|
" code = str(sheet.cell(n, 1).value)\n",
|
||||||
|
" dict1[code].setdefault('pushup',{})\n",
|
||||||
|
" dict1[code]['pushup']['成绩'] = str(sheet.cell(n,2).value)\n",
|
||||||
|
"filename = 'data/result_北海2025.json'\n",
|
||||||
|
"with open(filename, 'w') as fl:\n",
|
||||||
|
" json.dump(dict1, fl, ensure_ascii=False)\n",
|
||||||
|
"print('ok')"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "12b33ee8-2b4e-4b85-9301-4fbcadf4129c",
|
"id": "12b33ee8-2b4e-4b85-9301-4fbcadf4129c",
|
||||||
@@ -3220,9 +3288,17 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 53,
|
||||||
"id": "ca079428-2df9-4f15-b141-2c83cd0efaf5",
|
"id": "ca079428-2df9-4f15-b141-2c83cd0efaf5",
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-11-11T09:33:39.776590Z",
|
||||||
|
"iopub.status.busy": "2025-11-11T09:33:39.775794Z",
|
||||||
|
"iopub.status.idle": "2025-11-11T09:33:39.805844Z",
|
||||||
|
"shell.execute_reply": "2025-11-11T09:33:39.805299Z",
|
||||||
|
"shell.execute_reply.started": "2025-11-11T09:33:39.776523Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import json\n",
|
"import json\n",
|
||||||
@@ -3258,7 +3334,7 @@
|
|||||||
" list2 = [k,v['人数'],v['体测人数']]\n",
|
" list2 = [k,v['人数'],v['体测人数']]\n",
|
||||||
" list1.append(list2)\n",
|
" list1.append(list2)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"filename = 'data/北海炼化部门测试情况(截至20251110).xlsx'\n",
|
"filename = 'data/北海炼化部门测试情况(截至20251111).xlsx'\n",
|
||||||
"wb = openpyxl.Workbook()\n",
|
"wb = openpyxl.Workbook()\n",
|
||||||
"sheet = wb.active\n",
|
"sheet = wb.active\n",
|
||||||
"sheet.append(title)\n",
|
"sheet.append(title)\n",
|
||||||
@@ -3278,9 +3354,17 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 54,
|
||||||
"id": "482a3a46-31a6-433b-88a8-7cad228f853a",
|
"id": "482a3a46-31a6-433b-88a8-7cad228f853a",
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-11-11T09:33:43.302910Z",
|
||||||
|
"iopub.status.busy": "2025-11-11T09:33:43.302201Z",
|
||||||
|
"iopub.status.idle": "2025-11-11T09:33:43.341073Z",
|
||||||
|
"shell.execute_reply": "2025-11-11T09:33:43.339404Z",
|
||||||
|
"shell.execute_reply.started": "2025-11-11T09:33:43.302855Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import json\n",
|
"import json\n",
|
||||||
@@ -3321,6 +3405,63 @@
|
|||||||
"## 问卷人员统计"
|
"## 问卷人员统计"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 65,
|
||||||
|
"id": "0bbf2cb6-e7d9-4d0d-beba-77ac50082f05",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-11-13T06:17:23.628451Z",
|
||||||
|
"iopub.status.busy": "2025-11-13T06:17:23.627881Z",
|
||||||
|
"iopub.status.idle": "2025-11-13T06:17:23.729071Z",
|
||||||
|
"shell.execute_reply": "2025-11-13T06:17:23.728586Z",
|
||||||
|
"shell.execute_reply.started": "2025-11-13T06:17:23.628397Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import csv\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"import time\n",
|
||||||
|
"from datetime import date\n",
|
||||||
|
"\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"filename = 'data/sql_20251113.csv'\n",
|
||||||
|
"with open(filename,'r',newline='') as csv_file:\n",
|
||||||
|
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||||||
|
" header = next(fl) \n",
|
||||||
|
" for line in fl:\n",
|
||||||
|
" list1.append(line)\n",
|
||||||
|
"filename = 'data/北海炼化人员2025.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict3 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"phone = {}\n",
|
||||||
|
"for k,v in dict3.items():\n",
|
||||||
|
" if 'phone' in v.keys():\n",
|
||||||
|
" phone[str(v['phone'])] = k\n",
|
||||||
|
"dict2 = {}\n",
|
||||||
|
"list3 = []\n",
|
||||||
|
"for item in list1: \n",
|
||||||
|
" phone_num = str(item[0])[2:] \n",
|
||||||
|
" if phone_num in phone:\n",
|
||||||
|
" list2 = []\n",
|
||||||
|
" content = json.loads(json.loads(item[1])) \n",
|
||||||
|
" code = phone[phone_num]\n",
|
||||||
|
" list2 = [code,dict3[code]['name'],dict3[code]['unit'],phone_num]\n",
|
||||||
|
" list3.append(list2)\n",
|
||||||
|
"title =['测试编号','姓名','部门','手机号码']\n",
|
||||||
|
"filename = 'data/北海炼化问卷人员(截至20251113).xlsx'\n",
|
||||||
|
"wb = openpyxl.Workbook()\n",
|
||||||
|
"sheet = wb.active\n",
|
||||||
|
"sheet.append(title)\n",
|
||||||
|
"for row in list3:\n",
|
||||||
|
" sheet.append(row)\n",
|
||||||
|
" \n",
|
||||||
|
"wb.save(filename)"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 43,
|
"execution_count": 43,
|
||||||
@@ -3411,9 +3552,17 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 62,
|
||||||
"id": "f67f63d1-be8a-47ef-b95f-bdfca9725838",
|
"id": "f67f63d1-be8a-47ef-b95f-bdfca9725838",
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-11-13T06:00:49.916395Z",
|
||||||
|
"iopub.status.busy": "2025-11-13T06:00:49.915561Z",
|
||||||
|
"iopub.status.idle": "2025-11-13T06:00:50.043798Z",
|
||||||
|
"shell.execute_reply": "2025-11-13T06:00:50.043247Z",
|
||||||
|
"shell.execute_reply.started": "2025-11-13T06:00:49.916323Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import json\n",
|
"import json\n",
|
||||||
@@ -3476,10 +3625,87 @@
|
|||||||
"wb.save(filename)"
|
"wb.save(filename)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "9cb5f45e-15e5-4cf5-b82f-38e33729bad8",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 导出测试人员信息"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 61,
|
||||||
|
"id": "3a0f5f5d-2bf0-46c8-b796-661e2f44c60c",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-11-13T05:51:13.926738Z",
|
||||||
|
"iopub.status.busy": "2025-11-13T05:51:13.925983Z",
|
||||||
|
"iopub.status.idle": "2025-11-13T05:51:14.123325Z",
|
||||||
|
"shell.execute_reply": "2025-11-13T05:51:14.122772Z",
|
||||||
|
"shell.execute_reply.started": "2025-11-13T05:51:13.926666Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"\n",
|
||||||
|
"items = ['lung','grip','flexion','jump','pushup','situp','balance','reaction','step']\n",
|
||||||
|
"title = ['编号','姓名','性别','单位','部门','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/result_北海2025.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/北海炼化人员2025.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict2 = json.load(fl)\n",
|
||||||
|
" \n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"for k, v in dict1.items():\n",
|
||||||
|
" list2 = []\n",
|
||||||
|
" list2.append(str(k).rjust(5,'0'))\n",
|
||||||
|
" list2.append(v['name']) \n",
|
||||||
|
" list2.append(dict2[k]['sex'])\n",
|
||||||
|
" list2.append(dict2[k]['unit'])\n",
|
||||||
|
" list2.append(dict2[k]['birth'])\n",
|
||||||
|
" if 'phone' in v.keys():\n",
|
||||||
|
" list2.append(dict2[k]['phone'])\n",
|
||||||
|
" else:\n",
|
||||||
|
" list2.append('')\n",
|
||||||
|
" \n",
|
||||||
|
" if 'bmi' in v.keys():\n",
|
||||||
|
" height = v['bmi']['成绩'].split(',')[0]\n",
|
||||||
|
" weight = v['bmi']['成绩'].split(',')[1]\n",
|
||||||
|
" list2.append(height)\n",
|
||||||
|
" list2.append(weight)\n",
|
||||||
|
" else:\n",
|
||||||
|
" list2.append('')\n",
|
||||||
|
" list2.append('')\n",
|
||||||
|
" for item in items:\n",
|
||||||
|
" if item in v.keys():\n",
|
||||||
|
" list2.append(v[item]['成绩']) \n",
|
||||||
|
" elif item =='name':\n",
|
||||||
|
" list2.append(v[item])\n",
|
||||||
|
" else:\n",
|
||||||
|
" list2.append('')\n",
|
||||||
|
" \n",
|
||||||
|
" list1.append(list2)\n",
|
||||||
|
"filename = 'data/北海炼化体测情况表(2025年).xlsx'\n",
|
||||||
|
"wb = openpyxl.Workbook()\n",
|
||||||
|
"sheet = wb.active\n",
|
||||||
|
"sheet.append(title)\n",
|
||||||
|
"for row in list1:\n",
|
||||||
|
" sheet.append(row)\n",
|
||||||
|
" \n",
|
||||||
|
"wb.save(filename)"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "9cfbb3cd-8c5f-4353-b2fe-1eab7fa9ba6e",
|
"id": "4b58eeae-089d-4007-ab5a-1e1e9e088dd7",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": []
|
"source": []
|
||||||
|
|||||||
+348
-18
@@ -80,6 +80,57 @@
|
|||||||
"print(len(person),'ok')"
|
"print(len(person),'ok')"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 39,
|
||||||
|
"id": "cac3736a-56da-403b-9e62-5caaf989a6d4",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-11-14T05:28:56.646944Z",
|
||||||
|
"iopub.status.busy": "2025-11-14T05:28:56.646299Z",
|
||||||
|
"iopub.status.idle": "2025-11-14T05:28:58.033233Z",
|
||||||
|
"shell.execute_reply": "2025-11-14T05:28:58.032644Z",
|
||||||
|
"shell.execute_reply.started": "2025-11-14T05:28:56.646884Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"72 ok\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import openpyxl\n",
|
||||||
|
"import json\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"wb = openpyxl.load_workbook('data/采油院11月份测试名单.xlsx',data_only=True)\n",
|
||||||
|
"sheet = wb.active\n",
|
||||||
|
"# sheets = wb.sheetnames\n",
|
||||||
|
"person = {}\n",
|
||||||
|
"\n",
|
||||||
|
"for n in range(2, sheet.max_row+1):\n",
|
||||||
|
" code = int(sheet.cell(n, 2).value)\n",
|
||||||
|
" person.setdefault(str(code), {})\n",
|
||||||
|
" dict1 = {}\n",
|
||||||
|
" dict1['name'] = sheet.cell(n, 1).value\n",
|
||||||
|
" dict1['sex'] = sheet.cell(n, 4).value\n",
|
||||||
|
" if sheet.cell(n,8).value is not None:\n",
|
||||||
|
" dict1['unit'] = sheet.cell(n, 8).value\n",
|
||||||
|
" else:\n",
|
||||||
|
" dict1['unit'] = ''\n",
|
||||||
|
" dict1['birth'] = str(sheet.cell(n, 5).value).replace('/','-').split(' ')[0]\n",
|
||||||
|
" dict1['phone'] = sheet.cell(n,7).value \n",
|
||||||
|
" person[code] = dict1\n",
|
||||||
|
"filename = 'data/新疆油田采油工艺研究院-202511.json'\n",
|
||||||
|
"with open(filename, 'w') as fl:\n",
|
||||||
|
" json.dump(person, fl, ensure_ascii=False)\n",
|
||||||
|
"print(len(person),'ok')"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "6bcd45c2-10af-4d5f-9e0b-5cd1df4f7a7f",
|
"id": "6bcd45c2-10af-4d5f-9e0b-5cd1df4f7a7f",
|
||||||
@@ -142,6 +193,48 @@
|
|||||||
"print(len(re_ta))"
|
"print(len(re_ta))"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 40,
|
||||||
|
"id": "925f7152-b365-4df8-8d98-73569aef68f8",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-11-14T05:30:21.558180Z",
|
||||||
|
"iopub.status.busy": "2025-11-14T05:30:21.557445Z",
|
||||||
|
"iopub.status.idle": "2025-11-14T05:30:21.572875Z",
|
||||||
|
"shell.execute_reply": "2025-11-14T05:30:21.571867Z",
|
||||||
|
"shell.execute_reply.started": "2025-11-14T05:30:21.558103Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"35\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import datetime\n",
|
||||||
|
"import csv\n",
|
||||||
|
"from datetime import date\n",
|
||||||
|
"import my_module as My\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/新疆油田采油工艺研究院-202511.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl) \n",
|
||||||
|
"filename = 'data/marks_20251114-1.csv'\n",
|
||||||
|
"re_ta = My.get_result(filename,dict1)\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/result_新疆油田采油工艺研究院2511.json'\n",
|
||||||
|
"with open(filename,'w') as fl:\n",
|
||||||
|
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
||||||
|
"print(len(re_ta))"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "6d381859-6d21-45d2-8313-55ebbabf8bd4",
|
"id": "6d381859-6d21-45d2-8313-55ebbabf8bd4",
|
||||||
@@ -192,6 +285,64 @@
|
|||||||
"print('ok!') "
|
"print('ok!') "
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 41,
|
||||||
|
"id": "0e71f6b8-e17e-49f8-a577-7a2eb6f5e994",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-11-14T05:30:31.220354Z",
|
||||||
|
"iopub.status.busy": "2025-11-14T05:30:31.219652Z",
|
||||||
|
"iopub.status.idle": "2025-11-14T05:30:31.233956Z",
|
||||||
|
"shell.execute_reply": "2025-11-14T05:30:31.232979Z",
|
||||||
|
"shell.execute_reply.started": "2025-11-14T05:30:31.220290Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"ok!\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import time\n",
|
||||||
|
"import my_module as My\n",
|
||||||
|
"\n",
|
||||||
|
"#list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','height','weight']\n",
|
||||||
|
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp']\n",
|
||||||
|
"filename = 'data/result_新疆油田采油工艺研究院2511.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict2 = json.load(fl) \n",
|
||||||
|
"for k, v in dict2.items():\n",
|
||||||
|
" #print(k)\n",
|
||||||
|
" if v['sex'] == '男':\n",
|
||||||
|
" sex = 'M'\n",
|
||||||
|
" else:\n",
|
||||||
|
" sex = 'F' \n",
|
||||||
|
" if 'bmi' in v.keys():\n",
|
||||||
|
" #bmi_data = v['height']['成绩'].split()[0]+','+ v['weight']['成绩'].split()[0]\n",
|
||||||
|
" bmi_data = v['bmi']['成绩']\n",
|
||||||
|
" data1 = {'code':k,'sex':sex,'age':v['age'],'item':'HeightWeight','result':bmi_data}\n",
|
||||||
|
" dict2[k]['bmi'] = {}\n",
|
||||||
|
" dict2[k]['bmi']['成绩'] = bmi_data\n",
|
||||||
|
" dict2[k]['bmi']['score'] = My.cal_bmi(data1)\n",
|
||||||
|
" for item_en in list_item:\n",
|
||||||
|
" if item_en in v.keys(): \n",
|
||||||
|
" data1 = {'code':k,'sex':sex,'age':v['age'],'item':item_en,'result':float(v[item_en]['成绩'].split()[0])}\n",
|
||||||
|
" #print(k,v['name'])\n",
|
||||||
|
" dict2[k][item_en]['score'] = My.cal_score(data1)\n",
|
||||||
|
" #print(k,v[item_en]['成绩'],cal_score(data1))\n",
|
||||||
|
"\n",
|
||||||
|
"filename = f'data/result_新疆油田采油工艺研究院2511.json'\n",
|
||||||
|
"with open(filename,'w') as fl:\n",
|
||||||
|
" json.dump(dict2,fl , ensure_ascii=False) \n",
|
||||||
|
"print('ok!') "
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "d034a61d-1fbd-417b-99bd-277e43ebb678",
|
"id": "d034a61d-1fbd-417b-99bd-277e43ebb678",
|
||||||
@@ -503,6 +654,97 @@
|
|||||||
"print(nn)"
|
"print(nn)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "6eea20f8-b457-455e-8409-5c8cdaa1efb6",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### 导入问卷信息(202511)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 42,
|
||||||
|
"id": "83872322-129c-410d-a9a3-ef6f4fe8dcde",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-11-14T05:31:42.228026Z",
|
||||||
|
"iopub.status.busy": "2025-11-14T05:31:42.227253Z",
|
||||||
|
"iopub.status.idle": "2025-11-14T05:31:42.243026Z",
|
||||||
|
"shell.execute_reply": "2025-11-14T05:31:42.242577Z",
|
||||||
|
"shell.execute_reply.started": "2025-11-14T05:31:42.227955Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"35\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import csv\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"import time\n",
|
||||||
|
"from datetime import date\n",
|
||||||
|
"\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"filename = 'data/sql_20251114.csv'\n",
|
||||||
|
"with open(filename,'r',newline='') as csv_file:\n",
|
||||||
|
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||||||
|
" header = next(fl) \n",
|
||||||
|
" for line in fl:\n",
|
||||||
|
" list1.append(line)\n",
|
||||||
|
"filename = 'data/新疆油田采油工艺研究院-202511.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict3 = json.load(fl)\n",
|
||||||
|
"filename = 'data/result_新疆油田采油工艺研究院2511.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"phone = {}\n",
|
||||||
|
"for k,v in dict3.items():\n",
|
||||||
|
" if 'phone' in v.keys():\n",
|
||||||
|
" phone[str(v['phone'])] = k\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"nn = 0\n",
|
||||||
|
"for item in list1:\n",
|
||||||
|
" dict2 = {}\n",
|
||||||
|
" \n",
|
||||||
|
" phone_num = str(item[0])[2:]\n",
|
||||||
|
" if phone_num in phone:\n",
|
||||||
|
" content = json.loads(json.loads(item[1]))\n",
|
||||||
|
" tcm = []\n",
|
||||||
|
" spine = []\n",
|
||||||
|
" for i in range(0,60):\n",
|
||||||
|
" tcm.append(0)\n",
|
||||||
|
" for i in range(0,26):\n",
|
||||||
|
" spine.append(0)\n",
|
||||||
|
" for k, v in content.items(): \n",
|
||||||
|
" if 'tcm' in k:\n",
|
||||||
|
" i = int(k[3:])\n",
|
||||||
|
" tcm[i-1] = int(v)\n",
|
||||||
|
" if 'spine' in k:\n",
|
||||||
|
" i = int(k[5:])\n",
|
||||||
|
" if i<23:\n",
|
||||||
|
" spine[i-1] = int(v)\n",
|
||||||
|
" else:\n",
|
||||||
|
" spine[i] = int(v)\n",
|
||||||
|
" \n",
|
||||||
|
" code = phone[phone_num]\n",
|
||||||
|
" if code in dict3.keys(): \n",
|
||||||
|
" dict1[code]['tcm'] = tcm \n",
|
||||||
|
" dict1[code]['spine'] = spine\n",
|
||||||
|
"\n",
|
||||||
|
"with open(filename,'w') as fl:\n",
|
||||||
|
" json.dump(dict1, fl, ensure_ascii=False)\n",
|
||||||
|
"print(len(dict1))"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "8d5f4103-0d1e-4711-b324-ece360f8dcd3",
|
"id": "8d5f4103-0d1e-4711-b324-ece360f8dcd3",
|
||||||
@@ -579,6 +821,90 @@
|
|||||||
"print(i)"
|
"print(i)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 43,
|
||||||
|
"id": "694ad38e-755e-4885-94a9-c157ddc96564",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-11-14T05:32:21.311002Z",
|
||||||
|
"iopub.status.busy": "2025-11-14T05:32:21.310252Z",
|
||||||
|
"iopub.status.idle": "2025-11-14T05:32:41.401453Z",
|
||||||
|
"shell.execute_reply": "2025-11-14T05:32:41.400670Z",
|
||||||
|
"shell.execute_reply.started": "2025-11-14T05:32:21.310932Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"35\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import requests\n",
|
||||||
|
"import json\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"headers = {\n",
|
||||||
|
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
|
||||||
|
" }\n",
|
||||||
|
"filename = 'data/result_新疆油田采油工艺研究院2511.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"file_path ='./新疆油田采油工艺研究院2511/'\n",
|
||||||
|
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
||||||
|
"i=0\n",
|
||||||
|
"list2 = []\n",
|
||||||
|
"for k, v in dict1.items():\n",
|
||||||
|
" list1 = []\n",
|
||||||
|
" mydata = {}\n",
|
||||||
|
" \n",
|
||||||
|
" id = str(k).rjust(4,\"0\")\n",
|
||||||
|
" mydata['path'] = file_path+id+'-'+ v['name']+'.pdf'\n",
|
||||||
|
" mydata['title'] = '新疆油田采油工艺研究院'\n",
|
||||||
|
" mydata['subtitle'] = v['unit']\n",
|
||||||
|
" mydata['id'] = id\n",
|
||||||
|
" mydata['name'] = v['name']\n",
|
||||||
|
" if v['sex'] == '男':\n",
|
||||||
|
" mydata['gender'] = 'male'\n",
|
||||||
|
" else:\n",
|
||||||
|
" mydata['gender'] = 'female'\n",
|
||||||
|
" \n",
|
||||||
|
" mydata['month'] = v['month']\n",
|
||||||
|
" mydata['fits'] = {}\n",
|
||||||
|
" survey_list = ['tcm','psy57','spine']\n",
|
||||||
|
" for item in survey_list:\n",
|
||||||
|
" if item in v.keys():\n",
|
||||||
|
" mydata.setdefault('surveys',{})\n",
|
||||||
|
" mydata['surveys'][item] = v[item]\n",
|
||||||
|
" \n",
|
||||||
|
" \n",
|
||||||
|
" #mydata['fits'] = {}\n",
|
||||||
|
" for item in list_item:\n",
|
||||||
|
" if item in v.keys():\n",
|
||||||
|
" mydata.setdefault('fits',{})\n",
|
||||||
|
" if item in ['lung','pushup','step','situp']:\n",
|
||||||
|
" mark = v[item]['成绩'].split()[0].split('.')[0]\n",
|
||||||
|
" else:\n",
|
||||||
|
" mark = v[item]['成绩'].split()[0]\n",
|
||||||
|
" mydata['fits'][item] = {'mark':mark,'score':v[item]['score']}\n",
|
||||||
|
" #if len(mydata['fits']) >2 or len(mydata['surveys']) >0:\n",
|
||||||
|
" if len(mydata['fits']) >2 : \n",
|
||||||
|
" list1.append(mydata)\n",
|
||||||
|
" list2.append([k,v['name']])\n",
|
||||||
|
" i+=1\n",
|
||||||
|
" x = requests.post('http://localhost:3003', data = json.dumps(list1), headers=headers)\n",
|
||||||
|
" #print(id,v['name'],x.text)\n",
|
||||||
|
" #print(mydata)\n",
|
||||||
|
" #x.close()\n",
|
||||||
|
"print(i)"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "ffb6c02a-8ae1-4332-96ca-ce541bfbf0be",
|
"id": "ffb6c02a-8ae1-4332-96ca-ce541bfbf0be",
|
||||||
@@ -656,15 +982,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 21,
|
"execution_count": 26,
|
||||||
"id": "5c4df7b1-ced9-49c1-a9e4-dc2a54f201bc",
|
"id": "73d28b6a-91be-47bb-bf76-1b8c26faafb5",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
"execution": {
|
||||||
"iopub.execute_input": "2025-11-06T02:15:58.258398Z",
|
"iopub.execute_input": "2025-11-11T04:31:28.041103Z",
|
||||||
"iopub.status.busy": "2025-11-06T02:15:58.257685Z",
|
"iopub.status.busy": "2025-11-11T04:31:28.040413Z",
|
||||||
"iopub.status.idle": "2025-11-06T02:15:58.274276Z",
|
"iopub.status.idle": "2025-11-11T04:31:28.055394Z",
|
||||||
"shell.execute_reply": "2025-11-06T02:15:58.273471Z",
|
"shell.execute_reply": "2025-11-11T04:31:28.054740Z",
|
||||||
"shell.execute_reply.started": "2025-11-06T02:15:58.258334Z"
|
"shell.execute_reply.started": "2025-11-11T04:31:28.041040Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -702,7 +1028,7 @@
|
|||||||
" spine = []\n",
|
" spine = []\n",
|
||||||
" for i in range(0,60):\n",
|
" for i in range(0,60):\n",
|
||||||
" tcm.append(0)\n",
|
" tcm.append(0)\n",
|
||||||
" for i in range(0,25):\n",
|
" for i in range(0,26):\n",
|
||||||
" spine.append(0)\n",
|
" spine.append(0)\n",
|
||||||
" for k, v in content.items(): \n",
|
" for k, v in content.items(): \n",
|
||||||
" if 'tcm' in k:\n",
|
" if 'tcm' in k:\n",
|
||||||
@@ -710,7 +1036,11 @@
|
|||||||
" tcm[i-1] = int(v)\n",
|
" tcm[i-1] = int(v)\n",
|
||||||
" if 'spine' in k:\n",
|
" if 'spine' in k:\n",
|
||||||
" i = int(k[5:])\n",
|
" i = int(k[5:])\n",
|
||||||
" spine[i-1] = int(v)\n",
|
" if i<23:\n",
|
||||||
|
" spine[i-1] = int(v)\n",
|
||||||
|
" else:\n",
|
||||||
|
" spine[i] = int(v)\n",
|
||||||
|
" \n",
|
||||||
" code = phone\n",
|
" code = phone\n",
|
||||||
" dict1.setdefault(code,{})\n",
|
" dict1.setdefault(code,{})\n",
|
||||||
" dict1[code]['name'] = content['name']\n",
|
" dict1[code]['name'] = content['name']\n",
|
||||||
@@ -723,7 +1053,7 @@
|
|||||||
" dict1[code]['tcm'] = tcm \n",
|
" dict1[code]['tcm'] = tcm \n",
|
||||||
" dict1[code]['spine'] = spine\n",
|
" dict1[code]['spine'] = spine\n",
|
||||||
" \n",
|
" \n",
|
||||||
"filename = 'data/result_新疆油田-2511.json'\n",
|
"filename = 'data/result_新疆油田-2511-1.json'\n",
|
||||||
"\n",
|
"\n",
|
||||||
"with open(filename,'w') as fl:\n",
|
"with open(filename,'w') as fl:\n",
|
||||||
" json.dump(dict1, fl, ensure_ascii=False)\n",
|
" json.dump(dict1, fl, ensure_ascii=False)\n",
|
||||||
@@ -740,15 +1070,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 23,
|
"execution_count": 27,
|
||||||
"id": "cdbeb2f8-2784-4688-806a-6506799941cb",
|
"id": "cdbeb2f8-2784-4688-806a-6506799941cb",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
"execution": {
|
||||||
"iopub.execute_input": "2025-11-06T02:20:43.542803Z",
|
"iopub.execute_input": "2025-11-11T04:31:58.919201Z",
|
||||||
"iopub.status.busy": "2025-11-06T02:20:43.542192Z",
|
"iopub.status.busy": "2025-11-11T04:31:58.918605Z",
|
||||||
"iopub.status.idle": "2025-11-06T02:20:50.673104Z",
|
"iopub.status.idle": "2025-11-11T04:32:06.150780Z",
|
||||||
"shell.execute_reply": "2025-11-06T02:20:50.671961Z",
|
"shell.execute_reply": "2025-11-11T04:32:06.149803Z",
|
||||||
"shell.execute_reply.started": "2025-11-06T02:20:43.542746Z"
|
"shell.execute_reply.started": "2025-11-11T04:31:58.919144Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -769,11 +1099,11 @@
|
|||||||
"headers = {\n",
|
"headers = {\n",
|
||||||
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
|
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
|
||||||
" }\n",
|
" }\n",
|
||||||
"filename = 'data/result_新疆油田-2511.json'\n",
|
"filename = 'data/result_新疆油田-2511-1.json'\n",
|
||||||
"with open(filename,'r') as fl:\n",
|
"with open(filename,'r') as fl:\n",
|
||||||
" dict1 = json.load(fl)\n",
|
" dict1 = json.load(fl)\n",
|
||||||
"list1 = []\n",
|
"list1 = []\n",
|
||||||
"file_path ='./新疆油田-2511/'\n",
|
"file_path ='./新疆油田-2511-1/'\n",
|
||||||
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
||||||
"i=0\n",
|
"i=0\n",
|
||||||
"list2 = []\n",
|
"list2 = []\n",
|
||||||
|
|||||||
+222
-10
@@ -10,15 +10,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 18,
|
"execution_count": 25,
|
||||||
"id": "270e8c57-36d3-476c-8c50-4d8bc38a918a",
|
"id": "270e8c57-36d3-476c-8c50-4d8bc38a918a",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
"execution": {
|
||||||
"iopub.execute_input": "2025-11-09T05:35:45.149501Z",
|
"iopub.execute_input": "2025-11-13T08:43:12.873509Z",
|
||||||
"iopub.status.busy": "2025-11-09T05:35:45.148976Z",
|
"iopub.status.busy": "2025-11-13T08:43:12.873249Z",
|
||||||
"iopub.status.idle": "2025-11-09T05:35:45.291101Z",
|
"iopub.status.idle": "2025-11-13T08:43:13.076138Z",
|
||||||
"shell.execute_reply": "2025-11-09T05:35:45.290596Z",
|
"shell.execute_reply": "2025-11-13T08:43:13.075593Z",
|
||||||
"shell.execute_reply.started": "2025-11-09T05:35:45.149453Z"
|
"shell.execute_reply.started": "2025-11-13T08:43:12.873486Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"1299 ok\n"
|
"1301 ok\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -48,7 +48,8 @@
|
|||||||
" dict1['sex'] = sheet.cell(n, 5).value\n",
|
" dict1['sex'] = sheet.cell(n, 5).value\n",
|
||||||
" dict1['birth'] = str(sheet.cell(n, 6).value).replace('/','-').split(' ')[0] \n",
|
" dict1['birth'] = str(sheet.cell(n, 6).value).replace('/','-').split(' ')[0] \n",
|
||||||
" dict1['unit'] = sheet.cell(n, 3).value\n",
|
" dict1['unit'] = sheet.cell(n, 3).value\n",
|
||||||
" dict1['phone'] = str(sheet.cell(n, 7).value)\n",
|
" if sheet.cell(n, 7).value is not None:\n",
|
||||||
|
" dict1['phone'] = str(sheet.cell(n, 7).value)\n",
|
||||||
" person[code] = dict1\n",
|
" person[code] = dict1\n",
|
||||||
"filename = 'data/沧州炼化人员.json'\n",
|
"filename = 'data/沧州炼化人员.json'\n",
|
||||||
"with open(filename, 'w') as fl:\n",
|
"with open(filename, 'w') as fl:\n",
|
||||||
@@ -169,13 +170,224 @@
|
|||||||
"id": "f9ef800a-b760-4933-b7a4-c69edef593d0",
|
"id": "f9ef800a-b760-4933-b7a4-c69edef593d0",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"## 导出俯卧撑成绩"
|
"## 获取人员测试成绩"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 29,
|
||||||
|
"id": "ccb2fe86-c588-4373-85df-37adda55c694",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-11-14T04:02:24.632013Z",
|
||||||
|
"iopub.status.busy": "2025-11-14T04:02:24.631372Z",
|
||||||
|
"iopub.status.idle": "2025-11-14T04:02:24.726424Z",
|
||||||
|
"shell.execute_reply": "2025-11-14T04:02:24.725880Z",
|
||||||
|
"shell.execute_reply.started": "2025-11-14T04:02:24.631959Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"1175\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import datetime\n",
|
||||||
|
"import csv\n",
|
||||||
|
"from datetime import date\n",
|
||||||
|
"import my_module1 as My\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/沧州炼化人员.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl) \n",
|
||||||
|
"filename = 'data/marks_20251114.csv'\n",
|
||||||
|
"re_ta = My.get_result(filename,dict1)\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/result_沧州炼化.json'\n",
|
||||||
|
"with open(filename,'w') as fl:\n",
|
||||||
|
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
||||||
|
"print(len(re_ta))"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "a446935a-db14-41d5-9420-d1a5ddd0e548",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 统计各部门测试情况"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 30,
|
||||||
|
"id": "503c30bb-c537-43f6-b3c7-a1eeff4c313f",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-11-14T04:02:34.921004Z",
|
||||||
|
"iopub.status.busy": "2025-11-14T04:02:34.920268Z",
|
||||||
|
"iopub.status.idle": "2025-11-14T04:02:34.953734Z",
|
||||||
|
"shell.execute_reply": "2025-11-14T04:02:34.953246Z",
|
||||||
|
"shell.execute_reply.started": "2025-11-14T04:02:34.920949Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/result_沧州炼化.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/沧州炼化人员.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict2 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"dict3 = {}\n",
|
||||||
|
"for k, v in dict2.items():\n",
|
||||||
|
" unit = v['unit']\n",
|
||||||
|
" #sub_unit = v['sub_unit']\n",
|
||||||
|
" dict3.setdefault(unit,{})\n",
|
||||||
|
" dict3[unit].setdefault('人数',0)\n",
|
||||||
|
" dict3[unit].setdefault('体测人数',0)\n",
|
||||||
|
" #dict3[unit].setdefault(sub_unit,0)\n",
|
||||||
|
" #dict3[unit][sub_unit] = dict3[unit][sub_unit] + 1\n",
|
||||||
|
" dict3[unit]['人数'] = dict3[unit]['人数'] + 1\n",
|
||||||
|
"\n",
|
||||||
|
"title =['单位','体测人数']\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"for k,v in dict1.items(): \n",
|
||||||
|
" unit = v['unit']\n",
|
||||||
|
" #sub_unit = v['sub_unit']\n",
|
||||||
|
" #dict3[unit][sub_unit] = dict3[unit][sub_unit] - 1\n",
|
||||||
|
" dict3[unit].setdefault('体测人数',0)\n",
|
||||||
|
" dict3[unit]['体测人数'] = dict3[unit]['体测人数'] + 1\n",
|
||||||
|
"for k, v in dict3.items():\n",
|
||||||
|
" list2 = [k,v['人数'],v['体测人数']]\n",
|
||||||
|
" list1.append(list2)\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/沧州炼化部门测试情况(截至20251114).xlsx'\n",
|
||||||
|
"wb = openpyxl.Workbook()\n",
|
||||||
|
"sheet = wb.active\n",
|
||||||
|
"sheet.append(title)\n",
|
||||||
|
"for row in list1:\n",
|
||||||
|
" sheet.append(row)\n",
|
||||||
|
" \n",
|
||||||
|
"wb.save(filename)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "e04d391d-57cb-4ece-a77b-b940950f6717",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 统计未体测人员明细表"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 31,
|
||||||
|
"id": "57de7845-76f2-4cdc-88a9-eb869acb28a5",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-11-14T04:02:42.621335Z",
|
||||||
|
"iopub.status.busy": "2025-11-14T04:02:42.620669Z",
|
||||||
|
"iopub.status.idle": "2025-11-14T04:02:42.655530Z",
|
||||||
|
"shell.execute_reply": "2025-11-14T04:02:42.654876Z",
|
||||||
|
"shell.execute_reply.started": "2025-11-14T04:02:42.621305Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/result_沧州炼化.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/沧州炼化人员.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict2 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"\n",
|
||||||
|
"i = 1\n",
|
||||||
|
"for k, v in dict2.items(): \n",
|
||||||
|
" if k not in dict1.keys():\n",
|
||||||
|
" list2 = [i,k,v['name'],v['unit']]\n",
|
||||||
|
" i+=1\n",
|
||||||
|
" list1.append(list2)\n",
|
||||||
|
"#print(list1)\n",
|
||||||
|
"filename = f'data/沧州炼化未测试人员名单(截至20251114).xlsx'\n",
|
||||||
|
"title = ['序号','员工编号','姓名','部门']\n",
|
||||||
|
"wb = openpyxl.Workbook()\n",
|
||||||
|
"sheet = wb.active\n",
|
||||||
|
"sheet.append(title)\n",
|
||||||
|
"for row in list1:\n",
|
||||||
|
" sheet.append(row) \n",
|
||||||
|
"wb.save(filename)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "9d39b9e8-7932-4f99-88da-0becf48d73e0",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 统计体测人员项目数"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 34,
|
||||||
|
"id": "c2ca861f-54ca-4312-bf24-20dbc2f3f2e6",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-11-14T04:11:04.381187Z",
|
||||||
|
"iopub.status.busy": "2025-11-14T04:11:04.380519Z",
|
||||||
|
"iopub.status.idle": "2025-11-14T04:11:04.413211Z",
|
||||||
|
"shell.execute_reply": "2025-11-14T04:11:04.412250Z",
|
||||||
|
"shell.execute_reply.started": "2025-11-14T04:11:04.381125Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"1553238 齐金永 公用工程部 13231725301 2\n",
|
||||||
|
"1553763 王鑫 应急救援中心 15632778668 2\n",
|
||||||
|
"1552999 赵崇胜 储运部 13722775060 2\n",
|
||||||
|
"01553836 王成柱 炼油一部 13111760190 1\n",
|
||||||
|
"01553839 徐振柱 炼油一部 17772650508 1\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/result_沧州炼化.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"xm = ['bmi','lung','grip','flexion','jump','pushup','balance','reaction','step','situp']\n",
|
||||||
|
"for k,v in dict1.items():\n",
|
||||||
|
" list1 = []\n",
|
||||||
|
" for item in v.keys():\n",
|
||||||
|
" if item in xm:\n",
|
||||||
|
" list1.append(item)\n",
|
||||||
|
" if len(list1) <3:\n",
|
||||||
|
" print(k,v['name'],v['unit'],v['phone'],len(list1))"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "ccb2fe86-c588-4373-85df-37adda55c694",
|
"id": "e6dea90d-2b60-4ff5-9598-a49f41b6ab24",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": []
|
"source": []
|
||||||
|
|||||||
+366
-85
@@ -1831,26 +1831,10 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 55,
|
"execution_count": null,
|
||||||
"id": "a8438d1b-ec3d-41e3-9c28-d44e88378c75",
|
"id": "a8438d1b-ec3d-41e3-9c28-d44e88378c75",
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"execution": {
|
"outputs": [],
|
||||||
"iopub.execute_input": "2025-11-07T05:30:46.511261Z",
|
|
||||||
"iopub.status.busy": "2025-11-07T05:30:46.510560Z",
|
|
||||||
"iopub.status.idle": "2025-11-07T05:30:46.695916Z",
|
|
||||||
"shell.execute_reply": "2025-11-07T05:30:46.695456Z",
|
|
||||||
"shell.execute_reply.started": "2025-11-07T05:30:46.511196Z"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"1564 ok\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import openpyxl\n",
|
"import openpyxl\n",
|
||||||
"import json\n",
|
"import json\n",
|
||||||
@@ -1959,26 +1943,10 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 60,
|
"execution_count": null,
|
||||||
"id": "9caa8291-7d48-483b-992a-45f244567600",
|
"id": "9caa8291-7d48-483b-992a-45f244567600",
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"execution": {
|
"outputs": [],
|
||||||
"iopub.execute_input": "2025-11-07T06:15:57.737800Z",
|
|
||||||
"iopub.status.busy": "2025-11-07T06:15:57.737061Z",
|
|
||||||
"iopub.status.idle": "2025-11-07T06:15:57.818225Z",
|
|
||||||
"shell.execute_reply": "2025-11-07T06:15:57.817635Z",
|
|
||||||
"shell.execute_reply.started": "2025-11-07T06:15:57.737730Z"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"1564\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import openpyxl\n",
|
"import openpyxl\n",
|
||||||
"import json\n",
|
"import json\n",
|
||||||
@@ -2235,17 +2203,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 66,
|
"execution_count": null,
|
||||||
"id": "80c2b300-6a4f-4223-9b7a-9b8978ad4609",
|
"id": "80c2b300-6a4f-4223-9b7a-9b8978ad4609",
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2025-11-10T09:49:26.870477Z",
|
|
||||||
"iopub.status.busy": "2025-11-10T09:49:26.869856Z",
|
|
||||||
"iopub.status.idle": "2025-11-10T09:49:26.920161Z",
|
|
||||||
"shell.execute_reply": "2025-11-10T09:49:26.919605Z",
|
|
||||||
"shell.execute_reply.started": "2025-11-10T09:49:26.870441Z"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import json\n",
|
"import json\n",
|
||||||
@@ -2304,49 +2264,25 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
|
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
|
||||||
"mydb = myclient[\"baogao\"]\n",
|
"mydb = myclient[\"baogao\"]\n",
|
||||||
|
"mycol = mydb[\"pdf1\"]\n",
|
||||||
"\n",
|
"\n",
|
||||||
"place_id = 1\n",
|
"filename = 'data/镇海短信码2025.json'\n",
|
||||||
"place_code = \"20\"\n",
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl) \n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"for k, v in dict1.items():\n",
|
||||||
|
" list1.append({'bh':k,'phone':v['phone'],'place_id':1,'code':v['code'],'fn':v['fn']})\n",
|
||||||
"\n",
|
"\n",
|
||||||
"fi_path = '/home/songyi/python/mycrm/flask/pdf/files'\n",
|
"x = mycol.insert_many(list1)\n",
|
||||||
"fls = glob.glob(f'{fi_path}/{str(place_id)}/*.pdf')\n",
|
"print(len(list1),'ok') "
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"for fn in fls:\n",
|
|
||||||
" dict2 = {}\n",
|
|
||||||
" fi_name =Path(fn).stem.split('-')[0]\n",
|
|
||||||
" #fi_name =Path(fn).stem\n",
|
|
||||||
" code = int(fi_name)\n",
|
|
||||||
" dxm = list1[i]\n",
|
|
||||||
" dict2 = {'place_id':place_id,'code':dxm,'fn':Path(fn).name}\n",
|
|
||||||
" list2.append(dict2)\n",
|
|
||||||
" i +=1\n",
|
|
||||||
"x = mycol.insert_many(list2)\n",
|
|
||||||
"print(len(list2),'ok') "
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 64,
|
"execution_count": null,
|
||||||
"id": "3b73e071-62ad-41fb-8b9d-57893dbf8a6f",
|
"id": "3b73e071-62ad-41fb-8b9d-57893dbf8a6f",
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"execution": {
|
"outputs": [],
|
||||||
"iopub.execute_input": "2025-11-09T05:50:17.521854Z",
|
|
||||||
"iopub.status.busy": "2025-11-09T05:50:17.521109Z",
|
|
||||||
"iopub.status.idle": "2025-11-09T05:50:17.537693Z",
|
|
||||||
"shell.execute_reply": "2025-11-09T05:50:17.536539Z",
|
|
||||||
"shell.execute_reply.started": "2025-11-09T05:50:17.521785Z"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"[{'place_id': 1, 'code': '016368', 'fn': '016368-陈兴旺.pdf'}, {'place_id': 1, 'code': '013403', 'fn': '013403-孙震.pdf'}, {'place_id': 1, 'code': '008553', 'fn': '008553-张国栋.pdf'}, {'place_id': 1, 'code': '015775', 'fn': '015775-张永战.pdf'}, {'place_id': 1, 'code': '015867', 'fn': '015867-高再玲.pdf'}, {'place_id': 1, 'code': '015770', 'fn': '015770-许丹萍.pdf'}, {'place_id': 1, 'code': '021574', 'fn': '021574-杨子敬.pdf'}, {'place_id': 1, 'code': '013141', 'fn': '013141-何文丰.pdf'}, {'place_id': 1, 'code': '015635', 'fn': '015635-王宇光.pdf'}, {'place_id': 1, 'code': '016224', 'fn': '016224-方丽华.pdf'}, {'place_id': 1, 'code': '014081', 'fn': '014081-谢希杭.pdf'}, {'place_id': 1, 'code': '019323', 'fn': '019323-赖佳奇.pdf'}, {'place_id': 1, 'code': '020747', 'fn': '020747-贺海鹏.pdf'}, {'place_id': 1, 'code': '014609', 'fn': '014609-靳贤锐.pdf'}, {'place_id': 1, 'code': '016309', 'fn': '016309-张鹏宇.pdf'}, {'place_id': 1, 'code': '015206', 'fn': '015206-王贺永.pdf'}, {'place_id': 1, 'code': '015184', 'fn': '015184-彭志涛.pdf'}, {'place_id': 1, 'code': '018706', 'fn': '018706-陈佳欣.pdf'}, {'place_id': 1, 'code': '021568', 'fn': '021568-张峻哲.pdf'}, {'place_id': 1, 'code': '016402', 'fn': '016402-石晓雨.pdf'}, {'place_id': 1, 'code': '016023', 'fn': '016023-何正楠.pdf'}, {'place_id': 1, 'code': '008319', 'fn': '008319-陈文近.pdf'}, {'place_id': 1, 'code': '014701', 'fn': '014701-陈顺.pdf'}, {'place_id': 1, 'code': '013564', 'fn': '013564-徐凯华.pdf'}, {'place_id': 1, 'code': '015014', 'fn': '015014-赵刚.pdf'}, {'place_id': 1, 'code': '010481', 'fn': '010481-徐旭东.pdf'}, {'place_id': 1, 'code': '016354', 'fn': '016354-张婕.pdf'}]\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"\n",
|
"\n",
|
||||||
"import os,sys,shutil\n",
|
"import os,sys,shutil\n",
|
||||||
@@ -2380,10 +2316,355 @@
|
|||||||
"print(len(list2),'ok') "
|
"print(len(list2),'ok') "
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "9e271c11-dc3f-4746-82c8-380a2ae685d8",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 生成有电话人员验证码"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "c0380a6e-fdfe-4df1-b235-652e605ac312",
|
"id": "fe8d4bbf-f293-42e5-8e13-172083431fdd",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import os,sys,shutil\n",
|
||||||
|
"import json\n",
|
||||||
|
"import math\n",
|
||||||
|
"import glob\n",
|
||||||
|
"import random\n",
|
||||||
|
"from pathlib import Path\n",
|
||||||
|
"import pymongo\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/镇海人员2025.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict2 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"dict3 = {}\n",
|
||||||
|
"for k, v in dict2.items():\n",
|
||||||
|
" if 'phone' in v.keys():\n",
|
||||||
|
" dict3[k] = v\n",
|
||||||
|
"\n",
|
||||||
|
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
|
||||||
|
"mydb = myclient[\"baogao\"]\n",
|
||||||
|
"\n",
|
||||||
|
"place_id = 1\n",
|
||||||
|
"place_code = \"01\"\n",
|
||||||
|
"dw_name = \"中国石化镇海炼化公司\"\n",
|
||||||
|
"dw_jc = \"中国石化镇海炼化公司\"\n",
|
||||||
|
"fi_path = '/home/songyi/pdf-typescript-old2/镇海石化2025'\n",
|
||||||
|
"fls = glob.glob(f'{fi_path}/*.pdf')\n",
|
||||||
|
"\n",
|
||||||
|
"code_list = []\n",
|
||||||
|
"for i in range(10): # 0~9\n",
|
||||||
|
" code_list.append(str(i))\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"mycol = mydb[\"pdf\"]\n",
|
||||||
|
"\n",
|
||||||
|
"i = 0\n",
|
||||||
|
"while i < len(fls):\n",
|
||||||
|
" code = random.sample(code_list,5) #随机取4位数\n",
|
||||||
|
" code_num = ''.join(code) \n",
|
||||||
|
" if place_code+code_num not in list1:\n",
|
||||||
|
" list1.append(place_code+code_num)\n",
|
||||||
|
" i +=1\n",
|
||||||
|
"i = 0\n",
|
||||||
|
"list2= []\n",
|
||||||
|
"\n",
|
||||||
|
"for fn in fls:\n",
|
||||||
|
" dict2 = {}\n",
|
||||||
|
" fi_name =Path(fn).stem.split('-')[0]\n",
|
||||||
|
" #fi_name =Path(fn).stem\n",
|
||||||
|
" code = fi_name\n",
|
||||||
|
" dxm = list1[i]\n",
|
||||||
|
" dict2 = {'place_id':place_id,'code':dxm,'fn':Path(fn).name}\n",
|
||||||
|
" list2.append(dict2)\n",
|
||||||
|
" i +=1\n",
|
||||||
|
"x = mycol.insert_many(list2)\n",
|
||||||
|
"print(len(list2),'ok') \n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "2f9d6915-9933-48e1-94a7-9ae8fa4c8844",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import os,sys,shutil\n",
|
||||||
|
"import json\n",
|
||||||
|
"import math\n",
|
||||||
|
"import glob\n",
|
||||||
|
"import random\n",
|
||||||
|
"from pathlib import Path\n",
|
||||||
|
"import pymongo\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/镇海人员2025.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict2 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"dict3 = {}\n",
|
||||||
|
"for k, v in dict2.items():\n",
|
||||||
|
" if 'phone' in v.keys():\n",
|
||||||
|
" dict3[k] = v\n",
|
||||||
|
"print(len(dict3))\n",
|
||||||
|
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
|
||||||
|
"mydb = myclient[\"baogao\"]\n",
|
||||||
|
"\n",
|
||||||
|
"place_id = 1\n",
|
||||||
|
"place_code = \"01\"\n",
|
||||||
|
"dw_name = \"中国石化镇海炼化公司\"\n",
|
||||||
|
"dw_jc = \"中国石化镇海炼化公司\"\n",
|
||||||
|
"fi_path = '/home/songyi/pdf-typescript-old2/镇海石化2025'\n",
|
||||||
|
"fls = glob.glob(f'{fi_path}/*.pdf')\n",
|
||||||
|
"\n",
|
||||||
|
"code_list = []\n",
|
||||||
|
"for i in range(10): # 0~9\n",
|
||||||
|
" code_list.append(str(i))\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"mycol = mydb[\"pdf\"]\n",
|
||||||
|
"\n",
|
||||||
|
"i = 0\n",
|
||||||
|
"while i < len(fls):\n",
|
||||||
|
" code = random.sample(code_list,4) #随机取4位数\n",
|
||||||
|
" code_num = ''.join(code) \n",
|
||||||
|
" if place_code+code_num not in list1:\n",
|
||||||
|
" list1.append(place_code+code_num)\n",
|
||||||
|
" i +=1\n",
|
||||||
|
"i = 0\n",
|
||||||
|
"list2= []\n",
|
||||||
|
"dict4 = {}\n",
|
||||||
|
"for fn in fls:\n",
|
||||||
|
" dict2 = {}\n",
|
||||||
|
" fi_name =Path(fn).stem.split('-')[0]\n",
|
||||||
|
" #fi_name =Path(fn).stem\n",
|
||||||
|
" code = fi_name\n",
|
||||||
|
" if code in dict3.keys():\n",
|
||||||
|
" \n",
|
||||||
|
" dxm = list1[i]\n",
|
||||||
|
" \n",
|
||||||
|
" dict2 = {'bh':code,'phone':dict3[code]['phone'],'place_id':place_id,'code':dxm,'fn':Path(fn).name}\n",
|
||||||
|
" dict4[code] = {'phone':dict3[code]['phone'],'place_id':place_id,'code':dxm,'fn':Path(fn).name}\n",
|
||||||
|
" list2.append(dict2)\n",
|
||||||
|
" i +=1\n",
|
||||||
|
"x = mycol.insert_many(list2)\n",
|
||||||
|
"filename = f'data/镇海短信码2025.json'\n",
|
||||||
|
"with open(filename,'w') as fl:\n",
|
||||||
|
" json.dump(dict4,fl , ensure_ascii=False) \n",
|
||||||
|
"print('ok!') "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "d7c31e0f-b2c9-4fb3-a265-9032114954ca",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 批量发送短信(测试)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "9879c239-37c8-4054-8b39-99643d6f8792",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"from tencentcloud.common import credential\n",
|
||||||
|
"from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException\n",
|
||||||
|
"from tencentcloud.sms.v20210111 import sms_client, models\n",
|
||||||
|
"from tencentcloud.common.profile.client_profile import ClientProfile\n",
|
||||||
|
"from tencentcloud.common.profile.http_profile import HttpProfile\n",
|
||||||
|
"import json\n",
|
||||||
|
"import pymongo\n",
|
||||||
|
"import time\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"dw_jc = \"镇海炼化公司\"\n",
|
||||||
|
"filename = 'data/镇海短信码2025.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl) \n",
|
||||||
|
"\n",
|
||||||
|
"place_id = 1\n",
|
||||||
|
"\n",
|
||||||
|
"i=1\n",
|
||||||
|
"#dict2 = {375: {'phone': '13793180751', 'code': '0379208'}}\n",
|
||||||
|
"for k, v in dict1.items():\n",
|
||||||
|
" phone = '+86'+v['phone']\n",
|
||||||
|
" yzm = v['code']\n",
|
||||||
|
" try: \n",
|
||||||
|
" secretId = \"AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc\"\n",
|
||||||
|
" secretKey = \"51XVL1YxDKI6mJh8au6DDuTskS1RhwJX\"\n",
|
||||||
|
" cred = credential.Credential(secretId, secretKey) \n",
|
||||||
|
" httpProfile = HttpProfile()\n",
|
||||||
|
" httpProfile.reqMethod = \"POST\" # post请求(默认为post请求)\n",
|
||||||
|
" httpProfile.reqTimeout = 60 # 请求超时时间,单位为秒(默认60秒)\n",
|
||||||
|
" httpProfile.endpoint = \"sms.tencentcloudapi.com\" # 指定接入地域域名(默认就近接入)\n",
|
||||||
|
" clientProfile = ClientProfile()\n",
|
||||||
|
" clientProfile.signMethod = \"TC3-HMAC-SHA256\" # 指定签名算法\n",
|
||||||
|
" clientProfile.language = \"en-US\"\n",
|
||||||
|
" clientProfile.httpProfile = httpProfile\n",
|
||||||
|
" client = sms_client.SmsClient(cred, \"ap-guangzhou\", clientProfile)\n",
|
||||||
|
" req = models.SendSmsRequest()\n",
|
||||||
|
" req.SmsSdkAppId = \"1400140089\"\n",
|
||||||
|
" req.SignName = \"坤铭教育\"\n",
|
||||||
|
" req.TemplateId = \"1875765\" \n",
|
||||||
|
" req.TemplateParamSet = [dw_jc,yzm]\n",
|
||||||
|
" req.PhoneNumberSet = [phone]\n",
|
||||||
|
" req.SessionContext = \"\"\n",
|
||||||
|
" req.ExtendCode = \"\"\n",
|
||||||
|
" req.SenderId = \"\"\n",
|
||||||
|
" #resp = client.SendSms(req)\n",
|
||||||
|
" #dict3 = json.loads(resp.to_json_string(indent=2))\n",
|
||||||
|
"\n",
|
||||||
|
" #print(v['phone'],dict3['SendStatusSet'][0][\"Message\"])\n",
|
||||||
|
" print(i,v['phone'],v['fn'], v['code'])\n",
|
||||||
|
" i+=1\n",
|
||||||
|
" except TencentCloudSDKException as err:\n",
|
||||||
|
" print(v['phone'],err)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "8f68da91-de56-4cc5-abe6-2b275133e558",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 单个发送短信"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "9663b933-57f4-486c-80e6-f9d513bbe6a8",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"from tencentcloud.common import credential\n",
|
||||||
|
"from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException\n",
|
||||||
|
"from tencentcloud.sms.v20210111 import sms_client, models\n",
|
||||||
|
"from tencentcloud.common.profile.client_profile import ClientProfile\n",
|
||||||
|
"from tencentcloud.common.profile.http_profile import HttpProfile\n",
|
||||||
|
"import json\n",
|
||||||
|
"import pymongo\n",
|
||||||
|
"import time\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"dw_jc = \"中国石化镇海炼化公司\"\n",
|
||||||
|
"filename = 'data/镇海短信码2025.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl) \n",
|
||||||
|
"\n",
|
||||||
|
"phone = '+86'+'13793180751'\n",
|
||||||
|
"yzm = '019031'\n",
|
||||||
|
"try: \n",
|
||||||
|
" secretId = \"AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc\"\n",
|
||||||
|
" secretKey = \"51XVL1YxDKI6mJh8au6DDuTskS1RhwJX\"\n",
|
||||||
|
" cred = credential.Credential(secretId, secretKey) \n",
|
||||||
|
" httpProfile = HttpProfile()\n",
|
||||||
|
" httpProfile.reqMethod = \"POST\" # post请求(默认为post请求)\n",
|
||||||
|
" httpProfile.reqTimeout = 60 # 请求超时时间,单位为秒(默认60秒)\n",
|
||||||
|
" httpProfile.endpoint = \"sms.tencentcloudapi.com\" # 指定接入地域域名(默认就近接入)\n",
|
||||||
|
" clientProfile = ClientProfile()\n",
|
||||||
|
" clientProfile.signMethod = \"TC3-HMAC-SHA256\" # 指定签名算法\n",
|
||||||
|
" clientProfile.language = \"en-US\"\n",
|
||||||
|
" clientProfile.httpProfile = httpProfile\n",
|
||||||
|
" client = sms_client.SmsClient(cred, \"ap-guangzhou\", clientProfile)\n",
|
||||||
|
" req = models.SendSmsRequest()\n",
|
||||||
|
" req.SmsSdkAppId = \"1400140089\"\n",
|
||||||
|
" req.SignName = \"坤铭教育\"\n",
|
||||||
|
" req.TemplateId = \"1875765\" \n",
|
||||||
|
" req.TemplateParamSet = [dw_jc,yzm]\n",
|
||||||
|
" req.PhoneNumberSet = [phone]\n",
|
||||||
|
" req.SessionContext = \"\"\n",
|
||||||
|
" req.ExtendCode = \"\"\n",
|
||||||
|
" req.SenderId = \"\"\n",
|
||||||
|
" resp = client.SendSms(req)\n",
|
||||||
|
" dict3 = json.loads(resp.to_json_string(indent=2))\n",
|
||||||
|
"\n",
|
||||||
|
" print(phone,dict3['SendStatusSet'][0][\"Message\"])\n",
|
||||||
|
"except TencentCloudSDKException as err:\n",
|
||||||
|
" print(v['phone'],err)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "ab5f292c-1b1e-46a0-9b5b-f7be1573d438",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 批量发送短信"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "4426aa59-2754-4571-9270-dcb7b66bc941",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"from tencentcloud.common import credential\n",
|
||||||
|
"from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException\n",
|
||||||
|
"from tencentcloud.sms.v20210111 import sms_client, models\n",
|
||||||
|
"from tencentcloud.common.profile.client_profile import ClientProfile\n",
|
||||||
|
"from tencentcloud.common.profile.http_profile import HttpProfile\n",
|
||||||
|
"import json\n",
|
||||||
|
"import pymongo\n",
|
||||||
|
"import time\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"dw_jc = \"镇海炼化公司\"\n",
|
||||||
|
"filename = 'data/镇海短信码2025.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl) \n",
|
||||||
|
"\n",
|
||||||
|
"place_id = 1\n",
|
||||||
|
"\n",
|
||||||
|
"i=1\n",
|
||||||
|
"#dict2 = {375: {'phone': '13793180751', 'code': '0379208'}}\n",
|
||||||
|
"for k, v in dict1.items():\n",
|
||||||
|
" phone = '+86'+v['phone']\n",
|
||||||
|
" yzm = v['code']\n",
|
||||||
|
" try: \n",
|
||||||
|
" secretId = \"AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc\"\n",
|
||||||
|
" secretKey = \"51XVL1YxDKI6mJh8au6DDuTskS1RhwJX\"\n",
|
||||||
|
" cred = credential.Credential(secretId, secretKey) \n",
|
||||||
|
" httpProfile = HttpProfile()\n",
|
||||||
|
" httpProfile.reqMethod = \"POST\" # post请求(默认为post请求)\n",
|
||||||
|
" httpProfile.reqTimeout = 60 # 请求超时时间,单位为秒(默认60秒)\n",
|
||||||
|
" httpProfile.endpoint = \"sms.tencentcloudapi.com\" # 指定接入地域域名(默认就近接入)\n",
|
||||||
|
" clientProfile = ClientProfile()\n",
|
||||||
|
" clientProfile.signMethod = \"TC3-HMAC-SHA256\" # 指定签名算法\n",
|
||||||
|
" clientProfile.language = \"en-US\"\n",
|
||||||
|
" clientProfile.httpProfile = httpProfile\n",
|
||||||
|
" client = sms_client.SmsClient(cred, \"ap-guangzhou\", clientProfile)\n",
|
||||||
|
" req = models.SendSmsRequest()\n",
|
||||||
|
" req.SmsSdkAppId = \"1400140089\"\n",
|
||||||
|
" req.SignName = \"坤铭教育\"\n",
|
||||||
|
" req.TemplateId = \"1875765\" \n",
|
||||||
|
" req.TemplateParamSet = [dw_jc,yzm]\n",
|
||||||
|
" req.PhoneNumberSet = [phone]\n",
|
||||||
|
" req.SessionContext = \"\"\n",
|
||||||
|
" req.ExtendCode = \"\"\n",
|
||||||
|
" req.SenderId = \"\"\n",
|
||||||
|
" resp = client.SendSms(req)\n",
|
||||||
|
" #dict3 = json.loads(resp.to_json_string(indent=2))\n",
|
||||||
|
" time.sleep(3)\n",
|
||||||
|
"\n",
|
||||||
|
" #print(v['phone'],dict3['SendStatusSet'][0][\"Message\"])\n",
|
||||||
|
" print(i,v['phone'],v['fn'], v['code'])\n",
|
||||||
|
" i+=1\n",
|
||||||
|
" except TencentCloudSDKException as err:\n",
|
||||||
|
" print(v['phone'],err)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "02501165-d375-4101-8a97-107b52cccdc2",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": []
|
"source": []
|
||||||
|
|||||||
Reference in new issue
Block a user