LISHUZUOXUN_yangjiang/score_generator.py

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年4月5日8时', '2024年4月10日8时', '2024年4月13日15时', '2024年4月17日8时', '2024年4月20日15时',
'2024年4月24日8时', '2024年4月26日15时', '2024年4月30日8时', '2024年5月3日8时', '2024年5月8日8时',
'2024年5月10日15时'
]
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=2, 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=10, 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.3, 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=20, 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)