|
|
@@ -2,6 +2,9 @@ package oilsupplier
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
+ "fmt"
|
|
|
+ "github.com/tealeg/xlsx"
|
|
|
+ "reflect"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
@@ -880,3 +883,86 @@ func (this *OilGoodsAptitudeController) GoodsChildLisByParentId() {
|
|
|
this.Data["json"] = &datainfo
|
|
|
this.ServeJSON()
|
|
|
}
|
|
|
+
|
|
|
+// @Title get 导出ex
|
|
|
+// @Description get SampleType by token
|
|
|
+// @Success 200 {object} sampletype.SampleType
|
|
|
+// @router /exportexcelall [get]
|
|
|
+func (this *OilGoodsAptitudeController) ExportExcelAll() {
|
|
|
+ //获取分页信息
|
|
|
+ //page := this.GetPageInfoForm()
|
|
|
+ where := " 1=1 "
|
|
|
+ orderby := "Code"
|
|
|
+ asc := true
|
|
|
+ Order := this.GetString("Order")
|
|
|
+ Prop := this.GetString("Prop")
|
|
|
+ if Order != "" && Prop != "" {
|
|
|
+ orderby = Prop
|
|
|
+ if Order == "asc" {
|
|
|
+ asc = true
|
|
|
+ } else {
|
|
|
+ asc = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Edition := this.GetString("Edition")
|
|
|
+
|
|
|
+ if Edition != "" {
|
|
|
+ where = where + " and Edition = '" + Edition + "'"
|
|
|
+ }
|
|
|
+
|
|
|
+ t := time.Now()
|
|
|
+ svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
|
|
|
+ var list []goodsaptitude.OilGoodsAptitudeView
|
|
|
+ svc.GetMyPagingEntitiesWithOrderBytbl(OilGoodsAptDetailViewName, 0, 0, orderby, asc, &list, where)
|
|
|
+
|
|
|
+ var title []string
|
|
|
+ filetitle := "物资类"
|
|
|
+ //自定义显示列
|
|
|
+ showcolumnarr := this.GetString("showcolumnarr")
|
|
|
+ showcolumnnamearr := this.GetString("showcolumnnamearr")
|
|
|
+ titlestring := showcolumnnamearr
|
|
|
+ title = strings.Split(titlestring, ",")
|
|
|
+ f := xlsx.NewFile()
|
|
|
+ sheet, _ := f.AddSheet(filetitle)
|
|
|
+ //rowhead := sheet.AddRow()
|
|
|
+ //rowhead.WriteSlice(&title, -1)
|
|
|
+ cellname := strings.Split(showcolumnarr, ",")
|
|
|
+ row := sheet.AddRow()
|
|
|
+ row.WriteSlice(&cellname, -1)
|
|
|
+
|
|
|
+ for _, item := range list {
|
|
|
+ var enumModel goodsaptitude.OilGoodsAptitudeView
|
|
|
+ tmpModel := &item
|
|
|
+ enumModel = *tmpModel
|
|
|
+ immumodel := reflect.ValueOf(&enumModel)
|
|
|
+ elem := immumodel.Elem()
|
|
|
+ row := sheet.AddRow()
|
|
|
+ for _, name := range title {
|
|
|
+ cell := row.AddCell()
|
|
|
+ if strings.HasPrefix(name, "F") {
|
|
|
+ var val = elem.FieldByName(name).String()
|
|
|
+ if val == "1" {
|
|
|
+ cell.Value = "是"
|
|
|
+ } else {
|
|
|
+ cell.Value = ""
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ cell.Value = elem.FieldByName(name).String()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for c, cl := 0, len(sheet.Cols); c < cl; c++ {
|
|
|
+ sheet.Cols[c].Width = 20
|
|
|
+ }
|
|
|
+ //this.SaveSampleXlsx(filetitle, title, showcolumnarr, list, f)
|
|
|
+
|
|
|
+ dir := "static/file/excel/report/" + this.GetAccode()
|
|
|
+ SaveDirectory(dir)
|
|
|
+ path := dir + "/" + utils.TimeFormat(time.Now(), "200612") + filetitle + ".xlsx"
|
|
|
+ f.Save(path)
|
|
|
+ this.Data["json"] = this.Ctx.Request.Host + "/" + path
|
|
|
+ this.ServeJSON()
|
|
|
+ elapsed := time.Since(t)
|
|
|
+ fmt.Println(elapsed)
|
|
|
+}
|