cloudcc-cli 1.9.6 → 1.9.8

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 (35) hide show
  1. package/README.md +14 -0
  2. package/java/com/cloudcc/core/CCObject.java +73 -0
  3. package/{core → java/com/cloudcc}/core/CCService.java +139 -334
  4. package/java/com/cloudcc/core/CCTrigger.java +38 -0
  5. package/{core/core/CCTrigger.java → java/com/cloudcc/core/CCTriggerDemo.java} +4 -2
  6. package/java/com/cloudcc/core/CCTriggerHandler.java +17 -0
  7. package/java/com/cloudcc/core/SendEmail.java +23 -0
  8. package/java/com/cloudcc/core/ServiceResult.java +36 -0
  9. package/java/com/cloudcc/core/TimeUtil.java +11 -0
  10. package/java/com/cloudcc/core/Tool.java +270 -0
  11. package/{core → java/com/cloudcc}/core/TriggerInvoker.java +21 -17
  12. package/java/com/cloudcc/core/UserInfo.java +57 -0
  13. package/lib/fastjson-1.2.83.jar +0 -0
  14. package/lib/jackson-databind-2.13.3.jar +0 -0
  15. package/lib/log4j-1.2.17.jar +0 -0
  16. package/lib/reflections-0.9.12.jar +0 -0
  17. package/lib/slf4j-api-1.7.32.jar +0 -0
  18. package/lib/slf4j-log4j12-1.7.32.jar +0 -0
  19. package/package.json +3 -2
  20. package/pom.xml +100 -0
  21. package/src/classes/create.js +19 -2
  22. package/template/index.js +38 -1
  23. package/template/lib/ccopenapi-0.0.1.jar +0 -0
  24. package/template/lib/fastjson-1.2.83.jar +0 -0
  25. package/template/lib/reflections-0.9.12.jar +0 -0
  26. package/core/core/CCObject.java +0 -48
  27. package/core/core/CCTriggerHandler.java +0 -15
  28. package/core/core/PeakSvc.java +0 -8
  29. package/core/core/ServiceResult.java +0 -35
  30. package/core/core/UserInfo.java +0 -45
  31. /package/{core → java/com/cloudcc}/core/DevLogger.java +0 -0
  32. /package/{core → java/com/cloudcc}/core/OperatationEnum.java +0 -0
  33. /package/{core → java/com/cloudcc}/core/PeakInterf.java +0 -0
  34. /package/{core → java/com/cloudcc}/core/TriggerMethod.java +0 -0
  35. /package/{core → java/com/cloudcc}/core/TriggerTimeEnum.java +0 -0
@@ -1,132 +1,49 @@
1
1
  package com.cloudcc.core;
2
2
 
3
-
4
- import com.alibaba.fastjson.JSONArray;
5
- import com.alibaba.fastjson.JSONObject;
6
- import com.fasterxml.jackson.databind.ObjectMapper;
7
-
8
- import java.io.*;
3
+ import java.io.BufferedReader;
4
+ import java.io.BufferedWriter;
5
+ import java.io.IOException;
6
+ import java.io.InputStream;
7
+ import java.io.InputStreamReader;
8
+ import java.io.OutputStreamWriter;
9
9
  import java.net.HttpURLConnection;
10
10
  import java.net.URL;
11
11
  import java.nio.charset.StandardCharsets;
12
- import java.util.*;
12
+ import java.util.ArrayList;
13
+ import java.util.HashMap;
14
+ import java.util.List;
15
+ import java.util.Map;
13
16
 
14
- import org.slf4j.Logger;
15
- import org.slf4j.LoggerFactory;
17
+ import com.alibaba.fastjson.JSONArray;
18
+ import com.alibaba.fastjson.JSONObject;
16
19
 
17
- /**
18
- * @author T.han
19
- * @date 2023/8/17 15:09
20
- * @project CloudccNewPro
21
- * @Description //TODO
22
- */
23
20
  public class CCService {
24
-
25
21
  public static UserInfo userInfo;
26
22
  public String ACCESSTOKEN;
27
23
  public String path;
28
24
  public String URL;
29
- protected Map<String,Object> record_new;
30
- protected Map<String,Object> record_old;
25
+ protected Map<String, Object> record_new;
26
+ protected Map<String, Object> record_old;
27
+ public Map<String, String> Config = Tool.getConfig();
31
28
  public ServiceResult trigger = new ServiceResult();
32
29
  public String objectApiName;
33
- ResourceBundle prb = PropertyResourceBundle.getBundle("application");// 获取配置文件;
34
- String orgId = prb.getString("orgId");
35
- Logger logger = LoggerFactory.getLogger(this.getClass());
30
+ String orgId = Config.get("orgId");
36
31
 
37
32
  public CCService(UserInfo userInfo) {
38
- this.URL=getOrgApiUrl();
39
- this.ACCESSTOKEN = getToken();
40
- this.path = URL+ "/openApi/common";
41
- }
42
-
43
- /**
44
- * @return java.lang.String
45
- * @Description //TODO 获取公有云api网关地址
46
- * @Author T.han
47
- * @Date 2023/8/17 15:48
48
- * @Param
49
- **/
50
- public String getOrgApiUrl() {
51
- String apiUrl = "";
52
- String url = prb.getString("url");
53
- if(!"".equals(url)){
54
- String parUrl = url + "?scope=cloudccCRM&orgId=" + orgId;
55
- String relStr = sendGet(parUrl);
56
- JSONObject relObj = new JSONObject();
57
- relObj = JSONObject.parseObject(relStr);
58
- String result = relObj.getString("result");
59
- if ("true".equals(result)) {
60
- apiUrl = relObj.getString("orgapi_address");
61
- }
62
- }else {
63
- apiUrl="https://quectelcrm-dev.quectel.com/ccdomaingateway/apisvc-interface";
64
- }
65
-
66
- return apiUrl;
33
+ this.URL = Config.get("apiSvc");
34
+ this.ACCESSTOKEN = Config.get("token");
35
+ this.path = URL + "/openApi/common";
67
36
  }
68
37
 
69
- /**
70
- * @return java.lang.String
71
- * @Description //TODO 获取token
72
- * @Author T.han
73
- * @Date 2023/8/17 16:10
74
- * @Param
75
- **/
76
- public String getToken() {
77
- String accessToken = "";
78
- String username = prb.getString("username");
79
- String safetyMark = prb.getString("safetyMark");
80
- String clientId = prb.getString("clientId");
81
- String secretKey = prb.getString("secretKey");
82
- String grant_type = prb.getString("grant_type");
83
- //拼接 parObj 参数
84
- JSONObject parObj = new JSONObject();
85
- parObj.put("username", username);
86
- parObj.put("safetyMark", safetyMark);
87
- parObj.put("clientId", clientId);
88
- parObj.put("secretKey", secretKey);
89
- parObj.put("orgId", orgId);
90
- parObj.put("grant_type", grant_type);
91
- path= URL+ "/api/cauth/token";
92
- if (!"".equals(path)) {
93
- String relStr = sendPost(path, parObj.toString());
94
- JSONObject relObj = new JSONObject();
95
- relObj = JSONObject.parseObject(relStr);
96
- boolean result = relObj.getBoolean("result");
97
- if (result) {
98
- JSONObject data = (JSONObject)relObj.get("data");
99
- if (data != null && data.containsKey("accessToken")) {
100
- accessToken = relObj.getJSONObject("data").getString("accessToken");
101
- } else {
102
- logger.error("CCService.getToken报错:未获取到accessToken");
103
- }
104
- } else {
105
- String returnInfo = relObj.getString("returnInfo");
106
- logger.error("CCService.getToken报错:" + returnInfo);
107
- }
108
- } else {
109
- logger.error("CCService.getToken报错:未获取到网关地址");
110
- }
111
- return accessToken;
112
- }
113
-
114
- /**
115
- * @return java.util.List<com.cloudcc.newxm.util.CCObject>
116
- * @Description //TODO cquery 查询不加条件
117
- * @Author T.han
118
- * @Date 2023/8/17 16:38
119
- * @Param apiName 对象名
120
- **/
38
+ @SuppressWarnings("rawtypes")
121
39
  public List<CCObject> cquery(String apiName) {
122
40
  List<CCObject> orst = new ArrayList<CCObject>();
123
- //拼接 parObj 参数
124
41
  JSONObject parObj = new JSONObject();
125
- parObj.put("serviceName", "cquery"); //服务名
126
- parObj.put("objectApiName", apiName); //对象名
127
- parObj.put("expressions", "1=1"); //查询条件
128
- parObj.put("isAddDelete", "false"); //是否包含删除数据 true:包含 false:不包含
129
- parObj.put("fields", "");//查询字段 不填写时sql按 * 返回
42
+ parObj.put("serviceName", "cquery");
43
+ parObj.put("objectApiName", apiName);
44
+ parObj.put("expressions", "1=1");
45
+ parObj.put("isAddDelete", "false");
46
+ parObj.put("fields", "");
130
47
 
131
48
  String relStr = CCPost(path, parObj.toString());
132
49
  JSONObject relObj = new JSONObject();
@@ -146,23 +63,15 @@ public class CCService {
146
63
  return orst;
147
64
  }
148
65
 
149
- /**
150
- * @return java.util.List<com.cloudcc.newxm.util.CCObject>
151
- * @Description //TODO cquery 查询方法
152
- * @Author T.han
153
- * @Date 2023/8/17 16:42
154
- * @Param apiName 对象名
155
- * @Param expression 查询条件
156
- **/
66
+ @SuppressWarnings("rawtypes")
157
67
  public List<CCObject> cquery(String apiName, String expression) {
158
68
  List<CCObject> orst = new ArrayList<CCObject>();
159
- //拼接 parObj 参数
160
69
  JSONObject parObj = new JSONObject();
161
- parObj.put("serviceName", "cquery"); //服务名
162
- parObj.put("objectApiName", apiName); //对象名
163
- parObj.put("expressions", expression); //查询条件
164
- parObj.put("isAddDelete", "false"); //是否包含删除数据 true:包含 false:不包含
165
- parObj.put("fields", "");//查询字段 不填写时sql按 * 返回
70
+ parObj.put("serviceName", "cquery");
71
+ parObj.put("objectApiName", apiName);
72
+ parObj.put("expressions", expression);
73
+ parObj.put("isAddDelete", "false");
74
+ parObj.put("fields", "");
166
75
 
167
76
  String relStr = CCPost(path, parObj.toString());
168
77
  JSONObject relObj = new JSONObject();
@@ -182,30 +91,20 @@ public class CCService {
182
91
  return orst;
183
92
  }
184
93
 
185
- /**
186
- * @return java.util.List<com.cloudcc.newxm.util.CCObject>
187
- * @Description //TODO cqlQuery 查询方法
188
- * @Author T.han
189
- * @Date 2023/8/17 16:41
190
- * @Param apiName 对象名
191
- * @Param expression 查询sql
192
- **/
94
+ @SuppressWarnings("rawtypes")
193
95
  public List<CCObject> cqlQuery(String apiName, String expression) {
194
96
  List<CCObject> orst = new ArrayList<CCObject>();
195
- //拼接 parObj 参数
196
97
  JSONObject parObj = new JSONObject();
197
- parObj.put("serviceName", "cqlQueryWithLogInfo"); //服务名
198
- parObj.put("objectApiName", apiName); //对象名
199
- parObj.put("expressions", expression); //查询条件
200
- //拼接接口地址
201
- // String path = getOrgApiUrl() + "/openApi/common";
98
+ parObj.put("serviceName", "cqlQueryWithLogInfo");
99
+ parObj.put("objectApiName", apiName);
100
+ parObj.put("expressions", expression);
202
101
  String relStr = CCPost(path, parObj.toString());
203
102
  JSONObject relObj = new JSONObject();
204
103
  relObj = JSONObject.parseObject(relStr);
205
104
  String result = relObj.getString("result");
206
105
  if ("true".equals(result)) {
207
106
  List<Map> rst = relObj.getJSONArray("data").toJavaList(Map.class);
208
- for (Map<String,Object> m : rst) {
107
+ for (Map m : rst) {
209
108
  CCObject co = new CCObject(apiName);
210
109
  for (Object _key : m.keySet()) {
211
110
  String key = (String) _key;
@@ -217,13 +116,6 @@ public class CCService {
217
116
  return orst;
218
117
  }
219
118
 
220
- /**
221
- * @Description //TODO update方法
222
- * @Author T.han
223
- * @Date 2023/8/18 10:02
224
- * @Param cobj
225
- * @return void
226
- **/
227
119
  public void update(CCObject cobj) {
228
120
  JSONArray arry = new JSONArray();
229
121
  JSONObject obj = new JSONObject();
@@ -238,64 +130,56 @@ public class CCService {
238
130
  }
239
131
  arry.add(obj);
240
132
 
241
- //拼接 parObj 参数
242
133
  JSONObject parObj = new JSONObject();
243
- parObj.put("serviceName", "update"); //服务名
244
- parObj.put("objectApiName", objectApiName); //对象名
245
- parObj.put("data", arry.toString()); //查询条件
134
+ parObj.put("serviceName", "update");
135
+ parObj.put("objectApiName", objectApiName);
136
+ parObj.put("data", arry.toString());
246
137
  try {
247
- TriggerInvoker invoker = new TriggerInvoker(userInfo,"update","before");
138
+ TriggerInvoker invoker = new TriggerInvoker(userInfo, "update", "before");
248
139
  invoker.handler(cobj);
249
140
  String relStr = CCPost(path, parObj.toString());
250
141
  JSONObject relObj = JSONObject.parseObject(relStr);
251
142
  boolean result = relObj.getBoolean("result");
252
- if(result){
143
+ if (result) {
253
144
  JSONObject outObj = relObj.getJSONObject("data");
254
- if(outObj.containsKey("ids")){
145
+ if (outObj.containsKey("ids")) {
255
146
  JSONArray outData = outObj.getJSONArray("ids");
256
147
  StringBuilder sb = new StringBuilder();
257
- boolean hasSuccess = false; // 用于跟踪是否有成功处理的条目
258
- for(int i=0;i < outData.size();i++) {
148
+ boolean hasSuccess = false;
149
+ for (int i = 0; i < outData.size(); i++) {
259
150
  JSONObject acc = outData.getJSONObject(i);
260
- if(acc.getBoolean("success")){
151
+ if (acc.getBoolean("success")) {
261
152
  String id = acc.getString("id");
262
153
  if (sb.length() > 0) {
263
154
  sb.append(',');
264
155
  }
265
156
  sb.append(id);
266
157
  hasSuccess = true;
267
- }else{
268
- logger.error("update报错: " + acc.getString("errors"));
158
+ } else {
159
+ System.err.println("update报错: " + acc.getString("errors"));
269
160
  }
270
161
  }
271
162
  if (hasSuccess) {
272
163
  String retIds = sb.toString();
273
- logger.info("update成功: " + retIds);
274
- cobj.put("id",retIds);
275
- invoker = new TriggerInvoker(userInfo,"update","before");
164
+ System.out.println("update成功: " + retIds);
165
+ cobj.put("id", retIds);
166
+ invoker = new TriggerInvoker(userInfo, "update", "before");
276
167
  invoker.handler(cobj);
277
168
  }
278
- }else{
279
- logger.error("update未获取到ids 参数");
169
+ } else {
170
+ System.err.println("update未获取到ids 参数");
280
171
  }
281
172
 
282
- }else{
283
- logger.error("update报错= " + relObj.getString("returnInfo"));
173
+ } else {
174
+ System.err.println("update报错= " + relObj.getString("returnInfo"));
284
175
  }
285
176
 
286
177
  } catch (Exception e) {
287
- e.printStackTrace();
288
- logger.error("update报错= " + e);
178
+ e.printStackTrace();
179
+ System.err.println("update报错= " + e);
289
180
  }
290
181
  }
291
182
 
292
- /**
293
- * @Description //TODO insert 方法
294
- * @Author T.han
295
- * @Date 2023/8/18 10:27
296
- * @Param cobj 新建 json参数
297
- * @return com.cloudcc.newxm.util.ServiceResult 返回新建数据id
298
- **/
299
183
  public ServiceResult insert(CCObject cobj) {
300
184
  ServiceResult sr = new ServiceResult();
301
185
  JSONArray arry = new JSONArray();
@@ -309,46 +193,43 @@ public class CCService {
309
193
  obj.put(_key, values);
310
194
  }
311
195
  }
312
- // cobj.remove("CCObjectAPI");
313
196
  arry.add(obj);
314
- //拼接 parObj 参数
315
197
  JSONObject parObj = new JSONObject();
316
- parObj.put("serviceName", "insert"); //服务名
317
- parObj.put("objectApiName", objectApiName); //对象名
318
- parObj.put("data", arry.toString()); //查询条件
319
- logger.info("parObj = " + parObj);
198
+ parObj.put("serviceName", "insert");
199
+ parObj.put("objectApiName", objectApiName);
200
+ parObj.put("data", arry.toString());
201
+ System.out.println("parObj = " + parObj);
320
202
  try {
321
- //执行触发器
322
- TriggerInvoker invoker = new TriggerInvoker(userInfo,"insert","before");
203
+ TriggerInvoker invoker = new TriggerInvoker(userInfo, "insert", "before");
323
204
  invoker.handler(cobj);
324
205
  String relStr = CCPost(path, parObj.toString());
325
- logger.info("insert_relStr = " + relStr);
206
+ System.out.println("insert_relStr = " + relStr);
326
207
  JSONObject relObj = JSONObject.parseObject(relStr);
327
208
 
328
209
  String result = relObj.getString("result");
329
210
  if ("true".equals(result)) {
330
211
  JSONArray outData = relObj.getJSONObject("data").getJSONArray("ids");
331
212
  StringBuilder sb = new StringBuilder();
332
- for(int i=0;i < outData.size();i++) {
213
+ for (int i = 0; i < outData.size(); i++) {
333
214
  JSONObject acc = outData.getJSONObject(i);
334
- if(acc.getBoolean("success")){
215
+ if (acc.getBoolean("success")) {
335
216
  String id = acc.getString("id");
336
217
  if (sb.length() > 0) {
337
218
  sb.append(',');
338
219
  }
339
220
  sb.append(id);
340
- }else{
341
- logger.error("insert报错: " + acc.getString("errors"));
221
+ } else {
222
+ System.err.println("insert报错: " + acc.getString("errors"));
342
223
  }
343
224
  }
344
225
  String retIds = sb.toString();
345
- sr.put("id",retIds);
346
- cobj.put("id",retIds);
347
- invoker = new TriggerInvoker(userInfo,"insert","after");
226
+ sr.put("id", retIds);
227
+ cobj.put("id", retIds);
228
+ invoker = new TriggerInvoker(userInfo, "insert", "after");
348
229
  invoker.handler(cobj);
349
230
  }
350
231
  } catch (Exception e) {
351
- e.printStackTrace();
232
+ e.printStackTrace();
352
233
  System.out.println("insert报错= " + e);
353
234
  }
354
235
  System.out.println("sr = " + sr);
@@ -356,7 +237,6 @@ public class CCService {
356
237
  }
357
238
 
358
239
  public ServiceResult insert(List<CCObject> datalist) {
359
- // TODO Auto-generated method stub
360
240
  ServiceResult sr = new ServiceResult();
361
241
  JSONArray arry = new JSONArray();
362
242
  JSONObject obj = new JSONObject();
@@ -373,52 +253,43 @@ public class CCService {
373
253
  }
374
254
  arry.add(obj);
375
255
  }
376
- //拼接 parObj 参数
377
256
  JSONObject parObj = new JSONObject();
378
- parObj.put("serviceName", "insert"); //服务名
379
- parObj.put("objectApiName", objectApiName); //对象名
380
- parObj.put("data", arry.toString()); //查询条件
257
+ parObj.put("serviceName", "insert");
258
+ parObj.put("objectApiName", objectApiName);
259
+ parObj.put("data", arry.toString());
381
260
  System.out.println("parObj = " + parObj);
382
261
  try {
383
262
  String relStr = CCPost(path, parObj.toString());
384
- logger.info("insert_relStr = " + relStr);
263
+ System.out.println("insert_relStr = " + relStr);
385
264
  JSONObject relObj = new JSONObject();
386
265
  relObj = JSONObject.parseObject(relStr);
387
266
  String result = relObj.getString("result");
388
267
  if ("true".equals(result)) {
389
268
  JSONArray outData = relObj.getJSONObject("data").getJSONArray("ids");
390
269
  StringBuilder sb = new StringBuilder();
391
- for(int i=0;i < outData.size();i++) {
270
+ for (int i = 0; i < outData.size(); i++) {
392
271
  JSONObject acc = outData.getJSONObject(i);
393
- if(acc.getBoolean("success")){
272
+ if (acc.getBoolean("success")) {
394
273
  String id = acc.getString("id");
395
274
  if (sb.length() > 0) {
396
275
  sb.append(',');
397
276
  }
398
277
  sb.append(id);
399
- }else{
400
- logger.error("insert报错: " + acc.getString("errors"));
278
+ } else {
279
+ System.err.println("insert报错: " + acc.getString("errors"));
401
280
  }
402
281
  }
403
282
  String retIds = sb.toString();
404
- sr.put("id",retIds);
283
+ sr.put("id", retIds);
405
284
  }
406
285
  } catch (Exception e) {
407
- e.printStackTrace();
408
- logger.error("insert报错= " + e);
286
+ e.printStackTrace();
287
+ System.err.println("insert报错= " + e);
409
288
  }
410
289
  System.out.println("sr = " + sr);
411
290
  return sr;
412
291
  }
413
292
 
414
-
415
- /**
416
- * @Description //TODO 删除方法
417
- * @Author T.han
418
- * @Date 2023/8/18 10:38
419
- * @Param cobj 参数数据 {“id”:"a1231111"}
420
- * @return void
421
- **/
422
293
  public void delete(CCObject cobj) {
423
294
  JSONArray arry = new JSONArray();
424
295
  JSONObject obj = new JSONObject();
@@ -432,25 +303,21 @@ public class CCService {
432
303
  }
433
304
  }
434
305
  arry.add(obj);
435
- //拼接 parObj 参数
436
306
  JSONObject parObj = new JSONObject();
437
- parObj.put("serviceName", "delete"); //服务名
438
- parObj.put("objectApiName", objectApiName); //对象名
439
- parObj.put("data", arry.toString()); //查询条件
307
+ parObj.put("serviceName", "delete");
308
+ parObj.put("objectApiName", objectApiName);
309
+ parObj.put("data", arry.toString());
440
310
  System.out.println("parObj = " + parObj);
441
311
  try {
442
- TriggerInvoker invoker = new TriggerInvoker(userInfo,"delete","before");
312
+ TriggerInvoker invoker = new TriggerInvoker(userInfo, "delete", "before");
443
313
  invoker.handler(cobj);
444
- String relStr = CCPost(path, parObj.toString());
445
- invoker = new TriggerInvoker(userInfo,"delete","after");
314
+ invoker = new TriggerInvoker(userInfo, "delete", "after");
446
315
  invoker.handler(cobj);
447
316
  } catch (Exception e) {
448
- // e.printStackTrace();
449
- logger.error("delete报错= " + e);
317
+ System.err.println("delete报错= " + e);
450
318
  }
451
319
  }
452
320
 
453
-
454
321
  public ServiceResult upsert(CCObject cobj) {
455
322
  ServiceResult sr = new ServiceResult();
456
323
  JSONArray arry = new JSONArray();
@@ -465,13 +332,12 @@ public class CCService {
465
332
  }
466
333
  }
467
334
  arry.add(obj);
468
- //拼接 parObj 参数
469
335
  JSONObject parObj = new JSONObject();
470
- parObj.put("serviceName", "upsert"); //服务名
471
- parObj.put("objectApiName", objectApiName); //对象名
472
- parObj.put("data", arry.toString()); //查询条件
336
+ parObj.put("serviceName", "upsert");
337
+ parObj.put("objectApiName", objectApiName);
338
+ parObj.put("data", arry.toString());
473
339
  try {
474
- TriggerInvoker invoker = new TriggerInvoker(userInfo,"upsert","before");
340
+ TriggerInvoker invoker = new TriggerInvoker(userInfo, "upsert", "before");
475
341
  invoker.handler(cobj);
476
342
  String relStr = CCPost(path, parObj.toString());
477
343
  JSONObject relObj = new JSONObject();
@@ -480,33 +346,20 @@ public class CCService {
480
346
  if ("true".equals(result)) {
481
347
  JSONArray outData = relObj.getJSONObject("data").getJSONArray("ids");
482
348
  JSONObject acc = outData.getJSONObject(0);
483
- if(acc.getBoolean("success")){
484
- sr.put("id",acc.getString("id"));
485
- cobj.put("id",acc.getString("id"));
349
+ if (acc.getBoolean("success")) {
350
+ sr.put("id", acc.getString("id"));
351
+ cobj.put("id", acc.getString("id"));
486
352
  }
487
- invoker = new TriggerInvoker(userInfo,"upsert","before");
353
+ invoker = new TriggerInvoker(userInfo, "upsert", "before");
488
354
  invoker.handler(cobj);
489
355
  }
490
356
  } catch (Exception e) {
491
- e.printStackTrace();
357
+ e.printStackTrace();
492
358
  System.out.println("upsert报错= " + e);
493
359
  }
494
360
  return sr;
495
361
  }
496
362
 
497
-
498
-
499
-
500
-
501
- /**
502
- * @Description //TODO post请求
503
- * @Author T.han
504
- * @Date 2023/8/18 10:03
505
- * @Param path 接口地址 http://127.0.0.1/cloudcc/outken
506
- * @Param param 参数 json
507
- * @Param IsToken headers是否添加token false:不添加 true:添加
508
- * @return java.lang.String
509
- **/
510
363
  public String sendPost(String path, String param) {
511
364
  OutputStreamWriter out = null;
512
365
  BufferedReader br = null;
@@ -516,27 +369,19 @@ public class CCService {
516
369
  try {
517
370
  URL url = new URL(path);
518
371
  HttpURLConnection conn = null;
519
- // 打开和URL之间的连接
520
372
  conn = (HttpURLConnection) url.openConnection();
521
- // 发送POST请求必须设置如下两行
522
373
  conn.setDoOutput(true);
523
374
  conn.setDoInput(true);
524
- conn.setRequestMethod("POST"); // POST方法
525
- conn.setConnectTimeout(15 * 1000);// 设置连接超时时间为5秒
526
- conn.setReadTimeout(20 * 1000);// 设置读取超时时间为20秒
527
- String tokens = "";
528
- // 设置通用的请求属性
375
+ conn.setRequestMethod("POST");
376
+ conn.setConnectTimeout(15 * 1000);
377
+ conn.setReadTimeout(20 * 1000);
529
378
  conn.setRequestProperty("Content-Type", "application/json");
530
379
  conn.setRequestProperty("accept", "*/*");
531
380
  conn.connect();
532
- // 获取URLConnection对象对应的输出流
533
381
  out = new OutputStreamWriter(conn.getOutputStream());
534
- // 发送请求参数
535
382
  BufferedWriter bw = new BufferedWriter(out);
536
383
  bw.write(param);
537
- // flush输出流的缓冲
538
384
  bw.flush();
539
- // 定义BufferedReader输入流来读取URL的响应
540
385
  br = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
541
386
  String line;
542
387
  while ((line = br.readLine()) != null) {
@@ -575,28 +420,20 @@ public class CCService {
575
420
  try {
576
421
  URL url = new URL(path);
577
422
  HttpURLConnection conn = null;
578
- // 打开和URL之间的连接
579
423
  conn = (HttpURLConnection) url.openConnection();
580
- // 发送POST请求必须设置如下两行
581
424
  conn.setDoOutput(true);
582
425
  conn.setDoInput(true);
583
- conn.setRequestMethod("POST"); // POST方法
584
- conn.setConnectTimeout(15 * 1000);// 设置连接超时时间为5秒
585
- conn.setReadTimeout(20 * 1000);// 设置读取超时时间为20秒
586
- String tokens = "";
587
- // 设置通用的请求属性
426
+ conn.setRequestMethod("POST");
427
+ conn.setConnectTimeout(15 * 1000);
428
+ conn.setReadTimeout(20 * 1000);
588
429
  conn.setRequestProperty("Content-Type", "application/json");
589
430
  conn.setRequestProperty("accept", "*/*");
590
431
  conn.setRequestProperty("accessToken", ACCESSTOKEN);
591
432
  conn.connect();
592
- // 获取URLConnection对象对应的输出流
593
433
  out = new OutputStreamWriter(conn.getOutputStream());
594
- // 发送请求参数
595
434
  BufferedWriter bw = new BufferedWriter(out);
596
435
  bw.write(param);
597
- // flush输出流的缓冲
598
436
  bw.flush();
599
- // 定义BufferedReader输入流来读取URL的响应
600
437
  br = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
601
438
  String line;
602
439
  while ((line = br.readLine()) != null) {
@@ -626,13 +463,6 @@ public class CCService {
626
463
  return result;
627
464
  }
628
465
 
629
- /**
630
- * @Description //TODO GET请求方法
631
- * @Author T.han
632
- * @Date 2023/8/18 10:06
633
- * @Param path 地址 http://127.0.0.1/cloudcc/outoken?key1=value1&key2=value2
634
- * @return java.lang.String
635
- **/
636
466
  public static String sendGet(String path) {
637
467
  StringBuffer sb = new StringBuffer();
638
468
  String exception = "";
@@ -642,7 +472,7 @@ public class CCService {
642
472
  InputStream is = url.openStream();
643
473
  InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8);
644
474
  BufferedReader br = new BufferedReader(isr);
645
- String line;//读取数据
475
+ String line;
646
476
  while ((line = br.readLine()) != null) {
647
477
  sb.append(line);
648
478
  }
@@ -661,52 +491,32 @@ public class CCService {
661
491
  return result;
662
492
  }
663
493
 
664
- /**
665
- * 获取自定义列表设置
666
- * @param api 接口名称,用于指定获取哪个接口的自定义设置
667
- * @return 返回一个包含自定义设置数据的Map对象
668
- */
669
- public Map<String,Object> getListCustomSetting(String api) {
670
-
671
- // 初始化数据映射对象,用于存放最终返回的数据
672
- Map<String,Object> datMap = new HashMap<String,Object>();
673
-
674
- // 创建参数数组,用于存放调用接口的参数
675
- JSONArray argArray = new JSONArray();
494
+ public Map<String, Object> getListCustomSetting(String api) {
495
+ Map<String, Object> datMap = new HashMap<String, Object>();
496
+ JSONArray argArray = new JSONArray();
676
497
  JSONObject arryStr = new JSONObject();
677
498
  arryStr.put("argType", String.class);
678
499
  arryStr.put("argValue", api);
679
500
  argArray.add(arryStr);
680
501
 
681
502
  JSONObject parObj = new JSONObject();
682
- parObj.put("className", "upsert"); //服务名
683
- parObj.put("methodName", "getListCustomSetting"); //方法名
684
- parObj.put("params", argArray); //查询条件
503
+ parObj.put("className", "upsert");
504
+ parObj.put("methodName", "getListCustomSetting");
505
+ parObj.put("params", argArray);
685
506
  try {
686
507
  String relStr = CCPost(path, parObj.toString());
687
508
  JSONObject.parseObject(relStr);
688
- ObjectMapper objectMapper = new ObjectMapper();
689
- // 将对象描述转换为字符串并添加到结果中
690
- datMap = objectMapper.convertValue(objectMapper, Map.class);
691
509
  } catch (Exception e) {
692
510
  e.printStackTrace();
693
- logger.error("upsert报错= " + e);
511
+ System.err.println("upsert报错= " + e);
694
512
  }
695
513
 
696
514
  return datMap;
697
- }
698
- /**
699
- * 获取自定义设置列表。
700
- * 通过调用指定API和键值,来获取相应的自定义设置数据。
701
- * @author admin
702
- * @Version Created on 2024.4.10
703
- * @param api 要调用的API名称。
704
- * @param key 查询设置列表时使用的键值。
705
- * @return 返回一个包含自定义设置数据的Map对象。如果发生错误,可能返回空或错误信息的Map。
706
- */
707
- public Map<String,Object> getListCustomSetting(String api, String key) {
708
- Map<String,Object> datMap = new HashMap<String,Object>();
709
- JSONArray argArray = new JSONArray();
515
+ }
516
+
517
+ public Map<String, Object> getListCustomSetting(String api, String key) {
518
+ Map<String, Object> datMap = new HashMap<String, Object>();
519
+ JSONArray argArray = new JSONArray();
710
520
 
711
521
  JSONObject apiParam = new JSONObject();
712
522
  apiParam.put("argType", String.class);
@@ -719,25 +529,22 @@ public class CCService {
719
529
  argArray.add(keyParam);
720
530
 
721
531
  JSONObject parObj = new JSONObject();
722
- parObj.put("className", "TCCCustomSetting"); //服务名
723
- parObj.put("methodName", "getListCustomSetting"); //方法名
724
- parObj.put("params", argArray); //查询条件
532
+ parObj.put("className", "TCCCustomSetting");
533
+ parObj.put("methodName", "getListCustomSetting");
534
+ parObj.put("params", argArray);
725
535
 
726
536
  try {
727
537
  String relStr = CCPost(path, parObj.toString());
728
538
  JSONObject.parseObject(relStr);
729
- ObjectMapper objectMapper = new ObjectMapper();
730
- // 将对象描述转换为字符串并添加到结果中
731
- datMap = objectMapper.convertValue(objectMapper, Map.class);
732
539
  } catch (Exception e) {
733
540
  e.printStackTrace();
734
- logger.error("upsert报错= " + e);
541
+ System.err.println("upsert报错= " + e);
735
542
  }
736
543
 
737
544
  return datMap;
738
- }
545
+ }
739
546
 
740
- public Map cqueryForEs(String account, String where, String aTrue, String s) {
547
+ public HashMap<String, Object> cqueryForEs(String account, String where, String aTrue, String s) {
741
548
  return null;
742
549
  }
743
550
 
@@ -746,61 +553,59 @@ public class CCService {
746
553
  }
747
554
 
748
555
  public List<CCObject> cqueryWithRoleRight(String service_record, String s) {
749
- return null;
556
+ return null;
750
557
  }
751
558
 
752
559
  public ServiceResult insert(CCObject reminder, boolean b, boolean b1, boolean b2, boolean b3) {
753
- return null;
754
- }
560
+ return null;
561
+ }
755
562
 
756
- public void addCaseTeam(List<Map> caseteamList, String recordid) {
563
+ public void addCaseTeam(List<HashMap<String, Object>> caseteamList, String recordid) {
757
564
  }
758
565
 
759
- public ServiceResult update(CCObject serv, boolean b, boolean b1, boolean b2, boolean b3) {
566
+ public ServiceResult update(CCObject serv, boolean b, boolean b1, boolean b2, boolean b3) {
760
567
  return null;
761
- }
568
+ }
569
+
762
570
  public ServiceResult insertLt(CCObject in) throws Exception {
763
- // TODO Auto-generated method stub
764
571
  List<CCObject> datalist = new ArrayList<CCObject>();
765
572
  datalist.add(in);
766
573
  insert(datalist);
767
574
  return null;
768
575
  }
769
576
 
770
- public ServiceResult updateLt(CCObject objectData) throws Exception {
771
- // TODO Auto-generated method stub
772
- //不执行触发器
577
+ public ServiceResult updateLt(CCObject objectData) throws Exception {
773
578
  return null;
774
579
  }
775
580
 
776
581
  public void addMicroPost(String string, Object object, Object object2, Object object3, Object object4,
777
- Object object5, Object object6, String string2, String emailSubject, String string3, String stkhid,
778
- String stkhid2) {
779
- // TODO Auto-generated method stub
780
-
582
+ Object object5, Object object6, String string2, String emailSubject, String string3, String stkhid,
583
+ String stkhid2) {
781
584
  }
782
585
 
783
- public String sendEmail(String subject, String htmlBody, String toAddress, String relatedid, String ccaddress, String bccaddress, String attachmentId, String s, String s1) {
586
+ public String sendEmail(String subject, String htmlBody, String toAddress, String relatedid, String ccaddress,
587
+ String bccaddress, String attachmentId, String s, String s1) {
784
588
  return "";
785
589
  }
786
590
 
787
- public String uploadAttachment(Map m){
591
+ public String uploadAttachment(HashMap<String, Object> m) {
788
592
  return null;
789
593
  }
790
594
 
791
595
  public void deleteShareObjectBySql(String account, String s) {
792
596
 
793
597
  }
794
- public List<CCObject> cqueryByFields(String object, String exp, String fileds) {
598
+
599
+ public List<CCObject> cqueryByFields(String object, String exp, String fileds) {
795
600
  return null;
796
- }
601
+ }
797
602
 
798
603
  public String submitForApproval(String id, String s, String s1) {
799
604
  return null;
800
605
  }
801
606
 
802
- public String process(String processType, String tid, String touserId, String comments, String appPath) {
607
+ public String process(String processType, String tid, String touserId, String comments, String appPath) {
803
608
  return null;
804
- }
609
+ }
805
610
 
806
611
  }