diff --git a/app/cross_compare_report.py b/app/cross_compare_report.py index 73cc0f0..371c5ca 100644 --- a/app/cross_compare_report.py +++ b/app/cross_compare_report.py @@ -45,11 +45,9 @@ def gen_cross_compare_report(params): date_list = check_param(params, 'date_list') # 优化后 if not date_list or len(date_list) < 1: return json.dumps(make_common_res(7, '缺少日期参数,请最少选择一天作为查询日期')) - date_list = list(map(str, date_list)) compare_date_list = check_param(params, 'compare_date_list') # 优化前 if not compare_date_list or len(compare_date_list) < 1: return json.dumps(make_common_res(6, '缺少对比日期参数,请最少选择一天作为对比日期')) - compare_date_list = list(map(str, compare_date_list)) query_type = check_param(params, 'query_type') if not query_type: query_type = 0 @@ -618,11 +616,12 @@ def cancel_collect_report(params): def transition_date_list4screen(date_list): - for i in range(0, len(date_list)): - if len(date_list[i]) == 1: - date_list[i] = [datetime.datetime.strptime(date_list[i][0], '%Y%m%d').strftime('%Y-%m-%d'), datetime.datetime.strptime(date_list[i][0], '%Y%m%d').strftime('%Y-%m-%d')] - elif len(date_list[i]) == 2: - date_list[i] = [datetime.datetime.strptime(date_list[i][0], '%Y%m%d').strftime('%Y-%m-%d'), datetime.datetime.strptime(date_list[i][1], '%Y%m%d').strftime('%Y-%m-%d')] - elif len(date_list[i]) > 2: - date_list[i] = [datetime.datetime.strptime(date_list[i][0], '%Y%m%d').strftime('%Y-%m-%d'), datetime.datetime.strptime(date_list[i][-1], '%Y%m%d').strftime('%Y-%m-%d')] - return date_list \ No newline at end of file + tmp_list = date_list.copy() + for i in range(0, len(tmp_list)): + if len(tmp_list[i]) == 1: + tmp_list[i] = [datetime.strptime(tmp_list[i][0], '%Y%m%d').strftime('%Y-%m-%d'), datetime.strptime(tmp_list[i][0], '%Y%m%d').strftime('%Y-%m-%d')] + elif len(tmp_list[i]) == 2: + tmp_list[i] = [datetime.strptime(tmp_list[i][0], '%Y%m%d').strftime('%Y-%m-%d'), datetime.strptime(tmp_list[i][1], '%Y%m%d').strftime('%Y-%m-%d')] + elif len(tmp_list[i]) > 2: + tmp_list[i] = [datetime.strptime(tmp_list[i][0], '%Y%m%d').strftime('%Y-%m-%d'), datetime.strptime(tmp_list[i][-1], '%Y%m%d').strftime('%Y-%m-%d')] + return tmp_list \ No newline at end of file