Making warehouse management system software with python

Keywords: Python Pycharm Back-end Programmer crawler

Making warehouse management system software with python

1: System test run
——Inventory information management system --
|1: add product information
|2: product information report
|3: add shelf position
|4: shelf position report
|5: commodity warehousing management
|6: Commodity issue management
|7: commodity inventory information report
|0: exit
-----
Please select the function menu (0-7):
--------
2: Inventory management system overview
sku: Stock Keeping Unit
This section implements a simple module based inventory management system.
The system uses JSON file to save data.
The product information is designed as a dictionary and the key is sku_id (product ID), value sku_name (product name) and use products.json to realize its persistence.
The shelf position information is also designed as a dictionary, and the key is loc_id (shelf ID), value loc_name (shelf name), and use location.json to realize its persistence.
The commodity inventory information is designed as a list of [sku_id, loc_id], and its persistence is realized by using items.json# Price @ 762459510 get the supporting practical materials of python and crawler for free#
The inventory management system is designed into three module files: data.py, ui.py and main.py.

The inventory management system data.py is responsible for data management

The inventory management system ui.py is responsible for user interface interaction

3: Implementation of data processing module data.py
The inventory management system data.py is responsible for data management
Through the loads() function and dumps() function in Python standard library module JSON, you can read data from JSON files and dump data to JSON files.
Data processing module of inventory management system data.py.

import os
import json #global variable
_products = {} #Dictionary for saving product information: sku_id:sku_name
_locations = {} #Dictionary for storing shelf position: loc_id:loc_name
_items = [] #Save the list of commodity inventory. The element is tuple (sku_id,loc_id) def init():
"""From disk JSON Read data from format file
global _products, _locations, _items
if os.path.exists("products.json"):
f = open("products.json", "r", encoding = 'utf-8')
_products = json.loads(f.read())
f.close()
if os.path.exists("locations.json"):
f = open("locations.json", "r", encoding = 'utf-8′)
_locations = json.loads(f.read())
f.close()
if os.path.exists("items.json"):
f = open("items.json", "r", encoding ='utf-8′)
_items = json.loads(f.read())
f.close() def _save_products():
"""Product information data_products with JSON Save format to disk file
global _products
f = open("products.json", "w", encoding ='utf-8′)
f.write(json.dumps(_products, ensure_ascii = False))
f.close() def _save_locations():
"""Store shelf position data_ locations with JSON Save format to disk text
global _locations
f = open("locations.json", "w", encoding ='utf-8′)
f.write(json.dumps(_locations))
f.close() def _save_items():
"""Put commodity inventory data_ items with JSON Save format to disk file
global _items
f = open("items.json", "w", encoding ='utf-8')
f.write(json.dumps(_items))
f.close() def get_products():
"""Return product information
global _products
return _products def get_locations():
"""Return shelf position information "
global _locations
return _locations def get_items():
"""Return item inventory information
global _items
return _items def add_product(sku_id, sku_name):
"""Add a product sku_ id,sku_name"""
global _products
_products[sku_id] = sku_name
_save_products() def add_location(loc_id, loc_name):
"""Add a shelf position loc_ id, loc_ name"""
global _locations
_locations[loc_id] = loc_name
_save_locations() def add_item(sku_id, loc_id):
"""Stock in a commodity:commodity sku_ id, goods shelves sku_ id"""
global _items
_items.append((sku_id, loc_id))
_save_items() def remove_item(sku_id, loc_id):
"""Issue a commodity:commodity sku_ id,goods shelves sku_ id, return True; If it doesn't exist, return False"""
global _items
for i in range(len(_items)):
if sku_id == _items[i][0] and loc_id == _items[i][1]:
del _items[i]
_save_items()
return True
return False

4: Implementation of user interface interaction module ui.py
The inventory management system ui.py is responsible for user interface interaction
User interface interaction module import data module
Dictionary. items() returns a list of (key, value) pairs of the dictionary
Inventory management system user interface interaction module ui.py

import data def prompt_for_action():
"""Prompt function menu. Return to user input selection
while True:
print('- Inventory information management system——-')
print('| 1: Add product information')
print('| 2: Product information report')
print('| 3: Increase shelf position')
print('| 4: Shelf location report')
print('| 5: Commodity warehousing management')
print('| 6: Commodity ex warehouse management')
print('| 7: Commodity inventory information report')
print('| 0: sign out')
print('-----') choice = input('Please select function menu(0-7):')
if choice == '0': return 'QUIT'
elif choice == '1': return 'ADD_PRODUCT'
elif choice == '2': return 'REPORT_PRODUCTS'
elif choice == '3': return 'ADD_LOCATION'
elif choice == '4': return 'REPORT_LOCATIONS'
elif choice == '5': return 'ADD_ITEM'
elif choice == '6': return 'REMOVE_ITEM'
elif choice == '7': return 'REPORT_ITEMS' def prompt_for_old_sku_id():
"""Prompt the user for a valid product sku_id And return valid products ID, Or return None"""
while True:
sku_id = input("Please enter a product ID:")
if sku_id == "":
return None
elif sku_id not in data.get_products():
print("The product does not exist, please re-enter ")
else:
return sku_id def prompt_for_new_sku_id():
"""Prompt the user for a new product sku_id And return to the new product ID, Or return None"""
while True:
sku_id = input("Please enter a new product ID:")
if sku_id == "":
return None
elif sku_id in data.get_products():
print("This product already exists, please re-enter ")
else:
return sku_id def prompt_for_old_loc_id():
"""Prompt the user to enter a valid shelf position loc_id And return to the effective shelf position ID,Or return None"""
while True:
loc_id = input("Please enter shelf position ID:")
if loc_id == "":
return None
elif loc_id not in data.get_locations():
print("The shelf position does not exist, please re-enter ")
else:
return loc_id def prompt_for_new_loc_id():
"""Prompt the user to enter a new shelf position loc_ id And return, or return None"""
while True:
loc_id = input ("Please enter a new shelf position ID:")
if loc_id == "":
return None
elif loc_id in data.get_locations():
print('This shelf position already exists, please re-enter')
else:
return loc_id def prompt_for_sku_name():
"""Prompt user for product name sku_name And return the product name, or None"""
while True:
sku_name = input("Please enter the product name:")
if sku_name =="":
return None
else:
return sku_name def prompt_for_loc_name():
"""Prompt the user to enter the shelf location name loc_ name And return the shelf location name, or None"""
while True:
loc_name = input("Please enter shelf location name:")
if loc_name == "": return None
else: return loc_name def report_products():
"""Product information report
for (k, v) in data.get_products().items():
print('{0:8} {1}'.format(k, v)) def report_locations():
"""Shelf location report
for (k, v) in data.get_locations().items():
print(' {0:8} {1}'. format(k, v)) def report_items():
"""Inventory information report
for (k, v) in data.get_items():
sku_name = data.get_products()[k]
loc_name = data.get_locations()[v]
print('{0:8} {1}: {2:8} {3}'.format(k, sku_name, v, loc_name))

5: Functional design of inventory management system
After all, we can't escape the four words of adding, deleting, changing and checking

Prompt, prompt
Add product information
Call ui.prompt_for_new__sku_id(), prompting the user to enter a new product ID,
Call ui.prompt_for_sku_name(), prompting the user to enter the product name.
Call data.add_product(sku_id, sku_name) adds a new product.
If the user input is empty, it returns None, that is, do nothing.
Product information report
Call ui.report_products() displays a list of product information.
Increase shelf position
Call ui.prompt_for_new_loc_id(), prompting the user to enter a new shelf position ID,
Call ui.prompt_for_loc_name(), prompting the user to enter the shelf name.
Call data.add_ Add new shelves to location (sku_id, sku_name).
If the user input is empty, it returns None, that is, do nothing.
Shelf location report
Call ui.report_location() displays a list of shelf location information.
Commodity warehousing management
Call ui.prompt_for_old_sku_id(), prompting the user to enter the product ID,
Call ui.prompt_for_old_loc_id(), prompting the user to enter the shelf ID.
Call data.add_item(sku_id, loc_id) to realize commodity warehousing.
If the user input is empty, it returns None, that is, do nothing.
Commodity ex warehouse management
Call ui.prompt_for_old_sku_id(), prompting the user to enter the product ID,
Call ui.prompt_for_old_loc_id(), prompting the user to enter the shelf ID.
Call data.remove_item(sku_id, loc_id) to realize commodity delivery.
If the inventory does not exist, an error is reported. If the user input is empty, it returns None, that is, do nothing.
Commodity inventory information report
Call ui.report_items() displays a list of inventory information.
6: Implementation of main.py
The main module imports data and ui modules.
In main.py, define the main() function. First call data.init() to read data from the disk JSON format file. Then, in the infinite loop, call ui.prompt_. for_ Action () displays the function menu, accepts user input, and realizes the corresponding functions of each module according to the user's function selection. Finally, if your time is not very tight and you want to improve quickly, the most important thing is not afraid of hardship. I suggest you can contact Wei: 762459510. That's really good. Many people make rapid progress and need you to be not afraid of hardship! You can add it and have a look~
Inventory management system main module. PY

"" inventory management system: Based on JS0N ""

import data
import ui def main():
data.init()
while True:
action = ui.prompt_for_action()
if action == 'QUIT':
break
elif action == 'ADD_PRODUCT':
sku_id = ui.prompt_for_new_sku_id()
if sku_id != None:
sku_name = ui.prompt_for_sku_name()
if sku_name != None:
data.add_product(sku_id, sku_name)
elif action == 'REPORT_PRODUCTS':
ui.report_products()
elif action == 'ADD_LOCATION':
loc_id = ui.prompt_for_new_loc_id()
if loc_id != None:
loc_name = ui.prompt_for_loc_name()
if loc_name != None:
data.add_location(loc_id, loc_name)
elif action == 'REPORT_LOCATIONS':
ui.report_locations()
elif action == 'ADD_ITEM':
sku_id = ui.prompt_for_old_sku_id()
if sku_id != None:
loc_id = ui.prompt_for_old_loc_id()
if loc_id != None:
data.add_item(sku_id, loc_id)
elif action == 'REMOVE_ITEM':
sku_id = ui.prompt_for_old_sku_id()
if sku_id != None:
loc_id = ui.prompt_for_old_loc_id()
if loc_id != None:
if not data.remove_item(sku_id, loc_id):
print('The inventory does not exist!')
elif action == 'REPORT_ITEMS':
ui.report_items() if __name__ == "__main__": main()

Posted by wanda46 on Mon, 20 Sep 2021 01:55:45 -0700