Browse Source

优化设置背景

sunsheng 9 months ago
parent
commit
cfc082916e
2 changed files with 37 additions and 36 deletions
  1. 3 1
      app.yaml
  2. 34 35
      el/excel.go

+ 3 - 1
app.yaml

@@ -12,4 +12,6 @@ plans:
   - "66499ae023830800fd775212"
   - "6649990123830800fd775210"
   - "66499c1d23830800fd775213"
-  - "66499cfd23830800fd775214"
+  - "66499cfd23830800fd775214"
+  # 异常数据
+  # - "6679876623830800fd77569c" 2_667988be23830800fd77569f

+ 34 - 35
el/excel.go

@@ -122,6 +122,7 @@ func UpdateExcel(client *mongo.Client, plans []*model.ProductPlan) {
 				}
 
 			}
+			fmt.Println(tbills)
 
 			// 如果tbills为空,说明该部件没有订单
 			if len(tbills) == 0 {
@@ -223,6 +224,39 @@ func UpdateCell(planCompStatus []map[string]string) {
 	}
 	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, // 1 表示实心填充
+			Color:   []string{CELL_BACKGROUND},
+		},
+	})
+	if err != nil {
+		log.Fatal(err)
+	}
 
 	for _, compStatus := range planCompStatus {
 		// fmt.Println("-----------------------------------------------")
@@ -237,41 +271,6 @@ func UpdateCell(planCompStatus []map[string]string) {
 					// 设置背景
 					if csv == CELL_BACKGROUND {
 						// 设置单元格的值
-
-						// 定义样式
-						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, // 1 表示实心填充
-								Color:   []string{CELL_BACKGROUND},
-							},
-						})
-						if err != nil {
-							log.Fatal(err)
-						}
-
 						err = tmpfile.SetCellStyle(sheetName, cell, cell, style)
 						if err != nil {
 							log.Fatal(err)