qidongsheng 0619
This commit is contained in:
@@ -3,12 +3,11 @@ package excel
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"reflect"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"github.com/360EntSecGroup-Skylar/excelize"
|
||||
"io"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
type Obj2ExcelSheetConfig struct {
|
||||
@@ -20,7 +19,8 @@ type Obj2ExcelSheetConfig struct {
|
||||
func Obj2Excel(sheetList []*Obj2ExcelSheetConfig) []byte {
|
||||
globals.SugarLogger.Debug("Obj2Excel")
|
||||
excelFile := excelize.NewFile()
|
||||
for sheetIndex, sheetConfig := range sheetList {
|
||||
//for sheetIndex, sheetConfig := range sheetList {
|
||||
for _, sheetConfig := range sheetList {
|
||||
obj := sheetConfig.Data
|
||||
|
||||
typeInfo := reflect.TypeOf(obj)
|
||||
@@ -39,12 +39,14 @@ func Obj2Excel(sheetList []*Obj2ExcelSheetConfig) []byte {
|
||||
}
|
||||
|
||||
valueInfo := reflect.Indirect(reflect.ValueOf(obj))
|
||||
if sheetIndex == 0 {
|
||||
sheetName := excelFile.GetSheetName(1)
|
||||
excelFile.SetSheetName(sheetName, sheetConfig.Title)
|
||||
} else {
|
||||
excelFile.NewSheet(sheetConfig.Title)
|
||||
}
|
||||
/*因爲默認是Sheet1,所以直接賦值就叫sheet1,然後再改名字就行了,不然會默認多一頁空白頁為sheet1*/
|
||||
//if sheetIndex == 0 {
|
||||
index := excelFile.NewSheet("Sheet1")
|
||||
// sheetName := excelFile.GetSheetName(1)
|
||||
excelFile.SetSheetName("Sheet1", sheetConfig.Title)
|
||||
//} else {
|
||||
// excelFile.NewSheet(sheetConfig.Title)
|
||||
//}
|
||||
isMemberStruct := typeInfo.Kind() == reflect.Struct
|
||||
colWithList := make([]float64, len(sheetConfig.CaptionList))
|
||||
if isMemberStruct {
|
||||
@@ -63,9 +65,9 @@ func Obj2Excel(sheetList []*Obj2ExcelSheetConfig) []byte {
|
||||
for i := 0; i < valueInfo.Len(); i++ {
|
||||
for col, index := range indexSlice {
|
||||
str := fmt.Sprint(reflect.Indirect(valueInfo.Index(i)).FieldByIndex(index).Interface())
|
||||
// if colWith := float64(len(str)); colWith > colWithList[col] {
|
||||
// colWithList[col] = colWith
|
||||
// }
|
||||
//// if colWith := float64(len(str)); colWith > colWithList[col] {
|
||||
//// colWithList[col] = colWith
|
||||
//// }
|
||||
excelFile.SetCellStr(sheetConfig.Title, genAxis(i+1, col), str)
|
||||
}
|
||||
}
|
||||
@@ -104,6 +106,7 @@ func Obj2Excel(sheetList []*Obj2ExcelSheetConfig) []byte {
|
||||
// colName, _ := excelize.ColumnNumberToName(col + 1)
|
||||
// excelFile.SetColWidth(sheetConfig.Title, colName, colName, colWithList[col])
|
||||
// }
|
||||
excelFile.SetActiveSheet(index)
|
||||
}
|
||||
buf := &bytes.Buffer{}
|
||||
excelFile.Write(buf)
|
||||
|
||||
@@ -80,6 +80,7 @@ func NewParallelTask2(taskName string, config *ParallelConfig, ctx *jxcontext.Co
|
||||
if config.ParallelCount > MaxParallelCount {
|
||||
config.ParallelCount = MaxParallelCount
|
||||
}
|
||||
//??
|
||||
realItemList := utils.Interface2Slice(itemList)
|
||||
jobList := jxutils.SplitSlice(realItemList, config.BatchSize)
|
||||
jobListLen := len(jobList)
|
||||
|
||||
@@ -482,7 +482,7 @@ func (t *BaseTask) run(taskHandler func()) {
|
||||
}
|
||||
}
|
||||
|
||||
func SendMessage(t *BaseTask) {
|
||||
func SendMessage(t *BaseTask) {//基类任务
|
||||
time.Sleep(10 * time.Millisecond) // 等待GetResult中的isGetResultCalled赋值
|
||||
globals.SugarLogger.Debugf("BaseTask task ID:%s, name:%s finished, isGetResultCalled:%t", t.ID, t.Name, t.isGetResultCalled)
|
||||
if !t.isGetResultCalled && t.parent == nil && len(GetTasks(t.ID, TaskStatusBegin, TaskStatusEnd, 24, "")) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user