@steedos-labs/content-compliance-bev 0.2.6 → 0.2.8
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/dist/index.js +1 -1
- package/lib/actions/spotCheckMaterial.d.ts +12 -0
- package/lib/actions/spotCheckMaterial.js +282 -91
- package/lib/actions/spotCheckMaterial.js.map +1 -1
- package/main/default/objects/pepsico_material/buttons/pepsico_material_spot_check.button.yml +1 -1
- package/main/default/objects/pepsico_material/fields/spot_check_type.field.yml +2 -0
- package/package.json +1 -1
|
@@ -116,3 +116,15 @@ export declare const remindSpotCheckIncomplete: {
|
|
|
116
116
|
message?: undefined;
|
|
117
117
|
}>;
|
|
118
118
|
};
|
|
119
|
+
export declare const testSpotCheckNotifications: {
|
|
120
|
+
rest: {
|
|
121
|
+
method: string;
|
|
122
|
+
fullPath: string;
|
|
123
|
+
};
|
|
124
|
+
handler(ctx: any): Promise<{
|
|
125
|
+
success: boolean;
|
|
126
|
+
message: string;
|
|
127
|
+
count: number;
|
|
128
|
+
results: any[];
|
|
129
|
+
}>;
|
|
130
|
+
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.remindSpotCheckIncomplete = exports.generateSpotCheckPool = exports.clickPoolSpotEmail = exports.clickReportSpotEmail = exports.sendMonthlySpotCheckReport = exports.clickSpotEmail = exports.spotCheckMaterial = void 0;
|
|
3
|
+
exports.testSpotCheckNotifications = exports.remindSpotCheckIncomplete = exports.generateSpotCheckPool = exports.clickPoolSpotEmail = exports.clickReportSpotEmail = exports.sendMonthlySpotCheckReport = exports.clickSpotEmail = exports.spotCheckMaterial = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var lodash_1 = require("lodash");
|
|
6
6
|
var axios_1 = require("axios");
|
|
7
7
|
var collection_1 = require("./collection");
|
|
8
8
|
var moment = require('moment');
|
|
9
|
+
var MICRO_SPOT_CHECK_TYPES = ['审核专员抽查', '固定人员抽查'];
|
|
9
10
|
var sendEmail = function (from, to, subject, text, html, cc) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
10
11
|
var result;
|
|
11
12
|
return tslib_1.__generator(this, function (_a) {
|
|
@@ -110,8 +111,8 @@ exports.spotCheckMaterial = {
|
|
|
110
111
|
checkUsers = '';
|
|
111
112
|
spot_checked_done = false;
|
|
112
113
|
spot_checked_done_time = null;
|
|
113
|
-
if (!(material.spot_check_type
|
|
114
|
-
if (material.spot_check_type
|
|
114
|
+
if (!((0, lodash_1.includes)(MICRO_SPOT_CHECK_TYPES, material.spot_check_type) || material.spot_check_type === '四部门抽查')) return [3, 8];
|
|
115
|
+
if ((0, lodash_1.includes)(MICRO_SPOT_CHECK_TYPES, material.spot_check_type)) {
|
|
115
116
|
if (material.guding_spot_check != true && (0, lodash_1.includes)(material.guding_spot_check_user, user.userId)) {
|
|
116
117
|
checkRole = '审核专员';
|
|
117
118
|
checkField = 'guding_spot_check';
|
|
@@ -890,7 +891,7 @@ exports.generateSpotCheckPool = {
|
|
|
890
891
|
},
|
|
891
892
|
handler: function (ctx) {
|
|
892
893
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
893
|
-
var user, pid, logger, pool, yearMonth, pools, logs, logs_1, departmentUserIds_2, _a, _b, material, approval, _c, _d, field, users, e_5_1, specialistUserIds_2, _e, _f, material, approval, sUsers, e_6_1, ROOT_URL, midTierSubject, microSubject, midTierLink, midTierHtml, departmentToUsers, toUsersAll, error_6, midTierResult, _g, microLink, microHtml, specialistToUsers, toUsersAll, error_7, microResult, _h, fromUserId, departmentUserIds_1, departmentUserIds_1_1, userId, e_7_1, specialistUserIds_1, specialistUserIds_1_1, userId, e_8_1, error_8, error_9, message, updateError_1;
|
|
894
|
+
var user, pid, logger, pool, yearMonth, pools, logs, logs_1, departmentUserIds_2, _a, _b, material, approval, _c, _d, field, users, e_5_1, specialistUserIds_2, _e, _f, material, approval, sUsers, e_6_1, ROOT_URL, midTierSubject, microSubject, midTierPageUrl, microPageUrl, midTierLink, midTierHtml, departmentToUsers, toUsersAll, error_6, midTierResult, _g, microLink, microHtml, specialistToUsers, toUsersAll, error_7, microResult, _h, fromUserId, departmentUserIds_1, departmentUserIds_1_1, userId, e_7_1, specialistUserIds_1, specialistUserIds_1_1, userId, e_8_1, error_8, error_9, message, updateError_1;
|
|
894
895
|
var e_5, _j, e_9, _k, e_6, _l, e_7, _m, e_8, _o;
|
|
895
896
|
return tslib_1.__generator(this, function (_p) {
|
|
896
897
|
switch (_p.label) {
|
|
@@ -1046,7 +1047,9 @@ exports.generateSpotCheckPool = {
|
|
|
1046
1047
|
ROOT_URL = process.env.ROOT_URL;
|
|
1047
1048
|
midTierSubject = '【系统通知】腰部素材抽查通知';
|
|
1048
1049
|
microSubject = '【系统通知】尾部素材抽查通知';
|
|
1049
|
-
|
|
1050
|
+
midTierPageUrl = "/app/pepsico_content_review/page/pepsico_midtier_spot_check";
|
|
1051
|
+
microPageUrl = "/app/pepsico_content_review/page/pepsico_spot_check";
|
|
1052
|
+
midTierLink = "".concat(ROOT_URL).concat(midTierPageUrl);
|
|
1050
1053
|
midTierHtml = "\n <p>\u4EB2\u7231\u7684\u7528\u6237\uFF0C</p>\n <p>\u3010".concat(yearMonth, "\u3011\u6708\u5EA6\u62BD\u67E5\u7D20\u6750\u6C60\u5DF2\u751F\u6210\u3002\u8BF7\u70B9\u51FB\u4EE5\u4E0B\u94FE\u63A5\u8FDB\u5165\u62BD\u67E5\u9875\u9762\uFF1A</p>\n <p><a href=\"").concat(midTierLink, "\">\u70B9\u51FB\u8FDB\u5165\u62BD\u67E5</a></p>\n <p>\u6709\u4EFB\u4F55\u7591\u95EE\uFF0C\u8BF7\u8054\u7CFB\u7CFB\u7EDF\u7BA1\u7406\u5458\u3002</p>\n <p>\u8C22\u8C22\uFF01</p>\n ");
|
|
1051
1054
|
departmentToUsers = [];
|
|
1052
1055
|
if (!(departmentUserIds_2.size > 0)) return [3, 28];
|
|
@@ -1073,7 +1076,7 @@ exports.generateSpotCheckPool = {
|
|
|
1073
1076
|
_p.label = 31;
|
|
1074
1077
|
case 31:
|
|
1075
1078
|
midTierResult = _g;
|
|
1076
|
-
microLink = "".concat(ROOT_URL
|
|
1079
|
+
microLink = "".concat(ROOT_URL).concat(microPageUrl);
|
|
1077
1080
|
microHtml = "\n <p>\u4EB2\u7231\u7684\u7528\u6237\uFF0C</p>\n <p>\u3010".concat(yearMonth, "\u3011\u6708\u5EA6\u62BD\u67E5\u7D20\u6750\u6C60\u5DF2\u751F\u6210\u3002\u8BF7\u70B9\u51FB\u4EE5\u4E0B\u94FE\u63A5\u8FDB\u5165\u62BD\u67E5\u9875\u9762\uFF1A</p>\n <p><a href=\"").concat(microLink, "\">\u70B9\u51FB\u8FDB\u5165\u62BD\u67E5</a></p>\n <p>\u6709\u4EFB\u4F55\u7591\u95EE\uFF0C\u8BF7\u8054\u7CFB\u7CFB\u7EDF\u7BA1\u7406\u5458\u3002</p>\n <p>\u8C22\u8C22\uFF01</p>\n ");
|
|
1078
1081
|
specialistToUsers = [];
|
|
1079
1082
|
if (!(specialistUserIds_2.size > 0)) return [3, 35];
|
|
@@ -1116,8 +1119,9 @@ exports.generateSpotCheckPool = {
|
|
|
1116
1119
|
message: {
|
|
1117
1120
|
name: "\u3010".concat(yearMonth, "\u3011\u6708\u5EA6\u62BD\u67E5\u7D20\u6750\u6C60\u5DF2\u751F\u6210\uFF0C\u8BF7\u8FDB\u884C\u8170\u90E8\u7D20\u6750\u62BD\u67E5"),
|
|
1118
1121
|
body: '',
|
|
1119
|
-
related_to: { o: '
|
|
1120
|
-
|
|
1122
|
+
related_to: { o: 'notifications', ids: ['none'] },
|
|
1123
|
+
url: midTierPageUrl,
|
|
1124
|
+
related_name: '腰部素材抽查',
|
|
1121
1125
|
from: fromUserId,
|
|
1122
1126
|
space: pool.space
|
|
1123
1127
|
},
|
|
@@ -1152,8 +1156,9 @@ exports.generateSpotCheckPool = {
|
|
|
1152
1156
|
message: {
|
|
1153
1157
|
name: "\u3010".concat(yearMonth, "\u3011\u6708\u5EA6\u62BD\u67E5\u7D20\u6750\u6C60\u5DF2\u751F\u6210\uFF0C\u8BF7\u8FDB\u884C\u5C3E\u90E8\u7D20\u6750\u62BD\u67E5"),
|
|
1154
1158
|
body: '',
|
|
1155
|
-
related_to: { o: '
|
|
1156
|
-
|
|
1159
|
+
related_to: { o: 'notifications', ids: ['none'] },
|
|
1160
|
+
url: microPageUrl,
|
|
1161
|
+
related_name: '尾部素材抽查',
|
|
1157
1162
|
from: fromUserId,
|
|
1158
1163
|
space: pool.space
|
|
1159
1164
|
},
|
|
@@ -1234,8 +1239,8 @@ exports.remindSpotCheckIncomplete = {
|
|
|
1234
1239
|
},
|
|
1235
1240
|
handler: function (ctx) {
|
|
1236
1241
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1237
|
-
var user, logger, yearMonth, pendingUsers, midTierMaterials, midTierMaterials_1, midTierMaterials_1_1, material, deptFields, deptFields_1, deptFields_1_1, _a, done, user_1, users, users_2, users_2_1, uid, existing, microMaterials, microMaterials_1, microMaterials_1_1, material, users, users_3, users_3_1, uid, existing, ROOT_URL, midTierLink, microLink, subject, results, userIds, spaceUsers, _loop_2, pendingUsers_1, pendingUsers_1_1, _b, userId, info,
|
|
1238
|
-
var
|
|
1242
|
+
var user, logger, yearMonth, pendingUsers, midTierMaterials, midTierMaterials_1, midTierMaterials_1_1, material, deptFields, deptFields_1, deptFields_1_1, _a, done, user_1, users, users_2, users_2_1, uid, existing, microMaterials, microMaterials_1, microMaterials_1_1, material, users, approval, users_3, users_3_1, uid, existing, e_10_1, ROOT_URL, midTierPageUrl, microPageUrl, midTierLink, microLink, subject, results, userIds, spaceUsers, _loop_2, pendingUsers_1, pendingUsers_1_1, _b, userId, info, e_11_1;
|
|
1243
|
+
var e_12, _c, e_13, _d, e_14, _e, e_10, _f, e_15, _g, e_11, _h;
|
|
1239
1244
|
return tslib_1.__generator(this, function (_j) {
|
|
1240
1245
|
switch (_j.label) {
|
|
1241
1246
|
case 0:
|
|
@@ -1281,12 +1286,12 @@ exports.remindSpotCheckIncomplete = {
|
|
|
1281
1286
|
{ done: 'ca_spot_check', user: 'ca_spot_check_user' },
|
|
1282
1287
|
];
|
|
1283
1288
|
try {
|
|
1284
|
-
for (deptFields_1 = (
|
|
1289
|
+
for (deptFields_1 = (e_13 = void 0, tslib_1.__values(deptFields)), deptFields_1_1 = deptFields_1.next(); !deptFields_1_1.done; deptFields_1_1 = deptFields_1.next()) {
|
|
1285
1290
|
_a = deptFields_1_1.value, done = _a.done, user_1 = _a.user;
|
|
1286
1291
|
if (!material[done] && material[user_1]) {
|
|
1287
1292
|
users = Array.isArray(material[user_1]) ? material[user_1] : [material[user_1]];
|
|
1288
1293
|
try {
|
|
1289
|
-
for (users_2 = (
|
|
1294
|
+
for (users_2 = (e_14 = void 0, tslib_1.__values(users)), users_2_1 = users_2.next(); !users_2_1.done; users_2_1 = users_2.next()) {
|
|
1290
1295
|
uid = users_2_1.value;
|
|
1291
1296
|
if (uid) {
|
|
1292
1297
|
existing = pendingUsers.get(uid) || { midTierCount: 0, microCount: 0 };
|
|
@@ -1295,37 +1300,37 @@ exports.remindSpotCheckIncomplete = {
|
|
|
1295
1300
|
}
|
|
1296
1301
|
}
|
|
1297
1302
|
}
|
|
1298
|
-
catch (
|
|
1303
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
1299
1304
|
finally {
|
|
1300
1305
|
try {
|
|
1301
1306
|
if (users_2_1 && !users_2_1.done && (_e = users_2.return)) _e.call(users_2);
|
|
1302
1307
|
}
|
|
1303
|
-
finally { if (
|
|
1308
|
+
finally { if (e_14) throw e_14.error; }
|
|
1304
1309
|
}
|
|
1305
1310
|
}
|
|
1306
1311
|
}
|
|
1307
1312
|
}
|
|
1308
|
-
catch (
|
|
1313
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
1309
1314
|
finally {
|
|
1310
1315
|
try {
|
|
1311
1316
|
if (deptFields_1_1 && !deptFields_1_1.done && (_d = deptFields_1.return)) _d.call(deptFields_1);
|
|
1312
1317
|
}
|
|
1313
|
-
finally { if (
|
|
1318
|
+
finally { if (e_13) throw e_13.error; }
|
|
1314
1319
|
}
|
|
1315
1320
|
}
|
|
1316
1321
|
}
|
|
1317
|
-
catch (
|
|
1322
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
1318
1323
|
finally {
|
|
1319
1324
|
try {
|
|
1320
1325
|
if (midTierMaterials_1_1 && !midTierMaterials_1_1.done && (_c = midTierMaterials_1.return)) _c.call(midTierMaterials_1);
|
|
1321
1326
|
}
|
|
1322
|
-
finally { if (
|
|
1327
|
+
finally { if (e_12) throw e_12.error; }
|
|
1323
1328
|
}
|
|
1324
1329
|
return [4, ctx.getObject('pepsico_material').find({
|
|
1325
1330
|
filters: [
|
|
1326
1331
|
['spot_checked', '=', true],
|
|
1327
1332
|
['spot_checked_done', '!=', true],
|
|
1328
|
-
['spot_check_type', '
|
|
1333
|
+
['spot_check_type', 'in', MICRO_SPOT_CHECK_TYPES]
|
|
1329
1334
|
]
|
|
1330
1335
|
})];
|
|
1331
1336
|
case 5:
|
|
@@ -1336,69 +1341,97 @@ exports.remindSpotCheckIncomplete = {
|
|
|
1336
1341
|
})];
|
|
1337
1342
|
case 6:
|
|
1338
1343
|
_j.sent();
|
|
1344
|
+
_j.label = 7;
|
|
1345
|
+
case 7:
|
|
1346
|
+
_j.trys.push([7, 14, 15, 16]);
|
|
1347
|
+
microMaterials_1 = tslib_1.__values(microMaterials), microMaterials_1_1 = microMaterials_1.next();
|
|
1348
|
+
_j.label = 8;
|
|
1349
|
+
case 8:
|
|
1350
|
+
if (!!microMaterials_1_1.done) return [3, 13];
|
|
1351
|
+
material = microMaterials_1_1.value;
|
|
1352
|
+
if (!!material.guding_spot_check) return [3, 12];
|
|
1353
|
+
users = Array.isArray(material.guding_spot_check_user) ? material.guding_spot_check_user : (0, lodash_1.compact)([material.guding_spot_check_user]);
|
|
1354
|
+
if (!(users.length === 0 && material.pepsico_material_approval)) return [3, 11];
|
|
1355
|
+
return [4, ctx.getObject('pepsico_material_approval').findOne(material.pepsico_material_approval)];
|
|
1356
|
+
case 9:
|
|
1357
|
+
approval = _j.sent();
|
|
1358
|
+
users = Array.isArray(approval === null || approval === void 0 ? void 0 : approval.special_spot_check) ? approval.special_spot_check : (0, lodash_1.compact)([approval === null || approval === void 0 ? void 0 : approval.special_spot_check]);
|
|
1359
|
+
return [4, logger.info('[抽查催办] 尾部素材剩余抽查人为空,使用审批单专员抽查人兜底', {
|
|
1360
|
+
materialId: material._id,
|
|
1361
|
+
approvalId: material.pepsico_material_approval,
|
|
1362
|
+
userCount: users.length
|
|
1363
|
+
})];
|
|
1364
|
+
case 10:
|
|
1365
|
+
_j.sent();
|
|
1366
|
+
_j.label = 11;
|
|
1367
|
+
case 11:
|
|
1339
1368
|
try {
|
|
1340
|
-
for (
|
|
1341
|
-
|
|
1342
|
-
if (
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
uid = users_3_1.value;
|
|
1347
|
-
if (uid) {
|
|
1348
|
-
existing = pendingUsers.get(uid) || { midTierCount: 0, microCount: 0 };
|
|
1349
|
-
existing.microCount++;
|
|
1350
|
-
pendingUsers.set(uid, existing);
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
1355
|
-
finally {
|
|
1356
|
-
try {
|
|
1357
|
-
if (users_3_1 && !users_3_1.done && (_g = users_3.return)) _g.call(users_3);
|
|
1358
|
-
}
|
|
1359
|
-
finally { if (e_15) throw e_15.error; }
|
|
1360
|
-
}
|
|
1369
|
+
for (users_3 = (e_15 = void 0, tslib_1.__values(users)), users_3_1 = users_3.next(); !users_3_1.done; users_3_1 = users_3.next()) {
|
|
1370
|
+
uid = users_3_1.value;
|
|
1371
|
+
if (uid) {
|
|
1372
|
+
existing = pendingUsers.get(uid) || { midTierCount: 0, microCount: 0 };
|
|
1373
|
+
existing.microCount++;
|
|
1374
|
+
pendingUsers.set(uid, existing);
|
|
1361
1375
|
}
|
|
1362
1376
|
}
|
|
1363
1377
|
}
|
|
1364
|
-
catch (
|
|
1378
|
+
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
1365
1379
|
finally {
|
|
1366
1380
|
try {
|
|
1367
|
-
if (
|
|
1381
|
+
if (users_3_1 && !users_3_1.done && (_g = users_3.return)) _g.call(users_3);
|
|
1368
1382
|
}
|
|
1369
|
-
finally { if (
|
|
1383
|
+
finally { if (e_15) throw e_15.error; }
|
|
1384
|
+
}
|
|
1385
|
+
_j.label = 12;
|
|
1386
|
+
case 12:
|
|
1387
|
+
microMaterials_1_1 = microMaterials_1.next();
|
|
1388
|
+
return [3, 8];
|
|
1389
|
+
case 13: return [3, 16];
|
|
1390
|
+
case 14:
|
|
1391
|
+
e_10_1 = _j.sent();
|
|
1392
|
+
e_10 = { error: e_10_1 };
|
|
1393
|
+
return [3, 16];
|
|
1394
|
+
case 15:
|
|
1395
|
+
try {
|
|
1396
|
+
if (microMaterials_1_1 && !microMaterials_1_1.done && (_f = microMaterials_1.return)) _f.call(microMaterials_1);
|
|
1370
1397
|
}
|
|
1371
|
-
if (
|
|
1398
|
+
finally { if (e_10) throw e_10.error; }
|
|
1399
|
+
return [7];
|
|
1400
|
+
case 16:
|
|
1401
|
+
if (!(pendingUsers.size === 0)) return [3, 18];
|
|
1372
1402
|
console.log("[remindSpotCheckIncomplete] \u65E0\u672A\u5B8C\u6210\u62BD\u67E5\u4EFB\u52A1\uFF0C\u65E0\u9700\u50AC\u529E\u3002");
|
|
1373
1403
|
return [4, logger.info('[抽查催办] 无未完成抽查任务,无需催办', {
|
|
1374
1404
|
midTierCount: midTierMaterials.length,
|
|
1375
1405
|
microCount: microMaterials.length
|
|
1376
1406
|
})];
|
|
1377
|
-
case
|
|
1407
|
+
case 17:
|
|
1378
1408
|
_j.sent();
|
|
1379
1409
|
return [2, { success: true, message: '无未完成抽查任务' }];
|
|
1380
|
-
case
|
|
1410
|
+
case 18:
|
|
1381
1411
|
console.log("[remindSpotCheckIncomplete] \u9700\u50AC\u529E\u7528\u6237\u6570: ".concat(pendingUsers.size));
|
|
1382
1412
|
return [4, logger.info('[抽查催办] 需催办用户统计', {
|
|
1383
1413
|
userCount: pendingUsers.size,
|
|
1384
1414
|
midTierCount: midTierMaterials.length,
|
|
1385
1415
|
microCount: microMaterials.length
|
|
1386
1416
|
})];
|
|
1387
|
-
case
|
|
1417
|
+
case 19:
|
|
1388
1418
|
_j.sent();
|
|
1389
1419
|
ROOT_URL = process.env.ROOT_URL;
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1420
|
+
midTierPageUrl = "/app/pepsico_content_review/page/pepsico_midtier_spot_check";
|
|
1421
|
+
microPageUrl = "/app/pepsico_content_review/page/pepsico_spot_check";
|
|
1422
|
+
midTierLink = "".concat(ROOT_URL).concat(midTierPageUrl);
|
|
1423
|
+
microLink = "".concat(ROOT_URL).concat(microPageUrl);
|
|
1424
|
+
subject = '【系统通知】您有未完成的素材抽查工作';
|
|
1393
1425
|
results = [];
|
|
1394
1426
|
userIds = Array.from(pendingUsers.keys());
|
|
1395
1427
|
return [4, ctx.getObject('space_users').find({ filters: ['user', 'in', userIds] })];
|
|
1396
|
-
case
|
|
1428
|
+
case 20:
|
|
1397
1429
|
spaceUsers = _j.sent();
|
|
1398
1430
|
_loop_2 = function (userId, info) {
|
|
1399
|
-
var spaceUser, totalCount, linkHtml, html, error_10, error_11;
|
|
1400
|
-
|
|
1401
|
-
|
|
1431
|
+
var spaceUser, totalCount, linkHtml, html, error_10, notificationItems, notificationItems_1, notificationItems_1_1, item, e_16_1, error_11;
|
|
1432
|
+
var e_16, _k;
|
|
1433
|
+
return tslib_1.__generator(this, function (_l) {
|
|
1434
|
+
switch (_l.label) {
|
|
1402
1435
|
case 0:
|
|
1403
1436
|
spaceUser = (0, lodash_1.find)(spaceUsers, function (u) { return u.user === userId; });
|
|
1404
1437
|
if (!spaceUser)
|
|
@@ -1408,79 +1441,115 @@ exports.remindSpotCheckIncomplete = {
|
|
|
1408
1441
|
info.midTierCount > 0 ? "<p><a href=\"".concat(midTierLink, "\">\u70B9\u51FB\u8FDB\u5165\u8170\u90E8\u7D20\u6750\u62BD\u67E5</a></p>") : '',
|
|
1409
1442
|
info.microCount > 0 ? "<p><a href=\"".concat(microLink, "\">\u70B9\u51FB\u8FDB\u5165\u5C3E\u90E8\u7D20\u6750\u62BD\u67E5</a></p>") : ''
|
|
1410
1443
|
].join('');
|
|
1411
|
-
html = "\n <p>\u4EB2\u7231\u7684\u5BA1\u6838\u8001\u5E08\uFF0C</p>\n <p>\u60A8\u5728\u5BA1\u6838\u7CFB\u7EDF\uFF0C\
|
|
1444
|
+
html = "\n <p>\u4EB2\u7231\u7684\u5BA1\u6838\u8001\u5E08\uFF0C</p>\n <p>\u60A8\u5728\u5BA1\u6838\u7CFB\u7EDF\uFF0C\u7D20\u6750\u62BD\u67E5\u5E93\u4E2D\u8FD8\u6709 <b>".concat(totalCount, "</b> \u4E2A\u7D20\u6750\u672A\u5B8C\u6210\u62BD\u67E5\u5DE5\u4F5C\uFF0C\u8BF7\u767B\u5F55\u7CFB\u7EDF\u8FDB\u884C\u62BD\u67E5\u3002</p>\n <p>\u8BF7\u70B9\u51FB\u4EE5\u4E0B\u94FE\u63A5\u8FDB\u5165\u62BD\u67E5\u9875\u9762\uFF1A</p>\n ").concat(linkHtml, "\n <p>\u5982\u6709\u7591\u95EE\uFF0C\u8BF7\u8054\u7CFB\u7CFB\u7EDF\u7BA1\u7406\u5458\u3002</p>\n ");
|
|
1412
1445
|
if (!(spaceUser.email && spaceUser.email.endsWith('@pepsico.com'))) return [3, 4];
|
|
1413
|
-
|
|
1446
|
+
_l.label = 1;
|
|
1414
1447
|
case 1:
|
|
1415
|
-
|
|
1448
|
+
_l.trys.push([1, 3, , 4]);
|
|
1416
1449
|
return [4, sendEmail(process.env.B6_EMAIL_FROM, spaceUser.email, subject, '', html, '')];
|
|
1417
1450
|
case 2:
|
|
1418
|
-
|
|
1451
|
+
_l.sent();
|
|
1419
1452
|
results.push({ userId: userId, email: spaceUser.email, status: 'sent' });
|
|
1420
1453
|
return [3, 4];
|
|
1421
1454
|
case 3:
|
|
1422
|
-
error_10 =
|
|
1455
|
+
error_10 = _l.sent();
|
|
1423
1456
|
console.log("[remindSpotCheckIncomplete] \u90AE\u4EF6\u53D1\u9001\u5931\u8D25: ".concat(spaceUser.email), error_10);
|
|
1424
1457
|
results.push({ userId: userId, email: spaceUser.email, status: 'failed' });
|
|
1425
1458
|
return [3, 4];
|
|
1426
1459
|
case 4:
|
|
1427
|
-
|
|
1460
|
+
_l.trys.push([4, 13, , 14]);
|
|
1461
|
+
notificationItems = [
|
|
1462
|
+
{
|
|
1463
|
+
count: info.midTierCount,
|
|
1464
|
+
url: midTierPageUrl,
|
|
1465
|
+
relatedName: '腰部素材抽查'
|
|
1466
|
+
},
|
|
1467
|
+
{
|
|
1468
|
+
count: info.microCount,
|
|
1469
|
+
url: microPageUrl,
|
|
1470
|
+
relatedName: '尾部素材抽查'
|
|
1471
|
+
}
|
|
1472
|
+
].filter(function (item) { return item.count > 0; });
|
|
1473
|
+
_l.label = 5;
|
|
1474
|
+
case 5:
|
|
1475
|
+
_l.trys.push([5, 10, 11, 12]);
|
|
1476
|
+
notificationItems_1 = (e_16 = void 0, tslib_1.__values(notificationItems)), notificationItems_1_1 = notificationItems_1.next();
|
|
1477
|
+
_l.label = 6;
|
|
1478
|
+
case 6:
|
|
1479
|
+
if (!!notificationItems_1_1.done) return [3, 9];
|
|
1480
|
+
item = notificationItems_1_1.value;
|
|
1428
1481
|
return [4, ctx.broker.call('notifications.add', {
|
|
1429
1482
|
message: {
|
|
1430
|
-
name: "\u3010\
|
|
1483
|
+
name: "\u3010\u62BD\u67E5\u901A\u77E5\u3011\u60A8\u6709".concat(item.count, "\u4E2A\u7D20\u6750\u672A\u5B8C\u6210\u62BD\u67E5\uFF0C\u8BF7\u5C3D\u5FEB\u5904\u7406"),
|
|
1431
1484
|
body: '',
|
|
1432
|
-
related_to: { o: '
|
|
1433
|
-
|
|
1485
|
+
related_to: { o: 'notifications', ids: ['none'] },
|
|
1486
|
+
url: item.url,
|
|
1487
|
+
related_name: item.relatedName,
|
|
1434
1488
|
from: spaceUser.user,
|
|
1435
1489
|
space: spaceUser.space
|
|
1436
1490
|
},
|
|
1437
1491
|
from: spaceUser.user,
|
|
1438
1492
|
to: userId
|
|
1439
1493
|
})];
|
|
1440
|
-
case
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
case
|
|
1444
|
-
|
|
1494
|
+
case 7:
|
|
1495
|
+
_l.sent();
|
|
1496
|
+
_l.label = 8;
|
|
1497
|
+
case 8:
|
|
1498
|
+
notificationItems_1_1 = notificationItems_1.next();
|
|
1499
|
+
return [3, 6];
|
|
1500
|
+
case 9: return [3, 12];
|
|
1501
|
+
case 10:
|
|
1502
|
+
e_16_1 = _l.sent();
|
|
1503
|
+
e_16 = { error: e_16_1 };
|
|
1504
|
+
return [3, 12];
|
|
1505
|
+
case 11:
|
|
1506
|
+
try {
|
|
1507
|
+
if (notificationItems_1_1 && !notificationItems_1_1.done && (_k = notificationItems_1.return)) _k.call(notificationItems_1);
|
|
1508
|
+
}
|
|
1509
|
+
finally { if (e_16) throw e_16.error; }
|
|
1510
|
+
return [7];
|
|
1511
|
+
case 12: return [3, 14];
|
|
1512
|
+
case 13:
|
|
1513
|
+
error_11 = _l.sent();
|
|
1445
1514
|
console.log("[remindSpotCheckIncomplete] \u7AD9\u5185\u901A\u77E5\u53D1\u9001\u5931\u8D25: ".concat(userId), error_11);
|
|
1446
|
-
return [3,
|
|
1447
|
-
case
|
|
1515
|
+
return [3, 14];
|
|
1516
|
+
case 14: return [2];
|
|
1448
1517
|
}
|
|
1449
1518
|
});
|
|
1450
1519
|
};
|
|
1451
|
-
_j.label =
|
|
1452
|
-
case
|
|
1453
|
-
_j.trys.push([
|
|
1520
|
+
_j.label = 21;
|
|
1521
|
+
case 21:
|
|
1522
|
+
_j.trys.push([21, 26, 27, 28]);
|
|
1454
1523
|
pendingUsers_1 = tslib_1.__values(pendingUsers), pendingUsers_1_1 = pendingUsers_1.next();
|
|
1455
|
-
_j.label =
|
|
1456
|
-
case
|
|
1457
|
-
if (!!pendingUsers_1_1.done) return [3,
|
|
1524
|
+
_j.label = 22;
|
|
1525
|
+
case 22:
|
|
1526
|
+
if (!!pendingUsers_1_1.done) return [3, 25];
|
|
1458
1527
|
_b = tslib_1.__read(pendingUsers_1_1.value, 2), userId = _b[0], info = _b[1];
|
|
1459
1528
|
return [5, _loop_2(userId, info)];
|
|
1460
|
-
case
|
|
1529
|
+
case 23:
|
|
1461
1530
|
_j.sent();
|
|
1462
|
-
_j.label =
|
|
1463
|
-
case
|
|
1531
|
+
_j.label = 24;
|
|
1532
|
+
case 24:
|
|
1464
1533
|
pendingUsers_1_1 = pendingUsers_1.next();
|
|
1465
|
-
return [3,
|
|
1466
|
-
case
|
|
1467
|
-
case
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
return [3,
|
|
1471
|
-
case
|
|
1534
|
+
return [3, 22];
|
|
1535
|
+
case 25: return [3, 28];
|
|
1536
|
+
case 26:
|
|
1537
|
+
e_11_1 = _j.sent();
|
|
1538
|
+
e_11 = { error: e_11_1 };
|
|
1539
|
+
return [3, 28];
|
|
1540
|
+
case 27:
|
|
1472
1541
|
try {
|
|
1473
1542
|
if (pendingUsers_1_1 && !pendingUsers_1_1.done && (_h = pendingUsers_1.return)) _h.call(pendingUsers_1);
|
|
1474
1543
|
}
|
|
1475
|
-
finally { if (
|
|
1544
|
+
finally { if (e_11) throw e_11.error; }
|
|
1476
1545
|
return [7];
|
|
1477
|
-
case
|
|
1546
|
+
case 28:
|
|
1478
1547
|
console.log("[remindSpotCheckIncomplete] \u50AC\u529E\u5B8C\u6210\u3002\u7ED3\u679C:", results);
|
|
1479
1548
|
return [4, logger.info('[抽查催办] 催办完成', {
|
|
1480
1549
|
userCount: pendingUsers.size,
|
|
1481
1550
|
results: results
|
|
1482
1551
|
})];
|
|
1483
|
-
case
|
|
1552
|
+
case 29:
|
|
1484
1553
|
_j.sent();
|
|
1485
1554
|
return [2, { success: true, yearMonth: yearMonth, totalUsers: pendingUsers.size, results: results }];
|
|
1486
1555
|
}
|
|
@@ -1488,4 +1557,126 @@ exports.remindSpotCheckIncomplete = {
|
|
|
1488
1557
|
});
|
|
1489
1558
|
}
|
|
1490
1559
|
};
|
|
1560
|
+
exports.testSpotCheckNotifications = {
|
|
1561
|
+
rest: {
|
|
1562
|
+
method: "GET",
|
|
1563
|
+
fullPath: "/api/pepsico-content/test/spot-check-notifications"
|
|
1564
|
+
},
|
|
1565
|
+
handler: function (ctx) {
|
|
1566
|
+
var _a;
|
|
1567
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1568
|
+
var user, logger, now, yearMonth, fromUserId, toUserId, spaceId, spaceUsers, midTierPageUrl, microPageUrl, messages, results, messages_1, messages_1_1, message, e_17_1;
|
|
1569
|
+
var e_17, _b;
|
|
1570
|
+
return tslib_1.__generator(this, function (_c) {
|
|
1571
|
+
switch (_c.label) {
|
|
1572
|
+
case 0:
|
|
1573
|
+
user = ctx.meta.user;
|
|
1574
|
+
if (!user || !user.is_space_admin) {
|
|
1575
|
+
throw new Error('无权限');
|
|
1576
|
+
}
|
|
1577
|
+
ctx.getObject = this.getObject;
|
|
1578
|
+
return [4, this.getLogger()];
|
|
1579
|
+
case 1:
|
|
1580
|
+
logger = _c.sent();
|
|
1581
|
+
now = moment().format('YYYY-MM-DD HH:mm:ss');
|
|
1582
|
+
yearMonth = moment().format('YYYY-MM');
|
|
1583
|
+
fromUserId = user.userId;
|
|
1584
|
+
toUserId = user.userId;
|
|
1585
|
+
spaceId = user.spaceId;
|
|
1586
|
+
if (!!spaceId) return [3, 3];
|
|
1587
|
+
return [4, ctx.getObject('space_users').find({
|
|
1588
|
+
filters: [['user', '=', user.userId]],
|
|
1589
|
+
top: 1
|
|
1590
|
+
})];
|
|
1591
|
+
case 2:
|
|
1592
|
+
spaceUsers = _c.sent();
|
|
1593
|
+
spaceId = (_a = spaceUsers === null || spaceUsers === void 0 ? void 0 : spaceUsers[0]) === null || _a === void 0 ? void 0 : _a.space;
|
|
1594
|
+
_c.label = 3;
|
|
1595
|
+
case 3:
|
|
1596
|
+
if (!spaceId) {
|
|
1597
|
+
throw new Error('未找到当前用户所属工作区');
|
|
1598
|
+
}
|
|
1599
|
+
midTierPageUrl = "/app/pepsico_content_review/page/pepsico_midtier_spot_check";
|
|
1600
|
+
microPageUrl = "/app/pepsico_content_review/page/pepsico_spot_check";
|
|
1601
|
+
messages = [
|
|
1602
|
+
{
|
|
1603
|
+
name: "\u3010\u6D4B\u8BD5\u3011\u3010".concat(yearMonth, "\u3011\u6708\u5EA6\u62BD\u67E5\u7D20\u6750\u6C60\u5DF2\u751F\u6210\uFF0C\u8BF7\u8FDB\u884C\u8170\u90E8\u7D20\u6750\u62BD\u67E5"),
|
|
1604
|
+
url: midTierPageUrl,
|
|
1605
|
+
related_name: '腰部素材抽查'
|
|
1606
|
+
},
|
|
1607
|
+
{
|
|
1608
|
+
name: "\u3010\u6D4B\u8BD5\u3011\u3010".concat(yearMonth, "\u3011\u6708\u5EA6\u62BD\u67E5\u7D20\u6750\u6C60\u5DF2\u751F\u6210\uFF0C\u8BF7\u8FDB\u884C\u5C3E\u90E8\u7D20\u6750\u62BD\u67E5"),
|
|
1609
|
+
url: microPageUrl,
|
|
1610
|
+
related_name: '尾部素材抽查'
|
|
1611
|
+
},
|
|
1612
|
+
{
|
|
1613
|
+
name: "\u3010\u6D4B\u8BD5\u3011\u3010\u62BD\u67E5\u901A\u77E5\u3011\u60A8\u67091\u4E2A\u7D20\u6750\u672A\u5B8C\u6210\u62BD\u67E5\uFF0C\u8BF7\u5C3D\u5FEB\u5904\u7406\uFF08\u8170\u90E8\uFF09",
|
|
1614
|
+
url: midTierPageUrl,
|
|
1615
|
+
related_name: '腰部素材抽查'
|
|
1616
|
+
},
|
|
1617
|
+
{
|
|
1618
|
+
name: "\u3010\u6D4B\u8BD5\u3011\u3010\u62BD\u67E5\u901A\u77E5\u3011\u60A8\u67091\u4E2A\u7D20\u6750\u672A\u5B8C\u6210\u62BD\u67E5\uFF0C\u8BF7\u5C3D\u5FEB\u5904\u7406\uFF08\u5C3E\u90E8\uFF09",
|
|
1619
|
+
url: microPageUrl,
|
|
1620
|
+
related_name: '尾部素材抽查'
|
|
1621
|
+
}
|
|
1622
|
+
];
|
|
1623
|
+
results = [];
|
|
1624
|
+
_c.label = 4;
|
|
1625
|
+
case 4:
|
|
1626
|
+
_c.trys.push([4, 9, 10, 11]);
|
|
1627
|
+
messages_1 = tslib_1.__values(messages), messages_1_1 = messages_1.next();
|
|
1628
|
+
_c.label = 5;
|
|
1629
|
+
case 5:
|
|
1630
|
+
if (!!messages_1_1.done) return [3, 8];
|
|
1631
|
+
message = messages_1_1.value;
|
|
1632
|
+
return [4, ctx.broker.call('notifications.add', {
|
|
1633
|
+
message: {
|
|
1634
|
+
name: message.name,
|
|
1635
|
+
body: "\u6D4B\u8BD5\u7AD9\u5185\u4FE1\u53D1\u9001\u65F6\u95F4\uFF1A".concat(now),
|
|
1636
|
+
related_to: { o: 'notifications', ids: ['none'] },
|
|
1637
|
+
url: message.url,
|
|
1638
|
+
related_name: message.related_name,
|
|
1639
|
+
from: fromUserId,
|
|
1640
|
+
space: spaceId
|
|
1641
|
+
},
|
|
1642
|
+
from: fromUserId,
|
|
1643
|
+
to: toUserId
|
|
1644
|
+
})];
|
|
1645
|
+
case 6:
|
|
1646
|
+
_c.sent();
|
|
1647
|
+
results.push(message);
|
|
1648
|
+
_c.label = 7;
|
|
1649
|
+
case 7:
|
|
1650
|
+
messages_1_1 = messages_1.next();
|
|
1651
|
+
return [3, 5];
|
|
1652
|
+
case 8: return [3, 11];
|
|
1653
|
+
case 9:
|
|
1654
|
+
e_17_1 = _c.sent();
|
|
1655
|
+
e_17 = { error: e_17_1 };
|
|
1656
|
+
return [3, 11];
|
|
1657
|
+
case 10:
|
|
1658
|
+
try {
|
|
1659
|
+
if (messages_1_1 && !messages_1_1.done && (_b = messages_1.return)) _b.call(messages_1);
|
|
1660
|
+
}
|
|
1661
|
+
finally { if (e_17) throw e_17.error; }
|
|
1662
|
+
return [7];
|
|
1663
|
+
case 11: return [4, logger.info('[抽查通知测试] 已发送测试站内信', {
|
|
1664
|
+
userId: toUserId,
|
|
1665
|
+
space: spaceId,
|
|
1666
|
+
count: results.length,
|
|
1667
|
+
results: results
|
|
1668
|
+
})];
|
|
1669
|
+
case 12:
|
|
1670
|
+
_c.sent();
|
|
1671
|
+
return [2, {
|
|
1672
|
+
success: true,
|
|
1673
|
+
message: '测试站内信已发送给当前用户',
|
|
1674
|
+
count: results.length,
|
|
1675
|
+
results: results
|
|
1676
|
+
}];
|
|
1677
|
+
}
|
|
1678
|
+
});
|
|
1679
|
+
});
|
|
1680
|
+
}
|
|
1681
|
+
};
|
|
1491
1682
|
//# sourceMappingURL=spotCheckMaterial.js.map
|