neo-cmp-cli 1.13.11 → 1.13.13

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.
Files changed (100) hide show
  1. package/dist/neo/neoService.js +1 -1
  2. package/dist/package.json.js +1 -1
  3. package/package.json +1 -1
  4. package/template/antd-custom-cmp-template/package.json +1 -1
  5. package/template/asset-manage-template/package.json +1 -1
  6. package/template/echarts-custom-cmp-template/package.json +1 -1
  7. package/template/empty-custom-cmp-template/package.json +1 -1
  8. package/template/map-custom-cmp-template/package.json +1 -1
  9. package/template/neo-bi-cmps/docs/gartner-pipeline-apis.md +279 -0
  10. package/template/neo-bi-cmps/docs/gartner-pipeline-prd.md +389 -0
  11. package/template/neo-bi-cmps/docs/neo-backend-dev/SKILL.md +188 -0
  12. package/template/neo-bi-cmps/docs/neo-backend-dev/references/01-Trigger/345/274/200/345/217/221.md +183 -0
  13. package/template/neo-bi-cmps/docs/neo-backend-dev/references/02-/350/207/252/345/256/232/344/271/211API/345/274/200/345/217/221.md +196 -0
  14. package/template/neo-bi-cmps/docs/neo-backend-dev/references/03-SDK/345/267/245/345/205/267/347/261/273/346/216/245/345/217/243.md +346 -0
  15. package/template/neo-bi-cmps/docs/neo-backend-dev/references/04-/350/256/241/345/210/222/344/275/234/344/270/232/345/274/200/345/217/221.md +188 -0
  16. package/template/neo-bi-cmps/docs/neo-backend-dev/references/05-/351/241/265/351/235/242/345/274/200/345/217/221.md +293 -0
  17. package/template/neo-bi-cmps/docs/neo-backend-dev/references/06-/346/265/201/347/250/213/346/211/251/345/261/225/345/274/200/345/217/221.md +175 -0
  18. package/template/neo-bi-cmps/docs/neo-backend-dev/references/PaaS/345/271/263/345/217/260/345/274/200/345/217/221/346/211/213/345/206/214/350/247/243/350/257/273.md +313 -0
  19. package/template/neo-bi-cmps/docs/neo-backend-dev/references/auth-config.md +77 -0
  20. package/template/neo-bi-cmps/docs/neo-backend-dev/scripts/deploy_server_script.py +118 -0
  21. package/template/neo-bi-cmps/docs/neo-backend-dev/scripts/download_server_script.py +74 -0
  22. package/template/neo-bi-cmps/docs/neo-backend-dev/scripts/gen_entity_desc.py +69 -0
  23. package/template/neo-bi-cmps/docs/neo-backend-dev/scripts/gen_entitylist.py +87 -0
  24. package/template/neo-bi-cmps/docs/neo-backend-dev/scripts/query_crm.py +65 -0
  25. package/template/neo-bi-cmps/docs/neo-backend-dev/scripts/uninstall_server_script.py +48 -0
  26. package/template/neo-bi-cmps/docs/neo-backend-dev/scripts/update_model_jar.py +49 -0
  27. package/template/neo-bi-cmps/docs/neo-frontend-dev/SKILL.md +138 -0
  28. package/template/neo-bi-cmps/docs/neo-frontend-dev/references/auth-config.md +77 -0
  29. package/template/neo-bi-cmps/docs/neo-frontend-dev/references/component-dev.md +205 -0
  30. package/template/neo-bi-cmps/docs/neo-frontend-dev/references/entityTable-example.md +167 -0
  31. package/template/neo-bi-cmps/docs/neo-frontend-dev/references/templates.md +38 -0
  32. package/template/neo-bi-cmps/docs/neo-frontend-dev/scripts/gen_entity_desc.py +69 -0
  33. package/template/neo-bi-cmps/docs/neo-frontend-dev/scripts/gen_entitylist.py +87 -0
  34. package/template/neo-bi-cmps/docs/neo-frontend-dev/scripts/query_crm.py +65 -0
  35. package/template/neo-bi-cmps/docs/prototype-pipeline-forecasting.html +2453 -0
  36. package/template/neo-bi-cmps/docs//350/264/246/345/217/267/347/233/270/345/205/263/344/277/241/346/201/257.md +10 -0
  37. package/template/neo-bi-cmps/package.json +1 -1
  38. package/template/neo-bi-cmps/src/components/aiCommitDrawer__c/README.md +52 -0
  39. package/template/neo-bi-cmps/src/components/aiCommitDrawer__c/index.tsx +176 -0
  40. package/template/neo-bi-cmps/src/components/aiCommitDrawer__c/model.ts +49 -0
  41. package/template/neo-bi-cmps/src/components/aiCommitDrawer__c/style.scss +218 -0
  42. package/template/neo-bi-cmps/src/components/filterBar__c/README.md +35 -0
  43. package/template/neo-bi-cmps/src/components/filterBar__c/index.tsx +186 -0
  44. package/template/neo-bi-cmps/src/components/filterBar__c/model.ts +72 -0
  45. package/template/neo-bi-cmps/src/components/filterBar__c/style.scss +212 -0
  46. package/template/neo-bi-cmps/src/components/forecastChart__c/README.md +31 -0
  47. package/template/neo-bi-cmps/src/components/forecastChart__c/index.tsx +161 -0
  48. package/template/neo-bi-cmps/src/components/forecastChart__c/model.ts +39 -0
  49. package/template/neo-bi-cmps/src/components/forecastChart__c/style.scss +154 -0
  50. package/template/neo-bi-cmps/src/components/forecastGrid__c/README.md +36 -0
  51. package/template/neo-bi-cmps/src/components/forecastGrid__c/index.tsx +86 -0
  52. package/template/neo-bi-cmps/src/components/forecastGrid__c/model.ts +34 -0
  53. package/template/neo-bi-cmps/src/components/forecastGrid__c/style.scss +48 -0
  54. package/template/neo-bi-cmps/src/components/gapCloser__c/README.md +24 -0
  55. package/template/neo-bi-cmps/src/components/gapCloser__c/index.tsx +95 -0
  56. package/template/neo-bi-cmps/src/components/gapCloser__c/model.ts +43 -0
  57. package/template/neo-bi-cmps/src/components/gapCloser__c/style.scss +60 -0
  58. package/template/neo-bi-cmps/src/components/kpiCards__c/README.md +35 -0
  59. package/template/neo-bi-cmps/src/components/kpiCards__c/index.tsx +70 -0
  60. package/template/neo-bi-cmps/src/components/kpiCards__c/model.ts +35 -0
  61. package/template/neo-bi-cmps/src/components/kpiCards__c/style.scss +33 -0
  62. package/template/neo-bi-cmps/src/components/oppList__c/README.md +52 -0
  63. package/template/neo-bi-cmps/src/components/oppList__c/index.tsx +228 -0
  64. package/template/neo-bi-cmps/src/components/oppList__c/model.ts +40 -0
  65. package/template/neo-bi-cmps/src/components/oppList__c/style.scss +133 -0
  66. package/template/neo-bi-cmps/src/components/pipelineFunnel__c/README.md +39 -0
  67. package/template/neo-bi-cmps/src/components/pipelineFunnel__c/index.tsx +128 -0
  68. package/template/neo-bi-cmps/src/components/pipelineFunnel__c/model.ts +42 -0
  69. package/template/neo-bi-cmps/src/components/pipelineFunnel__c/style.scss +133 -0
  70. package/template/neo-bi-cmps/src/components/stageSwitch__c/README.md +36 -0
  71. package/template/neo-bi-cmps/src/components/stageSwitch__c/index.tsx +103 -0
  72. package/template/neo-bi-cmps/src/components/stageSwitch__c/model.ts +37 -0
  73. package/template/neo-bi-cmps/src/components/stageSwitch__c/style.scss +89 -0
  74. package/template/neo-bi-cmps/src/components/stageTimeChart__c/README.md +37 -0
  75. package/template/neo-bi-cmps/src/components/stageTimeChart__c/index.tsx +126 -0
  76. package/template/neo-bi-cmps/src/components/stageTimeChart__c/model.ts +35 -0
  77. package/template/neo-bi-cmps/src/components/stageTimeChart__c/style.scss +140 -0
  78. package/template/neo-bi-cmps/src/components/tabSwitch__c/README.md +37 -0
  79. package/template/neo-bi-cmps/src/components/tabSwitch__c/index.tsx +80 -0
  80. package/template/neo-bi-cmps/src/components/tabSwitch__c/model.ts +45 -0
  81. package/template/neo-bi-cmps/src/components/tabSwitch__c/style.scss +37 -0
  82. package/template/neo-custom-cmp-template/package.json +1 -1
  83. package/template/neo-custom-cmp-template/src/components/entityForm__c/index.tsx +48 -54
  84. package/template/neo-custom-cmp-template/src/components/entityForm__c/model.ts +1 -1
  85. package/template/neo-custom-cmp-template/src/components/entityForm__c/style.scss +80 -77
  86. package/template/neo-h5-cmps/package.json +1 -1
  87. package/template/neo-order-cmps/package.json +1 -1
  88. package/template/neo-web-entity-grid/package.json +1 -1
  89. package/template/neo-web-entity-grid/src/components/createForm__c/index.tsx +46 -54
  90. package/template/neo-web-entity-grid/src/components/createForm__c/resetAntd.scss +74 -0
  91. package/template/neo-web-entity-grid/src/components/createForm__c/style.scss +81 -152
  92. package/template/neo-web-entity-grid/src/components/searchForm__c/index.tsx +47 -52
  93. package/template/neo-web-entity-grid/src/components/searchForm__c/style.scss +60 -74
  94. package/template/neo-web-form/package.json +1 -1
  95. package/template/neo-web-form/src/components/batchAddTable__c/index.tsx +16 -7
  96. package/template/neo-web-form/src/components/batchAddTable__c/style.scss +14 -0
  97. package/template/neo-web-form/src/components/batchAddTable__c/tableModal.scss +60 -13
  98. package/template/react-custom-cmp-template/package.json +1 -1
  99. package/template/react-ts-custom-cmp-template/package.json +1 -1
  100. package/template/vue2-custom-cmp-template/package.json +1 -1
@@ -0,0 +1,346 @@
1
+ # 技能包:SDK 工具类接口
2
+
3
+ ## 概述
4
+
5
+ 销售易 PaaS SDK 提供了丰富的工具类接口,用于数据操作、HTTP 请求、缓存、异步任务等。
6
+
7
+ ---
8
+
9
+ ## 1. 数据操作接口(XObjectService)
10
+
11
+ 用于对销售易系统中的对象数据进行 CRUD 操作。
12
+
13
+ ### 查询数据
14
+
15
+ ```java
16
+ import com.rkhd.platform.sdk.service.XObjectService;
17
+ import com.rkhd.platform.sdk.model.QueryResult;
18
+ import com.rkhd.platform.sdk.model.XObject;
19
+
20
+ // 基本查询
21
+ QueryResult result = XObjectService.instance().query(
22
+ "SELECT id, name, createdAt FROM account WHERE name LIKE '%test%' LIMIT 10"
23
+ );
24
+ List<XObject> records = result.getRecords();
25
+
26
+ // 查询并包含已删除数据
27
+ QueryResult result = XObjectService.instance().query(sql, true);
28
+ ```
29
+
30
+ ### 插入数据
31
+
32
+ ```java
33
+ import com.rkhd.platform.sdk.service.XObjectService;
34
+ import com.rkhd.platform.sdk.service.MetadataService;
35
+
36
+ XObject xObject = new CustomEntity1__c();
37
+ xObject.setAttribute("name", "测试数据");
38
+ xObject.setAttribute("entityType",
39
+ MetadataService.instance().getBusiType(xObject.getApiKey(), "defaultBusiType").getId());
40
+ XObjectService.instance().insert(xObject);
41
+ ```
42
+
43
+ ### 更新数据
44
+
45
+ ```java
46
+ XObject xObject = new CustomEntity1__c();
47
+ xObject.setId(dataId);
48
+ xObject.setAttribute("name", "更新后的名称");
49
+ XObjectService.instance().update(xObject);
50
+ ```
51
+
52
+ ### 删除数据
53
+
54
+ ```java
55
+ XObject xObject = new CustomEntity1__c();
56
+ xObject.setId(dataId);
57
+ XObjectService.instance().delete(xObject);
58
+ ```
59
+
60
+ ### 限制
61
+
62
+ - 单次链路查询不超过 **10,000 条**
63
+ - 单次 DML 操作不超过 **10,000 条**
64
+ - 单个脚本中 rkhdHttpClient 可进行的 query 或 DML 最大 **50 次**
65
+
66
+ ---
67
+
68
+ ## 2. 向外部系统发起 HTTP 请求(CommonHttpClient)
69
+
70
+ ### GET 请求
71
+
72
+ ```java
73
+ import com.rkhd.platform.sdk.http.CommonHttpClient;
74
+ import com.rkhd.platform.sdk.http.CommonData;
75
+ import com.rkhd.platform.sdk.http.HttpResult;
76
+
77
+ CommonHttpClient client = CommonHttpClient.instance();
78
+ CommonData commonData = CommonData.newBuilder()
79
+ .callType("GET")
80
+ .callString("https://external-api.com/data?id=123")
81
+ .header("Authorization", "Bearer token")
82
+ .build();
83
+ HttpResult result = client.execute(commonData);
84
+ String responseBody = result.getResult();
85
+ ```
86
+
87
+ ### POST 请求(JSON)
88
+
89
+ ```java
90
+ import com.alibaba.fastjson.JSONObject;
91
+
92
+ JSONObject body = new JSONObject();
93
+ body.put("name", "test");
94
+ body.put("value", 100);
95
+
96
+ CommonData commonData = CommonData.newBuilder()
97
+ .callType("POST")
98
+ .callString("https://external-api.com/create")
99
+ .header("Content-Type", "application/json")
100
+ .header("Authorization", "Bearer token")
101
+ .body(body.toJSONString())
102
+ .build();
103
+ HttpResult result = CommonHttpClient.instance().execute(commonData);
104
+ ```
105
+
106
+ ### 下载文件
107
+
108
+ ```java
109
+ CommonData commonData = CommonData.newBuilder()
110
+ .callString("https://external-api.com/file/download")
111
+ .callType("GET")
112
+ .build();
113
+ RkhdBlob blob = CommonHttpClient.instance().downBlob(commonData);
114
+ String fileName = blob.getFileName();
115
+ byte[] fileContent = blob.getBytes();
116
+ ```
117
+
118
+ ### 限制
119
+
120
+ - 单个脚本中调用最大 **50 次**
121
+ - 入参最大值 **15 MB**
122
+ - HTTP 默认超时 **10 秒**
123
+
124
+ ---
125
+
126
+ ## 3. 向销售易系统发起 HTTP 请求(RkhdHttpClient)
127
+
128
+ ```java
129
+ import com.rkhd.platform.sdk.http.RkhdHttpClient;
130
+ import com.rkhd.platform.sdk.http.RkhdHttpData;
131
+
132
+ RkhdHttpClient client = RkhdHttpClient.instance();
133
+
134
+ // GET 请求
135
+ RkhdHttpData getData = RkhdHttpData.newBuilder()
136
+ .callString("/rest/data/v2/query")
137
+ .callType("GET")
138
+ .build();
139
+ String response = client.execute(getData);
140
+
141
+ // POST 请求(上传文件)
142
+ Map<String, Object> formData = new HashMap<>();
143
+ RkhdBlob blob = new RkhdBlob();
144
+ blob.setFileName("文件名.格式");
145
+ blob.setBytes(fileBytes);
146
+ formData.put("files", blob);
147
+ formData.put("isImage", false);
148
+ formData.put("needFileId", true);
149
+
150
+ RkhdHttpData postData = RkhdHttpData.newBuilder()
151
+ .callString("/rest/file/v2.0/file/batch")
152
+ .callType("POST")
153
+ .formData(formData)
154
+ .build();
155
+ postData.putHeader("Content-Type", "multipart/form-data");
156
+ client.execute(postData);
157
+ ```
158
+
159
+ ---
160
+
161
+ ## 4. 异步脚本(FutureTask)
162
+
163
+ ```java
164
+ import com.rkhd.platform.sdk.async.FutureTaskService;
165
+
166
+ // 在同步脚本中调用异步任务
167
+ FutureTaskService.instance().submit(
168
+ "other.{company}.{project}.async.MyAsyncTask",
169
+ "参数字符串"
170
+ );
171
+ ```
172
+
173
+ 异步任务实现类:
174
+
175
+ ```java
176
+ package other.{company}.{project}.async;
177
+
178
+ import com.rkhd.platform.sdk.async.FutureTask;
179
+ import com.rkhd.platform.sdk.log.Logger;
180
+ import com.rkhd.platform.sdk.log.LoggerFactory;
181
+
182
+ public class MyAsyncTask implements FutureTask {
183
+ private Logger log = LoggerFactory.getLogger();
184
+
185
+ @Override
186
+ public void execute(String params) {
187
+ log.info("异步任务开始执行, 参数: " + params);
188
+ // 业务逻辑
189
+ }
190
+ }
191
+ ```
192
+
193
+ ### 限制
194
+
195
+ - 同步脚本中可调用 FutureTask 最大 **50 次**
196
+ - 异步脚本中不可调用 FutureTask
197
+ - 异步脚本最大运行时长 **90 秒**
198
+
199
+ ---
200
+
201
+ ## 5. 租户级缓存(CacheService)
202
+
203
+ ```java
204
+ import com.rkhd.platform.sdk.cache.CacheService;
205
+
206
+ CacheService cache = CacheService.instance();
207
+
208
+ // 写入缓存
209
+ cache.put("myKey", "myValue");
210
+
211
+ // 读取缓存
212
+ String value = cache.get("myKey");
213
+
214
+ // 删除缓存
215
+ cache.remove("myKey");
216
+ ```
217
+
218
+ ### 限制
219
+
220
+ - 最大缓存大小 **200 KB**
221
+ - 最大缓存 key 数量 **64 个**
222
+ - 同步脚本调用次数 **50 次**
223
+ - 异步脚本调用次数 **100 次**
224
+
225
+ ---
226
+
227
+ ## 6. 批量数据处理(BatchJobService)
228
+
229
+ ```java
230
+ import com.rkhd.platform.sdk.batch.BatchJobService;
231
+
232
+ // 创建批量作业
233
+ BatchJobService.instance().submit(
234
+ "other.{company}.{project}.batch.MyBatchJob",
235
+ "SELECT id, name FROM account",
236
+ 200 // 每批次处理条数
237
+ );
238
+ ```
239
+
240
+ ### 限制
241
+
242
+ - 执行批次取值范围 **50 ~ 500 条**
243
+ - 单个 BatchJob 最大数据量 **100,000 条**
244
+ - 每日最大数据量 **1,000,000 条**
245
+
246
+ ---
247
+
248
+ ## 7. 日志接口(Logger)
249
+
250
+ ```java
251
+ import com.rkhd.platform.sdk.log.Logger;
252
+ import com.rkhd.platform.sdk.log.LoggerFactory;
253
+
254
+ private static final Logger LOG = LoggerFactory.getLogger();
255
+
256
+ LOG.debug("调试信息");
257
+ LOG.info("普通信息");
258
+ LOG.warn("警告信息");
259
+ LOG.error("错误信息");
260
+ ```
261
+
262
+ 日志查看路径:系统后台 → 日志审计 → 业务逻辑代码日志 → 文本输出
263
+
264
+ ---
265
+
266
+ ## 8. 自定义配置(CustomConfigService)
267
+
268
+ ```java
269
+ import com.rkhd.platform.sdk.service.CustomConfigService;
270
+
271
+ CustomConfigService configService = CustomConfigService.instance();
272
+ Map<String, String> configs = configService.getConfigSet("configSetApiName");
273
+ String value = configs.get("configItemKey");
274
+ ```
275
+
276
+ ---
277
+
278
+ ## 9. 发送邮件(EmailService)
279
+
280
+ ```java
281
+ import com.rkhd.platform.sdk.email.EmailService;
282
+ import com.rkhd.platform.sdk.email.EmailBody;
283
+
284
+ EmailService emailService = EmailService.instance();
285
+ EmailBody body = EmailBody.newBuilder()
286
+ .subject("邮件主题")
287
+ .body("邮件内容")
288
+ .smtpHost("smtp.163.com")
289
+ .smtpPort("465")
290
+ .isSSL(true)
291
+ .receiverList(Arrays.asList("receiver@example.com"))
292
+ .senderUserName("sender@163.com")
293
+ .senderUserPass("password")
294
+ .build();
295
+ emailService.sendEmail(body);
296
+ ```
297
+
298
+ ---
299
+
300
+ ## 10. 分布式锁(LockService)
301
+
302
+ ```java
303
+ import com.rkhd.platform.sdk.lock.LockService;
304
+
305
+ LockService lockService = LockService.instance();
306
+
307
+ // 获取锁
308
+ boolean locked = lockService.tryLock("lockKey", 10); // 超时10秒
309
+
310
+ if (locked) {
311
+ try {
312
+ // 业务逻辑
313
+ } finally {
314
+ lockService.unlock("lockKey");
315
+ }
316
+ }
317
+ ```
318
+
319
+ ### 限制
320
+
321
+ - 最大同时存在 key 数量 **5000 个**
322
+
323
+ ---
324
+
325
+ ## 11. 数据加解密(SymmetricCryptoUtil)
326
+
327
+ ```java
328
+ import com.rkhd.platform.sdk.crypto.SymmetricCryptoUtil;
329
+
330
+ // AES 加密
331
+ String encrypted = SymmetricCryptoUtil.encrypt("明文数据", "密钥");
332
+
333
+ // AES 解密
334
+ String decrypted = SymmetricCryptoUtil.decrypt(encrypted, "密钥");
335
+ ```
336
+
337
+ ---
338
+
339
+ ## 12. 获取环境信息(ScriptRuntimeContext)
340
+
341
+ ```java
342
+ import com.rkhd.platform.sdk.context.ScriptRuntimeContext;
343
+
344
+ ScriptRuntimeContext context = ScriptRuntimeContext.instance();
345
+ // 获取当前租户 ID、用户 ID 等运行时环境信息
346
+ ```
@@ -0,0 +1,188 @@
1
+ # 技能包:计划作业开发
2
+
3
+ ## 概述
4
+
5
+ 计划作业用于执行定时批量任务,如定时数据同步、定时清理、定时报表生成等。
6
+
7
+ ## 适用场景
8
+
9
+ - 定时从外部系统同步数据到 CRM
10
+ - 定时清理过期数据
11
+ - 定时生成统计报表
12
+ - 定时发送通知
13
+
14
+ ## 代码模板
15
+
16
+ ### 计划作业实现类
17
+
18
+ ```java
19
+ package other.{company}.{project};
20
+
21
+ import com.rkhd.platform.sdk.log.Logger;
22
+ import com.rkhd.platform.sdk.log.LoggerFactory;
23
+ import com.rkhd.platform.sdk.model.QueryResult;
24
+ import com.rkhd.platform.sdk.model.XObject;
25
+ import com.rkhd.platform.sdk.schedule.ScheduleJob;
26
+ import com.rkhd.platform.sdk.service.XObjectService;
27
+
28
+ import java.util.List;
29
+
30
+ /**
31
+ * 计划作业模板
32
+ * 定时执行的批量任务
33
+ */
34
+ public class MyScheduleJob implements ScheduleJob {
35
+
36
+ private static final Logger LOG = LoggerFactory.getLogger();
37
+
38
+ @Override
39
+ public void execute() {
40
+ LOG.info("计划作业开始执行");
41
+
42
+ try {
43
+ // === 在此编写定时任务逻辑 ===
44
+
45
+ // 示例:查询需要处理的数据
46
+ String sql = "SELECT id, name FROM customEntity1__c WHERE status__c = '待处理' LIMIT 100";
47
+ QueryResult result = XObjectService.instance().query(sql);
48
+ List<XObject> records = result.getRecords();
49
+
50
+ if (records != null && records.size() > 0) {
51
+ LOG.info("待处理数据条数: " + records.size());
52
+
53
+ for (XObject record : records) {
54
+ try {
55
+ // 处理每条数据
56
+ record.setAttribute("status__c", "已处理");
57
+ XObjectService.instance().update(record);
58
+ } catch (Exception e) {
59
+ LOG.error("处理数据失败, ID: " + record.getId() + ", 错误: " + e.getMessage());
60
+ }
61
+ }
62
+ } else {
63
+ LOG.info("没有待处理的数据");
64
+ }
65
+
66
+ LOG.info("计划作业执行完成");
67
+
68
+ } catch (Exception e) {
69
+ LOG.error("计划作业执行异常: " + e.getMessage());
70
+ }
71
+ }
72
+ }
73
+ ```
74
+
75
+ ### 带外部系统同步的计划作业
76
+
77
+ ```java
78
+ package other.{company}.{project};
79
+
80
+ import com.alibaba.fastjson.JSON;
81
+ import com.alibaba.fastjson.JSONArray;
82
+ import com.alibaba.fastjson.JSONObject;
83
+ import com.rkhd.platform.sdk.http.CommonData;
84
+ import com.rkhd.platform.sdk.http.CommonHttpClient;
85
+ import com.rkhd.platform.sdk.http.HttpResult;
86
+ import com.rkhd.platform.sdk.log.Logger;
87
+ import com.rkhd.platform.sdk.log.LoggerFactory;
88
+ import com.rkhd.platform.sdk.model.XObject;
89
+ import com.rkhd.platform.sdk.schedule.ScheduleJob;
90
+ import com.rkhd.platform.sdk.service.MetadataService;
91
+ import com.rkhd.platform.sdk.service.XObjectService;
92
+
93
+ /**
94
+ * 定时同步外部数据的计划作业
95
+ */
96
+ public class SyncScheduleJob implements ScheduleJob {
97
+
98
+ private static final Logger LOG = LoggerFactory.getLogger();
99
+
100
+ @Override
101
+ public void execute() {
102
+ LOG.info("数据同步计划作业开始执行");
103
+
104
+ try {
105
+ // 1. 从外部系统获取数据
106
+ CommonData commonData = CommonData.newBuilder()
107
+ .callType("GET")
108
+ .callString("https://external-api.com/data/list")
109
+ .header("Authorization", "Bearer external_token")
110
+ .build();
111
+ HttpResult httpResult = CommonHttpClient.instance().execute(commonData);
112
+ String response = httpResult.getResult();
113
+
114
+ // 2. 解析数据
115
+ JSONObject jsonResponse = JSON.parseObject(response);
116
+ JSONArray dataList = jsonResponse.getJSONArray("data");
117
+
118
+ if (dataList == null || dataList.size() == 0) {
119
+ LOG.info("外部系统无新数据");
120
+ return;
121
+ }
122
+
123
+ LOG.info("获取到外部数据条数: " + dataList.size());
124
+
125
+ // 3. 写入 CRM 系统
126
+ for (int i = 0; i < dataList.size(); i++) {
127
+ JSONObject item = dataList.getJSONObject(i);
128
+ try {
129
+ // 根据实际对象创建数据
130
+ // XObject xObject = new CustomEntity1__c();
131
+ // xObject.setAttribute("name", item.getString("name"));
132
+ // xObject.setAttribute("entityType",
133
+ // MetadataService.instance().getBusiType(
134
+ // xObject.getApiKey(), "defaultBusiType").getId());
135
+ // XObjectService.instance().insert(xObject);
136
+ } catch (Exception e) {
137
+ LOG.error("同步数据失败: " + e.getMessage());
138
+ }
139
+ }
140
+
141
+ LOG.info("数据同步计划作业执行完成");
142
+
143
+ } catch (Exception e) {
144
+ LOG.error("数据同步异常: " + e.getMessage());
145
+ }
146
+ }
147
+ }
148
+ ```
149
+
150
+ ## 配置文件模板
151
+
152
+ scriptTrigger.xml:
153
+
154
+ ```xml
155
+ <?xml version="1.0" encoding="utf-8"?>
156
+ <configs>
157
+ <config>
158
+ <scheduleJob>
159
+ <class>other.{company}.{project}.job.MyScheduleJob</class>
160
+ </scheduleJob>
161
+ <scheduleJob>
162
+ <class>other.{company}.{project}.job.SyncScheduleJob</class>
163
+ </scheduleJob>
164
+ </config>
165
+ </configs>
166
+ ```
167
+
168
+ ## 配置并启用计划作业
169
+
170
+ 1. 上传代码包并启用
171
+ 2. 进入系统后台 → 开发 → 计划作业
172
+ 3. 新建计划作业,选择对应的 Class
173
+ 4. 设置执行频率(最小间隔 15 分钟)
174
+ 5. 启用计划作业
175
+
176
+ ## 查看执行情况
177
+
178
+ - 系统后台 → 开发 → 计划作业 → 查看执行日志
179
+ - 系统后台 → 日志审计 → 业务逻辑代码日志
180
+
181
+ ## 限制
182
+
183
+ | 限制项 | 值 |
184
+ |--------|-----|
185
+ | 最多同时启用 | 30 个/租户 |
186
+ | 自定义类型最多启用 | 5 个/租户 |
187
+ | 最小执行间隔 | 15 分钟 |
188
+ | 异步脚本最大运行时长 | 90 秒 |