Business Process Description

This plan is mainly used for external ERP systems such as Kingdee, UFIDA, SAP, etc. to connect with Kunton; Kunton Small Warehouse can be integrated with MES, WMS, and ERP, using material requisition as outbound and replenishment as inbound. Customers can pull transaction data and summarize it in their own data center, allowing data from various systems to be collected in the center, achieving unified data management。

Document Description

(1) Interface Description

  1. Unless otherwise specified, the Content Type of all interfaces is application/JSON; Charset=UTF-8
  2. Unless otherwise specified, all data change types (add, modify, delete, synchronize) are batch operations, which means that the parameters of the interface are all list types, and the length of a single call to the list should not exceed 100 items. Please refer to the examples of each interface for details. During batch processing, if a processing failure is encountered, the processing will stop and a failure status code will be returned. If the data has been successfully processed, it will not be rolled back
  3. Unless otherwise specified, the field units for parameters in all interfaces are in characters
  4. Unless otherwise specified, the synchronization interface can be used for adding or modifying, and it is a stateless interface with no logical relationship to the previous call. When calling the interface, if it does not exist, a new data item will be created. If it exists, the data item will be updated with interface parameters
  5. Unless otherwise specified, all interface response content is returned in the following data structure with an HTTP status code of 200
{
  "code": xxx,
  "msg": xxx,
  "data": xxx
}

parameter description

name type required option description
code Integer Yes 200:Indicates success;500:unknown error;for other status values, please refer to the error status code table in the appendix
msg String No there is a corresponding value in the non 200 state, which is used to explain the reason for the failure
data Object/Array No The interface returns the actual content and participates in the specific interface response content

(2) Authentication Statement

When a user accesses the Kunton Open Platform, the platform administrator will provide the corresponding appKey, secretKey, abbreviated as ak or sk. The user generates the corresponding signature information in a specified way using the key, and carries the corresponding signature information for identity authentication when accessing the platform interface. This key is very important, please keep it properly to avoid data security issues caused by key leakage。

Signature generation steps

  1. Obtain the current system timestamp (in milliseconds), ensuring that the timestamp is within 10 minutes of the platform time
  2. Using sk as the key of the HmacSHA256 algorithm, perform summary calculation on the content obtained from step 1
  3. Output the content calculated by step 2 in base64 format
  4. Splice the content calculated by ak and step 3 with English colons, i.e. symbols, as a signature

Signature usage method

  1. Use the content obtained from step 1 as the value of the HTTP request header parameter X-Kt-Time
  2. Use the content obtained from step 4 as the value of the HTTP request header parameter X-Kt-Authorization
  3. When accessing the Kuntong Open Platform interface, attach step 1 and step 2 contents for access

Example of signature generation demo(Java)

public static void main(String[] args) throws Exception {
  String ak = "your_ak";
  String sk = "your_sk";

  Charset utf8 = StandardCharsets.UTF_8;

  String currentTimeStr = 
    String.valueOf(System.currentTimeMillis());
  Mac mac = Mac.getInstance("HmacSHA256");
  SecretKeySpec secretKeySpec = 
     new SecretKeySpec(sk.getBytes(utf8), "HmacSHA256");
  mac.init(secretKeySpec);

  byte[] digest = mac.doFinal(currentTimeStr.getBytes(utf8));

  String sign = Base64.getEncoder().encodeToString(digest);

  System.out.println("currentTime: " + currentTimeStr);
  System.out.println(String.join(":", ak, sign));
}

Example of signature generation demo(Python)

import time
import hashlib
import base64
import hmac

ak = "your_ak"
sk = "your_sk"

currentTimeStr = str(int(time.time() * 1000))

digest = hmac.new(
    bytes(sk, "UTF-8"), 
    bytes(currentTimeStr, "UTF-8"), 
    hashlib.sha256
  )

sign = base64.b64encode(digest.digest()).decode()

print("currentTime:", currentTimeStr)
print("sign", ak + ":" + sign)

Example of signature generation demo(C#)

using System;
using System.Security.Cryptography;
using System.Text;
namespace HelloWorldApplication
{
   class HelloWorld
   {
      static void Main(string[] args)
      {
        string ak = "your_ak";
        string sk = "your_sk";

        Encoding utf8 = Encoding.UTF8;

        string currentTimeStr = DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds.ToString("F0");
        HMACSHA256 mac = new HMACSHA256(Encoding.UTF8.GetBytes(sk));
        byte[] digest = mac.ComputeHash(Encoding.UTF8.GetBytes(currentTimeStr));

        string sign = Convert.ToBase64String(digest);

        Console.WriteLine("currentTime: " + currentTimeStr);
        Console.WriteLine(ak + ":" + sign);
      }
   }
}

Example of calling interface - Taking the synchronization department interface as an example(Python)

import requests
import time
import hashlib
import base64
import hmac

ak = "ak"
sk = "sk"

currentTimeStr = str(int(time.time() * 1000))

digest = hmac.new(
    bytes(sk, "UTF-8"),
    bytes(currentTimeStr, "UTF-8"),
    hashlib.sha256
)

sign = base64.b64encode(digest.digest()).decode()

print("currentTime:", currentTimeStr)
print("sign", ak + ":" + sign)

# Synchronization department
response = requests.post("https://openapi.szkunton.com/department/v1/syncDepartment",
                         json=[{"deptCode": "OpenCode123", "deptName": "OpenName123"}],
                         headers={
                             "X-Kt-Time": currentTimeStr,
                             "X-Kt-Authorization": ak + ":" + sign,
                             'Accept-Language': 'zh-CN'
                         })
print(response.text)

(3) Environmental Description

Env name website remark
fat https://openapi.global.szkunton.com/ Test environment usage
pro https://openapi.kuntonglobal.com ASEAN Pro environment usage
pro https://openapi-us.kuntonglobal.com US Pro environment usage

One、 Department Management

(1) Synchronize department

URL:/department/v1/syncDepartment

method:POST

parameter:

name type required option max length describe
deptCode String Yes 36 department number,the department number can only be English letters, numbers, and the length cannot exceed 36
deptName String Yes 64 department name
parentCode String No 36 parent department number

Note: The interface supports hierarchical synchronization of departments, but it is necessary to ensure that the current department’s superior department already exists, as shown in the example

response parameter:
Note:(Exists when code>=50XXX)

name type describe
errorIdx Integer Index corresponding to failed records

interface demo:

request

[
  {
    "deptCode": "Openy",
    "deptName": "Open-y"
  },
  {
    "deptCode": "Openy1",
    "deptName": "Open-y-1",
    "parentCode": "Openy"
  },
  {
    "deptCode": "Openy11",
    "deptName": "Openy11",
    "parentCode": "Openy1"
  }
]

response parameter:
Note:(Exists when code>=50XXX)

{
  "errorIdx": 1
}

(2) Delete department

URL:/department/v1/deleteDepartment

method:POST

parameter:

name type required option length describe
deptCode String Yes 36 department code

Note:The interface supports hierarchical deletion, but it is necessary to ensure that the corresponding sub departments of the current department have been deleted, as shown in the example

response parameter:
Note:(Exists when code>=50XXX)

name type describe
errorIdx Integer Index corresponding to failed records

Note:(Exists when code>=50XXX)

interface demo:

request

[
  "Openy11", "Openy1", "Openy"
]

response:

{
  "errorIdx": 1
}

Two、 Emploee management

(1) Synchronize emploee

URL:/user/v1/syncUser/

method:POST

parameter:

name type required option max length describe
userCode String Yes 32 Employee ID, employee ID can only be English letters, numbers, and a dash, and the length cannot exceed 32
userName String Yes 64 emploee name
deptCode String Yes 36 Department number, department number can only be English letters, numbers, and length cannot exceed 36
cardCode String No 32 card number,the card number can only be composed of English letters, numbers, and a dash, and the length cannot exceed 32
cardUniqueCode String No 32 Card serial number, the card serial number can only be English letters, numbers, and a dash, and the length cannot exceed 32
telephone String No 16 phone
email String No 64 email
remark String No 255 remark
lockStatus Integer Yes status,0:enable,1:disable
englishName String No 64 english name

Note:The card number and card serial number can either be filled in simultaneously or not filled in simultaneously

response parameter:
Note:(Exists when code>=50XXX)

name type describe
errorIdx Integer Index corresponding to failed records

interface demo:

Request

[
  {
    "userCode": "test",
    "userName": "testaaa",
    "deptCode": "A100",
    "cardCode": "cardCode100",
    "cardUniqueCode": "cardUniqueCode100",
    "telephone": "15811111111",
    "email": "test@szkunton.com",
    "remark": "testbbb",
    "lockStatus": 0,
    "englishName": "test"
  }
]

Response

{
  "errorIdx": 0
}

(2) Delete emploee

URL:/user/v1/deleteUser

method:POST

request parameter:

name type required option length describe
userCode String Yes 32 emploee number

interface demo:

Request

[
  "test", "test100"
]

(3) Synchronize emploee photos

URL:/user/v1/syncUserImg

method:POST

Content-Type:multipart/form-data

request parameter:

name type required option length describe
userCode String Yes 32 emploee number
image file Yes emploee photo,Only supports PNG and JPG format photos, with a size not exceeding 2MB

(4) Generate employee QR code

URL:/user/v1/createQrCode

method:Get

request parameter:

name type required option length describe
userCode String Yes 32 emploee number
type Integer No default value 0,qrcode type

Note:The validity period of the QR code is 1 minute, and it needs to be regenerated before operation can be performed. Please note that the interface returns a serialized field string, as shown below:{\"type\":0,\"data\":\"KBALZ1ZfcAoGQUFAQAoMCipWT3xDVjVeDXdfB0FPQUFFXlhzUkh9QlptV1h2WQ==\"},When actually generating a QR code, it is necessary to replace the escape character, that is, the final generated QR code content is:{"type":0,"data":"KBALZ1ZfcAoGQUFAQAoMCipWT3xDVjVeDXdfB0FPQUFFXlhzUkh9QlptV1h2WQ=="}

(5) Employee Bind Machine

URL:/user/v1/userBindMachine

method:Post

request parameter:

name type required option length describe
userCode String Yes 32 emploee number
deviceCodeList List Yes device code list
{
  "userCode": "GUEST1a9b9c",
  "deviceCodeList": ["WC0016"]
}

Three、 Product manager

(1) Synchronize product

URL:/sku/v1/syncSku

method:POST

request parameter:

name type required option length describe
skuNo String Yes 32 Product number, consisting of digits, letters, dashes, slashes, commas, dots, and plus signs
skuName String Yes 255 product name
price Double No Unit price of goods (unit: yuan)
description String No 255 product describe
manufacture String No 64 Manufacturer
brand String No 128 brand
pack String No 255 package
unit String No Unit name (enumeration value, see Appendix Unit enumeration table)
weight Double No Item weight (unit: g)
onSale Integer Yes 1:enable,0:disable

interface demo:

Request

[
  {
    "skuNo": "Test123",
    "skuName": "Test product name",
    "price": 1.23,
    "description": "This is a test product",
    "manufacture": "manufacturer",
    "brand": "brand",
    "pack": "100 PCS/box",
    "unit": "PCS",
    "weight": 0.1,
    "onSale": 1
  }
]

(2) Get product on the shelves

URL:/sku/v1/listOnShelfSkus

method:GET

Request parameter:

name type required option describe
showMinComboPlanNum Boolean No Indicates whether to obtain the capacity of the goods in the shipping lane, default: No
skuNo String No Accurately query a certain product (product number)
nodeSkuNo String No Accurately query a certain product (node product number)

Response content:

name type describe
skuNo String product number
skuName String product name
skuOrigin Integer Product sources: 1: Supply chain, 3: Customer built
nodeSkuNo String node product number
nodeSkuName String node product name
description String product describe
unit String product unit
skuTaxPrice Double product tax price
skuNoTaxPrice Double product no tax price
minComboPlanNum Integer The capacity of the products in the shipping lane. When the products are in multiple shipping lanes and the capacity of multiple shipping lanes is inconsistent, the return value is 1. Please do not place an order
channelDetails Array channel details
deviceCode String device number
channelLabelCodes Array channel label number

interface demo:

Request

GET /sku/v1/listOnSaleSkus?showMinComboPlanNum=true&skuNo=AA0048111

Response

[
  {
    "skuNo":"AA0048111",
    "skuName":"A35994",
    "skuOrigin":1,
    "nodeSkuNo":"AA0048111gcbh",
    "nodeSkuName":"AA0048111 node product name",
    "unit": "个",
    "description":"This is product describe",
    "minComboPlanNum":1
    "channelDetails": [
        {
            "deviceCode": "SC0011",
            "channelLabelCodes": [9]
        }
    ]
  }
]

Four、 Transaction Management

(1)Equipment material requisition

(2)Equipment replenishment

(3)Equipment recycling materials

(4)Equipment return materials

In the currently provided transaction management interface, the query parameters are consistent with the response content fields, only the interface is different. Different types of transaction query interfaces are shown in the table below

Transaction data type URL method
Equipment material requisition transaction data /trade/v1/listVmSaleLog POST
Equipment replenishment transaction data /trade/v1/listVmReplenishLog POST
Equipment recycling material transaction data /trade/v1/listVmEscheatLog POST
Equipment return materials transaction data /trade/v1/listVmRetreatLog POST

Request parameter:

Parameter name Type Required Description
page Long Yes page number
size Long Yes page size,Not exceeding200
startTime DateTime Yes Transaction start time,zone time:CMT+8,format:yyyy-MM-dd HH:mm:ss
endTime DateTime Yes Transaction end time,zone time:CMT+8,format:yyyy-MM-dd HH:mm:ss
deviceCode String No device number
skuNo String No product number
convertCustomSkuInfo boolean No Customer product information conversion(default false)

Note:The time span for a single query cannot exceed one year

Response content:

name type describe
page Long page number
size Long page size
total Long total records
totalPage Long total pages
rows Array
tradeNumber String
tradeItemNumber String
tradeTime DateTime zone time:CMT+8,format:yyyy-MM-dd HH:mm:ss
deviceCode String device number
auxiliaryDeviceCode String auxiliary device code,If this field is empty, it indicates that the current transaction is generated by the host
channelCode String channel number
channelLabelCode String Map the freight lane number (logical freight lane number, the freight lane number pasted on the device label), starting from the last freight lane number of the host. If the last freight lane number of the host is 36, then the first freight lane number of the first auxiliary machine is 37
userNo String emploee number
userName String emploee name
deptNo String emploee department number
deptName String emploee department name
projectCode String project number
projectName String project name
costCode String cost code
costName String cost name
skuNo String product number
skuName String product name
nodeSkuNo String node product number
nodeSkuName String node product name
vendorCode String vendor number
vendorName String vendor name
skuTaxPrice Double product tax price(unit price)
skuNoTaxPrice Double product no tax price(unit price)
tradeNum Long trade number
tradeTaxPrice Double trade tax price(Total price including tax)
tradeNoTaxPrice Double trade no tax price(Total price before tax)
skuUnit String product unit name
skuPack String product package
saleType Integer channel sales type 0: Supplier product 1: Customer owned product
remark String
customTradeNum Long Number of customer product transactions
customSkuUnit String Customer Product Unit(Calculate when convertCustomimSkuInfo is true)

interface demo:

Request

{
  "page": 1,
  "size": 20,
  "startTime": "2022-04-10 00:00:00",
  "endTime": "2022-04-20 00:00:00",
  "deviceCode": "Test",
  "skuNo": "test"
}

Response

{
  "page": {
    "page": 1,
    "size": 20,
    "total": 100,
    "totalPage": 5
  },
  "rows": [
    {
        "tradeNumber": "TS2204291055183360523262464",
        "tradeItemNumber":"TS2204291055183360523262464001",
        "tradeTime": "2022-04-15 12:21:21",
        "deviceCode": "3344444",
        "auxiliaryDeviceCode": "XDZ017",
        "channelCode": "12",
        "channelLabelCode": "30",
        "userNo": "Test",
        "userName": "san zhang",
        "deptNo": "TestDept",
        "deptName": "Production Department",
        "projectCode": "099",
        "projectName": "R&D",
        "costCode": "3333",
        "costName": "R&D",
        "skuNo": "sku0002",
        "skuName": "Labor protection gloves a",
        "skuTaxPrice":"26" ,
        "skuNoTaxPrice": "23.01",
        "tradeNum": "1",
        "tradeTaxPrice": "26",
        "tradeNoTaxPrice":"23.01",
        "skuUnit": "piece",
        "skuPack": "12 pieces/box",
        "saleType": 1,
        "remark": "dddd"
    }
  ]
}

Five、 Inventory management

(1) Query device product inventory

URL:/stock/v1/listVmStock

method:POST

request parameter:

name type required option describe
page Long Yes page number
size Long Yes page size,Not exceeding 200
skuNo String Yes product number
deviceCode String No device number

response content:

name type describe
page Long page number
size Long page size
total Long total records
totalPage Long total pages
rows Array
deviceCode String device number
skuNo String product number
skuName String product name
customerSkuNo String node product number
customerSkuName String node product name
stockQuantity Long Inventory count (all on shelf inventory)
stockDetail Array
channelLabelCode String channel number
stockQuantity Long stock

interface demo:

Request

{
  "page": 1,
  "size": 20,
  "deviceCode": "Test",
  "skuNo": "Test"
}

Response

{

  "page": {
     "page": 1,
    "size": 20,
    "total": 100,
    "totalPage": 5
  },
  "rows": [
    {
       "deviceCode": "Test",
       "skuNo": "Test",
       "skuName": "Test product",
       "stockQuantity": 100
       "stockDetail": [
           {
             "channelLabelCode": 48,
             "stockQuantity": 2
           },
            {
             "channelLabelCode": 49,
             "stockQuantity": 1
           }
        ]
     }
  ]
}

Interface processing logic description

Request parameter description:
If both deviceCode and skuNo are empty, query the comprehensive equipment inventory information under the customer’s order

  1. If deviceCode is not empty and skuNo is empty, query the inventory information of all products on the specified device
  2. If deviceCode is not empty and skuNo is not empty, query the inventory information of the specified product on the specified device

Response content description:

  1. If the customer has not bound the device or product, then rows is empty

appendix:

(1) Error status code

Error status code Status Code Description Remarks
10101 signature has expired If the signature time differs from the platform by more than 10 minutes, please generate a new signature with HTTP status code 401
10102 Signature error HTTP status code 401
10201 No module access permission No corresponding module access permission, contact the administrator to add,HTTP status code 401
10202 No data access permission No corresponding customer data access permission, contact the administrator to add,HTTP status code 401
10301 The application has been deactivated HTTP status code 401
10401 Call frequency too fast, triggering limit No more than 100 calls per minute for a single application or IP,HTTP status code 403
10501 Request parameter error Request parameter error ,HTTP status code 400
50101 The superior department does not exist
50102 Employee department does not exist
50103 the same as the superior department
50104 Sub department is not empty, current department cannot be deleted
50105 Department employee is not empty, cannot delete current department
50201 Card number already in use
50202 Card serial number used
50203 Employee facial feature information extraction failed
50204 Employee does not exist
50205 The QR code type is not supported
60101 The work order number already exists
60102 The material requisition employee does not exist
60103 The product does not exist
60104 Repeated product orders
70101 Request parameter key information incomplete
70102 Invalid request parameters
70103 The current customer’s warehouse is not available
70104 Material information does not exist
70105 The current applicant’s information is incorrect

(2) Unit enumeration list

Unit Name
handful of
pair
a pair of
a pair
one
a piece of
a tin of
a box of
rack
A piece of
board
festival
volume
star
block
grains
car
plate
film
package
bottle
double
station
set
A lift of
article
bucket
tube
box
packing
A bunch of
A sheet of
branch
a
group
bundle
a thousand
a hundred
a film
a copy of
once
A dozen
bag
top
feet
gram
kg
litre
meter
square meters
cubic meter
kg
ton

(3) Platform auxiliary interface

The platform provides the following interfaces to assist users in debugging interfaces during the development phase

interface meaning method
/debug/systemTime Obtain the current timestamp of the platform (in milliseconds) without carrying signature information GET
/debug/checkSign Verify if the signature calculation is correct, and refer to the authentication instructions for the signature method GET
文档更新时间: 2024-06-24 08:37   作者:周建勇