| | |
| | | "github.com/shopspring/decimal" |
| | | "github.com/xuri/excelize/v2" |
| | | "gorm.io/gorm" |
| | | "sort" |
| | | "strconv" |
| | | "strings" |
| | | "time" |
| | |
| | | // @Tags 入库/出库 |
| | | // @Summary 添加入库/出库 |
| | | // @Produce application/json |
| | | // @Param Authorization header string true "token" |
| | | // @Param object body request.AddOperation true "入库/出库信息" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/operation/operation [post] |
| | |
| | | util.ResponseFormat(c, code.Success, "添加成功") |
| | | } |
| | | |
| | | // CheckInventoryDealerType 检查基础类型,防止类型为空添加其它类型 |
| | | func CheckInventoryDealerType(params *models.Operation) { |
| | | var dictType constvar.MiniDictType |
| | | dictName := "其他" |
| | |
| | | params.DealerType = miniDict.Name |
| | | } |
| | | |
| | | // CheckDetailsRepeat 出库、入库、盘点涉及产品重复性检查(以产品编号、出库库房编号、入库库房编号) |
| | | // 存在重复值 true; 不存在返回 false |
| | | func CheckDetailsRepeat(details []*models.OperationDetails) bool { |
| | | var detailIDs []string |
| | | var tempID string |
| | | for _, v := range details { |
| | | detailIDs = append(detailIDs, v.ProductId) |
| | | if len(details) == 0 { |
| | | return false |
| | | } |
| | | sort.Strings(detailIDs) |
| | | for _, v := range detailIDs { |
| | | if v != tempID { |
| | | tempID = v |
| | | } else { |
| | | return true |
| | | } |
| | | var detailKeyMap = make(map[string]bool) |
| | | for _, v := range details { |
| | | key := fmt.Sprintf("%v%v%v", v.ProductId, v.FromLocationID, v.ToLocationID) |
| | | detailKeyMap[key] = true |
| | | } |
| | | if len(detailKeyMap) != len(details) { // 长度相同,不存在重复值;长度不同存在存在不同 |
| | | return true |
| | | } |
| | | return false |
| | | } |
| | |
| | | // @Tags 入库/出库 |
| | | // @Summary 入库/出库列表 |
| | | // @Produce application/json |
| | | // @Param Authorization header string true "token" |
| | | // @Param object body request.OperationList true "查询参数" |
| | | // @Success 200 {object} util.ResponseList{data=[]models.Operation} "成功" |
| | | // @Router /api-wms/v1/operation/list [post] |
| | |
| | | // } |
| | | //} |
| | | userInfo := middleware.GetUserInfo(c) |
| | | if userInfo == nil { |
| | | util.ResponseFormat(c, code.SetStatusError, "登录用户信息为空,请登录后重试!") |
| | | return |
| | | } |
| | | for _, v := range list { |
| | | v.CreatedBy = userInfo.NickName |
| | | //if err == nil { |
| | |
| | | // @Tags 入库/出库 |
| | | // @Summary 删除入库/出库信息 |
| | | // @Produce application/json |
| | | // @Param Authorization header string true "token" |
| | | // @Param id path int true "id" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/operation/operation/{id} [delete] |
| | |
| | | // @Tags 入库/出库 |
| | | // @Summary 更改记录状态 |
| | | // @Produce application/json |
| | | // @Param id path int true "id" |
| | | // @Param Authorization header string true "token" |
| | | // @Param id path int true "id" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/operation/finish/{id} [put] |
| | | // @Router /api-wms/v1/operation/finish/{id} [put] |
| | | func (slf OperationController) Finish(c *gin.Context) { |
| | | id, err := strconv.Atoi(c.Param("id")) |
| | | if err != nil { |
| | |
| | | return err |
| | | } |
| | | |
| | | if operation.BaseOperationType == constvar.BaseOperationTypeIncoming { |
| | | if operation.BaseOperationType == constvar.BaseOperationTypeIncoming { // 入库 |
| | | if err := service.FinishOperationInput(c, tx, operation, listDetails, mapLocAmount); err != nil { |
| | | return err |
| | | } |
| | | } |
| | | |
| | | if operation.BaseOperationType == constvar.BaseOperationTypeOutgoing || operation.BaseOperationType == constvar.BaseOperationTypeDisuse { |
| | | if operation.BaseOperationType == constvar.BaseOperationTypeOutgoing || // 出库 |
| | | operation.BaseOperationType == constvar.BaseOperationTypeDisuse { // 报废 |
| | | if err := service.FinishOperationOutput(tx, listDetails, mapLocAmount, operation); err != nil { |
| | | return err |
| | | } |
| | | } |
| | | |
| | | if operation.BaseOperationType == constvar.BaseOperationTypeInternal { |
| | | if operation.BaseOperationType == constvar.BaseOperationTypeInternal { // 内部调拨 |
| | | if err := service.FinishOperationInternal(tx, listDetails, operation); err != nil { |
| | | return err |
| | | } |
| | | } |
| | | |
| | | if operation.BaseOperationType == constvar.BaseOperationTypeAdjust { |
| | | if operation.BaseOperationType == constvar.BaseOperationTypeAdjust { // 库存盘点 |
| | | if err := service.FinishOperationAdjust(tx, listDetails, mapLocAmount, operation); err != nil { |
| | | return err |
| | | } |
| | |
| | | go UpdateOutStatus(operation.Source, operation.SourceNumber, 4) |
| | | } |
| | | } |
| | | |
| | | util.ResponseFormat(c, code.Success, "操作成功") |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | if warehouse.FileTemplateCategoryIn == constvar.FileWarehouseCategory_JialianInput2 { |
| | | fileUrl, err = JialianOperation1(warehouse.FileTemplateCategoryIn, operation) |
| | | fileUrl, err = JialianOperation1(constvar.FileWarehouseCategory_JialianInput2, operation) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | |
| | | } |
| | | |
| | | if warehouse.FileTemplateCategoryOut == constvar.FileWarehouseCategory_JialianOutput2 { |
| | | fileUrl, err = JialianOperation1(warehouse.FileTemplateCategoryOut, operation) |
| | | fileUrl, err = JialianOperation1(constvar.FileWarehouseCategory_JialianOutput2, operation) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |