python - 协助我的代码 - 自动化仓储库存控制
问题描述
下面的代码是我的一个个人项目。我是初学者,每天都在学习,所以,它并不完美。所以,对于有经验的人来说,有些事情可能是多余的。
问题陈述:自动化仓储库存控制
问题:一旦托盘上的物品数量达到一定数量,如果您请求的数量高于可用数量,它不会向您发送错误消息。它将继续而不是停止并给您一条消息,让您知道您不能这样做或没有足够的产品可用。
""" 这是必须调整的文件。从库存的角度来看。"""
class Product: #Parent of the class Product
def __init__(self, name, width, length, height, weight_of_case, UPC, quantity): #the __init__() is a method. Initializer, constructor.
self.name = name #parameters are the variables attached to the method.
self.width = width
self.length = length
self.height = height
self.weight_of_case = weight_of_case
self.UPC = UPC
self.quantity = quantity
print("Product Created.")
"""
class Toilet_Paper(Product): #This is just to test the inheritance of the value
pass #This would be considered the sibling of the Product class
class Snacks(Product): #This is just to test the inheritance of the value
pass #This would be considered the sibling of the Product class
"""
class New_Product: #Parent of the class New_Product
def __init__(self, new_name, new_width, new_length, new_height, new_weight_of_case, new_UPC, new_quantity):
self.new_name = new_name # parameters are the variables attached to the method.
self.new_width = new_width
self.new_length = new_length
self.new_height = new_height
self.new_weight_of_case = new_weight_of_case
self.new_UPC = new_UPC
self.new_quantity = new_quantity
print("New Product Created.")
"""
class Drinks(New_Product): #This is just to test the inheritance of the value
pass #This would be considered the sibling of the Product class
"""
p = Product(input("Name of Product: "), float(input("Width of case: ")), float(input("Length of case: ")), float(input("Height of case: ")),
float(input("Weight of case: ")), input("Enter UPC: "), input("Enter amount of pieces: ")) #This is how you create a new product.
weight_of_case = p.weight_of_case #This gets the attribute within p.
def casesremaining(total_cases, cases_selected):
return total_cases - cases_selected #if user enters more cases than are available to select, user should get a message saying "you canot select more cases than you have
def totalweight(weight_of_case, total_cases):
return weight_of_case * total_cases
def weight_of_cases_selected(cases_selected, weight_of_case):
return cases_selected * weight_of_case
total_cases = int(input("Enter amount of total cases on pallet: "))
total_weight = totalweight(float(weight_of_case), float(total_cases))
application = 1
yes = "yes"
no = "no"
print("Product added to pallet.")
print("Total weight of pallet is: {:.2f}.".format(total_weight))
print("Total amount of cases on a pallet is: ", total_cases)
while application == 1: #Could use "for cases in pallet():"
case_selection = (input("Do you want to select a case? yes/no: "))
if case_selection == yes:
select = int(input("How many cases would you like to select? "))
cases_selected = select
total_weight_of_cases_selected = weight_of_cases_selected(float(cases_selected), float(weight_of_case))
def remainingweight(total_weight, total_weight_of_cases_selected):
return total_weight - total_weight_of_cases_selected
remaining_weight = remainingweight(float(total_weight), float(total_weight_of_cases_selected))
if cases_selected == select:
total_cases_remaining = casesremaining(int(total_cases), int(cases_selected))
total_cases = total_cases_remaining #Forgot to update the original variable from input.
total_weight = remaining_weight #Same here. Remember to update variables as the program goes.
print("Total weight now is: {:.2f}".format(remaining_weight))
print("You know have ", total_cases_remaining, " cases remaining.")
#work on this
if cases_selected > total_cases: # new 10/25/2020 #Continue to check this. Not working
print("You cannot select more than what is available on the pallet.")
print("You need to order more.") #make a def or modify the actual def already in place.
yes = "yes" or "y" or "Yes"
no = "no" or "n" or "No"
order_more = input("Would you like to order more? yes/no")
continue
if total_cases == 0: #new part 10/1/2020
print("Your total amount of cases on the pallet is ", total_cases_remaining, ".")
print("You have no more cases on the pallet.")
no = "no"
add = "add"
change = "change"
add_cases = input("Would you like to add more cases on the pallet, or change product? (add/change/no) ")
if add_cases == add:
cases_to_add = int(input("How many cases would you like to add? "))
total_cases = cases_to_add+total_cases_remaining
total_weight = weight_of_case * cases_to_add
print("You have added to your pallet, ", cases_to_add, " more cases.")
print("Your total cases on pallet now is: ", total_cases, ".")
print("Your total weight of pallet now is: {:.2f}.".format(total_weight))
elif add_cases == change: #added on 10/12/2020 - May not work.
new_p = New_Product(input("Name of Product: "), float(input("Width of case: ")), float(input("Length of case: ")), float(input("Height of case: ")),
float(input("Weight of case: ")), input("Enter UPC: "), input("Enter amount of pieces: "))
weight_of_case = new_p.new_weight_of_case # This gets the attribute within p.
total_cases = int(input("Enter amount of total cases on pallet: ")) # problem is not changing the value after input.
total_weight = totalweight(float(weight_of_case), float(total_cases))
print("New Product added to pallet.")
print("Total weight of pallet is: {:.2f}.".format(total_weight))
print("Total amount of cases on a pallet is: ", total_cases)
continue
else:
if add_cases == no:
print("Thank you for using our application.")
break
else:
if case_selection == no or application == 0:
print("Thank you for using our application.")
break
#add 选项以添加更多产品。#添加通过str(string) range 4: 拉取UPC最后4个的功能。#即通过匹配UPC的最后4个来更容易更快地识别大小写。
""" "还加上每次更改发生的时间和日期。" "应用程序根据每个个案的权重计算个案总数。“应用程序根据重量识别每个托盘的不同数量的箱子。”也许您可以添加尺寸以指定不同类型的产品? “您可以输入产品ID。”您可以添加UPC。"您可以在哪里或使用什么来保存多个值(多个位置保存箱子),以便应用程序可以继续跟踪库存?\n", """
解决方案
推荐阅读
- mysql - 从多个表中的字段创建摘要视图
- javascript - 按下按钮没有记录任何东西AngularJS
- spring-boot - 有没有推荐的方法来让 Spring Boot 使用 logback 转换为 JSON 格式的日志
- python - 如何将函数连接到主线程外的 PyQt 信号
- swift - Watchkit 下一页防止按钮执行转场。
- c# - 在 UWP 中对多行文本框使用 SHIFT + ENTER
- xamarin - AVCaptureMetadataOutputObjectsDelegate、DidOutputMetadataObjects 并不总是被调用
- javascript - 浏览器关闭时,反应网络应用程序中的计时器在移动设备中不起作用
- coldfusion - 在 Lucee 中产生 perlin 噪声的最简单方法是什么?
- struct - structAppend 与重复