1.修改出入库模块的新增、修改、列表,operation_details不再保存产品名称和单位,改为读取material
2.修改报废模块的新增,修改、列表,不再使用productName和unit字段
9个文件已修改
193 ■■■■■ 已修改文件
controllers/operation.go 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/product_controller.go 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/operation.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/operation_details.go 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
request/operation.go 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
request/product_request.go 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/operation.go
@@ -115,9 +115,9 @@
        if v.ProductId == "" {
            return errors.New("productID为空")
        }
        if v.ProductName == "" {
            return errors.New("产品名称异常")
        }
        //if v.ProductName == "" {
        //    return errors.New("产品名称异常")
        //}
        if v.Amount.IsNegative() {
            return errors.New("产品数量出错")
        }
controllers/product_controller.go
@@ -343,10 +343,10 @@
        return
    }
    detail := &models.OperationDetails{
        ProductId:   params.ProductId,
        ProductName: params.ProductName,
        Amount:      params.Amount,
        Unit:        params.Unit,
        ProductId: params.ProductId,
        //ProductName: params.ProductName,
        Amount: params.Amount,
        //Unit:        params.Unit,
    }
    operation := models.Operation{
        Number:          strconv.FormatInt(time.Now().Unix(), 10),
@@ -384,7 +384,9 @@
        return
    }
    db := models.NewOperationSearch().Orm.Table("wms_operation").Select("wms_operation.id,wms_operation.number,wms_operation.source_number,wms_operation.status,wms_operation.from_location_id,wms_operation.to_location_id,wms_operation.operation_date,wms_operation.contacter_id,wms_operation.contacter_name,wms_operation.company_id,wms_operation.company_name,wms_operation.comment,wms_operation_details.product_id,wms_operation_details.product_name,wms_operation_details.unit,wms_operation_details.amount").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id")
    //db := models.NewOperationSearch().Orm.Table("wms_operation").Select("wms_operation.id,wms_operation.number,wms_operation.source_number,wms_operation.status,wms_operation.from_location_id,wms_operation.to_location_id,wms_operation.operation_date,wms_operation.contacter_id,wms_operation.contacter_name,wms_operation.company_id,wms_operation.company_name,wms_operation.comment,wms_operation_details.product_id,wms_operation_details.product_name,wms_operation_details.unit,wms_operation_details.amount").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id")
    db := models.NewOperationSearch().Orm.Table("wms_operation").Select("wms_operation.id,wms_operation.number,wms_operation.source_number,wms_operation.status,wms_operation.from_location_id,wms_operation.to_location_id,wms_operation.operation_date,wms_operation.contacter_id,wms_operation.contacter_name,wms_operation.company_id,wms_operation.company_name,wms_operation.comment,wms_operation_details.product_id,material.name as product_name,material.unit,wms_operation_details.amount").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id").InnerJoins("inner join material on material.id=wms_operation_details.product_id")
    if params.SourceNumber != "" {
        db = db.Where("wms_operation.source_number like ?", fmt.Sprintf("%%%v%%", params.SourceNumber))
@@ -515,10 +517,10 @@
        return
    }
    detail := &models.OperationDetails{
        ProductId:   params.ProductId,
        ProductName: params.ProductName,
        Amount:      params.Amount,
        Unit:        params.Unit,
        ProductId: params.ProductId,
        //ProductName: params.ProductName,
        Amount: params.Amount,
        //Unit:        params.Unit,
    }
    operation := models.Operation{
        Id:              params.Id,
docs/docs.go
@@ -2118,7 +2118,7 @@
            "type": "object",
            "properties": {
                "amount": {
                    "description": "数量",
                    "description": "ProductName string          ` + "`" + `json:\"productName\" gorm:\"type:varchar(255);not null;comment:产品名称\"` + "`" + ` //产品名称",
                    "type": "number"
                },
                "createTime": {
@@ -2131,15 +2131,16 @@
                    "description": "操作id",
                    "type": "integer"
                },
                "product": {
                    "description": "Unit        string          ` + "`" + `json:\"unit\" gorm:\"type:varchar(31);comment:单位\"` + "`" + `                    //单位",
                    "allOf": [
                        {
                            "$ref": "#/definitions/models.Material"
                        }
                    ]
                },
                "productId": {
                    "description": "产品id",
                    "type": "string"
                },
                "productName": {
                    "description": "产品名称",
                    "type": "string"
                },
                "unit": {
                    "type": "string"
                },
                "updateTime": {
@@ -2430,6 +2431,7 @@
            "type": "object",
            "properties": {
                "amount": {
                    "description": "ProductName    string          ` + "`" + `json:\"productName\"` + "`" + `",
                    "type": "number"
                },
                "fromLocationId": {
@@ -2438,17 +2440,11 @@
                "productId": {
                    "type": "string"
                },
                "productName": {
                    "type": "string"
                },
                "sourceNumber": {
                    "type": "string"
                },
                "toLocationId": {
                    "type": "integer"
                },
                "unit": {
                    "type": "string"
                }
            }
        },
@@ -2690,18 +2686,11 @@
                    "type": "integer"
                },
                "amount": {
                    "description": "数量",
                    "description": "ProductName string          ` + "`" + `json:\"productName\" gorm:\"type:varchar(255);not null;comment:产品名称\"` + "`" + ` //产品名称",
                    "type": "number"
                },
                "productId": {
                    "description": "产品id",
                    "type": "string"
                },
                "productName": {
                    "description": "产品名称",
                    "type": "string"
                },
                "unit": {
                    "type": "string"
                }
            }
@@ -2803,6 +2792,7 @@
            "type": "object",
            "properties": {
                "amount": {
                    "description": "ProductName    string                   ` + "`" + `json:\"productName\"` + "`" + `",
                    "type": "number"
                },
                "fromLocationId": {
@@ -2812,15 +2802,13 @@
                    "type": "integer"
                },
                "number": {
                    "description": "Unit           string                   ` + "`" + `json:\"unit\"` + "`" + `",
                    "type": "string"
                },
                "operationDate": {
                    "type": "string"
                },
                "productId": {
                    "type": "string"
                },
                "productName": {
                    "type": "string"
                },
                "sourceNumber": {
@@ -2831,9 +2819,6 @@
                },
                "toLocationId": {
                    "type": "integer"
                },
                "unit": {
                    "type": "string"
                }
            }
        },
docs/swagger.json
@@ -2106,7 +2106,7 @@
            "type": "object",
            "properties": {
                "amount": {
                    "description": "数量",
                    "description": "ProductName string          `json:\"productName\" gorm:\"type:varchar(255);not null;comment:产品名称\"` //产品名称",
                    "type": "number"
                },
                "createTime": {
@@ -2119,15 +2119,16 @@
                    "description": "操作id",
                    "type": "integer"
                },
                "product": {
                    "description": "Unit        string          `json:\"unit\" gorm:\"type:varchar(31);comment:单位\"`                    //单位",
                    "allOf": [
                        {
                            "$ref": "#/definitions/models.Material"
                        }
                    ]
                },
                "productId": {
                    "description": "产品id",
                    "type": "string"
                },
                "productName": {
                    "description": "产品名称",
                    "type": "string"
                },
                "unit": {
                    "type": "string"
                },
                "updateTime": {
@@ -2418,6 +2419,7 @@
            "type": "object",
            "properties": {
                "amount": {
                    "description": "ProductName    string          `json:\"productName\"`",
                    "type": "number"
                },
                "fromLocationId": {
@@ -2426,17 +2428,11 @@
                "productId": {
                    "type": "string"
                },
                "productName": {
                    "type": "string"
                },
                "sourceNumber": {
                    "type": "string"
                },
                "toLocationId": {
                    "type": "integer"
                },
                "unit": {
                    "type": "string"
                }
            }
        },
@@ -2678,18 +2674,11 @@
                    "type": "integer"
                },
                "amount": {
                    "description": "数量",
                    "description": "ProductName string          `json:\"productName\" gorm:\"type:varchar(255);not null;comment:产品名称\"` //产品名称",
                    "type": "number"
                },
                "productId": {
                    "description": "产品id",
                    "type": "string"
                },
                "productName": {
                    "description": "产品名称",
                    "type": "string"
                },
                "unit": {
                    "type": "string"
                }
            }
@@ -2791,6 +2780,7 @@
            "type": "object",
            "properties": {
                "amount": {
                    "description": "ProductName    string                   `json:\"productName\"`",
                    "type": "number"
                },
                "fromLocationId": {
@@ -2800,15 +2790,13 @@
                    "type": "integer"
                },
                "number": {
                    "description": "Unit           string                   `json:\"unit\"`",
                    "type": "string"
                },
                "operationDate": {
                    "type": "string"
                },
                "productId": {
                    "type": "string"
                },
                "productName": {
                    "type": "string"
                },
                "sourceNumber": {
@@ -2819,9 +2807,6 @@
                },
                "toLocationId": {
                    "type": "integer"
                },
                "unit": {
                    "type": "string"
                }
            }
        },
docs/swagger.yaml
@@ -478,7 +478,8 @@
  models.OperationDetails:
    properties:
      amount:
        description: 数量
        description: ProductName string          `json:"productName" gorm:"type:varchar(255);not
          null;comment:产品名称"` //产品名称
        type: number
      createTime:
        type: string
@@ -487,13 +488,12 @@
      operationId:
        description: 操作id
        type: integer
      product:
        allOf:
        - $ref: '#/definitions/models.Material'
        description: Unit        string          `json:"unit" gorm:"type:varchar(31);comment:单位"`                    //单位
      productId:
        description: 产品id
        type: string
      productName:
        description: 产品名称
        type: string
      unit:
        type: string
      updateTime:
        type: string
@@ -684,19 +684,16 @@
  request.AddDisuse:
    properties:
      amount:
        description: ProductName    string          `json:"productName"`
        type: number
      fromLocationId:
        type: integer
      productId:
        type: string
      productName:
        type: string
      sourceNumber:
        type: string
      toLocationId:
        type: integer
      unit:
        type: string
    type: object
  request.AddOperation:
    properties:
@@ -863,15 +860,11 @@
        description: 操作id
        type: integer
      amount:
        description: 数量
        description: ProductName string          `json:"productName" gorm:"type:varchar(255);not
          null;comment:产品名称"` //产品名称
        type: number
      productId:
        description: 产品id
        type: string
      productName:
        description: 产品名称
        type: string
      unit:
        type: string
    type: object
  request.OperationList:
@@ -941,18 +934,18 @@
  request.UpdateDisuse:
    properties:
      amount:
        description: ProductName    string                   `json:"productName"`
        type: number
      fromLocationId:
        type: integer
      id:
        type: integer
      number:
        description: Unit           string                   `json:"unit"`
        type: string
      operationDate:
        type: string
      productId:
        type: string
      productName:
        type: string
      sourceNumber:
        type: string
@@ -960,8 +953,6 @@
        $ref: '#/definitions/constvar.OperationStatus'
      toLocationId:
        type: integer
      unit:
        type: string
    type: object
  request.UpdateOperation:
    properties:
models/operation.go
@@ -134,7 +134,7 @@
    }
    if slf.Preload {
        db = db.Model(&Operation{}).Preload("Details").Preload("FromLocation").Preload("ToLocation")
        db = db.Model(&Operation{}).Preload("Details").Preload("Details.Product").Preload("FromLocation").Preload("ToLocation")
    }
    if slf.Disuse {
models/operation_details.go
@@ -11,12 +11,13 @@
    // OperationDetails 操作明细表
    OperationDetails struct {
        WmsModel
        Id          int             `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
        OperationID int             `json:"operationId" gorm:"type:int;not null;comment:操作记录id"`        //操作id
        ProductId   string          `json:"productId" gorm:"type:varchar(191);not null;comment:产品id"`   //产品id
        ProductName string          `json:"productName" gorm:"type:varchar(255);not null;comment:产品名称"` //产品名称
        Amount      decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:数量"`       //数量
        Unit        string          `json:"unit" gorm:"type:varchar(31);comment:单位"`
        Id          int    `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
        OperationID int    `json:"operationId" gorm:"type:int;not null;comment:操作记录id"`      //操作id
        ProductId   string `json:"productId" gorm:"type:varchar(191);not null;comment:产品id"` //产品id
        //ProductName string          `json:"productName" gorm:"type:varchar(255);not null;comment:产品名称"` //产品名称
        Amount decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:数量"` //数量
        //Unit        string          `json:"unit" gorm:"type:varchar(31);comment:单位"`                    //单位
        Product Material `json:"product" gorm:"foreignKey:ProductId;references:ID"`
    }
    OperationDetailsSearch struct {
request/operation.go
@@ -30,11 +30,12 @@
}
type OperationDetails struct {
    OperationId int             `json:"OperationId" gorm:"type:int;not null;comment:操作记录id"`        //操作id
    ProductId   string          `json:"productId" gorm:"type:varchar(191);not null;comment:产品id"`   //产品id
    ProductName string          `json:"productName" gorm:"type:varchar(255);not null;comment:产品名称"` //产品名称
    Amount      decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:数量"`       //数量
    Unit        string          `json:"unit" gorm:"type:varchar(31);comment:单位"`
    OperationId int    `json:"OperationId" gorm:"type:int;not null;comment:操作记录id"`      //操作id
    ProductId   string `json:"productId" gorm:"type:varchar(191);not null;comment:产品id"` //产品id
    //ProductName string          `json:"productName" gorm:"type:varchar(255);not null;comment:产品名称"` //产品名称
    Amount decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:数量"` //数量
    //Unit        string          `json:"unit" gorm:"type:varchar(31);comment:单位"`                    //单位
    //Product models.Material `json:"product" gorm:"foreignKey:ProductId;references:ID"`
}
type OperationList struct {
request/product_request.go
@@ -16,13 +16,13 @@
}
type AddDisuse struct {
    ProductId      string          `json:"productId"`
    ProductName    string          `json:"productName"`
    ProductId string `json:"productId"`
    //ProductName    string          `json:"productName"`
    Amount         decimal.Decimal `json:"amount"`
    FromLocationId int             `json:"fromLocationId"`
    ToLocationId   int             `json:"toLocationId"`
    SourceNumber   string          `json:"sourceNumber"`
    Unit           string          `json:"unit"`
    //Unit           string          `json:"unit"`
}
type QueryDisuseList struct {
@@ -32,15 +32,15 @@
}
type UpdateDisuse struct {
    Id             int                      `json:"id"`
    ProductId      string                   `json:"productId"`
    ProductName    string                   `json:"productName"`
    Amount         decimal.Decimal          `json:"amount"`
    FromLocationId int                      `json:"fromLocationId"`
    ToLocationId   int                      `json:"toLocationId"`
    SourceNumber   string                   `json:"sourceNumber"`
    Unit           string                   `json:"unit"`
    Number         string                   `json:"number"`
    Status         constvar.OperationStatus `json:"status"`
    OperationDate  string                   `json:"operationDate"`
    Id        int    `json:"id"`
    ProductId string `json:"productId"`
    //ProductName    string                   `json:"productName"`
    Amount         decimal.Decimal `json:"amount"`
    FromLocationId int             `json:"fromLocationId"`
    ToLocationId   int             `json:"toLocationId"`
    SourceNumber   string          `json:"sourceNumber"`
    //Unit           string                   `json:"unit"`
    Number        string                   `json:"number"`
    Status        constvar.OperationStatus `json:"status"`
    OperationDate string                   `json:"operationDate"`
}