suncloud 1 ano atrás
pai
commit
219e292dfc

+ 1 - 0
configer/app.yaml

@@ -15,6 +15,7 @@ configer:
     value: 127.0.0.1:6379#0#default#copter_vxxx
     devValue: 127.0.0.1:6397#0#default#copter_vxxx
 
+
 # adapter:
 #   -
 #     busName: comm

+ 2 - 0
configer/bin/v2.9.0/linux-amd64/nats-server

@@ -0,0 +1,2 @@
+{"level":"error","timestamp":"2024-02-20 15:00:32","message":"the nats service start fail fork/exec ./nats-server: permission denied","service_name":"copter-bus"}
+{"level":"error","timestamp":"2024-02-20 15:03:51","message":"the nats service start fail fork/exec ./nats-server: permission denied","service_name":"copter-bus"}

+ 19 - 18
src/api/excel.go

@@ -58,15 +58,15 @@ func (b *TestExcel) drawTitle() error {
 	endCell := fmt.Sprintf("H%d", b.Row)
 
 	b.RowMap = map[string]int{"A": 0, "B": 1, "C": 2, "D": 3, "E": 4, "F": 5, "G": 6, "H": 7}
-	b.RowWidthArray = []float64{11, 11, 11, 10, 7, 10, 7, 6.5}
-	b.Excel.SetColWidth(b.SheetName, "A", "A", 11)
-	b.Excel.SetColWidth(b.SheetName, "B", "B", 10)
-	b.Excel.SetColWidth(b.SheetName, "C", "C", 7)
+	b.RowWidthArray = []float64{16, 6, 10, 10, 10, 10, 6, 4}
+	b.Excel.SetColWidth(b.SheetName, "A", "A", 18)
+	b.Excel.SetColWidth(b.SheetName, "B", "B", 6)
+	b.Excel.SetColWidth(b.SheetName, "C", "C", 10)
 	b.Excel.SetColWidth(b.SheetName, "D", "D", 10)
-	b.Excel.SetColWidth(b.SheetName, "E", "E", 7)
-	b.Excel.SetColWidth(b.SheetName, "F", "F", 6.5)
-	b.Excel.SetColWidth(b.SheetName, "G", "G", 9)
-	b.Excel.SetColWidth(b.SheetName, "H", "H", 12)
+	b.Excel.SetColWidth(b.SheetName, "E", "E", 10)
+	b.Excel.SetColWidth(b.SheetName, "F", "F", 10)
+	b.Excel.SetColWidth(b.SheetName, "G", "G", 6)
+	b.Excel.SetColWidth(b.SheetName, "H", "H", 4)
 
 	// b.Excel.SetPageMargins(b.SheetName, marginLeft)
 	err := b.Excel.MergeCell(b.SheetName, startCell, endCell)
@@ -92,19 +92,19 @@ func (b *TestExcel) drawTitle() error {
 func (b *TestExcel) drawTableTitle() error {
 	b.Row++
 	var drawCol = func(prefix string, value string) error {
-		left1Cell := fmt.Sprintf("%s%d", prefix, b.Row)
-		left2Cell := fmt.Sprintf("%s%d", prefix, b.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)
+		cell := fmt.Sprintf("%s%d", prefix, b.Row)
+		// left2Cell := fmt.Sprintf("%s%d", prefix, b.Row+1)
+
+		// err := b.Excel.MergeCell(b.SheetName, left1Cell, left2Cell)
+		// if err != nil {
+		// 	return err
+		// }
+		err := b.Excel.SetCellStyle(b.SheetName, cell, cell, b.AlignCenterStyle)
 		if err != nil {
 			return err
 		}
 
-		return b.Excel.SetCellValue(b.SheetName, left1Cell, value)
+		return b.Excel.SetCellValue(b.SheetName, cell, value)
 	}
 
 	drawCol("A", "题目")
@@ -115,12 +115,13 @@ func (b *TestExcel) drawTableTitle() error {
 	drawCol("F", "选项D")
 	drawCol("G", "分值")
 	drawCol("H", "答案")
+	b.Excel.SetRowHeight(b.SheetName, b.Row, 20)
 
 	return nil
 }
 
 func (b *TestExcel) drawTableContent() error {
-	b.Row += 2
+	b.Row++
 	var DrawRow = func(rowIndex int, values ...string) float64 {
 		charas := []string{"A", "B", "C", "D", "E", "F", "G", "H"}
 		// 获取该行最大行高

+ 5 - 2
src/api/test.go

@@ -259,9 +259,10 @@ func ExportTest(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 		return nil, err
 	}
 	testExcel.Content = tests
+	fmt.Println(len(tests))
 	testExcel.Draws()
 	c.Header("Content-Type", "application/octet-stream")
-	c.Header("Content-Disposition", "attachment; filename="+"bill.xlsx")
+	c.Header("Content-Disposition", "attachment; filename="+fmt.Sprintf("%s-考核试题.xlsx", db))
 	c.Header("Content-Transfer-Encoding", "binary")
 
 	err = f.Write(c.Writer)
@@ -274,11 +275,13 @@ func ExportTest(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 
 // 下载试题模板
 func TestTmplate(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+	db := c.Param("scope")
+	fmt.Println(db)
 	// 设置下载的文件名
 	c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", TESTS_TMPLATE_FILE))
 
 	// 设置文件类型
-	c.Writer.Header().Set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
+	c.Writer.Header().Add("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
 
 	c.File(TESTS_TMPLATE_FILE)
 	return nil, nil

+ 1 - 1
src/api/utils.go

@@ -2,7 +2,7 @@ package api
 
 import "math"
 
-const TESTS_TMPLATE_FILE = "./file/试题模板.xlsx"
+const TESTS_TMPLATE_FILE = "./file/考核试题模板.xlsx"
 
 // func getRowHeight(content string, width float64,lineHeight float64) float64 {
 // 第一个参数为 行宽 第二个参数为 行高

BIN
src/file/考核试题模板.xlsx


+ 0 - 0
src/file/试题模板.xlsx