from database.dao.mysql_dao import MySqlDao from models import Recommend class ReportUtils: def __init__(self, city_uuid): self._recommend_model = Recommend(city_uuid) self._city_uuid = city_uuid self._dao = MySqlDao() def _get_recommend_cust_list(self, product_id): """获取推荐商户列表""" # 判断product_id是否是新品规 products_in_order = self._dao.get_product_from_order(self._city_uuid)["product_code"].unique().tolist() recall_count = 1000 # 参数调整 if product_id in products_in_order: recommend_list = self._recommend_model.get_recommend_list_by_gbdtlr(product_id, recall_count=recall_count) else: recommend_list = self._recommend_model.get_recommend_list_by_item2vec(product_id, recall_count=recall_count) recommend_list = list(map(lambda x: x["cust_code"], recommend_list)) return recommend_list if __name__ == "__main__": city_uuid = "00000000000000000000000011445301" product_id = '350139' report = ReportUtils(city_uuid) recommend_list = report._get_recommend_cust_list(product_id)