@plusscommunities/pluss-maintenance-aws 2.1.13 → 2.1.14
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.
|
@@ -9,6 +9,7 @@ const updateRef = require("@plusscommunities/pluss-core-aws/db/common/updateRef"
|
|
|
9
9
|
const indexQuery = require("@plusscommunities/pluss-core-aws/db/common/indexQuery");
|
|
10
10
|
const publishNotifications = require("@plusscommunities/pluss-core-aws/db/notifications/publishNotifications");
|
|
11
11
|
const getRef = require("@plusscommunities/pluss-core-aws/db/common/getRef");
|
|
12
|
+
const getString = require("@plusscommunities/pluss-core-aws/db/strings/getString");
|
|
12
13
|
const { values } = require("../../values.config");
|
|
13
14
|
|
|
14
15
|
class ArchibusStrategy extends IntegrationStrategy {
|
|
@@ -23,6 +24,7 @@ class ArchibusStrategy extends IntegrationStrategy {
|
|
|
23
24
|
|
|
24
25
|
this.statusMap = config.StatusMap;
|
|
25
26
|
this.siteMap = config.SiteMap ?? {};
|
|
27
|
+
this.buildingCodes = [];
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
/**
|
|
@@ -61,10 +63,48 @@ class ArchibusStrategy extends IntegrationStrategy {
|
|
|
61
63
|
*/
|
|
62
64
|
createRequest = async (request, mockResponse = null) => {
|
|
63
65
|
const logId = log("Archibus:CreateRequest", "Start", request);
|
|
64
|
-
|
|
66
|
+
|
|
67
|
+
let siteId = this.siteMap[request.site];
|
|
68
|
+
let buildingCode = null;
|
|
69
|
+
if (request.room) {
|
|
70
|
+
if (this.buildingCodes.length === 0) {
|
|
71
|
+
this.buildingCodes = await getString(
|
|
72
|
+
getRowId(request.site, `${values.serviceKey}buildingcodes`),
|
|
73
|
+
"plussSpace"
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
const building = this.buildingCodes.find((b) => {
|
|
77
|
+
const address = request.room.toLowerCase();
|
|
78
|
+
const search = b.SearchString.toLowerCase();
|
|
79
|
+
const name = b.BuildingName.toLowerCase();
|
|
80
|
+
return address.includes(search) || address.includes(name);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
if (building?.SiteCode) siteId = building.SiteCode.toString();
|
|
84
|
+
buildingCode = building?.BuildingCode;
|
|
85
|
+
}
|
|
65
86
|
if (!siteId) return false;
|
|
66
87
|
|
|
67
88
|
try {
|
|
89
|
+
const data = {
|
|
90
|
+
prob_type: "1.ON-SITE|1. MAINTENANCE",
|
|
91
|
+
requestor: "PLUSS",
|
|
92
|
+
description: `${request.title}${
|
|
93
|
+
_.isEmpty(request.description) ? "" : `\n\n${request.description}`
|
|
94
|
+
}${_.isEmpty(request.room) ? "" : `\n\nLocation: ${request.room}`}${
|
|
95
|
+
_.isEmpty(request.userName) ? "" : `\n\nName: ${request.userName}`
|
|
96
|
+
}${_.isEmpty(request.phone) ? "" : `\n\nPhone: ${request.phone}`}${
|
|
97
|
+
_.isEmpty(request.type) ? "" : `\n\nJob Type: ${request.type}`
|
|
98
|
+
}${
|
|
99
|
+
_.isEmpty(request.images)
|
|
100
|
+
? ""
|
|
101
|
+
: `\n\nImages: ${request.images.join("\n")}`
|
|
102
|
+
}`,
|
|
103
|
+
site_id: siteId,
|
|
104
|
+
};
|
|
105
|
+
if (buildingCode) data.bl_id = buildingCode;
|
|
106
|
+
log("Archibus:CreateRequest", "Request", data, logId);
|
|
107
|
+
|
|
68
108
|
const response =
|
|
69
109
|
mockResponse ??
|
|
70
110
|
(await axios({
|
|
@@ -76,29 +116,9 @@ class ArchibusStrategy extends IntegrationStrategy {
|
|
|
76
116
|
"Content-Type": "application/json",
|
|
77
117
|
Host: this.host,
|
|
78
118
|
},
|
|
79
|
-
data
|
|
80
|
-
prob_type: "1.ON-SITE|1. MAINTENANCE",
|
|
81
|
-
requestor: "PLUSS",
|
|
82
|
-
description: `${request.title}${
|
|
83
|
-
_.isEmpty(request.description) ? "" : `\n\n${request.description}`
|
|
84
|
-
}${_.isEmpty(request.room) ? "" : `\n\nLocation: ${request.room}`}${
|
|
85
|
-
_.isEmpty(request.userName) ? "" : `\n\nName: ${request.userName}`
|
|
86
|
-
}${_.isEmpty(request.phone) ? "" : `\n\nPhone: ${request.phone}`}${
|
|
87
|
-
_.isEmpty(request.type) ? "" : `\n\nJob Type: ${request.type}`
|
|
88
|
-
}${
|
|
89
|
-
_.isEmpty(request.images)
|
|
90
|
-
? ""
|
|
91
|
-
: `\n\nImages: ${request.images.join("\n")}`
|
|
92
|
-
}`,
|
|
93
|
-
site_id: siteId,
|
|
94
|
-
},
|
|
119
|
+
data,
|
|
95
120
|
}));
|
|
96
|
-
log(
|
|
97
|
-
"Archibus:CreateRequest",
|
|
98
|
-
"Response",
|
|
99
|
-
{ data: response.data, siteId },
|
|
100
|
-
logId
|
|
101
|
-
);
|
|
121
|
+
log("Archibus:CreateRequest", "Response", response.data, logId);
|
|
102
122
|
|
|
103
123
|
// Save the ID to external entities for future reference
|
|
104
124
|
await updateRef("externalentities", {
|
package/package-lock.json
CHANGED
package/package.json
CHANGED