liujiandao
2023-10-18 6c352b5884f552194f0da7a197efdb6b667cfab8
位置初始化
4个文件已修改
39 ■■■■ 已修改文件
controllers/report_forms_controller.go 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/db.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/location.go 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/report_forms_controller.go
@@ -69,13 +69,13 @@
    dbIn := models.NewOperationDetailsSearch().Orm.Model(&models.OperationDetails{}).
        Joins("left join wms_operation ON wms_operation_details.operation_id=wms_operation.id").
        Where("wms_operation.base_operation_type=?", constvar.BaseOperationTypeIncoming).
        Where("wms_operation.status=?", constvar.OperationStatus_Ready)
        Where("wms_operation.status in (?)", []int{3, 4})
    dbOut := models.NewOperationDetailsSearch().Orm.Model(&models.OperationDetails{}).
        Joins("left join wms_operation ON wms_operation_details.operation_id=wms_operation.id").
        Where("wms_operation.base_operation_type=?", constvar.BaseOperationTypeOutgoing).
        Where("wms_operation.status=?", constvar.OperationStatus_Ready)
        Where("wms_operation.status in (?)", []int{3, 4})
    if len(locationIds) > 0 {
        dbIn.Where("wms_operation.from_location_id in (?)", locationIds)
        dbIn.Where("wms_operation.to_location_id in (?)", locationIds)
        dbOut.Where("wms_operation.from_location_id in (?)", locationIds)
    }
    err = dbIn.Find(&inHouse).Error
@@ -94,7 +94,6 @@
        resp.ProduceId = material.ID
        resp.ProductName = material.Name
        resp.Cost = material.Cost
        resp.Amount = material.Amount
        resp.Unit = material.Unit
        resp.Value = material.Amount.Mul(material.Cost)
        resp.ProductType = material.CategoryName
@@ -108,6 +107,7 @@
                resp.Out = resp.Out.Add(details.Amount)
            }
        }
        resp.Amount = resp.In.Sub(resp.Out)
        resp.AvailableNumber = resp.Amount
        result = append(result, resp)
    }
@@ -132,7 +132,7 @@
    if params.PageInfo.Check() {
        detailsSearch.SetPage(params.Page, params.PageSize)
    }
    details, total, err := detailsSearch.SetProductId(params.ProduceId).Find()
    details, err := detailsSearch.SetProductId(params.ProduceId).FindNotTotal()
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "查询操作详情失败")
        return
@@ -142,7 +142,7 @@
        operationIds = append(operationIds, detail.OperationID)
    }
    //获取已完成的操作记录
    operations, err := models.NewOperationSearch().SetIds(operationIds).SetStatus(constvar.OperationStatus_Finish).FindNotTotal()
    operations, total, err := models.NewOperationSearch().SetIds(operationIds).SetStatus(constvar.OperationStatus_Finish).Find()
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "查询操作记录失败")
        return
docs/docs.go
@@ -3734,6 +3734,8 @@
    Description:      "",
    InfoInstanceName: "swagger",
    SwaggerTemplate:  docTemplate,
    LeftDelim:        "{{",
    RightDelim:       "}}",
}
func init() {
models/db.go
@@ -98,6 +98,7 @@
func InsertDefaultData() {
    models := []interface{}{
        NewDepartmentSearch(),
        NewLocationSearch(),
    }
    for _, model := range models {
        if id, ok := model.(InitDefaultData); ok {
models/location.go
@@ -317,3 +317,27 @@
    }
    return records, nil
}
// InitDefaultData 初始化数据
func (slf *LocationSearch) InitDefaultData() error {
    var (
        db          = slf.Orm.Table(slf.TableName())
        total int64 = 0
    )
    if err := db.Count(&total).Error; err != nil {
        return err
    }
    if total != 0 {
        return nil
    }
    locations := make([]*Location, 0)
    locations = append(locations, &Location{Name: "供应商位置", Type: 1, JointName: "供应商位置"})
    locations = append(locations, &Location{Name: "视图", Type: 2, JointName: "视图"})
    locations = append(locations, &Location{Name: "客户位置", Type: 4, JointName: "客户位置"})
    locations = append(locations, &Location{Name: "库存损失", Type: 5, JointName: "库存损失"})
    locations = append(locations, &Location{Name: "生产", Type: 6, JointName: "生产"})
    locations = append(locations, &Location{Name: "中转位置", Type: 7, JointName: "中转位置"})
    locations = append(locations, &Location{Name: "报废位置", Type: 8, JointName: "报废位置"})
    locations = append(locations, &Location{Name: "库存盘点", Type: 9, JointName: "库存盘点"})
    return slf.CreateBatch(locations)
}