animeic 2 years ago
parent
commit
84f7f10d3e

+ 25 - 28
boxcost/api/bill-process-excel.go

@@ -169,35 +169,32 @@ func (b *ProcessBillExcel) drawTableContent() error {
 			b.Excel.SetRowHeight(b.SheetName, rowIndex, 21)
 		}
 	}
-	process := b.Content.Process
-	if len(process) > 0 {
-		for _, ps := range process {
-
-			deliveryTime := ps.DeliveryTime.Local().Format("2006-01-02")
-			confirmCount := "-"
-			realAmount := "-"
-			// 预算金额
-			budgetAmount := fmt.Sprintf("%.2f", float64(ps.Count)*ps.Price)
-			b.FormatToEmpty(&budgetAmount)
-
-			if b.Content.Status == "complete" {
-				// 实际完成数
-				confirmCount = fmt.Sprintf("%d", b.Content.ConfirmCount)
-				b.FormatToEmpty(&confirmCount)
-
-				// 实际金额
-				realAmount = fmt.Sprintf("%.2f", float64(b.Content.ConfirmCount)*ps.Price)
-				b.FormatToEmpty(&realAmount)
-			}
-
-			// 采购项目 规格 数量 单位 单价 预算金额 实际金额 交货时间 备注
-			count := fmt.Sprintf("%d", ps.Count)
-			price := fmt.Sprintf("%.2f", ps.Price)
-			b.FormatToEmpty(&price)
-			DrawRow(row, ps.Name, ps.Norm, count, ps.Unit, price, budgetAmount, realAmount, deliveryTime, ps.Remark)
-			row++
-			b.Row++
+	ps := b.Content.Process
+	if ps != nil {
+		deliveryTime := ps.DeliveryTime.Local().Format("2006-01-02")
+		confirmCount := "-"
+		realAmount := "-"
+		// 预算金额
+		budgetAmount := fmt.Sprintf("%.2f", float64(ps.Count)*ps.Price)
+		b.FormatToEmpty(&budgetAmount)
+
+		if b.Content.Status == "complete" {
+			// 实际完成数
+			confirmCount = fmt.Sprintf("%d", b.Content.ConfirmCount)
+			b.FormatToEmpty(&confirmCount)
+
+			// 实际金额
+			realAmount = fmt.Sprintf("%.2f", float64(b.Content.ConfirmCount)*ps.Price)
+			b.FormatToEmpty(&realAmount)
 		}
+
+		// 采购项目 规格 数量 单位 单价 预算金额 实际金额 交货时间 备注
+		count := fmt.Sprintf("%d", ps.Count)
+		price := fmt.Sprintf("%.2f", ps.Price)
+		b.FormatToEmpty(&price)
+		DrawRow(row, ps.Name, ps.Norm, count, ps.Unit, price, budgetAmount, realAmount, deliveryTime, ps.Remark)
+		row++
+		b.Row++
 	}
 
 	return nil

+ 1 - 1
boxcost/api/bill.go

@@ -226,7 +226,7 @@ func DownLoadBills(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 
 	var billExcel IPurchBill
 
-	if len(bill.Process) > 0 {
+	if bill.Process != nil {
 		billExcel = NewProcessBill(f)
 	}
 

+ 18 - 18
boxcost/api/plan-cost-excel.go

@@ -407,7 +407,7 @@ func (b *PlanCostExcel) drawAllContent() error {
 	}
 
 	// 工序数据
-	if len(b.Content.Process) > 0 {
+	if b.Content.Process != nil {
 		// 生产汇总金额
 		startACell := fmt.Sprintf("%s%d", "A", row)
 		endMCell := fmt.Sprintf("%s%d", "K", row)
@@ -457,23 +457,23 @@ func (b *PlanCostExcel) drawAllContent() error {
 			}
 		}
 
-		for _, ps := range b.Content.Process {
-			count := fmt.Sprintf("%d", ps.Count)
-			confirmCount := fmt.Sprintf("%d", ps.ConfirmCount)
-			price := fmt.Sprintf("%.2f", ps.Price)
-			b.FormatToEmpty(&price)
-			budgetAmountf := ps.Price * float64(ps.Count)
-			budgetAmount := fmt.Sprintf("%.2f", budgetAmountf)
-			b.FormatToEmpty(&budgetAmount)
-			realAmountf := ps.Price * float64(ps.ConfirmCount)
-			realAmount := fmt.Sprintf("%.2f", realAmountf)
-			b.FormatToEmpty(&realAmount)
-			confirmTotalPlanPrice += realAmountf
-			totalPlanPrice += float32(budgetAmountf)
-
-			DrawRow(row, ps.Name, ps.Supplier, ps.Norm, ps.Unit, count, confirmCount, price, budgetAmount, realAmount)
-			row++
-		}
+		ps := b.Content.Process
+		count := fmt.Sprintf("%.2f", ps.Supplier.OrderCount)
+		confirmCount := fmt.Sprintf("%d", ps.ConfirmCount)
+		price := fmt.Sprintf("%.2f", ps.Supplier.OrderPrice)
+		b.FormatToEmpty(&price)
+		// budgetAmountf := ps.Supplier.OrderPrice * float64(ps.Supplier.OrderCount)
+		budgetAmount := fmt.Sprintf("%.2f", ps.Supplier.OrderRealPrice)
+		b.FormatToEmpty(&budgetAmount)
+		// realAmountf := ps.Price * float64(ps.ConfirmCount)
+		realAmountf := ps.Supplier.OrderPrice * float64(ps.ConfirmCount)
+		realAmount := fmt.Sprintf("%.2f", realAmountf)
+		b.FormatToEmpty(&realAmount)
+		confirmTotalPlanPrice += realAmountf
+		totalPlanPrice += float32(ps.Supplier.OrderRealPrice)
+
+		DrawRow(row, ps.ProcessInfo.Name, ps.Supplier.SupplierInfo.Name, ps.ProcessInfo.Norm, ps.ProcessInfo.Unit, count, confirmCount, price, budgetAmount, realAmount)
+		row++
 
 	}
 	// 生产汇总金额

+ 1 - 1
boxcost/db/model/bill.go

@@ -68,7 +68,7 @@ type PurchaseBill struct {
 	Paper []*PaperBill `bson:"papers,omitempty" json:"papers"`
 
 	// 工序管理
-	Process []*ProcessBill `bson:"process,omitempty" json:"process"`
+	Process *ProcessBill `bson:"process,omitempty" json:"process"`
 
 	// 序号
 	SerialNumber string `bson:"serialNumber,omitempty" json:"serialNumber"`

+ 1 - 1
boxcost/db/model/plan.go

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

+ 20 - 0
boxcost/db/model/process.go

@@ -48,3 +48,23 @@ type ProcessBill struct {
 	//交货时间
 	DeliveryTime time.Time `bson:"deliveryTime,omitempty" json:"deliveryTime"`
 }
+
+type ProcessData struct {
+	Id string `bson:"id,omitempty" json:"id"`
+
+	//所有工艺
+	ProcessInfo *Process `bson:"crafts,omitempty" json:"crafts"`
+
+	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"` //备注
+
+	//确认收货数量
+	ConfirmCount int `bson:"confirmCount,omitempty" json:"confirmCount"`
+}