From f0786e779666d67a50cd57d82cfe1e278b47d397 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期四, 04 七月 2024 11:54:11 +0800 Subject: [PATCH] fix --- controllers/operation.go | 87 ++++++++++++++++++++++++++++++++++--------- 1 files changed, 68 insertions(+), 19 deletions(-) diff --git a/controllers/operation.go b/controllers/operation.go index 4828007..a841978 100644 --- a/controllers/operation.go +++ b/controllers/operation.go @@ -9,7 +9,6 @@ "github.com/shopspring/decimal" "github.com/xuri/excelize/v2" "gorm.io/gorm" - "io/ioutil" "sort" "strconv" "strings" @@ -95,7 +94,15 @@ params.WarehouseId = operationType.WarehouseId } + if params.InventoryDealerType == 0 { + CheckInventoryDealerType(¶ms) + } + userInfo := middleware.GetUserInfo(c) + if userInfo == nil { + util.ResponseFormat(c, code.SetStatusError, "鐧诲綍鐢ㄦ埛淇℃伅涓虹┖锛岃鐧诲綍鍚庨噸璇曪紒") + return + } params.CreatedBy = userInfo.Username params.Status = constvar.OperationStatus_Ready //params.Number = strconv.FormatInt(time.Now().Unix(), 10) @@ -138,6 +145,45 @@ return } util.ResponseFormat(c, code.Success, "娣诲姞鎴愬姛") +} + +func CheckInventoryDealerType(params *models.Operation) { + var dictType constvar.MiniDictType + dictName := "鍏跺畠" + switch params.BaseOperationType { + case constvar.BaseOperationTypeIncoming: + dictType = constvar.StorageType + //dictName = "鍏跺畠鍏ュ簱" + case constvar.BaseOperationTypeOutgoing: + dictType = constvar.StockoutType + //dictName = "鍏跺畠鍑哄簱" + case constvar.BaseOperationTypeInternal: + dictType = constvar.TransferType + //dictName = "鍏跺畠璋冩嫧" + case constvar.BaseOperationTypeDisuse: + dictType = constvar.DisuseType + //dictName = "鍏跺畠鎶ュ簾" + case constvar.BaseOperationTypeAdjust: + dictType = constvar.TakeStockType + //dictName = "鍏跺畠鐩樼偣" + default: + return + } + miniDict, _ := models.NewMiniDictSearch().SetType(dictType).SetName(dictName).First() + if miniDict != nil { + params.InventoryDealerType = int(miniDict.ID) + } else { + dict := &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) + } } func CheckDetailsRepeat(details []*models.OperationDetails) bool { @@ -213,12 +259,8 @@ 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 == "" { @@ -278,7 +320,7 @@ // @Summary 鍏ュ簱/鍑哄簱鍒楄〃 // @Produce application/json // @Param object body request.OperationList true "鏌ヨ鍙傛暟" -// @Success 200 {object} util.ResponseList{data=[]models.Operation} "鎴愬姛" +// @Success 200 {object} util.ResponseList{data=[]models.Operation} "鎴愬姛" // @Router /api-wms/v1/operation/list [post] func (slf OperationController) List(c *gin.Context) { var params request.OperationList @@ -316,7 +358,22 @@ util.ResponseFormat(c, code.RequestError, "鏌ユ壘澶辫触:"+err.Error()) return } + //userList, err := service.GetUserList() + //userMap := make(map[string]string) + //if err == nil { + // for _, user := range userList { + // userMap[user.UserName] = user.NickName + // } + //} + userInfo := middleware.GetUserInfo(c) for _, v := range list { + //if err == nil { + if userInfo != nil { + // v.CreatedBy = userMap[v.CreatedBy] + // v.CheckedBy = userMap[v.CheckedBy] + v.CreatedBy = userInfo.NickName + v.CheckedBy = userInfo.NickName + } for _, v1 := range v.Details { //v1.SalePrice = decimal.NewFromFloat(1.2345) //v1.Cost = decimal.NewFromFloat(9.678) @@ -791,16 +848,13 @@ util.ResponseFormat(c, code.RequestParamError, err.Error()) return } - - } else if warehouse.FileTemplateCategoryIn == constvar.FileTemplateCategory_JialianInput1 { + } 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 { @@ -832,7 +886,7 @@ return } - } else if warehouse.FileTemplateCategoryOut == constvar.FileTemplateCategory_JialianOutput1 { + } else { fileUrl, err = JialianOperation2(warehouse.FileTemplateCategoryOut, operation) if err != nil { util.ResponseFormat(c, code.RequestParamError, err.Error()) @@ -873,8 +927,6 @@ // 璇诲彇妯℃澘鍐呭 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()) } @@ -1002,7 +1054,6 @@ fileUrl, err := upload.UploadFileToSeaWeed(string(constvar.FileType_File), uuid.NewV4().String()+".xlsx", buf.Bytes()) if err != nil { - ioutil.WriteFile("E:\\"+uuid.NewV4().String()+".xlsx", buf.Bytes(), 0644) logx.Errorf("file upload err: %v", err) return "", err } @@ -1121,7 +1172,6 @@ fileUrl, err := upload.UploadFileToSeaWeed(string(constvar.FileType_File), uuid.NewV4().String()+".xlsx", buf.Bytes()) if err != nil { - ioutil.WriteFile("E:\\"+uuid.NewV4().String()+".xlsx", buf.Bytes(), 0644) logx.Errorf("file upload err: %v", err) return "", err } @@ -1378,8 +1428,7 @@ // @Tags 鍏ュ簱/鍑哄簱 // @Summary 鑾峰彇浜哄憳鍒楄〃 // @Produce application/json -// @Param object body request.OperationCondition true "鍙傛暟" -// @Success 200 {object} util.ResponseList{data=[]inventory_order.WorkerInfo} "鎴愬姛" +// @Success 200 {object} util.Response "鎴愬姛" // @Router /api-wms/v1/operation/getPersonnelList [get] func (slf OperationController) GetPersonnelList(c *gin.Context) { cli := inventory_order.NewInventoryOrderServiceClient(init_client.ApsConn) -- Gitblit v1.8.0