Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS
| | |
| | | return |
| | | } |
| | | |
| | | if err := db.Offset((params.Page - 1) * params.PageSize).Limit(params.PageSize).Find(&records).Error; err != nil { |
| | | if err := db.Offset((params.Page - 1) * params.PageSize).Limit(params.PageSize).Order("wms_operation.created_at desc").Find(&records).Error; err != nil { |
| | | util.ResponseFormat(c, code.RequestError, "查找失败:"+err.Error()) |
| | | return |
| | | } |
| | |
| | | "wms/constvar" |
| | | "wms/extend/code" |
| | | "wms/extend/util" |
| | | "wms/middleware" |
| | | "wms/models" |
| | | "wms/pkg/logx" |
| | | "wms/pkg/mysqlx" |
| | |
| | | } |
| | | util.ResponseFormat(c, code.Success, "操作成功") |
| | | } |
| | | |
| | | // GetUserInfo |
| | | // |
| | | // @Tags 产品 |
| | | // @Summary 获取登录用户信息 |
| | | // @Produce application/json |
| | | // @Success 200 {object} util.ResponseList{data=map[string]interface{}} "成功" |
| | | // @Router /api-wms/v1/product/getUserInfo [get] |
| | | func (slf ProductController) GetUserInfo(c *gin.Context) { |
| | | userInfo := middleware.GetUserInfo(c) |
| | | m := make(map[string]interface{}) |
| | | m["userName"] = userInfo.Username |
| | | util.ResponseFormat(c, code.Success, m) |
| | | } |
| | |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | | } |
| | | err := models.NewWarehouseSearch().SetID(params.Id).Update(¶ms) |
| | | warehouse, err := models.NewWarehouseSearch().SetID(params.Id).First() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "仓库不存在") |
| | | return |
| | | } |
| | | err = models.WithTransaction(func(db *gorm.DB) error { |
| | | //更新作业类型名称 |
| | | if params.Name != warehouse.Name { |
| | | m := make(map[string]interface{}) |
| | | m["name"] = params.Name + "-入库" |
| | | err := models.NewOperationTypeSearch().SetOrm(db).SetBaseOperationType(constvar.BaseOperationTypeIncoming).SetWarehouseId(params.Id).UpdateByMap(m) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | m["name"] = params.Name + "-出库" |
| | | err = models.NewOperationTypeSearch().SetOrm(db).SetBaseOperationType(constvar.BaseOperationTypeOutgoing).SetWarehouseId(params.Id).UpdateByMap(m) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | m["name"] = params.Name + "-内部调拨" |
| | | err = models.NewOperationTypeSearch().SetOrm(db).SetBaseOperationType(constvar.BaseOperationTypeInternal).SetWarehouseId(params.Id).UpdateByMap(m) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | } |
| | | err = models.NewWarehouseSearch().SetID(params.Id).Update(¶ms) |
| | | return err |
| | | }) |
| | | |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "修改失败") |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/product/getUserInfo": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "产品" |
| | | ], |
| | | "summary": "获取登录用户信息", |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.ResponseList" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "object", |
| | | "additionalProperties": true |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/product/listDisuse": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | } |
| | | ] |
| | | }, |
| | | "toLocation": { |
| | | "description": "目标位置", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/models.Location" |
| | | } |
| | | ] |
| | | }, |
| | | "toLocationId": { |
| | | "description": "目标位置id", |
| | | "type": "integer" |
| | | }, |
| | | "updateTime": { |
| | | "type": "string" |
| | | }, |
| | |
| | | "$ref": "#/definitions/constvar.OperationStatus" |
| | | } |
| | | ] |
| | | }, |
| | | "toLocationId": { |
| | | "description": "目标位置id", |
| | | "type": "integer" |
| | | }, |
| | | "waybillNumber": { |
| | | "description": "运单号", |
| | |
| | | } |
| | | ] |
| | | }, |
| | | "toLocationId": { |
| | | "description": "目标位置id", |
| | | "type": "integer" |
| | | }, |
| | | "waybillNumber": { |
| | | "description": "运单号", |
| | | "type": "string" |
| | |
| | | Description: "", |
| | | InfoInstanceName: "swagger", |
| | | SwaggerTemplate: docTemplate, |
| | | LeftDelim: "{{", |
| | | RightDelim: "}}", |
| | | } |
| | | |
| | | func init() { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/product/getUserInfo": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "产品" |
| | | ], |
| | | "summary": "获取登录用户信息", |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.ResponseList" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "object", |
| | | "additionalProperties": true |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/product/listDisuse": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | } |
| | | ] |
| | | }, |
| | | "toLocation": { |
| | | "description": "目标位置", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/models.Location" |
| | | } |
| | | ] |
| | | }, |
| | | "toLocationId": { |
| | | "description": "目标位置id", |
| | | "type": "integer" |
| | | }, |
| | | "updateTime": { |
| | | "type": "string" |
| | | }, |
| | |
| | | "$ref": "#/definitions/constvar.OperationStatus" |
| | | } |
| | | ] |
| | | }, |
| | | "toLocationId": { |
| | | "description": "目标位置id", |
| | | "type": "integer" |
| | | }, |
| | | "waybillNumber": { |
| | | "description": "运单号", |
| | |
| | | } |
| | | ] |
| | | }, |
| | | "toLocationId": { |
| | | "description": "目标位置id", |
| | | "type": "integer" |
| | | }, |
| | | "waybillNumber": { |
| | | "description": "运单号", |
| | | "type": "string" |
| | |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.OperationStatus' |
| | | description: 状态 |
| | | toLocation: |
| | | allOf: |
| | | - $ref: '#/definitions/models.Location' |
| | | description: 目标位置 |
| | | toLocationId: |
| | | description: 目标位置id |
| | | type: integer |
| | | updateTime: |
| | | type: string |
| | | waybillNumber: |
| | |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.OperationStatus' |
| | | description: 状态 |
| | | toLocationId: |
| | | description: 目标位置id |
| | | type: integer |
| | | waybillNumber: |
| | | description: 运单号 |
| | | type: string |
| | |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.OperationStatus' |
| | | description: 状态 |
| | | toLocationId: |
| | | description: 目标位置id |
| | | type: integer |
| | | waybillNumber: |
| | | description: 运单号 |
| | | type: string |
| | |
| | | summary: 获取产品列表 |
| | | tags: |
| | | - 产品 |
| | | /api-wms/v1/product/getUserInfo: |
| | | get: |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/util.ResponseList' |
| | | - properties: |
| | | data: |
| | | additionalProperties: true |
| | | type: object |
| | | type: object |
| | | summary: 获取登录用户信息 |
| | | tags: |
| | | - 产品 |
| | | /api-wms/v1/product/listDisuse: |
| | | post: |
| | | parameters: |
| | |
| | | logx.Errorf("grpc server init error: %v", err.Error()) |
| | | panic(fmt.Sprintf("grpc server init error: %v", err.Error())) |
| | | } |
| | | fmt.Println("-----------监听端口: ", conf.WebConf.GrpcPort) |
| | | s := grpc.NewServer() |
| | | //todo 添加具体服务 |
| | | product_inventory.RegisterProductInventoryServiceServer(s, &product_inventory.Server{}) |
| | |
| | | |
| | | import ( |
| | | "errors" |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/golang-jwt/jwt/v4" |
| | | "wms/request" |
| | | ) |
| | |
| | | return nil, TokenInvalid |
| | | } |
| | | } |
| | | |
| | | func GetUserInfo(c *gin.Context) *request.CustomClaims { |
| | | if claims, exists := c.Get("claims"); exists { |
| | | waitUse := claims.(*request.CustomClaims) |
| | | return waitUse |
| | | } |
| | | return nil |
| | | } |
| | |
| | | ControlStrategy constvar.InvoicingStrategy `gorm:"type:int(11);comment:控制策略" json:"controlStrategy"` //控制策略 |
| | | BuyExplain string `gorm:"type:varchar(512);comment:采购说明" json:"buyExplain"` //采购说明 |
| | | Principal string `gorm:"type:varchar(255);comment:负责人" json:"principal"` //负责人 |
| | | Weight decimal.Decimal `gorm:"type:decimal(20,2);comment:重量" json:"weight"` //重量 |
| | | Weight decimal.Decimal `gorm:"type:decimal(20,3);comment:重量" json:"weight"` //重量 |
| | | Volume decimal.Decimal `gorm:"type:decimal(20,2);comment:体积" json:"volume"` //体积 |
| | | MakeAdvanceTime decimal.Decimal `gorm:"type:decimal(20,2);comment:制造前置时间" json:"makeAdvanceTime"` //制造前置时间(天) |
| | | OrderAdvanceTime decimal.Decimal `gorm:"type:decimal(20,2);comment:订单准备天数" json:"orderAdvanceTime"` //订单准备天数(天) |
| | |
| | | //HSCode string `gorm:"type:varchar(255);comment:HS编码" json:"HSCode"` //HS编码 |
| | | //OriginCountryId int `gorm:"type:int(11);comment:原产地id" json:"originCountryId"` //原产地id |
| | | //OriginCountryName string `gorm:"type:varchar(255);comment:原产地名称" json:"originCountryName"` //原产地名称 |
| | | InStorageExplain string `gorm:"type:varchar(512);comment:入库说明" json:"inStorageExplain"` //入库说明 |
| | | OutStorageExplain string `gorm:"type:varchar(512);comment:出库说明" json:"outStorageExplain"` //出库说明 |
| | | InternalTransferExplain string `gorm:"type:varchar(512);comment:内部调拨说明" json:"internalTransferExplain"` //内部调拨说明 |
| | | AttachmentList []*Attachment `json:"attachmentList" gorm:"many2many:material_attachment"` |
| | | AttachmentIDs []uint `json:"attachmentIDs" gorm:"-"` |
| | | PredictionAmount decimal.Decimal `json:"predictionAmount" gorm:"-"` |
| | | InputAmount decimal.Decimal `json:"inputAmount" gorm:"-"` |
| | | OutputAmount decimal.Decimal `json:"outputAmount" gorm:"-"` |
| | | MinInventoryRule decimal.Decimal `json:"minInventoryRule" gorm:"-"` //最小库存 |
| | | MaxInventoryRule decimal.Decimal `json:"maxInventoryRule" gorm:"-"` //最大库存 |
| | | ReorderRuleNum int64 `json:"reorderRuleNum"` |
| | | InStorageExplain string `gorm:"type:varchar(512);comment:入库说明" json:"inStorageExplain"` //入库说明 |
| | | OutStorageExplain string `gorm:"type:varchar(512);comment:出库说明" json:"outStorageExplain"` //出库说明 |
| | | InternalTransferExplain string `gorm:"type:varchar(512);comment:内部调拨说明" json:"internalTransferExplain"` //内部调拨说明 |
| | | AttachmentList []*Attachment `json:"attachmentList" gorm:"many2many:material_attachment"` |
| | | IsStorage int `gorm:"type:tinyint(1);default:1;comment:是否存库(1是2否)" json:"isStorage"` //无库存的在wms以及srm中需要过滤掉 |
| | | IsVirtual int `json:"isVirtual" gorm:"type:tinyint(1);default:2;comment:是否虚拟物料(1是2否)"` //虚拟物料在MRP计算时跳过该层级直接领用下级物料,虚拟物料不生成工单 |
| | | ReorderRuleNum int64 `json:"reorderRuleNum"` |
| | | |
| | | //以下为不存库的字段 |
| | | AttachmentIDs []uint `json:"attachmentIDs" gorm:"-"` |
| | | PredictionAmount decimal.Decimal `json:"predictionAmount" gorm:"-"` |
| | | InputAmount decimal.Decimal `json:"inputAmount" gorm:"-"` |
| | | OutputAmount decimal.Decimal `json:"outputAmount" gorm:"-"` |
| | | MinInventoryRule decimal.Decimal `json:"minInventoryRule" gorm:"-"` //最小库存 |
| | | MaxInventoryRule decimal.Decimal `json:"maxInventoryRule" gorm:"-"` //最大库存 |
| | | |
| | | } |
| | | |
| | | MaterialSearch struct { |
| | |
| | | } |
| | | |
| | | func NewMaterialSearch() *MaterialSearch { |
| | | return &MaterialSearch{Orm: mysqlx.GetDB()} |
| | | return &MaterialSearch{Orm: mysqlx.GetDB().Where("is_storage = ?", 1)} //只查询有库存的 |
| | | } |
| | | |
| | | func (slf *MaterialSearch) SetOrm(tx *gorm.DB) *MaterialSearch { |
| | |
| | | |
| | | type GetWarehouseList struct { |
| | | PageInfo |
| | | Keyword string `json:"keyword"` |
| | | Keyword string `json:"keyword" form:"keyword"` |
| | | } |
| | | |
| | | type AddWarehouse struct { |
| | |
| | | productAPI.POST("updateDisuse", productController.UpdateDisuse) //修改报废信息 |
| | | productAPI.POST("listHistory", productController.ListHistory) //产品位置历史记录 |
| | | productAPI.PUT("cancelDisuse/:id", productController.CancelDisuse) //取消报废 |
| | | productAPI.GET("getUserInfo", productController.GetUserInfo) //获取登录用户信息 |
| | | |
| | | } |
| | | |