animeic 2 years ago
parent
commit
f30d618d02

+ 10 - 0
boxcost/api/IExcel.go

@@ -0,0 +1,10 @@
+package api
+
+type IExcel interface {
+	SetContent(content interface{})
+	SetTitle(title string)
+	SetRow(row int)
+	GetRow() int
+
+	SetSignatures(sign interface{})
+}

+ 20 - 0
boxcost/api/bill-produce-excel.go

@@ -339,3 +339,23 @@ func (b *ProduceBillExcel) FormatToEmpty(str *string) {
 	}
 
 }
+
+func (b *ProduceBillExcel) SetContent(content interface{}) {
+	b.Content = content.(*model.ProduceBill)
+
+}
+func (b *ProduceBillExcel) SetTitle(title string) {
+	b.Title = title
+
+}
+func (b *ProduceBillExcel) SetRow(row int) {
+	b.Row = row
+}
+func (b *ProduceBillExcel) GetRow() int {
+	return b.Row
+}
+
+func (b *ProduceBillExcel) SetSignatures(sign interface{}) {
+	b.Signatures = sign.([]*model.Signature)
+
+}

+ 10 - 11
boxcost/api/bill-product-excel.go

@@ -353,23 +353,22 @@ func (b *ProductBillExcel) FormatToEmpty(str *string) {
 
 }
 
-func (b *ProductBillExcel) PrintPurchType() string {
-	return "process"
-}
-
-func (b *ProductBillExcel) SetContent(content *model.ProductBill) {
-	b.Content = content
+func (b *ProductBillExcel) SetContent(content interface{}) {
+	b.Content = content.(*model.ProductBill)
 
 }
 func (b *ProductBillExcel) SetTitle(title string) {
 	b.Title = title
 
 }
-func (b *ProductBillExcel) SetOffset(offset int) {
-	b.Offset = offset
-
+func (b *ProductBillExcel) SetRow(row int) {
+	b.Row = row
 }
-func (b *ProductBillExcel) SetSignatures(sign []*model.Signature) {
-	b.Signatures = sign
+func (b *ProductBillExcel) GetRow() int {
+	return b.Row
+}
+
+func (b *ProductBillExcel) SetSignatures(sign interface{}) {
+	b.Signatures = sign.([]*model.Signature)
 
 }

+ 21 - 0
boxcost/api/bill-purchase-excel.go

@@ -396,3 +396,24 @@ func (b *PurchaseBillExcel) FormatToEmpty(str *string) {
 	}
 
 }
+
+func (b *PurchaseBillExcel) SetContent(content interface{}) {
+
+	b.Content = content.(*model.PurchaseBill)
+
+}
+func (b *PurchaseBillExcel) SetTitle(title string) {
+	b.Title = title
+
+}
+func (b *PurchaseBillExcel) SetRow(row int) {
+	b.Row = row
+}
+func (b *PurchaseBillExcel) GetRow() int {
+	return b.Row
+}
+
+func (b *PurchaseBillExcel) SetSignatures(sign interface{}) {
+	b.Signatures = sign.([]*model.Signature)
+
+}

+ 0 - 23
boxcost/api/pack.go

@@ -47,30 +47,7 @@ func CreatePack(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	if pack.Name == "" {
 		return nil, errors.New("包装名为空")
 	}
-	// 创建时生产 CompCounts,packComponent Id,mat。id craft id
 	pack.CompCounts = len(pack.Components)
-
-	// 生成id
-	// components id
-	// if pack.CompCounts > 0 {
-	// 	for _, v := range pack.Components {
-	// 		v.Id = primitive.NewObjectID().Hex()
-	// 		// mats id
-	// 		if len(v.Mats) > 0 {
-	// 			for _, v := range v.Mats {
-	// 				v.Id = primitive.NewObjectID().Hex()
-	// 				// crafts id
-	// 				if len(v.Crafts) > 0 {
-	// 					for _, v := range v.Crafts {
-	// 						v.Id = primitive.NewObjectID().Hex()
-
-	// 					}
-	// 				}
-	// 			}
-	// 		}
-	// 	}
-	// }
-
 	pack.CreateTime = time.Now()
 	pack.UpdateTime = time.Now()
 

+ 71 - 56
boxcost/api/plan.go

@@ -84,6 +84,7 @@ type SupplierPlanCost struct {
 // 	return nil, nil
 
 // }
+
 // func DownLoadPlan(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 // 	_planId := c.Query("id")
 // 	compId := c.Query("compId")
@@ -118,69 +119,83 @@ type SupplierPlanCost struct {
 // 	index := f.NewSheet("Sheet1")
 // 	f.SetActiveSheet(index)
 // 	f.SetDefaultFont("宋体")
-
 // 	companyName := getCompanyName(apictx)
 
-// 	offset := 0
+// 	// 获取不同类型的单据id
+// 	set := make(map[int]map[primitive.ObjectID]struct{})
 // 	for _, stage := range curComp.Stages {
 // 		_billId := stage.BillId
 // 		billId, _ := primitive.ObjectIDFromHex(_billId)
-// 		if !billId.IsZero(){
-// 			// 采购单
-// 			if stage.Type == 1
+// 		if !billId.IsZero() {
+// 			set[stage.Type] = map[primitive.ObjectID]struct{}{billId: struct{}{}}
 // 		}
-// 		if err == nil {
-// 			purchase := model.PurchaseBill{}
-// 			found, _ := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
-// 				CollectName: repo.CollectionBillPurchase,
-// 				Query:       repo.Map{"_id": purchaseId},
-// 			}, &purchase)
-// 			fmt.Println(purchase)
-// 			if found {
-// 				var billExcel IPurchBill
-// 				if purchase.Process != nil {
-// 					billExcel = NewProcessBill(f)
-// 				}
-
-// 				if len(purchase.Paper) > 0 {
-// 					billExcel = NewPurchaseBill(f)
-// 				}
-// 				// purchaseExcel := NewPurchaseBill(f)
-// 				billExcel.SetContent(&purchase)
-// 				billExcel.SetTitle(fmt.Sprintf("%s原材料采购单", companyName))
-// 				billExcel.SetOffset(offset)
-// 				// billExcel.Title = fmt.Sprintf("%s原材料采购单", companyName)
-// 				//设置对应的数据
-// 				// purchaseExcel.Offset = offset
-// 				billExcel.Draws()
-
-// 				offset += 15
-// 			}
-// 		}
-// 		// if len(mat.Crafts) > 0 {
-// 		// 	for _, carft := range mat.Crafts {
-// 		// 		// 加工单
-// 		// 		_produceId := carft.BillId
-// 		// 		produceId, err := primitive.ObjectIDFromHex(_produceId)
-// 		// 		if err == nil {
-// 		// 			produce := model.ProduceBill{}
-// 		// 			found, _ := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
-// 		// 				CollectName: repo.CollectionBillProduce,
-// 		// 				Query:       repo.Map{"_id": produceId},
-// 		// 			}, &produce)
-// 		// 			if found {
-// 		// 				produceExcel := NewProduceBill(f)
-// 		// 				produceExcel.Content = &produce
-// 		// 				produceExcel.Title = fmt.Sprintf("%s加工单", companyName)
-// 		// 				//设置对应的数据
-// 		// 				produceExcel.Offset = offset
-// 		// 				produceExcel.Draws()
-
-// 		// 				offset += 15
-// 		// 			}
-
-// 		// 		}
+// 	}
+
+// 	// row := 0
+// 	// for k, bill := range set {
+// 	// 	for billId, _ := range bill {
+// 	// 		var billExcel IExcel
+// 	// 		collectName := ""
+// 	// 		if k == 1 {
+// 	// 			collectName = repo.CollectionBillPurchase
+// 	// 			billExcel = NewPurchaseBill(f)
+// 	// 		}
+// 	// 		if k == 2 {
+// 	// 			collectName = repo.CollectionBillProduce
+// 	// 			billExcel = NewProduceBill(f)
+// 	// 		}
+// 	// 		if k == 2 {
+// 	// 			collectName = repo.CollectionBillProduct
+// 	// 			billExcel = NewProductBill(f)
+// 	// 		}
+// 	// 		billExcel.SetRow(row)
+
+// 			// purchase := model.PurchaseBill{}
+// 			// found, _ := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
+// 			// 	CollectName: repo.CollectionBillPurchase,
+// 			// 	Query:       repo.Map{"_id": billId},
+// 			// }, &purchase)
+// 			// fmt.Println(purchase)
+// 			// if found {
+// 			// 	var billExcel IPurchBill
+// 			// 	if purchase.Process != nil {
+// 			// 		billExcel = NewProcessBill(f)
+// 			// 	}
+
+// 			// 	if len(purchase.Paper) > 0 {
+// 			// 		billExcel = NewPurchaseBill(f)
+// 			// 	}
+// 			// 	// purchaseExcel := NewPurchaseBill(f)
+// 			// 	billExcel.SetContent(&purchase)
+// 			// 	billExcel.SetTitle(fmt.Sprintf("%s原材料采购单", companyName))
+// 			// 	billExcel.SetOffset(offset)
+// 			// 	// billExcel.Title = fmt.Sprintf("%s原材料采购单", companyName)
+// 			// 	//设置对应的数据
+// 			// 	// purchaseExcel.Offset = offset
+// 			// 	billExcel.Draws()
+
+// 			// 	offset += 15
+// 			// }
+// //
+// 		// }
+
+// 		// 采购单
+// 		// if k == 1 {
+
+// 		// }
+// 		// // 加工单
+// 		// if k == 2 {
+// 		// 	for billId, _ := range bill {
+
 // 		// 	}
+
+// 		// }
+// 		// // 成品采购单
+// 		// if k == 3 {
+// 		// 	for billId, _ := range bill {
+
+// 		// 	}
+
 // 		// }
 // 	}
 

+ 0 - 9
boxcost/db/model/bill.go

@@ -184,15 +184,6 @@ type ProductBill struct {
 	UpdateTime   time.Time            `bson:"updateTime,omitempty" json:"updateTime"`
 	CompleteTime time.Time            `bson:"completeTime,omitempty" json:"completeTime"`
 
-	// //确认收货数量
-	// ConfirmCount int `bson:"confirmCount,omitempty" json:"confirmCount"`
-
-	// // 实际金额
-	// RealAmount float64 `bson:"realAmount,omitempty" json:"realAmount"`
-
-	// // 预算金额
-	// BudgetAmount float64 `bson:"budgetAmount,omitempty" json:"budgetAmount"`
-
 	//供应商
 	Supplier string `bson:"supplier,omitempty" json:"supplier"`