@steedos-labs/content-compliance-bev 0.2.5 → 0.2.7

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.
@@ -890,7 +890,7 @@ exports.generateSpotCheckPool = {
890
890
  },
891
891
  handler: function (ctx) {
892
892
  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, subject, 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;
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, 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
894
  var e_5, _j, e_9, _k, e_6, _l, e_7, _m, e_8, _o;
895
895
  return tslib_1.__generator(this, function (_p) {
896
896
  switch (_p.label) {
@@ -1044,8 +1044,11 @@ exports.generateSpotCheckPool = {
1044
1044
  return [7];
1045
1045
  case 24:
1046
1046
  ROOT_URL = process.env.ROOT_URL;
1047
- subject = '【系统通知】抽查素材通知';
1048
- midTierLink = "".concat(ROOT_URL, "/app/pepsico_content_review/pepsico_midtier_spot_check");
1047
+ midTierSubject = '【系统通知】腰部素材抽查通知';
1048
+ microSubject = '【系统通知】尾部素材抽查通知';
1049
+ midTierPageUrl = "/app/pepsico_content_review/page/pepsico_midtier_spot_check";
1050
+ microPageUrl = "/app/pepsico_content_review/page/pepsico_spot_check";
1051
+ midTierLink = "".concat(ROOT_URL).concat(midTierPageUrl);
1049
1052
  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 ");
1050
1053
  departmentToUsers = [];
1051
1054
  if (!(departmentUserIds_2.size > 0)) return [3, 28];
@@ -1063,7 +1066,7 @@ exports.generateSpotCheckPool = {
1063
1066
  return [3, 28];
1064
1067
  case 28:
1065
1068
  if (!(departmentToUsers.length > 0)) return [3, 30];
1066
- return [4, sendEmail(process.env.B6_EMAIL_FROM, (0, lodash_1.join)((0, lodash_1.map)(departmentToUsers, 'email'), ';'), subject, '', midTierHtml, '')];
1069
+ return [4, sendEmail(process.env.B6_EMAIL_FROM, (0, lodash_1.join)((0, lodash_1.map)(departmentToUsers, 'email'), ';'), midTierSubject, '', midTierHtml, '')];
1067
1070
  case 29:
1068
1071
  _g = _p.sent();
1069
1072
  return [3, 31];
@@ -1072,7 +1075,7 @@ exports.generateSpotCheckPool = {
1072
1075
  _p.label = 31;
1073
1076
  case 31:
1074
1077
  midTierResult = _g;
1075
- microLink = "".concat(ROOT_URL, "/app/pepsico_content_review/pepsico_spot_check");
1078
+ microLink = "".concat(ROOT_URL).concat(microPageUrl);
1076
1079
  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 ");
1077
1080
  specialistToUsers = [];
1078
1081
  if (!(specialistUserIds_2.size > 0)) return [3, 35];
@@ -1090,7 +1093,7 @@ exports.generateSpotCheckPool = {
1090
1093
  return [3, 35];
1091
1094
  case 35:
1092
1095
  if (!(specialistToUsers.length > 0)) return [3, 37];
1093
- return [4, sendEmail(process.env.B6_EMAIL_FROM, (0, lodash_1.join)((0, lodash_1.map)(specialistToUsers, 'email'), ';'), subject, '', microHtml, '')];
1096
+ return [4, sendEmail(process.env.B6_EMAIL_FROM, (0, lodash_1.join)((0, lodash_1.map)(specialistToUsers, 'email'), ';'), microSubject, '', microHtml, '')];
1094
1097
  case 36:
1095
1098
  _h = _p.sent();
1096
1099
  return [3, 38];
@@ -1115,8 +1118,8 @@ exports.generateSpotCheckPool = {
1115
1118
  message: {
1116
1119
  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"),
1117
1120
  body: '',
1118
- related_to: { o: 'pepsico_spot_check_pool', ids: [pid] },
1119
- related_name: pool.name || yearMonth,
1121
+ url: midTierPageUrl,
1122
+ related_name: '腰部素材抽查',
1120
1123
  from: fromUserId,
1121
1124
  space: pool.space
1122
1125
  },
@@ -1151,8 +1154,8 @@ exports.generateSpotCheckPool = {
1151
1154
  message: {
1152
1155
  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"),
1153
1156
  body: '',
1154
- related_to: { o: 'pepsico_spot_check_pool', ids: [pid] },
1155
- related_name: pool.name || yearMonth,
1157
+ url: microPageUrl,
1158
+ related_name: '尾部素材抽查',
1156
1159
  from: fromUserId,
1157
1160
  space: pool.space
1158
1161
  },
@@ -1186,7 +1189,7 @@ exports.generateSpotCheckPool = {
1186
1189
  mail_send_date: new Date(),
1187
1190
  mid_tier_pepsico_material: (0, lodash_1.map)(pools['Mid-tier'].samplingPool, '_id'),
1188
1191
  micro_pepsico_material: (0, lodash_1.map)(pools['Micro'].samplingPool, '_id'),
1189
- logs: logs + '\r\n' + "=== \u53D1\u9001\u90AE\u4EF6\uFF08\u56DB\u90E8\u95E8-\u8170\u90E8\uFF09 === \r\n\n \u90AE\u4EF6\u4E3B\u9898: ".concat(subject, "\r\n\n \u6536\u4EF6\u4EBA: ").concat((0, lodash_1.join)((0, lodash_1.map)(departmentToUsers, 'email'), ';'), "\r\n\n \u90AE\u4EF6\u5185\u5BB9: ").concat(midTierHtml, "\r\n\n \u90AE\u4EF6\u53D1\u9001\u7ED3\u679C: ").concat(midTierResult, "\r\n\n === \u53D1\u9001\u90AE\u4EF6\uFF08\u4E13\u5458-\u5C3E\u90E8\uFF09 === \r\n\n \u90AE\u4EF6\u4E3B\u9898: ").concat(subject, "\r\n\n \u6536\u4EF6\u4EBA: ").concat((0, lodash_1.join)((0, lodash_1.map)(specialistToUsers, 'email'), ';'), "\r\n\n \u90AE\u4EF6\u5185\u5BB9: ").concat(microHtml, "\r\n\n \u90AE\u4EF6\u53D1\u9001\u7ED3\u679C: ").concat(microResult, "\n ")
1192
+ logs: logs + '\r\n' + "=== \u53D1\u9001\u90AE\u4EF6\uFF08\u56DB\u90E8\u95E8-\u8170\u90E8\uFF09 === \r\n\n \u90AE\u4EF6\u4E3B\u9898: ".concat(midTierSubject, "\r\n\n \u6536\u4EF6\u4EBA: ").concat((0, lodash_1.join)((0, lodash_1.map)(departmentToUsers, 'email'), ';'), "\r\n\n \u90AE\u4EF6\u5185\u5BB9: ").concat(midTierHtml, "\r\n\n \u90AE\u4EF6\u53D1\u9001\u7ED3\u679C: ").concat(midTierResult, "\r\n\n === \u53D1\u9001\u90AE\u4EF6\uFF08\u4E13\u5458-\u5C3E\u90E8\uFF09 === \r\n\n \u90AE\u4EF6\u4E3B\u9898: ").concat(microSubject, "\r\n\n \u6536\u4EF6\u4EBA: ").concat((0, lodash_1.join)((0, lodash_1.map)(specialistToUsers, 'email'), ';'), "\r\n\n \u90AE\u4EF6\u5185\u5BB9: ").concat(microHtml, "\r\n\n \u90AE\u4EF6\u53D1\u9001\u7ED3\u679C: ").concat(microResult, "\n ")
1190
1193
  })];
1191
1194
  case 57:
1192
1195
  _p.sent();
@@ -1233,8 +1236,8 @@ exports.remindSpotCheckIncomplete = {
1233
1236
  },
1234
1237
  handler: function (ctx) {
1235
1238
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1236
- 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, e_10_1;
1237
- var e_11, _c, e_12, _d, e_13, _e, e_14, _f, e_15, _g, e_10, _h;
1239
+ 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;
1240
+ var e_12, _c, e_13, _d, e_14, _e, e_10, _f, e_15, _g, e_11, _h;
1238
1241
  return tslib_1.__generator(this, function (_j) {
1239
1242
  switch (_j.label) {
1240
1243
  case 0:
@@ -1248,19 +1251,28 @@ exports.remindSpotCheckIncomplete = {
1248
1251
  logger = _j.sent();
1249
1252
  ctx.logger = logger;
1250
1253
  yearMonth = moment().format('YYYY-MM');
1251
- console.log("[remindSpotCheckIncomplete] \u5F00\u59CB\u626B\u63CF ".concat(yearMonth, " \u672A\u5B8C\u6210\u62BD\u67E5\u4EFB\u52A1..."));
1254
+ console.log("[remindSpotCheckIncomplete] \u5F00\u59CB\u626B\u63CF\u622A\u6B62\u76EE\u524D\u6240\u6709\u672A\u5B8C\u6210\u62BD\u67E5\u4EFB\u52A1...");
1255
+ return [4, logger.info('[抽查催办] 开始扫描截止目前所有未完成抽查任务', {
1256
+ yearMonth: yearMonth
1257
+ })];
1258
+ case 2:
1259
+ _j.sent();
1252
1260
  pendingUsers = new Map();
1253
1261
  return [4, ctx.getObject('pepsico_material').find({
1254
1262
  filters: [
1255
- ['spot_check_pool_year_month', '=', yearMonth],
1256
1263
  ['spot_checked', '=', true],
1257
1264
  ['spot_checked_done', '!=', true],
1258
1265
  ['spot_check_type', '=', '四部门抽查']
1259
1266
  ]
1260
1267
  })];
1261
- case 2:
1268
+ case 3:
1262
1269
  midTierMaterials = _j.sent();
1263
1270
  console.log("[remindSpotCheckIncomplete] \u8170\u90E8\u672A\u5B8C\u6210\u7D20\u6750: ".concat(midTierMaterials.length));
1271
+ return [4, logger.info('[抽查催办] 腰部未完成素材统计', {
1272
+ count: midTierMaterials.length
1273
+ })];
1274
+ case 4:
1275
+ _j.sent();
1264
1276
  try {
1265
1277
  for (midTierMaterials_1 = tslib_1.__values(midTierMaterials), midTierMaterials_1_1 = midTierMaterials_1.next(); !midTierMaterials_1_1.done; midTierMaterials_1_1 = midTierMaterials_1.next()) {
1266
1278
  material = midTierMaterials_1_1.value;
@@ -1271,180 +1283,270 @@ exports.remindSpotCheckIncomplete = {
1271
1283
  { done: 'ca_spot_check', user: 'ca_spot_check_user' },
1272
1284
  ];
1273
1285
  try {
1274
- for (deptFields_1 = (e_12 = void 0, tslib_1.__values(deptFields)), deptFields_1_1 = deptFields_1.next(); !deptFields_1_1.done; deptFields_1_1 = deptFields_1.next()) {
1286
+ 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()) {
1275
1287
  _a = deptFields_1_1.value, done = _a.done, user_1 = _a.user;
1276
1288
  if (!material[done] && material[user_1]) {
1277
1289
  users = Array.isArray(material[user_1]) ? material[user_1] : [material[user_1]];
1278
1290
  try {
1279
- for (users_2 = (e_13 = void 0, tslib_1.__values(users)), users_2_1 = users_2.next(); !users_2_1.done; users_2_1 = users_2.next()) {
1291
+ 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()) {
1280
1292
  uid = users_2_1.value;
1281
1293
  if (uid) {
1282
- existing = pendingUsers.get(uid) || { count: 0, type: '四部门抽查' };
1283
- existing.count++;
1294
+ existing = pendingUsers.get(uid) || { midTierCount: 0, microCount: 0 };
1295
+ existing.midTierCount++;
1284
1296
  pendingUsers.set(uid, existing);
1285
1297
  }
1286
1298
  }
1287
1299
  }
1288
- catch (e_13_1) { e_13 = { error: e_13_1 }; }
1300
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
1289
1301
  finally {
1290
1302
  try {
1291
1303
  if (users_2_1 && !users_2_1.done && (_e = users_2.return)) _e.call(users_2);
1292
1304
  }
1293
- finally { if (e_13) throw e_13.error; }
1305
+ finally { if (e_14) throw e_14.error; }
1294
1306
  }
1295
1307
  }
1296
1308
  }
1297
1309
  }
1298
- catch (e_12_1) { e_12 = { error: e_12_1 }; }
1310
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
1299
1311
  finally {
1300
1312
  try {
1301
1313
  if (deptFields_1_1 && !deptFields_1_1.done && (_d = deptFields_1.return)) _d.call(deptFields_1);
1302
1314
  }
1303
- finally { if (e_12) throw e_12.error; }
1315
+ finally { if (e_13) throw e_13.error; }
1304
1316
  }
1305
1317
  }
1306
1318
  }
1307
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
1319
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
1308
1320
  finally {
1309
1321
  try {
1310
1322
  if (midTierMaterials_1_1 && !midTierMaterials_1_1.done && (_c = midTierMaterials_1.return)) _c.call(midTierMaterials_1);
1311
1323
  }
1312
- finally { if (e_11) throw e_11.error; }
1324
+ finally { if (e_12) throw e_12.error; }
1313
1325
  }
1314
1326
  return [4, ctx.getObject('pepsico_material').find({
1315
1327
  filters: [
1316
- ['spot_check_pool_year_month', '=', yearMonth],
1317
1328
  ['spot_checked', '=', true],
1318
1329
  ['spot_checked_done', '!=', true],
1319
1330
  ['spot_check_type', '=', '审核专员抽查']
1320
1331
  ]
1321
1332
  })];
1322
- case 3:
1333
+ case 5:
1323
1334
  microMaterials = _j.sent();
1324
1335
  console.log("[remindSpotCheckIncomplete] \u5C3E\u90E8\u672A\u5B8C\u6210\u7D20\u6750: ".concat(microMaterials.length));
1336
+ return [4, logger.info('[抽查催办] 尾部未完成素材统计', {
1337
+ count: microMaterials.length
1338
+ })];
1339
+ case 6:
1340
+ _j.sent();
1341
+ _j.label = 7;
1342
+ case 7:
1343
+ _j.trys.push([7, 14, 15, 16]);
1344
+ microMaterials_1 = tslib_1.__values(microMaterials), microMaterials_1_1 = microMaterials_1.next();
1345
+ _j.label = 8;
1346
+ case 8:
1347
+ if (!!microMaterials_1_1.done) return [3, 13];
1348
+ material = microMaterials_1_1.value;
1349
+ if (!!material.guding_spot_check) return [3, 12];
1350
+ users = Array.isArray(material.guding_spot_check_user) ? material.guding_spot_check_user : (0, lodash_1.compact)([material.guding_spot_check_user]);
1351
+ if (!(users.length === 0 && material.pepsico_material_approval)) return [3, 11];
1352
+ return [4, ctx.getObject('pepsico_material_approval').findOne(material.pepsico_material_approval)];
1353
+ case 9:
1354
+ approval = _j.sent();
1355
+ 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]);
1356
+ return [4, logger.info('[抽查催办] 尾部素材剩余抽查人为空,使用审批单专员抽查人兜底', {
1357
+ materialId: material._id,
1358
+ approvalId: material.pepsico_material_approval,
1359
+ userCount: users.length
1360
+ })];
1361
+ case 10:
1362
+ _j.sent();
1363
+ _j.label = 11;
1364
+ case 11:
1325
1365
  try {
1326
- for (microMaterials_1 = tslib_1.__values(microMaterials), microMaterials_1_1 = microMaterials_1.next(); !microMaterials_1_1.done; microMaterials_1_1 = microMaterials_1.next()) {
1327
- material = microMaterials_1_1.value;
1328
- if (!material.guding_spot_check && material.guding_spot_check_user) {
1329
- users = Array.isArray(material.guding_spot_check_user) ? material.guding_spot_check_user : [material.guding_spot_check_user];
1330
- try {
1331
- 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()) {
1332
- uid = users_3_1.value;
1333
- if (uid) {
1334
- existing = pendingUsers.get(uid) || { count: 0, type: '审核专员抽查' };
1335
- existing.count++;
1336
- pendingUsers.set(uid, existing);
1337
- }
1338
- }
1339
- }
1340
- catch (e_15_1) { e_15 = { error: e_15_1 }; }
1341
- finally {
1342
- try {
1343
- if (users_3_1 && !users_3_1.done && (_g = users_3.return)) _g.call(users_3);
1344
- }
1345
- finally { if (e_15) throw e_15.error; }
1346
- }
1366
+ 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()) {
1367
+ uid = users_3_1.value;
1368
+ if (uid) {
1369
+ existing = pendingUsers.get(uid) || { midTierCount: 0, microCount: 0 };
1370
+ existing.microCount++;
1371
+ pendingUsers.set(uid, existing);
1347
1372
  }
1348
1373
  }
1349
1374
  }
1350
- catch (e_14_1) { e_14 = { error: e_14_1 }; }
1375
+ catch (e_15_1) { e_15 = { error: e_15_1 }; }
1351
1376
  finally {
1352
1377
  try {
1353
- if (microMaterials_1_1 && !microMaterials_1_1.done && (_f = microMaterials_1.return)) _f.call(microMaterials_1);
1378
+ if (users_3_1 && !users_3_1.done && (_g = users_3.return)) _g.call(users_3);
1354
1379
  }
1355
- finally { if (e_14) throw e_14.error; }
1380
+ finally { if (e_15) throw e_15.error; }
1356
1381
  }
1357
- if (pendingUsers.size === 0) {
1358
- console.log("[remindSpotCheckIncomplete] \u5F53\u6708\u65E0\u672A\u5B8C\u6210\u62BD\u67E5\u4EFB\u52A1\uFF0C\u65E0\u9700\u50AC\u529E\u3002");
1359
- return [2, { success: true, message: '无未完成抽查任务' }];
1382
+ _j.label = 12;
1383
+ case 12:
1384
+ microMaterials_1_1 = microMaterials_1.next();
1385
+ return [3, 8];
1386
+ case 13: return [3, 16];
1387
+ case 14:
1388
+ e_10_1 = _j.sent();
1389
+ e_10 = { error: e_10_1 };
1390
+ return [3, 16];
1391
+ case 15:
1392
+ try {
1393
+ if (microMaterials_1_1 && !microMaterials_1_1.done && (_f = microMaterials_1.return)) _f.call(microMaterials_1);
1360
1394
  }
1395
+ finally { if (e_10) throw e_10.error; }
1396
+ return [7];
1397
+ case 16:
1398
+ if (!(pendingUsers.size === 0)) return [3, 18];
1399
+ console.log("[remindSpotCheckIncomplete] \u65E0\u672A\u5B8C\u6210\u62BD\u67E5\u4EFB\u52A1\uFF0C\u65E0\u9700\u50AC\u529E\u3002");
1400
+ return [4, logger.info('[抽查催办] 无未完成抽查任务,无需催办', {
1401
+ midTierCount: midTierMaterials.length,
1402
+ microCount: microMaterials.length
1403
+ })];
1404
+ case 17:
1405
+ _j.sent();
1406
+ return [2, { success: true, message: '无未完成抽查任务' }];
1407
+ case 18:
1361
1408
  console.log("[remindSpotCheckIncomplete] \u9700\u50AC\u529E\u7528\u6237\u6570: ".concat(pendingUsers.size));
1409
+ return [4, logger.info('[抽查催办] 需催办用户统计', {
1410
+ userCount: pendingUsers.size,
1411
+ midTierCount: midTierMaterials.length,
1412
+ microCount: microMaterials.length
1413
+ })];
1414
+ case 19:
1415
+ _j.sent();
1362
1416
  ROOT_URL = process.env.ROOT_URL;
1363
- midTierLink = "".concat(ROOT_URL, "/app/pepsico_content_review/pepsico_midtier_spot_check");
1364
- microLink = "".concat(ROOT_URL, "/app/pepsico_content_review/pepsico_spot_check");
1365
- subject = '【催办通知】您有未完成的抽查任务';
1417
+ midTierPageUrl = "/app/pepsico_content_review/page/pepsico_midtier_spot_check";
1418
+ microPageUrl = "/app/pepsico_content_review/page/pepsico_spot_check";
1419
+ midTierLink = "".concat(ROOT_URL).concat(midTierPageUrl);
1420
+ microLink = "".concat(ROOT_URL).concat(microPageUrl);
1421
+ subject = '【系统通知】您有未完成的素材抽查工作';
1366
1422
  results = [];
1367
1423
  userIds = Array.from(pendingUsers.keys());
1368
1424
  return [4, ctx.getObject('space_users').find({ filters: ['user', 'in', userIds] })];
1369
- case 4:
1425
+ case 20:
1370
1426
  spaceUsers = _j.sent();
1371
1427
  _loop_2 = function (userId, info) {
1372
- var spaceUser, link, html, error_10, error_11;
1373
- return tslib_1.__generator(this, function (_k) {
1374
- switch (_k.label) {
1428
+ var spaceUser, totalCount, linkHtml, html, error_10, notificationItems, notificationItems_1, notificationItems_1_1, item, e_16_1, error_11;
1429
+ var e_16, _k;
1430
+ return tslib_1.__generator(this, function (_l) {
1431
+ switch (_l.label) {
1375
1432
  case 0:
1376
1433
  spaceUser = (0, lodash_1.find)(spaceUsers, function (u) { return u.user === userId; });
1377
1434
  if (!spaceUser)
1378
1435
  return [2, "continue"];
1379
- link = info.type === '四部门抽查' ? midTierLink : microLink;
1380
- html = "\n <p>\u4EB2\u7231\u7684\u5BA1\u6838\u8001\u5E08\uFF0C</p>\n <p>\u60A8\u5728\u3010".concat(yearMonth, "\u3011\u62BD\u67E5\u5E93\u4E2D\u4ECD\u6709 <b>").concat(info.count, "</b> \u4E2A\u7D20\u6750\u5C1A\u672A\u5B8C\u6210\u62BD\u67E5\uFF0C\u8BF7\u5728\u6708\u5E95\u524D\u5B8C\u6210\u3002</p>\n <p>\u8BF7\u70B9\u51FB\u4EE5\u4E0B\u94FE\u63A5\u8FDB\u5165\u62BD\u67E5\u9875\u9762\uFF1A</p>\n <p><a href=\"").concat(link, "\">\u70B9\u51FB\u8FDB\u5165\u62BD\u67E5</a></p>\n <p>\u5982\u6709\u7591\u95EE\uFF0C\u8BF7\u8054\u7CFB\u7CFB\u7EDF\u7BA1\u7406\u5458\u3002</p>\n ");
1436
+ totalCount = info.midTierCount + info.microCount;
1437
+ linkHtml = [
1438
+ info.midTierCount > 0 ? "<p><a href=\"".concat(midTierLink, "\">\u70B9\u51FB\u8FDB\u5165\u8170\u90E8\u7D20\u6750\u62BD\u67E5</a></p>") : '',
1439
+ info.microCount > 0 ? "<p><a href=\"".concat(microLink, "\">\u70B9\u51FB\u8FDB\u5165\u5C3E\u90E8\u7D20\u6750\u62BD\u67E5</a></p>") : ''
1440
+ ].join('');
1441
+ 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 ");
1381
1442
  if (!(spaceUser.email && spaceUser.email.endsWith('@pepsico.com'))) return [3, 4];
1382
- _k.label = 1;
1443
+ _l.label = 1;
1383
1444
  case 1:
1384
- _k.trys.push([1, 3, , 4]);
1445
+ _l.trys.push([1, 3, , 4]);
1385
1446
  return [4, sendEmail(process.env.B6_EMAIL_FROM, spaceUser.email, subject, '', html, '')];
1386
1447
  case 2:
1387
- _k.sent();
1448
+ _l.sent();
1388
1449
  results.push({ userId: userId, email: spaceUser.email, status: 'sent' });
1389
1450
  return [3, 4];
1390
1451
  case 3:
1391
- error_10 = _k.sent();
1452
+ error_10 = _l.sent();
1392
1453
  console.log("[remindSpotCheckIncomplete] \u90AE\u4EF6\u53D1\u9001\u5931\u8D25: ".concat(spaceUser.email), error_10);
1393
1454
  results.push({ userId: userId, email: spaceUser.email, status: 'failed' });
1394
1455
  return [3, 4];
1395
1456
  case 4:
1396
- _k.trys.push([4, 6, , 7]);
1457
+ _l.trys.push([4, 13, , 14]);
1458
+ notificationItems = [
1459
+ {
1460
+ count: info.midTierCount,
1461
+ url: midTierPageUrl,
1462
+ relatedName: '腰部素材抽查'
1463
+ },
1464
+ {
1465
+ count: info.microCount,
1466
+ url: microPageUrl,
1467
+ relatedName: '尾部素材抽查'
1468
+ }
1469
+ ].filter(function (item) { return item.count > 0; });
1470
+ _l.label = 5;
1471
+ case 5:
1472
+ _l.trys.push([5, 10, 11, 12]);
1473
+ notificationItems_1 = (e_16 = void 0, tslib_1.__values(notificationItems)), notificationItems_1_1 = notificationItems_1.next();
1474
+ _l.label = 6;
1475
+ case 6:
1476
+ if (!!notificationItems_1_1.done) return [3, 9];
1477
+ item = notificationItems_1_1.value;
1397
1478
  return [4, ctx.broker.call('notifications.add', {
1398
1479
  message: {
1399
- name: "\u3010\u50AC\u529E\u3011\u60A8\u6709 ".concat(info.count, " \u4E2A\u7D20\u6750\u672A\u5B8C\u6210\u62BD\u67E5\uFF0C\u8BF7\u5C3D\u5FEB\u5904\u7406"),
1480
+ 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"),
1400
1481
  body: '',
1401
- related_to: { o: 'pepsico_material', ids: [] },
1402
- related_name: "".concat(yearMonth, " \u62BD\u67E5\u50AC\u529E"),
1482
+ url: item.url,
1483
+ related_name: item.relatedName,
1403
1484
  from: spaceUser.user,
1404
1485
  space: spaceUser.space
1405
1486
  },
1406
1487
  from: spaceUser.user,
1407
1488
  to: userId
1408
1489
  })];
1409
- case 5:
1410
- _k.sent();
1411
- return [3, 7];
1412
- case 6:
1413
- error_11 = _k.sent();
1490
+ case 7:
1491
+ _l.sent();
1492
+ _l.label = 8;
1493
+ case 8:
1494
+ notificationItems_1_1 = notificationItems_1.next();
1495
+ return [3, 6];
1496
+ case 9: return [3, 12];
1497
+ case 10:
1498
+ e_16_1 = _l.sent();
1499
+ e_16 = { error: e_16_1 };
1500
+ return [3, 12];
1501
+ case 11:
1502
+ try {
1503
+ if (notificationItems_1_1 && !notificationItems_1_1.done && (_k = notificationItems_1.return)) _k.call(notificationItems_1);
1504
+ }
1505
+ finally { if (e_16) throw e_16.error; }
1506
+ return [7];
1507
+ case 12: return [3, 14];
1508
+ case 13:
1509
+ error_11 = _l.sent();
1414
1510
  console.log("[remindSpotCheckIncomplete] \u7AD9\u5185\u901A\u77E5\u53D1\u9001\u5931\u8D25: ".concat(userId), error_11);
1415
- return [3, 7];
1416
- case 7: return [2];
1511
+ return [3, 14];
1512
+ case 14: return [2];
1417
1513
  }
1418
1514
  });
1419
1515
  };
1420
- _j.label = 5;
1421
- case 5:
1422
- _j.trys.push([5, 10, 11, 12]);
1516
+ _j.label = 21;
1517
+ case 21:
1518
+ _j.trys.push([21, 26, 27, 28]);
1423
1519
  pendingUsers_1 = tslib_1.__values(pendingUsers), pendingUsers_1_1 = pendingUsers_1.next();
1424
- _j.label = 6;
1425
- case 6:
1426
- if (!!pendingUsers_1_1.done) return [3, 9];
1520
+ _j.label = 22;
1521
+ case 22:
1522
+ if (!!pendingUsers_1_1.done) return [3, 25];
1427
1523
  _b = tslib_1.__read(pendingUsers_1_1.value, 2), userId = _b[0], info = _b[1];
1428
1524
  return [5, _loop_2(userId, info)];
1429
- case 7:
1525
+ case 23:
1430
1526
  _j.sent();
1431
- _j.label = 8;
1432
- case 8:
1527
+ _j.label = 24;
1528
+ case 24:
1433
1529
  pendingUsers_1_1 = pendingUsers_1.next();
1434
- return [3, 6];
1435
- case 9: return [3, 12];
1436
- case 10:
1437
- e_10_1 = _j.sent();
1438
- e_10 = { error: e_10_1 };
1439
- return [3, 12];
1440
- case 11:
1530
+ return [3, 22];
1531
+ case 25: return [3, 28];
1532
+ case 26:
1533
+ e_11_1 = _j.sent();
1534
+ e_11 = { error: e_11_1 };
1535
+ return [3, 28];
1536
+ case 27:
1441
1537
  try {
1442
1538
  if (pendingUsers_1_1 && !pendingUsers_1_1.done && (_h = pendingUsers_1.return)) _h.call(pendingUsers_1);
1443
1539
  }
1444
- finally { if (e_10) throw e_10.error; }
1540
+ finally { if (e_11) throw e_11.error; }
1445
1541
  return [7];
1446
- case 12:
1542
+ case 28:
1447
1543
  console.log("[remindSpotCheckIncomplete] \u50AC\u529E\u5B8C\u6210\u3002\u7ED3\u679C:", results);
1544
+ return [4, logger.info('[抽查催办] 催办完成', {
1545
+ userCount: pendingUsers.size,
1546
+ results: results
1547
+ })];
1548
+ case 29:
1549
+ _j.sent();
1448
1550
  return [2, { success: true, yearMonth: yearMonth, totalUsers: pendingUsers.size, results: results }];
1449
1551
  }
1450
1552
  });