kcode-pi 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +358 -0
- package/dist/cli/kcode.d.ts +15 -0
- package/dist/cli/kcode.js +153 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +7 -0
- package/docs/KCODE_DISTRIBUTION.md +91 -0
- package/extensions/kingdee-harness.ts +180 -0
- package/extensions/kingdee-header.ts +122 -0
- package/extensions/kingdee-tools.ts +379 -0
- package/knowledge/.backup/v1.0.0/version.json +10 -0
- package/knowledge/cangqiong/product-notes.md +15 -0
- package/knowledge/common/business-flows.md +115 -0
- package/knowledge/common/config-guides.md +110 -0
- package/knowledge/common/error-patterns.md +170 -0
- package/knowledge/common/implementation.md +144 -0
- package/knowledge/cosmic/hard-constraints.md +38 -0
- package/knowledge/cosmic/ksql-datafix.md +34 -0
- package/knowledge/cosmic/platform-baseline.md +32 -0
- package/knowledge/cosmic/plugin-decision-matrix.md +40 -0
- package/knowledge/cosmic/review-checklist.md +40 -0
- package/knowledge/cosmic/unittest.md +35 -0
- package/knowledge/enterprise/api-reference.md +186 -0
- package/knowledge/enterprise/code-patterns.md +217 -0
- package/knowledge/enterprise/plugin-lifecycle.md +188 -0
- package/knowledge/enterprise/tables.json +159 -0
- package/knowledge/flagship/api-reference.md +237 -0
- package/knowledge/flagship/code-patterns.md +246 -0
- package/knowledge/flagship/cosmic-platform-note.md +15 -0
- package/knowledge/flagship/plugin-lifecycle.md +248 -0
- package/knowledge/flagship/tables.json +159 -0
- package/knowledge/version.json +10 -0
- package/knowledge/xinghan/product-notes.md +15 -0
- package/package.json +71 -0
- package/prompts/kd-discuss.md +11 -0
- package/prompts/kd-execute.md +12 -0
- package/prompts/kd-plan.md +12 -0
- package/prompts/kd-ship.md +12 -0
- package/prompts/kd-spec.md +12 -0
- package/prompts/kd-verify.md +12 -0
- package/skills/kd-check/SKILL.md +26 -0
- package/skills/kd-cosmic-dev/SKILL.md +82 -0
- package/skills/kd-cosmic-review/SKILL.md +90 -0
- package/skills/kd-cosmic-unittest/SKILL.md +92 -0
- package/skills/kd-debug/SKILL.md +30 -0
- package/skills/kd-discuss/SKILL.md +24 -0
- package/skills/kd-execute/SKILL.md +22 -0
- package/skills/kd-gen/SKILL.md +34 -0
- package/skills/kd-ksql/SKILL.md +86 -0
- package/skills/kd-plan/SKILL.md +24 -0
- package/skills/kd-ship/SKILL.md +22 -0
- package/skills/kd-spec/SKILL.md +24 -0
- package/skills/kd-verify/SKILL.md +22 -0
- package/themes/kcode-dark.json +81 -0
- package/vendor/kingdee-skills/cosmic-unittest/SKILL.md +788 -0
- package/vendor/kingdee-skills/cosmic-unittest/author-cache.json +5 -0
- package/vendor/kingdee-skills/cosmic-unittest/cosmic-unittest-skill-overview.html +746 -0
- package/vendor/kingdee-skills/cosmic-unittest/examples/business-test.md +205 -0
- package/vendor/kingdee-skills/cosmic-unittest/examples/common-test.md +257 -0
- package/vendor/kingdee-skills/cosmic-unittest/examples/formplugin-test.md +560 -0
- package/vendor/kingdee-skills/cosmic-unittest/examples/op-plugin-test.md +231 -0
- package/vendor/kingdee-skills/cosmic-unittest/examples/validator-test.md +232 -0
- package/vendor/kingdee-skills/cosmic-unittest/patterns/business-helper.md +184 -0
- package/vendor/kingdee-skills/cosmic-unittest/patterns/common-module.md +355 -0
- package/vendor/kingdee-skills/cosmic-unittest/patterns/convert-plugin.md +130 -0
- package/vendor/kingdee-skills/cosmic-unittest/patterns/formplugin.md +235 -0
- package/vendor/kingdee-skills/cosmic-unittest/patterns/op-plugin.md +226 -0
- package/vendor/kingdee-skills/cosmic-unittest/patterns/validator.md +206 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/SKILL.md +674 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/advanced-scenario-checklist.md +307 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/algox-performance-checklist.md +129 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/coding-standard-checklist.md +491 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/cosmic-api-checklist.md +285 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/data-access-checklist.md +261 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/data-transaction-checklist.md +390 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/domain-logic-checklist.md +295 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/form-plugin-checklist.md +508 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/infra-checklist.md +254 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/ksql-checklist.md +305 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/lifecycle-checklist.md +298 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/operation-plugin-checklist.md +442 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/test-mock-checklist.md +120 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/ui-performance-checklist.md +320 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/scripts/pattern-matcher.py +336 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/scripts/review-score-calculator.py +121 -0
- package/vendor/kingdee-skills/ok-cosmic/CHANGELOG.md +295 -0
- package/vendor/kingdee-skills/ok-cosmic/README.md +460 -0
- package/vendor/kingdee-skills/ok-cosmic/SKILL.md +287 -0
- package/vendor/kingdee-skills/ok-cosmic/agents/openai.yaml +17 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/BatchImportPluginTemplate.java +93 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/BillPlugInTemplate.java +156 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/ConvertPlugInTemplate.java +255 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/FormPluginTemplate.java +597 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/IWorkflowPluginTemplate.java +91 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/ListPluginTemplate.java +194 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/OpPluginTemplate.java +201 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/OpenApiControllerTemplate.java +103 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/PrintPluginTemplate.java +95 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/ReportFormPluginTemplate.java +257 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/ReportListDataPluginTemplate.java +70 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/StandardTreeListPluginTemplate.java +130 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/TaskTemplate.java +80 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/TreeListPluginTemplate.java +152 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/WriteBackPlugInTemplate.java +286 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/attachment/AttachmentUploadBindSample.java +93 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/botp/BotpTracePushSample.java +168 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/botp/SampleConvertPlugin.java +223 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/cache/SampleCacheUsage.java +218 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/concurrent/SampleThreadPoolBatch.java +156 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/data/DynamicObjectCrudSample.java +205 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/data/DynamicObjectOpsSample.java +100 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/BeforeOperationConfirmSample.java +217 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/ConfirmDialogSample.java +131 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/EntryRowCalculateSample.java +116 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/F7FilterSample.java +134 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/GetAndSetValueSample.java +176 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/HyperlinkJumpSample.java +124 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/OpenBillModalSample.java +253 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/ReturnParentDataSample.java +295 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/TreeControlSample.java +140 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/ViewControlOpsSample.java +132 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/list/ListPluginBasicSample.java +170 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/list/ListPreOpenFilterSample.java +68 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/message/MessageNotifySample.java +95 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/mq/SampleMQConsumer.java +198 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/mq/sample_mq.xml +15 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/operation/OpAddValidatorsSample.java +137 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/operation/OperationOptionBridgeSample.java +228 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/package-info.java +19 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/query/BaseDataQuerySample.java +194 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/query/BatchQuerySample.java +368 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/query/DataSetQueryStatSample.java +131 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/report/SampleReportFormPlugin.java +179 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/report/SampleReportListDataPlugin.java +616 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/snippets-guide.md +64 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/task/ScheduleTaskSample.java +160 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/workflow/SampleWorkflowPlugin.java +302 -0
- package/vendor/kingdee-skills/ok-cosmic/manifest.json +78 -0
- package/vendor/kingdee-skills/ok-cosmic/ok-cosmic-intro.html +903 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/attachment-api.md +114 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/botp-convert.md +98 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/dynamic-object.md +113 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/entity-metadata.md +123 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/event-lifecycle.md +184 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/flex-prop.md +114 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/form-utils.md +133 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/operate-chain.md +159 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/plugin-base.md +218 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/query-dataset.md +149 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/request-context.md +88 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/view-handler.md +157 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-bill.md +76 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-botp.md +70 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-form.md +165 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-import.md +69 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-list.md +227 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-openapi.md +112 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-operation.md +135 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-print.md +65 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-report-data.md +64 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-report-form.md +90 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-task.md +62 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-tree-list.md +71 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-workflow.md +82 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-writeback.md +71 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-algo.md +67 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-cache.md +63 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-dynamic-model-svc.md +82 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-dynamic-object.md +70 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-entity-model.md +61 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-exception.md +64 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-file.md +63 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-id.md +47 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-lock.md +61 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-log.md +63 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-network-control.md +70 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-orm-access.md +78 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-request-context.md +62 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-threadpool.md +63 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-tx.md +64 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-utils.md +67 -0
- package/vendor/kingdee-skills/ok-cosmic/requirements.txt +2 -0
- package/vendor/kingdee-skills/ok-cosmic/rules/a-layer-rules.json +24 -0
- package/vendor/kingdee-skills/ok-cosmic/rules/anti-patterns.md +48 -0
- package/vendor/kingdee-skills/ok-cosmic/rules/cheat-sheet.md +256 -0
- package/vendor/kingdee-skills/ok-cosmic/rules/coding-preferences.md +140 -0
- package/vendor/kingdee-skills/ok-cosmic/rules/constraints.md +61 -0
- package/vendor/kingdee-skills/ok-cosmic/rules/decision-matrix.md +222 -0
- package/vendor/kingdee-skills/ok-cosmic/rules/intent-routing.md +94 -0
- package/vendor/kingdee-skills/ok-cosmic/rules/platform-baseline.md +69 -0
- package/vendor/kingdee-skills/ok-cosmic/rules/post-check.md +109 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/config_loader.py +204 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-api-knowledge.py +910 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-basedata-query.py +359 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-config-check.py +181 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-extpoints-query.py +389 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-form-metadata.py +856 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-post-check.py +262 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-post-lint.py +293 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/lint/__init__.py +2 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/lint/base.py +393 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/lint/resource_check.py +176 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/lint/scene_check.py +375 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/lint/style_check.py +434 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/lint/verify_check.py +36 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/route_client.py +186 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/script_utils.py +40 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/sqlite_cache.py +142 -0
- package/vendor/kingdee-skills/ok-cosmic/setup/cuslib/kd-cd-cosmic-commons.jar +0 -0
- package/vendor/kingdee-skills/ok-cosmic/setup/cuslib/kd-cd-cosmic-features.jar +0 -0
- package/vendor/kingdee-skills/ok-cosmic/setup/ok-cosmic-docs.db +0 -0
- package/vendor/kingdee-skills/ok-cosmic/setup/ok-cosmic.json +13 -0
- package/vendor/kingdee-skills/ok-cosmic/setup/setup-mac.sh +18 -0
- package/vendor/kingdee-skills/ok-cosmic/setup/setup-windows.bat +53 -0
- package/vendor/kingdee-skills/ok-cosmic/setup/setup.jar +0 -0
- package/vendor/kingdee-skills/ok-ksql/SKILL.md +81 -0
- package/vendor/kingdee-skills/ok-ksql/agents/openai.yaml +7 -0
- package/vendor/kingdee-skills/ok-ksql/manifest.json +14 -0
- package/vendor/kingdee-skills/ok-ksql/references/ksql-datafix.md +452 -0
- package/vendor/kingdee-skills/ok-ksql/scripts/ksql_lint.py +363 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
{
|
|
2
|
+
"T_PUR_POORDER": {
|
|
3
|
+
"name": "采购订单表",
|
|
4
|
+
"module": "采购管理",
|
|
5
|
+
"description": "采购订单主表,记录采购订单的基本信息",
|
|
6
|
+
"fields": [
|
|
7
|
+
{ "name": "FID", "type": "bigint", "nullable": false, "description": "主键ID" },
|
|
8
|
+
{ "name": "FBILLNO", "type": "varchar(50)", "nullable": false, "description": "单据编号" },
|
|
9
|
+
{ "name": "FDATE", "type": "datetime", "nullable": false, "description": "单据日期" },
|
|
10
|
+
{ "name": "FDOCUMENTSTATUS", "type": "char(1)", "nullable": false, "description": "单据状态:A=暂存,B=已提交,C=已审核" },
|
|
11
|
+
{ "name": "FCANCELSTATUS", "type": "char(1)", "nullable": false, "description": "作废状态:A=正常,B=已作废" },
|
|
12
|
+
{ "name": "FSUPPLIERID", "type": "bigint", "nullable": false, "description": "供应商ID" },
|
|
13
|
+
{ "name": "FPURCHASEORGID", "type": "bigint", "nullable": false, "description": "采购组织ID" },
|
|
14
|
+
{ "name": "FPURCHASEDEPTID", "type": "bigint", "nullable": true, "description": "采购部门ID" },
|
|
15
|
+
{ "name": "FPURCHASERID", "type": "bigint", "nullable": true, "description": "采购员ID" },
|
|
16
|
+
{ "name": "FCURRENCYID", "type": "bigint", "nullable": false, "description": "币种ID" },
|
|
17
|
+
{ "name": "FEXCHANGERATE", "type": "decimal(18,6)", "nullable": false, "description": "汇率" },
|
|
18
|
+
{ "name": "FTOTALAMOUNT", "type": "decimal(18,2)", "nullable": false, "description": "价税合计" },
|
|
19
|
+
{ "name": "FTOTALTAXAMOUNT", "type": "decimal(18,2)", "nullable": false, "description": "税额" },
|
|
20
|
+
{ "name": "FDESCRIPTION", "type": "varchar(500)", "nullable": true, "description": "备注" },
|
|
21
|
+
{ "name": "FCREATORID", "type": "bigint", "nullable": false, "description": "创建人ID" },
|
|
22
|
+
{ "name": "FCREATETIME", "type": "datetime", "nullable": false, "description": "创建时间" },
|
|
23
|
+
{ "name": "FMODIFIERID", "type": "bigint", "nullable": true, "description": "修改人ID" },
|
|
24
|
+
{ "name": "FMODIFYTIME", "type": "datetime", "nullable": true, "description": "修改时间" },
|
|
25
|
+
{ "name": "FAUDITORID", "type": "bigint", "nullable": true, "description": "审核人ID" },
|
|
26
|
+
{ "name": "FAUDITDATE", "type": "datetime", "nullable": true, "description": "审核日期" }
|
|
27
|
+
],
|
|
28
|
+
"relatedTables": [
|
|
29
|
+
{ "table": "T_PUR_POORDERENTRY", "relation": "FID", "description": "采购订单明细" },
|
|
30
|
+
{ "table": "T_PUR_POORDERFIN", "relation": "FID", "description": "采购订单财务信息" }
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"T_PUR_POORDERENTRY": {
|
|
34
|
+
"name": "采购订单明细表",
|
|
35
|
+
"module": "采购管理",
|
|
36
|
+
"description": "采购订单明细表,记录采购订单的物料明细",
|
|
37
|
+
"fields": [
|
|
38
|
+
{ "name": "FENTRYID", "type": "bigint", "nullable": false, "description": "明细ID" },
|
|
39
|
+
{ "name": "FID", "type": "bigint", "nullable": false, "description": "主表ID" },
|
|
40
|
+
{ "name": "FSEQ", "type": "int", "nullable": false, "description": "行号" },
|
|
41
|
+
{ "name": "FMATERIALID", "type": "bigint", "nullable": false, "description": "物料ID" },
|
|
42
|
+
{ "name": "FUNITID", "type": "bigint", "nullable": false, "description": "单位ID" },
|
|
43
|
+
{ "name": "FQTY", "type": "decimal(18,6)", "nullable": false, "description": "数量" },
|
|
44
|
+
{ "name": "FPRICE", "type": "decimal(18,6)", "nullable": false, "description": "单价" },
|
|
45
|
+
{ "name": "FAMOUNT", "type": "decimal(18,2)", "nullable": false, "description": "金额" },
|
|
46
|
+
{ "name": "FTAXPRICE", "type": "decimal(18,6)", "nullable": false, "description": "含税单价" },
|
|
47
|
+
{ "name": "FTAXAMOUNT", "type": "decimal(18,2)", "nullable": false, "description": "价税合计" },
|
|
48
|
+
{ "name": "FTAXRATE", "type": "decimal(18,2)", "nullable": false, "description": "税率" },
|
|
49
|
+
{ "name": "FDELIVERYDATE", "type": "datetime", "nullable": true, "description": "交货日期" },
|
|
50
|
+
{ "name": "FWAREHOUSEID", "type": "bigint", "nullable": true, "description": "收货仓库ID" },
|
|
51
|
+
{ "name": "FDESCRIPTION", "type": "varchar(500)", "nullable": true, "description": "备注" }
|
|
52
|
+
],
|
|
53
|
+
"relatedTables": [
|
|
54
|
+
{ "table": "T_PUR_POORDER", "relation": "FID", "description": "采购订单主表" },
|
|
55
|
+
{ "table": "T_BD_MATERIAL", "relation": "FMATERIALID", "description": "物料表" }
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
"T_SAL_ORDER": {
|
|
59
|
+
"name": "销售订单表",
|
|
60
|
+
"module": "销售管理",
|
|
61
|
+
"description": "销售订单主表,记录销售订单的基本信息",
|
|
62
|
+
"fields": [
|
|
63
|
+
{ "name": "FID", "type": "bigint", "nullable": false, "description": "主键ID" },
|
|
64
|
+
{ "name": "FBILLNO", "type": "varchar(50)", "nullable": false, "description": "单据编号" },
|
|
65
|
+
{ "name": "FDATE", "type": "datetime", "nullable": false, "description": "单据日期" },
|
|
66
|
+
{ "name": "FDOCUMENTSTATUS", "type": "char(1)", "nullable": false, "description": "单据状态:A=暂存,B=已提交,C=已审核" },
|
|
67
|
+
{ "name": "FCUSTID", "type": "bigint", "nullable": false, "description": "客户ID" },
|
|
68
|
+
{ "name": "FSALEORGID", "type": "bigint", "nullable": false, "description": "销售组织ID" },
|
|
69
|
+
{ "name": "FSALEDEPTID", "type": "bigint", "nullable": true, "description": "销售部门ID" },
|
|
70
|
+
{ "name": "FSALEERID", "type": "bigint", "nullable": true, "description": "销售员ID" },
|
|
71
|
+
{ "name": "FCURRENCYID", "type": "bigint", "nullable": false, "description": "币种ID" },
|
|
72
|
+
{ "name": "FEXCHANGERATE", "type": "decimal(18,6)", "nullable": false, "description": "汇率" },
|
|
73
|
+
{ "name": "FTOTALAMOUNT", "type": "decimal(18,2)", "nullable": false, "description": "价税合计" },
|
|
74
|
+
{ "name": "FDESCRIPTION", "type": "varchar(500)", "nullable": true, "description": "备注" }
|
|
75
|
+
],
|
|
76
|
+
"relatedTables": [
|
|
77
|
+
{ "table": "T_SAL_ORDERENTRY", "relation": "FID", "description": "销售订单明细" }
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
"T_STK_INVENTORY": {
|
|
81
|
+
"name": "库存余额表",
|
|
82
|
+
"module": "库存管理",
|
|
83
|
+
"description": "库存余额表,记录各仓库的物料库存数量",
|
|
84
|
+
"fields": [
|
|
85
|
+
{ "name": "FID", "type": "bigint", "nullable": false, "description": "主键ID" },
|
|
86
|
+
{ "name": "FSTOCKID", "type": "bigint", "nullable": false, "description": "仓库ID" },
|
|
87
|
+
{ "name": "FMATERIALID", "type": "bigint", "nullable": false, "description": "物料ID" },
|
|
88
|
+
{ "name": "FLOT", "type": "varchar(50)", "nullable": true, "description": "批号" },
|
|
89
|
+
{ "name": "FQTY", "type": "decimal(18,6)", "nullable": false, "description": "库存数量" },
|
|
90
|
+
{ "name": "FBASEQTY", "type": "decimal(18,6)", "nullable": false, "description": "基本单位数量" },
|
|
91
|
+
{ "name": "FSECQTY", "type": "decimal(18,6)", "nullable": true, "description": "辅助单位数量" },
|
|
92
|
+
{ "name": "FAMOUNT", "type": "decimal(18,2)", "nullable": false, "description": "库存金额" },
|
|
93
|
+
{ "name": "FPRICE", "type": "decimal(18,6)", "nullable": false, "description": "库存单价" }
|
|
94
|
+
],
|
|
95
|
+
"relatedTables": [
|
|
96
|
+
{ "table": "T_BD_MATERIAL", "relation": "FMATERIALID", "description": "物料表" },
|
|
97
|
+
{ "table": "T_BD_STOCK", "relation": "FSTOCKID", "description": "仓库表" }
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
"T_BD_MATERIAL": {
|
|
101
|
+
"name": "物料表",
|
|
102
|
+
"module": "基础资料",
|
|
103
|
+
"description": "物料主数据,记录物料的基本信息",
|
|
104
|
+
"fields": [
|
|
105
|
+
{ "name": "FID", "type": "bigint", "nullable": false, "description": "主键ID" },
|
|
106
|
+
{ "name": "FNUMBER", "type": "varchar(50)", "nullable": false, "description": "物料编码" },
|
|
107
|
+
{ "name": "FNAME", "type": "varchar(200)", "nullable": false, "description": "物料名称" },
|
|
108
|
+
{ "name": "FSPECIFICATION", "type": "varchar(500)", "nullable": true, "description": "规格型号" },
|
|
109
|
+
{ "name": "FBASEUNITID", "type": "bigint", "nullable": false, "description": "基本单位ID" },
|
|
110
|
+
{ "name": "FGROUPID", "type": "bigint", "nullable": false, "description": "物料分组ID" },
|
|
111
|
+
{ "name": "FENABLESTATUS", "type": "char(1)", "nullable": false, "description": "启用状态:A=启用,B=禁用" },
|
|
112
|
+
{ "name": "FDESCRIPTION", "type": "varchar(500)", "nullable": true, "description": "备注" }
|
|
113
|
+
],
|
|
114
|
+
"relatedTables": [
|
|
115
|
+
{ "table": "T_BD_UNIT", "relation": "FBASEUNITID", "description": "计量单位表" }
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
"T_BD_SUPPLIER": {
|
|
119
|
+
"name": "供应商表",
|
|
120
|
+
"module": "基础资料",
|
|
121
|
+
"description": "供应商主数据,记录供应商的基本信息",
|
|
122
|
+
"fields": [
|
|
123
|
+
{ "name": "FID", "type": "bigint", "nullable": false, "description": "主键ID" },
|
|
124
|
+
{ "name": "FNUMBER", "type": "varchar(50)", "nullable": false, "description": "供应商编码" },
|
|
125
|
+
{ "name": "FNAME", "type": "varchar(200)", "nullable": false, "description": "供应商名称" },
|
|
126
|
+
{ "name": "FSHORTNAME", "type": "varchar(100)", "nullable": true, "description": "简称" },
|
|
127
|
+
{ "name": "FTYPE", "type": "char(1)", "nullable": false, "description": "类型:1=普通供应商,2=内部供应商" },
|
|
128
|
+
{ "name": "FENABLESTATUS", "type": "char(1)", "nullable": false, "description": "启用状态:A=启用,B=禁用" }
|
|
129
|
+
],
|
|
130
|
+
"relatedTables": []
|
|
131
|
+
},
|
|
132
|
+
"T_BD_CUSTOMER": {
|
|
133
|
+
"name": "客户表",
|
|
134
|
+
"module": "基础资料",
|
|
135
|
+
"description": "客户主数据,记录客户的基本信息",
|
|
136
|
+
"fields": [
|
|
137
|
+
{ "name": "FID", "type": "bigint", "nullable": false, "description": "主键ID" },
|
|
138
|
+
{ "name": "FNUMBER", "type": "varchar(50)", "nullable": false, "description": "客户编码" },
|
|
139
|
+
{ "name": "FNAME", "type": "varchar(200)", "nullable": false, "description": "客户名称" },
|
|
140
|
+
{ "name": "FSHORTNAME", "type": "varchar(100)", "nullable": true, "description": "简称" },
|
|
141
|
+
{ "name": "FTYPE", "type": "char(1)", "nullable": false, "description": "类型:1=普通客户,2=内部客户" },
|
|
142
|
+
{ "name": "FENABLESTATUS", "type": "char(1)", "nullable": false, "description": "启用状态:A=启用,B=禁用" }
|
|
143
|
+
],
|
|
144
|
+
"relatedTables": []
|
|
145
|
+
},
|
|
146
|
+
"T_BD_STOCK": {
|
|
147
|
+
"name": "仓库表",
|
|
148
|
+
"module": "基础资料",
|
|
149
|
+
"description": "仓库主数据,记录仓库的基本信息",
|
|
150
|
+
"fields": [
|
|
151
|
+
{ "name": "FID", "type": "bigint", "nullable": false, "description": "主键ID" },
|
|
152
|
+
{ "name": "FNUMBER", "type": "varchar(50)", "nullable": false, "description": "仓库编码" },
|
|
153
|
+
{ "name": "FNAME", "type": "varchar(200)", "nullable": false, "description": "仓库名称" },
|
|
154
|
+
{ "name": "FSTOCKORGID", "type": "bigint", "nullable": false, "description": "库存组织ID" },
|
|
155
|
+
{ "name": "FENABLESTATUS", "type": "char(1)", "nullable": false, "description": "启用状态:A=启用,B=禁用" }
|
|
156
|
+
],
|
|
157
|
+
"relatedTables": []
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# 金蝶云星空旗舰版 Java API 参考
|
|
2
|
+
|
|
3
|
+
## 核心服务类
|
|
4
|
+
|
|
5
|
+
### BusinessDataServiceHelper
|
|
6
|
+
|
|
7
|
+
业务数据服务助手,是最常用的数据访问类。
|
|
8
|
+
|
|
9
|
+
**常用方法:**
|
|
10
|
+
|
|
11
|
+
```java
|
|
12
|
+
// 加载单个数据实体
|
|
13
|
+
DynamicObject loadSingle(AppContext ctx, Object pkValue, String entityName)
|
|
14
|
+
|
|
15
|
+
// 加载多个数据实体
|
|
16
|
+
DynamicObject[] load(AppContext ctx, Object[] pkValues, String entityName)
|
|
17
|
+
|
|
18
|
+
// 按条件查询
|
|
19
|
+
DynamicObject[] load(AppContext ctx, String entityName, QFilter[] filters)
|
|
20
|
+
|
|
21
|
+
// 按条件查询指定字段
|
|
22
|
+
DynamicObject[] load(AppContext ctx, String entityName, String selectFields, QFilter[] filters)
|
|
23
|
+
|
|
24
|
+
// 加载基础资料
|
|
25
|
+
DynamicObject loadSingle(AppContext ctx, String entityName, Object pkValue, QFilter[] filters)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**使用示例:**
|
|
29
|
+
|
|
30
|
+
```java
|
|
31
|
+
// 加载采购订单
|
|
32
|
+
QFilter filter = new QFilter("billno", "=", "PO-001");
|
|
33
|
+
DynamicObject[] orders = BusinessDataServiceHelper.load(
|
|
34
|
+
ctx,
|
|
35
|
+
"PUR_POOrder",
|
|
36
|
+
new QFilter[]{filter}
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
if (orders.length > 0) {
|
|
40
|
+
DynamicObject order = orders[0];
|
|
41
|
+
String billNo = order.getString("billno");
|
|
42
|
+
BigDecimal totalAmount = order.getBigDecimal("totalamount");
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### DBRoute
|
|
47
|
+
|
|
48
|
+
数据库路由,用于执行 SQL 查询。
|
|
49
|
+
|
|
50
|
+
**常用方法:**
|
|
51
|
+
|
|
52
|
+
```java
|
|
53
|
+
// 执行查询,返回 DataSet
|
|
54
|
+
DataSet queryDataSet(String routeName, String sql)
|
|
55
|
+
|
|
56
|
+
// 执行查询带参数
|
|
57
|
+
DataSet queryDataSet(String routeName, String sql, Object[] params)
|
|
58
|
+
|
|
59
|
+
// 执行更新
|
|
60
|
+
int execute(String routeName, String sql)
|
|
61
|
+
|
|
62
|
+
// 执行更新带参数
|
|
63
|
+
int execute(String routeName, String sql, Object[] params)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**使用示例:**
|
|
67
|
+
|
|
68
|
+
```java
|
|
69
|
+
// 查询采购订单
|
|
70
|
+
String sql = "SELECT FBILLNO, FDATE, FAMOUNT FROM T_PUR_POORDER WHERE FDOCUMENTSTATUS = 'C'";
|
|
71
|
+
DataSet ds = DBRoute.queryDataSet("default", sql);
|
|
72
|
+
|
|
73
|
+
while (ds.next()) {
|
|
74
|
+
String billNo = ds.getString("FBILLNO");
|
|
75
|
+
Date date = ds.getDate("FDATE");
|
|
76
|
+
BigDecimal amount = ds.getBigDecimal("FAMOUNT");
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### DataAccess
|
|
81
|
+
|
|
82
|
+
数据访问层,提供 ORM 功能。
|
|
83
|
+
|
|
84
|
+
**常用方法:**
|
|
85
|
+
|
|
86
|
+
```java
|
|
87
|
+
// 执行查询
|
|
88
|
+
DataSet executeDataSet(String sql)
|
|
89
|
+
|
|
90
|
+
// 执行更新
|
|
91
|
+
int executeUpdate(String sql)
|
|
92
|
+
|
|
93
|
+
// 批量插入
|
|
94
|
+
void insertBatch(String tableName, DataSet data)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## 插件基类
|
|
100
|
+
|
|
101
|
+
### AbstractBillPlugIn
|
|
102
|
+
|
|
103
|
+
表单插件基类,用于表单事件处理。
|
|
104
|
+
|
|
105
|
+
**常用事件:**
|
|
106
|
+
|
|
107
|
+
```java
|
|
108
|
+
// 表单加载后
|
|
109
|
+
public void afterLoadData(EventObject e)
|
|
110
|
+
|
|
111
|
+
// 字段值变更后
|
|
112
|
+
public void afterPropertyChanged(PropertyChangedArgs e)
|
|
113
|
+
|
|
114
|
+
// 保存前
|
|
115
|
+
public void beforeSave(BeforeSaveEventArgs e)
|
|
116
|
+
|
|
117
|
+
// 保存后
|
|
118
|
+
public void afterSave(EventObject e)
|
|
119
|
+
|
|
120
|
+
// 提交前
|
|
121
|
+
public void beforeSubmit(BeforeSubmitEventArgs e)
|
|
122
|
+
|
|
123
|
+
// 审核前
|
|
124
|
+
public void beforeAudit(BeforeAuditEventArgs e)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### AbstractOperatePlugin
|
|
128
|
+
|
|
129
|
+
操作插件基类,用于操作事件处理。
|
|
130
|
+
|
|
131
|
+
**常用事件:**
|
|
132
|
+
|
|
133
|
+
```java
|
|
134
|
+
// 操作执行前
|
|
135
|
+
public void beforeExecuteOperationTransaction(BeforeExecuteOperationTransactionArgs e)
|
|
136
|
+
|
|
137
|
+
// 操作执行后
|
|
138
|
+
public void afterExecuteOperationTransaction(AfterExecuteOperationTransactionArgs e)
|
|
139
|
+
|
|
140
|
+
// 校验操作
|
|
141
|
+
public void onGetValidateRules(GetValidateRulesEventArgs e)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### AbstractValidatePlugin
|
|
145
|
+
|
|
146
|
+
校验插件基类,用于数据校验。
|
|
147
|
+
|
|
148
|
+
**常用方法:**
|
|
149
|
+
|
|
150
|
+
```java
|
|
151
|
+
// 自定义校验规则
|
|
152
|
+
public void onGetValidateRules(GetValidateRulesEventArgs e)
|
|
153
|
+
|
|
154
|
+
// 校验数据
|
|
155
|
+
public void validate(ValidateEventArgs e)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## 常用工具类
|
|
161
|
+
|
|
162
|
+
### StringUtils
|
|
163
|
+
|
|
164
|
+
字符串处理工具。
|
|
165
|
+
|
|
166
|
+
```java
|
|
167
|
+
// 判断是否为空
|
|
168
|
+
boolean isEmpty(String str)
|
|
169
|
+
|
|
170
|
+
// 判断是否不为空
|
|
171
|
+
boolean isNotEmpty(String str)
|
|
172
|
+
|
|
173
|
+
// 去除空格
|
|
174
|
+
String trim(String str)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### NumberUtils
|
|
178
|
+
|
|
179
|
+
数字处理工具。
|
|
180
|
+
|
|
181
|
+
```java
|
|
182
|
+
// 判断是否为零
|
|
183
|
+
boolean isZero(BigDecimal value)
|
|
184
|
+
|
|
185
|
+
// 比较大小
|
|
186
|
+
int compareTo(BigDecimal v1, BigDecimal v2)
|
|
187
|
+
|
|
188
|
+
// 格式化数字
|
|
189
|
+
String formatNumber(BigDecimal value, int scale)
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### DateUtils
|
|
193
|
+
|
|
194
|
+
日期处理工具。
|
|
195
|
+
|
|
196
|
+
```java
|
|
197
|
+
// 获取当前日期
|
|
198
|
+
Date getNow()
|
|
199
|
+
|
|
200
|
+
// 格式化日期
|
|
201
|
+
String formatDate(Date date, String pattern)
|
|
202
|
+
|
|
203
|
+
// 解析日期
|
|
204
|
+
Date parseDate(String dateStr, String pattern)
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## 异常处理
|
|
210
|
+
|
|
211
|
+
### KDException
|
|
212
|
+
|
|
213
|
+
金蝶自定义异常。
|
|
214
|
+
|
|
215
|
+
```java
|
|
216
|
+
// 抛出异常
|
|
217
|
+
throw new KDException("错误编码", "错误信息");
|
|
218
|
+
|
|
219
|
+
// 带原因的异常
|
|
220
|
+
throw new KDException("错误编码", "错误信息", cause);
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### 异常处理最佳实践
|
|
224
|
+
|
|
225
|
+
```java
|
|
226
|
+
try {
|
|
227
|
+
// 业务逻辑
|
|
228
|
+
} catch (KDException e) {
|
|
229
|
+
// 金蝶业务异常
|
|
230
|
+
logger.error("业务处理失败: " + e.getMessage(), e);
|
|
231
|
+
throw e;
|
|
232
|
+
} catch (Exception e) {
|
|
233
|
+
// 其他异常
|
|
234
|
+
logger.error("系统异常: " + e.getMessage(), e);
|
|
235
|
+
throw new KDException("SYS001", "系统异常,请联系管理员", e);
|
|
236
|
+
}
|
|
237
|
+
```
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# 金蝶云星空旗舰版 Java 代码模式
|
|
2
|
+
|
|
3
|
+
## 数据访问模式
|
|
4
|
+
|
|
5
|
+
### 模式一:BusinessDataServiceHelper 查询
|
|
6
|
+
|
|
7
|
+
**适用场景:** 按主键或条件查询单个/多个实体
|
|
8
|
+
|
|
9
|
+
```java
|
|
10
|
+
// 按主键查询
|
|
11
|
+
DynamicObject entity = BusinessDataServiceHelper.loadSingle(
|
|
12
|
+
ctx,
|
|
13
|
+
primaryKey,
|
|
14
|
+
"PUR_POOrder"
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
// 按条件查询
|
|
18
|
+
QFilter filter = new QFilter("billno", "=", "PO-001");
|
|
19
|
+
DynamicObject[] entities = BusinessDataServiceHelper.load(
|
|
20
|
+
ctx,
|
|
21
|
+
"PUR_POOrder",
|
|
22
|
+
new QFilter[]{filter}
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
// 查询指定字段
|
|
26
|
+
String[] selectFields = new String[]{"id", "billno", "date", "amount"};
|
|
27
|
+
DynamicObject[] entities = BusinessDataServiceHelper.load(
|
|
28
|
+
ctx,
|
|
29
|
+
"PUR_POOrder",
|
|
30
|
+
selectFields,
|
|
31
|
+
new QFilter[]{filter}
|
|
32
|
+
);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 模式二:DBRoute SQL 查询
|
|
36
|
+
|
|
37
|
+
**适用场景:** 复杂查询、报表查询、跨表查询
|
|
38
|
+
|
|
39
|
+
```java
|
|
40
|
+
// 简单查询
|
|
41
|
+
String sql = "SELECT FBILLNO, FDATE, FAMOUNT FROM T_PUR_POORDER WHERE FDOCUMENTSTATUS = 'C'";
|
|
42
|
+
DataSet ds = DBRoute.queryDataSet("default", sql);
|
|
43
|
+
|
|
44
|
+
// 带参数查询
|
|
45
|
+
String sql = "SELECT * FROM T_PUR_POORDER WHERE FDATE >= ? AND FDATE <= ?";
|
|
46
|
+
DataSet ds = DBRoute.queryDataSet("default", sql, new Object[]{startDate, endDate});
|
|
47
|
+
|
|
48
|
+
// 聚合查询
|
|
49
|
+
String sql = "SELECT FSUPPLIERID, SUM(FAMOUNT) AS TOTAL FROM T_PUR_POORDER GROUP BY FSUPPLIERID";
|
|
50
|
+
DataSet ds = DBRoute.queryDataSet("default", sql);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 模式三:ORM 查询
|
|
54
|
+
|
|
55
|
+
**适用场景:** 需要类型安全的查询
|
|
56
|
+
|
|
57
|
+
```java
|
|
58
|
+
// 使用 DataAccess
|
|
59
|
+
DataAccess da = new DataAccess(ctx);
|
|
60
|
+
DataSet ds = da.executeDataSet("SELECT * FROM T_PUR_POORDER WHERE FID = ?", new Object[]{id});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 事务处理模式
|
|
66
|
+
|
|
67
|
+
### 事务内操作
|
|
68
|
+
|
|
69
|
+
```java
|
|
70
|
+
// 开始事务
|
|
71
|
+
DBRoute.beginTransaction();
|
|
72
|
+
try {
|
|
73
|
+
// 业务操作
|
|
74
|
+
DBRoute.execute("default", sql1);
|
|
75
|
+
DBRoute.execute("default", sql2);
|
|
76
|
+
|
|
77
|
+
// 提交事务
|
|
78
|
+
DBRoute.commitTransaction();
|
|
79
|
+
} catch (Exception e) {
|
|
80
|
+
// 回滚事务
|
|
81
|
+
DBRoute.rollbackTransaction();
|
|
82
|
+
throw e;
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 使用 try-with-resources
|
|
87
|
+
|
|
88
|
+
```java
|
|
89
|
+
try (TransactionScope scope = new TransactionScope()) {
|
|
90
|
+
// 业务操作
|
|
91
|
+
DBRoute.execute("default", sql1);
|
|
92
|
+
DBRoute.execute("default", sql2);
|
|
93
|
+
|
|
94
|
+
scope.complete();
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 异常处理模式
|
|
101
|
+
|
|
102
|
+
### 业务异常处理
|
|
103
|
+
|
|
104
|
+
```java
|
|
105
|
+
public void processOrder(DynamicObject order) {
|
|
106
|
+
try {
|
|
107
|
+
// 业务逻辑
|
|
108
|
+
validateOrder(order);
|
|
109
|
+
saveOrder(order);
|
|
110
|
+
} catch (KDException e) {
|
|
111
|
+
// 业务异常,记录日志并抛出
|
|
112
|
+
logger.error("处理订单失败: " + e.getMessage(), e);
|
|
113
|
+
throw e;
|
|
114
|
+
} catch (Exception e) {
|
|
115
|
+
// 其他异常,包装为业务异常
|
|
116
|
+
logger.error("系统异常: " + e.getMessage(), e);
|
|
117
|
+
throw new KDException("SYS001", "系统异常,请联系管理员", e);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### 校验异常处理
|
|
123
|
+
|
|
124
|
+
```java
|
|
125
|
+
public void validateOrder(DynamicObject order) {
|
|
126
|
+
List<String> errors = new ArrayList<>();
|
|
127
|
+
|
|
128
|
+
// 校验必填字段
|
|
129
|
+
if (StringUtils.isEmpty(order.getString("billno"))) {
|
|
130
|
+
errors.add("单据编号不能为空");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// 校验业务规则
|
|
134
|
+
BigDecimal amount = order.getBigDecimal("amount");
|
|
135
|
+
if (amount.compareTo(BigDecimal.ZERO) <= 0) {
|
|
136
|
+
errors.add("金额必须大于零");
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// 抛出校验异常
|
|
140
|
+
if (!errors.isEmpty()) {
|
|
141
|
+
throw new KDException("VALIDATE001", String.join("; ", errors));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 日志记录模式
|
|
149
|
+
|
|
150
|
+
### 使用 Logger
|
|
151
|
+
|
|
152
|
+
```java
|
|
153
|
+
private static final Logger logger = Logger.getLogger(OrderPlugin.class);
|
|
154
|
+
|
|
155
|
+
// 记录信息
|
|
156
|
+
logger.info("开始处理订单: " + billNo);
|
|
157
|
+
|
|
158
|
+
// 记录警告
|
|
159
|
+
logger.warn("订单金额较大: " + amount);
|
|
160
|
+
|
|
161
|
+
// 记录错误
|
|
162
|
+
logger.error("处理订单失败", exception);
|
|
163
|
+
|
|
164
|
+
// 调试日志
|
|
165
|
+
if (logger.isDebugEnabled()) {
|
|
166
|
+
logger.debug("订单详情: " + order.toString());
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 批量处理模式
|
|
173
|
+
|
|
174
|
+
### 批量查询
|
|
175
|
+
|
|
176
|
+
```java
|
|
177
|
+
// 分批查询大量数据
|
|
178
|
+
int batchSize = 1000;
|
|
179
|
+
int offset = 0;
|
|
180
|
+
List<DynamicObject> allResults = new ArrayList<>();
|
|
181
|
+
|
|
182
|
+
while (true) {
|
|
183
|
+
String sql = String.format(
|
|
184
|
+
"SELECT * FROM T_PUR_POORDER ORDER BY FID OFFSET %d ROWS FETCH NEXT %d ROWS ONLY",
|
|
185
|
+
offset, batchSize
|
|
186
|
+
);
|
|
187
|
+
DataSet ds = DBRoute.queryDataSet("default", sql);
|
|
188
|
+
|
|
189
|
+
if (ds.getRowCount() == 0) break;
|
|
190
|
+
|
|
191
|
+
while (ds.next()) {
|
|
192
|
+
// 处理每行数据
|
|
193
|
+
allResults.add(convertToEntity(ds));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
offset += batchSize;
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### 批量更新
|
|
201
|
+
|
|
202
|
+
```java
|
|
203
|
+
// 使用事务批量更新
|
|
204
|
+
DBRoute.beginTransaction();
|
|
205
|
+
try {
|
|
206
|
+
for (DynamicObject entity : entities) {
|
|
207
|
+
String sql = "UPDATE T_PUR_POORDER SET FSTATUS = ? WHERE FID = ?";
|
|
208
|
+
DBRoute.execute("default", sql, new Object[]{"C", entity.getLong("id")});
|
|
209
|
+
}
|
|
210
|
+
DBRoute.commitTransaction();
|
|
211
|
+
} catch (Exception e) {
|
|
212
|
+
DBRoute.rollbackTransaction();
|
|
213
|
+
throw e;
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## 缓存使用模式
|
|
220
|
+
|
|
221
|
+
### 基础资料缓存
|
|
222
|
+
|
|
223
|
+
```java
|
|
224
|
+
// 使用缓存加载基础资料
|
|
225
|
+
DynamicObject supplier = BusinessDataServiceHelper.loadSingle(
|
|
226
|
+
ctx,
|
|
227
|
+
supplierId,
|
|
228
|
+
"BD_Supplier"
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
// 缓存会自动管理,无需手动清理
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### 自定义缓存
|
|
235
|
+
|
|
236
|
+
```java
|
|
237
|
+
// 使用 CacheManager
|
|
238
|
+
CacheManager cacheManager = CacheManager.getInstance();
|
|
239
|
+
String cacheKey = "supplier_" + supplierId;
|
|
240
|
+
|
|
241
|
+
DynamicObject supplier = (DynamicObject) cacheManager.get(cacheKey);
|
|
242
|
+
if (supplier == null) {
|
|
243
|
+
supplier = BusinessDataServiceHelper.loadSingle(ctx, supplierId, "BD_Supplier");
|
|
244
|
+
cacheManager.put(cacheKey, supplier, 300); // 缓存5分钟
|
|
245
|
+
}
|
|
246
|
+
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Xingkong Flagship Cosmic Platform Note
|
|
2
|
+
|
|
3
|
+
Xingkong Flagship is a Cosmic-family product. Load Cosmic platform knowledge first, then apply flagship-specific project knowledge.
|
|
4
|
+
|
|
5
|
+
## Default Stack
|
|
6
|
+
|
|
7
|
+
- Platform: Cosmic.
|
|
8
|
+
- Language: Java.
|
|
9
|
+
- Main concerns: plugin lifecycle, metadata verification, SDK signature verification, transaction boundaries, performance review.
|
|
10
|
+
|
|
11
|
+
## Harness Rules
|
|
12
|
+
|
|
13
|
+
- Do not route Xingkong Flagship to enterprise C# rules.
|
|
14
|
+
- Do not treat `flagship` as a non-Cosmic Java BOS stack unless the project explicitly proves it is a legacy product outside Xingkong Flagship.
|
|
15
|
+
- Use Cosmic plugin and KSQL rules for new development.
|