tango-app-api-store-builder 1.0.0-beta-70 → 1.0.0-beta-72
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 +3 -2
- package/src/controllers/script.controller.js +199 -0
- package/src/controllers/storeBuilder.controller.js +117 -3
- package/src/controllers/task.controller.js +54 -12
- package/src/routes/script.routes.js +4 -1
- package/src/routes/storeBuilder.routes.js +3 -1
- package/src/routes/task.routes.js +2 -1
- package/src/service/{planoStaticBrandCategories.service.js → planoStaticData.service.js} +2 -2
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-72",
|
|
4
4
|
"description": "storeBuilder",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -21,9 +21,10 @@
|
|
|
21
21
|
"express-fileupload": "^1.5.1",
|
|
22
22
|
"handlebars": "^4.7.8",
|
|
23
23
|
"joi": "^17.13.3",
|
|
24
|
+
"jszip": "^3.10.1",
|
|
24
25
|
"mongodb": "^6.12.0",
|
|
25
26
|
"nodemon": "^3.1.9",
|
|
26
|
-
"tango-api-schema": "^2.2.
|
|
27
|
+
"tango-api-schema": "^2.2.94",
|
|
27
28
|
"tango-app-api-middleware": "^3.1.48",
|
|
28
29
|
"winston": "^3.17.0",
|
|
29
30
|
"winston-daily-rotate-file": "^5.0.0",
|
|
@@ -14,6 +14,8 @@ import * as planoTaskService from '../service/planoTask.service.js';
|
|
|
14
14
|
// import * as planoQrConversionRequestService from '../service/planoQrConversionRequest.service.js';
|
|
15
15
|
import * as fixtureConfigService from '../service/fixtureConfig.service.js';
|
|
16
16
|
import mongoose from 'mongoose';
|
|
17
|
+
import JSZip from 'jszip';
|
|
18
|
+
|
|
17
19
|
|
|
18
20
|
export async function getStoreNames( req, res ) {
|
|
19
21
|
try {
|
|
@@ -1774,3 +1776,200 @@ export async function getProdTaskData( req, res ) {
|
|
|
1774
1776
|
return res.sendError( e.message || 'Internal Server Error', 500 );
|
|
1775
1777
|
}
|
|
1776
1778
|
}
|
|
1779
|
+
|
|
1780
|
+
export async function updatelayoutFeedback( req, res ) {
|
|
1781
|
+
try {
|
|
1782
|
+
if ( req?.headers?.authorization?.split( ' ' )[1] !== 'hwjXfCD6TgMvc82cuSGZ9bNv9MuXsaiQ6uvx' ) {
|
|
1783
|
+
return res.sendError( 'Unauthorized', 401 );
|
|
1784
|
+
}
|
|
1785
|
+
const layoutFeedbacks = await planoTaskService.find( { type: 'layout' } );
|
|
1786
|
+
|
|
1787
|
+
for ( let i = 0; i < layoutFeedbacks.length; i++ ) {
|
|
1788
|
+
const layoutDoc = layoutFeedbacks[i].toObject();
|
|
1789
|
+
|
|
1790
|
+
const [ q1, q2, q3 ] = layoutDoc.answers;
|
|
1791
|
+
|
|
1792
|
+
if ( q1.value === false ) {
|
|
1793
|
+
const floor = await storeBuilderService.findOne( { _id: layoutDoc.floorId } );
|
|
1794
|
+
|
|
1795
|
+
const floorDoc = floor.toObject();
|
|
1796
|
+
|
|
1797
|
+
const fixtures = await storeFixtureService.find( { floorId: floorDoc._id } );
|
|
1798
|
+
|
|
1799
|
+
const constantFixtureLength = 1220;
|
|
1800
|
+
const constantDetailedFixtureLength = 1220;
|
|
1801
|
+
|
|
1802
|
+
const constantFixtureWidth = 610;
|
|
1803
|
+
const constantDetailedFixtureWidth = 1524;
|
|
1804
|
+
|
|
1805
|
+
const mmToFeet = 305;
|
|
1806
|
+
|
|
1807
|
+
|
|
1808
|
+
function roundToTwo( num ) {
|
|
1809
|
+
return Math.round( num * 100 ) / 100;
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
const leftFixtures = fixtures.filter( ( fixture ) => fixture.toObject().associatedElementType === 'wall' && fixture.toObject().associatedElementNumber === 1 && fixture.toObject().fixtureType === 'wall' );
|
|
1813
|
+
const rightFixtures = fixtures.filter( ( fixture ) => fixture.toObject().associatedElementType === 'wall' && fixture.toObject().associatedElementNumber === 3 && fixture.toObject().fixtureType === 'wall' );
|
|
1814
|
+
const floorFixtures = fixtures.filter( ( fixture ) => fixture.toObject().fixtureType === 'floor' );
|
|
1815
|
+
const backFixtures = fixtures.filter( ( fixture ) => fixture.toObject().associatedElementType === 'wall' && fixture.toObject().associatedElementNumber === 2 && fixture.toObject().fixtureType === 'wall' );
|
|
1816
|
+
|
|
1817
|
+
q2.correctedFixture.forEach( ( cf ) => {
|
|
1818
|
+
switch ( cf.alignment ) {
|
|
1819
|
+
case 'Wall 1':
|
|
1820
|
+
leftFixtures.push( {} );
|
|
1821
|
+
break;
|
|
1822
|
+
case 'Wall 2':
|
|
1823
|
+
backFixtures.push( {} );
|
|
1824
|
+
break;
|
|
1825
|
+
case 'Wall 3':
|
|
1826
|
+
rightFixtures.push( {} );
|
|
1827
|
+
break;
|
|
1828
|
+
|
|
1829
|
+
default:
|
|
1830
|
+
break;
|
|
1831
|
+
}
|
|
1832
|
+
} );
|
|
1833
|
+
|
|
1834
|
+
|
|
1835
|
+
const leftXDistanceFeet = leftFixtures.length ? roundToTwo( ( leftFixtures.length * ( constantFixtureLength / mmToFeet ) ) ) : 0;
|
|
1836
|
+
const leftXDetailedDistanceFeet = leftFixtures.length ? roundToTwo( ( leftFixtures.length * ( constantDetailedFixtureLength / mmToFeet ) ) ) : 0;
|
|
1837
|
+
|
|
1838
|
+
const leftYDistanceFeet = leftFixtures.length ? roundToTwo( ( ( constantFixtureWidth / mmToFeet ) ) ) : 0;
|
|
1839
|
+
const leftYDetailedDistanceFeet = leftFixtures.length ? roundToTwo( ( ( constantDetailedFixtureWidth / mmToFeet ) ) ) : 0;
|
|
1840
|
+
|
|
1841
|
+
const rightXDistanceFeet = rightFixtures.length ? roundToTwo( ( rightFixtures.length * ( constantFixtureLength / mmToFeet ) ) ) : 0;
|
|
1842
|
+
const rightXDetailedDistanceFeet = rightFixtures.length ? roundToTwo( ( rightFixtures.length * ( constantDetailedFixtureLength / mmToFeet ) ) ) : 0;
|
|
1843
|
+
|
|
1844
|
+
const rightYDistanceFeet = rightFixtures.length ? roundToTwo( ( constantFixtureWidth / mmToFeet ) ) : 0;
|
|
1845
|
+
const rightYDetailedDistanceFeet = rightFixtures.length ? roundToTwo( ( constantDetailedFixtureWidth / mmToFeet ) ): 0;
|
|
1846
|
+
|
|
1847
|
+
const maxFixturesPerRow = floorFixtures.length > 4 ? 3 : 2;
|
|
1848
|
+
const totalRows = Math.ceil( floorFixtures.length / maxFixturesPerRow );
|
|
1849
|
+
const floorXDistanceFeet = floorFixtures.length ? roundToTwo( ( maxFixturesPerRow * ( constantFixtureLength / mmToFeet ) ) ) : 0;
|
|
1850
|
+
const floorXDetailedDistanceFeet = floorFixtures.length ? roundToTwo( ( maxFixturesPerRow * ( constantDetailedFixtureLength / mmToFeet ) ) ): 0;
|
|
1851
|
+
|
|
1852
|
+
const floorYDistanceFeet = floorFixtures.length ? roundToTwo( ( totalRows * ( constantFixtureWidth/ mmToFeet ) ) ): 0;
|
|
1853
|
+
const floorYDetailedDistanceFeet = floorFixtures.length ? roundToTwo( totalRows * ( constantDetailedFixtureWidth/mmToFeet ) ): 0;
|
|
1854
|
+
|
|
1855
|
+
const backXDistanceFeet = backFixtures.length ? roundToTwo( ( constantFixtureWidth / mmToFeet ) ) : 0;
|
|
1856
|
+
const backXDetailedDistanceFeet = backFixtures.length ? roundToTwo( ( constantDetailedFixtureLength / mmToFeet ) ) : 0;
|
|
1857
|
+
|
|
1858
|
+
const backYDistanceFeet = backFixtures.length ? roundToTwo( ( ( backFixtures.length * ( constantFixtureLength / mmToFeet ) ) + ( ( ( leftFixtures.length ? 1 : 0 ) + ( rightFixtures.length ? 1 : 0 ) * constantFixtureWidth )/mmToFeet ) ) ) : 0;
|
|
1859
|
+
const backYDetailedDistanceFeet = backFixtures.length ? roundToTwo( ( ( backFixtures.length * ( constantDetailedFixtureWidth / mmToFeet ) ) + ( ( ( leftFixtures.length ? 1 : 0 ) + ( rightFixtures.length ? 1 : 0 ) * constantDetailedFixtureWidth )/mmToFeet ) ) ): 0;
|
|
1860
|
+
|
|
1861
|
+
const maxXDistance = Math.max( leftXDistanceFeet, rightXDistanceFeet, floorXDistanceFeet );
|
|
1862
|
+
const maxXDetailedDistance = Math.max( leftXDetailedDistanceFeet, rightXDetailedDistanceFeet, floorXDetailedDistanceFeet );
|
|
1863
|
+
|
|
1864
|
+
const maxYDistance = Math.max( floorYDistanceFeet, backYDistanceFeet );
|
|
1865
|
+
const maxYDetailedDistance = Math.max( floorYDetailedDistanceFeet, backYDetailedDistanceFeet );
|
|
1866
|
+
|
|
1867
|
+
|
|
1868
|
+
const finalXDistance = maxXDistance < ( backXDistanceFeet + floorXDistanceFeet )? ( ( backXDistanceFeet + floorXDistanceFeet ) + ( ( 2 * constantFixtureLength )/mmToFeet ) ) : ( floorFixtures.length && backFixtures.length ) ? ( maxXDistance + ( ( 2 * constantFixtureLength )/mmToFeet ) ) : maxXDistance;
|
|
1869
|
+
const finalXDetailedDistance = maxXDetailedDistance < ( backXDetailedDistanceFeet + floorXDetailedDistanceFeet )? ( ( backXDetailedDistanceFeet + floorXDetailedDistanceFeet ) + ( ( 2 * constantDetailedFixtureLength )/mmToFeet ) ) : ( floorFixtures.length && backFixtures.length ) ? ( maxXDetailedDistance + ( ( 2 * constantDetailedFixtureLength )/mmToFeet ) ) : maxXDetailedDistance;
|
|
1870
|
+
|
|
1871
|
+
const finalYDistance = maxYDistance < ( leftYDistanceFeet + rightYDistanceFeet + floorYDistanceFeet ) ? ( ( leftYDistanceFeet + rightYDistanceFeet + floorYDistanceFeet ) + ( ( 2 * constantFixtureWidth )/mmToFeet ) ) : ( maxYDistance + ( ( constantFixtureWidth )/mmToFeet ) );
|
|
1872
|
+
const finalYDetailedDistance = maxYDetailedDistance < ( leftYDetailedDistanceFeet + rightYDetailedDistanceFeet + floorYDetailedDistanceFeet ) ? ( ( leftYDetailedDistanceFeet + rightYDetailedDistanceFeet + floorYDetailedDistanceFeet ) + ( ( 2 * constantDetailedFixtureWidth )/mmToFeet ) ) : ( maxYDetailedDistance + ( ( constantDetailedFixtureWidth )/mmToFeet ) );
|
|
1873
|
+
|
|
1874
|
+
const layoutPolygon = [
|
|
1875
|
+
{
|
|
1876
|
+
elementType: 'wall',
|
|
1877
|
+
distance: roundToTwo( finalXDistance ),
|
|
1878
|
+
unit: 'ft',
|
|
1879
|
+
direction: 'right',
|
|
1880
|
+
angle: 90,
|
|
1881
|
+
elementNumber: 1,
|
|
1882
|
+
detailedDistance: roundToTwo( finalXDetailedDistance ),
|
|
1883
|
+
},
|
|
1884
|
+
{
|
|
1885
|
+
elementType: 'wall',
|
|
1886
|
+
distance: roundToTwo( finalYDistance ),
|
|
1887
|
+
unit: 'ft',
|
|
1888
|
+
direction: 'down',
|
|
1889
|
+
angle: 90,
|
|
1890
|
+
elementNumber: 2,
|
|
1891
|
+
detailedDistance: roundToTwo( finalYDetailedDistance ),
|
|
1892
|
+
},
|
|
1893
|
+
{
|
|
1894
|
+
elementType: 'wall',
|
|
1895
|
+
distance: roundToTwo( finalXDistance ),
|
|
1896
|
+
unit: 'ft',
|
|
1897
|
+
direction: 'left',
|
|
1898
|
+
angle: 90,
|
|
1899
|
+
elementNumber: 3,
|
|
1900
|
+
detailedDistance: roundToTwo( finalXDetailedDistance ),
|
|
1901
|
+
},
|
|
1902
|
+
{
|
|
1903
|
+
elementType: 'wall',
|
|
1904
|
+
distance: roundToTwo( ( ( finalYDistance * 40 ) / 100 ) ),
|
|
1905
|
+
unit: 'ft',
|
|
1906
|
+
direction: 'up',
|
|
1907
|
+
angle: 90,
|
|
1908
|
+
elementNumber: 4,
|
|
1909
|
+
detailedDistance: roundToTwo( ( ( finalYDetailedDistance * 35 ) / 100 ) ),
|
|
1910
|
+
},
|
|
1911
|
+
{
|
|
1912
|
+
elementType: 'entrance',
|
|
1913
|
+
distance: roundToTwo( ( ( finalYDistance * 20 ) / 100 ) ),
|
|
1914
|
+
unit: 'ft',
|
|
1915
|
+
direction: 'up',
|
|
1916
|
+
angle: 90,
|
|
1917
|
+
elementNumber: 1,
|
|
1918
|
+
detailedDistance: roundToTwo( ( ( finalYDetailedDistance * 30 ) / 100 ) ),
|
|
1919
|
+
},
|
|
1920
|
+
{
|
|
1921
|
+
elementType: 'wall',
|
|
1922
|
+
distance: roundToTwo( ( ( finalYDistance * 40 ) / 100 ) ),
|
|
1923
|
+
unit: 'ft',
|
|
1924
|
+
direction: 'up',
|
|
1925
|
+
angle: 90,
|
|
1926
|
+
elementNumber: 5,
|
|
1927
|
+
detailedDistance: roundToTwo( ( ( finalYDetailedDistance * 35 ) / 100 ) ),
|
|
1928
|
+
},
|
|
1929
|
+
];
|
|
1930
|
+
|
|
1931
|
+
await storeBuilderService.updateOne( { _id: floorDoc._id }, { layoutPolygon: layoutPolygon } );
|
|
1932
|
+
|
|
1933
|
+
console.log( layoutPolygon, floorDoc._id );
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
} catch ( e ) {
|
|
1937
|
+
logger.error( { functionName: 'updatelayoutFeedback', error: e } );
|
|
1938
|
+
return res.sendError( e.message || 'Internal Server Error', 500 );
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
export async function extractZipFileNames( req, res ) {
|
|
1943
|
+
try {
|
|
1944
|
+
if ( req?.headers?.authorization?.split( ' ' )[1] !== 'hwjXfCD6TgMvc82cuSGZ9bNv9MuXsaiQ6uvx' ) {
|
|
1945
|
+
return res.sendError( 'Unauthorized', 401 );
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1948
|
+
if ( !req.files.file ) {
|
|
1949
|
+
return res.sendError( 'No file uploaded', 400 );
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
const zip = new JSZip();
|
|
1953
|
+
const zipContents = await zip.loadAsync( req.files.file.data );
|
|
1954
|
+
|
|
1955
|
+
const fileNames = Object.keys( zipContents.files );
|
|
1956
|
+
|
|
1957
|
+
return res.sendSuccess( { fileNames } );
|
|
1958
|
+
} catch ( e ) {
|
|
1959
|
+
logger.error( { functionName: 'extractZipFileNames', error: e } );
|
|
1960
|
+
return res.sendError( e.message || 'Internal Server Error', 500 );
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
export async function updateFixtureFeedback( req, res ) {
|
|
1965
|
+
try {
|
|
1966
|
+
if ( req?.headers?.authorization?.split( ' ' )[1] !== 'hwjXfCD6TgMvc82cuSGZ9bNv9MuXsaiQ6uvx' ) {
|
|
1967
|
+
return res.sendError( 'Unauthorized', 401 );
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
|
|
1971
|
+
} catch ( e ) {
|
|
1972
|
+
logger.error( { functionName: 'updatelayoutFeedback', error: e } );
|
|
1973
|
+
return res.sendError( e.message || 'Internal Server Error', 500 );
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
@@ -14,7 +14,7 @@ import * as planoComplianceService from '../service/planoCompliance.service.js';
|
|
|
14
14
|
import * as planoTaskComplianceService from '../service/planoTask.service.js';
|
|
15
15
|
import * as planoQrConversionRequestService from '../service/planoQrConversionRequest.service.js';
|
|
16
16
|
import * as fixtureConfigService from '../service/fixtureConfig.service.js';
|
|
17
|
-
import * as
|
|
17
|
+
import * as planoStaticData from '../service/planoStaticData.service.js';
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
import path from 'path';
|
|
@@ -395,7 +395,11 @@ export async function storeLayout( req, res ) {
|
|
|
395
395
|
|
|
396
396
|
const storeLayout = await Promise.all(
|
|
397
397
|
planograms.map( async ( planogram ) => {
|
|
398
|
-
const
|
|
398
|
+
const floorList = await storeBuilderService.find( { planoId: planogram._id }, { floorName: 1, layoutPolygon: 1, crestLayout: true } );
|
|
399
|
+
|
|
400
|
+
const floors = floorList.map( ( floor ) => {
|
|
401
|
+
return floor.toObject();
|
|
402
|
+
} );
|
|
399
403
|
return {
|
|
400
404
|
...planogram.toObject(),
|
|
401
405
|
floors,
|
|
@@ -2433,6 +2437,61 @@ export const fixtureQrUpdate = async ( req, res ) => {
|
|
|
2433
2437
|
}
|
|
2434
2438
|
};
|
|
2435
2439
|
|
|
2440
|
+
export const fixtureQrUpdatev1 = async ( req, res ) => {
|
|
2441
|
+
try {
|
|
2442
|
+
const { fixtureId, date, productQr } = req.body;
|
|
2443
|
+
|
|
2444
|
+
const fixture = await storeFixtureService.findOne( { _id: new mongoose.Types.ObjectId( fixtureId ) }, { _id: 1 } );
|
|
2445
|
+
|
|
2446
|
+
if ( !fixture ) {
|
|
2447
|
+
return res.sendError( { message: 'Invalid fixture Id' }, 400 );
|
|
2448
|
+
}
|
|
2449
|
+
|
|
2450
|
+
const fixtureShelves = await fixtureShelfService.find( { fixtureId: new mongoose.Types.ObjectId( fixtureId ) } );
|
|
2451
|
+
|
|
2452
|
+
let productIndex = 0;
|
|
2453
|
+
|
|
2454
|
+
const complianceData = fixtureShelves.map( ( shelf ) => {
|
|
2455
|
+
const shelfObj = shelf.toObject();
|
|
2456
|
+
const products = shelfObj.shelfCapacity ?
|
|
2457
|
+
Array.from( { length: shelfObj.shelfCapacity }, () => ( {
|
|
2458
|
+
category: shelfObj.sectionName,
|
|
2459
|
+
productIndex: productIndex++,
|
|
2460
|
+
status: 'missing',
|
|
2461
|
+
} ) ) :
|
|
2462
|
+
[];
|
|
2463
|
+
|
|
2464
|
+
return { ...shelfObj, products };
|
|
2465
|
+
} );
|
|
2466
|
+
|
|
2467
|
+
const productMap = new Map();
|
|
2468
|
+
productQr.forEach( ( productCv, i ) => {
|
|
2469
|
+
if ( productCv.parent_brand ) {
|
|
2470
|
+
productMap.set( i, productCv );
|
|
2471
|
+
}
|
|
2472
|
+
} );
|
|
2473
|
+
|
|
2474
|
+
complianceData.forEach( ( shelf ) => {
|
|
2475
|
+
shelf.products.forEach( ( product ) => {
|
|
2476
|
+
const matchedProduct = productMap.get( product.productIndex );
|
|
2477
|
+
if ( matchedProduct && product.category === matchedProduct.parent_brand ) {
|
|
2478
|
+
Object.assign( product, { status: 'proper', barcode: matchedProduct.barcode } );
|
|
2479
|
+
}
|
|
2480
|
+
} );
|
|
2481
|
+
} );
|
|
2482
|
+
|
|
2483
|
+
const currentDate = new Date( date );
|
|
2484
|
+
|
|
2485
|
+
await planoQrConversionRequestService.updateOne( { fixtureId: new mongoose.Types.ObjectId( fixtureId ), date: currentDate }, { status: 'data-received', receivedQr: productQr, processedData: complianceData } );
|
|
2486
|
+
|
|
2487
|
+
res.sendSuccess( complianceData );
|
|
2488
|
+
} catch ( error ) {
|
|
2489
|
+
logger.error( 'fixtureQrUpdate =>', error );
|
|
2490
|
+
return res.sendError( { message: 'Internal Server Error' }, 500 );
|
|
2491
|
+
}
|
|
2492
|
+
};
|
|
2493
|
+
|
|
2494
|
+
|
|
2436
2495
|
export const updateDetailedDistance = async ( req, res ) => {
|
|
2437
2496
|
try {
|
|
2438
2497
|
const { floorId, elementNumber, elementType, detailedDistance } = req.body;
|
|
@@ -2721,7 +2780,7 @@ export const getFixtureBrands = async ( req, res ) => {
|
|
|
2721
2780
|
|
|
2722
2781
|
// const [ data ] = sections;
|
|
2723
2782
|
|
|
2724
|
-
const brandCategories = await
|
|
2783
|
+
const brandCategories = await planoStaticData.findOne( { type: 'brandCategory' } );
|
|
2725
2784
|
|
|
2726
2785
|
return res.sendSuccess( brandCategories.toObject().data );
|
|
2727
2786
|
} catch ( error ) {
|
|
@@ -2744,3 +2803,58 @@ export const checkPlanoExist = async ( req, res ) => {
|
|
|
2744
2803
|
return res.sendError( 'Internal Server Error', 500 );
|
|
2745
2804
|
}
|
|
2746
2805
|
};
|
|
2806
|
+
|
|
2807
|
+
export async function storeLayoutElements( req, res ) {
|
|
2808
|
+
try {
|
|
2809
|
+
// const planoIds = req.body.id.map( ( id ) => new mongoose.Types.ObjectId( id ) );
|
|
2810
|
+
|
|
2811
|
+
const planograms = await planoService.find(
|
|
2812
|
+
{ _id: new mongoose.Types.ObjectId( req.body.id ) },
|
|
2813
|
+
{ storeId: 1, storeName: 1, planoId: '$_id' },
|
|
2814
|
+
);
|
|
2815
|
+
|
|
2816
|
+
if ( !planograms?.length ) {
|
|
2817
|
+
return res.sendError( 'No data found', 204 );
|
|
2818
|
+
}
|
|
2819
|
+
|
|
2820
|
+
const storeLayout = await Promise.all(
|
|
2821
|
+
planograms.map( async ( planogram ) => {
|
|
2822
|
+
const floorList = await storeBuilderService.find(
|
|
2823
|
+
{ planoId: planogram._id },
|
|
2824
|
+
{ floorName: 1, layoutPolygon: 1, crestLayout: 1 },
|
|
2825
|
+
);
|
|
2826
|
+
|
|
2827
|
+
const floors = floorList.map( ( floor ) => {
|
|
2828
|
+
if ( floor.toObject()?.crestLayout ) {
|
|
2829
|
+
return {
|
|
2830
|
+
floorName: 'floor 1',
|
|
2831
|
+
layoutPolygon: [ 'wall 1', 'wall 2', 'wall 3', 'centre' ],
|
|
2832
|
+
};
|
|
2833
|
+
} else {
|
|
2834
|
+
const layoutPolygon = floor
|
|
2835
|
+
.toObject()
|
|
2836
|
+
?.layoutPolygon.map( ( element ) => {
|
|
2837
|
+
return `${element?.elementType} ${element?.elementNumber}`;
|
|
2838
|
+
} );
|
|
2839
|
+
layoutPolygon.push( 'centre' );
|
|
2840
|
+
return {
|
|
2841
|
+
...floor.toObject(),
|
|
2842
|
+
layoutPolygon,
|
|
2843
|
+
};
|
|
2844
|
+
}
|
|
2845
|
+
} );
|
|
2846
|
+
|
|
2847
|
+
return {
|
|
2848
|
+
...planogram.toObject(),
|
|
2849
|
+
floors,
|
|
2850
|
+
};
|
|
2851
|
+
} ),
|
|
2852
|
+
);
|
|
2853
|
+
|
|
2854
|
+
return res.sendSuccess( storeLayout );
|
|
2855
|
+
} catch ( e ) {
|
|
2856
|
+
logger.error( { functionName: 'storeLayoutv1', error: e, message: req.body } );
|
|
2857
|
+
return res.sendError( e, 500 );
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
|
|
@@ -9,6 +9,7 @@ import * as planoTaskService from '../service/planoTask.service.js';
|
|
|
9
9
|
import * as planoService from '../service/planogram.service.js';
|
|
10
10
|
import * as checklistService from '../service/checklist.service.js';
|
|
11
11
|
import timeZone from 'dayjs/plugin/timezone.js';
|
|
12
|
+
import * as planoProductService from '../service/planoProduct.service.js';
|
|
12
13
|
dayjs.extend( timeZone );
|
|
13
14
|
|
|
14
15
|
async function createUser( data ) {
|
|
@@ -110,6 +111,32 @@ export async function createTask( req, res ) {
|
|
|
110
111
|
if ( !taskDetails.length ) {
|
|
111
112
|
return res.sendError( 'No data found', 204 );
|
|
112
113
|
}
|
|
114
|
+
let userEmailList = [ ...new Set( req.body.stores.map( ( ele ) => ele.email ) ) ];
|
|
115
|
+
for ( let mail of userEmailList ) {
|
|
116
|
+
let query = [
|
|
117
|
+
{
|
|
118
|
+
$addFields: {
|
|
119
|
+
emailLower: { $toLower: '$email' },
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
$match: {
|
|
124
|
+
clientId: req.body.clientId,
|
|
125
|
+
emailLower: mail.toLowerCase(),
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
];
|
|
129
|
+
userDetails = await userService.aggregate( query );
|
|
130
|
+
if ( !userDetails.length ) {
|
|
131
|
+
let userData = {
|
|
132
|
+
clientId: req.body.clientId,
|
|
133
|
+
mobileNumber: '',
|
|
134
|
+
email: mail,
|
|
135
|
+
userName: mail.split( '@' )[0],
|
|
136
|
+
};
|
|
137
|
+
await createUser( userData );
|
|
138
|
+
}
|
|
139
|
+
}
|
|
113
140
|
let endDate = dayjs().add( req.body.days, 'day' ).format( 'YYYY-MM-DD' );
|
|
114
141
|
await Promise.all( taskDetails.map( async ( task ) => {
|
|
115
142
|
let data = {
|
|
@@ -183,22 +210,22 @@ export async function createTask( req, res ) {
|
|
|
183
210
|
{
|
|
184
211
|
$match: {
|
|
185
212
|
clientId: req.body.clientId,
|
|
186
|
-
email: getUserEmail.email,
|
|
213
|
+
email: getUserEmail.email.toLowerCase(),
|
|
187
214
|
},
|
|
188
215
|
},
|
|
189
216
|
];
|
|
190
217
|
userDetails = await userService.aggregate( query );
|
|
191
|
-
if ( !userDetails.length ) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
} else {
|
|
200
|
-
|
|
201
|
-
}
|
|
218
|
+
// if ( !userDetails.length ) {
|
|
219
|
+
// let userData = {
|
|
220
|
+
// clientId: req.body.clientId,
|
|
221
|
+
// mobileNumber: '',
|
|
222
|
+
// email: getUserEmail.email,
|
|
223
|
+
// userName: getUserEmail.email.split( '@' )[0],
|
|
224
|
+
// };
|
|
225
|
+
// userDetails = await createUser( userData );
|
|
226
|
+
// } else {
|
|
227
|
+
userDetails = userDetails[0];
|
|
228
|
+
// }
|
|
202
229
|
}
|
|
203
230
|
let taskData = { ...data };
|
|
204
231
|
taskData.store_id = store.storeId;
|
|
@@ -564,3 +591,18 @@ export async function getFixtureDetails( req, res ) {
|
|
|
564
591
|
return res.sendError( e, 500 );
|
|
565
592
|
}
|
|
566
593
|
}
|
|
594
|
+
|
|
595
|
+
export async function getVmDetails( req, res ) {
|
|
596
|
+
try {
|
|
597
|
+
let getVms = await planoProductService.find( { type: 'vm' }, { productName: 1 } );
|
|
598
|
+
if ( !getVms.length ) {
|
|
599
|
+
return res.sendError( 'No data found', 204 );
|
|
600
|
+
}
|
|
601
|
+
getVms = [ ...new Set( getVms.map( ( ele ) => ele.productName ) ) ];
|
|
602
|
+
getVms.push( 'other' );
|
|
603
|
+
return res.sendSuccess( getVms );
|
|
604
|
+
} catch ( e ) {
|
|
605
|
+
logger.error( { functionName: 'getVmDetails', error: e } );
|
|
606
|
+
return res.sendError( e, 500 );
|
|
607
|
+
}
|
|
608
|
+
}
|
|
@@ -16,4 +16,7 @@ scriptRouter
|
|
|
16
16
|
.post( '/updateinventory', scriptController.updateInventory )
|
|
17
17
|
.post( '/updateRfidProduct', scriptController.updateRfidProduct )
|
|
18
18
|
.post( '/updateRfidProduct2', scriptController.updateRfidProduct2 )
|
|
19
|
-
.post( '/getProdTaskData', scriptController.getProdTaskData )
|
|
19
|
+
.post( '/getProdTaskData', scriptController.getProdTaskData )
|
|
20
|
+
.post( '/updateLayoutFeedback', scriptController.updatelayoutFeedback )
|
|
21
|
+
.post( '/updateFixtureFeedback', scriptController.updateFixtureFeedback )
|
|
22
|
+
.post( '/getFileNames', scriptController.extractZipFileNames );
|
|
@@ -34,10 +34,12 @@ storeBuilderRouter
|
|
|
34
34
|
.post( '/updateQrCvProcessRequest', isAllowedSessionHandler, storeBuilderController.updateQrCvProcessRequest )
|
|
35
35
|
.post( '/getQrCvProcessRequest', isAllowedSessionHandler, storeBuilderController.getQrCvProcessRequest )
|
|
36
36
|
.post( '/fixtureQrUpdate', isAllowedSessionHandler, storeBuilderController.fixtureQrUpdate )
|
|
37
|
+
.post( '/fixtureQrUpdatev1', isAllowedSessionHandler, storeBuilderController.fixtureQrUpdatev1 )
|
|
37
38
|
.post( '/updateDeatailedDistance', isAllowedSessionHandler, storeBuilderController.updateDetailedDistance )
|
|
38
39
|
.post( '/upsertFixture', isAllowedSessionHandler, storeBuilderController.upsertFixtures )
|
|
39
40
|
.post( '/getshelfSections', isAllowedSessionHandler, storeBuilderController.getShelfSections )
|
|
40
41
|
.post( '/getFixtureTypes', isAllowedSessionHandler, storeBuilderController.getFixtureTypes )
|
|
41
42
|
.post( '/getFixtureLengths', isAllowedSessionHandler, storeBuilderController.getFixtureLengths )
|
|
42
43
|
.post( '/getFixtureBrands', isAllowedSessionHandler, storeBuilderController.getFixtureBrands )
|
|
43
|
-
.post( '/checkPlanoExist', isAllowedSessionHandler, storeBuilderController.checkPlanoExist )
|
|
44
|
+
.post( '/checkPlanoExist', isAllowedSessionHandler, storeBuilderController.checkPlanoExist )
|
|
45
|
+
.post( '/storeLayoutElements', isAllowedSessionHandler, storeBuilderController.storeLayoutElements );
|
|
@@ -11,4 +11,5 @@ storeBuilderTaskRouter
|
|
|
11
11
|
.post( '/uploadImage', isAllowedSessionHandler, taskController.uploadImage )
|
|
12
12
|
.post( '/updateStatus', isAllowedSessionHandler, taskController.updateStatus )
|
|
13
13
|
.post( '/updateAnswers', isAllowedSessionHandler, taskController.updateAnswers )
|
|
14
|
-
.get( '/getFixtureDetails', isAllowedSessionHandler, taskController.getFixtureDetails )
|
|
14
|
+
.get( '/getFixtureDetails', isAllowedSessionHandler, taskController.getFixtureDetails )
|
|
15
|
+
.get( '/getVmDetails', isAllowedSessionHandler, taskController.getVmDetails );
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import model from 'tango-api-schema';
|
|
2
2
|
|
|
3
3
|
export async function find( query={}, field={} ) {
|
|
4
|
-
return model.
|
|
4
|
+
return model.planoStaticData.find( query, field );
|
|
5
5
|
}
|
|
6
6
|
export async function findOne( query={}, field={} ) {
|
|
7
|
-
return model.
|
|
7
|
+
return model.planoStaticData.findOne( query, field );
|
|
8
8
|
}
|