animeic 2 yıl önce
ebeveyn
işleme
1653951c76
4 değiştirilmiş dosya ile 75 ekleme ve 117 silme
  1. 46 54
      boxcost/api/plan.go
  2. 25 58
      boxcost/db/model/pack.go
  3. 0 3
      boxcost/db/model/plan.go
  4. 4 2
      boxcost/db/repo/repo.go

+ 46 - 54
boxcost/api/plan.go

@@ -112,7 +112,7 @@ func DownLoadPlan(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	}
 
 	// 获取bill
-	if len(curComp.Mats) == 0 {
+	if len(curComp.Stages) == 0 {
 		return nil, errors.New("该组件数据不存在")
 	}
 	f := excelize.NewFile()
@@ -124,7 +124,7 @@ func DownLoadPlan(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	companyName := getCompanyName(apictx)
 
 	offset := 0
-	for _, mat := range curComp.Mats {
+	for _, mat := range curComp.Stages {
 		// 采购单
 		_purchaseId := mat.BillId
 		purchaseId, err := primitive.ObjectIDFromHex(_purchaseId)
@@ -156,31 +156,31 @@ func DownLoadPlan(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 				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
-					}
-
-				}
-			}
-		}
+		// 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
+		// 			}
+
+		// 		}
+		// 	}
+		// }
 	}
 
 	c.Header("Content-Type", "application/octet-stream")
@@ -242,40 +242,32 @@ func GetProductPlan(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	}
 
 	billStates := map[string]string{}
-
-	if len(plan.Process) > 0 {
-		for _, pp := range plan.Process {
-			ok, state := repo.RepoSeachDocMap(apictx.CreateRepoCtx(), &repo.DocSearchOptions{CollectName: repo.CollectionBillPurchase, Query: repo.Map{"_id": pp.BillId}, Project: []string{"status"}})
-			if ok {
-				billStates[pp.BillId] = state["status"].(string)
-			}
-		}
-
-	}
-
 	if plan.Pack != nil && plan.Pack.Components != nil {
-
 		for _, comp := range plan.Pack.Components {
-			if comp.Mats != nil {
-				for _, mat := range comp.Mats {
+			if comp.Stages != nil {
+				for _, stage := range comp.Stages {
+
+					if len(stage.BillId) > 0 {
+						collectName := ""
+						// 材料
+						if stage.Type == 1 {
+							collectName = repo.CollectionBillPurchase
+						}
+						// 工艺
+						if stage.Type == 2 {
+							collectName = repo.CollectionBillProduce
+						}
+						// 成品
+						if stage.Type == 3 {
+							collectName = repo.CollectionBillProduct
+						}
 
-					if len(mat.BillId) > 0 {
-						ok, state := repo.RepoSeachDocMap(apictx.CreateRepoCtx(), &repo.DocSearchOptions{CollectName: repo.CollectionBillPurchase, Query: repo.Map{"_id": mat.BillId}, Project: []string{"status"}})
+						ok, state := repo.RepoSeachDocMap(apictx.CreateRepoCtx(), &repo.DocSearchOptions{CollectName: collectName, Query: repo.Map{"_id": stage.BillId}, Project: []string{"status"}})
 						if ok {
-							billStates[mat.BillId] = state["status"].(string)
+							billStates[stage.BillId] = state["status"].(string)
 						}
 					}
 
-					if mat.Crafts != nil {
-						for _, craft := range mat.Crafts {
-							if len(craft.BillId) > 0 {
-								ok, state := repo.RepoSeachDocMap(apictx.CreateRepoCtx(), &repo.DocSearchOptions{CollectName: repo.CollectionBillProduce, Query: repo.Map{"_id": craft.BillId}, Project: []string{"status"}})
-								if ok {
-									billStates[craft.BillId] = state["status"].(string)
-								}
-							}
-						}
-					}
 				}
 			}
 		}

+ 25 - 58
boxcost/db/model/pack.go

@@ -35,7 +35,7 @@ type PackComponent struct {
 	UvSize string `bson:"uvSize,omitempty" json:"uvSize"`
 
 	//所有材料
-	Mats []*PackComponentMat `bson:"mats,omitempty" json:"mats"`
+	Stages []*ComponentStage `bson:"stages,omitempty" json:"stages"`
 
 	Remark string `bson:"remark,omitempty" json:"remark"`
 
@@ -43,74 +43,41 @@ type PackComponent struct {
 	TotalPrice float64 `bson:"totalPrice,omitempty" json:"totalPrice"`
 }
 
-type SupplierPriceVo struct {
-	Calc *PriceCalc `bson:"calc,omitempty" json:"calc"` //计价策略
-
-	//交货时间
-	DeliveryTime *time.Time `bson:"deliveryTime,omitempty" json:"deliveryTime"`
-
-	//订单单价
+type ComponentStage struct {
+	Id     string             `bson:"id,omitempty" json:"id"`
+	TypeId primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
+	// 预算价格
 	OrderPrice float64 `bson:"orderPrice,omitempty" json:"orderPrice"`
 
-	//订单数据量
+	// 订单数据量
 	OrderCount float64 `bson:"orderCount,omitempty" json:"orderCount"`
 
-	// 预算金额
-	OrderRealPrice float64 `bson:"orderRealPrice,omitempty" json:"orderRealPrice"`
-
-	//供应商信息
-	SupplierInfo *Supplier `bson:"supplierInfo,omitempty" json:"supplierInfo"`
-}
-
-type PackComponentMat struct {
-	Id string `bson:"id,omitempty" json:"id"`
-
-	//所有工艺
-	Crafts []*PackComponentMatCraft `bson:"crafts,omitempty" json:"crafts"`
-
-	MatInfo *Material `bson:"matInfo,omitempty" json:"matInfo"`
-
-	Supplier *SupplierPriceVo `bson:"supplier,omitempty" json:"supplier"`
-
-	BatchCount      int `bson:"batchCount,omitempty" json:"batchCount"`           //拼版数量
-	BatchSizeWidth  int `bson:"batchSizeWidth,omitempty" json:"batchSizeWidth"`   //平板尺寸
-	BatchSizeHeight int `bson:"batchSizeHeight,omitempty" json:"batchSizeHeight"` //平板尺寸
-
-	BillId string `bson:"billId,omitempty" json:"billId"`
-
-	Remark string `bson:"remark,omitempty" json:"remark"` //备注
-
+	//实际价格
 	RealPrice float64 `bson:"realPrice,omitempty" json:"realPrice"`
-
 	//确认收货数量
-	ConfirmCount int `bson:"confirmCount,omitempty" json:"confirmCount"`
-}
-
-type PackComponentMatCraft struct {
-	Id string `bson:"id,omitempty" json:"id"`
-
-	//工艺尺寸
-	Size string `bson:"size,omitempty" json:"size"`
-
-	//工艺数量
-	Count int `bson:"count,omitempty" json:"count"`
+	RealCount int `bson:"confirmCount,omitempty" json:"confirmCount"`
 
-	//工艺信息
-	CraftInfo *Craft `bson:"craftInfo,omitempty" json:"craftInfo"` //材料Id
+	// 供应相关信息
+	// 交货时间
+	DeliveryTime *time.Time `bson:"deliveryTime,omitempty" json:"deliveryTime"`
 
-	Supplier *SupplierPriceVo `bson:"supplier,omitempty" json:"supplier"`
+	// 供应商信息
+	SupplierInfo *Supplier `bson:"supplierInfo,omitempty" json:"supplierInfo"`
 
 	BatchCount      int `bson:"batchCount,omitempty" json:"batchCount"`           //拼版数量
 	BatchSizeWidth  int `bson:"batchSizeWidth,omitempty" json:"batchSizeWidth"`   //平板尺寸
 	BatchSizeHeight int `bson:"batchSizeHeight,omitempty" json:"batchSizeHeight"` //平板尺寸
 
-	BillId string `bson:"billId,omitempty" json:"billId"`
-
-	Remark string `bson:"remark,omitempty" json:"remark"` //备注
-
-	// 实际金额
-	RealPrice float64 `bson:"realPrice,omitempty" json:"realPrice"`
-
-	//确认收货数量
-	ConfirmCount int `bson:"confirmCount,omitempty" json:"confirmCount"`
+	Remark     string    `bson:"remark,omitempty" json:"remark"`     //备注
+	Size       string    `bson:"size,omitempty" json:"size"`         //工艺尺寸
+	Name       string    `bson:"name,omitempty" json:"name"`         //名称
+	Category   string    `bson:"category,omitempty" json:"category"` //分类
+	Price      float64   `bson:"price,omitempty" json:"price"`       //单价
+	Unit       string    `bson:"unit,omitempty" json:"unit"`         //单位
+	Norm       string    `bson:"norm,omitempty" json:"norm"`         // 规格
+	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
+	UpdateTime time.Time `bson:"updateTime,omitempty" json:"updateTime"`
+	Type       int       `bson:"type,omitempty" json:"type"`     //1-材料 2-供应 3-成品
+	Group      string    `bson:"group,omitempty" json:"group"`   //工序合标记,相同MatGroup的数据合并成一个单据
+	BillId     string    `bson:"billId,omitempty" json:"billId"` //订单Id
 }

+ 0 - 3
boxcost/db/model/plan.go

@@ -15,9 +15,6 @@ type ProductPlan struct {
 	Thumbnail  string `bson:"thumbnail,omitempty" json:"thumbnail"`
 	CreateUser string `bson:"createUser,omitempty" json:"createUser"`
 
-	// 工序 外箱、手工非
-	Process []*ProcessData `bson:"process,omitempty" json:"process"`
-
 	//生产数量
 	Total int `bson:"total,omitempty" json:"total"`
 

+ 4 - 2
boxcost/db/repo/repo.go

@@ -20,17 +20,19 @@ type RepoSession struct {
 const (
 	CollectionMaterial      = "material"
 	CollectionCraft         = "craft"
-	CollectionProcess       = "process"
+	CollectionProcess       = "process" // todo不需要
 	CollectionSupplier      = "supplier"
 	CollectionSupplierPrice = "supplier-price"
 	CollectionPack          = "pack"
 	CollectionProductPlan   = "product-plan"
 	CollectionBillPurchase  = "bill-purchase"
 	CollectionBillProduce   = "bill-produce"
+	CollectionBillProduct   = "bill-product" // 成品采购
 
 	CollectionSupplierMatprice     = "supplier-mats"
 	CollectionSupplierCraftprice   = "supplier-crafts"
-	CollectionSupplierProcessprice = "supplier-process"
+	CollectionSupplierProcessprice = "supplier-process" // todo 不需要
+	CollectionSupplierProductprice = "supplier-product" // 成品采购
 	CollectionIncrement            = "increment"
 	CollectionSignature            = "signature"
 	CollectionUsers                = "users"