|
@ -102,6 +102,7 @@ public class PhysicalExaminationRemindService extends BaseService {
|
|
|
public void sendBatchNotice(long teamId, String doctName) throws Exception {
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
|
|
|
String accessToken = accessTokenUtils.getAccessToken();
|
|
|
Boolean flag = true;
|
|
|
// 推送消息给微信端
|
|
|
JSONObject json = new org.json.JSONObject();
|
|
|
json.put("first", "您的家庭医生" + doctName + "提醒,您可以到签约社区进行免费的健康体检啦~");
|
|
@ -110,63 +111,39 @@ public class PhysicalExaminationRemindService extends BaseService {
|
|
|
json.put("url", "");
|
|
|
json.put("remark", "为了您和您的家庭医生了解您近期的健康状况,请及时到您签约的社区体检哟~");
|
|
|
|
|
|
String sql = "SELECT DISTINCT " +
|
|
|
" t1.* " +
|
|
|
" FROM" +
|
|
|
" wlyy_sign_family t1 " +
|
|
|
" WHERE " +
|
|
|
" t1. STATUS > 0 " +
|
|
|
" AND t1.admin_team_code = 485 " +
|
|
|
" AND ( " +
|
|
|
" YEAR (curdate()) - " +
|
|
|
" IF ( " +
|
|
|
" length(idcard) = 18, " +
|
|
|
" substring(idcard, 7, 4), " +
|
|
|
" IF ( " +
|
|
|
" length(idcard) = 15, " +
|
|
|
" concat('19', substring(idcard, 7, 2)), " +
|
|
|
" NULL " +
|
|
|
" ) " +
|
|
|
" ) " +
|
|
|
" ) > 65 " +
|
|
|
" AND t1.idcard NOT IN ( " +
|
|
|
" SELECT DISTINCT " +
|
|
|
" s.idcard " +
|
|
|
" FROM " +
|
|
|
" wlyy_sign_family s, " +
|
|
|
" wlyy_old_people_physical_examination o " +
|
|
|
" WHERE " +
|
|
|
" s.admin_team_code =485 " +
|
|
|
" AND s.`status` > 0 " +
|
|
|
" AND s.idcard = o.id_card " +
|
|
|
" AND o.medical_time >'2016-10-19 15:12:11' " +
|
|
|
" )" +
|
|
|
" ORDER BY " +
|
|
|
" t1.openid DESC, " +
|
|
|
" CONVERT (t1. NAME USING gbk)";
|
|
|
List<Patient>patients = patientDao.findExaminationRemind(485,new Date());
|
|
|
Patient patient = patientDao.findByCode("");
|
|
|
if (StringUtils.isNotBlank(patient.getOpenid())) {
|
|
|
pushMsgTask.putWxMsg(accessToken, 11, patient.getOpenid(), patient.getName(), json);
|
|
|
}
|
|
|
//发送代理人
|
|
|
JSONArray jsonArray = openIdUtils.getAgentOpenId(patient.getCode(), patient.getOpenid());
|
|
|
if (jsonArray != null && jsonArray.length() > 0) {
|
|
|
for (int i = 0; i < jsonArray.length(); i++) {
|
|
|
org.json.JSONObject j = jsonArray.getJSONObject(i);
|
|
|
Patient member = (Patient) j.get("member");
|
|
|
json.remove("toUser");
|
|
|
json.put("toUser", member.getCode());
|
|
|
json.remove("first");
|
|
|
try {
|
|
|
json.put("first", openIdUtils.getTitleMes(patient, j.isNull("relation") ? 1 : j.getInt("relation"), patient.getName()));
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(member.getOpenid())) {
|
|
|
pushMsgTask.putWxMsg(accessToken, 11, member.getOpenid(), patient.getName(), json);
|
|
|
List<Patient> patients = patientDao.findExaminationRemind(teamId, new Date());
|
|
|
for (Patient patient : patients) {
|
|
|
String mobile = patient.getMobile();
|
|
|
if (StringUtils.isNotBlank(patient.getOpenid())) {
|
|
|
pushMsgTask.putWxMsg(accessToken, 11, patient.getOpenid(), patient.getName(), json);
|
|
|
flag = false;
|
|
|
}
|
|
|
//发送代理人
|
|
|
JSONArray jsonArray = openIdUtils.getAgentOpenId(patient.getCode(), patient.getOpenid());
|
|
|
if (jsonArray != null && jsonArray.length() > 0) {
|
|
|
for (int i = 0; i < jsonArray.length(); i++) {
|
|
|
org.json.JSONObject j = jsonArray.getJSONObject(i);
|
|
|
Patient member = (Patient) j.get("member");
|
|
|
json.remove("toUser");
|
|
|
json.put("toUser", member.getCode());
|
|
|
json.remove("first");
|
|
|
try {
|
|
|
json.put("first", openIdUtils.getTitleMes(patient, j.isNull("relation") ? 1 : j.getInt("relation"), patient.getName()));
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(member.getOpenid())) {
|
|
|
pushMsgTask.putWxMsg(accessToken, 11, member.getOpenid(), patient.getName(), json);
|
|
|
flag = false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// 微信发送失败发送短信
|
|
|
if (flag && StringUtils.isNotEmpty(mobile)) {
|
|
|
smsService.sendMsg(mobile, "您的家庭医生" + doctName + "提醒,您可以到签约社区进行免费的健康体检啦~");
|
|
|
}
|
|
|
flag = true;
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|