tango-app-api-store-builder 1.0.0-beta-145 → 1.0.0-beta-146
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
|
@@ -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-146",
|
|
4
4
|
"description": "storeBuilder",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"path": "^0.12.7",
|
|
33
33
|
"selenium-webdriver": "^4.31.0",
|
|
34
34
|
"sharp": "^0.34.1",
|
|
35
|
-
"tango-api-schema": "^2.2.
|
|
35
|
+
"tango-api-schema": "^2.2.190",
|
|
36
36
|
"tango-app-api-middleware": "3.1.48",
|
|
37
37
|
"url": "^0.11.4",
|
|
38
38
|
"winston": "^3.17.0",
|
|
@@ -3013,10 +3013,10 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3013
3013
|
|
|
3014
3014
|
const vmCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'vm' } );
|
|
3015
3015
|
|
|
3016
|
-
const compliance = await planoTaskComplianceService.
|
|
3016
|
+
const compliance = await planoTaskComplianceService.findAndSort( {
|
|
3017
3017
|
fixtureId: fixture._id,
|
|
3018
|
-
type: req.body?.type ? req.body.type : 'fixture',
|
|
3019
|
-
}, { status: 1, answers: 1, taskType: 1 } );
|
|
3018
|
+
type: req.body?.type ? req.body.type : 'fixture',
|
|
3019
|
+
}, { status: 1, answers: 1, taskType: 1 }, { _id: -1 } );
|
|
3020
3020
|
|
|
3021
3021
|
const shelves = await fixtureShelfService.findAndSort( { fixtureId: fixture._id }, { }, { shelfNumber: 1 } );
|
|
3022
3022
|
|
|
@@ -3113,10 +3113,10 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3113
3113
|
|
|
3114
3114
|
const vmCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'vm' } );
|
|
3115
3115
|
|
|
3116
|
-
const compliance = await planoTaskComplianceService.
|
|
3116
|
+
const compliance = await planoTaskComplianceService.findAndSort( {
|
|
3117
3117
|
fixtureId: fixture._id,
|
|
3118
|
-
type: req.body?.type ? req.body.type : 'fixture',
|
|
3119
|
-
}, { status: 1, answers: 1, taskType: 1 } );
|
|
3118
|
+
type: req.body?.type ? req.body.type : 'fixture',
|
|
3119
|
+
}, { status: 1, answers: 1, taskType: 1 }, { _id: -1 } );
|
|
3120
3120
|
|
|
3121
3121
|
const shelves = await fixtureShelfService.findAndSort( { fixtureId: fixture._id }, { }, { shelfNumber: 1 } );
|
|
3122
3122
|
|
|
@@ -3241,15 +3241,28 @@ export async function planoList( req, res ) {
|
|
|
3241
3241
|
},
|
|
3242
3242
|
},
|
|
3243
3243
|
{
|
|
3244
|
-
$
|
|
3245
|
-
_id:
|
|
3246
|
-
|
|
3244
|
+
$project: {
|
|
3245
|
+
_id: 0,
|
|
3246
|
+
id: '$_id',
|
|
3247
|
+
floorName: 1,
|
|
3248
|
+
floorNumber: 1,
|
|
3247
3249
|
},
|
|
3248
3250
|
},
|
|
3251
|
+
// {
|
|
3252
|
+
// $group: {
|
|
3253
|
+
// _id: '',
|
|
3254
|
+
// layoutDetails: { $push: { k: '$_id', v: '$status', planoId: '$$plano' } },
|
|
3255
|
+
// },
|
|
3256
|
+
// },
|
|
3249
3257
|
],
|
|
3250
3258
|
as: 'layout',
|
|
3251
3259
|
},
|
|
3252
3260
|
},
|
|
3261
|
+
{
|
|
3262
|
+
$set: {
|
|
3263
|
+
layoutCount: { $size: '$layout' },
|
|
3264
|
+
},
|
|
3265
|
+
},
|
|
3253
3266
|
{ $unwind: { path: '$layout', preserveNullAndEmptyArrays: true } },
|
|
3254
3267
|
{
|
|
3255
3268
|
$lookup: {
|
|
@@ -3279,13 +3292,14 @@ export async function planoList( req, res ) {
|
|
|
3279
3292
|
{
|
|
3280
3293
|
$lookup: {
|
|
3281
3294
|
from: 'processedtasks',
|
|
3282
|
-
let: {
|
|
3295
|
+
let: { floor: '$layout.id' },
|
|
3283
3296
|
pipeline: [
|
|
3284
3297
|
{
|
|
3285
3298
|
$match: {
|
|
3286
3299
|
$expr: {
|
|
3287
3300
|
$and: [
|
|
3288
|
-
{ $eq: [ '$planoId', '$$plano' ] },
|
|
3301
|
+
// { $eq: [ '$planoId', '$$plano' ] },
|
|
3302
|
+
{ $eq: [ '$floorId', '$$floor' ] },
|
|
3289
3303
|
{ $eq: [ '$isPlano', true ] },
|
|
3290
3304
|
{
|
|
3291
3305
|
$lte: [ '$date_iso', new Date( dayjs().format( 'YYYY-MM-DD' ) ) ],
|
|
@@ -3335,15 +3349,17 @@ export async function planoList( req, res ) {
|
|
|
3335
3349
|
$lookup: {
|
|
3336
3350
|
from: 'planotaskcompliances',
|
|
3337
3351
|
let: {
|
|
3338
|
-
plano: '$_id',
|
|
3352
|
+
// plano: '$_id',
|
|
3339
3353
|
task: { $ifNull: [ '$taskIds', [] ] },
|
|
3354
|
+
floor: '$layout.id',
|
|
3340
3355
|
},
|
|
3341
3356
|
pipeline: [
|
|
3342
3357
|
{
|
|
3343
3358
|
$match: {
|
|
3344
3359
|
$expr: {
|
|
3345
3360
|
$and: [
|
|
3346
|
-
{ $eq: [ '$planoId', '$$plano' ] },
|
|
3361
|
+
// { $eq: [ '$planoId', '$$plano' ] },
|
|
3362
|
+
{ $eq: [ '$floorId', '$$floor' ] },
|
|
3347
3363
|
// { $in: [ '$taskId', pendingDetails.map( ( ele ) => ele.taskId ) ] },
|
|
3348
3364
|
// { $eq: [ '$taskType', 'initial' ] },
|
|
3349
3365
|
],
|
|
@@ -3351,6 +3367,19 @@ export async function planoList( req, res ) {
|
|
|
3351
3367
|
},
|
|
3352
3368
|
},
|
|
3353
3369
|
{ $sort: { _id: -1 } },
|
|
3370
|
+
{
|
|
3371
|
+
$group: {
|
|
3372
|
+
_id: { floorId: '$floorId', type: '$type' },
|
|
3373
|
+
doc: { $first: '$$ROOT' },
|
|
3374
|
+
},
|
|
3375
|
+
},
|
|
3376
|
+
{
|
|
3377
|
+
$project: {
|
|
3378
|
+
type: '$_id.type',
|
|
3379
|
+
floorId: '$_id.floorId',
|
|
3380
|
+
answers: '$doc.answers',
|
|
3381
|
+
},
|
|
3382
|
+
},
|
|
3354
3383
|
{
|
|
3355
3384
|
$set: {
|
|
3356
3385
|
hasPendingIssues: {
|
|
@@ -3388,11 +3417,46 @@ export async function planoList( req, res ) {
|
|
|
3388
3417
|
},
|
|
3389
3418
|
},
|
|
3390
3419
|
},
|
|
3420
|
+
hasDisagreeIssues: {
|
|
3421
|
+
$anyElementTrue: {
|
|
3422
|
+
$map: {
|
|
3423
|
+
input: {
|
|
3424
|
+
$reduce: {
|
|
3425
|
+
input: '$answers',
|
|
3426
|
+
initialValue: [],
|
|
3427
|
+
in: {
|
|
3428
|
+
$concatArrays: [
|
|
3429
|
+
'$$value',
|
|
3430
|
+
{
|
|
3431
|
+
$reduce: {
|
|
3432
|
+
input: { $ifNull: [ '$$this.issues', [] ] },
|
|
3433
|
+
initialValue: [],
|
|
3434
|
+
in: {
|
|
3435
|
+
$concatArrays: [
|
|
3436
|
+
'$$value',
|
|
3437
|
+
{ $ifNull: [ '$$this.Details', [] ] },
|
|
3438
|
+
],
|
|
3439
|
+
},
|
|
3440
|
+
},
|
|
3441
|
+
},
|
|
3442
|
+
],
|
|
3443
|
+
},
|
|
3444
|
+
},
|
|
3445
|
+
},
|
|
3446
|
+
as: 'detail',
|
|
3447
|
+
in: {
|
|
3448
|
+
$or: [
|
|
3449
|
+
{ $eq: [ '$$detail.status', 'disagree' ] },
|
|
3450
|
+
],
|
|
3451
|
+
},
|
|
3452
|
+
},
|
|
3453
|
+
},
|
|
3454
|
+
},
|
|
3391
3455
|
},
|
|
3392
3456
|
},
|
|
3393
3457
|
{
|
|
3394
3458
|
$group: {
|
|
3395
|
-
_id: '
|
|
3459
|
+
_id: '',
|
|
3396
3460
|
layoutCount: {
|
|
3397
3461
|
$sum: { $cond: [ { $eq: [ '$type', 'layout' ] }, 1, 0 ] },
|
|
3398
3462
|
},
|
|
@@ -3429,37 +3493,67 @@ export async function planoList( req, res ) {
|
|
|
3429
3493
|
],
|
|
3430
3494
|
},
|
|
3431
3495
|
},
|
|
3432
|
-
|
|
3433
|
-
},
|
|
3434
|
-
{
|
|
3435
|
-
$group: {
|
|
3436
|
-
_id: null,
|
|
3437
|
-
layoutCount: { $sum: '$layoutCount' },
|
|
3438
|
-
fixtureCount: { $sum: '$fixtureCount' },
|
|
3439
|
-
vmCount: { $sum: '$vmCount' },
|
|
3440
|
-
completeLayout: {
|
|
3496
|
+
layoutDisagree: {
|
|
3441
3497
|
$sum: {
|
|
3442
|
-
$cond:
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
},
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3498
|
+
$cond: [
|
|
3499
|
+
{ $and: [ { $eq: [ '$type', 'layout' ] }, '$hasDisagreeIssues' ] },
|
|
3500
|
+
1,
|
|
3501
|
+
0,
|
|
3502
|
+
],
|
|
3503
|
+
},
|
|
3504
|
+
},
|
|
3505
|
+
fixtureDisagree: {
|
|
3506
|
+
$sum: {
|
|
3507
|
+
$cond: [
|
|
3508
|
+
{ $and: [ { $eq: [ '$type', 'fixture' ] }, '$hasDisagreeIssues' ] },
|
|
3509
|
+
1,
|
|
3510
|
+
0,
|
|
3511
|
+
],
|
|
3512
|
+
},
|
|
3513
|
+
},
|
|
3514
|
+
vmDisagree: {
|
|
3515
|
+
$sum: {
|
|
3516
|
+
$cond: [
|
|
3517
|
+
{ $and: [ { $eq: [ '$type', 'vm' ] }, '$hasDisagreeIssues' ] },
|
|
3518
|
+
1,
|
|
3519
|
+
0,
|
|
3520
|
+
],
|
|
3456
3521
|
},
|
|
3457
3522
|
},
|
|
3458
|
-
layoutPending: { $sum: '$layoutPending' },
|
|
3459
|
-
fixturePending: { $sum: '$fixturePending' },
|
|
3460
|
-
vmPending: { $sum: '$vmPending' },
|
|
3461
3523
|
},
|
|
3462
3524
|
},
|
|
3525
|
+
// {
|
|
3526
|
+
// $group: {
|
|
3527
|
+
// _id: null,
|
|
3528
|
+
// layoutCount: { $sum: '$layoutCount' },
|
|
3529
|
+
// fixtureCount: { $sum: '$fixtureCount' },
|
|
3530
|
+
// vmCount: { $sum: '$vmCount' },
|
|
3531
|
+
// completeLayout: {
|
|
3532
|
+
// $sum: {
|
|
3533
|
+
// $cond: {
|
|
3534
|
+
// if: {
|
|
3535
|
+
// $and: [
|
|
3536
|
+
// { '$gt': [ '$layoutCount', 0 ] },
|
|
3537
|
+
// { '$gt': [ '$layoutPending', 0 ] },
|
|
3538
|
+
// { '$gt': [ '$fixtureCount', 0 ] },
|
|
3539
|
+
// { '$gt': [ '$fixturePending', 0 ] },
|
|
3540
|
+
// { '$gt': [ '$vmCount', 0 ] },
|
|
3541
|
+
// { '$gt': [ '$fixturePending', 0 ] },
|
|
3542
|
+
// ],
|
|
3543
|
+
// },
|
|
3544
|
+
// then: 1,
|
|
3545
|
+
// else: 0,
|
|
3546
|
+
// },
|
|
3547
|
+
// },
|
|
3548
|
+
// },
|
|
3549
|
+
// layoutPending: { $sum: '$layoutPending' },
|
|
3550
|
+
// fixturePending: { $sum: '$fixturePending' },
|
|
3551
|
+
// vmPending: { $sum: '$vmPending' },
|
|
3552
|
+
// layoutDisagree: { $sum: '$layoutDisagree' },
|
|
3553
|
+
// fixtureDisagree: { $sum: '$fixtureDisagree' },
|
|
3554
|
+
// vmDisagree: { $sum: '$vmDisagree' },
|
|
3555
|
+
// },
|
|
3556
|
+
// },
|
|
3463
3557
|
{
|
|
3464
3558
|
$project: {
|
|
3465
3559
|
_id: 0,
|
|
@@ -3469,6 +3563,7 @@ export async function planoList( req, res ) {
|
|
|
3469
3563
|
$and: [
|
|
3470
3564
|
{ $gt: [ '$layoutCount', 0 ] },
|
|
3471
3565
|
{ $eq: [ '$layoutPending', 0 ] },
|
|
3566
|
+
{ $eq: [ '$layoutDisagree', 0 ] },
|
|
3472
3567
|
],
|
|
3473
3568
|
},
|
|
3474
3569
|
then: 'complete',
|
|
@@ -3488,7 +3583,25 @@ export async function planoList( req, res ) {
|
|
|
3488
3583
|
],
|
|
3489
3584
|
},
|
|
3490
3585
|
then: 'pending',
|
|
3491
|
-
else:
|
|
3586
|
+
else: {
|
|
3587
|
+
$cond: {
|
|
3588
|
+
if: {
|
|
3589
|
+
$and: [
|
|
3590
|
+
{
|
|
3591
|
+
$gt: [ '$layoutCount', 0 ],
|
|
3592
|
+
},
|
|
3593
|
+
{
|
|
3594
|
+
$gt: [
|
|
3595
|
+
'$layoutDisagree',
|
|
3596
|
+
0,
|
|
3597
|
+
],
|
|
3598
|
+
},
|
|
3599
|
+
],
|
|
3600
|
+
},
|
|
3601
|
+
then: 'disagree',
|
|
3602
|
+
else: '',
|
|
3603
|
+
},
|
|
3604
|
+
},
|
|
3492
3605
|
},
|
|
3493
3606
|
},
|
|
3494
3607
|
},
|
|
@@ -3501,6 +3614,7 @@ export async function planoList( req, res ) {
|
|
|
3501
3614
|
{
|
|
3502
3615
|
$eq: [ '$fixturePending', 0 ],
|
|
3503
3616
|
},
|
|
3617
|
+
{ $eq: [ '$fixtureDisagree', 0 ] },
|
|
3504
3618
|
],
|
|
3505
3619
|
},
|
|
3506
3620
|
then: 'complete',
|
|
@@ -3523,7 +3637,46 @@ export async function planoList( req, res ) {
|
|
|
3523
3637
|
],
|
|
3524
3638
|
},
|
|
3525
3639
|
then: 'pending',
|
|
3526
|
-
else:
|
|
3640
|
+
else: {
|
|
3641
|
+
$cond: {
|
|
3642
|
+
if: {
|
|
3643
|
+
$and: [
|
|
3644
|
+
{
|
|
3645
|
+
$gt: [
|
|
3646
|
+
'$fixtureCount',
|
|
3647
|
+
0,
|
|
3648
|
+
],
|
|
3649
|
+
},
|
|
3650
|
+
{
|
|
3651
|
+
$gt: [
|
|
3652
|
+
'$fixturePending',
|
|
3653
|
+
0,
|
|
3654
|
+
],
|
|
3655
|
+
},
|
|
3656
|
+
],
|
|
3657
|
+
},
|
|
3658
|
+
then: 'pending',
|
|
3659
|
+
else: {
|
|
3660
|
+
$cond: {
|
|
3661
|
+
if: {
|
|
3662
|
+
$and: [
|
|
3663
|
+
{
|
|
3664
|
+
$gt: [ '$fixtureCount', 0 ],
|
|
3665
|
+
},
|
|
3666
|
+
{
|
|
3667
|
+
$gt: [
|
|
3668
|
+
'$fixtureDisagree',
|
|
3669
|
+
0,
|
|
3670
|
+
],
|
|
3671
|
+
},
|
|
3672
|
+
],
|
|
3673
|
+
},
|
|
3674
|
+
then: 'disagree',
|
|
3675
|
+
else: '',
|
|
3676
|
+
},
|
|
3677
|
+
},
|
|
3678
|
+
},
|
|
3679
|
+
},
|
|
3527
3680
|
},
|
|
3528
3681
|
},
|
|
3529
3682
|
},
|
|
@@ -3534,6 +3687,7 @@ export async function planoList( req, res ) {
|
|
|
3534
3687
|
$and: [
|
|
3535
3688
|
{ $gt: [ '$vmCount', 0 ] },
|
|
3536
3689
|
{ $eq: [ '$vmPending', 0 ] },
|
|
3690
|
+
{ $eq: [ '$vmDisagree', 0 ] },
|
|
3537
3691
|
],
|
|
3538
3692
|
},
|
|
3539
3693
|
then: 'complete',
|
|
@@ -3546,7 +3700,25 @@ export async function planoList( req, res ) {
|
|
|
3546
3700
|
],
|
|
3547
3701
|
},
|
|
3548
3702
|
then: 'pending',
|
|
3549
|
-
else:
|
|
3703
|
+
else: {
|
|
3704
|
+
$cond: {
|
|
3705
|
+
if: {
|
|
3706
|
+
$and: [
|
|
3707
|
+
{
|
|
3708
|
+
$gt: [ '$vmCount', 0 ],
|
|
3709
|
+
},
|
|
3710
|
+
{
|
|
3711
|
+
$gt: [
|
|
3712
|
+
'$vmDisagree',
|
|
3713
|
+
0,
|
|
3714
|
+
],
|
|
3715
|
+
},
|
|
3716
|
+
],
|
|
3717
|
+
},
|
|
3718
|
+
then: 'disagree',
|
|
3719
|
+
else: '',
|
|
3720
|
+
},
|
|
3721
|
+
},
|
|
3550
3722
|
},
|
|
3551
3723
|
},
|
|
3552
3724
|
},
|
|
@@ -3558,6 +3730,9 @@ export async function planoList( req, res ) {
|
|
|
3558
3730
|
fixtureCount: 1,
|
|
3559
3731
|
vmCount: 1,
|
|
3560
3732
|
completeLayout: 1,
|
|
3733
|
+
layoutDisagree: 1,
|
|
3734
|
+
fixtureDisagree: 1,
|
|
3735
|
+
vmDisagree: 1,
|
|
3561
3736
|
},
|
|
3562
3737
|
},
|
|
3563
3738
|
],
|
|
@@ -3569,7 +3744,7 @@ export async function planoList( req, res ) {
|
|
|
3569
3744
|
storeId: 1,
|
|
3570
3745
|
storeName: 1,
|
|
3571
3746
|
layoutName: 1,
|
|
3572
|
-
layoutDetails: '$layout
|
|
3747
|
+
layoutDetails: '$layout',
|
|
3573
3748
|
fixtureCount: '$fixtureDetails.fixtureCount',
|
|
3574
3749
|
vmCount: '$fixtureDetails.vmCount',
|
|
3575
3750
|
fixtureCapacity: '$fixtureDetails.fixtureCapacity',
|
|
@@ -3577,9 +3752,9 @@ export async function planoList( req, res ) {
|
|
|
3577
3752
|
planoProgress: 1,
|
|
3578
3753
|
createdAt: 1,
|
|
3579
3754
|
lastUpdate: '$updatedAt',
|
|
3580
|
-
taskDetails: { $ifNull: [ { $arrayElemAt: [ '$taskDetails', 0 ] },
|
|
3755
|
+
taskDetails: { $ifNull: [ { $arrayElemAt: [ '$taskDetails', 0 ] }, {} ] },
|
|
3581
3756
|
planoTask: { $ifNull: [ '$planoTask', [] ] },
|
|
3582
|
-
layoutCount:
|
|
3757
|
+
layoutCount: 1,
|
|
3583
3758
|
},
|
|
3584
3759
|
},
|
|
3585
3760
|
];
|
|
@@ -4133,11 +4308,14 @@ export async function getTaskDetails( req, res ) {
|
|
|
4133
4308
|
if: {
|
|
4134
4309
|
$and: [
|
|
4135
4310
|
{ '$gt': [ '$layoutCount', 0 ] },
|
|
4136
|
-
{ '$
|
|
4311
|
+
{ '$eq': [ '$layoutPending', 0 ] },
|
|
4312
|
+
{ '$eq': [ '$layoutDisagree', 0 ] },
|
|
4137
4313
|
{ '$gt': [ '$fixtureCount', 0 ] },
|
|
4138
|
-
{ '$
|
|
4314
|
+
{ '$eq': [ '$fixturePending', 0 ] },
|
|
4315
|
+
{ '$eq': [ '$fixtureDisagree', 0 ] },
|
|
4139
4316
|
{ '$gt': [ '$vmCount', 0 ] },
|
|
4140
|
-
{ '$
|
|
4317
|
+
{ '$eq': [ '$vmPending', 0 ] },
|
|
4318
|
+
{ '$eq': [ '$vmDisagree', 0 ] },
|
|
4141
4319
|
],
|
|
4142
4320
|
},
|
|
4143
4321
|
then: 1,
|
|
@@ -125,7 +125,7 @@ export async function createTask( req, res ) {
|
|
|
125
125
|
if ( !taskInfo ) {
|
|
126
126
|
return res.sendError( 'No data found', 204 );
|
|
127
127
|
}
|
|
128
|
-
await processedService.updateOne( { _id: req.body.taskId }, { checklistStatus: 'open', redoStatus: true, date_iso: new Date( dayjs().format( 'YYYY-MM-DD' ) ), scheduleStartTime_iso: dayjs.utc( '12:00 AM', 'hh:mm A' ).format(), scheduleEndTime_iso: dayjs.utc( scheduleEndTime, 'hh:mm A' ).format(), date_string: dayjs().format( 'YYYY-MM-DD' ) } );
|
|
128
|
+
await processedService.updateOne( { _id: req.body.taskId }, { checklistStatus: 'open', redoStatus: true, date_iso: new Date( dayjs().format( 'YYYY-MM-DD' ) ), scheduleStartTime_iso: dayjs.utc( '12:00 AM', 'hh:mm A' ).format(), scheduleEndTime_iso: dayjs.utc( scheduleEndTime, 'hh:mm A' ).format(), date_string: dayjs().format( 'YYYY-MM-DD' ), date_iso: new Date( dayjs().format( 'YYYY-MM-DD' ) ) } );
|
|
129
129
|
return res.sendSuccess( 'Task redo triggered successfully' );
|
|
130
130
|
} else {
|
|
131
131
|
let taskDetails = await taskService.find( { isPlano: true, client_id: req.body.clientId, ...( req.body.checkListName )? { checkListName: req.body.checkListName } : {} } );
|
|
@@ -264,7 +264,10 @@ export async function createTask( req, res ) {
|
|
|
264
264
|
let getUserEmail = req.body.stores.find( ( ele ) => ele.store.toLowerCase() == store.storeName.toLowerCase() );
|
|
265
265
|
let planoDetails = await planoService.findOne( { storeName: store.storeName } );
|
|
266
266
|
if ( planoDetails ) {
|
|
267
|
-
|
|
267
|
+
const [ floorDetails, floorCount ] = await Promise.all( [
|
|
268
|
+
await floorService.find( { planoId: planoDetails._id, ...( req.body?.floorId ) ? { _id: req.body?.floorId }:{} }, { _id: 1, floorName: 1 } ),
|
|
269
|
+
await floorService.count( { planoId: planoDetails._id } ),
|
|
270
|
+
] );
|
|
268
271
|
for ( let i=0; i<floorDetails.length; i++ ) {
|
|
269
272
|
if ( getUserEmail ) {
|
|
270
273
|
let query = [
|
|
@@ -284,7 +287,7 @@ export async function createTask( req, res ) {
|
|
|
284
287
|
userDetails = userDetails[0];
|
|
285
288
|
}
|
|
286
289
|
let taskData = { ...data };
|
|
287
|
-
if (
|
|
290
|
+
if ( floorCount > 1 ) {
|
|
288
291
|
taskData.checkListName = taskData.checkListName +' - '+ floorDetails[i].floorName;
|
|
289
292
|
}
|
|
290
293
|
taskData.floorId = floorDetails[i]._id;
|
|
@@ -299,6 +302,9 @@ export async function createTask( req, res ) {
|
|
|
299
302
|
await planoTaskService.deleteMany( { planoId: planoDetails?._id, floorId: taskData?.floorId } );
|
|
300
303
|
planoProgress = 25;
|
|
301
304
|
await processedService.deleteMany( { planoId: planoDetails?._id, floorId: taskData?.floorId, isPlano: true } );
|
|
305
|
+
} else {
|
|
306
|
+
let type = req.body.checkListName == 'Fixture Verification' ? 'fixture' :'vm';
|
|
307
|
+
await planoTaskService.deleteMany( { planoId: planoDetails?._id, floorId: taskData?.floorId, type: type } );
|
|
302
308
|
}
|
|
303
309
|
await planoService.updateOne( { _id: planoDetails?._id }, { $set: { planoProgress } } );
|
|
304
310
|
for ( let j=0; j<req.body.days; j++ ) {
|
|
@@ -521,6 +527,9 @@ export async function updateStatus( req, res ) {
|
|
|
521
527
|
email: req.user.email,
|
|
522
528
|
comment: req.body.comments,
|
|
523
529
|
};
|
|
530
|
+
if ( req.body.status == 'inprogress' ) {
|
|
531
|
+
await processedService.updateOne( { planoId: taskDetails.planoId, userEmail: taskDetails.userEmail, store_id: taskDetails.store_id, ...( taskDetails?.floorId ) ? { floorId: taskDetails.floorId } : {}, date_iso: { $gt: new Date( dayjs().format( 'YYYY-MM-DD' ) ) } }, { checklistStatus: 'inprogress', startTime_string: timeString } );
|
|
532
|
+
}
|
|
524
533
|
await processedService.updateOne( { _id: req.body.taskId }, { checklistStatus: req.body.status, ...( req.body.status == 'inprogress' ) ? { startTime_string: timeString } : { submitTime_string: timeString }, comments: { $push: comments } } );
|
|
525
534
|
if ( req.body.status == 'submit' ) {
|
|
526
535
|
await processedService.deleteMany( { planoId: taskDetails.planoId, userEmail: taskDetails.userEmail, store_id: taskDetails.store_id, ...( taskDetails?.floorId ) ? { floorId: taskDetails.floorId } : {}, date_iso: { $gt: new Date( dayjs().format( 'YYYY-MM-DD' ) ) } } );
|
|
@@ -592,6 +601,7 @@ export async function updateAnswers( req, res ) {
|
|
|
592
601
|
return res.sendError( e, 500 );
|
|
593
602
|
}
|
|
594
603
|
}
|
|
604
|
+
|
|
595
605
|
export async function updateAnswersv2( req, res ) {
|
|
596
606
|
try {
|
|
597
607
|
let taskDetails = await processedService.findOne( { _id: new mongoose.Types.ObjectId( req.body.taskId ) } );
|
|
@@ -5,7 +5,7 @@ import * as taskController from '../controllers/task.controller.js';
|
|
|
5
5
|
export const storeBuilderTaskRouter = express.Router();
|
|
6
6
|
|
|
7
7
|
storeBuilderTaskRouter
|
|
8
|
-
.post( '/createTask', taskController.createTask )
|
|
8
|
+
.post( '/createTask', isAllowedSessionHandler, taskController.createTask )
|
|
9
9
|
.post( '/createPlano', isAllowedSessionHandler, taskController.createPlano )
|
|
10
10
|
.get( '/taskDetails', isAllowedSessionHandler, taskController.getTaskDetails )
|
|
11
11
|
.post( '/uploadImage', isAllowedSessionHandler, taskController.uploadImage )
|
|
@@ -33,3 +33,7 @@ export async function aggregate( query ) {
|
|
|
33
33
|
export async function deleteMany( query ) {
|
|
34
34
|
return model.planoTaskCompliance.deleteMany( query );
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
export async function findAndSort( query={}, field={}, sort={} ) {
|
|
38
|
+
return model.planoTaskCompliance.findOne( query, field ).sort( sort );
|
|
39
|
+
}
|