tango-app-api-store-builder 1.0.0-beta-145 → 1.0.0-beta-147
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 +2 -2
- package/src/controllers/managePlano.controller.js +7 -5
- package/src/controllers/storeBuilder.controller.js +220 -55
- package/src/controllers/task.controller.js +14 -4
- package/src/routes/task.routes.js +1 -1
- package/src/service/planoTask.service.js +4 -0
- package/src/service/storeBuilder.service.js +4 -0
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-147",
|
|
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.191",
|
|
36
36
|
"tango-app-api-middleware": "3.1.48",
|
|
37
37
|
"url": "^0.11.4",
|
|
38
38
|
"winston": "^3.17.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as floorService from '../service/storeBuilder.service.js';
|
|
2
|
-
import { logger } from 'tango-app-api-middleware';
|
|
2
|
+
import { logger, insertOpenSearchData } from 'tango-app-api-middleware';
|
|
3
3
|
// import * as storeService from '../service/store.service.js';
|
|
4
4
|
import * as planoService from '../service/planogram.service.js';
|
|
5
5
|
import * as storeFixtureService from '../service/storeFixture.service.js';
|
|
@@ -302,8 +302,6 @@ function buildPipelineByType( type, planoId, floorId, filterByStatus, filterByAp
|
|
|
302
302
|
},
|
|
303
303
|
},
|
|
304
304
|
},
|
|
305
|
-
|
|
306
|
-
|
|
307
305
|
);
|
|
308
306
|
} else {
|
|
309
307
|
pipeline.push(
|
|
@@ -814,7 +812,7 @@ export async function updateredostatus( req, res ) {
|
|
|
814
812
|
|
|
815
813
|
export async function updateGlobalComment( req, res ) {
|
|
816
814
|
try {
|
|
817
|
-
|
|
815
|
+
let payload ={
|
|
818
816
|
userId: req.user._id,
|
|
819
817
|
userName: req.user.userName,
|
|
820
818
|
comment: req.body.comment,
|
|
@@ -823,7 +821,9 @@ export async function updateGlobalComment( req, res ) {
|
|
|
823
821
|
floorId: new mongoose.Types.ObjectId( req.body.floorId ),
|
|
824
822
|
taskType: req.body.taskType,
|
|
825
823
|
clientId: req.body.clientId,
|
|
826
|
-
}
|
|
824
|
+
};
|
|
825
|
+
await planoGlobalCommentService.create( payload );
|
|
826
|
+
await insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).planoglobalcomments, payload );
|
|
827
827
|
|
|
828
828
|
res.sendSuccess( 'updated successfully' );
|
|
829
829
|
} catch ( e ) {
|
|
@@ -838,6 +838,8 @@ export async function getGlobalComment( req, res ) {
|
|
|
838
838
|
floorId: new mongoose.Types.ObjectId( req.body.floorId ),
|
|
839
839
|
taskType: req.body.taskType,
|
|
840
840
|
} );
|
|
841
|
+
|
|
842
|
+
|
|
841
843
|
res.sendSuccess( layoutComment );
|
|
842
844
|
} catch ( e ) {
|
|
843
845
|
logger.error( { functionName: 'getGlobalComment', error: e } );
|
|
@@ -2645,7 +2645,7 @@ export async function storeFixturesv2( req, res ) {
|
|
|
2645
2645
|
{ storeId: { $in: req.body.id } },
|
|
2646
2646
|
],
|
|
2647
2647
|
},
|
|
2648
|
-
{ storeId: 1, storeName: 1, planoId: '$_id', productResolutionLevel: 1, scanType: 1, clientId: 1, validateShelfSections: 1
|
|
2648
|
+
{ storeId: 1, storeName: 1, planoId: '$_id', productResolutionLevel: 1, scanType: 1, clientId: 1, validateShelfSections: 1 },
|
|
2649
2649
|
);
|
|
2650
2650
|
|
|
2651
2651
|
if ( !planograms?.length ) return res.sendError( 'No data found', 204 );
|
|
@@ -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,25 +3241,38 @@ 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: {
|
|
3256
3269
|
from: 'storefixtures',
|
|
3257
|
-
let: {
|
|
3270
|
+
let: { floor: '$layout.id' },
|
|
3258
3271
|
pipeline: [
|
|
3259
3272
|
{
|
|
3260
3273
|
$match: {
|
|
3261
3274
|
$expr: {
|
|
3262
|
-
$eq: [ '$
|
|
3275
|
+
$eq: [ '$floorId', '$$floor' ],
|
|
3263
3276
|
},
|
|
3264
3277
|
},
|
|
3265
3278
|
},
|
|
@@ -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
|
],
|
|
@@ -3388,11 +3404,46 @@ export async function planoList( req, res ) {
|
|
|
3388
3404
|
},
|
|
3389
3405
|
},
|
|
3390
3406
|
},
|
|
3407
|
+
hasDisagreeIssues: {
|
|
3408
|
+
$anyElementTrue: {
|
|
3409
|
+
$map: {
|
|
3410
|
+
input: {
|
|
3411
|
+
$reduce: {
|
|
3412
|
+
input: '$answers',
|
|
3413
|
+
initialValue: [],
|
|
3414
|
+
in: {
|
|
3415
|
+
$concatArrays: [
|
|
3416
|
+
'$$value',
|
|
3417
|
+
{
|
|
3418
|
+
$reduce: {
|
|
3419
|
+
input: { $ifNull: [ '$$this.issues', [] ] },
|
|
3420
|
+
initialValue: [],
|
|
3421
|
+
in: {
|
|
3422
|
+
$concatArrays: [
|
|
3423
|
+
'$$value',
|
|
3424
|
+
{ $ifNull: [ '$$this.Details', [] ] },
|
|
3425
|
+
],
|
|
3426
|
+
},
|
|
3427
|
+
},
|
|
3428
|
+
},
|
|
3429
|
+
],
|
|
3430
|
+
},
|
|
3431
|
+
},
|
|
3432
|
+
},
|
|
3433
|
+
as: 'detail',
|
|
3434
|
+
in: {
|
|
3435
|
+
$or: [
|
|
3436
|
+
{ $eq: [ '$$detail.status', 'disagree' ] },
|
|
3437
|
+
],
|
|
3438
|
+
},
|
|
3439
|
+
},
|
|
3440
|
+
},
|
|
3441
|
+
},
|
|
3391
3442
|
},
|
|
3392
3443
|
},
|
|
3393
3444
|
{
|
|
3394
3445
|
$group: {
|
|
3395
|
-
_id: '
|
|
3446
|
+
_id: '',
|
|
3396
3447
|
layoutCount: {
|
|
3397
3448
|
$sum: { $cond: [ { $eq: [ '$type', 'layout' ] }, 1, 0 ] },
|
|
3398
3449
|
},
|
|
@@ -3429,37 +3480,67 @@ export async function planoList( req, res ) {
|
|
|
3429
3480
|
],
|
|
3430
3481
|
},
|
|
3431
3482
|
},
|
|
3432
|
-
|
|
3433
|
-
},
|
|
3434
|
-
{
|
|
3435
|
-
$group: {
|
|
3436
|
-
_id: null,
|
|
3437
|
-
layoutCount: { $sum: '$layoutCount' },
|
|
3438
|
-
fixtureCount: { $sum: '$fixtureCount' },
|
|
3439
|
-
vmCount: { $sum: '$vmCount' },
|
|
3440
|
-
completeLayout: {
|
|
3483
|
+
layoutDisagree: {
|
|
3441
3484
|
$sum: {
|
|
3442
|
-
$cond:
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
},
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3485
|
+
$cond: [
|
|
3486
|
+
{ $and: [ { $eq: [ '$type', 'layout' ] }, '$hasDisagreeIssues' ] },
|
|
3487
|
+
1,
|
|
3488
|
+
0,
|
|
3489
|
+
],
|
|
3490
|
+
},
|
|
3491
|
+
},
|
|
3492
|
+
fixtureDisagree: {
|
|
3493
|
+
$sum: {
|
|
3494
|
+
$cond: [
|
|
3495
|
+
{ $and: [ { $eq: [ '$type', 'fixture' ] }, '$hasDisagreeIssues' ] },
|
|
3496
|
+
1,
|
|
3497
|
+
0,
|
|
3498
|
+
],
|
|
3499
|
+
},
|
|
3500
|
+
},
|
|
3501
|
+
vmDisagree: {
|
|
3502
|
+
$sum: {
|
|
3503
|
+
$cond: [
|
|
3504
|
+
{ $and: [ { $eq: [ '$type', 'vm' ] }, '$hasDisagreeIssues' ] },
|
|
3505
|
+
1,
|
|
3506
|
+
0,
|
|
3507
|
+
],
|
|
3456
3508
|
},
|
|
3457
3509
|
},
|
|
3458
|
-
layoutPending: { $sum: '$layoutPending' },
|
|
3459
|
-
fixturePending: { $sum: '$fixturePending' },
|
|
3460
|
-
vmPending: { $sum: '$vmPending' },
|
|
3461
3510
|
},
|
|
3462
3511
|
},
|
|
3512
|
+
// {
|
|
3513
|
+
// $group: {
|
|
3514
|
+
// _id: null,
|
|
3515
|
+
// layoutCount: { $sum: '$layoutCount' },
|
|
3516
|
+
// fixtureCount: { $sum: '$fixtureCount' },
|
|
3517
|
+
// vmCount: { $sum: '$vmCount' },
|
|
3518
|
+
// completeLayout: {
|
|
3519
|
+
// $sum: {
|
|
3520
|
+
// $cond: {
|
|
3521
|
+
// if: {
|
|
3522
|
+
// $and: [
|
|
3523
|
+
// { '$gt': [ '$layoutCount', 0 ] },
|
|
3524
|
+
// { '$gt': [ '$layoutPending', 0 ] },
|
|
3525
|
+
// { '$gt': [ '$fixtureCount', 0 ] },
|
|
3526
|
+
// { '$gt': [ '$fixturePending', 0 ] },
|
|
3527
|
+
// { '$gt': [ '$vmCount', 0 ] },
|
|
3528
|
+
// { '$gt': [ '$fixturePending', 0 ] },
|
|
3529
|
+
// ],
|
|
3530
|
+
// },
|
|
3531
|
+
// then: 1,
|
|
3532
|
+
// else: 0,
|
|
3533
|
+
// },
|
|
3534
|
+
// },
|
|
3535
|
+
// },
|
|
3536
|
+
// layoutPending: { $sum: '$layoutPending' },
|
|
3537
|
+
// fixturePending: { $sum: '$fixturePending' },
|
|
3538
|
+
// vmPending: { $sum: '$vmPending' },
|
|
3539
|
+
// layoutDisagree: { $sum: '$layoutDisagree' },
|
|
3540
|
+
// fixtureDisagree: { $sum: '$fixtureDisagree' },
|
|
3541
|
+
// vmDisagree: { $sum: '$vmDisagree' },
|
|
3542
|
+
// },
|
|
3543
|
+
// },
|
|
3463
3544
|
{
|
|
3464
3545
|
$project: {
|
|
3465
3546
|
_id: 0,
|
|
@@ -3469,6 +3550,7 @@ export async function planoList( req, res ) {
|
|
|
3469
3550
|
$and: [
|
|
3470
3551
|
{ $gt: [ '$layoutCount', 0 ] },
|
|
3471
3552
|
{ $eq: [ '$layoutPending', 0 ] },
|
|
3553
|
+
{ $eq: [ '$layoutDisagree', 0 ] },
|
|
3472
3554
|
],
|
|
3473
3555
|
},
|
|
3474
3556
|
then: 'complete',
|
|
@@ -3488,7 +3570,25 @@ export async function planoList( req, res ) {
|
|
|
3488
3570
|
],
|
|
3489
3571
|
},
|
|
3490
3572
|
then: 'pending',
|
|
3491
|
-
else:
|
|
3573
|
+
else: {
|
|
3574
|
+
$cond: {
|
|
3575
|
+
if: {
|
|
3576
|
+
$and: [
|
|
3577
|
+
{
|
|
3578
|
+
$gt: [ '$layoutCount', 0 ],
|
|
3579
|
+
},
|
|
3580
|
+
{
|
|
3581
|
+
$gt: [
|
|
3582
|
+
'$layoutDisagree',
|
|
3583
|
+
0,
|
|
3584
|
+
],
|
|
3585
|
+
},
|
|
3586
|
+
],
|
|
3587
|
+
},
|
|
3588
|
+
then: 'disagree',
|
|
3589
|
+
else: '',
|
|
3590
|
+
},
|
|
3591
|
+
},
|
|
3492
3592
|
},
|
|
3493
3593
|
},
|
|
3494
3594
|
},
|
|
@@ -3501,6 +3601,7 @@ export async function planoList( req, res ) {
|
|
|
3501
3601
|
{
|
|
3502
3602
|
$eq: [ '$fixturePending', 0 ],
|
|
3503
3603
|
},
|
|
3604
|
+
{ $eq: [ '$fixtureDisagree', 0 ] },
|
|
3504
3605
|
],
|
|
3505
3606
|
},
|
|
3506
3607
|
then: 'complete',
|
|
@@ -3523,7 +3624,46 @@ export async function planoList( req, res ) {
|
|
|
3523
3624
|
],
|
|
3524
3625
|
},
|
|
3525
3626
|
then: 'pending',
|
|
3526
|
-
else:
|
|
3627
|
+
else: {
|
|
3628
|
+
$cond: {
|
|
3629
|
+
if: {
|
|
3630
|
+
$and: [
|
|
3631
|
+
{
|
|
3632
|
+
$gt: [
|
|
3633
|
+
'$fixtureCount',
|
|
3634
|
+
0,
|
|
3635
|
+
],
|
|
3636
|
+
},
|
|
3637
|
+
{
|
|
3638
|
+
$gt: [
|
|
3639
|
+
'$fixturePending',
|
|
3640
|
+
0,
|
|
3641
|
+
],
|
|
3642
|
+
},
|
|
3643
|
+
],
|
|
3644
|
+
},
|
|
3645
|
+
then: 'pending',
|
|
3646
|
+
else: {
|
|
3647
|
+
$cond: {
|
|
3648
|
+
if: {
|
|
3649
|
+
$and: [
|
|
3650
|
+
{
|
|
3651
|
+
$gt: [ '$fixtureCount', 0 ],
|
|
3652
|
+
},
|
|
3653
|
+
{
|
|
3654
|
+
$gt: [
|
|
3655
|
+
'$fixtureDisagree',
|
|
3656
|
+
0,
|
|
3657
|
+
],
|
|
3658
|
+
},
|
|
3659
|
+
],
|
|
3660
|
+
},
|
|
3661
|
+
then: 'disagree',
|
|
3662
|
+
else: '',
|
|
3663
|
+
},
|
|
3664
|
+
},
|
|
3665
|
+
},
|
|
3666
|
+
},
|
|
3527
3667
|
},
|
|
3528
3668
|
},
|
|
3529
3669
|
},
|
|
@@ -3534,6 +3674,7 @@ export async function planoList( req, res ) {
|
|
|
3534
3674
|
$and: [
|
|
3535
3675
|
{ $gt: [ '$vmCount', 0 ] },
|
|
3536
3676
|
{ $eq: [ '$vmPending', 0 ] },
|
|
3677
|
+
{ $eq: [ '$vmDisagree', 0 ] },
|
|
3537
3678
|
],
|
|
3538
3679
|
},
|
|
3539
3680
|
then: 'complete',
|
|
@@ -3546,7 +3687,25 @@ export async function planoList( req, res ) {
|
|
|
3546
3687
|
],
|
|
3547
3688
|
},
|
|
3548
3689
|
then: 'pending',
|
|
3549
|
-
else:
|
|
3690
|
+
else: {
|
|
3691
|
+
$cond: {
|
|
3692
|
+
if: {
|
|
3693
|
+
$and: [
|
|
3694
|
+
{
|
|
3695
|
+
$gt: [ '$vmCount', 0 ],
|
|
3696
|
+
},
|
|
3697
|
+
{
|
|
3698
|
+
$gt: [
|
|
3699
|
+
'$vmDisagree',
|
|
3700
|
+
0,
|
|
3701
|
+
],
|
|
3702
|
+
},
|
|
3703
|
+
],
|
|
3704
|
+
},
|
|
3705
|
+
then: 'disagree',
|
|
3706
|
+
else: '',
|
|
3707
|
+
},
|
|
3708
|
+
},
|
|
3550
3709
|
},
|
|
3551
3710
|
},
|
|
3552
3711
|
},
|
|
@@ -3558,6 +3717,9 @@ export async function planoList( req, res ) {
|
|
|
3558
3717
|
fixtureCount: 1,
|
|
3559
3718
|
vmCount: 1,
|
|
3560
3719
|
completeLayout: 1,
|
|
3720
|
+
layoutDisagree: 1,
|
|
3721
|
+
fixtureDisagree: 1,
|
|
3722
|
+
vmDisagree: 1,
|
|
3561
3723
|
},
|
|
3562
3724
|
},
|
|
3563
3725
|
],
|
|
@@ -3569,7 +3731,7 @@ export async function planoList( req, res ) {
|
|
|
3569
3731
|
storeId: 1,
|
|
3570
3732
|
storeName: 1,
|
|
3571
3733
|
layoutName: 1,
|
|
3572
|
-
layoutDetails: '$layout
|
|
3734
|
+
layoutDetails: '$layout',
|
|
3573
3735
|
fixtureCount: '$fixtureDetails.fixtureCount',
|
|
3574
3736
|
vmCount: '$fixtureDetails.vmCount',
|
|
3575
3737
|
fixtureCapacity: '$fixtureDetails.fixtureCapacity',
|
|
@@ -3577,9 +3739,9 @@ export async function planoList( req, res ) {
|
|
|
3577
3739
|
planoProgress: 1,
|
|
3578
3740
|
createdAt: 1,
|
|
3579
3741
|
lastUpdate: '$updatedAt',
|
|
3580
|
-
taskDetails: { $ifNull: [ { $arrayElemAt: [ '$taskDetails', 0 ] },
|
|
3742
|
+
taskDetails: { $ifNull: [ { $arrayElemAt: [ '$taskDetails', 0 ] }, {} ] },
|
|
3581
3743
|
planoTask: { $ifNull: [ '$planoTask', [] ] },
|
|
3582
|
-
layoutCount:
|
|
3744
|
+
layoutCount: 1,
|
|
3583
3745
|
},
|
|
3584
3746
|
},
|
|
3585
3747
|
];
|
|
@@ -3777,7 +3939,6 @@ export async function planoList( req, res ) {
|
|
|
3777
3939
|
];
|
|
3778
3940
|
|
|
3779
3941
|
let pendingDetails = await planotaskService.aggregate( taskQuery );
|
|
3780
|
-
|
|
3781
3942
|
taskQuery = [
|
|
3782
3943
|
{
|
|
3783
3944
|
$match: {
|
|
@@ -3899,6 +4060,7 @@ export async function planoList( req, res ) {
|
|
|
3899
4060
|
];
|
|
3900
4061
|
|
|
3901
4062
|
pendingDetails = await planoTaskComplianceService.aggregate( taskQuery );
|
|
4063
|
+
// console.log( JSON.stringify( pendingDetails ) );
|
|
3902
4064
|
let result = {
|
|
3903
4065
|
data: planoDetails[0].data,
|
|
3904
4066
|
count: planoDetails?.[0]?.count?.[0]?.total || 0,
|
|
@@ -4133,11 +4295,14 @@ export async function getTaskDetails( req, res ) {
|
|
|
4133
4295
|
if: {
|
|
4134
4296
|
$and: [
|
|
4135
4297
|
{ '$gt': [ '$layoutCount', 0 ] },
|
|
4136
|
-
{ '$
|
|
4298
|
+
{ '$eq': [ '$layoutPending', 0 ] },
|
|
4299
|
+
{ '$eq': [ '$layoutDisagree', 0 ] },
|
|
4137
4300
|
{ '$gt': [ '$fixtureCount', 0 ] },
|
|
4138
|
-
{ '$
|
|
4301
|
+
{ '$eq': [ '$fixturePending', 0 ] },
|
|
4302
|
+
{ '$eq': [ '$fixtureDisagree', 0 ] },
|
|
4139
4303
|
{ '$gt': [ '$vmCount', 0 ] },
|
|
4140
|
-
{ '$
|
|
4304
|
+
{ '$eq': [ '$vmPending', 0 ] },
|
|
4305
|
+
{ '$eq': [ '$vmDisagree', 0 ] },
|
|
4141
4306
|
],
|
|
4142
4307
|
},
|
|
4143
4308
|
then: 1,
|
|
@@ -4363,11 +4528,11 @@ export async function getTaskDetails( req, res ) {
|
|
|
4363
4528
|
|
|
4364
4529
|
let taskInfo = await planotaskService.aggregate( query );
|
|
4365
4530
|
let disabledInfo = [];
|
|
4366
|
-
let floorDetails = await layoutService.findOne( { _id: req.query.floorId }, { isEdited: 1 } );
|
|
4531
|
+
let floorDetails = await layoutService.findOne( { _id: req.query.floorId }, { isEdited: 1, planoProgress: 1 } );
|
|
4367
4532
|
if ( floorDetails && !floorDetails?.isEdited ) {
|
|
4368
4533
|
disabledInfo = taskInfo?.[0]?.taskStatus?.filter( ( ele ) => ( ( ele.feedbackStatus && ![ 'complete', 'disagree' ].includes( ele.feedbackStatus ) ) || ele.status != 'submit' ) && !ele?.breach );
|
|
4369
4534
|
}
|
|
4370
|
-
return res.sendSuccess( { taskDetails: taskInfo?.[0]?.taskStatus, disabled: disabledInfo?.length ? true : false } );
|
|
4535
|
+
return res.sendSuccess( { taskDetails: taskInfo?.[0]?.taskStatus, disabled: disabledInfo?.length ? true : false, planoProgress: floorDetails?.planoProgress ?? 25 } );
|
|
4371
4536
|
} catch ( e ) {
|
|
4372
4537
|
logger.error( { functionName: 'getTaskDetails', error: e } );
|
|
4373
4538
|
return res.sendError( e, 500 );
|
|
@@ -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,8 +302,11 @@ 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
|
-
await
|
|
309
|
+
await floorService.updateOne( { _id: taskData?.floorId }, { planoProgress } );
|
|
304
310
|
for ( let j=0; j<req.body.days; j++ ) {
|
|
305
311
|
let currDate = dayjs().add( j, 'day' );
|
|
306
312
|
let time = '12:00 AM';
|
|
@@ -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
|
+
}
|