tango-app-api-store-builder 1.0.0-beta-15 → 1.0.0-beta-16
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/package.json
CHANGED
|
@@ -1064,6 +1064,11 @@ export async function scan( req, res ) {
|
|
|
1064
1064
|
|
|
1065
1065
|
export async function scanv1( req, res ) {
|
|
1066
1066
|
try {
|
|
1067
|
+
if ( !req.body.floorId ) return res.sendError( 'Floor id is required', 400 );
|
|
1068
|
+
|
|
1069
|
+
if ( !req.body.fixtureId ) return res.sendError( 'Fixture id is required', 400 );
|
|
1070
|
+
|
|
1071
|
+
if ( !req.body.rfId ) return res.sendError( 'RFID is required', 400 );
|
|
1067
1072
|
const fixture = await storeFixtureService.findOne(
|
|
1068
1073
|
{ _id: new mongoose.Types.ObjectId( req.body.fixtureId ) },
|
|
1069
1074
|
{ storeId: 1, storeName: 1, planoId: '$_id', productResolutionLevel: 1 },
|
|
@@ -1071,13 +1076,10 @@ export async function scanv1( req, res ) {
|
|
|
1071
1076
|
|
|
1072
1077
|
if ( !fixture ) return res.sendError( 'No data found', 204 );
|
|
1073
1078
|
|
|
1074
|
-
|
|
1075
|
-
if ( !req.body.floorId ) return res.sendError( 'Floor id is required', 400 );
|
|
1076
|
-
|
|
1077
|
-
if ( !req.body.fixtureId ) return res.sendError( 'Fixture id is required', 400 );
|
|
1079
|
+
const currentDate = new Date( dayjs().format( 'YYYY-MM-DD' ) );
|
|
1078
1080
|
|
|
1079
|
-
if ( !req.body.rfId ) return res.sendError( 'RFID is required', 400 );
|
|
1080
1081
|
|
|
1082
|
+
if ( fixture.productResolutionLevel === 'L1' ) {
|
|
1081
1083
|
const mappingQuery = {
|
|
1082
1084
|
planoId: req.body.planoId,
|
|
1083
1085
|
floorId: req.body.floorId,
|
|
@@ -1087,8 +1089,6 @@ export async function scanv1( req, res ) {
|
|
|
1087
1089
|
|
|
1088
1090
|
const productMapping = await planoMappingService.findOne( mappingQuery );
|
|
1089
1091
|
|
|
1090
|
-
const currentDate = new Date( dayjs().format( 'YYYY-MM-DD' ) );
|
|
1091
|
-
|
|
1092
1092
|
if ( !productMapping ) {
|
|
1093
1093
|
const misplacedQuery = {
|
|
1094
1094
|
planoId: req.body.planoId,
|
|
@@ -1107,7 +1107,22 @@ export async function scanv1( req, res ) {
|
|
|
1107
1107
|
let misplacedProductDetails = await planoProductService.findOne( { _id: misplacedProductMapping.toObject().productId } );
|
|
1108
1108
|
|
|
1109
1109
|
await planoComplianceService.updateOne( { ...misplacedQuery, date: currentDate }, complianceData );
|
|
1110
|
-
|
|
1110
|
+
|
|
1111
|
+
const [ totalProducts, scannedProducts, misplacedProducts, missingProducts ] = await Promise.all( [
|
|
1112
|
+
planoMappingService.count( { fixtureId: fixture.toObject()._id } ),
|
|
1113
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate } ),
|
|
1114
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'misplaced' } ),
|
|
1115
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'missing' } ),
|
|
1116
|
+
] );
|
|
1117
|
+
|
|
1118
|
+
const metrics = {
|
|
1119
|
+
total: totalProducts,
|
|
1120
|
+
scanned: scannedProducts,
|
|
1121
|
+
misplaced: misplacedProducts,
|
|
1122
|
+
missing: missingProducts,
|
|
1123
|
+
};
|
|
1124
|
+
|
|
1125
|
+
return res.sendSuccess( { data: { ...misplacedProductMapping.toObject(), ...( misplacedProductDetails ? misplacedProductDetails?.toObject() : {} ) }, metrics: metrics, status: false } );
|
|
1111
1126
|
}
|
|
1112
1127
|
|
|
1113
1128
|
const complianceData = { ...productMapping.toObject(), planoMappingId: productMapping.toObject()._id, compliance: 'proper' };
|
|
@@ -1117,14 +1132,22 @@ export async function scanv1( req, res ) {
|
|
|
1117
1132
|
|
|
1118
1133
|
await planoComplianceService.updateOne( { ...mappingQuery, date: currentDate }, complianceData );
|
|
1119
1134
|
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1135
|
+
const [ totalProducts, scannedProducts, misplacedProducts, missingProducts ] = await Promise.all( [
|
|
1136
|
+
planoMappingService.count( { fixtureId: fixture.toObject()._id } ),
|
|
1137
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate } ),
|
|
1138
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'misplaced' } ),
|
|
1139
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'missing' } ),
|
|
1140
|
+
] );
|
|
1141
|
+
|
|
1142
|
+
const metrics = {
|
|
1143
|
+
total: totalProducts,
|
|
1144
|
+
scanned: scannedProducts,
|
|
1145
|
+
misplaced: misplacedProducts,
|
|
1146
|
+
missing: missingProducts,
|
|
1147
|
+
};
|
|
1127
1148
|
|
|
1149
|
+
return res.sendSuccess( { data: { ...productMapping.toObject(), ...( productDetails ? productDetails?.toObject() : {} ) }, metrics: metrics, status: true } );
|
|
1150
|
+
} else if ( fixture.productResolutionLevel === 'L2' ) {
|
|
1128
1151
|
if ( !req.body.shelfId && req.body.rfId ) {
|
|
1129
1152
|
const shelf = await fixtureShelfService.findOne( { planoId: req.body.planoId, floorId: req.body.floorId, fixtureId: req.body.fixtureId, rfId: req.body.rfId } );
|
|
1130
1153
|
if ( !shelf ) return res.sendError( 'No matching shelf for the rfId', 400 );
|
|
@@ -1143,8 +1166,6 @@ export async function scanv1( req, res ) {
|
|
|
1143
1166
|
|
|
1144
1167
|
const productMapping = await planoMappingService.findOne( mappingQuery );
|
|
1145
1168
|
|
|
1146
|
-
const currentDate = new Date( dayjs().format( 'YYYY-MM-DD' ) );
|
|
1147
|
-
|
|
1148
1169
|
if ( !productMapping ) {
|
|
1149
1170
|
const misplacedQuery = {
|
|
1150
1171
|
planoId: req.body.planoId,
|
|
@@ -1167,7 +1188,23 @@ export async function scanv1( req, res ) {
|
|
|
1167
1188
|
let misplacedProductDetails = await planoProductService.findOne( { _id: misplacedProductMapping.toObject().productId } );
|
|
1168
1189
|
|
|
1169
1190
|
await planoComplianceService.updateOne( { ...misplacedQuery, date: currentDate }, complianceData );
|
|
1170
|
-
|
|
1191
|
+
|
|
1192
|
+
|
|
1193
|
+
const [ totalProducts, scannedProducts, misplacedProducts, missingProducts ] = await Promise.all( [
|
|
1194
|
+
planoMappingService.count( { fixtureId: fixture.toObject()._id } ),
|
|
1195
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate } ),
|
|
1196
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'misplaced' } ),
|
|
1197
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'missing' } ),
|
|
1198
|
+
] );
|
|
1199
|
+
|
|
1200
|
+
const metrics = {
|
|
1201
|
+
total: totalProducts,
|
|
1202
|
+
scanned: scannedProducts,
|
|
1203
|
+
misplaced: misplacedProducts,
|
|
1204
|
+
missing: missingProducts,
|
|
1205
|
+
};
|
|
1206
|
+
|
|
1207
|
+
return res.sendSuccess( { data: { ...misplacedProductMapping.toObject(), ...( misplacedProductDetails ? misplacedProductDetails?.toObject() : {} ) }, metrics: metrics, status: false } );
|
|
1171
1208
|
}
|
|
1172
1209
|
|
|
1173
1210
|
const complianceData = { ...productMapping.toObject(), planoMappingId: productMapping.toObject()._id, compliance: 'proper' };
|
|
@@ -1177,14 +1214,22 @@ export async function scanv1( req, res ) {
|
|
|
1177
1214
|
|
|
1178
1215
|
await planoComplianceService.updateOne( { ...mappingQuery, date: currentDate }, complianceData );
|
|
1179
1216
|
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1217
|
+
const [ totalProducts, scannedProducts, misplacedProducts, missingProducts ] = await Promise.all( [
|
|
1218
|
+
planoMappingService.count( { fixtureId: fixture.toObject()._id } ),
|
|
1219
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate } ),
|
|
1220
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'misplaced' } ),
|
|
1221
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'missing' } ),
|
|
1222
|
+
] );
|
|
1223
|
+
|
|
1224
|
+
const metrics = {
|
|
1225
|
+
total: totalProducts,
|
|
1226
|
+
scanned: scannedProducts,
|
|
1227
|
+
misplaced: misplacedProducts,
|
|
1228
|
+
missing: missingProducts,
|
|
1229
|
+
};
|
|
1187
1230
|
|
|
1231
|
+
return res.sendSuccess( { data: { ...productMapping.toObject(), ...( productDetails ? productDetails?.toObject() : {} ) }, metrics: metrics, status: true } );
|
|
1232
|
+
} else if ( fixture.productResolutionLevel === 'L3' ) {
|
|
1188
1233
|
if ( !req.body.shelfId && req.body.rfId ) {
|
|
1189
1234
|
const shelf = await fixtureShelfService.findOne( { planoId: req.body.planoId, floorId: req.body.floorId, fixtureId: req.body.fixtureId, rfId: req.body.rfId } );
|
|
1190
1235
|
if ( !shelf ) return res.sendError( 'No matching shelf for the rfId', 400 );
|
|
@@ -1203,8 +1248,6 @@ export async function scanv1( req, res ) {
|
|
|
1203
1248
|
|
|
1204
1249
|
const productMapping = await planoMappingService.findOne( mappingQuery );
|
|
1205
1250
|
|
|
1206
|
-
const currentDate = new Date( dayjs().format( 'YYYY-MM-DD' ) );
|
|
1207
|
-
|
|
1208
1251
|
if ( !productMapping ) {
|
|
1209
1252
|
const shelf = await fixtureShelfService.findOne( { _id: new mongoose.Types.ObjectId( req.body.shelfId ) } );
|
|
1210
1253
|
|
|
@@ -1237,7 +1280,21 @@ export async function scanv1( req, res ) {
|
|
|
1237
1280
|
delete complianceData._id;
|
|
1238
1281
|
|
|
1239
1282
|
await planoComplianceService.updateOne( { ...misplacedQuery, date: currentDate }, complianceData );
|
|
1240
|
-
|
|
1283
|
+
|
|
1284
|
+
const [ totalProducts, scannedProducts, misplacedProducts, missingProducts ] = await Promise.all( [
|
|
1285
|
+
planoMappingService.count( { fixtureId: fixture.toObject()._id } ),
|
|
1286
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate } ),
|
|
1287
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'misplaced' } ),
|
|
1288
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'missing' } ),
|
|
1289
|
+
] );
|
|
1290
|
+
|
|
1291
|
+
const metrics = {
|
|
1292
|
+
total: totalProducts,
|
|
1293
|
+
scanned: scannedProducts,
|
|
1294
|
+
misplaced: misplacedProducts,
|
|
1295
|
+
missing: missingProducts,
|
|
1296
|
+
};
|
|
1297
|
+
return res.sendSuccess( { data: { ...misplacedProductMapping.toObject(), ...( misplacedProductDetails ? misplacedProductDetails?.toObject() : {} ) }, metrics: metrics, status: true } );
|
|
1241
1298
|
} else {
|
|
1242
1299
|
if ( shelf.toObject()._id.toString() !== misplacedProductShelf.toObject()._id.toString() ) {
|
|
1243
1300
|
return res.sendError( 'RFID conflict with section', 400 );
|
|
@@ -1246,7 +1303,20 @@ export async function scanv1( req, res ) {
|
|
|
1246
1303
|
delete complianceData._id;
|
|
1247
1304
|
|
|
1248
1305
|
await planoComplianceService.updateOne( { ...misplacedQuery, date: currentDate }, complianceData );
|
|
1249
|
-
|
|
1306
|
+
const [ totalProducts, scannedProducts, misplacedProducts, missingProducts ] = await Promise.all( [
|
|
1307
|
+
planoMappingService.count( { fixtureId: fixture.toObject()._id } ),
|
|
1308
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate } ),
|
|
1309
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'misplaced' } ),
|
|
1310
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'missing' } ),
|
|
1311
|
+
] );
|
|
1312
|
+
|
|
1313
|
+
const metrics = {
|
|
1314
|
+
total: totalProducts,
|
|
1315
|
+
scanned: scannedProducts,
|
|
1316
|
+
misplaced: misplacedProducts,
|
|
1317
|
+
missing: missingProducts,
|
|
1318
|
+
};
|
|
1319
|
+
return res.sendSuccess( { data: { ...misplacedProductMapping.toObject(), ...( misplacedProductDetails ? misplacedProductDetails?.toObject() : {} ) }, metrics: metrics, status: false } );
|
|
1250
1320
|
}
|
|
1251
1321
|
}
|
|
1252
1322
|
|
|
@@ -1258,14 +1328,23 @@ export async function scanv1( req, res ) {
|
|
|
1258
1328
|
|
|
1259
1329
|
await planoComplianceService.updateOne( { ...mappingQuery, planoMappingId: productMapping.toObject()._id, date: currentDate }, complianceData );
|
|
1260
1330
|
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1331
|
+
const [ totalProducts, scannedProducts, misplacedProducts, missingProducts ] = await Promise.all( [
|
|
1332
|
+
planoMappingService.count( { fixtureId: fixture.toObject()._id } ),
|
|
1333
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate } ),
|
|
1334
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'misplaced' } ),
|
|
1335
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'missing' } ),
|
|
1336
|
+
] );
|
|
1337
|
+
|
|
1338
|
+
const metrics = {
|
|
1339
|
+
total: totalProducts,
|
|
1340
|
+
scanned: scannedProducts,
|
|
1341
|
+
misplaced: misplacedProducts,
|
|
1342
|
+
missing: missingProducts,
|
|
1343
|
+
};
|
|
1266
1344
|
|
|
1267
|
-
if ( !req.body.fixtureId ) return res.sendError( 'Fixture id is required', 400 );
|
|
1268
1345
|
|
|
1346
|
+
return res.sendSuccess( { data: { ...productMapping.toObject(), ...( productDetails ? productDetails?.toObject() : {} ) }, metrics: metrics, status: true } );
|
|
1347
|
+
} else if ( fixture.productResolutionLevel === 'L4' ) {
|
|
1269
1348
|
if ( !req.body.shelfId && req.body.rfId ) {
|
|
1270
1349
|
const shelf = await fixtureShelfService.findOne( { planoId: req.body.planoId, floorId: req.body.floorId, fixtureId: req.body.fixtureId, rfId: req.body.rfId } );
|
|
1271
1350
|
if ( !shelf ) return res.sendError( 'No matching shelf for the rfId', 400 );
|
|
@@ -1294,8 +1373,6 @@ export async function scanv1( req, res ) {
|
|
|
1294
1373
|
return res.sendSuccess( { shelfId: shelf.toObject()._id } );
|
|
1295
1374
|
}
|
|
1296
1375
|
|
|
1297
|
-
const currentDate = new Date( dayjs().format( 'YYYY-MM-DD' ) );
|
|
1298
|
-
|
|
1299
1376
|
if ( productMapping.toObject().rfId !== req.body.rfId ) {
|
|
1300
1377
|
const complianceData = { ...productMapping.toObject(), planoMappingId: productMapping.toObject()._id, compliance: 'misplaced' };
|
|
1301
1378
|
delete complianceData._id;
|