sks-maximo-utils 1.0.0 → 1.0.1

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 CHANGED
@@ -37,6 +37,7 @@ import {
37
37
  importMaxObject,
38
38
  importMaxPresentation,
39
39
  importMaxDomain,
40
+ importMaxAutoKey,
40
41
  loadConfig,
41
42
  logger
42
43
  } from 'sks-maximo-utils';
@@ -52,6 +53,9 @@ importMaxPresentation({ fileName: "SCREENSXML/test.xml", logname: "应用" });
52
53
 
53
54
  // 导入域配置
54
55
  importMaxDomain({ fileName: "DBDOMAINJSON/domain.json", logname: "域" });
56
+
57
+ // 导入 AutoKey 配置
58
+ importMaxAutoKey({ fileName: "AUTOKEYJSON/autokey.json", logname: "自动编码" });
55
59
  ```
56
60
 
57
61
  ## 配置文件
@@ -100,6 +104,7 @@ importMaxDomain({ fileName: "DBDOMAINJSON/domain.json", logname: "域" });
100
104
  | importMaxObject | 导入 Maximo 对象配置(JSON) |
101
105
  | importMaxPresentation | 导入应用 XML 配置 |
102
106
  | importMaxDomain | 导入域配置 |
107
+ | importMaxAutoKey | 导入 AutoKey 配置 |
103
108
 
104
109
  ### 其他方法
105
110
 
package/TASK/TASK01.md CHANGED
@@ -10,4 +10,10 @@ nodeutils 目录是我用来编写 js 类的脚本进行更新maximo表结构等
10
10
  配置中的 filePath 我想在配置中去掉,获取node执行的目录
11
11
 
12
12
 
13
- 参考 E:\devwork\ideawork\maximo91_soloncode\nodetasks\0626001.js
13
+ 参考 E:\devwork\ideawork\maximo91_soloncode\nodetasks\0626001.js
14
+
15
+
16
+ # TASK02
17
+ 加了个 /api/script/SKS_DEPLOY_AUTOKEY?_langcode=ZH 接口
18
+
19
+ 帮我加方法,这个接口是添加 autokey 用的
package/index.js CHANGED
@@ -3,5 +3,5 @@ export { loadConfig, getConfig, getWorkDir } from './nodeutils/config.js';
3
3
  export { default as logger } from './nodeutils/logger.js';
4
4
  export { default as request } from './nodeutils/requestHttp.js';
5
5
  export { readFileContent, readJsonFile, readXmlFile, fileExists } from './nodeutils/fileUtils.js';
6
- export { importMaxObject, importMaxPresentation, importMaxDomain } from './nodeutils/maximoTools.js';
6
+ export { importMaxObject, importMaxPresentation, importMaxDomain, importMaxAutoKey } from './nodeutils/maximoTools.js';
7
7
  export { sendMockData, sendMockDataBatch, sendPOMockData, sendPOMockDataBatch, sendRlImportMockDataBatch } from './nodeutils/mockdataTools.js';
@@ -203,4 +203,65 @@ export async function importMaxDomain({fileName, logname}) {
203
203
  }
204
204
  return false
205
205
  }
206
+ }
207
+
208
+
209
+ /**
210
+ * 导入Maximo AutoKey配置
211
+ * @param {Object} options - 配置选项
212
+ * @param {string} options.fileName - 配置文件名(JSON或XML)
213
+ * @param {string} options.logname - 日志打印名称
214
+ * @returns {Promise<boolean>} 是否导入成功
215
+ */
216
+ export async function importMaxAutoKey({fileName, logname}) {
217
+ if(!logname||logname===""||logname===null){
218
+ logname = fileName
219
+ }
220
+ try {
221
+ let fileContent = null;
222
+ fileContent = readFileContent(fileName);
223
+
224
+ if (!fileContent) {
225
+ logger.error(`[${logname}]文件读取失败: ${fileName}`);
226
+ return false;
227
+ }
228
+
229
+ logger.info(`[${logname}]成功读取文件: ${fileName}`);
230
+ logger.info(`[${logname}]文件大小: ${fileContent.length} 字节`);
231
+ logger.info(`[${logname}]准备导入autokey: ${logname || '未指定'}`);
232
+
233
+ logger.info(`[${logname}]开始发送请求...`);
234
+ const response = await request({
235
+ url: '/api/script/SKS_DEPLOY_AUTOKEY',
236
+ method: 'post',
237
+ params: {
238
+ develop: true,
239
+ _langcode: 'zh',
240
+ },
241
+ data: fileContent
242
+ })
243
+
244
+ logger.info(`[${logname}]收到响应`);
245
+ logger.info(`[${logname}]响应类型:`, typeof response);
246
+ logger.info(`[${logname}]响应内容:`, response);
247
+
248
+ if (response !== null && response !== undefined) {
249
+ logger.warn(`[${logname}]导入成功`)
250
+ return true
251
+ } else {
252
+ logger.error(`[${logname}]导入失败,响应为空或null`)
253
+ logger.error(`[${logname}]响应值:`, response)
254
+ return false
255
+ }
256
+ } catch (error) {
257
+ logger.error(`[${logname}]请求出错:`, error.message)
258
+ if (error.response) {
259
+ // 服务器返回了错误状态码
260
+ } else if (error.request) {
261
+ logger.error(`[${logname}]请求已发出但无响应`)
262
+ } else {
263
+ logger.error(`[${logname}]错误详情:`, error)
264
+ }
265
+ return false
266
+ }
206
267
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sks-maximo-utils",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Maximo helper tools for updating table structures and data",
5
5
  "type": "module",
6
6
  "main": "index.js",