sks-maximo-utils 1.0.0 → 1.0.3

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
@@ -6,12 +6,12 @@ Maximo 表结构和数据更新工具集。
6
6
 
7
7
  ### 全局安装(CLI 使用)
8
8
  ```bash
9
- npm install -g sks-maximo-utils
9
+ npm install -g shoukaiseki-maximo-utils
10
10
  ```
11
11
 
12
12
  ### 项目中安装(引用使用)
13
13
  ```bash
14
- npm install sks-maximo-utils
14
+ npm install shoukaiseki-maximo-utils
15
15
  ```
16
16
 
17
17
  ## 使用方式
@@ -37,9 +37,10 @@ import {
37
37
  importMaxObject,
38
38
  importMaxPresentation,
39
39
  importMaxDomain,
40
+ importMaxAutoKey,
40
41
  loadConfig,
41
42
  logger
42
- } from 'sks-maximo-utils';
43
+ } from 'shoukaiseki-maximo-utils';
43
44
 
44
45
  // 加载配置(可选,默认 local)
45
46
  loadConfig('local');
@@ -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
 
@@ -120,7 +125,7 @@ npm install
120
125
  npm link
121
126
 
122
127
  # 在其他项目中链接测试
123
- npm link sks-maximo-utils
128
+ npm link shoukaiseki-maximo-utils
124
129
  ```
125
130
 
126
131
  ## License
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
  }
@@ -121,7 +121,21 @@ function createService() {
121
121
  }
122
122
  }, error => {
123
123
  logger.error('[Response Error] 请求错误:', error.message);
124
- logger.debug('[Response Error] 错误对象:', error);
124
+ try{
125
+ if(error){
126
+ logger.debug('[Response Error] 错误对象:', error);
127
+ if (error.data) {
128
+ logger.info('[Response Error] 错误error.data:', error.data);
129
+ }
130
+ if (error.response&&error.response.data) {
131
+ logger.info('[Response Error] 错误error.response.data:', error.response.data);
132
+ if(error.response.data['oslc:Error']&&error.response.data['oslc:Error']['oslc:extendedError']&&error.response.data['oslc:Error']['oslc:extendedError']['oslc:moreInfo']){
133
+ logger.info('[Response Error] 错误error.response.data:', error.response.data['oslc:Error']['oslc:extendedError']['oslc:moreInfo']);
134
+
135
+ }
136
+ }
137
+ }
138
+ }catch(e){}
125
139
 
126
140
  let { message } = error;
127
141
  if (message == "Network Error") {
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.3",
4
4
  "description": "Maximo helper tools for updating table structures and data",
5
5
  "type": "module",
6
6
  "main": "index.js",