This commit is contained in:
512song committed 2025-10-21 10:14:15 +08:00
1 parent ba6f6b413a
commit a10492f0ad
6 files changed
+1705 -151

No files matched your search

+270 -67
View File
@@ -1,5 +1,13 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "a3a2e21f-e62e-465b-818d-8acea289434f",
"metadata": {},
"source": [
"# 体质检测"
]
},
{
"cell_type": "markdown",
"id": "04524c85-988e-4dbf-86eb-939a9db7aa28",
@@ -10,27 +18,12 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "bbba6efc-73cd-4db6-bae7-014724fee731",
"metadata": {
"execution": {
"iopub.execute_input": "2025-08-14T12:48:54.906761Z",
"iopub.status.busy": "2025-08-14T12:48:54.906261Z",
"iopub.status.idle": "2025-08-14T12:48:55.181497Z",
"shell.execute_reply": "2025-08-14T12:48:55.180926Z",
"shell.execute_reply.started": "2025-08-14T12:48:54.906723Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1698 ok\n"
]
}
],
"outputs": [],
"source": [
"import openpyxl\n",
"import json\n",
@@ -342,17 +335,9 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "75b98b19-ab32-414a-b3f2-6efd58e1f9a9",
"metadata": {
"execution": {
"iopub.execute_input": "2025-08-28T09:16:02.802494Z",
"iopub.status.busy": "2025-08-28T09:16:02.801898Z",
"iopub.status.idle": "2025-08-28T09:16:02.994884Z",
"shell.execute_reply": "2025-08-28T09:16:02.994340Z",
"shell.execute_reply.started": "2025-08-28T09:16:02.802438Z"
}
},
"metadata": {},
"outputs": [],
"source": [
"import json\n",
@@ -557,26 +542,10 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "d31020be-c9c0-404f-8e0b-f8f507385f48",
"metadata": {
"execution": {
"iopub.execute_input": "2025-08-14T12:28:32.225197Z",
"iopub.status.busy": "2025-08-14T12:28:32.224475Z",
"iopub.status.idle": "2025-08-14T12:28:32.933373Z",
"shell.execute_reply": "2025-08-14T12:28:32.932821Z",
"shell.execute_reply.started": "2025-08-14T12:28:32.225127Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",
@@ -877,17 +846,9 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "360831b7-e204-4801-9f72-879e338ed962",
"metadata": {
"execution": {
"iopub.execute_input": "2025-08-13T11:53:04.589116Z",
"iopub.status.busy": "2025-08-13T11:53:04.588495Z",
"iopub.status.idle": "2025-08-13T11:53:04.762457Z",
"shell.execute_reply": "2025-08-13T11:53:04.761877Z",
"shell.execute_reply.started": "2025-08-13T11:53:04.589057Z"
}
},
"metadata": {},
"outputs": [],
"source": [
"import json\n",
@@ -963,17 +924,9 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "e3117237-b921-41fe-9b65-4918c5b2a165",
"metadata": {
"execution": {
"iopub.execute_input": "2025-08-13T08:52:05.672800Z",
"iopub.status.busy": "2025-08-13T08:52:05.672283Z",
"iopub.status.idle": "2025-08-13T08:52:05.820901Z",
"shell.execute_reply": "2025-08-13T08:52:05.820357Z",
"shell.execute_reply.started": "2025-08-13T08:52:05.672751Z"
}
},
"metadata": {},
"outputs": [],
"source": [
"import json\n",
@@ -1004,10 +957,260 @@
" "
]
},
{
"cell_type": "markdown",
"id": "fabb8138-ad15-43a0-abf5-c5ff73318333",
"metadata": {},
"source": [
"# 高危风险干预"
]
},
{
"cell_type": "markdown",
"id": "5b5fcb90-e60e-4edd-929a-702fe93bd0e7",
"metadata": {},
"source": [
"## 导入干预人员名单"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "396e64b8-c306-4613-9848-f0f183052b78",
"metadata": {
"execution": {
"iopub.execute_input": "2025-10-10T02:18:51.157197Z",
"iopub.status.busy": "2025-10-10T02:18:51.156880Z",
"iopub.status.idle": "2025-10-10T02:18:51.211412Z",
"shell.execute_reply": "2025-10-10T02:18:51.210755Z",
"shell.execute_reply.started": "2025-10-10T02:18:51.157161Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"210 ok\n"
]
}
],
"source": [
"import json\n",
"import csv\n",
"import openpyxl\n",
"import time\n",
"from datetime import date\n",
"\n",
"wb = openpyxl.load_workbook('data/宁夏能化高危风险人群最终干预人员名单.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 = int(sheet.cell(n, 2).value)\n",
" person.setdefault(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 3).value\n",
" dict1['sex'] = sheet.cell(n, 4).value\n",
" dict1['unit'] = sheet.cell(n, 6).value\n",
" \n",
" \n",
" dict1['age'] = int(sheet.cell(n, 5).value)\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": "952544fd-0fc6-4365-a43b-a12cab537bb2",
"metadata": {},
"source": [
"## 获取问卷人员信息"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "f60e8194-7ef6-49d8-8538-9b79f35bb64d",
"metadata": {
"execution": {
"iopub.execute_input": "2025-10-10T02:09:50.365387Z",
"iopub.status.busy": "2025-10-10T02:09:50.364816Z",
"iopub.status.idle": "2025-10-10T02:09:50.391653Z",
"shell.execute_reply": "2025-10-10T02:09:50.391205Z",
"shell.execute_reply.started": "2025-10-10T02:09:50.365335Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"145 ok\n"
]
}
],
"source": [
"import json\n",
"import csv\n",
"import openpyxl\n",
"import time\n",
"from datetime import date\n",
"\n",
"\n",
"dict1 = {}\n",
"list1 = []\n",
"filename = 'data/sql_20251009.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",
" name = item[1]\n",
" phone = str(item[2])[2:]\n",
" birth = str(item[4])\n",
" content = json.loads(item[0])\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 = int(dict2['code'])\n",
" dict1.setdefault(code,{})\n",
" dict1[code]['name'] = dict2['name']\n",
" if dict2['gender'] == 'm':\n",
" dict1[code]['sex'] = '男'\n",
" else:\n",
" dict1[code]['sex'] = '女'\n",
" dict1[code]['birth'] = str(item[4])\n",
" dict1[code]['unit'] = dict2['unit']\n",
" dict1[code]['phone'] = phone\n",
" dict1[code]['waist'] = dict2['waist']\n",
" dict1[code]['hip'] = dict2['hip']\n",
" dict1[code]['tcm'] = tcm\n",
"filename = 'data/survey_宁夏能化干预人员.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": "93a9b31e-49ea-45cd-bb0b-5c3db19bbb54",
"metadata": {},
"source": [
"## 导出问卷人员信息"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "f0853629-e971-492b-88c8-4e9521b4b017",
"metadata": {
"execution": {
"iopub.execute_input": "2025-10-10T02:16:14.316496Z",
"iopub.status.busy": "2025-10-10T02:16:14.315869Z",
"iopub.status.idle": "2025-10-10T02:16:14.344471Z",
"shell.execute_reply": "2025-10-10T02:16:14.343924Z",
"shell.execute_reply.started": "2025-10-10T02:16:14.316435Z"
}
},
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"\n",
"title = ['员工编号','姓名','性别','部门']\n",
"\n",
"filename = 'data/survey_宁夏能化干预人员.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",
"for k, v in dict2.items():\n",
" \n",
" if str(k) not in dict1.keys():\n",
" list2 = []\n",
" list2 = [k,v['name'],v['sex'],v['unit']] \n",
" list1.append(list2)\n",
"filename = 'data/宁夏能化干预人员未参加问卷人员(20251010).xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(title)\n",
"for row in list1:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename)"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "22be8f39-afbb-448a-8ae6-c825c7d38757",
"metadata": {
"execution": {
"iopub.execute_input": "2025-10-10T02:18:10.620552Z",
"iopub.status.busy": "2025-10-10T02:18:10.619865Z",
"iopub.status.idle": "2025-10-10T02:18:10.652211Z",
"shell.execute_reply": "2025-10-10T02:18:10.651710Z",
"shell.execute_reply.started": "2025-10-10T02:18:10.620490Z"
}
},
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"\n",
"title = ['员工编号','姓名','性别','部门','手机号码']\n",
"\n",
"filename = 'data/survey_宁夏能化干预人员.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",
"for k, v in dict2.items():\n",
" \n",
" if str(k) in dict1.keys():\n",
" list2 = []\n",
" list2 = [k,v['name'],v['sex'],v['unit'],dict1[k]['phone']] \n",
" list1.append(list2)\n",
"filename = 'data/宁夏能化干预人员参加问卷人员(20251010).xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(title)\n",
"for row in list1:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6133f0d5-75aa-41c0-a624-b354d89b5ba3",
"id": "f32288ee-167c-4e2a-9679-5d927db34950",
"metadata": {},
"outputs": [],
"source": []