فهرست منبع

fix: 员工列表补充部门名称 + error日志增加详细traceback

alphah 2 هفته پیش
والد
کامیت
1f88346808

+ 2 - 0
backend/app/plugin/module_payment/employee/schema.py

@@ -93,6 +93,8 @@ class EmployeeListOutSchema(BaseModel):
     employee_mobile: Optional[str] = Field(default=None, description="员工手机号")
     user_id: Optional[int] = Field(default=None, description="关联的系统用户ID")
     identity_open_id: Optional[str] = Field(default=None, description="员工openId(企业码身份)")
+    department_ids: Optional[list[str]] = Field(default=None, description="部门ID列表")
+    department_name: Optional[str] = Field(default=None, description="部门名称")
     created_time: Optional[datetime] = Field(default=None, description="创建时间")
 
 

+ 25 - 1
backend/app/plugin/module_payment/employee/service.py

@@ -135,7 +135,7 @@ class EmployeeService:
         """
         crud = EmployeeCRUD(auth)
         offset = (page_no - 1) * page_size
-        return await crud.page(
+        result = await crud.page(
             offset=offset,
             limit=page_size,
             order_by=[{"id": "desc"}],
@@ -143,6 +143,30 @@ class EmployeeService:
             out_schema=EmployeeListOutSchema,
             preload=["user"]
         )
+
+        # 补充部门名称
+        if result.get("items"):
+            from app.plugin.module_payment.department.model import DepartmentModel
+            from sqlalchemy import select
+            dept_ids = set()
+            for item in result["items"]:
+                dept_ids_list = item.get("department_ids") or []
+                if dept_ids_list:
+                    dept_ids.update(str(d) for d in dept_ids_list if d)
+
+            if dept_ids:
+                dept_stmt = select(DepartmentModel.department_id, DepartmentModel.department_name).where(
+                    DepartmentModel.department_id.in_(list(dept_ids)),
+                )
+                dept_result = await auth.db.execute(dept_stmt)
+                dept_map = {row.department_id: row.department_name for row in dept_result.fetchall() if row.department_id}
+
+                for item in result["items"]:
+                    dept_ids_list = item.get("department_ids") or []
+                    names = [dept_map.get(str(d), "") for d in dept_ids_list if dept_map.get(str(d))]
+                    item["department_name"] = "、".join(filter(None, names)) or None
+
+        return result
     
     @classmethod
     async def info_service(

+ 4 - 2
backend/app/plugin/module_payment/expense/quota/service.py

@@ -431,7 +431,8 @@ class QuotaService:
             }
             await issue_batch_crud.create(batch_data)
         except Exception as e:
-            log.warning(f"保存发放批次记录失败(不影响发放): {e}")
+            import traceback
+            log.warning(f"保存发放批次记录失败(不影响发放), 可检查: 1)batch_no是否重复 2)字段长度\n异常: {e}\n{traceback.format_exc()}")
 
         # 组装校验失败列表(在更新本地记录前获取,用于过滤)
         failed_owner_ids: set[str] = set()
@@ -531,7 +532,8 @@ class QuotaService:
                 log.warning(f"查询支付宝发放记录获取 quota_id 失败(不影响发放): {e}")
 
         except Exception as e:
-            log.warning(f"保存额度记录到本地失败(不影响发放): {e}")
+            import traceback
+            log.warning(f"保存额度记录到本地失败(不影响发放), 可检查: 1)tenant_id/enterprise_id 2)字段长度\n异常: {e}\n{traceback.format_exc()}")
 
         # 组装校验失败列表
         failed_list = None

BIN
frontend/dist.zip


+ 2 - 0
frontend/src/api/module_payment/employee.ts

@@ -79,6 +79,8 @@ export interface EmployeeTable {
   status: string;
   employee_mobile?: string;
   identity_open_id?: string;
+  department_name?: string;
+  department_ids?: string[];
   user_id?: number;
   created_time: string;
 }