|
@@ -47,12 +47,22 @@ func MatchString(targetStr string, regexPattern string) bool {
|
|
|
return re.MatchString(targetStr)
|
|
|
}
|
|
|
|
|
|
+type PlanStatusInfo struct {
|
|
|
+ PlanName string `json:"planName"`
|
|
|
+ PlanUnit string `json:"planUnit"`
|
|
|
+ PlanCount int `json:"planCount"`
|
|
|
+ PlanRowStart int `json:"planRowStart"`
|
|
|
+ PlanRowEnd int `json:"planRowEnd"`
|
|
|
+ PlanCompStatus []map[string]string `json:"planCompStatus"`
|
|
|
+}
|
|
|
+
|
|
|
func UpdateExcel(client *mongo.Client, plans []*model.ProductPlan) {
|
|
|
row := 5
|
|
|
- planCompStatus := []map[string]string{}
|
|
|
|
|
|
+ planStatusInfos := make([]*PlanStatusInfo, 0)
|
|
|
+ planCompStatus := []map[string]string{}
|
|
|
for _, plan := range plans {
|
|
|
-
|
|
|
+ startRow := row
|
|
|
for _, comp := range plan.Pack.Components {
|
|
|
|
|
|
|
|
@@ -85,6 +95,10 @@ func UpdateExcel(client *mongo.Client, plans []*model.ProductPlan) {
|
|
|
"组装": " ",
|
|
|
"交货": " ",
|
|
|
}
|
|
|
+ fmt.Println(plan.Name)
|
|
|
+ fmt.Println(comp.Name)
|
|
|
+ fmt.Println(row)
|
|
|
+ fmt.Println("------------------------------------")
|
|
|
compStatus["部件"] = comp.Name
|
|
|
compStatus["行数"] = fmt.Sprintf("%d", row)
|
|
|
row++
|
|
@@ -92,6 +106,13 @@ func UpdateExcel(client *mongo.Client, plans []*model.ProductPlan) {
|
|
|
seen := make(map[string]bool)
|
|
|
tbills := make([]string, 0, len(comp.Stages))
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
for _, stage := range comp.Stages {
|
|
|
|
|
|
if len(stage.BillId) > 0 {
|
|
@@ -159,6 +180,9 @@ func UpdateExcel(client *mongo.Client, plans []*model.ProductPlan) {
|
|
|
compStatus["纸张"] = "√"
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if lastBillType == billType {
|
|
|
for _, paper := range bill.Paper {
|
|
|
compStatus["交货"] = fmt.Sprintf("%d", paper.ConfirmCount)
|
|
@@ -187,6 +211,10 @@ func UpdateExcel(client *mongo.Client, plans []*model.ProductPlan) {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
compStatus["交货"] = fmt.Sprintf("%d", produce.ConfirmCount)
|
|
|
}
|
|
|
|
|
@@ -203,6 +231,9 @@ func UpdateExcel(client *mongo.Client, plans []*model.ProductPlan) {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if lastBillType == billType {
|
|
|
for _, product := range bill.Products {
|
|
|
compStatus["交货"] = fmt.Sprintf("%d", product.ConfirmCount)
|
|
@@ -213,10 +244,23 @@ func UpdateExcel(client *mongo.Client, plans []*model.ProductPlan) {
|
|
|
|
|
|
planCompStatus = append(planCompStatus, compStatus)
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ planStatusInfos = append(planStatusInfos, &PlanStatusInfo{
|
|
|
+ PlanName: plan.Name,
|
|
|
+
|
|
|
+ PlanUnit: "",
|
|
|
+ PlanCount: plan.Total,
|
|
|
+ PlanRowStart: startRow,
|
|
|
+ PlanRowEnd: row - 1,
|
|
|
+ PlanCompStatus: planCompStatus,
|
|
|
+ })
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- UpdateCell(planCompStatus)
|
|
|
+
|
|
|
+
|
|
|
+ UpdateCell1(planStatusInfos)
|
|
|
|
|
|
}
|
|
|
|
|
@@ -303,3 +347,102 @@ func UpdateCell(planCompStatus []map[string]string) {
|
|
|
log.Fatal(err)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func UpdateCell1(planStatusInfos []*PlanStatusInfo) {
|
|
|
+ tmpfile, err := excelize.OpenFile(EXCEL_TMPLATE_FILE)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal(err)
|
|
|
+ }
|
|
|
+ excelIndex := tmpfile.GetActiveSheetIndex()
|
|
|
+ sheetName := tmpfile.GetSheetName(excelIndex)
|
|
|
+
|
|
|
+ style, err := tmpfile.NewStyle(&excelize.Style{
|
|
|
+ Border: []excelize.Border{
|
|
|
+ {
|
|
|
+ Type: "left",
|
|
|
+ Color: "FF000000",
|
|
|
+ Style: 1,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Type: "right",
|
|
|
+ Color: "FF000000",
|
|
|
+ Style: 1,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Type: "top",
|
|
|
+ Color: "FF000000",
|
|
|
+ Style: 1,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Type: "bottom",
|
|
|
+ Color: "FF000000",
|
|
|
+ Style: 1,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ Fill: excelize.Fill{
|
|
|
+ Type: "pattern",
|
|
|
+ Pattern: 1,
|
|
|
+ Color: []string{CELL_BACKGROUND},
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal(err)
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, planStatusInfo := range planStatusInfos {
|
|
|
+
|
|
|
+
|
|
|
+ err = tmpfile.SetCellValue(sheetName, fmt.Sprintf("%s%d", "B", planStatusInfo.PlanRowStart), planStatusInfo.PlanName)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal(err)
|
|
|
+ }
|
|
|
+
|
|
|
+ err = tmpfile.SetCellValue(sheetName, fmt.Sprintf("%s%d", "D", planStatusInfo.PlanRowStart), planStatusInfo.PlanCount)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal(err)
|
|
|
+ }
|
|
|
+
|
|
|
+ planCompStatus := planStatusInfo.PlanCompStatus
|
|
|
+ for _, compStatus := range planCompStatus {
|
|
|
+
|
|
|
+ row := compStatus["行数"]
|
|
|
+ for colk, col := range needChangeCol {
|
|
|
+ for csk, csv := range compStatus {
|
|
|
+ if colk == csk {
|
|
|
+ cell := fmt.Sprintf("%s%s", col, row)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if csv == CELL_BACKGROUND {
|
|
|
+
|
|
|
+ err = tmpfile.SetCellStyle(sheetName, cell, cell, style)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal(err)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+
|
|
|
+ err = tmpfile.SetCellValue(sheetName, cell, csv)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal(err)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ date := time.Now().Format("2006年01月02日_150405")
|
|
|
+ fileName := fmt.Sprintf("礼盒加工追踪表_%s.xlsx", date)
|
|
|
+
|
|
|
+
|
|
|
+ err = tmpfile.SaveAs(fileName)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal(err)
|
|
|
+ }
|
|
|
+}
|