|
@@ -119,18 +119,15 @@ func DownLoadCompBills(c *gin.Context, apictx *ApiSession) (interface{}, error)
|
|
|
}
|
|
|
|
|
|
// 获取不同类型的单据id
|
|
|
- // set := make(map[int]map[primitive.ObjectID]struct{})
|
|
|
billIds := make([]string, 0)
|
|
|
for _, stage := range curComp.Stages {
|
|
|
- _billId := stage.BillId
|
|
|
-
|
|
|
- billId, _ := primitive.ObjectIDFromHex(_billId)
|
|
|
+ billId, _ := primitive.ObjectIDFromHex(stage.BillId)
|
|
|
if !billId.IsZero() {
|
|
|
- // set[stage.Type] = map[primitive.ObjectID]struct{}{billId: struct{}{}}
|
|
|
billIds = append(billIds, fmt.Sprintf("%d_%s", stage.BillType, stage.BillId))
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 去重单据号
|
|
|
typeBillIds := removeDuplicationSort(billIds)
|
|
|
if len(typeBillIds) < 1 {
|
|
|
return nil, errors.New("未找到单据信息")
|
|
@@ -146,7 +143,6 @@ func DownLoadCompBills(c *gin.Context, apictx *ApiSession) (interface{}, error)
|
|
|
tidArr := strings.Split(tId, "_")
|
|
|
|
|
|
var billExcel IExcel
|
|
|
-
|
|
|
// 采购
|
|
|
billId, _ := primitive.ObjectIDFromHex(tidArr[1])
|
|
|
if tidArr[0] == "1" {
|
|
@@ -163,7 +159,7 @@ func DownLoadCompBills(c *gin.Context, apictx *ApiSession) (interface{}, error)
|
|
|
repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
CollectName: repo.CollectionSignature,
|
|
|
Query: repo.Map{"_id": bson.M{"$in": purchase.SignUsers}},
|
|
|
- Sort: bson.M{"sort": 1}, // 升序
|
|
|
+ Sort: bson.M{"sort": 1},
|
|
|
}, &signs)
|
|
|
billExcel.SetSignatures(signs)
|
|
|
}
|
|
@@ -189,7 +185,7 @@ func DownLoadCompBills(c *gin.Context, apictx *ApiSession) (interface{}, error)
|
|
|
repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
CollectName: repo.CollectionSignature,
|
|
|
Query: repo.Map{"_id": bson.M{"$in": produce.SignUsers}},
|
|
|
- Sort: bson.M{"sort": 1}, // 升序
|
|
|
+ Sort: bson.M{"sort": 1},
|
|
|
}, &signs)
|
|
|
billExcel.SetSignatures(signs)
|
|
|
}
|
|
@@ -215,7 +211,7 @@ func DownLoadCompBills(c *gin.Context, apictx *ApiSession) (interface{}, error)
|
|
|
repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
CollectName: repo.CollectionSignature,
|
|
|
Query: repo.Map{"_id": bson.M{"$in": product.SignUsers}},
|
|
|
- Sort: bson.M{"sort": 1}, // 升序
|
|
|
+ Sort: bson.M{"sort": 1},
|
|
|
}, &signs)
|
|
|
billExcel.SetSignatures(signs)
|
|
|
}
|
|
@@ -228,10 +224,8 @@ func DownLoadCompBills(c *gin.Context, apictx *ApiSession) (interface{}, error)
|
|
|
if billExcel == nil {
|
|
|
continue
|
|
|
}
|
|
|
- // download?id=63f70cbbf72d8f1253ccbb4d&compId=1676975264366
|
|
|
billExcel.SetRow(row)
|
|
|
billExcel.Draws()
|
|
|
- fmt.Println(billExcel.GetRow())
|
|
|
row = billExcel.GetRow() + 5
|
|
|
}
|
|
|
|
|
@@ -257,7 +251,6 @@ func CreateProductPlan(c *gin.Context, apictx *ApiSession) (interface{}, error)
|
|
|
fmt.Println(err)
|
|
|
return nil, errors.New("参数错误!")
|
|
|
}
|
|
|
- ctx := apictx.CreateRepoCtx()
|
|
|
|
|
|
if plan.Name == "" {
|
|
|
return nil, errors.New("生产计划名为空")
|
|
@@ -270,7 +263,7 @@ func CreateProductPlan(c *gin.Context, apictx *ApiSession) (interface{}, error)
|
|
|
plan.CreateTime = time.Now()
|
|
|
plan.UpdateTime = time.Now()
|
|
|
|
|
|
- result, err := repo.RepoAddDoc(ctx, repo.CollectionProductPlan, &plan)
|
|
|
+ result, err := repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionProductPlan, &plan)
|
|
|
return result, err
|
|
|
}
|
|
|
|