conf/config.yaml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
response/report_forms_response.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
service/location_forms.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
conf/config.yaml
@@ -11,7 +11,7 @@ companyName: jialian db: # dsn: root:c++java123@tcp(192.168.20.119:3306)/wms?charset=utf8&parseTime=True&loc=Local dsn: root:c++java123@tcp(192.168.20.119:3306)/aps_server2?charset=utf8&parseTime=True&loc=Local dsn: root:c++java123@tcp(127.0.0.1:3306)/aps_server2?charset=utf8&parseTime=True&loc=Local logMode: true maxIdleCon: 20 maxOpenCon: 100 response/report_forms_response.go
@@ -44,12 +44,13 @@ } type LocationForms struct { ProduceId string `json:"produceId"` //产品id LocationId int `json:"locationId"` //位置id LocationName string `json:"locationName"` //位置名称 ProductName string `json:"productName"` //产品名称 ProductTypeName string `json:"productTypeName"` //产品类别 Amount decimal.Decimal `json:"amount"` //数量 Unit string `json:"unit"` //单位 Value decimal.Decimal `json:"value"` //总价值 ProduceId string `json:"produceId"` //产品id LocationId int `json:"locationId"` //位置id LocationName string `json:"locationName"` //位置名称 ProductName string `json:"productName"` //产品名称 ProductTypeName string `json:"productTypeName"` //产品类别 Amount decimal.Decimal `json:"amount"` //数量 AmountMoreUnits []models.UnitItems `json:"amountMoreUnits"` //在库数量多单位 Unit string `json:"unit"` //单位 Value decimal.Decimal `json:"value"` //总价值 } service/location_forms.go
@@ -33,6 +33,11 @@ resp.ProductTypeName = amount.ProductCategory.Name resp.Unit = amount.Product.Unit resp.Value = resp.Amount.Mul(amount.Product.Cost) if *amount.Product.MoreUnit { resp.AmountMoreUnits = CreateMoreUnit(resp.Amount, amount.Product.MoreUnitList) } result = append(result, resp) } @@ -95,12 +100,23 @@ f := excelize.NewFile() // 自定义表头 headers := []string{"位置", "产品", "产品类别", "在库数量", "价值"} headers := []interface{}{"位置", "产品", "产品类别", map[string][]string{"在库数量": {"件", "匹", "米", "重量"}}, "价值"} // 设置表头 for i, header := range headers { cell := getColumnAlphabet(i+1) + "1" f.SetCellValue("Sheet1", cell, header) var i int for _, h := range headers { if v, ok := h.(string); ok { f.SetCellValue("Sheet1", getColumnAlphabet(i)+"1", v) i++ } else if childHeaders, ok := h.(map[string][]string); ok { for title, list := range childHeaders { f.SetCellValue("Sheet1", getColumnAlphabet(i)+"1", title) for _, t := range list { f.SetCellValue("Sheet1", getColumnAlphabet(i)+"2", t) i++ } } } } for i, v := range dataList { @@ -109,7 +125,7 @@ f.SetCellValue("Sheet1", "B"+column, v.ProductName) f.SetCellValue("Sheet1", "C"+column, v.ProductTypeName) f.SetCellValue("Sheet1", "D"+column, v.Amount) f.SetCellValue("Sheet1", "E"+column, v.Value) FillMoreUnitToExcel(v.Amount, v.AmountMoreUnits, 4, i+2, f) } fileName = fmt.Sprintf("位置报表%s.xlsx", time.Now().Format("2006-01-02-1504"))