|
@@ -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
|
|
|
}
|