tango-app-api-store-builder 1.0.0-beta-14 → 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
|
@@ -577,6 +577,7 @@ export async function storeFixturesv1( req, res ) {
|
|
|
577
577
|
return {
|
|
578
578
|
...fixture.toObject(),
|
|
579
579
|
status: complianceCount === 0 ? '' : complianceCount === productCount ? 'complete' : 'incomplete',
|
|
580
|
+
productCount: productCount,
|
|
580
581
|
};
|
|
581
582
|
} ),
|
|
582
583
|
);
|
|
@@ -606,14 +607,18 @@ export async function storeFixturesv1( req, res ) {
|
|
|
606
607
|
return {
|
|
607
608
|
...fixture.toObject(),
|
|
608
609
|
status: complianceCount === 0 ? '' : complianceCount === productCount ? 'complete' : 'incomplete',
|
|
610
|
+
productCount: productCount,
|
|
609
611
|
};
|
|
610
612
|
} ),
|
|
611
613
|
);
|
|
612
614
|
|
|
615
|
+
const productCount = await planoMappingService.count( { floorId: floor._id } );
|
|
616
|
+
|
|
613
617
|
return {
|
|
614
618
|
...floor.toObject(),
|
|
615
619
|
layoutPolygon: layoutPolygonWithFixtures,
|
|
616
620
|
centerFixture: centerFixturesWithStatus,
|
|
621
|
+
productCount: productCount,
|
|
617
622
|
};
|
|
618
623
|
} ),
|
|
619
624
|
);
|
|
@@ -1059,6 +1064,11 @@ export async function scan( req, res ) {
|
|
|
1059
1064
|
|
|
1060
1065
|
export async function scanv1( req, res ) {
|
|
1061
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 );
|
|
1062
1072
|
const fixture = await storeFixtureService.findOne(
|
|
1063
1073
|
{ _id: new mongoose.Types.ObjectId( req.body.fixtureId ) },
|
|
1064
1074
|
{ storeId: 1, storeName: 1, planoId: '$_id', productResolutionLevel: 1 },
|
|
@@ -1066,13 +1076,10 @@ export async function scanv1( req, res ) {
|
|
|
1066
1076
|
|
|
1067
1077
|
if ( !fixture ) return res.sendError( 'No data found', 204 );
|
|
1068
1078
|
|
|
1069
|
-
|
|
1070
|
-
if ( !req.body.floorId ) return res.sendError( 'Floor id is required', 400 );
|
|
1071
|
-
|
|
1072
|
-
if ( !req.body.fixtureId ) return res.sendError( 'Fixture id is required', 400 );
|
|
1079
|
+
const currentDate = new Date( dayjs().format( 'YYYY-MM-DD' ) );
|
|
1073
1080
|
|
|
1074
|
-
if ( !req.body.rfId ) return res.sendError( 'RFID is required', 400 );
|
|
1075
1081
|
|
|
1082
|
+
if ( fixture.productResolutionLevel === 'L1' ) {
|
|
1076
1083
|
const mappingQuery = {
|
|
1077
1084
|
planoId: req.body.planoId,
|
|
1078
1085
|
floorId: req.body.floorId,
|
|
@@ -1082,8 +1089,6 @@ export async function scanv1( req, res ) {
|
|
|
1082
1089
|
|
|
1083
1090
|
const productMapping = await planoMappingService.findOne( mappingQuery );
|
|
1084
1091
|
|
|
1085
|
-
const currentDate = new Date( dayjs().format( 'YYYY-MM-DD' ) );
|
|
1086
|
-
|
|
1087
1092
|
if ( !productMapping ) {
|
|
1088
1093
|
const misplacedQuery = {
|
|
1089
1094
|
planoId: req.body.planoId,
|
|
@@ -1102,7 +1107,22 @@ export async function scanv1( req, res ) {
|
|
|
1102
1107
|
let misplacedProductDetails = await planoProductService.findOne( { _id: misplacedProductMapping.toObject().productId } );
|
|
1103
1108
|
|
|
1104
1109
|
await planoComplianceService.updateOne( { ...misplacedQuery, date: currentDate }, complianceData );
|
|
1105
|
-
|
|
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 } );
|
|
1106
1126
|
}
|
|
1107
1127
|
|
|
1108
1128
|
const complianceData = { ...productMapping.toObject(), planoMappingId: productMapping.toObject()._id, compliance: 'proper' };
|
|
@@ -1112,14 +1132,22 @@ export async function scanv1( req, res ) {
|
|
|
1112
1132
|
|
|
1113
1133
|
await planoComplianceService.updateOne( { ...mappingQuery, date: currentDate }, complianceData );
|
|
1114
1134
|
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
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
|
+
};
|
|
1122
1148
|
|
|
1149
|
+
return res.sendSuccess( { data: { ...productMapping.toObject(), ...( productDetails ? productDetails?.toObject() : {} ) }, metrics: metrics, status: true } );
|
|
1150
|
+
} else if ( fixture.productResolutionLevel === 'L2' ) {
|
|
1123
1151
|
if ( !req.body.shelfId && req.body.rfId ) {
|
|
1124
1152
|
const shelf = await fixtureShelfService.findOne( { planoId: req.body.planoId, floorId: req.body.floorId, fixtureId: req.body.fixtureId, rfId: req.body.rfId } );
|
|
1125
1153
|
if ( !shelf ) return res.sendError( 'No matching shelf for the rfId', 400 );
|
|
@@ -1138,8 +1166,6 @@ export async function scanv1( req, res ) {
|
|
|
1138
1166
|
|
|
1139
1167
|
const productMapping = await planoMappingService.findOne( mappingQuery );
|
|
1140
1168
|
|
|
1141
|
-
const currentDate = new Date( dayjs().format( 'YYYY-MM-DD' ) );
|
|
1142
|
-
|
|
1143
1169
|
if ( !productMapping ) {
|
|
1144
1170
|
const misplacedQuery = {
|
|
1145
1171
|
planoId: req.body.planoId,
|
|
@@ -1162,7 +1188,23 @@ export async function scanv1( req, res ) {
|
|
|
1162
1188
|
let misplacedProductDetails = await planoProductService.findOne( { _id: misplacedProductMapping.toObject().productId } );
|
|
1163
1189
|
|
|
1164
1190
|
await planoComplianceService.updateOne( { ...misplacedQuery, date: currentDate }, complianceData );
|
|
1165
|
-
|
|
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 } );
|
|
1166
1208
|
}
|
|
1167
1209
|
|
|
1168
1210
|
const complianceData = { ...productMapping.toObject(), planoMappingId: productMapping.toObject()._id, compliance: 'proper' };
|
|
@@ -1172,14 +1214,22 @@ export async function scanv1( req, res ) {
|
|
|
1172
1214
|
|
|
1173
1215
|
await planoComplianceService.updateOne( { ...mappingQuery, date: currentDate }, complianceData );
|
|
1174
1216
|
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
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
|
+
};
|
|
1182
1230
|
|
|
1231
|
+
return res.sendSuccess( { data: { ...productMapping.toObject(), ...( productDetails ? productDetails?.toObject() : {} ) }, metrics: metrics, status: true } );
|
|
1232
|
+
} else if ( fixture.productResolutionLevel === 'L3' ) {
|
|
1183
1233
|
if ( !req.body.shelfId && req.body.rfId ) {
|
|
1184
1234
|
const shelf = await fixtureShelfService.findOne( { planoId: req.body.planoId, floorId: req.body.floorId, fixtureId: req.body.fixtureId, rfId: req.body.rfId } );
|
|
1185
1235
|
if ( !shelf ) return res.sendError( 'No matching shelf for the rfId', 400 );
|
|
@@ -1198,8 +1248,6 @@ export async function scanv1( req, res ) {
|
|
|
1198
1248
|
|
|
1199
1249
|
const productMapping = await planoMappingService.findOne( mappingQuery );
|
|
1200
1250
|
|
|
1201
|
-
const currentDate = new Date( dayjs().format( 'YYYY-MM-DD' ) );
|
|
1202
|
-
|
|
1203
1251
|
if ( !productMapping ) {
|
|
1204
1252
|
const shelf = await fixtureShelfService.findOne( { _id: new mongoose.Types.ObjectId( req.body.shelfId ) } );
|
|
1205
1253
|
|
|
@@ -1213,6 +1261,7 @@ export async function scanv1( req, res ) {
|
|
|
1213
1261
|
};
|
|
1214
1262
|
const misplacedProductMapping = await planoMappingService.findOne( misplacedQuery );
|
|
1215
1263
|
|
|
1264
|
+
|
|
1216
1265
|
if ( !misplacedProductMapping ) {
|
|
1217
1266
|
const shelf = await fixtureShelfService.findOne( misplacedQuery );
|
|
1218
1267
|
if ( !shelf ) {
|
|
@@ -1221,6 +1270,7 @@ export async function scanv1( req, res ) {
|
|
|
1221
1270
|
return res.sendSuccess( { shelfId: shelf.toObject()._id } );
|
|
1222
1271
|
}
|
|
1223
1272
|
|
|
1273
|
+
|
|
1224
1274
|
const misplacedProductShelf = await fixtureShelfService.findOne( { _id: misplacedProductMapping.toObject().shelfId } );
|
|
1225
1275
|
|
|
1226
1276
|
let misplacedProductDetails = await planoProductService.findOne( { _id: misplacedProductMapping.toObject().productId } );
|
|
@@ -1230,16 +1280,47 @@ export async function scanv1( req, res ) {
|
|
|
1230
1280
|
delete complianceData._id;
|
|
1231
1281
|
|
|
1232
1282
|
await planoComplianceService.updateOne( { ...misplacedQuery, date: currentDate }, complianceData );
|
|
1233
|
-
|
|
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 } );
|
|
1234
1298
|
} else {
|
|
1299
|
+
if ( shelf.toObject()._id.toString() !== misplacedProductShelf.toObject()._id.toString() ) {
|
|
1300
|
+
return res.sendError( 'RFID conflict with section', 400 );
|
|
1301
|
+
}
|
|
1235
1302
|
const complianceData = { ...misplacedProductMapping.toObject(), planoMappingId: misplacedProductMapping.toObject()._id, compliance: 'misplaced' };
|
|
1236
1303
|
delete complianceData._id;
|
|
1237
1304
|
|
|
1238
1305
|
await planoComplianceService.updateOne( { ...misplacedQuery, date: currentDate }, complianceData );
|
|
1239
|
-
|
|
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 } );
|
|
1240
1320
|
}
|
|
1241
1321
|
}
|
|
1242
1322
|
|
|
1323
|
+
|
|
1243
1324
|
const complianceData = { ...productMapping.toObject(), compliance: 'proper' };
|
|
1244
1325
|
delete complianceData._id;
|
|
1245
1326
|
|
|
@@ -1247,14 +1328,23 @@ export async function scanv1( req, res ) {
|
|
|
1247
1328
|
|
|
1248
1329
|
await planoComplianceService.updateOne( { ...mappingQuery, planoMappingId: productMapping.toObject()._id, date: currentDate }, complianceData );
|
|
1249
1330
|
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
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
|
+
};
|
|
1255
1344
|
|
|
1256
|
-
if ( !req.body.fixtureId ) return res.sendError( 'Fixture id is required', 400 );
|
|
1257
1345
|
|
|
1346
|
+
return res.sendSuccess( { data: { ...productMapping.toObject(), ...( productDetails ? productDetails?.toObject() : {} ) }, metrics: metrics, status: true } );
|
|
1347
|
+
} else if ( fixture.productResolutionLevel === 'L4' ) {
|
|
1258
1348
|
if ( !req.body.shelfId && req.body.rfId ) {
|
|
1259
1349
|
const shelf = await fixtureShelfService.findOne( { planoId: req.body.planoId, floorId: req.body.floorId, fixtureId: req.body.fixtureId, rfId: req.body.rfId } );
|
|
1260
1350
|
if ( !shelf ) return res.sendError( 'No matching shelf for the rfId', 400 );
|
|
@@ -1283,8 +1373,6 @@ export async function scanv1( req, res ) {
|
|
|
1283
1373
|
return res.sendSuccess( { shelfId: shelf.toObject()._id } );
|
|
1284
1374
|
}
|
|
1285
1375
|
|
|
1286
|
-
const currentDate = new Date( dayjs().format( 'YYYY-MM-DD' ) );
|
|
1287
|
-
|
|
1288
1376
|
if ( productMapping.toObject().rfId !== req.body.rfId ) {
|
|
1289
1377
|
const complianceData = { ...productMapping.toObject(), planoMappingId: productMapping.toObject()._id, compliance: 'misplaced' };
|
|
1290
1378
|
delete complianceData._id;
|
|
@@ -1353,14 +1441,13 @@ export async function updateMissing( req, res ) {
|
|
|
1353
1441
|
}
|
|
1354
1442
|
|
|
1355
1443
|
const mappingCompliance = await planoComplianceService.findOne( {
|
|
1356
|
-
|
|
1357
|
-
shelfPosition: mapping.shelfPosition,
|
|
1444
|
+
planoMappingId: mapping._id,
|
|
1358
1445
|
date: currentDate,
|
|
1359
1446
|
} );
|
|
1360
1447
|
|
|
1361
1448
|
if ( !mappingCompliance ) {
|
|
1362
1449
|
delete mapping.toObject()._id;
|
|
1363
|
-
planoComplianceService.create( { ...mapping.toObject(), compliance: 'missing', date: currentDate } );
|
|
1450
|
+
planoComplianceService.create( { ...mapping.toObject(), planoMappingId: mapping._id, compliance: 'missing', date: currentDate } );
|
|
1364
1451
|
}
|
|
1365
1452
|
|
|
1366
1453
|
return {
|