|
@@ -77,7 +77,8 @@ class PatentearlyService extends CrudService {
|
|
|
let total = 0;
|
|
|
let data = await this.patentinfo.find({ term: '有效' }, { name: 1, inventor: 1, create_date: 1 }).skip(skip).limit(limit);
|
|
|
if (data.length > 0) data = JSON.parse(JSON.stringify(data));
|
|
|
- // 取出今天是不是在失效时间的前1个月范围内
|
|
|
+ // 取出今天是不是在失效时间的前${limitMonth}个月范围内
|
|
|
+ const limitMonth = 3;
|
|
|
for (const i of data) {
|
|
|
const { create_date } = i;
|
|
|
// 取专利日期
|
|
@@ -88,13 +89,28 @@ class PatentearlyService extends CrudService {
|
|
|
const afterYear = moment(nowYear).add(1, 'year').format('YYYY');
|
|
|
// // 开始时间(先组合日期,减去三个月)
|
|
|
const nowDate = afterYear + '-' + month;
|
|
|
- const start = moment(nowDate).subtract(3, 'months').format('YYYY-MM-DD');
|
|
|
+ const start = moment(nowDate).subtract(limitMonth, 'months').format('YYYY-MM-DD');
|
|
|
// 结束时间
|
|
|
const end = afterYear + '-' + month;
|
|
|
const r = moment().isBetween(start, end, null, '[]');
|
|
|
console.log(r);
|
|
|
if (r) {
|
|
|
total++;
|
|
|
+ // 2021-11-08 第一天/最后一天/相差天数被10整出的天数(并不算是严格的每隔10天) 发送消息
|
|
|
+ // 是否发送的变量
|
|
|
+ let dr = false;
|
|
|
+ if (moment().format('YYYY-MM-DD') === start || moment().format('YYYY-MM-DD') === end) {
|
|
|
+ // 第一天/最后一天发送
|
|
|
+ dr = true;
|
|
|
+ } else {
|
|
|
+ // 差10天就发
|
|
|
+ const dur = 10;
|
|
|
+ const subDay = moment(end).diff(moment(), 'days');
|
|
|
+ // 判断是不是整数.整数就发送
|
|
|
+ dr = _.isInteger(_.floor(_.divide(subDay, dur)));
|
|
|
+ }
|
|
|
+ // 不发就继续
|
|
|
+ if (!dr) continue;
|
|
|
const { inventor, name } = i;
|
|
|
// 2021-11-04 修改,因为inventor修改为发明人[Object],所以发明人需要处理成字符串
|
|
|
const user_id = inventor.map(i => ObjectId(i.user_id));
|