This commit is contained in:
zlwu committed 2026-06-13 19:47:22 +08:00
1 parent e1d6de45a3
commit 5ad07c8cac
616 files changed
+181132 -35125

No files matched your search

+1 -1
View File
@@ -1 +1 @@
37799
41962
+2
View File
@@ -29,6 +29,7 @@ from app.api.pilot_infusion_schedule_mgmt import router as pilot_infusion_schedu
from app.api.outbound_release_review import router as outbound_release_review_router
from app.api.clinical_payment import router as clinical_payment_router
from app.api.env_detect import router as env_detect_router
from app.api.cleanroom_garment import router as cleanroom_garment_router
__all__ = [
"public_router",
@@ -61,4 +62,5 @@ __all__ = [
"outbound_release_review_router",
"clinical_payment_router",
"env_detect_router",
"cleanroom_garment_router",
]
+499
View File
@@ -0,0 +1,499 @@
"""洁净服管理 API"""
from typing import List, Optional
from fastapi import APIRouter, Depends, Query
from pydantic import BaseModel, ConfigDict, Field
from sqlalchemy.orm import Session
from app.core.database import get_db
from app.core.menu_guard import require_admin_or_super_admin, require_menu_code
from app.core.response import error_response, success_response
from app.crud import cleanroom_garment as garment_svc
from app.models.models import SysUser
router = APIRouter(prefix="/web/admin", tags=["洁净服管理"])
def _get_tenant_no(db: Session, user: dict) -> str:
user_id = user.get("user_id")
if not user_id:
raise PermissionError("用户身份信息缺失,无法确定租户")
sys_user = db.query(SysUser).filter(SysUser.id == user_id).first()
if not sys_user or not sys_user.tenant_no:
raise PermissionError("用户租户信息缺失")
return sys_user.tenant_no
class GarmentCreateBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
garment_code: str = Field(..., alias="garmentCode")
garment_name: str = Field(..., alias="garmentName")
wash_discard_limit: int = Field(..., alias="washDiscardLimit")
sterilize_discard_limit: int = Field(..., alias="sterilizeDiscardLimit")
inbound_date: str = Field(..., alias="inboundDate")
order_num: Optional[int] = Field(None, alias="orderNum")
remark: Optional[str] = None
class GarmentUpdateBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
garment_code: Optional[str] = Field(None, alias="garmentCode")
garment_name: Optional[str] = Field(None, alias="garmentName")
wash_discard_limit: Optional[int] = Field(None, alias="washDiscardLimit")
sterilize_discard_limit: Optional[int] = Field(None, alias="sterilizeDiscardLimit")
inbound_date: Optional[str] = Field(None, alias="inboundDate")
order_num: Optional[int] = Field(None, alias="orderNum")
remark: Optional[str] = None
class GarmentBatchDeleteBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
ids: List[str] = Field(..., alias="ids")
class GarmentDiscardBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
discard_date: Optional[str] = Field(None, alias="discardDate")
remark: Optional[str] = None
class GarmentBatchDiscardBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
garment_ids: List[str] = Field(..., alias="garmentIds")
discard_date: Optional[str] = Field(None, alias="discardDate")
remark: Optional[str] = None
class WashLogCreateBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
garment_id: str = Field(..., alias="garmentId")
wash_time: str = Field(..., alias="washTime")
operator_user_id: Optional[str] = Field(None, alias="operatorUserId")
operator_name: Optional[str] = Field(None, alias="operatorName")
order_num: Optional[int] = Field(0, alias="orderNum")
remark: Optional[str] = None
class WashLogUpdateBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
wash_time: Optional[str] = Field(None, alias="washTime")
operator_user_id: Optional[str] = Field(None, alias="operatorUserId")
operator_name: Optional[str] = Field(None, alias="operatorName")
order_num: Optional[int] = Field(None, alias="orderNum")
remark: Optional[str] = None
class WashLogBatchBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
garment_ids: List[str] = Field(..., alias="garmentIds")
wash_time: str = Field(..., alias="washTime")
operator_user_id: Optional[str] = Field(None, alias="operatorUserId")
operator_name: Optional[str] = Field(None, alias="operatorName")
remark: Optional[str] = None
class SterilizeLogCreateBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
garment_id: str = Field(..., alias="garmentId")
sterilize_time: str = Field(..., alias="sterilizeTime")
operator_user_id: Optional[str] = Field(None, alias="operatorUserId")
operator_name: Optional[str] = Field(None, alias="operatorName")
order_num: Optional[int] = Field(0, alias="orderNum")
remark: Optional[str] = None
class SterilizeLogUpdateBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
sterilize_time: Optional[str] = Field(None, alias="sterilizeTime")
operator_user_id: Optional[str] = Field(None, alias="operatorUserId")
operator_name: Optional[str] = Field(None, alias="operatorName")
order_num: Optional[int] = Field(None, alias="orderNum")
remark: Optional[str] = None
class SterilizeLogBatchBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
garment_ids: List[str] = Field(..., alias="garmentIds")
sterilize_time: str = Field(..., alias="sterilizeTime")
operator_user_id: Optional[str] = Field(None, alias="operatorUserId")
operator_name: Optional[str] = Field(None, alias="operatorName")
remark: Optional[str] = None
@router.get("/cleanroom-garments")
async def list_cleanroom_garments(
page: int = Query(1, ge=1),
pageSize: int = Query(10, ge=1, le=100, alias="pageSize"),
keyword: Optional[str] = None,
garmentStatus: Optional[str] = Query(None, alias="garmentStatus"),
needAttention: Optional[str] = Query(None, alias="needAttention"),
user: dict = Depends(require_menu_code("production:cleanroom-garment:list")),
db: Session = Depends(get_db),
):
tenant_no = _get_tenant_no(db, user)
items, total = garment_svc.list_garments(
db,
page=page,
page_size=pageSize,
keyword=keyword,
garment_status=garmentStatus,
need_attention=needAttention in ("1", "true", "True"),
tenant_no=tenant_no,
user_info=user,
)
tp = garment_svc.total_pages(total, pageSize)
return success_response({"list": items, "total": total, "page": page, "pageSize": pageSize, "totalPages": tp})
@router.get("/cleanroom-garments/{garment_id}")
async def get_cleanroom_garment(
garment_id: str,
user: dict = Depends(require_menu_code("production:cleanroom-garment:list")),
db: Session = Depends(get_db),
):
tenant_no = _get_tenant_no(db, user)
detail = garment_svc.get_garment_detail(db, garment_id, tenant_no=tenant_no)
if not detail:
return error_response(404, "洁净服不存在")
return success_response(detail)
@router.post("/cleanroom-garments")
async def create_cleanroom_garment(
body: GarmentCreateBody,
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
obj = garment_svc.create_garment(
db,
garment_code=body.garment_code,
garment_name=body.garment_name,
wash_discard_limit=body.wash_discard_limit,
sterilize_discard_limit=body.sterilize_discard_limit,
inbound_date=body.inbound_date,
tenant_no=tenant_no,
order_num=body.order_num,
remark=body.remark,
user_id=user.get("user_id"),
)
return success_response(garment_svc.get_garment_detail(db, obj.id, tenant_no=tenant_no), message="创建成功")
except ValueError as e:
return error_response(400, str(e))
@router.put("/cleanroom-garments/{garment_id}")
async def update_cleanroom_garment(
garment_id: str,
body: GarmentUpdateBody,
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
payload = body.model_dump(exclude_unset=True, by_alias=False)
obj = garment_svc.update_garment(
db,
garment_id,
garment_code=payload.get("garment_code"),
garment_name=payload.get("garment_name"),
wash_discard_limit=payload.get("wash_discard_limit"),
sterilize_discard_limit=payload.get("sterilize_discard_limit"),
inbound_date=payload.get("inbound_date"),
order_num=payload.get("order_num"),
remark=payload.get("remark"),
user_id=user.get("user_id"),
tenant_no=tenant_no,
)
return success_response(garment_svc.get_garment_detail(db, obj.id, tenant_no=tenant_no), message="更新成功")
except ValueError as e:
return error_response(400, str(e))
@router.post("/cleanroom-garments/batch-delete")
async def batch_delete_cleanroom_garments(
body: GarmentBatchDeleteBody,
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
count = garment_svc.batch_soft_delete_garments(db, body.ids, tenant_no=tenant_no)
return success_response({"deletedCount": count}, message="删除成功")
except ValueError as e:
return error_response(400, str(e))
@router.delete("/cleanroom-garments/{garment_id}")
async def delete_cleanroom_garment(
garment_id: str,
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
garment_svc.soft_delete_garment(db, garment_id, tenant_no=tenant_no)
return success_response(None, message="删除成功")
except ValueError as e:
return error_response(400, str(e))
@router.post("/cleanroom-garments/batch-discard")
async def batch_discard_cleanroom_garments(
body: GarmentBatchDiscardBody,
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
result = garment_svc.batch_discard_garments(
db,
body.garment_ids,
discard_date=body.discard_date,
remark=body.remark,
user_id=user.get("user_id"),
tenant_no=tenant_no,
)
return success_response(result, message="废弃成功")
except ValueError as e:
return error_response(400, str(e))
@router.post("/cleanroom-garments/{garment_id}/discard")
async def discard_cleanroom_garment(
garment_id: str,
body: GarmentDiscardBody,
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
obj = garment_svc.discard_garment(
db,
garment_id,
discard_date=body.discard_date,
remark=body.remark,
user_id=user.get("user_id"),
tenant_no=tenant_no,
)
return success_response(garment_svc.get_garment_detail(db, obj.id, tenant_no=tenant_no), message="废弃成功")
except ValueError as e:
return error_response(400, str(e))
@router.get("/cleanroom-garment-wash-logs")
async def list_wash_logs(
page: int = Query(1, ge=1),
pageSize: int = Query(10, ge=1, le=100, alias="pageSize"),
garmentId: str = Query(..., alias="garmentId"),
user: dict = Depends(require_menu_code("production:cleanroom-garment:list")),
db: Session = Depends(get_db),
):
tenant_no = _get_tenant_no(db, user)
items, total = garment_svc.list_wash_logs(
db, garment_id=garmentId, page=page, page_size=pageSize, tenant_no=tenant_no
)
tp = garment_svc.total_pages(total, pageSize)
return success_response({"list": items, "total": total, "page": page, "pageSize": pageSize, "totalPages": tp})
@router.post("/cleanroom-garment-wash-logs")
async def create_wash_log(
body: WashLogCreateBody,
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
obj = garment_svc.create_wash_log(
db,
garment_id=body.garment_id,
wash_time=body.wash_time,
operator_user_id=body.operator_user_id,
operator_name=body.operator_name,
tenant_no=tenant_no,
order_num=body.order_num,
remark=body.remark,
user_id=user.get("user_id"),
)
return success_response(garment_svc._wash_log_to_dict(obj), message="创建成功")
except ValueError as e:
return error_response(400, str(e))
@router.post("/cleanroom-garment-wash-logs/batch")
async def batch_create_wash_logs(
body: WashLogBatchBody,
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
result = garment_svc.batch_create_wash_logs(
db,
garment_ids=body.garment_ids,
wash_time=body.wash_time,
operator_user_id=body.operator_user_id,
operator_name=body.operator_name,
remark=body.remark,
tenant_no=tenant_no,
user_id=user.get("user_id"),
)
return success_response(result, message="批量清洗登记成功")
except ValueError as e:
return error_response(400, str(e))
@router.put("/cleanroom-garment-wash-logs/{log_id}")
async def update_wash_log(
log_id: str,
body: WashLogUpdateBody,
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
payload = body.model_dump(exclude_unset=True, by_alias=False)
obj = garment_svc.update_wash_log(
db,
log_id,
wash_time=payload.get("wash_time"),
operator_user_id=payload.get("operator_user_id"),
operator_name=payload.get("operator_name"),
order_num=payload.get("order_num"),
remark=payload.get("remark"),
user_id=user.get("user_id"),
tenant_no=tenant_no,
)
return success_response(garment_svc._wash_log_to_dict(obj), message="更新成功")
except ValueError as e:
return error_response(400, str(e))
@router.delete("/cleanroom-garment-wash-logs/{log_id}")
async def delete_wash_log(
log_id: str,
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
garment_svc.soft_delete_wash_log(db, log_id, tenant_no=tenant_no)
return success_response(None, message="删除成功")
except ValueError as e:
return error_response(400, str(e))
@router.get("/cleanroom-garment-sterilize-logs")
async def list_sterilize_logs(
page: int = Query(1, ge=1),
pageSize: int = Query(10, ge=1, le=100, alias="pageSize"),
garmentId: str = Query(..., alias="garmentId"),
user: dict = Depends(require_menu_code("production:cleanroom-garment:list")),
db: Session = Depends(get_db),
):
tenant_no = _get_tenant_no(db, user)
items, total = garment_svc.list_sterilize_logs(
db, garment_id=garmentId, page=page, page_size=pageSize, tenant_no=tenant_no
)
tp = garment_svc.total_pages(total, pageSize)
return success_response({"list": items, "total": total, "page": page, "pageSize": pageSize, "totalPages": tp})
@router.post("/cleanroom-garment-sterilize-logs")
async def create_sterilize_log(
body: SterilizeLogCreateBody,
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
obj = garment_svc.create_sterilize_log(
db,
garment_id=body.garment_id,
sterilize_time=body.sterilize_time,
operator_user_id=body.operator_user_id,
operator_name=body.operator_name,
tenant_no=tenant_no,
order_num=body.order_num,
remark=body.remark,
user_id=user.get("user_id"),
)
return success_response(garment_svc._sterilize_log_to_dict(obj), message="创建成功")
except ValueError as e:
return error_response(400, str(e))
@router.post("/cleanroom-garment-sterilize-logs/batch")
async def batch_create_sterilize_logs(
body: SterilizeLogBatchBody,
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
result = garment_svc.batch_create_sterilize_logs(
db,
garment_ids=body.garment_ids,
sterilize_time=body.sterilize_time,
operator_user_id=body.operator_user_id,
operator_name=body.operator_name,
remark=body.remark,
tenant_no=tenant_no,
user_id=user.get("user_id"),
)
return success_response(result, message="批量灭菌登记成功")
except ValueError as e:
return error_response(400, str(e))
@router.put("/cleanroom-garment-sterilize-logs/{log_id}")
async def update_sterilize_log(
log_id: str,
body: SterilizeLogUpdateBody,
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
payload = body.model_dump(exclude_unset=True, by_alias=False)
obj = garment_svc.update_sterilize_log(
db,
log_id,
sterilize_time=payload.get("sterilize_time"),
operator_user_id=payload.get("operator_user_id"),
operator_name=payload.get("operator_name"),
order_num=payload.get("order_num"),
remark=payload.get("remark"),
user_id=user.get("user_id"),
tenant_no=tenant_no,
)
return success_response(garment_svc._sterilize_log_to_dict(obj), message="更新成功")
except ValueError as e:
return error_response(400, str(e))
@router.delete("/cleanroom-garment-sterilize-logs/{log_id}")
async def delete_sterilize_log(
log_id: str,
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
garment_svc.soft_delete_sterilize_log(db, log_id, tenant_no=tenant_no)
return success_response(None, message="删除成功")
except ValueError as e:
return error_response(400, str(e))
+456 -40
View File
@@ -1,5 +1,6 @@
"""市场物料库 API"""
from datetime import datetime
from decimal import Decimal
from typing import List, Optional
from fastapi import APIRouter, Depends, Query
@@ -9,9 +10,12 @@ from sqlalchemy.orm import Session
from app.api.sample_reception import _get_current_user_id, _get_tenant_no, _page_payload
from app.core.database import get_db
from app.core.utils import parse_datetime
from app.core.menu_guard import require_admin_or_super_admin, require_menu_code
from app.core.menu_guard import require_menu_code
from app.core.response import error_response, success_response
from app.crud import material as mat_svc
from app.crud import material_stock_batch as batch_svc
from app.crud import material_stock_check as stock_check_svc
from app.crud import material_usage as mu_svc
from app.crud import material_stock_log as msl_svc
router = APIRouter(prefix="/web/admin", tags=["市场物料"])
@@ -50,23 +54,30 @@ class MaterialUpdateBody(BaseModel):
class StockInBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
stock_in_no: str = Field(..., alias="stockInNo")
stock_in_date: str = Field(..., alias="stockInDate")
expire_date: str = Field(..., alias="expireDate")
catalog_no: str = Field(..., alias="catalogNo")
batch_no: str = Field(..., alias="batchNo")
manufacturer: str
unit_price: float = Field(..., alias="unitPrice")
amount: float
qty: float = Field(..., gt=0)
remark: Optional[str] = None
stock_in_time: Optional[str] = Field(None, alias="stockInTime")
class StockOutBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
qty: float = Field(..., gt=0)
receiver: Optional[str] = None
purpose: Optional[str] = None
remark: Optional[str] = None
stock_out_time: Optional[str] = Field(None, alias="stockOutTime")
class BatchStockInItem(BaseModel):
model_config = ConfigDict(populate_by_name=True)
material_id: str = Field(..., alias="materialId")
stock_in_no: str = Field(..., alias="stockInNo")
stock_in_date: str = Field(..., alias="stockInDate")
expire_date: str = Field(..., alias="expireDate")
catalog_no: str = Field(..., alias="catalogNo")
batch_no: str = Field(..., alias="batchNo")
manufacturer: str
unit_price: float = Field(..., alias="unitPrice")
amount: float
qty: float = Field(..., gt=0)
remark: Optional[str] = None
@@ -80,7 +91,7 @@ class BatchStockInBody(BaseModel):
class BatchStockOutItem(BaseModel):
model_config = ConfigDict(populate_by_name=True)
material_id: str = Field(..., alias="materialId")
batch_id: str = Field(..., alias="batchId")
qty: float = Field(..., gt=0)
remark: Optional[str] = None
@@ -94,6 +105,172 @@ class BatchStockOutBody(BaseModel):
stock_out_time: Optional[str] = Field(None, alias="stockOutTime")
class BatchDiscardItem(BaseModel):
model_config = ConfigDict(populate_by_name=True)
batch_id: str = Field(..., alias="batchId")
qty: float = Field(..., gt=0)
usage_unit: Optional[str] = Field(None, alias="usageUnit")
remark: Optional[str] = None
class BatchDiscardBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
items: List[BatchDiscardItem] = Field(..., min_length=1)
discard_reason: str = Field(..., alias="discardReason")
remark: Optional[str] = None
discard_time: Optional[str] = Field(None, alias="discardTime")
class MaterialBatchUpdateBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
stock_in_no: Optional[str] = Field(None, alias="stockInNo")
stock_in_date: Optional[str] = Field(None, alias="stockInDate")
expire_date: Optional[str] = Field(None, alias="expireDate")
catalog_no: Optional[str] = Field(None, alias="catalogNo")
batch_no: Optional[str] = Field(None, alias="batchNo")
manufacturer: Optional[str] = None
unit_price: Optional[float] = Field(None, alias="unitPrice")
amount: Optional[float] = None
remark: Optional[str] = None
material_code: Optional[str] = Field(None, alias="materialCode")
material_name: Optional[str] = Field(None, alias="materialName")
spec_model: Optional[str] = Field(None, alias="specModel")
unit: Optional[str] = None
warning_qty: Optional[float] = Field(None, alias="warningQty")
status: Optional[str] = None
class StockCheckCreateBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
title: str
check_time: Optional[str] = Field(None, alias="checkTime")
remark: Optional[str] = None
class StockCheckUnusedLineItem(BaseModel):
model_config = ConfigDict(populate_by_name=True)
material_code: Optional[str] = Field(None, alias="materialCode")
material_name: str = Field(..., alias="materialName")
spec_model: Optional[str] = Field(None, alias="specModel")
unit: Optional[str] = None
stock_in_no: Optional[str] = Field(None, alias="stockInNo")
stock_in_date: Optional[str] = Field(None, alias="stockInDate")
expire_date: Optional[str] = Field(None, alias="expireDate")
catalog_no: Optional[str] = Field(None, alias="catalogNo")
batch_no: Optional[str] = Field(None, alias="batchNo")
manufacturer: Optional[str] = None
unit_price: Optional[float] = Field(None, alias="unitPrice")
holder: Optional[str] = None
unused_qty: float = Field(..., alias="unusedQty", gt=0)
remark: Optional[str] = None
class StockCheckUnusedLinesBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
items: List[StockCheckUnusedLineItem] = Field(default_factory=list)
# ---------- 入库批次 ----------
@router.get("/material-batches")
async def list_material_batches(
page: int = Query(1, ge=1),
pageSize: int = Query(10, ge=1, le=100),
keyword: Optional[str] = None,
materialId: Optional[str] = None,
status: Optional[str] = None,
db: Session = Depends(get_db),
user: dict = Depends(require_menu_code("biz:material:list")),
):
try:
tenant_no = _get_tenant_no(db, user)
items, total = batch_svc.list_batches(
db,
page=page,
page_size=pageSize,
keyword=keyword,
material_id=materialId,
status=status,
tenant_no=tenant_no,
user_info=user,
)
return success_response(_page_payload(items, total, page, pageSize))
except PermissionError as e:
return error_response(403, str(e))
except Exception as e:
return error_response(400, str(e))
@router.get("/material-batches/options")
async def material_batch_options(
keyword: Optional[str] = None,
materialId: Optional[str] = None,
onlyAvailable: bool = Query(True, alias="onlyAvailable"),
db: Session = Depends(get_db),
user: dict = Depends(require_menu_code("biz:material:list")),
):
try:
tenant_no = _get_tenant_no(db, user)
return success_response(
batch_svc.batch_options(
db,
tenant_no,
keyword=keyword,
material_id=materialId,
only_available=onlyAvailable,
)
)
except Exception as e:
return error_response(400, str(e))
@router.put("/material-batches/{batch_id}")
async def update_material_batch(
batch_id: str,
body: MaterialBatchUpdateBody,
db: Session = Depends(get_db),
user: dict = Depends(require_menu_code("biz:material:list")),
):
try:
tenant_no = _get_tenant_no(db, user)
user_id = _get_current_user_id(user)
data = body.model_dump(exclude_none=True)
obj = batch_svc.update_batch(
db,
batch_id,
tenant_no=tenant_no,
user_id=user_id,
**data,
)
material = mat_svc.get_material_entity(db, obj.material_id, tenant_no)
return success_response(
batch_svc._batch_row_to_dict(obj, material),
message="更新成功",
)
except ValueError as e:
return error_response(400, str(e))
except Exception as e:
return error_response(400, str(e))
@router.delete("/material-batches/{batch_id}")
async def delete_material_batch(
batch_id: str,
db: Session = Depends(get_db),
user: dict = Depends(require_menu_code("biz:material:list")),
):
try:
tenant_no = _get_tenant_no(db, user)
user_id = _get_current_user_id(user)
batch_svc.delete_batch(db, batch_id, tenant_no=tenant_no, user_id=user_id)
return success_response(None, message="删除成功")
except ValueError as e:
return error_response(400, str(e))
except Exception as e:
return error_response(400, str(e))
# ---------- 物料 CRUD ----------
@@ -206,10 +383,29 @@ async def batch_stock_in_material(
return error_response(400, "入库时间格式无效")
operate_time = rt
items = [
{"material_id": x.material_id, "qty": x.qty, "remark": x.remark}
{
"material_id": x.material_id,
"materialId": x.material_id,
"stock_in_no": x.stock_in_no,
"stockInNo": x.stock_in_no,
"stock_in_date": x.stock_in_date,
"stockInDate": x.stock_in_date,
"expire_date": x.expire_date,
"expireDate": x.expire_date,
"catalog_no": x.catalog_no,
"catalogNo": x.catalog_no,
"batch_no": x.batch_no,
"batchNo": x.batch_no,
"manufacturer": x.manufacturer,
"unit_price": x.unit_price,
"unitPrice": x.unit_price,
"amount": x.amount,
"qty": x.qty,
"remark": x.remark,
}
for x in body.items
]
count = mat_svc.batch_stock_in(
count = batch_svc.batch_stock_in(
db,
items=items,
remark=body.remark,
@@ -240,10 +436,10 @@ async def batch_stock_out_material(
return error_response(400, "出库时间格式无效")
operate_time = rt
items = [
{"material_id": x.material_id, "qty": x.qty, "remark": x.remark}
{"batch_id": x.batch_id, "batchId": x.batch_id, "qty": x.qty, "remark": x.remark}
for x in body.items
]
count = mat_svc.batch_stock_out(
count = batch_svc.batch_stock_out(
db,
items=items,
receiver=body.receiver,
@@ -260,6 +456,48 @@ async def batch_stock_out_material(
return error_response(400, str(e))
@router.post("/materials/batch-discard")
async def batch_discard_material(
body: BatchDiscardBody,
db: Session = Depends(get_db),
user: dict = Depends(require_menu_code("biz:material:list")),
):
try:
tenant_no = _get_tenant_no(db, user)
user_id = _get_current_user_id(user)
operate_time = datetime.now()
if body.discard_time:
rt = parse_datetime(body.discard_time)
if not rt:
return error_response(400, "废弃时间格式无效")
operate_time = rt
items = [
{
"batch_id": x.batch_id,
"batchId": x.batch_id,
"qty": x.qty,
"usageUnit": x.usage_unit,
"usage_unit": x.usage_unit,
"remark": x.remark,
}
for x in body.items
]
count = batch_svc.batch_discard(
db,
items=items,
discard_reason=body.discard_reason,
remark=body.remark,
tenant_no=tenant_no,
user_id=user_id,
operate_time=operate_time,
)
return success_response({"count": count}, message=f"批量废弃成功,共 {count} 项")
except ValueError as e:
return error_response(400, str(e))
except Exception as e:
return error_response(400, str(e))
@router.post("/materials/{material_id}/stock-in")
async def stock_in_material(
material_id: str,
@@ -276,48 +514,89 @@ async def stock_in_material(
if not rt:
return error_response(400, "入库时间格式无效")
operate_time = rt
obj = mat_svc.stock_in(
db, material_id, qty=body.qty, remark=body.remark,
tenant_no=tenant_no, user_id=user_id, operate_time=operate_time,
obj = batch_svc.stock_in_one(
db,
material_id,
stock_in_no=body.stock_in_no,
stock_in_date=body.stock_in_date,
expire_date=body.expire_date,
catalog_no=body.catalog_no,
batch_no=body.batch_no,
manufacturer=body.manufacturer,
unit_price=body.unit_price,
amount=body.amount,
qty=Decimal(str(body.qty)),
remark=body.remark,
tenant_no=tenant_no,
user_id=user_id,
operate_time=operate_time,
)
return success_response(obj, message="入库成功")
return success_response(batch_svc._batch_row_to_dict(obj), message="入库成功")
except ValueError as e:
return error_response(400, str(e))
except Exception as e:
return error_response(400, str(e))
@router.post("/materials/{material_id}/stock-out")
async def stock_out_material(
material_id: str,
body: StockOutBody,
@router.post("/material-batches/batch-stock-in")
async def batch_stock_in_material_batches(
body: BatchStockInBody,
db: Session = Depends(get_db),
user: dict = Depends(require_menu_code("biz:material:list")),
):
return await batch_stock_in_material(body, db, user)
@router.post("/material-batches/batch-stock-out")
async def batch_stock_out_material_batches(
body: BatchStockOutBody,
db: Session = Depends(get_db),
user: dict = Depends(require_menu_code("biz:material:list")),
):
return await batch_stock_out_material(body, db, user)
@router.post("/material-batches/batch-discard")
async def batch_discard_material_batches(
body: BatchDiscardBody,
db: Session = Depends(get_db),
user: dict = Depends(require_menu_code("biz:material:list")),
):
return await batch_discard_material(body, db, user)
# ---------- 物料变动记录 ----------
@router.get("/material-usages")
async def list_material_usages(
page: int = Query(1, ge=1),
pageSize: int = Query(10, ge=1, le=100),
materialId: Optional[str] = None,
changeType: Optional[str] = None,
startTime: Optional[str] = None,
endTime: Optional[str] = None,
keyword: Optional[str] = None,
stockInNo: Optional[str] = None,
db: Session = Depends(get_db),
user: dict = Depends(require_menu_code("biz:materialStockLog:list")),
):
try:
tenant_no = _get_tenant_no(db, user)
user_id = _get_current_user_id(user)
operate_time = datetime.now()
if body.stock_out_time:
rt = parse_datetime(body.stock_out_time)
if not rt:
return error_response(400, "出库时间格式无效")
operate_time = rt
obj = mat_svc.stock_out(
db, material_id, qty=body.qty, receiver=body.receiver,
purpose=body.purpose, remark=body.remark,
tenant_no=tenant_no, user_id=user_id, operate_time=operate_time,
items, total = mu_svc.list_usages(
db, tenant_no, page=page, page_size=pageSize,
material_id=materialId, change_type=changeType,
start_time=startTime, end_time=endTime,
keyword=keyword, stock_in_no=stockInNo,
user_info=user,
)
return success_response(obj, message="出库成功")
except ValueError as e:
return error_response(400, str(e))
return success_response(_page_payload(items, total, page, pageSize))
except PermissionError as e:
return error_response(403, str(e))
except Exception as e:
return error_response(400, str(e))
# ---------- 库存变动记录 ----------
@router.get("/material-stock-logs")
async def list_stock_logs(
page: int = Query(1, ge=1),
@@ -330,6 +609,7 @@ async def list_stock_logs(
db: Session = Depends(get_db),
user: dict = Depends(require_menu_code("biz:materialStockLog:list")),
):
"""历史库存变动(biz_material_stock_log,只读)。"""
try:
tenant_no = _get_tenant_no(db, user)
items, total = msl_svc.list_stock_logs(
@@ -342,3 +622,139 @@ async def list_stock_logs(
return error_response(403, str(e))
except Exception as e:
return error_response(400, str(e))
# ---------- 库存盘点 ----------
@router.get("/material-stock-checks")
async def list_material_stock_checks(
page: int = Query(1, ge=1),
pageSize: int = Query(10, ge=1, le=100),
keyword: Optional[str] = None,
status: Optional[str] = None,
startTime: Optional[str] = None,
endTime: Optional[str] = None,
db: Session = Depends(get_db),
user: dict = Depends(require_menu_code("biz:material:list")),
):
try:
tenant_no = _get_tenant_no(db, user)
items, total = stock_check_svc.list_checks(
db,
tenant_no,
page=page,
page_size=pageSize,
keyword=keyword,
status=status,
start_time=startTime,
end_time=endTime,
user_info=user,
)
return success_response(_page_payload(items, total, page, pageSize))
except PermissionError as e:
return error_response(403, str(e))
except Exception as e:
return error_response(400, str(e))
@router.post("/material-stock-checks")
async def create_material_stock_check(
body: StockCheckCreateBody,
db: Session = Depends(get_db),
user: dict = Depends(require_menu_code("biz:material:list")),
):
try:
tenant_no = _get_tenant_no(db, user)
user_id = _get_current_user_id(user)
dept_id = user.get("deptId") or user.get("dept_id") or ""
res = stock_check_svc.create_check(
db,
title=body.title,
tenant_no=tenant_no,
user_id=user_id,
dept_id=dept_id,
check_time=body.check_time,
remark=body.remark,
)
return success_response(res, message="盘点单创建成功")
except ValueError as e:
return error_response(400, str(e))
except Exception as e:
return error_response(400, str(e))
@router.get("/material-stock-checks/{check_id}")
async def get_material_stock_check(
check_id: str,
db: Session = Depends(get_db),
user: dict = Depends(require_menu_code("biz:material:list")),
):
try:
tenant_no = _get_tenant_no(db, user)
data = stock_check_svc.get_check_detail(db, check_id, tenant_no)
return success_response(data)
except ValueError as e:
return error_response(400, str(e))
except Exception as e:
return error_response(400, str(e))
@router.put("/material-stock-checks/{check_id}/unused-lines")
async def save_material_stock_check_unused_lines(
check_id: str,
body: StockCheckUnusedLinesBody,
db: Session = Depends(get_db),
user: dict = Depends(require_menu_code("biz:material:list")),
):
try:
tenant_no = _get_tenant_no(db, user)
user_id = _get_current_user_id(user)
dept_id = user.get("deptId") or user.get("dept_id") or ""
count = stock_check_svc.save_unused_lines(
db,
check_id,
items=[x.model_dump(by_alias=False) for x in body.items],
tenant_no=tenant_no,
user_id=user_id,
dept_id=dept_id,
)
return success_response({"count": count}, message="登记保存成功")
except ValueError as e:
return error_response(400, str(e))
except Exception as e:
return error_response(400, str(e))
@router.post("/material-stock-checks/{check_id}/complete")
async def complete_material_stock_check(
check_id: str,
db: Session = Depends(get_db),
user: dict = Depends(require_menu_code("biz:material:list")),
):
try:
tenant_no = _get_tenant_no(db, user)
user_id = _get_current_user_id(user)
stock_check_svc.complete_check(db, check_id, tenant_no=tenant_no, user_id=user_id)
return success_response(None, message="盘点已完成")
except ValueError as e:
return error_response(400, str(e))
except Exception as e:
return error_response(400, str(e))
@router.post("/material-stock-checks/{check_id}/cancel")
async def cancel_material_stock_check(
check_id: str,
db: Session = Depends(get_db),
user: dict = Depends(require_menu_code("biz:material:list")),
):
try:
tenant_no = _get_tenant_no(db, user)
user_id = _get_current_user_id(user)
stock_check_svc.cancel_check(db, check_id, tenant_no=tenant_no, user_id=user_id)
return success_response(None, message="盘点已作废")
except ValueError as e:
return error_response(400, str(e))
except Exception as e:
return error_response(400, str(e))
+55 -2
View File
@@ -415,6 +415,24 @@ STATIC_MENU_TREE = [
"component": "/production/production-work-order/index",
"meta": {"title": "生产工单", "keepAlive": True, "menuCode": "production:work-order:list"},
},
{
"id": "94000000000000000000000000000001",
"name": "ProductionMyProductionTask",
"path": "my-production-task",
"component": "/production/my-production-task/index",
"meta": {"title": "我的生产任务", "keepAlive": True, "menuCode": "production:my-task:list"},
},
{
"id": "94000000000000000000000000000002",
"name": "ProductionMyMaterialUsage",
"path": "my-production-material-usage",
"component": "/production/my-production-material-usage/index",
"meta": {
"title": "我的物料领用记录",
"keepAlive": True,
"menuCode": "production:my-material-usage:list",
},
},
{
"id": "91000000000000000000000000000001",
"name": "ProductionSampleReceptionCompletion",
@@ -426,6 +444,17 @@ STATIC_MENU_TREE = [
"menuCode": "production:sample-reception-completion:list",
},
},
{
"id": "95000000000000000000000000000003",
"name": "ProductionCleanroomGarment",
"path": "cleanroom-garment",
"component": "/production/cleanroom-garment/index",
"meta": {
"title": "洁净服管理",
"keepAlive": True,
"menuCode": "production:cleanroom-garment:list",
},
},
],
},
# 生产基础信息
@@ -441,19 +470,36 @@ STATIC_MENU_TREE = [
"roles": ["admin"],
},
"children": [
{
"id": "90000000000000000000000000000014",
"name": "ProductionMaterial",
"path": "production-material",
"component": "/production/production-material/index",
"meta": {"title": "生产物料库", "keepAlive": True, "menuCode": "production:material:list"},
},
{
"id": "90000000000000000000000000000002",
"name": "ProductionConsumable",
"path": "consumable",
"component": "/production/consumable/index",
"meta": {"title": "耗材管理", "keepAlive": True, "menuCode": "production:consumable:list"},
"meta": {
"title": "耗材管理",
"keepAlive": True,
"isHide": True,
"menuCode": "production:consumable:list",
},
},
{
"id": "90000000000000000000000000000003",
"name": "ProductionReagent",
"path": "reagent",
"component": "/production/reagent/index",
"meta": {"title": "试剂管理", "keepAlive": True, "menuCode": "production:reagent:list"},
"meta": {
"title": "试剂管理",
"keepAlive": True,
"isHide": True,
"menuCode": "production:reagent:list",
},
},
{
"id": "90000000000000000000000000000004",
@@ -476,6 +522,13 @@ STATIC_MENU_TREE = [
"component": "/production/process/index",
"meta": {"title": "工艺库管理", "keepAlive": True, "menuCode": "production:process:list"},
},
{
"id": "90000000000000000000000000000009",
"name": "ProductionEquipment",
"path": "equipment",
"component": "/production/equipment/index",
"meta": {"title": "设备管理", "keepAlive": True, "menuCode": "production:equipment:list"},
},
],
},
],
+152 -10
View File
@@ -16,7 +16,7 @@ from app.crud import exhibition_appointment as exhibition_svc
from app.crud import storage_facility as storage_facility_svc
from app.crud import storage_occupancy as occupancy_svc
from app.core.utils import generate_uuid
from app.models.models import BizCleanRoom, BizCleanRoomAccessLog, BizExhibitionAppointment, BizStorageFacility, BizStorageFacilitySlot, SysUser
from app.models.models import BizCleanRoom, BizCleanRoomAccessLog, BizCleanRoomUvDisinfectLog, BizExhibitionAppointment, BizStorageFacility, BizStorageFacilitySlot, SysUser
router = APIRouter(prefix="/web/admin", tags=["运营支撑"])
@@ -289,6 +289,132 @@ async def delete_access_log(
return error_response(400, str(e))
# ---------------------------------------------------------------------------
# 紫外线消毒记录
# ---------------------------------------------------------------------------
class UvDisinfectLogCreateBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
clean_room_id: str = Field(..., alias="cleanRoomId")
operator_name: Optional[str] = Field(None, alias="operatorName")
start_time: Optional[str] = Field(None, alias="startTime")
end_time: Optional[str] = Field(None, alias="endTime")
duration_minutes: Optional[int] = Field(None, alias="durationMinutes")
order_num: Optional[int] = Field(0, alias="orderNum")
remark: Optional[str] = None
class UvDisinfectLogUpdateBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
operator_name: Optional[str] = Field(None, alias="operatorName")
start_time: Optional[str] = Field(None, alias="startTime")
end_time: Optional[str] = Field(None, alias="endTime")
duration_minutes: Optional[int] = Field(None, alias="durationMinutes")
order_num: Optional[int] = Field(None, alias="orderNum")
remark: Optional[str] = None
@router.get("/clean-room-uv-disinfect-logs")
async def list_uv_disinfect_logs(
page: int = Query(1, ge=1),
pageSize: int = Query(10, ge=1, le=100, alias="pageSize"),
cleanRoomId: str = Query(..., alias="cleanRoomId"),
keyword: Optional[str] = None,
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
tenant_no = _get_tenant_no(db, user)
query = db.query(BizCleanRoomUvDisinfectLog).filter(
BizCleanRoomUvDisinfectLog.del_flag == 0,
BizCleanRoomUvDisinfectLog.tenant_no == tenant_no,
BizCleanRoomUvDisinfectLog.clean_room_id == cleanRoomId,
)
if keyword:
kw = f"%{keyword}%"
query = query.filter(BizCleanRoomUvDisinfectLog.operator_name.like(kw))
query = apply_data_scope(query, BizCleanRoomUvDisinfectLog, user, db, tenant_no)
total = query.count()
items = (
query.order_by(BizCleanRoomUvDisinfectLog.create_time.desc())
.offset((page - 1) * pageSize)
.limit(pageSize)
.all()
)
result_list = [clean_room_svc._uv_disinfect_log_to_dict(r) for r in items]
tp = clean_room_svc.total_pages(total, pageSize)
return success_response({"list": result_list, "total": total, "page": page, "pageSize": pageSize, "totalPages": tp})
@router.post("/clean-room-uv-disinfect-logs")
async def create_uv_disinfect_log(
body: UvDisinfectLogCreateBody,
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
obj = clean_room_svc.create_uv_disinfect_log(
db,
clean_room_id=body.clean_room_id,
operator_name=body.operator_name,
start_time=_parse_optional_dt(body.start_time),
end_time=_parse_optional_dt(body.end_time),
duration_minutes=body.duration_minutes,
tenant_no=tenant_no,
order_num=body.order_num,
remark=body.remark,
user_id_param=user.get("user_id"),
)
return success_response(clean_room_svc._uv_disinfect_log_to_dict(obj), message="创建成功")
except ValueError as e:
return error_response(400, str(e))
@router.put("/clean-room-uv-disinfect-logs/{log_id}")
async def update_uv_disinfect_log(
log_id: str,
body: UvDisinfectLogUpdateBody,
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
payload: dict[str, Any] = body.model_dump(exclude_unset=True, by_alias=False)
obj = clean_room_svc.update_uv_disinfect_log(
db,
log_id,
operator_name=payload.get("operator_name"),
start_time=_parse_optional_dt(payload.get("start_time")) if "start_time" in payload else None,
end_time=_parse_optional_dt(payload.get("end_time")) if "end_time" in payload else None,
duration_minutes=payload.get("duration_minutes"),
order_num=payload.get("order_num"),
remark=payload.get("remark"),
user_id_param=user.get("user_id"),
tenant_no=tenant_no,
clear_end_time="end_time" in payload and payload.get("end_time") is None,
)
return success_response(clean_room_svc._uv_disinfect_log_to_dict(obj), message="更新成功")
except ValueError as e:
return error_response(400, str(e))
@router.delete("/clean-room-uv-disinfect-logs/{log_id}")
async def delete_uv_disinfect_log(
log_id: str,
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
clean_room_svc.soft_delete_uv_disinfect_log(db, log_id, tenant_no=tenant_no)
return success_response(None, message="删除成功")
except ValueError as e:
return error_response(400, str(e))
# ---------------------------------------------------------------------------
# 仓储设施
# ---------------------------------------------------------------------------
@@ -299,6 +425,7 @@ class StorageFacilityCreateBody(BaseModel):
parent_id: str = Field("0", alias="parentId")
node_name: str = Field(..., alias="nodeName")
node_code: str = Field(..., alias="nodeCode", min_length=1, max_length=32)
node_type: Optional[str] = Field(None, alias="nodeType")
is_leaf: Optional[int] = Field(0, alias="isLeaf")
order_num: Optional[int] = Field(0, alias="orderNum")
@@ -309,6 +436,7 @@ class StorageFacilityUpdateBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
node_name: Optional[str] = Field(None, alias="nodeName")
node_code: Optional[str] = Field(None, alias="nodeCode", min_length=1, max_length=32)
node_type: Optional[str] = Field(None, alias="nodeType")
is_leaf: Optional[int] = Field(None, alias="isLeaf")
order_num: Optional[int] = Field(None, alias="orderNum")
@@ -327,7 +455,13 @@ async def list_storage_facilities(
BizStorageFacility.tenant_no == tenant_no,
)
if keyword:
query = query.filter(BizStorageFacility.node_name.like(f"%{keyword}%"))
like = f"%{keyword}%"
query = query.filter(
or_(
BizStorageFacility.node_name.like(like),
BizStorageFacility.node_code.like(like),
)
)
query = apply_data_scope(query, BizStorageFacility, user, db, tenant_no)
items = query.order_by(
BizStorageFacility.order_num.asc(),
@@ -349,6 +483,7 @@ async def create_storage_facility(
db,
parent_id=body.parent_id,
node_name=body.node_name,
node_code=body.node_code,
node_type=body.node_type,
is_leaf=body.is_leaf,
tenant_no=tenant_no,
@@ -375,6 +510,7 @@ async def update_storage_facility(
db,
node_id,
node_name=payload.get("node_name"),
node_code=payload.get("node_code"),
node_type=payload.get("node_type"),
is_leaf=payload.get("is_leaf"),
order_num=payload.get("order_num"),
@@ -421,7 +557,6 @@ class StorageSlotBatchCreateBody(BaseModel):
facility_node_id: str = Field(..., alias="facilityNodeId")
rows: int = Field(..., ge=1, le=50)
cols: int = Field(..., ge=1, le=50)
code_prefix: Optional[str] = Field("", alias="codePrefix")
class StorageSlotUpdateBody(BaseModel):
@@ -443,12 +578,12 @@ class StorageSlotInsertRowBody(BaseModel):
facility_node_id: str = Field(..., alias="facilityNodeId")
after_row_num: int = Field(..., ge=0, alias="afterRowNum")
cols: int = Field(..., ge=1)
code_prefix: Optional[str] = Field("", alias="codePrefix")
@router.get("/storage-facility-slots")
async def list_storage_slots(
facilityNodeId: str = Query(..., alias="facilityNodeId"),
availableOnly: Optional[bool] = Query(None, alias="availableOnly"),
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
@@ -459,8 +594,17 @@ async def list_storage_slots(
BizStorageFacilitySlot.facility_node_id == facilityNodeId,
)
query = apply_data_scope(query, BizStorageFacilitySlot, user, db, tenant_no)
items = query.order_by(BizStorageFacilitySlot.order_num.asc(), BizStorageFacilitySlot.create_time.asc()).all()
result_list = [storage_facility_svc._slot_to_dict(r) for r in items]
items = query.order_by(
BizStorageFacilitySlot.order_num.asc(),
BizStorageFacilitySlot.create_time.asc(),
).all()
facility_by_id = storage_facility_svc.load_facility_map(db, tenant_no)
result_list = [storage_facility_svc._slot_to_dict(r, facility_by_id) for r in items]
if availableOnly:
result_list = [
row for row in result_list
if (row.get("slotStatus") or "") == "空" or int(row.get("occupiedCount") or 0) == 0
]
return success_response(result_list)
@@ -477,7 +621,6 @@ async def batch_create_storage_slots(
facility_node_id=body.facility_node_id,
rows=body.rows,
cols=body.cols,
code_prefix=body.code_prefix,
tenant_no=tenant_no,
user_id=user.get("user_id"),
)
@@ -504,7 +647,7 @@ async def create_storage_slot(
remark=body.remark,
user_id=user.get("user_id"),
)
return success_response(storage_facility_svc._slot_to_dict(obj), message="创建成功")
return success_response(storage_facility_svc._slot_to_dict_for_row(db, obj), message="创建成功")
except ValueError as e:
return error_response(400, str(e))
@@ -529,7 +672,7 @@ async def update_storage_slot(
user_id=user.get("user_id"),
tenant_no=tenant_no,
)
return success_response(storage_facility_svc._slot_to_dict(obj), message="更新成功")
return success_response(storage_facility_svc._slot_to_dict_for_row(db, obj), message="更新成功")
except ValueError as e:
return error_response(400, str(e))
@@ -547,7 +690,6 @@ async def insert_storage_slot_row(
facility_node_id=body.facility_node_id,
after_row_num=body.after_row_num,
cols=body.cols,
code_prefix=body.code_prefix or "",
tenant_no=tenant_no,
user_id=user.get("user_id"),
)
+375 -92
View File
@@ -5,7 +5,13 @@ from sqlalchemy.orm import Session
from typing import Any, Optional, List
from app.core.database import get_db
from app.core.menu_guard import require_admin_or_super_admin, require_menu_code
from app.core.menu_guard import (
SUPER_ADMIN_ROLE,
get_user_menu_codes,
require_admin_or_super_admin,
require_any_menu_code,
require_menu_code,
)
from app.core.response import success_response, error_response
from app.crud import consumable as consumable_svc
from app.crud import reagent as reagent_svc
@@ -13,6 +19,7 @@ from app.crud import consumable_stock_log as consumable_stock_log_svc
from app.crud import reagent_stock_log as reagent_stock_log_svc
from app.crud import sop_document as sop_document_svc
from app.crud import process_category as process_category_svc
from app.crud import equipment as equipment_svc
from app.crud import output_type as output_type_svc
from app.crud import consumable_pack as consumable_pack_svc
from app.crud import process as process_svc
@@ -46,6 +53,8 @@ from app.schemas.production_task import (
ProductionTaskCreate,
ProductionTaskUpdate,
ProductionTaskStatusUpdate,
ProductionTaskForwardBody,
ProductionTaskAssigneeUpdate,
TaskStepAdd,
TaskStepUpdate,
TaskStepMaterialItem,
@@ -60,6 +69,12 @@ from app.schemas.qc_work_order import ProductionQcWorkOrderCreateBody
router = APIRouter(prefix="/web/admin", tags=["生产管理"])
_LEGACY_MATERIAL_GONE_MSG = "耗材/试剂维护已迁移至【生产物料库】,请使用 production-material 接口"
def _legacy_material_write_gone():
return error_response(410, _LEGACY_MATERIAL_GONE_MSG)
def _get_tenant_no(db: Session, user: dict) -> str:
user_id = user.get("user_id")
@@ -69,6 +84,29 @@ def _get_tenant_no(db: Session, user: dict) -> str:
return (sys_user.tenant_no if sys_user else None) or "zkxw"
def _get_current_user_id(user: dict) -> str:
return (user.get("user_id") or "").strip()
def _assert_production_task_write_access(
db: Session,
user: dict,
task_id: str,
tenant_no: str,
operate_scope: Optional[str],
) -> None:
scope = (operate_scope or "manage").strip().lower()
user_id = _get_current_user_id(user)
role = user.get("role")
codes = get_user_menu_codes(db, user_id) if role != SUPER_ADMIN_ROLE else set()
if scope == "mine":
if role != SUPER_ADMIN_ROLE and "production:my-task:list" not in codes:
raise PermissionError("无菜单访问权限")
production_task_svc.assert_task_assignee(db, task_id, user_id, tenant_no)
elif role != SUPER_ADMIN_ROLE and "production:work-order:list" not in codes:
raise PermissionError("无菜单访问权限")
# ---------------------------------------------------------------------------
# 1. 耗材
# ---------------------------------------------------------------------------
@@ -132,26 +170,7 @@ async def create_consumable(
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
obj = consumable_svc.create_consumable(
db,
consumable_code=body.consumable_code,
consumable_name=body.consumable_name,
spec_model=body.spec_model,
standard_usage=body.standard_usage,
unit=body.unit,
description=body.description,
tenant_no=tenant_no,
warning_qty=body.warning_qty,
status=body.status,
order_num=body.order_num,
remark=body.remark,
user_id=user.get("user_id"),
)
return success_response(consumable_svc._row_to_dict(obj), message="创建成功")
except ValueError as e:
return error_response(400, str(e))
return _legacy_material_write_gone()
@router.put("/consumables/{consumable_id}")
@@ -161,26 +180,7 @@ async def update_consumable(
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
payload: dict[str, Any] = body.model_dump(exclude_unset=True, by_alias=False)
obj = consumable_svc.update_consumable(
db,
consumable_id,
consumable_code=payload.get("consumable_code"),
consumable_name=payload.get("consumable_name"),
spec_model=payload.get("spec_model"),
standard_usage=payload.get("standard_usage"),
unit=payload.get("unit"),
description=payload.get("description"),
warning_qty=payload.get("warning_qty"),
status=payload.get("status"),
order_num=payload.get("order_num"),
remark=payload.get("remark"),
user_id=user.get("user_id"),
)
return success_response(consumable_svc._row_to_dict(obj), message="更新成功")
except ValueError as e:
return error_response(400, str(e))
return _legacy_material_write_gone()
@router.delete("/consumables/{consumable_id}")
@@ -189,11 +189,7 @@ async def delete_consumable(
_user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
consumable_svc.soft_delete_consumable(db, consumable_id)
return success_response(None, message="删除成功")
except ValueError as e:
return error_response(400, str(e))
return _legacy_material_write_gone()
class StockInBody(BaseModel):
@@ -424,26 +420,7 @@ async def create_reagent(
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
obj = reagent_svc.create_reagent(
db,
reagent_code=body.reagent_code,
reagent_name=body.reagent_name,
spec=body.spec,
standard_usage=body.standard_usage,
unit=body.unit,
description=body.description,
tenant_no=tenant_no,
warning_qty=body.warning_qty,
status=body.status,
order_num=body.order_num,
remark=body.remark,
user_id=user.get("user_id"),
)
return success_response(reagent_svc._row_to_dict(obj), message="创建成功")
except ValueError as e:
return error_response(400, str(e))
return _legacy_material_write_gone()
@router.put("/reagents/{reagent_id}")
@@ -453,26 +430,7 @@ async def update_reagent(
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
payload: dict[str, Any] = body.model_dump(exclude_unset=True, by_alias=False)
obj = reagent_svc.update_reagent(
db,
reagent_id,
reagent_code=payload.get("reagent_code"),
reagent_name=payload.get("reagent_name"),
spec=payload.get("spec"),
standard_usage=payload.get("standard_usage"),
unit=payload.get("unit"),
description=payload.get("description"),
warning_qty=payload.get("warning_qty"),
status=payload.get("status"),
order_num=payload.get("order_num"),
remark=payload.get("remark"),
user_id=user.get("user_id"),
)
return success_response(reagent_svc._row_to_dict(obj), message="更新成功")
except ValueError as e:
return error_response(400, str(e))
return _legacy_material_write_gone()
@router.delete("/reagents/{reagent_id}")
@@ -481,11 +439,7 @@ async def delete_reagent(
_user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
reagent_svc.soft_delete_reagent(db, reagent_id)
return success_response(None, message="删除成功")
except ValueError as e:
return error_response(400, str(e))
return _legacy_material_write_gone()
@router.post("/reagents/{reagent_id}/stock-in")
@@ -833,6 +787,148 @@ async def delete_process_category(
return error_response(400, str(e))
# ---------------------------------------------------------------------------
# 设备管理
# ---------------------------------------------------------------------------
class EquipmentCreateBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
equipment_code: str = Field(..., alias="equipmentCode")
equipment_name: str = Field(..., alias="equipmentName")
equipment_model: Optional[str] = Field(None, alias="equipmentModel")
manufacturer: Optional[str] = None
purchase_date: Optional[str] = Field(None, alias="purchaseDate")
purchase_amount: Optional[float] = Field(None, alias="purchaseAmount")
location: Optional[str] = None
serial_no: Optional[str] = Field(None, alias="serialNo")
status: Optional[str] = "1"
order_num: Optional[int] = Field(0, alias="orderNum")
remark: Optional[str] = None
class EquipmentUpdateBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
equipment_code: Optional[str] = Field(None, alias="equipmentCode")
equipment_name: Optional[str] = Field(None, alias="equipmentName")
equipment_model: Optional[str] = Field(None, alias="equipmentModel")
manufacturer: Optional[str] = None
purchase_date: Optional[str] = Field(None, alias="purchaseDate")
purchase_amount: Optional[float] = Field(None, alias="purchaseAmount")
location: Optional[str] = None
serial_no: Optional[str] = Field(None, alias="serialNo")
status: Optional[str] = None
order_num: Optional[int] = Field(None, alias="orderNum")
remark: Optional[str] = None
@router.get("/equipments")
async def list_equipments(
page: int = Query(1, ge=1),
pageSize: int = Query(10, ge=1, le=100, alias="pageSize"),
keyword: Optional[str] = None,
status: Optional[str] = None,
user: dict = Depends(require_menu_code("production:equipment:list")),
db: Session = Depends(get_db),
):
tenant_no = _get_tenant_no(db, user)
items, total = equipment_svc.list_equipments(
db,
page=page,
page_size=pageSize,
keyword=keyword,
status=status,
tenant_no=tenant_no,
user_info=user,
)
tp = equipment_svc.total_pages(total, pageSize)
return success_response({"list": items, "total": total, "page": page, "pageSize": pageSize, "totalPages": tp})
@router.get("/equipments/all")
async def list_all_equipments(
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
tenant_no = _get_tenant_no(db, user)
items, _ = equipment_svc.list_equipments(
db, page=1, page_size=9999, tenant_no=tenant_no, user_info=user
)
return success_response(items)
@router.post("/equipments")
async def create_equipment(
body: EquipmentCreateBody,
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
obj = equipment_svc.create_equipment(
db,
equipment_code=body.equipment_code,
equipment_name=body.equipment_name,
equipment_model=body.equipment_model,
manufacturer=body.manufacturer,
purchase_date=body.purchase_date,
purchase_amount=body.purchase_amount,
location=body.location,
serial_no=body.serial_no,
status=body.status,
tenant_no=tenant_no,
order_num=body.order_num,
remark=body.remark,
user_id=user.get("user_id"),
)
return success_response(equipment_svc._row_to_dict(obj), message="创建成功")
except ValueError as e:
return error_response(400, str(e))
@router.put("/equipments/{equipment_id}")
async def update_equipment(
equipment_id: str,
body: EquipmentUpdateBody,
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
payload: dict[str, Any] = body.model_dump(exclude_unset=True, by_alias=False)
obj = equipment_svc.update_equipment(
db,
equipment_id,
equipment_code=payload.get("equipment_code"),
equipment_name=payload.get("equipment_name"),
equipment_model=payload.get("equipment_model"),
manufacturer=payload.get("manufacturer"),
purchase_date=payload.get("purchase_date"),
purchase_amount=payload.get("purchase_amount"),
location=payload.get("location"),
serial_no=payload.get("serial_no"),
status=payload.get("status"),
order_num=payload.get("order_num"),
remark=payload.get("remark"),
user_id=user.get("user_id"),
)
return success_response(equipment_svc._row_to_dict(obj), message="更新成功")
except ValueError as e:
return error_response(400, str(e))
@router.delete("/equipments/{equipment_id}")
async def delete_equipment(
equipment_id: str,
_user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
equipment_svc.soft_delete_equipment(db, equipment_id)
return success_response(None, message="删除成功")
except ValueError as e:
return error_response(400, str(e))
# ---------------------------------------------------------------------------
# 5. 工艺产出物类型
# ---------------------------------------------------------------------------
@@ -1717,6 +1813,7 @@ async def configure_production_work_order(
route_id=body.route_id,
description=body.description or "",
remark=body.remark or "",
assignee_user_id=body.assignee_user_id,
tenant_no=tenant_no,
user_id=user.get("user_id"),
create_dept_id=user.get("dept_id", ""),
@@ -1826,6 +1923,101 @@ async def list_production_tasks(
return success_response({"list": items, "total": total, "page": page, "pageSize": pageSize, "totalPages": tp})
@router.get("/production-tasks/mine")
async def list_my_production_tasks(
page: int = Query(1, ge=1),
pageSize: int = Query(10, ge=1, le=100, alias="pageSize"),
keyword: Optional[str] = None,
taskStatus: Optional[str] = None,
workOrderType: Optional[str] = None,
scope: str = Query("current", description="current|history"),
user: dict = Depends(require_menu_code("production:my-task:list")),
db: Session = Depends(get_db),
):
tenant_no = _get_tenant_no(db, user)
items, total = production_task_svc.list_mine_production_tasks(
db,
assignee_user_id=_get_current_user_id(user),
tenant_no=tenant_no,
scope=scope,
page=page,
page_size=pageSize,
keyword=keyword,
task_status=taskStatus,
work_order_type=workOrderType,
)
tp = production_task_svc.total_pages(total, pageSize)
return success_response({"list": items, "total": total, "page": page, "pageSize": pageSize, "totalPages": tp})
@router.post("/production-tasks/{task_id}/forward")
async def forward_production_task_api(
task_id: str,
body: ProductionTaskForwardBody,
operateScope: Optional[str] = Query(None, alias="operateScope"),
user: dict = Depends(require_any_menu_code("production:my-task:list", "production:work-order:list")),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
scope = (operateScope or "mine").strip().lower()
require_assignee = scope == "mine"
if not require_assignee:
role = user.get("role")
codes = get_user_menu_codes(db, _get_current_user_id(user)) if role != SUPER_ADMIN_ROLE else set()
if role != SUPER_ADMIN_ROLE and "production:work-order:list" not in codes:
raise PermissionError("无菜单访问权限")
from_uid = _get_current_user_id(user) if require_assignee else (user.get("user_id") or "")
task = production_task_svc.forward_production_task(
db,
task_id,
from_user_id=from_uid,
to_user_id=body.to_user_id,
tenant_no=tenant_no,
operator_id=user.get("user_id"),
create_dept_id=user.get("dept_id", ""),
remark=body.remark,
require_assignee=require_assignee,
)
db.commit()
item = production_task_svc._task_to_dict(task)
production_task_svc._enrich_assignee_names(db, [item])
return success_response(item, message="转发成功")
except PermissionError as e:
db.rollback()
return error_response(403, str(e))
except ValueError as e:
db.rollback()
return error_response(400, str(e))
@router.put("/production-tasks/{task_id}/assignee")
async def reassign_production_task_api(
task_id: str,
body: ProductionTaskAssigneeUpdate,
user: dict = Depends(require_menu_code("production:work-order:list")),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
task = production_task_svc.reassign_production_task(
db,
task_id,
assignee_user_id=body.assignee_user_id,
tenant_no=tenant_no,
operator_id=user.get("user_id"),
create_dept_id=user.get("dept_id", ""),
remark=body.remark,
)
db.commit()
item = production_task_svc._task_to_dict(task)
production_task_svc._enrich_assignee_names(db, [item])
return success_response(item, message="改派成功")
except ValueError as e:
db.rollback()
return error_response(400, str(e))
@router.get("/production-tasks/{task_id}")
async def get_production_task_detail(
task_id: str,
@@ -1875,11 +2067,13 @@ async def delete_production_task(
async def update_production_task_status(
task_id: str,
body: ProductionTaskStatusUpdate,
operateScope: Optional[str] = Query(None, alias="operateScope"),
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
_assert_production_task_write_access(db, user, task_id, tenant_no, operateScope)
task = production_task_svc.update_task_status(
db,
task_id,
@@ -1890,6 +2084,8 @@ async def update_production_task_status(
remark=body.remark,
)
return success_response(production_task_svc._task_to_dict(task), message="操作成功")
except PermissionError as e:
return error_response(403, str(e))
except ValueError as e:
return error_response(400, str(e))
@@ -1898,16 +2094,20 @@ async def update_production_task_status(
async def add_production_task_step(
task_id: str,
body: TaskStepAdd,
operateScope: Optional[str] = Query(None, alias="operateScope"),
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
_assert_production_task_write_access(db, user, task_id, tenant_no, operateScope)
data = body.model_dump(by_alias=False)
step_data = production_task_svc.add_task_step(
db, task_id, tenant_no, user.get("user_id"), data,
)
return success_response(step_data, message="添加成功")
except PermissionError as e:
return error_response(403, str(e))
except ValueError as e:
return error_response(400, str(e))
@@ -1917,16 +2117,20 @@ async def update_production_task_step(
task_id: str,
step_id: str,
body: TaskStepUpdate,
operateScope: Optional[str] = Query(None, alias="operateScope"),
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
_assert_production_task_write_access(db, user, task_id, tenant_no, operateScope)
data = body.model_dump(exclude_unset=True, by_alias=False)
step = production_task_svc.update_task_step(
db, step_id, tenant_no, user.get("user_id"), data,
)
return success_response(production_task_svc._step_to_dict(step), message="更新成功")
except PermissionError as e:
return error_response(403, str(e))
except ValueError as e:
return error_response(400, str(e))
@@ -1935,13 +2139,17 @@ async def update_production_task_step(
async def delete_production_task_step(
task_id: str,
step_id: str,
operateScope: Optional[str] = Query(None, alias="operateScope"),
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
_assert_production_task_write_access(db, user, task_id, tenant_no, operateScope)
production_task_svc.delete_task_step(db, step_id, tenant_no, user.get("user_id"))
return success_response(None, message="删除成功")
except PermissionError as e:
return error_response(403, str(e))
except ValueError as e:
return error_response(400, str(e))
@@ -1949,12 +2157,17 @@ async def delete_production_task_step(
@router.put("/production-tasks/step/reorder")
async def reorder_production_task_steps(
body: TaskStepReorderBody,
_user: dict = Depends(require_admin_or_super_admin),
operateScope: Optional[str] = Query(None, alias="operateScope"),
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
_assert_production_task_write_access(db, user, body.task_id, tenant_no, operateScope)
production_task_svc.reorder_task_steps(db, body.task_id, body.step_ids)
return success_response(None, message="排序成功")
except PermissionError as e:
return error_response(403, str(e))
except ValueError as e:
return error_response(400, str(e))
@@ -1963,11 +2176,13 @@ async def reorder_production_task_steps(
async def copy_production_task_step(
task_id: str,
step_id: str,
operateScope: Optional[str] = Query(None, alias="operateScope"),
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
_assert_production_task_write_access(db, user, task_id, tenant_no, operateScope)
step_data = production_task_svc.copy_task_step(
db,
step_id=step_id,
@@ -1975,6 +2190,8 @@ async def copy_production_task_step(
user_id=user.get("user_id"),
)
return success_response(step_data, message="复制成功")
except PermissionError as e:
return error_response(403, str(e))
except ValueError as e:
return error_response(400, str(e))
@@ -1984,11 +2201,13 @@ async def replace_task_step_reagents(
task_id: str,
step_id: str,
body: List[TaskStepMaterialItem],
operateScope: Optional[str] = Query(None, alias="operateScope"),
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
_assert_production_task_write_access(db, user, task_id, tenant_no, operateScope)
items_data = []
for it in body:
d = it.model_dump(by_alias=False)
@@ -1999,11 +2218,14 @@ async def replace_task_step_reagents(
"standard_usage": d.get("standard_usage"),
"actual_usage": d.get("actual_usage"),
"unit": d.get("unit"),
"requisition_usage_id": d.get("requisition_usage_id"),
"is_key_material": d.get("is_key_material", "0"),
"remark": d.get("remark"),
})
production_task_svc.replace_step_reagents(db, step_id, tenant_no, user.get("user_id"), items_data)
return success_response(None, message="更新成功")
except PermissionError as e:
return error_response(403, str(e))
except ValueError as e:
return error_response(400, str(e))
@@ -2013,11 +2235,13 @@ async def replace_task_step_consumables(
task_id: str,
step_id: str,
body: List[TaskStepMaterialItem],
operateScope: Optional[str] = Query(None, alias="operateScope"),
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
_assert_production_task_write_access(db, user, task_id, tenant_no, operateScope)
items_data = []
for it in body:
d = it.model_dump(by_alias=False)
@@ -2028,11 +2252,49 @@ async def replace_task_step_consumables(
"standard_usage": d.get("standard_usage"),
"actual_usage": d.get("actual_usage"),
"unit": d.get("unit"),
"requisition_usage_id": d.get("requisition_usage_id"),
"is_required": d.get("is_required", "1"),
"remark": d.get("remark"),
})
production_task_svc.replace_step_consumables(db, step_id, tenant_no, user.get("user_id"), items_data)
return success_response(None, message="更新成功")
except PermissionError as e:
return error_response(403, str(e))
except ValueError as e:
return error_response(400, str(e))
@router.put("/production-tasks/{task_id}/steps/{step_id}/configured-reagents")
async def replace_task_step_configured_reagents(
task_id: str,
step_id: str,
body: List[TaskStepMaterialItem],
operateScope: Optional[str] = Query(None, alias="operateScope"),
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
_assert_production_task_write_access(db, user, task_id, tenant_no, operateScope)
items_data = []
for it in body:
d = it.model_dump(by_alias=False)
items_data.append({
"configured_reagent_code": d.get("material_code"),
"configured_reagent_name": d.get("material_name"),
"spec": d.get("spec"),
"standard_usage": d.get("standard_usage"),
"actual_usage": d.get("actual_usage"),
"unit": d.get("unit"),
"requisition_usage_id": d.get("requisition_usage_id"),
"remark": d.get("remark"),
})
production_task_svc.replace_step_configured_reagents(
db, step_id, tenant_no, user.get("user_id"), items_data
)
return success_response(None, message="更新成功")
except PermissionError as e:
return error_response(403, str(e))
except ValueError as e:
return error_response(400, str(e))
@@ -2042,14 +2304,18 @@ async def replace_task_step_data_collections(
task_id: str,
step_id: str,
body: List[TaskStepDataCollectionItem],
operateScope: Optional[str] = Query(None, alias="operateScope"),
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
_assert_production_task_write_access(db, user, task_id, tenant_no, operateScope)
items_data = [it.model_dump(by_alias=False) for it in body]
production_task_svc.replace_step_data_collections(db, step_id, tenant_no, user.get("user_id"), items_data)
return success_response(None, message="更新成功")
except PermissionError as e:
return error_response(403, str(e))
except ValueError as e:
return error_response(400, str(e))
@@ -2059,14 +2325,18 @@ async def replace_task_step_outputs(
task_id: str,
step_id: str,
body: List[TaskStepOutputItem],
operateScope: Optional[str] = Query(None, alias="operateScope"),
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
_assert_production_task_write_access(db, user, task_id, tenant_no, operateScope)
items_data = [it.model_dump(by_alias=False) for it in body]
production_task_svc.replace_step_outputs(db, step_id, tenant_no, user.get("user_id"), items_data)
return success_response(None, message="更新成功")
except PermissionError as e:
return error_response(403, str(e))
except ValueError as e:
return error_response(400, str(e))
@@ -2075,14 +2345,18 @@ async def replace_task_step_outputs(
async def set_production_task_inputs(
task_id: str,
body: List[TaskInputItem],
operateScope: Optional[str] = Query(None, alias="operateScope"),
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
_assert_production_task_write_access(db, user, task_id, tenant_no, operateScope)
items_data = [it.model_dump(by_alias=False) for it in body]
production_task_svc.set_task_inputs(db, task_id, tenant_no, user.get("user_id"), items_data)
return success_response(None, message="设置成功")
except PermissionError as e:
return error_response(403, str(e))
except ValueError as e:
return error_response(400, str(e))
@@ -2091,14 +2365,18 @@ async def set_production_task_inputs(
async def set_production_task_outputs(
task_id: str,
body: List[TaskOutputItem],
operateScope: Optional[str] = Query(None, alias="operateScope"),
user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
try:
tenant_no = _get_tenant_no(db, user)
_assert_production_task_write_access(db, user, task_id, tenant_no, operateScope)
items_data = [it.model_dump(by_alias=False) for it in body]
production_task_svc.set_task_outputs(db, task_id, tenant_no, user.get("user_id"), items_data)
return success_response(None, message="设置成功")
except PermissionError as e:
return error_response(403, str(e))
except ValueError as e:
return error_response(400, str(e))
@@ -2257,3 +2535,8 @@ async def delete_cell_product(
return success_response(None, message="删除成功")
except ValueError as e:
return error_response(400, str(e))
from app.api.production_material import router as production_material_router
router.include_router(production_material_router)
File diff suppressed because it is too large. Load diff
+68
View File
@@ -1174,6 +1174,22 @@ class BatchStockOutBody(BaseModel):
stock_out_time: Optional[str] = Field(None, alias="stockOutTime")
class BatchDiscardItem(BaseModel):
model_config = ConfigDict(populate_by_name=True)
batch_id: str = Field(..., alias="batchId")
qty: float = Field(..., gt=0)
usage_unit: Optional[str] = Field(None, alias="usageUnit")
remark: Optional[str] = None
class BatchDiscardBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
items: List[BatchDiscardItem] = Field(..., min_length=1)
discard_reason: str = Field(..., alias="discardReason")
remark: Optional[str] = None
discard_time: Optional[str] = Field(None, alias="discardTime")
class QcMaterialBatchUpdateBody(BaseModel):
model_config = ConfigDict(populate_by_name=True)
stock_in_no: Optional[str] = Field(None, alias="stockInNo")
@@ -1490,6 +1506,48 @@ async def batch_stock_out_qc_material(
return error_response(400, str(e))
@router.post("/qc-materials/batch-discard")
async def batch_discard_qc_material(
body: BatchDiscardBody,
db: Session = Depends(get_db),
user: dict = Depends(require_menu_code("biz:qcMaterial:list")),
):
try:
tenant_no = _get_tenant_no(db, user)
user_id = _get_current_user_id(user)
operate_time = datetime.now()
if body.discard_time:
rt = parse_datetime(body.discard_time)
if not rt:
return error_response(400, "废弃时间格式无效")
operate_time = rt
items = [
{
"batch_id": x.batch_id,
"batchId": x.batch_id,
"qty": x.qty,
"usageUnit": x.usage_unit,
"usage_unit": x.usage_unit,
"remark": x.remark,
}
for x in body.items
]
count = batch_svc.batch_discard(
db,
items=items,
discard_reason=body.discard_reason,
remark=body.remark,
tenant_no=tenant_no,
user_id=user_id,
operate_time=operate_time,
)
return success_response({"count": count}, message=f"批量废弃成功,共 {count} 项")
except ValueError as e:
return error_response(400, str(e))
except Exception as e:
return error_response(400, str(e))
@router.post("/qc-materials/{material_id}/stock-in")
async def stock_in_qc_material(
material_id: str,
@@ -1552,6 +1610,16 @@ async def batch_stock_out_qc_material_batches(
return await batch_stock_out_qc_material(body, db, user)
@router.post("/qc-material-batches/batch-discard")
async def batch_discard_qc_material_batches(
body: BatchDiscardBody,
db: Session = Depends(get_db),
user: dict = Depends(require_menu_code("biz:qcMaterial:list")),
):
"""批量废弃(与 /qc-materials/batch-discard 等价)。"""
return await batch_discard_qc_material(body, db, user)
# ---------- 物料变动记录 ----------
+74 -55
View File
@@ -19,6 +19,7 @@ from app.models.models import (
BizStorageFacility,
BizStorageFacilitySlot,
)
from app.services.storage_facility_code import build_full_slot_code
_CELL_PRODUCT_STATUSES = frozenset(
{"frozen", "in_production", "sold", "used", "voided", "thawed"}
@@ -64,28 +65,22 @@ def _apply_cell_product_status_change(
).first()
if existing:
return
occ = BizStorageSlotOccupancy(
id=generate_uuid(),
occupancy_svc.assert_slot_vacant(
db, slot_id, tenant_no=tenant_no, exclude_product_id=obj.id,
)
occupancy_svc._add_stored_occupancy_no_commit(
db,
slot_id=slot_id,
item_type="cell_product",
item_id=obj.id,
item_code=obj.product_code or "",
item_name=obj.product_name or "",
item_source=obj.source_type or "manual",
stored_at=now,
occupancy_status="stored",
tenant_no=tenant_no,
order_num=0,
create_by=user_id,
create_dept_id="",
create_time=now,
update_by=user_id,
update_time=now,
del_flag=0,
user_id=user_id,
create_dept_id=obj.create_dept_id or "",
stored_at=now,
)
db.add(occ)
db.flush()
occupancy_svc._refresh_slot_cache(db, slot_id)
def _row_to_dict(c: BizCellProduct) -> Dict[str, Any]:
@@ -192,12 +187,11 @@ def _enrich_product_dicts(
)
facility_by_id = {f.id: f for f in facilities}
for slot in slots:
node_path = _build_facility_path_label(slot.facility_node_id, facility_by_id)
code = (slot.slot_code or "").strip()
if node_path and code:
slot_map[slot.id] = f"{node_path} / {code}"
else:
slot_map[slot.id] = code or node_path or ""
slot_map[slot.id] = build_full_slot_code(
slot.facility_node_id,
slot.slot_code,
facility_by_id,
)
# --- 来源信息富化 ---
from app.models.models import BizProductionTask, BizProductionWorkOrder
@@ -401,29 +395,21 @@ def create_cell_product(
db.add(obj)
db.flush()
if obj.storage_slot_id:
occ = BizStorageSlotOccupancy(
id=generate_uuid(),
slot_id=obj.storage_slot_id,
slot_id = (obj.storage_slot_id or "").strip()
if slot_id and (obj.product_status or "") in _CELL_PRODUCT_STORE_STATUSES:
occupancy_svc.assert_slot_vacant(db, slot_id, tenant_no=tenant_no, exclude_product_id=obj.id)
occupancy_svc._add_stored_occupancy_no_commit(
db,
slot_id=slot_id,
item_type="cell_product",
item_id=obj.id,
item_code=obj.product_code,
item_name=obj.product_name,
item_code=obj.product_code or "",
item_name=obj.product_name or "",
item_source=obj.source_type or "manual",
stored_at=datetime.now(),
occupancy_status="stored",
tenant_no=tenant_no,
order_num=0,
create_by=user_id,
user_id=user_id,
create_dept_id=create_dept_id or "",
create_time=datetime.now(),
update_by=user_id,
update_time=datetime.now(),
del_flag=0,
)
db.add(occ)
db.flush()
occupancy_svc._refresh_slot_cache(db, obj.storage_slot_id)
db.commit()
db.refresh(obj)
@@ -441,6 +427,9 @@ def update_cell_product(
if not obj:
raise ValueError("细胞产品不存在")
old_slot_id = (obj.storage_slot_id or "").strip()
slot_change_requested = data.storage_slot_id is not None
if data.product_name is not None:
obj.product_name = (data.product_name or "").strip()
if data.product_type_id is not None:
@@ -479,6 +468,37 @@ def update_cell_product(
if data.remark is not None:
obj.remark = (data.remark or "").strip() or None
new_slot_id = (obj.storage_slot_id or "").strip()
in_store = (obj.product_status or "") in _CELL_PRODUCT_STORE_STATUSES
if slot_change_requested and old_slot_id != new_slot_id:
stored_occ = db.query(BizStorageSlotOccupancy).filter(
BizStorageSlotOccupancy.item_type == "cell_product",
BizStorageSlotOccupancy.item_id == obj.id,
BizStorageSlotOccupancy.occupancy_status == "stored",
BizStorageSlotOccupancy.del_flag == 0,
).first()
if stored_occ and (stored_occ.slot_id or "").strip() != new_slot_id:
occupancy_svc.remove_by_item_no_commit(db, "cell_product", obj.id, user_id=user_id)
stored_occ = None
if new_slot_id and in_store and not stored_occ:
occupancy_svc.assert_slot_vacant(
db, new_slot_id, tenant_no=tenant_no, exclude_product_id=obj.id,
)
occupancy_svc._add_stored_occupancy_no_commit(
db,
slot_id=new_slot_id,
item_type="cell_product",
item_id=obj.id,
item_code=obj.product_code or "",
item_name=obj.product_name or "",
item_source=obj.source_type or "manual",
tenant_no=tenant_no,
user_id=user_id,
create_dept_id=obj.create_dept_id or "",
)
elif not new_slot_id and stored_occ:
occupancy_svc.remove_by_item_no_commit(db, "cell_product", obj.id, user_id=user_id)
obj.update_by = user_id
obj.update_time = datetime.now()
db.add(obj)
@@ -496,6 +516,7 @@ def delete_cell_product(
obj = get_cell_product(db, id, tenant_no)
if not obj:
raise ValueError("细胞产品不存在")
occupancy_svc.remove_by_item_no_commit(db, "cell_product", obj.id, user_id=user_id)
obj.del_flag = 1
obj.update_by = user_id
obj.update_time = datetime.now()
@@ -589,6 +610,8 @@ def _validate_batch_items(
raise ValueError("每份产品须选择储物格位置")
slot_ids.append(sid)
occupancy_svc.assert_batch_slots_unique(slot_ids)
existing_codes = (
db.query(BizCellProduct.product_code)
.filter(
@@ -614,8 +637,10 @@ def create_cell_products_by_quantity(
data: Any = None,
count: int,
) -> List[BizCellProduct]:
"""按入库份数拆分:基础编码-01、基础编码-02 …"""
"""按入库份数拆分:基础编码-01、基础编码-02 …(须通过 items 为每份指定独立储物格)"""
count = max(1, min(int(count), 50))
if count > 1:
raise ValueError("入库多份时请通过入库明细为每份产品分别选择储物格")
base = normalize_product_code_base(getattr(data, "product_code", None) or "")
if not base:
raise ValueError("产品编码不能为空")
@@ -653,6 +678,9 @@ def create_cell_products_batch(
items,
require_storage_slot=require_storage_slot,
)
for slot_id in slot_ids:
if slot_id:
occupancy_svc.assert_slot_vacant(db, slot_id, tenant_no=tenant_no)
now = datetime.now()
created: List[BizCellProduct] = []
for code, slot_id in zip(codes, slot_ids):
@@ -686,32 +714,23 @@ def create_cell_products_batch(
)
db.add(obj)
created.append(obj)
db.flush()
for obj in created:
if obj.storage_slot_id:
occ = BizStorageSlotOccupancy(
id=generate_uuid(),
slot_id=obj.storage_slot_id,
slot_id = (obj.storage_slot_id or "").strip()
if slot_id and (obj.product_status or "") in _CELL_PRODUCT_STORE_STATUSES:
occupancy_svc._add_stored_occupancy_no_commit(
db,
slot_id=slot_id,
item_type="cell_product",
item_id=obj.id,
item_code=obj.product_code,
item_name=obj.product_name,
item_source=obj.source_type or "manual",
stored_at=now,
occupancy_status="stored",
tenant_no=tenant_no,
order_num=0,
create_by=user_id,
user_id=user_id,
create_dept_id=create_dept_id or "",
create_time=now,
update_by=user_id,
update_time=now,
del_flag=0,
stored_at=now,
)
db.add(occ)
db.flush()
slot_ids_seen = {obj.storage_slot_id for obj in created if obj.storage_slot_id}
for sid in slot_ids_seen:
occupancy_svc._refresh_slot_cache(db, sid)
db.commit()
for obj in created:
+190 -2
View File
@@ -1,4 +1,4 @@
"""洁净室及进出记录 CRUD(biz_clean_room + biz_clean_room_access_log)"""
"""洁净室及进出记录、紫外线消毒记录 CRUD(biz_clean_room + biz_clean_room_access_log + biz_clean_room_uv_disinfect_log)"""
from __future__ import annotations
import math
@@ -9,7 +9,7 @@ from sqlalchemy import and_, func, or_
from sqlalchemy.orm import Session
from app.core.utils import generate_uuid
from app.models.models import BizCleanRoom, BizCleanRoomAccessLog
from app.models.models import BizCleanRoom, BizCleanRoomAccessLog, BizCleanRoomUvDisinfectLog
# ---------------------------------------------------------------------------
@@ -342,3 +342,191 @@ def total_pages(total: int, page_size: int) -> int:
if total <= 0:
return 0
return int(math.ceil(total / float(page_size)))
# ---------------------------------------------------------------------------
# 紫外线消毒记录
# ---------------------------------------------------------------------------
def _calc_duration_minutes(start_time: Optional[datetime], end_time: Optional[datetime]) -> Optional[int]:
if not start_time or not end_time:
return None
delta = end_time - start_time
minutes = int(delta.total_seconds() // 60)
return max(minutes, 0)
def _uv_disinfect_log_to_dict(log: BizCleanRoomUvDisinfectLog) -> Dict[str, Any]:
duration = log.duration_minutes
if duration is None:
duration = _calc_duration_minutes(log.start_time, log.end_time)
return {
"id": log.id,
"cleanRoomId": log.clean_room_id,
"userId": log.user_id,
"operatorName": log.operator_name,
"startTime": log.start_time.strftime("%Y-%m-%d %H:%M:%S") if log.start_time else "",
"endTime": log.end_time.strftime("%Y-%m-%d %H:%M:%S") if log.end_time else "",
"durationMinutes": duration if duration is not None else None,
"tenantNo": log.tenant_no,
"orderNum": log.order_num if log.order_num is not None else 0,
"remark": log.remark or "",
"createTime": log.create_time.strftime("%Y-%m-%d %H:%M:%S") if log.create_time else "",
"updateTime": log.update_time.strftime("%Y-%m-%d %H:%M:%S") if log.update_time else "",
}
def list_uv_disinfect_logs(
db: Session,
*,
page: int = 1,
page_size: int = 10,
clean_room_id: Optional[str] = None,
keyword: Optional[str] = None,
tenant_no: Optional[str] = None,
) -> Tuple[List[Dict[str, Any]], int]:
def _filtered():
q0 = db.query(BizCleanRoomUvDisinfectLog).filter(BizCleanRoomUvDisinfectLog.del_flag == 0)
if clean_room_id:
q0 = q0.filter(BizCleanRoomUvDisinfectLog.clean_room_id == clean_room_id)
if tenant_no:
q0 = q0.filter(BizCleanRoomUvDisinfectLog.tenant_no == tenant_no)
kw = (keyword or "").strip()
if kw:
like = f"%{kw}%"
q0 = q0.filter(BizCleanRoomUvDisinfectLog.operator_name.like(like))
return q0
total = _filtered().order_by(None).with_entities(func.count(BizCleanRoomUvDisinfectLog.id)).scalar() or 0
page = max(1, page)
page_size = min(max(1, page_size), 100)
rows = (
_filtered()
.order_by(BizCleanRoomUvDisinfectLog.create_time.desc())
.offset((page - 1) * page_size)
.limit(page_size)
.all()
)
return [_uv_disinfect_log_to_dict(x) for x in rows], int(total)
def get_uv_disinfect_log(
db: Session, log_id: str, tenant_no: Optional[str] = None
) -> Optional[BizCleanRoomUvDisinfectLog]:
q = db.query(BizCleanRoomUvDisinfectLog).filter(
and_(BizCleanRoomUvDisinfectLog.id == log_id, BizCleanRoomUvDisinfectLog.del_flag == 0)
)
if tenant_no:
q = q.filter(BizCleanRoomUvDisinfectLog.tenant_no == tenant_no)
return q.first()
def create_uv_disinfect_log(
db: Session,
*,
clean_room_id: str,
user_id: Optional[str] = None,
operator_name: Optional[str] = None,
start_time: Optional[datetime] = None,
end_time: Optional[datetime] = None,
duration_minutes: Optional[int] = None,
tenant_no: str = "zkxw",
order_num: Optional[int] = None,
remark: Optional[str] = None,
user_id_param: Optional[str] = None,
) -> BizCleanRoomUvDisinfectLog:
cr_id = (clean_room_id or "").strip()
if not cr_id:
raise ValueError("洁净室ID不能为空")
op_name = (operator_name or "").strip()
if not op_name:
raise ValueError("操作人不能为空")
st = start_time or datetime.now()
if end_time and end_time < st:
raise ValueError("结束时间不能早于开始时间")
dur = duration_minutes
if dur is None:
dur = _calc_duration_minutes(st, end_time)
obj = BizCleanRoomUvDisinfectLog(
id=generate_uuid(),
clean_room_id=cr_id,
user_id=(user_id or "").strip() or None,
operator_name=op_name,
start_time=st,
end_time=end_time,
duration_minutes=dur,
tenant_no=tenant_no,
order_num=order_num if order_num is not None else 0,
remark=(remark or "").strip() or None,
create_by=user_id_param,
create_dept_id="",
create_time=datetime.now(),
update_by=user_id_param,
update_time=datetime.now(),
del_flag=0,
)
db.add(obj)
db.commit()
db.refresh(obj)
return obj
def update_uv_disinfect_log(
db: Session,
log_id: str,
*,
user_id: Optional[str] = None,
operator_name: Optional[str] = None,
start_time: Optional[datetime] = None,
end_time: Optional[datetime] = None,
duration_minutes: Optional[int] = None,
order_num: Optional[int] = None,
remark: Optional[str] = None,
user_id_param: Optional[str] = None,
tenant_no: Optional[str] = None,
clear_end_time: bool = False,
) -> BizCleanRoomUvDisinfectLog:
obj = get_uv_disinfect_log(db, log_id, tenant_no=tenant_no)
if not obj:
raise ValueError("紫外线消毒记录不存在")
if operator_name is not None:
op_name = (operator_name or "").strip()
if not op_name:
raise ValueError("操作人不能为空")
obj.operator_name = op_name
if user_id is not None:
obj.user_id = (user_id or "").strip() or None
if start_time is not None:
obj.start_time = start_time
if clear_end_time:
obj.end_time = None
elif end_time is not None:
obj.end_time = end_time
st = obj.start_time
et = obj.end_time
if et and st and et < st:
raise ValueError("结束时间不能早于开始时间")
if duration_minutes is not None:
obj.duration_minutes = duration_minutes
else:
obj.duration_minutes = _calc_duration_minutes(st, et)
if order_num is not None:
obj.order_num = order_num
if remark is not None:
obj.remark = (remark or "").strip() or None
obj.update_by = user_id_param
obj.update_time = datetime.now()
db.add(obj)
db.commit()
db.refresh(obj)
return obj
def soft_delete_uv_disinfect_log(db: Session, log_id: str, tenant_no: Optional[str] = None) -> None:
obj = get_uv_disinfect_log(db, log_id, tenant_no=tenant_no)
if not obj:
raise ValueError("紫外线消毒记录不存在")
obj.del_flag = 1
obj.update_time = datetime.now()
db.add(obj)
db.commit()
+853
View File
@@ -0,0 +1,853 @@
"""洁净服及清洗/灭菌记录 CRUD"""
from __future__ import annotations
import math
from datetime import date, datetime
from typing import Any, Dict, List, Optional, Tuple
from sqlalchemy import and_, func, or_
from sqlalchemy.orm import Session
from app.core.utils import generate_uuid
from app.models.cleanroom_garment import (
BizCleanroomGarment,
BizCleanroomGarmentSterilizeLog,
BizCleanroomGarmentWashLog,
)
GARMENT_STATUS_NORMAL = "zc"
GARMENT_STATUS_DISCARDED = "yfq"
def total_pages(total: int, page_size: int) -> int:
if total <= 0:
return 0
return int(math.ceil(total / max(1, page_size)))
def _parse_date(v: Any) -> Optional[date]:
if v is None or v == "":
return None
if isinstance(v, date) and not isinstance(v, datetime):
return v
if isinstance(v, datetime):
return v.date()
s = str(v).strip()
if not s:
return None
for fmt in ("%Y-%m-%d", "%Y/%m/%d"):
try:
return datetime.strptime(s[:10], fmt).date()
except ValueError:
continue
raise ValueError("日期格式无效,请使用 YYYY-MM-DD")
def _parse_datetime(v: Any) -> datetime:
if isinstance(v, datetime):
return v
s = str(v or "").strip()
if not s:
raise ValueError("时间不能为空")
for fmt in ("%Y-%m-%d %H:%M:%S", "%Y-%m-%d %H:%M", "%Y-%m-%d"):
try:
if fmt == "%Y-%m-%d":
return datetime.strptime(s[:10], fmt)
return datetime.strptime(s[:19] if len(s) >= 19 else s, fmt)
except ValueError:
continue
raise ValueError("时间格式无效,请使用 YYYY-MM-DD HH:mm:ss")
def _parse_limit(v: Any, label: str) -> int:
if v is None or v == "":
raise ValueError(f"{label}不能为空")
try:
n = int(v)
except (TypeError, ValueError):
raise ValueError(f"{label}必须为整数")
if n < 1:
raise ValueError(f"{label}必须大于等于 1")
return n
def _count_map(db: Session, model, garment_ids: List[str], tenant_no: Optional[str]) -> Dict[str, int]:
if not garment_ids:
return {}
q = (
db.query(model.garment_id, func.count(model.id))
.filter(model.del_flag == 0, model.garment_id.in_(garment_ids))
)
if tenant_no:
q = q.filter(model.tenant_no == tenant_no)
return {gid: int(cnt) for gid, cnt in q.group_by(model.garment_id).all()}
def _garment_to_dict(
g: BizCleanroomGarment,
*,
wash_count: int = 0,
sterilize_count: int = 0,
) -> Dict[str, Any]:
wash_limit_reached = wash_count >= int(g.wash_discard_limit or 0)
sterilize_limit_reached = sterilize_count >= int(g.sterilize_discard_limit or 0)
return {
"id": g.id,
"garmentCode": g.garment_code,
"garmentName": g.garment_name,
"washDiscardLimit": int(g.wash_discard_limit or 0),
"sterilizeDiscardLimit": int(g.sterilize_discard_limit or 0),
"inboundDate": g.inbound_date.strftime("%Y-%m-%d") if g.inbound_date else "",
"discardDate": g.discard_date.strftime("%Y-%m-%d") if g.discard_date else "",
"garmentStatus": g.garment_status or GARMENT_STATUS_NORMAL,
"washCount": wash_count,
"sterilizeCount": sterilize_count,
"washLimitReached": wash_limit_reached,
"sterilizeLimitReached": sterilize_limit_reached,
"needAttention": wash_limit_reached or sterilize_limit_reached,
"tenantNo": g.tenant_no,
"orderNum": g.order_num if g.order_num is not None else 0,
"remark": g.remark or "",
"createTime": g.create_time.strftime("%Y-%m-%d %H:%M:%S") if g.create_time else "",
"updateTime": g.update_time.strftime("%Y-%m-%d %H:%M:%S") if g.update_time else "",
}
def list_garments(
db: Session,
*,
page: int = 1,
page_size: int = 10,
keyword: Optional[str] = None,
garment_status: Optional[str] = None,
need_attention: Optional[bool] = None,
tenant_no: Optional[str] = None,
user_info=None,
) -> Tuple[List[Dict[str, Any]], int]:
wash_cnt_sq = (
db.query(
BizCleanroomGarmentWashLog.garment_id.label("garment_id"),
func.count(BizCleanroomGarmentWashLog.id).label("wash_count"),
)
.filter(BizCleanroomGarmentWashLog.del_flag == 0)
.group_by(BizCleanroomGarmentWashLog.garment_id)
.subquery()
)
ster_cnt_sq = (
db.query(
BizCleanroomGarmentSterilizeLog.garment_id.label("garment_id"),
func.count(BizCleanroomGarmentSterilizeLog.id).label("sterilize_count"),
)
.filter(BizCleanroomGarmentSterilizeLog.del_flag == 0)
.group_by(BizCleanroomGarmentSterilizeLog.garment_id)
.subquery()
)
def _filtered():
q0 = (
db.query(
BizCleanroomGarment,
func.coalesce(wash_cnt_sq.c.wash_count, 0).label("wash_count"),
func.coalesce(ster_cnt_sq.c.sterilize_count, 0).label("sterilize_count"),
)
.outerjoin(wash_cnt_sq, BizCleanroomGarment.id == wash_cnt_sq.c.garment_id)
.outerjoin(ster_cnt_sq, BizCleanroomGarment.id == ster_cnt_sq.c.garment_id)
.filter(BizCleanroomGarment.del_flag == 0)
)
if tenant_no:
q0 = q0.filter(BizCleanroomGarment.tenant_no == tenant_no)
kw = (keyword or "").strip()
if kw:
like = f"%{kw}%"
q0 = q0.filter(
or_(
BizCleanroomGarment.garment_code.like(like),
BizCleanroomGarment.garment_name.like(like),
)
)
st = (garment_status or "").strip()
if st in (GARMENT_STATUS_NORMAL, GARMENT_STATUS_DISCARDED):
q0 = q0.filter(BizCleanroomGarment.garment_status == st)
if need_attention:
q0 = q0.filter(
BizCleanroomGarment.garment_status == GARMENT_STATUS_NORMAL,
or_(
func.coalesce(wash_cnt_sq.c.wash_count, 0) >= BizCleanroomGarment.wash_discard_limit,
func.coalesce(ster_cnt_sq.c.sterilize_count, 0) >= BizCleanroomGarment.sterilize_discard_limit,
),
)
if user_info:
from app.core.data_scope import apply_data_scope
q0 = apply_data_scope(q0, BizCleanroomGarment, user_info, db, tenant_no)
return q0
total = _filtered().order_by(None).count()
page = max(1, page)
page_size = min(max(1, page_size), 100)
rows = (
_filtered()
.order_by(BizCleanroomGarment.create_time.desc())
.offset((page - 1) * page_size)
.limit(page_size)
.all()
)
result = []
for g, wash_count, sterilize_count in rows:
result.append(
_garment_to_dict(
g,
wash_count=int(wash_count or 0),
sterilize_count=int(sterilize_count or 0),
)
)
return result, int(total)
def get_garment(
db: Session, garment_id: str, tenant_no: Optional[str] = None
) -> Optional[BizCleanroomGarment]:
q = db.query(BizCleanroomGarment).filter(
and_(BizCleanroomGarment.id == garment_id, BizCleanroomGarment.del_flag == 0)
)
if tenant_no:
q = q.filter(BizCleanroomGarment.tenant_no == tenant_no)
return q.first()
def get_garment_detail(
db: Session, garment_id: str, tenant_no: Optional[str] = None
) -> Optional[Dict[str, Any]]:
obj = get_garment(db, garment_id, tenant_no=tenant_no)
if not obj:
return None
wash_map = _count_map(db, BizCleanroomGarmentWashLog, [garment_id], tenant_no)
ster_map = _count_map(db, BizCleanroomGarmentSterilizeLog, [garment_id], tenant_no)
return _garment_to_dict(
obj,
wash_count=wash_map.get(garment_id, 0),
sterilize_count=ster_map.get(garment_id, 0),
)
def garment_code_exists(
db: Session, code: str, tenant_no: str, exclude_id: Optional[str] = None
) -> bool:
q = db.query(BizCleanroomGarment).filter(
and_(
BizCleanroomGarment.garment_code == code.strip(),
BizCleanroomGarment.tenant_no == tenant_no,
BizCleanroomGarment.del_flag == 0,
)
)
if exclude_id:
q = q.filter(BizCleanroomGarment.id != exclude_id)
return q.first() is not None
def create_garment(
db: Session,
*,
garment_code: str,
garment_name: str,
wash_discard_limit: Any,
sterilize_discard_limit: Any,
inbound_date: Any,
tenant_no: str = "zkxw",
order_num: Optional[int] = None,
remark: Optional[str] = None,
user_id: Optional[str] = None,
) -> BizCleanroomGarment:
code = (garment_code or "").strip()
if not code:
raise ValueError("编号不能为空")
if garment_code_exists(db, code, tenant_no):
raise ValueError("编号已存在")
name = (garment_name or "").strip()
if not name:
raise ValueError("名称不能为空")
inbound = _parse_date(inbound_date)
if not inbound:
raise ValueError("入库日期不能为空")
obj = BizCleanroomGarment(
id=generate_uuid(),
garment_code=code,
garment_name=name,
wash_discard_limit=_parse_limit(wash_discard_limit, "清洗报废次数"),
sterilize_discard_limit=_parse_limit(sterilize_discard_limit, "灭菌报废次数"),
inbound_date=inbound,
discard_date=None,
garment_status=GARMENT_STATUS_NORMAL,
tenant_no=tenant_no,
order_num=order_num if order_num is not None else 0,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id="",
create_time=datetime.now(),
update_by=user_id,
update_time=datetime.now(),
del_flag=0,
)
db.add(obj)
db.commit()
db.refresh(obj)
return obj
def update_garment(
db: Session,
garment_id: str,
*,
garment_code: Optional[str] = None,
garment_name: Optional[str] = None,
wash_discard_limit: Any = None,
sterilize_discard_limit: Any = None,
inbound_date: Any = None,
order_num: Optional[int] = None,
remark: Optional[str] = None,
user_id: Optional[str] = None,
tenant_no: Optional[str] = None,
) -> BizCleanroomGarment:
obj = get_garment(db, garment_id, tenant_no=tenant_no)
if not obj:
raise ValueError("洁净服不存在")
if garment_code is not None:
new_code = garment_code.strip()
if not new_code:
raise ValueError("编号不能为空")
if new_code != obj.garment_code and garment_code_exists(db, new_code, obj.tenant_no, exclude_id=garment_id):
raise ValueError("编号已存在")
obj.garment_code = new_code
if garment_name is not None:
name = (garment_name or "").strip()
if not name:
raise ValueError("名称不能为空")
obj.garment_name = name
if wash_discard_limit is not None:
obj.wash_discard_limit = _parse_limit(wash_discard_limit, "清洗报废次数")
if sterilize_discard_limit is not None:
obj.sterilize_discard_limit = _parse_limit(sterilize_discard_limit, "灭菌报废次数")
if inbound_date is not None:
inbound = _parse_date(inbound_date)
if not inbound:
raise ValueError("入库日期不能为空")
obj.inbound_date = inbound
if order_num is not None:
obj.order_num = order_num
if remark is not None:
obj.remark = (remark or "").strip() or None
obj.update_by = user_id
obj.update_time = datetime.now()
db.add(obj)
db.commit()
db.refresh(obj)
return obj
def soft_delete_garment(db: Session, garment_id: str, tenant_no: Optional[str] = None) -> None:
obj = get_garment(db, garment_id, tenant_no=tenant_no)
if not obj:
raise ValueError("洁净服不存在")
obj.del_flag = 1
obj.update_time = datetime.now()
db.add(obj)
db.commit()
def batch_soft_delete_garments(
db: Session, garment_ids: List[str], tenant_no: Optional[str] = None
) -> int:
count = 0
for gid in garment_ids:
try:
soft_delete_garment(db, gid, tenant_no=tenant_no)
count += 1
except ValueError:
continue
return count
def discard_garment(
db: Session,
garment_id: str,
*,
discard_date: Any = None,
remark: Optional[str] = None,
user_id: Optional[str] = None,
tenant_no: Optional[str] = None,
) -> BizCleanroomGarment:
obj = get_garment(db, garment_id, tenant_no=tenant_no)
if not obj:
raise ValueError("洁净服不存在")
if obj.garment_status == GARMENT_STATUS_DISCARDED:
raise ValueError("该洁净服已废弃")
d = _parse_date(discard_date) if discard_date else date.today()
obj.garment_status = GARMENT_STATUS_DISCARDED
obj.discard_date = d
if remark is not None:
obj.remark = (remark or "").strip() or obj.remark
obj.update_by = user_id
obj.update_time = datetime.now()
db.add(obj)
db.commit()
db.refresh(obj)
return obj
def batch_discard_garments(
db: Session,
garment_ids: List[str],
*,
discard_date: Any = None,
remark: Optional[str] = None,
user_id: Optional[str] = None,
tenant_no: Optional[str] = None,
) -> Dict[str, Any]:
success_count = 0
skipped_items: List[Dict[str, str]] = []
for gid in garment_ids:
obj = get_garment(db, gid, tenant_no=tenant_no)
if not obj:
skipped_items.append({"garmentId": gid, "reason": "不存在"})
continue
if obj.garment_status == GARMENT_STATUS_DISCARDED:
skipped_items.append({"garmentId": gid, "garmentCode": obj.garment_code, "reason": "已废弃"})
continue
discard_garment(
db,
gid,
discard_date=discard_date,
remark=remark,
user_id=user_id,
tenant_no=tenant_no,
)
success_count += 1
return {
"successCount": success_count,
"skippedCount": len(skipped_items),
"skippedItems": skipped_items,
}
def _ensure_garment_active(g: Optional[BizCleanroomGarment]) -> BizCleanroomGarment:
if not g:
raise ValueError("洁净服不存在")
if g.garment_status == GARMENT_STATUS_DISCARDED:
raise ValueError(f"洁净服「{g.garment_code}」已废弃,不可登记")
return g
# ---------------------------------------------------------------------------
# 清洗记录
# ---------------------------------------------------------------------------
def _wash_log_to_dict(log: BizCleanroomGarmentWashLog) -> Dict[str, Any]:
return {
"id": log.id,
"garmentId": log.garment_id,
"washTime": log.wash_time.strftime("%Y-%m-%d %H:%M:%S") if log.wash_time else "",
"operatorUserId": log.operator_user_id or "",
"operatorName": log.operator_name or "",
"tenantNo": log.tenant_no,
"orderNum": log.order_num if log.order_num is not None else 0,
"remark": log.remark or "",
"createTime": log.create_time.strftime("%Y-%m-%d %H:%M:%S") if log.create_time else "",
"updateTime": log.update_time.strftime("%Y-%m-%d %H:%M:%S") if log.update_time else "",
}
def list_wash_logs(
db: Session,
*,
garment_id: str,
page: int = 1,
page_size: int = 10,
tenant_no: Optional[str] = None,
) -> Tuple[List[Dict[str, Any]], int]:
q = db.query(BizCleanroomGarmentWashLog).filter(
BizCleanroomGarmentWashLog.del_flag == 0,
BizCleanroomGarmentWashLog.garment_id == garment_id,
)
if tenant_no:
q = q.filter(BizCleanroomGarmentWashLog.tenant_no == tenant_no)
total = q.count()
page = max(1, page)
page_size = min(max(1, page_size), 100)
rows = (
q.order_by(BizCleanroomGarmentWashLog.wash_time.desc())
.offset((page - 1) * page_size)
.limit(page_size)
.all()
)
return [_wash_log_to_dict(x) for x in rows], int(total)
def get_wash_log(db: Session, log_id: str, tenant_no: Optional[str] = None) -> Optional[BizCleanroomGarmentWashLog]:
q = db.query(BizCleanroomGarmentWashLog).filter(
and_(BizCleanroomGarmentWashLog.id == log_id, BizCleanroomGarmentWashLog.del_flag == 0)
)
if tenant_no:
q = q.filter(BizCleanroomGarmentWashLog.tenant_no == tenant_no)
return q.first()
def create_wash_log(
db: Session,
*,
garment_id: str,
wash_time: Any,
operator_user_id: Optional[str] = None,
operator_name: Optional[str] = None,
tenant_no: str = "zkxw",
order_num: Optional[int] = None,
remark: Optional[str] = None,
user_id: Optional[str] = None,
) -> BizCleanroomGarmentWashLog:
garment = _ensure_garment_active(get_garment(db, garment_id, tenant_no=tenant_no))
wt = _parse_datetime(wash_time)
obj = BizCleanroomGarmentWashLog(
id=generate_uuid(),
garment_id=garment.id,
wash_time=wt,
operator_user_id=(operator_user_id or "").strip() or None,
operator_name=(operator_name or "").strip() or None,
tenant_no=tenant_no,
order_num=order_num if order_num is not None else 0,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id="",
create_time=datetime.now(),
update_by=user_id,
update_time=datetime.now(),
del_flag=0,
)
db.add(obj)
db.commit()
db.refresh(obj)
return obj
def update_wash_log(
db: Session,
log_id: str,
*,
wash_time: Any = None,
operator_user_id: Optional[str] = None,
operator_name: Optional[str] = None,
order_num: Optional[int] = None,
remark: Optional[str] = None,
user_id: Optional[str] = None,
tenant_no: Optional[str] = None,
) -> BizCleanroomGarmentWashLog:
obj = get_wash_log(db, log_id, tenant_no=tenant_no)
if not obj:
raise ValueError("清洗记录不存在")
garment = get_garment(db, obj.garment_id, tenant_no=tenant_no)
_ensure_garment_active(garment)
if wash_time is not None:
obj.wash_time = _parse_datetime(wash_time)
if operator_user_id is not None:
obj.operator_user_id = (operator_user_id or "").strip() or None
if operator_name is not None:
obj.operator_name = (operator_name or "").strip() or None
if order_num is not None:
obj.order_num = order_num
if remark is not None:
obj.remark = (remark or "").strip() or None
obj.update_by = user_id
obj.update_time = datetime.now()
db.add(obj)
db.commit()
db.refresh(obj)
return obj
def soft_delete_wash_log(db: Session, log_id: str, tenant_no: Optional[str] = None) -> None:
obj = get_wash_log(db, log_id, tenant_no=tenant_no)
if not obj:
raise ValueError("清洗记录不存在")
obj.del_flag = 1
obj.update_time = datetime.now()
db.add(obj)
db.commit()
def batch_create_wash_logs(
db: Session,
*,
garment_ids: List[str],
wash_time: Any,
operator_user_id: Optional[str] = None,
operator_name: Optional[str] = None,
remark: Optional[str] = None,
tenant_no: str = "zkxw",
user_id: Optional[str] = None,
) -> Dict[str, Any]:
if not garment_ids:
raise ValueError("请选择洁净服")
discarded_codes: List[str] = []
garments: List[BizCleanroomGarment] = []
for gid in garment_ids:
g = get_garment(db, gid, tenant_no=tenant_no)
if not g:
raise ValueError("存在无效的洁净服")
if g.garment_status == GARMENT_STATUS_DISCARDED:
discarded_codes.append(g.garment_code)
else:
garments.append(g)
if discarded_codes:
raise ValueError(f"以下洁净服已废弃,不可登记:{', '.join(discarded_codes)}")
wt = _parse_datetime(wash_time)
items: List[Dict[str, Any]] = []
try:
for g in garments:
log = BizCleanroomGarmentWashLog(
id=generate_uuid(),
garment_id=g.id,
wash_time=wt,
operator_user_id=(operator_user_id or "").strip() or None,
operator_name=(operator_name or "").strip() or None,
tenant_no=tenant_no,
order_num=0,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id="",
create_time=datetime.now(),
update_by=user_id,
update_time=datetime.now(),
del_flag=0,
)
db.add(log)
db.commit()
except Exception:
db.rollback()
raise
wash_map = _count_map(db, BizCleanroomGarmentWashLog, [g.id for g in garments], tenant_no)
for g in garments:
wc = wash_map.get(g.id, 0)
items.append(
{
"garmentId": g.id,
"garmentCode": g.garment_code,
"washCount": wc,
"washLimitReached": wc >= int(g.wash_discard_limit or 0),
"sterilizeCount": _count_map(db, BizCleanroomGarmentSterilizeLog, [g.id], tenant_no).get(g.id, 0),
"sterilizeLimitReached": False,
}
)
for item in items:
g = next(x for x in garments if x.id == item["garmentId"])
sc = item["sterilizeCount"]
item["sterilizeLimitReached"] = sc >= int(g.sterilize_discard_limit or 0)
item["needAttention"] = item["washLimitReached"] or item["sterilizeLimitReached"]
return {"successCount": len(items), "items": items}
# ---------------------------------------------------------------------------
# 灭菌记录
# ---------------------------------------------------------------------------
def _sterilize_log_to_dict(log: BizCleanroomGarmentSterilizeLog) -> Dict[str, Any]:
return {
"id": log.id,
"garmentId": log.garment_id,
"sterilizeTime": log.sterilize_time.strftime("%Y-%m-%d %H:%M:%S") if log.sterilize_time else "",
"operatorUserId": log.operator_user_id or "",
"operatorName": log.operator_name or "",
"tenantNo": log.tenant_no,
"orderNum": log.order_num if log.order_num is not None else 0,
"remark": log.remark or "",
"createTime": log.create_time.strftime("%Y-%m-%d %H:%M:%S") if log.create_time else "",
"updateTime": log.update_time.strftime("%Y-%m-%d %H:%M:%S") if log.update_time else "",
}
def list_sterilize_logs(
db: Session,
*,
garment_id: str,
page: int = 1,
page_size: int = 10,
tenant_no: Optional[str] = None,
) -> Tuple[List[Dict[str, Any]], int]:
q = db.query(BizCleanroomGarmentSterilizeLog).filter(
BizCleanroomGarmentSterilizeLog.del_flag == 0,
BizCleanroomGarmentSterilizeLog.garment_id == garment_id,
)
if tenant_no:
q = q.filter(BizCleanroomGarmentSterilizeLog.tenant_no == tenant_no)
total = q.count()
page = max(1, page)
page_size = min(max(1, page_size), 100)
rows = (
q.order_by(BizCleanroomGarmentSterilizeLog.sterilize_time.desc())
.offset((page - 1) * page_size)
.limit(page_size)
.all()
)
return [_sterilize_log_to_dict(x) for x in rows], int(total)
def get_sterilize_log(
db: Session, log_id: str, tenant_no: Optional[str] = None
) -> Optional[BizCleanroomGarmentSterilizeLog]:
q = db.query(BizCleanroomGarmentSterilizeLog).filter(
and_(BizCleanroomGarmentSterilizeLog.id == log_id, BizCleanroomGarmentSterilizeLog.del_flag == 0)
)
if tenant_no:
q = q.filter(BizCleanroomGarmentSterilizeLog.tenant_no == tenant_no)
return q.first()
def create_sterilize_log(
db: Session,
*,
garment_id: str,
sterilize_time: Any,
operator_user_id: Optional[str] = None,
operator_name: Optional[str] = None,
tenant_no: str = "zkxw",
order_num: Optional[int] = None,
remark: Optional[str] = None,
user_id: Optional[str] = None,
) -> BizCleanroomGarmentSterilizeLog:
garment = _ensure_garment_active(get_garment(db, garment_id, tenant_no=tenant_no))
st = _parse_datetime(sterilize_time)
obj = BizCleanroomGarmentSterilizeLog(
id=generate_uuid(),
garment_id=garment.id,
sterilize_time=st,
operator_user_id=(operator_user_id or "").strip() or None,
operator_name=(operator_name or "").strip() or None,
tenant_no=tenant_no,
order_num=order_num if order_num is not None else 0,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id="",
create_time=datetime.now(),
update_by=user_id,
update_time=datetime.now(),
del_flag=0,
)
db.add(obj)
db.commit()
db.refresh(obj)
return obj
def update_sterilize_log(
db: Session,
log_id: str,
*,
sterilize_time: Any = None,
operator_user_id: Optional[str] = None,
operator_name: Optional[str] = None,
order_num: Optional[int] = None,
remark: Optional[str] = None,
user_id: Optional[str] = None,
tenant_no: Optional[str] = None,
) -> BizCleanroomGarmentSterilizeLog:
obj = get_sterilize_log(db, log_id, tenant_no=tenant_no)
if not obj:
raise ValueError("灭菌记录不存在")
garment = get_garment(db, obj.garment_id, tenant_no=tenant_no)
_ensure_garment_active(garment)
if sterilize_time is not None:
obj.sterilize_time = _parse_datetime(sterilize_time)
if operator_user_id is not None:
obj.operator_user_id = (operator_user_id or "").strip() or None
if operator_name is not None:
obj.operator_name = (operator_name or "").strip() or None
if order_num is not None:
obj.order_num = order_num
if remark is not None:
obj.remark = (remark or "").strip() or None
obj.update_by = user_id
obj.update_time = datetime.now()
db.add(obj)
db.commit()
db.refresh(obj)
return obj
def soft_delete_sterilize_log(db: Session, log_id: str, tenant_no: Optional[str] = None) -> None:
obj = get_sterilize_log(db, log_id, tenant_no=tenant_no)
if not obj:
raise ValueError("灭菌记录不存在")
obj.del_flag = 1
obj.update_time = datetime.now()
db.add(obj)
db.commit()
def batch_create_sterilize_logs(
db: Session,
*,
garment_ids: List[str],
sterilize_time: Any,
operator_user_id: Optional[str] = None,
operator_name: Optional[str] = None,
remark: Optional[str] = None,
tenant_no: str = "zkxw",
user_id: Optional[str] = None,
) -> Dict[str, Any]:
if not garment_ids:
raise ValueError("请选择洁净服")
discarded_codes: List[str] = []
garments: List[BizCleanroomGarment] = []
for gid in garment_ids:
g = get_garment(db, gid, tenant_no=tenant_no)
if not g:
raise ValueError("存在无效的洁净服")
if g.garment_status == GARMENT_STATUS_DISCARDED:
discarded_codes.append(g.garment_code)
else:
garments.append(g)
if discarded_codes:
raise ValueError(f"以下洁净服已废弃,不可登记:{', '.join(discarded_codes)}")
st = _parse_datetime(sterilize_time)
items: List[Dict[str, Any]] = []
try:
for g in garments:
log = BizCleanroomGarmentSterilizeLog(
id=generate_uuid(),
garment_id=g.id,
sterilize_time=st,
operator_user_id=(operator_user_id or "").strip() or None,
operator_name=(operator_name or "").strip() or None,
tenant_no=tenant_no,
order_num=0,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id="",
create_time=datetime.now(),
update_by=user_id,
update_time=datetime.now(),
del_flag=0,
)
db.add(log)
db.commit()
except Exception:
db.rollback()
raise
ster_map = _count_map(db, BizCleanroomGarmentSterilizeLog, [g.id for g in garments], tenant_no)
wash_map = _count_map(db, BizCleanroomGarmentWashLog, [g.id for g in garments], tenant_no)
for g in garments:
sc = ster_map.get(g.id, 0)
wc = wash_map.get(g.id, 0)
items.append(
{
"garmentId": g.id,
"garmentCode": g.garment_code,
"washCount": wc,
"washLimitReached": wc >= int(g.wash_discard_limit or 0),
"sterilizeCount": sc,
"sterilizeLimitReached": sc >= int(g.sterilize_discard_limit or 0),
"needAttention": False,
}
)
for item in items:
item["needAttention"] = item["washLimitReached"] or item["sterilizeLimitReached"]
return {"successCount": len(items), "items": items}
+264
View File
@@ -0,0 +1,264 @@
"""设备 CRUD(biz_equipment)"""
from __future__ import annotations
import math
from datetime import date, datetime
from decimal import Decimal
from typing import Any, Dict, List, Optional, Tuple
from sqlalchemy import and_, func, or_
from sqlalchemy.orm import Session
from app.core.utils import generate_uuid
from app.models.models import BizEquipment
def _dec(v: Any) -> Optional[float]:
if v is None:
return None
return float(v)
def _norm_status(v: Any) -> str:
if v is None:
return "1"
if isinstance(v, bool):
return "1" if v else "0"
if isinstance(v, (int, float)):
if int(v) == 0:
return "0"
if int(v) == 1:
return "1"
s = str(v).strip()
if s in ("0", "1"):
return s
return "1"
def _parse_date(v: Any) -> Optional[date]:
if v is None or v == "":
return None
if isinstance(v, date) and not isinstance(v, datetime):
return v
if isinstance(v, datetime):
return v.date()
s = str(v).strip()
if not s:
return None
for fmt in ("%Y-%m-%d", "%Y/%m/%d"):
try:
return datetime.strptime(s[:10], fmt).date()
except ValueError:
continue
raise ValueError("购入日期格式无效,请使用 YYYY-MM-DD")
def _row_to_dict(r: BizEquipment) -> Dict[str, Any]:
return {
"id": r.id,
"equipmentCode": r.equipment_code,
"equipmentName": r.equipment_name,
"equipmentModel": r.equipment_model or "",
"manufacturer": r.manufacturer or "",
"purchaseDate": r.purchase_date.strftime("%Y-%m-%d") if r.purchase_date else "",
"purchaseAmount": _dec(r.purchase_amount),
"location": r.location or "",
"serialNo": r.serial_no or "",
"status": _norm_status(r.status),
"tenantNo": r.tenant_no,
"orderNum": r.order_num if r.order_num is not None else 0,
"remark": r.remark or "",
"createTime": r.create_time.strftime("%Y-%m-%d %H:%M:%S") if r.create_time else "",
"updateTime": r.update_time.strftime("%Y-%m-%d %H:%M:%S") if r.update_time else "",
}
def list_equipments(
db: Session,
*,
page: int = 1,
page_size: int = 10,
keyword: Optional[str] = None,
status: Optional[str] = None,
tenant_no: Optional[str] = None,
user_info=None,
) -> Tuple[List[Dict[str, Any]], int]:
def _filtered():
q0 = db.query(BizEquipment).filter(BizEquipment.del_flag == 0)
if tenant_no:
q0 = q0.filter(BizEquipment.tenant_no == tenant_no)
kw = (keyword or "").strip()
if kw:
like = f"%{kw}%"
q0 = q0.filter(
or_(
BizEquipment.equipment_code.like(like),
BizEquipment.equipment_name.like(like),
BizEquipment.equipment_model.like(like),
BizEquipment.manufacturer.like(like),
)
)
st = (status or "").strip()
if st in ("0", "1"):
q0 = q0.filter(BizEquipment.status == st)
if user_info:
from app.core.data_scope import apply_data_scope
q0 = apply_data_scope(q0, BizEquipment, user_info, db, tenant_no)
return q0
total = _filtered().order_by(None).with_entities(func.count(BizEquipment.id)).scalar() or 0
page = max(1, page)
page_size = min(max(1, page_size), 100)
rows = (
_filtered()
.order_by(BizEquipment.create_time.desc())
.offset((page - 1) * page_size)
.limit(page_size)
.all()
)
return [_row_to_dict(x) for x in rows], int(total)
def get_equipment(db: Session, equipment_id: str) -> Optional[BizEquipment]:
return (
db.query(BizEquipment)
.filter(and_(BizEquipment.id == equipment_id, BizEquipment.del_flag == 0))
.first()
)
def equipment_code_exists(
db: Session, code: str, tenant_no: str, exclude_id: Optional[str] = None
) -> bool:
q = db.query(BizEquipment).filter(
and_(
BizEquipment.equipment_code == code.strip(),
BizEquipment.tenant_no == tenant_no,
BizEquipment.del_flag == 0,
)
)
if exclude_id:
q = q.filter(BizEquipment.id != exclude_id)
return q.first() is not None
def create_equipment(
db: Session,
*,
equipment_code: str,
equipment_name: str,
equipment_model: Optional[str] = None,
manufacturer: Optional[str] = None,
purchase_date: Optional[Any] = None,
purchase_amount: Optional[float] = None,
location: Optional[str] = None,
serial_no: Optional[str] = None,
status: Optional[str] = None,
tenant_no: str = "zkxw",
order_num: Optional[int] = None,
remark: Optional[str] = None,
user_id: Optional[str] = None,
) -> BizEquipment:
ec = (equipment_code or "").strip()
if not ec:
raise ValueError("设备编码不能为空")
if equipment_code_exists(db, ec, tenant_no):
raise ValueError("设备编码已存在")
obj = BizEquipment(
id=generate_uuid(),
equipment_code=ec,
equipment_name=(equipment_name or "").strip() or ec,
equipment_model=(equipment_model or "").strip() or None,
manufacturer=(manufacturer or "").strip() or None,
purchase_date=_parse_date(purchase_date),
purchase_amount=Decimal(str(purchase_amount)) if purchase_amount is not None else None,
location=(location or "").strip() or None,
serial_no=(serial_no or "").strip() or None,
status=_norm_status(status),
tenant_no=tenant_no,
order_num=order_num if order_num is not None else 0,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id="",
create_time=datetime.now(),
update_by=user_id,
update_time=datetime.now(),
del_flag=0,
)
db.add(obj)
db.commit()
db.refresh(obj)
return obj
def update_equipment(
db: Session,
equipment_id: str,
*,
equipment_code: Optional[str] = None,
equipment_name: Optional[str] = None,
equipment_model: Optional[str] = None,
manufacturer: Optional[str] = None,
purchase_date: Optional[Any] = None,
purchase_amount: Optional[float] = None,
location: Optional[str] = None,
serial_no: Optional[str] = None,
status: Optional[str] = None,
order_num: Optional[int] = None,
remark: Optional[str] = None,
user_id: Optional[str] = None,
) -> BizEquipment:
obj = get_equipment(db, equipment_id)
if not obj:
raise ValueError("设备不存在")
if equipment_code is not None:
new_code = equipment_code.strip()
if not new_code:
raise ValueError("设备编码不能为空")
if new_code != obj.equipment_code and equipment_code_exists(
db, new_code, obj.tenant_no, exclude_id=equipment_id
):
raise ValueError("设备编码已存在")
obj.equipment_code = new_code
if equipment_name is not None:
obj.equipment_name = (equipment_name or "").strip() or obj.equipment_name
if equipment_model is not None:
obj.equipment_model = (equipment_model or "").strip() or None
if manufacturer is not None:
obj.manufacturer = (manufacturer or "").strip() or None
if purchase_date is not None:
obj.purchase_date = _parse_date(purchase_date)
if purchase_amount is not None:
obj.purchase_amount = Decimal(str(purchase_amount)) if purchase_amount != "" else None
if location is not None:
obj.location = (location or "").strip() or None
if serial_no is not None:
obj.serial_no = (serial_no or "").strip() or None
if status is not None:
obj.status = _norm_status(status)
if order_num is not None:
obj.order_num = order_num
if remark is not None:
obj.remark = (remark or "").strip() or None
obj.update_by = user_id
obj.update_time = datetime.now()
db.add(obj)
db.commit()
db.refresh(obj)
return obj
def soft_delete_equipment(db: Session, equipment_id: str) -> None:
obj = get_equipment(db, equipment_id)
if not obj:
raise ValueError("设备不存在")
obj.del_flag = 1
obj.update_time = datetime.now()
db.add(obj)
db.commit()
def total_pages(total: int, page_size: int) -> int:
if total <= 0:
return 0
return int(math.ceil(total / float(page_size)))
+62 -270
View File
@@ -9,7 +9,7 @@ from sqlalchemy import func, or_
from sqlalchemy.orm import Session
from app.core.utils import generate_uuid
from app.models.material import BizMaterial, BizMaterialStockLog
from app.models.material import BizMaterial
def _dec(v: Any) -> float:
@@ -22,6 +22,26 @@ def _fmt_dt(t: Optional[datetime]) -> str:
return t.strftime("%Y-%m-%d %H:%M:%S") if t else ""
def _norm_status(v: Any) -> str:
if v is None:
return "1"
if isinstance(v, bool):
return "1" if v else "0"
if isinstance(v, (int, float)):
if int(v) == 0:
return "0"
if int(v) == 1:
return "1"
s = str(v).strip()
if s in ("0", "1"):
return s
return "1"
def _is_enabled_status(v: Any) -> bool:
return _norm_status(v) == "1"
def _row_to_dict(r: BizMaterial) -> Dict[str, Any]:
return {
"id": r.id,
@@ -32,7 +52,7 @@ def _row_to_dict(r: BizMaterial) -> Dict[str, Any]:
"unit": r.unit or "",
"stockQty": _dec(r.stock_qty),
"warningQty": _dec(r.warning_qty),
"status": r.status or "1",
"status": _norm_status(r.status),
"imageUrls": r.image_urls or "",
"orderNum": r.order_num if r.order_num is not None else 0,
"remark": r.remark or "",
@@ -255,296 +275,68 @@ def soft_delete_material(
db.commit()
def stock_in(
db: Session,
material_id: str,
*,
qty: float,
remark: Optional[str] = None,
tenant_no: str,
user_id: Optional[str] = None,
dept_id: str = "",
operate_time: Optional[datetime] = None,
) -> Dict[str, Any]:
if qty is None or qty <= 0:
raise ValueError("入库数量必须大于0")
qty_dec = Decimal(str(qty))
obj = (
def get_material_entity(
db: Session, material_id: str, tenant_no: str
) -> Optional[BizMaterial]:
return (
db.query(BizMaterial)
.filter(
BizMaterial.id == material_id,
BizMaterial.tenant_no == tenant_no,
BizMaterial.del_flag == 0,
)
.with_for_update()
.first()
)
if not obj:
raise ValueError("物料不存在")
op_time = operate_time or datetime.now()
stock_before = obj.stock_qty if obj.stock_qty is not None else Decimal("0")
stock_after = stock_before + qty_dec
obj.stock_qty = stock_after
obj.update_by = user_id
obj.update_time = datetime.now()
db.add(obj)
log = BizMaterialStockLog(
id=generate_uuid(),
material_id=obj.id,
material_code=obj.material_code,
material_name=obj.material_name,
change_type="rk",
change_qty=qty_dec,
stock_before=stock_before,
stock_after=stock_after,
tenant_no=tenant_no,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id=dept_id or "",
create_time=op_time,
update_by=user_id,
update_time=op_time,
del_flag=0,
)
db.add(log)
db.commit()
db.refresh(obj)
return _row_to_dict(obj)
def batch_stock_in(
db: Session,
*,
items: List[Dict[str, Any]],
remark: Optional[str] = None,
tenant_no: str,
user_id: Optional[str] = None,
dept_id: str = "",
operate_time: Optional[datetime] = None,
) -> int:
"""批量入库,同一事务;任一条失败则全部回滚。"""
if not items:
raise ValueError("请至少选择一条物料")
op_time = operate_time or datetime.now()
shared_remark = (remark or "").strip() or None
try:
for it in items:
material_id = (it.get("material_id") or it.get("materialId") or "").strip()
qty = it.get("qty")
if not material_id:
raise ValueError("物料ID不能为空")
if qty is None or qty <= 0:
raise ValueError("入库数量必须大于0")
qty_dec = Decimal(str(qty))
line_remark = (it.get("remark") or "").strip()
log_remark = line_remark or shared_remark or None
obj = (
db.query(BizMaterial)
.filter(
BizMaterial.id == material_id,
BizMaterial.tenant_no == tenant_no,
BizMaterial.del_flag == 0,
)
.with_for_update()
.first()
)
if not obj:
raise ValueError("物料不存在")
if obj.status != "1":
raise ValueError(f"物料「{obj.material_name}」已停用,无法入库")
stock_before = obj.stock_qty if obj.stock_qty is not None else Decimal("0")
stock_after = stock_before + qty_dec
obj.stock_qty = stock_after
obj.update_by = user_id
obj.update_time = datetime.now()
db.add(obj)
log = BizMaterialStockLog(
id=generate_uuid(),
material_id=obj.id,
material_code=obj.material_code,
material_name=obj.material_name,
change_type="rk",
change_qty=qty_dec,
stock_before=stock_before,
stock_after=stock_after,
tenant_no=tenant_no,
remark=log_remark,
create_by=user_id,
create_dept_id=dept_id or "",
create_time=op_time,
update_by=user_id,
update_time=op_time,
del_flag=0,
)
db.add(log)
db.commit()
return len(items)
except Exception:
db.rollback()
raise
def stock_out(
def update_material_fields(
db: Session,
material_id: str,
*,
qty: float,
receiver: Optional[str] = None,
purpose: Optional[str] = None,
remark: Optional[str] = None,
tenant_no: str,
user_id: Optional[str] = None,
dept_id: str = "",
operate_time: Optional[datetime] = None,
) -> Dict[str, Any]:
if qty is None or qty <= 0:
raise ValueError("出库数量必须大于0")
qty_dec = Decimal(str(qty))
obj = (
db.query(BizMaterial)
.filter(
BizMaterial.id == material_id,
BizMaterial.tenant_no == tenant_no,
BizMaterial.del_flag == 0,
)
.with_for_update()
.first()
)
material_code: Optional[str] = None,
material_name: Optional[str] = None,
spec_model: Optional[str] = None,
unit: Optional[str] = None,
warning_qty: Optional[Decimal] = None,
status: Optional[str] = None,
order_num: Optional[int] = None,
remark: Optional[str] = None,
) -> BizMaterial:
obj = get_material_entity(db, material_id, tenant_no)
if not obj:
raise ValueError("物料不存在")
stock_before = obj.stock_qty if obj.stock_qty is not None else Decimal("0")
if stock_before < qty_dec:
raise ValueError(
f"物料「{obj.material_name}」库存不足,当前库存 {stock_before},需出库 {qty_dec}"
)
op_time = operate_time or datetime.now()
stock_after = stock_before - qty_dec
obj.stock_qty = stock_after
if material_code is not None:
code = material_code.strip()
if not code:
raise ValueError("物料编码不能为空")
if code != obj.material_code and _code_exists(db, code, tenant_no, exclude_id=material_id):
raise ValueError("物料编码已存在")
obj.material_code = code
if material_name is not None:
name = (material_name or "").strip()
if not name:
raise ValueError("物料名称不能为空")
obj.material_name = name
if spec_model is not None:
obj.spec_model = (spec_model or "").strip() or None
if unit is not None:
obj.unit = (unit or "").strip() or None
if warning_qty is not None:
obj.warning_qty = warning_qty
if status is not None:
obj.status = _norm_status(status)
if order_num is not None:
obj.order_num = order_num
if remark is not None:
obj.remark = (remark or "").strip() or None
obj.update_by = user_id
obj.update_time = datetime.now()
db.add(obj)
log = BizMaterialStockLog(
id=generate_uuid(),
material_id=obj.id,
material_code=obj.material_code,
material_name=obj.material_name,
change_type="ck",
change_qty=qty_dec,
stock_before=stock_before,
stock_after=stock_after,
receiver=(receiver or "").strip() or None,
purpose=(purpose or "").strip() or None,
tenant_no=tenant_no,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id=dept_id or "",
create_time=op_time,
update_by=user_id,
update_time=op_time,
del_flag=0,
)
db.add(log)
db.commit()
db.refresh(obj)
return _row_to_dict(obj)
def batch_stock_out(
db: Session,
*,
items: List[Dict[str, Any]],
receiver: Optional[str] = None,
purpose: Optional[str] = None,
remark: Optional[str] = None,
tenant_no: str,
user_id: Optional[str] = None,
dept_id: str = "",
operate_time: Optional[datetime] = None,
) -> int:
"""批量出库,同一事务;任一条失败则全部回滚。"""
if not items:
raise ValueError("请至少选择一条物料")
op_time = operate_time or datetime.now()
shared_receiver = (receiver or "").strip() or None
shared_purpose = (purpose or "").strip() or None
shared_remark = (remark or "").strip() or None
try:
for it in items:
material_id = (it.get("material_id") or it.get("materialId") or "").strip()
qty = it.get("qty")
if not material_id:
raise ValueError("物料ID不能为空")
if qty is None or qty <= 0:
raise ValueError("出库数量必须大于0")
qty_dec = Decimal(str(qty))
line_remark = (it.get("remark") or "").strip()
log_remark = line_remark or shared_remark or None
obj = (
db.query(BizMaterial)
.filter(
BizMaterial.id == material_id,
BizMaterial.tenant_no == tenant_no,
BizMaterial.del_flag == 0,
)
.with_for_update()
.first()
)
if not obj:
raise ValueError("物料不存在")
if obj.status != "1":
raise ValueError(f"物料「{obj.material_name}」已停用,无法出库")
stock_before = obj.stock_qty if obj.stock_qty is not None else Decimal("0")
if stock_before < qty_dec:
raise ValueError(
f"物料「{obj.material_name}」库存不足,当前库存 {stock_before},需出库 {qty_dec}"
)
stock_after = stock_before - qty_dec
obj.stock_qty = stock_after
obj.update_by = user_id
obj.update_time = datetime.now()
db.add(obj)
log = BizMaterialStockLog(
id=generate_uuid(),
material_id=obj.id,
material_code=obj.material_code,
material_name=obj.material_name,
change_type="ck",
change_qty=qty_dec,
stock_before=stock_before,
stock_after=stock_after,
receiver=shared_receiver,
purpose=shared_purpose,
tenant_no=tenant_no,
remark=log_remark,
create_by=user_id,
create_dept_id=dept_id or "",
create_time=op_time,
update_by=user_id,
update_time=op_time,
del_flag=0,
)
db.add(log)
db.commit()
return len(items)
except Exception:
db.rollback()
raise
return obj
def options_list(db: Session, tenant_no: str) -> List[Dict[str, Any]]:
+915
View File
@@ -0,0 +1,915 @@
"""市场物料入库批次 CRUD"""
from __future__ import annotations
from datetime import date, datetime
from decimal import Decimal
from typing import Any, Dict, List, Optional, Tuple
from sqlalchemy import func, or_
from sqlalchemy.orm import Session
from app.core.utils import generate_uuid
from app.crud.material import _dec, _fmt_dt, _is_enabled_status, _norm_status
from app.models.material import BizMaterial, BizMaterialStockBatch, BizMaterialUsage
def _fmt_date(d: Optional[date]) -> str:
return d.strftime("%Y-%m-%d") if d else ""
def _parse_date(v: Any, *, label: str = "入库日期") -> date:
if isinstance(v, date) and not isinstance(v, datetime):
return v
s = str(v or "").strip()
if not s:
raise ValueError(f"{label}不能为空")
if len(s) >= 10:
s = s[:10]
try:
return datetime.strptime(s, "%Y-%m-%d").date()
except ValueError as e:
raise ValueError("入库日期格式无效,应为 YYYY-MM-DD") from e
def _parse_expire_date(v: Any) -> date:
return _parse_date(v, label="过期日期")
def _require_str(v: Any, label: str) -> str:
s = str(v or "").strip()
if not s:
raise ValueError(f"{label}不能为空")
return s
def _require_decimal(v: Any, label: str) -> Decimal:
if v is None or str(v).strip() == "":
raise ValueError(f"{label}不能为空")
try:
d = Decimal(str(v))
except Exception as e:
raise ValueError(f"{label}格式无效") from e
if d < 0:
raise ValueError(f"{label}不能为负数")
return d
def stock_in_no_exists(
db: Session, stock_in_no: str, tenant_no: str, exclude_id: Optional[str] = None
) -> bool:
s = (stock_in_no or "").strip()
if not s:
return False
q = db.query(BizMaterialStockBatch).filter(
BizMaterialStockBatch.stock_in_no == s,
BizMaterialStockBatch.tenant_no == tenant_no,
BizMaterialStockBatch.del_flag == 0,
)
if exclude_id:
q = q.filter(BizMaterialStockBatch.id != exclude_id)
return q.first() is not None
def _batch_row_to_dict(b: BizMaterialStockBatch, material: Optional[BizMaterial] = None) -> Dict[str, Any]:
mat = material
warning_qty = _dec(mat.warning_qty) if mat else 0
stock_qty = _dec(mat.stock_qty) if mat else _dec(b.remaining_qty)
status = _norm_status(mat.status) if mat else "1"
return {
"id": b.id,
"batchId": b.id,
"materialId": b.material_id,
"materialCode": b.material_code or "",
"materialName": b.material_name or "",
"specModel": b.spec_model or "",
"unit": b.unit or "",
"stockInNo": b.stock_in_no or "",
"stockInDate": _fmt_date(b.stock_in_date),
"expireDate": _fmt_date(b.expire_date),
"catalogNo": b.catalog_no or "",
"batchNo": b.batch_no or "",
"manufacturer": b.manufacturer or "",
"unitPrice": float(b.unit_price) if b.unit_price is not None else 0,
"amount": float(b.amount) if b.amount is not None else 0,
"inQty": _dec(b.in_qty),
"remainingQty": _dec(b.remaining_qty),
"stockQty": stock_qty,
"warningQty": warning_qty,
"status": status,
"remark": b.remark or "",
"createTime": _fmt_dt(b.create_time),
"updateTime": _fmt_dt(b.update_time),
}
def _usage_batch_snapshots(
batch: BizMaterialStockBatch,
*,
out_qty: Optional[Decimal] = None,
) -> Dict[str, Any]:
unit_price = batch.unit_price
if out_qty is not None:
amount = (Decimal(str(unit_price or 0)) * abs(out_qty)).quantize(Decimal("0.01"))
else:
amount = batch.amount
return {
"batch_id": batch.id,
"stock_in_no": batch.stock_in_no,
"catalog_no": batch.catalog_no,
"batch_no": batch.batch_no,
"manufacturer": batch.manufacturer,
"unit_price": unit_price,
"amount": amount,
}
def _get_material_for_update(
db: Session, material_id: str, tenant_no: str
) -> BizMaterial:
obj = (
db.query(BizMaterial)
.filter(
BizMaterial.id == material_id,
BizMaterial.tenant_no == tenant_no,
BizMaterial.del_flag == 0,
)
.with_for_update()
.first()
)
if not obj:
raise ValueError("物料不存在")
return obj
def list_batches(
db: Session,
*,
page: int = 1,
page_size: int = 10,
keyword: Optional[str] = None,
material_id: Optional[str] = None,
status: Optional[str] = None,
tenant_no: Optional[str] = None,
user_info=None,
) -> Tuple[List[Dict[str, Any]], int]:
def _filtered():
q0 = (
db.query(BizMaterialStockBatch, BizMaterial)
.join(
BizMaterial,
BizMaterial.id == BizMaterialStockBatch.material_id,
)
.filter(
BizMaterialStockBatch.del_flag == 0,
BizMaterial.del_flag == 0,
)
)
if tenant_no:
q0 = q0.filter(BizMaterialStockBatch.tenant_no == tenant_no)
kw = (keyword or "").strip()
if kw:
like = f"%{kw}%"
q0 = q0.filter(
or_(
BizMaterialStockBatch.material_code.like(like),
BizMaterialStockBatch.material_name.like(like),
BizMaterialStockBatch.stock_in_no.like(like),
BizMaterialStockBatch.batch_no.like(like),
BizMaterialStockBatch.catalog_no.like(like),
)
)
if material_id:
q0 = q0.filter(BizMaterialStockBatch.material_id == material_id)
st = (status or "").strip()
if st in ("0", "1"):
q0 = q0.filter(BizMaterial.status == st)
if user_info:
from app.core.data_scope import apply_data_scope
q0 = apply_data_scope(q0, BizMaterialStockBatch, user_info, db, tenant_no)
return q0
total = _filtered().order_by(None).with_entities(func.count(BizMaterialStockBatch.id)).scalar() or 0
page = max(1, page)
page_size = min(max(1, page_size), 100)
rows = (
_filtered()
.order_by(
BizMaterialStockBatch.stock_in_date.desc(),
BizMaterialStockBatch.create_time.desc(),
)
.offset((page - 1) * page_size)
.limit(page_size)
.all()
)
return [_batch_row_to_dict(b, m) for b, m in rows], int(total)
def batch_options(
db: Session,
tenant_no: str,
*,
keyword: Optional[str] = None,
material_id: Optional[str] = None,
only_available: bool = True,
) -> List[Dict[str, Any]]:
q = (
db.query(BizMaterialStockBatch, BizMaterial)
.join(BizMaterial, BizMaterial.id == BizMaterialStockBatch.material_id)
.filter(
BizMaterialStockBatch.tenant_no == tenant_no,
BizMaterialStockBatch.del_flag == 0,
BizMaterial.del_flag == 0,
BizMaterial.status == "1",
)
)
if only_available:
q = q.filter(BizMaterialStockBatch.remaining_qty > 0)
if material_id:
q = q.filter(BizMaterialStockBatch.material_id == material_id)
kw = (keyword or "").strip()
if kw:
like = f"%{kw}%"
q = q.filter(
or_(
BizMaterialStockBatch.stock_in_no.like(like),
BizMaterialStockBatch.material_name.like(like),
BizMaterialStockBatch.material_code.like(like),
BizMaterialStockBatch.batch_no.like(like),
BizMaterialStockBatch.catalog_no.like(like),
)
)
rows = q.order_by(BizMaterialStockBatch.stock_in_date.asc()).all()
out: List[Dict[str, Any]] = []
for b, m in rows:
unit = b.unit or ""
rem = _dec(b.remaining_qty)
mfr = (b.manufacturer or "").strip()
cat = (b.catalog_no or "").strip()
label = (
f"{b.stock_in_no} / {b.material_name}"
f" / 厂家:{mfr or '—'}"
f" / 批号:{b.batch_no or '—'}"
f" / 货号:{cat or '—'}"
f" / 剩:{rem}{unit}"
)
unit_price = float(b.unit_price) if b.unit_price is not None else 0
out.append(
{
"id": b.id,
"batchId": b.id,
"stockInNo": b.stock_in_no or "",
"stockInDate": _fmt_date(b.stock_in_date),
"expireDate": _fmt_date(b.expire_date),
"materialId": b.material_id,
"materialCode": b.material_code or "",
"materialName": b.material_name or "",
"specModel": b.spec_model or "",
"unit": unit,
"batchNo": b.batch_no or "",
"catalogNo": b.catalog_no or "",
"manufacturer": b.manufacturer or "",
"unitPrice": unit_price,
"amount": float(b.amount) if b.amount is not None else 0,
"remainingQty": rem,
"label": label,
}
)
return out
def _create_batch_and_usage(
db: Session,
*,
material: BizMaterial,
stock_in_no: str,
stock_in_date: date,
expire_date: date,
catalog_no: str,
batch_no: str,
manufacturer: str,
unit_price: Decimal,
amount: Decimal,
qty: Decimal,
remark: Optional[str],
tenant_no: str,
user_id: Optional[str],
operate_time: datetime,
commit: bool = False,
) -> BizMaterialStockBatch:
if qty <= 0:
raise ValueError("入库数量必须大于0")
sno = _require_str(stock_in_no, "入库编号")
if stock_in_no_exists(db, sno, tenant_no):
raise ValueError(f"入库编号「{sno}」已存在")
if not _is_enabled_status(material.status):
raise ValueError(f"物料「{material.material_name}」已停用,无法入库")
old_stock = material.stock_qty or Decimal("0")
new_stock = old_stock + qty
material.stock_qty = new_stock
material.update_by = user_id
material.update_time = datetime.now()
db.add(material)
batch = BizMaterialStockBatch(
id=generate_uuid(),
material_id=material.id,
material_code=material.material_code,
material_name=material.material_name,
spec_model=material.spec_model,
unit=material.unit,
stock_in_no=sno,
stock_in_date=stock_in_date,
expire_date=expire_date,
catalog_no=catalog_no,
batch_no=batch_no,
manufacturer=manufacturer,
unit_price=unit_price,
amount=amount,
in_qty=qty,
remaining_qty=qty,
tenant_no=tenant_no,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id=material.create_dept_id or "",
create_time=operate_time,
update_by=user_id,
update_time=operate_time,
del_flag=0,
)
db.add(batch)
snaps = _usage_batch_snapshots(batch)
usage = BizMaterialUsage(
id=generate_uuid(),
material_id=material.id,
material_code=material.material_code,
material_name=material.material_name,
change_type="in",
change_qty=qty,
stock_before=old_stock,
stock_after=new_stock,
source_type="manual_in",
tenant_no=tenant_no,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id=material.create_dept_id or "",
create_time=operate_time,
update_by=user_id,
update_time=operate_time,
del_flag=0,
**snaps,
)
db.add(usage)
if commit:
db.commit()
db.refresh(batch)
return batch
def stock_in_one(
db: Session,
material_id: str,
*,
stock_in_no: str,
stock_in_date: Any,
expire_date: Any,
catalog_no: str,
batch_no: str,
manufacturer: str,
unit_price: Any,
amount: Any,
qty: Decimal,
remark: Optional[str] = None,
tenant_no: str,
user_id: Optional[str] = None,
operate_time: Optional[datetime] = None,
) -> BizMaterialStockBatch:
op_time = operate_time or datetime.now()
material = _get_material_for_update(db, material_id, tenant_no)
batch = _create_batch_and_usage(
db,
material=material,
stock_in_no=stock_in_no,
stock_in_date=_parse_date(stock_in_date),
expire_date=_parse_expire_date(expire_date),
catalog_no=_require_str(catalog_no, "货号"),
batch_no=_require_str(batch_no, "批号"),
manufacturer=_require_str(manufacturer, "厂家"),
unit_price=_require_decimal(unit_price, "单价"),
amount=_require_decimal(amount, "金额"),
qty=qty,
remark=remark,
tenant_no=tenant_no,
user_id=user_id,
operate_time=op_time,
commit=True,
)
return batch
def batch_stock_in(
db: Session,
*,
items: List[Dict[str, Any]],
remark: Optional[str] = None,
tenant_no: str,
user_id: Optional[str] = None,
operate_time: Optional[datetime] = None,
) -> int:
if not items:
raise ValueError("请至少添加一条入库明细")
op_time = operate_time or datetime.now()
shared_remark = (remark or "").strip() or None
seen_nos: set = set()
try:
for it in items:
material_id = (it.get("material_id") or it.get("materialId") or "").strip()
if not material_id:
raise ValueError("请选择物资")
sno = _require_str(it.get("stock_in_no") or it.get("stockInNo"), "入库编号")
if sno in seen_nos:
raise ValueError(f"入库编号「{sno}」在本单中重复")
seen_nos.add(sno)
qty = it.get("qty")
if qty is None or Decimal(str(qty)) <= 0:
raise ValueError("入库数量必须大于0")
qty_dec = Decimal(str(qty))
line_remark = (it.get("remark") or "").strip() or shared_remark
material = _get_material_for_update(db, material_id, tenant_no)
_create_batch_and_usage(
db,
material=material,
stock_in_no=sno,
stock_in_date=_parse_date(it.get("stock_in_date") or it.get("stockInDate")),
expire_date=_parse_expire_date(it.get("expire_date") or it.get("expireDate")),
catalog_no=_require_str(it.get("catalog_no") or it.get("catalogNo"), "货号"),
batch_no=_require_str(it.get("batch_no") or it.get("batchNo"), "批号"),
manufacturer=_require_str(it.get("manufacturer"), "厂家"),
unit_price=_require_decimal(it.get("unit_price") or it.get("unitPrice"), "单价"),
amount=_require_decimal(it.get("amount"), "金额"),
qty=qty_dec,
remark=line_remark,
tenant_no=tenant_no,
user_id=user_id,
operate_time=op_time,
commit=False,
)
db.commit()
return len(items)
except Exception:
db.rollback()
raise
def _stock_out_batch(
db: Session,
batch_id: str,
*,
qty: Decimal,
receiver: Optional[str],
purpose: Optional[str],
remark: Optional[str],
usage_unit: Optional[str] = None,
tenant_no: str,
user_id: Optional[str],
operate_time: datetime,
) -> None:
if qty <= 0:
raise ValueError("出库数量必须大于0")
if not (receiver or "").strip():
raise ValueError("请选择领用人")
batch = (
db.query(BizMaterialStockBatch)
.filter(
BizMaterialStockBatch.id == batch_id,
BizMaterialStockBatch.tenant_no == tenant_no,
BizMaterialStockBatch.del_flag == 0,
)
.with_for_update()
.first()
)
if not batch:
raise ValueError("入库批次不存在")
material = _get_material_for_update(db, batch.material_id, tenant_no)
if not _is_enabled_status(material.status):
raise ValueError(f"物料「{material.material_name}」已停用,无法出库")
rem = batch.remaining_qty or Decimal("0")
if rem < qty:
raise ValueError(
f"批次「{batch.stock_in_no}」库存不足,当前剩余 {rem},需出库 {qty}"
)
batch.remaining_qty = rem - qty
batch.update_by = user_id
batch.update_time = datetime.now()
db.add(batch)
stock_before = material.stock_qty or Decimal("0")
new_stock = stock_before - qty
material.stock_qty = new_stock
material.update_by = user_id
material.update_time = datetime.now()
db.add(material)
snaps = _usage_batch_snapshots(batch, out_qty=qty)
unit_label = (usage_unit or "").strip() or (batch.unit or "").strip() or None
usage = BizMaterialUsage(
id=generate_uuid(),
material_id=material.id,
material_code=material.material_code,
material_name=material.material_name,
change_type="use",
change_qty=-qty,
usage_unit=unit_label,
stock_before=stock_before,
stock_after=new_stock,
source_type="manual_out",
tenant_no=tenant_no,
receiver=(receiver or "").strip() or None,
purpose=(purpose or "").strip() or None,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id=material.create_dept_id or "",
create_time=operate_time,
update_by=user_id,
update_time=operate_time,
del_flag=0,
**snaps,
)
db.add(usage)
def batch_stock_out(
db: Session,
*,
items: List[Dict[str, Any]],
receiver: Optional[str] = None,
purpose: Optional[str] = None,
remark: Optional[str] = None,
tenant_no: str,
user_id: Optional[str] = None,
operate_time: Optional[datetime] = None,
) -> int:
if not items:
raise ValueError("请至少添加一条出库明细")
op_time = operate_time or datetime.now()
shared_remark = (remark or "").strip() or None
seen_batches: set = set()
try:
for it in items:
batch_id = (it.get("batch_id") or it.get("batchId") or "").strip()
if not batch_id:
raise ValueError("请选择入库批次")
if batch_id in seen_batches:
raise ValueError("同一入库批次不可重复添加")
seen_batches.add(batch_id)
qty = it.get("qty")
if qty is None or Decimal(str(qty)) <= 0:
raise ValueError("出库数量必须大于0")
qty_dec = Decimal(str(qty))
line_remark = (it.get("remark") or "").strip() or shared_remark
usage_unit = (it.get("usageUnit") or it.get("usage_unit") or "").strip() or None
_stock_out_batch(
db,
batch_id,
qty=qty_dec,
receiver=receiver,
purpose=purpose,
remark=line_remark,
usage_unit=usage_unit,
tenant_no=tenant_no,
user_id=user_id,
operate_time=op_time,
)
db.commit()
return len(items)
except Exception:
db.rollback()
raise
DISCARD_REASONS = frozenset({"过期", "质量问题", "污染/破损", "其他"})
def _validate_discard_reason(discard_reason: Optional[str], remark: Optional[str]) -> str:
reason = (discard_reason or "").strip()
if reason not in DISCARD_REASONS:
raise ValueError("请选择有效的废弃原因")
if reason == "其他" and not (remark or "").strip():
raise ValueError("选择「其他」时请填写备注说明")
return reason
def _discard_batch(
db: Session,
batch_id: str,
*,
qty: Decimal,
discard_reason: str,
remark: Optional[str],
usage_unit: Optional[str] = None,
tenant_no: str,
user_id: Optional[str],
operate_time: datetime,
) -> None:
if qty <= 0:
raise ValueError("废弃数量必须大于0")
batch = (
db.query(BizMaterialStockBatch)
.filter(
BizMaterialStockBatch.id == batch_id,
BizMaterialStockBatch.tenant_no == tenant_no,
BizMaterialStockBatch.del_flag == 0,
)
.with_for_update()
.first()
)
if not batch:
raise ValueError("入库批次不存在")
material = _get_material_for_update(db, batch.material_id, tenant_no)
if not _is_enabled_status(material.status):
raise ValueError(f"物料「{material.material_name}」已停用,无法废弃")
rem = batch.remaining_qty or Decimal("0")
if rem < qty:
raise ValueError(
f"批次「{batch.stock_in_no}」库存不足,当前剩余 {rem},需废弃 {qty}"
)
batch.remaining_qty = rem - qty
batch.update_by = user_id
batch.update_time = datetime.now()
db.add(batch)
stock_before = material.stock_qty or Decimal("0")
new_stock = stock_before - qty
material.stock_qty = new_stock
material.update_by = user_id
material.update_time = datetime.now()
db.add(material)
snaps = _usage_batch_snapshots(batch, out_qty=qty)
unit_label = (usage_unit or "").strip() or (batch.unit or "").strip() or None
usage = BizMaterialUsage(
id=generate_uuid(),
material_id=material.id,
material_code=material.material_code,
material_name=material.material_name,
change_type="discard",
change_qty=-qty,
usage_unit=unit_label,
stock_before=stock_before,
stock_after=new_stock,
source_type="manual_discard",
tenant_no=tenant_no,
purpose=discard_reason,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id=material.create_dept_id or "",
create_time=operate_time,
update_by=user_id,
update_time=operate_time,
del_flag=0,
**snaps,
)
db.add(usage)
def batch_discard(
db: Session,
*,
items: List[Dict[str, Any]],
discard_reason: Optional[str] = None,
remark: Optional[str] = None,
tenant_no: str,
user_id: Optional[str] = None,
operate_time: Optional[datetime] = None,
) -> int:
if not items:
raise ValueError("请至少添加一条废弃明细")
op_time = operate_time or datetime.now()
shared_remark = (remark or "").strip() or None
reason = _validate_discard_reason(discard_reason, shared_remark)
seen_batches: set = set()
try:
for it in items:
batch_id = (it.get("batch_id") or it.get("batchId") or "").strip()
if not batch_id:
raise ValueError("请选择入库批次")
if batch_id in seen_batches:
raise ValueError("同一入库批次不可重复添加")
seen_batches.add(batch_id)
qty = it.get("qty")
if qty is None or Decimal(str(qty)) <= 0:
raise ValueError("废弃数量必须大于0")
qty_dec = Decimal(str(qty))
line_remark = (it.get("remark") or "").strip() or shared_remark
if reason == "其他" and not line_remark:
raise ValueError("选择「其他」时请填写备注说明")
usage_unit = (it.get("usageUnit") or it.get("usage_unit") or "").strip() or None
_discard_batch(
db,
batch_id,
qty=qty_dec,
discard_reason=reason,
remark=line_remark,
usage_unit=usage_unit,
tenant_no=tenant_no,
user_id=user_id,
operate_time=op_time,
)
db.commit()
return len(items)
except Exception:
db.rollback()
raise
def get_batch(db: Session, batch_id: str, tenant_no: str) -> Optional[BizMaterialStockBatch]:
return (
db.query(BizMaterialStockBatch)
.filter(
BizMaterialStockBatch.id == batch_id,
BizMaterialStockBatch.tenant_no == tenant_no,
BizMaterialStockBatch.del_flag == 0,
)
.first()
)
def update_batch(
db: Session,
batch_id: str,
*,
tenant_no: str,
user_id: Optional[str] = None,
stock_in_no: Optional[str] = None,
stock_in_date: Optional[Any] = None,
expire_date: Optional[Any] = None,
catalog_no: Optional[str] = None,
batch_no: Optional[str] = None,
manufacturer: Optional[str] = None,
unit_price: Optional[Any] = None,
amount: Optional[Any] = None,
remark: Optional[str] = None,
material_code: Optional[str] = None,
material_name: Optional[str] = None,
spec_model: Optional[str] = None,
unit: Optional[str] = None,
warning_qty: Optional[Any] = None,
status: Optional[str] = None,
) -> BizMaterialStockBatch:
from app.crud import material as mat_svc
batch = get_batch(db, batch_id, tenant_no)
if not batch:
raise ValueError("入库批次不存在")
material = _get_material_for_update(db, batch.material_id, tenant_no)
mat_data: Dict[str, Any] = {}
if material_code is not None:
mat_data["material_code"] = material_code
if material_name is not None:
mat_data["material_name"] = material_name
if spec_model is not None:
mat_data["spec_model"] = spec_model
if unit is not None:
mat_data["unit"] = unit
if warning_qty is not None:
mat_data["warning_qty"] = Decimal(str(warning_qty))
if status is not None:
mat_data["status"] = _norm_status(status)
if mat_data:
material = mat_svc.update_material_fields(
db,
batch.material_id,
tenant_no=tenant_no,
user_id=user_id,
**mat_data,
)
if stock_in_no is not None:
sno = _require_str(stock_in_no, "入库编号")
if stock_in_no_exists(db, sno, tenant_no, exclude_id=batch_id):
raise ValueError(f"入库编号「{sno}」已存在")
batch.stock_in_no = sno
if stock_in_date is not None:
batch.stock_in_date = _parse_date(stock_in_date)
if expire_date is not None:
batch.expire_date = _parse_expire_date(expire_date)
if catalog_no is not None:
batch.catalog_no = _require_str(catalog_no, "货号")
if batch_no is not None:
batch.batch_no = _require_str(batch_no, "批号")
if manufacturer is not None:
batch.manufacturer = _require_str(manufacturer, "厂家")
if unit_price is not None:
batch.unit_price = _require_decimal(unit_price, "单价")
if amount is not None:
batch.amount = _require_decimal(amount, "金额")
if remark is not None:
batch.remark = (remark or "").strip() or None
batch.material_code = material.material_code
batch.material_name = material.material_name
batch.spec_model = material.spec_model
batch.unit = material.unit
batch.update_by = user_id
batch.update_time = datetime.now()
db.add(batch)
in_usage = (
db.query(BizMaterialUsage)
.filter(
BizMaterialUsage.batch_id == batch_id,
BizMaterialUsage.tenant_no == tenant_no,
BizMaterialUsage.del_flag == 0,
BizMaterialUsage.change_type == "in",
BizMaterialUsage.source_type == "manual_in",
)
.first()
)
if in_usage:
in_usage.material_code = material.material_code
in_usage.material_name = material.material_name
in_usage.stock_in_no = batch.stock_in_no
in_usage.catalog_no = batch.catalog_no
in_usage.batch_no = batch.batch_no
in_usage.manufacturer = batch.manufacturer
in_usage.unit_price = batch.unit_price
in_usage.amount = batch.amount
in_usage.remark = batch.remark
in_usage.update_by = user_id
in_usage.update_time = datetime.now()
db.add(in_usage)
db.commit()
db.refresh(batch)
return batch
def delete_batch(
db: Session,
batch_id: str,
*,
tenant_no: str,
user_id: Optional[str] = None,
) -> None:
batch = get_batch(db, batch_id, tenant_no)
if not batch:
raise ValueError("入库批次不存在")
used = (
db.query(BizMaterialUsage)
.filter(
BizMaterialUsage.batch_id == batch_id,
BizMaterialUsage.tenant_no == tenant_no,
BizMaterialUsage.del_flag == 0,
BizMaterialUsage.change_type == "use",
)
.count()
)
if used > 0:
raise ValueError("该批次已有领用或出库记录,无法删除")
material = _get_material_for_update(db, batch.material_id, tenant_no)
rem = batch.remaining_qty or Decimal("0")
material.stock_qty = (material.stock_qty or Decimal("0")) - rem
material.update_by = user_id
material.update_time = datetime.now()
db.add(material)
now = datetime.now()
batch.del_flag = 1
batch.update_by = user_id
batch.update_time = now
db.add(batch)
usages = (
db.query(BizMaterialUsage)
.filter(
BizMaterialUsage.batch_id == batch_id,
BizMaterialUsage.tenant_no == tenant_no,
BizMaterialUsage.del_flag == 0,
)
.all()
)
for u in usages:
u.del_flag = 1
u.update_by = user_id
u.update_time = now
db.add(u)
db.commit()
+472
View File
@@ -0,0 +1,472 @@
"""市场物料库存盘点 CRUD"""
from __future__ import annotations
from datetime import datetime
from decimal import Decimal
from typing import Any, Dict, List, Optional, Tuple
from sqlalchemy import func, or_
from sqlalchemy.orm import Session
from app.core.utils import generate_uuid
from app.crud.material_stock_batch import _dec, _fmt_date, _fmt_dt, _parse_date, _require_str
from app.models.models import SysUser
from app.models.material import (
BizMaterialStockBatch,
BizMaterialStockCheck,
BizMaterialStockCheckBatchLine,
BizMaterialStockCheckUnusedLine,
)
def _user_nick_name_map(db: Session, user_ids: List[str]) -> Dict[str, str]:
ids = list({x for x in user_ids if x})
if not ids:
return {}
rows = db.query(SysUser.id, SysUser.nick_name).filter(SysUser.id.in_(ids)).all()
return {u.id: (u.nick_name or "").strip() for u in rows}
def _status_label(status: str) -> str:
if status == "completed":
return "已完成"
if status == "cancelled":
return "已作废"
return "进行中"
def _batch_line_to_dict(row: BizMaterialStockCheckBatchLine) -> Dict[str, Any]:
return {
"id": row.id,
"checkId": row.check_id,
"batchId": row.batch_id,
"materialId": row.material_id,
"materialCode": row.material_code or "",
"materialName": row.material_name or "",
"specModel": row.spec_model or "",
"unit": row.unit or "",
"stockInNo": row.stock_in_no or "",
"stockInDate": _fmt_date(row.stock_in_date),
"expireDate": _fmt_date(row.expire_date),
"catalogNo": row.catalog_no or "",
"batchNo": row.batch_no or "",
"manufacturer": row.manufacturer or "",
"unitPrice": float(row.unit_price) if row.unit_price is not None else 0,
"amount": float(row.amount) if row.amount is not None else 0,
"remainingQty": _dec(row.remaining_qty),
"remainingAmount": _unused_amount(row.unit_price, row.remaining_qty),
"remark": row.remark or "",
}
def _unused_amount(unit_price: Any, qty: Any) -> float:
if unit_price is None:
return 0
return float((Decimal(str(unit_price)) * Decimal(str(qty))).quantize(Decimal("0.01")))
def _unused_line_to_dict(row: BizMaterialStockCheckUnusedLine) -> Dict[str, Any]:
unit_price = float(row.unit_price) if row.unit_price is not None else None
unused_qty = _dec(row.unused_qty)
return {
"id": row.id,
"checkId": row.check_id,
"materialCode": row.material_code or "",
"materialName": row.material_name or "",
"specModel": row.spec_model or "",
"unit": row.unit or "",
"stockInNo": row.stock_in_no or "",
"stockInDate": _fmt_date(row.stock_in_date),
"expireDate": _fmt_date(row.expire_date),
"catalogNo": row.catalog_no or "",
"batchNo": row.batch_no or "",
"manufacturer": row.manufacturer or "",
"unitPrice": unit_price,
"remainingAmount": _unused_amount(row.unit_price, row.unused_qty) if unit_price is not None else None,
"holder": row.holder or "",
"unusedQty": unused_qty,
"remark": row.remark or "",
}
def _check_header_to_dict(
row: BizMaterialStockCheck,
*,
create_by_name: str = "",
batch_line_count: int = 0,
unused_line_count: int = 0,
) -> Dict[str, Any]:
return {
"id": row.id,
"title": row.title or "",
"checkTime": _fmt_dt(row.check_time),
"status": row.status or "draft",
"statusLabel": _status_label(row.status or "draft"),
"completeTime": _fmt_dt(row.complete_time) if row.complete_time else "",
"remark": row.remark or "",
"batchLineCount": batch_line_count,
"unusedLineCount": unused_line_count,
"createBy": row.create_by or "",
"createByName": create_by_name or row.create_by or "",
"createTime": _fmt_dt(row.create_time),
"updateTime": _fmt_dt(row.update_time),
}
def _get_check(db: Session, check_id: str, tenant_no: str) -> Optional[BizMaterialStockCheck]:
return (
db.query(BizMaterialStockCheck)
.filter(
BizMaterialStockCheck.id == check_id,
BizMaterialStockCheck.tenant_no == tenant_no,
BizMaterialStockCheck.del_flag == 0,
)
.first()
)
def _line_counts(db: Session, check_ids: List[str]) -> Dict[str, Tuple[int, int]]:
if not check_ids:
return {}
batch_rows = (
db.query(
BizMaterialStockCheckBatchLine.check_id,
func.count(BizMaterialStockCheckBatchLine.id),
)
.filter(
BizMaterialStockCheckBatchLine.check_id.in_(check_ids),
BizMaterialStockCheckBatchLine.del_flag == 0,
)
.group_by(BizMaterialStockCheckBatchLine.check_id)
.all()
)
unused_rows = (
db.query(
BizMaterialStockCheckUnusedLine.check_id,
func.count(BizMaterialStockCheckUnusedLine.id),
)
.filter(
BizMaterialStockCheckUnusedLine.check_id.in_(check_ids),
BizMaterialStockCheckUnusedLine.del_flag == 0,
)
.group_by(BizMaterialStockCheckUnusedLine.check_id)
.all()
)
batch_map = {cid: int(cnt) for cid, cnt in batch_rows}
unused_map = {cid: int(cnt) for cid, cnt in unused_rows}
out: Dict[str, Tuple[int, int]] = {}
for cid in check_ids:
out[cid] = (batch_map.get(cid, 0), unused_map.get(cid, 0))
return out
def list_checks(
db: Session,
tenant_no: str,
*,
page: int = 1,
page_size: int = 10,
keyword: Optional[str] = None,
status: Optional[str] = None,
start_time: Optional[str] = None,
end_time: Optional[str] = None,
user_info=None,
) -> Tuple[List[Dict[str, Any]], int]:
def _filtered():
q0 = db.query(BizMaterialStockCheck).filter(
BizMaterialStockCheck.tenant_no == tenant_no,
BizMaterialStockCheck.del_flag == 0,
)
kw = (keyword or "").strip()
if kw:
q0 = q0.filter(BizMaterialStockCheck.title.like(f"%{kw}%"))
st = (status or "").strip()
if st:
q0 = q0.filter(BizMaterialStockCheck.status == st)
if start_time:
q0 = q0.filter(BizMaterialStockCheck.check_time >= start_time)
if end_time:
q0 = q0.filter(BizMaterialStockCheck.check_time <= end_time + " 23:59:59")
if user_info:
from app.core.data_scope import apply_data_scope
q0 = apply_data_scope(q0, BizMaterialStockCheck, user_info, db, tenant_no)
return q0
total = _filtered().order_by(None).with_entities(func.count(BizMaterialStockCheck.id)).scalar() or 0
page = max(1, page)
page_size = min(max(1, page_size), 100)
rows = (
_filtered()
.order_by(BizMaterialStockCheck.check_time.desc(), BizMaterialStockCheck.create_time.desc())
.offset((page - 1) * page_size)
.limit(page_size)
.all()
)
ids = [r.id for r in rows]
counts = _line_counts(db, ids)
name_map = _user_nick_name_map(db, [r.create_by for r in rows if r.create_by])
items = []
for r in rows:
bc, uc = counts.get(r.id, (0, 0))
items.append(
_check_header_to_dict(
r,
create_by_name=name_map.get(r.create_by or "", ""),
batch_line_count=bc,
unused_line_count=uc,
)
)
return items, int(total)
def get_check_detail(db: Session, check_id: str, tenant_no: str) -> Dict[str, Any]:
row = _get_check(db, check_id, tenant_no)
if not row:
raise ValueError("盘点单不存在")
bc, uc = _line_counts(db, [check_id]).get(check_id, (0, 0))
name_map = _user_nick_name_map(db, [row.create_by] if row.create_by else [])
batch_lines = (
db.query(BizMaterialStockCheckBatchLine)
.filter(
BizMaterialStockCheckBatchLine.check_id == check_id,
BizMaterialStockCheckBatchLine.del_flag == 0,
)
.order_by(BizMaterialStockCheckBatchLine.stock_in_no.asc())
.all()
)
unused_lines = (
db.query(BizMaterialStockCheckUnusedLine)
.filter(
BizMaterialStockCheckUnusedLine.check_id == check_id,
BizMaterialStockCheckUnusedLine.del_flag == 0,
)
.order_by(BizMaterialStockCheckUnusedLine.create_time.asc())
.all()
)
data = _check_header_to_dict(
row,
create_by_name=name_map.get(row.create_by or "", ""),
batch_line_count=bc,
unused_line_count=uc,
)
data["batchLines"] = [_batch_line_to_dict(x) for x in batch_lines]
data["unusedLines"] = [_unused_line_to_dict(x) for x in unused_lines]
return data
def _parse_check_time(v: Any) -> datetime:
if isinstance(v, datetime):
return v
s = str(v or "").strip()
if not s:
return datetime.now()
for fmt, length in (("%Y-%m-%d %H:%M:%S", 19), ("%Y-%m-%d", 10)):
try:
return datetime.strptime(s[:length], fmt)
except ValueError:
continue
raise ValueError("盘点时间格式无效")
def create_check(
db: Session,
*,
title: str,
tenant_no: str,
user_id: Optional[str] = None,
dept_id: str = "",
check_time: Optional[Any] = None,
remark: Optional[str] = None,
) -> Dict[str, Any]:
t = _require_str(title, "盘点标题")
op_time = datetime.now()
ck_time = _parse_check_time(check_time) if check_time else op_time
check = BizMaterialStockCheck(
id=generate_uuid(),
title=t,
check_time=ck_time,
status="draft",
tenant_no=tenant_no,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id=dept_id or "",
create_time=op_time,
update_by=user_id,
update_time=op_time,
del_flag=0,
)
db.add(check)
batches = (
db.query(BizMaterialStockBatch)
.filter(
BizMaterialStockBatch.tenant_no == tenant_no,
BizMaterialStockBatch.del_flag == 0,
BizMaterialStockBatch.remaining_qty > 0,
)
.order_by(BizMaterialStockBatch.stock_in_date.desc(), BizMaterialStockBatch.create_time.desc())
.all()
)
for b in batches:
line = BizMaterialStockCheckBatchLine(
id=generate_uuid(),
check_id=check.id,
batch_id=b.id,
material_id=b.material_id,
material_code=b.material_code,
material_name=b.material_name,
spec_model=b.spec_model,
unit=b.unit,
stock_in_no=b.stock_in_no,
stock_in_date=b.stock_in_date,
expire_date=b.expire_date,
catalog_no=b.catalog_no,
batch_no=b.batch_no,
manufacturer=b.manufacturer,
unit_price=b.unit_price,
amount=b.amount,
remaining_qty=b.remaining_qty,
tenant_no=tenant_no,
create_by=user_id,
create_dept_id=dept_id or "",
create_time=op_time,
update_by=user_id,
update_time=op_time,
del_flag=0,
)
db.add(line)
db.commit()
db.refresh(check)
return {
"id": check.id,
"batchLineCount": len(batches),
}
def _parse_optional_date(v: Any) -> Optional[Any]:
if v is None or str(v).strip() == "":
return None
return _parse_date(v, label="日期")
def save_unused_lines(
db: Session,
check_id: str,
*,
items: List[Dict[str, Any]],
tenant_no: str,
user_id: Optional[str] = None,
dept_id: str = "",
) -> int:
check = _get_check(db, check_id, tenant_no)
if not check:
raise ValueError("盘点单不存在")
if (check.status or "") != "draft":
raise ValueError("仅进行中的盘点单可登记未用完物料")
now = datetime.now()
old_rows = (
db.query(BizMaterialStockCheckUnusedLine)
.filter(
BizMaterialStockCheckUnusedLine.check_id == check_id,
BizMaterialStockCheckUnusedLine.del_flag == 0,
)
.all()
)
for r in old_rows:
r.del_flag = 1
r.update_by = user_id
r.update_time = now
db.add(r)
count = 0
for it in items or []:
name = _require_str(it.get("material_name") or it.get("materialName"), "物料名称")
qty = it.get("unused_qty") if it.get("unused_qty") is not None else it.get("unusedQty")
if qty is None or Decimal(str(qty)) <= 0:
raise ValueError("未用完数量必须大于0")
qty_dec = Decimal(str(qty))
stock_in_date = _parse_optional_date(it.get("stock_in_date") or it.get("stockInDate"))
expire_date = _parse_optional_date(it.get("expire_date") or it.get("expireDate"))
row = BizMaterialStockCheckUnusedLine(
id=generate_uuid(),
check_id=check_id,
material_code=(it.get("material_code") or it.get("materialCode") or "").strip() or None,
material_name=name,
spec_model=(it.get("spec_model") or it.get("specModel") or "").strip() or None,
unit=(it.get("unit") or "").strip() or None,
stock_in_no=(it.get("stock_in_no") or it.get("stockInNo") or "").strip() or None,
stock_in_date=stock_in_date,
expire_date=expire_date,
catalog_no=(it.get("catalog_no") or it.get("catalogNo") or "").strip() or None,
batch_no=(it.get("batch_no") or it.get("batchNo") or "").strip() or None,
manufacturer=(it.get("manufacturer") or "").strip() or None,
unit_price=(
Decimal(str(it.get("unit_price") or it.get("unitPrice")))
if (it.get("unit_price") is not None or it.get("unitPrice") is not None)
else None
),
holder=(it.get("holder") or "").strip() or None,
unused_qty=qty_dec,
tenant_no=tenant_no,
remark=(it.get("remark") or "").strip() or None,
create_by=user_id,
create_dept_id=dept_id or "",
create_time=now,
update_by=user_id,
update_time=now,
del_flag=0,
)
db.add(row)
count += 1
check.update_by = user_id
check.update_time = now
db.add(check)
db.commit()
return count
def complete_check(
db: Session,
check_id: str,
*,
tenant_no: str,
user_id: Optional[str] = None,
) -> None:
check = _get_check(db, check_id, tenant_no)
if not check:
raise ValueError("盘点单不存在")
if (check.status or "") != "draft":
raise ValueError("仅进行中的盘点单可完成")
now = datetime.now()
check.status = "completed"
check.complete_time = now
check.update_by = user_id
check.update_time = now
db.add(check)
db.commit()
def cancel_check(
db: Session,
check_id: str,
*,
tenant_no: str,
user_id: Optional[str] = None,
) -> None:
check = _get_check(db, check_id, tenant_no)
if not check:
raise ValueError("盘点单不存在")
if (check.status or "") != "draft":
raise ValueError("仅进行中的盘点单可作废")
now = datetime.now()
check.status = "cancelled"
check.update_by = user_id
check.update_time = now
db.add(check)
db.commit()
+279
View File
@@ -0,0 +1,279 @@
"""市场物料变动记录 CRUD"""
from __future__ import annotations
from typing import Any, Dict, List, Optional, Tuple
from sqlalchemy import func, or_
from sqlalchemy.orm import Session
from app.models.material import BizMaterialStockBatch, BizMaterialUsage
from app.models.models import SysUser
def _parse_receiver_purpose_from_remark(remark: Optional[str]) -> Tuple[str, str]:
receiver, purpose = "", ""
for part in (remark or "").split(";"):
seg = part.strip()
if seg.startswith("领用人:"):
receiver = seg[len("领用人:") :].strip()
elif seg.startswith("用途:"):
purpose = seg[len("用途:") :].strip()
return receiver, purpose
def _resolve_receiver_purpose(r: BizMaterialUsage) -> Tuple[str, str]:
receiver = (getattr(r, "receiver", None) or "").strip()
purpose = (getattr(r, "purpose", None) or "").strip()
if receiver or purpose:
return receiver, purpose
if (r.source_type or "") == "manual_out":
return _parse_receiver_purpose_from_remark(r.remark)
return "", ""
def _display_remark(r: BizMaterialUsage) -> str:
remark = (r.remark or "").strip()
if (r.source_type or "") != "manual_out" or not remark:
return remark
parts: List[str] = []
for part in remark.split(";"):
seg = part.strip()
if not seg or seg.startswith("领用人:") or seg.startswith("用途:"):
continue
if seg.startswith("备注"):
seg = seg[2:].strip() or seg
parts.append(seg)
return ";".join(parts) if parts else ""
def _user_nick_name_map(db: Session, user_ids: List[str]) -> Dict[str, str]:
ids = list({x for x in user_ids if x})
if not ids:
return {}
rows = db.query(SysUser.id, SysUser.nick_name).filter(SysUser.id.in_(ids)).all()
return {u.id: (u.nick_name or "").strip() for u in rows}
def _receiver_display_map(db: Session, receivers: List[str]) -> Dict[str, str]:
keys = list({(x or "").strip() for x in receivers if (x or "").strip()})
if not keys:
return {}
by_id = _user_nick_name_map(db, keys)
out: Dict[str, str] = {}
for k in keys:
out[k] = by_id.get(k) or k
return out
def _usage_unit_label(r: BizMaterialUsage, batch: Optional[BizMaterialStockBatch]) -> str:
u = (getattr(r, "usage_unit", None) or "").strip()
if u:
return u
if batch and (batch.unit or "").strip():
return (batch.unit or "").strip()
return ""
def _stock_in_date_for_row(r: BizMaterialUsage, batch: Optional[BizMaterialStockBatch]) -> str:
if batch and batch.stock_in_date:
return batch.stock_in_date.strftime("%Y-%m-%d")
return ""
def _unit_price_for_row(r: BizMaterialUsage, batch: Optional[BizMaterialStockBatch]) -> Optional[float]:
if r.unit_price is not None:
return float(r.unit_price)
if batch and batch.unit_price is not None:
return float(batch.unit_price)
return None
def _amount_for_row(r: BizMaterialUsage, batch: Optional[BizMaterialStockBatch]) -> Optional[float]:
is_in = (r.change_type or "") == "in"
if is_in:
if r.amount is not None:
return float(r.amount)
if batch and batch.amount is not None:
return float(batch.amount)
return None
unit_price = _unit_price_for_row(r, batch)
change_qty = float(r.change_qty) if r.change_qty is not None else 0
qty = abs(change_qty)
if unit_price is None or qty <= 0:
return None
return round(unit_price * qty, 2)
def _row_to_dict(
r: BizMaterialUsage,
*,
create_by_name: str = "",
batch: Optional[BizMaterialStockBatch] = None,
receiver_name: str = "",
) -> Dict[str, Any]:
create_by = r.create_by or ""
receiver, purpose = _resolve_receiver_purpose(r)
create_time = r.create_time.strftime("%Y-%m-%d %H:%M:%S") if r.create_time else ""
is_manual_out = (r.source_type or "") == "manual_out"
stock_after = float(r.stock_after) if r.stock_after is not None else 0
change_qty = float(r.change_qty) if r.change_qty is not None else 0
stock_before = (
float(r.stock_before)
if r.stock_before is not None
else stock_after - change_qty
)
usage_unit = _usage_unit_label(r, batch)
return {
"id": r.id,
"materialId": r.material_id,
"materialCode": r.material_code or "",
"materialName": r.material_name or "",
"batchId": r.batch_id or "",
"stockInNo": r.stock_in_no or "",
"stockInDate": _stock_in_date_for_row(r, batch),
"catalogNo": r.catalog_no or "",
"batchNo": r.batch_no or "",
"manufacturer": r.manufacturer or "",
"unitPrice": _unit_price_for_row(r, batch),
"amount": _amount_for_row(r, batch),
"changeType": r.change_type,
"changeQty": change_qty,
"usageUnit": usage_unit,
"stockBefore": stock_before,
"stockAfter": stock_after,
"receiver": receiver,
"receiverName": receiver_name or receiver,
"purpose": purpose,
"sourceType": r.source_type or "",
"useTime": create_time if is_manual_out else "",
"remark": _display_remark(r),
"createBy": create_by,
"createByName": create_by_name or create_by,
"createTime": create_time,
"updateTime": r.update_time.strftime("%Y-%m-%d %H:%M:%S") if r.update_time else "",
}
def _batch_map(db: Session, batch_ids: List[str]) -> Dict[str, BizMaterialStockBatch]:
ids = [x for x in batch_ids if x]
if not ids:
return {}
rows = (
db.query(BizMaterialStockBatch)
.filter(BizMaterialStockBatch.id.in_(ids), BizMaterialStockBatch.del_flag == 0)
.all()
)
return {r.id: r for r in rows}
def _list_usages_query(
db: Session,
tenant_no: str,
*,
material_id: Optional[str] = None,
change_type: Optional[str] = None,
start_time: Optional[str] = None,
end_time: Optional[str] = None,
keyword: Optional[str] = None,
stock_in_no: Optional[str] = None,
user_info=None,
):
q0 = db.query(BizMaterialUsage).filter(
BizMaterialUsage.tenant_no == tenant_no,
BizMaterialUsage.del_flag == 0,
)
if material_id:
q0 = q0.filter(BizMaterialUsage.material_id == material_id)
ct = (change_type or "").strip()
if ct == "out":
q0 = q0.filter(
BizMaterialUsage.change_type == "use",
BizMaterialUsage.source_type == "manual_out",
)
elif ct == "in":
q0 = q0.filter(BizMaterialUsage.change_type == "in")
elif ct == "discard":
q0 = q0.filter(BizMaterialUsage.change_type == "discard")
sno = (stock_in_no or "").strip()
if sno:
q0 = q0.filter(BizMaterialUsage.stock_in_no.like(f"%{sno}%"))
kw = (keyword or "").strip()
if kw:
like = f"%{kw}%"
q0 = q0.filter(
or_(
BizMaterialUsage.material_code.like(like),
BizMaterialUsage.material_name.like(like),
BizMaterialUsage.stock_in_no.like(like),
BizMaterialUsage.batch_no.like(like),
BizMaterialUsage.catalog_no.like(like),
)
)
if start_time:
q0 = q0.filter(BizMaterialUsage.create_time >= start_time)
if end_time:
q0 = q0.filter(BizMaterialUsage.create_time <= end_time + " 23:59:59")
if user_info:
from app.core.data_scope import apply_data_scope
q0 = apply_data_scope(q0, BizMaterialUsage, user_info, db, tenant_no)
return q0
def _paginate_usages(db: Session, q0, *, page: int, page_size: int) -> Tuple[List[Dict[str, Any]], int]:
total = q0.order_by(None).with_entities(func.count(BizMaterialUsage.id)).scalar() or 0
page = max(1, page)
page_size = min(max(1, page_size), 100)
rows = (
q0.order_by(BizMaterialUsage.create_time.desc())
.offset((page - 1) * page_size)
.limit(page_size)
.all()
)
bmap = _batch_map(db, [x.batch_id for x in rows if x.batch_id])
name_map = _user_nick_name_map(db, [x.create_by for x in rows if x.create_by])
receivers = []
for x in rows:
rcv, _ = _resolve_receiver_purpose(x)
if rcv:
receivers.append(rcv)
receiver_map = _receiver_display_map(db, receivers)
return [
_row_to_dict(
x,
create_by_name=name_map.get(x.create_by or "", ""),
batch=bmap.get(x.batch_id or ""),
receiver_name=receiver_map.get(
(_resolve_receiver_purpose(x)[0] or ""), _resolve_receiver_purpose(x)[0] or ""
),
)
for x in rows
], int(total)
def list_usages(
db: Session,
tenant_no: str,
*,
page: int = 1,
page_size: int = 10,
material_id: Optional[str] = None,
change_type: Optional[str] = None,
start_time: Optional[str] = None,
end_time: Optional[str] = None,
keyword: Optional[str] = None,
stock_in_no: Optional[str] = None,
user_info=None,
) -> Tuple[List[Dict[str, Any]], int]:
q0 = _list_usages_query(
db,
tenant_no,
material_id=material_id,
change_type=change_type,
start_time=start_time,
end_time=end_time,
keyword=keyword,
stock_in_no=stock_in_no,
user_info=user_info,
)
return _paginate_usages(db, q0, page=page, page_size=page_size)
@@ -91,6 +91,9 @@ def _restore_cell_occupancy_no_commit(
.first()
)
if latest_removed:
occupancy_svc.assert_slot_vacant(
db, latest_removed.slot_id, tenant_no=tenant_no, exclude_product_id=product.id,
)
latest_removed.occupancy_status = "stored"
latest_removed.removed_at = None
latest_removed.update_by = user_id
@@ -99,6 +102,9 @@ def _restore_cell_occupancy_no_commit(
db.flush()
occupancy_svc._refresh_slot_cache(db, latest_removed.slot_id)
return
occupancy_svc.assert_slot_vacant(
db, slot_id, tenant_no=tenant_no, exclude_product_id=product.id,
)
db.add(
BizStorageSlotOccupancy(
id=generate_uuid(),
+635
View File
@@ -0,0 +1,635 @@
"""物料库 CRUD"""
from __future__ import annotations
from datetime import datetime
from decimal import Decimal
from typing import Any, Dict, List, Optional, Tuple
from sqlalchemy import and_, func, or_
from sqlalchemy.orm import Session
from app.core.utils import generate_uuid
from app.models.production_material import BizProductionMaterial, BizProductionMaterialUsage
def _dec(v: Any) -> float:
if v is None:
return 0.0
return float(v)
def _fmt_dt(t: Optional[datetime]) -> str:
return t.strftime("%Y-%m-%d %H:%M:%S") if t else ""
def _norm_status(v: Any) -> str:
"""统一状态为 '1'(启用)或 '0'(停用),避免 0 / '0' / or 判断歧义。"""
if v is None:
return "1"
if isinstance(v, bool):
return "1" if v else "0"
if isinstance(v, (int, float)):
if int(v) == 0:
return "0"
if int(v) == 1:
return "1"
s = str(v).strip()
if s in ("0", "1"):
return s
return "1"
def _is_enabled_status(v: Any) -> bool:
return _norm_status(v) == "1"
MATERIAL_TYPES = ("reagent", "consumable", "configured_reagent")
def _norm_material_type(v: Any) -> str:
s = (str(v or "").strip()).lower()
if s in MATERIAL_TYPES:
return s
raise ValueError("物料类型无效,应为 reagent、consumable 或 configured_reagent")
def _filter_material_type(mt: Optional[str]) -> Optional[str]:
s = (mt or "").strip().lower()
return s if s in MATERIAL_TYPES else None
def _row_to_dict(r: BizProductionMaterial) -> Dict[str, Any]:
return {
"id": r.id,
"materialType": r.material_type or "",
"materialCode": r.material_code,
"materialName": r.material_name,
"specModel": r.spec_model or "",
"unit": r.unit or "",
"stockQty": _dec(r.stock_qty),
"warningQty": _dec(r.warning_qty),
"status": _norm_status(r.status),
"orderNum": r.order_num if r.order_num is not None else 0,
"remark": r.remark or "",
"createTime": _fmt_dt(r.create_time),
"updateTime": _fmt_dt(r.update_time),
}
def code_exists(
db: Session,
code: str,
material_type: str,
tenant_no: str,
exclude_id: Optional[str] = None,
) -> bool:
c = (code or "").strip()
if not c:
return False
mt = _norm_material_type(material_type)
q = db.query(BizProductionMaterial).filter(
BizProductionMaterial.material_code == c,
BizProductionMaterial.material_type == mt,
BizProductionMaterial.tenant_no == tenant_no,
BizProductionMaterial.del_flag == 0,
)
if exclude_id:
q = q.filter(BizProductionMaterial.id != exclude_id)
return q.first() is not None
def total_pages(db: Session, tenant_no: str, page_size: int = 10) -> int:
cnt = (
db.query(func.count(BizProductionMaterial.id))
.filter(
BizProductionMaterial.tenant_no == tenant_no,
BizProductionMaterial.del_flag == 0,
)
.scalar()
or 0
)
ps = max(1, page_size)
return (cnt + ps - 1) // ps
def list_materials(
db: Session,
*,
page: int = 1,
page_size: int = 10,
keyword: Optional[str] = None,
material_type: Optional[str] = None,
status: Optional[str] = None,
tenant_no: Optional[str] = None,
user_info=None,
) -> Tuple[List[Dict[str, Any]], int]:
def _filtered():
q0 = db.query(BizProductionMaterial).filter(BizProductionMaterial.del_flag == 0)
if tenant_no:
q0 = q0.filter(BizProductionMaterial.tenant_no == tenant_no)
mt = _filter_material_type(material_type)
if mt:
q0 = q0.filter(BizProductionMaterial.material_type == mt)
kw = (keyword or "").strip()
if kw:
like = f"%{kw}%"
q0 = q0.filter(
or_(
BizProductionMaterial.material_code.like(like),
BizProductionMaterial.material_name.like(like),
)
)
st = (status or "").strip()
if st in ("0", "1"):
q0 = q0.filter(BizProductionMaterial.status == st)
if user_info:
from app.core.data_scope import apply_data_scope
q0 = apply_data_scope(q0, BizProductionMaterial, user_info, db, tenant_no)
return q0
total = _filtered().order_by(None).with_entities(func.count(BizProductionMaterial.id)).scalar() or 0
page = max(1, page)
page_size = min(max(1, page_size), 100)
rows = (
_filtered()
.order_by(BizProductionMaterial.create_time.desc())
.offset((page - 1) * page_size)
.limit(page_size)
.all()
)
return [_row_to_dict(x) for x in rows], int(total)
def get_material(
db: Session, row_id: str, tenant_no: Optional[str] = None
) -> Optional[BizProductionMaterial]:
q = db.query(BizProductionMaterial).filter(
BizProductionMaterial.id == row_id, BizProductionMaterial.del_flag == 0
)
if tenant_no:
q = q.filter(BizProductionMaterial.tenant_no == tenant_no)
return q.first()
def create_material(
db: Session,
*,
material_type: str,
material_code: str,
material_name: str,
spec_model: Optional[str] = None,
unit: Optional[str] = None,
stock_qty: Optional[Decimal] = None,
warning_qty: Optional[Decimal] = None,
status: str = "1",
tenant_no: str,
order_num: Optional[int] = None,
remark: Optional[str] = None,
user_id: Optional[str] = None,
create_dept_id: str = "",
) -> BizProductionMaterial:
code = (material_code or "").strip()
if not code:
raise ValueError("物料编码不能为空")
mt = _norm_material_type(material_type)
if code_exists(db, code, mt, tenant_no):
raise ValueError("物料编码已存在")
name = (material_name or "").strip()
if not name:
raise ValueError("物料名称不能为空")
st = _norm_status(status)
obj = BizProductionMaterial(
id=generate_uuid(),
material_type=mt,
material_code=code,
material_name=name,
spec_model=(spec_model or "").strip() or None,
unit=(unit or "").strip() or None,
stock_qty=stock_qty if stock_qty is not None else 0,
warning_qty=warning_qty if warning_qty is not None else 0,
status=st,
tenant_no=tenant_no,
order_num=order_num if order_num is not None else 0,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id=create_dept_id or "",
create_time=datetime.now(),
update_by=user_id,
update_time=datetime.now(),
del_flag=0,
)
db.add(obj)
db.commit()
db.refresh(obj)
return obj
def update_material(
db: Session,
row_id: str,
*,
material_type: Optional[str] = None,
material_code: Optional[str] = None,
material_name: Optional[str] = None,
spec_model: Optional[str] = None,
unit: Optional[str] = None,
warning_qty: Optional[Decimal] = None,
status: Optional[str] = None,
order_num: Optional[int] = None,
remark: Optional[str] = None,
user_id: Optional[str] = None,
tenant_no: Optional[str] = None,
) -> BizProductionMaterial:
obj = get_material(db, row_id, tenant_no=tenant_no)
if not obj:
raise ValueError("物料不存在")
mt = _norm_material_type(material_type) if material_type is not None else obj.material_type
if material_type is not None:
obj.material_type = mt
if material_code is not None:
code = material_code.strip()
if not code:
raise ValueError("物料编码不能为空")
if code != obj.material_code and code_exists(
db, code, mt, obj.tenant_no, exclude_id=row_id
):
raise ValueError("物料编码已存在")
obj.material_code = code
if material_name is not None:
name = (material_name or "").strip()
if not name:
raise ValueError("物料名称不能为空")
obj.material_name = name
if spec_model is not None:
obj.spec_model = (spec_model or "").strip() or None
if unit is not None:
obj.unit = (unit or "").strip() or None
if warning_qty is not None:
obj.warning_qty = warning_qty
if status is not None:
obj.status = _norm_status(status)
if order_num is not None:
obj.order_num = order_num
if remark is not None:
obj.remark = (remark or "").strip() or None
obj.update_by = user_id
obj.update_time = datetime.now()
db.add(obj)
db.commit()
db.refresh(obj)
return obj
def soft_delete_material(db: Session, row_id: str, tenant_no: Optional[str] = None) -> None:
obj = get_material(db, row_id, tenant_no=tenant_no)
if not obj:
raise ValueError("物料不存在")
if obj.stock_qty is not None and _dec(obj.stock_qty) > 0:
raise ValueError("该物料仍有库存,无法删除")
obj.del_flag = 1
obj.update_time = datetime.now()
db.add(obj)
db.commit()
def _build_manual_out_remark(
*,
receiver: Optional[str] = None,
purpose: Optional[str] = None,
remark: Optional[str] = None,
line_remark: Optional[str] = None,
) -> Optional[str]:
parts: List[str] = []
r = (receiver or "").strip()
if r:
parts.append(f"领用人:{r}")
p = (purpose or "").strip()
if p:
parts.append(f"用途:{p}")
extra = (line_remark or remark or "").strip()
if extra:
parts.append(extra)
return ";".join(parts) if parts else None
def stock_in(
db: Session,
row_id: str,
*,
qty: Decimal,
remark: Optional[str] = None,
user_id: Optional[str] = None,
tenant_no: Optional[str] = None,
operate_time: Optional[datetime] = None,
) -> BizProductionMaterial:
if qty is None or float(qty) <= 0:
raise ValueError("入库数量必须大于0")
# 行锁锁定物料行
obj = (
db.query(BizProductionMaterial)
.filter(BizProductionMaterial.id == row_id, BizProductionMaterial.del_flag == 0)
.with_for_update()
.first()
)
if not obj:
raise ValueError("物料不存在")
if tenant_no and obj.tenant_no != tenant_no:
raise ValueError("物料不存在")
if not _is_enabled_status(obj.status):
raise ValueError(f"物料「{obj.material_name}」已停用,无法入库")
op_time = operate_time or datetime.now()
old_stock = obj.stock_qty or 0
new_stock = old_stock + qty
obj.stock_qty = new_stock
obj.update_by = user_id
obj.update_time = datetime.now()
db.add(obj)
usage = BizProductionMaterialUsage(
id=generate_uuid(),
material_id=obj.id,
material_type=obj.material_type,
material_code=obj.material_code,
material_name=obj.material_name,
change_type="in",
change_qty=qty,
stock_after=new_stock,
source_type="manual_in",
tenant_no=obj.tenant_no,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id=obj.create_dept_id or "",
create_time=op_time,
update_by=user_id,
update_time=op_time,
del_flag=0,
)
db.add(usage)
db.commit()
db.refresh(obj)
return obj
def batch_stock_in(
db: Session,
*,
items: List[Dict[str, Any]],
remark: Optional[str] = None,
tenant_no: str,
user_id: Optional[str] = None,
operate_time: Optional[datetime] = None,
) -> int:
"""批量入库,同一事务;任一条失败则全部回滚。"""
if not items:
raise ValueError("请至少选择一条物料")
op_time = operate_time or datetime.now()
shared_remark = (remark or "").strip() or None
try:
for it in items:
material_id = (it.get("material_id") or it.get("materialId") or "").strip()
qty = it.get("qty")
if not material_id:
raise ValueError("物料ID不能为空")
if qty is None or float(qty) <= 0:
raise ValueError("入库数量必须大于0")
qty_dec = Decimal(str(qty))
line_remark = (it.get("remark") or "").strip()
log_remark = line_remark or shared_remark or None
obj = (
db.query(BizProductionMaterial)
.filter(
BizProductionMaterial.id == material_id,
BizProductionMaterial.tenant_no == tenant_no,
BizProductionMaterial.del_flag == 0,
)
.with_for_update()
.first()
)
if not obj:
raise ValueError("物料不存在")
if not _is_enabled_status(obj.status):
raise ValueError(f"物料「{obj.material_name}」已停用,无法入库")
old_stock = obj.stock_qty or 0
new_stock = old_stock + qty_dec
obj.stock_qty = new_stock
obj.update_by = user_id
obj.update_time = datetime.now()
db.add(obj)
usage = BizProductionMaterialUsage(
id=generate_uuid(),
material_id=obj.id,
material_type=obj.material_type,
material_code=obj.material_code,
material_name=obj.material_name,
change_type="in",
change_qty=qty_dec,
stock_after=new_stock,
source_type="manual_in",
tenant_no=obj.tenant_no,
remark=log_remark,
create_by=user_id,
create_dept_id=obj.create_dept_id or "",
create_time=op_time,
update_by=user_id,
update_time=op_time,
del_flag=0,
)
db.add(usage)
db.commit()
return len(items)
except Exception:
db.rollback()
raise
def stock_out(
db: Session,
row_id: str,
*,
qty: Decimal,
receiver: Optional[str] = None,
purpose: Optional[str] = None,
remark: Optional[str] = None,
user_id: Optional[str] = None,
tenant_no: Optional[str] = None,
operate_time: Optional[datetime] = None,
) -> BizProductionMaterial:
if qty is None or float(qty) <= 0:
raise ValueError("出库数量必须大于0")
qty_dec = Decimal(str(qty))
if not (receiver or "").strip():
raise ValueError("请选择领用人")
obj = (
db.query(BizProductionMaterial)
.filter(BizProductionMaterial.id == row_id, BizProductionMaterial.del_flag == 0)
.with_for_update()
.first()
)
if not obj:
raise ValueError("物料不存在")
if tenant_no and obj.tenant_no != tenant_no:
raise ValueError("物料不存在")
if not _is_enabled_status(obj.status):
raise ValueError(f"物料「{obj.material_name}」已停用,无法出库")
stock_before = obj.stock_qty if obj.stock_qty is not None else Decimal("0")
if stock_before < qty_dec:
raise ValueError(
f"物料「{obj.material_name}」库存不足,当前库存 {stock_before},需出库 {qty_dec}"
)
op_time = operate_time or datetime.now()
new_stock = stock_before - qty_dec
obj.stock_qty = new_stock
obj.update_by = user_id
obj.update_time = datetime.now()
db.add(obj)
usage = BizProductionMaterialUsage(
id=generate_uuid(),
material_id=obj.id,
material_type=obj.material_type,
material_code=obj.material_code,
material_name=obj.material_name,
change_type="use",
change_qty=-qty_dec,
stock_after=new_stock,
source_type="manual_out",
tenant_no=obj.tenant_no,
receiver=(receiver or "").strip() or None,
purpose=(purpose or "").strip() or None,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id=obj.create_dept_id or "",
create_time=op_time,
update_by=user_id,
update_time=op_time,
del_flag=0,
)
db.add(usage)
db.commit()
db.refresh(obj)
return obj
def batch_stock_out(
db: Session,
*,
items: List[Dict[str, Any]],
receiver: Optional[str] = None,
purpose: Optional[str] = None,
remark: Optional[str] = None,
tenant_no: str,
user_id: Optional[str] = None,
operate_time: Optional[datetime] = None,
) -> int:
"""批量出库,同一事务;任一条失败则全部回滚。"""
if not items:
raise ValueError("请至少选择一条物料")
if not (receiver or "").strip():
raise ValueError("请选择领用人")
op_time = operate_time or datetime.now()
recv = (receiver or "").strip() or None
purp = (purpose or "").strip() or None
shared_remark = (remark or "").strip() or None
try:
for it in items:
material_id = (it.get("material_id") or it.get("materialId") or "").strip()
qty = it.get("qty")
if not material_id:
raise ValueError("物料ID不能为空")
if qty is None or float(qty) <= 0:
raise ValueError("出库数量必须大于0")
qty_dec = Decimal(str(qty))
line_remark = (it.get("remark") or "").strip() or shared_remark
obj = (
db.query(BizProductionMaterial)
.filter(
BizProductionMaterial.id == material_id,
BizProductionMaterial.tenant_no == tenant_no,
BizProductionMaterial.del_flag == 0,
)
.with_for_update()
.first()
)
if not obj:
raise ValueError("物料不存在")
if not _is_enabled_status(obj.status):
raise ValueError(f"物料「{obj.material_name}」已停用,无法出库")
stock_before = obj.stock_qty if obj.stock_qty is not None else Decimal("0")
if stock_before < qty_dec:
raise ValueError(
f"物料「{obj.material_name}」库存不足,当前库存 {stock_before},需出库 {qty_dec}"
)
new_stock = stock_before - qty_dec
obj.stock_qty = new_stock
obj.update_by = user_id
obj.update_time = datetime.now()
db.add(obj)
usage = BizProductionMaterialUsage(
id=generate_uuid(),
material_id=obj.id,
material_type=obj.material_type,
material_code=obj.material_code,
material_name=obj.material_name,
change_type="use",
change_qty=-qty_dec,
stock_after=new_stock,
source_type="manual_out",
tenant_no=obj.tenant_no,
receiver=recv,
purpose=purp,
remark=line_remark,
create_by=user_id,
create_dept_id=obj.create_dept_id or "",
create_time=op_time,
update_by=user_id,
update_time=op_time,
del_flag=0,
)
db.add(usage)
db.commit()
return len(items)
except Exception:
db.rollback()
raise
def options_list(
db: Session,
tenant_no: str,
*,
material_type: Optional[str] = None,
) -> List[Dict[str, Any]]:
q = db.query(BizProductionMaterial).filter(
BizProductionMaterial.tenant_no == tenant_no,
BizProductionMaterial.del_flag == 0,
BizProductionMaterial.status == "1",
)
mt = _filter_material_type(material_type)
if mt:
q = q.filter(BizProductionMaterial.material_type == mt)
rows = q.order_by(BizProductionMaterial.create_time.desc()).all()
return [
{
"id": r.id,
"label": r.material_name,
"materialType": r.material_type or "",
"materialCode": r.material_code,
"materialName": r.material_name,
"specModel": r.spec_model or "",
"unit": r.unit or "",
"stockQty": _dec(r.stock_qty),
}
for r in rows
]
@@ -0,0 +1,169 @@
"""配置试剂配方 BOM CRUD"""
from __future__ import annotations
from datetime import datetime
from decimal import Decimal
from typing import Any, Dict, List, Optional
from sqlalchemy import and_
from sqlalchemy.orm import Session
from app.core.utils import generate_uuid
from app.crud.production_material import _dec, _fmt_dt
from app.models.production_material import BizProductionMaterial, BizProductionMaterialFormula
COMPONENT_TYPES = ("reagent", "consumable")
def _line_to_dict(r: BizProductionMaterialFormula) -> Dict[str, Any]:
return {
"id": r.id,
"configuredMaterialId": r.configured_material_id,
"componentMaterialId": r.component_material_id,
"componentMaterialType": r.component_material_type or "",
"componentMaterialCode": r.component_material_code or "",
"componentMaterialName": r.component_material_name or "",
"standardQty": _dec(r.standard_qty),
"usageUnit": r.usage_unit or "",
"orderNum": r.order_num if r.order_num is not None else 0,
"remark": r.remark or "",
}
def _get_configured_material(
db: Session, material_id: str, tenant_no: str
) -> BizProductionMaterial:
row = (
db.query(BizProductionMaterial)
.filter(
BizProductionMaterial.id == material_id,
BizProductionMaterial.tenant_no == tenant_no,
BizProductionMaterial.del_flag == 0,
)
.first()
)
if not row:
raise ValueError("配置试剂不存在")
if (row.material_type or "").strip() != "configured_reagent":
raise ValueError("仅配置试剂目录可维护配方")
return row
def get_formula(
db: Session, configured_material_id: str, tenant_no: str
) -> List[Dict[str, Any]]:
_get_configured_material(db, configured_material_id, tenant_no)
rows = (
db.query(BizProductionMaterialFormula)
.filter(
BizProductionMaterialFormula.configured_material_id == configured_material_id,
BizProductionMaterialFormula.tenant_no == tenant_no,
BizProductionMaterialFormula.del_flag == 0,
)
.order_by(
BizProductionMaterialFormula.order_num.asc(),
BizProductionMaterialFormula.create_time.asc(),
)
.all()
)
return [_line_to_dict(r) for r in rows]
def replace_formula(
db: Session,
configured_material_id: str,
*,
lines: List[Dict[str, Any]],
tenant_no: str,
user_id: Optional[str] = None,
dept_id: str = "",
) -> List[Dict[str, Any]]:
configured = _get_configured_material(db, configured_material_id, tenant_no)
now = datetime.now()
if not lines:
raise ValueError("请至少添加一条配方明细")
seen_components: set = set()
new_rows: List[BizProductionMaterialFormula] = []
for idx, it in enumerate(lines):
comp_id = (
it.get("componentMaterialId") or it.get("component_material_id") or ""
).strip()
if not comp_id:
raise ValueError("请选择子物料")
if comp_id in seen_components:
raise ValueError("配方中存在重复的子物料")
seen_components.add(comp_id)
comp_type = (
it.get("componentMaterialType") or it.get("component_material_type") or ""
).strip().lower()
if comp_type not in COMPONENT_TYPES:
raise ValueError("子物料类型无效,应为试剂或耗材")
comp = (
db.query(BizProductionMaterial)
.filter(
BizProductionMaterial.id == comp_id,
BizProductionMaterial.tenant_no == tenant_no,
BizProductionMaterial.del_flag == 0,
)
.first()
)
if not comp:
raise ValueError("子物料不存在")
if (comp.material_type or "").strip() != comp_type:
raise ValueError(f"子物料「{comp.material_name}」类型与所选不一致")
qty_raw = it.get("standardQty") if it.get("standardQty") is not None else it.get("standard_qty")
if qty_raw is None or Decimal(str(qty_raw)) <= 0:
raise ValueError("标准用量必须大于0")
standard_qty = Decimal(str(qty_raw))
usage_unit = (
it.get("usageUnit") or it.get("usage_unit") or comp.unit or ""
).strip()[:32]
new_rows.append(
BizProductionMaterialFormula(
id=generate_uuid(),
configured_material_id=configured_material_id,
component_material_id=comp_id,
component_material_type=comp_type,
component_material_code=comp.material_code,
component_material_name=comp.material_name,
standard_qty=standard_qty,
usage_unit=usage_unit or None,
tenant_no=tenant_no,
order_num=idx,
remark=(it.get("remark") or "").strip()[:512] or None,
create_by=user_id,
create_dept_id=dept_id or configured.create_dept_id or "",
create_time=now,
update_by=user_id,
update_time=now,
del_flag=0,
)
)
existing = (
db.query(BizProductionMaterialFormula)
.filter(
BizProductionMaterialFormula.configured_material_id == configured_material_id,
BizProductionMaterialFormula.tenant_no == tenant_no,
BizProductionMaterialFormula.del_flag == 0,
)
.all()
)
for row in existing:
row.del_flag = 1
row.update_by = user_id
row.update_time = now
db.add(row)
for row in new_rows:
db.add(row)
db.commit()
return get_formula(db, configured_material_id, tenant_no)
@@ -0,0 +1,758 @@
"""配置试剂配制单 CRUD"""
from __future__ import annotations
from datetime import date, datetime
from decimal import Decimal
from typing import Any, Dict, List, Optional, Tuple
from sqlalchemy import and_, func, or_
from sqlalchemy.orm import Session
from app.core.utils import generate_uuid, parse_datetime
from app.crud.production_material import _dec, _fmt_dt, _is_enabled_status
from app.crud.production_material_stock_batch import (
_create_batch_and_usage,
_get_material_for_update,
_parse_date,
_parse_expire_date,
_require_str,
stock_in_no_exists,
_optional_str,
)
from app.models.models import SysUser
from app.models.production_material import (
BizProductionMaterial,
BizProductionMaterialPrep,
BizProductionMaterialPrepLine,
BizProductionMaterialUsage,
)
PREP_STATUSES = ("draft", "completed", "cancelled")
def _status_label(status: str) -> str:
if status == "completed":
return "已完成"
if status == "cancelled":
return "已作废"
return "草稿"
def _fmt_date(d: Optional[date]) -> str:
return d.strftime("%Y-%m-%d") if d else ""
def _user_nick_name_map(db: Session, user_ids: List[str]) -> Dict[str, str]:
ids = list({x for x in user_ids if x})
if not ids:
return {}
rows = db.query(SysUser.id, SysUser.nick_name).filter(SysUser.id.in_(ids)).all()
return {u.id: (u.nick_name or "").strip() for u in rows}
def _generate_prep_no(db: Session, tenant_no: str) -> str:
day = datetime.now().strftime("%Y%m%d")
like = f"PZ-{day}-%"
cnt = (
db.query(func.count(BizProductionMaterialPrep.id))
.filter(
BizProductionMaterialPrep.tenant_no == tenant_no,
BizProductionMaterialPrep.prep_no.like(like),
)
.scalar()
)
return f"PZ-{day}-{(cnt or 0) + 1:03d}"
def _generate_stock_in_no(db: Session, tenant_no: str) -> str:
day = datetime.now().strftime("%Y%m%d")
like = f"RK{day}%"
cnt = (
db.query(func.count(BizProductionMaterialPrep.id))
.filter(
BizProductionMaterialPrep.tenant_no == tenant_no,
BizProductionMaterialPrep.stock_in_no.like(like),
BizProductionMaterialPrep.del_flag == 0,
)
.scalar()
)
sno = f"RK{day}{(cnt or 0) + 1:04d}"
if stock_in_no_exists(db, sno, tenant_no):
sno = f"RK{day}{(cnt or 0) + 1:04d}P"
return sno
def _line_to_dict(row: BizProductionMaterialPrepLine) -> Dict[str, Any]:
return {
"id": row.id,
"prepId": row.prep_id,
"componentMaterialId": row.component_material_id,
"componentMaterialType": row.component_material_type or "",
"componentMaterialCode": row.component_material_code or "",
"componentMaterialName": row.component_material_name or "",
"requisitionUsageId": (row.requisition_usage_id or "").strip(),
"actualQty": _dec(row.actual_qty),
"usageUnit": row.usage_unit or "",
"orderNum": row.order_num if row.order_num is not None else 0,
"remark": row.remark or "",
}
def _header_to_dict(
row: BizProductionMaterialPrep,
*,
create_by_name: str = "",
line_count: int = 0,
) -> Dict[str, Any]:
return {
"id": row.id,
"prepNo": row.prep_no or "",
"configuredMaterialId": row.configured_material_id,
"configuredMaterialCode": row.configured_material_code or "",
"configuredMaterialName": row.configured_material_name or "",
"prepTime": _fmt_dt(row.prep_time),
"outputQty": _dec(row.output_qty),
"outputUnit": row.output_unit or "",
"batchNo": row.batch_no or "",
"storageLocation": row.storage_location or "",
"expireDate": _fmt_date(row.expire_date),
"stockInNo": row.stock_in_no or "",
"outputBatchId": row.output_batch_id or "",
"status": row.status or "draft",
"statusLabel": _status_label(row.status or "draft"),
"lineCount": line_count,
"remark": row.remark or "",
"createBy": row.create_by or "",
"createByName": create_by_name or row.create_by or "",
"createTime": _fmt_dt(row.create_time),
"updateTime": _fmt_dt(row.update_time),
}
def _get_prep_row(db: Session, prep_id: str, tenant_no: str) -> BizProductionMaterialPrep:
row = (
db.query(BizProductionMaterialPrep)
.filter(
BizProductionMaterialPrep.id == prep_id,
BizProductionMaterialPrep.tenant_no == tenant_no,
BizProductionMaterialPrep.del_flag == 0,
)
.first()
)
if not row:
raise ValueError("配制单不存在")
return row
def _require_draft(row: BizProductionMaterialPrep) -> None:
if (row.status or "").strip() != "draft":
raise ValueError("仅草稿状态的配制单可编辑")
def _validate_requisition(
db: Session,
req_id: str,
*,
tenant_no: str,
component_material_id: str,
seen: set,
) -> BizProductionMaterialUsage:
if not req_id:
raise ValueError("请选择子物料领用记录")
if req_id in seen:
raise ValueError("配制明细中存在重复的领用记录")
seen.add(req_id)
req = (
db.query(BizProductionMaterialUsage)
.filter(
BizProductionMaterialUsage.id == req_id,
BizProductionMaterialUsage.tenant_no == tenant_no,
BizProductionMaterialUsage.del_flag == 0,
BizProductionMaterialUsage.source_type == "manual_out",
BizProductionMaterialUsage.change_type == "use",
)
.first()
)
if not req:
raise ValueError("领用记录不存在或已失效")
if (req.material_id or "").strip() != component_material_id:
raise ValueError("领用记录与子物料不匹配")
return req
def _parse_prep_lines(
db: Session,
lines: List[Dict[str, Any]],
*,
tenant_no: str,
) -> List[Dict[str, Any]]:
if not lines:
raise ValueError("请至少添加一条配制明细")
parsed: List[Dict[str, Any]] = []
seen_req: set = set()
for idx, it in enumerate(lines):
comp_id = (
it.get("componentMaterialId") or it.get("component_material_id") or ""
).strip()
if not comp_id:
raise ValueError("请选择子物料")
comp_type = (
it.get("componentMaterialType") or it.get("component_material_type") or ""
).strip().lower()
if comp_type not in ("reagent", "consumable"):
raise ValueError("子物料类型无效")
comp = (
db.query(BizProductionMaterial)
.filter(
BizProductionMaterial.id == comp_id,
BizProductionMaterial.tenant_no == tenant_no,
BizProductionMaterial.del_flag == 0,
)
.first()
)
if not comp:
raise ValueError("子物料不存在")
req_id = (
it.get("requisitionUsageId") or it.get("requisition_usage_id") or ""
).strip()
req = _validate_requisition(
db, req_id, tenant_no=tenant_no, component_material_id=comp_id, seen=seen_req
)
qty_raw = it.get("actualQty") if it.get("actualQty") is not None else it.get("actual_qty")
if qty_raw is None or Decimal(str(qty_raw)) <= 0:
raise ValueError("实际用量必须大于0")
actual_qty = Decimal(str(qty_raw))
usage_unit = (
it.get("usageUnit") or it.get("usage_unit") or comp.unit or ""
).strip()[:32]
parsed.append(
{
"idx": idx,
"component": comp,
"component_type": comp_type,
"requisition": req,
"actual_qty": actual_qty,
"usage_unit": usage_unit,
"remark": (it.get("remark") or "").strip()[:512] or None,
}
)
return parsed
def list_preps(
db: Session,
tenant_no: str,
*,
page: int = 1,
page_size: int = 10,
keyword: Optional[str] = None,
status: Optional[str] = None,
configured_material_id: Optional[str] = None,
) -> Tuple[List[Dict[str, Any]], int]:
q0 = db.query(BizProductionMaterialPrep).filter(
BizProductionMaterialPrep.tenant_no == tenant_no,
BizProductionMaterialPrep.del_flag == 0,
)
st = (status or "").strip().lower()
if st in PREP_STATUSES:
q0 = q0.filter(BizProductionMaterialPrep.status == st)
cmid = (configured_material_id or "").strip()
if cmid:
q0 = q0.filter(BizProductionMaterialPrep.configured_material_id == cmid)
kw = (keyword or "").strip()
if kw:
like = f"%{kw}%"
q0 = q0.filter(
or_(
BizProductionMaterialPrep.prep_no.like(like),
BizProductionMaterialPrep.configured_material_code.like(like),
BizProductionMaterialPrep.configured_material_name.like(like),
BizProductionMaterialPrep.batch_no.like(like),
BizProductionMaterialPrep.stock_in_no.like(like),
)
)
total = q0.count()
rows = (
q0.order_by(BizProductionMaterialPrep.prep_time.desc(), BizProductionMaterialPrep.create_time.desc())
.offset((page - 1) * page_size)
.limit(page_size)
.all()
)
prep_ids = [r.id for r in rows]
line_counts: Dict[str, int] = {}
if prep_ids:
cnt_rows = (
db.query(
BizProductionMaterialPrepLine.prep_id,
func.count(BizProductionMaterialPrepLine.id),
)
.filter(
BizProductionMaterialPrepLine.prep_id.in_(prep_ids),
BizProductionMaterialPrepLine.del_flag == 0,
)
.group_by(BizProductionMaterialPrepLine.prep_id)
.all()
)
line_counts = {pid: int(c) for pid, c in cnt_rows}
name_map = _user_nick_name_map(db, [r.create_by for r in rows if r.create_by])
items = [
_header_to_dict(
r,
create_by_name=name_map.get(r.create_by or "", ""),
line_count=line_counts.get(r.id, 0),
)
for r in rows
]
return items, total
def get_prep_detail(db: Session, prep_id: str, tenant_no: str) -> Dict[str, Any]:
row = _get_prep_row(db, prep_id, tenant_no)
lines = (
db.query(BizProductionMaterialPrepLine)
.filter(
BizProductionMaterialPrepLine.prep_id == prep_id,
BizProductionMaterialPrepLine.tenant_no == tenant_no,
BizProductionMaterialPrepLine.del_flag == 0,
)
.order_by(
BizProductionMaterialPrepLine.order_num.asc(),
BizProductionMaterialPrepLine.create_time.asc(),
)
.all()
)
name_map = _user_nick_name_map(db, [row.create_by] if row.create_by else [])
result = _header_to_dict(
row,
create_by_name=name_map.get(row.create_by or "", ""),
line_count=len(lines),
)
result["lines"] = [_line_to_dict(ln) for ln in lines]
return result
def create_prep(
db: Session,
*,
data: Dict[str, Any],
tenant_no: str,
user_id: Optional[str] = None,
dept_id: str = "",
) -> Dict[str, Any]:
configured_id = (
data.get("configuredMaterialId") or data.get("configured_material_id") or ""
).strip()
if not configured_id:
raise ValueError("请选择配置试剂")
configured = (
db.query(BizProductionMaterial)
.filter(
BizProductionMaterial.id == configured_id,
BizProductionMaterial.tenant_no == tenant_no,
BizProductionMaterial.del_flag == 0,
)
.first()
)
if not configured:
raise ValueError("配置试剂不存在")
if (configured.material_type or "").strip() != "configured_reagent":
raise ValueError("所选物料不是配置试剂")
prep_time_raw = data.get("prepTime") or data.get("prep_time")
prep_time = parse_datetime(prep_time_raw) if prep_time_raw else datetime.now()
output_qty_raw = data.get("outputQty") if data.get("outputQty") is not None else data.get("output_qty")
if output_qty_raw is None or Decimal(str(output_qty_raw)) <= 0:
raise ValueError("产出数量必须大于0")
output_qty = Decimal(str(output_qty_raw))
batch_no = _require_str(data.get("batchNo") or data.get("batch_no"), "产出批号")
expire_raw = data.get("expireDate") or data.get("expire_date")
expire_date = _parse_expire_date(expire_raw)
lines_raw = data.get("lines") or []
parsed_lines = _parse_prep_lines(db, lines_raw, tenant_no=tenant_no)
now = datetime.now()
prep_id = generate_uuid()
prep_no = _generate_prep_no(db, tenant_no)
prep = BizProductionMaterialPrep(
id=prep_id,
prep_no=prep_no,
configured_material_id=configured_id,
configured_material_code=configured.material_code,
configured_material_name=configured.material_name,
prep_time=prep_time,
output_qty=output_qty,
output_unit=(data.get("outputUnit") or data.get("output_unit") or configured.unit or "").strip()[:32] or None,
batch_no=batch_no,
storage_location=_optional_str(data.get("storageLocation") or data.get("storage_location")),
expire_date=expire_date,
status="draft",
tenant_no=tenant_no,
remark=(data.get("remark") or "").strip()[:512] or None,
create_by=user_id,
create_dept_id=dept_id or configured.create_dept_id or "",
create_time=now,
update_by=user_id,
update_time=now,
del_flag=0,
)
db.add(prep)
for pl in parsed_lines:
comp = pl["component"]
db.add(
BizProductionMaterialPrepLine(
id=generate_uuid(),
prep_id=prep_id,
component_material_id=comp.id,
component_material_type=pl["component_type"],
component_material_code=comp.material_code,
component_material_name=comp.material_name,
requisition_usage_id=pl["requisition"].id,
actual_qty=pl["actual_qty"],
usage_unit=pl["usage_unit"] or None,
tenant_no=tenant_no,
order_num=pl["idx"],
remark=pl["remark"],
create_by=user_id,
create_dept_id=dept_id or configured.create_dept_id or "",
create_time=now,
update_by=user_id,
update_time=now,
del_flag=0,
)
)
db.commit()
return get_prep_detail(db, prep_id, tenant_no)
def update_prep(
db: Session,
prep_id: str,
*,
data: Dict[str, Any],
tenant_no: str,
user_id: Optional[str] = None,
dept_id: str = "",
) -> Dict[str, Any]:
prep = _get_prep_row(db, prep_id, tenant_no)
_require_draft(prep)
now = datetime.now()
if data.get("prepTime") or data.get("prep_time"):
prep.prep_time = parse_datetime(data.get("prepTime") or data.get("prep_time"))
if data.get("outputQty") is not None or data.get("output_qty") is not None:
output_qty_raw = data.get("outputQty") if data.get("outputQty") is not None else data.get("output_qty")
if Decimal(str(output_qty_raw)) <= 0:
raise ValueError("产出数量必须大于0")
prep.output_qty = Decimal(str(output_qty_raw))
if data.get("outputUnit") is not None or data.get("output_unit") is not None:
prep.output_unit = (
data.get("outputUnit") or data.get("output_unit") or ""
).strip()[:32] or None
if data.get("batchNo") or data.get("batch_no"):
prep.batch_no = _require_str(data.get("batchNo") or data.get("batch_no"), "产出批号")
if data.get("storageLocation") is not None or data.get("storage_location") is not None:
prep.storage_location = _optional_str(
data.get("storageLocation") if data.get("storageLocation") is not None else data.get("storage_location")
)
if data.get("expireDate") or data.get("expire_date"):
prep.expire_date = _parse_expire_date(data.get("expireDate") or data.get("expire_date"))
if data.get("remark") is not None:
prep.remark = (data.get("remark") or "").strip()[:512] or None
lines_raw = data.get("lines")
if lines_raw is not None:
parsed_lines = _parse_prep_lines(db, lines_raw, tenant_no=tenant_no)
existing = (
db.query(BizProductionMaterialPrepLine)
.filter(
BizProductionMaterialPrepLine.prep_id == prep_id,
BizProductionMaterialPrepLine.del_flag == 0,
)
.all()
)
for ln in existing:
ln.del_flag = 1
ln.update_by = user_id
ln.update_time = now
db.add(ln)
for pl in parsed_lines:
comp = pl["component"]
db.add(
BizProductionMaterialPrepLine(
id=generate_uuid(),
prep_id=prep_id,
component_material_id=comp.id,
component_material_type=pl["component_type"],
component_material_code=comp.material_code,
component_material_name=comp.material_name,
requisition_usage_id=pl["requisition"].id,
actual_qty=pl["actual_qty"],
usage_unit=pl["usage_unit"] or None,
tenant_no=tenant_no,
order_num=pl["idx"],
remark=pl["remark"],
create_by=user_id,
create_dept_id=dept_id or prep.create_dept_id or "",
create_time=now,
update_by=user_id,
update_time=now,
del_flag=0,
)
)
prep.update_by = user_id
prep.update_time = now
db.add(prep)
db.commit()
return get_prep_detail(db, prep_id, tenant_no)
def _write_prep_consume_usage(
db: Session,
*,
prep: BizProductionMaterialPrep,
line: BizProductionMaterialPrepLine,
req: BizProductionMaterialUsage,
tenant_no: str,
user_id: Optional[str],
dept_id: str,
operate_time: datetime,
) -> Decimal:
material = (
db.query(BizProductionMaterial)
.filter(
BizProductionMaterial.id == line.component_material_id,
BizProductionMaterial.tenant_no == tenant_no,
BizProductionMaterial.del_flag == 0,
)
.first()
)
if not material:
raise ValueError("子物料不存在")
actual_qty = line.actual_qty or Decimal("0")
stock_qty = material.stock_qty if material.stock_qty is not None else Decimal("0")
unit_price = req.unit_price
line_amount = Decimal("0")
if unit_price is not None and actual_qty > 0:
line_amount = (Decimal(str(unit_price)) * actual_qty).quantize(Decimal("0.01"))
usage = BizProductionMaterialUsage(
id=generate_uuid(),
material_id=material.id,
material_type=material.material_type,
material_code=material.material_code,
material_name=material.material_name,
batch_id=req.batch_id,
stock_in_no=req.stock_in_no,
catalog_no=req.catalog_no,
batch_no=req.batch_no,
manufacturer=req.manufacturer,
storage_location=req.storage_location,
unit_price=req.unit_price,
amount=line_amount if line_amount > 0 else req.amount,
change_type="use",
change_qty=-actual_qty,
usage_unit=line.usage_unit,
stock_before=stock_qty,
stock_after=stock_qty,
parent_usage_id=req.id,
prep_id=prep.id,
source_type="prep_consume",
tenant_no=tenant_no,
remark=f"配制单 {prep.prep_no}",
create_by=user_id,
create_dept_id=dept_id,
create_time=operate_time,
update_by=user_id,
update_time=operate_time,
del_flag=0,
)
db.add(usage)
return line_amount
def complete_prep(
db: Session,
prep_id: str,
*,
tenant_no: str,
user_id: Optional[str] = None,
dept_id: str = "",
) -> Dict[str, Any]:
prep = _get_prep_row(db, prep_id, tenant_no)
if (prep.status or "").strip() != "draft":
raise ValueError("仅草稿状态的配制单可确认配制")
lines = (
db.query(BizProductionMaterialPrepLine)
.filter(
BizProductionMaterialPrepLine.prep_id == prep_id,
BizProductionMaterialPrepLine.del_flag == 0,
)
.order_by(BizProductionMaterialPrepLine.order_num.asc())
.all()
)
if not lines:
raise ValueError("配制单无明细,无法确认")
configured = _get_material_for_update(db, prep.configured_material_id, tenant_no)
if (configured.material_type or "").strip() != "configured_reagent":
raise ValueError("配置试剂目录无效")
if not _is_enabled_status(configured.status):
raise ValueError(f"配置试剂「{configured.material_name}」已停用")
operate_time = datetime.now()
total_amount = Decimal("0")
try:
req_map: Dict[str, BizProductionMaterialUsage] = {}
for line in lines:
req_id = (line.requisition_usage_id or "").strip()
if not req_id:
raise ValueError("配制明细缺少领用记录")
if req_id not in req_map:
req = (
db.query(BizProductionMaterialUsage)
.filter(
BizProductionMaterialUsage.id == req_id,
BizProductionMaterialUsage.tenant_no == tenant_no,
BizProductionMaterialUsage.del_flag == 0,
BizProductionMaterialUsage.source_type == "manual_out",
)
.first()
)
if not req:
raise ValueError("领用记录不存在或已失效")
req_map[req_id] = req
amt = _write_prep_consume_usage(
db,
prep=prep,
line=line,
req=req_map[req_id],
tenant_no=tenant_no,
user_id=user_id,
dept_id=dept_id or prep.create_dept_id or "",
operate_time=operate_time,
)
total_amount += amt
stock_in_no = _generate_stock_in_no(db, tenant_no)
output_qty = prep.output_qty or Decimal("0")
if output_qty <= 0:
raise ValueError("产出数量必须大于0")
unit_price = Decimal("0")
amount = total_amount
if output_qty > 0 and total_amount > 0:
unit_price = (total_amount / output_qty).quantize(Decimal("0.01"))
amount = (unit_price * output_qty).quantize(Decimal("0.01"))
stock_in_date = prep.prep_time.date() if prep.prep_time else operate_time.date()
catalog_no = (configured.material_code or prep.batch_no or "—").strip() or "—"
batch = _create_batch_and_usage(
db,
material=configured,
stock_in_no=stock_in_no,
stock_in_date=stock_in_date,
expire_date=prep.expire_date,
catalog_no=catalog_no,
batch_no=prep.batch_no,
manufacturer="自配",
storage_location=prep.storage_location,
unit_price=unit_price,
amount=amount,
qty=output_qty,
remark=f"配制单 {prep.prep_no}",
tenant_no=tenant_no,
user_id=user_id,
operate_time=operate_time,
commit=False,
source_type="prep_in",
prep_id=prep.id,
)
prep.status = "completed"
prep.stock_in_no = stock_in_no
prep.output_batch_id = batch.id
prep.update_by = user_id
prep.update_time = operate_time
db.add(prep)
db.commit()
except Exception:
db.rollback()
raise
return get_prep_detail(db, prep_id, tenant_no)
def cancel_prep(
db: Session,
prep_id: str,
*,
tenant_no: str,
user_id: Optional[str] = None,
) -> None:
prep = _get_prep_row(db, prep_id, tenant_no)
_require_draft(prep)
now = datetime.now()
prep.status = "cancelled"
prep.update_by = user_id
prep.update_time = now
db.add(prep)
db.commit()
def delete_prep(
db: Session,
prep_id: str,
*,
tenant_no: str,
user_id: Optional[str] = None,
) -> None:
prep = _get_prep_row(db, prep_id, tenant_no)
_require_draft(prep)
now = datetime.now()
prep.del_flag = 1
prep.update_by = user_id
prep.update_time = now
db.add(prep)
lines = (
db.query(BizProductionMaterialPrepLine)
.filter(
BizProductionMaterialPrepLine.prep_id == prep_id,
BizProductionMaterialPrepLine.del_flag == 0,
)
.all()
)
for ln in lines:
ln.del_flag = 1
ln.update_by = user_id
ln.update_time = now
db.add(ln)
db.commit()
@@ -0,0 +1,953 @@
"""生产物料入库批次 CRUD"""
from __future__ import annotations
from datetime import date, datetime
from decimal import Decimal
from typing import Any, Dict, List, Optional, Tuple
from sqlalchemy import func, or_
from sqlalchemy.orm import Session
from app.core.utils import generate_uuid
from app.crud.production_material import _dec, _fmt_dt, _filter_material_type, _is_enabled_status, _norm_status
from app.models.production_material import BizProductionMaterial, BizProductionMaterialStockBatch, BizProductionMaterialUsage
def _fmt_date(d: Optional[date]) -> str:
return d.strftime("%Y-%m-%d") if d else ""
def _parse_date(v: Any, *, label: str = "入库日期") -> date:
if isinstance(v, date) and not isinstance(v, datetime):
return v
s = str(v or "").strip()
if not s:
raise ValueError(f"{label}不能为空")
if len(s) >= 10:
s = s[:10]
try:
return datetime.strptime(s, "%Y-%m-%d").date()
except ValueError as e:
raise ValueError("入库日期格式无效,应为 YYYY-MM-DD") from e
def _parse_expire_date(v: Any) -> date:
return _parse_date(v, label="过期日期")
def _require_str(v: Any, label: str) -> str:
s = str(v or "").strip()
if not s:
raise ValueError(f"{label}不能为空")
return s
def _optional_str(v: Any, *, max_len: int = 200) -> Optional[str]:
s = str(v or "").strip()
if not s:
return None
return s[:max_len]
def _require_decimal(v: Any, label: str) -> Decimal:
if v is None or str(v).strip() == "":
raise ValueError(f"{label}不能为空")
try:
d = Decimal(str(v))
except Exception as e:
raise ValueError(f"{label}格式无效") from e
if d < 0:
raise ValueError(f"{label}不能为负数")
return d
def stock_in_no_exists(
db: Session, stock_in_no: str, tenant_no: str, exclude_id: Optional[str] = None
) -> bool:
s = (stock_in_no or "").strip()
if not s:
return False
q = db.query(BizProductionMaterialStockBatch).filter(
BizProductionMaterialStockBatch.stock_in_no == s,
BizProductionMaterialStockBatch.tenant_no == tenant_no,
BizProductionMaterialStockBatch.del_flag == 0,
)
if exclude_id:
q = q.filter(BizProductionMaterialStockBatch.id != exclude_id)
return q.first() is not None
def _batch_row_to_dict(b: BizProductionMaterialStockBatch, material: Optional[BizProductionMaterial] = None) -> Dict[str, Any]:
mat = material
warning_qty = _dec(mat.warning_qty) if mat else 0
stock_qty = _dec(mat.stock_qty) if mat else _dec(b.remaining_qty)
status = _norm_status(mat.status) if mat else "1"
return {
"id": b.id,
"batchId": b.id,
"materialId": b.material_id,
"materialType": b.material_type or (mat.material_type if mat else ""),
"materialCode": b.material_code or "",
"materialName": b.material_name or "",
"specModel": b.spec_model or "",
"unit": b.unit or "",
"stockInNo": b.stock_in_no or "",
"stockInDate": _fmt_date(b.stock_in_date),
"expireDate": _fmt_date(b.expire_date),
"catalogNo": b.catalog_no or "",
"batchNo": b.batch_no or "",
"manufacturer": b.manufacturer or "",
"storageLocation": b.storage_location or "",
"unitPrice": float(b.unit_price) if b.unit_price is not None else 0,
"amount": float(b.amount) if b.amount is not None else 0,
"inQty": _dec(b.in_qty),
"remainingQty": _dec(b.remaining_qty),
"stockQty": stock_qty,
"warningQty": warning_qty,
"status": status,
"remark": b.remark or "",
"createTime": _fmt_dt(b.create_time),
"updateTime": _fmt_dt(b.update_time),
}
def _usage_batch_snapshots(
batch: BizProductionMaterialStockBatch,
*,
out_qty: Optional[Decimal] = None,
) -> Dict[str, Any]:
unit_price = batch.unit_price
if out_qty is not None:
amount = (Decimal(str(unit_price or 0)) * abs(out_qty)).quantize(Decimal("0.01"))
else:
amount = batch.amount
return {
"batch_id": batch.id,
"stock_in_no": batch.stock_in_no,
"catalog_no": batch.catalog_no,
"batch_no": batch.batch_no,
"manufacturer": batch.manufacturer,
"storage_location": batch.storage_location,
"unit_price": unit_price,
"amount": amount,
}
def _get_material_for_update(
db: Session, material_id: str, tenant_no: str
) -> BizProductionMaterial:
obj = (
db.query(BizProductionMaterial)
.filter(
BizProductionMaterial.id == material_id,
BizProductionMaterial.tenant_no == tenant_no,
BizProductionMaterial.del_flag == 0,
)
.with_for_update()
.first()
)
if not obj:
raise ValueError("物料不存在")
return obj
def list_batches(
db: Session,
*,
page: int = 1,
page_size: int = 10,
keyword: Optional[str] = None,
material_id: Optional[str] = None,
material_type: Optional[str] = None,
status: Optional[str] = None,
tenant_no: Optional[str] = None,
user_info=None,
) -> Tuple[List[Dict[str, Any]], int]:
def _filtered():
q0 = (
db.query(BizProductionMaterialStockBatch, BizProductionMaterial)
.join(
BizProductionMaterial,
BizProductionMaterial.id == BizProductionMaterialStockBatch.material_id,
)
.filter(
BizProductionMaterialStockBatch.del_flag == 0,
BizProductionMaterial.del_flag == 0,
)
)
if tenant_no:
q0 = q0.filter(BizProductionMaterialStockBatch.tenant_no == tenant_no)
kw = (keyword or "").strip()
if kw:
like = f"%{kw}%"
q0 = q0.filter(
or_(
BizProductionMaterialStockBatch.material_code.like(like),
BizProductionMaterialStockBatch.material_name.like(like),
BizProductionMaterialStockBatch.stock_in_no.like(like),
BizProductionMaterialStockBatch.batch_no.like(like),
BizProductionMaterialStockBatch.catalog_no.like(like),
)
)
if material_id:
q0 = q0.filter(BizProductionMaterialStockBatch.material_id == material_id)
mt = _filter_material_type(material_type)
if mt:
q0 = q0.filter(BizProductionMaterialStockBatch.material_type == mt)
st = (status or "").strip()
if st in ("0", "1"):
q0 = q0.filter(BizProductionMaterial.status == st)
if user_info:
from app.core.data_scope import apply_data_scope
q0 = apply_data_scope(q0, BizProductionMaterialStockBatch, user_info, db, tenant_no)
return q0
total = _filtered().order_by(None).with_entities(func.count(BizProductionMaterialStockBatch.id)).scalar() or 0
page = max(1, page)
page_size = min(max(1, page_size), 100)
rows = (
_filtered()
.order_by(
BizProductionMaterialStockBatch.stock_in_date.desc(),
BizProductionMaterialStockBatch.create_time.desc(),
)
.offset((page - 1) * page_size)
.limit(page_size)
.all()
)
return [_batch_row_to_dict(b, m) for b, m in rows], int(total)
def batch_options(
db: Session,
tenant_no: str,
*,
keyword: Optional[str] = None,
material_id: Optional[str] = None,
material_type: Optional[str] = None,
only_available: bool = True,
) -> List[Dict[str, Any]]:
q = (
db.query(BizProductionMaterialStockBatch, BizProductionMaterial)
.join(BizProductionMaterial, BizProductionMaterial.id == BizProductionMaterialStockBatch.material_id)
.filter(
BizProductionMaterialStockBatch.tenant_no == tenant_no,
BizProductionMaterialStockBatch.del_flag == 0,
BizProductionMaterial.del_flag == 0,
BizProductionMaterial.status == "1",
)
)
if only_available:
q = q.filter(BizProductionMaterialStockBatch.remaining_qty > 0)
if material_id:
q = q.filter(BizProductionMaterialStockBatch.material_id == material_id)
mt = _filter_material_type(material_type)
if mt:
q = q.filter(BizProductionMaterialStockBatch.material_type == mt)
kw = (keyword or "").strip()
if kw:
like = f"%{kw}%"
q = q.filter(
or_(
BizProductionMaterialStockBatch.stock_in_no.like(like),
BizProductionMaterialStockBatch.material_name.like(like),
BizProductionMaterialStockBatch.material_code.like(like),
BizProductionMaterialStockBatch.batch_no.like(like),
BizProductionMaterialStockBatch.catalog_no.like(like),
)
)
rows = q.order_by(BizProductionMaterialStockBatch.stock_in_date.asc()).all()
out: List[Dict[str, Any]] = []
for b, m in rows:
unit = b.unit or ""
rem = _dec(b.remaining_qty)
mfr = (b.manufacturer or "").strip()
cat = (b.catalog_no or "").strip()
label = (
f"{b.stock_in_no} / {b.material_name}"
f" / 厂家:{mfr or '—'}"
f" / 批号:{b.batch_no or '—'}"
f" / 货号:{cat or '—'}"
f" / 剩:{rem}{unit}"
)
unit_price = float(b.unit_price) if b.unit_price is not None else 0
out.append(
{
"id": b.id,
"batchId": b.id,
"stockInNo": b.stock_in_no or "",
"stockInDate": _fmt_date(b.stock_in_date),
"expireDate": _fmt_date(b.expire_date),
"materialId": b.material_id,
"materialType": b.material_type or "",
"materialCode": b.material_code or "",
"materialName": b.material_name or "",
"specModel": b.spec_model or "",
"unit": unit,
"batchNo": b.batch_no or "",
"catalogNo": b.catalog_no or "",
"manufacturer": b.manufacturer or "",
"storageLocation": b.storage_location or "",
"unitPrice": unit_price,
"amount": float(b.amount) if b.amount is not None else 0,
"remainingQty": rem,
"label": label,
}
)
return out
def _create_batch_and_usage(
db: Session,
*,
material: BizProductionMaterial,
stock_in_no: str,
stock_in_date: date,
expire_date: date,
catalog_no: str,
batch_no: str,
manufacturer: str,
storage_location: Optional[str],
unit_price: Decimal,
amount: Decimal,
qty: Decimal,
remark: Optional[str],
tenant_no: str,
user_id: Optional[str],
operate_time: datetime,
commit: bool = False,
source_type: str = "manual_in",
prep_id: Optional[str] = None,
) -> BizProductionMaterialStockBatch:
if qty <= 0:
raise ValueError("入库数量必须大于0")
sno = _require_str(stock_in_no, "入库编号")
if stock_in_no_exists(db, sno, tenant_no):
raise ValueError(f"入库编号「{sno}」已存在")
if not _is_enabled_status(material.status):
raise ValueError(f"物料「{material.material_name}」已停用,无法入库")
if (material.material_type or "").strip() == "configured_reagent":
raise ValueError("配置试剂仅能通过配制单入库,不可手工批次入库")
old_stock = material.stock_qty or Decimal("0")
new_stock = old_stock + qty
material.stock_qty = new_stock
material.update_by = user_id
material.update_time = datetime.now()
db.add(material)
batch = BizProductionMaterialStockBatch(
id=generate_uuid(),
material_id=material.id,
material_type=material.material_type,
material_code=material.material_code,
material_name=material.material_name,
spec_model=material.spec_model,
unit=material.unit,
stock_in_no=sno,
stock_in_date=stock_in_date,
expire_date=expire_date,
catalog_no=catalog_no,
batch_no=batch_no,
manufacturer=manufacturer,
storage_location=storage_location,
unit_price=unit_price,
amount=amount,
in_qty=qty,
remaining_qty=qty,
tenant_no=tenant_no,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id=material.create_dept_id or "",
create_time=operate_time,
update_by=user_id,
update_time=operate_time,
del_flag=0,
)
db.add(batch)
snaps = _usage_batch_snapshots(batch)
usage = BizProductionMaterialUsage(
id=generate_uuid(),
material_id=material.id,
material_type=material.material_type,
material_code=material.material_code,
material_name=material.material_name,
change_type="in",
change_qty=qty,
stock_before=old_stock,
stock_after=new_stock,
source_type=source_type,
prep_id=prep_id,
tenant_no=tenant_no,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id=material.create_dept_id or "",
create_time=operate_time,
update_by=user_id,
update_time=operate_time,
del_flag=0,
**snaps,
)
db.add(usage)
if commit:
db.commit()
db.refresh(batch)
return batch
def stock_in_one(
db: Session,
material_id: str,
*,
stock_in_no: str,
stock_in_date: Any,
expire_date: Any,
catalog_no: str,
batch_no: str,
manufacturer: str,
unit_price: Any,
amount: Any,
qty: Decimal,
remark: Optional[str] = None,
storage_location: Optional[str] = None,
tenant_no: str,
user_id: Optional[str] = None,
operate_time: Optional[datetime] = None,
) -> BizProductionMaterialStockBatch:
op_time = operate_time or datetime.now()
material = _get_material_for_update(db, material_id, tenant_no)
batch = _create_batch_and_usage(
db,
material=material,
stock_in_no=stock_in_no,
stock_in_date=_parse_date(stock_in_date),
expire_date=_parse_expire_date(expire_date),
catalog_no=_require_str(catalog_no, "货号"),
batch_no=_require_str(batch_no, "批号"),
manufacturer=_require_str(manufacturer, "厂家"),
storage_location=_optional_str(storage_location),
unit_price=_require_decimal(unit_price, "单价"),
amount=_require_decimal(amount, "金额"),
qty=qty,
remark=remark,
tenant_no=tenant_no,
user_id=user_id,
operate_time=op_time,
commit=True,
)
return batch
def batch_stock_in(
db: Session,
*,
items: List[Dict[str, Any]],
remark: Optional[str] = None,
tenant_no: str,
user_id: Optional[str] = None,
operate_time: Optional[datetime] = None,
) -> int:
if not items:
raise ValueError("请至少添加一条入库明细")
op_time = operate_time or datetime.now()
shared_remark = (remark or "").strip() or None
seen_nos: set = set()
try:
for it in items:
material_id = (it.get("material_id") or it.get("materialId") or "").strip()
if not material_id:
raise ValueError("请选择物资")
sno = _require_str(it.get("stock_in_no") or it.get("stockInNo"), "入库编号")
if sno in seen_nos:
raise ValueError(f"入库编号「{sno}」在本单中重复")
seen_nos.add(sno)
qty = it.get("qty")
if qty is None or Decimal(str(qty)) <= 0:
raise ValueError("入库数量必须大于0")
qty_dec = Decimal(str(qty))
line_remark = (it.get("remark") or "").strip() or shared_remark
material = _get_material_for_update(db, material_id, tenant_no)
_create_batch_and_usage(
db,
material=material,
stock_in_no=sno,
stock_in_date=_parse_date(it.get("stock_in_date") or it.get("stockInDate")),
expire_date=_parse_expire_date(it.get("expire_date") or it.get("expireDate")),
catalog_no=_require_str(it.get("catalog_no") or it.get("catalogNo"), "货号"),
batch_no=_require_str(it.get("batch_no") or it.get("batchNo"), "批号"),
manufacturer=_require_str(it.get("manufacturer"), "厂家"),
storage_location=_optional_str(it.get("storage_location") or it.get("storageLocation")),
unit_price=_require_decimal(it.get("unit_price") or it.get("unitPrice"), "单价"),
amount=_require_decimal(it.get("amount"), "金额"),
qty=qty_dec,
remark=line_remark,
tenant_no=tenant_no,
user_id=user_id,
operate_time=op_time,
commit=False,
)
db.commit()
return len(items)
except Exception:
db.rollback()
raise
def _stock_out_batch(
db: Session,
batch_id: str,
*,
qty: Decimal,
receiver: Optional[str],
purpose: Optional[str],
remark: Optional[str],
usage_unit: Optional[str] = None,
tenant_no: str,
user_id: Optional[str],
operate_time: datetime,
) -> None:
if qty <= 0:
raise ValueError("出库数量必须大于0")
if not (receiver or "").strip():
raise ValueError("请选择领用人")
batch = (
db.query(BizProductionMaterialStockBatch)
.filter(
BizProductionMaterialStockBatch.id == batch_id,
BizProductionMaterialStockBatch.tenant_no == tenant_no,
BizProductionMaterialStockBatch.del_flag == 0,
)
.with_for_update()
.first()
)
if not batch:
raise ValueError("入库批次不存在")
material = _get_material_for_update(db, batch.material_id, tenant_no)
if not _is_enabled_status(material.status):
raise ValueError(f"物料「{material.material_name}」已停用,无法出库")
rem = batch.remaining_qty or Decimal("0")
if rem < qty:
raise ValueError(
f"批次「{batch.stock_in_no}」库存不足,当前剩余 {rem},需出库 {qty}"
)
batch.remaining_qty = rem - qty
batch.update_by = user_id
batch.update_time = datetime.now()
db.add(batch)
stock_before = material.stock_qty or Decimal("0")
new_stock = stock_before - qty
material.stock_qty = new_stock
material.update_by = user_id
material.update_time = datetime.now()
db.add(material)
snaps = _usage_batch_snapshots(batch, out_qty=qty)
unit_label = (usage_unit or "").strip() or (batch.unit or "").strip() or None
usage = BizProductionMaterialUsage(
id=generate_uuid(),
material_id=material.id,
material_type=material.material_type,
material_code=material.material_code,
material_name=material.material_name,
change_type="use",
change_qty=-qty,
usage_unit=unit_label,
stock_before=stock_before,
stock_after=new_stock,
source_type="manual_out",
tenant_no=tenant_no,
receiver=(receiver or "").strip() or None,
purpose=(purpose or "").strip() or None,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id=material.create_dept_id or "",
create_time=operate_time,
update_by=user_id,
update_time=operate_time,
del_flag=0,
**snaps,
)
db.add(usage)
def batch_stock_out(
db: Session,
*,
items: List[Dict[str, Any]],
receiver: Optional[str] = None,
purpose: Optional[str] = None,
remark: Optional[str] = None,
tenant_no: str,
user_id: Optional[str] = None,
operate_time: Optional[datetime] = None,
) -> int:
if not items:
raise ValueError("请至少添加一条出库明细")
op_time = operate_time or datetime.now()
shared_remark = (remark or "").strip() or None
seen_batches: set = set()
try:
for it in items:
batch_id = (it.get("batch_id") or it.get("batchId") or "").strip()
if not batch_id:
raise ValueError("请选择入库批次")
if batch_id in seen_batches:
raise ValueError("同一入库批次不可重复添加")
seen_batches.add(batch_id)
qty = it.get("qty")
if qty is None or Decimal(str(qty)) <= 0:
raise ValueError("出库数量必须大于0")
qty_dec = Decimal(str(qty))
line_remark = (it.get("remark") or "").strip() or shared_remark
usage_unit = (it.get("usageUnit") or it.get("usage_unit") or "").strip() or None
_stock_out_batch(
db,
batch_id,
qty=qty_dec,
receiver=receiver,
purpose=purpose,
remark=line_remark,
usage_unit=usage_unit,
tenant_no=tenant_no,
user_id=user_id,
operate_time=op_time,
)
db.commit()
return len(items)
except Exception:
db.rollback()
raise
DISCARD_REASONS = frozenset({"过期", "质量问题", "污染/破损", "其他"})
def _validate_discard_reason(discard_reason: Optional[str], remark: Optional[str]) -> str:
reason = (discard_reason or "").strip()
if reason not in DISCARD_REASONS:
raise ValueError("请选择有效的废弃原因")
if reason == "其他" and not (remark or "").strip():
raise ValueError("选择「其他」时请填写备注说明")
return reason
def _discard_batch(
db: Session,
batch_id: str,
*,
qty: Decimal,
discard_reason: str,
remark: Optional[str],
usage_unit: Optional[str] = None,
tenant_no: str,
user_id: Optional[str],
operate_time: datetime,
) -> None:
if qty <= 0:
raise ValueError("废弃数量必须大于0")
batch = (
db.query(BizProductionMaterialStockBatch)
.filter(
BizProductionMaterialStockBatch.id == batch_id,
BizProductionMaterialStockBatch.tenant_no == tenant_no,
BizProductionMaterialStockBatch.del_flag == 0,
)
.with_for_update()
.first()
)
if not batch:
raise ValueError("入库批次不存在")
material = _get_material_for_update(db, batch.material_id, tenant_no)
if not _is_enabled_status(material.status):
raise ValueError(f"物料「{material.material_name}」已停用,无法废弃")
rem = batch.remaining_qty or Decimal("0")
if rem < qty:
raise ValueError(
f"批次「{batch.stock_in_no}」库存不足,当前剩余 {rem},需废弃 {qty}"
)
batch.remaining_qty = rem - qty
batch.update_by = user_id
batch.update_time = datetime.now()
db.add(batch)
stock_before = material.stock_qty or Decimal("0")
new_stock = stock_before - qty
material.stock_qty = new_stock
material.update_by = user_id
material.update_time = datetime.now()
db.add(material)
snaps = _usage_batch_snapshots(batch, out_qty=qty)
unit_label = (usage_unit or "").strip() or (batch.unit or "").strip() or None
usage = BizProductionMaterialUsage(
id=generate_uuid(),
material_id=material.id,
material_type=material.material_type,
material_code=material.material_code,
material_name=material.material_name,
change_type="discard",
change_qty=-qty,
usage_unit=unit_label,
stock_before=stock_before,
stock_after=new_stock,
source_type="manual_discard",
tenant_no=tenant_no,
purpose=discard_reason,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id=material.create_dept_id or "",
create_time=operate_time,
update_by=user_id,
update_time=operate_time,
del_flag=0,
**snaps,
)
db.add(usage)
def batch_discard(
db: Session,
*,
items: List[Dict[str, Any]],
discard_reason: Optional[str] = None,
remark: Optional[str] = None,
tenant_no: str,
user_id: Optional[str] = None,
operate_time: Optional[datetime] = None,
) -> int:
if not items:
raise ValueError("请至少添加一条废弃明细")
op_time = operate_time or datetime.now()
shared_remark = (remark or "").strip() or None
reason = _validate_discard_reason(discard_reason, shared_remark)
seen_batches: set = set()
try:
for it in items:
batch_id = (it.get("batch_id") or it.get("batchId") or "").strip()
if not batch_id:
raise ValueError("请选择入库批次")
if batch_id in seen_batches:
raise ValueError("同一入库批次不可重复添加")
seen_batches.add(batch_id)
qty = it.get("qty")
if qty is None or Decimal(str(qty)) <= 0:
raise ValueError("废弃数量必须大于0")
qty_dec = Decimal(str(qty))
line_remark = (it.get("remark") or "").strip() or shared_remark
if reason == "其他" and not line_remark:
raise ValueError("选择「其他」时请填写备注说明")
usage_unit = (it.get("usageUnit") or it.get("usage_unit") or "").strip() or None
_discard_batch(
db,
batch_id,
qty=qty_dec,
discard_reason=reason,
remark=line_remark,
usage_unit=usage_unit,
tenant_no=tenant_no,
user_id=user_id,
operate_time=op_time,
)
db.commit()
return len(items)
except Exception:
db.rollback()
raise
def get_batch(db: Session, batch_id: str, tenant_no: str) -> Optional[BizProductionMaterialStockBatch]:
return (
db.query(BizProductionMaterialStockBatch)
.filter(
BizProductionMaterialStockBatch.id == batch_id,
BizProductionMaterialStockBatch.tenant_no == tenant_no,
BizProductionMaterialStockBatch.del_flag == 0,
)
.first()
)
def update_batch(
db: Session,
batch_id: str,
*,
tenant_no: str,
user_id: Optional[str] = None,
stock_in_no: Optional[str] = None,
stock_in_date: Optional[Any] = None,
expire_date: Optional[Any] = None,
catalog_no: Optional[str] = None,
batch_no: Optional[str] = None,
manufacturer: Optional[str] = None,
storage_location: Optional[str] = None,
unit_price: Optional[Any] = None,
amount: Optional[Any] = None,
remark: Optional[str] = None,
material_code: Optional[str] = None,
material_name: Optional[str] = None,
spec_model: Optional[str] = None,
unit: Optional[str] = None,
warning_qty: Optional[Any] = None,
status: Optional[str] = None,
) -> BizProductionMaterialStockBatch:
from app.crud import production_material as mat_svc
batch = get_batch(db, batch_id, tenant_no)
if not batch:
raise ValueError("入库批次不存在")
material = _get_material_for_update(db, batch.material_id, tenant_no)
mat_data: Dict[str, Any] = {}
if material_code is not None:
mat_data["material_code"] = material_code
if material_name is not None:
mat_data["material_name"] = material_name
if spec_model is not None:
mat_data["spec_model"] = spec_model
if unit is not None:
mat_data["unit"] = unit
if warning_qty is not None:
mat_data["warning_qty"] = Decimal(str(warning_qty))
if status is not None:
mat_data["status"] = _norm_status(status)
if mat_data:
material = mat_svc.update_material(
db,
batch.material_id,
tenant_no=tenant_no,
user_id=user_id,
**mat_data,
)
if stock_in_no is not None:
sno = _require_str(stock_in_no, "入库编号")
if stock_in_no_exists(db, sno, tenant_no, exclude_id=batch_id):
raise ValueError(f"入库编号「{sno}」已存在")
batch.stock_in_no = sno
if stock_in_date is not None:
batch.stock_in_date = _parse_date(stock_in_date)
if expire_date is not None:
batch.expire_date = _parse_expire_date(expire_date)
if catalog_no is not None:
batch.catalog_no = _require_str(catalog_no, "货号")
if batch_no is not None:
batch.batch_no = _require_str(batch_no, "批号")
if manufacturer is not None:
batch.manufacturer = _require_str(manufacturer, "厂家")
if storage_location is not None:
batch.storage_location = _optional_str(storage_location)
if unit_price is not None:
batch.unit_price = _require_decimal(unit_price, "单价")
if amount is not None:
batch.amount = _require_decimal(amount, "金额")
if remark is not None:
batch.remark = (remark or "").strip() or None
batch.material_code = material.material_code
batch.material_name = material.material_name
batch.spec_model = material.spec_model
batch.unit = material.unit
batch.update_by = user_id
batch.update_time = datetime.now()
db.add(batch)
in_usage = (
db.query(BizProductionMaterialUsage)
.filter(
BizProductionMaterialUsage.batch_id == batch_id,
BizProductionMaterialUsage.tenant_no == tenant_no,
BizProductionMaterialUsage.del_flag == 0,
BizProductionMaterialUsage.change_type == "in",
BizProductionMaterialUsage.source_type.in_(["manual_in", "prep_in"]),
)
.first()
)
if in_usage:
in_usage.material_code = material.material_code
in_usage.material_name = material.material_name
in_usage.stock_in_no = batch.stock_in_no
in_usage.catalog_no = batch.catalog_no
in_usage.batch_no = batch.batch_no
in_usage.manufacturer = batch.manufacturer
in_usage.storage_location = batch.storage_location
in_usage.unit_price = batch.unit_price
in_usage.amount = batch.amount
in_usage.remark = batch.remark
in_usage.update_by = user_id
in_usage.update_time = datetime.now()
db.add(in_usage)
db.commit()
db.refresh(batch)
return batch
def delete_batch(
db: Session,
batch_id: str,
*,
tenant_no: str,
user_id: Optional[str] = None,
) -> None:
batch = get_batch(db, batch_id, tenant_no)
if not batch:
raise ValueError("入库批次不存在")
used = (
db.query(BizProductionMaterialUsage)
.filter(
BizProductionMaterialUsage.batch_id == batch_id,
BizProductionMaterialUsage.tenant_no == tenant_no,
BizProductionMaterialUsage.del_flag == 0,
BizProductionMaterialUsage.change_type == "use",
)
.count()
)
if used > 0:
raise ValueError("该批次已有领用或出库记录,无法删除")
material = _get_material_for_update(db, batch.material_id, tenant_no)
rem = batch.remaining_qty or Decimal("0")
material.stock_qty = (material.stock_qty or Decimal("0")) - rem
material.update_by = user_id
material.update_time = datetime.now()
db.add(material)
now = datetime.now()
batch.del_flag = 1
batch.update_by = user_id
batch.update_time = now
db.add(batch)
usages = (
db.query(BizProductionMaterialUsage)
.filter(
BizProductionMaterialUsage.batch_id == batch_id,
BizProductionMaterialUsage.tenant_no == tenant_no,
BizProductionMaterialUsage.del_flag == 0,
)
.all()
)
for u in usages:
u.del_flag = 1
u.update_by = user_id
u.update_time = now
db.add(u)
db.commit()
@@ -0,0 +1,478 @@
"""生产物料库存盘点 CRUD"""
from __future__ import annotations
from datetime import datetime
from decimal import Decimal
from typing import Any, Dict, List, Optional, Tuple
from sqlalchemy import func, or_
from sqlalchemy.orm import Session
from app.core.utils import generate_uuid
from app.crud.production_material_stock_batch import _dec, _fmt_date, _fmt_dt, _parse_date, _require_str
from app.models.models import SysUser
from app.models.production_material import (
BizProductionMaterialStockBatch,
BizProductionMaterialStockCheck,
BizProductionMaterialStockCheckBatchLine,
BizProductionMaterialStockCheckUnusedLine,
)
def _user_nick_name_map(db: Session, user_ids: List[str]) -> Dict[str, str]:
ids = list({x for x in user_ids if x})
if not ids:
return {}
rows = db.query(SysUser.id, SysUser.nick_name).filter(SysUser.id.in_(ids)).all()
return {u.id: (u.nick_name or "").strip() for u in rows}
def _status_label(status: str) -> str:
if status == "completed":
return "已完成"
if status == "cancelled":
return "已作废"
return "进行中"
def _batch_line_to_dict(row: BizProductionMaterialStockCheckBatchLine) -> Dict[str, Any]:
return {
"id": row.id,
"checkId": row.check_id,
"batchId": row.batch_id,
"materialId": row.material_id,
"materialType": row.material_type or "",
"materialCode": row.material_code or "",
"materialName": row.material_name or "",
"specModel": row.spec_model or "",
"unit": row.unit or "",
"stockInNo": row.stock_in_no or "",
"stockInDate": _fmt_date(row.stock_in_date),
"expireDate": _fmt_date(row.expire_date),
"catalogNo": row.catalog_no or "",
"batchNo": row.batch_no or "",
"manufacturer": row.manufacturer or "",
"storageLocation": row.storage_location or "",
"unitPrice": float(row.unit_price) if row.unit_price is not None else 0,
"amount": float(row.amount) if row.amount is not None else 0,
"remainingQty": _dec(row.remaining_qty),
"remainingAmount": _unused_amount(row.unit_price, row.remaining_qty),
"remark": row.remark or "",
}
def _unused_amount(unit_price: Any, qty: Any) -> float:
if unit_price is None:
return 0
return float((Decimal(str(unit_price)) * Decimal(str(qty))).quantize(Decimal("0.01")))
def _unused_line_to_dict(row: BizProductionMaterialStockCheckUnusedLine) -> Dict[str, Any]:
unit_price = float(row.unit_price) if row.unit_price is not None else None
unused_qty = _dec(row.unused_qty)
return {
"id": row.id,
"checkId": row.check_id,
"materialType": row.material_type or "",
"materialCode": row.material_code or "",
"materialName": row.material_name or "",
"specModel": row.spec_model or "",
"unit": row.unit or "",
"stockInNo": row.stock_in_no or "",
"stockInDate": _fmt_date(row.stock_in_date),
"expireDate": _fmt_date(row.expire_date),
"catalogNo": row.catalog_no or "",
"batchNo": row.batch_no or "",
"manufacturer": row.manufacturer or "",
"unitPrice": unit_price,
"remainingAmount": _unused_amount(row.unit_price, row.unused_qty) if unit_price is not None else None,
"holder": row.holder or "",
"unusedQty": unused_qty,
"remark": row.remark or "",
}
def _check_header_to_dict(
row: BizProductionMaterialStockCheck,
*,
create_by_name: str = "",
batch_line_count: int = 0,
unused_line_count: int = 0,
) -> Dict[str, Any]:
return {
"id": row.id,
"title": row.title or "",
"checkTime": _fmt_dt(row.check_time),
"status": row.status or "draft",
"statusLabel": _status_label(row.status or "draft"),
"completeTime": _fmt_dt(row.complete_time) if row.complete_time else "",
"remark": row.remark or "",
"batchLineCount": batch_line_count,
"unusedLineCount": unused_line_count,
"createBy": row.create_by or "",
"createByName": create_by_name or row.create_by or "",
"createTime": _fmt_dt(row.create_time),
"updateTime": _fmt_dt(row.update_time),
}
def _get_check(db: Session, check_id: str, tenant_no: str) -> Optional[BizProductionMaterialStockCheck]:
return (
db.query(BizProductionMaterialStockCheck)
.filter(
BizProductionMaterialStockCheck.id == check_id,
BizProductionMaterialStockCheck.tenant_no == tenant_no,
BizProductionMaterialStockCheck.del_flag == 0,
)
.first()
)
def _line_counts(db: Session, check_ids: List[str]) -> Dict[str, Tuple[int, int]]:
if not check_ids:
return {}
batch_rows = (
db.query(
BizProductionMaterialStockCheckBatchLine.check_id,
func.count(BizProductionMaterialStockCheckBatchLine.id),
)
.filter(
BizProductionMaterialStockCheckBatchLine.check_id.in_(check_ids),
BizProductionMaterialStockCheckBatchLine.del_flag == 0,
)
.group_by(BizProductionMaterialStockCheckBatchLine.check_id)
.all()
)
unused_rows = (
db.query(
BizProductionMaterialStockCheckUnusedLine.check_id,
func.count(BizProductionMaterialStockCheckUnusedLine.id),
)
.filter(
BizProductionMaterialStockCheckUnusedLine.check_id.in_(check_ids),
BizProductionMaterialStockCheckUnusedLine.del_flag == 0,
)
.group_by(BizProductionMaterialStockCheckUnusedLine.check_id)
.all()
)
batch_map = {cid: int(cnt) for cid, cnt in batch_rows}
unused_map = {cid: int(cnt) for cid, cnt in unused_rows}
out: Dict[str, Tuple[int, int]] = {}
for cid in check_ids:
out[cid] = (batch_map.get(cid, 0), unused_map.get(cid, 0))
return out
def list_checks(
db: Session,
tenant_no: str,
*,
page: int = 1,
page_size: int = 10,
keyword: Optional[str] = None,
status: Optional[str] = None,
start_time: Optional[str] = None,
end_time: Optional[str] = None,
user_info=None,
) -> Tuple[List[Dict[str, Any]], int]:
def _filtered():
q0 = db.query(BizProductionMaterialStockCheck).filter(
BizProductionMaterialStockCheck.tenant_no == tenant_no,
BizProductionMaterialStockCheck.del_flag == 0,
)
kw = (keyword or "").strip()
if kw:
q0 = q0.filter(BizProductionMaterialStockCheck.title.like(f"%{kw}%"))
st = (status or "").strip()
if st:
q0 = q0.filter(BizProductionMaterialStockCheck.status == st)
if start_time:
q0 = q0.filter(BizProductionMaterialStockCheck.check_time >= start_time)
if end_time:
q0 = q0.filter(BizProductionMaterialStockCheck.check_time <= end_time + " 23:59:59")
if user_info:
from app.core.data_scope import apply_data_scope
q0 = apply_data_scope(q0, BizProductionMaterialStockCheck, user_info, db, tenant_no)
return q0
total = _filtered().order_by(None).with_entities(func.count(BizProductionMaterialStockCheck.id)).scalar() or 0
page = max(1, page)
page_size = min(max(1, page_size), 100)
rows = (
_filtered()
.order_by(BizProductionMaterialStockCheck.check_time.desc(), BizProductionMaterialStockCheck.create_time.desc())
.offset((page - 1) * page_size)
.limit(page_size)
.all()
)
ids = [r.id for r in rows]
counts = _line_counts(db, ids)
name_map = _user_nick_name_map(db, [r.create_by for r in rows if r.create_by])
items = []
for r in rows:
bc, uc = counts.get(r.id, (0, 0))
items.append(
_check_header_to_dict(
r,
create_by_name=name_map.get(r.create_by or "", ""),
batch_line_count=bc,
unused_line_count=uc,
)
)
return items, int(total)
def get_check_detail(db: Session, check_id: str, tenant_no: str) -> Dict[str, Any]:
row = _get_check(db, check_id, tenant_no)
if not row:
raise ValueError("盘点单不存在")
bc, uc = _line_counts(db, [check_id]).get(check_id, (0, 0))
name_map = _user_nick_name_map(db, [row.create_by] if row.create_by else [])
batch_lines = (
db.query(BizProductionMaterialStockCheckBatchLine)
.filter(
BizProductionMaterialStockCheckBatchLine.check_id == check_id,
BizProductionMaterialStockCheckBatchLine.del_flag == 0,
)
.order_by(BizProductionMaterialStockCheckBatchLine.stock_in_no.asc())
.all()
)
unused_lines = (
db.query(BizProductionMaterialStockCheckUnusedLine)
.filter(
BizProductionMaterialStockCheckUnusedLine.check_id == check_id,
BizProductionMaterialStockCheckUnusedLine.del_flag == 0,
)
.order_by(BizProductionMaterialStockCheckUnusedLine.create_time.asc())
.all()
)
data = _check_header_to_dict(
row,
create_by_name=name_map.get(row.create_by or "", ""),
batch_line_count=bc,
unused_line_count=uc,
)
data["batchLines"] = [_batch_line_to_dict(x) for x in batch_lines]
data["unusedLines"] = [_unused_line_to_dict(x) for x in unused_lines]
return data
def _parse_check_time(v: Any) -> datetime:
if isinstance(v, datetime):
return v
s = str(v or "").strip()
if not s:
return datetime.now()
for fmt, length in (("%Y-%m-%d %H:%M:%S", 19), ("%Y-%m-%d", 10)):
try:
return datetime.strptime(s[:length], fmt)
except ValueError:
continue
raise ValueError("盘点时间格式无效")
def create_check(
db: Session,
*,
title: str,
tenant_no: str,
user_id: Optional[str] = None,
dept_id: str = "",
check_time: Optional[Any] = None,
remark: Optional[str] = None,
) -> Dict[str, Any]:
t = _require_str(title, "盘点标题")
op_time = datetime.now()
ck_time = _parse_check_time(check_time) if check_time else op_time
check = BizProductionMaterialStockCheck(
id=generate_uuid(),
title=t,
check_time=ck_time,
status="draft",
tenant_no=tenant_no,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id=dept_id or "",
create_time=op_time,
update_by=user_id,
update_time=op_time,
del_flag=0,
)
db.add(check)
batches = (
db.query(BizProductionMaterialStockBatch)
.filter(
BizProductionMaterialStockBatch.tenant_no == tenant_no,
BizProductionMaterialStockBatch.del_flag == 0,
BizProductionMaterialStockBatch.remaining_qty > 0,
)
.order_by(BizProductionMaterialStockBatch.stock_in_date.desc(), BizProductionMaterialStockBatch.create_time.desc())
.all()
)
for b in batches:
line = BizProductionMaterialStockCheckBatchLine(
id=generate_uuid(),
check_id=check.id,
batch_id=b.id,
material_id=b.material_id,
material_type=b.material_type,
material_code=b.material_code,
material_name=b.material_name,
spec_model=b.spec_model,
unit=b.unit,
stock_in_no=b.stock_in_no,
stock_in_date=b.stock_in_date,
expire_date=b.expire_date,
catalog_no=b.catalog_no,
batch_no=b.batch_no,
manufacturer=b.manufacturer,
storage_location=b.storage_location,
unit_price=b.unit_price,
amount=b.amount,
remaining_qty=b.remaining_qty,
tenant_no=tenant_no,
create_by=user_id,
create_dept_id=dept_id or "",
create_time=op_time,
update_by=user_id,
update_time=op_time,
del_flag=0,
)
db.add(line)
db.commit()
db.refresh(check)
return {
"id": check.id,
"batchLineCount": len(batches),
}
def _parse_optional_date(v: Any) -> Optional[Any]:
if v is None or str(v).strip() == "":
return None
return _parse_date(v, label="日期")
def save_unused_lines(
db: Session,
check_id: str,
*,
items: List[Dict[str, Any]],
tenant_no: str,
user_id: Optional[str] = None,
dept_id: str = "",
) -> int:
check = _get_check(db, check_id, tenant_no)
if not check:
raise ValueError("盘点单不存在")
if (check.status or "") != "draft":
raise ValueError("仅进行中的盘点单可登记未用完物料")
now = datetime.now()
old_rows = (
db.query(BizProductionMaterialStockCheckUnusedLine)
.filter(
BizProductionMaterialStockCheckUnusedLine.check_id == check_id,
BizProductionMaterialStockCheckUnusedLine.del_flag == 0,
)
.all()
)
for r in old_rows:
r.del_flag = 1
r.update_by = user_id
r.update_time = now
db.add(r)
count = 0
for it in items or []:
name = _require_str(it.get("material_name") or it.get("materialName"), "物料名称")
qty = it.get("unused_qty") if it.get("unused_qty") is not None else it.get("unusedQty")
if qty is None or Decimal(str(qty)) <= 0:
raise ValueError("未用完数量必须大于0")
qty_dec = Decimal(str(qty))
stock_in_date = _parse_optional_date(it.get("stock_in_date") or it.get("stockInDate"))
expire_date = _parse_optional_date(it.get("expire_date") or it.get("expireDate"))
row = BizProductionMaterialStockCheckUnusedLine(
id=generate_uuid(),
check_id=check_id,
material_type=(it.get("material_type") or it.get("materialType") or "").strip() or None,
material_code=(it.get("material_code") or it.get("materialCode") or "").strip() or None,
material_name=name,
spec_model=(it.get("spec_model") or it.get("specModel") or "").strip() or None,
unit=(it.get("unit") or "").strip() or None,
stock_in_no=(it.get("stock_in_no") or it.get("stockInNo") or "").strip() or None,
stock_in_date=stock_in_date,
expire_date=expire_date,
catalog_no=(it.get("catalog_no") or it.get("catalogNo") or "").strip() or None,
batch_no=(it.get("batch_no") or it.get("batchNo") or "").strip() or None,
manufacturer=(it.get("manufacturer") or "").strip() or None,
unit_price=(
Decimal(str(it.get("unit_price") or it.get("unitPrice")))
if (it.get("unit_price") is not None or it.get("unitPrice") is not None)
else None
),
holder=(it.get("holder") or "").strip() or None,
unused_qty=qty_dec,
tenant_no=tenant_no,
remark=(it.get("remark") or "").strip() or None,
create_by=user_id,
create_dept_id=dept_id or "",
create_time=now,
update_by=user_id,
update_time=now,
del_flag=0,
)
db.add(row)
count += 1
check.update_by = user_id
check.update_time = now
db.add(check)
db.commit()
return count
def complete_check(
db: Session,
check_id: str,
*,
tenant_no: str,
user_id: Optional[str] = None,
) -> None:
check = _get_check(db, check_id, tenant_no)
if not check:
raise ValueError("盘点单不存在")
if (check.status or "") != "draft":
raise ValueError("仅进行中的盘点单可完成")
now = datetime.now()
check.status = "completed"
check.complete_time = now
check.update_by = user_id
check.update_time = now
db.add(check)
db.commit()
def cancel_check(
db: Session,
check_id: str,
*,
tenant_no: str,
user_id: Optional[str] = None,
) -> None:
check = _get_check(db, check_id, tenant_no)
if not check:
raise ValueError("盘点单不存在")
if (check.status or "") != "draft":
raise ValueError("仅进行中的盘点单可作废")
now = datetime.now()
check.status = "cancelled"
check.update_by = user_id
check.update_time = now
db.add(check)
db.commit()
@@ -0,0 +1,893 @@
"""物料变动记录 CRUD"""
from __future__ import annotations
from datetime import datetime
from decimal import Decimal
from typing import Any, Dict, List, Optional, Tuple
from fastapi import HTTPException
from sqlalchemy import and_, func, or_
from sqlalchemy.orm import Session
from app.core.utils import generate_uuid
from app.crud.production_material import _filter_material_type
from app.models.production_material import BizProductionMaterial, BizProductionMaterialStockBatch, BizProductionMaterialUsage
from app.models.models import SysUser
from app.crud.production_material_stock_batch import _usage_batch_snapshots
def _parse_receiver_purpose_from_remark(remark: Optional[str]) -> Tuple[str, str]:
"""兼容旧数据:领用人/用途曾拼接在 remark 中。"""
receiver, purpose = "", ""
for part in (remark or "").split(";"):
seg = part.strip()
if seg.startswith("领用人:"):
receiver = seg[len("领用人:") :].strip()
elif seg.startswith("用途:"):
purpose = seg[len("用途:") :].strip()
return receiver, purpose
def _resolve_receiver_purpose(r: BizProductionMaterialUsage) -> Tuple[str, str]:
receiver = (getattr(r, "receiver", None) or "").strip()
purpose = (getattr(r, "purpose", None) or "").strip()
if receiver or purpose:
return receiver, purpose
if (r.source_type or "") == "manual_out":
return _parse_receiver_purpose_from_remark(r.remark)
return "", ""
def _display_remark(r: BizProductionMaterialUsage) -> str:
"""手动出库时备注仅展示用户填写内容,不含领用人/用途拼接段。"""
remark = (r.remark or "").strip()
if (r.source_type or "") != "manual_out" or not remark:
return remark
parts: List[str] = []
for part in remark.split(";"):
seg = part.strip()
if not seg or seg.startswith("领用人:") or seg.startswith("用途:"):
continue
if seg.startswith("备注"):
seg = seg[2:].strip() or seg
parts.append(seg)
return ";".join(parts) if parts else ""
def _user_nick_name_map(db: Session, user_ids: List[str]) -> Dict[str, str]:
ids = list({x for x in user_ids if x})
if not ids:
return {}
rows = db.query(SysUser.id, SysUser.nick_name).filter(SysUser.id.in_(ids)).all()
return {u.id: (u.nick_name or "").strip() for u in rows}
def _receiver_display_map(db: Session, receivers: List[str]) -> Dict[str, str]:
"""领用人字段可能是用户 ID 或昵称。"""
keys = list({(x or "").strip() for x in receivers if (x or "").strip()})
if not keys:
return {}
by_id = _user_nick_name_map(db, keys)
out: Dict[str, str] = {}
for k in keys:
out[k] = by_id.get(k) or k
return out
def _usage_unit_label(r: BizProductionMaterialUsage, batch: Optional[BizProductionMaterialStockBatch]) -> str:
u = (getattr(r, "usage_unit", None) or "").strip()
if u:
return u
if batch and (batch.unit or "").strip():
return (batch.unit or "").strip()
return ""
def _stock_in_date_for_row(r: BizProductionMaterialUsage, batch: Optional[BizProductionMaterialStockBatch]) -> str:
if batch and batch.stock_in_date:
return batch.stock_in_date.strftime("%Y-%m-%d")
return ""
def _unit_price_for_row(r: BizProductionMaterialUsage, batch: Optional[BizProductionMaterialStockBatch]) -> Optional[float]:
if r.unit_price is not None:
return float(r.unit_price)
if batch and batch.unit_price is not None:
return float(batch.unit_price)
return None
def _amount_for_row(r: BizProductionMaterialUsage, batch: Optional[BizProductionMaterialStockBatch]) -> Optional[float]:
is_in = (r.change_type or "") == "in"
if is_in:
if r.amount is not None:
return float(r.amount)
if batch and batch.amount is not None:
return float(batch.amount)
return None
unit_price = _unit_price_for_row(r, batch)
change_qty = float(r.change_qty) if r.change_qty is not None else 0
qty = abs(change_qty)
if unit_price is None or qty <= 0:
return None
return round(unit_price * qty, 2)
def _row_to_dict(
r: BizProductionMaterialUsage,
*,
create_by_name: str = "",
batch: Optional[BizProductionMaterialStockBatch] = None,
receiver_name: str = "",
requisition_receiver: str = "",
requisition_receiver_name: str = "",
) -> Dict[str, Any]:
create_by = r.create_by or ""
receiver, purpose = _resolve_receiver_purpose(r)
create_time = r.create_time.strftime("%Y-%m-%d %H:%M:%S") if r.create_time else ""
is_manual_out = (r.source_type or "") == "manual_out"
stock_after = float(r.stock_after) if r.stock_after is not None else 0
change_qty = float(r.change_qty) if r.change_qty is not None else 0
stock_before = (
float(r.stock_before)
if r.stock_before is not None
else stock_after - change_qty
)
usage_unit = _usage_unit_label(r, batch)
req_receiver = requisition_receiver or receiver
req_receiver_name = requisition_receiver_name or receiver_name or req_receiver
return {
"id": r.id,
"materialId": r.material_id,
"materialType": r.material_type or "",
"materialCode": r.material_code or "",
"materialName": r.material_name or "",
"batchId": r.batch_id or "",
"stockInNo": r.stock_in_no or "",
"stockInDate": _stock_in_date_for_row(r, batch),
"catalogNo": r.catalog_no or "",
"batchNo": r.batch_no or "",
"manufacturer": r.manufacturer or "",
"storageLocation": (r.storage_location or "").strip() or (batch.storage_location if batch else "") or "",
"unitPrice": _unit_price_for_row(r, batch),
"amount": _amount_for_row(r, batch),
"changeType": r.change_type,
"changeQty": change_qty,
"usageUnit": usage_unit,
"stockBefore": stock_before,
"stockAfter": stock_after,
"stepId": r.step_id or "",
"stepName": r.step_name or "",
"taskId": r.task_id or "",
"taskNo": r.task_no or "",
"parentUsageId": (r.parent_usage_id or "").strip(),
"requisitionUsageId": (r.parent_usage_id or "").strip(),
"prepId": (r.prep_id or "").strip(),
"receiver": receiver,
"receiverName": receiver_name or receiver,
"requisitionReceiver": req_receiver,
"requisitionReceiverName": req_receiver_name,
"purpose": purpose,
"sourceType": r.source_type or "",
"useTime": create_time if is_manual_out else "",
"remark": _display_remark(r),
"createBy": create_by,
"createByName": create_by_name or create_by,
"createTime": create_time,
"updateTime": r.update_time.strftime("%Y-%m-%d %H:%M:%S") if r.update_time else "",
}
def _batch_map(db: Session, batch_ids: List[str]) -> Dict[str, BizProductionMaterialStockBatch]:
ids = [x for x in batch_ids if x]
if not ids:
return {}
rows = (
db.query(BizProductionMaterialStockBatch)
.filter(BizProductionMaterialStockBatch.id.in_(ids), BizProductionMaterialStockBatch.del_flag == 0)
.all()
)
return {r.id: r for r in rows}
def _mine_usage_filter(user_id: str, nick_name: str):
"""当前登录人的领用记录:手动出库(领用人)或任务使用(填报人)。"""
uid = (user_id or "").strip()
nn = (nick_name or "").strip()
manual_conds = [BizProductionMaterialUsage.source_type == "manual_out"]
receiver_match: List[Any] = []
if nn:
receiver_match.append(BizProductionMaterialUsage.receiver == nn)
receiver_match.append(BizProductionMaterialUsage.remark.like(f"%领用人:{nn}%"))
if uid:
receiver_match.append(BizProductionMaterialUsage.receiver == uid)
if receiver_match:
manual_conds.append(or_(*receiver_match))
else:
manual_conds.append(BizProductionMaterialUsage.id == "")
task_conds = [
BizProductionMaterialUsage.source_type == "step_save",
BizProductionMaterialUsage.create_by == uid,
]
prep_conds = [
BizProductionMaterialUsage.source_type == "prep_consume",
BizProductionMaterialUsage.create_by == uid,
]
return and_(
BizProductionMaterialUsage.change_type == "use",
or_(and_(*manual_conds), and_(*task_conds), and_(*prep_conds)),
)
def _list_usages_query(
db: Session,
tenant_no: str,
*,
material_id: Optional[str] = None,
material_type: Optional[str] = None,
change_type: Optional[str] = None,
start_time: Optional[str] = None,
end_time: Optional[str] = None,
keyword: Optional[str] = None,
stock_in_no: Optional[str] = None,
user_info=None,
mine_user_id: Optional[str] = None,
mine_nick_name: Optional[str] = None,
):
q0 = db.query(BizProductionMaterialUsage).filter(
BizProductionMaterialUsage.tenant_no == tenant_no,
BizProductionMaterialUsage.del_flag == 0,
)
if mine_user_id is not None:
q0 = q0.filter(_mine_usage_filter(mine_user_id, mine_nick_name or ""))
if material_id:
q0 = q0.filter(BizProductionMaterialUsage.material_id == material_id)
mt = _filter_material_type(material_type)
if mt:
q0 = q0.filter(BizProductionMaterialUsage.material_type == mt)
ct = (change_type or "").strip()
if ct == "out":
q0 = q0.filter(
BizProductionMaterialUsage.change_type == "use",
BizProductionMaterialUsage.source_type == "manual_out",
)
elif ct == "use":
q0 = q0.filter(
BizProductionMaterialUsage.change_type == "use",
BizProductionMaterialUsage.source_type == "step_save",
)
elif ct == "in":
q0 = q0.filter(BizProductionMaterialUsage.change_type == "in")
elif ct == "discard":
q0 = q0.filter(BizProductionMaterialUsage.change_type == "discard")
sno = (stock_in_no or "").strip()
if sno:
q0 = q0.filter(BizProductionMaterialUsage.stock_in_no.like(f"%{sno}%"))
kw = (keyword or "").strip()
if kw:
like = f"%{kw}%"
q0 = q0.filter(
or_(
BizProductionMaterialUsage.material_code.like(like),
BizProductionMaterialUsage.material_name.like(like),
BizProductionMaterialUsage.stock_in_no.like(like),
BizProductionMaterialUsage.batch_no.like(like),
BizProductionMaterialUsage.catalog_no.like(like),
)
)
if start_time:
q0 = q0.filter(BizProductionMaterialUsage.create_time >= start_time)
if end_time:
q0 = q0.filter(BizProductionMaterialUsage.create_time <= end_time + " 23:59:59")
if user_info and mine_user_id is None:
from app.core.data_scope import apply_data_scope
q0 = apply_data_scope(q0, BizProductionMaterialUsage, user_info, db, tenant_no)
return q0
def _paginate_usages(db: Session, q0, *, page: int, page_size: int) -> Tuple[List[Dict[str, Any]], int]:
total = q0.order_by(None).with_entities(func.count(BizProductionMaterialUsage.id)).scalar() or 0
page = max(1, page)
page_size = min(max(1, page_size), 100)
rows = (
q0.order_by(BizProductionMaterialUsage.create_time.desc())
.offset((page - 1) * page_size)
.limit(page_size)
.all()
)
bmap = _batch_map(db, [x.batch_id for x in rows if x.batch_id])
name_map = _user_nick_name_map(db, [x.create_by for x in rows if x.create_by])
receivers = []
for x in rows:
rcv, _ = _resolve_receiver_purpose(x)
if rcv:
receivers.append(rcv)
receiver_map = _receiver_display_map(db, receivers)
return [
_row_to_dict(
x,
create_by_name=name_map.get(x.create_by or "", ""),
batch=bmap.get(x.batch_id or ""),
receiver_name=receiver_map.get(
(_resolve_receiver_purpose(x)[0] or ""), _resolve_receiver_purpose(x)[0] or ""
),
)
for x in rows
], int(total)
def list_usages(
db: Session,
tenant_no: str,
*,
page: int = 1,
page_size: int = 10,
material_id: Optional[str] = None,
material_type: Optional[str] = None,
change_type: Optional[str] = None,
start_time: Optional[str] = None,
end_time: Optional[str] = None,
keyword: Optional[str] = None,
stock_in_no: Optional[str] = None,
user_info=None,
) -> Tuple[List[Dict[str, Any]], int]:
q0 = _list_usages_query(
db,
tenant_no,
material_id=material_id,
material_type=material_type,
change_type=change_type,
start_time=start_time,
end_time=end_time,
keyword=keyword,
stock_in_no=stock_in_no,
user_info=user_info,
)
return _paginate_usages(db, q0, page=page, page_size=page_size)
def list_my_usages(
db: Session,
tenant_no: str,
*,
user_id: str,
nick_name: str = "",
page: int = 1,
page_size: int = 10,
material_id: Optional[str] = None,
material_type: Optional[str] = None,
change_type: Optional[str] = None,
start_time: Optional[str] = None,
end_time: Optional[str] = None,
keyword: Optional[str] = None,
stock_in_no: Optional[str] = None,
) -> Tuple[List[Dict[str, Any]], int]:
"""当前登录人的物料领用记录(手动出库 + 任务使用)。"""
q0 = _list_usages_query(
db,
tenant_no,
material_id=material_id,
material_type=material_type,
change_type=change_type,
start_time=start_time,
end_time=end_time,
keyword=keyword,
stock_in_no=stock_in_no,
mine_user_id=user_id,
mine_nick_name=nick_name,
)
return _paginate_usages(db, q0, page=page, page_size=page_size)
def list_usages_by_step(
db: Session,
step_id: str,
tenant_no: str,
*,
user_info=None,
) -> List[Dict[str, Any]]:
"""查询生产步骤关联的物料使用记录(step_save)。"""
q = db.query(BizProductionMaterialUsage).filter(
BizProductionMaterialUsage.tenant_no == tenant_no,
BizProductionMaterialUsage.del_flag == 0,
BizProductionMaterialUsage.step_id == step_id,
BizProductionMaterialUsage.change_type == "use",
BizProductionMaterialUsage.source_type == "step_save",
)
if user_info:
from app.core.data_scope import apply_data_scope
q = apply_data_scope(q, BizProductionMaterialUsage, user_info, db, tenant_no)
rows = q.order_by(BizProductionMaterialUsage.create_time.asc()).all()
bmap = _batch_map(db, [x.batch_id for x in rows if x.batch_id])
parent_ids = [x.parent_usage_id for x in rows if (x.parent_usage_id or "").strip()]
parent_map: Dict[str, BizProductionMaterialUsage] = {}
if parent_ids:
parents = (
db.query(BizProductionMaterialUsage)
.filter(
BizProductionMaterialUsage.id.in_(parent_ids),
BizProductionMaterialUsage.del_flag == 0,
)
.all()
)
parent_map = {p.id: p for p in parents}
parent_receivers = []
for p in parent_map.values():
rcv, _ = _resolve_receiver_purpose(p)
if rcv:
parent_receivers.append(rcv)
parent_receiver_map = _receiver_display_map(db, parent_receivers)
out: List[Dict[str, Any]] = []
for x in rows:
parent = parent_map.get((x.parent_usage_id or "").strip())
req_rcv, _ = _resolve_receiver_purpose(parent) if parent else ("", "")
req_rcv_name = parent_receiver_map.get(req_rcv, req_rcv) if req_rcv else ""
rcv, _ = _resolve_receiver_purpose(x)
out.append(
_row_to_dict(
x,
batch=bmap.get(x.batch_id or ""),
receiver_name=parent_receiver_map.get(rcv, rcv) if not parent else req_rcv_name,
requisition_receiver=req_rcv,
requisition_receiver_name=req_rcv_name,
)
)
return out
def list_linked_step_usages(
db: Session,
parent_usage_id: str,
tenant_no: str,
*,
user_info=None,
) -> List[Dict[str, Any]]:
"""查询领用记录关联的生产任务物料消耗(parent_usage_id → step_save)。"""
pid = (parent_usage_id or "").strip()
if not pid:
return []
parent = (
db.query(BizProductionMaterialUsage)
.filter(
BizProductionMaterialUsage.id == pid,
BizProductionMaterialUsage.tenant_no == tenant_no,
BizProductionMaterialUsage.del_flag == 0,
)
.first()
)
if not parent:
raise HTTPException(status_code=404, detail="领用记录不存在")
if (parent.source_type or "") != "manual_out":
return []
q = db.query(BizProductionMaterialUsage).filter(
BizProductionMaterialUsage.tenant_no == tenant_no,
BizProductionMaterialUsage.del_flag == 0,
BizProductionMaterialUsage.parent_usage_id == pid,
BizProductionMaterialUsage.change_type == "use",
BizProductionMaterialUsage.source_type == "step_save",
)
if user_info:
from app.core.data_scope import apply_data_scope
q = apply_data_scope(q, BizProductionMaterialUsage, user_info, db, tenant_no)
rows = q.order_by(BizProductionMaterialUsage.create_time.desc()).all()
bmap = _batch_map(db, [x.batch_id for x in rows if x.batch_id])
name_map = _user_nick_name_map(db, [x.create_by for x in rows if x.create_by])
return [
_row_to_dict(
x,
create_by_name=name_map.get(x.create_by or "", ""),
batch=bmap.get(x.batch_id or ""),
requisition_receiver_name="",
)
for x in rows
]
def revert_step_material_usages(
db: Session,
step_id: str,
tenant_no: str,
user_id: Optional[str] = None,
) -> None:
"""撤销步骤此前 step_save 扣减,便于重新填报物料使用。"""
rows = (
db.query(BizProductionMaterialUsage)
.filter(
BizProductionMaterialUsage.step_id == step_id,
BizProductionMaterialUsage.tenant_no == tenant_no,
BizProductionMaterialUsage.del_flag == 0,
BizProductionMaterialUsage.source_type == "step_save",
BizProductionMaterialUsage.change_type == "use",
)
.all()
)
if not rows:
return
now = datetime.now()
for r in rows:
if (r.parent_usage_id or "").strip():
r.del_flag = 1
r.update_by = user_id
r.update_time = now
continue
restore_qty = abs(r.change_qty) if r.change_qty is not None else Decimal("0")
if restore_qty <= 0:
r.del_flag = 1
r.update_by = user_id
r.update_time = now
continue
batch_id = (r.batch_id or "").strip()
if batch_id:
batch = (
db.query(BizProductionMaterialStockBatch)
.with_for_update()
.filter(
BizProductionMaterialStockBatch.id == batch_id,
BizProductionMaterialStockBatch.tenant_no == tenant_no,
BizProductionMaterialStockBatch.del_flag == 0,
)
.first()
)
if batch:
batch.remaining_qty = (batch.remaining_qty or Decimal("0")) + restore_qty
batch.update_by = user_id
batch.update_time = now
material = (
db.query(BizProductionMaterial)
.with_for_update()
.filter(
BizProductionMaterial.id == r.material_id,
BizProductionMaterial.tenant_no == tenant_no,
BizProductionMaterial.del_flag == 0,
)
.first()
)
if material:
material.stock_qty = (material.stock_qty or Decimal("0")) + restore_qty
material.update_by = user_id
material.update_time = now
r.del_flag = 1
r.update_by = user_id
r.update_time = now
def list_requisition_options(
db: Session,
tenant_no: str,
*,
keyword: Optional[str] = None,
material_type: Optional[str] = None,
limit: int = 50,
user_info=None,
) -> List[Dict[str, Any]]:
"""领用记录选项(manual_out),供生产步骤关联物料使用。"""
q0 = db.query(BizProductionMaterialUsage).filter(
BizProductionMaterialUsage.tenant_no == tenant_no,
BizProductionMaterialUsage.del_flag == 0,
BizProductionMaterialUsage.change_type == "use",
BizProductionMaterialUsage.source_type == "manual_out",
)
mt = _filter_material_type(material_type)
if mt:
q0 = q0.filter(BizProductionMaterialUsage.material_type == mt)
if user_info:
from app.core.data_scope import apply_data_scope
q0 = apply_data_scope(q0, BizProductionMaterialUsage, user_info, db, tenant_no)
kw = (keyword or "").strip()
if kw:
like = f"%{kw}%"
q0 = q0.filter(
or_(
BizProductionMaterialUsage.material_code.like(like),
BizProductionMaterialUsage.material_name.like(like),
BizProductionMaterialUsage.stock_in_no.like(like),
BizProductionMaterialUsage.batch_no.like(like),
BizProductionMaterialUsage.catalog_no.like(like),
BizProductionMaterialUsage.receiver.like(like),
)
)
limit = min(max(1, limit), 100)
rows = q0.order_by(BizProductionMaterialUsage.create_time.desc()).limit(limit).all()
bmap = _batch_map(db, [x.batch_id for x in rows if x.batch_id])
receivers = []
for r in rows:
rcv, _ = _resolve_receiver_purpose(r)
if rcv:
receivers.append(rcv)
receiver_map = _receiver_display_map(db, receivers)
options: List[Dict[str, Any]] = []
for r in rows:
batch = bmap.get(r.batch_id or "")
rcv, _ = _resolve_receiver_purpose(r)
rcv_name = receiver_map.get(rcv, rcv) if rcv else ""
qty_abs = abs(float(r.change_qty or 0))
unit = _usage_unit_label(r, batch)
use_time = r.create_time.strftime("%Y-%m-%d %H:%M:%S") if r.create_time else ""
unit_suffix = unit or ""
label = (
f"{use_time} {r.material_name or ''} / {r.stock_in_no or ''} "
f"/ 批号:{r.batch_no or '—'} / 领用:{qty_abs}{unit_suffix} / 领用人:{rcv_name or '—'}"
).strip()
options.append(
{
"id": r.id,
"label": label,
"materialId": r.material_id,
"materialType": r.material_type or "",
"materialName": r.material_name or "",
"stockInNo": r.stock_in_no or "",
"batchNo": r.batch_no or "",
"batchId": r.batch_id or "",
"receiver": rcv,
"receiverName": rcv_name,
"requisitionQty": qty_abs,
"usageUnit": unit,
"useTime": use_time,
}
)
return options
def _record_step_usage_from_requisition(
db: Session,
step_id: str,
step_name: str,
task_id: str,
task_no: str,
item: Dict[str, Any],
tenant_no: str,
user_id: Optional[str] = None,
dept_id: str = "",
) -> None:
req_id = (
item.get("requisitionUsageId")
or item.get("requisition_usage_id")
or item.get("parentUsageId")
or item.get("parent_usage_id")
or ""
).strip()
if not req_id:
raise HTTPException(status_code=400, detail="请选择领用记录")
qty = item.get("qty")
if qty is None or Decimal(str(qty)) <= 0:
raise HTTPException(status_code=400, detail="物料使用数量必须大于0")
qty_dec = Decimal(str(qty))
req = (
db.query(BizProductionMaterialUsage)
.filter(
BizProductionMaterialUsage.id == req_id,
BizProductionMaterialUsage.tenant_no == tenant_no,
BizProductionMaterialUsage.del_flag == 0,
BizProductionMaterialUsage.source_type == "manual_out",
BizProductionMaterialUsage.change_type == "use",
)
.first()
)
if not req:
raise HTTPException(status_code=400, detail="领用记录不存在或已失效")
material = (
db.query(BizProductionMaterial)
.filter(
BizProductionMaterial.id == req.material_id,
BizProductionMaterial.tenant_no == tenant_no,
BizProductionMaterial.del_flag == 0,
)
.first()
)
if not material:
raise HTTPException(status_code=400, detail="关联物料不存在")
usage_unit = (
str(item.get("usageUnit") or item.get("usage_unit") or "").strip()
or _usage_unit_label(req, None)
or ""
)[:32]
stock_qty = material.stock_qty if material.stock_qty is not None else Decimal("0")
usage_remark = str(item.get("remark") or "").strip()[:512]
now = datetime.now()
usage = BizProductionMaterialUsage(
id=generate_uuid(),
material_id=req.material_id,
material_type=req.material_type or material.material_type,
material_code=req.material_code or material.material_code,
material_name=req.material_name or material.material_name,
batch_id=req.batch_id,
stock_in_no=req.stock_in_no,
catalog_no=req.catalog_no,
batch_no=req.batch_no,
manufacturer=req.manufacturer,
storage_location=req.storage_location,
unit_price=req.unit_price,
amount=req.amount,
change_type="use",
change_qty=-qty_dec,
usage_unit=usage_unit or None,
stock_before=stock_qty,
stock_after=stock_qty,
step_id=step_id,
step_name=step_name,
task_id=task_id,
task_no=task_no,
parent_usage_id=req_id,
source_type="step_save",
tenant_no=tenant_no,
remark=usage_remark,
create_by=user_id,
create_dept_id=dept_id,
create_time=now,
update_by=user_id,
update_time=now,
del_flag=0,
)
db.add(usage)
def _deduct_step_usage_legacy_batch(
db: Session,
step_id: str,
step_name: str,
task_id: str,
task_no: str,
item: Dict[str, Any],
tenant_no: str,
user_id: Optional[str] = None,
dept_id: str = "",
) -> None:
"""旧版:按入库批次扣减库存(兼容历史数据)。"""
batch_id = (item.get("batchId") or item.get("batch_id") or "").strip()
qty = item.get("qty")
if not batch_id:
raise HTTPException(status_code=400, detail="入库批次不能为空")
if qty is None or Decimal(str(qty)) <= 0:
raise HTTPException(status_code=400, detail="物料使用数量必须大于0")
qty_dec = Decimal(str(qty))
batch = (
db.query(BizProductionMaterialStockBatch)
.with_for_update()
.filter(
BizProductionMaterialStockBatch.id == batch_id,
BizProductionMaterialStockBatch.tenant_no == tenant_no,
BizProductionMaterialStockBatch.del_flag == 0,
)
.first()
)
if not batch:
raise HTTPException(status_code=400, detail=f"入库批次不存在(ID: {batch_id})")
rem = batch.remaining_qty or Decimal("0")
if rem < qty_dec:
raise HTTPException(
status_code=400,
detail=f"批次「{batch.stock_in_no}」库存不足,当前剩余 {rem},需使用 {qty_dec}",
)
material = (
db.query(BizProductionMaterial)
.with_for_update()
.filter(
BizProductionMaterial.id == batch.material_id,
BizProductionMaterial.tenant_no == tenant_no,
BizProductionMaterial.del_flag == 0,
BizProductionMaterial.status == "1",
)
.first()
)
if not material:
raise HTTPException(status_code=400, detail="物料不存在或已停用")
batch.remaining_qty = rem - qty_dec
batch.update_by = user_id
batch.update_time = datetime.now()
db.add(batch)
stock_qty = material.stock_qty if material.stock_qty is not None else Decimal("0")
if stock_qty < qty_dec:
raise HTTPException(
status_code=400,
detail=f"物料「{material.material_name}」汇总库存不足",
)
new_stock = stock_qty - qty_dec
material.stock_qty = new_stock
material.update_by = user_id
material.update_time = datetime.now()
db.add(material)
usage_remark = str(item.get("remark") or "").strip()[:512]
usage_unit = str(item.get("usageUnit") or item.get("usage_unit") or "").strip()[:32] or None
snaps = _usage_batch_snapshots(batch, out_qty=qty_dec)
usage = BizProductionMaterialUsage(
id=generate_uuid(),
material_id=material.id,
material_type=material.material_type,
material_code=material.material_code,
material_name=material.material_name,
change_type="use",
change_qty=-qty_dec,
usage_unit=usage_unit,
stock_before=stock_qty,
stock_after=new_stock,
step_id=step_id,
step_name=step_name,
task_id=task_id,
task_no=task_no,
source_type="step_save",
tenant_no=tenant_no,
remark=usage_remark,
create_by=user_id,
create_dept_id=dept_id,
create_time=datetime.now(),
update_by=user_id,
update_time=datetime.now(),
del_flag=0,
**snaps,
)
db.add(usage)
def register_step_usage_from_requisition(
db: Session,
step_id: str,
step_name: str,
task_id: str,
task_no: str,
material_usages: List[Dict[str, Any]],
tenant_no: str,
user_id: Optional[str] = None,
dept_id: str = "",
) -> None:
"""登记步骤物料使用;关联领用记录时不扣减库存。调用方控制事务,本函数不 commit。"""
revert_step_material_usages(db, step_id, tenant_no, user_id=user_id)
seen_requisition: set = set()
seen_batch: set = set()
for item in material_usages:
req_id = (
item.get("requisitionUsageId")
or item.get("requisition_usage_id")
or item.get("parentUsageId")
or ""
).strip()
if req_id:
if req_id in seen_requisition:
raise HTTPException(status_code=400, detail="物料列表中存在重复领用记录,请检查")
seen_requisition.add(req_id)
_record_step_usage_from_requisition(
db,
step_id,
step_name,
task_id,
task_no,
item,
tenant_no,
user_id=user_id,
dept_id=dept_id,
)
continue
batch_id = (item.get("batchId") or item.get("batch_id") or "").strip()
if not batch_id:
raise HTTPException(status_code=400, detail="请选择领用记录")
if batch_id in seen_batch:
raise HTTPException(status_code=400, detail="物料列表中存在重复入库批次,请检查")
seen_batch.add(batch_id)
_deduct_step_usage_legacy_batch(
db,
step_id,
step_name,
task_id,
task_no,
item,
tenant_no,
user_id=user_id,
dept_id=dept_id,
)
+484 -32
View File
@@ -24,10 +24,12 @@ from app.models.models import (
BizProcessRouteStepOutput,
BizProcessRouteStepReagent,
BizProductionTask,
BizProductionTaskHandover,
BizProductionTaskInput,
BizProductionTaskOutput,
BizProductionTaskStep,
BizProductionTaskStepConsumable,
BizProductionTaskStepConfiguredReagent,
BizProductionTaskStepDataCollection,
BizProductionTaskStepOutput,
BizProductionTaskStepReagent,
@@ -35,12 +37,39 @@ from app.models.models import (
BizProtocolSample,
BizSampleReception,
BizStorageSlotOccupancy,
SysUser,
)
from app.crud import storage_occupancy as occupancy_svc
from app.crud.cell_product import _row_to_dict as _cp_row_to_dict, _enrich_product_dicts as _cp_enrich
from app.models.research_donation import BizResearchDonation, BizResearchDonationSample
def _require_requisition_for_catalog_material(
db: Session,
tenant_no: str,
material_code: Optional[str],
material_type: str,
actual_usage: Optional[str],
requisition_usage_id: Optional[str],
) -> None:
code = (material_code or "").strip()
actual = (actual_usage or "").strip()
req_id = (requisition_usage_id or "").strip()
if not code or not actual or req_id:
return
from app.models.production_material import BizProductionMaterial
catalog_row = db.query(BizProductionMaterial).filter(
and_(
BizProductionMaterial.material_code == code,
BizProductionMaterial.material_type == material_type,
BizProductionMaterial.tenant_no == tenant_no,
BizProductionMaterial.del_flag == 0,
)
).first()
if catalog_row:
raise ValueError(f"物料「{code}」需选择领用记录")
_PROTOCOL_STATUS_LABELS = {
"dsx": "待生效", "sxz": "生效中", "ygq": "已过期", "yzf": "已作废", "zky": "转科研"
}
@@ -200,6 +229,8 @@ def _task_to_dict(t: BizProductionTask, *, work_order_no: str = "") -> Dict[str,
"description": t.description or "",
"routeId": t.route_id or "",
"taskStatus": t.task_status,
"currentAssigneeUserId": t.current_assignee_user_id or "",
"currentAssigneeUserName": "",
"startedTime": _fmt_dt(t.started_time),
"completedTime": _fmt_dt(t.completed_time),
"conclusion": (getattr(t, "conclusion", None) or "").strip(),
@@ -243,12 +274,29 @@ def _step_reagent_to_dict(r: BizProductionTaskStepReagent) -> Dict[str, Any]:
"standardUsage": r.standard_usage or "",
"actualUsage": r.actual_usage or "",
"unit": r.unit or "",
"requisitionUsageId": (r.requisition_usage_id or "").strip(),
"isKeyMaterial": r.is_key_material if r.is_key_material is not None else "0",
"orderNum": r.order_num if r.order_num is not None else 0,
"remark": r.remark or "",
}
def _step_configured_reagent_to_dict(r: BizProductionTaskStepConfiguredReagent) -> Dict[str, Any]:
return {
"id": r.id,
"stepId": r.step_id,
"configuredReagentCode": r.configured_reagent_code or "",
"configuredReagentName": r.configured_reagent_name or "",
"spec": r.spec or "",
"standardUsage": r.standard_usage or "",
"actualUsage": r.actual_usage or "",
"unit": r.unit or "",
"requisitionUsageId": (r.requisition_usage_id or "").strip(),
"orderNum": r.order_num if r.order_num is not None else 0,
"remark": r.remark or "",
}
def _step_consumable_to_dict(c: BizProductionTaskStepConsumable) -> Dict[str, Any]:
return {
"id": c.id,
@@ -259,6 +307,7 @@ def _step_consumable_to_dict(c: BizProductionTaskStepConsumable) -> Dict[str, An
"standardUsage": c.standard_usage or "",
"actualUsage": c.actual_usage or "",
"unit": c.unit or "",
"requisitionUsageId": (c.requisition_usage_id or "").strip(),
"isRequired": c.is_required if c.is_required is not None else "1",
"orderNum": c.order_num if c.order_num is not None else 0,
"remark": c.remark or "",
@@ -372,9 +421,13 @@ def _step_sub_tables_to_dict(db: Session, step_id: str) -> Dict[str, Any]:
data_collections = db.query(BizProductionTaskStepDataCollection).filter(
and_(BizProductionTaskStepDataCollection.step_id == step_id, BizProductionTaskStepDataCollection.del_flag == 0)
).order_by(BizProductionTaskStepDataCollection.order_num.asc(), BizProductionTaskStepDataCollection.create_time.asc()).all()
configured_reagents = db.query(BizProductionTaskStepConfiguredReagent).filter(
and_(BizProductionTaskStepConfiguredReagent.step_id == step_id, BizProductionTaskStepConfiguredReagent.del_flag == 0)
).order_by(BizProductionTaskStepConfiguredReagent.order_num.asc(), BizProductionTaskStepConfiguredReagent.create_time.asc()).all()
return {
"reagents": [_step_reagent_to_dict(r) for r in reagents],
"consumables": [_step_consumable_to_dict(c) for c in consumables],
"configuredReagents": [_step_configured_reagent_to_dict(r) for r in configured_reagents],
"outputs": [_step_output_to_dict(o) for o in outputs],
"dataCollections": [_step_data_collection_to_dict(d) for d in data_collections],
}
@@ -502,6 +555,215 @@ def _clone_route_to_task(
_clone_step_data_collections(db, rs.id, new_step.id, tenant_no, user_id, now)
def _validate_assignee_user_id(db: Session, user_id: str, tenant_no: str) -> str:
uid = (user_id or "").strip()
if not uid:
raise ValueError("请选择负责人")
row = (
db.query(SysUser.id)
.filter(
SysUser.id == uid,
SysUser.tenant_no == tenant_no,
SysUser.del_flag == 0,
SysUser.status == "1",
)
.first()
)
if not row:
raise ValueError("负责人用户无效或已停用")
return uid
def _enrich_assignee_names(db: Session, items: List[Dict[str, Any]]) -> None:
user_ids = list({(x.get("currentAssigneeUserId") or "").strip() for x in items if (x.get("currentAssigneeUserId") or "").strip()})
if not user_ids:
return
rows = (
db.query(SysUser.id, SysUser.nick_name)
.filter(SysUser.id.in_(user_ids), SysUser.del_flag == 0)
.all()
)
name_map = {r.id: (r.nick_name or "").strip() for r in rows}
for item in items:
uid = (item.get("currentAssigneeUserId") or "").strip()
if uid:
item["currentAssigneeUserName"] = name_map.get(uid, "")
def _enrich_handover_times(
db: Session,
items: List[Dict[str, Any]],
*,
from_user_id: str,
tenant_no: str,
) -> None:
task_ids = [x.get("id") for x in items if x.get("id")]
if not task_ids:
return
rows = (
db.query(
BizProductionTaskHandover.task_id,
func.max(BizProductionTaskHandover.handover_time),
)
.filter(
BizProductionTaskHandover.task_id.in_(task_ids),
BizProductionTaskHandover.from_user_id == from_user_id,
BizProductionTaskHandover.tenant_no == tenant_no,
BizProductionTaskHandover.del_flag == 0,
)
.group_by(BizProductionTaskHandover.task_id)
.all()
)
time_map = {r[0]: _fmt_dt(r[1]) for r in rows}
for item in items:
item["handoverTime"] = time_map.get(item.get("id"), "")
def get_production_task_row(
db: Session, task_id: str, tenant_no: str
) -> Optional[BizProductionTask]:
return (
db.query(BizProductionTask)
.filter(
BizProductionTask.id == task_id,
BizProductionTask.tenant_no == tenant_no,
BizProductionTask.del_flag == 0,
)
.first()
)
def assert_task_assignee(
db: Session, task_id: str, user_id: str, tenant_no: str
) -> BizProductionTask:
task = get_production_task_row(db, task_id, tenant_no)
if not task:
raise ValueError("任务不存在")
if (task.current_assignee_user_id or "") != (user_id or ""):
raise PermissionError("非当前任务负责人,无权操作")
return task
def _record_task_handover(
db: Session,
*,
task_id: str,
from_user_id: str,
to_user_id: str,
tenant_no: str,
operator_id: Optional[str],
create_dept_id: str,
remark: Optional[str] = None,
) -> None:
now = datetime.now()
db.add(
BizProductionTaskHandover(
id=generate_uuid(),
task_id=task_id,
from_user_id=from_user_id,
to_user_id=to_user_id,
handover_time=now,
remark=(remark or "").strip() or None,
tenant_no=tenant_no,
order_num=0,
create_by=operator_id,
create_dept_id=create_dept_id or "",
create_time=now,
update_by=operator_id,
update_time=now,
del_flag=0,
)
)
def forward_production_task(
db: Session,
task_id: str,
*,
from_user_id: str,
to_user_id: str,
tenant_no: str,
operator_id: Optional[str] = None,
create_dept_id: str = "",
remark: Optional[str] = None,
require_assignee: bool = True,
) -> BizProductionTask:
to_uid = _validate_assignee_user_id(db, to_user_id, tenant_no)
from_uid = (from_user_id or "").strip()
if not from_uid:
raise ValueError("转出用户无效")
if from_uid == to_uid:
raise ValueError("不能转发给自己")
if require_assignee:
task = assert_task_assignee(db, task_id, from_uid, tenant_no)
else:
task = get_production_task_row(db, task_id, tenant_no)
if not task:
raise ValueError("任务不存在")
handover_from = (task.current_assignee_user_id or from_uid).strip() or from_uid
_record_task_handover(
db,
task_id=task_id,
from_user_id=handover_from,
to_user_id=to_uid,
tenant_no=tenant_no,
operator_id=operator_id,
create_dept_id=create_dept_id,
remark=remark,
)
task.current_assignee_user_id = to_uid
task.update_by = operator_id
task.update_time = datetime.now()
db.add(task)
db.flush()
return task
def reassign_production_task(
db: Session,
task_id: str,
*,
assignee_user_id: str,
tenant_no: str,
operator_id: Optional[str] = None,
create_dept_id: str = "",
remark: Optional[str] = None,
) -> BizProductionTask:
task = get_production_task_row(db, task_id, tenant_no)
if not task:
raise ValueError("任务不存在")
to_uid = _validate_assignee_user_id(db, assignee_user_id, tenant_no)
from_uid = (task.current_assignee_user_id or operator_id or "").strip()
if from_uid and from_uid != to_uid:
_record_task_handover(
db,
task_id=task_id,
from_user_id=from_uid,
to_user_id=to_uid,
tenant_no=tenant_no,
operator_id=operator_id,
create_dept_id=create_dept_id,
remark=(remark or "").strip() or "管理员改派",
)
elif not from_uid:
_record_task_handover(
db,
task_id=task_id,
from_user_id=operator_id or to_uid,
to_user_id=to_uid,
tenant_no=tenant_no,
operator_id=operator_id,
create_dept_id=create_dept_id,
remark=(remark or "").strip() or "管理员改派",
)
task.current_assignee_user_id = to_uid
task.update_by = operator_id
task.update_time = datetime.now()
db.add(task)
db.flush()
return task
def create_production_task(
db: Session, *, tenant_no: str, user_id: Optional[str] = None,
create_dept_id: str = "", data: Dict[str, Any],
@@ -531,6 +793,9 @@ def create_production_task(
if not (data.get("task_type") or "").strip():
task_type = "outbound"
assignee_raw = (data.get("assignee_user_id") or data.get("assigneeUserId") or "").strip()
assignee_user_id = _validate_assignee_user_id(db, assignee_raw, tenant_no)
task_no = _generate_task_no(db, tenant_no)
now = datetime.now()
task = BizProductionTask(
@@ -543,6 +808,7 @@ def create_production_task(
description=(data.get("description") or "").strip() or None,
route_id=data.get("route_id") or None,
task_status="dpz",
current_assignee_user_id=assignee_user_id,
remark=(data.get("remark") or "").strip() or None,
attachments=(data.get("attachments") or "").strip() or None,
tenant_no=tenant_no,
@@ -586,6 +852,9 @@ def list_production_tasks(
task_status: Optional[str] = None,
started_time_start: Optional[str] = None,
started_time_end: Optional[str] = None,
current_assignee_user_id: Optional[str] = None,
mine_history_user_id: Optional[str] = None,
work_order_type: Optional[str] = None,
user_info=None,
) -> Tuple[List[Dict[str, Any]], int]:
def _filtered():
@@ -593,6 +862,7 @@ def list_production_tasks(
BizProductionTask.tenant_no == tenant_no,
BizProductionTask.del_flag == 0,
)
joined_wo = False
kw = (keyword or "").strip()
if kw:
like = f"%{kw}%"
@@ -614,6 +884,7 @@ def list_production_tasks(
BizProductionWorkOrder.del_flag == 0,
),
).filter(or_(*keyword_conditions))
joined_wo = True
elif task_no and task_no.strip():
q = q.filter(BizProductionTask.task_no.like(f"%{task_no.strip()}%"))
if work_order_id and work_order_id.strip():
@@ -630,6 +901,37 @@ def list_production_tasks(
BizProductionTask.started_time
<= _normalize_date_bound(started_time_end.strip(), end_of_day=True)
)
ca_uid = (current_assignee_user_id or "").strip()
if ca_uid:
q = q.filter(BizProductionTask.current_assignee_user_id == ca_uid)
mh_uid = (mine_history_user_id or "").strip()
if mh_uid:
handover_task_ids = (
db.query(BizProductionTaskHandover.task_id)
.filter(
BizProductionTaskHandover.from_user_id == mh_uid,
BizProductionTaskHandover.tenant_no == tenant_no,
BizProductionTaskHandover.del_flag == 0,
)
.distinct()
.subquery()
)
q = q.filter(
BizProductionTask.current_assignee_user_id != mh_uid,
BizProductionTask.id.in_(handover_task_ids),
)
wo_type = (work_order_type or "").strip()
if wo_type:
if not joined_wo:
q = q.join(
BizProductionWorkOrder,
and_(
BizProductionWorkOrder.id == BizProductionTask.work_order_id,
BizProductionWorkOrder.del_flag == 0,
),
)
joined_wo = True
q = q.filter(BizProductionWorkOrder.work_order_type == wo_type)
if user_info:
from app.core.data_scope import apply_data_scope
q = apply_data_scope(q, BizProductionTask, user_info, db, tenant_no)
@@ -832,9 +1134,51 @@ def list_production_tasks(
_rs = source
item["receptionSource"] = _rs
item["receptionSourceLabel"] = _RECEPTION_SOURCE_LABELS.get(_rs, _rs)
_enrich_assignee_names(db, items)
return items, int(total)
def list_mine_production_tasks(
db: Session,
*,
assignee_user_id: str,
tenant_no: str,
scope: str = "current",
page: int = 1,
page_size: int = 10,
keyword: Optional[str] = None,
task_status: Optional[str] = None,
work_order_type: Optional[str] = None,
) -> Tuple[List[Dict[str, Any]], int]:
uid = (assignee_user_id or "").strip()
if not uid:
return [], 0
sc = (scope or "current").strip().lower()
if sc == "history":
items, total = list_production_tasks(
db,
tenant_no=tenant_no,
page=page,
page_size=page_size,
keyword=keyword,
task_status=task_status,
mine_history_user_id=uid,
work_order_type=work_order_type,
)
_enrich_handover_times(db, items, from_user_id=uid, tenant_no=tenant_no)
return items, total
return list_production_tasks(
db,
tenant_no=tenant_no,
page=page,
page_size=page_size,
keyword=keyword,
task_status=task_status,
current_assignee_user_id=uid,
work_order_type=work_order_type,
)
def get_production_task_detail(db: Session, task_id: str, tenant_no: str) -> Optional[Dict[str, Any]]:
task = db.query(BizProductionTask).filter(
and_(
@@ -903,9 +1247,13 @@ def get_production_task_detail(db: Session, task_id: str, tenant_no: str) -> Opt
data_collections = db.query(BizProductionTaskStepDataCollection).filter(
and_(BizProductionTaskStepDataCollection.step_id == s.id, BizProductionTaskStepDataCollection.del_flag == 0)
).order_by(BizProductionTaskStepDataCollection.order_num.asc(), BizProductionTaskStepDataCollection.create_time.asc()).all()
configured_reagents = db.query(BizProductionTaskStepConfiguredReagent).filter(
and_(BizProductionTaskStepConfiguredReagent.step_id == s.id, BizProductionTaskStepConfiguredReagent.del_flag == 0)
).order_by(BizProductionTaskStepConfiguredReagent.order_num.asc(), BizProductionTaskStepConfiguredReagent.create_time.asc()).all()
sd["reagents"] = [_step_reagent_to_dict(r) for r in reagents]
sd["consumables"] = [_step_consumable_to_dict(c) for c in consumables]
sd["configuredReagents"] = [_step_configured_reagent_to_dict(r) for r in configured_reagents]
sd["outputs"] = [_step_output_to_dict(o) for o in outputs]
sd["dataCollections"] = [_step_data_collection_to_dict(d) for d in data_collections]
step_list.append(sd)
@@ -1222,9 +1570,13 @@ def add_task_step(
data_collections = db.query(BizProductionTaskStepDataCollection).filter(
and_(BizProductionTaskStepDataCollection.step_id == step.id, BizProductionTaskStepDataCollection.del_flag == 0)
).order_by(BizProductionTaskStepDataCollection.order_num.asc(), BizProductionTaskStepDataCollection.create_time.asc()).all()
configured_reagents = db.query(BizProductionTaskStepConfiguredReagent).filter(
and_(BizProductionTaskStepConfiguredReagent.step_id == step.id, BizProductionTaskStepConfiguredReagent.del_flag == 0)
).order_by(BizProductionTaskStepConfiguredReagent.order_num.asc(), BizProductionTaskStepConfiguredReagent.create_time.asc()).all()
result["reagents"] = [_step_reagent_to_dict(r) for r in reagents]
result["consumables"] = [_step_consumable_to_dict(c) for c in consumables]
result["configuredReagents"] = [_step_configured_reagent_to_dict(r) for r in configured_reagents]
result["outputs"] = [_step_output_to_dict(o) for o in outputs]
result["dataCollections"] = [_step_data_collection_to_dict(d) for d in data_collections]
return result
@@ -1285,6 +1637,7 @@ def delete_task_step(db: Session, step_id: str, tenant_no: str, user_id: Optiona
db.add(step)
_soft_delete_sub(db, BizProductionTaskStepReagent, "step_id", step_id, now)
_soft_delete_sub(db, BizProductionTaskStepConsumable, "step_id", step_id, now)
_soft_delete_sub(db, BizProductionTaskStepConfiguredReagent, "step_id", step_id, now)
_soft_delete_sub(db, BizProductionTaskStepOutput, "step_id", step_id, now)
_soft_delete_sub(db, BizProductionTaskStepDataCollection, "step_id", step_id, now)
db.commit()
@@ -1314,11 +1667,19 @@ def replace_step_reagents(
try:
_soft_delete_sub(db, BizProductionTaskStepReagent, "step_id", step_id, now)
# Revert previous step_save stock deductions
from app.crud import reagent_stock_log as reagent_stock_log_crud
reagent_stock_log_crud.revert_step_stock_changes(db, step_id, tenant_no, user_id)
usage_items: List[Dict[str, Any]] = []
for idx, it in enumerate(items):
req_id = (
(it.get("requisition_usage_id") or it.get("requisitionUsageId") or "").strip()
)
_require_requisition_for_catalog_material(
db,
tenant_no,
it.get("reagent_code"),
"reagent",
it.get("actual_usage"),
req_id,
)
db.add(BizProductionTaskStepReagent(
id=generate_uuid(), step_id=step_id, tenant_no=tenant_no,
reagent_code=(it.get("reagent_code") or "").strip() or None,
@@ -1327,15 +1688,23 @@ def replace_step_reagents(
standard_usage=(it.get("standard_usage") or "").strip() or None,
actual_usage=(it.get("actual_usage") or "").strip() or None,
unit=(it.get("unit") or "").strip() or None,
requisition_usage_id=req_id or None,
is_key_material=it.get("is_key_material", "0"),
remark=(it.get("remark") or "").strip() or None,
order_num=idx, create_by=user_id, create_dept_id="",
create_time=now, update_by=user_id, update_time=now, del_flag=0,
))
if req_id:
usage_items.append({
"requisitionUsageId": req_id,
"qty": it.get("actual_usage"),
"usageUnit": it.get("unit"),
"remark": it.get("remark"),
})
# Deduct stock based on actual_usage
reagent_stock_log_crud.deduct_for_step(
db, step_id, step_name, task_id, task_no, items, tenant_no, user_id, "",
from app.crud import production_material_usage as pm_usage_crud
pm_usage_crud.register_step_usage_from_requisition(
db, step_id, step_name, task_id, task_no, usage_items, tenant_no, user_id, "",
)
db.commit()
@@ -1368,11 +1737,19 @@ def replace_step_consumables(
try:
_soft_delete_sub(db, BizProductionTaskStepConsumable, "step_id", step_id, now)
# Revert previous step_save stock deductions
from app.crud import consumable_stock_log as consumable_stock_log_crud
consumable_stock_log_crud.revert_step_stock_changes(db, step_id, tenant_no, user_id)
usage_items: List[Dict[str, Any]] = []
for idx, it in enumerate(items):
req_id = (
(it.get("requisition_usage_id") or it.get("requisitionUsageId") or "").strip()
)
_require_requisition_for_catalog_material(
db,
tenant_no,
it.get("consumable_code"),
"consumable",
it.get("actual_usage"),
req_id,
)
db.add(BizProductionTaskStepConsumable(
id=generate_uuid(), step_id=step_id, tenant_no=tenant_no,
consumable_code=(it.get("consumable_code") or "").strip() or None,
@@ -1381,15 +1758,91 @@ def replace_step_consumables(
standard_usage=(it.get("standard_usage") or "").strip() or None,
actual_usage=(it.get("actual_usage") or "").strip() or None,
unit=(it.get("unit") or "").strip() or None,
requisition_usage_id=req_id or None,
is_required=it.get("is_required", "1"),
remark=(it.get("remark") or "").strip() or None,
order_num=idx, create_by=user_id, create_dept_id="",
create_time=now, update_by=user_id, update_time=now, del_flag=0,
))
if req_id:
usage_items.append({
"requisitionUsageId": req_id,
"qty": it.get("actual_usage"),
"usageUnit": it.get("unit"),
"remark": it.get("remark"),
})
# Deduct stock based on actual_usage
consumable_stock_log_crud.deduct_for_step(
db, step_id, step_name, task_id, task_no, items, tenant_no, user_id, "",
from app.crud import production_material_usage as pm_usage_crud
pm_usage_crud.register_step_usage_from_requisition(
db, step_id, step_name, task_id, task_no, usage_items, tenant_no, user_id, "",
)
db.commit()
except Exception:
db.rollback()
raise
def replace_step_configured_reagents(
db: Session, step_id: str, tenant_no: str,
user_id: Optional[str], items: List[Dict[str, Any]],
) -> None:
now = datetime.now()
step_row = db.query(BizProductionTaskStep).filter(
and_(BizProductionTaskStep.id == step_id, BizProductionTaskStep.del_flag == 0)
).first()
task_id = ""
task_no = ""
step_name = ""
if step_row:
step_name = step_row.process_name or ""
task_row = db.query(BizProductionTask).filter(
and_(BizProductionTask.id == step_row.task_id, BizProductionTask.del_flag == 0)
).first()
if task_row:
task_id = task_row.id
task_no = task_row.task_no or ""
try:
_soft_delete_sub(db, BizProductionTaskStepConfiguredReagent, "step_id", step_id, now)
usage_items: List[Dict[str, Any]] = []
for idx, it in enumerate(items):
req_id = (
(it.get("requisition_usage_id") or it.get("requisitionUsageId") or "").strip()
)
_require_requisition_for_catalog_material(
db,
tenant_no,
it.get("configured_reagent_code"),
"configured_reagent",
it.get("actual_usage"),
req_id,
)
db.add(BizProductionTaskStepConfiguredReagent(
id=generate_uuid(), step_id=step_id, tenant_no=tenant_no,
configured_reagent_code=(it.get("configured_reagent_code") or "").strip() or None,
configured_reagent_name=(it.get("configured_reagent_name") or "").strip() or None,
spec=(it.get("spec") or "").strip() or None,
standard_usage=(it.get("standard_usage") or "").strip() or None,
actual_usage=(it.get("actual_usage") or "").strip() or None,
unit=(it.get("unit") or "").strip() or None,
requisition_usage_id=req_id or None,
remark=(it.get("remark") or "").strip() or None,
order_num=idx, create_by=user_id, create_dept_id="",
create_time=now, update_by=user_id, update_time=now, del_flag=0,
))
if req_id:
usage_items.append({
"requisitionUsageId": req_id,
"qty": it.get("actual_usage"),
"usageUnit": it.get("unit"),
"remark": it.get("remark"),
})
from app.crud import production_material_usage as pm_usage_crud
pm_usage_crud.register_step_usage_from_requisition(
db, step_id, step_name, task_id, task_no, usage_items, tenant_no, user_id, "",
)
db.commit()
@@ -1504,32 +1957,24 @@ def _parse_optional_date(val):
def _create_occupancy_for_product(db: Session, product: BizCellProduct, tenant_no: str, user_id: Optional[str]):
"""为细胞产品创建库位占用记录"""
if not product.storage_slot_id:
slot_id = (product.storage_slot_id or "").strip()
if not slot_id:
return
now = datetime.now()
occ = BizStorageSlotOccupancy(
id=generate_uuid(),
slot_id=product.storage_slot_id,
occupancy_svc.assert_slot_vacant(
db, slot_id, tenant_no=tenant_no, exclude_product_id=product.id,
)
occupancy_svc._add_stored_occupancy_no_commit(
db,
slot_id=slot_id,
item_type="cell_product",
item_id=product.id,
item_code=product.product_code or "",
item_name=product.product_name or "",
item_source="production",
stored_at=now,
occupancy_status="stored",
tenant_no=tenant_no,
order_num=0,
remark=None,
create_by=user_id,
create_dept_id="",
create_time=now,
update_by=user_id,
update_time=now,
del_flag=0,
user_id=user_id,
create_dept_id=product.create_dept_id or "",
)
db.add(occ)
db.flush()
occupancy_svc._refresh_slot_cache(db, product.storage_slot_id)
def _update_product_from_output(product: BizCellProduct, it: Dict[str, Any], user_id, now):
@@ -1580,6 +2025,13 @@ def set_task_outputs(
) -> None:
now = datetime.now()
batch_slot_ids: List[str] = []
for it in items:
sid = (it.get("storage_slot_id") or it.get("storageSlotId") or "").strip()
if sid:
batch_slot_ids.append(sid)
occupancy_svc.assert_batch_slots_unique(batch_slot_ids)
# --- 1. 加载旧 outputs ---
old_rows = db.query(BizProductionTaskOutput).filter(
and_(
@@ -29,6 +29,7 @@ from app.models.models import (
)
from app.models.research_donation import BizResearchDonation, BizResearchDonationSample
from app.schemas.production_work_order import ProductionWorkOrderComplete, ProductionWorkOrderListQuery
from app.services.qc_work_order_fee_summary import enrich_work_order_fee_summaries
_WORK_ORDER_STATUS_LABELS = {
"dpz": "待配置",
@@ -389,6 +390,9 @@ def _wo_to_response_dict(db: Session, wo: BizProductionWorkOrder) -> Dict[str, A
_attach_outbound_detail(db, wo, out)
else:
_attach_reception_detail(db, wo, out, wo.tenant_no or "")
tenant_no = (wo.tenant_no or "").strip()
if tenant_no:
out = enrich_work_order_fee_summaries(db, [out], tenant_no)[0]
return out
@@ -610,6 +614,7 @@ def list_production_work_orders(
)
items = _enrich_wo_items(db, [_wo_to_dict(x) for x in rows])
items = _enrich_outbound_items(db, tenant_no, items)
items = enrich_work_order_fee_summaries(db, items, tenant_no)
return {"items": items, "total": int(total)}
@@ -1152,6 +1157,7 @@ def configure_temp_production_work_order(
route_id: Optional[str],
description: str,
remark: str,
assignee_user_id: str,
tenant_no: str,
user_id: Optional[str] = None,
create_dept_id: str = "",
@@ -1174,6 +1180,7 @@ def configure_temp_production_work_order(
"route_id": route_id,
"description": description,
"remark": remark,
"assignee_user_id": assignee_user_id,
},
order_source="temporary",
)
+140
View File
@@ -597,6 +597,146 @@ def batch_stock_out(
raise
DISCARD_REASONS = frozenset({"过期", "质量问题", "污染/破损", "其他"})
def _validate_discard_reason(discard_reason: Optional[str], remark: Optional[str]) -> str:
reason = (discard_reason or "").strip()
if reason not in DISCARD_REASONS:
raise ValueError("请选择有效的废弃原因")
if reason == "其他" and not (remark or "").strip():
raise ValueError("选择「其他」时请填写备注说明")
return reason
def _discard_batch(
db: Session,
batch_id: str,
*,
qty: Decimal,
discard_reason: str,
remark: Optional[str],
usage_unit: Optional[str] = None,
tenant_no: str,
user_id: Optional[str],
operate_time: datetime,
) -> None:
if qty <= 0:
raise ValueError("废弃数量必须大于0")
batch = (
db.query(BizQcMaterialStockBatch)
.filter(
BizQcMaterialStockBatch.id == batch_id,
BizQcMaterialStockBatch.tenant_no == tenant_no,
BizQcMaterialStockBatch.del_flag == 0,
)
.with_for_update()
.first()
)
if not batch:
raise ValueError("入库批次不存在")
material = _get_material_for_update(db, batch.material_id, tenant_no)
if not _is_enabled_status(material.status):
raise ValueError(f"物料「{material.material_name}」已停用,无法废弃")
rem = batch.remaining_qty or Decimal("0")
if rem < qty:
raise ValueError(
f"批次「{batch.stock_in_no}」库存不足,当前剩余 {rem},需废弃 {qty}"
)
batch.remaining_qty = rem - qty
batch.update_by = user_id
batch.update_time = datetime.now()
db.add(batch)
stock_before = material.stock_qty or Decimal("0")
new_stock = stock_before - qty
material.stock_qty = new_stock
material.update_by = user_id
material.update_time = datetime.now()
db.add(material)
snaps = _usage_batch_snapshots(batch, out_qty=qty)
unit_label = (usage_unit or "").strip() or (batch.unit or "").strip() or None
usage = BizQcMaterialUsage(
id=generate_uuid(),
material_id=material.id,
material_code=material.material_code,
material_name=material.material_name,
change_type="discard",
change_qty=-qty,
usage_unit=unit_label,
stock_before=stock_before,
stock_after=new_stock,
source_type="manual_discard",
tenant_no=tenant_no,
purpose=discard_reason,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id=material.create_dept_id or "",
create_time=operate_time,
update_by=user_id,
update_time=operate_time,
del_flag=0,
**snaps,
)
db.add(usage)
def batch_discard(
db: Session,
*,
items: List[Dict[str, Any]],
discard_reason: Optional[str] = None,
remark: Optional[str] = None,
tenant_no: str,
user_id: Optional[str] = None,
operate_time: Optional[datetime] = None,
) -> int:
if not items:
raise ValueError("请至少添加一条废弃明细")
op_time = operate_time or datetime.now()
shared_remark = (remark or "").strip() or None
reason = _validate_discard_reason(discard_reason, shared_remark)
seen_batches: set = set()
try:
for it in items:
batch_id = (it.get("batch_id") or it.get("batchId") or "").strip()
if not batch_id:
raise ValueError("请选择入库批次")
if batch_id in seen_batches:
raise ValueError("同一入库批次不可重复添加")
seen_batches.add(batch_id)
qty = it.get("qty")
if qty is None or Decimal(str(qty)) <= 0:
raise ValueError("废弃数量必须大于0")
qty_dec = Decimal(str(qty))
line_remark = (it.get("remark") or "").strip() or shared_remark
if reason == "其他" and not line_remark:
raise ValueError("选择「其他」时请填写备注说明")
usage_unit = (it.get("usageUnit") or it.get("usage_unit") or "").strip() or None
_discard_batch(
db,
batch_id,
qty=qty_dec,
discard_reason=reason,
remark=line_remark,
usage_unit=usage_unit,
tenant_no=tenant_no,
user_id=user_id,
operate_time=op_time,
)
db.commit()
return len(items)
except Exception:
db.rollback()
raise
def get_batch(db: Session, batch_id: str, tenant_no: str) -> Optional[BizQcMaterialStockBatch]:
return (
db.query(BizQcMaterialStockBatch)
+2
View File
@@ -244,6 +244,8 @@ def _list_usages_query(
)
elif ct == "in":
q0 = q0.filter(BizQcMaterialUsage.change_type == "in")
elif ct == "discard":
q0 = q0.filter(BizQcMaterialUsage.change_type == "discard")
sno = (stock_in_no or "").strip()
if sno:
q0 = q0.filter(BizQcMaterialUsage.stock_in_no.like(f"%{sno}%"))
+79 -13
View File
@@ -10,6 +10,14 @@ from sqlalchemy.orm import Session
from app.core.utils import generate_uuid
from app.models.models import BizStorageFacility, BizStorageFacilitySlot
from app.services.storage_facility_code import (
assert_sibling_node_code_unique,
build_full_slot_code,
cascade_refresh_slot_name_snapshots_for_nodes,
cascade_refresh_slot_name_snapshots_for_slots,
load_facility_map,
validate_node_code,
)
# ---------------------------------------------------------------------------
@@ -22,6 +30,7 @@ def _row_to_dict(f: BizStorageFacility) -> Dict[str, Any]:
"id": f.id,
"parentId": f.parent_id,
"nodeName": f.node_name,
"nodeCode": f.node_code or "",
"nodeType": f.node_type or "",
"isLeaf": 1 if f.is_leaf else 0,
"tenantNo": f.tenant_no,
@@ -45,7 +54,12 @@ def list_all_facilities(
kw = (keyword or "").strip()
if kw:
like = f"%{kw}%"
q = q.filter(BizStorageFacility.node_name.like(like))
q = q.filter(
or_(
BizStorageFacility.node_name.like(like),
BizStorageFacility.node_code.like(like),
)
)
rows = q.order_by(BizStorageFacility.order_num.asc(), BizStorageFacility.create_time.asc()).all()
return [_row_to_dict(x) for x in rows]
@@ -93,6 +107,7 @@ def create_facility(
*,
parent_id: str = "0",
node_name: str,
node_code: str,
node_type: Optional[str] = None,
is_leaf: int = 0,
tenant_no: str = "zkxw",
@@ -103,10 +118,16 @@ def create_facility(
name = (node_name or "").strip()
if not name:
raise ValueError("节点名称不能为空")
code = validate_node_code(node_code)
pid = parent_id or "0"
assert_sibling_node_code_unique(
db, parent_id=pid, node_code=code, tenant_no=tenant_no
)
obj = BizStorageFacility(
id=generate_uuid(),
parent_id=parent_id or "0",
parent_id=pid,
node_name=name,
node_code=code,
node_type=(node_type or "").strip() or None,
is_leaf=is_leaf,
tenant_no=tenant_no,
@@ -130,6 +151,7 @@ def update_facility(
node_id: str,
*,
node_name: Optional[str] = None,
node_code: Optional[str] = None,
node_type: Optional[str] = None,
is_leaf: Optional[int] = None,
order_num: Optional[int] = None,
@@ -140,11 +162,22 @@ def update_facility(
obj = get_facility(db, node_id, tenant_no=tenant_no)
if not obj:
raise ValueError("存储设施节点不存在")
old_node_code = (obj.node_code or "").strip()
if node_name is not None:
name = (node_name or "").strip()
if not name:
raise ValueError("节点名称不能为空")
obj.node_name = name
if node_code is not None:
code = validate_node_code(node_code)
assert_sibling_node_code_unique(
db,
parent_id=obj.parent_id or "0",
node_code=code,
tenant_no=obj.tenant_no,
exclude_id=obj.id,
)
obj.node_code = code
if node_type is not None:
obj.node_type = (node_type or "").strip() or None
if is_leaf is not None:
@@ -156,6 +189,16 @@ def update_facility(
obj.update_by = user_id
obj.update_time = datetime.now()
db.add(obj)
node_code_changed = node_code is not None and (obj.node_code or "").strip() != old_node_code
if node_code_changed:
cascade_refresh_slot_name_snapshots_for_nodes(
db,
[node_id],
obj.tenant_no,
collect_descendant_ids_fn=collect_descendant_ids,
)
db.commit()
db.refresh(obj)
return obj
@@ -187,12 +230,21 @@ def soft_delete_facility(db: Session, node_id: str, tenant_no: Optional[str] = N
# ---------------------------------------------------------------------------
def _slot_to_dict(s: BizStorageFacilitySlot) -> Dict[str, Any]:
def _slot_to_dict(
s: BizStorageFacilitySlot,
facility_by_id: Optional[Dict[str, BizStorageFacility]] = None,
) -> Dict[str, Any]:
occupied_count = s.occupied_count if s.occupied_count is not None else 0
full_slot_code = ""
if facility_by_id is not None:
full_slot_code = build_full_slot_code(s.facility_node_id, s.slot_code, facility_by_id)
return {
"id": s.id,
"facilityNodeId": s.facility_node_id,
"slotCode": s.slot_code or "",
"fullSlotCode": full_slot_code,
"slotStatus": s.slot_status or "",
"occupiedCount": int(occupied_count),
"tenantNo": s.tenant_no,
"orderNum": s.order_num if s.order_num is not None else 0,
"remark": s.remark or "",
@@ -216,7 +268,8 @@ def list_slots(
if tenant_no:
q = q.filter(BizStorageFacilitySlot.tenant_no == tenant_no)
rows = q.order_by(BizStorageFacilitySlot.order_num.asc(), BizStorageFacilitySlot.create_time.asc()).all()
return [_slot_to_dict(x) for x in rows]
facility_by_id = load_facility_map(db, tenant_no or "") if tenant_no else {}
return [_slot_to_dict(x, facility_by_id) for x in rows]
def get_slot(db: Session, slot_id: str, tenant_no: Optional[str] = None) -> Optional[BizStorageFacilitySlot]:
@@ -228,6 +281,11 @@ def get_slot(db: Session, slot_id: str, tenant_no: Optional[str] = None) -> Opti
return q.first()
def _slot_to_dict_for_row(db: Session, s: BizStorageFacilitySlot) -> Dict[str, Any]:
facility_by_id = load_facility_map(db, s.tenant_no)
return _slot_to_dict(s, facility_by_id)
def create_slot(
db: Session,
*,
@@ -277,6 +335,7 @@ def update_slot(
obj = get_slot(db, slot_id, tenant_no=tenant_no)
if not obj:
raise ValueError("存储设施小格不存在")
old_slot_code = (obj.slot_code or "").strip()
if slot_code is not None:
obj.slot_code = (slot_code or "").strip() or None
if slot_status is not None:
@@ -288,6 +347,11 @@ def update_slot(
obj.update_by = user_id
obj.update_time = datetime.now()
db.add(obj)
slot_code_changed = slot_code is not None and (obj.slot_code or "").strip() != old_slot_code
if slot_code_changed:
cascade_refresh_slot_name_snapshots_for_slots(db, [slot_id], obj.tenant_no)
db.commit()
db.refresh(obj)
return obj
@@ -341,7 +405,6 @@ def batch_create_slots(
facility_node_id: str,
rows: int,
cols: int,
code_prefix: str = "",
tenant_no: str = "zkxw",
user_id: Optional[str] = None,
) -> List[Dict[str, Any]]:
@@ -359,12 +422,11 @@ def batch_create_slots(
raise ValueError("所属设施节点不存在")
if not node.is_leaf:
raise ValueError("只能为叶子节点创建格子")
prefix = (code_prefix or "").strip()
now = datetime.now()
slots: List[BizStorageFacilitySlot] = []
for r in range(1, rows + 1):
for c in range(1, cols + 1):
code = f"{prefix}{r}-{c}" if prefix else f"{r}-{c}"
code = f"{r}-{c}"
order = (r - 1) * cols + c
obj = BizStorageFacilitySlot(
id=generate_uuid(),
@@ -384,9 +446,10 @@ def batch_create_slots(
db.add(obj)
slots.append(obj)
db.commit()
facility_by_id = load_facility_map(db, tenant_no)
for s in slots:
db.refresh(s)
return [_slot_to_dict(s) for s in slots]
return [_slot_to_dict(s, facility_by_id) for s in slots]
def insert_row_and_shift_slots(
@@ -395,7 +458,6 @@ def insert_row_and_shift_slots(
facility_node_id: str,
after_row_num: int,
cols: int,
code_prefix: str = "",
tenant_no: str = "zkxw",
user_id: Optional[str] = None,
) -> Dict[str, int]:
@@ -430,27 +492,28 @@ def insert_row_and_shift_slots(
now = datetime.now()
shifted_count = 0
affected_slot_ids: List[str] = []
for slot in slots:
match = row_code_pattern.match((slot.slot_code or "").strip())
if not match:
continue
prefix, row_no_raw, col_no_raw = match.groups()
_prefix, row_no_raw, col_no_raw = match.groups()
row_no = int(row_no_raw)
if row_no > after_row_num:
slot.slot_code = f"{prefix}{row_no + 1}-{int(col_no_raw)}"
slot.slot_code = f"{row_no + 1}-{int(col_no_raw)}"
slot.update_by = user_id
slot.update_time = now
shifted_count += 1
affected_slot_ids.append(slot.id)
insert_row_num = after_row_num + 1
prefix = (code_prefix or "").strip()
created_slots: List[BizStorageFacilitySlot] = []
for col in range(1, cols + 1):
created_slots.append(
BizStorageFacilitySlot(
id=generate_uuid(),
facility_node_id=fid,
slot_code=f"{prefix}{insert_row_num}-{col}",
slot_code=f"{insert_row_num}-{col}",
slot_status="空",
tenant_no=tenant_no,
order_num=0,
@@ -465,5 +528,8 @@ def insert_row_and_shift_slots(
)
if created_slots:
db.add_all(created_slots)
affected_slot_ids.extend(s.id for s in created_slots)
if affected_slot_ids:
cascade_refresh_slot_name_snapshots_for_slots(db, affected_slot_ids, tenant_no)
db.commit()
return {"shiftedCount": shifted_count, "createdCount": len(created_slots)}
+170 -61
View File
@@ -4,11 +4,151 @@ from __future__ import annotations
from datetime import datetime
from typing import Any, Dict, List, Optional
from sqlalchemy import and_, func
from sqlalchemy import func
from sqlalchemy.orm import Session
from app.core.utils import generate_uuid
from app.models.models import BizStorageFacilitySlot, BizStorageSlotOccupancy
from app.models.models import (
BizCellProduct,
BizStorageFacilitySlot,
BizStorageSlotOccupancy,
)
SLOT_OCCUPIED_MSG = "该储物格已被占用,请选择其他储物格"
_BATCH_DUPLICATE_SLOT_MSG = "同一批次不能选择重复的储物格"
_CELL_PRODUCT_IN_STORE_STATUSES = frozenset({"frozen", "thawed", "in_production"})
def assert_batch_slots_unique(slot_ids: List[Optional[str]]) -> None:
"""同一批次内储物格不可重复。"""
seen: set[str] = set()
for sid in slot_ids:
slot_id = (sid or "").strip()
if not slot_id:
continue
if slot_id in seen:
raise ValueError(_BATCH_DUPLICATE_SLOT_MSG)
seen.add(slot_id)
def assert_slot_vacant(
db: Session,
slot_id: str,
*,
tenant_no: str = "",
exclude_occupancy_id: Optional[str] = None,
exclude_product_id: Optional[str] = None,
) -> None:
"""断言储物格当前无在库物品(任意 item_type)。"""
slot_id = (slot_id or "").strip()
if not slot_id:
return
slot = (
db.query(BizStorageFacilitySlot)
.filter(
BizStorageFacilitySlot.id == slot_id,
BizStorageFacilitySlot.del_flag == 0,
)
.with_for_update()
.first()
)
if not slot:
raise ValueError("储物格不存在")
if tenant_no and slot.tenant_no and slot.tenant_no != tenant_no:
raise ValueError("储物格不存在")
occ_q = db.query(BizStorageSlotOccupancy).filter(
BizStorageSlotOccupancy.slot_id == slot_id,
BizStorageSlotOccupancy.occupancy_status == "stored",
BizStorageSlotOccupancy.del_flag == 0,
)
if exclude_occupancy_id:
occ_q = occ_q.filter(BizStorageSlotOccupancy.id != exclude_occupancy_id)
if occ_q.first():
raise ValueError(SLOT_OCCUPIED_MSG)
prod_q = db.query(BizCellProduct).filter(
BizCellProduct.storage_slot_id == slot_id,
BizCellProduct.del_flag == 0,
BizCellProduct.product_status.in_(list(_CELL_PRODUCT_IN_STORE_STATUSES)),
)
if tenant_no:
prod_q = prod_q.filter(BizCellProduct.tenant_no == tenant_no)
if exclude_product_id:
prod_q = prod_q.filter(BizCellProduct.id != exclude_product_id)
if prod_q.first():
raise ValueError(SLOT_OCCUPIED_MSG)
def _add_stored_occupancy_no_commit(
db: Session,
*,
slot_id: str,
item_type: str,
item_id: str,
item_code: str,
item_name: str,
item_source: str,
tenant_no: str,
user_id: Optional[str] = None,
create_dept_id: str = "",
remark: Optional[str] = None,
stored_at: Optional[datetime] = None,
) -> BizStorageSlotOccupancy:
now = stored_at or datetime.now()
obj = BizStorageSlotOccupancy(
id=generate_uuid(),
slot_id=slot_id,
item_type=item_type,
item_id=item_id,
item_code=(item_code or "").strip() or None,
item_name=(item_name or "").strip() or None,
item_source=(item_source or "manual").strip(),
stored_at=now,
removed_at=None,
occupancy_status="stored",
tenant_no=tenant_no,
order_num=0,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id=create_dept_id or "",
create_time=now,
update_by=user_id,
update_time=now,
del_flag=0,
)
db.add(obj)
db.flush()
_refresh_slot_cache(db, slot_id)
return obj
def remove_by_item_no_commit(
db: Session,
item_type: str,
item_id: str,
*,
user_id: Optional[str] = None,
) -> None:
"""按物品出库(不 commit)。"""
obj = db.query(BizStorageSlotOccupancy).filter(
BizStorageSlotOccupancy.item_type == item_type,
BizStorageSlotOccupancy.item_id == item_id,
BizStorageSlotOccupancy.occupancy_status == "stored",
BizStorageSlotOccupancy.del_flag == 0,
).first()
if not obj:
return
now = datetime.now()
obj.occupancy_status = "removed"
obj.removed_at = now
obj.update_by = user_id
obj.update_time = now
db.add(obj)
db.flush()
_refresh_slot_cache(db, obj.slot_id)
def _row_to_dict(c: BizStorageSlotOccupancy) -> Dict[str, Any]:
@@ -79,31 +219,22 @@ def create_occupancy(
remark: Optional[str] = None,
) -> BizStorageSlotOccupancy:
"""创建入库记录 + 刷新 slot 缓存"""
now = datetime.now()
obj = BizStorageSlotOccupancy(
id=generate_uuid(),
slot_id = (slot_id or "").strip()
if not slot_id:
raise ValueError("储物格不能为空")
assert_slot_vacant(db, slot_id, tenant_no=tenant_no)
obj = _add_stored_occupancy_no_commit(
db,
slot_id=slot_id,
item_type=item_type,
item_id=item_id,
item_code=(item_code or "").strip() or None,
item_name=(item_name or "").strip() or None,
item_source=(item_source or "manual").strip(),
stored_at=now,
removed_at=None,
occupancy_status="stored",
item_code=item_code,
item_name=item_name,
item_source=item_source,
tenant_no=tenant_no,
order_num=0,
remark=(remark or "").strip() or None,
create_by=user_id,
create_dept_id="",
create_time=now,
update_by=user_id,
update_time=now,
del_flag=0,
user_id=user_id,
remark=remark,
)
db.add(obj)
db.flush()
_refresh_slot_cache(db, slot_id)
db.commit()
db.refresh(obj)
return obj
@@ -117,37 +248,30 @@ def batch_create_occupancies(
user_id: Optional[str] = None,
) -> List[BizStorageSlotOccupancy]:
"""批量入库"""
now = datetime.now()
slot_ids = [(it.get("slot_id") or "").strip() for it in items]
assert_batch_slots_unique(slot_ids)
for sid in slot_ids:
if sid:
assert_slot_vacant(db, sid, tenant_no=tenant_no)
created: List[BizStorageSlotOccupancy] = []
slot_ids_seen: set = set()
for it in items:
obj = BizStorageSlotOccupancy(
id=generate_uuid(),
slot_id=it["slot_id"],
sid = (it.get("slot_id") or "").strip()
obj = _add_stored_occupancy_no_commit(
db,
slot_id=sid,
item_type=it.get("item_type", "cell_product"),
item_id=it["item_id"],
item_code=(it.get("item_code") or "").strip() or None,
item_name=(it.get("item_name") or "").strip() or None,
item_source=(it.get("item_source") or "production").strip(),
stored_at=now,
removed_at=None,
occupancy_status="stored",
item_code=it.get("item_code") or "",
item_name=it.get("item_name") or "",
item_source=it.get("item_source") or "production",
tenant_no=tenant_no,
order_num=0,
remark=(it.get("remark") or "").strip() or None,
create_by=user_id,
create_dept_id="",
create_time=now,
update_by=user_id,
update_time=now,
del_flag=0,
user_id=user_id,
remark=it.get("remark"),
)
db.add(obj)
created.append(obj)
slot_ids_seen.add(it["slot_id"])
db.flush()
for sid in slot_ids_seen:
_refresh_slot_cache(db, sid)
slot_ids_seen.add(sid)
db.commit()
for obj in created:
db.refresh(obj)
@@ -190,22 +314,7 @@ def remove_by_item(
user_id: Optional[str] = None,
) -> None:
"""按物品类型+ID出库(细胞产品状态变更时调用)"""
obj = db.query(BizStorageSlotOccupancy).filter(
BizStorageSlotOccupancy.item_type == item_type,
BizStorageSlotOccupancy.item_id == item_id,
BizStorageSlotOccupancy.occupancy_status == "stored",
BizStorageSlotOccupancy.del_flag == 0,
).first()
if not obj:
return
now = datetime.now()
obj.occupancy_status = "removed"
obj.removed_at = now
obj.update_by = user_id
obj.update_time = now
db.add(obj)
db.flush()
_refresh_slot_cache(db, obj.slot_id)
remove_by_item_no_commit(db, item_type, item_id, user_id=user_id)
db.commit()
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_cell_product_py", "label": "cell_product.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L1"}, {"id": "crud_cell_product_apply_cell_product_status_change", "label": "_apply_cell_product_status_change()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L31"}, {"id": "crud_cell_product_row_to_dict", "label": "_row_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L86"}, {"id": "crud_cell_product_build_facility_path_label", "label": "_build_facility_path_label()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L119"}, {"id": "crud_cell_product_enrich_product_dicts", "label": "_enrich_product_dicts()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L134"}, {"id": "crud_cell_product_product_to_response", "label": "product_to_response()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L264"}, {"id": "crud_cell_product_list_cell_products", "label": "list_cell_products()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L269"}, {"id": "crud_cell_product_get_cell_product", "label": "get_cell_product()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L333"}, {"id": "crud_cell_product_create_cell_product", "label": "create_cell_product()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L347"}, {"id": "crud_cell_product_update_cell_product", "label": "update_cell_product()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L419"}, {"id": "crud_cell_product_delete_cell_product", "label": "delete_cell_product()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L510"}, {"id": "crud_cell_product_next_code_start_seq", "label": "_next_code_start_seq()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L527"}, {"id": "crud_cell_product_get_next_code", "label": "get_next_code()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L548"}, {"id": "crud_cell_product_normalize_product_code_base", "label": "normalize_product_code_base()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L558"}, {"id": "crud_cell_product_build_split_product_codes", "label": "build_split_product_codes()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L569"}, {"id": "crud_cell_product_reserve_next_codes", "label": "reserve_next_codes()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L576"}, {"id": "crud_cell_product_validate_batch_items", "label": "_validate_batch_items()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L586"}, {"id": "crud_cell_product_create_cell_products_by_quantity", "label": "create_cell_products_by_quantity()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L631"}, {"id": "crud_cell_product_create_cell_products_batch", "label": "create_cell_products_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L665"}, {"id": "crud_cell_product_total_pages", "label": "total_pages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L741"}, {"id": "crud_cell_product_product_node", "label": "_product_node()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L756"}, {"id": "crud_cell_product_nest_ancestor_parent", "label": "_nest_ancestor_parent()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L768"}, {"id": "crud_cell_product_edge_meta", "label": "_edge_meta()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "LLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_services_storage_facility_code_py", "label": "storage_facility_code.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/storage_facility_code.py", "source_location": "L1"}, {"id": "services_storage_facility_code_validate_node_code", "label": "validate_node_code()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/storage_facility_code.py", "source_location": "L20"}, {"id": "services_storage_facility_code_assert_sibling_node_code_unique", "label": "assert_sibling_node_code_unique()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/storage_facility_code.py", "source_location": "L31"}, {"id": "services_storage_facility_code_build_node_code_path", "label": "build_node_code_path()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/storage_facility_code.py", "source_location": "L53"}, {"id": "services_storage_facility_code_build_full_slot_code", "label": "build_full_slot_code()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/storage_facility_code.py", "source_location": "L78"}, {"id": "services_storage_facility_code_load_facility_map", "label": "load_facility_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/storage_facility_code.py", "source_location": "L90"}, {"id": "services_storage_facility_code_collect_slot_ids_under_nodes", "label": "collect_slot_ids_under_nodes()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/storage_facility_code.py", "source_location": "L102"}, {"id": "services_storage_facility_code_refresh_outbound_release_cell_slot_names", "label": "refresh_outbound_release_cell_slot_names()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/storage_facility_code.py", "source_location": "L145"}, {"id": "services_storage_facility_code_cascade_refresh_slot_name_snapshots_for_slots", "label": "cascade_refresh_slot_name_snapshots_for_slots()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/storage_facility_code.py", "source_location": "L190"}, {"id": "services_storage_facility_code_cascade_refresh_slot_name_snapshots_for_nodes", "label": "cascade_refresh_slot_name_snapshots_for_nodes()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/storage_facility_code.py", "source_location": "L219"}, {"id": "services_storage_facility_code_rationale_1", "label": "\u5e93\u4f4d\u8282\u70b9\u7f16\u53f7\u8def\u5f84\u4e0e\u50a8\u7269\u683c\u5b8c\u6574\u7f16\u53f7\u8ba1\u7b97\u3001\u5feb\u7167\u7ea7\u8054\u5237\u65b0\u3002", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/storage_facility_code.py", "source_location": "L1"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_services_storage_facility_code_py", "target": "re", "relation": "imports", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/storage_facility_code.py", "source_location": "L4", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_services_storage_facility_code_py", "target": "datetime", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/storage_facility_code.py", "source_location": "L5", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_services_storage_facility_code_py", "target": "typing", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/storage_facility_code.py", "source_location": "L6", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_services_storage_facility_code_py", "target": "sqlalchemy_orm", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/storage_facility_code.py", "source_location": "L8", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_services_storage_facility_code_py", "target": "app_models_models", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/storage_facility_code.py", "source_location": "L10", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_services_storage_facility_code_py", "target": "services_storage_facility_code_validate_node_code", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/storage_facility_code.py", "source_location": "L20", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_services_storage_facility_code_py", "target": "sLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_work_order_py", "label": "production_work_order.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L1"}, {"id": "crud_production_work_order_normalize_date_bound", "label": "_normalize_date_bound()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L48"}, {"id": "crud_production_work_order_fmt_dt", "label": "_fmt_dt()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L55"}, {"id": "crud_production_work_order_soft_delete_sub", "label": "_soft_delete_sub()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L59"}, {"id": "crud_production_work_order_generate_work_order_no", "label": "_generate_work_order_no()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L71"}, {"id": "crud_production_work_order_wo_to_dict", "label": "_wo_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L90"}, {"id": "crud_production_work_order_enrich_wo_items", "label": "_enrich_wo_items()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L123"}, {"id": "crud_production_work_order_enrich_outbound_items", "label": "_enrich_outbound_items()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L136"}, {"id": "crud_production_work_order_outbound_work_order_ids_by_keyword", "label": "_outbound_work_order_ids_by_keyword()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L241"}, {"id": "crud_production_work_order_reception_source_label", "label": "_reception_source_label()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L293"}, {"id": "crud_production_work_order_accept_conclusion_label", "label": "_accept_conclusion_label()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L298"}, {"id": "crud_production_work_order_attach_reception_detail", "label": "_attach_reception_detail()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L303"}, {"id": "crud_production_work_order_attach_outbound_detail", "label": "_attach_outbound_detail()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L333"}, {"id": "crud_production_work_order_wo_to_response_dict", "label": "_wo_to_response_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L386"}, {"id": "crud_production_work_order_create_production_work_order_from_reception", "label": "create_production_work_order_from_reception()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L399"}, {"id": "crud_production_work_order_list_production_work_orders", "label": "list_production_work_orders()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L510"}, {"id": "crud_production_work_order_sync_production_work_order_status_from_tasks", "label": "sync_production_work_order_status_from_tasks()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L621"}, {"id": "crud_production_work_order_get_production_work_order", "label": "get_production_work_order()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L664"}, {"id": "crud_production_work_order_update_production_work_order", "label": "update_production_work_order()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L678"}, {"id": "crud_production_work_order_complete_production_work_order", "label": "complete_production_work_order()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L699"}, {"id": "crud_production_work_order_production_task_info", "label": "_production_task_info()", "file_type": "code", "Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_schemas_production_task_py", "label": "production_task.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_task.py", "source_location": "L1"}, {"id": "schemas_production_task_productiontaskcreate", "label": "ProductionTaskCreate", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_task.py", "source_location": "L6"}, {"id": "basemodel", "label": "BaseModel", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "schemas_production_task_productiontaskforwardbody", "label": "ProductionTaskForwardBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_task.py", "source_location": "L17"}, {"id": "schemas_production_task_productiontaskassigneeupdate", "label": "ProductionTaskAssigneeUpdate", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_task.py", "source_location": "L23"}, {"id": "schemas_production_task_productiontasklistquery", "label": "ProductionTaskListQuery", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_task.py", "source_location": "L29"}, {"id": "schemas_production_task_productiontaskupdate", "label": "ProductionTaskUpdate", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_task.py", "source_location": "L38"}, {"id": "schemas_production_task_productiontaskstatusupdate", "label": "ProductionTaskStatusUpdate", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_task.py", "source_location": "L45"}, {"id": "schemas_production_task_taskstepadd", "label": "TaskStepAdd", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_task.py", "source_location": "L52"}, {"id": "schemas_production_task_taskstepupdate", "label": "TaskStepUpdate", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_task.py", "source_location": "L63"}, {"id": "schemas_production_task_taskstepmaterialitem", "label": "TaskStepMaterialItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_task.py", "source_location": "L73"}, {"id": "schemas_production_task_taskstepoutputitem", "label": "TaskStepOutputItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_task.py", "source_location": "L86"}, {"id": "schemas_production_task_taskstepdatacollectionitem", "label": "TaskStepDataCollectionItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_task.py", "source_location": "L93"}, {"id": "schemas_production_task_taskinputitem", "label": "TaskInputItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_task.py", "source_location": "L100"}, {"id": "schemas_production_task_taskoutputitem", "label": "TaskOutputItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_task.py", "source_location": "L109"}, {"id": "schemas_production_task_taskstepreorderbody", "label": "TaskStepReorderBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_task.py", "source_location": "L137"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_schemas_production_task_py", "target": "pydantic", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_task.py", "source_location": "L1", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_schemas_production_task_py", "target": "typing", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_task.py", "source_location": "L2", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_schemas_production_task_py", "target": "datetime", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_task.py", "source_location": "L3", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_schemas_production_task_py", "target": "schemas_production_task_productiontaskcreate", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_task.py", "source_location": "L6", "weight": 1.0}, {"source": "schemas_production_task_productiontaskcreate", "target": "basemodel", "relation": "inherits", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_task.py", "source_location": "L6", "weight": 1.Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_api_production_material_py", "label": "production_material.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L1"}, {"id": "api_production_material_productionmaterialbody", "label": "ProductionMaterialBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L26"}, {"id": "basemodel", "label": "BaseModel", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "api_production_material_productionmaterialupdatebody", "label": "ProductionMaterialUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L38"}, {"id": "api_production_material_stockinbody", "label": "StockInBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L50"}, {"id": "api_production_material_batchstockinitem", "label": "BatchStockInItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L65"}, {"id": "api_production_material_batchstockinbody", "label": "BatchStockInBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L80"}, {"id": "api_production_material_batchstockoutitem", "label": "BatchStockOutItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L87"}, {"id": "api_production_material_batchstockoutbody", "label": "BatchStockOutBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L94"}, {"id": "api_production_material_productionmaterialbatchupdatebody", "label": "ProductionMaterialBatchUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L103"}, {"id": "api_production_material_list_production_material_batches", "label": "list_production_material_batches()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L123"}, {"id": "api_production_material_production_material_batch_options", "label": "production_material_batch_options()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L154"}, {"id": "api_production_material_update_production_material_batch", "label": "update_production_material_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L179"}, {"id": "api_production_material_delete_production_material_batch", "label": "delete_production_material_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L208"}, {"id": "api_production_material_list_production_materials", "label": "list_production_materials()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L225"}, {"id": "api_production_material_production_material_options", "label": "production_material_options()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L254"}, {"id": "api_production_material_create_production_material", "label": "create_production_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L269"}, {"id": "api_production_material_update_production_material", "label": "update_production_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L300"}, {"id": "api_production_material_delete_production_material", "label": "delete_production_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L329"}, {"id": "api_production_material_batch_stock_in_production_material", "label": "batch_stock_in_production_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L346"}, {"id": "api_production_material_batch_stock_out_production_material", "label": "batch_stock_out_production_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L399"}, {"id": "api_production_material_stock_in_production_material", "label": "stock_in_proLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_api_operations_py", "label": "operations.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L1"}, {"id": "api_operations_get_tenant_no", "label": "_get_tenant_no()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L24"}, {"id": "api_operations_cleanroomcreatebody", "label": "CleanRoomCreateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L39"}, {"id": "basemodel", "label": "BaseModel", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "api_operations_cleanroomupdatebody", "label": "CleanRoomUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L51"}, {"id": "api_operations_list_clean_rooms", "label": "list_clean_rooms()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L64"}, {"id": "api_operations_create_clean_room", "label": "create_clean_room()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L89"}, {"id": "api_operations_update_clean_room", "label": "update_clean_room()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L114"}, {"id": "api_operations_delete_clean_room", "label": "delete_clean_room()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L142"}, {"id": "api_operations_accesslogcreatebody", "label": "AccessLogCreateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L160"}, {"id": "api_operations_accesslogupdatebody", "label": "AccessLogUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L174"}, {"id": "api_operations_parse_optional_dt", "label": "_parse_optional_dt()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L187"}, {"id": "api_operations_list_access_logs", "label": "list_access_logs()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L194"}, {"id": "api_operations_create_access_log", "label": "create_access_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L223"}, {"id": "api_operations_update_access_log", "label": "update_access_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L250"}, {"id": "api_operations_delete_access_log", "label": "delete_access_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L279"}, {"id": "api_operations_uvdisinfectlogcreatebody", "label": "UvDisinfectLogCreateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L297"}, {"id": "api_operations_uvdisinfectlogupdatebody", "label": "UvDisinfectLogUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L309"}, {"id": "api_operations_list_uv_disinfect_logs", "label": "list_uv_disinfect_logs()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L321"}, {"id": "api_operations_create_uv_disinfect_log", "label": "create_uv_disinfect_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L352"}, {"id": "api_operations_update_uv_disinfect_log", "label": "update_uv_disinfect_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L377"}, {"id": "api_operations_delete_uv_disinfect_log", "label": "delete_uv_disinfect_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L405"}, {"id": "api_operations_storagefacilitycreatebody", "label": "StorageFacilityCreateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L423"}, {"id": "api_operations_storagefacilityupdatebody", "label": "StorageFacilityUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L434"}, {"id": "api_operations_list_storage_facilities", "labelLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_stock_batch_py", "label": "material_stock_batch.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L1"}, {"id": "crud_material_stock_batch_fmt_date", "label": "_fmt_date()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L16"}, {"id": "crud_material_stock_batch_parse_date", "label": "_parse_date()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L20"}, {"id": "crud_material_stock_batch_parse_expire_date", "label": "_parse_expire_date()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L34"}, {"id": "crud_material_stock_batch_require_str", "label": "_require_str()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L38"}, {"id": "crud_material_stock_batch_require_decimal", "label": "_require_decimal()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L45"}, {"id": "crud_material_stock_batch_stock_in_no_exists", "label": "stock_in_no_exists()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L57"}, {"id": "crud_material_stock_batch_batch_row_to_dict", "label": "_batch_row_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L73"}, {"id": "crud_material_stock_batch_usage_batch_snapshots", "label": "_usage_batch_snapshots()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L105"}, {"id": "crud_material_stock_batch_get_material_for_update", "label": "_get_material_for_update()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L126"}, {"id": "crud_material_stock_batch_list_batches", "label": "list_batches()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L144"}, {"id": "crud_material_stock_batch_batch_options", "label": "batch_options()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L208"}, {"id": "crud_material_stock_batch_create_batch_and_usage", "label": "_create_batch_and_usage()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L281"}, {"id": "crud_material_stock_batch_stock_in_one", "label": "stock_in_one()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L372"}, {"id": "crud_material_stock_batch_batch_stock_in", "label": "batch_stock_in()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L413"}, {"id": "crud_material_stock_batch_stock_out_batch", "label": "_stock_out_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L469"}, {"id": "crud_material_stock_batch_batch_stock_out", "label": "batch_stock_out()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L550"}, {"id": "crud_material_stock_batch_validate_discard_reason", "label": "_validate_discard_reason()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L603"}, {"id": "crud_material_stock_batch_discard_batch", "label": "_discard_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L612"}, {"id": "crud_material_stock_batch_batch_discard", "label": "batch_discard()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L689"}, {"id": "crud_material_stock_batch_get_batch", "label": "get_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L740"}, {"id": "crud_material_stock_batch_update_batch", "label": "update_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_batch.py", "source_location": "L752"}, {"id": "crud_material_stock_batch_delete_batchLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_models_models_py", "label": "models.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L1"}, {"id": "models_models_userrole", "label": "UserRole", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L10"}, {"id": "str", "label": "str", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "models_models_sysuser", "label": "SysUser", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L22"}, {"id": "base", "label": "Base", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "models_models_sysrole", "label": "SysRole", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L48"}, {"id": "models_models_sysuserrole", "label": "SysUserRole", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L68"}, {"id": "models_models_sysrolemenu", "label": "SysRoleMenu", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L87"}, {"id": "models_models_sysroledatascopedetail", "label": "SysRoleDataScopeDetail", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L106"}, {"id": "models_models_sysmenu", "label": "SysMenu", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L126"}, {"id": "models_models_sysdept", "label": "SysDept", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L152"}, {"id": "models_models_systenant", "label": "SysTenant", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L175"}, {"id": "models_models_syssite", "label": "SysSite", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L195"}, {"id": "models_models_syspost", "label": "SysPost", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L220"}, {"id": "models_models_sysuserpost", "label": "SysUserPost", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L240"}, {"id": "models_models_bizitemunit", "label": "BizItemUnit", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L259"}, {"id": "models_models_bizexpresscompany", "label": "BizExpressCompany", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L278"}, {"id": "models_models_bizcustomer", "label": "BizCustomer", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L297"}, {"id": "models_models_bizcellsampletype", "label": "BizCellSampleType", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L320"}, {"id": "models_models_bizcollectionregion", "label": "BizCollectionRegion", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L341"}, {"id": "models_models_bizcollectionhospital", "label": "BizCollectionHospital", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L359"}, {"id": "models_models_bizcollectionprotocolno", "label": "BizCollectionProtocolNo", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L378"}, {"id": "models_models_bizbiznosequence", "label": "BizBizNoSequence", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L400"}, {"id": "models_models_bizsamplecode", "label": "BizSampleCode", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L420"}, {"id": "models_models_sysdicttype", "label": "SysDictType", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L448"}, {"id": "models_models_sysethnic", "label": "SysEthnic", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L467"}, {"id": "models_models_sysdictdata", "label": "SysDictData", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location"Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_main_py", "label": "main.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/main.py", "source_location": "L1"}, {"id": "app_main_lifespan", "label": "lifespan()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/main.py", "source_location": "L20"}, {"id": "app_main_error_json", "label": "_error_json()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/main.py", "source_location": "L67"}, {"id": "app_main_sqlalchemy_exception_handler", "label": "sqlalchemy_exception_handler()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/main.py", "source_location": "L80"}, {"id": "app_main_unhandled_exception_handler", "label": "unhandled_exception_handler()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/main.py", "source_location": "L91"}, {"id": "app_main_mask_secret", "label": "_mask_secret()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/main.py", "source_location": "L134"}, {"id": "app_main_root", "label": "root()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/main.py", "source_location": "L156"}, {"id": "app_main_health_check", "label": "health_check()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/main.py", "source_location": "L161"}, {"id": "app_main_rationale_81", "label": "\u6570\u636e\u5e93\u5f02\u5e38\uff1a\u8fd4\u56de JSON \u5e76\u4fdd\u7559 CORS \u5934\uff0c\u907f\u514d\u6d4f\u89c8\u5668\u53ea\u62a5\u8de8\u57df\u9519\u8bef", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/main.py", "source_location": "L81"}, {"id": "app_main_rationale_92", "label": "\u672a\u6355\u83b7\u5f02\u5e38\uff1a\u7edf\u4e00 JSON 500\uff0c\u786e\u4fdd\u8de8\u57df\u573a\u666f\u4e0b\u4ecd\u6709 Access-Control-Allow-Origin", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/main.py", "source_location": "L92"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_main_py", "target": "contextlib", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/main.py", "source_location": "L2", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_main_py", "target": "logging", "relation": "imports", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/main.py", "source_location": "L3", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_main_py", "target": "datetime", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/main.py", "source_location": "L4", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_main_py", "target": "fastapi", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/main.py", "source_location": "L6", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_main_py", "target": "fastapi_middleware_cors", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/main.py", "source_location": "L7", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_main_py", "target": "fastapi_responses", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/main.py", "source_location": "L8", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_main_py", "target": "sqlalchemy_exc", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/main.py", "source_location": "L9", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_main_py", "target": "app_core_config", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/main.py", "source_location": "L11", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_main_py", "target": "app_core_database", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/main.py", "source_location": "L12", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_main_py", "target": "app_core_api_request_log_middleware", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/main.py", "source_location": "L13", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_main_py", "target": "app_core_api_crypto_middleware", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/main.py"Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_prep_py", "label": "production_material_prep.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L1"}, {"id": "crud_production_material_prep_status_label", "label": "_status_label()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L33"}, {"id": "crud_production_material_prep_fmt_date", "label": "_fmt_date()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L41"}, {"id": "crud_production_material_prep_user_nick_name_map", "label": "_user_nick_name_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L45"}, {"id": "crud_production_material_prep_generate_prep_no", "label": "_generate_prep_no()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L53"}, {"id": "crud_production_material_prep_generate_stock_in_no", "label": "_generate_stock_in_no()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L67"}, {"id": "crud_production_material_prep_line_to_dict", "label": "_line_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L85"}, {"id": "crud_production_material_prep_header_to_dict", "label": "_header_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L101"}, {"id": "crud_production_material_prep_get_prep_row", "label": "_get_prep_row()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L132"}, {"id": "crud_production_material_prep_require_draft", "label": "_require_draft()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L147"}, {"id": "crud_production_material_prep_validate_requisition", "label": "_validate_requisition()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L152"}, {"id": "crud_production_material_prep_parse_prep_lines", "label": "_parse_prep_lines()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L184"}, {"id": "crud_production_material_prep_list_preps", "label": "list_preps()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L249"}, {"id": "crud_production_material_prep_get_prep_detail", "label": "get_prep_detail()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L316"}, {"id": "crud_production_material_prep_create_prep", "label": "create_prep()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L341"}, {"id": "crud_production_material_prep_update_prep", "label": "update_prep()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L441"}, {"id": "crud_production_material_prep_write_prep_consume_usage", "label": "_write_prep_consume_usage()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L530"}, {"id": "crud_production_material_prep_complete_prep", "label": "complete_prep()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L596"}, {"id": "crud_production_material_prep_cancel_prep", "label": "cancel_prep()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L712"}, {"id": "crud_production_material_prep_delete_prep", "label": "delete_prep()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L729"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_prep_py", "target": "datetime", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L4", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxwLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_clean_room_py", "label": "clean_room.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L1"}, {"id": "crud_clean_room_row_to_dict", "label": "_row_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L19"}, {"id": "crud_clean_room_list_clean_rooms", "label": "list_clean_rooms()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L35"}, {"id": "crud_clean_room_get_clean_room", "label": "get_clean_room()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L66"}, {"id": "crud_clean_room_room_code_exists", "label": "room_code_exists()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L73"}, {"id": "crud_clean_room_create_clean_room", "label": "create_clean_room()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L82"}, {"id": "crud_clean_room_update_clean_room", "label": "update_clean_room()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L123"}, {"id": "crud_clean_room_soft_delete_clean_room", "label": "soft_delete_clean_room()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L167"}, {"id": "crud_clean_room_access_log_to_dict", "label": "_access_log_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L181"}, {"id": "crud_clean_room_list_access_logs", "label": "list_access_logs()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L200"}, {"id": "crud_clean_room_get_access_log", "label": "get_access_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L237"}, {"id": "crud_clean_room_create_access_log", "label": "create_access_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L244"}, {"id": "crud_clean_room_update_access_log", "label": "update_access_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L289"}, {"id": "crud_clean_room_soft_delete_access_log", "label": "soft_delete_access_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L331"}, {"id": "crud_clean_room_total_pages", "label": "total_pages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L341"}, {"id": "crud_clean_room_calc_duration_minutes", "label": "_calc_duration_minutes()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L351"}, {"id": "crud_clean_room_uv_disinfect_log_to_dict", "label": "_uv_disinfect_log_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L359"}, {"id": "crud_clean_room_list_uv_disinfect_logs", "label": "list_uv_disinfect_logs()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L379"}, {"id": "crud_clean_room_get_uv_disinfect_log", "label": "get_uv_disinfect_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L413"}, {"id": "crud_clean_room_create_uv_disinfect_log", "label": "create_uv_disinfect_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L424"}, {"id": "crud_clean_room_update_uv_disinfect_log", "label": "update_uv_disinfect_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L474"}, {"id": "crud_clean_room_soft_delete_uv_disinfect_log", "label": "soft_delete_uv_disinfect_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L525"}, {"id": "crud_clean_room_rationale_1", "label": "\u6d01\u51c0\u5ba4\u53ca\u8fdb\u51fa\u8bb0\u5f55\u3001\u7d2b\u5916\u7ebf\u6d88\u6bd2\u8bb0\u5f55 CRUD\uff08biz_clean_room + biz_clean_room_access_log + biz_clean_roo", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/clean_room.py", "source_location": "L1"}],Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_api_cleanroom_garment_py", "label": "cleanroom_garment.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/cleanroom_garment.py", "source_location": "L1"}, {"id": "api_cleanroom_garment_get_tenant_no", "label": "_get_tenant_no()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/cleanroom_garment.py", "source_location": "L17"}, {"id": "api_cleanroom_garment_garmentcreatebody", "label": "GarmentCreateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/cleanroom_garment.py", "source_location": "L27"}, {"id": "basemodel", "label": "BaseModel", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "api_cleanroom_garment_garmentupdatebody", "label": "GarmentUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/cleanroom_garment.py", "source_location": "L39"}, {"id": "api_cleanroom_garment_garmentbatchdeletebody", "label": "GarmentBatchDeleteBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/cleanroom_garment.py", "source_location": "L51"}, {"id": "api_cleanroom_garment_garmentdiscardbody", "label": "GarmentDiscardBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/cleanroom_garment.py", "source_location": "L57"}, {"id": "api_cleanroom_garment_garmentbatchdiscardbody", "label": "GarmentBatchDiscardBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/cleanroom_garment.py", "source_location": "L64"}, {"id": "api_cleanroom_garment_washlogcreatebody", "label": "WashLogCreateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/cleanroom_garment.py", "source_location": "L72"}, {"id": "api_cleanroom_garment_washlogupdatebody", "label": "WashLogUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/cleanroom_garment.py", "source_location": "L83"}, {"id": "api_cleanroom_garment_washlogbatchbody", "label": "WashLogBatchBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/cleanroom_garment.py", "source_location": "L93"}, {"id": "api_cleanroom_garment_sterilizelogcreatebody", "label": "SterilizeLogCreateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/cleanroom_garment.py", "source_location": "L103"}, {"id": "api_cleanroom_garment_sterilizelogupdatebody", "label": "SterilizeLogUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/cleanroom_garment.py", "source_location": "L114"}, {"id": "api_cleanroom_garment_sterilizelogbatchbody", "label": "SterilizeLogBatchBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/cleanroom_garment.py", "source_location": "L124"}, {"id": "api_cleanroom_garment_list_cleanroom_garments", "label": "list_cleanroom_garments()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/cleanroom_garment.py", "source_location": "L135"}, {"id": "api_cleanroom_garment_get_cleanroom_garment", "label": "get_cleanroom_garment()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/cleanroom_garment.py", "source_location": "L160"}, {"id": "api_cleanroom_garment_create_cleanroom_garment", "label": "create_cleanroom_garment()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/cleanroom_garment.py", "source_location": "L173"}, {"id": "api_cleanroom_garment_update_cleanroom_garment", "label": "update_cleanroom_garment()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/cleanroom_garment.py", "source_location": "L198"}, {"id": "api_cleanroom_garment_batch_delete_cleanroom_garments", "label": "batch_delete_cleanroom_garments()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/cleanroom_garment.py", "source_location": "L226"}, {"id": "api_cleanroom_garment_delete_cleanroom_garment", "label": "delete_cleanroom_garment()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/cleanroom_garment.py", "source_location": "L240"}, {"id": "api_cleanroom_garment_batch_discard_cleanroom_garments", "label": "batch_discard_cleanroom_garments()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/cleanroom_garment.py", "source_location": "L254"}, {"id": "api_cleanroom_garment_discard_cleanroom_garment", "label": "discard_cleanroom_garment()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/cleanroom_garment.py", "source_location": "L275"}, {"id": "api_cleanroom_garment_list_wash_logs", "label": "list_wash_logs()", "file_type": "code", "source_fiLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_outbound_handover_inventory_py", "label": "outbound_handover_inventory.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/outbound_handover_inventory.py", "source_location": "L1"}, {"id": "crud_outbound_handover_inventory_handover_usage_remark", "label": "_handover_usage_remark()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/outbound_handover_inventory.py", "source_location": "L21"}, {"id": "crud_outbound_handover_inventory_handover_usage_remark_prefix", "label": "_handover_usage_remark_prefix()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/outbound_handover_inventory.py", "source_location": "L25"}, {"id": "crud_outbound_handover_inventory_remove_cell_occupancy_no_commit", "label": "_remove_cell_occupancy_no_commit()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/outbound_handover_inventory.py", "source_location": "L29"}, {"id": "crud_outbound_handover_inventory_restore_cell_occupancy_no_commit", "label": "_restore_cell_occupancy_no_commit()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/outbound_handover_inventory.py", "source_location": "L58"}, {"id": "crud_outbound_handover_inventory_get_cell_product_locked", "label": "_get_cell_product_locked()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/outbound_handover_inventory.py", "source_location": "L135"}, {"id": "crud_outbound_handover_inventory_revert_handover_inventory", "label": "revert_handover_inventory()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/outbound_handover_inventory.py", "source_location": "L156"}, {"id": "crud_outbound_handover_inventory_apply_handover_inventory", "label": "apply_handover_inventory()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/outbound_handover_inventory.py", "source_location": "L226"}, {"id": "crud_outbound_handover_inventory_rationale_1", "label": "\u8f93\u6ce8\u8ba1\u5212\u51fa\u5e93\u4ea4\u63a5 \u2014 \u7ec6\u80de\u4ea7\u54c1\u72b6\u6001\u4e0e\u8d28\u68c0\u7269\u6599\u5e93\u5b58\u8054\u52a8\u3002", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/outbound_handover_inventory.py", "source_location": "L1"}, {"id": "crud_outbound_handover_inventory_rationale_35", "label": "\u6309\u7ec6\u80de\u4ea7\u54c1 ID \u91ca\u653e\u5e93\u4f4d\u5360\u7528\uff08\u4e0d commit\uff09\u3002", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/outbound_handover_inventory.py", "source_location": "L35"}, {"id": "crud_outbound_handover_inventory_rationale_65", "label": "\u51fa\u5e93\u4ea4\u63a5\u56de\u6eda\u65f6\u6062\u590d\u5e93\u4f4d\u5360\u7528\uff08\u4e0d commit\uff09\u3002", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/outbound_handover_inventory.py", "source_location": "L65"}, {"id": "crud_outbound_handover_inventory_rationale_164", "label": "\u56de\u6eda\u672c\u8f93\u6ce8\u8ba1\u5212\u4e0a\u6b21\u51fa\u5e93\u4ea4\u63a5\u4ea7\u751f\u7684\u5e93\u5b58/\u72b6\u6001\u53d8\u66f4\uff08\u4e0d commit\uff09\u3002", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/outbound_handover_inventory.py", "source_location": "L164"}, {"id": "crud_outbound_handover_inventory_rationale_237", "label": "\u5e94\u7528\u51fa\u5e93\u4ea4\u63a5\uff1a\u7ec6\u80de\u4ea7\u54c1\u51fa\u5e93 + \u8d28\u68c0\u7269\u6599\u6263\u51cf\uff08\u4e0d commit\uff09\u3002", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/outbound_handover_inventory.py", "source_location": "L237"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_outbound_handover_inventory_py", "target": "datetime", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/outbound_handover_inventory.py", "source_location": "L4", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_outbound_handover_inventory_py", "target": "decimal", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/outbound_handover_inventory.py", "source_location": "L5", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_outbound_handover_inventory_py", "target": "typing", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/outbound_handover_inventory.py", "source_location": "L6", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_outbound_handover_inventory_py", "target": "fastapi", "relation": "imports_from", "confidence": "EXTRACTED",Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_api_production_material_py", "label": "production_material.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L1"}, {"id": "api_production_material_productionmaterialbody", "label": "ProductionMaterialBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L28"}, {"id": "basemodel", "label": "BaseModel", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "api_production_material_productionmaterialupdatebody", "label": "ProductionMaterialUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L40"}, {"id": "api_production_material_stockinbody", "label": "StockInBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L52"}, {"id": "api_production_material_batchstockinitem", "label": "BatchStockInItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L68"}, {"id": "api_production_material_batchstockinbody", "label": "BatchStockInBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L84"}, {"id": "api_production_material_batchstockoutitem", "label": "BatchStockOutItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L91"}, {"id": "api_production_material_batchstockoutbody", "label": "BatchStockOutBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L98"}, {"id": "api_production_material_batchdiscarditem", "label": "BatchDiscardItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L107"}, {"id": "api_production_material_batchdiscardbody", "label": "BatchDiscardBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L115"}, {"id": "api_production_material_productionmaterialbatchupdatebody", "label": "ProductionMaterialBatchUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L123"}, {"id": "api_production_material_list_production_material_batches", "label": "list_production_material_batches()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L144"}, {"id": "api_production_material_production_material_batch_options", "label": "production_material_batch_options()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L175"}, {"id": "api_production_material_update_production_material_batch", "label": "update_production_material_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L200"}, {"id": "api_production_material_delete_production_material_batch", "label": "delete_production_material_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L229"}, {"id": "api_production_material_list_production_materials", "label": "list_production_materials()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L246"}, {"id": "api_production_material_production_material_options", "label": "production_material_options()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L275"}, {"id": "api_production_material_create_production_material", "label": "create_production_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L290"}, {"id": "api_production_material_update_production_material", "label": "update_production_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L321"}, {"id": "api_production_material_delete_production_material", "label": "delete_production_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L350"}, {"id": "api_production_material_batch_stock_in_production_material", "label": "batch_stock_in_production_material()", "file_type": "code", "source_file": "/Users/wLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_stock_check_py", "label": "material_stock_check.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_check.py", "source_location": "L1"}, {"id": "crud_material_stock_check_user_nick_name_map", "label": "_user_nick_name_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_check.py", "source_location": "L22"}, {"id": "crud_material_stock_check_status_label", "label": "_status_label()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_check.py", "source_location": "L30"}, {"id": "crud_material_stock_check_batch_line_to_dict", "label": "_batch_line_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_check.py", "source_location": "L38"}, {"id": "crud_material_stock_check_unused_amount", "label": "_unused_amount()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_check.py", "source_location": "L62"}, {"id": "crud_material_stock_check_unused_line_to_dict", "label": "_unused_line_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_check.py", "source_location": "L68"}, {"id": "crud_material_stock_check_check_header_to_dict", "label": "_check_header_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_check.py", "source_location": "L92"}, {"id": "crud_material_stock_check_get_check", "label": "_get_check()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_check.py", "source_location": "L116"}, {"id": "crud_material_stock_check_line_counts", "label": "_line_counts()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_check.py", "source_location": "L128"}, {"id": "crud_material_stock_check_list_checks", "label": "list_checks()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_check.py", "source_location": "L163"}, {"id": "crud_material_stock_check_get_check_detail", "label": "get_check_detail()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_check.py", "source_location": "L223"}, {"id": "crud_material_stock_check_parse_check_time", "label": "_parse_check_time()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_check.py", "source_location": "L258"}, {"id": "crud_material_stock_check_create_check", "label": "create_check()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_check.py", "source_location": "L272"}, {"id": "crud_material_stock_check_parse_optional_date", "label": "_parse_optional_date()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_check.py", "source_location": "L349"}, {"id": "crud_material_stock_check_save_unused_lines", "label": "save_unused_lines()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_check.py", "source_location": "L355"}, {"id": "crud_material_stock_check_complete_check", "label": "complete_check()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_check.py", "source_location": "L434"}, {"id": "crud_material_stock_check_cancel_check", "label": "cancel_check()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_check.py", "source_location": "L455"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_stock_check_py", "target": "datetime", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_check.py", "source_location": "L4", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_stock_check_py", "target": "decimal", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_check.py", "source_location": "L5", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_stock_check_py", "target": "typing", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_check.py", "source_location": "L6", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_stock_check_py", "target": "sqlalchemy", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_stock_check.py", "sourceLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_api_material_py", "label": "material.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L1"}, {"id": "api_material_materialbody", "label": "MaterialBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L27"}, {"id": "basemodel", "label": "BaseModel", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "api_material_materialupdatebody", "label": "MaterialUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L41"}, {"id": "api_material_stockinbody", "label": "StockInBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L55"}, {"id": "api_material_batchstockinitem", "label": "BatchStockInItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L70"}, {"id": "api_material_batchstockinbody", "label": "BatchStockInBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L85"}, {"id": "api_material_batchstockoutitem", "label": "BatchStockOutItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L92"}, {"id": "api_material_batchstockoutbody", "label": "BatchStockOutBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L99"}, {"id": "api_material_batchdiscarditem", "label": "BatchDiscardItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L108"}, {"id": "api_material_batchdiscardbody", "label": "BatchDiscardBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L116"}, {"id": "api_material_materialbatchupdatebody", "label": "MaterialBatchUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L124"}, {"id": "api_material_stockcheckcreatebody", "label": "StockCheckCreateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L143"}, {"id": "api_material_stockcheckunusedlineitem", "label": "StockCheckUnusedLineItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L150"}, {"id": "api_material_stockcheckunusedlinesbody", "label": "StockCheckUnusedLinesBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L168"}, {"id": "api_material_list_material_batches", "label": "list_material_batches()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L177"}, {"id": "api_material_material_batch_options", "label": "material_batch_options()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L206"}, {"id": "api_material_update_material_batch", "label": "update_material_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L229"}, {"id": "api_material_delete_material_batch", "label": "delete_material_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L258"}, {"id": "api_material_list_materials", "label": "list_materials()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L278"}, {"id": "api_material_material_options", "label": "material_options()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L301"}, {"id": "api_material_create_material", "label": "create_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L313"}, {"id": "api_material_update_material", "label": "update_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L333"}, {"id": "api_material_delete_material", "label": "delete_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L354"}, {"id": "api_material_batch_stock_in_material", "label": "batch_stock_in_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/material.py", "source_location": "L371"}, {"id": "api_material_batchLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_cleanroom_garment_py", "label": "cleanroom_garment.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L1"}, {"id": "crud_cleanroom_garment_total_pages", "label": "total_pages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L22"}, {"id": "crud_cleanroom_garment_parse_date", "label": "_parse_date()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L28"}, {"id": "crud_cleanroom_garment_parse_datetime", "label": "_parse_datetime()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L46"}, {"id": "crud_cleanroom_garment_parse_limit", "label": "_parse_limit()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L62"}, {"id": "crud_cleanroom_garment_count_map", "label": "_count_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L74"}, {"id": "crud_cleanroom_garment_garment_to_dict", "label": "_garment_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L86"}, {"id": "crud_cleanroom_garment_list_garments", "label": "list_garments()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L116"}, {"id": "crud_cleanroom_garment_get_garment", "label": "get_garment()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L207"}, {"id": "crud_cleanroom_garment_get_garment_detail", "label": "get_garment_detail()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L218"}, {"id": "crud_cleanroom_garment_garment_code_exists", "label": "garment_code_exists()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L233"}, {"id": "crud_cleanroom_garment_create_garment", "label": "create_garment()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L248"}, {"id": "crud_cleanroom_garment_update_garment", "label": "update_garment()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L297"}, {"id": "crud_cleanroom_garment_soft_delete_garment", "label": "soft_delete_garment()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L347"}, {"id": "crud_cleanroom_garment_batch_soft_delete_garments", "label": "batch_soft_delete_garments()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L357"}, {"id": "crud_cleanroom_garment_discard_garment", "label": "discard_garment()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L370"}, {"id": "crud_cleanroom_garment_batch_discard_garments", "label": "batch_discard_garments()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L397"}, {"id": "crud_cleanroom_garment_ensure_garment_active", "label": "_ensure_garment_active()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L432"}, {"id": "crud_cleanroom_garment_wash_log_to_dict", "label": "_wash_log_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L445"}, {"id": "crud_cleanroom_garment_list_wash_logs", "label": "list_wash_logs()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L460"}, {"id": "crud_cleanroom_garment_get_wash_log", "label": "get_wash_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L486"}, {"id": "crud_cleanroom_garment_create_wash_log", "label": "create_wash_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroom_garment.py", "source_location": "L495"}, {"id": "crud_cleanroom_garment_update_wash_log", "label": "update_wash_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cleanroLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_api_production_py", "label": "production.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L1"}, {"id": "api_production_legacy_material_write_gone", "label": "_legacy_material_write_gone()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L75"}, {"id": "api_production_get_tenant_no", "label": "_get_tenant_no()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L79"}, {"id": "api_production_get_current_user_id", "label": "_get_current_user_id()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L87"}, {"id": "api_production_assert_production_task_write_access", "label": "_assert_production_task_write_access()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L91"}, {"id": "api_production_consumablecreatebody", "label": "ConsumableCreateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L115"}, {"id": "basemodel", "label": "BaseModel", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "api_production_consumableupdatebody", "label": "ConsumableUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L129"}, {"id": "api_production_list_consumables", "label": "list_consumables()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L144"}, {"id": "api_production_list_all_consumables", "label": "list_all_consumables()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L158"}, {"id": "api_production_create_consumable", "label": "create_consumable()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L168"}, {"id": "api_production_update_consumable", "label": "update_consumable()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L177"}, {"id": "api_production_delete_consumable", "label": "delete_consumable()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L187"}, {"id": "api_production_stockinbody", "label": "StockInBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L195"}, {"id": "api_production_stockoutbody", "label": "StockOutBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L201"}, {"id": "api_production_batchstockinitem", "label": "BatchStockInItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L209"}, {"id": "api_production_batchstockinbody", "label": "BatchStockInBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L216"}, {"id": "api_production_batchstockoutitem", "label": "BatchStockOutItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L222"}, {"id": "api_production_batchstockoutbody", "label": "BatchStockOutBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L228"}, {"id": "api_production_consumable_stock_in", "label": "consumable_stock_in()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L237"}, {"id": "api_production_consumable_stock_out", "label": "consumable_stock_out()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L259"}, {"id": "api_production_consumable_batch_stock_in", "label": "consumable_batch_stock_in()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L283"}, {"id": "api_production_consumable_batch_stock_out", "label": "consumable_batch_stock_out()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L301"}, {"id": "api_production_list_consumable_stock_logs", "label": "list_consumable_stock_logs()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L320"}, {"id": "api_production_list_all_consumable_stock_logs", "labLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_api_qc_py", "label": "qc.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L1"}, {"id": "api_qc_thirdpartycompanybody", "label": "ThirdPartyCompanyBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L44"}, {"id": "basemodel", "label": "BaseModel", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "api_qc_thirdpartycompanyupdatebody", "label": "ThirdPartyCompanyUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L61"}, {"id": "api_qc_list_qc_third_party_companies", "label": "list_qc_third_party_companies()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L79"}, {"id": "api_qc_list_qc_third_party_company_options", "label": "list_qc_third_party_company_options()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L101"}, {"id": "api_qc_create_qc_third_party_company", "label": "create_qc_third_party_company()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L115"}, {"id": "api_qc_update_qc_third_party_company", "label": "update_qc_third_party_company()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L149"}, {"id": "api_qc_delete_qc_third_party_company", "label": "delete_qc_third_party_company()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L185"}, {"id": "api_qc_thirdpartyitembody", "label": "ThirdPartyItemBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L205"}, {"id": "api_qc_thirdpartyitemupdatebody", "label": "ThirdPartyItemUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L217"}, {"id": "api_qc_list_qc_third_party_items", "label": "list_qc_third_party_items()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L230"}, {"id": "api_qc_list_qc_third_party_items_active", "label": "list_qc_third_party_items_active()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L259"}, {"id": "api_qc_create_qc_third_party_item", "label": "create_qc_third_party_item()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L274"}, {"id": "api_qc_update_qc_third_party_item", "label": "update_qc_third_party_item()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L303"}, {"id": "api_qc_delete_qc_third_party_item", "label": "delete_qc_third_party_item()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L334"}, {"id": "api_qc_labtestitembody", "label": "LabTestItemBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L354"}, {"id": "api_qc_labtestitemupdatebody", "label": "LabTestItemUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L365"}, {"id": "api_qc_itemparambody", "label": "ItemParamBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L379"}, {"id": "api_qc_taskresultbody", "label": "TaskResultBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L384"}, {"id": "api_qc_taskcompletewithresultbody", "label": "TaskCompleteWithResultBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L389"}, {"id": "api_qc_list_qc_lab_test_items", "label": "list_qc_lab_test_items()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L399"}, {"id": "api_qc_list_qc_lab_test_items_active", "label": "list_qc_lab_test_items_active()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L421"}, {"id": "api_qc_create_qc_lab_test_item", "label": "create_qc_lab_test_item()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L435"}, {"id": "api_qc_update_qc_lab_test_item", "label": "update_qc_lab_test_item()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/qc.py", "source_location": "L463"}, {"id": "api_Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_storage_facility_py", "label": "storage_facility.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L1"}, {"id": "crud_storage_facility_row_to_dict", "label": "_row_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L28"}, {"id": "crud_storage_facility_list_all_facilities", "label": "list_all_facilities()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L44"}, {"id": "crud_storage_facility_get_facility", "label": "get_facility()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L67"}, {"id": "crud_storage_facility_get_children", "label": "get_children()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L76"}, {"id": "crud_storage_facility_collect_descendant_ids", "label": "collect_descendant_ids()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L92"}, {"id": "crud_storage_facility_create_facility", "label": "create_facility()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L105"}, {"id": "crud_storage_facility_update_facility", "label": "update_facility()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L149"}, {"id": "crud_storage_facility_soft_delete_facility", "label": "soft_delete_facility()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L207"}, {"id": "crud_storage_facility_slot_to_dict", "label": "_slot_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L233"}, {"id": "crud_storage_facility_list_slots", "label": "list_slots()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L256"}, {"id": "crud_storage_facility_get_slot", "label": "get_slot()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L275"}, {"id": "crud_storage_facility_slot_to_dict_for_row", "label": "_slot_to_dict_for_row()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L284"}, {"id": "crud_storage_facility_create_slot", "label": "create_slot()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L289"}, {"id": "crud_storage_facility_update_slot", "label": "update_slot()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L324"}, {"id": "crud_storage_facility_soft_delete_slot", "label": "soft_delete_slot()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L360"}, {"id": "crud_storage_facility_clear_slots_by_facility_node", "label": "clear_slots_by_facility_node()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L370"}, {"id": "crud_storage_facility_batch_create_slots", "label": "batch_create_slots()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L402"}, {"id": "crud_storage_facility_insert_row_and_shift_slots", "label": "insert_row_and_shift_slots()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L455"}, {"id": "crud_storage_facility_rationale_1", "label": "\u5b58\u50a8\u8bbe\u65bd\uff08\u6811\u7ed3\u6784\uff09+ \u5c0f\u683c CRUD\uff08biz_storage_facility / biz_storage_facility_slot\uff09", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L1"}, {"id": "crud_storage_facility_rationale_50", "label": "Return FLAT list of all non-deleted facility nodes (no pagination, no tree build", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L50"}, {"id": "crud_storage_facility_rationale_77", "label": "Direct children of a node.", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L77"}, {"id": "Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_task_py", "label": "production_task.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L1"}, {"id": "crud_production_task_production_conclusion_label", "label": "_production_conclusion_label()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L72"}, {"id": "crud_production_task_fmt_dt", "label": "_fmt_dt()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L79"}, {"id": "crud_production_task_normalize_date_bound", "label": "_normalize_date_bound()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L83"}, {"id": "crud_production_task_enrich_outbound_task_items", "label": "_enrich_outbound_task_items()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L90"}, {"id": "crud_production_task_generate_task_no", "label": "_generate_task_no()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L179"}, {"id": "crud_production_task_task_to_dict", "label": "_task_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L193"}, {"id": "crud_production_task_step_to_dict", "label": "_step_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L220"}, {"id": "crud_production_task_step_reagent_to_dict", "label": "_step_reagent_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L240"}, {"id": "crud_production_task_step_consumable_to_dict", "label": "_step_consumable_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L256"}, {"id": "crud_production_task_step_output_to_dict", "label": "_step_output_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L272"}, {"id": "crud_production_task_step_data_collection_to_dict", "label": "_step_data_collection_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L284"}, {"id": "crud_production_task_task_input_to_dict", "label": "_task_input_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L296"}, {"id": "crud_production_task_task_output_to_dict", "label": "_task_output_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L318"}, {"id": "crud_production_task_soft_delete_sub", "label": "_soft_delete_sub()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L343"}, {"id": "crud_production_task_resolve_sub_table_order_num", "label": "_resolve_sub_table_order_num()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L356"}, {"id": "crud_production_task_step_sub_tables_to_dict", "label": "_step_sub_tables_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L365"}, {"id": "crud_production_task_clone_step_reagents", "label": "_clone_step_reagents()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L387"}, {"id": "crud_production_task_clone_step_consumables", "label": "_clone_step_consumables()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L410"}, {"id": "crud_production_task_clone_step_outputs", "label": "_clone_step_outputs()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L433"}, {"id": "crud_production_task_clone_step_data_collections", "label": "_clone_step_data_collections()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L455"}, {"id": "crud_production_task_clone_route_to_task", "label": "_clone_route_to_task()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L476"}, {"id": "crud_production_task_validate_assignee_user_iLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_usage_py", "label": "material_usage.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_usage.py", "source_location": "L1"}, {"id": "crud_material_usage_parse_receiver_purpose_from_remark", "label": "_parse_receiver_purpose_from_remark()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_usage.py", "source_location": "L13"}, {"id": "crud_material_usage_resolve_receiver_purpose", "label": "_resolve_receiver_purpose()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_usage.py", "source_location": "L24"}, {"id": "crud_material_usage_display_remark", "label": "_display_remark()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_usage.py", "source_location": "L34"}, {"id": "crud_material_usage_user_nick_name_map", "label": "_user_nick_name_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_usage.py", "source_location": "L49"}, {"id": "crud_material_usage_receiver_display_map", "label": "_receiver_display_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_usage.py", "source_location": "L57"}, {"id": "crud_material_usage_usage_unit_label", "label": "_usage_unit_label()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_usage.py", "source_location": "L68"}, {"id": "crud_material_usage_stock_in_date_for_row", "label": "_stock_in_date_for_row()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_usage.py", "source_location": "L77"}, {"id": "crud_material_usage_unit_price_for_row", "label": "_unit_price_for_row()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_usage.py", "source_location": "L83"}, {"id": "crud_material_usage_amount_for_row", "label": "_amount_for_row()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_usage.py", "source_location": "L91"}, {"id": "crud_material_usage_row_to_dict", "label": "_row_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_usage.py", "source_location": "L107"}, {"id": "crud_material_usage_batch_map", "label": "_batch_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_usage.py", "source_location": "L157"}, {"id": "crud_material_usage_list_usages_query", "label": "_list_usages_query()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_usage.py", "source_location": "L169"}, {"id": "crud_material_usage_paginate_usages", "label": "_paginate_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_usage.py", "source_location": "L223"}, {"id": "crud_material_usage_list_usages", "label": "list_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_usage.py", "source_location": "L254"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_usage_py", "target": "typing", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_usage.py", "source_location": "L4", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_usage_py", "target": "sqlalchemy", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_usage.py", "source_location": "L6", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_usage_py", "target": "sqlalchemy_orm", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_usage.py", "source_location": "L7", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_usage_py", "target": "app_models_material", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_usage.py", "source_location": "L9", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_usage_py", "target": "app_models_models", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material_usage.py", "source_location": "L10", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_usage_py", "target": "crud_material_usage_parse_receiver_purpose_from_remark", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_api_production_py", "label": "production.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L1"}, {"id": "api_production_get_tenant_no", "label": "_get_tenant_no()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L73"}, {"id": "api_production_get_current_user_id", "label": "_get_current_user_id()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L81"}, {"id": "api_production_assert_production_task_write_access", "label": "_assert_production_task_write_access()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L85"}, {"id": "api_production_consumablecreatebody", "label": "ConsumableCreateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L109"}, {"id": "basemodel", "label": "BaseModel", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "api_production_consumableupdatebody", "label": "ConsumableUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L123"}, {"id": "api_production_list_consumables", "label": "list_consumables()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L138"}, {"id": "api_production_list_all_consumables", "label": "list_all_consumables()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L152"}, {"id": "api_production_create_consumable", "label": "create_consumable()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L162"}, {"id": "api_production_update_consumable", "label": "update_consumable()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L190"}, {"id": "api_production_delete_consumable", "label": "delete_consumable()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L219"}, {"id": "api_production_stockinbody", "label": "StockInBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L231"}, {"id": "api_production_stockoutbody", "label": "StockOutBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L237"}, {"id": "api_production_batchstockinitem", "label": "BatchStockInItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L245"}, {"id": "api_production_batchstockinbody", "label": "BatchStockInBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L252"}, {"id": "api_production_batchstockoutitem", "label": "BatchStockOutItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L258"}, {"id": "api_production_batchstockoutbody", "label": "BatchStockOutBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L264"}, {"id": "api_production_consumable_stock_in", "label": "consumable_stock_in()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L273"}, {"id": "api_production_consumable_stock_out", "label": "consumable_stock_out()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L295"}, {"id": "api_production_consumable_batch_stock_in", "label": "consumable_batch_stock_in()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L319"}, {"id": "api_production_consumable_batch_stock_out", "label": "consumable_batch_stock_out()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L337"}, {"id": "api_production_list_consumable_stock_logs", "label": "list_consumable_stock_logs()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L356"}, {"id": "api_production_list_all_consumable_stock_logs", "label": "list_all_consumable_stock_logs()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L375"}, {"id": "api_production_reagentcreatebody", "label": Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_stock_batch_py", "label": "production_material_stock_batch.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L1"}, {"id": "crud_production_material_stock_batch_fmt_date", "label": "_fmt_date()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L16"}, {"id": "crud_production_material_stock_batch_parse_date", "label": "_parse_date()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L20"}, {"id": "crud_production_material_stock_batch_parse_expire_date", "label": "_parse_expire_date()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L34"}, {"id": "crud_production_material_stock_batch_require_str", "label": "_require_str()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L38"}, {"id": "crud_production_material_stock_batch_require_decimal", "label": "_require_decimal()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L45"}, {"id": "crud_production_material_stock_batch_stock_in_no_exists", "label": "stock_in_no_exists()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L57"}, {"id": "crud_production_material_stock_batch_batch_row_to_dict", "label": "_batch_row_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L73"}, {"id": "crud_production_material_stock_batch_usage_batch_snapshots", "label": "_usage_batch_snapshots()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L106"}, {"id": "crud_production_material_stock_batch_get_material_for_update", "label": "_get_material_for_update()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L127"}, {"id": "crud_production_material_stock_batch_list_batches", "label": "list_batches()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L145"}, {"id": "crud_production_material_stock_batch_batch_options", "label": "batch_options()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L213"}, {"id": "crud_production_material_stock_batch_create_batch_and_usage", "label": "_create_batch_and_usage()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L291"}, {"id": "crud_production_material_stock_batch_stock_in_one", "label": "stock_in_one()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L384"}, {"id": "crud_production_material_stock_batch_batch_stock_in", "label": "batch_stock_in()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L425"}, {"id": "crud_production_material_stock_batch_stock_out_batch", "label": "_stock_out_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L481"}, {"id": "crud_production_material_stock_batch_batch_stock_out", "label": "batch_stock_out()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L563"}, {"id": "crud_production_material_stock_batch_get_batch", "label": "get_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L613"}, {"id": "crud_production_material_stock_batch_update_batch", "label": "update_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L625"}, {"id": "crud_production_material_stock_batch_delete_batch", "label": "delete_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L736"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_baLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_api_production_py", "label": "production.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L1"}, {"id": "api_production_legacy_material_write_gone", "label": "_legacy_material_write_gone()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L75"}, {"id": "api_production_get_tenant_no", "label": "_get_tenant_no()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L79"}, {"id": "api_production_get_current_user_id", "label": "_get_current_user_id()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L87"}, {"id": "api_production_assert_production_task_write_access", "label": "_assert_production_task_write_access()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L91"}, {"id": "api_production_consumablecreatebody", "label": "ConsumableCreateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L115"}, {"id": "basemodel", "label": "BaseModel", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "api_production_consumableupdatebody", "label": "ConsumableUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L129"}, {"id": "api_production_list_consumables", "label": "list_consumables()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L144"}, {"id": "api_production_list_all_consumables", "label": "list_all_consumables()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L158"}, {"id": "api_production_create_consumable", "label": "create_consumable()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L168"}, {"id": "api_production_update_consumable", "label": "update_consumable()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L177"}, {"id": "api_production_delete_consumable", "label": "delete_consumable()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L187"}, {"id": "api_production_stockinbody", "label": "StockInBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L195"}, {"id": "api_production_stockoutbody", "label": "StockOutBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L201"}, {"id": "api_production_batchstockinitem", "label": "BatchStockInItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L209"}, {"id": "api_production_batchstockinbody", "label": "BatchStockInBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L216"}, {"id": "api_production_batchstockoutitem", "label": "BatchStockOutItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L222"}, {"id": "api_production_batchstockoutbody", "label": "BatchStockOutBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L228"}, {"id": "api_production_consumable_stock_in", "label": "consumable_stock_in()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L237"}, {"id": "api_production_consumable_stock_out", "label": "consumable_stock_out()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L259"}, {"id": "api_production_consumable_batch_stock_in", "label": "consumable_batch_stock_in()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L283"}, {"id": "api_production_consumable_batch_stock_out", "label": "consumable_batch_stock_out()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L301"}, {"id": "api_production_list_consumable_stock_logs", "label": "list_consumable_stock_logs()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L320"}, {"id": "api_production_list_all_consumable_stock_logs", "labLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_storage_occupancy_py", "label": "storage_occupancy.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_occupancy.py", "source_location": "L1"}, {"id": "crud_storage_occupancy_assert_batch_slots_unique", "label": "assert_batch_slots_unique()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_occupancy.py", "source_location": "L23"}, {"id": "crud_storage_occupancy_assert_slot_vacant", "label": "assert_slot_vacant()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_occupancy.py", "source_location": "L35"}, {"id": "crud_storage_occupancy_add_stored_occupancy_no_commit", "label": "_add_stored_occupancy_no_commit()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_occupancy.py", "source_location": "L85"}, {"id": "crud_storage_occupancy_remove_by_item_no_commit", "label": "remove_by_item_no_commit()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_occupancy.py", "source_location": "L128"}, {"id": "crud_storage_occupancy_row_to_dict", "label": "_row_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_occupancy.py", "source_location": "L154"}, {"id": "crud_storage_occupancy_refresh_slot_cache", "label": "_refresh_slot_cache()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_occupancy.py", "source_location": "L173"}, {"id": "crud_storage_occupancy_create_occupancy", "label": "create_occupancy()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_occupancy.py", "source_location": "L208"}, {"id": "crud_storage_occupancy_batch_create_occupancies", "label": "batch_create_occupancies()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_occupancy.py", "source_location": "L243"}, {"id": "crud_storage_occupancy_remove_occupancy", "label": "remove_occupancy()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_occupancy.py", "source_location": "L281"}, {"id": "crud_storage_occupancy_remove_by_item", "label": "remove_by_item()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_occupancy.py", "source_location": "L309"}, {"id": "crud_storage_occupancy_list_occupancies", "label": "list_occupancies()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_occupancy.py", "source_location": "L321"}, {"id": "crud_storage_occupancy_list_occupancy_history", "label": "list_occupancy_history()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_occupancy.py", "source_location": "L355"}, {"id": "crud_storage_occupancy_rationale_1", "label": "\u5e93\u4f4d\u5360\u7528\u8bb0\u5f55 CRUD\uff08biz_storage_slot_occupancy\uff09", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_occupancy.py", "source_location": "L1"}, {"id": "crud_storage_occupancy_rationale_43", "label": "\u65ad\u8a00\u50a8\u7269\u683c\u5f53\u524d\u65e0\u5728\u5e93\u7269\u54c1\uff08\u4efb\u610f item_type\uff09\u3002", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_occupancy.py", "source_location": "L43"}, {"id": "crud_storage_occupancy_rationale_174", "label": "\u5237\u65b0 slot \u7684 occupied_count / last_item_type / last_stored_at / slot_status", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_occupancy.py", "source_location": "L174"}, {"id": "crud_storage_occupancy_rationale_316", "label": "\u6309\u7269\u54c1\u7c7b\u578b+ID\u51fa\u5e93\uff08\u7ec6\u80de\u4ea7\u54c1\u72b6\u6001\u53d8\u66f4\u65f6\u8c03\u7528\uff09", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_occupancy.py", "source_location": "L316"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_storage_occupancy_py", "target": "datetime", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_occupancy.py", "source_location": "L4", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_storage_occupancy_py", "target": "typing", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_occupancy.py", "source_location": "L5", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_storage_occupancy_py", "target": "sqlalchemy", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "label": "production_material.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L1"}, {"id": "models_production_material_bizproductionmaterial", "label": "BizProductionMaterial", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L8"}, {"id": "base", "label": "Base", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "models_production_material_bizproductionmaterialstockbatch", "label": "BizProductionMaterialStockBatch", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L31"}, {"id": "models_production_material_bizproductionmaterialusage", "label": "BizProductionMaterialUsage", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L63"}, {"id": "models_production_material_bizproductionmaterialformula", "label": "BizProductionMaterialFormula", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L107"}, {"id": "models_production_material_bizproductionmaterialprep", "label": "BizProductionMaterialPrep", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L129"}, {"id": "models_production_material_bizproductionmaterialprepline", "label": "BizProductionMaterialPrepLine", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L157"}, {"id": "models_production_material_bizproductionmaterialstockcheck", "label": "BizProductionMaterialStockCheck", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L180"}, {"id": "models_production_material_bizproductionmaterialstockcheckbatchline", "label": "BizProductionMaterialStockCheckBatchLine", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L199"}, {"id": "models_production_material_bizproductionmaterialstockcheckunusedline", "label": "BizProductionMaterialStockCheckUnusedLine", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L232"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "datetime", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L1", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "sqlalchemy", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L3", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "app_core_database", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L5", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "models_production_material_bizproductionmaterial", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L8", "weight": 1.0}, {"source": "models_production_material_bizproductionmaterial", "target": "base", "relation": "inherits", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L8", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "models_production_material_bizproductionmaterialstockbatch", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L31", "weight": 1.0}, {"source": "models_production_material_bizproductionmaterialstockbatch", "target": "base", "relation": "inherits", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L31", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "models_production_material_bizproductionmaterialusage", "relation": "contains", "confidence": "EXTRACTED", "sourceLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "label": "menu.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L1"}, {"id": "api_menu_get_menu_list", "label": "get_menu_list()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L887"}, {"id": "api_menu_rationale_1", "label": "\u8fd0\u8425\u7aef\u83dc\u5355\u63a5\u53e3\uff08\u4e0e web-admin \u524d\u7aef\u9759\u6001\u8def\u7531 sqxp.ts \u5bf9\u9f50\uff0c5 \u4e2a\u4e00\u7ea7\u83dc\u5355\u5206\u7ec4\uff09", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L1"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "target": "fastapi", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L2", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "target": "app_core_menu_guard", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L4", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "target": "app_core_response", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L5", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "target": "api_menu_get_menu_list", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L887", "weight": 1.0}, {"source": "api_menu_rationale_1", "target": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "relation": "rationale_for", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L1", "weight": 1.0}], "raw_calls": [{"caller_nid": "api_menu_get_menu_list", "callee": "success_response", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L889"}]}
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_storage_facility_py", "label": "storage_facility.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L1"}, {"id": "crud_storage_facility_row_to_dict", "label": "_row_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L20"}, {"id": "crud_storage_facility_list_all_facilities", "label": "list_all_facilities()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L35"}, {"id": "crud_storage_facility_get_facility", "label": "get_facility()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L53"}, {"id": "crud_storage_facility_get_children", "label": "get_children()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L62"}, {"id": "crud_storage_facility_collect_descendant_ids", "label": "collect_descendant_ids()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L78"}, {"id": "crud_storage_facility_create_facility", "label": "create_facility()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L91"}, {"id": "crud_storage_facility_update_facility", "label": "update_facility()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L128"}, {"id": "crud_storage_facility_soft_delete_facility", "label": "soft_delete_facility()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L164"}, {"id": "crud_storage_facility_slot_to_dict", "label": "_slot_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L190"}, {"id": "crud_storage_facility_list_slots", "label": "list_slots()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L206"}, {"id": "crud_storage_facility_get_slot", "label": "get_slot()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L224"}, {"id": "crud_storage_facility_create_slot", "label": "create_slot()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L233"}, {"id": "crud_storage_facility_update_slot", "label": "update_slot()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L268"}, {"id": "crud_storage_facility_soft_delete_slot", "label": "soft_delete_slot()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L298"}, {"id": "crud_storage_facility_clear_slots_by_facility_node", "label": "clear_slots_by_facility_node()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L308"}, {"id": "crud_storage_facility_batch_create_slots", "label": "batch_create_slots()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L340"}, {"id": "crud_storage_facility_insert_row_and_shift_slots", "label": "insert_row_and_shift_slots()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L394"}, {"id": "crud_storage_facility_rationale_1", "label": "\u5b58\u50a8\u8bbe\u65bd\uff08\u6811\u7ed3\u6784\uff09+ \u5c0f\u683c CRUD\uff08biz_storage_facility / biz_storage_facility_slot\uff09", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L1"}, {"id": "crud_storage_facility_rationale_41", "label": "Return FLAT list of all non-deleted facility nodes (no pagination, no tree build", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L41"}, {"id": "crud_storage_facility_rationale_63", "label": "Direct children of a node.", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facility.py", "source_location": "L63"}, {"id": "crud_storage_facility_rationale_79", "label": "Iteratively collect ALL descendant node IDs (stack-based, no recursion).", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/storage_facilLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_task_py", "label": "production_task.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L1"}, {"id": "crud_production_task_require_requisition_for_catalog_material", "label": "_require_requisition_for_catalog_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L47"}, {"id": "crud_production_task_production_conclusion_label", "label": "_production_conclusion_label()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L99"}, {"id": "crud_production_task_fmt_dt", "label": "_fmt_dt()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L106"}, {"id": "crud_production_task_normalize_date_bound", "label": "_normalize_date_bound()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L110"}, {"id": "crud_production_task_enrich_outbound_task_items", "label": "_enrich_outbound_task_items()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L117"}, {"id": "crud_production_task_generate_task_no", "label": "_generate_task_no()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L206"}, {"id": "crud_production_task_task_to_dict", "label": "_task_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L220"}, {"id": "crud_production_task_step_to_dict", "label": "_step_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L247"}, {"id": "crud_production_task_step_reagent_to_dict", "label": "_step_reagent_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L267"}, {"id": "crud_production_task_step_configured_reagent_to_dict", "label": "_step_configured_reagent_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L284"}, {"id": "crud_production_task_step_consumable_to_dict", "label": "_step_consumable_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L300"}, {"id": "crud_production_task_step_output_to_dict", "label": "_step_output_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L317"}, {"id": "crud_production_task_step_data_collection_to_dict", "label": "_step_data_collection_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L329"}, {"id": "crud_production_task_task_input_to_dict", "label": "_task_input_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L341"}, {"id": "crud_production_task_task_output_to_dict", "label": "_task_output_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L363"}, {"id": "crud_production_task_soft_delete_sub", "label": "_soft_delete_sub()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L388"}, {"id": "crud_production_task_resolve_sub_table_order_num", "label": "_resolve_sub_table_order_num()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L401"}, {"id": "crud_production_task_step_sub_tables_to_dict", "label": "_step_sub_tables_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L410"}, {"id": "crud_production_task_clone_step_reagents", "label": "_clone_step_reagents()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L436"}, {"id": "crud_production_task_clone_step_consumables", "label": "_clone_step_consumables()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L459"}, {"id": "crud_production_task_clone_step_outputs", "label": "_clone_step_outputs()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L482"}, {Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_work_order_py", "label": "production_work_order.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L1"}, {"id": "crud_production_work_order_normalize_date_bound", "label": "_normalize_date_bound()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L48"}, {"id": "crud_production_work_order_fmt_dt", "label": "_fmt_dt()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L55"}, {"id": "crud_production_work_order_soft_delete_sub", "label": "_soft_delete_sub()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L59"}, {"id": "crud_production_work_order_generate_work_order_no", "label": "_generate_work_order_no()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L71"}, {"id": "crud_production_work_order_wo_to_dict", "label": "_wo_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L90"}, {"id": "crud_production_work_order_enrich_wo_items", "label": "_enrich_wo_items()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L123"}, {"id": "crud_production_work_order_enrich_outbound_items", "label": "_enrich_outbound_items()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L136"}, {"id": "crud_production_work_order_outbound_work_order_ids_by_keyword", "label": "_outbound_work_order_ids_by_keyword()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L241"}, {"id": "crud_production_work_order_reception_source_label", "label": "_reception_source_label()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L293"}, {"id": "crud_production_work_order_accept_conclusion_label", "label": "_accept_conclusion_label()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L298"}, {"id": "crud_production_work_order_attach_reception_detail", "label": "_attach_reception_detail()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L303"}, {"id": "crud_production_work_order_attach_outbound_detail", "label": "_attach_outbound_detail()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L333"}, {"id": "crud_production_work_order_wo_to_response_dict", "label": "_wo_to_response_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L386"}, {"id": "crud_production_work_order_create_production_work_order_from_reception", "label": "create_production_work_order_from_reception()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L399"}, {"id": "crud_production_work_order_list_production_work_orders", "label": "list_production_work_orders()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L510"}, {"id": "crud_production_work_order_sync_production_work_order_status_from_tasks", "label": "sync_production_work_order_status_from_tasks()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L621"}, {"id": "crud_production_work_order_get_production_work_order", "label": "get_production_work_order()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L664"}, {"id": "crud_production_work_order_update_production_work_order", "label": "update_production_work_order()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L678"}, {"id": "crud_production_work_order_complete_production_work_order", "label": "complete_production_work_order()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_work_order.py", "source_location": "L699"}, {"id": "crud_production_work_order_production_task_info", "label": "_production_task_info()", "file_type": "code", "Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_usage_py", "label": "production_material_usage.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L1"}, {"id": "crud_production_material_usage_parse_receiver_purpose_from_remark", "label": "_parse_receiver_purpose_from_remark()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L19"}, {"id": "crud_production_material_usage_resolve_receiver_purpose", "label": "_resolve_receiver_purpose()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L31"}, {"id": "crud_production_material_usage_display_remark", "label": "_display_remark()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L41"}, {"id": "crud_production_material_usage_user_nick_name_map", "label": "_user_nick_name_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L57"}, {"id": "crud_production_material_usage_receiver_display_map", "label": "_receiver_display_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L65"}, {"id": "crud_production_material_usage_usage_unit_label", "label": "_usage_unit_label()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L77"}, {"id": "crud_production_material_usage_stock_in_date_for_row", "label": "_stock_in_date_for_row()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L86"}, {"id": "crud_production_material_usage_unit_price_for_row", "label": "_unit_price_for_row()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L92"}, {"id": "crud_production_material_usage_amount_for_row", "label": "_amount_for_row()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L100"}, {"id": "crud_production_material_usage_row_to_dict", "label": "_row_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L116"}, {"id": "crud_production_material_usage_batch_map", "label": "_batch_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L181"}, {"id": "crud_production_material_usage_mine_usage_filter", "label": "_mine_usage_filter()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L193"}, {"id": "crud_production_material_usage_list_usages_query", "label": "_list_usages_query()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L222"}, {"id": "crud_production_material_usage_paginate_usages", "label": "_paginate_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L287"}, {"id": "crud_production_material_usage_list_usages", "label": "list_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L318"}, {"id": "crud_production_material_usage_list_my_usages", "label": "list_my_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L348"}, {"id": "crud_production_material_usage_list_usages_by_step", "label": "list_usages_by_step()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L381"}, {"id": "crud_production_material_usage_list_linked_step_usages", "label": "list_linked_step_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L438"}, {"id": "crud_production_material_usage_revert_step_material_usages", "label": "revert_step_material_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L488"}, {"id": "crud_production_material_usage_list_requisition_options", "label": "list_requisition_options()", "file_type": "code", "source_file": "/Users/wuzilong/work/00codLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_models_models_py", "label": "models.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L1"}, {"id": "models_models_userrole", "label": "UserRole", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L10"}, {"id": "str", "label": "str", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "models_models_sysuser", "label": "SysUser", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L22"}, {"id": "base", "label": "Base", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "models_models_sysrole", "label": "SysRole", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L48"}, {"id": "models_models_sysuserrole", "label": "SysUserRole", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L68"}, {"id": "models_models_sysrolemenu", "label": "SysRoleMenu", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L87"}, {"id": "models_models_sysroledatascopedetail", "label": "SysRoleDataScopeDetail", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L106"}, {"id": "models_models_sysmenu", "label": "SysMenu", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L126"}, {"id": "models_models_sysdept", "label": "SysDept", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L152"}, {"id": "models_models_systenant", "label": "SysTenant", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L175"}, {"id": "models_models_syssite", "label": "SysSite", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L195"}, {"id": "models_models_syspost", "label": "SysPost", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L220"}, {"id": "models_models_sysuserpost", "label": "SysUserPost", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L240"}, {"id": "models_models_bizitemunit", "label": "BizItemUnit", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L259"}, {"id": "models_models_bizexpresscompany", "label": "BizExpressCompany", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L278"}, {"id": "models_models_bizcustomer", "label": "BizCustomer", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L297"}, {"id": "models_models_bizcellsampletype", "label": "BizCellSampleType", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L320"}, {"id": "models_models_bizcollectionregion", "label": "BizCollectionRegion", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L341"}, {"id": "models_models_bizcollectionhospital", "label": "BizCollectionHospital", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L359"}, {"id": "models_models_bizcollectionprotocolno", "label": "BizCollectionProtocolNo", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L378"}, {"id": "models_models_bizbiznosequence", "label": "BizBizNoSequence", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L400"}, {"id": "models_models_bizsamplecode", "label": "BizSampleCode", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L420"}, {"id": "models_models_sysdicttype", "label": "SysDictType", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L448"}, {"id": "models_models_sysethnic", "label": "SysEthnic", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L467"}, {"id": "models_models_sysdictdata", "label": "SysDictData", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location"Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "label": "menu.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L1"}, {"id": "api_menu_get_menu_list", "label": "get_menu_list()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L841"}, {"id": "api_menu_rationale_1", "label": "\u8fd0\u8425\u7aef\u83dc\u5355\u63a5\u53e3\uff08\u4e0e web-admin \u524d\u7aef\u9759\u6001\u8def\u7531 sqxp.ts \u5bf9\u9f50\uff0c5 \u4e2a\u4e00\u7ea7\u83dc\u5355\u5206\u7ec4\uff09", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L1"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "target": "fastapi", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L2", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "target": "app_core_menu_guard", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L4", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "target": "app_core_response", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L5", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "target": "api_menu_get_menu_list", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L841", "weight": 1.0}, {"source": "api_menu_rationale_1", "target": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "relation": "rationale_for", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L1", "weight": 1.0}], "raw_calls": [{"caller_nid": "api_menu_get_menu_list", "callee": "success_response", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L843"}]}
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_task_py", "label": "production_task.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L1"}, {"id": "crud_production_task_production_conclusion_label", "label": "_production_conclusion_label()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L70"}, {"id": "crud_production_task_fmt_dt", "label": "_fmt_dt()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L77"}, {"id": "crud_production_task_normalize_date_bound", "label": "_normalize_date_bound()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L81"}, {"id": "crud_production_task_enrich_outbound_task_items", "label": "_enrich_outbound_task_items()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L88"}, {"id": "crud_production_task_generate_task_no", "label": "_generate_task_no()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L177"}, {"id": "crud_production_task_task_to_dict", "label": "_task_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L191"}, {"id": "crud_production_task_step_to_dict", "label": "_step_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L216"}, {"id": "crud_production_task_step_reagent_to_dict", "label": "_step_reagent_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L236"}, {"id": "crud_production_task_step_consumable_to_dict", "label": "_step_consumable_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L252"}, {"id": "crud_production_task_step_output_to_dict", "label": "_step_output_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L268"}, {"id": "crud_production_task_step_data_collection_to_dict", "label": "_step_data_collection_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L280"}, {"id": "crud_production_task_task_input_to_dict", "label": "_task_input_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L292"}, {"id": "crud_production_task_task_output_to_dict", "label": "_task_output_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L314"}, {"id": "crud_production_task_soft_delete_sub", "label": "_soft_delete_sub()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L339"}, {"id": "crud_production_task_resolve_sub_table_order_num", "label": "_resolve_sub_table_order_num()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L352"}, {"id": "crud_production_task_step_sub_tables_to_dict", "label": "_step_sub_tables_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L361"}, {"id": "crud_production_task_clone_step_reagents", "label": "_clone_step_reagents()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L383"}, {"id": "crud_production_task_clone_step_consumables", "label": "_clone_step_consumables()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L406"}, {"id": "crud_production_task_clone_step_outputs", "label": "_clone_step_outputs()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L429"}, {"id": "crud_production_task_clone_step_data_collections", "label": "_clone_step_data_collections()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L451"}, {"id": "crud_production_task_clone_route_to_task", "label": "_clone_route_to_task()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_task.py", "source_location": "L472"}, {"id": "crud_production_task_create_production_task",Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "label": "production_material.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L1"}, {"id": "models_production_material_bizproductionmaterial", "label": "BizProductionMaterial", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L8"}, {"id": "base", "label": "Base", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "models_production_material_bizproductionmaterialstockbatch", "label": "BizProductionMaterialStockBatch", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L31"}, {"id": "models_production_material_bizproductionmaterialusage", "label": "BizProductionMaterialUsage", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L62"}, {"id": "models_production_material_bizproductionmaterialformula", "label": "BizProductionMaterialFormula", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L105"}, {"id": "models_production_material_bizproductionmaterialprep", "label": "BizProductionMaterialPrep", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L127"}, {"id": "models_production_material_bizproductionmaterialprepline", "label": "BizProductionMaterialPrepLine", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L154"}, {"id": "models_production_material_bizproductionmaterialstockcheck", "label": "BizProductionMaterialStockCheck", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L177"}, {"id": "models_production_material_bizproductionmaterialstockcheckbatchline", "label": "BizProductionMaterialStockCheckBatchLine", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L196"}, {"id": "models_production_material_bizproductionmaterialstockcheckunusedline", "label": "BizProductionMaterialStockCheckUnusedLine", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L228"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "datetime", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L1", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "sqlalchemy", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L3", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "app_core_database", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L5", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "models_production_material_bizproductionmaterial", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L8", "weight": 1.0}, {"source": "models_production_material_bizproductionmaterial", "target": "base", "relation": "inherits", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L8", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "models_production_material_bizproductionmaterialstockbatch", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L31", "weight": 1.0}, {"source": "models_production_material_bizproductionmaterialstockbatch", "target": "base", "relation": "inherits", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L31", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "models_production_material_bizproductionmaterialusage", "relation": "contains", "confidence": "EXTRACTED", "sourceLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "label": "menu.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L1"}, {"id": "api_menu_get_menu_list", "label": "get_menu_list()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L876"}, {"id": "api_menu_rationale_1", "label": "\u8fd0\u8425\u7aef\u83dc\u5355\u63a5\u53e3\uff08\u4e0e web-admin \u524d\u7aef\u9759\u6001\u8def\u7531 sqxp.ts \u5bf9\u9f50\uff0c5 \u4e2a\u4e00\u7ea7\u83dc\u5355\u5206\u7ec4\uff09", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L1"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "target": "fastapi", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L2", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "target": "app_core_menu_guard", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L4", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "target": "app_core_response", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L5", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "target": "api_menu_get_menu_list", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L876", "weight": 1.0}, {"source": "api_menu_rationale_1", "target": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "relation": "rationale_for", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L1", "weight": 1.0}], "raw_calls": [{"caller_nid": "api_menu_get_menu_list", "callee": "success_response", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L878"}]}
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_api_init_py", "label": "__init__.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/__init__.py", "source_location": "L1"}, {"id": "api_init_rationale_1", "label": "API \u8def\u7531\u5305\uff08\u9aa8\u67b6\uff1a\u516c\u5171\u9274\u6743 + \u9759\u6001\u83dc\u5355 + \u8fd0\u8425\u7aef\u5360\u4f4d\uff09", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/__init__.py", "source_location": "L1"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_api_init_py", "target": "app_api_public", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/__init__.py", "source_location": "L2", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_init_py", "target": "app_api_menu", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/__init__.py", "source_location": "L3", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_init_py", "target": "app_api_admin", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/__init__.py", "source_location": "L4", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_init_py", "target": "app_api_workflow", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/__init__.py", "source_location": "L5", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_init_py", "target": "app_api_basic_info", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/__init__.py", "source_location": "L6", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_init_py", "target": "app_api_collection_protocol", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/__init__.py", "source_location": "L7", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_init_py", "target": "app_api_leave", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/__init__.py", "source_location": "L8", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_init_py", "target": "app_api_operations", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/__init__.py", "source_location": "L9", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_init_py", "target": "app_api_ethnic", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/__init__.py", "source_location": "L10", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_init_py", "target": "app_api_sample_reception", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/__init__.py", "source_location": "L11", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_init_py", "target": "app_api_qc", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/__init__.py", "source_location": "L12", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_init_py", "target": "app_api_research_donation", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/__init__.py", "source_location": "L13", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_init_py", "target": "app_api_production", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/__init__.py", "source_location": "L14", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_init_py", "target": "app_api_pilot_service", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/__init__.py", "source_location": "L15", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_init_py", "target": "app_api_insurance_company", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/__init__.py", "source_location": "L16", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_init_py", "target": "app_api_material", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/__init__.py", "source_location": "L17", "weight": 1.0}, {"source": "usLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_usage_py", "label": "production_material_usage.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L1"}, {"id": "crud_production_material_usage_parse_receiver_purpose_from_remark", "label": "_parse_receiver_purpose_from_remark()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L19"}, {"id": "crud_production_material_usage_resolve_receiver_purpose", "label": "_resolve_receiver_purpose()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L31"}, {"id": "crud_production_material_usage_display_remark", "label": "_display_remark()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L41"}, {"id": "crud_production_material_usage_user_nick_name_map", "label": "_user_nick_name_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L57"}, {"id": "crud_production_material_usage_receiver_display_map", "label": "_receiver_display_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L65"}, {"id": "crud_production_material_usage_usage_unit_label", "label": "_usage_unit_label()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L77"}, {"id": "crud_production_material_usage_stock_in_date_for_row", "label": "_stock_in_date_for_row()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L86"}, {"id": "crud_production_material_usage_unit_price_for_row", "label": "_unit_price_for_row()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L92"}, {"id": "crud_production_material_usage_amount_for_row", "label": "_amount_for_row()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L100"}, {"id": "crud_production_material_usage_row_to_dict", "label": "_row_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L116"}, {"id": "crud_production_material_usage_batch_map", "label": "_batch_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L181"}, {"id": "crud_production_material_usage_mine_usage_filter", "label": "_mine_usage_filter()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L193"}, {"id": "crud_production_material_usage_list_usages_query", "label": "_list_usages_query()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L222"}, {"id": "crud_production_material_usage_paginate_usages", "label": "_paginate_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L289"}, {"id": "crud_production_material_usage_list_usages", "label": "list_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L320"}, {"id": "crud_production_material_usage_list_my_usages", "label": "list_my_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L350"}, {"id": "crud_production_material_usage_list_usages_by_step", "label": "list_usages_by_step()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L383"}, {"id": "crud_production_material_usage_list_linked_step_usages", "label": "list_linked_step_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L440"}, {"id": "crud_production_material_usage_revert_step_material_usages", "label": "revert_step_material_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L490"}, {"id": "crud_production_material_usage_list_requisition_options", "label": "list_requisition_options()", "file_type": "code", "source_file": "/Users/wuzilong/work/00codLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_schemas_production_work_order_py", "label": "production_work_order.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_work_order.py", "source_location": "L1"}, {"id": "schemas_production_work_order_productionworkorderbase", "label": "ProductionWorkOrderBase", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_work_order.py", "source_location": "L6"}, {"id": "basemodel", "label": "BaseModel", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "schemas_production_work_order_productionworkorderlistquery", "label": "ProductionWorkOrderListQuery", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_work_order.py", "source_location": "L10"}, {"id": "schemas_production_work_order_productionworkordercomplete", "label": "ProductionWorkOrderComplete", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_work_order.py", "source_location": "L25"}, {"id": "schemas_production_work_order_productionworkorderupdate", "label": "ProductionWorkOrderUpdate", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_work_order.py", "source_location": "L29"}, {"id": "schemas_production_work_order_productionworkordercreate", "label": "ProductionWorkOrderCreate", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_work_order.py", "source_location": "L35"}, {"id": "schemas_production_work_order_productionworkorderconfigurebody", "label": "ProductionWorkOrderConfigureBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_work_order.py", "source_location": "L45"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_schemas_production_work_order_py", "target": "pydantic", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_work_order.py", "source_location": "L1", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_schemas_production_work_order_py", "target": "typing", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_work_order.py", "source_location": "L2", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_schemas_production_work_order_py", "target": "datetime", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_work_order.py", "source_location": "L3", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_schemas_production_work_order_py", "target": "schemas_production_work_order_productionworkorderbase", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_work_order.py", "source_location": "L6", "weight": 1.0}, {"source": "schemas_production_work_order_productionworkorderbase", "target": "basemodel", "relation": "inherits", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_work_order.py", "source_location": "L6", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_schemas_production_work_order_py", "target": "schemas_production_work_order_productionworkorderlistquery", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_work_order.py", "source_location": "L10", "weight": 1.0}, {"source": "schemas_production_work_order_productionworkorderlistquery", "target": "basemodel", "relation": "inherits", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_work_order.py", "source_location": "L10", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_schemas_production_work_order_py", "target": "schemas_production_work_order_productionworkordercomplete", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_work_order.py", "source_location": "L25", "weight": 1.0}, {"source": "schemas_production_work_order_productionworkordercomplete", "target": "basemodel", "relation": "inherits", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/production_work_order.py", "source_location": "L25", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_schemas_production_work_order_py", "target": "schemas_production_work_order_productionworkorderupdate", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/schemas/productLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_api_production_material_py", "label": "production_material.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L1"}, {"id": "api_production_material_productionmaterialbody", "label": "ProductionMaterialBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L28"}, {"id": "basemodel", "label": "BaseModel", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "api_production_material_productionmaterialupdatebody", "label": "ProductionMaterialUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L40"}, {"id": "api_production_material_stockinbody", "label": "StockInBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L52"}, {"id": "api_production_material_batchstockinitem", "label": "BatchStockInItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L68"}, {"id": "api_production_material_batchstockinbody", "label": "BatchStockInBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L84"}, {"id": "api_production_material_batchstockoutitem", "label": "BatchStockOutItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L91"}, {"id": "api_production_material_batchstockoutbody", "label": "BatchStockOutBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L98"}, {"id": "api_production_material_productionmaterialbatchupdatebody", "label": "ProductionMaterialBatchUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L107"}, {"id": "api_production_material_list_production_material_batches", "label": "list_production_material_batches()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L128"}, {"id": "api_production_material_production_material_batch_options", "label": "production_material_batch_options()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L159"}, {"id": "api_production_material_update_production_material_batch", "label": "update_production_material_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L184"}, {"id": "api_production_material_delete_production_material_batch", "label": "delete_production_material_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L213"}, {"id": "api_production_material_list_production_materials", "label": "list_production_materials()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L230"}, {"id": "api_production_material_production_material_options", "label": "production_material_options()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L259"}, {"id": "api_production_material_create_production_material", "label": "create_production_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L274"}, {"id": "api_production_material_update_production_material", "label": "update_production_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L305"}, {"id": "api_production_material_delete_production_material", "label": "delete_production_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L334"}, {"id": "api_production_material_batch_stock_in_production_material", "label": "batch_stock_in_production_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L351"}, {"id": "api_production_material_batch_stock_out_production_material", "label": "batch_stock_out_production_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L406"}, {"id": "api_production_material_stock_in_production_material", "label": "stock_in_proLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "label": "menu.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L1"}, {"id": "api_menu_get_menu_list", "label": "get_menu_list()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L841"}, {"id": "api_menu_rationale_1", "label": "\u8fd0\u8425\u7aef\u83dc\u5355\u63a5\u53e3\uff08\u4e0e web-admin \u524d\u7aef\u9759\u6001\u8def\u7531 sqxp.ts \u5bf9\u9f50\uff0c5 \u4e2a\u4e00\u7ea7\u83dc\u5355\u5206\u7ec4\uff09", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L1"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "target": "fastapi", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L2", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "target": "app_core_menu_guard", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L4", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "target": "app_core_response", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L5", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "target": "api_menu_get_menu_list", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L841", "weight": 1.0}, {"source": "api_menu_rationale_1", "target": "users_wuzilong_work_00code_zkxw_backend_app_api_menu_py", "relation": "rationale_for", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L1", "weight": 1.0}], "raw_calls": [{"caller_nid": "api_menu_get_menu_list", "callee": "success_response", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/menu.py", "source_location": "L843"}]}
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_api_operations_py", "label": "operations.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L1"}, {"id": "api_operations_get_tenant_no", "label": "_get_tenant_no()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L24"}, {"id": "api_operations_cleanroomcreatebody", "label": "CleanRoomCreateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L39"}, {"id": "basemodel", "label": "BaseModel", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "api_operations_cleanroomupdatebody", "label": "CleanRoomUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L51"}, {"id": "api_operations_list_clean_rooms", "label": "list_clean_rooms()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L64"}, {"id": "api_operations_create_clean_room", "label": "create_clean_room()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L89"}, {"id": "api_operations_update_clean_room", "label": "update_clean_room()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L114"}, {"id": "api_operations_delete_clean_room", "label": "delete_clean_room()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L142"}, {"id": "api_operations_accesslogcreatebody", "label": "AccessLogCreateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L160"}, {"id": "api_operations_accesslogupdatebody", "label": "AccessLogUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L174"}, {"id": "api_operations_parse_optional_dt", "label": "_parse_optional_dt()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L187"}, {"id": "api_operations_list_access_logs", "label": "list_access_logs()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L194"}, {"id": "api_operations_create_access_log", "label": "create_access_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L223"}, {"id": "api_operations_update_access_log", "label": "update_access_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L250"}, {"id": "api_operations_delete_access_log", "label": "delete_access_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L279"}, {"id": "api_operations_uvdisinfectlogcreatebody", "label": "UvDisinfectLogCreateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L297"}, {"id": "api_operations_uvdisinfectlogupdatebody", "label": "UvDisinfectLogUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L309"}, {"id": "api_operations_list_uv_disinfect_logs", "label": "list_uv_disinfect_logs()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L321"}, {"id": "api_operations_create_uv_disinfect_log", "label": "create_uv_disinfect_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L352"}, {"id": "api_operations_update_uv_disinfect_log", "label": "update_uv_disinfect_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L377"}, {"id": "api_operations_delete_uv_disinfect_log", "label": "delete_uv_disinfect_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L405"}, {"id": "api_operations_storagefacilitycreatebody", "label": "StorageFacilityCreateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L423"}, {"id": "api_operations_storagefacilityupdatebody", "label": "StorageFacilityUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L435"}, {"id": "api_operations_list_storage_facilities", "labelLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_models_models_py", "label": "models.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L1"}, {"id": "models_models_userrole", "label": "UserRole", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L10"}, {"id": "str", "label": "str", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "models_models_sysuser", "label": "SysUser", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L22"}, {"id": "base", "label": "Base", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "models_models_sysrole", "label": "SysRole", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L48"}, {"id": "models_models_sysuserrole", "label": "SysUserRole", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L68"}, {"id": "models_models_sysrolemenu", "label": "SysRoleMenu", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L87"}, {"id": "models_models_sysroledatascopedetail", "label": "SysRoleDataScopeDetail", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L106"}, {"id": "models_models_sysmenu", "label": "SysMenu", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L126"}, {"id": "models_models_sysdept", "label": "SysDept", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L152"}, {"id": "models_models_systenant", "label": "SysTenant", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L175"}, {"id": "models_models_syssite", "label": "SysSite", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L195"}, {"id": "models_models_syspost", "label": "SysPost", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L220"}, {"id": "models_models_sysuserpost", "label": "SysUserPost", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L240"}, {"id": "models_models_bizitemunit", "label": "BizItemUnit", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L259"}, {"id": "models_models_bizexpresscompany", "label": "BizExpressCompany", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L278"}, {"id": "models_models_bizcustomer", "label": "BizCustomer", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L297"}, {"id": "models_models_bizcellsampletype", "label": "BizCellSampleType", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L320"}, {"id": "models_models_bizcollectionregion", "label": "BizCollectionRegion", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L341"}, {"id": "models_models_bizcollectionhospital", "label": "BizCollectionHospital", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L359"}, {"id": "models_models_bizcollectionprotocolno", "label": "BizCollectionProtocolNo", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L378"}, {"id": "models_models_bizbiznosequence", "label": "BizBizNoSequence", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L400"}, {"id": "models_models_bizsamplecode", "label": "BizSampleCode", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L420"}, {"id": "models_models_sysdicttype", "label": "SysDictType", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L448"}, {"id": "models_models_sysethnic", "label": "SysEthnic", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L467"}, {"id": "models_models_sysdictdata", "label": "SysDictData", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location"Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_stock_batch_py", "label": "production_material_stock_batch.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L1"}, {"id": "crud_production_material_stock_batch_fmt_date", "label": "_fmt_date()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L16"}, {"id": "crud_production_material_stock_batch_parse_date", "label": "_parse_date()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L20"}, {"id": "crud_production_material_stock_batch_parse_expire_date", "label": "_parse_expire_date()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L34"}, {"id": "crud_production_material_stock_batch_require_str", "label": "_require_str()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L38"}, {"id": "crud_production_material_stock_batch_require_decimal", "label": "_require_decimal()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L45"}, {"id": "crud_production_material_stock_batch_stock_in_no_exists", "label": "stock_in_no_exists()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L57"}, {"id": "crud_production_material_stock_batch_batch_row_to_dict", "label": "_batch_row_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L73"}, {"id": "crud_production_material_stock_batch_usage_batch_snapshots", "label": "_usage_batch_snapshots()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L106"}, {"id": "crud_production_material_stock_batch_get_material_for_update", "label": "_get_material_for_update()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L127"}, {"id": "crud_production_material_stock_batch_list_batches", "label": "list_batches()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L145"}, {"id": "crud_production_material_stock_batch_batch_options", "label": "batch_options()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L213"}, {"id": "crud_production_material_stock_batch_create_batch_and_usage", "label": "_create_batch_and_usage()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L291"}, {"id": "crud_production_material_stock_batch_stock_in_one", "label": "stock_in_one()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L389"}, {"id": "crud_production_material_stock_batch_batch_stock_in", "label": "batch_stock_in()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L430"}, {"id": "crud_production_material_stock_batch_stock_out_batch", "label": "_stock_out_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L486"}, {"id": "crud_production_material_stock_batch_batch_stock_out", "label": "batch_stock_out()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L568"}, {"id": "crud_production_material_stock_batch_get_batch", "label": "get_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L618"}, {"id": "crud_production_material_stock_batch_update_batch", "label": "update_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L630"}, {"id": "crud_production_material_stock_batch_delete_batch", "label": "delete_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L741"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_baLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_py", "label": "production_material.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L1"}, {"id": "crud_production_material_dec", "label": "_dec()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L15"}, {"id": "crud_production_material_fmt_dt", "label": "_fmt_dt()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L21"}, {"id": "crud_production_material_norm_status", "label": "_norm_status()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L25"}, {"id": "crud_production_material_is_enabled_status", "label": "_is_enabled_status()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L42"}, {"id": "crud_production_material_norm_material_type", "label": "_norm_material_type()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L49"}, {"id": "crud_production_material_filter_material_type", "label": "_filter_material_type()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L56"}, {"id": "crud_production_material_row_to_dict", "label": "_row_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L61"}, {"id": "crud_production_material_code_exists", "label": "code_exists()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L79"}, {"id": "crud_production_material_total_pages", "label": "total_pages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L101"}, {"id": "crud_production_material_list_materials", "label": "list_materials()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L115"}, {"id": "crud_production_material_get_material", "label": "get_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L163"}, {"id": "crud_production_material_create_material", "label": "create_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L174"}, {"id": "crud_production_material_update_material", "label": "update_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L227"}, {"id": "crud_production_material_soft_delete_material", "label": "soft_delete_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L283"}, {"id": "crud_production_material_build_manual_out_remark", "label": "_build_manual_out_remark()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L295"}, {"id": "crud_production_material_stock_in", "label": "stock_in()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L315"}, {"id": "crud_production_material_batch_stock_in", "label": "batch_stock_in()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L372"}, {"id": "crud_production_material_stock_out", "label": "stock_out()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L448"}, {"id": "crud_production_material_batch_stock_out", "label": "batch_stock_out()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L519"}, {"id": "crud_production_material_options_list", "label": "options_list()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L608"}, {"id": "crud_production_material_rationale_26", "label": "\u7edf\u4e00\u72b6\u6001\u4e3a '1'\uff08\u542f\u7528\uff09\u6216 '0'\uff08\u505c\u7528\uff09\uff0c\u907f\u514d 0 / '0' / or \u5224\u65ad\u6b67\u4e49\u3002", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L26"}, {"id": "crud_production_Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_py", "label": "production_material.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L1"}, {"id": "crud_production_material_dec", "label": "_dec()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L15"}, {"id": "crud_production_material_fmt_dt", "label": "_fmt_dt()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L21"}, {"id": "crud_production_material_norm_status", "label": "_norm_status()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L25"}, {"id": "crud_production_material_is_enabled_status", "label": "_is_enabled_status()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L42"}, {"id": "crud_production_material_norm_material_type", "label": "_norm_material_type()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L46"}, {"id": "crud_production_material_row_to_dict", "label": "_row_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L53"}, {"id": "crud_production_material_code_exists", "label": "code_exists()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L71"}, {"id": "crud_production_material_total_pages", "label": "total_pages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L93"}, {"id": "crud_production_material_list_materials", "label": "list_materials()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L107"}, {"id": "crud_production_material_get_material", "label": "get_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L155"}, {"id": "crud_production_material_create_material", "label": "create_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L166"}, {"id": "crud_production_material_update_material", "label": "update_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L219"}, {"id": "crud_production_material_soft_delete_material", "label": "soft_delete_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L275"}, {"id": "crud_production_material_build_manual_out_remark", "label": "_build_manual_out_remark()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L287"}, {"id": "crud_production_material_stock_in", "label": "stock_in()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L307"}, {"id": "crud_production_material_batch_stock_in", "label": "batch_stock_in()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L364"}, {"id": "crud_production_material_stock_out", "label": "stock_out()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L440"}, {"id": "crud_production_material_batch_stock_out", "label": "batch_stock_out()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L511"}, {"id": "crud_production_material_options_list", "label": "options_list()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L600"}, {"id": "crud_production_material_rationale_26", "label": "\u7edf\u4e00\u72b6\u6001\u4e3a '1'\uff08\u542f\u7528\uff09\u6216 '0'\uff08\u505c\u7528\uff09\uff0c\u907f\u514d 0 / '0' / or \u5224\u65ad\u6b67\u4e49\u3002", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material.py", "source_location": "L26"}, {"id": "crud_production_material_rationale_373", "label": "\u6279\u91cf\u5165\u5e93\uff0c\u540c\u4e00\u4e8b\u52a1\uff1b\u4efb\u4e00\u6761\u5931\u8d25\u5219\u5168\u90e8\u56de\u6eda\u3002", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00codLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_models_qc_material_py", "label": "qc_material.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/qc_material.py", "source_location": "L1"}, {"id": "models_qc_material_bizqcmaterial", "label": "BizQcMaterial", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/qc_material.py", "source_location": "L8"}, {"id": "base", "label": "Base", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "models_qc_material_bizqcmaterialstockbatch", "label": "BizQcMaterialStockBatch", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/qc_material.py", "source_location": "L30"}, {"id": "models_qc_material_bizqcmaterialusage", "label": "BizQcMaterialUsage", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/qc_material.py", "source_location": "L60"}, {"id": "models_qc_material_bizqcmaterialstockcheck", "label": "BizQcMaterialStockCheck", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/qc_material.py", "source_location": "L99"}, {"id": "models_qc_material_bizqcmaterialstockcheckbatchline", "label": "BizQcMaterialStockCheckBatchLine", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/qc_material.py", "source_location": "L118"}, {"id": "models_qc_material_bizqcmaterialstockcheckunusedline", "label": "BizQcMaterialStockCheckUnusedLine", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/qc_material.py", "source_location": "L149"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_models_qc_material_py", "target": "datetime", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/qc_material.py", "source_location": "L1", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_qc_material_py", "target": "sqlalchemy", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/qc_material.py", "source_location": "L3", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_qc_material_py", "target": "app_core_database", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/qc_material.py", "source_location": "L5", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_qc_material_py", "target": "models_qc_material_bizqcmaterial", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/qc_material.py", "source_location": "L8", "weight": 1.0}, {"source": "models_qc_material_bizqcmaterial", "target": "base", "relation": "inherits", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/qc_material.py", "source_location": "L8", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_qc_material_py", "target": "models_qc_material_bizqcmaterialstockbatch", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/qc_material.py", "source_location": "L30", "weight": 1.0}, {"source": "models_qc_material_bizqcmaterialstockbatch", "target": "base", "relation": "inherits", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/qc_material.py", "source_location": "L30", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_qc_material_py", "target": "models_qc_material_bizqcmaterialusage", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/qc_material.py", "source_location": "L60", "weight": 1.0}, {"source": "models_qc_material_bizqcmaterialusage", "target": "base", "relation": "inherits", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/qc_material.py", "source_location": "L60", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_qc_material_py", "target": "models_qc_material_bizqcmaterialstockcheck", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/qc_material.py", "source_location": "L99", "weight": 1.0}, {"source": "models_qc_material_bizqcmaterialstockcheck", "target": "base", "relation": "inherits", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/qc_material.py", "source_location": "L99", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_qc_material_py", "target": "models_qc_material_bizqcmaterialstockcheckbatchline", "relation": "contains", "confidence": "EXTRACTED", "source_file"Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "label": "production_material.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L1"}, {"id": "models_production_material_bizproductionmaterial", "label": "BizProductionMaterial", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L8"}, {"id": "base", "label": "Base", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "models_production_material_bizproductionmaterialstockbatch", "label": "BizProductionMaterialStockBatch", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L31"}, {"id": "models_production_material_bizproductionmaterialusage", "label": "BizProductionMaterialUsage", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L63"}, {"id": "models_production_material_bizproductionmaterialformula", "label": "BizProductionMaterialFormula", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L107"}, {"id": "models_production_material_bizproductionmaterialprep", "label": "BizProductionMaterialPrep", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L129"}, {"id": "models_production_material_bizproductionmaterialprepline", "label": "BizProductionMaterialPrepLine", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L157"}, {"id": "models_production_material_bizproductionmaterialstockcheck", "label": "BizProductionMaterialStockCheck", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L180"}, {"id": "models_production_material_bizproductionmaterialstockcheckbatchline", "label": "BizProductionMaterialStockCheckBatchLine", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L199"}, {"id": "models_production_material_bizproductionmaterialstockcheckunusedline", "label": "BizProductionMaterialStockCheckUnusedLine", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L232"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "datetime", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L1", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "sqlalchemy", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L3", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "app_core_database", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L5", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "models_production_material_bizproductionmaterial", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L8", "weight": 1.0}, {"source": "models_production_material_bizproductionmaterial", "target": "base", "relation": "inherits", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L8", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "models_production_material_bizproductionmaterialstockbatch", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L31", "weight": 1.0}, {"source": "models_production_material_bizproductionmaterialstockbatch", "target": "base", "relation": "inherits", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L31", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "models_production_material_bizproductionmaterialusage", "relation": "contains", "confidence": "EXTRACTED", "sourceLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_models_init_py", "label": "__init__.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/__init__.py", "source_location": "L1"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_models_init_py", "target": "app_models_base", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/__init__.py", "source_location": "L2", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_init_py", "target": "app_models_models", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/__init__.py", "source_location": "L3", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_init_py", "target": "app_models_production_material", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/__init__.py", "source_location": "L52", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_init_py", "target": "app_models_research_donation", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/__init__.py", "source_location": "L60", "weight": 1.0}], "raw_calls": []}
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_py", "label": "material.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L1"}, {"id": "crud_material_dec", "label": "_dec()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L15"}, {"id": "crud_material_fmt_dt", "label": "_fmt_dt()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L21"}, {"id": "crud_material_norm_status", "label": "_norm_status()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L25"}, {"id": "crud_material_is_enabled_status", "label": "_is_enabled_status()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L41"}, {"id": "crud_material_row_to_dict", "label": "_row_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L45"}, {"id": "crud_material_code_exists", "label": "_code_exists()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L64"}, {"id": "crud_material_list_materials", "label": "list_materials()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L80"}, {"id": "crud_material_get_material", "label": "get_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L129"}, {"id": "crud_material_create_material", "label": "create_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L146"}, {"id": "crud_material_update_material", "label": "update_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L192"}, {"id": "crud_material_soft_delete_material", "label": "soft_delete_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L252"}, {"id": "crud_material_get_material_entity", "label": "get_material_entity()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L278"}, {"id": "crud_material_update_material_fields", "label": "update_material_fields()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L292"}, {"id": "crud_material_options_list", "label": "options_list()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L342"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_py", "target": "datetime", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L4", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_py", "target": "decimal", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L5", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_py", "target": "typing", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L6", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_py", "target": "sqlalchemy", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L8", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_py", "target": "sqlalchemy_orm", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L9", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_py", "target": "app_core_utils", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L11", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_py", "target": "app_models_material", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/material.py", "source_location": "L12", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_material_py", "tarLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_stock_check_py", "label": "production_material_stock_check.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_check.py", "source_location": "L1"}, {"id": "crud_production_material_stock_check_user_nick_name_map", "label": "_user_nick_name_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_check.py", "source_location": "L22"}, {"id": "crud_production_material_stock_check_status_label", "label": "_status_label()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_check.py", "source_location": "L30"}, {"id": "crud_production_material_stock_check_batch_line_to_dict", "label": "_batch_line_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_check.py", "source_location": "L38"}, {"id": "crud_production_material_stock_check_unused_amount", "label": "_unused_amount()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_check.py", "source_location": "L64"}, {"id": "crud_production_material_stock_check_unused_line_to_dict", "label": "_unused_line_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_check.py", "source_location": "L70"}, {"id": "crud_production_material_stock_check_check_header_to_dict", "label": "_check_header_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_check.py", "source_location": "L95"}, {"id": "crud_production_material_stock_check_get_check", "label": "_get_check()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_check.py", "source_location": "L119"}, {"id": "crud_production_material_stock_check_line_counts", "label": "_line_counts()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_check.py", "source_location": "L131"}, {"id": "crud_production_material_stock_check_list_checks", "label": "list_checks()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_check.py", "source_location": "L166"}, {"id": "crud_production_material_stock_check_get_check_detail", "label": "get_check_detail()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_check.py", "source_location": "L226"}, {"id": "crud_production_material_stock_check_parse_check_time", "label": "_parse_check_time()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_check.py", "source_location": "L261"}, {"id": "crud_production_material_stock_check_create_check", "label": "create_check()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_check.py", "source_location": "L275"}, {"id": "crud_production_material_stock_check_parse_optional_date", "label": "_parse_optional_date()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_check.py", "source_location": "L354"}, {"id": "crud_production_material_stock_check_save_unused_lines", "label": "save_unused_lines()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_check.py", "source_location": "L360"}, {"id": "crud_production_material_stock_check_complete_check", "label": "complete_check()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_check.py", "source_location": "L440"}, {"id": "crud_production_material_stock_check_cancel_check", "label": "cancel_check()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_check.py", "source_location": "L461"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_stock_check_py", "target": "datetime", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_check.py", "source_location": "L4", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_stock_check_py", "target": "decimal", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_check.py", "source_location": "L5", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_stock_check_py", "target": "typing", "relation": "Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_models_init_py", "label": "__init__.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/__init__.py", "source_location": "L1"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_models_init_py", "target": "app_models_base", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/__init__.py", "source_location": "L2", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_init_py", "target": "app_models_models", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/__init__.py", "source_location": "L3", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_init_py", "target": "app_models_production_material", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/__init__.py", "source_location": "L53", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_init_py", "target": "app_models_research_donation", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/__init__.py", "source_location": "L61", "weight": 1.0}], "raw_calls": []}
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_equipment_py", "label": "equipment.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/equipment.py", "source_location": "L1"}, {"id": "crud_equipment_dec", "label": "_dec()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/equipment.py", "source_location": "L16"}, {"id": "crud_equipment_norm_status", "label": "_norm_status()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/equipment.py", "source_location": "L22"}, {"id": "crud_equipment_parse_date", "label": "_parse_date()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/equipment.py", "source_location": "L38"}, {"id": "crud_equipment_row_to_dict", "label": "_row_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/equipment.py", "source_location": "L56"}, {"id": "crud_equipment_list_equipments", "label": "list_equipments()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/equipment.py", "source_location": "L76"}, {"id": "crud_equipment_get_equipment", "label": "get_equipment()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/equipment.py", "source_location": "L122"}, {"id": "crud_equipment_equipment_code_exists", "label": "equipment_code_exists()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/equipment.py", "source_location": "L130"}, {"id": "crud_equipment_create_equipment", "label": "create_equipment()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/equipment.py", "source_location": "L145"}, {"id": "crud_equipment_update_equipment", "label": "update_equipment()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/equipment.py", "source_location": "L194"}, {"id": "crud_equipment_soft_delete_equipment", "label": "soft_delete_equipment()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/equipment.py", "source_location": "L251"}, {"id": "crud_equipment_total_pages", "label": "total_pages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/equipment.py", "source_location": "L261"}, {"id": "crud_equipment_rationale_1", "label": "\u8bbe\u5907 CRUD\uff08biz_equipment\uff09", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/equipment.py", "source_location": "L1"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_equipment_py", "target": "math", "relation": "imports", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/equipment.py", "source_location": "L4", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_equipment_py", "target": "datetime", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/equipment.py", "source_location": "L5", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_equipment_py", "target": "decimal", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/equipment.py", "source_location": "L6", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_equipment_py", "target": "typing", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/equipment.py", "source_location": "L7", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_equipment_py", "target": "sqlalchemy", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/equipment.py", "source_location": "L9", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_equipment_py", "target": "sqlalchemy_orm", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/equipment.py", "source_location": "L10", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_equipment_py", "target": "app_core_utils", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/equipment.py", "source_location": "L12", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_equipment_py", "target": "app_models_models", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/equipment.py", "source_location": "L13", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_equipment_py", "target": "crud_equipment_dec", "relation": "contains", "confLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_models_models_py", "label": "models.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L1"}, {"id": "models_models_userrole", "label": "UserRole", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L10"}, {"id": "str", "label": "str", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "models_models_sysuser", "label": "SysUser", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L22"}, {"id": "base", "label": "Base", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "models_models_sysrole", "label": "SysRole", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L48"}, {"id": "models_models_sysuserrole", "label": "SysUserRole", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L68"}, {"id": "models_models_sysrolemenu", "label": "SysRoleMenu", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L87"}, {"id": "models_models_sysroledatascopedetail", "label": "SysRoleDataScopeDetail", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L106"}, {"id": "models_models_sysmenu", "label": "SysMenu", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L126"}, {"id": "models_models_sysdept", "label": "SysDept", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L152"}, {"id": "models_models_systenant", "label": "SysTenant", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L175"}, {"id": "models_models_syssite", "label": "SysSite", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L195"}, {"id": "models_models_syspost", "label": "SysPost", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L220"}, {"id": "models_models_sysuserpost", "label": "SysUserPost", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L240"}, {"id": "models_models_bizitemunit", "label": "BizItemUnit", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L259"}, {"id": "models_models_bizexpresscompany", "label": "BizExpressCompany", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L278"}, {"id": "models_models_bizcustomer", "label": "BizCustomer", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L297"}, {"id": "models_models_bizcellsampletype", "label": "BizCellSampleType", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L320"}, {"id": "models_models_bizcollectionregion", "label": "BizCollectionRegion", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L341"}, {"id": "models_models_bizcollectionhospital", "label": "BizCollectionHospital", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L359"}, {"id": "models_models_bizcollectionprotocolno", "label": "BizCollectionProtocolNo", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L378"}, {"id": "models_models_bizbiznosequence", "label": "BizBizNoSequence", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L400"}, {"id": "models_models_bizsamplecode", "label": "BizSampleCode", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L420"}, {"id": "models_models_sysdicttype", "label": "SysDictType", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L448"}, {"id": "models_models_sysethnic", "label": "SysEthnic", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L467"}, {"id": "models_models_sysdictdata", "label": "SysDictData", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location"Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_usage_py", "label": "production_material_usage.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L1"}, {"id": "crud_production_material_usage_parse_receiver_purpose_from_remark", "label": "_parse_receiver_purpose_from_remark()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L19"}, {"id": "crud_production_material_usage_resolve_receiver_purpose", "label": "_resolve_receiver_purpose()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L31"}, {"id": "crud_production_material_usage_display_remark", "label": "_display_remark()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L41"}, {"id": "crud_production_material_usage_user_nick_name_map", "label": "_user_nick_name_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L57"}, {"id": "crud_production_material_usage_receiver_display_map", "label": "_receiver_display_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L65"}, {"id": "crud_production_material_usage_usage_unit_label", "label": "_usage_unit_label()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L77"}, {"id": "crud_production_material_usage_stock_in_date_for_row", "label": "_stock_in_date_for_row()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L86"}, {"id": "crud_production_material_usage_unit_price_for_row", "label": "_unit_price_for_row()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L92"}, {"id": "crud_production_material_usage_amount_for_row", "label": "_amount_for_row()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L100"}, {"id": "crud_production_material_usage_row_to_dict", "label": "_row_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L116"}, {"id": "crud_production_material_usage_batch_map", "label": "_batch_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L180"}, {"id": "crud_production_material_usage_mine_usage_filter", "label": "_mine_usage_filter()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L192"}, {"id": "crud_production_material_usage_list_usages_query", "label": "_list_usages_query()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L221"}, {"id": "crud_production_material_usage_paginate_usages", "label": "_paginate_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L286"}, {"id": "crud_production_material_usage_list_usages", "label": "list_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L317"}, {"id": "crud_production_material_usage_list_my_usages", "label": "list_my_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L347"}, {"id": "crud_production_material_usage_list_usages_by_step", "label": "list_usages_by_step()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L380"}, {"id": "crud_production_material_usage_list_linked_step_usages", "label": "list_linked_step_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L437"}, {"id": "crud_production_material_usage_revert_step_material_usages", "label": "revert_step_material_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L487"}, {"id": "crud_production_material_usage_list_requisition_options", "label": "list_requisition_options()", "file_type": "code", "source_file": "/Users/wuzilong/work/00codLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_prep_py", "label": "production_material_prep.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L1"}, {"id": "crud_production_material_prep_status_label", "label": "_status_label()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L32"}, {"id": "crud_production_material_prep_fmt_date", "label": "_fmt_date()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L40"}, {"id": "crud_production_material_prep_user_nick_name_map", "label": "_user_nick_name_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L44"}, {"id": "crud_production_material_prep_generate_prep_no", "label": "_generate_prep_no()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L52"}, {"id": "crud_production_material_prep_generate_stock_in_no", "label": "_generate_stock_in_no()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L66"}, {"id": "crud_production_material_prep_line_to_dict", "label": "_line_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L84"}, {"id": "crud_production_material_prep_header_to_dict", "label": "_header_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L100"}, {"id": "crud_production_material_prep_get_prep_row", "label": "_get_prep_row()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L130"}, {"id": "crud_production_material_prep_require_draft", "label": "_require_draft()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L145"}, {"id": "crud_production_material_prep_validate_requisition", "label": "_validate_requisition()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L150"}, {"id": "crud_production_material_prep_parse_prep_lines", "label": "_parse_prep_lines()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L182"}, {"id": "crud_production_material_prep_list_preps", "label": "list_preps()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L247"}, {"id": "crud_production_material_prep_get_prep_detail", "label": "get_prep_detail()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L314"}, {"id": "crud_production_material_prep_create_prep", "label": "create_prep()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L339"}, {"id": "crud_production_material_prep_update_prep", "label": "update_prep()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L438"}, {"id": "crud_production_material_prep_write_prep_consume_usage", "label": "_write_prep_consume_usage()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L522"}, {"id": "crud_production_material_prep_complete_prep", "label": "complete_prep()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L587"}, {"id": "crud_production_material_prep_cancel_prep", "label": "cancel_prep()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L702"}, {"id": "crud_production_material_prep_delete_prep", "label": "delete_prep()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L719"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_prep_py", "target": "datetime", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_prep.py", "source_location": "L4", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxwLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_api_operations_py", "label": "operations.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L1"}, {"id": "api_operations_get_tenant_no", "label": "_get_tenant_no()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L24"}, {"id": "api_operations_cleanroomcreatebody", "label": "CleanRoomCreateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L39"}, {"id": "basemodel", "label": "BaseModel", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "api_operations_cleanroomupdatebody", "label": "CleanRoomUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L51"}, {"id": "api_operations_list_clean_rooms", "label": "list_clean_rooms()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L64"}, {"id": "api_operations_create_clean_room", "label": "create_clean_room()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L89"}, {"id": "api_operations_update_clean_room", "label": "update_clean_room()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L114"}, {"id": "api_operations_delete_clean_room", "label": "delete_clean_room()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L142"}, {"id": "api_operations_accesslogcreatebody", "label": "AccessLogCreateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L160"}, {"id": "api_operations_accesslogupdatebody", "label": "AccessLogUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L174"}, {"id": "api_operations_parse_optional_dt", "label": "_parse_optional_dt()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L187"}, {"id": "api_operations_list_access_logs", "label": "list_access_logs()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L194"}, {"id": "api_operations_create_access_log", "label": "create_access_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L223"}, {"id": "api_operations_update_access_log", "label": "update_access_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L250"}, {"id": "api_operations_delete_access_log", "label": "delete_access_log()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L279"}, {"id": "api_operations_storagefacilitycreatebody", "label": "StorageFacilityCreateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L297"}, {"id": "api_operations_storagefacilityupdatebody", "label": "StorageFacilityUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L308"}, {"id": "api_operations_list_storage_facilities", "label": "list_storage_facilities()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L319"}, {"id": "api_operations_create_storage_facility", "label": "create_storage_facility()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L341"}, {"id": "api_operations_update_storage_facility", "label": "update_storage_facility()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L365"}, {"id": "api_operations_delete_storage_facility", "label": "delete_storage_facility()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L391"}, {"id": "api_operations_storageslotcreatebody", "label": "StorageSlotCreateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L409"}, {"id": "api_operations_storageslotbatchcreatebody", "label": "StorageSlotBatchCreateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/operations.py", "source_location": "L419"}, {"id": "api_operations_storageslotupdatebody", "label":Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_models_models_py", "label": "models.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L1"}, {"id": "models_models_userrole", "label": "UserRole", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L10"}, {"id": "str", "label": "str", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "models_models_sysuser", "label": "SysUser", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L22"}, {"id": "base", "label": "Base", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "models_models_sysrole", "label": "SysRole", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L48"}, {"id": "models_models_sysuserrole", "label": "SysUserRole", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L68"}, {"id": "models_models_sysrolemenu", "label": "SysRoleMenu", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L87"}, {"id": "models_models_sysroledatascopedetail", "label": "SysRoleDataScopeDetail", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L106"}, {"id": "models_models_sysmenu", "label": "SysMenu", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L126"}, {"id": "models_models_sysdept", "label": "SysDept", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L152"}, {"id": "models_models_systenant", "label": "SysTenant", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L175"}, {"id": "models_models_syssite", "label": "SysSite", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L195"}, {"id": "models_models_syspost", "label": "SysPost", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L220"}, {"id": "models_models_sysuserpost", "label": "SysUserPost", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L240"}, {"id": "models_models_bizitemunit", "label": "BizItemUnit", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L259"}, {"id": "models_models_bizexpresscompany", "label": "BizExpressCompany", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L278"}, {"id": "models_models_bizcustomer", "label": "BizCustomer", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L297"}, {"id": "models_models_bizcellsampletype", "label": "BizCellSampleType", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L320"}, {"id": "models_models_bizcollectionregion", "label": "BizCollectionRegion", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L341"}, {"id": "models_models_bizcollectionhospital", "label": "BizCollectionHospital", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L359"}, {"id": "models_models_bizcollectionprotocolno", "label": "BizCollectionProtocolNo", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L378"}, {"id": "models_models_bizbiznosequence", "label": "BizBizNoSequence", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L400"}, {"id": "models_models_bizsamplecode", "label": "BizSampleCode", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L420"}, {"id": "models_models_sysdicttype", "label": "SysDictType", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L448"}, {"id": "models_models_sysethnic", "label": "SysEthnic", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L467"}, {"id": "models_models_sysdictdata", "label": "SysDictData", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location"Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_models_models_py", "label": "models.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L1"}, {"id": "models_models_userrole", "label": "UserRole", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L10"}, {"id": "str", "label": "str", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "models_models_sysuser", "label": "SysUser", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L22"}, {"id": "base", "label": "Base", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "models_models_sysrole", "label": "SysRole", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L48"}, {"id": "models_models_sysuserrole", "label": "SysUserRole", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L68"}, {"id": "models_models_sysrolemenu", "label": "SysRoleMenu", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L87"}, {"id": "models_models_sysroledatascopedetail", "label": "SysRoleDataScopeDetail", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L106"}, {"id": "models_models_sysmenu", "label": "SysMenu", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L126"}, {"id": "models_models_sysdept", "label": "SysDept", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L152"}, {"id": "models_models_systenant", "label": "SysTenant", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L175"}, {"id": "models_models_syssite", "label": "SysSite", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L195"}, {"id": "models_models_syspost", "label": "SysPost", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L220"}, {"id": "models_models_sysuserpost", "label": "SysUserPost", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L240"}, {"id": "models_models_bizitemunit", "label": "BizItemUnit", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L259"}, {"id": "models_models_bizexpresscompany", "label": "BizExpressCompany", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L278"}, {"id": "models_models_bizcustomer", "label": "BizCustomer", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L297"}, {"id": "models_models_bizcellsampletype", "label": "BizCellSampleType", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L320"}, {"id": "models_models_bizcollectionregion", "label": "BizCollectionRegion", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L341"}, {"id": "models_models_bizcollectionhospital", "label": "BizCollectionHospital", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L359"}, {"id": "models_models_bizcollectionprotocolno", "label": "BizCollectionProtocolNo", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L378"}, {"id": "models_models_bizbiznosequence", "label": "BizBizNoSequence", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L400"}, {"id": "models_models_bizsamplecode", "label": "BizSampleCode", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L420"}, {"id": "models_models_sysdicttype", "label": "SysDictType", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L448"}, {"id": "models_models_sysethnic", "label": "SysEthnic", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location": "L467"}, {"id": "models_models_sysdictdata", "label": "SysDictData", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/models.py", "source_location"Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "label": "production_material.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L1"}, {"id": "models_production_material_bizproductionmaterial", "label": "BizProductionMaterial", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L8"}, {"id": "base", "label": "Base", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "models_production_material_bizproductionmaterialstockbatch", "label": "BizProductionMaterialStockBatch", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L31"}, {"id": "models_production_material_bizproductionmaterialusage", "label": "BizProductionMaterialUsage", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L62"}, {"id": "models_production_material_bizproductionmaterialstockcheck", "label": "BizProductionMaterialStockCheck", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L104"}, {"id": "models_production_material_bizproductionmaterialstockcheckbatchline", "label": "BizProductionMaterialStockCheckBatchLine", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L123"}, {"id": "models_production_material_bizproductionmaterialstockcheckunusedline", "label": "BizProductionMaterialStockCheckUnusedLine", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L155"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "datetime", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L1", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "sqlalchemy", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L3", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "app_core_database", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L5", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "models_production_material_bizproductionmaterial", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L8", "weight": 1.0}, {"source": "models_production_material_bizproductionmaterial", "target": "base", "relation": "inherits", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L8", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "models_production_material_bizproductionmaterialstockbatch", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L31", "weight": 1.0}, {"source": "models_production_material_bizproductionmaterialstockbatch", "target": "base", "relation": "inherits", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L31", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "models_production_material_bizproductionmaterialusage", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L62", "weight": 1.0}, {"source": "models_production_material_bizproductionmaterialusage", "target": "base", "relation": "inherits", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L62", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_production_material_py", "target": "models_production_material_bizproductionmaterialstockcheck", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/production_material.py", "source_location": "L104", "weight": 1.Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_api_production_py", "label": "production.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L1"}, {"id": "api_production_legacy_material_write_gone", "label": "_legacy_material_write_gone()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L75"}, {"id": "api_production_get_tenant_no", "label": "_get_tenant_no()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L79"}, {"id": "api_production_get_current_user_id", "label": "_get_current_user_id()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L87"}, {"id": "api_production_assert_production_task_write_access", "label": "_assert_production_task_write_access()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L91"}, {"id": "api_production_consumablecreatebody", "label": "ConsumableCreateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L115"}, {"id": "basemodel", "label": "BaseModel", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "api_production_consumableupdatebody", "label": "ConsumableUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L129"}, {"id": "api_production_list_consumables", "label": "list_consumables()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L144"}, {"id": "api_production_list_all_consumables", "label": "list_all_consumables()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L158"}, {"id": "api_production_create_consumable", "label": "create_consumable()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L168"}, {"id": "api_production_update_consumable", "label": "update_consumable()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L177"}, {"id": "api_production_delete_consumable", "label": "delete_consumable()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L187"}, {"id": "api_production_stockinbody", "label": "StockInBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L195"}, {"id": "api_production_stockoutbody", "label": "StockOutBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L201"}, {"id": "api_production_batchstockinitem", "label": "BatchStockInItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L209"}, {"id": "api_production_batchstockinbody", "label": "BatchStockInBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L216"}, {"id": "api_production_batchstockoutitem", "label": "BatchStockOutItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L222"}, {"id": "api_production_batchstockoutbody", "label": "BatchStockOutBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L228"}, {"id": "api_production_consumable_stock_in", "label": "consumable_stock_in()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L237"}, {"id": "api_production_consumable_stock_out", "label": "consumable_stock_out()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L259"}, {"id": "api_production_consumable_batch_stock_in", "label": "consumable_batch_stock_in()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L283"}, {"id": "api_production_consumable_batch_stock_out", "label": "consumable_batch_stock_out()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L301"}, {"id": "api_production_list_consumable_stock_logs", "label": "list_consumable_stock_logs()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production.py", "source_location": "L320"}, {"id": "api_production_list_all_consumable_stock_logs", "labLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_qc_material_stock_batch_py", "label": "qc_material_stock_batch.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/qc_material_stock_batch.py", "source_location": "L1"}, {"id": "crud_qc_material_stock_batch_fmt_date", "label": "_fmt_date()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/qc_material_stock_batch.py", "source_location": "L16"}, {"id": "crud_qc_material_stock_batch_parse_date", "label": "_parse_date()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/qc_material_stock_batch.py", "source_location": "L20"}, {"id": "crud_qc_material_stock_batch_parse_expire_date", "label": "_parse_expire_date()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/qc_material_stock_batch.py", "source_location": "L34"}, {"id": "crud_qc_material_stock_batch_require_str", "label": "_require_str()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/qc_material_stock_batch.py", "source_location": "L38"}, {"id": "crud_qc_material_stock_batch_require_decimal", "label": "_require_decimal()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/qc_material_stock_batch.py", "source_location": "L45"}, {"id": "crud_qc_material_stock_batch_stock_in_no_exists", "label": "stock_in_no_exists()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/qc_material_stock_batch.py", "source_location": "L57"}, {"id": "crud_qc_material_stock_batch_batch_row_to_dict", "label": "_batch_row_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/qc_material_stock_batch.py", "source_location": "L73"}, {"id": "crud_qc_material_stock_batch_usage_batch_snapshots", "label": "_usage_batch_snapshots()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/qc_material_stock_batch.py", "source_location": "L105"}, {"id": "crud_qc_material_stock_batch_get_material_for_update", "label": "_get_material_for_update()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/qc_material_stock_batch.py", "source_location": "L126"}, {"id": "crud_qc_material_stock_batch_list_batches", "label": "list_batches()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/qc_material_stock_batch.py", "source_location": "L144"}, {"id": "crud_qc_material_stock_batch_batch_options", "label": "batch_options()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/qc_material_stock_batch.py", "source_location": "L208"}, {"id": "crud_qc_material_stock_batch_create_batch_and_usage", "label": "_create_batch_and_usage()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/qc_material_stock_batch.py", "source_location": "L281"}, {"id": "crud_qc_material_stock_batch_stock_in_one", "label": "stock_in_one()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/qc_material_stock_batch.py", "source_location": "L372"}, {"id": "crud_qc_material_stock_batch_batch_stock_in", "label": "batch_stock_in()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/qc_material_stock_batch.py", "source_location": "L413"}, {"id": "crud_qc_material_stock_batch_stock_out_batch", "label": "_stock_out_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/qc_material_stock_batch.py", "source_location": "L469"}, {"id": "crud_qc_material_stock_batch_batch_stock_out", "label": "batch_stock_out()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/qc_material_stock_batch.py", "source_location": "L550"}, {"id": "crud_qc_material_stock_batch_validate_discard_reason", "label": "_validate_discard_reason()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/qc_material_stock_batch.py", "source_location": "L603"}, {"id": "crud_qc_material_stock_batch_discard_batch", "label": "_discard_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/qc_material_stock_batch.py", "source_location": "L612"}, {"id": "crud_qc_material_stock_batch_batch_discard", "label": "batch_discard()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/qc_material_stock_batch.py", "source_location": "L689"}, {"id": "crud_qc_material_stock_batch_get_batch", "label": "get_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/qc_material_stock_batch.py", "source_location": "L740"}, {"id": "crud_qc_material_stock_batch_update_batch", "label": "update_batch()", "file_type": "code", "source_file": "/Users/wuzilong/woLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_api_production_material_py", "label": "production_material.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L1"}, {"id": "api_production_material_productionmaterialbody", "label": "ProductionMaterialBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L26"}, {"id": "basemodel", "label": "BaseModel", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "api_production_material_productionmaterialupdatebody", "label": "ProductionMaterialUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L38"}, {"id": "api_production_material_stockinbody", "label": "StockInBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L50"}, {"id": "api_production_material_batchstockinitem", "label": "BatchStockInItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L65"}, {"id": "api_production_material_batchstockinbody", "label": "BatchStockInBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L80"}, {"id": "api_production_material_batchstockoutitem", "label": "BatchStockOutItem", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L87"}, {"id": "api_production_material_batchstockoutbody", "label": "BatchStockOutBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L94"}, {"id": "api_production_material_productionmaterialbatchupdatebody", "label": "ProductionMaterialBatchUpdateBody", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L103"}, {"id": "api_production_material_list_production_material_batches", "label": "list_production_material_batches()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L123"}, {"id": "api_production_material_production_material_batch_options", "label": "production_material_batch_options()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L154"}, {"id": "api_production_material_update_production_material_batch", "label": "update_production_material_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L179"}, {"id": "api_production_material_delete_production_material_batch", "label": "delete_production_material_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L208"}, {"id": "api_production_material_list_production_materials", "label": "list_production_materials()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L225"}, {"id": "api_production_material_production_material_options", "label": "production_material_options()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L254"}, {"id": "api_production_material_create_production_material", "label": "create_production_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L269"}, {"id": "api_production_material_update_production_material", "label": "update_production_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L300"}, {"id": "api_production_material_delete_production_material", "label": "delete_production_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L329"}, {"id": "api_production_material_batch_stock_in_production_material", "label": "batch_stock_in_production_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L346"}, {"id": "api_production_material_batch_stock_out_production_material", "label": "batch_stock_out_production_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/api/production_material.py", "source_location": "L399"}, {"id": "api_production_material_stock_in_production_material", "label": "stock_in_proLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_usage_py", "label": "production_material_usage.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L1"}, {"id": "crud_production_material_usage_parse_receiver_purpose_from_remark", "label": "_parse_receiver_purpose_from_remark()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L18"}, {"id": "crud_production_material_usage_resolve_receiver_purpose", "label": "_resolve_receiver_purpose()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L30"}, {"id": "crud_production_material_usage_display_remark", "label": "_display_remark()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L40"}, {"id": "crud_production_material_usage_user_nick_name_map", "label": "_user_nick_name_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L56"}, {"id": "crud_production_material_usage_receiver_display_map", "label": "_receiver_display_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L64"}, {"id": "crud_production_material_usage_usage_unit_label", "label": "_usage_unit_label()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L76"}, {"id": "crud_production_material_usage_stock_in_date_for_row", "label": "_stock_in_date_for_row()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L85"}, {"id": "crud_production_material_usage_unit_price_for_row", "label": "_unit_price_for_row()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L91"}, {"id": "crud_production_material_usage_amount_for_row", "label": "_amount_for_row()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L99"}, {"id": "crud_production_material_usage_row_to_dict", "label": "_row_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L115"}, {"id": "crud_production_material_usage_batch_map", "label": "_batch_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L178"}, {"id": "crud_production_material_usage_mine_usage_filter", "label": "_mine_usage_filter()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L190"}, {"id": "crud_production_material_usage_list_usages_query", "label": "_list_usages_query()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L215"}, {"id": "crud_production_material_usage_paginate_usages", "label": "_paginate_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L280"}, {"id": "crud_production_material_usage_list_usages", "label": "list_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L311"}, {"id": "crud_production_material_usage_list_my_usages", "label": "list_my_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L341"}, {"id": "crud_production_material_usage_list_usages_by_step", "label": "list_usages_by_step()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L374"}, {"id": "crud_production_material_usage_list_linked_step_usages", "label": "list_linked_step_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L431"}, {"id": "crud_production_material_usage_revert_step_material_usages", "label": "revert_step_material_usages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_usage.py", "source_location": "L481"}, {"id": "crud_production_material_usage_list_requisition_options", "label": "list_requisition_options()", "file_type": "code", "source_file": "/Users/wuzilong/work/00codeLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_services_qc_work_order_fee_summary_py", "label": "qc_work_order_fee_summary.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/qc_work_order_fee_summary.py", "source_location": "L1"}, {"id": "services_qc_work_order_fee_summary_is_outbound_fee_biz_type", "label": "_is_outbound_fee_biz_type()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/qc_work_order_fee_summary.py", "source_location": "L30"}, {"id": "services_qc_work_order_fee_summary_dec", "label": "_dec()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/qc_work_order_fee_summary.py", "source_location": "L34"}, {"id": "services_qc_work_order_fee_summary_received_amount_from_details", "label": "_received_amount_from_details()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/qc_work_order_fee_summary.py", "source_location": "L43"}, {"id": "services_qc_work_order_fee_summary_protocol_status_hint", "label": "_protocol_status_hint()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/qc_work_order_fee_summary.py", "source_location": "L52"}, {"id": "services_qc_work_order_fee_summary_protocol_overall_status", "label": "_protocol_overall_status()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/qc_work_order_fee_summary.py", "source_location": "L76"}, {"id": "services_qc_work_order_fee_summary_fmt_ymd", "label": "_fmt_ymd()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/qc_work_order_fee_summary.py", "source_location": "L98"}, {"id": "services_qc_work_order_fee_summary_payment_detail_row", "label": "_payment_detail_row()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/qc_work_order_fee_summary.py", "source_location": "L105"}, {"id": "services_qc_work_order_fee_summary_sort_payment_details", "label": "_sort_payment_details()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/qc_work_order_fee_summary.py", "source_location": "L123"}, {"id": "services_qc_work_order_fee_summary_build_protocol_payment_summary", "label": "build_protocol_payment_summary()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/qc_work_order_fee_summary.py", "source_location": "L134"}, {"id": "services_qc_work_order_fee_summary_build_protocol_payment_summaries", "label": "build_protocol_payment_summaries()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/qc_work_order_fee_summary.py", "source_location": "L162"}, {"id": "services_qc_work_order_fee_summary_build_basic_experiment_fee_summary", "label": "build_basic_experiment_fee_summary()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/qc_work_order_fee_summary.py", "source_location": "L204"}, {"id": "services_qc_work_order_fee_summary_build_basic_experiment_fee_summaries", "label": "build_basic_experiment_fee_summaries()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/qc_work_order_fee_summary.py", "source_location": "L224"}, {"id": "services_qc_work_order_fee_summary_is_inbound_cell_storage_item", "label": "_is_inbound_cell_storage_item()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/qc_work_order_fee_summary.py", "source_location": "L260"}, {"id": "services_qc_work_order_fee_summary_load_reception_map", "label": "_load_reception_map()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/qc_work_order_fee_summary.py", "source_location": "L267"}, {"id": "services_qc_work_order_fee_summary_load_protocol_id_by_no", "label": "_load_protocol_id_by_no()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/qc_work_order_fee_summary.py", "source_location": "L281"}, {"id": "services_qc_work_order_fee_summary_effective_collection_protocol_id", "label": "_effective_collection_protocol_id()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/qc_work_order_fee_summary.py", "source_location": "L299"}, {"id": "services_qc_work_order_fee_summary_enrich_work_order_fee_summaries", "label": "enrich_work_order_fee_summaries()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/qc_work_order_fee_summary.py", "source_location": "L315"}, {"id": "services_qc_work_order_fee_summary_rationale_1", "label": "\u8d28\u68c0\u5de5\u5355 \u00b7 \u7528\u6237\u8d39\u7528\u6458\u8981\uff08\u91c7\u96c6\u534f\u8bae / \u57fa\u7840\u5b9e\u9a8c\uff09", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/services/qc_woLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_cell_product_py", "label": "cell_product.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L1"}, {"id": "crud_cell_product_apply_cell_product_status_change", "label": "_apply_cell_product_status_change()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L30"}, {"id": "crud_cell_product_row_to_dict", "label": "_row_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L85"}, {"id": "crud_cell_product_build_facility_path_label", "label": "_build_facility_path_label()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L118"}, {"id": "crud_cell_product_enrich_product_dicts", "label": "_enrich_product_dicts()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L133"}, {"id": "crud_cell_product_product_to_response", "label": "product_to_response()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L264"}, {"id": "crud_cell_product_list_cell_products", "label": "list_cell_products()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L269"}, {"id": "crud_cell_product_get_cell_product", "label": "get_cell_product()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L333"}, {"id": "crud_cell_product_create_cell_product", "label": "create_cell_product()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L347"}, {"id": "crud_cell_product_update_cell_product", "label": "update_cell_product()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L419"}, {"id": "crud_cell_product_delete_cell_product", "label": "delete_cell_product()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L510"}, {"id": "crud_cell_product_next_code_start_seq", "label": "_next_code_start_seq()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L527"}, {"id": "crud_cell_product_get_next_code", "label": "get_next_code()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L548"}, {"id": "crud_cell_product_normalize_product_code_base", "label": "normalize_product_code_base()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L558"}, {"id": "crud_cell_product_build_split_product_codes", "label": "build_split_product_codes()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L569"}, {"id": "crud_cell_product_reserve_next_codes", "label": "reserve_next_codes()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L576"}, {"id": "crud_cell_product_validate_batch_items", "label": "_validate_batch_items()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L586"}, {"id": "crud_cell_product_create_cell_products_by_quantity", "label": "create_cell_products_by_quantity()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L631"}, {"id": "crud_cell_product_create_cell_products_batch", "label": "create_cell_products_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L665"}, {"id": "crud_cell_product_total_pages", "label": "total_pages()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L741"}, {"id": "crud_cell_product_product_node", "label": "_product_node()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L756"}, {"id": "crud_cell_product_nest_ancestor_parent", "label": "_nest_ancestor_parent()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "L768"}, {"id": "crud_cell_product_edge_meta", "label": "_edge_meta()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/cell_product.py", "source_location": "LLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_models_cleanroom_garment_py", "label": "cleanroom_garment.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/cleanroom_garment.py", "source_location": "L1"}, {"id": "models_cleanroom_garment_bizcleanroomgarment", "label": "BizCleanroomGarment", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/cleanroom_garment.py", "source_location": "L8"}, {"id": "base", "label": "Base", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "models_cleanroom_garment_bizcleanroomgarmentwashlog", "label": "BizCleanroomGarmentWashLog", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/cleanroom_garment.py", "source_location": "L32"}, {"id": "models_cleanroom_garment_bizcleanroomgarmentsterilizelog", "label": "BizCleanroomGarmentSterilizeLog", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/cleanroom_garment.py", "source_location": "L53"}, {"id": "models_cleanroom_garment_rationale_9", "label": "\u6d01\u51c0\u670d\u4fe1\u606f biz_cleanroom_garment", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/cleanroom_garment.py", "source_location": "L9"}, {"id": "models_cleanroom_garment_rationale_33", "label": "\u6d01\u51c0\u670d\u6e05\u6d17\u8bb0\u5f55 biz_cleanroom_garment_wash_log", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/cleanroom_garment.py", "source_location": "L33"}, {"id": "models_cleanroom_garment_rationale_54", "label": "\u6d01\u51c0\u670d\u706d\u83cc\u8bb0\u5f55 biz_cleanroom_garment_sterilize_log", "file_type": "rationale", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/cleanroom_garment.py", "source_location": "L54"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_models_cleanroom_garment_py", "target": "datetime", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/cleanroom_garment.py", "source_location": "L1", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_cleanroom_garment_py", "target": "sqlalchemy", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/cleanroom_garment.py", "source_location": "L3", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_cleanroom_garment_py", "target": "app_core_database", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/cleanroom_garment.py", "source_location": "L5", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_cleanroom_garment_py", "target": "models_cleanroom_garment_bizcleanroomgarment", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/cleanroom_garment.py", "source_location": "L8", "weight": 1.0}, {"source": "models_cleanroom_garment_bizcleanroomgarment", "target": "base", "relation": "inherits", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/cleanroom_garment.py", "source_location": "L8", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_cleanroom_garment_py", "target": "models_cleanroom_garment_bizcleanroomgarmentwashlog", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/cleanroom_garment.py", "source_location": "L32", "weight": 1.0}, {"source": "models_cleanroom_garment_bizcleanroomgarmentwashlog", "target": "base", "relation": "inherits", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/cleanroom_garment.py", "source_location": "L32", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_models_cleanroom_garment_py", "target": "models_cleanroom_garment_bizcleanroomgarmentsterilizelog", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/cleanroom_garment.py", "source_location": "L53", "weight": 1.0}, {"source": "models_cleanroom_garment_bizcleanroomgarmentsterilizelog", "target": "base", "relation": "inherits", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/cleanroom_garment.py", "source_location": "L53", "weight": 1.0}, {"source": "models_cleanroom_garment_rationale_9", "target": "models_cleanroom_garment_bizcleanroomgarment", "relation": "rationale_for", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/models/cleanroom_garment.py", "source_location": "L9", "weight": 1.0}, {"source": "models_cleanroom_garment_rationale_33", "target": "models_cleanroom_garment_bizcleanroomgLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_stock_batch_py", "label": "production_material_stock_batch.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L1"}, {"id": "crud_production_material_stock_batch_fmt_date", "label": "_fmt_date()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L16"}, {"id": "crud_production_material_stock_batch_parse_date", "label": "_parse_date()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L20"}, {"id": "crud_production_material_stock_batch_parse_expire_date", "label": "_parse_expire_date()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L34"}, {"id": "crud_production_material_stock_batch_require_str", "label": "_require_str()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L38"}, {"id": "crud_production_material_stock_batch_optional_str", "label": "_optional_str()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L45"}, {"id": "crud_production_material_stock_batch_require_decimal", "label": "_require_decimal()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L52"}, {"id": "crud_production_material_stock_batch_stock_in_no_exists", "label": "stock_in_no_exists()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L64"}, {"id": "crud_production_material_stock_batch_batch_row_to_dict", "label": "_batch_row_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L80"}, {"id": "crud_production_material_stock_batch_usage_batch_snapshots", "label": "_usage_batch_snapshots()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L114"}, {"id": "crud_production_material_stock_batch_get_material_for_update", "label": "_get_material_for_update()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L136"}, {"id": "crud_production_material_stock_batch_list_batches", "label": "list_batches()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L154"}, {"id": "crud_production_material_stock_batch_batch_options", "label": "batch_options()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L222"}, {"id": "crud_production_material_stock_batch_create_batch_and_usage", "label": "_create_batch_and_usage()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L301"}, {"id": "crud_production_material_stock_batch_stock_in_one", "label": "stock_in_one()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L401"}, {"id": "crud_production_material_stock_batch_batch_stock_in", "label": "batch_stock_in()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L444"}, {"id": "crud_production_material_stock_batch_stock_out_batch", "label": "_stock_out_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L501"}, {"id": "crud_production_material_stock_batch_batch_stock_out", "label": "batch_stock_out()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L583"}, {"id": "crud_production_material_stock_batch_validate_discard_reason", "label": "_validate_discard_reason()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L636"}, {"id": "crud_production_material_stock_batch_discard_batch", "label": "_discard_batch()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_stock_batch.py", "source_location": "L645"}, {"id": "crud_production_mLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_formula_py", "label": "production_material_formula.py", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_formula.py", "source_location": "L1"}, {"id": "crud_production_material_formula_line_to_dict", "label": "_line_to_dict()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_formula.py", "source_location": "L18"}, {"id": "crud_production_material_formula_get_configured_material", "label": "_get_configured_material()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_formula.py", "source_location": "L33"}, {"id": "crud_production_material_formula_get_formula", "label": "get_formula()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_formula.py", "source_location": "L52"}, {"id": "crud_production_material_formula_replace_formula", "label": "replace_formula()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_formula.py", "source_location": "L72"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_formula_py", "target": "datetime", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_formula.py", "source_location": "L4", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_formula_py", "target": "decimal", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_formula.py", "source_location": "L5", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_formula_py", "target": "typing", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_formula.py", "source_location": "L6", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_formula_py", "target": "sqlalchemy", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_formula.py", "source_location": "L8", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_formula_py", "target": "sqlalchemy_orm", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_formula.py", "source_location": "L9", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_formula_py", "target": "app_core_utils", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_formula.py", "source_location": "L11", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_formula_py", "target": "app_crud_production_material", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_formula.py", "source_location": "L12", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_formula_py", "target": "app_models_production_material", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_formula.py", "source_location": "L13", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_formula_py", "target": "crud_production_material_formula_line_to_dict", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_formula.py", "source_location": "L18", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_formula_py", "target": "crud_production_material_formula_get_configured_material", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_formula.py", "source_location": "L33", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_formula_py", "target": "crud_production_material_formula_get_formula", "relation": "contains", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/backend/app/crud/production_material_formula.py", "source_location": "L52", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_backend_app_crud_production_material_formula_py", "target": "crud_production_material_formula_replace_formula", "relaLine truncated
Loaded 100 of 616 files, more files were not shown because too many files have changed in this diff. Show more