| | |
| | | "github.com/shopspring/decimal" |
| | | "github.com/xuri/excelize/v2" |
| | | "gorm.io/gorm" |
| | | "io/ioutil" |
| | | "sort" |
| | | "strconv" |
| | | "strings" |
| | |
| | | params.WarehouseId = operationType.WarehouseId |
| | | } |
| | | |
| | | if params.InventoryDealerType == 0 { |
| | | if params.DealerType == "" { |
| | | CheckInventoryDealerType(¶ms) |
| | | } |
| | | |
| | |
| | | default: |
| | | return |
| | | } |
| | | miniDict, _ := models.NewMiniDictSearch().SetType(dictType).SetName(dictName).First() |
| | | if miniDict != nil { |
| | | params.InventoryDealerType = int(miniDict.ID) |
| | | } else { |
| | | dict := &models.MiniDict{ |
| | | miniDict, err := models.NewMiniDictSearch().SetType(dictType).SetName(dictName).First() |
| | | if err == gorm.ErrRecordNotFound { |
| | | miniDict = &models.MiniDict{ |
| | | Type: dictType, |
| | | Name: dictName, |
| | | } |
| | | models.NewMiniDictSearch().Create(dict) |
| | | miniDict, err := models.NewMiniDictSearch().SetType(dictType).SetName(dictName).First() |
| | | if err != nil { |
| | | return |
| | | } |
| | | params.InventoryDealerType = int(miniDict.ID) |
| | | models.NewMiniDictSearch().Create(miniDict) |
| | | } |
| | | params.DealerType = miniDict.Name |
| | | } |
| | | |
| | | func CheckDetailsRepeat(details []*models.OperationDetails) bool { |
| | |
| | | |
| | | if params.OperationTypeId == 0 && int(params.BaseOperationType) == 0 { |
| | | return errors.New("未识别该记录类型1") |
| | | } |
| | | |
| | | if params.BaseOperationType != 0 { |
| | | if params.WarehouseId == 0 { |
| | | return errors.New("未识别该记录类型2") |
| | | } |
| | | } else if params.OperationTypeId == 0 && params.BaseOperationType != 0 && params.WarehouseId == 0 { |
| | | return errors.New("未识别该记录类型2") |
| | | } |
| | | |
| | | if params.OperationDate == "" { |
| | |
| | | |
| | | // GetOperationInfo |
| | | // @Tags 入库/出库 |
| | | // @Summary 入库/出库列表 |
| | | // @Summary 操作详情接口 |
| | | // @Produce application/json |
| | | // |
| | | // @Param id path string true "id" |
| | | // |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Param id path string true "id" |
| | | // @Param Authorization header string true "token" |
| | | // @Success 200 {object} util.Response{data=models.Operation} "成功" |
| | | // @Router /api-wms/v1/operation/getOperationInfo/{id} [get] |
| | | func (slf OperationController) GetOperationInfo(c *gin.Context) { |
| | | number := c.Param("id") |
| | |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | | } |
| | | |
| | | if operation.BaseOperationType == constvar.BaseOperationTypeOutgoing || operation.BaseOperationType == constvar.BaseOperationTypeInternal { //查询实时在库库存 |
| | | productIds := make([]string, 0) |
| | | locationIds := make([]int, 0) |
| | | for _, v := range operation.Details { |
| | | productIds = append(productIds, v.ProductId) |
| | | locationIds = append(locationIds, v.FromLocationID) |
| | | } |
| | | locationAmountMap, err := service.GetLocationAmounts(productIds, locationIds) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查询产品库存错误") |
| | | return |
| | | } |
| | | for _, v := range operation.Details { |
| | | if locationAmountMap[v.ProductId] != nil { |
| | | v.StockAmount = locationAmountMap[v.ProductId][v.FromLocationID] |
| | | } |
| | | } |
| | | } |
| | | |
| | | util.ResponseFormat(c, code.Success, operation) |
| | | } |
| | | |
| | |
| | | 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(constvar.FileTemplateCategory_JialianInput1, 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(constvar.FileTemplateCategory_JialianOutput1, 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 |
| | | } |
| | | |