This commit is contained in:
512song committed 2025-07-03 22:19:02 +08:00
1 parent b58fc4376a
commit 321337fdda
6 files changed
+1101 -479

No files matched your search

+244 -191
View File
@@ -10,15 +10,15 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 75,
"id": "bbba6efc-73cd-4db6-bae7-014724fee731",
"metadata": {
"execution": {
"iopub.execute_input": "2025-06-26T09:23:57.936852Z",
"iopub.status.busy": "2025-06-26T09:23:57.936142Z",
"iopub.status.idle": "2025-06-26T09:23:58.004545Z",
"shell.execute_reply": "2025-06-26T09:23:58.004103Z",
"shell.execute_reply.started": "2025-06-26T09:23:57.936786Z"
"iopub.execute_input": "2025-07-03T14:10:10.030695Z",
"iopub.status.busy": "2025-07-03T14:10:10.030380Z",
"iopub.status.idle": "2025-07-03T14:10:10.104203Z",
"shell.execute_reply": "2025-07-03T14:10:10.103560Z",
"shell.execute_reply.started": "2025-07-03T14:10:10.030662Z"
},
"tags": []
},
@@ -67,27 +67,12 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "ce406710-6b7d-4c51-98ec-78883bd3ce5f",
"metadata": {
"execution": {
"iopub.execute_input": "2025-06-20T07:51:09.404359Z",
"iopub.status.busy": "2025-06-20T07:51:09.403401Z",
"iopub.status.idle": "2025-06-20T07:51:09.412040Z",
"shell.execute_reply": "2025-06-20T07:51:09.410889Z",
"shell.execute_reply.started": "2025-06-20T07:51:09.404278Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"outputs": [],
"source": [
"import json\n",
"\n",
@@ -120,15 +105,15 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 76,
"id": "970e171e-1360-448f-a28c-520ccb8f314a",
"metadata": {
"execution": {
"iopub.execute_input": "2025-06-27T04:18:55.832397Z",
"iopub.status.busy": "2025-06-27T04:18:55.832091Z",
"iopub.status.idle": "2025-06-27T04:18:55.841888Z",
"shell.execute_reply": "2025-06-27T04:18:55.841317Z",
"shell.execute_reply.started": "2025-06-27T04:18:55.832371Z"
"iopub.execute_input": "2025-07-03T14:10:45.274585Z",
"iopub.status.busy": "2025-07-03T14:10:45.273833Z",
"iopub.status.idle": "2025-07-03T14:10:45.293613Z",
"shell.execute_reply": "2025-07-03T14:10:45.292999Z",
"shell.execute_reply.started": "2025-07-03T14:10:45.274514Z"
},
"tags": []
},
@@ -137,7 +122,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"57\n"
"86\n"
]
}
],
@@ -151,7 +136,7 @@
"filename = 'data/南京化工人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"filename = 'data/marks_20250627.csv'\n",
"filename = 'data/marks_20250703.csv'\n",
"re_ta = My.get_result(filename,dict1)\n",
"\n",
"\n",
@@ -171,15 +156,15 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 77,
"id": "0905ad6a-f7e4-43ed-ae29-c4850deb946b",
"metadata": {
"execution": {
"iopub.execute_input": "2025-06-26T09:26:45.723598Z",
"iopub.status.busy": "2025-06-26T09:26:45.723143Z",
"iopub.status.idle": "2025-06-26T09:26:45.735635Z",
"shell.execute_reply": "2025-06-26T09:26:45.734794Z",
"shell.execute_reply.started": "2025-06-26T09:26:45.723567Z"
"iopub.execute_input": "2025-07-03T14:10:49.291562Z",
"iopub.status.busy": "2025-07-03T14:10:49.290910Z",
"iopub.status.idle": "2025-07-03T14:10:49.313086Z",
"shell.execute_reply": "2025-07-03T14:10:49.312338Z",
"shell.execute_reply.started": "2025-07-03T14:10:49.291501Z"
}
},
"outputs": [
@@ -237,16 +222,9 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": null,
"id": "867ad6b0-9e9d-48bc-a10a-3b9cb6125890",
"metadata": {
"execution": {
"iopub.execute_input": "2025-06-26T09:26:59.739745Z",
"iopub.status.busy": "2025-06-26T09:26:59.738920Z",
"iopub.status.idle": "2025-06-26T09:26:59.761164Z",
"shell.execute_reply": "2025-06-26T09:26:59.760746Z",
"shell.execute_reply.started": "2025-06-26T09:26:59.739659Z"
},
"tags": []
},
"outputs": [],
@@ -289,7 +267,7 @@
" list2.append('')\n",
" \n",
" list1.append(list2)\n",
"filename = 'data/南京化工测试情况明细表(截至20250626).xlsx'\n",
"filename = 'data/南京化工测试情况明细表(截至20250630).xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(title)\n",
@@ -304,176 +282,267 @@
"id": "699c6a40-a6ae-4300-9646-708cb85aa5e8",
"metadata": {},
"source": [
"## 统计各部门测试人员情况"
"## 统计问卷人员情况"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "c4b71b0f-0f0c-4962-a540-611cbab51bfa",
"metadata": {
"execution": {
"iopub.execute_input": "2025-06-27T04:19:17.469888Z",
"iopub.status.busy": "2025-06-27T04:19:17.469137Z",
"iopub.status.idle": "2025-06-27T04:19:17.491232Z",
"shell.execute_reply": "2025-06-27T04:19:17.490732Z",
"shell.execute_reply.started": "2025-06-27T04:19:17.469824Z"
}
},
"outputs": [],
"source": [
"import json\n",
"\n",
"filename = 'data/result_南京化工.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"filename = 'data/南京化工人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n",
"\n",
"list1 = []\n",
"for k, v in dict2.items():\n",
" if k not in dict1.keys():\n",
" list2 = []\n",
" unit = v['unit']\n",
" list2 = [k,v['name'],v['sex'],unit]\n",
" list1.append(list2)\n",
" \n",
"\n",
"\n",
"\n",
"filename = 'data/南京化工未体测人员.xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(title)\n",
"for row in list1:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename)"
]
},
{
"cell_type": "markdown",
"id": "3796748f-2079-46b6-a3a1-b22441880843",
"metadata": {},
"source": [
"## 统计各部门已测试情况"
]
},
{
"cell_type": "code",
"execution_count": 66,
"execution_count": 78,
"id": "def3f47a-24ef-4815-b63b-2a16b79b4c15",
"metadata": {
"execution": {
"iopub.execute_input": "2025-06-17T11:02:38.842412Z",
"iopub.status.busy": "2025-06-17T11:02:38.841860Z",
"iopub.status.idle": "2025-06-17T11:02:38.879864Z",
"shell.execute_reply": "2025-06-17T11:02:38.879320Z",
"shell.execute_reply.started": "2025-06-17T11:02:38.842360Z"
"iopub.execute_input": "2025-07-03T14:11:05.924023Z",
"iopub.status.busy": "2025-07-03T14:11:05.923517Z",
"iopub.status.idle": "2025-07-03T14:11:05.951213Z",
"shell.execute_reply": "2025-07-03T14:11:05.950561Z",
"shell.execute_reply.started": "2025-07-03T14:11:05.923975Z"
},
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"import csv\n",
"import openpyxl\n",
"import time\n",
"from datetime import date\n",
"\n",
"filename = 'data/result_宁夏能化人员.json'\n",
"\n",
"filename = 'data/南京化工人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"filename = 'data/宁夏能化人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n",
"\n",
"dict3 = {}\n",
"\n",
"\n",
"title =['单位','体测人数']\n",
"list1 = []\n",
"phone1 = set()\n",
"phone2 = set()\n",
"for k,v in dict1.items():\n",
" unit = v['unit']\n",
" if unit=='管理部门':\n",
" sub_unit = dict2[k]['sub_unit']\n",
" else:\n",
" sub_unit = unit\n",
" dict3.setdefault(unit,{}) \n",
" dict3[unit].setdefault(sub_unit,{})\n",
" dict3[unit][sub_unit].setdefault('人数',0)\n",
" dict3[unit][sub_unit]['人数'] = dict3[unit][sub_unit]['人数'] + 1\n",
" phone1.add(v['phone'])\n",
"list1 = []\n",
"filename = 'data/survey_records_20250703.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",
"for k, v in dict3.items():\n",
" list2 = []\n",
" for k1,v1 in v.items():\n",
" list2 = [k,k1,v1['人数']]\n",
" list1.append(list2)\n",
"\n",
"filename = 'data/宁夏能化部门测试情况表.xlsx'\n",
"i =1\n",
"list2 = []\n",
"for item in list1:\n",
" code = int(item[3])\n",
" for k, v in dict1.items():\n",
" list3 = []\n",
" if v['phone'] == code: \n",
" list3.append(k)\n",
" list3.append(v['name'])\n",
" list3.append(v['sex'])\n",
" list3.append(v['unit'])\n",
" list3.append(code)\n",
" list2.append(list3)\n",
"filename = 'data/南化问卷情况表.xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(title)\n",
"for row in list1:\n",
"#sheet.append(title)\n",
"for row in list2:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename)"
"wb.save(filename) "
]
},
{
"cell_type": "code",
"execution_count": 65,
"id": "61dde8c3-844a-4016-8952-cb726ab5f61d",
"execution_count": 79,
"id": "9cb0172e-5f6c-4b47-8431-83dc5cc4601c",
"metadata": {
"execution": {
"iopub.execute_input": "2025-06-17T11:01:30.219475Z",
"iopub.status.busy": "2025-06-17T11:01:30.218747Z",
"iopub.status.idle": "2025-06-17T11:01:30.259871Z",
"shell.execute_reply": "2025-06-17T11:01:30.259320Z",
"shell.execute_reply.started": "2025-06-17T11:01:30.219409Z"
"iopub.execute_input": "2025-07-03T14:11:09.342124Z",
"iopub.status.busy": "2025-07-03T14:11:09.341492Z",
"iopub.status.idle": "2025-07-03T14:11:09.352176Z",
"shell.execute_reply": "2025-07-03T14:11:09.350856Z",
"shell.execute_reply.started": "2025-07-03T14:11:09.342065Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"13718042132\n",
"13705162311\n"
]
}
],
"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",
"phone1 = set()\n",
"phone2 = set()\n",
"for k,v in dict1.items():\n",
" phone1.add(v['phone'])\n",
"list1 = []\n",
"filename = 'data/survey_records_20250701.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",
"for item in list1:\n",
" code = int(item[3]) \n",
" if code not in phone1: \n",
" print(code)"
]
},
{
"cell_type": "markdown",
"id": "797717d5-47b9-4d47-be6c-8d54bede67d4",
"metadata": {},
"source": [
"## 导入问卷信息"
]
},
{
"cell_type": "code",
"execution_count": 80,
"id": "9d9dd574-9fbf-4d0a-96fd-9b55d98021d2",
"metadata": {
"execution": {
"iopub.execute_input": "2025-07-03T14:11:25.002448Z",
"iopub.status.busy": "2025-07-03T14:11:25.001635Z",
"iopub.status.idle": "2025-07-03T14:11:25.029582Z",
"shell.execute_reply": "2025-07-03T14:11:25.029137Z",
"shell.execute_reply.started": "2025-07-03T14:11:25.002370Z"
}
},
"outputs": [],
"source": [
"import json\n",
"import csv\n",
"import openpyxl\n",
"import time\n",
"from datetime import date\n",
"\n",
"filename = 'data/result_宁夏能化人员.json'\n",
"dict1 = {}\n",
"\n",
"filename = 'data/result_南京化工.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"filename = 'data/宁夏能化人员.json'\n",
"filename = 'data/南京化工人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n",
" dict3 = json.load(fl)\n",
"\n",
"dict3 = {}\n",
"phone = {}\n",
"for k,v in dict3.items():\n",
" if 'phone' in v.keys():\n",
" phone[v['phone']] = k\n",
"\n",
"\n",
"title =['单位','体测人数']\n",
"list1 = []\n",
"for k,v in dict2.items():\n",
" unit = v['unit']\n",
" if unit=='管理部门':\n",
" sub_unit = dict2[k]['sub_unit']\n",
" else:\n",
" sub_unit = unit\n",
" dict3.setdefault(unit,{}) \n",
" dict3[unit].setdefault(sub_unit,{})\n",
" dict3[unit][sub_unit].setdefault('人数',0)\n",
" dict3[unit][sub_unit]['人数'] = dict3[unit][sub_unit]['人数'] + 1\n",
"filename = 'data/survey_records_20250703.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",
"for k, v in dict3.items():\n",
" list2 = []\n",
" for k1,v1 in v.items():\n",
" list2 = [k,k1,v1['人数']]\n",
" list1.append(list2)\n",
"\n",
"filename = 'data/宁夏能化部门人员情况表.xlsx'\n",
"wb = openpyxl.Workbook()\n",
"\n",
"nn = 0\n",
"for item in list1:\n",
" if int(item[3]) in phone.keys(): \n",
" tcm = []\n",
" code = phone[int(item[3])]\n",
" \n",
" for i in range(0,60):\n",
" tcm.append(0)\n",
" \n",
" \n",
" content = json.loads(item[4])\n",
" if code not in dict1.keys():\n",
" dict1[code] = dict3[code]\n",
" rq = date.fromisoformat(item[5].replace('/','-').split(' ')[0])\n",
" dict1[code]['rq'] = str(date.fromisoformat(item[5].replace('/','-').split(' ')[0]))\n",
" #dict1[code]['rq'] = item[5].replace('/','-').split(' ')[0]\n",
" else:\n",
" rq=date.fromisoformat('2025-07-01')\n",
" dict1[code]['rq'] = '2025-07-01'\n",
" for k, v in content.items():\n",
" \n",
" if 'tcm' in k:\n",
" i = int(k[3:])\n",
" tcm[i-1] = int(v) \n",
" \n",
" if 'tcm' in item[4]: \n",
" dict1[code]['tcm'] = tcm\n",
" \n",
" birth = date.fromisoformat(dict3[code]['birth'].replace('/','-'))\n",
" \n",
" days = (rq-birth).days \n",
" dict1[code]['age'] = int(days/365)\n",
" dict1[code]['month'] = int(days/365*12)\n",
" #print(phone[item[2]])\n",
" nn+=1\n",
"filename = 'data/result_南京化工-1.json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False)\n"
]
},
{
"cell_type": "markdown",
"id": "89689b86-3fae-402e-a456-a646f0c7201f",
"metadata": {},
"source": [
"## 导入腰臀数据"
]
},
{
"cell_type": "code",
"execution_count": 81,
"id": "4a0678c6-0c64-4314-bb03-24b10a3d695a",
"metadata": {
"execution": {
"iopub.execute_input": "2025-07-03T14:11:29.937365Z",
"iopub.status.busy": "2025-07-03T14:11:29.936849Z",
"iopub.status.idle": "2025-07-03T14:11:29.966917Z",
"shell.execute_reply": "2025-07-03T14:11:29.966365Z",
"shell.execute_reply.started": "2025-07-03T14:11:29.937316Z"
}
},
"outputs": [],
"source": [
"import json\n",
"import csv\n",
"import openpyxl\n",
"import time\n",
"from datetime import date\n",
"\n",
"dict1 = {}\n",
"\n",
"filename = 'data/result_南京化工-1.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"wb = openpyxl.load_workbook('data/南化腰臀数据.xlsx',data_only=True)\n",
"sheet = wb.active\n",
"sheet.append(title)\n",
"for row in list1:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename)"
"# sheets = wb.sheetnames\n",
"person = {}\n",
"\n",
"for n in range(2, sheet.max_row+1):\n",
" code = str(sheet.cell(n, 1).value)\n",
" if code in dict1.keys():\n",
" yao = str(sheet.cell(n, 2).value)\n",
" tun = str(sheet.cell(n, 3).value)\n",
" dict1[code]['腰臀比'] = yao+','+tun\n",
"filename = 'data/result_南京化工-1.json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False)\n"
]
},
{
@@ -486,26 +555,10 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"id": "23ffd115-72a3-4f90-9e64-ffa6420df8a4",
"metadata": {
"execution": {
"iopub.execute_input": "2025-06-26T07:15:55.749748Z",
"iopub.status.busy": "2025-06-26T07:15:55.749253Z",
"iopub.status.idle": "2025-06-26T07:15:56.590649Z",
"shell.execute_reply": "2025-06-26T07:15:56.589700Z",
"shell.execute_reply.started": "2025-06-26T07:15:55.749700Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"import json\n",