Просмотр исходного кода

Merge branch 'bzq/excel_style' of eta_gn_server/eta_chart_lib into debug

baoziqiang 5 месяцев назад
Родитель
Сommit
97b98f7b63
3 измененных файлов с 16 добавлено и 54 удалено
  1. 1 0
      models/request/mixed_table.go
  2. 11 0
      services/excel/lucky_sheet.go
  3. 4 54
      utils/common.go

+ 1 - 0
models/request/mixed_table.go

@@ -167,6 +167,7 @@ type MixCellShowStyle struct {
 	Last            string      `description:"起始操作:nt|decimal" json:"last"`
 	Color           string      `description:"颜色值,#RRG" json:"color"`
 	BackgroundColor string      `description:"背景颜色值,#RRG" json:"background-color"`
+	Align           string      `description:"对齐方式:left|center|right" json:"align"`
 }
 
 type DateDataBeforeAfterReq struct {

+ 11 - 0
services/excel/lucky_sheet.go

@@ -1231,6 +1231,17 @@ func GetTableDataByMixedTableData(config [][]request.MixedTableCellDataReq, hide
 							cell.ShowValue = cell.Value
 						}
 					}
+					switch styleConfig.Align {
+					case "center":
+						tmp.HorizontalType = 0
+						tmp.Ht = 0
+					case "left":
+						tmp.HorizontalType = 1
+						tmp.Ht = 1
+					case "right":
+						tmp.HorizontalType = 2
+						tmp.Ht = 2
+					}
 					_, err := strconv.ParseFloat(cell.ShowValue, 64)
 					if err == nil {
 						hasPercent := false

+ 4 - 54
utils/common.go

@@ -19,7 +19,6 @@ import (
 	"net"
 	"net/http"
 	"os"
-	"os/exec"
 	"path"
 	"regexp"
 	"strconv"
@@ -30,13 +29,12 @@ import (
 	"gorm.io/gorm"
 )
 
-// 随机数种子
-var rnd = rand.New(rand.NewSource(time.Now().UnixNano()))
-
 func GetRandString(size int) string {
 	allLetterDigit := []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "!", "@", "#", "$", "%", "^", "&", "*"}
 	randomSb := ""
 	digitSize := len(allLetterDigit)
+	// 随机数种子
+	rnd := rand.New(rand.NewSource(time.Now().UnixNano()))
 	for i := 0; i < size; i++ {
 		randomSb += allLetterDigit[rnd.Intn(digitSize)]
 	}
@@ -47,6 +45,8 @@ func GetRandStringNoSpecialChar(size int) string {
 	allLetterDigit := []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
 	randomSb := ""
 	digitSize := len(allLetterDigit)
+	// 随机数种子
+	rnd := rand.New(rand.NewSource(time.Now().UnixNano()))
 	for i := 0; i < size; i++ {
 		randomSb += allLetterDigit[rnd.Intn(digitSize)]
 	}
@@ -79,23 +79,6 @@ func MD5(data string) string {
 	return hex.EncodeToString(m[:])
 }
 
-// 获取数字随机字符
-func GetRandDigit(n int) string {
-	return fmt.Sprintf("%0"+strconv.Itoa(n)+"d", rnd.Intn(int(math.Pow10(n))))
-}
-
-// 获取随机数
-func GetRandNumber(n int) int {
-	return rnd.Intn(n)
-}
-
-func GetRandInt(min, max int) int {
-	if min >= max || min == 0 || max == 0 {
-		return max
-	}
-	return rand.Intn(max-min) + min
-}
-
 func GetToday(format string) string {
 	today := time.Now().Format(format)
 	return today
@@ -534,39 +517,6 @@ func Sha1(data string) string {
 	return hex.EncodeToString(sha1.Sum([]byte("")))
 }
 
-func GetVideoPlaySeconds(videoPath string) (playSeconds float64, err error) {
-	cmd := `ffmpeg -i ` + videoPath + `  2>&1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,//`
-	out, err := exec.Command("bash", "-c", cmd).Output()
-	if err != nil {
-		return
-	}
-	outTimes := string(out)
-	fmt.Println("outTimes:", outTimes)
-	if outTimes != "" {
-		timeArr := strings.Split(outTimes, ":")
-		h := timeArr[0]
-		m := timeArr[1]
-		s := timeArr[2]
-		hInt, err := strconv.Atoi(h)
-		if err != nil {
-			return playSeconds, err
-		}
-
-		mInt, err := strconv.Atoi(m)
-		if err != nil {
-			return playSeconds, err
-		}
-		s = strings.Trim(s, " ")
-		s = strings.Trim(s, "\n")
-		sInt, err := strconv.ParseFloat(s, 64)
-		if err != nil {
-			return playSeconds, err
-		}
-		playSeconds = float64(hInt)*3600 + float64(mInt)*60 + float64(sInt)
-	}
-	return
-}
-
 func GetMaxTradeCode(tradeCode string) (maxTradeCode string, err error) {
 	tradeCode = strings.Replace(tradeCode, "W", "", -1)
 	tradeCode = strings.Trim(tradeCode, " ")