Commit 2520c23b authored by huangqiang's avatar huangqiang

完成基础参数设置

parent e734a68a
This diff is collapsed.
...@@ -62,7 +62,7 @@ class RunTest: ...@@ -62,7 +62,7 @@ class RunTest:
if __name__ == '__main__': if __name__ == '__main__':
case_path_list = [ case_path_list = [
"./script/download_flle/jyy_download_file/test_education_download.py", "./script/ji_yun_ying_pc/system_set/test_basic_parameter_set.py::TestFullClassTargetSet",
# "./script/ding_ding_jdata/person_time/test_person_time.py::TestsPersonTimeDetail::test_detail_page_search_date", # "./script/ding_ding_jdata/person_time/test_person_time.py::TestsPersonTimeDetail::test_detail_page_search_date",
# "./script/ding_ding_jdata/person_time/test_person_time.py::TestsPersonTimeDetail::test_detail_page_search_target", # "./script/ding_ding_jdata/person_time/test_person_time.py::TestsPersonTimeDetail::test_detail_page_search_target",
# "./script/ding_ding_jdata/person_time/test_person_time.py::TestsPersonTimeDetail::test_detail_page_search_subject", # "./script/ding_ding_jdata/person_time/test_person_time.py::TestsPersonTimeDetail::test_detail_page_search_subject",
......
from script.base_api.service_education.education import education_classes_query_post from script.base_api.service_education.education import education_classes_query_post
from script.global_data_config.global_data import GlobalDataConfig from script.global_data_config.global_data import GlobalDataConfig
from script.base_api.service_education.classCapacity import classCapacity_query_post
from script.default_header import jyy_header from script.default_header import jyy_header
# 查询班级列表
class QueryClassList: class QueryClassList:
def __init__(self, courseType="常规班课", pageNum=1, pageSize=10, schoolAreaIds=None): def __init__(self, courseType="常规班课", pageNum=1, pageSize=10, schoolAreaIds=None):
...@@ -14,3 +16,17 @@ class QueryClassList: ...@@ -14,3 +16,17 @@ class QueryClassList:
def run(self, other_field: dict = {}, header=jyy_header, return_json=True, **kwargs): def run(self, other_field: dict = {}, header=jyy_header, return_json=True, **kwargs):
body = {**self.__dict__, **other_field} body = {**self.__dict__, **other_field}
return education_classes_query_post(body=body, header=header, return_json=return_json, **kwargs) return education_classes_query_post(body=body, header=header, return_json=return_json, **kwargs)
# 查询满班目标
class QueryFullClassTarget:
def __init__(self, pageNum=1, pageSize=10, grade="", subject=""):
self.pageNum = pageNum
self.pageSize = pageSize
self.grade = grade
self.subject = subject
def run(self, other_field: dict = {}, header=jyy_header, return_json=True, **kwargs):
body = {**self.__dict__, **other_field}
return classCapacity_query_post(body=body, header=header, return_json=return_json, **kwargs)
\ No newline at end of file
...@@ -3,6 +3,7 @@ from script.base_api.service_education.system import system_setting_querySystemS ...@@ -3,6 +3,7 @@ from script.base_api.service_education.system import system_setting_querySystemS
from script.default_header import jyy_header from script.default_header import jyy_header
# 查询系统设置(默认退费原因)
class QuerySystemSetting: class QuerySystemSetting:
def __init__(self, types=["refundReason"]): def __init__(self, types=["refundReason"]):
......
...@@ -2,6 +2,7 @@ from script.base_api.service_gos.gos import gos_upload_uploadGoods_file_post ...@@ -2,6 +2,7 @@ from script.base_api.service_gos.gos import gos_upload_uploadGoods_file_post
from script.default_header import jyy_header from script.default_header import jyy_header
# 上传图片
class GosUploadGoodsFile: class GosUploadGoodsFile:
def __init__(self, base64files=None): def __init__(self, base64files=None):
......
...@@ -3,6 +3,7 @@ from script.global_data_config.global_data import GlobalDataConfig ...@@ -3,6 +3,7 @@ from script.global_data_config.global_data import GlobalDataConfig
from script.default_header import jyy_header from script.default_header import jyy_header
# 设置目标方案
class TargetSet: class TargetSet:
def __init__(self, school_area_id, target_data: dict, target=None): def __init__(self, school_area_id, target_data: dict, target=None):
......
...@@ -3,15 +3,12 @@ from script.base_api.service_statistics.statistics import statistics_query_conti ...@@ -3,15 +3,12 @@ from script.base_api.service_statistics.statistics import statistics_query_conti
from script.base_api.service_statistics.statistics import statistics_refundRate_post from script.base_api.service_statistics.statistics import statistics_refundRate_post
from script.base_api.service_statistics.statistics import statistics_fullClass_rate_post from script.base_api.service_statistics.statistics import statistics_fullClass_rate_post
from script.base_api.service_statistics.statistics import statistics_supplementaryPayment_post from script.base_api.service_statistics.statistics import statistics_supplementaryPayment_post
from script.global_data_config.school_data import SchoolDataConfig
from script.default_header import jyy_header from script.default_header import jyy_header
from common.operation_time import GetTime from common.operation_time import GetTime
# 成都一区的校区ID
cd1_school_area_id = [3104, 3166, 3334, 3335, 3337, 3339, 3340, 3373, 3158, 2371, 2389, 2400,
3069, 3099, 3149, 2397, 2398, 3044, 3054, 3063, 2369, 2385, 2386, 2388,
2399, 2401, 3097, 3137, 3155, 3156, 2416, 3039, 3065, 3167, 2368, 3071]
# 查询人次
class PersonTime: class PersonTime:
def __init__(self, pageNum=1, pageSize=10, createTime=None, year="2021", term="暑", groups=None, schoolIds=None, refundType="teacherRefund"): def __init__(self, pageNum=1, pageSize=10, createTime=None, year="2021", term="暑", groups=None, schoolIds=None, refundType="teacherRefund"):
...@@ -21,14 +18,14 @@ class PersonTime: ...@@ -21,14 +18,14 @@ class PersonTime:
self.year = year self.year = year
self.term = term self.term = term
self.groups = groups or ["big_area_id", "area_id", "school_area_id"] self.groups = groups or ["big_area_id", "area_id", "school_area_id"]
self.schoolIds = schoolIds or cd1_school_area_id self.schoolIds = schoolIds or SchoolDataConfig.get_department_id(is_rm_test_school=True)
self.refundType = refundType self.refundType = refundType
def run(self, other_field: dict = {}, header=jyy_header, return_json=True, **kwargs): def run(self, other_field: dict = {}, header=jyy_header, return_json=True, **kwargs):
body = {**self.__dict__, **other_field} body = {**self.__dict__, **other_field}
return statistics_personTime_post(body=body, header=header, return_json=return_json, **kwargs) return statistics_personTime_post(body=body, header=header, return_json=return_json, **kwargs)
# 查询续报率
class ContinueRate: class ContinueRate:
def __init__(self, pageNum=1, pageSize=10, createTime=None, year="2021", term="暑", groups=None, schoolIds=None, refundType="teacherRefund"): def __init__(self, pageNum=1, pageSize=10, createTime=None, year="2021", term="暑", groups=None, schoolIds=None, refundType="teacherRefund"):
...@@ -38,7 +35,7 @@ class ContinueRate: ...@@ -38,7 +35,7 @@ class ContinueRate:
self.year = year self.year = year
self.term = term self.term = term
self.groups = groups or ["big_area_id", "area_id", "school_area_id"] self.groups = groups or ["big_area_id", "area_id", "school_area_id"]
self.schoolIds = schoolIds or cd1_school_area_id self.schoolIds = schoolIds or SchoolDataConfig.get_department_id(is_rm_test_school=True)
self.refundType = refundType self.refundType = refundType
def run(self, other_field: dict = {}, header=jyy_header, return_json=True, **kwargs): def run(self, other_field: dict = {}, header=jyy_header, return_json=True, **kwargs):
...@@ -46,6 +43,7 @@ class ContinueRate: ...@@ -46,6 +43,7 @@ class ContinueRate:
return statistics_query_continue_post(body=body, header=header, return_json=return_json, **kwargs) return statistics_query_continue_post(body=body, header=header, return_json=return_json, **kwargs)
# 查询退费率
class RefundRate: class RefundRate:
def __init__(self, pageNum=1, pageSize=10, createTime=None, year="2021", term="暑", groups=None, schoolIds=None, refundType="schoolRefund"): def __init__(self, pageNum=1, pageSize=10, createTime=None, year="2021", term="暑", groups=None, schoolIds=None, refundType="schoolRefund"):
...@@ -55,7 +53,7 @@ class RefundRate: ...@@ -55,7 +53,7 @@ class RefundRate:
self.year = year self.year = year
self.term = term self.term = term
self.groups = groups or ["big_area_id", "area_id", "school_area_id"] self.groups = groups or ["big_area_id", "area_id", "school_area_id"]
self.schoolIds = schoolIds or cd1_school_area_id self.schoolIds = schoolIds or SchoolDataConfig.get_department_id(is_rm_test_school=True)
self.refundType = refundType self.refundType = refundType
def run(self, other_field: dict = {}, header=jyy_header, return_json=True, **kwargs): def run(self, other_field: dict = {}, header=jyy_header, return_json=True, **kwargs):
...@@ -63,6 +61,7 @@ class RefundRate: ...@@ -63,6 +61,7 @@ class RefundRate:
return statistics_refundRate_post(body=body, header=header, return_json=return_json, **kwargs) return statistics_refundRate_post(body=body, header=header, return_json=return_json, **kwargs)
# 查询满班率
class FullClassRate: class FullClassRate:
def __init__(self, pageNum=1, pageSize=10, createTime=None, year="2021", term="暑", groups=None, schoolIds=None, refundType="teacherRefund"): def __init__(self, pageNum=1, pageSize=10, createTime=None, year="2021", term="暑", groups=None, schoolIds=None, refundType="teacherRefund"):
...@@ -72,7 +71,7 @@ class FullClassRate: ...@@ -72,7 +71,7 @@ class FullClassRate:
self.year = year self.year = year
self.term = term self.term = term
self.groups = groups or ["big_area_id", "area_id", "school_area_id"] self.groups = groups or ["big_area_id", "area_id", "school_area_id"]
self.schoolIds = schoolIds or cd1_school_area_id self.schoolIds = schoolIds or SchoolDataConfig.get_department_id(is_rm_test_school=True)
self.refundType = refundType self.refundType = refundType
def run(self, other_field: dict = {}, header=jyy_header, return_json=True, **kwargs): def run(self, other_field: dict = {}, header=jyy_header, return_json=True, **kwargs):
...@@ -80,6 +79,7 @@ class FullClassRate: ...@@ -80,6 +79,7 @@ class FullClassRate:
return statistics_fullClass_rate_post(body=body, header=header, return_json=return_json, **kwargs) return statistics_fullClass_rate_post(body=body, header=header, return_json=return_json, **kwargs)
# 查询补费率
class FillRate: class FillRate:
def __init__(self, pageNum=1, pageSize=10, createTime=None, year="2021", term="暑", groups=None, schoolIds=None, refundType="teacherRefund"): def __init__(self, pageNum=1, pageSize=10, createTime=None, year="2021", term="暑", groups=None, schoolIds=None, refundType="teacherRefund"):
...@@ -89,7 +89,7 @@ class FillRate: ...@@ -89,7 +89,7 @@ class FillRate:
self.year = year self.year = year
self.term = term self.term = term
self.groups = groups or ["big_area_id", "area_id", "school_area_id"] self.groups = groups or ["big_area_id", "area_id", "school_area_id"]
self.schoolIds = schoolIds or cd1_school_area_id self.schoolIds = schoolIds or SchoolDataConfig.get_department_id(is_rm_test_school=True)
self.refundType = refundType self.refundType = refundType
def run(self, other_field: dict = {}, header=jyy_header, return_json=True, **kwargs): def run(self, other_field: dict = {}, header=jyy_header, return_json=True, **kwargs):
......
...@@ -29,8 +29,6 @@ groups_field_map = { ...@@ -29,8 +29,6 @@ groups_field_map = {
} }
# 获取日期筛选数据(默认最近7天) # 获取日期筛选数据(默认最近7天)
def get_date_search_data(num: int = 6): def get_date_search_data(num: int = 6):
today_date = GetTime.get_today().get("today_date") today_date = GetTime.get_today().get("today_date")
......
class ClassDataConfig:
year = [2019, 2020, 2021, 2022]
grade = ["零年级", "一年级", "二年级", "三年级", "四年级", "五年级", "六年级", "七年级", "八年级", "九年级", "高一", "高二", "高三"]
term = ["春", "暑", "秋", "寒"]
# 学段
learning_period = ["小低", "小高", "初中", "高中"]
# 小低
small_low = ["一年级", "二年级", "三年级"]
# 小高
small_high = ["四年级", "五年级", "六年级"]
# 初中
junior_high = ["七年级", "八年级", "九年级"]
# 高中
high_school = ["高一", "高二", "高三"]
subject = ["语文", "英语", "物理", "数学", "化学"]
course_type = ["常规班课", "精品定制课", "服务班课", "集训班课", "专题班课"]
class_type = {
"常规班课": ["极趣班", "极思班", "极智班", "极客班", "极客A班", "极客蓝队班", "五四极趣班", "五四极思班", "五四极智班", "新生", "人教班", "八人精品", "定制班"],
"精品定制课": ["一对一定制班", "一对三定制班", "一对八定制班", "一对六定制班"],
"服务班课": ["公开课", "辅导课", "讲座"],
"集训班课": ["五年级选修课班", "五四制班", "知识体系复习课班"],
"专题班课": ["专题"]
}
# 期数
phase = [1, 0, 2, 3, 4]
# 价格类型
priceType = ["低价", "正价"]
# 学生类型
studentType = ["老生", "新生"]
# 获取所有班型
@classmethod
def get_all_class_type(cls):
all_class_type = []
for v in cls.class_type.values():
all_class_type = [*all_class_type, *v]
return all_class_type
# 获取常规班型
@classmethod
def get_routine_class_type(cls, is_rm_new_student_class=False):
all_routine_class_type = cls.class_type.get("常规班课")
if is_rm_new_student_class:
all_routine_class_type.remove("新生")
return all_routine_class_type
# 获取精品班型
@classmethod
def get_boutique_class_type(cls):
return cls.class_type.get("精品定制课")
# 获取服务班型
@classmethod
def get_service_class_type(cls):
return cls.class_type.get("服务班课")
# 获取专题班型
@classmethod
def get_special_class_type(cls):
return cls.class_type.get("专题班课")
# 获取专题班型
@classmethod
def get_ji_xun_class_type(cls):
return cls.class_type.get("集训班课")
if __name__ == '__main__':
print(ClassDataConfig.get_routine_class_type(True))
\ No newline at end of file
from common.operation_time import GetTime
class DateDataConfig:
# 今天日期
today_date = GetTime.get_today().get("today_date")
# 今天日期
yesterday_date = GetTime.get_today_before(1).get("before_date_1")
# 7天前的日期
before_date_7 = GetTime.get_today_before(7).get("before_date_7")
# 30天前的日期
before_date_30 = GetTime.get_today_before(30).get("before_date_30")
# 获取最近日期筛选数据(默认最近7天)
@staticmethod
def get_date_search_data(num: int = 6):
today_date = GetTime.get_today().get("today_date")
start_date = GetTime.get_today_before(num).get(f"before_date_{num}")
return GetTime.get_every_day(start_date, today_date)
# 获取日期列表的列表的筛选数据
@staticmethod
def get_date_list_de_list():
date_data_list = []
today_date = GetTime.get_today().get("today_date")
date_data_list.append((today_date, today_date))
for x in range(5, 35, 5):
date_data_list.append((GetTime.get_today_before(x).get(f"before_date_{x}"), today_date))
date_data_list = [GetTime.get_every_day(*x) for x in date_data_list]
return date_data_list
# 日期按按周分组
@staticmethod
def get_week_date_group(begin_date, end_date):
week_info_list = GetTime.get_week_info(begin_date, end_date)
year_weeks = set([x.get("year_week") for x in week_info_list])
week_group = []
for year_week in year_weeks:
week_date = [x.get('date_data') for x in week_info_list if x.get("year_week") == year_week]
week_group.append({
"year_week": year_week,
"week_date": week_date
})
from operator import itemgetter
week_group = sorted(week_group, key=itemgetter("year_week"))
return week_group
if __name__ == '__main__':
print(DateDataConfig.get_date_list_de_list())
...@@ -74,6 +74,44 @@ class GlobalDataConfig: ...@@ -74,6 +74,44 @@ class GlobalDataConfig:
all_class_type = [*all_class_type, *v] all_class_type = [*all_class_type, *v]
return all_class_type return all_class_type
# 获取下一年
@staticmethod
def get_next_year_term(year, term):
if term == "春":
return year, "暑"
elif term == "暑":
return year, "秋"
elif term == "秋":
return year, "寒"
else:
return int(year) + 1, "春"
# mongo的表名
@staticmethod
def get_mongo_db_table_name(year, term, data_type: str):
term_map = {
"春": "01",
"暑": "03",
"秋": "05",
"寒": "07",
}
return f"{year}{term_map.get(term)}_{data_type}"
# 使用分页总数和每页数量获取分页数据
@staticmethod
def get_page_num_and_size(total, size):
"""
:total:记录条数
:size:每页数量
:return: 返回分页数组,单个元素为元组,0:page_num,1:page_size
"""
num = 0
num_and_size = []
for x in range(0, total, size):
num += 1
num_and_size.append((num, size))
return num_and_size
# 获取部门ID列表 # 获取部门ID列表
@classmethod @classmethod
def get_department_id(cls, department_type=30, is_rm_test_school=False) -> list: def get_department_id(cls, department_type=30, is_rm_test_school=False) -> list:
...@@ -155,21 +193,6 @@ class GlobalDataConfig: ...@@ -155,21 +193,6 @@ class GlobalDataConfig:
] ]
return targets return targets
# 使用分页总数和每页数量获取分页数据
@staticmethod
def get_page_num_and_size(total, size):
"""
:total:记录条数
:size:每页数量
:return: 返回分页数组,单个元素为元组,0:page_num,1:page_size
"""
num = 0
num_and_size = []
for x in range(0, total, size):
num += 1
num_and_size.append((num, size))
return num_and_size
# 获取单个校区筛数据 # 获取单个校区筛数据
@classmethod @classmethod
def get_single_school_search(cls, num=20, all_school=False, is_rm_test_school=True): def get_single_school_search(cls, num=20, all_school=False, is_rm_test_school=True):
...@@ -207,28 +230,4 @@ class GlobalDataConfig: ...@@ -207,28 +230,4 @@ class GlobalDataConfig:
group_school_data.append(ran_school_area) group_school_data.append(ran_school_area)
return group_school_data return group_school_data
# 获取下一年
@staticmethod
def get_next_year_term(year, term):
if term == "春":
return year, "暑"
elif term == "暑":
return year, "秋"
elif term == "秋":
return year, "寒"
else:
return int(year) + 1, "春"
# mongo的表名
@staticmethod
def get_mongo_db_table_name(year, term, data_type: str):
term_map = {
"春": "01",
"暑": "03",
"秋": "05",
"寒": "07",
}
return f"{year}{term_map.get(term)}_{data_type}"
from common.connect_db import OperationDb
import random
class SchoolDataConfig:
# 测试校区
test_school_area = [3074, 3076, 3345, 3047, 3049, 3095, 2383, 3015, 3052]
# 获取部门ID列表
@classmethod
def get_department_id(cls, department_type=30, is_rm_test_school=False) -> list:
"""
:department_type:部门类型
:is_rm_test_school:是否剔除测试校区默认否
:return:id列表
"""
sql = f"""select id from service_user.department where type = {department_type}"""
school_area_datas = OperationDb.query_sql(sql)
school_area_ids = [x[0] for x in school_area_datas]
if is_rm_test_school:
return [x for x in school_area_ids if x not in cls.test_school_area]
else:
return school_area_ids
# 通过区域id获取对应校区ID列表
@staticmethod
def get_school_id_by_area_id(area_id):
sql = f"""select id from service_user.department where type = 30 and parent_id = {area_id}"""
school_area_datas = OperationDb.query_sql(sql)
school_area_ids = [x[0] for x in school_area_datas]
return school_area_ids
# 通过大区id获取对应校区ID列表
@staticmethod
def get_school_id_by_big_area_id(big_area_id):
sql = f"""select id from service_user.department
where type = 30 and parent_id in (select id from service_user.department where type = 40 and parent_id = {big_area_id})"""
school_area_datas = OperationDb.query_sql(sql)
school_area_ids = [x[0] for x in school_area_datas]
return school_area_ids
# 通过大区id获取对应区域ID列表
@staticmethod
def get_area_id_by_big_area_id(big_area_id):
sql = f"""select id from service_user.department where type = 40 and parent_id = {big_area_id}"""
area_datas = OperationDb.query_sql(sql)
area_ids = [x[0] for x in area_datas]
return area_ids
# id和名称映射(40为区域名称映射)
@staticmethod
def get_department_id_name_map(department_type=30) -> dict:
sql = f"""select id,name from service_user.department where type = {department_type}"""
school_area_datas = OperationDb.query_sql(sql)
return {x[0]: x[1] for x in school_area_datas}
# 部门id和短名称映射(40为区域名称映射)
@staticmethod
def get_department_short_name_map(department_type=30):
sql = f"""select id,short_name from service_user.department where type = {department_type}"""
school_area_datas = OperationDb.query_sql(sql)
return {x[0]: x[1] for x in school_area_datas}
# 获取单个校区筛数据
@classmethod
def get_single_school_search(cls, num=20, all_school=False, is_rm_test_school=True):
"""
:num:返回的校区个数:默认20
:is_rm_test_school:是否剔除测试校区
:all_school: 为True返回全部校区, 默认否
:return: 校区ID列表
"""
school_area_ids = cls.get_department_id(department_type=30, is_rm_test_school=is_rm_test_school)
if all_school:
return school_area_ids
else:
return random.sample(school_area_ids, num)
# 获取组合校区筛数据
@classmethod
def get_group_school_search(cls, num=10, is_rm_test_school=True):
"""
:num:返回的校区组合个数:默认20
:is_rm_test_school:是否剔除测试校区
:return: 校区ID列表
"""
group_school_data = []
school_area_ids = cls.get_department_id(department_type=30, is_rm_test_school=is_rm_test_school)
for x in range(num):
ran_school_area_num = random.randint(2, len(school_area_ids))
ran_school_area = random.sample(school_area_ids, ran_school_area_num)
group_school_data.append(ran_school_area)
return group_school_data
\ No newline at end of file
from common.connect_db import OperationDb
from script.global_data_config.date_data import DateDataConfig
class TargetDataConfig:
# 获取所有目标方案
@staticmethod
def get_target():
sql = """SELECT * FROM public.target_plan"""
targets = OperationDb.pd_query_sql(sql)
return targets.to_dict(orient="records")
# 获取所有目标方案
@staticmethod
def get_target_after_id(target_id):
sql = f"""SELECT * FROM public.target_plan where id > {target_id}"""
targets = OperationDb.pd_query_sql(sql)
return targets.to_dict(orient="records")
# 获取当期目标方案
@staticmethod
def get_current_term_target():
sql = """SELECT * FROM public.target_plan where is_default = '是'"""
targets = OperationDb.pd_query_sql(sql)
return targets.to_dict(orient="records")
# 获取当期之后的目标方案
@staticmethod
def get_target_after_default():
sql = """SELECT * FROM public.target_plan where id >= (SELECT id FROM public.target_plan where is_default = '是')"""
targets = OperationDb.pd_query_sql(sql)
return targets.to_dict(orient="records")
# 获取下一年
@staticmethod
def get_next_year_term(year, term):
if term == "春":
return year, "暑"
elif term == "暑":
return year, "秋"
elif term == "秋":
return year, "寒"
else:
return int(year) + 1, "春"
# 根据目标方案或者查询的截止日期
@staticmethod
def get_end_time_by_target(target: dict):
target_end_date = target.get("end_time")
today_date = DateDataConfig.today_date
if today_date >= target_end_date:
create_time = target_end_date
else:
create_time = today_date
return create_time
from common.connect_db import OperationMongoDb from common.connect_db import OperationMongoDb
from script.global_data_config.school_data import SchoolDataConfig
def get_order_infos(): def get_order_infos():
...@@ -9,25 +10,5 @@ def get_order_infos(): ...@@ -9,25 +10,5 @@ def get_order_infos():
return omd.query_data(table_name, condition=condition, fields=fields) return omd.query_data(table_name, condition=condition, fields=fields)
login_data = [ school_areas = SchoolDataConfig.get_department_id(is_rm_test_school=True)
{"type": "employee",
"identityType": 1,
"ip": "0.0.0.0",
"account": "15300000000",
"password": "88888888"
}
]
school_areas = [2389,2398,3363,3015,3154,3352,2369,3095,3348,3333,3351,3359,3345,3365,3362,3339,
3353,3334,2400,3360,3361,3373,3371,3366,3349,3372,3340,2427,3367,3335,3148,3374,
3377,3369,3376,3378,3368,3336,3370,3357,3350,3001,3072,3049,3342,3337,2411,3344,
2412,3100,3146,3052,3047,3157,3107,3108,3076,3147,3167,2413,2383,3064,3152,3063,
3101,3130,3170,3074,3165,3044,3059,3038,3166,3168,2385,3171,2373,3137,3151,2417,
3041,3036,3060,3125,3046,3109,3110,3142,3149,3037,3039,3104,2422,3158,2407,2386,
3099,2410,3067,3329,2371,3330,3133,3071,3070,3053,3065,3150,3061,3126,3062,2423,
2364,3043,2415,3131,2388,3096,2376,3042,3127,2402,2359,2365,2408,2425,3002,2391,
3135,3136,3153,3139,3144,2419,3075,2416,2421,2363,2368,2403,2414,2392,3138,2406,
3156,3155,3097,3098,3141,3069,2405,2399,2397,2360,3145,2420,2404,2374,2401,3054,
3124]
...@@ -43,5 +43,5 @@ def set_excel(df, set_dir, sheet_name): ...@@ -43,5 +43,5 @@ def set_excel(df, set_dir, sheet_name):
writer.save() writer.save()
print(get_week_date_group("2021-04-30", "2021-05-10")) # print(get_week_date_group("2021-04-30", "2021-05-10"))
...@@ -85,3 +85,14 @@ def assert_grade_open_subject(data_list, year, term): ...@@ -85,3 +85,14 @@ def assert_grade_open_subject(data_list, year, term):
[sorted(x["subjects"]) for x in data_list] [sorted(x["subjects"]) for x in data_list]
open_subject = basic_parameter_set_data.get_grade_open_subject(year, term) open_subject = basic_parameter_set_data.get_grade_open_subject(year, term)
public_asserts.assert_dict_list_equal(data_list, open_subject, join_columns=["schoolAreaId", "grade"], df1_name="极运营数据", df2_name="计算数据") public_asserts.assert_dict_list_equal(data_list, open_subject, join_columns=["schoolAreaId", "grade"], df1_name="极运营数据", df2_name="计算数据")
@allure.step("验证最高班型数据正确")
def assert_max_class_type(data_list, year, term):
for data in data_list:
data["maxClassTypes"] = sorted(str(data.get("maxClassTypes")).split(","))
my_class_info = global_data.get_class_type_by_year_term(year, term)
field_list = ["areaId", "areaName", "bigAreaId", "bigAreaName", "year", "term", "grade", "subject", "maxClassTypes"]
public_asserts.assert_dict_list_equal_by_field(data_list, my_class_info, field_list=field_list,
join_columns=["areaId", "grade", "subject"],
df1_name="极运营数据", df2_name="计算数据")
...@@ -179,3 +179,28 @@ def get_add_crm_source_data(): ...@@ -179,3 +179,28 @@ def get_add_crm_source_data():
def delete_crm_source(crm_source_id): def delete_crm_source(crm_source_id):
sql = f"delete from service_crm.student_source_dict where id = {crm_source_id}" sql = f"delete from service_crm.student_source_dict where id = {crm_source_id}"
OperationDb.insert_update_delete_sql(sql) OperationDb.insert_update_delete_sql(sql)
# 删除新增的满班目标
def delete_full_class_target_by_id(target_id):
sql = f"delete from public.class_capacity where id = {target_id}"
OperationDb.insert_update_delete_sql(sql)
# 删除新增的满班目标
def delete_full_class_target_by_condition(region, grade, subject):
sql = f"""delete from public.class_capacity
where region = {region} and grade = '{grade}' and subject = '{subject}'"""
OperationDb.insert_update_delete_sql(sql)
# 满班目标是否存在
def is_have_full_class_target(region, grade, subject):
sql = f"""select id as count
from public.class_capacity
where region = {region} and grade = '{grade}' and subject = '{subject}'"""
result = OperationDb.query_sql(sql)
if result:
return True
else:
return False
...@@ -102,6 +102,19 @@ def get_school_type(count_phase, new_school_phase_num): ...@@ -102,6 +102,19 @@ def get_school_type(count_phase, new_school_phase_num):
return "other" return "other"
def get_max_class_type(class_types: list, class_num) -> list:
max_class_type = [x for x in class_types if x in ["极客班", "极客A班", "五四极客班", "极客蓝队班"]]
if max_class_type:
max_class_type.sort()
else:
max_class_types = [x for x in class_types if x in ["极智班", "五四极智班"]]
if class_num == 1:
max_class_type = max_class_types
else:
max_class_type = []
return max_class_type
# 获取全部校年份期段数据 # 获取全部校年份期段数据
def get_all_school_year_code(): def get_all_school_year_code():
school_year_code_datas = OperationDb.query_sql(query_sql.school_year_code_sql) school_year_code_datas = OperationDb.query_sql(query_sql.school_year_code_sql)
...@@ -194,6 +207,14 @@ def get_class_by_year_term(year, term): ...@@ -194,6 +207,14 @@ def get_class_by_year_term(year, term):
return class_infos return class_infos
# 获取所有班级(查询班型)
def get_class_type_by_year_term(year, term):
class_infos = OperationDb.pd_query_sql(query_sql.query_max_class_type_sql % (year, term, year, term))
class_infos = class_infos.to_dict(orient="records")
for class_info in class_infos:
class_info["maxClassTypes"] = get_max_class_type(class_info.get("class_types"), class_info.get("class_num"))
return [x for x in class_infos if x.get("maxClassTypes")]
# 所有目标方案 # 所有目标方案
all_target = get_target() all_target = get_target()
# 默认目标方案 # 默认目标方案
......
# 查询校区的财年和期段的code
school_year_code_sql = """ school_year_code_sql = """
SELECT SELECT
big_area.id AS big_area_id, big_area.id AS big_area_id,
...@@ -21,7 +22,7 @@ WHERE ...@@ -21,7 +22,7 @@ WHERE
and open_financial_year NOTNULL and open_financial_year NOTNULL
ORDER BY open_financial_year asc, open_financial_term asc ORDER BY open_financial_year asc, open_financial_term asc
""" """
# 查询校区的财年和期段的code加上城市
school_year_code_city_sql = """ school_year_code_city_sql = """
SELECT SELECT
big_area.id AS big_area_id, big_area.id AS big_area_id,
...@@ -54,7 +55,7 @@ WHERE ...@@ -54,7 +55,7 @@ WHERE
and open_financial_year_code NOTNULL and open_financial_year_code NOTNULL
ORDER BY open_financial_year_code ORDER BY open_financial_year_code
""" """
# 按年份期段查询班级(测试校区除外)
class_query_sql = """ class_query_sql = """
SELECT SELECT
big_area.name as big_area_name, big_area.name as big_area_name,
...@@ -76,3 +77,94 @@ WHERE ...@@ -76,3 +77,94 @@ WHERE
cls.status =1 and cls.course_type = '常规班课' and cls.year = %s and cls.term = '%s' cls.status =1 and cls.course_type = '常规班课' and cls.year = %s and cls.term = '%s'
and cls.school_area not in (3074, 3076, 3345, 3047, 3049, 3095, 2383, 3015, 3052) and cls.school_area not in (3074, 3076, 3345, 3047, 3049, 3095, 2383, 3015, 3052)
""" """
# 查询最高班型
query_max_class_type_sql = """
SELECT
cls_temp.bigAreaId,
cls_temp.bigAreaName,
cls_temp.areaId,
cls_temp.areaName,
cls_temp.YEAR,
cls_temp.term,
cls_temp.grade,
cls_temp.subject,
cls_temp.class_types,
cls_num_temp.class_num
FROM
(
SELECT
big_area.ID AS bigAreaId,
big_area.NAME bigAreaName,
d_area.id AS areaId,
d_area.NAME AS areaName,
cls.YEAR,
cls.term,
cls.grade,
cls.subject,
ARRAY_AGG ( DISTINCT ( cls.class_type ) ) AS class_types
FROM
service_education.classes cls
LEFT JOIN service_user.department dept_sch ON cls.school_area = dept_sch.id
LEFT JOIN service_user.department d_area ON dept_sch.parent_id = d_area.id
LEFT JOIN service_user.department big_area ON d_area.parent_id = big_area.id
WHERE
cls.YEAR = %s
AND cls.term = '%s'
AND cls.status = 1
AND cls.course_type = '常规班课'
AND cls.school_area NOT IN (
3074,
3076,
3345,
3047,
3049,
3095,
2383,
3015,
3052
)
GROUP BY
big_area.ID,
big_area.NAME,
d_area.ID,
d_area.NAME,
cls.YEAR,
cls.term,
cls.grade,
cls.subject
) cls_temp
LEFT JOIN (
SELECT
d_area.ID AS areaId,
cls.grade,
cls.subject,
COUNT ( cls.class_id ) class_num
FROM
service_education.classes cls
LEFT JOIN service_user.department dept_sch ON cls.school_area = dept_sch.id
LEFT JOIN service_user.department d_area ON dept_sch.parent_id = d_area.id
WHERE
cls.YEAR = %s
AND cls.term = '%s'
AND cls.status = 1
AND cls.course_type = '常规班课'
AND cls.class_type IN ( '极智班', '五四极智班' )
AND cls.school_area NOT IN (
3074,
3076,
3345,
3047,
3049,
3095,
2383,
3015,
3052
)
GROUP BY
d_area.id,
cls.grade,
cls.subject
) cls_num_temp ON cls_temp.areaId = cls_num_temp.areaId
AND cls_temp.grade = cls_num_temp.grade
AND cls_temp.subject = cls_num_temp.subject
"""
...@@ -146,7 +146,9 @@ def assert_download_data_equal_query(download_file_path, query_list, download_fi ...@@ -146,7 +146,9 @@ def assert_download_data_equal_query(download_file_path, query_list, download_fi
""" """
download_file_path: 下载文件路径 download_file_path: 下载文件路径
query_list: 查询的数据列表 query_list: 查询的数据列表
download_field_map: 查询的数据字段与excel字段的对应关系,且只对map里的字段
join_columns : 对比时连接的列(单个为字符串, 多个传入列表),排序不一样时使用 join_columns : 对比时连接的列(单个为字符串, 多个传入列表),排序不一样时使用
fillna_values: 为空时的填充数据
on_index : 当join_columns为none时设置为true,排序一样时使用 on_index : 当join_columns为none时设置为true,排序一样时使用
df1_name : 对比后的名称 df1_name : 对比后的名称
df2_name : 对比后的名称 df2_name : 对比后的名称
...@@ -173,3 +175,74 @@ def assert_download_data_equal_query(download_file_path, query_list, download_fi ...@@ -173,3 +175,74 @@ def assert_download_data_equal_query(download_file_path, query_list, download_fi
assert download_df.empty, f"无数据时数据应该为空,{download_df}" assert download_df.empty, f"无数据时数据应该为空,{download_df}"
@allure.step("断言响应的字典列表与期望的字典列表所有数据都一致, 指定字段")
def assert_dict_list_equal_by_field(data_list, query_list, field_list: list, field_map: dict = {},
df1_name="响应数据", df2_name="计算数据",
join_columns=None, on_index=False,
ignore_spaces=False, ignore_case=False, cast_column_names_lower=True
):
"""
data_list: 响应的数据列表
query_list: 查询的数据列表
field_list: 要对比的字段
field_map:两个列表的字段之间的映射
join_columns : 对比时连接的列(单个为字符串, 多个传入列表),排序不一样时使用
on_index : 当join_columns为none时设置为true,排序一样时使用
df1_name : 对比后的名称
df2_name : 对比后的名称
ignore_spaces : 是否忽略空格
ignore_case : 是否忽略大小写
cast_column_names_lower: 列表转小写
"""
if query_list:
res_df = pd.DataFrame(data_list)
query_df = pd.DataFrame(query_list)
query_df.rename(columns=field_map, inplace=True)
res_df.rename(columns=field_map, inplace=True)
query_df.columns = query_df.columns.map(lambda x: x.lower())
res_df.columns = res_df.columns.map(lambda x: x.lower())
field_list = [x.lower() for x in field_list]
query_df = query_df.loc[:, field_list]
res_df = res_df.loc[:, field_list]
query_df = query_df.astype(str)
res_df = res_df.astype(str)
result = datacompy.Compare(res_df, query_df, join_columns=join_columns,
on_index=on_index, df1_name=df1_name, df2_name=df2_name,
ignore_spaces=ignore_spaces, ignore_case=ignore_case, cast_column_names_lower=cast_column_names_lower
)
assert result.matches(), result.report()
else:
assert data_list == [], f"无数据时数据应该为空,{data_list}"
@allure.step("断言响应中的list字段为空列表")
def assert_list_field_is_not_data(res):
data = res.get("data")
assert data, f"data字段错误,{data}"
data_list = data.get("list")
assert data_list == [], f"错误数据查询出的list数据应该为空,{data_list}"
@allure.step("断言响应中的list对应字段无错误数据, 如果无数据算通过")
def assert_list_field_not_err_data(key_field, field_name, res, compare_type="equal"):
"""
:key_field: 字段需要包含或等于的值
:field_name: 对比的字段的名称
:res: list字段在data下的响应
:compare_type:比较方式
"""
data = res.get("data")
assert data, f"data字段错误,{data}"
data_list = data.get("list")
if data_list:
if compare_type == "equal":
err_data = [x for x in data_list if x.get(field_name) != key_field]
assert err_data == [], f"{field_name}字段不能存在不等于选择的数据,{err_data}"
else:
err_data = [x for x in data_list if str(key_field) not in str(x.get(field_name))]
assert err_data == [], f"{field_name}字段不能存在不等于选择的数据,{err_data}"
...@@ -30,4 +30,4 @@ def get_method(url, method): ...@@ -30,4 +30,4 @@ def get_method(url, method):
if __name__ == '__main__': if __name__ == '__main__':
get_method("/service-education/education/classes/query", "post") get_method("/service-education/classCapacity/query", "post")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment