baoyubo 3 mesi fa
parent
commit
63f80bd681

+ 10 - 3
routers/api/resourceProvison/MaterialReserveManagement/warehouse_inbound.py

@@ -37,7 +37,7 @@ async def create_pattern(
         warehouse_info = warehouse_room_id_get_warehouse_room_info(db,room_id)
         warehouse_id = ''
         if warehouse_info:
-            warehouse_id = warehouse_info.warehouse_id
+            warehouse_id = warehouse_info.warehouse
         new_inbound = ResourceProvisionInboundBasic(
             # id = new_guid(),
             warehouse_id=warehouse_id, #body['warehouse_id'],
@@ -65,11 +65,16 @@ async def create_pattern(
         new_inbound.inbound_order_number= f'{time.strftime("%Y%m%d", time.localtime())}1{str(new_inbound.id).zfill(7)}'
         filePath = f'/data/upload/mergefile/uploads/{body["filename"]}'
         movementData = pd.read_excel(filePath).to_dict(orient='records')
-        create_movement(db, movementData, new_inbound.inbound_order_number, 'I', user_id)
-        db.commit()
+        status_1 = create_movement(db, movementData, new_inbound.inbound_order_number, 'I', user_id)
+        if status_1!="成功":
+            new_inbound.del_flag='2'
+            db.commit()
+            return JSONResponse(status_code=500,content={"code": 200, "msg": status_1, "data": None})
+        #
         return {"code": 200, "msg": "创建成功", "data": None}
     except Exception as e:
         traceback.print_exc()
+        db.rollback()
         raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
 
 
@@ -141,6 +146,7 @@ async def get_pattern_info(
                 "type": info.type,
                 "supplier_name": info.supplier_name,
                 "creation_time": info.creation_time,
+                "planned_completion_time":info.planned_completion_time,
                 "remark": info.remark,
                 "supplier_code": info.supplier_code,
                 "completion_time": info.completion_time,
@@ -199,6 +205,7 @@ async def get_pattern_list(
                 "type": info.type,
                 "supplier_name": info.supplier_name,
                 "creation_time": info.creation_time,
+                "planned_completion_time":info.planned_completion_time,
                 "remark": info.remark,
                 "supplier_code": info.supplier_code,
                 "completion_time": info.completion_time,

+ 5 - 2
routers/api/resourceProvison/MaterialReserveManagement/warehouse_movement.py

@@ -53,9 +53,12 @@ async def get_pattern_list(
         lists = query.offset((page - 1) * pageSize).limit(pageSize).all()
         data = [ ]
         for info in lists:
-            material_info = material_id_get_material_info(db,material_id)
+            material_info = material_id_get_material_info(db,info.material_id)
+            material_name = ''
+            if material_info:
+                material_name = material_info.material_name
             data.append({"id": info.id,
-                "product_info": f"ID: {info.material_id}/n{material_info.material_name}",
+                "product_info": f"ID: {info.material_id}\n{material_name}",
                 "io_number": info.io_number,
                 "io_flag": info.io_flag,
                 "changed_stock": info.changed_stock,

+ 6 - 2
routers/api/resourceProvison/MaterialReserveManagement/warehouse_outbound.py

@@ -58,11 +58,15 @@ async def create_pattern(
         new_outbound.outbound_number= f'{time.strftime("%Y%m%d", time.localtime())}0{str(new_outbound.id).zfill(7)}'
         filePath = f'/data/upload/mergefile/uploads/{body["filename"]}'
         movementData = pd.read_excel(filePath).to_dict(orient='records')
-        create_movement(db, movementData, new_outbound.inbound_order_number, 'I', user_id)
-        db.commit()
+        status_1 = create_movement(db, movementData, new_outbound.inbound_order_number, 'I', user_id)
+        if status_1 != "成功":
+            new_outbound.del_flag = '2'
+            db.commit()
+            return JSONResponse(status_code=500, content={"code": 200, "msg": status_1, "data": None})
         return {"code": 200, "msg": "创建成功", "data": None}
     except Exception as e:
         traceback.print_exc()
+        db.rollback()
         raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")