|
@ -337,6 +337,70 @@ public class PatientRemindService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// /**
|
|
|
// * 提醒所有患者关注微信
|
|
|
// *
|
|
|
// * @param doctor
|
|
|
// */
|
|
|
// public void remindPatientWechatFocusAll(String doctor) throws Exception {
|
|
|
// try {
|
|
|
// Calendar today = Calendar.getInstance();
|
|
|
// today.set(Calendar.HOUR, 23);
|
|
|
// today.set(Calendar.MINUTE, 59);
|
|
|
// today.set(Calendar.SECOND, 59);
|
|
|
// today.set(Calendar.MILLISECOND, 999);
|
|
|
// int page = 0;
|
|
|
// int start = 0;
|
|
|
// boolean flag = true;
|
|
|
// Doctor doc = doctorDao.findByCode(doctor);
|
|
|
// if (doc == null) {
|
|
|
// throw new Exception("doctor info can not find");
|
|
|
// }
|
|
|
// String sql = "select p.code,p.name,p.mobile" +
|
|
|
// " from " +
|
|
|
// " wlyy_sign_family f join wlyy_patient p on f.patient = p.code" +
|
|
|
// " where " +
|
|
|
// " (f.doctor = ? or f.doctor_health = ?) " +
|
|
|
// " and f.status > 0 " +
|
|
|
// " and f.expenses_status = '1' " +
|
|
|
// " and LENGTH(trim(ifnull(p.openid,''))) < 1 limit ?,3000";
|
|
|
// List<Map<String, Object>> patients = new ArrayList<>();
|
|
|
// List<String> redisPatients = new ArrayList<>();
|
|
|
// Set<String> exist = redisTemplate.opsForSet().members("wechat:focus:remind:set");
|
|
|
// while (flag) {
|
|
|
// List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor, start});
|
|
|
//
|
|
|
// if (result != null && result.size() > 0) {
|
|
|
// patients.addAll(result);
|
|
|
// for (Map<String, Object> map : result) {
|
|
|
// if (exist != null && exist.contains(map.get("code").toString())) {
|
|
|
// continue;
|
|
|
// }
|
|
|
// redisPatients.add(map.get("code").toString());
|
|
|
// }
|
|
|
// page = page + 1;
|
|
|
// start = page * 3000;
|
|
|
// } else {
|
|
|
// flag = false;
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// if (patients.size() > 0) {
|
|
|
// RemindFocusWechatTask task = new RemindFocusWechatTask(patients, doc,sMSService);
|
|
|
// new Thread(task).start();
|
|
|
// redisTemplate.opsForSet().add("wechat:focus:remind:set", redisPatients.toArray(new String[]{}));
|
|
|
// redisTemplate.expire("wechat:focus:remind:set", today.getTimeInMillis() - Calendar.getInstance().getTimeInMillis(), TimeUnit.MILLISECONDS);
|
|
|
// }
|
|
|
//
|
|
|
// redisTemplate.opsForValue().set("wechat:focus:remind:doctor:" + doctor, "0");
|
|
|
// redisTemplate.expire("wechat:focus:remind:doctor:" + doctor, 10, TimeUnit.MINUTES);
|
|
|
// } catch (Exception e) {
|
|
|
// redisTemplate.opsForValue().set("wechat:focus:remind:doctor:" + doctor, "0");
|
|
|
// redisTemplate.expire("wechat:focus:remind:doctor:" + doctor, 10, TimeUnit.MINUTES);
|
|
|
// e.printStackTrace();
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
/**
|
|
|
* 提醒所有患者关注微信
|
|
|
*
|
|
@ -366,14 +430,14 @@ public class PatientRemindService extends BaseService {
|
|
|
" and LENGTH(trim(ifnull(p.openid,''))) < 1 limit ?,3000";
|
|
|
List<Map<String, Object>> patients = new ArrayList<>();
|
|
|
List<String> redisPatients = new ArrayList<>();
|
|
|
Set<String> exist = redisTemplate.opsForSet().members("wechat:focus:remind:set");
|
|
|
Set<String> exist = redisTemplate.keys("wechat:focus:remind:flag:*");
|
|
|
while (flag) {
|
|
|
List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor, start});
|
|
|
|
|
|
if (result != null && result.size() > 0) {
|
|
|
patients.addAll(result);
|
|
|
for (Map<String, Object> map : result) {
|
|
|
if (exist != null && exist.contains(map.get("code").toString())) {
|
|
|
if (exist != null && exist.size()>0&& isExist(map.get("code").toString(),exist)) {
|
|
|
continue;
|
|
|
}
|
|
|
redisPatients.add(map.get("code").toString());
|
|
@ -388,10 +452,11 @@ public class PatientRemindService extends BaseService {
|
|
|
if (patients.size() > 0) {
|
|
|
RemindFocusWechatTask task = new RemindFocusWechatTask(patients, doc,sMSService);
|
|
|
new Thread(task).start();
|
|
|
redisTemplate.opsForSet().add("wechat:focus:remind:set", redisPatients.toArray(new String[]{}));
|
|
|
redisTemplate.expire("wechat:focus:remind:set", today.getTimeInMillis() - Calendar.getInstance().getTimeInMillis(), TimeUnit.MILLISECONDS);
|
|
|
for(String pString:redisPatients){
|
|
|
redisTemplate.opsForValue().set("wechat:focus:remind:flag:"+pString, pString,2,TimeUnit.MINUTES);//向redis里存入数据和设置缓存时
|
|
|
//redisTemplate.opsForValue().set("wechat:focus:remind:flag:"+pString, pString,today.getTimeInMillis() - Calendar.getInstance().getTimeInMillis(),TimeUnit.MILLISECONDS);//向redis里存入数据和设置缓存时
|
|
|
}
|
|
|
}
|
|
|
|
|
|
redisTemplate.opsForValue().set("wechat:focus:remind:doctor:" + doctor, "0");
|
|
|
redisTemplate.expire("wechat:focus:remind:doctor:" + doctor, 10, TimeUnit.MINUTES);
|
|
|
} catch (Exception e) {
|
|
@ -401,6 +466,15 @@ public class PatientRemindService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public boolean isExist(String code,Set<String> set){
|
|
|
for(String c :set){
|
|
|
if(c.contains(code)){
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 微信关注提醒
|
|
|
*
|
|
@ -415,8 +489,11 @@ public class PatientRemindService extends BaseService {
|
|
|
today.set(Calendar.SECOND, 59);
|
|
|
today.set(Calendar.MILLISECOND, 59);
|
|
|
JSONObject result = new JSONObject();
|
|
|
redisTemplate.opsForSet().add("wechat:focus:remind:set", p.get("code").toString());
|
|
|
redisTemplate.expireAt("wechat:focus:remind:set", today.getTime());
|
|
|
|
|
|
redisTemplate.opsForValue().set("wechat:focus:remind:flag:"+ p.get("code").toString(),p.get("code").toString(),today.getTimeInMillis() - Calendar.getInstance().getTimeInMillis(),TimeUnit.MILLISECONDS);//向redis里存入数据和设置缓存时
|
|
|
|
|
|
// redisTemplate.opsForSet().add("wechat:focus:remind:set", p.get("code").toString());
|
|
|
// redisTemplate.expireAt("wechat:focus:remind:set", today.getTime());
|
|
|
|
|
|
if (p.get("mobile") == null || StringUtils.isEmpty(p.get("mobile").toString())) {
|
|
|
result.put("status", -1);
|