|
@@ -194,7 +194,7 @@ func (b *PlanCostExcel) drawSupplierContent() error {
|
|
|
b.FormatToEmpty(&orderPrice)
|
|
|
// 预算金额
|
|
|
orderRealPrice := fmt.Sprintf("%.2f", mat.Supplier.OrderRealPrice)
|
|
|
- perRealPrice += mat.Supplier.OrderRealPrice
|
|
|
+ perOrderRealPrice += mat.Supplier.OrderRealPrice
|
|
|
b.FormatToEmpty(&orderRealPrice)
|
|
|
// 实际金额
|
|
|
perRealPrice += mat.RealPrice
|
|
@@ -245,9 +245,8 @@ func (b *PlanCostExcel) drawSupplierContent() error {
|
|
|
// 实际金额 在外层合并单元格
|
|
|
realAmount := ""
|
|
|
b.drawRow(row, "", "", craft.CraftInfo.Name, supplierName, craft.CraftInfo.Norm, carftHeigth, carftWidth, craft.CraftInfo.Unit, orderCount, confirmCount, price, budgetAmount, realAmount)
|
|
|
- row++
|
|
|
mergeEndRow = row
|
|
|
-
|
|
|
+ row++
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -285,60 +284,56 @@ func (b *PlanCostExcel) drawSupplierContent() error {
|
|
|
totalRealPrice += perRealPrice
|
|
|
}
|
|
|
|
|
|
- // 工序数据
|
|
|
- if b.Content.Process != nil {
|
|
|
- // 生产汇总金额
|
|
|
- startACell := fmt.Sprintf("%s%d", "A", row)
|
|
|
- endMCell := fmt.Sprintf("%s%d", "K", row)
|
|
|
- b.Excel.MergeCell(b.SheetName, startACell, endMCell)
|
|
|
- b.Excel.SetCellStyle(b.SheetName, startACell, endMCell, b.AlignCenterStyle)
|
|
|
- b.Excel.SetCellValue(b.SheetName, startACell, "额外工序")
|
|
|
- row++
|
|
|
- // 工序 外箱 手工费 表头
|
|
|
- var drawCol = func(startCell, endCell string, value string) error {
|
|
|
- left1Cell := fmt.Sprintf("%s%d", startCell, row)
|
|
|
- left2Cell := fmt.Sprintf("%s%d", endCell, row+1)
|
|
|
-
|
|
|
- err := b.Excel.MergeCell(b.SheetName, left1Cell, left2Cell)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left2Cell, b.AlignCenterStyle)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- return b.Excel.SetCellValue(b.SheetName, left1Cell, value)
|
|
|
+ // 工序数据
|
|
|
+ if b.Content.Process != nil {
|
|
|
+ if len(b.Content.Process) > 0 {
|
|
|
+ isSupplier := false
|
|
|
+ for _, ps := range b.Content.Process {
|
|
|
+ if supplierId == ps.Supplier.SupplierInfo.Id {
|
|
|
+ isSupplier = true
|
|
|
+ break
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- drawCol("B", "C", "材料/工序")
|
|
|
- drawCol("D", "D", "供应商名称")
|
|
|
- drawCol("E", "G", "规格")
|
|
|
- drawCol("H", "H", "单位")
|
|
|
- drawCol("I", "I", "下单数量")
|
|
|
- drawCol("J", "J", "实际数量")
|
|
|
- drawCol("K", "K", "单价")
|
|
|
- drawCol("L", "L", "预算金额")
|
|
|
- drawCol("M", "M", "实际金额")
|
|
|
- row++
|
|
|
-
|
|
|
- var DrawRow = func(rowIndex int, values ...string) {
|
|
|
- charas := []string{"B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M"}
|
|
|
- for i, c := range charas {
|
|
|
- v := ""
|
|
|
- if i < len(values) {
|
|
|
- v = values[i]
|
|
|
+ if isSupplier {
|
|
|
+ // 生产汇总金额
|
|
|
+ startACell := fmt.Sprintf("%s%d", "A", row)
|
|
|
+ endMCell := fmt.Sprintf("%s%d", "K", row)
|
|
|
+ b.Excel.MergeCell(b.SheetName, startACell, endMCell)
|
|
|
+ b.Excel.SetCellStyle(b.SheetName, startACell, endMCell, b.AlignCenterStyle)
|
|
|
+ b.Excel.SetCellValue(b.SheetName, startACell, "额外工序")
|
|
|
+ row++
|
|
|
+ // 工序 外箱 手工费 表头
|
|
|
+ var drawCol = func(startCell, endCell string, value string) error {
|
|
|
+ left1Cell := fmt.Sprintf("%s%d", startCell, row)
|
|
|
+ left2Cell := fmt.Sprintf("%s%d", endCell, row)
|
|
|
+ err := b.Excel.MergeCell(b.SheetName, left1Cell, left2Cell)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
}
|
|
|
- b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("%s%d", c, rowIndex), v)
|
|
|
- val2Cel := fmt.Sprintf("%s%d", c, rowIndex)
|
|
|
- b.Excel.SetCellStyle(b.SheetName, val2Cel, val2Cel, b.AlignCenterStyle)
|
|
|
- b.Excel.SetRowHeight(b.SheetName, rowIndex, 21)
|
|
|
+ err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left2Cell, b.AlignCenterStyle)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+
|
|
|
+ return b.Excel.SetCellValue(b.SheetName, left1Cell, value)
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if len(b.Content.Process) > 0 {
|
|
|
- for _, ps := range b.Content.Process {
|
|
|
- if supplierId == ps.Supplier.SupplierInfo.Id {
|
|
|
+ drawCol("A", "A", "")
|
|
|
+ drawCol("B", "C", "材料/工序")
|
|
|
+ drawCol("D", "E", "供应商名称")
|
|
|
+ drawCol("F", "G", "规格")
|
|
|
+ drawCol("H", "H", "单位")
|
|
|
+ drawCol("I", "I", "下单数量")
|
|
|
+ drawCol("J", "J", "实际数量")
|
|
|
+ drawCol("K", "K", "单价")
|
|
|
+ drawCol("L", "L", "预算金额")
|
|
|
+ drawCol("M", "M", "实际金额")
|
|
|
+ row++
|
|
|
+ if len(b.Content.Process) > 0 {
|
|
|
+ for _, ps := range b.Content.Process {
|
|
|
orderCount := fmt.Sprintf("%.2f", ps.Supplier.OrderCount)
|
|
|
confirmCount := fmt.Sprintf("%d", ps.ConfirmCount)
|
|
|
price := fmt.Sprintf("%.2f", ps.Supplier.OrderPrice)
|
|
@@ -348,9 +343,23 @@ func (b *PlanCostExcel) drawSupplierContent() error {
|
|
|
orderRealPrice := fmt.Sprintf("%.2f", ps.Supplier.OrderRealPrice)
|
|
|
b.FormatToEmpty(&orderRealPrice)
|
|
|
realPrice := fmt.Sprintf("%.2f", ps.RealPrice)
|
|
|
- DrawRow(row, ps.ProcessInfo.Name, ps.Supplier.SupplierInfo.Name, ps.ProcessInfo.Norm, ps.ProcessInfo.Unit, orderCount, confirmCount, price, orderRealPrice, realPrice)
|
|
|
- row++
|
|
|
+ supplierName := ""
|
|
|
+ if ps.Supplier.SupplierInfo != nil {
|
|
|
+ supplierName = ps.Supplier.SupplierInfo.Name
|
|
|
+ }
|
|
|
+
|
|
|
+ b.drawRow(row, "", "", "", "", "", "", "", ps.ProcessInfo.Unit, orderCount, confirmCount, price, orderRealPrice, realPrice)
|
|
|
|
|
|
+ b.Excel.MergeCell(b.SheetName, fmt.Sprintf("%s%d", "B", row), fmt.Sprintf("%s%d", "C", row))
|
|
|
+ b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("%s%d", "B", row), ps.ProcessInfo.Name)
|
|
|
+
|
|
|
+ b.Excel.MergeCell(b.SheetName, fmt.Sprintf("%s%d", "D", row), fmt.Sprintf("%s%d", "E", row))
|
|
|
+ b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("%s%d", "D", row), supplierName)
|
|
|
+
|
|
|
+ b.Excel.MergeCell(b.SheetName, fmt.Sprintf("%s%d", "F", row), fmt.Sprintf("%s%d", "G", row))
|
|
|
+ b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("%s%d", "F", row), ps.ProcessInfo.Norm)
|
|
|
+
|
|
|
+ row++
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -359,29 +368,29 @@ func (b *PlanCostExcel) drawSupplierContent() error {
|
|
|
|
|
|
}
|
|
|
|
|
|
- // 生产汇总金额
|
|
|
- startACell := fmt.Sprintf("%s%d", "A", row)
|
|
|
- endKCell := fmt.Sprintf("%s%d", "K", row)
|
|
|
- LCell := fmt.Sprintf("%s%d", "L", row)
|
|
|
- MCell := fmt.Sprintf("%s%d", "M", row)
|
|
|
- b.Excel.MergeCell(b.SheetName, startACell, endKCell)
|
|
|
- b.Excel.SetCellStyle(b.SheetName, startACell, endKCell, b.AlignCenterStyle)
|
|
|
- b.Excel.SetCellValue(b.SheetName, startACell, "生产计划汇总金额")
|
|
|
-
|
|
|
- // 生产预算汇总
|
|
|
- b.Excel.SetCellStyle(b.SheetName, LCell, LCell, b.AlignCenterStyle)
|
|
|
- planOrderRealPrice := fmt.Sprintf("%.2f", totalOrderRealPrice)
|
|
|
- b.FormatToEmpty(&planOrderRealPrice)
|
|
|
- b.Excel.SetCellValue(b.SheetName, LCell, planOrderRealPrice)
|
|
|
-
|
|
|
- // 生产实际汇总
|
|
|
- b.Excel.SetCellStyle(b.SheetName, MCell, MCell, b.AlignCenterStyle)
|
|
|
- planRealPrice := fmt.Sprintf("%.2f", totalRealPrice)
|
|
|
- b.FormatToEmpty(&planRealPrice)
|
|
|
- b.Excel.SetCellValue(b.SheetName, MCell, planRealPrice)
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+ // 生产汇总金额
|
|
|
+ startACell := fmt.Sprintf("%s%d", "A", row)
|
|
|
+ endKCell := fmt.Sprintf("%s%d", "K", row)
|
|
|
+ LCell := fmt.Sprintf("%s%d", "L", row)
|
|
|
+ MCell := fmt.Sprintf("%s%d", "M", row)
|
|
|
+ b.Excel.MergeCell(b.SheetName, startACell, endKCell)
|
|
|
+ b.Excel.SetCellStyle(b.SheetName, startACell, endKCell, b.AlignCenterStyle)
|
|
|
+ b.Excel.SetCellValue(b.SheetName, startACell, "生产计划汇总金额")
|
|
|
+
|
|
|
+ // 生产预算汇总
|
|
|
+ b.Excel.SetCellStyle(b.SheetName, LCell, LCell, b.AlignCenterStyle)
|
|
|
+ planOrderRealPrice := fmt.Sprintf("%.2f", totalOrderRealPrice)
|
|
|
+ b.FormatToEmpty(&planOrderRealPrice)
|
|
|
+ b.Excel.SetCellValue(b.SheetName, LCell, planOrderRealPrice)
|
|
|
+
|
|
|
+ // 生产实际汇总
|
|
|
+ b.Excel.SetCellStyle(b.SheetName, MCell, MCell, b.AlignCenterStyle)
|
|
|
+ planRealPrice := fmt.Sprintf("%.2f", totalRealPrice)
|
|
|
+ b.FormatToEmpty(&planRealPrice)
|
|
|
+ b.Excel.SetCellValue(b.SheetName, MCell, planRealPrice)
|
|
|
+
|
|
|
return nil
|
|
|
}
|
|
|
|
|
@@ -436,7 +445,7 @@ func (b *PlanCostExcel) drawAllContent() error {
|
|
|
b.FormatToEmpty(&orderPrice)
|
|
|
// 预算金额
|
|
|
orderRealPrice := fmt.Sprintf("%.2f", mat.Supplier.OrderRealPrice)
|
|
|
- perRealPrice += mat.Supplier.OrderRealPrice
|
|
|
+ perOrderRealPrice += mat.Supplier.OrderRealPrice
|
|
|
b.FormatToEmpty(&orderRealPrice)
|
|
|
// 实际金额
|
|
|
perRealPrice += mat.RealPrice
|
|
@@ -475,8 +484,9 @@ func (b *PlanCostExcel) drawAllContent() error {
|
|
|
// 实际金额 在外层合并单元格
|
|
|
realAmount := ""
|
|
|
b.drawRow(row, "", "", craft.CraftInfo.Name, supplierName, craft.CraftInfo.Norm, carftHeigth, carftWidth, craft.CraftInfo.Unit, orderCount, confirmCount, price, budgetAmount, realAmount)
|
|
|
- row++
|
|
|
mergeEndRow = row
|
|
|
+ row++
|
|
|
+
|
|
|
}
|
|
|
// 多个工序 合并预算价格、实际价格
|
|
|
b.Excel.MergeCell(b.SheetName, fmt.Sprintf("L%d", mergeStartRow), fmt.Sprintf("L%d", mergeEndRow))
|
|
@@ -501,11 +511,10 @@ func (b *PlanCostExcel) drawAllContent() error {
|
|
|
|
|
|
// 预算
|
|
|
totalOrderRealPrice += perOrderRealPrice
|
|
|
- // 预算
|
|
|
+ // 实际金额
|
|
|
totalRealPrice += perRealPrice
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
// 工序数据
|
|
|
if b.Content.Process != nil {
|
|
|
// 生产汇总金额
|
|
@@ -518,8 +527,7 @@ func (b *PlanCostExcel) drawAllContent() error {
|
|
|
// 工序 外箱 手工费 表头
|
|
|
var drawCol = func(startCell, endCell string, value string) error {
|
|
|
left1Cell := fmt.Sprintf("%s%d", startCell, row)
|
|
|
- left2Cell := fmt.Sprintf("%s%d", endCell, row+1)
|
|
|
-
|
|
|
+ left2Cell := fmt.Sprintf("%s%d", endCell, row)
|
|
|
err := b.Excel.MergeCell(b.SheetName, left1Cell, left2Cell)
|
|
|
if err != nil {
|
|
|
return err
|
|
@@ -532,9 +540,10 @@ func (b *PlanCostExcel) drawAllContent() error {
|
|
|
return b.Excel.SetCellValue(b.SheetName, left1Cell, value)
|
|
|
}
|
|
|
|
|
|
+ drawCol("A", "A", "")
|
|
|
drawCol("B", "C", "材料/工序")
|
|
|
- drawCol("D", "D", "供应商名称")
|
|
|
- drawCol("E", "G", "规格")
|
|
|
+ drawCol("D", "E", "供应商名称")
|
|
|
+ drawCol("F", "G", "规格")
|
|
|
drawCol("H", "H", "单位")
|
|
|
drawCol("I", "I", "下单数量")
|
|
|
drawCol("J", "J", "实际数量")
|
|
@@ -542,21 +551,6 @@ func (b *PlanCostExcel) drawAllContent() error {
|
|
|
drawCol("L", "L", "预算金额")
|
|
|
drawCol("M", "M", "实际金额")
|
|
|
row++
|
|
|
-
|
|
|
- var DrawRow = func(rowIndex int, values ...string) {
|
|
|
- charas := []string{"B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M"}
|
|
|
- for i, c := range charas {
|
|
|
- v := ""
|
|
|
- if i < len(values) {
|
|
|
- v = values[i]
|
|
|
- }
|
|
|
- b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("%s%d", c, rowIndex), v)
|
|
|
- val2Cel := fmt.Sprintf("%s%d", c, rowIndex)
|
|
|
- b.Excel.SetCellStyle(b.SheetName, val2Cel, val2Cel, b.AlignCenterStyle)
|
|
|
- b.Excel.SetRowHeight(b.SheetName, rowIndex, 21)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
if len(b.Content.Process) > 0 {
|
|
|
for _, ps := range b.Content.Process {
|
|
|
orderCount := fmt.Sprintf("%.2f", ps.Supplier.OrderCount)
|
|
@@ -568,7 +562,22 @@ func (b *PlanCostExcel) drawAllContent() error {
|
|
|
orderRealPrice := fmt.Sprintf("%.2f", ps.Supplier.OrderRealPrice)
|
|
|
b.FormatToEmpty(&orderRealPrice)
|
|
|
realPrice := fmt.Sprintf("%.2f", ps.RealPrice)
|
|
|
- DrawRow(row, ps.ProcessInfo.Name, ps.Supplier.SupplierInfo.Name, ps.ProcessInfo.Norm, ps.ProcessInfo.Unit, orderCount, confirmCount, price, orderRealPrice, realPrice)
|
|
|
+ supplierName := ""
|
|
|
+ if ps.Supplier.SupplierInfo != nil {
|
|
|
+ supplierName = ps.Supplier.SupplierInfo.Name
|
|
|
+ }
|
|
|
+
|
|
|
+ b.drawRow(row, "", "", "", "", "", "", "", ps.ProcessInfo.Unit, orderCount, confirmCount, price, orderRealPrice, realPrice)
|
|
|
+
|
|
|
+ b.Excel.MergeCell(b.SheetName, fmt.Sprintf("%s%d", "B", row), fmt.Sprintf("%s%d", "C", row))
|
|
|
+ b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("%s%d", "B", row), ps.ProcessInfo.Name)
|
|
|
+
|
|
|
+ b.Excel.MergeCell(b.SheetName, fmt.Sprintf("%s%d", "D", row), fmt.Sprintf("%s%d", "E", row))
|
|
|
+ b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("%s%d", "D", row), supplierName)
|
|
|
+
|
|
|
+ b.Excel.MergeCell(b.SheetName, fmt.Sprintf("%s%d", "F", row), fmt.Sprintf("%s%d", "G", row))
|
|
|
+ b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("%s%d", "F", row), ps.ProcessInfo.Norm)
|
|
|
+
|
|
|
row++
|
|
|
}
|
|
|
|