tango-app-api-store-builder 1.0.0-beta-112 → 1.0.0-beta-114
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/inputjson/layoutverification.json +254 -255
- package/package.json +2 -2
- package/response.json +7 -0
- package/src/controllers/fixtureTemplate.controller.js +15 -3
- package/src/controllers/managePlano.controller.js +128 -4
- package/src/controllers/planoLibrary.controller.js +23 -4
- package/src/controllers/script.controller.js +222 -89
- package/src/controllers/storeBuilder.controller.js +173 -5
- package/src/controllers/task.controller.js +19 -16
- package/src/dtos/validation.dtos.js +1 -0
- package/src/routes/managePlano.routes.js +3 -1
- package/src/routes/storeBuilder.routes.js +4 -2
- package/src/service/fixtureConfig.service.js +4 -0
- package/src/service/planoproductCategory.service.js +8 -0
|
@@ -574,6 +574,7 @@ export async function storeFixturesv1( req, res ) {
|
|
|
574
574
|
const floorsWithFixtures = await Promise.all(
|
|
575
575
|
floors.map( async ( floor ) => {
|
|
576
576
|
let productCapacity = 0;
|
|
577
|
+
let fixtureCount = 0;
|
|
577
578
|
const layoutPolygonWithFixtures = await Promise.all(
|
|
578
579
|
floor.layoutPolygon.map( async ( element ) => {
|
|
579
580
|
const fixtures = await storeFixtureService.findAndSort( {
|
|
@@ -595,6 +596,7 @@ export async function storeFixturesv1( req, res ) {
|
|
|
595
596
|
fixture.imageUrl = '';
|
|
596
597
|
}
|
|
597
598
|
productCapacity += fixture.toObject().fixtureCapacity;
|
|
599
|
+
fixtureCount += 1;
|
|
598
600
|
const productCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'product' } );
|
|
599
601
|
|
|
600
602
|
const vmCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'vm' } );
|
|
@@ -696,6 +698,8 @@ export async function storeFixturesv1( req, res ) {
|
|
|
696
698
|
fixture.imageUrl = '';
|
|
697
699
|
}
|
|
698
700
|
productCapacity += fixture.toObject().fixtureCapacity;
|
|
701
|
+
fixtureCount += 1;
|
|
702
|
+
|
|
699
703
|
const productCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'product' } );
|
|
700
704
|
|
|
701
705
|
const vmCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'vm' } );
|
|
@@ -741,10 +745,16 @@ export async function storeFixturesv1( req, res ) {
|
|
|
741
745
|
|
|
742
746
|
const vmDetails = await Promise.all( vms.map( async ( vm ) => {
|
|
743
747
|
const vmTemplate = await planoProductService.findOne( { _id: vm.toObject().productId } );
|
|
744
|
-
|
|
748
|
+
const params = {
|
|
749
|
+
Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
|
|
750
|
+
file_path: vmTemplate?.productImageUrl,
|
|
751
|
+
};
|
|
752
|
+
const vmImage = await signedUrl( params );
|
|
745
753
|
return {
|
|
746
754
|
...vm.toObject(),
|
|
747
755
|
...vmTemplate?.toObject(),
|
|
756
|
+
...( typeof vmImage === 'string' && { productImageUrl: vmImage } ),
|
|
757
|
+
|
|
748
758
|
};
|
|
749
759
|
} ) );
|
|
750
760
|
|
|
@@ -774,6 +784,7 @@ export async function storeFixturesv1( req, res ) {
|
|
|
774
784
|
layoutPolygon: layoutPolygonWithFixtures,
|
|
775
785
|
centerFixture: centerFixturesWithStatus,
|
|
776
786
|
productCount: productCapacity,
|
|
787
|
+
fixtureCount: fixtureCount,
|
|
777
788
|
// productCapacity: productCapacity,
|
|
778
789
|
otherElements: otherElements,
|
|
779
790
|
};
|
|
@@ -1590,7 +1601,8 @@ export const uploadImage = async ( req, res ) => {
|
|
|
1590
1601
|
return res.sendError( { message: 'Something went Wrong' }, 500 );
|
|
1591
1602
|
}
|
|
1592
1603
|
|
|
1593
|
-
|
|
1604
|
+
|
|
1605
|
+
return res.sendSuccess( { message: 'Uploaded Successfully', imgUrl: imgUrl, path: imgUrl.Key } );
|
|
1594
1606
|
} catch ( e ) {
|
|
1595
1607
|
logger.error( 'uploadImage =>', e );
|
|
1596
1608
|
return res.sendError( e, 500 );
|
|
@@ -1626,6 +1638,7 @@ export async function storeFixturesTask( req, res ) {
|
|
|
1626
1638
|
const floorsWithFixtures = await Promise.all(
|
|
1627
1639
|
floors.map( async ( floor ) => {
|
|
1628
1640
|
let productCapacity = 0;
|
|
1641
|
+
let fixtureCount = 0;
|
|
1629
1642
|
const layoutPolygonWithFixtures = await Promise.all(
|
|
1630
1643
|
floor.layoutPolygon.map( async ( element ) => {
|
|
1631
1644
|
const fixtures = await storeFixtureService.findAndSort( {
|
|
@@ -1647,6 +1660,7 @@ export async function storeFixturesTask( req, res ) {
|
|
|
1647
1660
|
fixture.imageUrl = '';
|
|
1648
1661
|
}
|
|
1649
1662
|
productCapacity += fixture.toObject().fixtureCapacity;
|
|
1663
|
+
fixtureCount += 1;
|
|
1650
1664
|
const productCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'product' } );
|
|
1651
1665
|
|
|
1652
1666
|
const vmCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'vm' } );
|
|
@@ -1677,9 +1691,16 @@ export async function storeFixturesTask( req, res ) {
|
|
|
1677
1691
|
|
|
1678
1692
|
const vmDetails = await Promise.all( vms.map( async ( vm ) => {
|
|
1679
1693
|
const vmTemplate = await planoProductService.findOne( { _id: vm.toObject().productId } );
|
|
1694
|
+
const params = {
|
|
1695
|
+
Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
|
|
1696
|
+
file_path: vmTemplate?.productImageUrl,
|
|
1697
|
+
};
|
|
1698
|
+
const vmImage = await signedUrl( params );
|
|
1680
1699
|
return {
|
|
1681
1700
|
...vm.toObject(),
|
|
1682
1701
|
...vmTemplate?.toObject(),
|
|
1702
|
+
...( typeof vmImage === 'string' && { productImageUrl: vmImage } ),
|
|
1703
|
+
|
|
1683
1704
|
};
|
|
1684
1705
|
} ) );
|
|
1685
1706
|
|
|
@@ -1727,6 +1748,7 @@ export async function storeFixturesTask( req, res ) {
|
|
|
1727
1748
|
fixture.imageUrl = '';
|
|
1728
1749
|
}
|
|
1729
1750
|
productCapacity += fixture.toObject().fixtureCapacity;
|
|
1751
|
+
fixtureCount += 1;
|
|
1730
1752
|
const productCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'product' } );
|
|
1731
1753
|
|
|
1732
1754
|
const vmCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'vm' } );
|
|
@@ -1758,9 +1780,16 @@ export async function storeFixturesTask( req, res ) {
|
|
|
1758
1780
|
const vmDetails = await Promise.all( vms.map( async ( vm ) => {
|
|
1759
1781
|
const vmTemplate = await planoProductService.findOne( { _id: vm.toObject().productId } );
|
|
1760
1782
|
|
|
1783
|
+
const params = {
|
|
1784
|
+
Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
|
|
1785
|
+
file_path: vmTemplate?.productImageUrl,
|
|
1786
|
+
};
|
|
1787
|
+
const vmImage = await signedUrl( params );
|
|
1761
1788
|
return {
|
|
1762
1789
|
...vm.toObject(),
|
|
1763
1790
|
...vmTemplate?.toObject(),
|
|
1791
|
+
...( typeof vmImage === 'string' && { productImageUrl: vmImage } ),
|
|
1792
|
+
|
|
1764
1793
|
};
|
|
1765
1794
|
} ) );
|
|
1766
1795
|
|
|
@@ -1790,6 +1819,7 @@ export async function storeFixturesTask( req, res ) {
|
|
|
1790
1819
|
layoutPolygon: layoutPolygonWithFixtures,
|
|
1791
1820
|
centerFixture: centerFixturesWithStatus,
|
|
1792
1821
|
productCount: productCapacity,
|
|
1822
|
+
fixtureCount: fixtureCount,
|
|
1793
1823
|
// productCapacity: productCapacity,
|
|
1794
1824
|
otherElements: otherElements,
|
|
1795
1825
|
};
|
|
@@ -2630,6 +2660,8 @@ export async function storeFixturesv2( req, res ) {
|
|
|
2630
2660
|
const floorsWithFixtures = await Promise.all(
|
|
2631
2661
|
floors.map( async ( floor ) => {
|
|
2632
2662
|
let productCapacity = 0;
|
|
2663
|
+
let fixtureCount = 0;
|
|
2664
|
+
let totalVmCount = 0;
|
|
2633
2665
|
const layoutPolygonWithFixtures = await Promise.all(
|
|
2634
2666
|
floor.layoutPolygon.map( async ( element ) => {
|
|
2635
2667
|
const fixtures = await storeFixtureService.findAndSort( {
|
|
@@ -2651,6 +2683,7 @@ export async function storeFixturesv2( req, res ) {
|
|
|
2651
2683
|
fixture.imageUrl = '';
|
|
2652
2684
|
}
|
|
2653
2685
|
productCapacity += fixture.toObject().fixtureCapacity;
|
|
2686
|
+
fixtureCount += 1;
|
|
2654
2687
|
const productCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'product' } );
|
|
2655
2688
|
|
|
2656
2689
|
const vmCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'vm' } );
|
|
@@ -2694,6 +2727,7 @@ export async function storeFixturesv2( req, res ) {
|
|
|
2694
2727
|
|
|
2695
2728
|
|
|
2696
2729
|
const vmDetails = await Promise.all( fixture.toObject()?.vmConfig?.map( async ( vm ) => {
|
|
2730
|
+
totalVmCount += 1;
|
|
2697
2731
|
const vmInfo = await planoVmService.findOne( { _id: vm.vmId } );
|
|
2698
2732
|
return {
|
|
2699
2733
|
...vm,
|
|
@@ -2745,6 +2779,7 @@ export async function storeFixturesv2( req, res ) {
|
|
|
2745
2779
|
fixture.imageUrl = '';
|
|
2746
2780
|
}
|
|
2747
2781
|
productCapacity += fixture.toObject().fixtureCapacity;
|
|
2782
|
+
fixtureCount += 1;
|
|
2748
2783
|
const productCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'product' } );
|
|
2749
2784
|
|
|
2750
2785
|
const vmCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'vm' } );
|
|
@@ -2788,6 +2823,7 @@ export async function storeFixturesv2( req, res ) {
|
|
|
2788
2823
|
|
|
2789
2824
|
|
|
2790
2825
|
const vmDetails = await Promise.all( fixture.toObject().vmConfig.map( async ( vm ) => {
|
|
2826
|
+
totalVmCount += 1;
|
|
2791
2827
|
const vmInfo = await planoVmService.findOne( { _id: vm.vmId } );
|
|
2792
2828
|
|
|
2793
2829
|
return {
|
|
@@ -2819,6 +2855,8 @@ export async function storeFixturesv2( req, res ) {
|
|
|
2819
2855
|
|
|
2820
2856
|
return {
|
|
2821
2857
|
...floor.toObject(),
|
|
2858
|
+
fixtureCount: fixtureCount,
|
|
2859
|
+
vmCount: totalVmCount,
|
|
2822
2860
|
layoutPolygon: layoutPolygonWithFixtures,
|
|
2823
2861
|
centerFixture: centerFixturesWithStatus,
|
|
2824
2862
|
productCount: productCapacity,
|
|
@@ -2942,6 +2980,8 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
2942
2980
|
const floorsWithFixtures = await Promise.all(
|
|
2943
2981
|
floors.map( async ( floor ) => {
|
|
2944
2982
|
let productCapacity = 0;
|
|
2983
|
+
let fixtureCount = 0;
|
|
2984
|
+
let totalVmCount = 0;
|
|
2945
2985
|
const layoutPolygonWithFixtures = await Promise.all(
|
|
2946
2986
|
floor.layoutPolygon.map( async ( element ) => {
|
|
2947
2987
|
const fixtures = await storeFixtureService.findAndSort( {
|
|
@@ -2963,6 +3003,7 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
2963
3003
|
fixture.imageUrl = '';
|
|
2964
3004
|
}
|
|
2965
3005
|
productCapacity += fixture.toObject().fixtureCapacity;
|
|
3006
|
+
fixtureCount += 1;
|
|
2966
3007
|
const productCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'product' } );
|
|
2967
3008
|
|
|
2968
3009
|
const vmCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'vm' } );
|
|
@@ -2971,9 +3012,9 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
2971
3012
|
fixtureId: fixture._id,
|
|
2972
3013
|
type: req.body?.type ? req.body.type : 'fixture',
|
|
2973
3014
|
date_string: req.body?.date,
|
|
2974
|
-
}, { status: 1 } );
|
|
3015
|
+
}, { status: 1, answers: 1 } );
|
|
2975
3016
|
|
|
2976
|
-
const shelves = await fixtureShelfService.findAndSort( { fixtureId: fixture._id }, {
|
|
3017
|
+
const shelves = await fixtureShelfService.findAndSort( { fixtureId: fixture._id }, { }, { shelfNumber: 1 } );
|
|
2977
3018
|
|
|
2978
3019
|
const shelfDetails = await Promise.all(
|
|
2979
3020
|
shelves.map( async ( shelf ) => {
|
|
@@ -2991,6 +3032,7 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
2991
3032
|
|
|
2992
3033
|
|
|
2993
3034
|
const vmDetails = await Promise.all( fixture.toObject()?.vmConfig?.map( async ( vm ) => {
|
|
3035
|
+
totalVmCount += 1;
|
|
2994
3036
|
const vmInfo = await planoVmService.findOne( { _id: vm.vmId } );
|
|
2995
3037
|
return {
|
|
2996
3038
|
...vm,
|
|
@@ -2998,11 +3040,20 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
2998
3040
|
};
|
|
2999
3041
|
} ) );
|
|
3000
3042
|
|
|
3043
|
+
let disabled = true;
|
|
3044
|
+
if ( compliance?.status && compliance.status == 'incomplete' ) {
|
|
3045
|
+
let issueDetails = compliance?.answers?.[0]?.issues.find( ( ele ) => ele.status == 'disagree' );
|
|
3046
|
+
if ( issueDetails ) {
|
|
3047
|
+
disabled = false;
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
|
|
3001
3051
|
return {
|
|
3002
3052
|
...fixture.toObject(),
|
|
3003
3053
|
status: compliance?.status ? compliance.status : '',
|
|
3004
3054
|
shelfCount: shelves.length,
|
|
3005
3055
|
productCount: productCount,
|
|
3056
|
+
disabled: disabled,
|
|
3006
3057
|
vmCount: vmCount,
|
|
3007
3058
|
shelfConfig: shelfDetails,
|
|
3008
3059
|
vmConfig: vmDetails,
|
|
@@ -3042,6 +3093,7 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3042
3093
|
fixture.imageUrl = '';
|
|
3043
3094
|
}
|
|
3044
3095
|
productCapacity += fixture.toObject().fixtureCapacity;
|
|
3096
|
+
fixtureCount += 1;
|
|
3045
3097
|
const productCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'product' } );
|
|
3046
3098
|
|
|
3047
3099
|
const vmCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'vm' } );
|
|
@@ -3052,7 +3104,7 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3052
3104
|
date_string: req.body?.date,
|
|
3053
3105
|
}, { status: 1 } );
|
|
3054
3106
|
|
|
3055
|
-
const shelves = await fixtureShelfService.findAndSort( { fixtureId: fixture._id }, {
|
|
3107
|
+
const shelves = await fixtureShelfService.findAndSort( { fixtureId: fixture._id }, { }, { shelfNumber: 1 } );
|
|
3056
3108
|
|
|
3057
3109
|
const shelfDetails = await Promise.all(
|
|
3058
3110
|
shelves.map( async ( shelf ) => {
|
|
@@ -3069,6 +3121,7 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3069
3121
|
);
|
|
3070
3122
|
|
|
3071
3123
|
const vmDetails = await Promise.all( fixture.toObject()?.vmConfig?.map( async ( vm ) => {
|
|
3124
|
+
totalVmCount += 1;
|
|
3072
3125
|
const vmInfo = await planoVmService.findOne( { _id: vm.vmId } );
|
|
3073
3126
|
return {
|
|
3074
3127
|
...vm,
|
|
@@ -3099,6 +3152,8 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3099
3152
|
|
|
3100
3153
|
return {
|
|
3101
3154
|
...floor.toObject(),
|
|
3155
|
+
fixtureCount: fixtureCount,
|
|
3156
|
+
vmCount: totalVmCount,
|
|
3102
3157
|
layoutPolygon: layoutPolygonWithFixtures,
|
|
3103
3158
|
centerFixture: centerFixturesWithStatus,
|
|
3104
3159
|
productCount: productCapacity,
|
|
@@ -3121,3 +3176,116 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3121
3176
|
return res.sendError( e, 500 );
|
|
3122
3177
|
}
|
|
3123
3178
|
}
|
|
3179
|
+
|
|
3180
|
+
export async function planoList( req, res ) {
|
|
3181
|
+
try {
|
|
3182
|
+
let inputData = req.body;
|
|
3183
|
+
let limit = inputData?.limit || 10;
|
|
3184
|
+
let page = inputData?.offset - 1 || 0;
|
|
3185
|
+
let skip = limit * page;
|
|
3186
|
+
let query = [
|
|
3187
|
+
{
|
|
3188
|
+
$match: {
|
|
3189
|
+
clientId: inputData.clientId,
|
|
3190
|
+
},
|
|
3191
|
+
},
|
|
3192
|
+
{
|
|
3193
|
+
$lookup: {
|
|
3194
|
+
from: 'storelayouts',
|
|
3195
|
+
let: { plano: '$_id' },
|
|
3196
|
+
pipeline: [
|
|
3197
|
+
{
|
|
3198
|
+
$match: {
|
|
3199
|
+
$expr: {
|
|
3200
|
+
$eq: [ '$planoId', '$$plano' ],
|
|
3201
|
+
},
|
|
3202
|
+
},
|
|
3203
|
+
},
|
|
3204
|
+
{
|
|
3205
|
+
$group: {
|
|
3206
|
+
_id: '',
|
|
3207
|
+
layoutDetails: { $push: { k: '$_id', v: '$status', planoId: '$$plano' } },
|
|
3208
|
+
},
|
|
3209
|
+
},
|
|
3210
|
+
],
|
|
3211
|
+
as: 'layout',
|
|
3212
|
+
},
|
|
3213
|
+
},
|
|
3214
|
+
{ $unwind: { path: '$layout', preserveNullAndEmptyArrays: true } },
|
|
3215
|
+
{
|
|
3216
|
+
$lookup: {
|
|
3217
|
+
from: 'storefixtures',
|
|
3218
|
+
let: { plano: '$_id' },
|
|
3219
|
+
pipeline: [
|
|
3220
|
+
{
|
|
3221
|
+
$match: {
|
|
3222
|
+
$expr: {
|
|
3223
|
+
$eq: [ '$planoId', '$$plano' ],
|
|
3224
|
+
},
|
|
3225
|
+
},
|
|
3226
|
+
},
|
|
3227
|
+
{
|
|
3228
|
+
$group: {
|
|
3229
|
+
_id: '',
|
|
3230
|
+
fixtureCount: { $sum: 1 },
|
|
3231
|
+
vmCount: { $sum: { $size: '$vmConfig' } },
|
|
3232
|
+
fixtureCapacity: { $sum: '$fixtureCapacity' },
|
|
3233
|
+
},
|
|
3234
|
+
},
|
|
3235
|
+
],
|
|
3236
|
+
as: 'fixtureDetails',
|
|
3237
|
+
},
|
|
3238
|
+
},
|
|
3239
|
+
{ $unwind: { path: '$fixtureDetails', preserveNullAndEmptyArrays: true } },
|
|
3240
|
+
{
|
|
3241
|
+
$project: {
|
|
3242
|
+
storeName: 1,
|
|
3243
|
+
layoutName: 1,
|
|
3244
|
+
layoutDetails: '$layout.layoutDetails',
|
|
3245
|
+
fixtureCount: '$fixtureDetails.fixtureCount',
|
|
3246
|
+
vmCount: '$fixtureDetails.vmCount',
|
|
3247
|
+
fixtureCapacity: '$fixtureDetails.fixtureCapacity',
|
|
3248
|
+
status: 1,
|
|
3249
|
+
planoProgress: 1,
|
|
3250
|
+
},
|
|
3251
|
+
},
|
|
3252
|
+
];
|
|
3253
|
+
if ( inputData.sortColumnName && inputData.sortBy ) {
|
|
3254
|
+
query.push( { $sort: { [inputData.sortColumnName]: inputData.sortBy } } );
|
|
3255
|
+
}
|
|
3256
|
+
if ( inputData.searchValue ) {
|
|
3257
|
+
query.push( {
|
|
3258
|
+
$match: {
|
|
3259
|
+
storeName: { $regex: inputData.searchValue, $options: 'i' },
|
|
3260
|
+
},
|
|
3261
|
+
} );
|
|
3262
|
+
}
|
|
3263
|
+
|
|
3264
|
+
query.push( {
|
|
3265
|
+
$facet: {
|
|
3266
|
+
data: [
|
|
3267
|
+
{ $skip: skip },
|
|
3268
|
+
{ $limit: limit },
|
|
3269
|
+
],
|
|
3270
|
+
count: [
|
|
3271
|
+
{ $count: 'total' },
|
|
3272
|
+
],
|
|
3273
|
+
},
|
|
3274
|
+
} );
|
|
3275
|
+
|
|
3276
|
+
let planoDetails = await planoService.aggregate( query );
|
|
3277
|
+
|
|
3278
|
+
if ( !planoDetails[0].data.length ) {
|
|
3279
|
+
return res.sendError( 'No data found', 204 );
|
|
3280
|
+
}
|
|
3281
|
+
let result = {
|
|
3282
|
+
data: planoDetails[0].data,
|
|
3283
|
+
count: planoDetails?.[0]?.count?.[0]?.total || 0,
|
|
3284
|
+
};
|
|
3285
|
+
return res.sendSuccess( result );
|
|
3286
|
+
} catch ( e ) {
|
|
3287
|
+
console.log( e );
|
|
3288
|
+
logger.error( { functionName: 'planoList', error: e } );
|
|
3289
|
+
return res.sendError( e, 500 );
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
@@ -11,7 +11,7 @@ import * as checklistService from '../service/checklist.service.js';
|
|
|
11
11
|
import timeZone from 'dayjs/plugin/timezone.js';
|
|
12
12
|
import * as planoProductService from '../service/planoProduct.service.js';
|
|
13
13
|
import mongoose from 'mongoose';
|
|
14
|
-
const ObjectId = mongoose.Types.ObjectId;
|
|
14
|
+
// const ObjectId = mongoose.Types.ObjectId;
|
|
15
15
|
import * as floorService from '../service/storeBuilder.service.js';
|
|
16
16
|
import * as planoStaticService from '../service/planoStaticData.service.js';
|
|
17
17
|
|
|
@@ -118,10 +118,10 @@ export async function createTask( req, res ) {
|
|
|
118
118
|
}
|
|
119
119
|
let endDate;
|
|
120
120
|
let scheduleEndTime = '11:59 PM';
|
|
121
|
-
let taskConfig = await planoStaticService.findOne( { clientId: req.body.clientId } );
|
|
121
|
+
let taskConfig = await planoStaticService.findOne( { clientId: req.body.clientId, type: 'task' } );
|
|
122
122
|
if ( taskConfig && !req.body?.endTime ) {
|
|
123
|
-
scheduleEndTime = taskConfig
|
|
124
|
-
req.body.days = taskConfig?.dueDay ||
|
|
123
|
+
scheduleEndTime = taskConfig?.dueTime || '11:59 PM';
|
|
124
|
+
req.body.days = taskConfig?.dueDay || 1;
|
|
125
125
|
req.body.geoFencing = taskConfig?.allowedStoreLocation || false;
|
|
126
126
|
}
|
|
127
127
|
if ( req.body?.endTime ) {
|
|
@@ -242,15 +242,14 @@ export async function createTask( req, res ) {
|
|
|
242
242
|
let taskData = { ...data };
|
|
243
243
|
if ( floorDetails.length > 1 ) {
|
|
244
244
|
taskData.checkListName = taskData.checkListName +' - '+ floorDetails[i].floorName;
|
|
245
|
-
taskData.floorId = floorDetails[i]._id;
|
|
246
245
|
}
|
|
246
|
+
taskData.floorId = floorDetails[i]._id;
|
|
247
247
|
taskData.store_id = store.storeId;
|
|
248
248
|
taskData.storeName = store.storeName;
|
|
249
249
|
taskData.userId = userDetails._id;
|
|
250
250
|
taskData.userName = userDetails.userName;
|
|
251
251
|
taskData.userEmail = userDetails.email;
|
|
252
252
|
taskData.planoId = planoDetails?._id;
|
|
253
|
-
console.log( taskData );
|
|
254
253
|
for ( let i=0; i<req.body.days; i++ ) {
|
|
255
254
|
let currDate = dayjs().add( i, 'day' );
|
|
256
255
|
let insertData = { ...taskData, date_string: currDate.format( 'YYYY-MM-DD' ), date_iso: new Date( currDate.format( 'YYYY-MM-DD' ) ), scheduleStartTime_iso: dayjs.utc( `${currDate.format( 'YYYY-MM-DD' )} 12:00 AM`, 'YYYY-MM-DD hh:mm A' ).format() };
|
|
@@ -533,8 +532,12 @@ export async function updateAnswers( req, res ) {
|
|
|
533
532
|
}
|
|
534
533
|
export async function updateAnswersv2( req, res ) {
|
|
535
534
|
try {
|
|
536
|
-
let taskDetails = await processedService.findOne( {
|
|
535
|
+
let taskDetails = await processedService.findOne( { _id: new mongoose.Types.ObjectId( req.body.taskId ) } );
|
|
537
536
|
console.log( taskDetails );
|
|
537
|
+
if ( !taskDetails ) {
|
|
538
|
+
return res.sendError( 'No data found', 204 );
|
|
539
|
+
}
|
|
540
|
+
|
|
538
541
|
let data = {
|
|
539
542
|
fixtureId: req.body.fixtureId,
|
|
540
543
|
answers: req.body.answers,
|
|
@@ -543,9 +546,9 @@ export async function updateAnswersv2( req, res ) {
|
|
|
543
546
|
floorId: req.body.floorId,
|
|
544
547
|
type: req.body.type,
|
|
545
548
|
date_iso: new Date( dayjs().format( 'YYYY-MM-DD' ) ),
|
|
546
|
-
taskId:
|
|
547
|
-
storeName:
|
|
548
|
-
storeId:
|
|
549
|
+
taskId: req.body.taskId,
|
|
550
|
+
storeName: req.body?.storeName,
|
|
551
|
+
storeId: req.body?.storeId,
|
|
549
552
|
};
|
|
550
553
|
console.log( data );
|
|
551
554
|
await planoTaskService.updateOne( { planoId: req.body.planoId, floorId: req.body.floorId, fixtureId: req.body.fixtureId, type: req.body.type, date_string: dayjs().format( 'YYYY-MM-DD' ), ...( taskDetails?._id ) ? { taskId: taskDetails?._id } :{} }, data );
|
|
@@ -729,11 +732,11 @@ export async function generatetaskDetails( req, res ) {
|
|
|
729
732
|
},
|
|
730
733
|
{
|
|
731
734
|
$group: {
|
|
732
|
-
_id: '$
|
|
735
|
+
_id: '$storeName',
|
|
733
736
|
count: { $sum: 1 },
|
|
734
|
-
|
|
737
|
+
planoId: { $last: '$planoId' },
|
|
735
738
|
taskId: { $push: '$_id' },
|
|
736
|
-
checklistStatus: { $
|
|
739
|
+
checklistStatus: { $last: '$checklistStatus' },
|
|
737
740
|
date_string: { $push: '$date_string' },
|
|
738
741
|
},
|
|
739
742
|
},
|
|
@@ -741,11 +744,11 @@ export async function generatetaskDetails( req, res ) {
|
|
|
741
744
|
$project: {
|
|
742
745
|
_id: 0,
|
|
743
746
|
taskId: 1,
|
|
744
|
-
|
|
747
|
+
planoId: 1,
|
|
745
748
|
checklistStatus: 1,
|
|
746
749
|
count: 1,
|
|
747
750
|
date_string: 1,
|
|
748
|
-
|
|
751
|
+
storeName: '$_id',
|
|
749
752
|
},
|
|
750
753
|
},
|
|
751
754
|
];
|
|
@@ -768,7 +771,7 @@ export async function generatetaskDetails( req, res ) {
|
|
|
768
771
|
} ) );
|
|
769
772
|
|
|
770
773
|
processedTaskDetails.forEach( ( item ) => {
|
|
771
|
-
let taskIndex = taskDetails.findIndex( ( taskItem ) => taskItem.checklistStatus
|
|
774
|
+
let taskIndex = taskDetails.findIndex( ( taskItem ) => taskItem.checklistStatus =='submit' && taskItem.date_string.includes( item.date_string ) && item.planoId.toString() == taskItem.planoId.toString() );
|
|
772
775
|
console.log( taskIndex, 'index' );
|
|
773
776
|
if ( taskIndex != -1 ) {
|
|
774
777
|
taskDetails[taskIndex].storeStatus = item.status == 'complete' ? 'yes' : 'No';
|
|
@@ -201,6 +201,7 @@ export const updateTaskConfig = {
|
|
|
201
201
|
export const uploadBrandListSchema = joi.object( {
|
|
202
202
|
clientId: joi.string().required(),
|
|
203
203
|
brandData: joi.array().items( joi.any() ).min( 1 ).required(),
|
|
204
|
+
brandUsedList:joi.array().items(joi.any()).min(0)
|
|
204
205
|
} );
|
|
205
206
|
|
|
206
207
|
export const uploadBrandList = {
|
|
@@ -13,4 +13,6 @@ managePlanoRouter
|
|
|
13
13
|
.get( '/templateList', managePlanoController.templateList )
|
|
14
14
|
.get( '/fixtureBrandsList', managePlanoController.fixtureBrandsList )
|
|
15
15
|
.get( '/fixtureVMList', managePlanoController.fixtureVMList )
|
|
16
|
-
.post( '/updateFixtureStatus', isAllowedSessionHandler, managePlanoController.updateFixtureStatus )
|
|
16
|
+
.post( '/updateFixtureStatus', isAllowedSessionHandler, managePlanoController.updateFixtureStatus )
|
|
17
|
+
.post( '/updateStoreFixture', managePlanoController.updateStoreFixture )
|
|
18
|
+
.post( '/updateStoreFixture', managePlanoController.updateStoreFixture );
|
|
@@ -46,5 +46,7 @@ storeBuilderRouter
|
|
|
46
46
|
.post( '/qrScan', storeBuilderController.qrScan )
|
|
47
47
|
.post( '/storeFixturesV2', validate( validateDtos.storeList ), storeBuilderController.storeFixturesv2 )
|
|
48
48
|
.post( '/fixtureShelfDetailsv2', validate( validateDtos.fixtureShelfProduct ), storeBuilderController.fixtureShelfProductv2 )
|
|
49
|
-
.post( '/storeFixturesTaskv2', storeBuilderController.storeFixturesTaskv2 )
|
|
50
|
-
|
|
49
|
+
.post( '/storeFixturesTaskv2', storeBuilderController.storeFixturesTaskv2 );
|
|
50
|
+
|
|
51
|
+
storeBuilderRouter
|
|
52
|
+
.post( '/planoList', isAllowedSessionHandler, storeBuilderController.planoList );
|
|
@@ -42,3 +42,7 @@ export async function deleteOne( query = {} ) {
|
|
|
42
42
|
export const findAndSort = async ( query={}, field={}, sort={} ) => {
|
|
43
43
|
return await model.fixtureConfigModel.find( query, field ).sort( sort ).collation( { locale: 'en_US', numericOrdering: true } );
|
|
44
44
|
};
|
|
45
|
+
|
|
46
|
+
export const sortAndFindOne = async ( query={}, field={}, sort={} ) => {
|
|
47
|
+
return await model.fixtureConfigModel.find( query, field ).sort( sort ).limit( 1 );
|
|
48
|
+
};
|
|
@@ -36,4 +36,12 @@ export const aggregate = async ( query=[] ) => {
|
|
|
36
36
|
return await model.planoProductCategoryModel.aggregate( query );
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
export async function upsertOne( query, record ) {
|
|
40
|
+
return model.planoProductCategoryModel.findOneAndUpdate(
|
|
41
|
+
query,
|
|
42
|
+
record,
|
|
43
|
+
{ upsert: true, new: true },
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
39
47
|
|