This commit is contained in:
512song committed 2025-12-22 21:13:47 +08:00
1 parent 6803e6fff6
commit b894e793a5
5 files changed
+1705 -202

No files matched your search

+166 -51
View File
@@ -116,6 +116,59 @@
"print('ok')"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "de0185f6-a3ce-4d12-96d5-2d4fd01cf293",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-19T03:19:11.165261Z",
"iopub.status.busy": "2025-12-19T03:19:11.164496Z",
"iopub.status.idle": "2025-12-19T03:19:11.195061Z",
"shell.execute_reply": "2025-12-19T03:19:11.194508Z",
"shell.execute_reply.started": "2025-12-19T03:19:11.165190Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"85\n",
"ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"from datetime import date\n",
"\n",
"wb = openpyxl.load_workbook('data/东营老年大学北体班2025年度复测花名册.xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"person = {}\n",
"\n",
"for n in range(2, sheet.max_row+1):\n",
" if sheet.cell(n,1).value is not None:\n",
" code = int(sheet.cell(n, 1).value)\n",
" person.setdefault(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 2).value\n",
" dict1['sex'] = sheet.cell(n, 3).value\n",
" dict1['unit'] = sheet.cell(n, 5).value\n",
" dict1['birth'] = str(sheet.cell(n, 4).value).replace('/','-').split(' ')[0]\n",
" #dict1['age'] = sheet.cell(n, 6).value\n",
" if sheet.cell(n,6).value is not None:\n",
" dict1['phone'] = str(sheet.cell(n,6).value) \n",
" person[code] = dict1\n",
"filename = 'data/东营老年大学北体班2025年度复测.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
"print(len(person))\n",
"print('ok')"
]
},
{
"cell_type": "code",
"execution_count": 88,
@@ -473,6 +526,85 @@
"print(len(re_ta))"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "b6faa6d3-8237-4e75-9014-a76826ae2c36",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-19T03:19:24.207176Z",
"iopub.status.busy": "2025-12-19T03:19:24.206625Z",
"iopub.status.idle": "2025-12-19T03:19:24.227876Z",
"shell.execute_reply": "2025-12-19T03:19:24.226944Z",
"shell.execute_reply.started": "2025-12-19T03:19:24.207123Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"59\n"
]
}
],
"source": [
"import json\n",
"import datetime\n",
"import csv\n",
"from datetime import date\n",
"\n",
"\n",
"re_ta = {}\n",
"list1 = []\n",
"filename = 'data/东营老年大学北体班2025年度复测.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"filename = 'data/marks_20251219.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",
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
" list1.append(line)\n",
"\n",
"for result in list1:\n",
" user = str(result[2])\n",
" rq = date.fromisoformat(result[5].replace('/','-'))\n",
" if user in dict1.keys():\n",
" #print(user)\n",
" l_xm = []\n",
" m_item = str(result[3]) \n",
" re_ta.setdefault(user,{}) \n",
" re_ta[user]['name'] = dict1[user]['name']\n",
" re_ta[user]['sex'] = dict1[user]['sex']\n",
" re_ta[user]['birth'] = dict1[user]['birth']\n",
" re_ta[user]['unit'] = dict1[user]['unit']\n",
" if 'phone' in dict1[user].keys():\n",
" re_ta[user]['phone'] = dict1[user]['phone']\n",
" if dict1[user]['sex'] == '男':\n",
" l_xm = ['bmi','lung','grip','flexion','jump','pushup','balance','reaction','step']\n",
" else:\n",
" l_xm = ['bmi','lung','grip','flexion','jump','balance','reaction','step','situp']\n",
" #re_ta[user]['unit'] = dict1[user]['unit']\n",
" birth = date.fromisoformat(dict1[user]['birth'].replace('/','-'))\n",
" item_name = result[3] \n",
" if item_name in l_xm: \n",
" days = (rq-birth).days \n",
" re_ta[user]['age'] = int(days/365)\n",
" re_ta[user]['month'] = int(days/365*12)\n",
" re_ta[user]['rq'] = result[5]\n",
" re_ta[user].setdefault(item_name,{}) \n",
" score = result[4] \n",
" re_ta[user][item_name]['成绩'] = score\n",
"\n",
"filename = 'data/result_东营老年大学北体班2025年度复测.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": "74ec60b7-b1d9-488d-95fa-4ddd020c2a4c",
@@ -483,15 +615,15 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 27,
"id": "c3b99428-00d5-45ea-9803-261194525fa4",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-12T13:13:35.809342Z",
"iopub.status.busy": "2025-12-12T13:13:35.808036Z",
"iopub.status.idle": "2025-12-12T13:13:35.820106Z",
"shell.execute_reply": "2025-12-12T13:13:35.818957Z",
"shell.execute_reply.started": "2025-12-12T13:13:35.809273Z"
"iopub.execute_input": "2025-12-19T03:19:29.967201Z",
"iopub.status.busy": "2025-12-19T03:19:29.966497Z",
"iopub.status.idle": "2025-12-19T03:19:29.983427Z",
"shell.execute_reply": "2025-12-19T03:19:29.982437Z",
"shell.execute_reply.started": "2025-12-19T03:19:29.967135Z"
}
},
"outputs": [
@@ -499,7 +631,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"ok!\n"
"ok! 59\n"
]
}
],
@@ -510,7 +642,7 @@
"\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_油田老年大学年度体质复测.json'\n",
"filename = 'data/result_东营老年大学北体班2025年度复测.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl) \n",
"for k, v in dict2.items():\n",
@@ -533,10 +665,10 @@
" dict2[k][item_en]['score'] = My.cal_score(data1)\n",
" #print(k,v[item_en]['成绩'],cal_score(data1))\n",
"\n",
"filename = 'data/result_油田老年大学年度体质复测.json'\n",
"filename = 'data/result_东营老年大学北体班2025年度复测.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict2,fl , ensure_ascii=False) \n",
"print('ok!') "
"print('ok!',len(dict2)) "
]
},
{
@@ -1008,15 +1140,15 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 28,
"id": "0ba2e1a3-78c8-44d9-ab7d-b17b52b0a99f",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-12T13:38:13.857680Z",
"iopub.status.busy": "2025-12-12T13:38:13.856977Z",
"iopub.status.idle": "2025-12-12T13:38:13.880423Z",
"shell.execute_reply": "2025-12-12T13:38:13.879532Z",
"shell.execute_reply.started": "2025-12-12T13:38:13.857614Z"
"iopub.execute_input": "2025-12-19T03:19:45.959079Z",
"iopub.status.busy": "2025-12-19T03:19:45.958247Z",
"iopub.status.idle": "2025-12-19T03:19:45.990040Z",
"shell.execute_reply": "2025-12-19T03:19:45.989559Z",
"shell.execute_reply.started": "2025-12-19T03:19:45.959012Z"
}
},
"outputs": [
@@ -1024,21 +1156,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"15684378667\n",
"15684378667\n",
"13699180673\n",
"15105461296\n",
"13012909096\n",
"13954605763\n",
"13287350839\n",
"13561090015\n",
"13287336162\n",
"13963396946\n",
"15105461298\n",
"13864739068\n",
"13013569039\n",
"13864757610\n",
"15725185717\n"
"59\n"
]
}
],
@@ -1051,13 +1169,13 @@
"\n",
"dict1 = {}\n",
"\n",
"filename = 'data/result_油田老年大学年度体质复测.json'\n",
"filename = 'data/result_东营老年大学北体班2025年度复测.json'\n",
"with open(filename,'r') as fl:\n",
" dict3 = json.load(fl)\n",
"\n",
" dict1 = json.load(fl)\n",
"print(len(dict1))\n",
"\n",
"list1 = []\n",
"filename = 'data/sql_20251212.csv'\n",
"filename = 'data/sql_20251219.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl) \n",
@@ -1077,11 +1195,8 @@
" for i in range(0,26):\n",
" spine.append(0)\n",
" phone = item[0][2:]\n",
" print(phone)\n",
" for k1, v1 in dict3.items():\n",
" if 'phone' in v1.keys() and phone ==v1['phone']: \n",
" dict1[k1] = dict3[k1]\n",
" #dict1[k1]['month'] = dict1[k1]['age'] *12\n",
" #print(phone)\n",
" \n",
"for item in list1:\n",
" #print(item)\n",
" psy = []\n",
@@ -1136,7 +1251,7 @@
" \n",
" dict1[k1]['rq'] = item[2].replace('/','-').split(' ')[0]\n",
"#print(dict1)\n",
"filename = 'data/result_油田老年大学年度体质复测.json'\n",
"filename = 'data/result_东营老年大学北体班2025年度复测.json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False) "
@@ -1305,15 +1420,15 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 29,
"id": "7ee80847-2bc0-4cbe-9534-c5dcf97c2833",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-12T13:38:35.200844Z",
"iopub.status.busy": "2025-12-12T13:38:35.200220Z",
"iopub.status.idle": "2025-12-12T13:38:42.941941Z",
"shell.execute_reply": "2025-12-12T13:38:42.941270Z",
"shell.execute_reply.started": "2025-12-12T13:38:35.200787Z"
"iopub.execute_input": "2025-12-19T03:19:56.159337Z",
"iopub.status.busy": "2025-12-19T03:19:56.157645Z",
"iopub.status.idle": "2025-12-19T03:20:30.404540Z",
"shell.execute_reply": "2025-12-19T03:20:30.403593Z",
"shell.execute_reply.started": "2025-12-19T03:19:56.159261Z"
}
},
"outputs": [
@@ -1321,7 +1436,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"12\n"
"59\n"
]
}
],
@@ -1334,11 +1449,11 @@
"headers = {\n",
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
" }\n",
"filename = 'data/result_油田老年大学年度体质复测.json'\n",
"filename = 'data/result_东营老年大学北体班2025年度复测.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
"file_path ='./油田老年大学年度体质复测/'\n",
"file_path ='./油田老年大学北体班2025年度体质复测/'\n",
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
"i=0\n",
"list2 = []\n",
@@ -1348,7 +1463,7 @@
" \n",
" id = str(k).rjust(4,\"0\")\n",
" mydata['path'] = file_path+id+'-'+ v['name']+'.pdf'\n",
" mydata['title'] = '油田老年大学年度体质复测'\n",
" mydata['title'] = '油田老年大学北体班年度体质复测'\n",
" mydata['subtitle'] = v['unit']\n",
" mydata['id'] = id\n",
" mydata['name'] = v['name']\n",
+108 -42
View File
@@ -1632,20 +1632,36 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "46aa847d-e1fe-45bd-85b6-e2d792ec8842",
"metadata": {},
"outputs": [],
"execution_count": 14,
"id": "9ace695e-6a23-44d4-b284-8e8d9805eb81",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-19T12:50:48.618259Z",
"iopub.status.busy": "2025-12-19T12:50:48.617488Z",
"iopub.status.idle": "2025-12-19T12:50:48.633205Z",
"shell.execute_reply": "2025-12-19T12:50:48.632731Z",
"shell.execute_reply.started": "2025-12-19T12:50:48.618188Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"75\n"
]
}
],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"\n",
"filename = 'data/result_沧州炼化-1.json'\n",
"filename = 'data/result_南京化工(2512)-1.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
" \n",
"\n",
"#items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"items = {}\n",
"items['lung'] = '肺活量'\n",
@@ -1690,10 +1706,11 @@
" mark = v[item]['成绩'].split()[0]\n",
" mydata['fits'][items[item]] = {'mark':mark,'score':v[item]['score']}\n",
" score = score + v[item]['score']\n",
" mydata['score'] = round(score/len(mydata['fits']),2)\n",
" \n",
" if len(mydata['fits']) >2:\n",
" mydata['score'] = round(score/len(mydata['fits']),2)\n",
" dict2[str(k)] = mydata\n",
"filename = f'data/data_沧州炼化.json'\n",
"filename = f'data/data_南京化工(202512).json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict2,fl , ensure_ascii=False) \n",
"print(len(dict2)) "
@@ -1709,17 +1726,34 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"id": "63edd636-f034-4aa6-8575-63d5cdb84adb",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-19T12:51:01.984861Z",
"iopub.status.busy": "2025-12-19T12:51:01.984219Z",
"iopub.status.idle": "2025-12-19T12:51:01.994995Z",
"shell.execute_reply": "2025-12-19T12:51:01.993895Z",
"shell.execute_reply.started": "2025-12-19T12:51:01.984802Z"
},
"tags": []
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"平均成绩:2.5654分,男性:63人\n",
"平均成绩:2.675分,女性:12人\n",
"平均成绩:2.5829分,总体:75人\n"
]
}
],
"source": [
"import json\n",
"\n",
"nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n",
"filename = 'data/data_沧州炼化.json'\n",
"filename = 'data/data_南京化工(202512).json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"i = 1\n",
@@ -1753,12 +1787,32 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 16,
"id": "1b4a3f02-9b2e-41fc-ac6c-8163907a07f1",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-19T12:51:42.136559Z",
"iopub.status.busy": "2025-12-19T12:51:42.135934Z",
"iopub.status.idle": "2025-12-19T12:51:42.152707Z",
"shell.execute_reply": "2025-12-19T12:51:42.151634Z",
"shell.execute_reply.started": "2025-12-19T12:51:42.136501Z"
},
"tags": []
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0~255分人数:33人,男性:31人,女性:2人\n",
"256~332分人数:35人,男性:26人,女性:9人\n",
"333~367分人数:5人,男性:5人,女性:0人\n",
"368~500分人数:2人,男性:1人,女性:1人\n",
"75\n",
"ok\n"
]
}
],
"source": [
"import json\n",
"\n",
@@ -2012,13 +2066,37 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 17,
"id": "ad69c45d-3f62-42df-894d-47424e759029",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-19T12:52:40.178756Z",
"iopub.status.busy": "2025-12-19T12:52:40.178152Z",
"iopub.status.idle": "2025-12-19T12:52:40.184826Z",
"shell.execute_reply": "2025-12-19T12:52:40.184289Z",
"shell.execute_reply.started": "2025-12-19T12:52:40.178722Z"
},
"scrolled": true,
"tags": []
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"BMI 1.19 75\n",
"肺活量 3.33 73\n",
"握力 3.39 75\n",
"坐位体前屈 2.29 72\n",
"纵跳 2.29 70\n",
"俯卧撑 2.58 52\n",
"一分钟仰卧起坐 3.67 9\n",
"单脚站立 2.35 75\n",
"选择反应时 3.54 74\n",
"台阶指数 2.2 46\n"
]
}
],
"source": [
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
@@ -2310,15 +2388,15 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 18,
"id": "6f9768ce-2ef5-4253-9fc6-49dbdcf00a19",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-12T13:17:17.795264Z",
"iopub.status.busy": "2025-12-12T13:17:17.794719Z",
"iopub.status.idle": "2025-12-12T13:17:17.805357Z",
"shell.execute_reply": "2025-12-12T13:17:17.804292Z",
"shell.execute_reply.started": "2025-12-12T13:17:17.795214Z"
"iopub.execute_input": "2025-12-22T11:04:03.470806Z",
"iopub.status.busy": "2025-12-22T11:04:03.470172Z",
"iopub.status.idle": "2025-12-22T11:04:03.479616Z",
"shell.execute_reply": "2025-12-22T11:04:03.479011Z",
"shell.execute_reply.started": "2025-12-22T11:04:03.470775Z"
}
},
"outputs": [],
@@ -2672,35 +2750,23 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 19,
"id": "9ecd3ad8-c8af-4f3e-90e5-1618fea905a4",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-12T13:46:10.803542Z",
"iopub.status.busy": "2025-12-12T13:46:10.802812Z",
"iopub.status.idle": "2025-12-12T13:46:10.973193Z",
"shell.execute_reply": "2025-12-12T13:46:10.972533Z",
"shell.execute_reply.started": "2025-12-12T13:46:10.803460Z"
"iopub.execute_input": "2025-12-22T11:04:25.639587Z",
"iopub.status.busy": "2025-12-22T11:04:25.638549Z",
"iopub.status.idle": "2025-12-22T11:04:25.677688Z",
"shell.execute_reply": "2025-12-22T11:04:25.677118Z",
"shell.execute_reply.started": "2025-12-22T11:04:25.639534Z"
}
},
"outputs": [
{
"ename": "IndexError",
"evalue": "list index out of range",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[9], line 57\u001b[0m\n\u001b[1;32m 55\u001b[0m psy\u001b[38;5;241m=\u001b[39mv[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mpsy_yangmiao_old\u001b[39m\u001b[38;5;124m'\u001b[39m]\n\u001b[1;32m 56\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;241m26\u001b[39m,\u001b[38;5;241m40\u001b[39m):\n\u001b[0;32m---> 57\u001b[0m new_valve \u001b[38;5;241m=\u001b[39m \u001b[43mpsy\u001b[49m\u001b[43m[\u001b[49m\u001b[43mi\u001b[49m\u001b[43m]\u001b[49m\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m\n\u001b[1;32m 58\u001b[0m psy[i] \u001b[38;5;241m=\u001b[39m new_valve\n\u001b[1;32m 59\u001b[0m dict3 \u001b[38;5;241m=\u001b[39m {}\n",
"\u001b[0;31mIndexError\u001b[0m: list index out of range"
]
}
],
"outputs": [],
"source": [
"import openpyxl\n",
"\n",
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp']\n",
"filename = 'data/result_油田老年大学年度体质复测.json'\n",
"filename = 'data/result_新疆油田乒乓球高阶培训班.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"data_list = []\n",
@@ -2782,7 +2848,7 @@
" list6.append('')\n",
" i+=1\n",
" data_list.append(list6)\n",
"filename = 'data/油田老年大学年度体质复测体质检测明细表(2025年11月).xlsx'\n",
"filename = 'data/新疆油田乒乓球高阶培训班.xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"title = ['编号', '姓名', '性别', '单位/部门', '年龄', '身高', '体重', 'bmi', '肺活量', '得分', '握力', '得分', '坐位体前屈', '得分', '纵跳', '得分', '俯卧撑', '得分', '单脚站立', '得分', '选择反应时', '得分', '台阶指数', '得分', '一分钟仰卧起坐', '得分', '中医体质', '是否倾向', '平和', '气虚', '阳虚', '阴虚', '痰湿', '湿热', '血瘀', '气郁', '特禀', '成就感', '愉快心理', '放松程度', '压力应对', '体力充沛', '情感充沛度', '颈椎', '胸椎', '腰椎', '骶尾椎']\n",
+662 -26
View File
@@ -42,6 +42,53 @@
"print(len(person),'ok')"
]
},
{
"cell_type": "code",
"execution_count": 50,
"id": "4b8567fe-1d70-4361-9fda-6180033843ea",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-19T13:00:53.324989Z",
"iopub.status.busy": "2025-12-19T13:00:53.324102Z",
"iopub.status.idle": "2025-12-19T13:00:53.345891Z",
"shell.execute_reply": "2025-12-19T13:00:53.345160Z",
"shell.execute_reply.started": "2025-12-19T13:00:53.324915Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1 ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"\n",
"wb = openpyxl.load_workbook('data/南化合作者.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(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 1).value\n",
" dict1['sex'] = sheet.cell(n, 4).value\n",
" dict1['unit'] = ''\n",
" dict1['birth'] = str(sheet.cell(n, 5).value).replace('/','-').split(' ')[0]\n",
" person[code] = dict1\n",
"filename = 'data/南京合作者.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
"print(len(person),'ok')"
]
},
{
"cell_type": "markdown",
"id": "048a95aa-1691-45f6-b933-6eaf95ae1d30",
@@ -90,11 +137,51 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "970e171e-1360-448f-a28c-520ccb8f314a",
"execution_count": 51,
"id": "b5676c48-cbc2-49d5-a87d-bb4fba4c27fa",
"metadata": {
"tags": []
"execution": {
"iopub.execute_input": "2025-12-19T13:01:09.505132Z",
"iopub.status.busy": "2025-12-19T13:01:09.504235Z",
"iopub.status.idle": "2025-12-19T13:01:09.517218Z",
"shell.execute_reply": "2025-12-19T13:01:09.515931Z",
"shell.execute_reply.started": "2025-12-19T13:01:09.505045Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\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/南京化工人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"filename = 'data/marks_20251219-1.csv'\n",
"re_ta = My.get_result(filename,dict1)\n",
"\n",
"\n",
"filename = 'data/result_南京化工(2512).json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(re_ta, fl, ensure_ascii=False) \n",
"print(len(re_ta))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4d77a1bf-74fa-4836-95bc-b52311e26ea2",
"metadata": {},
"outputs": [],
"source": [
"import json\n",
@@ -106,11 +193,11 @@
"filename = 'data/南京化工人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"filename = 'data/marks_20250703.csv'\n",
"filename = 'data/marks_20251219-1.csv'\n",
"re_ta = My.get_result(filename,dict1)\n",
"\n",
"\n",
"filename = 'data/result_南京化工.json'\n",
"filename = 'data/result_南京化工(2512).json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(re_ta, fl, ensure_ascii=False) \n",
"print(len(re_ta))"
@@ -126,10 +213,26 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 52,
"id": "0905ad6a-f7e4-43ed-ae29-c4850deb946b",
"metadata": {},
"outputs": [],
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-19T13:01:55.523463Z",
"iopub.status.busy": "2025-12-19T13:01:55.522900Z",
"iopub.status.idle": "2025-12-19T13:01:55.535201Z",
"shell.execute_reply": "2025-12-19T13:01:55.533872Z",
"shell.execute_reply.started": "2025-12-19T13:01:55.523413Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok!\n"
]
}
],
"source": [
"import json\n",
"import time\n",
@@ -137,7 +240,7 @@
"\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_南京化工.json'\n",
"filename = 'data/result_南京化工(2512).json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl) \n",
"for k, v in dict2.items():\n",
@@ -160,7 +263,65 @@
" dict2[k][item_en]['score'] = My.cal_score(data1)\n",
" #print(k,v[item_en]['成绩'],cal_score(data1))\n",
"\n",
"filename = f'data/result_南京化工.json'\n",
"filename = f'data/result_南京化工(2512).json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict2,fl , ensure_ascii=False) \n",
"print('ok!') "
]
},
{
"cell_type": "code",
"execution_count": 49,
"id": "15c8a68c-86ce-441e-99c2-5fc803003ffd",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-19T13:00:15.836697Z",
"iopub.status.busy": "2025-12-19T13:00:15.835734Z",
"iopub.status.idle": "2025-12-19T13:00:15.844310Z",
"shell.execute_reply": "2025-12-19T13:00:15.843424Z",
"shell.execute_reply.started": "2025-12-19T13:00:15.836643Z"
}
},
"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_南京合作者.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_南京合作者.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict2,fl , ensure_ascii=False) \n",
"print('ok!') "
@@ -231,6 +392,59 @@
"wb.save(filename)"
]
},
{
"cell_type": "markdown",
"id": "6a09d6b0-537f-49e8-b9c7-acfd95d9d8b6",
"metadata": {},
"source": [
"## 导出未参加测试人员信息"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "ac8d363e-862b-4155-a966-3ab15d2da336",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-17T09:28:53.660937Z",
"iopub.status.busy": "2025-12-17T09:28:53.659835Z",
"iopub.status.idle": "2025-12-17T09:28:53.683257Z",
"shell.execute_reply": "2025-12-17T09:28:53.682805Z",
"shell.execute_reply.started": "2025-12-17T09:28:53.660879Z"
}
},
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"filename = 'data/result_南京化工(2512).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'],v['phone']]\n",
" i+=1\n",
" list1.append(list2)\n",
"#print(list1)\n",
"filename = f'data/南京化工未测试人员名单(截至20251217).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": "699c6a40-a6ae-4300-9646-708cb85aa5e8",
@@ -295,6 +509,192 @@
"wb.save(filename) "
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "becf7708-1122-4d46-84f2-a790646b3c08",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-17T09:17:14.884858Z",
"iopub.status.busy": "2025-12-17T09:17:14.883621Z",
"iopub.status.idle": "2025-12-17T09:17:14.906561Z",
"shell.execute_reply": "2025-12-17T09:17:14.906028Z",
"shell.execute_reply.started": "2025-12-17T09:17:14.884762Z"
}
},
"outputs": [],
"source": [
"import json\n",
"import csv\n",
"import openpyxl\n",
"import time\n",
"from datetime import date\n",
"\n",
"\n",
"filename = 'data/南京化工人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"phone = {}\n",
"for k,v in dict1.items():\n",
" if 'phone' in v.keys():\n",
" phone[str(v['phone'])] = k\n",
"list1 = []\n",
"filename = 'data/sql_20251219-1.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",
"\n",
"i =1\n",
"list2 = []\n",
"for item in list1:\n",
" content = json.loads(json.loads(item[1]))\n",
" phone_num = str(item[0])[2:]\n",
" if phone_num in phone:\n",
" content = json.loads(json.loads(item[1]))\n",
" list3 = []\n",
" list3.append(content['code'])\n",
" list3.append(content['name'])\n",
" list3.append(content['gender'])\n",
" list2.append(list3)\n",
"filename = 'data/南化问卷情况表(202512).xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"#sheet.append(title)\n",
"for row in list2:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename) "
]
},
{
"cell_type": "markdown",
"id": "0e36111a-cdd2-4306-92af-d5d062b0b678",
"metadata": {},
"source": [
"## 统计未参加问卷人员情况"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "e6e77dac-68a1-4495-b86d-6c0179ca4641",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-17T09:16:37.963798Z",
"iopub.status.busy": "2025-12-17T09:16:37.962781Z",
"iopub.status.idle": "2025-12-17T09:16:37.989342Z",
"shell.execute_reply": "2025-12-17T09:16:37.988840Z",
"shell.execute_reply.started": "2025-12-17T09:16:37.963744Z"
}
},
"outputs": [],
"source": [
"import json\n",
"import csv\n",
"import openpyxl\n",
"import time\n",
"from datetime import date\n",
"\n",
"\n",
"filename = 'data/南京化工人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"phone = {}\n",
"for k,v in dict1.items():\n",
" if 'phone' in v.keys():\n",
" phone[str(v['phone'])] = k\n",
"list1 = []\n",
"filename = 'data/sql_20251217.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",
"list2 = []\n",
"for item in list1:\n",
" phone_num = str(item[0])[2:]\n",
" if phone_num in phone.keys():\n",
" code = phone[phone_num]\n",
" list3 = []\n",
" list3.append(code)\n",
" list3.append(content['code'])\n",
" list3.append(dict1[code]['name'])\n",
" list3.append(dict1[code]['sex'])\n",
" list3.append(dict1[code]['unit'])\n",
" list3.append(phone_num)\n",
" list2.append(list3)\n",
"filename = 'data/南化未参加问卷人员情况表(202512).xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"#sheet.append(title)\n",
"for row in list2:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename) "
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "676c8816-28eb-4914-97c1-bc0a3c7896e7",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-17T09:26:57.896010Z",
"iopub.status.busy": "2025-12-17T09:26:57.895164Z",
"iopub.status.idle": "2025-12-17T09:26:57.919497Z",
"shell.execute_reply": "2025-12-17T09:26:57.918911Z",
"shell.execute_reply.started": "2025-12-17T09:26:57.895933Z"
}
},
"outputs": [],
"source": [
"import json\n",
"import csv\n",
"import openpyxl\n",
"import time\n",
"from datetime import date\n",
"\n",
"\n",
"filename = 'data/南京化工人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"phone = set()\n",
"\n",
"filename = 'data/sql_20251217.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",
"list2 = []\n",
"for item in list1:\n",
" phone_num = str(item[0])[2:]\n",
" phone.add(phone_num)\n",
"for k,v in dict1.items():\n",
" if str(v['phone']) not in phone:\n",
" \n",
" list3 = []\n",
" list3.append(k)\n",
" list3.append(v['name'])\n",
" list3.append(v['sex'])\n",
" list3.append(v['unit'])\n",
" list3.append(v['phone'])\n",
" list2.append(list3)\n",
"filename = 'data/南化未参加问卷人员情况表(202512).xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"#sheet.append(title)\n",
"for row in list2:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename) "
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -588,11 +988,35 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7392d5bf-c6a8-4cdf-8653-0fb4961f1405",
"cell_type": "markdown",
"id": "72f1a3a9-ae54-4e6f-ab7f-a06771c42b28",
"metadata": {},
"outputs": [],
"source": [
"## 导入问卷信息(20251219)"
]
},
{
"cell_type": "code",
"execution_count": 43,
"id": "235939f8-6072-4f72-8e83-bcbdd911125f",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-19T12:28:44.188661Z",
"iopub.status.busy": "2025-12-19T12:28:44.188060Z",
"iopub.status.idle": "2025-12-19T12:28:44.219189Z",
"shell.execute_reply": "2025-12-19T12:28:44.218579Z",
"shell.execute_reply.started": "2025-12-19T12:28:44.188607Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"78\n"
]
}
],
"source": [
"import json\n",
"import csv\n",
@@ -601,21 +1025,60 @@
"from datetime import date\n",
"\n",
"\n",
"dict1 = {}\n",
"filename = f'data/南京化工人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"filename = f'data/result_南京化工(2512).json'\n",
"with open(filename,'r') as fl:\n",
" dict3 = json.load(fl)\n",
"list1 = []\n",
"filename = 'data/sql_20251027.csv'\n",
"filename = 'data/sql_20251219-1.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",
"nn = 0\n",
"nn = 1\n",
"i =1\n",
"dict4 = {}\n",
"for item in list1:\n",
" dict2 = {}\n",
" \n",
" phone = str(item[0])[2:]\n",
" content = json.loads(item[1])\n",
" print(type(json.loads(content)))"
" content = json.loads(json.loads(item[1]))\n",
" tcm = []\n",
" for i in range(0,60):\n",
" tcm.append(0)\n",
" for k, v in content.items(): \n",
" if 'tcm' not in k:\n",
" dict2[k] = v\n",
" else:\n",
" i = int(k[3:])\n",
" tcm[i-1] = int(v)\n",
" \n",
" code = str(int(dict2['code']))\n",
" if code in dict3.keys():\n",
" dict3[code]['waist'] = dict2['waist']\n",
" dict3[code]['hip'] = dict2['hip']\n",
" dict3[code]['tcm'] = tcm\n",
" elif code in dict1.keys():\n",
" dict3[code] = dict1[code]\n",
" birth = date.fromisoformat(dict3[code]['birth'].replace('/','-'))\n",
" rq = date.fromisoformat(item[2].replace('/','-').split(' ')[0])\n",
" days = (rq-birth).days \n",
" dict3[code]['age'] = int(days/365)\n",
" dict3[code]['month'] = int(days/365*12)\n",
" \n",
" dict3[code]['waist'] = dict2['waist']\n",
" dict3[code]['hip'] = dict2['hip']\n",
" dict3[code]['tcm'] = tcm\n",
" \n",
"filename = 'data/result_南京化工(2512)-1.json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict3, fl, ensure_ascii=False)\n",
"print(len(dict3))"
]
},
{
@@ -671,15 +1134,15 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 40,
"id": "e233e6c3-9c3f-42c7-8057-012bbcfe8b26",
"metadata": {
"execution": {
"iopub.execute_input": "2025-10-28T02:58:52.451889Z",
"iopub.status.busy": "2025-10-28T02:58:52.451452Z",
"iopub.status.idle": "2025-10-28T02:58:52.546239Z",
"shell.execute_reply": "2025-10-28T02:58:52.545487Z",
"shell.execute_reply.started": "2025-10-28T02:58:52.451850Z"
"iopub.execute_input": "2025-12-19T12:21:00.570832Z",
"iopub.status.busy": "2025-12-19T12:21:00.570241Z",
"iopub.status.idle": "2025-12-19T12:21:00.617789Z",
"shell.execute_reply": "2025-12-19T12:21:00.617186Z",
"shell.execute_reply.started": "2025-12-19T12:21:00.570776Z"
}
},
"outputs": [
@@ -1306,8 +1769,181 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 47,
"id": "1b9d4042-5e73-44e3-8079-eee2c5be1858",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-19T12:34:33.579089Z",
"iopub.status.busy": "2025-12-19T12:34:33.578712Z",
"iopub.status.idle": "2025-12-19T12:34:33.629552Z",
"shell.execute_reply": "2025-12-19T12:34:33.629034Z",
"shell.execute_reply.started": "2025-12-19T12:34:33.579053Z"
}
},
"outputs": [],
"source": [
"import openpyxl\n",
"\n",
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp']\n",
"filename = 'data/result_南京化工(2512)-1.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"data_list = []\n",
"for k, v in dict1.items():\n",
" list6 = []\n",
" list6.append(str(k).rjust(4,'0'))\n",
" list6.append(v['name'])\n",
" list6.append(v['sex'])\n",
" list6.append(v['unit'])\n",
" list6.append(v['age'])\n",
" if 'bmi' in v.keys():\n",
" bmi = v['bmi']['成绩']\n",
" list6.append(bmi.split(',')[0]+' 厘米')\n",
" list6.append(bmi.split(',')[1]+' 千克')\n",
" list6.append(v['bmi']['score'])\n",
" else:\n",
" list6.append('')\n",
" list6.append('')\n",
" list6.append('')\n",
" for xm in list_item:\n",
" if xm in v.keys():\n",
" list6.append(v[xm]['成绩'])\n",
" list6.append(v[xm]['score'])\n",
" else:\n",
" list6.append('')\n",
" list6.append('')\n",
" if 'waist' in v.keys():\n",
" list6.append(v['waist'])\n",
" else:\n",
" list6.append('')\n",
" if 'hip' in v.keys():\n",
" list6.append(v['hip'])\n",
" else:\n",
" list6.append('')\n",
" if 'tcm' in v.keys():\n",
" list1 = []\n",
" tcm =v['tcm']\n",
" for item in tcm:\n",
" list1.append(item)\n",
" score = tcm_calc(list1)\n",
"\n",
" result = tcm_kind(score)\n",
" kind = result['kind']\n",
" near = result['near']\n",
" #print(k,kinds[kind], near, score)\n",
" list6.append(kinds[kind])\n",
" if near:\n",
" list6.append('是')\n",
" else:\n",
" list6.append('')\n",
" for item in score:\n",
" list6.append(item)\n",
" else:\n",
" for i in range(0,11):\n",
" list6.append('')\n",
" i+=1\n",
" \n",
" data_list.append(list6)\n",
"filename = 'data/南京化工(2512).xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"title = ['编号', '姓名', '性别', '单位/部门', '年龄', '身高', '体重', 'bmi', '肺活量', '得分', '握力', '得分', '坐位体前屈', '得分', '纵跳', '得分', '俯卧撑', '得分', '单脚站立', '得分', '选择反应时', '得分', '台阶指数', '得分', '一分钟仰卧起坐', '得分','腰围','臀围','中医体质', '是否倾向', '平和', '气虚', '阳虚', '阴虚', '痰湿', '湿热', '血瘀', '气郁', '特禀']\n",
"sheet.append(title)\n",
"for row in data_list:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename) "
]
},
{
"cell_type": "code",
"execution_count": 56,
"id": "7e3a34a5-5e00-4594-b78f-c8529c5eccfd",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-19T13:06:03.574275Z",
"iopub.status.busy": "2025-12-19T13:06:03.573467Z",
"iopub.status.idle": "2025-12-19T13:06:47.044868Z",
"shell.execute_reply": "2025-12-19T13:06:47.043893Z",
"shell.execute_reply.started": "2025-12-19T13:06:03.574203Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"78\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_南京化工(2512)-1.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
"file_path ='./南京化工(202512)/'\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(8,\"0\")\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','psy','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": "code",
"execution_count": null,
"id": "02b19f4d-466d-4370-8638-17b02159c28d",
"metadata": {},
"outputs": [],
"source": []
+451 -69
View File
@@ -1037,7 +1037,7 @@
}
],
"source": [
"##### import json\n",
"import json\n",
"import csv\n",
"import openpyxl\n",
"import time\n",
@@ -1095,6 +1095,79 @@
"print(len(dict1),'ok')"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "02d82c2a-2319-4c0b-be58-0a1b107fdc35",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-22T07:38:35.217789Z",
"iopub.status.busy": "2025-12-22T07:38:35.217210Z",
"iopub.status.idle": "2025-12-22T07:38:35.238667Z",
"shell.execute_reply": "2025-12-22T07:38:35.238165Z",
"shell.execute_reply.started": "2025-12-22T07:38:35.217760Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"111 ok\n"
]
}
],
"source": [
"import json\n",
"import csv\n",
"import openpyxl\n",
"import time\n",
"from datetime import date\n",
"\n",
"filename = 'data/宁夏能化高危风险干预人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict3 = json.load(fl)\n",
" \n",
"dict1 = {}\n",
"list1 = []\n",
"filename = 'data/sql_20251222.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",
"\n",
"nn = 0\n",
"for item in list1:\n",
" dict2 = {}\n",
" \n",
" phone = str(item[0])[2:]\n",
" content = json.loads(json.loads(item[1]))\n",
" tcm = []\n",
" for i in range(0,60):\n",
" tcm.append(0)\n",
" for k, v in content.items(): \n",
" if 'tcm' not in k:\n",
" dict2[k] = v\n",
" else:\n",
" i = int(k[3:])\n",
" tcm[i-1] = int(v)\n",
" \n",
" code = str(int(dict2['code']))\n",
" if code in dict3.keys():\n",
" dict1[code] = dict3[code]\n",
" dict1[code]['waist'] = dict2['waist']\n",
" dict1[code]['hip'] = dict2['hip']\n",
" dict1[code]['tcm'] = tcm \n",
" \n",
"\n",
"filename = 'data/survey_宁夏能化高危风险干预人员(202512).json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False)\n",
"print(len(dict1),'ok')"
]
},
{
"cell_type": "markdown",
"id": "c4486c37-d1a4-460f-9997-6405c51b805c",
@@ -1105,15 +1178,15 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 26,
"id": "34cb26d7-cd7b-4ad5-bb7b-71cfcce16c24",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-09T09:51:13.116856Z",
"iopub.status.busy": "2025-12-09T09:51:13.116051Z",
"iopub.status.idle": "2025-12-09T09:51:13.133080Z",
"shell.execute_reply": "2025-12-09T09:51:13.132231Z",
"shell.execute_reply.started": "2025-12-09T09:51:13.116787Z"
"iopub.execute_input": "2025-12-22T07:39:25.697010Z",
"iopub.status.busy": "2025-12-22T07:39:25.696512Z",
"iopub.status.idle": "2025-12-22T07:39:25.707108Z",
"shell.execute_reply": "2025-12-22T07:39:25.706358Z",
"shell.execute_reply.started": "2025-12-22T07:39:25.696961Z"
}
},
"outputs": [],
@@ -1179,15 +1252,15 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 27,
"id": "d78c0f3f-cd1a-4c6c-9f5b-b1b874a95fe3",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-09T09:52:01.947920Z",
"iopub.status.busy": "2025-12-09T09:52:01.947633Z",
"iopub.status.idle": "2025-12-09T09:52:01.999096Z",
"shell.execute_reply": "2025-12-09T09:52:01.998620Z",
"shell.execute_reply.started": "2025-12-09T09:52:01.947897Z"
"iopub.execute_input": "2025-12-22T07:40:30.226248Z",
"iopub.status.busy": "2025-12-22T07:40:30.225697Z",
"iopub.status.idle": "2025-12-22T07:40:30.260291Z",
"shell.execute_reply": "2025-12-22T07:40:30.259853Z",
"shell.execute_reply.started": "2025-12-22T07:40:30.226194Z"
}
},
"outputs": [],
@@ -1195,7 +1268,7 @@
"import openpyxl\n",
"\n",
"\n",
"filename = 'data/survey_宁夏能化高危风险干预人员.json'\n",
"filename = 'data/survey_宁夏能化高危风险干预人员(202512).json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"data_list = []\n",
@@ -1233,7 +1306,7 @@
" i+=1\n",
" \n",
" data_list.append(list6)\n",
"filename = 'data/宁夏能化高危风险干预人员体质问卷明细表(20251209).xlsx'\n",
"filename = 'data/宁夏能化高危风险干预人员体质问卷明细表(20251222).xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"title = ['编号', '姓名', '性别', '单位/部门', '年龄', '腰围', '臀围', '中医体质', '是否倾向', '平和', '气虚', '阳虚', '阴虚', '痰湿', '湿热', '血瘀', '气郁', '特禀']\n",
@@ -1308,15 +1381,15 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 15,
"id": "22be8f39-afbb-448a-8ae6-c825c7d38757",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-14T23:43:21.978932Z",
"iopub.status.busy": "2025-12-14T23:43:21.978409Z",
"iopub.status.idle": "2025-12-14T23:43:22.273147Z",
"shell.execute_reply": "2025-12-14T23:43:22.272647Z",
"shell.execute_reply.started": "2025-12-14T23:43:21.978883Z"
"iopub.execute_input": "2025-12-22T03:43:54.245786Z",
"iopub.status.busy": "2025-12-22T03:43:54.245059Z",
"iopub.status.idle": "2025-12-22T03:43:54.418251Z",
"shell.execute_reply": "2025-12-22T03:43:54.417770Z",
"shell.execute_reply.started": "2025-12-22T03:43:54.245721Z"
}
},
"outputs": [],
@@ -1327,7 +1400,7 @@
"\n",
"title = []\n",
"\n",
"filename = 'data/surveys_records_2025-12-15.json'\n",
"filename = 'data/surveys_records_2025-12-22.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
@@ -1352,7 +1425,7 @@
" \n",
" list1.append(list2)\n",
"all_title = ['id', 'date_created','name', 'gender', 'birth', 'code', 'unit', 'height', 'weight', 'next_weight', 'waist', 'hip', 'level4', 'level3', 'level2', 'recipe', 'level1', 'last_level4', 'last_level3', 'last_level2', 'last_level1', 'last_recipe', 'last_lose', 'last_sport', 'sport_type', 'sport_duration', 'last_sport_time', 'last_lose-Comment', 'last_recipe-Comment', 'last_lose_weight', 'last_sport-Comment', 'sport_type-Comment']\n",
"filename = 'data/宁夏能化干预人员问卷(20251215).xlsx'\n",
"filename = 'data/宁夏能化干预人员问卷(20251222).xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(all_title)\n",
@@ -1388,15 +1461,15 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 16,
"id": "91c53866-3725-4ceb-b0eb-23fb14e20561",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-14T23:43:35.251673Z",
"iopub.status.busy": "2025-12-14T23:43:35.251057Z",
"iopub.status.idle": "2025-12-14T23:43:35.339896Z",
"shell.execute_reply": "2025-12-14T23:43:35.339186Z",
"shell.execute_reply.started": "2025-12-14T23:43:35.251623Z"
"iopub.execute_input": "2025-12-22T03:44:05.908310Z",
"iopub.status.busy": "2025-12-22T03:44:05.907768Z",
"iopub.status.idle": "2025-12-22T03:44:06.062310Z",
"shell.execute_reply": "2025-12-22T03:44:06.061610Z",
"shell.execute_reply.started": "2025-12-22T03:44:05.908261Z"
}
},
"outputs": [
@@ -1404,24 +1477,26 @@
"name": "stdout",
"output_type": "stream",
"text": [
"('梁正武', '男', '电气仪表中心', '1984-05-01', '02018801', 1)\n",
"('张艳萍', '女', '公用工程运行部', '1978-09-01', '02020548', 1)\n",
"('叶云飞', '男', '公用工程运行部', '1985-11-01', '02019460', 1)\n",
"('李效龙', '男', 'BDO运行部', '1987-09-01', '0201968', 1)\n",
"('何富来', '男', '宁夏能化', '1983-03-01', '02019507', 1)\n",
"('马荣', '女', '公用工程运行部', '1984-03-01', '02020205', 1)\n",
"('刘永清', '男', '热电运行部', '1968-10-01', '02019958', 1)\n",
"('马学锋', '男', '热电运行部', '1974-12-01', '02020025', 1)\n",
"('段庆霖', '男', '热电运行部', '1990-02-01', '02020062', 1)\n",
"('周卫星', '男', '热电运行部', '1970-05-01', '02019986', 1)\n",
"('姚户昌', '男', '热电运行部', '1970-12-01', '02019968', 1)\n",
"('姜德溪', '男', '热电运行部', '1970-01-01', '2019970', 1)\n",
"('陈海宝', '男', '乙炔运行部', '1990-07-01', '02019346', 1)\n",
"('丁红忠', '男', '热电运行部', '1990-09-01', '02020160', 1)\n",
"('孙柏', '男', '环保建材运行部', '1982-03-01', '02020446', 1)\n",
"('黄博', '男', '物资采购中心', '1995-12-01', '03391681', 1)\n",
"('王正东', '男', '热电运行部', '1990-01-01', '03428864', 1)\n",
"17\n"
"('汪晖', '男', '销售中心', '1971-02-01', '02019646', 1)\n",
"('马燕金', '男', '销售中心', '1983-04-01', '02018528', 1)\n",
"('孙皓', '男', '销售中心', '1990-10-01', '02019111', 1)\n",
"('李润良', '男', '环保建材运行部', '1992-06-01', '03427471', 1)\n",
"('王春光', '男', '环保建材运行部', '1969-12-01', '02020528', 1)\n",
"('户利平', '男', '环保建材运行部', '1969-08-01', '02020512', 1)\n",
"('马婉婷', '女', '公用工程运行部', '2001-11-01', '03561578', 1)\n",
"('储方伟', '男', '环保建材运行部', '1976-01-01', '02020483', 1)\n",
"('马斯勇', '男', '环保建材运行部', '1987-08-01', '02020525', 1)\n",
"('康磊', '男', '公用工程运行部', '1987-07-01', '02020289', 1)\n",
"('王涛', '男', '环保建材运行部', '1982-07-01', '00000521', 1)\n",
"('杨德忠', '男', '公用工程运行部', '1972-11-01', '02020306', 1)\n",
"('杨思国', '男', '电气仪表中心', '1981-04-01', '02018877', 1)\n",
"('党金广', '男', '电气仪表中心', '1987-08-01', '02018839', 1)\n",
"('张锋', '男', '电气仪表中心', '1971-05-01', '02020003', 1)\n",
"('张磊', '男', '电气仪表中心', '1989-12-01', '02018949', 1)\n",
"('秦国振', '男', '电气仪表中心', '1997-07-01', '03462294', 1)\n",
"('陈龙', '男', '电气仪表中心', '1981-05-01', '02018914', 1)\n",
"('朱岳峰', '男', '电气仪表中心', '1988-02-01', '02018865', 1)\n",
"19\n"
]
}
],
@@ -1437,7 +1512,7 @@
" password=\"songyi\"\n",
")\n",
"cur = conn.cursor()\n",
"wb = openpyxl.load_workbook('data/宁夏能化干预人员问卷(20251215).xlsx',data_only=True)\n",
"wb = openpyxl.load_workbook('data/宁夏能化干预人员问卷(20251222).xlsx',data_only=True)\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"org_id = 1\n",
@@ -1571,15 +1646,15 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 20,
"id": "b7133988-213c-4b52-8d6b-17b56b8ea310",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-14T23:43:56.303850Z",
"iopub.status.busy": "2025-12-14T23:43:56.303555Z",
"iopub.status.idle": "2025-12-14T23:43:56.413335Z",
"shell.execute_reply": "2025-12-14T23:43:56.412897Z",
"shell.execute_reply.started": "2025-12-14T23:43:56.303825Z"
"iopub.execute_input": "2025-12-22T03:49:22.646173Z",
"iopub.status.busy": "2025-12-22T03:49:22.645514Z",
"iopub.status.idle": "2025-12-22T03:49:22.842656Z",
"shell.execute_reply": "2025-12-22T03:49:22.842110Z",
"shell.execute_reply.started": "2025-12-22T03:49:22.646116Z"
}
},
"outputs": [
@@ -1587,7 +1662,313 @@
"name": "stdout",
"output_type": "stream",
"text": [
"108 ok\n"
"02019646\n",
"2018434\n",
"02018586\n",
"02018444\n",
"02020443\n",
"02020415\n",
"02018446\n",
"2018447\n",
"03533284\n",
"02020243\n",
"02019374\n",
"02020238\n",
"02019952\n",
"03497967\n",
"02018709\n",
"02019342\n",
"02019620\n",
"02020203\n",
"02018528\n",
"02019111\n",
"02018482\n",
"02018481\n",
"02018628\n",
"02018498\n",
"02018499\n",
"964089\n",
"0214545\n",
"02020481\n",
"2018609\n",
"01348929\n",
"02020526\n",
"03427471\n",
"02020196\n",
"02020528\n",
"2019094\n",
"02020512\n",
"02020476\n",
"03561578\n",
"0003533364\n",
"02019294\n",
"02020483\n",
"02020527\n",
"02020467\n",
"02020296\n",
"02020525\n",
"02020289\n",
"03434760\n",
"02018435\n",
"2019094\n",
"02019688\n",
"02019688\n",
"03561564\n",
"02020346\n",
"02020458\n",
"00000521\n",
"02020306\n",
"02019655\n",
"02020189\n",
"02019787\n",
"02019787\n",
"02018611\n",
"02018566\n",
"02018645\n",
"02019485\n",
"02020127\n",
"02019054\n",
"2019006\n",
"028415\n",
"03462271\n",
"02028323\n",
"02020492\n",
"02018794\n",
"02018877\n",
"02018926\n",
"02018809\n",
"02018938\n",
"02020083\n",
"02018839\n",
"2018985\n",
"02019866\n",
"02018793\n",
"03428863\n",
"02019017\n",
"02018981\n",
"02020003\n",
"03462285\n",
"02018626\n",
"02018604\n",
"02018892\n",
"02018827\n",
"02018949\n",
"02019599\n",
"02019622\n",
"02018575\n",
"2018438\n",
"02019613\n",
"03363370\n",
"01702447\n",
"020186\n",
"02018709\n",
"03497967\n",
"0201968\n",
"02019641\n",
"02018709\n",
"02019697\n",
"02019021\n",
"0435\n",
"02018685\n",
"02018772\n",
"02019620\n",
"03497960\n",
"02019888\n",
"02019682\n",
"03391642\n",
"03462294\n",
"02018914\n",
"2019961\n",
"02018859\n",
"02019377\n",
"02017961\n",
"02018607\n",
"02018865\n",
"02020277\n",
"02020251\n",
"02020321\n",
"03391661\n",
"02020276\n",
"02019062\n",
"02019887\n",
"03148213\n",
"2019822\n",
"02019840\n",
"02019790\n",
"02019819\n",
"02019754\n",
"03437945\n",
"02019749\n",
"02019111\n",
"03418292\n",
"02019764\n",
"02019744\n",
"02019734\n",
"02019374\n",
"02019778\n",
"02019788\n",
"02019725\n",
"02017961\n",
"02019751\n",
"02020282\n",
"02019856\n",
"02019832\n",
"02019848\n",
"03437965\n",
"02019954\n",
"02020052\n",
"02019820\n",
"02019893\n",
"02019752\n",
"02019784\n",
"02020343\n",
"02019810\n",
"2019735\n",
"02019023\n",
"02020327\n",
"02019852\n",
"02018538\n",
"02018977\n",
"2018942\n",
"02019898\n",
"02019794\n",
"02019805\n",
"02019342\n",
"02019895\n",
"02019154\n",
"02019775\n",
"3391687\n",
"02019917\n",
"02018754\n",
"03418302\n",
"02019738\n",
"03462274\n",
"03561561\n",
"02019783\n",
"02018967\n",
"2019324\n",
"02019355\n",
"02019003\n",
"02019377\n",
"02019803\n",
"02019311\n",
"02019346\n",
"02019525\n",
"02020502\n",
"03497957\n",
"02020242\n",
"02019347\n",
"3418215\n",
"02019340\n",
"02019773\n",
"0219181\n",
"02019336\n",
"02019340\n",
"02018999\n",
"02019357\n",
"02019100\n",
"02019430\n",
"02019356\n",
"03418230\n",
"03437952\n",
"03437952\n",
"02019231\n",
"03497937\n",
"03497917\n",
"02019318\n",
"03462262\n",
"02019110\n",
"2019919\n",
"02019382\n",
"03497562\n",
"02019369\n",
"03391686\n",
"02019736\n",
"02019786\n",
"02019411\n",
"3391674\n",
"02018727\n",
"02019035\n",
"02019350\n",
"02019414\n",
"2019353\n",
"2019353\n",
"2019493\n",
"02019903\n",
"02019825\n",
"02019802\n",
"03394941\n",
"02020243\n",
"2019914\n",
"02019164\n",
"02019467\n",
"03437937\n",
"02019366\n",
"02019344\n",
"2019930\n",
"02019910\n",
"02019647\n",
"02019843\n",
"01825596\n",
"02019882\n",
"03409694\n",
"02019391\n",
"02019389\n",
"02019301\n",
"02020005\n",
"02019920\n",
"02019498\n",
"02019373\n",
"02019733\n",
"2019998\n",
"02020000\n",
"02019401\n",
"02019901\n",
"03418242\n",
"02019383\n",
"02019438\n",
"02019871\n",
"02019193\n",
"02019635\n",
"02020203\n",
"02019098\n",
"02019459\n",
"02018996\n",
"02019499\n",
"02019687\n",
"02018674\n",
"02019059\n",
"02019059\n",
"2019845\n",
"2018609\n",
"02019379\n",
"02020006\n",
"2019923\n",
"02019774\n",
"02019068\n",
"020294\n",
"03403228\n",
"3019337\n",
"02018711\n",
"03462315\n",
"02019739\n",
"02019278\n",
"02019416\n",
"2018973\n",
"02019256\n",
"02019878\n",
"02019664\n",
"02019404\n",
"02019058\n",
"02019504\n",
"02019361\n",
"02019600\n",
"02019381\n",
"02019248\n",
"02019543\n",
"02019648\n",
"02020260\n",
"287 ok\n"
]
}
],
@@ -1595,22 +1976,23 @@
"import json\n",
"import openpyxl\n",
"\n",
"wb = openpyxl.load_workbook('data/宁夏能化干预人员问卷(20251215).xlsx',data_only=True)\n",
"wb = openpyxl.load_workbook('data/宁夏能化干预人员问卷(20251222).xlsx',data_only=True)\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"person = {}\n",
"for n in range(2, sheet.max_row+1):\n",
" code = str(sheet.cell(n, 6).value)\n",
" print(code)\n",
" person.setdefault(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 3).value\n",
" dict1['sex'] = sheet.cell(n, 4).value\n",
" birth = str(sheet.cell(n, 5).value).split()[0]\n",
" if len(birth)<10:\n",
" nian = birth.split('-')[0]\n",
" yue = birth.split('-')[1].rjust(2,'0')\n",
" if len(birth.split('-')[0]) ==3:\n",
" ri = birth.split('-')[2].rjust(2,'0')\n",
" nian = birth.replace('/','-').split('-')[0]\n",
" yue = birth.replace('/','-').split('-')[1].rjust(2,'0')\n",
" if len(birth.replace('/','-').split('-')[0]) ==3:\n",
" ri = birth.replace('/','-').split('-')[2].rjust(2,'0')\n",
" else:\n",
" ri = '01' \n",
" dict1['birth'] = nian+'-'+ yue + '-'+ ri\n",
@@ -1618,7 +2000,7 @@
" person[code] = dict1\n",
"#print(person)\n",
"\n",
"filename = 'data/surveys_records_2025-12-10.json'\n",
"filename = 'data/surveys_records_2025-12-22.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
@@ -1676,7 +2058,7 @@
" dict2['last_lose-Comment'] = data['last_lose-Comment']\n",
" if code in person.keys():\n",
" person[code][rq] = dict2\n",
"filename = 'data/宁夏能化干预人员问卷情况(20251215).json'\n",
"filename = 'data/宁夏能化干预人员问卷情况(20251222).json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
@@ -1694,15 +2076,15 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 21,
"id": "55b20059-ae36-493e-b0c5-c7e35473efc7",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-14T23:44:12.601625Z",
"iopub.status.busy": "2025-12-14T23:44:12.600884Z",
"iopub.status.idle": "2025-12-14T23:44:12.741676Z",
"shell.execute_reply": "2025-12-14T23:44:12.741060Z",
"shell.execute_reply.started": "2025-12-14T23:44:12.601562Z"
"iopub.execute_input": "2025-12-22T03:49:42.115930Z",
"iopub.status.busy": "2025-12-22T03:49:42.114895Z",
"iopub.status.idle": "2025-12-22T03:49:43.037249Z",
"shell.execute_reply": "2025-12-22T03:49:43.036729Z",
"shell.execute_reply.started": "2025-12-22T03:49:42.115872Z"
}
},
"outputs": [],
@@ -1721,7 +2103,7 @@
"cur = conn.cursor()\n",
"event_id = 1\n",
"org_id = 1\n",
"filename = 'data/宁夏能化干预人员问卷情况(20251215).json'\n",
"filename = 'data/宁夏能化干预人员问卷情况(20251222).json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = ['name','sex','birth','unit']\n",
@@ -85,7 +85,7 @@
"id": "2ce125a6-a42f-4dd1-8c9c-a6a4ebcfce65",
"metadata": {},
"source": [
"## 体测人员导入(2025年11月)"
"### 体测人员导入(2025年11月)"
]
},
{
@@ -123,6 +123,67 @@
"print(len(person),'ok')"
]
},
{
"cell_type": "markdown",
"id": "22b07903-00a2-437a-b7fc-73723496fe50",
"metadata": {},
"source": [
"### 体测人员导入(乒乓球高阶培训班)"
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "e08d1b73-ddbd-434e-a843-2c28803a7725",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-22T10:51:18.804347Z",
"iopub.status.busy": "2025-12-22T10:51:18.804029Z",
"iopub.status.idle": "2025-12-22T10:51:18.825533Z",
"shell.execute_reply": "2025-12-22T10:51:18.825029Z",
"shell.execute_reply.started": "2025-12-22T10:51:18.804321Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"48 ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"\n",
"wb = openpyxl.load_workbook('data/新疆油田乒乓球高阶培训班成员名单.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, 1).value)\n",
" person.setdefault(str(code), {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 3).value\n",
" dict1['sex'] = sheet.cell(n, 4).value\n",
" if sheet.cell(n,2).value is not None:\n",
" dict1['unit'] = sheet.cell(n, 2).value\n",
" else:\n",
" dict1['unit'] = ''\n",
" dict1['birth'] = str(sheet.cell(n, 7).value).replace('/','-').split(' ')[0]\n",
" dict1['phone'] = sheet.cell(n,6).value \n",
" dict1['age'] = int(sheet.cell(n,5).value) \n",
" dict1['month'] = int(sheet.cell(n,5).value)*12\n",
" person[code] = dict1\n",
"filename = 'data/新疆油田乒乓球高阶培训班.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
"print(len(person),'ok')"
]
},
{
"cell_type": "markdown",
"id": "6bcd45c2-10af-4d5f-9e0b-5cd1df4f7a7f",
@@ -185,6 +246,48 @@
"print(len(re_ta))"
]
},
{
"cell_type": "code",
"execution_count": 37,
"id": "eb757f8a-8a98-47e5-a9db-a361da70dd54",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-22T10:59:29.789147Z",
"iopub.status.busy": "2025-12-22T10:59:29.788475Z",
"iopub.status.idle": "2025-12-22T10:59:29.801239Z",
"shell.execute_reply": "2025-12-22T10:59:29.800106Z",
"shell.execute_reply.started": "2025-12-22T10:59:29.789091Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"24\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/新疆油田乒乓球高阶培训班.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"filename = 'data/marks_20251222.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": "e75065f5-127e-49c9-bc1f-c0843ab1996b",
@@ -229,10 +332,26 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 40,
"id": "0905ad6a-f7e4-43ed-ae29-c4850deb946b",
"metadata": {},
"outputs": [],
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-22T11:00:30.947600Z",
"iopub.status.busy": "2025-12-22T11:00:30.946785Z",
"iopub.status.idle": "2025-12-22T11:00:30.964388Z",
"shell.execute_reply": "2025-12-22T11:00:30.963715Z",
"shell.execute_reply.started": "2025-12-22T11:00:30.947526Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok!\n"
]
}
],
"source": [
"import json\n",
"import time\n",
@@ -240,7 +359,7 @@
"\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_新疆油田采油工艺研究院1.json'\n",
"filename = 'data/result_新疆油田乒乓球高阶培训班.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl) \n",
"for k, v in dict2.items():\n",
@@ -263,7 +382,7 @@
" dict2[k][item_en]['score'] = My.cal_score(data1)\n",
" #print(k,v[item_en]['成绩'],cal_score(data1))\n",
"\n",
"filename = f'data/result_新疆油田采油工艺研究院1-1.json'\n",
"filename = f'data/result_新疆油田乒乓球高阶培训班.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict2,fl , ensure_ascii=False) \n",
"print('ok!') "
@@ -438,15 +557,15 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 26,
"id": "f4fc0e48-5c8a-4ad9-817e-dd8dd1bf7b55",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-15T00:10:27.023346Z",
"iopub.status.busy": "2025-12-15T00:10:27.023028Z",
"iopub.status.idle": "2025-12-15T00:10:27.028151Z",
"shell.execute_reply": "2025-12-15T00:10:27.027670Z",
"shell.execute_reply.started": "2025-12-15T00:10:27.023320Z"
"iopub.execute_input": "2025-12-18T14:06:54.465137Z",
"iopub.status.busy": "2025-12-18T14:06:54.464816Z",
"iopub.status.idle": "2025-12-18T14:06:54.472416Z",
"shell.execute_reply": "2025-12-18T14:06:54.471751Z",
"shell.execute_reply.started": "2025-12-18T14:06:54.465112Z"
}
},
"outputs": [
@@ -454,14 +573,14 @@
"name": "stdout",
"output_type": "stream",
"text": [
"2025-07-03 2025-08-18\n"
"2025-06-27 2025-07-02\n"
]
}
],
"source": [
"import json\n",
"\n",
"filename = 'data/result_新疆油田采油工艺研究院1-1.json'\n",
"filename = 'data/result_南京化工-1.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
@@ -826,6 +945,107 @@
"print(len(dict1))"
]
},
{
"cell_type": "markdown",
"id": "27047aae-81ad-4996-85af-ec77c5f33db5",
"metadata": {},
"source": [
"### 导入问卷信息(乒乓球高阶培训班)"
]
},
{
"cell_type": "code",
"execution_count": 41,
"id": "01ee701f-af8c-48ff-ad3c-2315c1ce16d7",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-22T11:00:47.106304Z",
"iopub.status.busy": "2025-12-22T11:00:47.105790Z",
"iopub.status.idle": "2025-12-22T11:00:47.126495Z",
"shell.execute_reply": "2025-12-22T11:00:47.125968Z",
"shell.execute_reply.started": "2025-12-22T11:00:47.106259Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"24\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_20251222-1.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/新疆油田乒乓球高阶培训班.json'\n",
"with open(filename,'r') as fl:\n",
" dict3 = json.load(fl)\n",
"filename = 'data/result_新疆油田乒乓球高阶培训班.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",
" psy = []\n",
" for i in range(0,45):\n",
" psy.append(0)\n",
" psy[44] = []\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 'psy' in k:\n",
" i = int(k[3:])\n",
" psy[i-1] = int(v)\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",
" for i in range(26,40):\n",
" new_valve = 1+psy[i]\n",
" psy[i] = new_valve \n",
" code = phone[phone_num]\n",
" if code in dict3.keys(): \n",
" dict1[code]['tcm'] = tcm \n",
" dict1[code]['spine'] = spine\n",
" dict1[code]['psy'] = psy\n",
"filename = 'data/result_新疆油田乒乓球高阶培训班.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False)\n",
"print(len(dict1))"
]
},
{
"cell_type": "markdown",
"id": "8d5f4103-0d1e-4711-b324-ece360f8dcd3",
@@ -1038,6 +1258,90 @@
"print(i)"
]
},
{
"cell_type": "code",
"execution_count": 42,
"id": "635709b0-5777-481f-8639-6988b8e31d82",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-22T11:00:53.865364Z",
"iopub.status.busy": "2025-12-22T11:00:53.864923Z",
"iopub.status.idle": "2025-12-22T11:01:08.186681Z",
"shell.execute_reply": "2025-12-22T11:01:08.186051Z",
"shell.execute_reply.started": "2025-12-22T11:00:53.865321Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"24\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_新疆油田乒乓球高阶培训班.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"file_path ='./新疆油田乒乓球高阶培训班/'\n",
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
"i=0\n",
"#list2 = ['185','186','187','188','189','190','191','192','193','194','195','196','197','198']\n",
"for k, v in dict1.items():\n",
" \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','psy','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",
" 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",
"id": "ffb6c02a-8ae1-4332-96ca-ce541bfbf0be",