This commit is contained in:
512song committed 2025-06-13 18:32:13 +08:00
1 parent db1359b2d0
commit b424b0f3b6
4 files changed
+501 -202

No files matched your search

+220 -39
View File
@@ -10,12 +10,27 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 33,
"id": "bbba6efc-73cd-4db6-bae7-014724fee731",
"metadata": {
"execution": {
"iopub.execute_input": "2025-06-13T10:07:44.495425Z",
"iopub.status.busy": "2025-06-13T10:07:44.493555Z",
"iopub.status.idle": "2025-06-13T10:07:44.777744Z",
"shell.execute_reply": "2025-06-13T10:07:44.777194Z",
"shell.execute_reply.started": "2025-06-13T10:07:44.495298Z"
},
"tags": []
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
@@ -90,12 +105,27 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 34,
"id": "970e171e-1360-448f-a28c-520ccb8f314a",
"metadata": {
"execution": {
"iopub.execute_input": "2025-06-13T10:07:57.397108Z",
"iopub.status.busy": "2025-06-13T10:07:57.396380Z",
"iopub.status.idle": "2025-06-13T10:07:57.473353Z",
"shell.execute_reply": "2025-06-13T10:07:57.472766Z",
"shell.execute_reply.started": "2025-06-13T10:07:57.397044Z"
},
"tags": []
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1131\n"
]
}
],
"source": [
"import json\n",
"import datetime\n",
@@ -106,7 +136,7 @@
"filename = 'data/宁夏能化人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"filename = 'data/marks_20250611.csv'\n",
"filename = 'data/marks_20250613.csv'\n",
"re_ta = My.get_result(filename,dict1)\n",
"\n",
"\n",
@@ -116,6 +146,72 @@
"print(len(re_ta))"
]
},
{
"cell_type": "markdown",
"id": "6d381859-6d21-45d2-8313-55ebbabf8bd4",
"metadata": {},
"source": [
"## 生成测试得分"
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "0905ad6a-f7e4-43ed-ae29-c4850deb946b",
"metadata": {
"execution": {
"iopub.execute_input": "2025-06-13T10:08:03.790216Z",
"iopub.status.busy": "2025-06-13T10:08:03.789961Z",
"iopub.status.idle": "2025-06-13T10:08:03.907343Z",
"shell.execute_reply": "2025-06-13T10:08:03.906882Z",
"shell.execute_reply.started": "2025-06-13T10:08:03.790193Z"
}
},
"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!') "
]
},
{
"cell_type": "markdown",
"id": "d034a61d-1fbd-417b-99bd-277e43ebb678",
@@ -192,15 +288,15 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 37,
"id": "c4b71b0f-0f0c-4962-a540-611cbab51bfa",
"metadata": {
"execution": {
"iopub.execute_input": "2025-06-11T10:33:23.785169Z",
"iopub.status.busy": "2025-06-11T10:33:23.784411Z",
"iopub.status.idle": "2025-06-11T10:33:23.824528Z",
"shell.execute_reply": "2025-06-11T10:33:23.823918Z",
"shell.execute_reply.started": "2025-06-11T10:33:23.785101Z"
"iopub.execute_input": "2025-06-13T10:22:08.044562Z",
"iopub.status.busy": "2025-06-13T10:22:08.043982Z",
"iopub.status.idle": "2025-06-13T10:22:08.121488Z",
"shell.execute_reply": "2025-06-13T10:22:08.120903Z",
"shell.execute_reply.started": "2025-06-13T10:22:08.044505Z"
}
},
"outputs": [],
@@ -215,29 +311,22 @@
"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",
" if unit=='管理部门':\n",
" sub_unit = v['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",
" #dict3[unit]['人数'] = dict3[unit]['人数'] + 1\n",
"\n",
"title =['单位','体测人数']\n",
"list1 = []\n",
"\n",
"for k, v in dict3.items():\n",
" list2 = []\n",
" for k1,v1 in v.items():\n",
" list2 = [k,k1,v1['人数']]\n",
"for k, v in dict2.items():\n",
" if k not in dict1.keys():\n",
" list2 = []\n",
" unit = v['unit']\n",
" if unit=='管理部门':\n",
" sub_unit = v['sub_unit']\n",
" else:\n",
" sub_unit = unit\n",
" list2 = [k,v['name'],v['sex'],sub_unit]\n",
" list1.append(list2)\n",
" \n",
"\n",
"filename = 'data/宁夏能化人员情况.xlsx'\n",
"\n",
"\n",
"filename = 'data/宁夏能化未体测人员(截至20250613).xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(title)\n",
@@ -257,15 +346,15 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 36,
"id": "def3f47a-24ef-4815-b63b-2a16b79b4c15",
"metadata": {
"execution": {
"iopub.execute_input": "2025-06-11T10:49:09.048584Z",
"iopub.status.busy": "2025-06-11T10:49:09.047316Z",
"iopub.status.idle": "2025-06-11T10:49:09.067937Z",
"shell.execute_reply": "2025-06-11T10:49:09.067219Z",
"shell.execute_reply.started": "2025-06-11T10:49:09.048505Z"
"iopub.execute_input": "2025-06-13T10:08:30.376056Z",
"iopub.status.busy": "2025-06-13T10:08:30.375387Z",
"iopub.status.idle": "2025-06-13T10:08:30.403659Z",
"shell.execute_reply": "2025-06-13T10:08:30.403187Z",
"shell.execute_reply.started": "2025-06-13T10:08:30.376001Z"
},
"tags": []
},
@@ -303,7 +392,7 @@
" list2 = [k,k1,v1['人数']]\n",
" list1.append(list2)\n",
"\n",
"filename = 'data/宁夏能化部门测试情况表(截至20260611).xlsx'\n",
"filename = 'data/宁夏能化部门测试情况表(截至20260613).xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(title)\n",
@@ -313,10 +402,102 @@
"wb.save(filename)"
]
},
{
"cell_type": "markdown",
"id": "8d5f4103-0d1e-4711-b324-ece360f8dcd3",
"metadata": {},
"source": [
"## 生成报告"
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "23ffd115-72a3-4f90-9e64-ffa6420df8a4",
"metadata": {
"execution": {
"iopub.execute_input": "2025-06-13T03:03:04.228661Z",
"iopub.status.busy": "2025-06-13T03:03:04.228138Z",
"iopub.status.idle": "2025-06-13T03:08:51.563935Z",
"shell.execute_reply": "2025-06-13T03:08:51.562949Z",
"shell.execute_reply.started": "2025-06-13T03:03:04.228598Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"690\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",
"list1 = []\n",
"file_path ='./宁夏能化人员/'\n",
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
"i=0\n",
"list2 = []\n",
"for k, v in dict1.items():\n",
" list1 = []\n",
" mydata = {}\n",
" \n",
" id = str(k).rjust(4,\"0\")\n",
" mydata['path'] = file_path+id+'-'+ v['name']+'.pdf'\n",
" mydata['title'] = '中国石化长城能源化工(宁夏)有限公司'\n",
" mydata['subtitle'] = v['unit']\n",
" mydata['id'] = id\n",
" mydata['name'] = v['name']\n",
" if v['sex'] == '男':\n",
" mydata['gender'] = 'male'\n",
" else:\n",
" mydata['gender'] = 'female'\n",
" \n",
" mydata['month'] = v['month']\n",
" mydata['fits'] = {}\n",
" survey_list = ['tcm','psy57','spine']\n",
" for item in survey_list:\n",
" if item in v.keys():\n",
" mydata.setdefault('surveys',{})\n",
" mydata['surveys'][item] = v[item]\n",
" \n",
" \n",
" #mydata['fits'] = {}\n",
" for item in list_item:\n",
" if item in v.keys():\n",
" mydata.setdefault('fits',{})\n",
" if item in ['lung','pushup','step','situp']:\n",
" mark = v[item]['成绩'].split()[0].split('.')[0]\n",
" else:\n",
" mark = v[item]['成绩'].split()[0]\n",
" mydata['fits'][item] = {'mark':mark,'score':v[item]['score']}\n",
" #if len(mydata['fits']) >2 or len(mydata['surveys']) >0:\n",
" if len(mydata['fits']) >2 : \n",
" list1.append(mydata)\n",
" list2.append([k,v['name']])\n",
" i+=1\n",
" x = requests.post('http://localhost:3003', data = json.dumps(list1), headers=headers)\n",
" #print(id,v['name'],x.text)\n",
" #print(mydata)\n",
" #x.close()\n",
"print(i)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "67e63f07-3f20-4e0e-9c07-7bf6024eeb4b",
"id": "87556725-f68a-484b-827c-f6735155e940",
"metadata": {},
"outputs": [],
"source": []