浏览代码

add cell pdf && execl style

animeic 2 年之前
父节点
当前提交
30d484643d

+ 105 - 16
boxcost/api/bill-purchase-excel.go

@@ -2,7 +2,13 @@ package api
 
 import (
 	"box-cost/db/model"
+	"box-cost/log"
 	"fmt"
+	"strconv"
+
+	_ "image/gif"
+	_ "image/jpeg"
+	_ "image/png"
 
 	"github.com/xuri/excelize/v2"
 )
@@ -22,9 +28,11 @@ type PurchaseBillExcel struct {
 }
 
 func (b *PurchaseBillExcel) drawTitle() error {
+	marginLeft := excelize.PageMarginLeft(0.2)
+	b.Excel.SetPageMargins(b.SheetName, marginLeft)
 	tileIndex := b.Offset + 1
 	startCell := fmt.Sprintf("A%d", tileIndex)
-	err := b.Excel.MergeCell(b.SheetName, startCell, fmt.Sprintf("I%d", tileIndex))
+	err := b.Excel.MergeCell(b.SheetName, startCell, fmt.Sprintf("L%d", tileIndex))
 	if err != nil {
 		return err
 	}
@@ -78,7 +86,7 @@ func (b *PurchaseBillExcel) drawSubTitles() error {
 
 	var drawRight = func(rowIndex int, value string) error {
 		right1Cell := fmt.Sprintf("F%d", rowIndex)
-		err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("I%d", rowIndex))
+		err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("L%d", rowIndex))
 		if err != nil {
 			return err
 		}
@@ -117,7 +125,6 @@ func (b *PurchaseBillExcel) drawSubTitles() error {
 
 func (b *PurchaseBillExcel) drawTableTitle() error {
 	row := b.Offset + 5
-
 	//A采购项目 B规格(克) 尺寸C-D 数量E 单价F-G 交货时间H 备注I
 	var drawCol = func(prefix string, value string) error {
 		left1Cell := fmt.Sprintf("%s%d", prefix, row)
@@ -164,9 +171,9 @@ func (b *PurchaseBillExcel) drawTableTitle() error {
 
 	drawCol("A", "采购项目")
 	drawCol("B", "规格(克)")
-	drawCol("H", "交货时间")
-	drawCol("I", " 备注")
-	drawCol("E", " 数量")
+
+	drawCol("E", "数量")
+	drawCol("F", "完成数量")
 
 	drawCol2("C", "D", "尺寸(mm)", "长", "宽")
 	drawCol2("C", "D", "尺寸(mm)", "长", "宽")
@@ -187,7 +194,11 @@ func (b *PurchaseBillExcel) drawTableTitle() error {
 		}
 	}
 
-	drawCol2("F", "G", "单价", unit1, unit2)
+	drawCol2("G", "H", "单价", unit1, unit2)
+	drawCol("I", "预算金额")
+	drawCol("J", "实际金额")
+	drawCol("K", "交货时间")
+	drawCol("L", "备注")
 
 	return nil
 }
@@ -196,7 +207,7 @@ func (b *PurchaseBillExcel) drawTableContent() error {
 	row := b.Offset + 7
 
 	var DrawRow = func(rowIndex int, values ...string) {
-		charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I"}
+		charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"}
 		for i, c := range charas {
 			v := ""
 			if i < len(values) {
@@ -213,7 +224,29 @@ func (b *PurchaseBillExcel) drawTableContent() error {
 	if len(papers) > 0 {
 		for _, paper := range papers {
 			deliveryTime := paper.DeliveryTime.Local().Format("2006-01-02")
-			DrawRow(row, paper.Name, paper.Norm, paper.Height, paper.Width, fmt.Sprintf("%d", paper.Count), paper.Price, paper.Price2, deliveryTime, paper.Remark)
+
+			confirmCount := "-"
+			realAmount := "-"
+			price, err := strconv.ParseFloat(paper.Price, 64)
+			if err != nil {
+				price = 0.00
+			}
+
+			// 预算金额
+			budgetAmount := fmt.Sprintf("%.2f", float64(paper.Count)*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)*price)
+				b.FormatToEmpty(&realAmount)
+			}
+
+			DrawRow(row, paper.Name, paper.Norm, paper.Height, paper.Width, fmt.Sprintf("%d", paper.Count), confirmCount, paper.Price, paper.Price2, budgetAmount, realAmount, deliveryTime, paper.Remark)
 			row++
 		}
 	}
@@ -222,7 +255,7 @@ func (b *PurchaseBillExcel) drawTableContent() error {
 }
 
 func (b *PurchaseBillExcel) drawTableFooter() error {
-	row := b.Offset + 10
+	row := b.Offset + 8
 
 	left1Cell := fmt.Sprintf("A%d", row)
 
@@ -248,8 +281,8 @@ func (b *PurchaseBillExcel) drawTableFooter() error {
 	b.Excel.SetCellValue(b.SheetName, addCel, b.Content.SendTo)
 
 	sureCel := fmt.Sprintf("F%d", row)
-	b.Excel.MergeCell(b.SheetName, sureCel, fmt.Sprintf("I%d", row))
-	b.Excel.SetCellStyle(b.SheetName, sureCel, fmt.Sprintf("I%d", row), styleLeft)
+	b.Excel.MergeCell(b.SheetName, sureCel, fmt.Sprintf("L%d", row))
+	b.Excel.SetCellStyle(b.SheetName, sureCel, fmt.Sprintf("L%d", row), styleLeft)
 	b.Excel.SetCellValue(b.SheetName, sureCel, "供应商签字:")
 
 	b.Excel.SetRowHeight(b.SheetName, row, 21)
@@ -257,12 +290,61 @@ func (b *PurchaseBillExcel) drawTableFooter() error {
 	return nil
 }
 
+func (b *PurchaseBillExcel) drawTableSignature() error {
+	row := b.Offset + 11
+	// border := []excelize.Border{
+	// 	{Type: "top", Style: 1, Color: "000000"},
+	// 	{Type: "left", Style: 1, Color: "000000"},
+	// 	{Type: "right", Style: 1, Color: "000000"},
+	// 	{Type: "bottom", Style: 1, Color: "000000"},
+	// }
+
+	style1, _ := b.Excel.NewStyle(&excelize.Style{
+		Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
+		// Border:    border,
+	})
+
+	fontCell := fmt.Sprintf("I%d", row)
+	imageCell := fmt.Sprintf("J%d", row)
+	b.Excel.MergeCell(b.SheetName, fontCell, fmt.Sprintf("I%d", row+2))
+	b.Excel.SetCellStyle(b.SheetName, fontCell, fontCell, style1)
+	b.Excel.SetCellValue(b.SheetName, fontCell, "领导签字:")
+
+	// 签字图片 J10-K12
+	b.Excel.MergeCell(b.SheetName, imageCell, fmt.Sprintf("K%d", row+2))
+	b.Excel.SetCellStyle(b.SheetName, imageCell, imageCell, style1)
+	b.Excel.SetCellValue(b.SheetName, imageCell, "")
+
+	// 状态为已审核时,签字
+	if b.Content.Status == "reviewed" || b.Content.Status == "complete" {
+		err := b.Excel.AddPicture(b.SheetName, imageCell, "signature.png", `{
+			"x_scale": 0.35,
+			"y_scale": 0.35,
+			"x_offset": 10,
+			"print_obj": true,
+			"lock_aspect_ratio": false,
+			"locked": false,
+			"positioning": "oneCell"
+		}`)
+		if err != nil {
+			log.Error(err)
+			fmt.Println(err)
+		}
+
+	}
+
+	b.Excel.SetRowHeight(b.SheetName, row, 21)
+
+	return nil
+}
+
 func (b *PurchaseBillExcel) Draws() {
 	b.drawTitle()
 	b.drawSubTitles()
 	b.drawTableTitle()
 	b.drawTableContent()
 	b.drawTableFooter()
+	b.drawTableSignature()
 }
 
 func NewPurchaseBill(f *excelize.File) *PurchaseBillExcel {
@@ -288,10 +370,17 @@ func NewPurchaseBill(f *excelize.File) *PurchaseBillExcel {
 		AlignCenterStyle: styleLeft,
 	}
 
-	f.SetColWidth(b.SheetName, "A", "A", 17)
-	f.SetColWidth(b.SheetName, "B", "B", 13)
-	f.SetColWidth(b.SheetName, "C", "G", 9.5)
-	f.SetColWidth(b.SheetName, "H", "I", 12)
+	f.SetColWidth(b.SheetName, "A", "A", 15)
+	f.SetColWidth(b.SheetName, "B", "J", 9)
+	// f.SetColWidth(b.SheetName, "C", "H", 9.5)
+	f.SetColWidth(b.SheetName, "L", "L", 12)
 	f.SetPageMargins(b.SheetName, excelize.PageMarginTop(0), excelize.PageMarginLeft(0), excelize.PageMarginRight(0))
 	return b
 }
+
+func (b *PurchaseBillExcel) FormatToEmpty(str *string) {
+	if *str == "0" || *str == "0.00" {
+		*str = ""
+	}
+
+}

+ 1 - 0
boxcost/api/bill.go

@@ -164,6 +164,7 @@ func DownLoadBills(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 		buf, _ := f.WriteToBuffer()
 		res, err := excelToPdf(buf, apictx.Svc.Conf.PdfApiAddr)
 		if err != nil {
+			fmt.Println(err)
 			return nil, errors.New("转化pdf失败")
 		}
 		c.Header("Content-Type", "application/octet-stream")

+ 117 - 27
boxcost/api/plan-cost-excel.go

@@ -140,9 +140,12 @@ func (b *PlanCostExcel) drawTableTitle() error {
 	drawCol3("E", "F", "G", "规格", "厚度(纸克)", "长", "宽")
 	drawCol("H", "单位")
 	drawCol("I", "下单数量")
-	drawCol("J", "单价(预算)")
-	drawCol("K", "预算金额")
-	drawCol("L", "汇总金额")
+	drawCol("J", "实际数量")
+	drawCol("K", "单价")
+	drawCol("L", "预算金额")
+	drawCol("M", "实际金额")
+	drawCol("N", "预算汇总")
+	drawCol("O", "实际汇总")
 
 	return nil
 }
@@ -155,9 +158,11 @@ func (b *PlanCostExcel) drawSupplierContent() error {
 	row := b.Offset + 4
 	comps := b.Content.Pack.Components
 	var totalPlanPrice float32 = 0.00
+	var confirmTotalPlanPrice float64 = 0.00
 	if len(comps) > 0 {
 		for _, comp := range comps {
 			var totalOrderRealPrice float32 = 0.00
+			var totalConfirmRealPrice float64 = 0.00
 			if len(comp.Mats) > 0 {
 				startRow := 0
 				for _, mat := range comp.Mats {
@@ -176,13 +181,22 @@ func (b *PlanCostExcel) drawSupplierContent() error {
 							b.FormatToEmpty(&matWidth)
 							orderCount := fmt.Sprintf("%d", int(mat.Supplier.OrderCount))
 							b.FormatToEmpty(&orderCount)
+
+							// 实际数量
+							confirmCount := fmt.Sprintf("%d", mat.MatInfo.ConfirmCount)
+							b.FormatToEmpty(&confirmCount)
+							// 单价
 							orderPrice := fmt.Sprintf("%.2f", mat.Supplier.OrderPrice)
 							b.FormatToEmpty(&orderPrice)
 							totalOrderRealPrice += mat.Supplier.OrderRealPrice
 							orderRealPrice := fmt.Sprintf("%.2f", mat.Supplier.OrderRealPrice)
-
 							b.FormatToEmpty(&orderRealPrice)
-							b.drawRow(row, "", mat.MatInfo.Name, "", supplierName, mat.MatInfo.Norm, matHeigth, matWidth, mat.MatInfo.Unit, orderCount, orderPrice, orderRealPrice, "")
+							// 实际金额
+							confirmPrice := mat.Supplier.OrderPrice * float64(mat.MatInfo.ConfirmCount)
+							totalConfirmRealPrice += confirmPrice
+							confirmRealPrice := fmt.Sprintf("%.2f", confirmPrice)
+							b.FormatToEmpty(&confirmRealPrice)
+							b.drawRow(row, "", mat.MatInfo.Name, "", supplierName, mat.MatInfo.Norm, matHeigth, matWidth, mat.MatInfo.Unit, orderCount, confirmCount, orderPrice, orderRealPrice, confirmRealPrice, "", "")
 							row++
 						}
 
@@ -204,12 +218,24 @@ func (b *PlanCostExcel) drawSupplierContent() error {
 									b.FormatToEmpty(&carftHeigth)
 									carftWidth := fmt.Sprintf("%d", craft.BatchSizeWidth)
 									b.FormatToEmpty(&carftWidth)
+
+									// 实际数量
+									confirmCraftCount := fmt.Sprintf("%d", craft.CraftInfo.ConfirmCount)
+									b.FormatToEmpty(&confirmCraftCount)
+
 									carftOrderPrice := fmt.Sprintf("%.2f", craft.Supplier.OrderPrice)
 									b.FormatToEmpty(&carftOrderPrice)
 									totalOrderRealPrice += craft.Supplier.OrderRealPrice
 									carftOrderRealPrice := fmt.Sprintf("%.2f", craft.Supplier.OrderRealPrice)
 									b.FormatToEmpty(&carftOrderRealPrice)
-									b.drawRow(row, "", "", craft.CraftInfo.Name, craftSupplierName, craft.CraftInfo.Norm, carftHeigth, carftWidth, craft.CraftInfo.Unit, carftOrderCount, carftOrderPrice, carftOrderRealPrice, "")
+
+									// 实际金额
+									confirmCraftPrice := craft.Supplier.OrderPrice * float64(craft.CraftInfo.ConfirmCount)
+									totalConfirmRealPrice += confirmCraftPrice
+									confirmCraftRealPrice := fmt.Sprintf("%.2f", confirmCraftPrice)
+									b.FormatToEmpty(&confirmCraftRealPrice)
+
+									b.drawRow(row, "", "", craft.CraftInfo.Name, craftSupplierName, craft.CraftInfo.Norm, carftHeigth, carftWidth, craft.CraftInfo.Unit, carftOrderCount, confirmCraftCount, carftOrderPrice, carftOrderRealPrice, confirmCraftRealPrice, "", "")
 									row++
 
 								}
@@ -234,9 +260,9 @@ func (b *PlanCostExcel) drawSupplierContent() error {
 					fmt.Println("startACell:", startACell)
 					fmt.Println("endACell:", endACell)
 					fmt.Println("compName:", comp.Name)
-					// 供应商组件汇总金额
-					startLCell := fmt.Sprintf("%s%d", "L", startRow)
-					endLCell := fmt.Sprintf("%s%d", "L", endRow)
+					// 供应商组件预算汇总
+					startLCell := fmt.Sprintf("%s%d", "N", startRow)
+					endLCell := fmt.Sprintf("%s%d", "N", endRow)
 					b.Excel.MergeCell(b.SheetName, startLCell, endLCell)
 					err = b.Excel.SetCellStyle(b.SheetName, startLCell, endLCell, b.AlignCenterStyle)
 					if err != nil {
@@ -245,24 +271,44 @@ func (b *PlanCostExcel) drawSupplierContent() error {
 					compTotalPrice := fmt.Sprintf("%.2f", totalOrderRealPrice)
 					b.FormatToEmpty(&compTotalPrice)
 					b.Excel.SetCellValue(b.SheetName, startLCell, compTotalPrice)
+					// 供应商组件实际汇总
+					startOCell := fmt.Sprintf("%s%d", "O", startRow)
+					endOCell := fmt.Sprintf("%s%d", "O", endRow)
+					b.Excel.MergeCell(b.SheetName, startOCell, endOCell)
+					err = b.Excel.SetCellStyle(b.SheetName, startOCell, endOCell, b.AlignCenterStyle)
+					if err != nil {
+						return err
+					}
+					compConfirmTotalPrice := fmt.Sprintf("%.2f", totalConfirmRealPrice)
+					b.FormatToEmpty(&compConfirmTotalPrice)
+					b.Excel.SetCellValue(b.SheetName, startLCell, compConfirmTotalPrice)
 
 				}
 
 			}
 			totalPlanPrice += totalOrderRealPrice
+			confirmTotalPlanPrice += totalConfirmRealPrice
 		}
 		// 生产汇总金额
 		startACell := fmt.Sprintf("%s%d", "A", row)
-		endKCell := fmt.Sprintf("%s%d", "K", row)
-		endLCell := fmt.Sprintf("%s%d", "L", row)
-		b.Excel.MergeCell(b.SheetName, startACell, endKCell)
-		b.Excel.SetCellStyle(b.SheetName, startACell, endKCell, b.AlignCenterStyle)
+		endMCell := fmt.Sprintf("%s%d", "M", row)
+		NCell := fmt.Sprintf("%s%d", "N", row)
+		OCell := fmt.Sprintf("%s%d", "O", row)
+		b.Excel.MergeCell(b.SheetName, startACell, endMCell)
+		b.Excel.SetCellStyle(b.SheetName, startACell, endMCell, b.AlignCenterStyle)
 		b.Excel.SetCellValue(b.SheetName, startACell, "生产计划汇总金额")
 
-		b.Excel.SetCellStyle(b.SheetName, endLCell, endLCell, b.AlignCenterStyle)
+		// 生产预算汇总
+		b.Excel.SetCellStyle(b.SheetName, NCell, NCell, b.AlignCenterStyle)
 		planTotalPrice := fmt.Sprintf("%.2f", totalPlanPrice)
 		b.FormatToEmpty(&planTotalPrice)
-		b.Excel.SetCellValue(b.SheetName, endLCell, planTotalPrice)
+		b.Excel.SetCellValue(b.SheetName, NCell, planTotalPrice)
+
+		// 生产实际汇总
+		b.Excel.SetCellStyle(b.SheetName, OCell, OCell, b.AlignCenterStyle)
+		planConfirmTotalPrice := fmt.Sprintf("%.2f", confirmTotalPlanPrice)
+		b.FormatToEmpty(&planConfirmTotalPrice)
+		b.Excel.SetCellValue(b.SheetName, OCell, planConfirmTotalPrice)
 
 	}
 
@@ -270,7 +316,7 @@ func (b *PlanCostExcel) drawSupplierContent() error {
 }
 
 func (b *PlanCostExcel) drawRow(rowIndex int, values ...string) {
-	charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"}
+	charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O"}
 	for i, c := range charas {
 		v := ""
 		if i < len(values) {
@@ -288,10 +334,11 @@ func (b *PlanCostExcel) drawRow(rowIndex int, values ...string) {
 
 func (b *PlanCostExcel) drawAllContent() error {
 	row := b.Offset + 4
-
 	comps := b.Content.Pack.Components
+	var confirmTotalPlanPrice float64 = 0.00
 	if len(comps) > 0 {
 		for _, comp := range comps {
+			var totalConfirmRealPrice float64 = 0.00
 			if len(comp.Mats) > 0 {
 				startRow := row
 				for _, mat := range comp.Mats {
@@ -306,12 +353,28 @@ func (b *PlanCostExcel) drawAllContent() error {
 					b.FormatToEmpty(&matWidth)
 					orderCount := fmt.Sprintf("%d", int(mat.Supplier.OrderCount))
 					b.FormatToEmpty(&orderCount)
+					// orderPrice := fmt.Sprintf("%.2f", mat.Supplier.OrderPrice)
+					// b.FormatToEmpty(&orderPrice)
+
+					// orderRealPrice := fmt.Sprintf("%.2f", mat.Supplier.OrderRealPrice)
+					// b.FormatToEmpty(&orderRealPrice)
+					// b.drawRow(row, "", mat.MatInfo.Name, "", supplierName, mat.MatInfo.Norm, matHeigth, matWidth, mat.MatInfo.Unit, orderCount, orderPrice, orderRealPrice, "")
+
+					// 实际数量
+					confirmCount := fmt.Sprintf("%d", mat.MatInfo.ConfirmCount)
+					b.FormatToEmpty(&confirmCount)
+					// 单价
 					orderPrice := fmt.Sprintf("%.2f", mat.Supplier.OrderPrice)
 					b.FormatToEmpty(&orderPrice)
-
+					// totalOrderRealPrice += mat.Supplier.OrderRealPrice
 					orderRealPrice := fmt.Sprintf("%.2f", mat.Supplier.OrderRealPrice)
 					b.FormatToEmpty(&orderRealPrice)
-					b.drawRow(row, "", mat.MatInfo.Name, "", supplierName, mat.MatInfo.Norm, matHeigth, matWidth, mat.MatInfo.Unit, orderCount, orderPrice, orderRealPrice, "")
+					// 实际金额
+					confirmPrice := mat.Supplier.OrderPrice * float64(mat.MatInfo.ConfirmCount)
+					totalConfirmRealPrice += confirmPrice
+					confirmRealPrice := fmt.Sprintf("%.2f", confirmPrice)
+					b.FormatToEmpty(&confirmRealPrice)
+					b.drawRow(row, "", mat.MatInfo.Name, "", supplierName, mat.MatInfo.Norm, matHeigth, matWidth, mat.MatInfo.Unit, orderCount, confirmCount, orderPrice, orderRealPrice, confirmRealPrice, "", "")
 
 					row++
 					if len(mat.Crafts) > 0 {
@@ -328,11 +391,30 @@ func (b *PlanCostExcel) drawAllContent() error {
 							b.FormatToEmpty(&carftHeigth)
 							carftWidth := fmt.Sprintf("%d", craft.BatchSizeWidth)
 							b.FormatToEmpty(&carftWidth)
+							// carftOrderPrice := fmt.Sprintf("%.2f", craft.Supplier.OrderPrice)
+							// b.FormatToEmpty(&carftOrderPrice)
+							// carftOrderRealPrice := fmt.Sprintf("%.2f", craft.Supplier.OrderRealPrice)
+							// b.FormatToEmpty(&carftOrderRealPrice)
+							// b.drawRow(row, "", "", craft.CraftInfo.Name, craftSupplierName, craft.CraftInfo.Norm, carftHeigth, carftWidth, craft.CraftInfo.Unit, carftOrderCount, carftOrderPrice, carftOrderRealPrice, "")
+
+							// 实际数量
+							confirmCraftCount := fmt.Sprintf("%d", craft.CraftInfo.ConfirmCount)
+							b.FormatToEmpty(&confirmCraftCount)
+
 							carftOrderPrice := fmt.Sprintf("%.2f", craft.Supplier.OrderPrice)
 							b.FormatToEmpty(&carftOrderPrice)
+							// totalOrderRealPrice += craft.Supplier.OrderRealPrice
 							carftOrderRealPrice := fmt.Sprintf("%.2f", craft.Supplier.OrderRealPrice)
 							b.FormatToEmpty(&carftOrderRealPrice)
-							b.drawRow(row, "", "", craft.CraftInfo.Name, craftSupplierName, craft.CraftInfo.Norm, carftHeigth, carftWidth, craft.CraftInfo.Unit, carftOrderCount, carftOrderPrice, carftOrderRealPrice, "")
+
+							// 实际金额
+							confirmCraftPrice := craft.Supplier.OrderPrice * float64(craft.CraftInfo.ConfirmCount)
+							totalConfirmRealPrice += confirmCraftPrice
+							confirmCraftRealPrice := fmt.Sprintf("%.2f", confirmCraftPrice)
+							b.FormatToEmpty(&confirmCraftRealPrice)
+
+							b.drawRow(row, "", "", craft.CraftInfo.Name, craftSupplierName, craft.CraftInfo.Norm, carftHeigth, carftWidth, craft.CraftInfo.Unit, carftOrderCount, confirmCraftCount, carftOrderPrice, carftOrderRealPrice, confirmCraftRealPrice, "", "")
+
 							row++
 
 						}
@@ -359,22 +441,30 @@ func (b *PlanCostExcel) drawAllContent() error {
 				compTotalPrice := fmt.Sprintf("%.2f", comp.TotalPrice)
 				b.FormatToEmpty(&compTotalPrice)
 				b.Excel.SetCellValue(b.SheetName, startLCell, compTotalPrice)
+				confirmTotalPlanPrice += totalConfirmRealPrice
 
 			}
 		}
 		// 生产汇总金额
 		startACell := fmt.Sprintf("%s%d", "A", row)
-		endKCell := fmt.Sprintf("%s%d", "K", row)
-		endLCell := fmt.Sprintf("%s%d", "L", row)
-		b.Excel.MergeCell(b.SheetName, startACell, endKCell)
-		b.Excel.SetCellStyle(b.SheetName, startACell, endKCell, b.AlignCenterStyle)
+		endMCell := fmt.Sprintf("%s%d", "M", row)
+		NCell := fmt.Sprintf("%s%d", "L", row)
+		OCell := fmt.Sprintf("%s%d", "O", row)
+		b.Excel.MergeCell(b.SheetName, startACell, endMCell)
+		b.Excel.SetCellStyle(b.SheetName, startACell, endMCell, b.AlignCenterStyle)
 		b.Excel.SetCellValue(b.SheetName, startACell, "生产计划汇总金额")
 
-		b.Excel.SetCellStyle(b.SheetName, endLCell, endLCell, b.AlignCenterStyle)
+		// 生产预算汇总
+		b.Excel.SetCellStyle(b.SheetName, NCell, NCell, b.AlignCenterStyle)
 		planTotalPrice := fmt.Sprintf("%.2f", b.Content.TotalPrice)
 		b.FormatToEmpty(&planTotalPrice)
-		b.Excel.SetCellValue(b.SheetName, endLCell, planTotalPrice)
+		b.Excel.SetCellValue(b.SheetName, NCell, planTotalPrice)
 
+		// 生产实际汇总
+		b.Excel.SetCellStyle(b.SheetName, OCell, OCell, b.AlignCenterStyle)
+		planConfirmTotalPrice := fmt.Sprintf("%.2f", confirmTotalPlanPrice)
+		b.FormatToEmpty(&planConfirmTotalPrice)
+		b.Excel.SetCellValue(b.SheetName, OCell, planConfirmTotalPrice)
 	}
 
 	return nil
@@ -415,7 +505,7 @@ func NewPlanCostExcel(f *excelize.File) *PlanCostExcel {
 	}
 
 	f.SetColWidth(b.SheetName, "A", "D", 12)
-	f.SetColWidth(b.SheetName, "E", "L", 10)
+	f.SetColWidth(b.SheetName, "E", "O", 10)
 	f.SetPageMargins(b.SheetName, excelize.PageMarginTop(0), excelize.PageMarginLeft(0), excelize.PageMarginRight(0))
 	return b
 }

+ 3 - 1
boxcost/api/utils.go

@@ -68,13 +68,15 @@ func excelToPdf(formBody *bytes.Buffer, pdfHost string) (*http.Response, error)
 	}
 	client := &gotenberg.Client{Hostname: pdfHost, HTTPClient: httpClient}
 	doc, err := gotenberg.NewDocumentFromBytes("foo.xlsx", formBody.Bytes())
+
 	if err != nil {
-		fmt.Println("fdf:", err)
+		fmt.Println(" to pdf read data err:", err)
 		return nil, err
 	}
 
 	req := gotenberg.NewOfficeRequest(doc)
 	req.Landscape(true)
+	req.AddWebhookURLHTTPHeader("scale", "0.7")
 
 	return client.Post(req)
 

+ 1 - 1
boxcost/db/db.go

@@ -35,7 +35,7 @@ func (db *MongoDB) GetOrCreateDatabase(name string) *mongo.Database {
 }
 
 func NewMongoDB(bus *comm.NatsBus) *MongoDB {
-	inst, err := bus.NewMongoDBFromConfig("box-mongo")
+	inst, err := bus.NewMongoDBFromConfigDev("box-mongo")
 	if err != nil {
 		panic(err)
 	}

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

@@ -42,7 +42,7 @@ type PurchaseBill struct {
 	//类别
 	Type string `bson:"type,omitempty" json:"type"`
 
-	//created complete
+	// 进行中 created  已完成 complete 已弃用 deprecated  已审核 reviewed
 	Status     string    `bson:"status,omitempty" json:"status"`
 	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
 	UpdateTime time.Time `bson:"updateTime,omitempty" json:"updateTime"`
@@ -106,7 +106,7 @@ type ProduceBill struct {
 	//类别
 	Type string `bson:"type,omitempty" json:"type"`
 
-	//created complete
+	// 进行中 created  已完成 complete 已弃用 deprecated  已审核 reviewed
 	Status     string    `bson:"status,omitempty" json:"status"`
 	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
 	UpdateTime time.Time `bson:"updateTime,omitempty" json:"updateTime"`

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

@@ -22,4 +22,7 @@ type Craft struct {
 
 	//分类
 	Category string `bson:"category,omitempty" json:"category"`
+
+	//确认收货数量
+	ConfirmCount int `bson:"confirmCount,omitempty" json:"confirmCount"`
 }

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

@@ -39,4 +39,7 @@ type Material struct {
 
 	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
 	UpdateTime time.Time `bson:"updateTime,omitempty" json:"updateTime"`
+
+	//确认收货数量
+	ConfirmCount int `bson:"confirmCount,omitempty" json:"confirmCount"`
 }

二进制
boxcost/signature.png


二进制
boxcost/signature1.png