Merge remote-tracking branch 'origin/jialian' into jialian
| | |
| | | "github.com/shopspring/decimal" |
| | | "github.com/xuri/excelize/v2" |
| | | "gorm.io/gorm" |
| | | "io/ioutil" |
| | | "sort" |
| | | "strconv" |
| | | "strings" |
| | |
| | | return |
| | | } |
| | | |
| | | if warehouse.FileTemplateCategoryIn == constvar.FileTemplateCategory_JialianInput1 { |
| | | fileUrl, err = JialianOperation2(warehouse.FileTemplateCategoryIn, operation) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | | } |
| | | |
| | | } else if warehouse.FileTemplateCategoryIn == constvar.FileWarehouseCategory_JialianInput2 { |
| | | if warehouse.FileTemplateCategoryIn == constvar.FileWarehouseCategory_JialianInput2 { |
| | | fileUrl, err = JialianOperation1(warehouse.FileTemplateCategoryIn, operation) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | | } |
| | | |
| | | } else { |
| | | fileUrl, err = JialianOperation2(warehouse.FileTemplateCategoryIn, operation) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | | } |
| | | } |
| | | |
| | | } else if companyName == "geruimi" { |
| | | fileUrl, err = ExportInputSelfmade(constvar.FileTemplateCategory_Selfmade, operation) |
| | | if err != nil { |
| | |
| | | return |
| | | } |
| | | |
| | | if warehouse.FileTemplateCategoryOut == constvar.FileTemplateCategory_JialianOutput1 { |
| | | fileUrl, err = JialianOperation2(warehouse.FileTemplateCategoryOut, operation) |
| | | if warehouse.FileTemplateCategoryOut == constvar.FileWarehouseCategory_JialianOutput2 { |
| | | fileUrl, err = JialianOperation1(warehouse.FileTemplateCategoryOut, operation) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | | } |
| | | |
| | | } else if warehouse.FileTemplateCategoryOut == constvar.FileWarehouseCategory_JialianOutput2 { |
| | | fileUrl, err = JialianOperation1(warehouse.FileTemplateCategoryOut, operation) |
| | | } else { |
| | | fileUrl, err = JialianOperation2(warehouse.FileTemplateCategoryOut, operation) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | |
| | | |
| | | // 读取模板内容 |
| | | f, err := excelize.OpenReader(readerCloser) |
| | | //fl, err := os.Open("E:\\家纺出入库单.xlsx") |
| | | //f, err := excelize.OpenReader(fl) |
| | | if err != nil { |
| | | return "", errors.New("读取excel模版失败:" + err.Error()) |
| | | } |
| | |
| | | } |
| | | |
| | | fileUrl, err := upload.UploadFileToSeaWeed(string(constvar.FileType_File), uuid.NewV4().String()+".xlsx", buf.Bytes()) |
| | | ioutil.WriteFile("E:\\"+uuid.NewV4().String()+".xlsx", buf.Bytes(), 0644) |
| | | if err != nil { |
| | | //ioutil.WriteFile("E:\\"+uuid.NewV4().String()+".xlsx", buf.Bytes(), 0644) |
| | | logx.Errorf("file upload err: %v", err) |
| | | return "", err |
| | | } |
| | |
| | | } |
| | | |
| | | fileUrl, err := upload.UploadFileToSeaWeed(string(constvar.FileType_File), uuid.NewV4().String()+".xlsx", buf.Bytes()) |
| | | ioutil.WriteFile("E:\\"+uuid.NewV4().String()+".xlsx", buf.Bytes(), 0644) |
| | | if err != nil { |
| | | logx.Errorf("file upload err: %v", err) |
| | | return "", err |
| | |
| | | logx.Errorf("file upload err: %v", err) |
| | | return "", err |
| | | } |
| | | |
| | | return fileUrl, nil |
| | | } |
| | | |
| | |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/shopspring/decimal" |
| | | "github.com/spf13/cast" |
| | | "github.com/xuri/excelize/v2" |
| | | "gorm.io/gorm" |
| | | "net/url" |
| | | "strconv" |
| | | "time" |
| | | "wms/constvar" |
| | |
| | | "wms/request" |
| | | "wms/response" |
| | | "wms/service" |
| | | "wms/utils/http" |
| | | ) |
| | | |
| | | type ProductController struct { |
| | |
| | | |
| | | // InputProduct |
| | | // |
| | | // @Tags 物料管理 |
| | | // @Summary 导入物料 |
| | | // @Tags 产品 |
| | | // @Summary 导入物料/产品 |
| | | // |
| | | // @Accept multipart/form-data |
| | | // @Param file formData file true "file" |
| | |
| | | resp.InputCount = insertCount |
| | | util.ResponseFormat(c, code.Success, resp) |
| | | } |
| | | |
| | | // DownloadInputFormat |
| | | // |
| | | // @Tags 产品 |
| | | // @Summary 下载导入物料/产品模板 |
| | | // |
| | | // @Param Authorization header string true "token" |
| | | // |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/product/downloadInputFormat [get] |
| | | func (slf ProductController) DownloadInputFormat(c *gin.Context) { |
| | | template, err := models.NewFileTemplateAttachmentSearch().SetCategory(7).First() //物料导入模板 |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.NoTemplateError, "获取模版记录失败:"+err.Error()) |
| | | return |
| | | } |
| | | readerCloser, err := http.HttpGetWithReadCloser(template.FileUrl) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.NoTemplateError, "获取模版记录失败:"+err.Error()) |
| | | return |
| | | } |
| | | f, err := excelize.OpenReader(readerCloser) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.NoTemplateError, "获取模版记录失败:"+err.Error()) |
| | | return |
| | | } |
| | | fileContentDisposition := "attachment;filename=\"" + url.QueryEscape("物料导入.xlsx") + "\"" |
| | | c.Writer.Header().Add("Content-Disposition", fileContentDisposition) |
| | | c.Writer.Header().Add("Content-Type", "application/octet-stream") |
| | | //c.Writer.Header().Add("Content-Type", "application/xlsx") |
| | | if err = f.Write(c.Writer); err != nil { |
| | | util.ResponseFormat(c, code.NoTemplateError, "数据导出异常:"+err.Error()) |
| | | return |
| | | } |
| | | |
| | | readerCloser.Close() |
| | | util.ResponseFormat(c, code.Success, "") |
| | | } |
| | |
| | | productAPI.POST("updateProduct", productController.UpdateProduct) // 修改产品详情 |
| | | productAPI.DELETE("deleteProduct/:id", productController.DeleteProduct) // 通过ID获删除产品 |
| | | productAPI.DELETE("deleteProductByBarCode/:barCode", productController.DeleteProductByBarCode) // 通过条形码删除产品 |
| | | productAPI.GET("downloadInputFormat", productController.DownloadInputFormat) // 下载导入物料模板 |
| | | |
| | | productAPI.POST("addProductCategory", productController.AddProductCategory) //添加产品类型 |
| | | productAPI.POST("getProductCategoryList", productController.GetProductCategoryList) //获取产品类型列表 |
| | |
| | | |
| | | func GetDealerItems(m map[string]decimal.Decimal) (items []*models.WarehouseStatsItems) { |
| | | for k, v := range m { |
| | | name := k |
| | | if name == "" { |
| | | name = "其他" |
| | | } |
| | | items = append(items, &models.WarehouseStatsItems{ |
| | | Name: k, |
| | | Name: name, |
| | | Amount: v, |
| | | }) |
| | | } |