apisql.sql 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. -- create table notice.apisql(
  2. -- id int(11) not null auto_increment,
  3. -- sqlname varchar(255) not null,
  4. -- sqltext text not null,
  5. -- primary key(id)
  6. -- ) ENGINE = InnoDB DEFAULT CHARSET = utf8 comment 'sql语句';
  7. update apisql set
  8. sqltext="select m.* from message m join message_type mt
  9. on m.sys_name=mt.sys_name and m.pasture_id=mt.pasture_id and m.service_id=mt.service_id
  10. where m.status=0 and (
  11. mt.remind_type=1
  12. or
  13. (
  14. mt.remind_type=2 and
  15. timestampdiff(minute,m.created_at,now())>mt.delay_time and
  16. date_format(now(),'%H:%i')>mt.push_time and
  17. (
  18. cycle_type=1 or cycle_type=3 or
  19. (
  20. cycle_type=2 and timestampdiff(minute,m.updated_at,now()) >mt.interval_time
  21. and m.push_count<mt.push_limit
  22. )
  23. )
  24. )
  25. or
  26. (
  27. mt.remind_type=3 and
  28. (
  29. mt.date_type=1
  30. or (mt.date_type=2 and weekday(now() ) +1 =mt.push_date)
  31. or (mt.date_type=3 and (day(now()) =mt.push_date or DAYOFMONTH(now())<mt.push_date))
  32. )
  33. and date_format(now(),'%H:%i')>mt.push_time
  34. )
  35. ) "