This commit is contained in:
512song committed 2025-11-14 13:50:06 +08:00
1 parent f3a7c981d5
commit 48f119d087
5 files changed
+1196 -131

No files matched your search

@@ -80,6 +80,57 @@
"print(len(person),'ok')"
]
},
{
"cell_type": "code",
"execution_count": 39,
"id": "cac3736a-56da-403b-9e62-5caaf989a6d4",
"metadata": {
"execution": {
"iopub.execute_input": "2025-11-14T05:28:56.646944Z",
"iopub.status.busy": "2025-11-14T05:28:56.646299Z",
"iopub.status.idle": "2025-11-14T05:28:58.033233Z",
"shell.execute_reply": "2025-11-14T05:28:58.032644Z",
"shell.execute_reply.started": "2025-11-14T05:28:56.646884Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"72 ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"\n",
"wb = openpyxl.load_workbook('data/采油院11月份测试名单.xlsx',data_only=True)\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"person = {}\n",
"\n",
"for n in range(2, sheet.max_row+1):\n",
" code = int(sheet.cell(n, 2).value)\n",
" person.setdefault(str(code), {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 1).value\n",
" dict1['sex'] = sheet.cell(n, 4).value\n",
" if sheet.cell(n,8).value is not None:\n",
" dict1['unit'] = sheet.cell(n, 8).value\n",
" else:\n",
" dict1['unit'] = ''\n",
" dict1['birth'] = str(sheet.cell(n, 5).value).replace('/','-').split(' ')[0]\n",
" dict1['phone'] = sheet.cell(n,7).value \n",
" person[code] = dict1\n",
"filename = 'data/新疆油田采油工艺研究院-202511.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": "6bcd45c2-10af-4d5f-9e0b-5cd1df4f7a7f",
@@ -142,6 +193,48 @@
"print(len(re_ta))"
]
},
{
"cell_type": "code",
"execution_count": 40,
"id": "925f7152-b365-4df8-8d98-73569aef68f8",
"metadata": {
"execution": {
"iopub.execute_input": "2025-11-14T05:30:21.558180Z",
"iopub.status.busy": "2025-11-14T05:30:21.557445Z",
"iopub.status.idle": "2025-11-14T05:30:21.572875Z",
"shell.execute_reply": "2025-11-14T05:30:21.571867Z",
"shell.execute_reply.started": "2025-11-14T05:30:21.558103Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"35\n"
]
}
],
"source": [
"import json\n",
"import datetime\n",
"import csv\n",
"from datetime import date\n",
"import my_module as My\n",
"\n",
"filename = 'data/新疆油田采油工艺研究院-202511.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"filename = 'data/marks_20251114-1.csv'\n",
"re_ta = My.get_result(filename,dict1)\n",
"\n",
"\n",
"filename = 'data/result_新疆油田采油工艺研究院2511.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(re_ta, fl, ensure_ascii=False) \n",
"print(len(re_ta))"
]
},
{
"cell_type": "markdown",
"id": "6d381859-6d21-45d2-8313-55ebbabf8bd4",
@@ -192,6 +285,64 @@
"print('ok!') "
]
},
{
"cell_type": "code",
"execution_count": 41,
"id": "0e71f6b8-e17e-49f8-a577-7a2eb6f5e994",
"metadata": {
"execution": {
"iopub.execute_input": "2025-11-14T05:30:31.220354Z",
"iopub.status.busy": "2025-11-14T05:30:31.219652Z",
"iopub.status.idle": "2025-11-14T05:30:31.233956Z",
"shell.execute_reply": "2025-11-14T05:30:31.232979Z",
"shell.execute_reply.started": "2025-11-14T05:30:31.220290Z"
}
},
"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_新疆油田采油工艺研究院2511.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_新疆油田采油工艺研究院2511.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",
@@ -503,6 +654,97 @@
"print(nn)"
]
},
{
"cell_type": "markdown",
"id": "6eea20f8-b457-455e-8409-5c8cdaa1efb6",
"metadata": {},
"source": [
"### 导入问卷信息(202511)"
]
},
{
"cell_type": "code",
"execution_count": 42,
"id": "83872322-129c-410d-a9a3-ef6f4fe8dcde",
"metadata": {
"execution": {
"iopub.execute_input": "2025-11-14T05:31:42.228026Z",
"iopub.status.busy": "2025-11-14T05:31:42.227253Z",
"iopub.status.idle": "2025-11-14T05:31:42.243026Z",
"shell.execute_reply": "2025-11-14T05:31:42.242577Z",
"shell.execute_reply.started": "2025-11-14T05:31:42.227955Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"35\n"
]
}
],
"source": [
"import json\n",
"import csv\n",
"import openpyxl\n",
"import time\n",
"from datetime import date\n",
"\n",
"list1 = []\n",
"filename = 'data/sql_20251114.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",
"filename = 'data/新疆油田采油工艺研究院-202511.json'\n",
"with open(filename,'r') as fl:\n",
" dict3 = json.load(fl)\n",
"filename = 'data/result_新疆油田采油工艺研究院2511.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"phone = {}\n",
"for k,v in dict3.items():\n",
" if 'phone' in v.keys():\n",
" phone[str(v['phone'])] = k\n",
"\n",
"\n",
"\n",
"nn = 0\n",
"for item in list1:\n",
" dict2 = {}\n",
" \n",
" phone_num = str(item[0])[2:]\n",
" if phone_num in phone:\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,26):\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",
" if i<23:\n",
" spine[i-1] = int(v)\n",
" else:\n",
" spine[i] = int(v)\n",
" \n",
" code = phone[phone_num]\n",
" if code in dict3.keys(): \n",
" dict1[code]['tcm'] = tcm \n",
" dict1[code]['spine'] = spine\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False)\n",
"print(len(dict1))"
]
},
{
"cell_type": "markdown",
"id": "8d5f4103-0d1e-4711-b324-ece360f8dcd3",
@@ -579,6 +821,90 @@
"print(i)"
]
},
{
"cell_type": "code",
"execution_count": 43,
"id": "694ad38e-755e-4885-94a9-c157ddc96564",
"metadata": {
"execution": {
"iopub.execute_input": "2025-11-14T05:32:21.311002Z",
"iopub.status.busy": "2025-11-14T05:32:21.310252Z",
"iopub.status.idle": "2025-11-14T05:32:41.401453Z",
"shell.execute_reply": "2025-11-14T05:32:41.400670Z",
"shell.execute_reply.started": "2025-11-14T05:32:21.310932Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"35\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'] = 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": "markdown",
"id": "ffb6c02a-8ae1-4332-96ca-ce541bfbf0be",
@@ -656,15 +982,15 @@
},
{
"cell_type": "code",
"execution_count": 21,
"id": "5c4df7b1-ced9-49c1-a9e4-dc2a54f201bc",
"execution_count": 26,
"id": "73d28b6a-91be-47bb-bf76-1b8c26faafb5",
"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"
"iopub.execute_input": "2025-11-11T04:31:28.041103Z",
"iopub.status.busy": "2025-11-11T04:31:28.040413Z",
"iopub.status.idle": "2025-11-11T04:31:28.055394Z",
"shell.execute_reply": "2025-11-11T04:31:28.054740Z",
"shell.execute_reply.started": "2025-11-11T04:31:28.041040Z"
}
},
"outputs": [
@@ -702,7 +1028,7 @@
" spine = []\n",
" for i in range(0,60):\n",
" tcm.append(0)\n",
" for i in range(0,25):\n",
" for i in range(0,26):\n",
" spine.append(0)\n",
" for k, v in content.items(): \n",
" if 'tcm' in k:\n",
@@ -710,7 +1036,11 @@
" tcm[i-1] = int(v)\n",
" if 'spine' in k:\n",
" i = int(k[5:])\n",
" spine[i-1] = int(v)\n",
" if i<23:\n",
" spine[i-1] = int(v)\n",
" else:\n",
" spine[i] = int(v)\n",
" \n",
" code = phone\n",
" dict1.setdefault(code,{})\n",
" dict1[code]['name'] = content['name']\n",
@@ -723,7 +1053,7 @@
" dict1[code]['tcm'] = tcm \n",
" dict1[code]['spine'] = spine\n",
" \n",
"filename = 'data/result_新疆油田-2511.json'\n",
"filename = 'data/result_新疆油田-2511-1.json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False)\n",
@@ -740,15 +1070,15 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 27,
"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"
"iopub.execute_input": "2025-11-11T04:31:58.919201Z",
"iopub.status.busy": "2025-11-11T04:31:58.918605Z",
"iopub.status.idle": "2025-11-11T04:32:06.150780Z",
"shell.execute_reply": "2025-11-11T04:32:06.149803Z",
"shell.execute_reply.started": "2025-11-11T04:31:58.919144Z"
}
},
"outputs": [
@@ -769,11 +1099,11 @@
"headers = {\n",
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
" }\n",
"filename = 'data/result_新疆油田-2511.json'\n",
"filename = 'data/result_新疆油田-2511-1.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
"file_path ='./新疆油田-2511/'\n",
"file_path ='./新疆油田-2511-1/'\n",
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
"i=0\n",
"list2 = []\n",