jiangshuai
2023-12-13 7f22e4058d0b27eca88181629caa14e1fba5c18e
入库、出库、调拨、报废根据编码规则自动生成单号
6个文件已修改
84 ■■■■■ 已修改文件
constvar/const.go 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/code.go 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/operation.go 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
constvar/const.go
@@ -230,3 +230,13 @@
    FileTemplateCategory_Selfmade FileTemplateCategory = iota + 1 //入库-自制
    FileTemplateCategory_Output                                   //出库
)
type CodeStandardType string
const (
    CodeStandardType_Material CodeStandardType = "物料编码"
    CodeStandardType_Incoming CodeStandardType = "入库编码"
    CodeStandardType_Outgoing CodeStandardType = "出库编码"
    CodeStandardType_Internal CodeStandardType = "调拨编码"
    CodeStandardType_Disuse   CodeStandardType = "报废编码"
)
controllers/code.go
@@ -3,6 +3,7 @@
import (
    "github.com/gin-gonic/gin"
    "github.com/spf13/cast"
    "wms/constvar"
    cd "wms/extend/code"
    "wms/extend/util"
    "wms/models"
@@ -87,9 +88,17 @@
        id  = 0
        err error
    )
    switch params.Type {
    case "物料编码":
    switch constvar.CodeStandardType(params.Type) {
    case constvar.CodeStandardType_Material:
        id, err = models.NewMaterialSearch().MaxAutoIncr()
    case constvar.CodeStandardType_Incoming:
        id, err = models.NewOperationSearch().SetBaseOperationType(constvar.BaseOperationTypeIncoming).MaxAutoIncr()
    case constvar.CodeStandardType_Outgoing:
        id, err = models.NewOperationSearch().SetBaseOperationType(constvar.BaseOperationTypeOutgoing).MaxAutoIncr()
    case constvar.CodeStandardType_Internal:
        id, err = models.NewOperationSearch().SetBaseOperationType(constvar.BaseOperationTypeInternal).MaxAutoIncr()
    case constvar.CodeStandardType_Disuse:
        id, err = models.NewOperationSearch().SetBaseOperationType(constvar.BaseOperationTypeDisuse).MaxAutoIncr()
    default:
        util.ResponseFormat(c, cd.RequestError, "编码规则不存在")
        return
docs/docs.go
@@ -1243,7 +1243,7 @@
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.OperationAllList"
                            "$ref": "#/definitions/request.OperationCondition"
                        }
                    }
                ],
@@ -4193,6 +4193,22 @@
                }
            }
        },
        "request.OperationCondition": {
            "type": "object",
            "properties": {
                "condition": {
                    "type": "string"
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
                },
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                }
            }
        },
        "request.OperationDetails": {
            "type": "object",
            "properties": {
docs/swagger.json
@@ -1231,7 +1231,7 @@
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.OperationAllList"
                            "$ref": "#/definitions/request.OperationCondition"
                        }
                    }
                ],
@@ -4181,6 +4181,22 @@
                }
            }
        },
        "request.OperationCondition": {
            "type": "object",
            "properties": {
                "condition": {
                    "type": "string"
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
                },
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                }
            }
        },
        "request.OperationDetails": {
            "type": "object",
            "properties": {
docs/swagger.yaml
@@ -1179,6 +1179,17 @@
      sourceNumber:
        type: string
    type: object
  request.OperationCondition:
    properties:
      condition:
        type: string
      page:
        description: 页码
        type: integer
      pageSize:
        description: 每页大小
        type: integer
    type: object
  request.OperationDetails:
    properties:
      OperationId:
@@ -2353,7 +2364,7 @@
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.OperationAllList'
          $ref: '#/definitions/request.OperationCondition'
      produces:
      - application/json
      responses:
models/operation.go
@@ -337,3 +337,15 @@
    return records, nil
}
func (slf *OperationSearch) MaxAutoIncr() (int, error) {
    var (
        db    = slf.build()
        total int64
    )
    if err := db.Count(&total).Error; err != nil {
        return int(total), fmt.Errorf("max err: %v", err)
    }
    return int(total), nil
}