修改计划排程,超过小时产能提示产线的小时产能以及超出的件数

This commit is contained in:
hujiaying
2024-10-10 16:47:25 +08:00
parent d1ff7c196d
commit 50bb50f5ab
3 changed files with 16 additions and 9 deletions

View File

@@ -231,13 +231,13 @@ class ResWorkcenter(models.Model):
default_capacity = round(
self.production_line_hour_capacity * date_planned_working_hours, 2)
_logger.info('排程日期:%s,计划数量:%s,日产能:%s,日工时:%s' % (
date_planned, sum_qty, default_capacity, date_planned_working_hours))
date_planned, sum_qty, default_capacity, date_planned_working_hours))
if sum_qty >= default_capacity:
return False
return True
# 处理排程是否超过小时产能
def deal_available_single_machine_capacity(self, date_planned):
def deal_available_single_machine_capacity(self, date_planned, count):
date_planned_start = date_planned.strftime('%Y-%m-%d %H:00:00')
date_planned_end = date_planned + timedelta(hours=1)
@@ -249,7 +249,11 @@ class ResWorkcenter(models.Model):
if plan_ids:
sum_qty = sum([p.product_qty for p in plan_ids])
if sum_qty >= self.production_line_hour_capacity:
production_line_hour_capacity = self.production_line_hour_capacity
if sum_qty >= production_line_hour_capacity:
message = '当前计划开始时间不能预约排程,超过生产线小时产能(%d件)%d' % (
production_line_hour_capacity, count)
raise UserError(message)
return False
return True