This commit is contained in:
512song committed 2025-11-19 19:44:42 +08:00
1 parent 31ddcb887f
commit 4f0f65a076
6 files changed
+1896 -136

No files matched your search

+203 -30
View File
@@ -946,27 +946,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 18, "execution_count": null,
"id": "02319955-7fb6-4791-ae45-55b03bdadd54", "id": "02319955-7fb6-4791-ae45-55b03bdadd54",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2025-11-17T14:25:08.413467Z",
"iopub.status.busy": "2025-11-17T14:25:08.412602Z",
"iopub.status.idle": "2025-11-17T14:25:08.498336Z",
"shell.execute_reply": "2025-11-17T14:25:08.497785Z",
"shell.execute_reply.started": "2025-11-17T14:25:08.413400Z"
},
"tags": [] "tags": []
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [ "source": [
"import os,sys,shutil\n", "import os,sys,shutil\n",
"import json\n", "import json\n",
@@ -1656,7 +1641,7 @@
"import openpyxl\n", "import openpyxl\n",
"\n", "\n",
"\n", "\n",
"filename = 'data/result_镇海2025.json'\n", "filename = 'data/result_北海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",
"\n", "\n",
@@ -1684,7 +1669,6 @@
"for k, v in dict1.items():\n", "for k, v in dict1.items():\n",
" list1 = []\n", " list1 = []\n",
" mydata = {}\n", " mydata = {}\n",
" \n",
" id = str(k).rjust(8,\"0\")\n", " id = str(k).rjust(8,\"0\")\n",
" mydata['unit'] = v['unit']\n", " mydata['unit'] = v['unit']\n",
" mydata['name'] = v['name']\n", " mydata['name'] = v['name']\n",
@@ -1709,7 +1693,7 @@
" mydata['score'] = round(score/len(mydata['fits']),2)\n", " mydata['score'] = round(score/len(mydata['fits']),2)\n",
" if len(mydata['fits']) >2:\n", " if len(mydata['fits']) >2:\n",
" dict2[str(k)] = mydata\n", " dict2[str(k)] = mydata\n",
"filename = f'data/data_镇海2025.json'\n", "filename = f'data/data_北海炼化2025.json'\n",
"with open(filename,'w') as fl:\n", "with open(filename,'w') as fl:\n",
" json.dump(dict2,fl , ensure_ascii=False) \n", " json.dump(dict2,fl , ensure_ascii=False) \n",
"print(len(dict2)) " "print(len(dict2)) "
@@ -1735,7 +1719,7 @@
"import json\n", "import json\n",
"\n", "\n",
"nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n", "nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n",
"filename = 'data/data_镇海2025.json'\n", "filename = 'data/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",
"i = 1\n", "i = 1\n",
@@ -2108,7 +2092,7 @@
" score = 0\n", " score = 0\n",
" n = 0\n", " n = 0\n",
" for k, v in dict1.items():\n", " for k, v in dict1.items():\n",
" if item == v['unit'] and v['sex'] == '女':\n", " if item == v['unit'] and v['sex'] == '男':\n",
" score = score + v['score']\n", " score = score + v['score']\n",
" n = n +1 \n", " n = n +1 \n",
" if n>0:\n", " if n>0:\n",
@@ -2179,9 +2163,7 @@
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n", " dict1 = json.load(fl)\n",
"\n", "\n",
"filename = 'data/北海炼化人员2024.json'\n", "\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n",
"dict3 = {}\n", "dict3 = {}\n",
"\n", "\n",
"for k, v in dict1.items():\n", "for k, v in dict1.items():\n",
@@ -2202,6 +2184,196 @@
" print(k1,v1['score'],v1['count'])" " print(k1,v1['score'],v1['count'])"
] ]
}, },
{
"cell_type": "markdown",
"id": "422a3a6e-468d-4092-9da0-3692814374ca",
"metadata": {},
"source": [
"## 统计班次成绩"
]
},
{
"cell_type": "code",
"execution_count": 123,
"id": "0cec9f15-91dd-49e5-9efd-96b6bac0a86f",
"metadata": {
"execution": {
"iopub.execute_input": "2025-11-19T06:23:29.245390Z",
"iopub.status.busy": "2025-11-19T06:23:29.244814Z",
"iopub.status.idle": "2025-11-19T06:23:29.275383Z",
"shell.execute_reply": "2025-11-19T06:23:29.274885Z",
"shell.execute_reply.started": "2025-11-19T06:23:29.245323Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"白班 3.49 174\n",
"倒班 3.35 103\n",
"值班 3.4 18\n"
]
}
],
"source": [
"items = ['BMI','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数'] \n",
"filename = 'data/data_镇海2025.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"banci = []\n",
"for k, v in dict1.items():\n",
" if v['banci'] not in banci:\n",
" banci.append(v['banci'])\n",
"\n",
"for item in banci:\n",
" score = 0\n",
" n = 0\n",
" for k, v in dict1.items():\n",
" if item == v['banci'] and v['sex'] == '女':\n",
" score = score + v['score']\n",
" n = n +1 \n",
" print(item,round(score/n,2),n)"
]
},
{
"cell_type": "markdown",
"id": "d0266733-3d7a-4903-952b-6ed9a6b45961",
"metadata": {},
"source": [
"## 统计班次测试等级"
]
},
{
"cell_type": "code",
"execution_count": 125,
"id": "127016d1-9aba-45bb-8205-4f4f424eb02e",
"metadata": {
"execution": {
"iopub.execute_input": "2025-11-19T06:26:04.003109Z",
"iopub.status.busy": "2025-11-19T06:26:04.002545Z",
"iopub.status.idle": "2025-11-19T06:26:04.016810Z",
"shell.execute_reply": "2025-11-19T06:26:04.015641Z",
"shell.execute_reply.started": "2025-11-19T06:26:04.003053Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"白班 97 152 219 36\n",
"倒班 76 184 266 70\n",
"值班 43 60 61 5\n"
]
}
],
"source": [
"import json\n",
"\n",
"items = ['优秀','良好','合格','不合格'] \n",
"\n",
"dict3 = {}\n",
"for k, v in dict1.items():\n",
" banci = v['banci']\n",
" dict3.setdefault(banci,{})\n",
" for item in items:\n",
" dict3[banci].setdefault(item,0)\n",
"\n",
"for k, v in dict1.items():\n",
" banci = v['banci']\n",
" #dict3.setdefault(unit,{})\n",
" #for item in items:\n",
" #dict3[unit].setdefault(v['level'],0)\n",
" if v['sex'] =='男':\n",
" dict3[banci][v['level']] +=1\n",
"for k, v in dict3.items():\n",
" print(k,v['优秀'],v['良好'],v['合格'],v['不合格'])"
]
},
{
"cell_type": "code",
"execution_count": 126,
"id": "1b2ebf62-9bf6-4c44-b2ec-ed9393c3c355",
"metadata": {
"execution": {
"iopub.execute_input": "2025-11-19T06:27:20.183814Z",
"iopub.status.busy": "2025-11-19T06:27:20.183150Z",
"iopub.status.idle": "2025-11-19T06:27:20.228117Z",
"shell.execute_reply": "2025-11-19T06:27:20.227481Z",
"shell.execute_reply.started": "2025-11-19T06:27:20.183764Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"白班\n",
"BMI 2697 677\n",
"肺活量 2703 678\n",
"握力 1693 678\n",
"坐位体前屈 1901 676\n",
"纵跳 2435 675\n",
"俯卧撑 1978 497\n",
"一分钟仰卧起坐 722 169\n",
"单脚站立 2003 674\n",
"选择反应时 2289 673\n",
"台阶指数 1698 667\n",
"倒班\n",
"BMI 2571 699\n",
"肺活量 2727 698\n",
"握力 1794 698\n",
"坐位体前屈 1852 697\n",
"纵跳 2321 697\n",
"俯卧撑 2310 586\n",
"一分钟仰卧起坐 385 98\n",
"单脚站立 1921 693\n",
"选择反应时 2273 697\n",
"台阶指数 1749 691\n",
"值班\n",
"BMI 719 187\n",
"肺活量 701 187\n",
"握力 487 185\n",
"坐位体前屈 541 186\n",
"纵跳 666 187\n",
"俯卧撑 742 168\n",
"一分钟仰卧起坐 68 17\n",
"单脚站立 534 186\n",
"选择反应时 656 187\n",
"台阶指数 561 184\n"
]
}
],
"source": [
"import json\n",
"\n",
"items = ['BMI','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数'] \n",
"filename = 'data/data_镇海2025.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"\n",
"dict3 = {}\n",
"\n",
"for k, v in dict1.items():\n",
" unit = v['banci']\n",
" dict3.setdefault(unit,{})\n",
" for item in items:\n",
" dict3[unit].setdefault(item,{})\n",
" dict3[unit][item].setdefault('score',0)\n",
" dict3[unit][item].setdefault('count',0)\n",
" for k1,v1 in v['fits'].items():\n",
" if k1 in items:\n",
" dict3[unit][k1]['score']+=v1['score']\n",
" dict3[unit][k1]['count']+=1\n",
"\n",
"for k, v in dict3.items():\n",
" print(k)\n",
" for k1, v1 in v.items():\n",
" print(k1,v1['score'],v1['count'])"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "bdb81e20-32ec-4e0e-b2ac-13dac2060068", "id": "bdb81e20-32ec-4e0e-b2ac-13dac2060068",
@@ -2584,7 +2756,7 @@
"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_新疆油田采油工艺研究院2511.json'\n", "filename = 'data/result_北海2025-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",
"data_list = []\n", "data_list = []\n",
@@ -2593,7 +2765,7 @@
" list6.append(str(k).rjust(4,'0'))\n", " list6.append(str(k).rjust(4,'0'))\n",
" list6.append(v['name'])\n", " list6.append(v['name'])\n",
" list6.append(v['sex'])\n", " list6.append(v['sex'])\n",
" #list6.append(v['unit'])\n", " list6.append(v['unit'])\n",
" list6.append(v['age'])\n", " list6.append(v['age'])\n",
" if 'bmi' in v.keys():\n", " if 'bmi' in v.keys():\n",
" bmi = v['bmi']['成绩']\n", " bmi = v['bmi']['成绩']\n",
@@ -2666,10 +2838,11 @@
" list6.append('')\n", " list6.append('')\n",
" i+=1\n", " i+=1\n",
" data_list.append(list6)\n", " data_list.append(list6)\n",
"filename = 'data/新疆油田采油工艺研究院情况明细表(202511).xlsx'\n", "filename = 'data/北海炼化情况明细表(2025年).xlsx'\n",
"wb = openpyxl.Workbook()\n", "wb = openpyxl.Workbook()\n",
"sheet = wb.active\n", "sheet = wb.active\n",
"#sheet.append(title)\n", "title = ['编号', '姓名', '性别', '单位/部门', '年龄', '身高', '体重', 'bmi', '肺活量', '得分', '握力', '得分', '坐位体前屈', '得分', '纵跳', '得分', '俯卧撑', '得分', '单脚站立', '得分', '选择反应时', '得分', '台阶指数', '得分', '一分钟仰卧起坐', '得分', '中医体质', '是否倾向', '平和', '气虚', '阳虚', '阴虚', '痰湿', '湿热', '血瘀', '气郁', '特禀', '成就感', '愉快心理', '放松程度', '压力应对', '体力充沛', '情感充沛度', '颈椎', '胸椎', '腰椎', '骶尾椎']\n",
"sheet.append(title)\n",
"for row in data_list:\n", "for row in data_list:\n",
" sheet.append(row)\n", " sheet.append(row)\n",
" \n", " \n",
@@ -2679,7 +2852,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"id": "200d10a8-15a7-4ec9-b407-ffb06c0e19be", "id": "4d77aad2-5ae6-42a6-b5ed-eecefcdbfa50",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": []
+46 -28
View File
@@ -2165,7 +2165,9 @@
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "76c5c17a-462d-4a7b-95a5-6b895f5a25dc", "id": "76c5c17a-462d-4a7b-95a5-6b895f5a25dc",
"metadata": {}, "metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"source": [ "source": [
"# 2024年体质检测" "# 2024年体质检测"
] ]
@@ -3165,10 +3167,26 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 36,
"id": "f143e8d3-9e9a-4c27-be8c-88a3e5f94f51", "id": "f143e8d3-9e9a-4c27-be8c-88a3e5f94f51",
"metadata": {}, "metadata": {
"outputs": [], "execution": {
"iopub.execute_input": "2025-11-18T03:19:39.385691Z",
"iopub.status.busy": "2025-11-18T03:19:39.385436Z",
"iopub.status.idle": "2025-11-18T03:19:39.399964Z",
"shell.execute_reply": "2025-11-18T03:19:39.399394Z",
"shell.execute_reply.started": "2025-11-18T03:19:39.385668Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"880 ok\n"
]
}
],
"source": [ "source": [
"import json\n", "import json\n",
"\n", "\n",
@@ -3200,15 +3218,15 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 14, "execution_count": 37,
"id": "7b79c7bb-ce87-44b2-95b1-01e9cb66d5f0", "id": "7b79c7bb-ce87-44b2-95b1-01e9cb66d5f0",
"metadata": { "metadata": {
"execution": { "execution": {
"iopub.execute_input": "2025-11-17T07:32:53.282654Z", "iopub.execute_input": "2025-11-18T03:20:48.522459Z",
"iopub.status.busy": "2025-11-17T07:32:53.281905Z", "iopub.status.busy": "2025-11-18T03:20:48.521987Z",
"iopub.status.idle": "2025-11-17T07:32:53.332471Z", "iopub.status.idle": "2025-11-18T03:20:48.574117Z",
"shell.execute_reply": "2025-11-17T07:32:53.331897Z", "shell.execute_reply": "2025-11-18T03:20:48.573580Z",
"shell.execute_reply.started": "2025-11-17T07:32:53.282586Z" "shell.execute_reply.started": "2025-11-18T03:20:48.522337Z"
} }
}, },
"outputs": [ "outputs": [
@@ -3250,15 +3268,15 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 15, "execution_count": 38,
"id": "458725a6-3b5b-48a1-af90-cd4d0bda3635", "id": "458725a6-3b5b-48a1-af90-cd4d0bda3635",
"metadata": { "metadata": {
"execution": { "execution": {
"iopub.execute_input": "2025-11-17T07:33:02.993633Z", "iopub.execute_input": "2025-11-18T03:20:56.396804Z",
"iopub.status.busy": "2025-11-17T07:33:02.993053Z", "iopub.status.busy": "2025-11-18T03:20:56.396056Z",
"iopub.status.idle": "2025-11-17T07:33:03.110653Z", "iopub.status.idle": "2025-11-18T03:20:56.449035Z",
"shell.execute_reply": "2025-11-17T07:33:03.109552Z", "shell.execute_reply": "2025-11-18T03:20:56.448467Z",
"shell.execute_reply.started": "2025-11-17T07:33:02.993579Z" "shell.execute_reply.started": "2025-11-18T03:20:56.396734Z"
} }
}, },
"outputs": [ "outputs": [
@@ -3302,15 +3320,15 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 19, "execution_count": 39,
"id": "ef655e34-635b-4baa-97c3-925022f45949", "id": "ef655e34-635b-4baa-97c3-925022f45949",
"metadata": { "metadata": {
"execution": { "execution": {
"iopub.execute_input": "2025-11-17T10:47:57.459196Z", "iopub.execute_input": "2025-11-18T03:21:01.850425Z",
"iopub.status.busy": "2025-11-17T10:47:57.458528Z", "iopub.status.busy": "2025-11-18T03:21:01.849736Z",
"iopub.status.idle": "2025-11-17T10:47:57.506947Z", "iopub.status.idle": "2025-11-18T03:21:01.898524Z",
"shell.execute_reply": "2025-11-17T10:47:57.506509Z", "shell.execute_reply": "2025-11-18T03:21:01.897960Z",
"shell.execute_reply.started": "2025-11-17T10:47:57.459138Z" "shell.execute_reply.started": "2025-11-18T03:21:01.850354Z"
} }
}, },
"outputs": [ "outputs": [
@@ -3857,15 +3875,15 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 34, "execution_count": 40,
"id": "4628f644-a571-4f2b-8d7b-e6b60b2ddcfd", "id": "4628f644-a571-4f2b-8d7b-e6b60b2ddcfd",
"metadata": { "metadata": {
"execution": { "execution": {
"iopub.execute_input": "2025-11-17T12:25:33.111224Z", "iopub.execute_input": "2025-11-18T03:24:38.906208Z",
"iopub.status.busy": "2025-11-17T12:25:33.110488Z", "iopub.status.busy": "2025-11-18T03:24:38.905689Z",
"iopub.status.idle": "2025-11-17T12:25:33.267732Z", "iopub.status.idle": "2025-11-18T03:24:39.068007Z",
"shell.execute_reply": "2025-11-17T12:25:33.267196Z", "shell.execute_reply": "2025-11-18T03:24:39.067392Z",
"shell.execute_reply.started": "2025-11-17T12:25:33.111154Z" "shell.execute_reply.started": "2025-11-18T03:24:38.906160Z"
} }
}, },
"outputs": [ "outputs": [
+85 -21
View File
@@ -2793,9 +2793,7 @@
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "08bcbf58-4356-4f30-850f-0d0ff0e2528b", "id": "08bcbf58-4356-4f30-850f-0d0ff0e2528b",
"metadata": { "metadata": {},
"jp-MarkdownHeadingCollapsed": true
},
"source": [ "source": [
"# 第三次体测(2024年10月)" "# 第三次体测(2024年10月)"
] ]
@@ -3523,15 +3521,15 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 12,
"id": "52de3ba0-f430-444b-87e9-1f13c3e2dcc2", "id": "52de3ba0-f430-444b-87e9-1f13c3e2dcc2",
"metadata": { "metadata": {
"execution": { "execution": {
"iopub.execute_input": "2025-11-17T13:15:52.024202Z", "iopub.execute_input": "2025-11-19T10:29:58.335947Z",
"iopub.status.busy": "2025-11-17T13:15:52.023733Z", "iopub.status.busy": "2025-11-19T10:29:58.335228Z",
"iopub.status.idle": "2025-11-17T13:15:52.062303Z", "iopub.status.idle": "2025-11-19T10:29:58.415390Z",
"shell.execute_reply": "2025-11-17T13:15:52.061818Z", "shell.execute_reply": "2025-11-19T10:29:58.414784Z",
"shell.execute_reply.started": "2025-11-17T13:15:52.024158Z" "shell.execute_reply.started": "2025-11-19T10:29:58.335884Z"
} }
}, },
"outputs": [ "outputs": [
@@ -3539,7 +3537,7 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"253\n" "1138\n"
] ]
} }
], ],
@@ -3553,7 +3551,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_20251117-2.csv'\n", "filename = 'data/marks_20251119.csv'\n",
"re_ta = My.get_result(filename,dict1)\n", "re_ta = My.get_result(filename,dict1)\n",
"\n", "\n",
"\n", "\n",
@@ -3568,20 +3566,20 @@
"id": "f58f041b-a3cb-475c-8ac2-a8a747c96386", "id": "f58f041b-a3cb-475c-8ac2-a8a747c96386",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## 统计未体测人员明细表" "## 统计体测人员明细表"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 13,
"id": "04990b9f-a8f9-4442-935e-d223fde24e72", "id": "04990b9f-a8f9-4442-935e-d223fde24e72",
"metadata": { "metadata": {
"execution": { "execution": {
"iopub.execute_input": "2025-11-17T13:21:58.571623Z", "iopub.execute_input": "2025-11-19T10:30:02.364463Z",
"iopub.status.busy": "2025-11-17T13:21:58.570712Z", "iopub.status.busy": "2025-11-19T10:30:02.363762Z",
"iopub.status.idle": "2025-11-17T13:21:58.620055Z", "iopub.status.idle": "2025-11-19T10:30:02.477779Z",
"shell.execute_reply": "2025-11-17T13:21:58.619536Z", "shell.execute_reply": "2025-11-19T10:30:02.477220Z",
"shell.execute_reply.started": "2025-11-17T13:21:58.571556Z" "shell.execute_reply.started": "2025-11-19T10:30:02.364407Z"
} }
}, },
"outputs": [], "outputs": [],
@@ -3601,12 +3599,12 @@
"\n", "\n",
"i = 1\n", "i = 1\n",
"for k, v in dict1.items(): \n", "for k, v in dict1.items(): \n",
" list2 = [i,k,v['name'],v['unit']]\n", " list2 = [i,k,v['name'],v['unit'],dict2[k]['sub_unit']]\n",
" i+=1\n", " i+=1\n",
" list1.append(list2)\n", " list1.append(list2)\n",
"#print(list1)\n", "#print(list1)\n",
"filename = f'data/天津石化体测人员名单(截至20251117).xlsx'\n", "filename = f'data/天津石化体测人员名单(截至20251119).xlsx'\n",
"title = ['序号','员工编号','姓名','部门']\n", "title = ['序号','员工编号','姓名','部门','车间']\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",
@@ -3615,6 +3613,72 @@
"wb.save(filename)" "wb.save(filename)"
] ]
}, },
{
"cell_type": "markdown",
"id": "ca8b7f16-4654-4117-9e86-6d81ae464bac",
"metadata": {},
"source": [
"## 统计各部门测试情况"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "fcb3c816-5260-4807-9536-b8203680ed1c",
"metadata": {
"execution": {
"iopub.execute_input": "2025-11-19T10:23:38.619220Z",
"iopub.status.busy": "2025-11-19T10:23:38.618501Z",
"iopub.status.idle": "2025-11-19T10:23:38.645291Z",
"shell.execute_reply": "2025-11-19T10:23:38.644881Z",
"shell.execute_reply.started": "2025-11-19T10:23:38.619162Z"
}
},
"outputs": [],
"source": [
"import json\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",
"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/天津石化部门测试情况(20241119).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", "cell_type": "markdown",
"id": "85a03b00-9624-4ae9-aa6d-386798d457df", "id": "85a03b00-9624-4ae9-aa6d-386798d457df",
+210 -23
View File
@@ -1366,10 +1366,10 @@
" dict2 = {}\n", " dict2 = {}\n",
" code = item['data']['code']\n", " code = item['data']['code']\n",
" rq = item['date_created'].split()[0]\n", " rq = item['date_created'].split()[0]\n",
" dict2['height'] = item['data']['height']\n", " dict2['height'] = str('%.2f' % item['data']['height'])\n",
" dict2['weight'] = item['data']['weight']\n", " dict2['weight'] = str('%.2f' %item['data']['weight'])\n",
" dict2['next_weight'] = item['data']['weight']-item['data']['next_weight']\n", " dict2['next_weight'] = str('%.2f' %(item['data']['weight']-item['data']['next_weight']))\n",
" dict2['bmi'] = (item['data']['weight']/item['data']['height'])/item['data']['height']*10000\n", " dict2['bmi'] = str('%.2f' %((item['data']['weight']/item['data']['height'])/item['data']['height']*10000))\n",
" bmi = (item['data']['weight']/item['data']['height'])/item['data']['height']*10000\n", " bmi = (item['data']['weight']/item['data']['height'])/item['data']['height']*10000\n",
" if bmi<18.5:\n", " if bmi<18.5:\n",
" bmi_zt = '体重偏轻'\n", " bmi_zt = '体重偏轻'\n",
@@ -1380,25 +1380,25 @@
" else:\n", " else:\n",
" bmi_zt = '体重肥胖'\n", " bmi_zt = '体重肥胖'\n",
" dict2['bmi_zt'] = bmi_zt\n", " dict2['bmi_zt'] = bmi_zt\n",
" dict2['waist'] = item['data']['waist']\n", " dict2['waist'] = str('%.2f' %item['data']['waist'])\n",
" dict2['hip'] = item['data']['hip']\n", " dict2['hip'] = str('%.2f' %item['data']['hip'])\n",
" whr = dict2['waist']/dict2['hip']\n", " whr = item['data']['waist']/item['data']['hip']\n",
" if item['data']['gender'] =='male' and whr > 0.9:\n", " if item['data']['gender'] =='male' and whr > 0.9:\n",
" whr_zt = '超标'\n", " whr_zt = '超标'\n",
" elif item['data']['gender'] =='female' and whr > 0.85:\n", " elif item['data']['gender'] =='female' and whr > 0.85:\n",
" whr_zt = '超标'\n", " whr_zt = '超标'\n",
" else:\n", " else:\n",
" whr_zt = '正常'\n", " whr_zt = '正常'\n",
" dict2['whr'] = whr\n", " dict2['whr'] = str('%.2f' %whr)\n",
" dict2['whr_zt'] = whr_zt\n", " dict2['whr_zt'] = whr_zt\n",
" if 'sport_type' in item['data'].keys(): \n", " if 'sport_type' in item['data'].keys(): \n",
" dict2['sport_type'] = ','.join(item['data']['sport_type']).replace('other','其他')\n", " dict2['sport_type'] = ','.join(item['data']['sport_type']).replace('other','其他')\n",
" dict2['sport_duration'] = item['data']['sport_duration']\n", " dict2['sport_duration'] = str(item['data']['sport_duration'])\n",
" dict2['recipe'] = item['data']['recipe']\n", " dict2['recipe'] = item['data']['recipe']\n",
" if 'last_sport' in item['data'].keys(): \n", " if 'last_sport' in item['data'].keys(): \n",
" dict2['last_sport'] = item['data']['last_sport']\n", " dict2['last_sport'] = item['data']['last_sport']\n",
" if 'last_sport_time' in item['data'].keys():\n", " if 'last_sport_time' in item['data'].keys():\n",
" dict2['last_sport_time'] = item['data']['last_sport_time']\n", " dict2['last_sport_time'] = str(item['data']['last_sport_time'])\n",
" if 'last_sport-Comment' in item['data'].keys():\n", " if 'last_sport-Comment' in item['data'].keys():\n",
" dict2['last_sport-Comment'] = item['data']['last_sport-Comment']\n", " dict2['last_sport-Comment'] = item['data']['last_sport-Comment']\n",
" dict2['last_recipe'] = item['data']['last_recipe']\n", " dict2['last_recipe'] = item['data']['last_recipe']\n",
@@ -1407,12 +1407,12 @@
" if 'last_lose' in item['data'].keys(): \n", " if 'last_lose' in item['data'].keys(): \n",
" dict2['last_lose'] = item['data']['last_lose']\n", " dict2['last_lose'] = item['data']['last_lose']\n",
" if 'last_lose_weight' in item['data'].keys():\n", " if 'last_lose_weight' in item['data'].keys():\n",
" dict2['last_lose_weight'] = item['data']['last_lose_weight']\n", " dict2['last_lose_weight'] = str('%.2f' %item['data']['last_lose_weight'])\n",
" if 'last_lose-Comment' in item['data'].keys(): \n", " if 'last_lose-Comment' in item['data'].keys(): \n",
" dict2['last_lose-Comment'] = item['data']['last_lose-Comment']\n", " dict2['last_lose-Comment'] = item['data']['last_lose-Comment']\n",
" if code in person.keys():\n", " if code in person.keys():\n",
" person[code][rq] = dict2\n", " person[code][rq] = dict2\n",
"filename = 'data/宁夏能化干预人员问卷情况.json'\n", "filename = 'data/宁夏能化干预人员问卷情况-1.json'\n",
"\n", "\n",
"with open(filename,'w') as fl:\n", "with open(filename,'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n", " json.dump(person, fl, ensure_ascii=False)\n",
@@ -1430,17 +1430,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 45, "execution_count": null,
"id": "633c35d3-61f0-4a9d-9982-441e4c1291b9", "id": "633c35d3-61f0-4a9d-9982-441e4c1291b9",
"metadata": { "metadata": {},
"execution": {
"iopub.execute_input": "2025-11-17T09:35:16.409939Z",
"iopub.status.busy": "2025-11-17T09:35:16.409246Z",
"iopub.status.idle": "2025-11-17T09:35:16.664860Z",
"shell.execute_reply": "2025-11-17T09:35:16.664302Z",
"shell.execute_reply.started": "2025-11-17T09:35:16.409918Z"
}
},
"outputs": [], "outputs": [],
"source": [ "source": [
"import json\n", "import json\n",
@@ -1514,10 +1506,205 @@
"wb.save(filename) " "wb.save(filename) "
] ]
}, },
{
"cell_type": "markdown",
"id": "0fe62c71-eb58-4204-85bc-dc5497231df4",
"metadata": {},
"source": [
"## 问卷信息汇总导入数据库"
]
},
{
"cell_type": "code",
"execution_count": 77,
"id": "55b20059-ae36-493e-b0c5-c7e35473efc7",
"metadata": {
"execution": {
"iopub.execute_input": "2025-11-19T10:42:23.125996Z",
"iopub.status.busy": "2025-11-19T10:42:23.125745Z",
"iopub.status.idle": "2025-11-19T10:42:25.142922Z",
"shell.execute_reply": "2025-11-19T10:42:25.142275Z",
"shell.execute_reply.started": "2025-11-19T10:42:23.125974Z"
}
},
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",
"import psycopg2\n",
"from datetime import datetime\n",
"\n",
"conn = psycopg2.connect(\n",
" host=\"localhost\",\n",
" database=\"tice\",\n",
" user=\"mydata\",\n",
" password=\"songyi\"\n",
")\n",
"cur = conn.cursor()\n",
"event_id = 1\n",
"org_id = 1\n",
"filename = 'data/宁夏能化干预人员问卷情况-1.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = ['name','sex','birth','unit']\n",
"xm = ['height','weight','next_weight','bmi','bmi_zt','waist', 'hip','whr','whr_zt' ]\n",
"data2 = []\n",
"for k,v in dict1.items():\n",
" list2 = []\n",
" \n",
" for k1,v1 in v.items():\n",
" #list2 = []\n",
" if k1 not in list1:\n",
" list2.append(k1)\n",
" list2.sort()\n",
" \n",
" for rq in list2:\n",
" for k1, v1 in v[rq].items():\n",
" code = k\n",
" \n",
" sql = \"SELECT id from fitness_person where code = %s and org_id = %s\"\n",
" params = (code,org_id)\n",
" cur.execute(sql, params)\n",
" rows = cur.fetchone()\n",
" if rows:\n",
" data1 = []\n",
" data1.append(event_id)\n",
" data1.append(rows[0])\n",
" data1.append(rq)\n",
" for item in xm:\n",
" data1.append(v[rq][item])\n",
" if 'sport_type' in v[rq].keys():\n",
" data1.append(v[rq]['sport_type'])\n",
" else:\n",
" data1.append('')\n",
" \n",
" if 'sport_duration' in v[rq].keys():\n",
" data1.append(v[rq]['sport_duration'])\n",
" else:\n",
" data1.append('')\n",
" if v[rq]['recipe']=='free':\n",
" data1.append('自行控制')\n",
" else:\n",
" data1.append('减脂餐')\n",
" if v[rq]['last_sport']=='是':\n",
" data1.append('运动时长:'+str(v[rq]['last_sport_time'])+'分钟')\n",
" else:\n",
" data1.append('未运动,'+v[rq]['last_sport-Comment'])\n",
" if v[rq]['last_recipe']=='是':\n",
" data1.append('是')\n",
" else:\n",
" data1.append('否。'+v[rq]['last_recipe-Comment'])\n",
" if v[rq]['last_lose']=='是':\n",
" data1.append('是,减重'+str(v[rq]['last_lose_weight'])+'公斤。')\n",
" elif 'last_lose-Comment' in v[rq].keys():\n",
" data1.append('否。'+v[rq]['last_lose-Comment'])\n",
" else:\n",
" data1.append('否。')\n",
" data2.append(tuple(data1))\n",
" \n",
"sql = \"INSERT INTO fitness_record_data (event_id,user_id,date_created, height, weight, next_weight, bmi,bmi_zt,waist, hip, whr,whr_zt, sport_type, sport_duration, recipe, last_sport, last_recipe, last_lose_comment)\" \n",
"sql = sql + \" VALUES (%s,%s, %s, %s,%s, %s, %s, %s, %s,%s, %s, %s, %s, %s,%s, %s, %s, %s)\"\n",
"cur.executemany(sql, data2)\n",
"conn.commit()\n",
"\n",
"# 关闭连接\n",
"cur.close()\n",
"conn.close()"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"id": "c19f04a8-64a4-4660-8359-7780de4a5227", "id": "a068cd21-d751-46f9-9c95-f26cf14ddeb8",
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",
"import psycopg2\n",
"\n",
"conn = psycopg2.connect(\n",
" host=\"localhost\",\n",
" database=\"tice\",\n",
" user=\"mydata\",\n",
" password=\"songyi\"\n",
")\n",
"cur = conn.cursor()\n",
"event_id = 1\n",
"org_id = 1\n",
"filename = 'data/宁夏能化干预人员问卷情况-1.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = ['name','sex','birth','unit']\n",
"xm = ['height','weight','next_weight','bmi','bmi_zt','waist', 'hip','whr','whr_zt' ]\n",
"data2 = []\n",
"for k,v in dict1.items():\n",
" list2 = []\n",
" \n",
" for k1,v1 in v.items():\n",
" #list2 = []\n",
" if k1 not in list1:\n",
" list2.append(k1)\n",
" list2.sort()\n",
" \n",
" for rq in list2:\n",
" for k1, v1 in v[rq].items():\n",
" code = k\n",
" \n",
" sql = \"SELECT id from fitness_person where code = %s and org_id = %s\"\n",
" params = (code,org_id)\n",
" cur.execute(sql, params)\n",
" rows = cur.fetchone()\n",
" if rows:\n",
" data1 = []\n",
" data1.append(event_id)\n",
" data1.append(rows[0])\n",
" data1.append(datetime.strptime(rq,'%Y-%m-%d'))\n",
" data1.append(k)\n",
" for item in xm:\n",
" data1.append(v[rq][item])\n",
" if 'sport_type' in v[rq].keys():\n",
" data1.append(v[rq]['sport_type'])\n",
" else:\n",
" data1.append('')\n",
" if 'sport_type' in v[rq].keys():\n",
" data1.append(v[rq]['sport_type'])\n",
" else:\n",
" data1.append('')\n",
" \n",
" if 'sport_duration' in v[rq].keys():\n",
" data1.append(v[rq]['sport_duration'])\n",
" else:\n",
" data1.append('')\n",
" if v[rq]['recipe']=='free':\n",
" data1.append('自行控制')\n",
" else:\n",
" data1.append('减脂餐')\n",
" if v[rq]['last_sport']=='是':\n",
" data1.append('运动时长:'+str(v[rq]['last_sport_time'])+'分钟')\n",
" else:\n",
" data1.append('未运动,'+v[rq]['last_sport-Comment'])\n",
" if v[rq]['last_recipe']=='是':\n",
" data1.append('是')\n",
" else:\n",
" data1.append('否。'+v[rq]['last_recipe-Comment'])\n",
" if v[rq]['last_lose']=='是':\n",
" data1.append('是,减重'+str(v[rq]['last_lose_weight'])+'公斤。')\n",
" elif 'last_lose-Comment' in v[rq].keys():\n",
" data1.append('否。'+v[rq]['last_lose-Comment'])\n",
" else:\n",
" data1.append('否。')\n",
" print(data1)\n",
" sql = \"INSERT INTO fitness_record_data (event_id,user_id,date_created, height, weight, next_weight, bmi,bmi_zt,waist, hip, whr,whr_zt, sport_type, sport_duration, recipe, last_sport, last_recipe, last_lose, last_lose_comment)\" \n",
"sql = sql + \" VALUES (%s,%s, %s, %s,%s, %s, %s, %s, %s,%s, %s, %s, %s, %s,%s, %s, %s, %s, %s)\"\n",
"cur.executemany(sql, data2)\n",
"conn.commit()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c4cbfed3-51cf-47b8-af20-eee4ac61b556",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": []
File diff suppressed because it is too large. Load diff
+54 -27
View File
@@ -2148,6 +2148,57 @@
"wb.save(filename)" "wb.save(filename)"
] ]
}, },
{
"cell_type": "markdown",
"id": "ab2ff226-2c58-495c-ad52-7cb3dc8a1dfd",
"metadata": {},
"source": [
"## 添加班次信息"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "557508ff-842c-4e15-93fa-457b571223a8",
"metadata": {
"execution": {
"iopub.execute_input": "2025-11-19T06:12:59.269561Z",
"iopub.status.busy": "2025-11-19T06:12:59.269005Z",
"iopub.status.idle": "2025-11-19T06:12:59.475923Z",
"shell.execute_reply": "2025-11-19T06:12:59.475387Z",
"shell.execute_reply.started": "2025-11-19T06:12:59.269511Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok!\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"from datetime import date\n",
"\n",
"wb = openpyxl.load_workbook('data/镇海体质监测人员名单(已标注班次).xlsx')\n",
"sheet = wb.active\n",
"filename = 'data/data_镇海2025.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl) \n",
"\n",
"for n in range(2, sheet.max_row+1):\n",
" code = str(sheet.cell(n, 1).value).lower()\n",
" if code in dict2.keys():\n",
" banci = sheet.cell(n, 6).value\n",
" dict2[code]['banci'] = banci\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict2,fl , ensure_ascii=False) \n",
"print('ok!') \n"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "0d7d8dd1-45f7-455d-8db3-38febc2a2395", "id": "0d7d8dd1-45f7-455d-8db3-38febc2a2395",
@@ -2537,26 +2588,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 96, "execution_count": null,
"id": "9663b933-57f4-486c-80e6-f9d513bbe6a8", "id": "9663b933-57f4-486c-80e6-f9d513bbe6a8",
"metadata": { "metadata": {},
"execution": { "outputs": [],
"iopub.execute_input": "2025-11-14T07:35:38.747096Z",
"iopub.status.busy": "2025-11-14T07:35:38.746559Z",
"iopub.status.idle": "2025-11-14T07:35:38.947152Z",
"shell.execute_reply": "2025-11-14T07:35:38.945993Z",
"shell.execute_reply.started": "2025-11-14T07:35:38.747068Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"+8613793180751 send success\n"
]
}
],
"source": [ "source": [
"from tencentcloud.common import credential\n", "from tencentcloud.common import credential\n",
"from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException\n", "from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException\n",
@@ -2676,14 +2711,6 @@
" except TencentCloudSDKException as err:\n", " except TencentCloudSDKException as err:\n",
" print(v['phone'],err)" " print(v['phone'],err)"
] ]
},
{
"cell_type": "code",
"execution_count": null,
"id": "02501165-d375-4101-8a97-107b52cccdc2",
"metadata": {},
"outputs": [],
"source": []
} }
], ],
"metadata": { "metadata": {