Skip to content

进销存——货位管理

一. 数据库设计

1. 货架层级表shelf

表结构

"id" int ID
"station_id" string 站点ID
"name" string 本级层级名
"level" int  等级
"status" int 状态(层级使用状态,使用中还是已删除)

注:当本级货架为根货架时,parent_id为Null。(child_id同样)

索引

{station_id:1}

2. 货位信息表shelf_location

表结构

"id" int ID
"station_id" string 站点ID
"name" string 货架名
"level" int 货架位级
"status" int 状态
"parent_id" int 上级货位ID

索引

{station_id:1}

--

二. 接口设计

1.新建货架层级 /station/stock/shelf/add

接口名:/station/stock/shelf/add 改

method:POST

请求

name M string 货架层级名

注:name限制为6位数以内的中文字符。

响应

code M int 0为成功,其他为失败
msg M string 错误提示信息 
data M dict 返回货架层级ID  改

响应数据举例

code:0
msg:"ok"
data:{
    'id':1  
     }

逻辑

· 参数校验。
· 检测是否有重名。

2.更改改货架层级的名称/station/stock/shelf/edit

接口名:/station/stock/shelf/edit 改

method:POST

请求

level M int 货架层级ID
new_name M string 货架层级预用名

响应

code M int 0为成功,其他为失败
msg M string 错误提示信息

逻辑

· 校验参数。
· 更改层级名时,验证层级预用名是否和其他层级重名。

3.删除货位层级/station/stock/shelf/delete

接口名:/station/stock/shelf/delete 改

method:POST

请求

level      改

响应

code M int 0为成功,其他为失败
msg M string 错误提示信息

逻辑

· 校验参数。
· 删除层级时,校验level值是否等于可删除的最后一层级。

4.新建货位/station/stock/shelf_location/add

接口名:/station/stock/shelf_location/add 改

method:POST

请求

name M string 货位名
parent_id O int 父货位ID

当此货位为根货位时,无parent_id。

响应

code M int 0为成功,其他为失败
msg M string 错误提示信息 
data M dict 货位ID                改

响应数据举例

code:0
msg:"ok"
data:{
    'id':1  
     }

逻辑

· 校验参数。
· 新建货位名时,验证货位名是否和此层级下其他的货位名重名。

5.更改货位/station/stock/shelf_location/edit

接口名:/station/stock/shelf_location/edit 改

method:POST

请求

id M int 货位ID        改
new_name M string 货位预用名

响应

code M int 0为成功,其他为失败
msg M string 错误提示信息

逻辑

· 校验参数。
· 更改货位名时,验证货位预用名是否和此站点下其他的货位名重名。

6.删除货位/station/stock/shelf_location/delete

接口名:/station/stock/shelf_location/delete 改

method:POST

请求

id M int 货位ID         改

响应

code M int 0为成功,其他为失败
msg M string 错误提示信息

逻辑

· 校验参数。
· 删除货位时,验证货位下是否有子货位。

7.获取货位信息/station/stock/shelf/get

接口名:/station/stock/shelf/get

method:get

请求: 无

响应

code M int 0为成功,其他为失败
msg M string 错误提示信息 
data M list[
    {
    classification M string
    level M int
    shelf M list[
        {
         shelf_id M int
         shelf_name M string
         parent_id M int
         },
        {
         .....
        },
        ],
    }

没有值的字段,值返回NULL。

响应数据举例

    data[{
        "classification":"楼层",
        "level":1,
        "shelf":[
            {
            "shelf_id":1, 
            "name":"1楼",
            "parent_id":Null,
            },
            {
            "shelf_id":2, 
            "name":"2楼",
            "parent_id":Null,
            },
            {
            "shelf_id":3, 
            "name":"3楼",
            "parent_id":Null,
             },
            ]
         },
         {
         "classification":"仓库",
         "level":2,
         "shelf":[
            {
            "shelf_id":4, 
            "name":"1仓",
            "parent_id":1,
            },
            {
            "shelf_id":5, 
            "name":"2仓",
            "parent_id":2,
            },
            {
            "shelf_id":6, 
            "name":"3仓",
            "parent_id":3,
             },
             {
            "shelf_id":7, 
            "name":"3仓",
            "parent_id":3,
             }
             {
            "shelf_id":8, 
            "name":"3仓",
            "parent_id":3,
             },
            ]
         },
         {
          "classification":"通道",
          "level":3,
          "shelf":[
             {
               "shelf_id":9, 
               "name":"1通道",
               "parent_id":8,
             },
           ]
         },
         {
          "classification":"货架",
          "level":4,
          "shelf":Null
         },
        ]