62 lines
1.7 KiB
Python
62 lines
1.7 KiB
Python
from DBHelper.MongoHelperInstance import DB_GUA
|
|
from Modules.Common.CommonUtils import CommonUtils
|
|
|
|
|
|
class RatingUtils(object):
|
|
|
|
@staticmethod
|
|
def make_new_rid():
|
|
"""新建评级ID"""
|
|
new_rid = CommonUtils.random_code(8)
|
|
case = DB_GUA.find_single_column(
|
|
"评级数据",
|
|
"评级记录",
|
|
{"评级ID": new_rid},
|
|
"评级ID"
|
|
) is not None
|
|
while case:
|
|
new_rid = CommonUtils.random_code(8)
|
|
return new_rid
|
|
|
|
@staticmethod
|
|
def in_progress_rating(cid):
|
|
"""查找进行中的评级"""
|
|
in_progress_rid = DB_GUA.find_single_column(
|
|
"评级数据",
|
|
"评级记录",
|
|
{"企业ID": cid, "评级状态": "进行"},
|
|
"评级ID"
|
|
)
|
|
return in_progress_rid
|
|
|
|
@staticmethod
|
|
def trans_report_date_to_rank_year(report_date):
|
|
"""报告期转换为评级年度"""
|
|
|
|
def main(_date):
|
|
items = _date.split("-")
|
|
year = items[0]
|
|
month = items[1]
|
|
if month == "12":
|
|
rank_year = "{}年".format(int(year)+1)
|
|
else:
|
|
rank_year = "{}年".format(year)
|
|
return rank_year
|
|
|
|
if type(report_date) == str:
|
|
return main(report_date)
|
|
elif type(report_date) == list:
|
|
rank_years = [main(item) for item in report_date]
|
|
rank_years = sorted(set(rank_years), key=rank_years.index)
|
|
return rank_years
|
|
|
|
@staticmethod
|
|
def check_cid_legal(cid):
|
|
_cid = DB_GUA.find_single_column(
|
|
"企业数据",
|
|
"工商信息",
|
|
{"企业ID": cid},
|
|
"企业ID"
|
|
)
|
|
assert _cid, "错误的企业ID"
|