zhangqian
2024-06-28 1691d8ee8fe10799d98b296625fd30183407ef25
新增操作类型增加基础操作类型和仓库id来支持库存盘点
6个文件已修改
94 ■■■■■ 已修改文件
controllers/operation.go 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/operation.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
request/operation.go 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/operation.go
@@ -72,17 +72,28 @@
        util.ResponseFormat(c, code.RequestParamError, "明细中不能存在重复的产品")
        return
    }
    operationType, err := models.NewOperationTypeSearch().SetID(uint(params.OperationTypeId)).First()
    var operationType *models.OperationType
    var err error
    if params.OperationTypeId == 0 {
        operationType, err = models.NewOperationTypeSearch().SetWarehouseId(params.WarehouseId).SetBaseOperationType(params.BaseOperationType).First()
        if err != nil || params.WarehouseId != operationType.WarehouseId {
            util.ResponseFormat(c, code.RequestParamError, "参数缺失")
            return
        }
    } else {
        operationType, err = models.NewOperationTypeSearch().SetID(uint(params.OperationTypeId)).First()
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, err.Error())
        return
    }
    }
    userInfo := middleware.GetUserInfo(c)
    params.CreatedBy = userInfo.Username
    params.Status = constvar.OperationStatus_Ready
    //params.Number = strconv.FormatInt(time.Now().Unix(), 10)
    params.BaseOperationType = operationType.BaseOperationType
    params.WarehouseId = operationType.WarehouseId
    var numberNum int64
    if err := mysqlx.GetDB().Model(&models.Operation{}).Where("number=?", params.Number).Count(&numberNum).Error; err != nil {
@@ -191,7 +202,13 @@
    }
    if params.OperationTypeId == 0 && int(params.BaseOperationType) == 0 {
        return errors.New("未识别该记录类型")
        return errors.New("未识别该记录类型1")
    }
    if params.BaseOperationType != 0 {
        if params.WarehouseId == 0 {
            return errors.New("未识别该记录类型2")
        }
    }
    if params.OperationDate == "" {
@@ -282,7 +299,9 @@
        costMap[material.ID] = material.Cost
        salePriceMap[material.ID] = material.SalePrice
    }
    list, total, err := search.SetOperationTypeId(params.OperationTypeId).SetPreload(true).SetOrder("created_at desc").Find()
    list, total, err := search.SetOperationTypeId(params.OperationTypeId).
        SetBaseOperationType(params.BaseOperationType).
        SetPreload(true).SetOrder("created_at desc").Find()
    if err != nil {
        util.ResponseFormat(c, code.RequestError, "查找失败:"+err.Error())
        return
@@ -303,8 +322,8 @@
    if !params.PageInfo.Check() {
        return errors.New("数据分页信息错误")
    }
    if params.OperationTypeId == 0 {
        return errors.New("operationTypeId为0")
    if params.OperationTypeId == 0 && params.BaseOperationType == 0 {
        return errors.New("operationTypeId和baseOperationType不能同时为0")
    }
    return nil
}
docs/docs.go
@@ -4878,6 +4878,9 @@
                "updateTime": {
                    "type": "string"
                },
                "warehouseId": {
                    "type": "integer"
                },
                "waybillNumber": {
                    "description": "运单号",
                    "type": "string"
@@ -5360,6 +5363,14 @@
                "accountantId": {
                    "type": "string"
                },
                "baseOperationType": {
                    "description": "基础作业类型 5库存盘点",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.BaseOperationType"
                        }
                    ]
                },
                "comment": {
                    "description": "备注",
                    "type": "string"
@@ -5451,6 +5462,10 @@
                },
                "toLocationId": {
                    "description": "目标位置id",
                    "type": "integer"
                },
                "warehouseId": {
                    "description": "仓库id",
                    "type": "integer"
                },
                "waybillNumber": {
@@ -5963,6 +5978,14 @@
        "request.OperationList": {
            "type": "object",
            "properties": {
                "baseOperationType": {
                    "description": "1 入库 2 出库 3 内部调拨 4 报废 5 库存盘点",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.BaseOperationType"
                        }
                    ]
                },
                "number": {
                    "type": "string"
                },
docs/swagger.json
@@ -4867,6 +4867,9 @@
                "updateTime": {
                    "type": "string"
                },
                "warehouseId": {
                    "type": "integer"
                },
                "waybillNumber": {
                    "description": "运单号",
                    "type": "string"
@@ -5349,6 +5352,14 @@
                "accountantId": {
                    "type": "string"
                },
                "baseOperationType": {
                    "description": "基础作业类型 5库存盘点",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.BaseOperationType"
                        }
                    ]
                },
                "comment": {
                    "description": "备注",
                    "type": "string"
@@ -5440,6 +5451,10 @@
                },
                "toLocationId": {
                    "description": "目标位置id",
                    "type": "integer"
                },
                "warehouseId": {
                    "description": "仓库id",
                    "type": "integer"
                },
                "waybillNumber": {
@@ -5952,6 +5967,14 @@
        "request.OperationList": {
            "type": "object",
            "properties": {
                "baseOperationType": {
                    "description": "1 入库 2 出库 3 内部调拨 4 报废 5 库存盘点",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.BaseOperationType"
                        }
                    ]
                },
                "number": {
                    "type": "string"
                },
docs/swagger.yaml
@@ -967,6 +967,8 @@
        type: integer
      updateTime:
        type: string
      warehouseId:
        type: integer
      waybillNumber:
        description: 运单号
        type: string
@@ -1292,6 +1294,10 @@
        type: string
      accountantId:
        type: string
      baseOperationType:
        allOf:
        - $ref: '#/definitions/constvar.BaseOperationType'
        description: 基础作业类型 5库存盘点
      comment:
        description: 备注
        type: string
@@ -1358,6 +1364,9 @@
        description: 状态
      toLocationId:
        description: 目标位置id
        type: integer
      warehouseId:
        description: 仓库id
        type: integer
      waybillNumber:
        description: 运单号
@@ -1716,6 +1725,10 @@
    type: object
  request.OperationList:
    properties:
      baseOperationType:
        allOf:
        - $ref: '#/definitions/constvar.BaseOperationType'
        description: 1 入库 2 出库 3 内部调拨 4 报废 5 库存盘点
      number:
        type: string
      operationTypeId:
models/operation.go
@@ -61,6 +61,7 @@
        CheckedBy    string `json:"checkedBy" gorm:"type:varchar(255);comment:验证者UserId"`
        Remark       string `json:"remark"`
        WarehouseId      int  `json:"warehouseId" gorm:"type:int;not null;comment:仓库id"`
        IsInternalOutput bool `json:"isInternalOutput"` //是否调拨产生的出库
    }
request/operation.go
@@ -36,6 +36,8 @@
    Accountant        string              `json:"accountant" gorm:"type:varchar(255);comment:会计名称"`
    CustodianId       string              `json:"custodianId" gorm:"type:varchar(255);comment:保管员id"`
    Custodian         string              `json:"custodian" gorm:"type:varchar(255);comment:保管员名称"`
    BaseOperationType constvar.BaseOperationType `json:"baseOperationType" gorm:"type:tinyint;not null;comment:基础作业类型"` //基础作业类型 5库存盘点
    WarehouseId       int                        `json:"warehouseId" gorm:"type:int;not null;comment:仓库id"`             //仓库id
}
type OperationDetails struct {
@@ -60,6 +62,7 @@
type OperationList struct {
    PageInfo
    OperationTypeId int                      `json:"operationTypeId" form:"operationTypeId"`
    BaseOperationType constvar.BaseOperationType `json:"baseOperationType"` // 1 入库 2 出库 3 内部调拨 4 报废 5 库存盘点
    Number          string                   `json:"number"`
    Status          constvar.OperationStatus `json:"status"`
}