|
@@ -230,6 +230,22 @@ func UpdateProductBill(c *gin.Context, apictx *ApiSession) (interface{}, error)
|
|
bill.SupplierRemark = " "
|
|
bill.SupplierRemark = " "
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 获取当前订单提交数
|
|
|
|
+ // 对比提交数量是否变化,变化了就同步计划中的提交数
|
|
|
|
+ currProduct := &model.ProductBill{}
|
|
|
|
+ currConfirmCountMap := map[string]int{}
|
|
|
|
+ repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
|
|
|
|
+ CollectName: repo.CollectionBillProduct,
|
|
|
|
+ Query: repo.Map{"_id": bill.Id},
|
|
|
|
+ Project: []string{"products"},
|
|
|
|
+ }, currProduct)
|
|
|
|
+ if len(currProduct.Products) > 0 {
|
|
|
|
+ for _, cp := range currProduct.Products {
|
|
|
|
+ currConfirmCountMap[cp.Id] = cp.ConfirmCount
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ isSyncConfirm := false
|
|
|
|
+
|
|
// 更新供应商确定数量与plan中stage项的同步
|
|
// 更新供应商确定数量与plan中stage项的同步
|
|
if len(bill.Products) > 0 {
|
|
if len(bill.Products) > 0 {
|
|
idCounts := map[string]int{}
|
|
idCounts := map[string]int{}
|
|
@@ -237,17 +253,46 @@ func UpdateProductBill(c *gin.Context, apictx *ApiSession) (interface{}, error)
|
|
if len(product.Id) == 0 {
|
|
if len(product.Id) == 0 {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- idCounts[product.Id] = product.ConfirmCount
|
|
|
|
|
|
+ // 对比提交数量不一致时
|
|
|
|
+ if v, ok := currConfirmCountMap[product.Id]; ok {
|
|
|
|
+ if v != product.ConfirmCount {
|
|
|
|
+ isSyncConfirm = true
|
|
|
|
+ idCounts[product.Id] = product.ConfirmCount
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
- fmt.Println(idCounts)
|
|
|
|
- result, err := updateStageCount(c, bill.PlanId, idCounts, apictx)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println(err)
|
|
|
|
- log.Error(err)
|
|
|
|
|
|
+ fmt.Println("单据变化的提交数量:", idCounts)
|
|
|
|
+
|
|
|
|
+ if isSyncConfirm {
|
|
|
|
+ result, err := updateStageCount(c, bill.PlanId, idCounts, apictx)
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Println(err)
|
|
|
|
+ log.Error(err)
|
|
|
|
+ }
|
|
|
|
+ fmt.Println(result)
|
|
|
|
+
|
|
}
|
|
}
|
|
- fmt.Println(result)
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 更新供应商确定数量与plan中stage项的同步
|
|
|
|
+ // if len(bill.Products) > 0 {
|
|
|
|
+ // idCounts := map[string]int{}
|
|
|
|
+ // for _, product := range bill.Products {
|
|
|
|
+ // if len(product.Id) == 0 {
|
|
|
|
+ // continue
|
|
|
|
+ // }
|
|
|
|
+ // idCounts[product.Id] = product.ConfirmCount
|
|
|
|
+ // }
|
|
|
|
+ // fmt.Println(idCounts)
|
|
|
|
+ // result, err := updateStageCount(c, bill.PlanId, idCounts, apictx)
|
|
|
|
+ // if err != nil {
|
|
|
|
+ // fmt.Println(err)
|
|
|
|
+ // log.Error(err)
|
|
|
|
+ // }
|
|
|
|
+ // fmt.Println(result)
|
|
|
|
+ // }
|
|
|
|
+
|
|
bill.UpdateTime = time.Now()
|
|
bill.UpdateTime = time.Now()
|
|
// return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionBillProduct, bill.Id.Hex(), &bill)
|
|
// return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionBillProduct, bill.Id.Hex(), &bill)
|
|
return repo.RepoUpdateSetDoc1(apictx.CreateRepoCtx(), repo.CollectionBillProduct, bill.Id.Hex(), &bill, &repo.RecordLogReq{
|
|
return repo.RepoUpdateSetDoc1(apictx.CreateRepoCtx(), repo.CollectionBillProduct, bill.Id.Hex(), &bill, &repo.RecordLogReq{
|