WMS_MAIN/AI_METHOD_ROUTING.md
liufumingren 77435aeb79 1
2026-06-23 18:48:33 +08:00

12 KiB
Raw Blame History

AI 方法路由速查(WMS)

本文用于让 AI/开发者快速理解入口路由与 method 到代码文件的映射关系。

1. 入口定义(router 风格)

当前路由定义见 app/router.js:

  • POST /qimen -> 奇门开发接口入口
  • POST /system -> Web 端与 PDA 端统一业务入口

注意:当前代码中 /qimen 与 /system 都是 POST 路由。

2. /system 入口说明(统一 Web + PDA)

调用链:

  1. app/router.js -> controller.home.system
  2. app/controller/home.js 的 system() 读取 ctx.query.method
  3. app/service/system.js 的 callMethod(className, actionName, requestData, authHeader)
  4. 从 ctx.service.systemMethods 中按 method 分段下钻并执行目标函数

参数规则(system):

  • 必填 query: method, v, timestamp
  • 认证头:可传 Authorization
  • 请求体:JSON(system() 中按 JSON 解析)

外部请求示例:

POST http://127.0.0.1:6060/system?method=print.getComputerPrinter&v=1.0&timestamp=1773386721

示例 body(按业务方法需要):

{
  "id": 10001
}

3. /qimen 入口说明(奇门开发接口)

调用链:

  1. app/router.js -> controller.home.qimen
  2. app/controller/home.js 的 qimen() 读取 ctx.query.method
  3. app/service/qimen.js 的 callMethod(className, actionName, xmlData, ...)
  4. 从 ctx.service.qimenMethods 中按 method 分段下钻并执行目标函数

参数规则(qimen):

  • 必填 query: app_key, method, v, format, sign_method, sign, timestamp
  • 请求体:XML(qimen() 中按 XML 解析)

4. method 指向规则(核心)

统一规则:

  • method 最后一段是函数名(actionName)
  • 前面部分是 service 路径(className)
  • service 路径按 . 拆分后,对应到 app/service/systemMethods 或 app/service/qimenMethods 的目录层级

4.1 /system 示例

  1. method=print.getComputerPrinter
  • service 路径:print
  • 函数名:getComputerPrinter
  • 对应文件:app/service/systemMethods/print.js
  • 对应方法:getComputerPrinter(data)
  1. method=setting.printTemplate.list
  • service 路径:setting.printTemplate
  • 函数名:list
  • 对应文件:app/service/systemMethods/setting/printTemplate.js
  • 对应方法:list(data)
  1. method=printer.station.list
  • service 路径:printer.station
  • 函数名:list
  • 对应文件:app/service/systemMethods/printer/station.js
  • 对应方法:list()

4.2 /qimen 示例

  1. method=deliveryorder.xxx
  • service 路径:deliveryorder
  • 对应文件:app/service/qimenMethods/deliveryorder.js
  1. method=taobao.qimen.service.xxx
  • service 路径:taobao.qimen.service
  • 对应文件:app/service/qimenMethods/taobao/qimen/service.js

5. AI 快速定位建议

当收到 method=aaa.bbb.ccc 时,优先按以下步骤定位:

  1. 判定入口:/system 还是 /qimen
  2. 取最后一段 ccc 作为函数名
  3. 其余部分 aaa.bbb 作为 service 路径
  4. 在对应 methods 目录查找文件并确认类方法是否存在

可用检索命令示例:

rg "getComputerPrinter|class PrintService" app/service/systemMethods
rg "class .*Service|module.exports" app/service/qimenMethods

后续所有的method新增变更全部需要维护到下方

method结束

6. 全量 Service Method 能力清单(自动扫描)

维护说明:

  • 扫描范围:app/service/**/*.js
  • 本节内容由脚本生成,新增/修改 service 后请同步刷新。
  • 刷新命令:node .\script\tmp-gen-service-method-inventory.cjs
  • 临时清单输出:temp/tmp-service-method-inventory.md

自动生成时间: 2026-03-22T15:27:37.958Z

扫描范围: app/service/**/*.js 文件数: 50

  • app/service/api.js (1)
    • callMethod
  • app/service/apiMethods/test.js (4)
    • entryorderConfirm, playbackRequest, fibonacci, fibonacciRecursive
  • app/service/dispatcher.js (3)
    • buildMap, getMethodMap, invoke
  • app/service/main.js (11)
    • success, fail, normalizeDate, setInfo, getInfo, findQimenAppWithContract, queryFromDatabase, checkAuth, checkApiPermission, setUserContext, systemInit
  • app/service/pda.js (3)
    • callMethod, validateParams, saveLog
  • app/service/qimen.js (12)
    • validateApi, getErpName, parseXmlToArray, cleanXmlString, callMethod, formatResponse, xmlResponse, buildXmlNode, escapeXml, saveQimenLog, saveQimenLogResult, saveQimenLogBody
  • app/service/qimenMethods/deliveryorder.js (3)
    • query, create, batchcreate
  • app/service/qimenMethods/entryorder.js (2)
    • create, query
  • app/service/qimenMethods/inventory.js (1)
    • query
  • app/service/qimenMethods/order.js (2)
    • cancel, pending
  • app/service/qimenMethods/returnorder.js (2)
    • create, query
  • app/service/qimenMethods/singleitem.js (2)
    • synchronize, query
  • app/service/qimenMethods/stockout.js (2)
    • create, query
  • app/service/qimenMethods/taobao/qimen/service.js (1)
    • heartbeat
  • app/service/system.js (4)
    • callMethod, validateParams, validateRequestContext, saveLog
  • app/service/systemMethods/config.js (1)
    • list
  • app/service/systemMethods/dashboard.js (6)
    • storeStats, warehouseStats, hot_order_rank, express_ratio, platform_distribution, order_trend
  • app/service/systemMethods/index.js (13)
    • fastWhereTree, loadStores, getCOSUploadConfig, getImages, uploadSuccessNotify, ReferenceFile, getMessageDetail, getI18nMessage, putI18nCollect, extractModule, tryAutoTranslateNewKeys, searchSpace, getExpressList
  • app/service/systemMethods/order.js (11)
    • getWarehouseId, getOrderModels, applyDateRange, buildWhere, parseDateTime, list, detail, listItems, stats, updateStatus, updateDeliveryTime
  • app/service/systemMethods/print.js (3)
    • send, sendToComputer, log
  • app/service/systemMethods/printer/station.js (1)
    • list
  • app/service/systemMethods/setting/printTemplate.js (3)
    • list, save, listTemplatesByType
  • app/service/systemMethods/stock.js (21)
    • stockWarehouse, getProhibitedType, getInfo, saveWarehouseStock, createWarehouseStock, getBarcodes, saveWarehouseStockBarcode, getStoreStocks, bindItem, unbindItem, checkItemCodeUnique, queryStockLogs, handleBatchDelete, deleteUnit, deleteProhibited, handleBatchChange, getStockUnits, getUnitList, createProhibited, createUnit, search
  • app/service/systemMethods/storage/receiving.js (13)
    • getReceivingList, getReceivingDetail, batchCancelReceiving, create, addItem, removeItem, saveReceiving, get, addDetail, deleteDetail, detailChange, cancel, completeReceiving
  • app/service/systemMethods/storage/direct_inbound.js (4)
    • getItems, addItem, commit, removeItem
  • app/service/systemMethods/store.js (6)
    • createStore, createWarehouse, joinStore, joinWarehouse, getStoreRoles, auditApply
  • app/service/systemMethods/user.js (5)
    • login, logout, info, changeRole, register
  • app/service/systemMethods/warehouse.js (20)
    • getWarehouseZones, getWarehouseTree, getChildren, create, update, delete, detail, checkBarcodeUnique, toggleActive, getPath, createRack, getPickPath, updateRackPosition, recalculatePickPath, updateNeighbors, getAreaRacks, getSpacesByRack, createRackWithSpaces, getSpaceInfo, updateSpaceInfo
  • app/service/systems/account_platform.js (11)
    • getActiveInclude, getPrimaryRoleBinding, formatActiveContext, switchActiveRole, getActiveRoleByPlatform, getMultiplePlatformActiveRoles, getAllPlatformActives, clearPlatformActive, clearPlatformCache, getAvailableRoles, getCurrentContext
  • app/service/systems/auth/user.js (21)
    • login, ID, changeRole, info, getRoles, findById, setUserCache, getAvatarByEmployeeId, clearUserCache, clearRelatedCache, getPermissions, getMenus, convertToRoutes, findUserByIdentifier, checkUserStatus, verifyPassword, encryptPassword, generateSalt, updateLastLoginTime, ensurePlatformActiveRole, register
  • app/service/systems/delivery_order.js (7)
    • addOrder, generateItemsHash, calculateCRC32, prepareOrderData, addOrderLines, safeParseFloat, addOrderToQueue
  • app/service/systems/entry_order.js (9)
    • addOrder, getLineCount, received, success, fail, tryCreateEntryOrder, addItems, qimenEntryorderConfirm, entryorderConfirm
  • app/service/systems/inbound_direct_log.js (4)
    • getItems, addItem, commit, removeItem
  • app/service/systems/fast_where.js (13)
    • buildTree, getTreeByType, buildSubTree, getWithChildrenByType, getAllChildren, getByType, getGroups, getChildrenByPid, getTreeChildrenByPid, create, update, findById, delete
  • app/service/systems/file.js (2)
    • getImages, ReferenceFile
  • app/service/systems/location_space.js (16)
    • create, batchCreate, list, detail, update, delete, toggleStatus, updateStatus, findAvailableSpaces, findByCode, findByBarcode, getWarehouseStats, getZoneStats, validateAllocation, validateTransferOut, _validateReferences
  • app/service/systems/location_zone.js (22)
    • getWarehouseLevelZones, getZoneTreeByWarehouse, getChildrenByZoneId, isLeafNode, createZone, validateBasicFields, validateByZoneType, validateParentElement, validateZoneOverlap, isOverlap, generateZoneCodeByType, getDefaultColorByType, getZoneTypeText, updateZone, deleteZone, checkZoneOverlap, getZoneDetail, toggleZoneActive, getZonePath, generateSpacesForRack, getSpaceInfo, checkBarcodeUnique
  • app/service/systems/location.js (10)
    • createRackWithSpaces, _generateSpacesForRack, _calculateAreaRackOrder, _calculatePickPathForWarehouse, _updateSpacePickSequence, _calculatePickPriority, updateRackPosition, getPickPath, updateNeighborRelations, _findNeighborRacks
  • app/service/systems/notification.js (1)
    • send
  • app/service/systems/operation_log.js (4)
    • createOperationLog, queryStockLogs, queryOrderLogs, getMessageDetail
  • app/service/systems/platform.js (6)
    • checkPlatformExists, getPlatformInfo, clearPlatformCache, getPlatformSettingDetail, batchCheckPlatforms, createPlatformSetting
  • app/service/systems/polo_api.js (6)
    • getJsonDatas, getJsonData, getSignText, md5Encrypt, _formatDate, _formatPickupDate
  • app/service/systems/print/index.js (2)
    • sendToComputer, test
  • app/service/systems/qimen_query.js (6)
    • send, replaceXmlTagsWithString, addSign, getQueryParams, generateUrlWithParams, sendRequest
  • app/service/systems/setting/print_template.js (14)
    • listTemplatesByType, getTree, getTemplatesByType, save, getBusinessTypesAndItem, getGroupedPrintItems, getTableConfigs, clearBusinessTypesCache, getXmlByTemplate, buildXmlFromElements, renderElement, computeItemStyle, computeTableItemStyle, renderTable
  • app/service/systems/sign.js (10)
    • Constants, toXml, signTopRequest, verifyTopRequest, verifyAndExtractParams, generateSignedParams, encryptHMAC, encryptHMACSHA256, encryptMD5, byte2hex
  • app/service/systems/space.js (1)
    • searchSpace
  • app/service/systems/stock_store.js (34)
    • create, initQimenStockData, convertToQimenFormat, getItemInfoWithCache, getItemStorages, _calculateCacheTTL, clearItemStorageCache, lockItemStorages, ID, inbound, outbound, checkAndCreateWarehouseStock, getWarehouseStock, buildSequelizeCondition, processConditionValue, formatDate, isEmptyValue, getProhibitedType, getBarcodes, handleBatchChange, saveWarehouseStockBarcode, getStoreStocks, bindItem, unbindItem, getInfo, saveWarehouseStock, createWarehouseStock, validateSaveParams, stockLog, checkItemCodeUnique, handleBatchDelete, deleteUnit, deleteProhibited, search
  • app/service/systems/storage/index.js (1)
    • index
  • app/service/systems/storage/receiving.js (16)
    • getReceivingList, getReceivingDetail, batchCancelReceiving, isEmptyValue, buildSequelizeCondition, processConditionValue, create, get, addDetail, updateDetail, getStockStoreInfo, updateReceivingStats, deleteDetail, detailChange, invalid, completeReceiving
  • app/service/systems/store.js (14)
    • getStoreName, getStoreRemaskName, createStore, createWarehouse, joinStore, joinWarehouse, ensureEmployeeRoleBinding, assignAdminRoleToCreator, generateJoinToken, sendNotification, sendNotificationToAdmins, getStoreRoles, auditApply, loadStores
  • app/service/systems/upload.js (14)
    • initCOS, getUploadParams, hash_hmac, validateFileInfo, generateFileName, parseSizeToBytes, formatFileSize, getFrontendConfig, uploadFile, validateFile, uploadSuccessNotify, getMimeType, createFileReference, handleUploadCallback