jiangshuai
2023-11-14 9d0d545bdd6f1448c19c24d2159a4f1752131d31
Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS
9个文件已修改
97 ■■■■ 已修改文件
controllers/location.go 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/report_forms_controller.go 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/warehouse.go 45 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/location.go 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/operation_details.go 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
request/report_forms_request.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/location.go
@@ -4,6 +4,7 @@
    "errors"
    "github.com/gin-gonic/gin"
    "strconv"
    "strings"
    "wms/extend/code"
    "wms/extend/util"
    "wms/models"
@@ -159,7 +160,7 @@
        }
        params.JointName = first.JointName + "/" + params.Name
    } else {
        params.JointName = params.Name
        params.JointName = strings.Split(params.JointName, "/")[0] + "/" + params.Name
    }
    err := models.NewLocationSearch().Update(&params)
    if err != nil {
controllers/report_forms_controller.go
@@ -166,7 +166,7 @@
    if params.PageInfo.Check() {
        detailsSearch.SetPage(params.Page, params.PageSize)
    }
    details, total, err := detailsSearch.SetProductId(params.ProduceId).Find()
    details, total, err := detailsSearch.SetPreload(true).SetProductId(params.ProduceId).Find()
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "查询操作详情失败")
        return
@@ -218,16 +218,19 @@
        util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误")
        return
    }
    //查询位置
    locations, err := models.NewLocationSearch().SetJointName(params.WareHouseCode).FindAll()
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "查询位置失败")
        return
    }
    ids := make([]int, 0)
    for _, location := range locations {
        ids = append(ids, location.Id)
    if params.LocationId != 0 {
        ids = append(ids, params.LocationId)
    } else {
        //查询位置
        locations, err := models.NewLocationSearch().SetJointName(params.WareHouseCode).FindAll()
        if err != nil {
            util.ResponseFormat(c, code.RequestParamError, "查询位置失败")
            return
        }
        for _, location := range locations {
            ids = append(ids, location.Id)
        }
    }
    amounts, total, err := models.NewLocationProductAmountSearch().SetPage(params.Page, params.PageSize).SetPreload(true).SetKeyword(params.KeyWord).SetProductId(params.ProductId).SetLocationIds(ids).FindByPage()
controllers/warehouse.go
@@ -7,6 +7,7 @@
    "github.com/spf13/cast"
    "gorm.io/gorm"
    "strconv"
    "strings"
    "wms/constvar"
    "wms/extend/code"
    "wms/extend/util"
@@ -41,12 +42,24 @@
        util.ResponseFormat(c, code.RequestParamError, err.Error())
        return
    }
    //创建视图
    view := &models.Location{
        Name:      params.Code,
        JointName: params.Code,
        Type:      constvar.LocationTypeView,
    }
    id, err := models.NewLocationSearch().CreateReturnId(view)
    if err != nil {
        util.ResponseFormat(c, code.SaveFail, "视图创建失败")
        return
    }
    //创建默认位置
    location := &models.Location{
        Name:              "默认位置",
        JointName:         params.Code,
        JointName:         params.Code + "/默认位置",
        Type:              constvar.LocationTypeInternal,
        ReplenishLocation: true,
        ParentId:          id,
    }
    locationId, err := models.NewLocationSearch().CreateReturnId(location)
    if err != nil {
@@ -129,9 +142,27 @@
    }
    //更新位置信息
    if oldRecord != nil && params.Code != oldRecord.Code {
        m := make(map[string]interface{})
        m["joint_name"] = params.Code
        err := models.NewLocationSearch().SetID(oldRecord.LocationId).UpdateByMap(m)
        locations, err := models.NewLocationSearch().SetJointName(oldRecord.Code).FindNotTotal()
        if err != nil {
            return errors.New("查询位置信息失败")
        }
        err = models.WithTransaction(func(db *gorm.DB) error {
            for _, location := range locations {
                m := make(map[string]interface{})
                index := strings.Index(location.JointName, "/")
                if index > 0 {
                    m["joint_name"] = params.Code + location.JointName[index:]
                } else {
                    m["joint_name"] = params.Code
                }
                err = models.NewLocationSearch().SetOrm(db).SetID(location.Id).UpdateByMap(m)
                if err != nil {
                    return err
                }
            }
            return nil
        })
        if err != nil {
            return errors.New("更新位置信息失败")
        }
@@ -168,11 +199,11 @@
        return
    }
    //获取位置信息
    codes := make([]string, 0)
    ids := make([]int, 0)
    for _, warehouse := range list {
        codes = append(codes, warehouse.Code)
        ids = append(ids, warehouse.LocationId)
    }
    locations, err := models.NewLocationSearch().SetJointNames(codes).FindNotTotal()
    locations, err := models.NewLocationSearch().SetIds(ids).FindNotTotal()
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "位置信息查找失败")
        return
docs/docs.go
@@ -3656,6 +3656,9 @@
                "keyWord": {
                    "type": "string"
                },
                "locationId": {
                    "type": "integer"
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
@@ -4372,6 +4375,8 @@
    Description:      "",
    InfoInstanceName: "swagger",
    SwaggerTemplate:  docTemplate,
    LeftDelim:        "{{",
    RightDelim:       "}}",
}
func init() {
docs/swagger.json
@@ -3644,6 +3644,9 @@
                "keyWord": {
                    "type": "string"
                },
                "locationId": {
                    "type": "integer"
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
docs/swagger.yaml
@@ -994,6 +994,8 @@
    properties:
      keyWord:
        type: string
      locationId:
        type: integer
      page:
        description: 页码
        type: integer
models/location.go
@@ -38,6 +38,7 @@
        Orm        *gorm.DB
        Preload    bool
        JointNames []string
        Ids        []int
    }
)
@@ -66,6 +67,11 @@
func (slf *LocationSearch) SetID(ID int) *LocationSearch {
    slf.Id = ID
    return slf
}
func (slf *LocationSearch) SetIds(ids []int) *LocationSearch {
    slf.Ids = ids
    return slf
}
@@ -116,6 +122,10 @@
        db = db.Where("id = ?", slf.Id)
    }
    if len(slf.Ids) > 0 {
        db = db.Where("id in (?)", slf.Ids)
    }
    if slf.Order != "" {
        db = db.Order(slf.Order)
    }
models/operation_details.go
@@ -100,6 +100,9 @@
    if slf.ProductId != "" {
        db = db.Where("product_id = ?", slf.ProductId)
    }
    if slf.Preload {
        db = db.Preload("Product")
    }
    return db
}
@@ -207,7 +210,7 @@
    if slf.PageNum*slf.PageSize > 0 {
        db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
    }
    if err := db.Preload("Product").Find(&records).Error; err != nil {
    if err := db.Find(&records).Error; err != nil {
        return records, fmt.Errorf("find records err: %v", err)
    }
request/report_forms_request.go
@@ -23,4 +23,5 @@
    KeyWord       string `json:"keyWord"`
    WareHouseCode string `json:"wareHouseCode"`
    ProductId     string `json:"productId"`
    LocationId    int    `json:"locationId"`
}