|
@@ -14,6 +14,7 @@ class LocationModel(models.Model):
|
|
|
('M1', '通道区'), # 通道区
|
|
|
('E1', '提升机'), # 提升机
|
|
|
('C1', '输送机'), # 输送机
|
|
|
+ ('B1', '充电桩'), # 货架区
|
|
|
)
|
|
|
LOCATION_STATUS = (
|
|
|
('available', '可用'),
|
|
@@ -33,7 +34,8 @@ class LocationModel(models.Model):
|
|
|
update_time = models.DateTimeField(auto_now=True, blank=True, null=True, verbose_name="Update Time")
|
|
|
empty_label = models.BooleanField(default=True, verbose_name="Empty Flag")
|
|
|
|
|
|
- location_code = models.CharField(max_length=20, unique=True, verbose_name='库位编码')
|
|
|
+ location_code = models.CharField(max_length=20, unique=True, verbose_name='库位编码')
|
|
|
+ location_group = models.CharField(max_length=20, verbose_name='库位组')
|
|
|
# 示例:T1-L1C001-1
|
|
|
# T1-L1C001-1 代表货位类型为T1,层号为1,列号为001,货位号为1
|
|
|
location_type = models.CharField(max_length=3, choices=LOCATION_TYPES, verbose_name='货位类型')
|
|
@@ -77,12 +79,132 @@ class LocationModel(models.Model):
|
|
|
cls.objects.filter(warehouse_code=warehouse_code).delete()
|
|
|
"""根据规划图生成库位"""
|
|
|
# 定义核心参数(根据规划图调整)
|
|
|
- MAIN_AISLES = [18, 29] # 子通道列号
|
|
|
+ MAIN_AISLES = [18, 1] # 子通道列号
|
|
|
SUB_AISLES = [2,8, 13] # 主通道行号
|
|
|
-
|
|
|
-
|
|
|
+ for row in range(1, 14): # 1-13行
|
|
|
+ for col in range(1, 3): # 1-19列
|
|
|
+ for layer in range(1, 4): # 1-3层
|
|
|
+ # 判断通道区
|
|
|
+ if col in MAIN_AISLES or row in SUB_AISLES:
|
|
|
+ loc_type = 'M1'
|
|
|
+ c_number = row
|
|
|
+ # 通道
|
|
|
+
|
|
|
+ if col ==1 and row == 1:
|
|
|
+ loc_type = 'T1'
|
|
|
+ c_number = 1
|
|
|
+
|
|
|
+ # 判断货位类型(根据实际规划)
|
|
|
+
|
|
|
+ else:
|
|
|
+ if row <2:
|
|
|
+ loc_type = 'T1'
|
|
|
+ c_number = 1
|
|
|
+ elif row < 8:
|
|
|
+ loc_type = 'T5'
|
|
|
+ c_number = row-2
|
|
|
+ elif row < 13:
|
|
|
+ loc_type = 'T4'
|
|
|
+ c_number = row-8
|
|
|
+ else:
|
|
|
+ loc_type = 'T2'
|
|
|
+ c_number = 16-row
|
|
|
+ # 生成唯一编码
|
|
|
+ location_code = f"{loc_type}-L{layer}C{col:03d}-{c_number:02d}"
|
|
|
+ location_group = f"{loc_type}-L{layer}C{col:03d}"
|
|
|
+ # print(f"生成库位:{location_code}-{row}-{col}-{layer}")
|
|
|
+
|
|
|
+ # 创建库位
|
|
|
+ cls.objects.update_or_create(
|
|
|
+ warehouse_code=warehouse_code,
|
|
|
+ row=row,
|
|
|
+ col=col,
|
|
|
+ layer=layer,
|
|
|
+ c_number=c_number,
|
|
|
+ shelf_type=loc_type,
|
|
|
+ defaults={
|
|
|
+ 'location_code': location_code,
|
|
|
+ 'location_group': location_group,
|
|
|
+ 'location_type': loc_type,
|
|
|
+ 'max_capacity': {
|
|
|
+ 'T5': 5,
|
|
|
+ 'T4': 4,
|
|
|
+ 'T2': 2,
|
|
|
+ 'T1': 1,
|
|
|
+ 'M1': 0,
|
|
|
+ 'E1': 0,
|
|
|
+ 'C1': 0
|
|
|
+ }[loc_type],
|
|
|
+ 'coordinate': f"{row}-{col}-{layer}",
|
|
|
+ 'is_active': True
|
|
|
+ },
|
|
|
+ access_priority=c_number
|
|
|
+ )
|
|
|
for row in range(1, 16): # 1-15行
|
|
|
- for col in range(1, 19): # 1-19列
|
|
|
+ for col in range(3, 17): # 1-16列
|
|
|
+ for layer in range(1, 4): # 1-3层
|
|
|
+ # 判断通道区
|
|
|
+ if col in MAIN_AISLES or row in SUB_AISLES:
|
|
|
+ loc_type = 'M1'
|
|
|
+ c_number = row
|
|
|
+ # 通道
|
|
|
+
|
|
|
+ if col ==18 and row == 1:
|
|
|
+ loc_type = 'T1'
|
|
|
+ c_number = 1
|
|
|
+
|
|
|
+ # 判断货位类型(根据实际规划)
|
|
|
+
|
|
|
+ else:
|
|
|
+ if row <2:
|
|
|
+ loc_type = 'T1'
|
|
|
+ c_number = 1
|
|
|
+ elif row < 8:
|
|
|
+ loc_type = 'T5'
|
|
|
+ c_number = row-2
|
|
|
+ elif row < 13:
|
|
|
+ loc_type = 'T4'
|
|
|
+ c_number = row-8
|
|
|
+ else:
|
|
|
+ loc_type = 'T2'
|
|
|
+ c_number = 16-row
|
|
|
+
|
|
|
+ # 生成唯一编码
|
|
|
+ location_code = f"{loc_type}-L{layer}C{col:03d}-{c_number:02d}"
|
|
|
+ location_group = f"{loc_type}-L{layer}C{col:03d}"
|
|
|
+
|
|
|
+ # print(f"生成库位:{location_code}-{row}-{col}-{layer}")
|
|
|
+
|
|
|
+ # 创建库位
|
|
|
+ cls.objects.update_or_create(
|
|
|
+ warehouse_code=warehouse_code,
|
|
|
+ row=row,
|
|
|
+ col=col,
|
|
|
+ layer=layer,
|
|
|
+ c_number=c_number,
|
|
|
+ shelf_type=loc_type,
|
|
|
+ defaults={
|
|
|
+ 'location_code': location_code,
|
|
|
+ 'location_group': location_group,
|
|
|
+
|
|
|
+ 'location_type': loc_type,
|
|
|
+ 'max_capacity': {
|
|
|
+ 'T5': 5,
|
|
|
+ 'T4': 4,
|
|
|
+ 'T2': 2,
|
|
|
+ 'T1': 1,
|
|
|
+ 'M1': 0,
|
|
|
+ 'E1': 0,
|
|
|
+ 'C1': 0
|
|
|
+ }[loc_type],
|
|
|
+ 'coordinate': f"{row}-{col}-{layer}",
|
|
|
+ 'is_active': True
|
|
|
+ },
|
|
|
+ access_priority=c_number
|
|
|
+ )
|
|
|
+ # print("✅ 库位生成成功!")
|
|
|
+ for row in range(1, 14): # 1-15行
|
|
|
+ for col in range(17, 20): # 1-16列
|
|
|
for layer in range(1, 4): # 1-3层
|
|
|
# 判断通道区
|
|
|
if col in MAIN_AISLES or row in SUB_AISLES:
|
|
@@ -112,6 +234,7 @@ class LocationModel(models.Model):
|
|
|
|
|
|
# 生成唯一编码
|
|
|
location_code = f"{loc_type}-L{layer}C{col:03d}-{c_number:02d}"
|
|
|
+ location_group = f"{loc_type}-L{layer}C{col:03d}"
|
|
|
# print(f"生成库位:{location_code}-{row}-{col}-{layer}")
|
|
|
|
|
|
# 创建库位
|
|
@@ -124,6 +247,8 @@ class LocationModel(models.Model):
|
|
|
shelf_type=loc_type,
|
|
|
defaults={
|
|
|
'location_code': location_code,
|
|
|
+ 'location_group': location_group,
|
|
|
+
|
|
|
'location_type': loc_type,
|
|
|
'max_capacity': {
|
|
|
'T5': 5,
|
|
@@ -139,9 +264,9 @@ class LocationModel(models.Model):
|
|
|
},
|
|
|
access_priority=c_number
|
|
|
)
|
|
|
- # print("✅ 库位生成成功!")
|
|
|
+ # print("✅ 库位生成成功!")
|
|
|
for row in range(1, 18): # 1-17行
|
|
|
- for col in range(19, 30): # 19-29列
|
|
|
+ for col in range(20, 30): # 19-29列
|
|
|
for layer in range(1, 4): # 1-3层
|
|
|
# 判断通道区
|
|
|
if col in MAIN_AISLES or row in SUB_AISLES:
|
|
@@ -187,14 +312,57 @@ class LocationModel(models.Model):
|
|
|
loc_type = 'S4'
|
|
|
c_number = 18-row
|
|
|
|
|
|
+
|
|
|
+
|
|
|
# 生成唯一编码
|
|
|
location_code = f"{loc_type}-L{layer}C{col:03d}-{c_number:02d}"
|
|
|
+ location_group = f"{loc_type}-L{layer}C{col:03d}"
|
|
|
+ # print(f"生成库位:{location_code}-{row}-{col}-{layer}")
|
|
|
|
|
|
- # 生成唯一编码
|
|
|
+ # 创建库位
|
|
|
+ cls.objects.update_or_create(
|
|
|
+ warehouse_code=warehouse_code,
|
|
|
+ row=row,
|
|
|
+ col=col,
|
|
|
+ layer=layer,
|
|
|
+ c_number=c_number,
|
|
|
+ shelf_type=loc_type,
|
|
|
+ defaults={
|
|
|
+ 'location_code': location_code,
|
|
|
+ 'location_group': location_group,
|
|
|
+
|
|
|
+ 'location_type': loc_type,
|
|
|
+ 'max_capacity': {
|
|
|
+ 'T5': 5,
|
|
|
+ 'T4': 4,
|
|
|
+ 'S4': 4,
|
|
|
+ 'T2': 2,
|
|
|
+ 'T1': 1,
|
|
|
+ 'M1': 0,
|
|
|
+ 'E1': 0,
|
|
|
+ 'C1': 0,
|
|
|
+ 'B1': 0
|
|
|
+ }[loc_type],
|
|
|
+ 'coordinate': f"{row}-{col}-{layer}",
|
|
|
+ 'is_active': True
|
|
|
+ },
|
|
|
+ access_priority=c_number
|
|
|
+ )
|
|
|
+
|
|
|
+ # 输送机
|
|
|
+ for row in [14]: # 1-17行
|
|
|
+ for col in [1,18]: # 1-19列
|
|
|
+ for layer in range(1, 4): # 1-3层
|
|
|
+ # 判断货位类型(根据实际规划)
|
|
|
+ loc_type = 'C1'
|
|
|
+ c_number = 1
|
|
|
location_code = f"{loc_type}-L{layer}C{col:03d}-{c_number:02d}"
|
|
|
+ location_group = f"{loc_type}-L{layer}C{col:03d}"
|
|
|
+
|
|
|
# print(f"生成库位:{location_code}-{row}-{col}-{layer}")
|
|
|
|
|
|
# 创建库位
|
|
|
+ # 创建库位
|
|
|
cls.objects.update_or_create(
|
|
|
warehouse_code=warehouse_code,
|
|
|
row=row,
|
|
@@ -204,6 +372,8 @@ class LocationModel(models.Model):
|
|
|
shelf_type=loc_type,
|
|
|
defaults={
|
|
|
'location_code': location_code,
|
|
|
+ 'location_group': location_group,
|
|
|
+
|
|
|
'location_type': loc_type,
|
|
|
'max_capacity': {
|
|
|
'T5': 5,
|
|
@@ -213,14 +383,440 @@ class LocationModel(models.Model):
|
|
|
'T1': 1,
|
|
|
'M1': 0,
|
|
|
'E1': 0,
|
|
|
- 'C1': 0
|
|
|
+ 'C1': 0,
|
|
|
+ 'B1': 0
|
|
|
+ }[loc_type],
|
|
|
+ 'coordinate': f"{row}-{col}-{layer}",
|
|
|
+ 'is_active': True
|
|
|
+ },
|
|
|
+ access_priority=c_number
|
|
|
+ )
|
|
|
+ for row in [16]: # 1-17行
|
|
|
+ for col in [1,18]: # 1-19列
|
|
|
+ for layer in [1]: # 1-3层
|
|
|
+ # 判断货位类型(根据实际规划)
|
|
|
+ loc_type = 'C1'
|
|
|
+ c_number = row
|
|
|
+ location_code = f"{loc_type}-L{layer}C{col:03d}-{c_number:02d}"
|
|
|
+ location_group = f"{loc_type}-L{layer}C{col:03d}"
|
|
|
+
|
|
|
+ # 创建库位
|
|
|
+ cls.objects.update_or_create(
|
|
|
+ warehouse_code=warehouse_code,
|
|
|
+ row=row,
|
|
|
+ col=col,
|
|
|
+ layer=layer,
|
|
|
+ c_number=c_number,
|
|
|
+ shelf_type=loc_type,
|
|
|
+ defaults={
|
|
|
+ 'location_code': location_code,
|
|
|
+ 'location_group': location_group,
|
|
|
+
|
|
|
+ 'location_type': loc_type,
|
|
|
+ 'max_capacity': {
|
|
|
+ 'T5': 5,
|
|
|
+ 'T4': 4,
|
|
|
+ 'S4': 4,
|
|
|
+ 'T2': 2,
|
|
|
+ 'T1': 1,
|
|
|
+ 'M1': 0,
|
|
|
+ 'E1': 0,
|
|
|
+ 'C1': 0,
|
|
|
+ 'B1': 0
|
|
|
}[loc_type],
|
|
|
'coordinate': f"{row}-{col}-{layer}",
|
|
|
'is_active': True
|
|
|
},
|
|
|
access_priority=c_number
|
|
|
)
|
|
|
+ # 提升机
|
|
|
+ for row in [15]: # 1-17行
|
|
|
+ for col in [1,18]: # 1-19列
|
|
|
+ for layer in range(1, 4): # 1-3层
|
|
|
+ # 判断货位类型(根据实际规划)
|
|
|
+ loc_type = 'E1'
|
|
|
+ c_number = row
|
|
|
+ location_code = f"{loc_type}-L{layer}C{col:03d}-{c_number:02d}"
|
|
|
+ location_group = f"{loc_type}-L{layer}C{col:03d}"
|
|
|
+ # 创建库位
|
|
|
+ cls.objects.update_or_create(
|
|
|
+ warehouse_code=warehouse_code,
|
|
|
+ row=row,
|
|
|
+ col=col,
|
|
|
+ layer=layer,
|
|
|
+ c_number=c_number,
|
|
|
+ shelf_type=loc_type,
|
|
|
+ defaults={
|
|
|
+ 'location_code': location_code,
|
|
|
+ 'location_group': location_group,
|
|
|
|
|
|
+ 'location_type': loc_type,
|
|
|
+ 'max_capacity': {
|
|
|
+ 'T5': 5,
|
|
|
+ 'T4': 4,
|
|
|
+ 'S4': 4,
|
|
|
+ 'T2': 2,
|
|
|
+ 'T1': 1,
|
|
|
+ 'M1': 0,
|
|
|
+ 'E1': 0,
|
|
|
+ 'C1': 0,
|
|
|
+ 'B1': 0
|
|
|
+ }[loc_type],
|
|
|
+ 'coordinate': f"{row}-{col}-{layer}",
|
|
|
+ 'is_active': True
|
|
|
+ },
|
|
|
+ access_priority=c_number
|
|
|
+ )
|
|
|
+ # 充电桩
|
|
|
+ for row in [14]: # 1-17行
|
|
|
+ for col in [2]: # 1-19列
|
|
|
+ for layer in range(1, 3): # 1-3层
|
|
|
+ # 判断货位类型(根据实际规划)
|
|
|
+ loc_type = 'B1'
|
|
|
+ c_number = 1
|
|
|
+ location_code = f"{loc_type}-L{layer}C{col:03d}-{c_number:02d}"
|
|
|
+ location_group = f"{loc_type}-L{layer}C{col:03d}"
|
|
|
+
|
|
|
+ # 创建库位
|
|
|
+ cls.objects.update_or_create(
|
|
|
+ warehouse_code=warehouse_code,
|
|
|
+ row=row,
|
|
|
+ col=col,
|
|
|
+ layer=layer,
|
|
|
+ c_number=c_number,
|
|
|
+ shelf_type=loc_type,
|
|
|
+ defaults={
|
|
|
+ 'location_code': location_code,
|
|
|
+ 'location_group': location_group,
|
|
|
+
|
|
|
+ 'location_type': loc_type,
|
|
|
+ 'max_capacity': {
|
|
|
+ 'T5': 5,
|
|
|
+ 'T4': 4,
|
|
|
+ 'S4': 4,
|
|
|
+ 'T2': 2,
|
|
|
+ 'T1': 1,
|
|
|
+ 'M1': 0,
|
|
|
+ 'E1': 0,
|
|
|
+ 'C1': 0,
|
|
|
+ 'B1': 0
|
|
|
+ }[loc_type],
|
|
|
+ 'coordinate': f"{row}-{col}-{layer}",
|
|
|
+ 'is_active': True
|
|
|
+ },
|
|
|
+ access_priority=c_number
|
|
|
+ )
|
|
|
+
|
|
|
+
|
|
|
+class LocationGroupModel(models.Model):
|
|
|
+ LOCATION_TYPES = (
|
|
|
+ ('T5', '5货位'), # 5托盘/批次
|
|
|
+ ('T4', '4货位'), # 4托盘/批次
|
|
|
+ ('S4', '4单货位'), # 4单托盘
|
|
|
+ ('T2', '2货位'), # 2托盘/批次
|
|
|
+ ('T1', '散货位'), # 1托盘
|
|
|
+ )
|
|
|
+ LOCATION_STATUS = (
|
|
|
+ ('available', '可用'),
|
|
|
+ ('occupied', '占用'),
|
|
|
+ ('disabled', '禁用'),
|
|
|
+ ('reserved', '预留'),
|
|
|
+ ('maintenance', '维护中'),
|
|
|
+ )
|
|
|
+ warehouse_code = models.CharField(max_length=50, verbose_name='仓库编码')
|
|
|
+ group_name = models.CharField(max_length=50, verbose_name='库位组名称')
|
|
|
+ group_type = models.CharField(max_length=50, choices=LOCATION_TYPES, verbose_name='库位组类型')
|
|
|
+ group_code = models.CharField(max_length=50, verbose_name='库位组编码')
|
|
|
+ location_items = models.ManyToManyField(LocationModel, verbose_name='库位')
|
|
|
+ status = models.CharField(max_length=20, choices=LOCATION_STATUS, default='available', verbose_name='库位状态')
|
|
|
+ max_capacity = models.PositiveIntegerField(verbose_name='最大容量') # 根据类型自动设置
|
|
|
+ current_quantity = models.PositiveIntegerField(default=0, verbose_name='当前托盘数')
|
|
|
+ current_goods_quantity = models.PositiveIntegerField(default=0, verbose_name='当前货物数')
|
|
|
+ current_batch = models.CharField(max_length=50, default='', verbose_name='当前批次')
|
|
|
+ current_goods_code = models.CharField(max_length=50, default='', verbose_name='当前货物编码')
|
|
|
+ # create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
|
|
|
+ class Meta:
|
|
|
+ db_table = 'location_group'
|
|
|
+ verbose_name = 'Location Group'
|
|
|
+ verbose_name_plural = "Location Group"
|
|
|
+ ordering = ['-id']
|
|
|
+ unique_together = ( 'warehouse_code', 'group_code') # 防止重复组编码
|
|
|
+ @classmethod
|
|
|
+ def generate_group(cls,warehouse_code):
|
|
|
+ cls.objects.filter(warehouse_code=warehouse_code).delete()
|
|
|
+ MAIN_AISLES = [18, 1] # 子通道列号
|
|
|
+ SUB_AISLES = [2,8, 13] # 主通道行号
|
|
|
+ for row in range(1, 14): # 1-13行
|
|
|
+ for col in range(1, 3): # 1-19列
|
|
|
+ for layer in range(1, 4): # 1-3层
|
|
|
+ # 判断通道区
|
|
|
+ if col in MAIN_AISLES or row in SUB_AISLES:
|
|
|
+ loc_type = 'M1'
|
|
|
+ c_number = row
|
|
|
+ # 通道
|
|
|
+
|
|
|
+ if col ==1 and row == 1:
|
|
|
+ loc_type = 'T1'
|
|
|
+ c_number = 1
|
|
|
+
|
|
|
+ # 判断货位类型(根据实际规划)
|
|
|
+
|
|
|
+ else:
|
|
|
+ if row <2:
|
|
|
+ loc_type = 'T1'
|
|
|
+ c_number = 1
|
|
|
+ elif row < 8:
|
|
|
+ loc_type = 'T5'
|
|
|
+ c_number = row-2
|
|
|
+ elif row < 13:
|
|
|
+ loc_type = 'T4'
|
|
|
+ c_number = row-8
|
|
|
+ else:
|
|
|
+ loc_type = 'T2'
|
|
|
+ c_number = 16-row
|
|
|
+ # 生成唯一编码
|
|
|
+ print(f"生成库组:{row}-{col}-{layer}")
|
|
|
+ if loc_type == 'M1':
|
|
|
+ continue
|
|
|
+ # 创建库位
|
|
|
+ group_code = f"{loc_type}-L{layer}C{col:03d}"
|
|
|
+ group_name = f"{loc_type}-L{layer}C{col:03d}"
|
|
|
+
|
|
|
+ if cls.objects.filter(warehouse_code=warehouse_code, group_code=group_code).exists():
|
|
|
+ group_item = cls.objects.get(warehouse_code=warehouse_code, group_code=group_code)
|
|
|
+ group_item.location_items.add(LocationModel.objects.get(warehouse_code=warehouse_code, row=row, col=col, layer=layer))
|
|
|
+ group_item.save()
|
|
|
+ else:
|
|
|
+ group_item = cls.objects.create(
|
|
|
+ warehouse_code=warehouse_code,
|
|
|
+ group_name=group_name,
|
|
|
+ group_type=loc_type,
|
|
|
+ group_code=group_code,
|
|
|
+ max_capacity={
|
|
|
+ 'T5': 5,
|
|
|
+ 'T4': 4,
|
|
|
+ 'T2': 2,
|
|
|
+ 'T1': 1,
|
|
|
+ 'S4': 4,
|
|
|
+
|
|
|
+ 'M1': 0,
|
|
|
+ 'E1': 0,
|
|
|
+ 'C1': 0
|
|
|
+ }[loc_type],
|
|
|
+ current_quantity=0,
|
|
|
+ status='available'
|
|
|
+ )
|
|
|
+ group_item.location_items.add(LocationModel.objects.get(warehouse_code=warehouse_code, row=row, col=col, layer=layer))
|
|
|
+ group_item.save()
|
|
|
+
|
|
|
+ for row in range(1, 16): # 1-15行
|
|
|
+ for col in range(3, 17): # 1-16列
|
|
|
+ for layer in range(1, 4): # 1-3层
|
|
|
+ # 判断通道区
|
|
|
+ if col in MAIN_AISLES or row in SUB_AISLES:
|
|
|
+ loc_type = 'M1'
|
|
|
+ c_number = row
|
|
|
+ # 通道
|
|
|
+
|
|
|
+ if col ==18 and row == 1:
|
|
|
+ loc_type = 'T1'
|
|
|
+ c_number = 1
|
|
|
+
|
|
|
+ # 判断货位类型(根据实际规划)
|
|
|
+
|
|
|
+ else:
|
|
|
+ if row <2:
|
|
|
+ loc_type = 'T1'
|
|
|
+ c_number = 1
|
|
|
+ elif row < 8:
|
|
|
+ loc_type = 'T5'
|
|
|
+ c_number = row-2
|
|
|
+ elif row < 13:
|
|
|
+ loc_type = 'T4'
|
|
|
+ c_number = row-8
|
|
|
+ else:
|
|
|
+ loc_type = 'T2'
|
|
|
+ c_number = 16-row
|
|
|
+ # print(f"生成库位:{location_code}-{row}-{col}-{layer}")
|
|
|
+ if loc_type == 'M1':
|
|
|
+ continue
|
|
|
+ # 创建库位
|
|
|
+ group_code = f"{loc_type}-L{layer}C{col:03d}"
|
|
|
+ group_name = f"{loc_type}-L{layer}C{col:03d}"
|
|
|
+
|
|
|
+ if cls.objects.filter(warehouse_code=warehouse_code, group_code=group_code).exists():
|
|
|
+ group_item = cls.objects.get(warehouse_code=warehouse_code, group_code=group_code)
|
|
|
+ group_item.location_items.add(LocationModel.objects.get(warehouse_code=warehouse_code, row=row, col=col, layer=layer))
|
|
|
+ group_item.save()
|
|
|
+ else:
|
|
|
+ group_item = cls.objects.create(
|
|
|
+ warehouse_code=warehouse_code,
|
|
|
+ group_name=group_name,
|
|
|
+ group_type=loc_type,
|
|
|
+ group_code=group_code,
|
|
|
+ max_capacity={
|
|
|
+ 'T5': 5,
|
|
|
+ 'T4': 4,
|
|
|
+ 'T2': 2,
|
|
|
+ 'T1': 1,
|
|
|
+ 'S4': 4,
|
|
|
+ 'M1': 0,
|
|
|
+ 'E1': 0,
|
|
|
+ 'C1': 0
|
|
|
+ }[loc_type],
|
|
|
+ current_quantity=0,
|
|
|
+ status='available'
|
|
|
+ )
|
|
|
+ group_item.location_items.add(LocationModel.objects.get(warehouse_code=warehouse_code, row=row, col=col, layer=layer))
|
|
|
+ group_item.save()
|
|
|
+
|
|
|
+
|
|
|
+ for row in range(1, 14): # 1-15行
|
|
|
+ for col in range(17, 20): # 1-16列
|
|
|
+ for layer in range(1, 4): # 1-3层
|
|
|
+ # 判断通道区
|
|
|
+ if col in MAIN_AISLES or row in SUB_AISLES:
|
|
|
+ loc_type = 'M1'
|
|
|
+ c_number = row
|
|
|
+ # 通道
|
|
|
+
|
|
|
+ if col ==18 and row == 1:
|
|
|
+ loc_type = 'T1'
|
|
|
+ c_number = 1
|
|
|
+
|
|
|
+ # 判断货位类型(根据实际规划)
|
|
|
+
|
|
|
+ else:
|
|
|
+ if row <2:
|
|
|
+ loc_type = 'T1'
|
|
|
+ c_number = 1
|
|
|
+ elif row < 8:
|
|
|
+ loc_type = 'T5'
|
|
|
+ c_number = row-2
|
|
|
+ elif row < 13:
|
|
|
+ loc_type = 'T4'
|
|
|
+ c_number = row-8
|
|
|
+ else:
|
|
|
+ loc_type = 'T2'
|
|
|
+ c_number = 16-row
|
|
|
+
|
|
|
+ # print(f"生成库位:{location_code}-{row}-{col}-{layer}")
|
|
|
+ if loc_type == 'M1':
|
|
|
+ continue
|
|
|
+ # 创建库位
|
|
|
+ group_code = f"{loc_type}-L{layer}C{col:03d}"
|
|
|
+ group_name = f"{loc_type}-L{layer}C{col:03d}"
|
|
|
+
|
|
|
+ if cls.objects.filter(warehouse_code=warehouse_code, group_code=group_code).exists():
|
|
|
+ group_item = cls.objects.get(warehouse_code=warehouse_code, group_code=group_code)
|
|
|
+ group_item.location_items.add(LocationModel.objects.get(warehouse_code=warehouse_code, row=row, col=col, layer=layer))
|
|
|
+ group_item.save()
|
|
|
+ else:
|
|
|
+ group_item = cls.objects.create(
|
|
|
+ warehouse_code=warehouse_code,
|
|
|
+ group_name=group_name,
|
|
|
+ group_type=loc_type,
|
|
|
+ group_code=group_code,
|
|
|
+ max_capacity={
|
|
|
+ 'T5': 5,
|
|
|
+ 'T4': 4,
|
|
|
+ 'T2': 2,
|
|
|
+ 'T1': 1,
|
|
|
+ 'S4': 4,
|
|
|
+ 'M1': 0,
|
|
|
+ 'E1': 0,
|
|
|
+ 'C1': 0
|
|
|
+ }[loc_type],
|
|
|
+ current_quantity=0,
|
|
|
+ status='available'
|
|
|
+ )
|
|
|
+ group_item.location_items.add(LocationModel.objects.get(warehouse_code=warehouse_code, row=row, col=col, layer=layer))
|
|
|
+ group_item.save()
|
|
|
+
|
|
|
+ for row in range(1, 18): # 1-17行
|
|
|
+ for col in range(20, 30): # 19-29列
|
|
|
+ for layer in range(1, 4): # 1-3层
|
|
|
+ # 判断通道区
|
|
|
+ if col in MAIN_AISLES or row in SUB_AISLES:
|
|
|
+ loc_type = 'M1'
|
|
|
+ c_number = row
|
|
|
+ # 通道
|
|
|
+
|
|
|
+ if col ==18 and row == 1:
|
|
|
+ loc_type = 'T1'
|
|
|
+ c_number = 1
|
|
|
+ if col ==29 and row == 1:
|
|
|
+ loc_type = 'T1'
|
|
|
+ c_number = 1
|
|
|
+ if col ==29 and row == 14:
|
|
|
+ loc_type = 'S4'
|
|
|
+ c_number = 4
|
|
|
+ if col ==29 and row == 15:
|
|
|
+ loc_type = 'S4'
|
|
|
+ c_number = 3
|
|
|
+ if col ==29 and row == 16:
|
|
|
+ loc_type = 'S4'
|
|
|
+ c_number = 2
|
|
|
+ if col ==29 and row == 17:
|
|
|
+ loc_type = 'S4'
|
|
|
+ c_number = 1
|
|
|
+
|
|
|
+
|
|
|
+ # 判断货位类型(根据实际规划)
|
|
|
+
|
|
|
+ else:
|
|
|
+ # 判断货位类型(根据实际规划)
|
|
|
+ if row < 2:
|
|
|
+ loc_type = 'T1'
|
|
|
+ c_number = row
|
|
|
+
|
|
|
+ elif row < 8:
|
|
|
+ loc_type = 'T5'
|
|
|
+ c_number = row-2
|
|
|
+ elif row < 13:
|
|
|
+ loc_type = 'T4'
|
|
|
+ c_number = row-8
|
|
|
+ else:
|
|
|
+ loc_type = 'S4'
|
|
|
+ c_number = 18-row
|
|
|
+
|
|
|
+ # print(f"生成库位:{location_code}-{row}-{col}-{layer}")
|
|
|
+ if loc_type == 'M1':
|
|
|
+ continue
|
|
|
+ # 创建库位
|
|
|
+ group_code = f"{loc_type}-L{layer}C{col:03d}"
|
|
|
+ group_name = f"{loc_type}-L{layer}C{col:03d}"
|
|
|
+
|
|
|
+ if cls.objects.filter(warehouse_code=warehouse_code, group_code=group_code).exists():
|
|
|
+ group_item = cls.objects.get(warehouse_code=warehouse_code, group_code=group_code)
|
|
|
+ group_item.location_items.add(LocationModel.objects.get(warehouse_code=warehouse_code, row=row, col=col, layer=layer))
|
|
|
+ group_item.save()
|
|
|
+ else:
|
|
|
+ group_item = cls.objects.create(
|
|
|
+ warehouse_code=warehouse_code,
|
|
|
+ group_name=group_name,
|
|
|
+ group_type=loc_type,
|
|
|
+ group_code=group_code,
|
|
|
+ max_capacity={
|
|
|
+ 'T5': 5,
|
|
|
+ 'T4': 4,
|
|
|
+ 'T2': 2,
|
|
|
+ 'T1': 1,
|
|
|
+ 'S4': 4,
|
|
|
+ 'M1': 0,
|
|
|
+ 'E1': 0,
|
|
|
+ 'C1': 0
|
|
|
+ }[loc_type],
|
|
|
+ current_quantity=0,
|
|
|
+ status='available'
|
|
|
+ )
|
|
|
+ group_item.location_items.add(LocationModel.objects.get(warehouse_code=warehouse_code, row=row, col=col, layer=layer))
|
|
|
+ group_item.save()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
# 库位-托盘关联表(记录实时存放关系)
|
|
|
class LocationContainerLink(models.Model):
|