103 lines
4.0 KiB
Python
103 lines
4.0 KiB
Python
|
import json
|
||
|
import random
|
||
|
import sys
|
||
|
import time
|
||
|
|
||
|
import numpy as np
|
||
|
|
||
|
from Database.database_mgr import *
|
||
|
from Exercise3.running_muwb import score_compute
|
||
|
from score_doc import get_fin_score
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
gender = "man"
|
||
|
age = 23
|
||
|
person_num = 60
|
||
|
day_tag = [
|
||
|
'2024年3月29日13时', '2024年4月2日13时', '2024年4月5日13时', '2024年4月9日13时', '2024年4月12日13时',
|
||
|
'2024年4月16日13时', '2024年4月19日13时', '2024年4月23日13时', '2024年4月26日13时', '2024年4月30日13时',
|
||
|
'2024年5月3日13时'
|
||
|
]
|
||
|
for day in day_tag:
|
||
|
date_struct = time.strptime(day, "%Y年%m月%d日%H时")
|
||
|
timestamp = time.mktime(date_struct)
|
||
|
print(day, timestamp)
|
||
|
days = len(day_tag)
|
||
|
|
||
|
# 生成基础数据
|
||
|
base = {}
|
||
|
# 引题向上
|
||
|
data = np.random.normal(loc=14, scale=7, size=(person_num,))
|
||
|
count_data = np.round(data)
|
||
|
for i, count in enumerate(count_data):
|
||
|
base.setdefault(PULLUP, [])
|
||
|
base[PULLUP].append(count)
|
||
|
|
||
|
# 仰卧起坐
|
||
|
data = np.random.normal(loc=60, scale=20, size=(person_num,))
|
||
|
count_data = np.round(data)
|
||
|
for i, count in enumerate(count_data):
|
||
|
base.setdefault(SITUP, [])
|
||
|
base[SITUP].append(count)
|
||
|
|
||
|
# 蛇形跑
|
||
|
data = np.random.normal(loc=20, scale=0.7, size=(person_num,))
|
||
|
count_data = np.round(data, 2)
|
||
|
for i, count in enumerate(count_data):
|
||
|
base.setdefault(RUNAROUND, [])
|
||
|
base[RUNAROUND].append(count)
|
||
|
|
||
|
# 长跑
|
||
|
data = np.random.normal(loc=790, scale=40, size=(person_num,))
|
||
|
count_data = np.round(data)
|
||
|
for i, count in enumerate(count_data):
|
||
|
base.setdefault(RUNNING, [])
|
||
|
base[RUNNING].append(count)
|
||
|
|
||
|
for dur in range(days):
|
||
|
# 引题向上
|
||
|
for i, count in enumerate(base[PULLUP]):
|
||
|
ratio = dur * random.randrange(start=0, stop=5000) / 1e6
|
||
|
count = count * (1 + ratio)
|
||
|
base[PULLUP][i] = count
|
||
|
score = get_fin_score.Military(gender, int(age),
|
||
|
integratedProjectResult=int(count)).IntegratedProjectScoreEvaluation()
|
||
|
if isinstance(score, str):
|
||
|
score = 0
|
||
|
print(i + 1, f"人员{i + 1}", f"{int(i // 10 + 1)}班", day_tag[dur], "PULLUP", int(count), score, dur)
|
||
|
|
||
|
# 仰卧起坐
|
||
|
for i, count in enumerate(base[SITUP]):
|
||
|
ratio = dur * random.randrange(start=0, stop=1000) / 1e6
|
||
|
count = count * (1 + ratio)
|
||
|
base[SITUP][i] = count
|
||
|
score = get_fin_score.Military(gender, int(age), sitUpsResult=int(count)).SitUpsScoreEvaluation()
|
||
|
if isinstance(score, str):
|
||
|
score = 0
|
||
|
print(i + 1, f"人员{i + 1}", f"{int(i // 10 + 1)}班", day_tag[dur], "SITUP", int(count), score, dur)
|
||
|
|
||
|
# 蛇形跑
|
||
|
for i, count in enumerate(base[RUNAROUND]):
|
||
|
ratio = dur * random.randrange(start=0, stop=500) / 1e6
|
||
|
count = count * (1 - ratio)
|
||
|
base[RUNAROUND][i] = count
|
||
|
score = get_fin_score.Military(gender, int(age),
|
||
|
serpentine60RunResult=round(count, 2)).Serpentine60RunScoreEvaluation()
|
||
|
if isinstance(score, str):
|
||
|
score = 0
|
||
|
print(i + 1, f"人员{i + 1}", f"{int(i // 10 + 1)}班", day_tag[dur], "RUNBF", round(count, 2), score, dur)
|
||
|
|
||
|
# 长跑
|
||
|
# 成绩文件
|
||
|
PATH = sys.path[0]
|
||
|
file = open(f"{PATH}/Exercise3/running_score.json")
|
||
|
score_data = json.load(file)
|
||
|
for i, count in enumerate(base[RUNNING]):
|
||
|
ratio = dur * random.randrange(start=0, stop=1000) / 1e6
|
||
|
count = count * (1 - ratio)
|
||
|
base[RUNNING][i] = count
|
||
|
score = score_compute(age=age, cost=count, score_data=score_data)
|
||
|
if isinstance(score, str):
|
||
|
score = 0
|
||
|
print(i + 1, f"人员{i + 1}", f"{int(i // 10 + 1)}班", day_tag[dur], "RUNNING", int(count), score, dur)
|