|
@@ -75,12 +75,14 @@ async def create(
|
|
|
area = n['area'],
|
|
|
management_unit = n['management_unit'],
|
|
|
fuzeren = n['fuzeren'],
|
|
|
- order_num = i
|
|
|
+ order_num = i,
|
|
|
+ price = 0
|
|
|
)
|
|
|
db.add(new_detail)
|
|
|
|
|
|
db.commit()
|
|
|
|
|
|
+ '''
|
|
|
# 信息中心
|
|
|
to_user_id = user_info.user_id
|
|
|
yzy_account = user_info.yzy_account
|
|
@@ -103,6 +105,7 @@ async def create(
|
|
|
"title": "物资调配审批"
|
|
|
}
|
|
|
YzyApi.add_to_msg_queue(db, data)
|
|
|
+ '''
|
|
|
|
|
|
return {"code": 200, "msg": "创建成功", "data": None}
|
|
|
|
|
@@ -124,4 +127,123 @@ def send_yzy_msg(db: Session, msg_type: str, to_user_id: int, yzy_account: str,
|
|
|
}
|
|
|
YzyApi.add_to_msg_queue(db, data)
|
|
|
|
|
|
- db_msg_center.add_message(db, msg_type, to_user_id, "物资调配审批", description, foreign_key, from_scenario)
|
|
|
+ db_msg_center.add_message(db, msg_type, to_user_id, "物资调配审批", description, foreign_key, from_scenario)
|
|
|
+
|
|
|
+@router.get("/list")
|
|
|
+async def get_transfter_list(
|
|
|
+ user_id = Depends(valid_access_token),
|
|
|
+ page: int = Query(1, gt=0, description='页码'),
|
|
|
+ pageSize: int = Query(None, gt=0, description='每页条目数量'),
|
|
|
+ db: Session = Depends(get_db)
|
|
|
+):
|
|
|
+ try:
|
|
|
+ query = db.query(RescueMateriaTransfer)
|
|
|
+ total_items = query.count()
|
|
|
+ # 排序
|
|
|
+ if pageSize is None:
|
|
|
+ pageSize = total_items
|
|
|
+ query = query.order_by(RescueMateriaTransfer.application_time.desc())
|
|
|
+ # 执行分页查询
|
|
|
+ lists = query.offset((page - 1) * pageSize).limit(pageSize).all()
|
|
|
+ data = []
|
|
|
+ for info in lists:
|
|
|
+ pid = info.id
|
|
|
+
|
|
|
+ material = []
|
|
|
+ rows = db.query(RescueMateriaTransferDetail).filter(RescueMateriaTransferDetail.pid == pid).order_by(RescueMateriaTransferDetail.order_num.asc()).all()
|
|
|
+ for row in rows:
|
|
|
+ material.append({
|
|
|
+ "id": row.id,
|
|
|
+ "materia_id": row.materia_id,
|
|
|
+ "materia_name": row.materia_name,
|
|
|
+ "materia_type": row.materia_type,
|
|
|
+ "materia_unit": row.materia_unit,
|
|
|
+ "materia_num": row.materia_num,
|
|
|
+ "num": row.num,
|
|
|
+ "price": row.price,
|
|
|
+ "purchase_time": get_datetime_str(row.purchase_time),
|
|
|
+ "order_num": row.order_num,
|
|
|
+ "area": row.area,
|
|
|
+ "management_unit": row.management_unit,
|
|
|
+ "fuzeren": row.fuzeren
|
|
|
+ })
|
|
|
+
|
|
|
+ data.append({
|
|
|
+ "id": info.id,
|
|
|
+ "application_time": get_datetime_str(info.application_time),
|
|
|
+ "applicant": info.applicant,
|
|
|
+ "treatment": get_treatment_text(info.treatment),
|
|
|
+ "receiving_unit": info.receiving_unit,
|
|
|
+ "receiving_location": info.receiving_location,
|
|
|
+ "use": info.use,
|
|
|
+ "contact_person": info.contact_person,
|
|
|
+ "contact_phone": info.contact_phone,
|
|
|
+ "notes": info.notes,
|
|
|
+ "apply_status": info.apply_status,
|
|
|
+ "apply_time": get_datetime_str(info.apply_time),
|
|
|
+ "material": material
|
|
|
+ })
|
|
|
+
|
|
|
+ return {
|
|
|
+ "code": 200,
|
|
|
+ "msg": "查询成功",
|
|
|
+ "data": data,
|
|
|
+ "total": total_items,
|
|
|
+ "page": page,
|
|
|
+ "pageSize": pageSize,
|
|
|
+ "totalPages": (total_items + pageSize - 1) // pageSize
|
|
|
+ }
|
|
|
+ except Exception as e:
|
|
|
+ traceback.print_exc()
|
|
|
+ raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
|
|
|
+
|
|
|
+def get_treatment_text(val: str) -> str:
|
|
|
+ if val == '1':
|
|
|
+ return '无偿调拨'
|
|
|
+ elif val == '2':
|
|
|
+ return '有偿调拨'
|
|
|
+ else:
|
|
|
+ return str(val)
|
|
|
+
|
|
|
+@router.get("/detail")
|
|
|
+async def get_transfter_detail(
|
|
|
+ id: str,
|
|
|
+ user_id = Depends(valid_access_token),
|
|
|
+ page: int = Query(1, gt=0, description='页码'),
|
|
|
+ pageSize: int = Query(None, gt=0, description='每页条目数量'),
|
|
|
+ db: Session = Depends(get_db)
|
|
|
+):
|
|
|
+ try:
|
|
|
+ row = db.query(RescueMateriaTransfer).filter(RescueMateriaTransfer.id == int(id)).first()
|
|
|
+ if row:
|
|
|
+ data = get_model_dict(row)
|
|
|
+ data["apply_time"] = get_datetime_str(row.apply_time)
|
|
|
+
|
|
|
+ material = []
|
|
|
+ rows = db.query(RescueMateriaTransferDetail).filter(RescueMateriaTransferDetail.pid == row.id).order_by(RescueMateriaTransferDetail.order_num.asc()).all()
|
|
|
+ for row in rows:
|
|
|
+ material.append({
|
|
|
+ "id": row.id,
|
|
|
+ "materia_id": row.materia_id,
|
|
|
+ "materia_name": row.materia_name,
|
|
|
+ "materia_type": row.materia_type,
|
|
|
+ "materia_unit": row.materia_unit,
|
|
|
+ "materia_num": row.materia_num,
|
|
|
+ "num": row.num,
|
|
|
+ "price": row.price,
|
|
|
+ "purchase_time": get_datetime_str(row.purchase_time),
|
|
|
+ "order_num": row.order_num,
|
|
|
+ "area": row.area,
|
|
|
+ "management_unit": row.management_unit,
|
|
|
+ "fuzeren": row.fuzeren
|
|
|
+ })
|
|
|
+
|
|
|
+ data['material'] = material
|
|
|
+ return {
|
|
|
+ "code": 200,
|
|
|
+ "msg": "查询成功",
|
|
|
+ "data": data
|
|
|
+ }
|
|
|
+ except Exception as e:
|
|
|
+ traceback.print_exc()
|
|
|
+ raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
|