|
@@ -195,7 +195,7 @@ func UpdateProduceBill(c *gin.Context, apictx *ApiSession) (interface{}, error)
|
|
|
return nil, errors.New("id的为空")
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
if len(bill.Type) > 0 {
|
|
|
billType, err := searchBillTypeById(apictx, repo.CollectionBillProduce, bill.Id)
|
|
|
if err != nil {
|
|
@@ -228,6 +228,22 @@ func UpdateProduceBill(c *gin.Context, apictx *ApiSession) (interface{}, error)
|
|
|
bill.SupplierRemark = " "
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ currProduce := &model.ProduceBill{}
|
|
|
+ currConfirmCountMap := map[string]int{}
|
|
|
+ repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
|
|
|
+ CollectName: repo.CollectionBillProduce,
|
|
|
+ Query: repo.Map{"_id": bill.Id},
|
|
|
+ Project: []string{"produces"},
|
|
|
+ }, currProduce)
|
|
|
+ if len(currProduce.Produces) > 0 {
|
|
|
+ for _, cp := range currProduce.Produces {
|
|
|
+ currConfirmCountMap[cp.Id] = cp.ConfirmCount
|
|
|
+ }
|
|
|
+ }
|
|
|
+ isSyncConfirm := false
|
|
|
+
|
|
|
|
|
|
if len(bill.Produces) > 0 {
|
|
|
idCounts := map[string]int{}
|
|
@@ -235,15 +251,26 @@ func UpdateProduceBill(c *gin.Context, apictx *ApiSession) (interface{}, error)
|
|
|
if len(produce.Id) == 0 {
|
|
|
continue
|
|
|
}
|
|
|
- idCounts[produce.Id] = produce.ConfirmCount
|
|
|
+
|
|
|
+ if v, ok := currConfirmCountMap[produce.Id]; ok {
|
|
|
+ if v != produce.ConfirmCount {
|
|
|
+ isSyncConfirm = true
|
|
|
+ idCounts[produce.Id] = produce.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)
|
|
|
}
|
|
|
|
|
|
bill.UpdateTime = time.Now()
|