tango-app-api-store-builder 1.0.0-beta-26 → 1.0.0-beta-28
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/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { storeBuilderRouter } from './src/routes/storeBuilder.routes.js';
|
|
2
|
-
import {
|
|
2
|
+
import { storeBuilderTaskRouter } from './src/routes/task.routes.js';
|
|
3
3
|
|
|
4
|
-
export { storeBuilderRouter,
|
|
4
|
+
export { storeBuilderRouter, storeBuilderTaskRouter };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-store-builder",
|
|
3
|
-
"version": "1.0.0-beta-
|
|
3
|
+
"version": "1.0.0-beta-28",
|
|
4
4
|
"description": "storeBuilder",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"joi": "^17.13.3",
|
|
24
24
|
"mongodb": "^6.12.0",
|
|
25
25
|
"nodemon": "^3.1.9",
|
|
26
|
-
"tango-api-schema": "^2.2.
|
|
26
|
+
"tango-api-schema": "^2.2.57",
|
|
27
27
|
"tango-app-api-middleware": "^3.1.48",
|
|
28
28
|
"winston": "^3.17.0",
|
|
29
29
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -541,7 +541,7 @@ export async function storeFixturesv1( req, res ) {
|
|
|
541
541
|
|
|
542
542
|
const planograms = await planoService.find(
|
|
543
543
|
{ _id: { $in: planoIds } },
|
|
544
|
-
{ storeId: 1, storeName: 1, planoId: '$_id', productResolutionLevel: 1 },
|
|
544
|
+
{ storeId: 1, storeName: 1, planoId: '$_id', productResolutionLevel: 1, scanType: 1 },
|
|
545
545
|
);
|
|
546
546
|
|
|
547
547
|
if ( !planograms?.length ) return res.sendError( 'No data found', 204 );
|
|
@@ -568,6 +568,15 @@ export async function storeFixturesv1( req, res ) {
|
|
|
568
568
|
|
|
569
569
|
const fixturesWithStatus = await Promise.all(
|
|
570
570
|
fixtures.map( async ( fixture ) => {
|
|
571
|
+
if ( fixture?.imageUrl ) {
|
|
572
|
+
let params = {
|
|
573
|
+
Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
|
|
574
|
+
file_path: fixture.imageUrl,
|
|
575
|
+
};
|
|
576
|
+
fixture.imageUrl = await signedUrl( params );
|
|
577
|
+
} else {
|
|
578
|
+
fixture.imageUrl = '';
|
|
579
|
+
}
|
|
571
580
|
const productCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'product' } );
|
|
572
581
|
|
|
573
582
|
const vmCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'vm' } );
|
|
@@ -827,6 +836,103 @@ export async function fixtureShelfProduct( req, res ) {
|
|
|
827
836
|
}
|
|
828
837
|
}
|
|
829
838
|
|
|
839
|
+
// export async function fixtureShelfProductv1( req, res ) {
|
|
840
|
+
// try {
|
|
841
|
+
// const { planoId, fixtureId } = req.body;
|
|
842
|
+
|
|
843
|
+
// const [ planogram, fixture ] = await Promise.all( [
|
|
844
|
+
// planoService.findOne(
|
|
845
|
+
// { _id: new mongoose.Types.ObjectId( planoId ) },
|
|
846
|
+
// { storeId: 1, storeName: 1, planoId: '$_id', productResolutionLevel: 1 },
|
|
847
|
+
// ),
|
|
848
|
+
// storeFixtureService.findOne( {
|
|
849
|
+
// _id: new mongoose.Types.ObjectId( fixtureId ),
|
|
850
|
+
// } ),
|
|
851
|
+
// ] );
|
|
852
|
+
|
|
853
|
+
// if ( !planogram ) return res.sendError( 'Planogram not found', 204 );
|
|
854
|
+
// if ( !fixture ) return res.sendError( 'Fixture not found', 204 );
|
|
855
|
+
|
|
856
|
+
// const currentDate = new Date( dayjs().format( 'YYYY-MM-DD' ) );
|
|
857
|
+
|
|
858
|
+
// const getProductsAndVms = async ( mappings ) => {
|
|
859
|
+
// const productIds = mappings.map( ( mapping ) => mapping.productId );
|
|
860
|
+
// const [ products, vms ] = await Promise.all( [
|
|
861
|
+
// planoProductService.find( { _id: { $in: productIds }, type: 'product' } ),
|
|
862
|
+
// planoProductService.find( { _id: { $in: productIds }, type: 'vm' } ),
|
|
863
|
+
// ] );
|
|
864
|
+
|
|
865
|
+
// const productMap = new Map( products.map( ( product ) => [ product._id.toString(), product.toObject() ] ) );
|
|
866
|
+
// const vmMap = new Map( vms.map( ( vm ) => [ vm._id.toString(), vm.toObject() ] ) );
|
|
867
|
+
|
|
868
|
+
// const productDetails = await Promise.all(
|
|
869
|
+
// mappings.filter( ( item ) => item.type === 'product' ).map( async ( mapping ) => {
|
|
870
|
+
// const productData = productMap.get( mapping.productId.toString() ) || {};
|
|
871
|
+
// const mappingCompliance = await planoComplianceService.findOne( {
|
|
872
|
+
// planoMappingId: mapping._id,
|
|
873
|
+
// date: currentDate,
|
|
874
|
+
// } );
|
|
875
|
+
// const status = mappingCompliance ? mappingCompliance.compliance : '';
|
|
876
|
+
// return { ...mapping.toObject(), ...productData, status };
|
|
877
|
+
// } ),
|
|
878
|
+
// );
|
|
879
|
+
|
|
880
|
+
// const vmDetails = await Promise.all(
|
|
881
|
+
// mappings.filter( ( item ) => item.type === 'vm' ).map( async ( mapping ) => {
|
|
882
|
+
// const vmData = vmMap.get( mapping.productId.toString() ) || {};
|
|
883
|
+
// return { ...mapping.toObject(), ...vmData };
|
|
884
|
+
// } ),
|
|
885
|
+
// );
|
|
886
|
+
|
|
887
|
+
// return { productDetails, vmDetails };
|
|
888
|
+
// };
|
|
889
|
+
|
|
890
|
+
// if ( fixture.toObject().productResolutionLevel === 'L1' ) {
|
|
891
|
+
// const productMappings = await planoMappingService.find( { fixtureId: new mongoose.Types.ObjectId( fixtureId ) } );
|
|
892
|
+
// const { productDetails, vmDetails } = await getProductsAndVms( productMappings );
|
|
893
|
+
// return res.sendSuccess( { ...fixture.toObject(), products: productDetails, vms: vmDetails } );
|
|
894
|
+
// }
|
|
895
|
+
// if ( fixture.toObject().productResolutionLevel === 'L2' || fixture.toObject().productResolutionLevel === 'L4' ) {
|
|
896
|
+
// const fixtureShelves = await fixtureShelfService.find( { fixtureId: new mongoose.Types.ObjectId( fixtureId ) } );
|
|
897
|
+
// if ( !fixtureShelves.length ) return res.sendError( 'No shelves found for the fixture', 204 );
|
|
898
|
+
// const shelfProducts = await Promise.all(
|
|
899
|
+
// fixtureShelves.map( async ( shelf ) => {
|
|
900
|
+
// const productMappings = await planoMappingService.find( { shelfId: shelf._id } );
|
|
901
|
+
// const { productDetails, vmDetails } = await getProductsAndVms( productMappings );
|
|
902
|
+
// return { ...shelf.toObject(), products: productDetails, vms: vmDetails };
|
|
903
|
+
// } ),
|
|
904
|
+
// );
|
|
905
|
+
// return res.sendSuccess( { ...fixture.toObject(), shelves: shelfProducts } );
|
|
906
|
+
// }
|
|
907
|
+
// if ( fixture.toObject().productResolutionLevel === 'L3' ) {
|
|
908
|
+
// const fixtureShelves = await fixtureShelfService.find( { fixtureId: new mongoose.Types.ObjectId( fixtureId ) } );
|
|
909
|
+
// if ( !fixtureShelves.length ) return res.sendError( 'No shelves found for the fixture', 204 );
|
|
910
|
+
// const groupedShelves = await ( async () => {
|
|
911
|
+
// const shelfProducts = await Promise.all(
|
|
912
|
+
// fixtureShelves.map( async ( shelf ) => {
|
|
913
|
+
// const productMappings = await planoMappingService.find( { shelfId: shelf._id } );
|
|
914
|
+
// const { productDetails, vmDetails } = await getProductsAndVms( productMappings );
|
|
915
|
+
// return { ...shelf.toObject(), products: productDetails, vms: vmDetails };
|
|
916
|
+
// } ),
|
|
917
|
+
// );
|
|
918
|
+
// return shelfProducts.reduce( ( acc, shelf ) => {
|
|
919
|
+
// const sectionName = shelf.sectionName || 'Unknown';
|
|
920
|
+
// if ( !acc[sectionName] ) {
|
|
921
|
+
// acc[sectionName] = [];
|
|
922
|
+
// }
|
|
923
|
+
// acc[sectionName].push( shelf );
|
|
924
|
+
// return acc;
|
|
925
|
+
// }, {} );
|
|
926
|
+
// } )();
|
|
927
|
+
// return res.sendSuccess( { ...fixture.toObject(), categories: groupedShelves } );
|
|
928
|
+
// }
|
|
929
|
+
// return res.sendError( 'Incorrect resolution level', 400 );
|
|
930
|
+
// } catch ( e ) {
|
|
931
|
+
// logger.error( { functionName: 'fixtureShelfProductv1', error: e, message: req.body } );
|
|
932
|
+
// return res.sendError( e, 500 );
|
|
933
|
+
// }
|
|
934
|
+
// }
|
|
935
|
+
|
|
830
936
|
export async function fixtureShelfProductv1( req, res ) {
|
|
831
937
|
try {
|
|
832
938
|
const { planoId, fixtureId } = req.body;
|
|
@@ -836,9 +942,7 @@ export async function fixtureShelfProductv1( req, res ) {
|
|
|
836
942
|
{ _id: new mongoose.Types.ObjectId( planoId ) },
|
|
837
943
|
{ storeId: 1, storeName: 1, planoId: '$_id', productResolutionLevel: 1 },
|
|
838
944
|
),
|
|
839
|
-
storeFixtureService.findOne( {
|
|
840
|
-
_id: new mongoose.Types.ObjectId( fixtureId ),
|
|
841
|
-
} ),
|
|
945
|
+
storeFixtureService.findOne( { _id: new mongoose.Types.ObjectId( fixtureId ) } ),
|
|
842
946
|
] );
|
|
843
947
|
|
|
844
948
|
if ( !planogram ) return res.sendError( 'Planogram not found', 204 );
|
|
@@ -846,188 +950,66 @@ export async function fixtureShelfProductv1( req, res ) {
|
|
|
846
950
|
|
|
847
951
|
const currentDate = new Date( dayjs().format( 'YYYY-MM-DD' ) );
|
|
848
952
|
|
|
849
|
-
|
|
850
|
-
const
|
|
851
|
-
const
|
|
852
|
-
const products = await planoProductService.find( { _id: { $in: productIds } } );
|
|
953
|
+
const getProducts = async ( mappings ) => {
|
|
954
|
+
const productIds = mappings.map( ( mapping ) => mapping.productId );
|
|
955
|
+
const products = await planoProductService.find( { _id: { $in: productIds }, type: 'product' } );
|
|
853
956
|
const productMap = new Map( products.map( ( product ) => [ product._id.toString(), product.toObject() ] ) );
|
|
854
957
|
|
|
855
|
-
|
|
856
|
-
|
|
958
|
+
return await Promise.all(
|
|
959
|
+
mappings.map( async ( mapping ) => {
|
|
857
960
|
const productData = productMap.get( mapping.productId.toString() ) || {};
|
|
961
|
+
delete productData._id;
|
|
858
962
|
const mappingCompliance = await planoComplianceService.findOne( {
|
|
859
963
|
planoMappingId: mapping._id,
|
|
860
964
|
date: currentDate,
|
|
861
965
|
} );
|
|
862
|
-
|
|
863
966
|
const status = mappingCompliance ? mappingCompliance.compliance : '';
|
|
864
|
-
|
|
865
967
|
return { ...mapping.toObject(), ...productData, status };
|
|
866
968
|
} ),
|
|
867
969
|
);
|
|
970
|
+
};
|
|
868
971
|
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'missing' } ),
|
|
875
|
-
] );
|
|
876
|
-
|
|
877
|
-
const fixtureMetrics = {
|
|
878
|
-
total: totalProducts,
|
|
879
|
-
scanned: scannedProducts,
|
|
880
|
-
misplaced: misplacedProducts,
|
|
881
|
-
proper: properProducts,
|
|
882
|
-
missing: missingProducts,
|
|
883
|
-
};
|
|
972
|
+
const vmMappings = await planoMappingService.find( { fixtureId: new mongoose.Types.ObjectId( fixtureId ), type: 'vm' } );
|
|
973
|
+
const vmIds = vmMappings.map( ( mapping ) => mapping.productId );
|
|
974
|
+
const vms = await planoProductService.find( { _id: { $in: vmIds }, type: 'vm' } );
|
|
975
|
+
const vmMap = new Map( vms.map( ( vm ) => [ vm._id.toString(), vm.toObject() ] ) );
|
|
976
|
+
const vmDetails = vmMappings.map( ( mapping ) => vmMap.get( mapping.productId.toString() ) || {} );
|
|
884
977
|
|
|
885
|
-
|
|
978
|
+
if ( fixture.toObject().productResolutionLevel === 'L1' ) {
|
|
979
|
+
const productMappings = await planoMappingService.find( { fixtureId: new mongoose.Types.ObjectId( fixtureId ), type: 'product' } );
|
|
980
|
+
const productDetails = await getProducts( productMappings );
|
|
981
|
+
return res.sendSuccess( { ...fixture.toObject(), products: productDetails, vms: vmDetails } );
|
|
886
982
|
}
|
|
887
|
-
if ( fixture.toObject().productResolutionLevel === 'L2' || fixture.toObject().productResolutionLevel === 'L4' ) {
|
|
888
|
-
const fixtureShelves = await fixtureShelfService.find( {
|
|
889
|
-
fixtureId: new mongoose.Types.ObjectId( fixtureId ),
|
|
890
|
-
} );
|
|
891
983
|
|
|
984
|
+
if ( [ 'L2', 'L4' ].includes( fixture.toObject().productResolutionLevel ) ) {
|
|
985
|
+
const fixtureShelves = await fixtureShelfService.find( { fixtureId: new mongoose.Types.ObjectId( fixtureId ) } );
|
|
892
986
|
if ( !fixtureShelves.length ) return res.sendError( 'No shelves found for the fixture', 204 );
|
|
893
|
-
|
|
894
987
|
const shelfProducts = await Promise.all(
|
|
895
988
|
fixtureShelves.map( async ( shelf ) => {
|
|
896
|
-
const productMappings = await planoMappingService.find( { shelfId: shelf._id } );
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
return { ...shelf.toObject(), products: [] };
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
const productIds = productMappings.map( ( mapping ) => mapping.productId );
|
|
903
|
-
const products = await planoProductService.find( { _id: { $in: productIds } } );
|
|
904
|
-
const productMap = new Map( products.map( ( product ) => [ product._id.toString(), product.toObject() ] ) );
|
|
905
|
-
|
|
906
|
-
const productDetails = await Promise.all(
|
|
907
|
-
productMappings.map( async ( mapping ) => {
|
|
908
|
-
const productData = productMap.get( mapping.productId.toString() );
|
|
909
|
-
if ( !productData ) {
|
|
910
|
-
return { ...mapping.toObject(), status: '' };
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
const mappingCompliance = await planoComplianceService.findOne( {
|
|
914
|
-
planoMappingId: mapping._id,
|
|
915
|
-
date: currentDate,
|
|
916
|
-
} );
|
|
917
|
-
|
|
918
|
-
const status = mappingCompliance ? mappingCompliance.compliance : '';
|
|
919
|
-
|
|
920
|
-
return {
|
|
921
|
-
...mapping.toObject(),
|
|
922
|
-
...productData,
|
|
923
|
-
status,
|
|
924
|
-
};
|
|
925
|
-
} ),
|
|
926
|
-
);
|
|
927
|
-
|
|
928
|
-
return {
|
|
929
|
-
...shelf.toObject(),
|
|
930
|
-
products: productDetails,
|
|
931
|
-
};
|
|
989
|
+
const productMappings = await planoMappingService.find( { shelfId: shelf._id, type: 'product' } );
|
|
990
|
+
const productDetails = await getProducts( productMappings );
|
|
991
|
+
return { ...shelf.toObject(), products: productDetails };
|
|
932
992
|
} ),
|
|
933
993
|
);
|
|
994
|
+
return res.sendSuccess( { ...fixture.toObject(), shelves: shelfProducts, vms: vmDetails } );
|
|
995
|
+
}
|
|
934
996
|
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate } ),
|
|
938
|
-
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'misplaced' } ),
|
|
939
|
-
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'proper' } ),
|
|
940
|
-
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'missing' } ),
|
|
941
|
-
] );
|
|
942
|
-
|
|
943
|
-
const fixtureMetrics = {
|
|
944
|
-
total: totalProducts,
|
|
945
|
-
scanned: scannedProducts,
|
|
946
|
-
misplaced: misplacedProducts,
|
|
947
|
-
proper: properProducts,
|
|
948
|
-
missing: missingProducts,
|
|
949
|
-
};
|
|
950
|
-
|
|
951
|
-
return res.sendSuccess( { ...fixture.toObject(), shelves: shelfProducts, fixtureMetrics: fixtureMetrics } );
|
|
952
|
-
} else if ( fixture.toObject().productResolutionLevel === 'L3' ) {
|
|
953
|
-
const fixtureShelves = await fixtureShelfService.find( {
|
|
954
|
-
fixtureId: new mongoose.Types.ObjectId( fixtureId ),
|
|
955
|
-
} );
|
|
956
|
-
|
|
997
|
+
if ( fixture.toObject().productResolutionLevel === 'L3' ) {
|
|
998
|
+
const fixtureShelves = await fixtureShelfService.find( { fixtureId: new mongoose.Types.ObjectId( fixtureId ) } );
|
|
957
999
|
if ( !fixtureShelves.length ) return res.sendError( 'No shelves found for the fixture', 204 );
|
|
958
|
-
const groupedShelves =
|
|
959
|
-
const
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
const products = await planoProductService.find( { _id: { $in: productIds } } );
|
|
969
|
-
const productMap = new Map( products.map( ( product ) => [ product._id.toString(), product.toObject() ] ) );
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
const productDetails = await Promise.all(
|
|
973
|
-
productMappings.map( async ( mapping ) => {
|
|
974
|
-
const productData = productMap.get( mapping.productId.toString() );
|
|
975
|
-
if ( !productData ) {
|
|
976
|
-
return { ...mapping.toObject(), status: '' };
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
const mappingCompliance = await planoComplianceService.findOne( {
|
|
980
|
-
planoMappingId: mapping._id,
|
|
981
|
-
date: currentDate,
|
|
982
|
-
} );
|
|
983
|
-
|
|
984
|
-
const status = mappingCompliance ? mappingCompliance.compliance : '';
|
|
985
|
-
|
|
986
|
-
return {
|
|
987
|
-
...mapping.toObject(),
|
|
988
|
-
...productData,
|
|
989
|
-
status,
|
|
990
|
-
};
|
|
991
|
-
} ),
|
|
992
|
-
);
|
|
993
|
-
|
|
994
|
-
return {
|
|
995
|
-
...shelf.toObject(),
|
|
996
|
-
products: productDetails,
|
|
997
|
-
};
|
|
998
|
-
} ),
|
|
999
|
-
);
|
|
1000
|
-
|
|
1001
|
-
return shelfProducts.reduce( ( acc, shelf ) => {
|
|
1002
|
-
const sectionName = shelf.sectionName || 'Unknown';
|
|
1003
|
-
if ( !acc[sectionName] ) {
|
|
1004
|
-
acc[sectionName] = [];
|
|
1005
|
-
}
|
|
1006
|
-
acc[sectionName].push( shelf );
|
|
1007
|
-
return acc;
|
|
1008
|
-
}, {} );
|
|
1009
|
-
} )();
|
|
1010
|
-
|
|
1011
|
-
const [ totalProducts, scannedProducts, misplacedProducts, properProducts, missingProducts ] = await Promise.all( [
|
|
1012
|
-
planoMappingService.count( { fixtureId: fixture.toObject()._id } ),
|
|
1013
|
-
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate } ),
|
|
1014
|
-
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'misplaced' } ),
|
|
1015
|
-
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'proper' } ),
|
|
1016
|
-
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'missing' } ),
|
|
1017
|
-
] );
|
|
1018
|
-
|
|
1019
|
-
const fixtureMetrics = {
|
|
1020
|
-
total: totalProducts,
|
|
1021
|
-
scanned: scannedProducts,
|
|
1022
|
-
misplaced: misplacedProducts,
|
|
1023
|
-
proper: properProducts,
|
|
1024
|
-
missing: missingProducts,
|
|
1025
|
-
};
|
|
1026
|
-
|
|
1027
|
-
return res.sendSuccess( { ...fixture.toObject(), categories: groupedShelves, fixtureMetrics: fixtureMetrics } );
|
|
1028
|
-
} else {
|
|
1029
|
-
return res.sendError( 'Incorrect resolution level', 400 );
|
|
1000
|
+
const groupedShelves = fixtureShelves.reduce( async ( accPromise, shelf ) => {
|
|
1001
|
+
const acc = await accPromise;
|
|
1002
|
+
const productMappings = await planoMappingService.find( { shelfId: shelf._id, type: 'product' } );
|
|
1003
|
+
const productDetails = await getProducts( productMappings );
|
|
1004
|
+
const sectionName = shelf.sectionName || 'Unknown';
|
|
1005
|
+
if ( !acc[sectionName] ) acc[sectionName] = [];
|
|
1006
|
+
acc[sectionName].push( { ...shelf.toObject(), products: productDetails } );
|
|
1007
|
+
return acc;
|
|
1008
|
+
}, Promise.resolve( {} ) );
|
|
1009
|
+
return res.sendSuccess( { ...fixture.toObject(), categories: await groupedShelves, vms: vmDetails } );
|
|
1030
1010
|
}
|
|
1011
|
+
|
|
1012
|
+
return res.sendError( 'Incorrect resolution level', 400 );
|
|
1031
1013
|
} catch ( e ) {
|
|
1032
1014
|
logger.error( { functionName: 'fixtureShelfProductv1', error: e, message: req.body } );
|
|
1033
1015
|
return res.sendError( e, 500 );
|
|
@@ -1893,7 +1875,7 @@ export async function storeFixturesTask( req, res ) {
|
|
|
1893
1875
|
|
|
1894
1876
|
const planograms = await planoService.find(
|
|
1895
1877
|
{ _id: { $in: planoIds } },
|
|
1896
|
-
{ storeId: 1, storeName: 1, planoId: '$_id', productResolutionLevel: 1 },
|
|
1878
|
+
{ storeId: 1, storeName: 1, planoId: '$_id', productResolutionLevel: 1, scanType: 1 },
|
|
1897
1879
|
);
|
|
1898
1880
|
|
|
1899
1881
|
if ( !planograms?.length ) return res.sendError( 'No data found', 204 );
|
|
@@ -5,6 +5,7 @@ import * as userService from '../service/user.service.js';
|
|
|
5
5
|
import dayjs from 'dayjs';
|
|
6
6
|
import { logger, fileUpload, signedUrl } from 'tango-app-api-middleware';
|
|
7
7
|
import * as planoTaskService from '../service/planoTask.service.js';
|
|
8
|
+
import * as planoService from '../service/planogram.service.js';
|
|
8
9
|
|
|
9
10
|
async function createUser( data ) {
|
|
10
11
|
try {
|
|
@@ -193,6 +194,7 @@ export async function createTask( req, res ) {
|
|
|
193
194
|
}
|
|
194
195
|
if ( !req.body.userEmail ) {
|
|
195
196
|
await Promise.all( storeDetails.map( async ( store ) => {
|
|
197
|
+
let planoDetails = await planoService.findOne( { storeId: store.storeId } );
|
|
196
198
|
userDetails = await userService.findOne( { email: store?.spocDetails?.[0]?.email } );
|
|
197
199
|
if ( !userDetails ) {
|
|
198
200
|
let userData = {
|
|
@@ -209,6 +211,7 @@ export async function createTask( req, res ) {
|
|
|
209
211
|
taskData.userId = userDetails._id;
|
|
210
212
|
taskData.userName = userDetails.userName;
|
|
211
213
|
taskData.userEmail = userDetails.email;
|
|
214
|
+
taskData.planoId = planoDetails?.planoId;
|
|
212
215
|
await processedService.create( taskData );
|
|
213
216
|
} ) );
|
|
214
217
|
}
|
|
@@ -2,9 +2,9 @@ import express from 'express';
|
|
|
2
2
|
// import { isAllowedSessionHandler } from 'tango-app-api-middleware';
|
|
3
3
|
import * as taskController from '../controllers/task.controller.js';
|
|
4
4
|
|
|
5
|
-
export const
|
|
5
|
+
export const storeBuilderTaskRouter = express.Router();
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
storeBuilderTaskRouter
|
|
8
8
|
.post( '/createTask', taskController.createTask )
|
|
9
9
|
.get( '/taskDetails', taskController.getTaskDetails )
|
|
10
10
|
.post( '/uploadImage', taskController.uploadImage )
|