diff --git a/PythonProject/api/statistics_api.py b/PythonProject/api/statistics_api.py index c1804ef..e327bf3 100644 --- a/PythonProject/api/statistics_api.py +++ b/PythonProject/api/statistics_api.py @@ -40,4 +40,10 @@ def get_days(db=Depends(get_db)): @StatisticsAPI.get('/emp',response_model=AllEmpResponse,tags=['统计分析模块'],summary='统计每个学生的就业时长') def get_emp(db=Depends(get_db)): l= select_days2(db) - return l \ No newline at end of file + return l + +# 薪资区间分布:统计薪资在5k以下、5k-10k、10k-15k、15k以上的人数分布,反映学生的整体就业质量。 +@StatisticsAPI.get('/salaries',tags=['统计分析模块'],summary='统计薪资分布') +def get_salaries(db=Depends(get_db)): + s=classify_salary(db) + return s \ No newline at end of file diff --git a/PythonProject/dao/statistics_dao.py b/PythonProject/dao/statistics_dao.py index 68780c6..5f79595 100644 --- a/PythonProject/dao/statistics_dao.py +++ b/PythonProject/dao/statistics_dao.py @@ -107,4 +107,25 @@ def select_days2(db): ).all() return l2 except Exception: - raise HTTPException(status_code=500, detail="查询异常") \ No newline at end of file + raise HTTPException(status_code=500, detail="查询异常") + + +# 薪资区间分布:统计薪资在5k以下、5k-10k、10k-15k、15k以上的人数分布,反映学生的整体就业质量。 +def classify_salary(db): + try: + a=b=c=d=0 + l=db.query(Employment_info).filter(Employment_info.delete_status==0).all() + for i in l: + if i.salary is None: + continue + elif i.salary<5000: + a+=1 + elif 5000<=i.salary<10000: + b+=1 + elif 10000<=i.salary<15000: + c+=1 + else: + d+=1 + return {'5k以下': a, '5k-10k': b, '10k-15k': c, '15k': d} + except: + raise HTTPException(status_code=500,detail='查询异常!')