组装单

组装单列表

curl -H "Authorization: Token token=<token>, uid=<uid>" \
  http://example.com/api/packages.json
{
    "status": {
        "code": 200,
        "message": "OK"
    },
    "packages": [
        {
            "id": 232,
            "creator_id": 1,
            "status": "approving",
            "approved_level": 0,
            "number": "ZZ0125",
            "cost": "0.0",
            "note": "",
            "total_cost": "0.901",
            "total_quantity": "1.0",
            "total_base_quantity": "1.0",
            "date": "2019-04-10",
            "created_at": "2019-04-10",
            "updated_at": "2019-04-10",
            "print_count": 0
        }
    ]
}
  • HTTP请求

    GET /api/packages.json

  • 请求参数

参数名 是否必填 默认值 字段说明
page 1 第几页
per 15 每页返回数
keyword 关键词
keyword_type 关键词类型(bills.number: 单据编号/备注)
finished_product_category_id all 成品分类
finished_product_id all 成品产品
part_product_category_id all 零件分类
part_product_id all 零件产品
date 本月 组装日趋
status 审批状态
department_id all 部门
creator_id all 创建人
  • 返回字段说明
返回值字段 字段类型 字段说明
id integer ID
creator_id integer 创建人ID
status string 状态
approved_level integer 审批层级
number string 编号
cost string 组装费用
note string 备注
total_cost string 总成本
total_quantity string 总数量
total_base_quantity string 基本数量合计(开启多单位时候对应的基本单位的数量,未开启时候跟数量一致)
date string 组装日期
created_at string 创建日期
updated_at string 更新日期
print_count integer 打印次数

新增组装单

curl -i -X POST --header "Authorization: Token token=<user_token>, uid=<uid>" \
  http://example.com/api/packages.json
{
  "status": {
    "code": "200",
    "message": "OK"
  },
  "package": {
    "id": 57
  }
}
  • HTTP请求

    POST /api/packages.json

  • 请求参数

参数名 是否必填 默认值 字段说明
status 审批状态(draft[草稿] approving[待审批] submitted[已提交] rejected[已驳回] passed[审批通过] deprecated[已作废])
number 编号
date 组装日期
cost 组装费用
note 备注
total_quantity 总数量
total_base_quantity 基本数量合计(开启多单位时候对应的基本单位的数量,未开启时候跟数量一致)
total_cost 总成本
fifo_total_cost 先入先出成本合计
approved_level 审批层级
allow_negative_inventory 允许负库存
attachments_attributes[0][dn_key] 七牛存储的key
attachments_attributes[0][key] 同上
attachments_attributes[0][filename] 文件名
attachments_attributes[0][url] 文件URL
attachments_attributes[0][size] 文件大小
finished_item_attributes[product_attr_group_id] 产品属性组ID
finished_item_attributes[product_unit_id] 产品单位ID
finished_item_attributes[product_id] 产品ID
finished_item_attributes[warehouse_id] 仓库ID
finished_item_attributes[warehouse_name] 仓库名称
finished_item_attributes[name] 产品项名称
finished_item_attributes[number] 产品项编号
finished_item_attributes[attr] 产品项属性名称
finished_item_attributes[spec] 产品项规格
finished_item_attributes[unit_name] 单位名称
finished_item_attributes[quantity] 产品项数量
finished_item_attributes[base_unit] 基本单位
finished_item_attributes[base_quantity] 基本数量(开启多单位时候基本数量等于基本单位与当前单位的换算率 * 当前数量;未开启多单位时候和当前数量一致)
finished_item_attributes[deputy_unit_quantity] 副单位数(需要开启多单位)
finished_item_attributes[unit_cost] 单位成本
finished_item_attributes[cost] 成本
finished_item_attributes[fifo_unit_cost] 先入先出单位成本
finished_item_attributes[fifo_cost] 先入先出成本
finished_item_attributes[batch_id] 批次号ID
finished_item_attributes[batch_number] 批次号
finished_item_attributes[produced_at] 生产日期
finished_item_attributes[expired_at] 有效日期
finished_item_attributes[note] 产品项备注
finished_item_attributes[conversion] 零件与成品的换算关系
finished_item_attributes[modified] 最后修改字段
finished_item_attributes[_destroy] false 产品项是否删除
part_item_attributes[0][product_attr_group_id] 产品属性组ID
part_item_attributes[0][product_unit_id] 产品单位ID
part_item_attributes[0][product_id] 产品ID
part_item_attributes[0][warehouse_id] 仓库ID
part_item_attributes[0][warehouse_name] 仓库名称
part_item_attributes[0][name] 产品项名称
part_item_attributes[0][number] 产品项编号
part_item_attributes[0][attr] 产品项属性名称
part_item_attributes[0][spec] 产品项规格
part_item_attributes[0][unit_name] 单位名称
part_item_attributes[0][quantity] 产品项数量
part_item_attributes[0][base_unit] 基本单位
part_item_attributes[0][base_quantity] 基本数量(开启多单位时候基本数量等于基本单位与当前单位的换算率 * 当前数量;未开启多单位时候和当前数量一致)
part_item_attributes[0][deputy_unit_quantity] 副单位数(需要开启多单位)
part_item_attributes[0][unit_cost] 单位成本
part_item_attributes[0][cost] 成本
part_item_attributes[0][fifo_unit_cost] 先入先出单位成本
part_item_attributes[0][fifo_cost] 先入先出成本
part_item_attributes[0][batch_id] 批次号ID
part_item_attributes[0][batch_number] 批次号
part_item_attributes[0][produced_at] 生产日期
part_item_attributes[0][expired_at] 有效日期
part_item_attributes[0][note] 产品项备注
part_item_attributes[0][conversion] 零件与成品的换算关系
part_item_attributes[0][modified] 最后修改字段
part_item_attributes[0][_destroy] false 产品项是否删除
  • 返回字段说明
返回值字段 字段类型 字段说明
id string ID

组装单详情

curl -H "Authorization: Token token=<token>, uid=<uid>" \
  http://example.com/api/packages/:id.json
{
    "status": {
        "code": 200,
        "message": "OK"
    },
    "packages": {
        "id": 234,
        "status": "submitted",
        "number": "BOM0039",
        "note": "",
        "created_at": "2019-04-10",
        "print_count": 0,
        "finished_item": {
            "id": 571,
            "product_id": 401,
            "product_attr_group_id": 719,
            "warehouse_id": 25,
            "product_unit_id": 684,
            "category": "finished",
            "name": "CP0224",
            "number": "CP0224",
            "attr": "",
            "spec": "",
            "warehouse_name": "名字很长很长很长的仓库",
            "unit_name": "车",
            "quantity": "1.0",
            "base_unit": "台",
            "base_quantity": "200.0",
            "deputy_unit_quantity": "1车",
            "note": "",
            "conversion": "1.0"
        },
        "part_items": [
            {
                "id": 572,
                "product_id": 399,
                "product_attr_group_id": 717,
                "warehouse_id": 24,
                "product_unit_id": 678,
                "category": "part",
                "name": "CP0221",
                "number": "CP0221",
                "attr": "",
                "spec": "",
                "warehouse_name": "测试仓库11",
                "unit_name": "台",
                "quantity": "2.1",
                "base_unit": "台",
                "base_quantity": "2.1",
                "deputy_unit_quantity": "2.1台",
                "note": "",
                "conversion": "2.1"
            }
        ]
    }
}
  • HTTP请求

    GET /api/packages/:id.json

  • 请求参数

  • 返回字段说明

返回值字段 字段类型 字段说明
id integer ID
status string 状态
number string 编号
note string 备注
created_at string 创建日期
print_count integer 打印次数
finished_item[id] integer 成品ID
finished_item[product_id] integer 产品ID
finished_item[product_attr_group_id] integer 产品属性组ID
finished_item[product_unit_id] integer 产品单位ID
finished_item[warehouse_id] integer 仓库ID
finished_item[category] string 类别(finished)
finished_item[name] string 产品名称
finished_item[number] string 产品编号
finished_item[attr] string 产品属性名称
finished_item[spec] string 产品规格
finished_item[warehouse_name] string 仓库名称
finished_item[unit_name] string 单位名称
finished_item[quantity] string 数量
finished_item[base_unit] string 基本单位名称
finished_item[base_quantity] string 基本数量(开启多单位时候基本数量等于基本单位与当前单位的换算率 * 当前数量;未开启多单位时候和当前数量一致)
finished_item[deputy_unit_quantity] string 副单位数(需要开启多单位)
finished_item[note] string 备注
finished_item[conversion] string 换算关系
part_items[0][id] integer 零件ID
part_items[0][product_id] integer 产品ID
part_items[0][product_attr_group_id] integer 产品属性组ID
part_items[0][product_unit_id] integer 产品单位ID
part_items[0][warehouse_id] integer 仓库ID
part_items[0][category] string 类别(part)
part_items[0][name] string 产品名称
part_items[0][number] string 产品编号
part_items[0][attr] string 产品属性名称
part_items[0][spec] string 产品规格
part_items[0][warehouse_name] string 仓库名称
part_items[0][unit_name] string 单位名称
part_items[0][quantity] string 数量
part_items[0][base_unit] string 基本单位名称
part_items[0][base_quantity] string 基本数量(开启多单位时候基本数量等于基本单位与当前单位的换算率 * 当前数量;未开启多单位时候和当前数量一致)
part_items[0][deputy_unit_quantity] string 副单位数(需要开启多单位)
part_items[0][note] string 备注
part_items[0][conversion] string 换算关系
attachments[0][id] integer 附件ID
attachments[0][filename] string 附件文件名
attachments[0][url] string 附件URL

编辑组装单

curl -i -X PUT --header "Authorization: Token token=<user_token>, uid=<uid>" \
  http://example.com/api/packages/:id.json
{
  "status": {
    "code": "200",
    "message": "OK"
  },
  "package": {
    "id": 57
  }
}
  • HTTP请求

    PUT /api/packages/:id.json

  • 请求参数

参数名 是否必填 默认值 字段说明
status 审批状态(draft[草稿] approving[待审批] submitted[已提交] rejected[已驳回] passed[审批通过] deprecated[已作废])
number 编号
note 备注
total_quantity 联系人ID
total_base_quantity 联系人ID
attachments_attributes[0][id] 附件ID
attachments_attributes[0][dn_key] 七牛存储的key
attachments_attributes[0][key] 同上
attachments_attributes[0][filename] 文件名
attachments_attributes[0][url] 文件URL
attachments_attributes[0][size] 文件大小
finished_item_attributes[id] 成品ID
finished_item_attributes[product_attr_group_id] 产品属性组ID
finished_item_attributes[product_unit_id] 产品单位ID
finished_item_attributes[product_id] 产品ID
finished_item_attributes[warehouse_id] 仓库ID
finished_item_attributes[warehouse_name] 仓库名称
finished_item_attributes[name] 产品项名称
finished_item_attributes[number] 产品项编号
finished_item_attributes[attr] 产品项属性名称
finished_item_attributes[spec] 产品项规格
finished_item_attributes[unit_name] 单位名称
finished_item_attributes[quantity] 产品项数量
finished_item_attributes[base_unit] 基本单位
finished_item_attributes[base_quantity] 基本数量(开启多单位时候基本数量等于基本单位与当前单位的换算率 * 当前数量;未开启多单位时候和当前数量一致)
finished_item_attributes[deputy_unit_quantity] 副单位数(需要开启多单位)
finished_item_attributes[note] 产品项备注
finished_item_attributes[conversion] 零件与成品的换算关系
finished_item_attributes[modified] 最后修改字段
finished_item_attributes[_destroy] false 产品项是否删除
part_item_attributes[0][id] 零件ID
part_item_attributes[0][product_attr_group_id] 产品属性组ID
part_item_attributes[0][product_unit_id] 产品单位ID
part_item_attributes[0][product_id] 产品ID
part_item_attributes[0][warehouse_id] 仓库ID
part_item_attributes[0][warehouse_name] 仓库名称
part_item_attributes[0][name] 产品项名称
part_item_attributes[0][number] 产品项编号
part_item_attributes[0][attr] 产品项属性名称
part_item_attributes[0][spec] 产品项规格
part_item_attributes[0][unit_name] 单位名称
part_item_attributes[0][quantity] 产品项数量
part_item_attributes[0][base_unit] 基本单位
part_item_attributes[0][base_quantity] 基本数量(开启多单位时候基本数量等于基本单位与当前单位的换算率 * 当前数量;未开启多单位时候和当前数量一致)
part_item_attributes[0][deputy_unit_quantity] 副单位数(需要开启多单位)
part_item_attributes[0][note] 产品项备注
part_item_attributes[0][conversion] 零件与成品的换算关系
part_item_attributes[0][modified] 最后修改字段
part_item_attributes[0][_destroy] false 产品项是否删除
  • 返回字段说明
返回值字段 字段类型 字段说明
id string ID
文档更新时间: 2025-03-17 14:52   作者:姜河