|
|
@ -628,22 +628,22 @@ func (impl *InventoryCheckHeadServiceImplement) AccomplishCheckHead(user *models |
|
|
|
lst.CheckResult = model.CHECK_RESULT_LESS |
|
|
|
} |
|
|
|
if lst.ActQty != book.Qty { |
|
|
|
articleWithReplenish, err := artDao.SelectOneWithReplenish(lst.ArtId) |
|
|
|
article, err := artDao.SelectOne(lst.ArtId) |
|
|
|
if err != nil { |
|
|
|
_ = session.Rollback() |
|
|
|
return err |
|
|
|
} |
|
|
|
if articleWithReplenish == nil { |
|
|
|
if article == nil { |
|
|
|
_ = session.Rollback() |
|
|
|
return grmi.NewBusinessError("不存在对应的物料") |
|
|
|
} |
|
|
|
articleWithReplenish.Article.Qty = articleWithReplenish.Article.Qty + (lst.ActQty - book.Qty) |
|
|
|
err = artDao.UpdateOne(&articleWithReplenish.Article) |
|
|
|
article.Qty = article.Qty + (lst.ActQty - book.Qty) |
|
|
|
err = artDao.UpdateOne(article) |
|
|
|
if err != nil { |
|
|
|
_ = session.Rollback() |
|
|
|
return err |
|
|
|
} |
|
|
|
if articleWithReplenish.Article.Qty < articleWithReplenish.ArticleReplenish.MinQty { |
|
|
|
if article.Qty < article.ArticleReplenish.MinQty { |
|
|
|
orderLi, err := replenishDao.Select([]grmi.Predicate{meta.ReplenishOrder_ArtId.NewPredicate(grmi.Equal, lst.ArtId), meta.ReplenishOrder_Status.NewPredicate(grmi.Equal, model.REPLENISH_ORDER_STATUS_ON)}, nil) |
|
|
|
if err != nil { |
|
|
|
_ = session.Rollback() |
|
|
@ -660,11 +660,11 @@ func (impl *InventoryCheckHeadServiceImplement) AccomplishCheckHead(user *models |
|
|
|
replenishOrder := model.ReplenishOrder{ |
|
|
|
ReplenishId: orderId, |
|
|
|
ArtId: lst.ArtId, |
|
|
|
Qty: articleWithReplenish.ArticleReplenish.ReplenishQty, |
|
|
|
Uom: articleWithReplenish.Article.Uom, |
|
|
|
Qty: article.ArticleReplenish.ReplenishQty, |
|
|
|
Uom: article.Uom, |
|
|
|
ReplenishTime: grmi.DateTime(time.Now()), |
|
|
|
ArtType: articleWithReplenish.Article.ArtType, |
|
|
|
ArtName: articleWithReplenish.Article.Descr1, |
|
|
|
ArtType: article.ArtType, |
|
|
|
ArtName: article.Descr1, |
|
|
|
Status: model.REPLENISH_ORDER_STATUS_ON, |
|
|
|
} |
|
|
|
err = replenishDao.InsertOne(&replenishOrder) |
|
|
@ -684,6 +684,7 @@ func (impl *InventoryCheckHeadServiceImplement) AccomplishCheckHead(user *models |
|
|
|
_ = session.Rollback() |
|
|
|
return err |
|
|
|
} |
|
|
|
lst.InventoryCheckId = entity.InventoryCheckId |
|
|
|
lstLi[index] = lst |
|
|
|
} |
|
|
|
err = lstDao.Insert(&lstLi) |
|
|
|