#!/usr/bin/env python3 # -*- coding: utf-8 -*- import json import sys from datetime import datetime # 测试接口 import subprocess # 测试2025年1月的数据 cmd1 = [ 'curl', '-s', '-X', 'POST', 'http://localhost:2011/api/Extend/LqDailyReport/get-tianwang-group-performance-completion', '-H', 'Content-Type: application/json', '-d', '{"startTime": "2025-01-01", "endTime": "2025-01-31"}' ] result1 = subprocess.run(cmd1, capture_output=True, text=True) data1 = json.loads(result1.stdout) print("=" * 60) print("2025年1月数据") print("=" * 60) print(f"接口状态: {data1.get('code')}") print(f"返回消息: {data1.get('msg')}") depts1 = [d for d in data1.get('data', []) if '教育' in d.get('DepartmentName', '')] print("\n=== 教育部数据 ===") for d in depts1: print(f"{d.get('DepartmentName')}:") print(f" BillingPerformance: {d.get('BillingPerformance')}") print(f" RefundPerformance: {d.get('RefundPerformance')}") print(f" DeductAmount: {d.get('DeductAmount')}") print(f" CompletedPerformance: {d.get('CompletedPerformance')}") print(f" StoreCount: {d.get('StoreCount')}") total1 = sum([d.get('BillingPerformance', 0) for d in depts1]) print(f"\n教育一部+教育二部合计 BillingPerformance: {total1}") # 测试当前月份的数据 current_month = datetime.now().strftime("%Y-%m") start_date = f"{current_month}-01" end_date = datetime.now().strftime("%Y-%m-%d") cmd2 = [ 'curl', '-s', '-X', 'POST', 'http://localhost:2011/api/Extend/LqDailyReport/get-tianwang-group-performance-completion', '-H', 'Content-Type: application/json', '-d', f'{{"startTime": "{start_date}", "endTime": "{end_date}"}}' ] result2 = subprocess.run(cmd2, capture_output=True, text=True) data2 = json.loads(result2.stdout) print("\n" + "=" * 60) print(f"当前月份 ({current_month}) 数据") print("=" * 60) print(f"接口状态: {data2.get('code')}") depts2 = [d for d in data2.get('data', []) if '教育' in d.get('DepartmentName', '')] print("\n=== 教育部数据 ===") for d in depts2: print(f"{d.get('DepartmentName')}:") print(f" BillingPerformance: {d.get('BillingPerformance')}") print(f" RefundPerformance: {d.get('RefundPerformance')}") print(f" DeductAmount: {d.get('DeductAmount')}") print(f" CompletedPerformance: {d.get('CompletedPerformance')}") print(f" StoreCount: {d.get('StoreCount')}") total2 = sum([d.get('BillingPerformance', 0) for d in depts2]) print(f"\n教育一部+教育二部合计 BillingPerformance: {total2}")