@cpzxrobot/sdk 1.2.38 → 1.2.40

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.
@@ -1,10 +1,13 @@
1
1
  import { Cpzxrobot } from "./types";
2
+ import { WarzoneGateway } from "./warzone_gateway";
2
3
 
3
4
  export class CompanyGateway extends Object {
4
5
  context: Cpzxrobot;
6
+ warzone!: WarzoneGateway;
5
7
  constructor(context: Cpzxrobot) {
6
8
  super();
7
9
  this.context = context;
10
+ this.warzone = new WarzoneGateway(context);
8
11
  }
9
12
 
10
13
  async list(pageNo: number, pageSize: number,pid:number, companyName:string) {
package/device_gateway.ts CHANGED
@@ -33,7 +33,7 @@ class DeviceFault {
33
33
  for (let i = 0; i < columns!.length; i++) {
34
34
  const column = columns![i];
35
35
  const value = values[i];
36
-
36
+
37
37
  if (column === 'category') params.category = value;
38
38
  else if (column === 'time') params.time = new Date(value);
39
39
  else if (column === 'resolved') params.resolved = value === 'true';
@@ -41,7 +41,7 @@ class DeviceFault {
41
41
  else if (column === 'value') params.value = value;
42
42
  else if (column === 'message') params.message = value;
43
43
  }
44
-
44
+
45
45
  this.category = params.category;
46
46
  this.time = params.time;
47
47
  this.resolved = params.resolved;
@@ -268,6 +268,13 @@ export class DeviceGateway extends Object {
268
268
  return this.normalFilter.getData(id, args);
269
269
  }
270
270
 
271
+ async info(
272
+ id: number,
273
+ ) {
274
+ let axios = await this.context.ready;
275
+ return axios.get(`/api/v1/device/info/${id}`);
276
+ }
277
+
271
278
  async validate(serialNumbers: string[], type: string = "pywl") {
272
279
  let axios = await this.context.ready;
273
280
  return axios.post(`/api/v2/device/validateSerialNumber`, {
@@ -288,16 +295,16 @@ export class DeviceGateway extends Object {
288
295
  const json = response.data;
289
296
  var faultsData = json.faults as string;
290
297
 
291
- // #group,false,false,true,true,false,false,true,true,true,true,true,true
292
- // #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,boolean,string,string,string,string,string,string
293
- // #default,last,,,,,,,,,,,
294
- // ,result,table,_start,_stop,_time,_value,DeviceId,_field,_measurement,category,field,status
295
- // ,,0,2025-04-20T22:07:43.623582865Z,2025-04-21T04:07:43.623582865Z,2025-04-21T00:27:00Z,false,004a05c1-7b5b-471c-ab68-f583039ddcfe,bool_value,DeviceStatus,离线报警,online,fault
296
- // ,,0,2025-04-20T22:07:43.623582865Z,2025-04-21T04:07:43.623582865Z,2025-04-21T00:30:00Z,true,004a05c1-7b5b-471c-ab68-f583039ddcfe,bool_value,DeviceStatus,离线报警,online,fault
297
- // ,,1,2025-04-20T22:07:43.623582865Z,2025-04-21T04:07:43.623582865Z,2025-04-21T00:27:00Z,false,004a05c1-7b5b-471c-ab68-f583039ddcfe,repeated,DeviceStatus,离线报警,online,fault
298
- // ,,1,2025-04-20T22:07:43.623582865Z,2025-04-21T04:07:43.623582865Z,2025-04-21T00:30:00Z,false,004a05c1-7b5b-471c-ab68-f583039ddcfe,repeated,DeviceStatus,离线报警,online,fault
299
- // ,,2,2025-04-20T22:07:43.623582865Z,2025-04-21T04:07:43.623582865Z,2025-04-21T00:27:00Z,false,004a05c1-7b5b-471c-ab68-f583039ddcfe,resolved,DeviceStatus,离线报警,online,fault
300
- // ,,2,2025-04-20T22:07:43.623582865Z,2025-04-21T04:07:43.623582865Z,2025-04-21T00:30:00Z,true,004a05c1-7b5b-471c-ab68-f583039ddcfe,resolved,DeviceStatus,离线报警,online,fault
298
+ // #group,false,false,true,true,false,false,true,true,true,true,true,true
299
+ // #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,boolean,string,string,string,string,string,string
300
+ // #default,last,,,,,,,,,,,
301
+ // ,result,table,_start,_stop,_time,_value,DeviceId,_field,_measurement,category,field,status
302
+ // ,,0,2025-04-20T22:07:43.623582865Z,2025-04-21T04:07:43.623582865Z,2025-04-21T00:27:00Z,false,004a05c1-7b5b-471c-ab68-f583039ddcfe,bool_value,DeviceStatus,离线报警,online,fault
303
+ // ,,0,2025-04-20T22:07:43.623582865Z,2025-04-21T04:07:43.623582865Z,2025-04-21T00:30:00Z,true,004a05c1-7b5b-471c-ab68-f583039ddcfe,bool_value,DeviceStatus,离线报警,online,fault
304
+ // ,,1,2025-04-20T22:07:43.623582865Z,2025-04-21T04:07:43.623582865Z,2025-04-21T00:27:00Z,false,004a05c1-7b5b-471c-ab68-f583039ddcfe,repeated,DeviceStatus,离线报警,online,fault
305
+ // ,,1,2025-04-20T22:07:43.623582865Z,2025-04-21T04:07:43.623582865Z,2025-04-21T00:30:00Z,false,004a05c1-7b5b-471c-ab68-f583039ddcfe,repeated,DeviceStatus,离线报警,online,fault
306
+ // ,,2,2025-04-20T22:07:43.623582865Z,2025-04-21T04:07:43.623582865Z,2025-04-21T00:27:00Z,false,004a05c1-7b5b-471c-ab68-f583039ddcfe,resolved,DeviceStatus,离线报警,online,fault
307
+ // ,,2,2025-04-20T22:07:43.623582865Z,2025-04-21T04:07:43.623582865Z,2025-04-21T00:30:00Z,true,004a05c1-7b5b-471c-ab68-f583039ddcfe,resolved,DeviceStatus,离线报警,online,fault
301
308
 
302
309
  faultsData = faultsData.replace(/\r/g, "");
303
310
  var arr = faultsData.split("\n");
@@ -320,7 +327,7 @@ export class DeviceGateway extends Object {
320
327
 
321
328
  }
322
329
 
323
-
330
+
324
331
  // 报告设备问题
325
332
  report(id: number, status: number, description: string): Promise<any> {
326
333
  return this.context.ready.then(() => {
@@ -340,7 +347,7 @@ export class DeviceGateway extends Object {
340
347
  get ctrl() {
341
348
  return {
342
349
  // 获取设备控制参数
343
- get: (deviceId: number,type: string, no: any ): Promise<any> => {
350
+ get: (deviceId: number, type: string, no: any): Promise<any> => {
344
351
  return this.context.ready.then(() => {
345
352
  return this.context.axios.get(`/api/v2/device/ctrl/${deviceId}/${type}/${no}`)
346
353
  .then((res) => {
@@ -353,7 +360,7 @@ export class DeviceGateway extends Object {
353
360
  },
354
361
 
355
362
  // 配置设备控制参数
356
- set: (deviceId: number,type: string, no: any,params: any): Promise<any> => {
363
+ set: (deviceId: number, type: string, no: any, params: any): Promise<any> => {
357
364
  return this.context.ready.then(() => {
358
365
  return this.context.axios.post(`/api/v2/device/ctrl/${deviceId}/${type}/${no}`, params)
359
366
  .then((res) => {
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CompanyGateway = void 0;
4
+ const warzone_gateway_1 = require("./warzone_gateway");
4
5
  class CompanyGateway extends Object {
5
6
  constructor(context) {
6
7
  super();
7
8
  this.context = context;
9
+ this.warzone = new warzone_gateway_1.WarzoneGateway(context);
8
10
  }
9
11
  async list(pageNo, pageSize, pid, companyName) {
10
12
  var axios = await this.context.ready;
@@ -188,6 +188,10 @@ class DeviceGateway extends Object {
188
188
  }) {
189
189
  return this.normalFilter.getData(id, args);
190
190
  }
191
+ async info(id) {
192
+ let axios = await this.context.ready;
193
+ return axios.get(`/api/v1/device/info/${id}`);
194
+ }
191
195
  async validate(serialNumbers, type = "pywl") {
192
196
  let axios = await this.context.ready;
193
197
  return axios.post(`/api/v2/device/validateSerialNumber`, {
package/dist/index.js CHANGED
@@ -135,7 +135,7 @@ class Cpzxrobot {
135
135
  return new Promise((resolve, reject) => {
136
136
  const reader = new FileReader();
137
137
  reader.readAsDataURL(blob);
138
- reader.onloadend = () => {
138
+ reader.onloadend = async () => {
139
139
  // @ts-ignoreconst reader = new FileReader();
140
140
  const base64 = reader.result;
141
141
  // @ts-ignore
@@ -230,5 +230,39 @@ class ProjectGateway extends Object {
230
230
  }
231
231
  };
232
232
  }
233
+ get plan() {
234
+ return {
235
+ // 创建计划
236
+ add: (args) => {
237
+ return this.context.ready.then((axios) => {
238
+ return axios.post(`/api/v2/coremde-sale/project/plan/add`, args);
239
+ });
240
+ },
241
+ // 分页获取计划列表
242
+ list: (args) => {
243
+ return this.context.ready.then((axios) => {
244
+ return axios.post(`/api/v2/coremde-sale/project/plan/list`, args);
245
+ });
246
+ },
247
+ // 获取单个计划详情
248
+ get: (id) => {
249
+ return this.context.ready.then((axios) => {
250
+ return axios.get(`/api/v2/coremde-sale/project/plan/get?id=${id}`);
251
+ });
252
+ },
253
+ // 更新计划
254
+ update: (args) => {
255
+ return this.context.ready.then((axios) => {
256
+ return axios.post(`/api/v2/coremde-sale/project/plan/update`, args);
257
+ });
258
+ },
259
+ // 删除计划
260
+ delete: (id) => {
261
+ return this.context.ready.then((axios) => {
262
+ return axios.get(`/api/v2/coremde-sale/project/plan/delete?id=${id}`);
263
+ });
264
+ }
265
+ };
266
+ }
233
267
  }
234
268
  exports.ProjectGateway = ProjectGateway;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WarzoneGateway = void 0;
4
+ class WarzoneGateway extends Object {
5
+ constructor(context) {
6
+ super();
7
+ this.context = context;
8
+ }
9
+ // 创建战区
10
+ add(args) {
11
+ return this.context.ready.then((axios) => {
12
+ return axios.post(`/api/v2/coremde-sale/war-zone/add`, args);
13
+ });
14
+ }
15
+ // 分页获取战区列表
16
+ list(args) {
17
+ return this.context.ready.then((axios) => {
18
+ return axios.post(`/api/v2/coremde-sale/war-zone/list`, args);
19
+ });
20
+ }
21
+ // 获取单个战区详情
22
+ get(id) {
23
+ return this.context.ready.then((axios) => {
24
+ return axios.get(`/api/v2/coremde-sale/war-zone/get?id=${id}`);
25
+ });
26
+ }
27
+ // 更新战区信息
28
+ update(args) {
29
+ return this.context.ready.then((axios) => {
30
+ return axios.post(`/api/v2/coremde-sale/war-zone/update`, args);
31
+ });
32
+ }
33
+ // 删除战区
34
+ delete(id) {
35
+ return this.context.ready.then((axios) => {
36
+ return axios.get(`/api/v2/coremde-sale/war-zone/delete?id=${id}`);
37
+ });
38
+ }
39
+ get manager() {
40
+ return {
41
+ // 指定战区负责人
42
+ add: (args) => {
43
+ return this.context.ready.then((axios) => {
44
+ return axios.post(`/api/v2/coremde-sale/war-zone/manager/add`, args);
45
+ });
46
+ },
47
+ // 修改战区负责人
48
+ update: (args) => {
49
+ return this.context.ready.then((axios) => {
50
+ return axios.get(`/api/v2/coremde-sale/war-zone/manager/update`, {
51
+ params: args
52
+ });
53
+ });
54
+ },
55
+ // 删除战区负责人
56
+ delete: (id) => {
57
+ return this.context.ready.then((axios) => {
58
+ return axios.get(`/api/v2/coremde-sale/war-zone/manager/delete?id=${id}`);
59
+ });
60
+ }
61
+ };
62
+ }
63
+ }
64
+ exports.WarzoneGateway = WarzoneGateway;
package/index.ts CHANGED
@@ -175,7 +175,7 @@ export class Cpzxrobot {
175
175
  return new Promise<void>((resolve, reject) => {
176
176
  const reader = new FileReader();
177
177
  reader.readAsDataURL(blob);
178
- reader.onloadend = () => {
178
+ reader.onloadend = async () => {
179
179
  // @ts-ignoreconst reader = new FileReader();
180
180
  const base64 = reader.result as string;
181
181
  // @ts-ignore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.2.38",
3
+ "version": "1.2.40",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -282,4 +282,61 @@ export class ProjectGateway extends Object {
282
282
  };
283
283
  }
284
284
 
285
+ get plan() {
286
+ return {
287
+ // 创建计划
288
+ add: (args: {
289
+ projectId: number;
290
+ planStartDate: string;
291
+ planEndDate: string;
292
+ departmentId: number;
293
+ projectNodeId: number;
294
+ projectManager: string;
295
+ groupId: number;
296
+ }) => {
297
+ return this.context.ready.then((axios) => {
298
+ return axios.post(`/api/v2/coremde-sale/project/plan/add`, args);
299
+ });
300
+ },
301
+ // 分页获取计划列表
302
+ list: (args: {
303
+ pageNo: number;
304
+ pageSize: number;
305
+ projectId?: number;
306
+ projectNodeId?: number;
307
+ planStartDate?: string;
308
+ planEndDate?: string;
309
+ }) => {
310
+ return this.context.ready.then((axios) => {
311
+ return axios.post(`/api/v2/coremde-sale/project/plan/list`, args);
312
+ });
313
+ },
314
+ // 获取单个计划详情
315
+ get: (id: number) => {
316
+ return this.context.ready.then((axios) => {
317
+ return axios.get(`/api/v2/coremde-sale/project/plan/get?id=${id}`);
318
+ });
319
+ },
320
+ // 更新计划
321
+ update: (args: {
322
+ planStartDate: string;
323
+ planEndDate: string;
324
+ departmentId: number;
325
+ projectNodeId: number;
326
+ projectManager: string;
327
+ id: number;
328
+ }) => {
329
+ return this.context.ready.then((axios) => {
330
+ return axios.post(`/api/v2/coremde-sale/project/plan/update`, args);
331
+ });
332
+ },
333
+ // 删除计划
334
+ delete: (id: number) => {
335
+ return this.context.ready.then((axios) => {
336
+ return axios.get(`/api/v2/coremde-sale/project/plan/delete?id=${id}`);
337
+ });
338
+ }
339
+ };
340
+ }
341
+
285
342
  }
@@ -0,0 +1,96 @@
1
+ import { Cpzxrobot } from "./types";
2
+
3
+ export class WarzoneGateway extends Object {
4
+ context: Cpzxrobot;
5
+
6
+ constructor(context: Cpzxrobot) {
7
+ super();
8
+ this.context = context;
9
+ }
10
+
11
+ // 创建战区
12
+ add(args: {
13
+ groupId: string;
14
+ warZoneName: string;
15
+ areas: Array<{
16
+ areaName: string;
17
+ code: string;
18
+ children: Array<{
19
+ areaName?: string;
20
+ code?: string;
21
+ children?: Array<Record<string, never>>;
22
+ }>;
23
+ }>;
24
+ }) {
25
+ return this.context.ready.then((axios) => {
26
+ return axios.post(`/api/v2/coremde-sale/war-zone/add`, args);
27
+ });
28
+ }
29
+
30
+ // 分页获取战区列表
31
+ list(args: { pageNo: number; pageSize: number }) {
32
+ return this.context.ready.then((axios) => {
33
+ return axios.post(`/api/v2/coremde-sale/war-zone/list`, args);
34
+ });
35
+ }
36
+
37
+ // 获取单个战区详情
38
+ get(id: number) {
39
+ return this.context.ready.then((axios) => {
40
+ return axios.get(`/api/v2/coremde-sale/war-zone/get?id=${id}`);
41
+ });
42
+ }
43
+
44
+ // 更新战区信息
45
+ update(args: {
46
+ warZoneName: string;
47
+ areas: Array<{
48
+ areaId: number;
49
+ areaName: string;
50
+ areaCode: string;
51
+ children: Array<{
52
+ areaId: number;
53
+ areaName: string;
54
+ areaCode: string;
55
+ children?: Array<Record<string, never>>;
56
+ }>;
57
+ }>;
58
+ warZoneId: number;
59
+ }) {
60
+ return this.context.ready.then((axios) => {
61
+ return axios.post(`/api/v2/coremde-sale/war-zone/update`, args);
62
+ });
63
+ }
64
+
65
+ // 删除战区
66
+ delete(id: number) {
67
+ return this.context.ready.then((axios) => {
68
+ return axios.get(`/api/v2/coremde-sale/war-zone/delete?id=${id}`);
69
+ });
70
+ }
71
+
72
+ get manager() {
73
+ return {
74
+ // 指定战区负责人
75
+ add: (args: { warZoneId: number; userId: number }) => {
76
+ return this.context.ready.then((axios) => {
77
+ return axios.post(`/api/v2/coremde-sale/war-zone/manager/add`, args);
78
+ });
79
+ },
80
+ // 修改战区负责人
81
+ update: (args: { id: number; userId: number }) => {
82
+ return this.context.ready.then((axios) => {
83
+ return axios.get(`/api/v2/coremde-sale/war-zone/manager/update`, {
84
+ params: args
85
+ });
86
+ });
87
+ },
88
+ // 删除战区负责人
89
+ delete: (id: number) => {
90
+ return this.context.ready.then((axios) => {
91
+ return axios.get(`/api/v2/coremde-sale/war-zone/manager/delete?id=${id}`);
92
+ });
93
+ }
94
+ };
95
+ }
96
+ }