This commit is contained in:
512song committed 2025-11-07 14:43:16 +08:00
1 parent 2e77e939dd
commit b2ba8722fa
5 files changed
+855 -182

No files matched your search

@@ -47,26 +47,10 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "de3144e7-544a-4430-bf69-3d20479d50c9",
"metadata": {
"execution": {
"iopub.execute_input": "2025-08-25T07:09:50.818045Z",
"iopub.status.busy": "2025-08-25T07:09:50.817355Z",
"iopub.status.idle": "2025-08-25T07:09:51.017532Z",
"shell.execute_reply": "2025-08-25T07:09:51.017045Z",
"shell.execute_reply.started": "2025-08-25T07:09:50.817980Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"30 ok\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import openpyxl\n",
"import json\n",
@@ -106,27 +90,12 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "970e171e-1360-448f-a28c-520ccb8f314a",
"metadata": {
"execution": {
"iopub.execute_input": "2025-08-25T07:10:06.792695Z",
"iopub.status.busy": "2025-08-25T07:10:06.791764Z",
"iopub.status.idle": "2025-08-25T07:10:06.809711Z",
"shell.execute_reply": "2025-08-25T07:10:06.808745Z",
"shell.execute_reply.started": "2025-08-25T07:10:06.792617Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"25\n"
]
}
],
"outputs": [],
"source": [
"import json\n",
"import datetime\n",
@@ -183,26 +152,10 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "0905ad6a-f7e4-43ed-ae29-c4850deb946b",
"metadata": {
"execution": {
"iopub.execute_input": "2025-08-25T07:13:08.181827Z",
"iopub.status.busy": "2025-08-25T07:13:08.181087Z",
"iopub.status.idle": "2025-08-25T07:13:08.195674Z",
"shell.execute_reply": "2025-08-25T07:13:08.194568Z",
"shell.execute_reply.started": "2025-08-25T07:13:08.181758Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok!\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import time\n",
@@ -249,16 +202,9 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "867ad6b0-9e9d-48bc-a10a-3b9cb6125890",
"metadata": {
"execution": {
"iopub.execute_input": "2025-08-13T02:46:29.876079Z",
"iopub.status.busy": "2025-08-13T02:46:29.875587Z",
"iopub.status.idle": "2025-08-13T02:46:29.904595Z",
"shell.execute_reply": "2025-08-13T02:46:29.904071Z",
"shell.execute_reply.started": "2025-08-13T02:46:29.876014Z"
},
"tags": []
},
"outputs": [],
@@ -567,26 +513,10 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "23ffd115-72a3-4f90-9e64-ffa6420df8a4",
"metadata": {
"execution": {
"iopub.execute_input": "2025-08-25T07:13:29.388206Z",
"iopub.status.busy": "2025-08-25T07:13:29.387452Z",
"iopub.status.idle": "2025-08-25T07:13:42.980504Z",
"shell.execute_reply": "2025-08-25T07:13:42.979631Z",
"shell.execute_reply.started": "2025-08-25T07:13:29.388132Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"25\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"import json\n",
@@ -649,10 +579,253 @@
"print(i)"
]
},
{
"cell_type": "markdown",
"id": "ffb6c02a-8ae1-4332-96ca-ce541bfbf0be",
"metadata": {},
"source": [
"## 问卷信息统计"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "87556725-f68a-484b-827c-f6735155e940",
"id": "d22061b2-0109-4d6c-90d7-c31d9e318add",
"metadata": {},
"outputs": [],
"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_20251106.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",
"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 = phone\n",
" dict1.setdefault(code,{})\n",
" dict1[code]['name'] = content['name']\n",
" if content['gender'] == 'male':\n",
" dict1[code]['sex'] = '男'\n",
" else:\n",
" dict1[code]['sex'] = '女'\n",
" dict1[code]['birth'] = str(content['birth'])\n",
" dict1[code]['unit'] = '采油工艺研究院'\n",
" #dict1[code]['phone'] = phone\n",
" #dict1[code]['weight'] = dict2['weight']\n",
" #dict1[code]['waist'] = dict2['waist']\n",
" #dict1[code]['hip'] = dict2['hip']\n",
" dict1[code]['tcm'] = tcm\n",
"list1 = []\n",
"for k, v in dict1.items():\n",
" list2 = [k,v['name'],v['sex'],v['birth']]\n",
" list1.append(list2)\n",
"title =['手机号码','姓名','性别','出生年月']\n",
"filename = 'data/采油工艺研究院问卷人员(截至20251105).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": 21,
"id": "5c4df7b1-ced9-49c1-a9e4-dc2a54f201bc",
"metadata": {
"execution": {
"iopub.execute_input": "2025-11-06T02:15:58.258398Z",
"iopub.status.busy": "2025-11-06T02:15:58.257685Z",
"iopub.status.idle": "2025-11-06T02:15:58.274276Z",
"shell.execute_reply": "2025-11-06T02:15:58.273471Z",
"shell.execute_reply.started": "2025-11-06T02:15:58.258334Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"27\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_20251106.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",
"for item in list1:\n",
" dict2 = {}\n",
" \n",
" phone = str(item[0])[2:]\n",
" content = json.loads(json.loads(item[1]))\n",
" tcm = []\n",
" spine = []\n",
" for i in range(0,60):\n",
" tcm.append(0)\n",
" for i in range(0,25):\n",
" spine.append(0)\n",
" for k, v in content.items(): \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",
" spine[i-1] = int(v)\n",
" code = phone\n",
" dict1.setdefault(code,{})\n",
" dict1[code]['name'] = content['name']\n",
" if content['gender'] == 'male':\n",
" dict1[code]['sex'] = '男'\n",
" else:\n",
" dict1[code]['sex'] = '女'\n",
" dict1[code]['birth'] = str(content['birth'])+'-01'\n",
" dict1[code]['unit'] = '采油工艺研究院'\n",
" dict1[code]['tcm'] = tcm \n",
" dict1[code]['spine'] = spine\n",
" \n",
"filename = 'data/result_新疆油田-2511.json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False)\n",
"print(len(dict1))"
]
},
{
"cell_type": "markdown",
"id": "3a7bc501-6739-4b74-90f6-21066de637e2",
"metadata": {},
"source": [
"## 生成问卷报告"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "cdbeb2f8-2784-4688-806a-6506799941cb",
"metadata": {
"execution": {
"iopub.execute_input": "2025-11-06T02:20:43.542803Z",
"iopub.status.busy": "2025-11-06T02:20:43.542192Z",
"iopub.status.idle": "2025-11-06T02:20:50.673104Z",
"shell.execute_reply": "2025-11-06T02:20:50.671961Z",
"shell.execute_reply.started": "2025-11-06T02:20:43.542746Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"27\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_新疆油田-2511.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
"file_path ='./新疆油田-2511/'\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'] = 60\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": "8564de3a-1511-4a79-9ec3-32aea03595c7",
"metadata": {},
"outputs": [],
"source": []