|
@@ -44,6 +44,19 @@ type PlanSummary struct {
|
|
SendTo map[string]string
|
|
SendTo map[string]string
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+type PlanSimple struct {
|
|
|
|
+ Id primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
|
|
|
|
+ Name string `bson:"name,omitempty" json:"name"`
|
|
|
|
+ CreateUser string `bson:"createUser,omitempty" json:"createUser"`
|
|
|
|
+ //生产数量
|
|
|
|
+ Total int `bson:"total,omitempty" json:"total"`
|
|
|
|
+ //状态
|
|
|
|
+ Status string `bson:"status,omitempty" json:"status"`
|
|
|
|
+ //总价
|
|
|
|
+ TotalPrice float64 `bson:"totalPrice,omitempty" json:"totalPrice"`
|
|
|
|
+ CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
|
|
|
|
+}
|
|
|
|
+
|
|
func SummarySupplierPlan(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
func SummarySupplierPlan(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
_, _, query := UtilQueryPageSize(c)
|
|
_, _, query := UtilQueryPageSize(c)
|
|
supplierId := primitive.NilObjectID
|
|
supplierId := primitive.NilObjectID
|
|
@@ -65,21 +78,29 @@ func SummarySupplierPlan(c *gin.Context, apictx *ApiSession) (interface{}, error
|
|
err := repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
err := repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
CollectName: repo.CollectionProductPlan,
|
|
CollectName: repo.CollectionProductPlan,
|
|
Query: query,
|
|
Query: query,
|
|
- Project: []string{"_id", "pack"},
|
|
|
|
Sort: bson.M{"createTime": -1},
|
|
Sort: bson.M{"createTime": -1},
|
|
}, &plans)
|
|
}, &plans)
|
|
if err != nil {
|
|
if err != nil {
|
|
log.Error(err)
|
|
log.Error(err)
|
|
return nil, errors.New("查询数据错误!")
|
|
return nil, errors.New("查询数据错误!")
|
|
}
|
|
}
|
|
- planIds := []primitive.ObjectID{}
|
|
|
|
|
|
+ planSimples := []*PlanSimple{}
|
|
if len(plans) < 1 {
|
|
if len(plans) < 1 {
|
|
- return planIds, nil
|
|
|
|
|
|
+ return planSimples, nil
|
|
}
|
|
}
|
|
// 遍历
|
|
// 遍历
|
|
|
|
|
|
flag := false
|
|
flag := false
|
|
for _, plan := range plans {
|
|
for _, plan := range plans {
|
|
|
|
+ ps := &PlanSimple{
|
|
|
|
+ Id: plan.Id,
|
|
|
|
+ Name: plan.Name,
|
|
|
|
+ CreateUser: plan.CreateUser,
|
|
|
|
+ Total: plan.Total,
|
|
|
|
+ Status: plan.Status,
|
|
|
|
+ TotalPrice: plan.TotalPrice,
|
|
|
|
+ CreateTime: plan.CreateTime,
|
|
|
|
+ }
|
|
// 选供应商
|
|
// 选供应商
|
|
if !supplierId.IsZero() {
|
|
if !supplierId.IsZero() {
|
|
for _, comp := range plan.Pack.Components {
|
|
for _, comp := range plan.Pack.Components {
|
|
@@ -92,7 +113,7 @@ func SummarySupplierPlan(c *gin.Context, apictx *ApiSession) (interface{}, error
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
if stage.SupplierInfo.Id == supplierId {
|
|
if stage.SupplierInfo.Id == supplierId {
|
|
- planIds = append(planIds, plan.Id)
|
|
|
|
|
|
+ planSimples = append(planSimples, ps)
|
|
flag = true
|
|
flag = true
|
|
break
|
|
break
|
|
}
|
|
}
|
|
@@ -103,14 +124,14 @@ func SummarySupplierPlan(c *gin.Context, apictx *ApiSession) (interface{}, error
|
|
}
|
|
}
|
|
|
|
|
|
} else {
|
|
} else {
|
|
- planIds = append(planIds, plan.Id)
|
|
|
|
|
|
+ planSimples = append(planSimples, ps)
|
|
}
|
|
}
|
|
if flag {
|
|
if flag {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- return planIds, nil
|
|
|
|
|
|
+ return planSimples, nil
|
|
}
|
|
}
|
|
|
|
|
|
// /summary/download?planIds=id1,id2&supplierId=xxx
|
|
// /summary/download?planIds=id1,id2&supplierId=xxx
|