diff --git a/reporting.ipynb b/reporting.ipynb index e62181a..51a5fe2 100644 --- a/reporting.ipynb +++ b/reporting.ipynb @@ -16,13 +16,13 @@ "import importlib\n", "importlib.reload(neo)\n", "\n", - "plant = neo.Plant.from_id(\"76f89f82-1238-43bb-b34f-796a92d491a2\")\n", - "print(plant.name)\n", + "#plant = neo.Asset.Plant.from_id(\"76f89f82-1238-43bb-b34f-796a92d491a2\")\n", + "#print(plant.name)\n", "\n", "\n", - "seedings = neo.Seeding.get_list()\n", + "seedings = neo.Log.Seeding.get_list()\n", "for seeding in seedings:\n", - " plant = seeding.getPlant()\n", + " plant = seeding.plant\n", " equipment = seeding.equipment[0]\n", " quantity1 = seeding.quantities[0]\n", " quantity2 = seeding.quantities[1]\n", @@ -45,6 +45,50 @@ " print(f\"Q2 units: {quantity2.units.name}\")" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "c1bf2175-65f7-4704-8d39-15a08849c9ae", + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [], + "source": [ + "import neofarm.lib as neo\n", + "import importlib\n", + "importlib.reload(neo)\n", + "\n", + "#plant = neo.Asset.Plant.from_id(\"76f89f82-1238-43bb-b34f-796a92d491a2\")\n", + "#print(plant.name)\n", + "\n", + "\n", + "seedings = neo.Log.Purchase.get_list()\n", + "for seeding in seedings:\n", + " plant = seeding.plant\n", + " #equipment = seeding.equipment[0]\n", + " quantity1 = seeding.quantities[0]\n", + " # quantity2 = seeding.quantities[1]\n", + " print(f\"name: {seeding.name}\")\n", + " print(f\"timestamp: {seeding.timestamp}\")\n", + " #print(f\"plant name: {plant.name}\")\n", + " #print(f\"plant crop: {plant.crop[0].name}\")\n", + " #print(f\"plant loc: {plant.location[0].name}\")\n", + " #print(f\"equipment: {equipment.name}\")\n", + " print(f\"isMovement: {seeding.isMovement}\")\n", + " print(f\"Q1 type: {quantity1.type}\")\n", + " print(f\"Q1 measure: {quantity1.measure}\")\n", + " print(f\"Q1 value: {quantity1.value}\")\n", + " print(f\"Q1 units: {quantity1.units.name}\")\n", + " print(f\"Q1 inv adj: {quantity1.inventory_adjustment}\")\n", + " print(f\"Q1 inv ass: {quantity1.inventory_asset.name}\")\n", + " print(f\"Q2 type: {quantity2.type}\")\n", + " print(f\"Q2 measure: {quantity2.measure}\")\n", + " print(f\"Q2 value: {quantity2.value}\")\n", + " print(f\"Q2 units: {quantity2.units.name}\")" + ] + }, { "cell_type": "code", "execution_count": null, @@ -158,8 +202,8 @@ " print(f\"quant_measure: {input.quantities[0].measure}\")\n", " print(f\"quant_value: {input.quantities[0].value}\")\n", " print(f\"quant_inventory_adjustment: {input.quantities[0].inventory_adjustment}\")\n", - " print(f\"quant_value: {input.quantities[0].unit_price}\")\n", - "\n", + " #print(f\"quant_value: {input.quantities[0].unit_price}\")\n", + " print(f\"unit_name: {input.quantities[0].units.name}\")\n", " \t\n", "#log Seeding \n", " logs = asset.get_logs_of_type(neo.Log.Seeding)\n", @@ -246,70 +290,214 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "ce30a9db-735e-4174-ad56-0f0079ab04c6", - "metadata": { - "jupyter": { - "source_hidden": true - } - }, - "outputs": [], - "source": [ - "#alle logs von einem Plant in Tabelle\n", - "import neofarm.lib as neo\n", - "import pandas as pd\n", - "from datetime import datetime\n", - "\n", - "if __name__ == \"__main__\":\n", - " asset = neo.Asset.Plant.from_id(\"76f89f82-1238-43bb-b34f-796a92d491a2\")\n", - " \n", - " # Definiere den Pflanzennamen\n", - " PlantName = \"W-Raps Helmacker Plant 24/25\"\n", - " print(f\"PlantName: {PlantName}\")\n", - " \n", - " # Erstelle eine Liste, in der die Log-Daten für die Tabelle gesammelt werden\n", - " data = []\n", - "\n", - " # Funktion, um die Logs zu verarbeiten und zur Tabelle hinzuzufügen\n", - " def process_logs(logs, log_type):\n", - " for log in logs:\n", - " formatted_date = datetime.fromisoformat(log.timestamp).strftime(\"%d.%m.%y %H:%M\")\n", - " equipment_name = log.equipment[0].name if log.equipment else \"\"\n", - " location_name = log.location[0].name if hasattr(log, 'location') and log.location else \"\"\n", - " data.append({\n", - " #\"PlantName\": PlantName,\n", - " \"LogType\": log_type,\n", - " \"Name\": log.name,\n", - " \"Timestamp\": formatted_date,\n", - " \"Equipment\": equipment_name,\n", - " \"Location\": location_name\n", - " })\n", - "\n", - " # Verarbeite die verschiedenen Log-Typen\n", - " process_logs(asset.get_logs_of_type(neo.Log.Maintenance), \"Maintenance\")\n", - " process_logs(asset.get_logs_of_type(neo.Log.Seeding), \"Seeding\")\n", - " process_logs(asset.get_logs_of_type(neo.Log.Input), \"Input\")\n", - " process_logs(asset.get_logs_of_type(neo.Log.Medical), \"Medical\")\n", - " process_logs(asset.get_logs_of_type(neo.Log.Harvest), \"Harvest\")\n", - " process_logs(asset.get_logs_of_type(neo.Log.Sale), \"Sale\")\n", - "\n", - " # Erstelle ein DataFrame aus den gesammelten Daten und zeige es an\n", - " df = pd.DataFrame(data)\n", - " display(df)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "649e4d8e-c3a9-4d5f-9bdf-9427f416fca9", "metadata": { + "collapsed": true, "jupyter": { + "outputs_hidden": true, "source_hidden": true - } + }, + "scrolled": true }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "PlantName: W-Raps Helmacker Plant 24/25\n" + ] + }, + { + "data": { + "text/html": [ + "
| \n", + " | PlantName | \n", + "LogType | \n", + "Name | \n", + "Timestamp | \n", + "Equipment | \n", + "Location | \n", + "QuantType | \n", + "QuantMeasure | \n", + "QuantValue | \n", + "QuantInventoryAdjustment | \n", + "
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", + "W-Raps Helmacker Plant 24/25 | \n", + "Maintenance | \n", + "Scheibeneggen Helmacker Maintenance 24/25 | \n", + "28.07.24 11:34 | \n", + "Scheibenegge Catros | \n", + "None | \n", + "quantity--price | \n", + "time | \n", + "2 | \n", + "None | \n", + "
| 1 | \n", + "W-Raps Helmacker Plant 24/25 | \n", + "Seeding | \n", + "W-Raps Otello KWS Helmacker Seeding 24/25 | \n", + "22.08.24 22:00 | \n", + "Sähmaschine Cataya | \n", + "Helmacker | \n", + "quantity--standard | \n", + "weight | \n", + "50 | \n", + "decrement | \n", + "
| 2 | \n", + "W-Raps Helmacker Plant 24/25 | \n", + "Seeding | \n", + "W-Raps Otello KWS Helmacker Seeding 24/25 | \n", + "22.08.24 22:00 | \n", + "Sähmaschine Cataya | \n", + "Helmacker | \n", + "quantity--standard | \n", + "area | \n", + "3.02 | \n", + "None | \n", + "
| 3 | \n", + "W-Raps Helmacker Plant 24/25 | \n", + "Input | \n", + "Innovert Raps Input 24/25 | \n", + "12.10.24 13:18 | \n", + "Spritze | \n", + "None | \n", + "quantity--standard | \n", + "volume | \n", + "10 | \n", + "decrement | \n", + "
| 4 | \n", + "W-Raps Helmacker Plant 24/25 | \n", + "Input | \n", + "Innovert Raps Input 24/25 | \n", + "03.11.24 23:00 | \n", + "Spritze | \n", + "None | \n", + "quantity--standard | \n", + "volume | \n", + "10 | \n", + "decrement | \n", + "
| 5 | \n", + "W-Raps Helmacker Plant 24/25 | \n", + "Medical | \n", + "Schneckenkorn Medical 24/25 | \n", + "30.08.24 06:42 | \n", + "Schneckenkornstreuer Leinfelder | \n", + "None | \n", + "quantity--standard | \n", + "weight | \n", + "10 | \n", + "decrement | \n", + "
| 6 | \n", + "W-Raps Helmacker Plant 24/25 | \n", + "Harvest | \n", + "W-Raps Helmacker Harvest 24/25 | \n", + "20.10.24 10:11 | \n", + "Mähdrescher Leinfelder | \n", + "None | \n", + "quantity--standard | \n", + "weight | \n", + "5 | \n", + "increment | \n", + "
| 7 | \n", + "W-Raps Helmacker Plant 24/25 | \n", + "Sale | \n", + "W-Raps Sale 24/25 | \n", + "28.10.24 07:54 | \n", + "None | \n", + "None | \n", + "quantity--price | \n", + "weight | \n", + "5 | \n", + "decrement | \n", + "