liujiandao
2023-11-10 07079a17b93d1dc2f06d73a5a08f6ba63a87d9a3
出入库操作添加物流信息
1个文件已添加
8个文件已修改
586 ■■■■■ 已修改文件
controllers/operation.go 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 146 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 144 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 97 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/db.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/logistic_company.go 153 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/operation.go 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
request/operation.go 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/router.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/operation.go
@@ -257,7 +257,7 @@
    util.ResponseFormat(c, code.Success, "修改成功")
}
// DeleteDevice
// Delete
//
//    @Tags        入库/出库
//    @Summary    删除入库/出库信息
@@ -299,7 +299,7 @@
    util.ResponseFormat(c, code.Success, "删除成功")
}
// DeleteDevice
// Finish
//
//    @Tags        入库/出库
//    @Summary    更改记录状态
@@ -682,7 +682,7 @@
    util.ResponseFormat(c, code.Success, "操作成功")
}
// listTransfer
// ListTransfer
// @Tags      入库/出库
// @Summary   库存调拨列表
// @Produce   application/json
@@ -712,3 +712,18 @@
    }
    util.ResponseFormatListWithPage(c, code.Success, list, int(total), params.Page, params.PageSize)
}
// GetLogisticCompanyList
// @Tags      入库/出库
// @Summary   获取物流公司列表
// @Produce   application/json
// @Success   200 {object} util.ResponseList{data=[]models.LogisticCompany} "成功"
// @Router    /api-wms/v1/operation/getLogisticCompanyList [get]
func (slf OperationController) GetLogisticCompanyList(c *gin.Context) {
    companies, err := models.NewLogisticCompanySearch().FindNotTotal()
    if err != nil {
        util.ResponseFormat(c, code.RequestError, "查找失败:"+err.Error())
        return
    }
    util.ResponseFormat(c, code.Success, companies)
}
docs/docs.go
@@ -963,6 +963,40 @@
                }
            }
        },
        "/api-wms/v1/operation/getLogisticCompanyList": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "入库/出库"
                ],
                "summary": "获取物流公司列表",
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/util.ResponseList"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/definitions/models.LogisticCompany"
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api-wms/v1/operation/list": {
            "post": {
                "produces": [
@@ -2224,6 +2258,24 @@
                "CostingMethodAverageCost"
            ]
        },
        "constvar.FileType": {
            "type": "string",
            "enum": [
                "file",
                "picture",
                "thumbnail"
            ],
            "x-enum-comments": {
                "FileType_File": "文件",
                "FileType_Picture": "图片",
                "FileType_Thumbnail": "缩略图"
            },
            "x-enum-varnames": [
                "FileType_File",
                "FileType_Picture",
                "FileType_Thumbnail"
            ]
        },
        "constvar.ForceRemovalStrategy": {
            "type": "integer",
            "enum": [
@@ -2436,6 +2488,26 @@
                "ReservationNever"
            ]
        },
        "models.Attachment": {
            "type": "object",
            "properties": {
                "FileUrl": {
                    "type": "string"
                },
                "ext": {
                    "type": "string"
                },
                "fileName": {
                    "type": "string"
                },
                "fileType": {
                    "$ref": "#/definitions/constvar.FileType"
                },
                "id": {
                    "type": "integer"
                }
            }
        },
        "models.Company": {
            "type": "object",
            "properties": {
@@ -2572,12 +2644,51 @@
                }
            }
        },
        "models.LogisticCompany": {
            "type": "object",
            "properties": {
                "contact": {
                    "description": "联系人",
                    "type": "string"
                },
                "contact_phone": {
                    "description": "联系电话",
                    "type": "string"
                },
                "hidden": {
                    "description": "隐藏",
                    "type": "boolean"
                },
                "id": {
                    "type": "string"
                },
                "monthly_account": {
                    "description": "月结账号",
                    "type": "string"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "models.Material": {
            "type": "object",
            "properties": {
                "amount": {
                    "description": "数量",
                    "type": "number"
                },
                "attachmentIDs": {
                    "type": "array",
                    "items": {
                        "type": "integer"
                    }
                },
                "attachmentList": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/models.Attachment"
                    }
                },
                "barcode": {
                    "description": "条码",
@@ -2814,6 +2925,16 @@
                "id": {
                    "type": "integer"
                },
                "logisticCompany": {
                    "$ref": "#/definitions/models.LogisticCompany"
                },
                "logisticCompanyId": {
                    "type": "string"
                },
                "logisticWeight": {
                    "description": "物流重量",
                    "type": "number"
                },
                "number": {
                    "description": "单号",
                    "type": "string"
@@ -2855,6 +2976,14 @@
                },
                "updateTime": {
                    "type": "string"
                },
                "waybillNumber": {
                    "description": "运单号",
                    "type": "string"
                },
                "weight": {
                    "description": "重量",
                    "type": "number"
                }
            }
        },
@@ -3191,6 +3320,13 @@
                "id": {
                    "type": "integer"
                },
                "logisticCompanyId": {
                    "type": "string"
                },
                "logisticWeight": {
                    "description": "物流重量",
                    "type": "number"
                },
                "number": {
                    "description": "单号",
                    "type": "string"
@@ -3222,6 +3358,14 @@
                "toLocationId": {
                    "description": "目标位置id",
                    "type": "integer"
                },
                "waybillNumber": {
                    "description": "运单号",
                    "type": "string"
                },
                "weight": {
                    "description": "重量",
                    "type": "number"
                }
            }
        },
@@ -4154,6 +4298,8 @@
    Description:      "",
    InfoInstanceName: "swagger",
    SwaggerTemplate:  docTemplate,
    LeftDelim:        "{{",
    RightDelim:       "}}",
}
func init() {
docs/swagger.json
@@ -951,6 +951,40 @@
                }
            }
        },
        "/api-wms/v1/operation/getLogisticCompanyList": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "入库/出库"
                ],
                "summary": "获取物流公司列表",
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/util.ResponseList"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/definitions/models.LogisticCompany"
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api-wms/v1/operation/list": {
            "post": {
                "produces": [
@@ -2212,6 +2246,24 @@
                "CostingMethodAverageCost"
            ]
        },
        "constvar.FileType": {
            "type": "string",
            "enum": [
                "file",
                "picture",
                "thumbnail"
            ],
            "x-enum-comments": {
                "FileType_File": "文件",
                "FileType_Picture": "图片",
                "FileType_Thumbnail": "缩略图"
            },
            "x-enum-varnames": [
                "FileType_File",
                "FileType_Picture",
                "FileType_Thumbnail"
            ]
        },
        "constvar.ForceRemovalStrategy": {
            "type": "integer",
            "enum": [
@@ -2424,6 +2476,26 @@
                "ReservationNever"
            ]
        },
        "models.Attachment": {
            "type": "object",
            "properties": {
                "FileUrl": {
                    "type": "string"
                },
                "ext": {
                    "type": "string"
                },
                "fileName": {
                    "type": "string"
                },
                "fileType": {
                    "$ref": "#/definitions/constvar.FileType"
                },
                "id": {
                    "type": "integer"
                }
            }
        },
        "models.Company": {
            "type": "object",
            "properties": {
@@ -2560,12 +2632,51 @@
                }
            }
        },
        "models.LogisticCompany": {
            "type": "object",
            "properties": {
                "contact": {
                    "description": "联系人",
                    "type": "string"
                },
                "contact_phone": {
                    "description": "联系电话",
                    "type": "string"
                },
                "hidden": {
                    "description": "隐藏",
                    "type": "boolean"
                },
                "id": {
                    "type": "string"
                },
                "monthly_account": {
                    "description": "月结账号",
                    "type": "string"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "models.Material": {
            "type": "object",
            "properties": {
                "amount": {
                    "description": "数量",
                    "type": "number"
                },
                "attachmentIDs": {
                    "type": "array",
                    "items": {
                        "type": "integer"
                    }
                },
                "attachmentList": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/models.Attachment"
                    }
                },
                "barcode": {
                    "description": "条码",
@@ -2802,6 +2913,16 @@
                "id": {
                    "type": "integer"
                },
                "logisticCompany": {
                    "$ref": "#/definitions/models.LogisticCompany"
                },
                "logisticCompanyId": {
                    "type": "string"
                },
                "logisticWeight": {
                    "description": "物流重量",
                    "type": "number"
                },
                "number": {
                    "description": "单号",
                    "type": "string"
@@ -2843,6 +2964,14 @@
                },
                "updateTime": {
                    "type": "string"
                },
                "waybillNumber": {
                    "description": "运单号",
                    "type": "string"
                },
                "weight": {
                    "description": "重量",
                    "type": "number"
                }
            }
        },
@@ -3179,6 +3308,13 @@
                "id": {
                    "type": "integer"
                },
                "logisticCompanyId": {
                    "type": "string"
                },
                "logisticWeight": {
                    "description": "物流重量",
                    "type": "number"
                },
                "number": {
                    "description": "单号",
                    "type": "string"
@@ -3210,6 +3346,14 @@
                "toLocationId": {
                    "description": "目标位置id",
                    "type": "integer"
                },
                "waybillNumber": {
                    "description": "运单号",
                    "type": "string"
                },
                "weight": {
                    "description": "重量",
                    "type": "number"
                }
            }
        },
docs/swagger.yaml
@@ -33,6 +33,20 @@
    - CostingMethodStandardPrice
    - CostingMethodFIFO
    - CostingMethodAverageCost
  constvar.FileType:
    enum:
    - file
    - picture
    - thumbnail
    type: string
    x-enum-comments:
      FileType_File: 文件
      FileType_Picture: 图片
      FileType_Thumbnail: 缩略图
    x-enum-varnames:
    - FileType_File
    - FileType_Picture
    - FileType_Thumbnail
  constvar.ForceRemovalStrategy:
    enum:
    - 1
@@ -203,6 +217,19 @@
    - WhetherTypeAsk
    - WhetherTypeAlways
    - ReservationNever
  models.Attachment:
    properties:
      FileUrl:
        type: string
      ext:
        type: string
      fileName:
        type: string
      fileType:
        $ref: '#/definitions/constvar.FileType'
      id:
        type: integer
    type: object
  models.Company:
    properties:
      createTime:
@@ -297,11 +324,38 @@
      updateTime:
        type: string
    type: object
  models.LogisticCompany:
    properties:
      contact:
        description: 联系人
        type: string
      contact_phone:
        description: 联系电话
        type: string
      hidden:
        description: 隐藏
        type: boolean
      id:
        type: string
      monthly_account:
        description: 月结账号
        type: string
      name:
        type: string
    type: object
  models.Material:
    properties:
      amount:
        description: 数量
        type: number
      attachmentIDs:
        items:
          type: integer
        type: array
      attachmentList:
        items:
          $ref: '#/definitions/models.Attachment'
        type: array
      barcode:
        description: 条码
        type: string
@@ -476,6 +530,13 @@
        type: integer
      id:
        type: integer
      logisticCompany:
        $ref: '#/definitions/models.LogisticCompany'
      logisticCompanyId:
        type: string
      logisticWeight:
        description: 物流重量
        type: number
      number:
        description: 单号
        type: string
@@ -503,6 +564,12 @@
        type: integer
      updateTime:
        type: string
      waybillNumber:
        description: 运单号
        type: string
      weight:
        description: 重量
        type: number
    type: object
  models.OperationDetails:
    properties:
@@ -733,6 +800,11 @@
        type: integer
      id:
        type: integer
      logisticCompanyId:
        type: string
      logisticWeight:
        description: 物流重量
        type: number
      number:
        description: 单号
        type: string
@@ -755,6 +827,12 @@
      toLocationId:
        description: 目标位置id
        type: integer
      waybillNumber:
        description: 运单号
        type: string
      weight:
        description: 重量
        type: number
    type: object
  request.AddOperationType:
    properties:
@@ -1971,6 +2049,25 @@
      summary: 更改记录状态
      tags:
      - 入库/出库
  /api-wms/v1/operation/getLogisticCompanyList:
    get:
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            allOf:
            - $ref: '#/definitions/util.ResponseList'
            - properties:
                data:
                  items:
                    $ref: '#/definitions/models.LogisticCompany'
                  type: array
              type: object
      summary: 获取物流公司列表
      tags:
      - 入库/出库
  /api-wms/v1/operation/list:
    post:
      parameters:
models/db.go
@@ -87,6 +87,7 @@
        LocationProductAmount{},
        ReorderRule{},
        Attachment{},
        LogisticCompany{},
    )
    return err
}
models/logistic_company.go
New file
@@ -0,0 +1,153 @@
package models
import (
    "fmt"
    "gorm.io/gorm"
    "wms/pkg/mysqlx"
)
type (
    // LogisticCompany 物流公司
    //todo 与aps共用,修改字段要同步修改aps
    LogisticCompany struct {
        BaseModelString
        Name string `gorm:"unique;type:varchar(191);not null;comment:名称" json:"name"`
        // 月结账号
        MonthlyAccount string `gorm:"type:varchar(191);comment:月结账号" json:"monthly_account"`
        // 联系人
        Contact string `gorm:"type:varchar(191);comment:联系人" json:"contact"`
        // 联系电话
        ContactPhone string `gorm:"type:varchar(191);comment:联系电话" json:"contact_phone"`
        // 隐藏
        Hidden bool `gorm:"type:tinyint(1);comment:是否隐藏" json:"hidden"`
    }
    LogisticCompanySearch struct {
        LogisticCompany
        Order    string
        PageNum  int
        PageSize int
        Orm      *gorm.DB
    }
)
func (slf LogisticCompany) TableName() string {
    return "logistic_company"
}
func NewLogisticCompanySearch() *LogisticCompanySearch {
    return &LogisticCompanySearch{Orm: mysqlx.GetDB()}
}
func (slf *LogisticCompanySearch) SetOrm(tx *gorm.DB) *LogisticCompanySearch {
    slf.Orm = tx
    return slf
}
func (slf *LogisticCompanySearch) SetPage(page, size int) *LogisticCompanySearch {
    slf.PageNum, slf.PageSize = page, size
    return slf
}
func (slf *LogisticCompanySearch) SetOrder(order string) *LogisticCompanySearch {
    slf.Order = order
    return slf
}
func (slf *LogisticCompanySearch) SetID(id string) *LogisticCompanySearch {
    slf.ID = id
    return slf
}
func (slf *LogisticCompanySearch) SetName(name string) *LogisticCompanySearch {
    slf.Name = name
    return slf
}
func (slf *LogisticCompanySearch) SetKeyword(keyword string) *LogisticCompanySearch {
    slf.Name = keyword
    return slf
}
func (slf *LogisticCompanySearch) build() *gorm.DB {
    var db = slf.Orm.Table(slf.TableName())
    if slf.ID != "" {
        db = db.Where("id = ?", slf.ID)
    }
    if slf.Name != "" {
        db = db.Where("name like ?", "%"+slf.Name+"%")
    }
    if slf.Order != "" {
        db = db.Order(slf.Order)
    }
    if slf.PageNum > 0 && slf.PageSize > 0 {
        db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
    }
    return db
}
func (slf *LogisticCompanySearch) CreateBatch(data []LogisticCompany) error {
    var db = slf.build()
    if err := db.Create(&data).Error; err != nil {
        return err
    }
    return nil
}
func (slf *LogisticCompanySearch) Create(record *LogisticCompany) error {
    var db = slf.build()
    if err := db.Create(record).Error; err != nil {
        return err
    }
    return nil
}
func (slf *LogisticCompanySearch) Save(record *LogisticCompany) error {
    var db = slf.build()
    if err := db.Save(record).Error; err != nil {
        return err
    }
    return nil
}
func (slf *LogisticCompanySearch) Delete() error {
    var db = slf.build()
    if err := db.Delete(slf).Error; err != nil {
        return err
    }
    return nil
}
func (slf *LogisticCompanySearch) Find() ([]LogisticCompany, int64, error) {
    var db = slf.build()
    var records []LogisticCompany
    var total int64
    if err := db.Count(&total).Error; err != nil {
        return nil, 0, err
    }
    if slf.PageNum*slf.PageSize > 0 {
        db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
    }
    if err := db.Find(&records).Error; err != nil {
        return records, total, fmt.Errorf("find records err: %v", err)
    }
    return records, total, nil
}
func (slf *LogisticCompanySearch) FindNotTotal() ([]LogisticCompany, error) {
    var db = slf.build()
    var records []LogisticCompany
    if err := db.Find(&records).Error; err != nil {
        return records, fmt.Errorf("find records err: %v", err)
    }
    return records, nil
}
models/operation.go
@@ -2,6 +2,7 @@
import (
    "fmt"
    "github.com/shopspring/decimal"
    "gorm.io/gorm"
    "wms/constvar"
    "wms/pkg/mysqlx"
@@ -27,6 +28,11 @@
        CompanyID         int                      `json:"companyID" gorm:"type:int;comment:公司ID-客户"`
        CompanyName       string                   `json:"companyName" gorm:"type:varchar(127);comment:公司名称-客户"`
        Comment           string                   `json:"comment" gorm:"type:text;comment:备注"`
        LogisticCompanyId string                   `json:"logisticCompanyId"   gorm:"type:varchar(191);comment:物流公司id"`
        LogisticCompany   LogisticCompany          `json:"logisticCompany"      gorm:"foreignKey:LogisticCompanyId"`
        WaybillNumber     string                   `json:"waybillNumber" gorm:"type:varchar(255);comment:运单号"`    //运单号
        Weight            decimal.Decimal          `gorm:"type:decimal(20,2);comment:重量" json:"weight"`           //重量
        LogisticWeight    decimal.Decimal          `gorm:"type:decimal(20,2);comment:物流重量" json:"logisticWeight"` //物流重量
        Details           []*OperationDetails        `json:"details" gorm:"foreignKey:OperationID;references:Id"`
        BaseOperationType constvar.BaseOperationType `json:"baseOperationType" gorm:"type:tinyint;not null;comment:基础作业类型"` //基础作业类型
@@ -145,7 +151,8 @@
    }
    if slf.Preload {
        db = db.Model(&Operation{}).Preload("Details").Preload("Details.Product").Preload("FromLocation").Preload("ToLocation")
        db = db.Model(&Operation{}).Preload("Details").Preload("Details.Product").Preload("FromLocation").
            Preload("ToLocation").Preload("LogisticCompany")
    }
    if slf.Disuse {
request/operation.go
@@ -21,12 +21,10 @@
    CompanyID         int                      `json:"companyID" gorm:"type:int;comment:公司ID"`              //公司ID-客户
    CompanyName       string                   `json:"companyName" gorm:"type:varchar(127);comment:公司名称"`   //公司名称-客户名称
    Comment           string                   `json:"comment" gorm:"type:text;comment:备注"`                 //备注
    //Weight          decimal.Decimal          `json:"weight" gorm:"type:decimal(20,2);comment:重量(kg)"`           //重量(kg)-非必填
    //TransferWeight  decimal.Decimal          `json:"transferWeight" gorm:"type:decimal(20,2);comment:物流重量(kg)"` //物流重量(kg)-非必填
    //CarrierID       int                      `json:"carrierID" gorm:"type:int;comment:承运商ID"`                   //承运商ID-非必填
    //CarrierName     string                   `json:"carrierName" gorm:"type:varchar(63);comment:承运商名称"`         //承运商名称-非必填
    //Tracking        string                   `json:"tracking" gorm:"type:varchar(127);comment:追踪参考"`            //追踪参考-非必填
    LogisticCompanyId string                   `json:"logisticCompanyId"   gorm:"type:varchar(191);comment:物流公司id"`
    WaybillNumber     string                   `json:"waybillNumber" gorm:"type:varchar(255);comment:运单号"`    //运单号
    Weight            decimal.Decimal          `gorm:"type:decimal(20,2);comment:重量" json:"weight"`           //重量
    LogisticWeight    decimal.Decimal          `gorm:"type:decimal(20,2);comment:物流重量" json:"logisticWeight"` //物流重量
}
type OperationDetails struct {
@@ -62,6 +60,10 @@
    CompanyName       string                     `json:"companyName" gorm:"type:varchar(127);comment:公司名称"`   //公司名称-客户名称
    Comment           string                     `json:"comment" gorm:"type:text;comment:备注"`                 //备注
    BaseOperationType constvar.BaseOperationType `json:"baseOperationType"`                                   //基础作业类型
    LogisticCompanyId string                     `json:"logisticCompanyId"   gorm:"type:varchar(191);comment:物流公司id"`
    WaybillNumber     string                     `json:"waybillNumber" gorm:"type:varchar(255);comment:运单号"`    //运单号
    Weight            decimal.Decimal            `gorm:"type:decimal(20,2);comment:重量" json:"weight"`           //重量
    LogisticWeight    decimal.Decimal            `gorm:"type:decimal(20,2);comment:物流重量" json:"logisticWeight"` //物流重量
}
type OperationAllList struct {
router/router.go
@@ -86,6 +86,7 @@
        operationAPI.DELETE("operation/:id", operationController.Delete)
        operationAPI.PUT("finish/:id", operationController.Finish)
        operationAPI.POST("listTransfer", operationController.ListTransfer)
        operationAPI.GET("getLogisticCompanyList", operationController.GetLogisticCompanyList)
    }