RemindFocusWechatTask.java 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package com.yihu.wlyy.task;
  2. import com.yihu.wlyy.entity.doctor.profile.Doctor;
  3. import com.yihu.wlyy.service.common.SMSService;
  4. import org.apache.commons.lang3.StringUtils;
  5. import org.json.JSONObject;
  6. import org.springframework.stereotype.Component;
  7. import java.text.SimpleDateFormat;
  8. import java.util.Calendar;
  9. import java.util.List;
  10. import java.util.Map;
  11. /**
  12. * 居民微信关注提醒
  13. * <p>
  14. * Created by lyr-pc on 2017/1/16.
  15. */
  16. public class RemindFocusWechatTask implements Runnable {
  17. List<Map<String, Object>> patients;
  18. Doctor doctor;
  19. /**
  20. * 构造函数
  21. *
  22. * @param patients 居民列表
  23. */
  24. public RemindFocusWechatTask(List<Map<String, Object>> patients, Doctor doctor) {
  25. this.patients = patients;
  26. this.doctor = doctor;
  27. }
  28. @Override
  29. public void run() {
  30. for (Map<String, Object> p : patients) {
  31. try {
  32. if (p.get("mobile") == null || StringUtils.isEmpty(p.get("mobile").toString())) {
  33. continue;
  34. }
  35. String msg = "尊敬的" + p.get("name").toString() + "," + doctor.getName() + "医生提醒您:" +
  36. "为更好地为您提供健康服务,请您关注并登录\"厦门i健康\"微信公众号,与医生进行互动。";
  37. JSONObject smsResult = SMSService.sendMsg(p.get("mobile").toString(), msg);
  38. } catch (Exception e) {
  39. e.printStackTrace();
  40. }
  41. }
  42. }
  43. }