Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

chenweida 8 years ago
parent
commit
5f4419e305
19 changed files with 737 additions and 308 deletions
  1. 1 1
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/message/HealthMessageJob.java
  2. 30 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/job/FollowupPlanJob.java
  3. 2 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpDao.java
  4. 19 10
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java
  5. 5 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/statistics/PopulationBaseDao.java
  6. 64 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java
  7. 7 10
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java
  8. 124 104
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  9. 129 36
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  10. 65 47
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/PatientRemindService.java
  11. 74 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  12. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java
  13. 16 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java
  14. 2 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthController.java
  15. 102 81
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/message/DoctorMessageController.java
  16. 33 8
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java
  17. 41 8
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java
  18. 20 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/quota/JobController.java
  19. 2 0
      patient-co-wlyy/src/main/resources/application.properties

+ 1 - 1
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/message/HealthMessageJob.java

@ -101,7 +101,7 @@ public class HealthMessageJob implements Job {
                message.setSender("system");
                message.setCzrq(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(yesterday+" 23:59:00"));
                message.setState(1);
                String title="新增系统消息";
                String title="新增待分配居民";
                message.setTitle(title);
                SimpleDateFormat dateFormat1=new SimpleDateFormat("yyyy-MM-dd");
                SimpleDateFormat dateFormat2=new SimpleDateFormat("MM月dd日");

+ 30 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/job/FollowupPlanJob.java

@ -0,0 +1,30 @@
package com.yihu.wlyy.job;
import com.yihu.wlyy.service.app.followup.FollowUpService;
import com.yihu.wlyy.util.DateUtil;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.util.Date;
/**
 * Created by hzp on 2017.1.4.
 */
public class FollowupPlanJob implements Job {
    @Autowired
    FollowUpService followUpService;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
        System.out.print("follow plan message sending...");
        String date = DateUtil.dateToStrShort(new Date());
        //发送随访计划消息
        followUpService.sendMessage(date);
    }
}

+ 2 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpDao.java

@ -15,6 +15,7 @@ import com.yihu.wlyy.entity.followup.Followup;
import java.util.Date;
import java.util.List;
import java.util.Map;
public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>, JpaSpecificationExecutor<Followup> {
@ -26,4 +27,5 @@ public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>,
    @Query(value = "select a.* from wlyy_followup a where a.doctor_code in ?1 and a.patient_code = ?2 and a.followup_class=?3 and a.status ='1' order by a.followup_date DESC limit 1",nativeQuery = true)
    Followup findLastFollowup(String[] doctors,String patientCode,String followClass) throws Exception;
}

+ 19 - 10
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java

@ -14,33 +14,42 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface MessageDao extends PagingAndSortingRepository<Message, Long>, JpaSpecificationExecutor<Message> {
    @Query("select count(a) from Message a where a.type =1 and a.read= 1 and a.receiver=?1 ")
    int amountUnreadByReceiver(String doctor);
    @Query("select count(1) from Message a where a.type =1 and a.read= 1 and a.receiver=?1 ")
    Integer amountUnreadByReceiver(String doctor);
    @Query("select a from Message a where a.type =1 and a.read= 1 and a.receiver=?1 order by a.czrq desc")
    Page<Message> amountUnreadLastByReceiver(String doctor, Pageable pageRequest);
    @Query("select count(a) from Message a where a.type =2 and a.read= 1 and a.receiver=?1 ")
    int amountUnreadHealthByReceiver(String doctor);
    @Query("select count(1) from Message a where a.type =2 and a.read= 1 and a.receiver=?1 ")
    Integer amountUnreadHealthByReceiver(String doctor);
    @Query("select a from Message a where (a.type =2 ) and a.read= 1 and a.receiver=?1 order by a.czrq desc")
    Page<Message> amountUnreadHealthLastByReceiver(String doctor,Pageable pageRequest);
    @Query("select a from Message a where a.type =2 and a.read= 1 and a.receiver=?1 order by a.czrq desc")
    List<Message> amountUnreadHealthLastByReceiver(String doctor,Pageable pageRequest);
    @Modifying
    @Query("update Message a set a.read = 0,a.over='0' where a.id = ?1")
    int read(long msgid);
    @Query("SELECT a FROM Message a WHERE a.sender=?1 AND a.receiver = ?2 and a.signStatus = ?3 and a.read=1")
    Message findByParams(String sender, String receiver, String signStatus);
    @Query("SELECT a FROM Message a WHERE a.sender=?1 AND a.receiver = ?2 and a.signStatus = ?3 ")
    Message findAllByParams(String sender, String receiver, String signStatus);
    Message findUnreadSign(String sender, String receiver, String signStatus);
    @Query(" from Message a where a.read = 1 and over ='1' and a.sender = ?1 and a.receiver=?2 and a.signStatus='1'")
    Message findByPatient(String patient,String doctor);
    @Query("select a from Message a where a.read= 1 and a.receiver = ?1 and a.sender=?2 and a.tzType=?3")
    List<Message> getHealthIndexMessageByPatient(String doctor,String patient,String type,Pageable pageRequest);
    @Query("select a from Message a where a.read= 1 and a.receiver = ?1 and a.type not in (1,2) order by a.czrq desc")
    List<Message> getSystemMessage(String doctor);
    @Query("select count(a) from Message a where a.read = 0 and a.over ='0'  and a.receiver=?1 and a.type=?2 ")
    int findMessageNum(String doctor, Integer type);
}

+ 5 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/statistics/PopulationBaseDao.java

@ -5,6 +5,9 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Iterator;
import java.util.List;
/**
 * Created by lyr on 2016/08/18.
 */
@ -14,4 +17,6 @@ public interface PopulationBaseDao extends PagingAndSortingRepository<Population
    int findPeopleNumByCode(String code);
    PopulationBase findByCodeAndYear(String code,Integer year);
    List<PopulationBase> findByYear(Integer year);
}

+ 64 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java

@ -8,22 +8,25 @@ import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.followup.Followup;
import com.yihu.wlyy.entity.followup.FollowupContent;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.followup.FollowupContentDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.team.DrHealthTeamService;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.task.FollowupUploadTask;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import com.yihu.wlyy.repository.followup.FollowUpDao;
@ -64,6 +67,12 @@ public class FollowUpService extends BaseService {
	@Autowired
	private DrHealthTeamService drHealthTeamService;
	@Autowired
	private MessageDao messageDao;
	@Autowired
	private JdbcTemplate jdbcTemplate;
	/**
	 * 转译随访信息
     */
@ -550,7 +559,7 @@ public class FollowUpService extends BaseService {
				FollowupContent copyItem = new FollowupContent();
				copyItem.setFollowupId(id);
				copyItem.setFollowupKey(item.getFollowupKey());
				copyItem.setFollowupValue(item.getFollowupKey());
				copyItem.setFollowupValue(item.getFollowupValue());
				copyItem.setFollowupProject(item.getFollowupProject());
				copyItem.setCreateTime(new Date());
				copyList.add(copyItem);
@ -559,4 +568,57 @@ public class FollowUpService extends BaseService {
			followupContentDao.save(copyList);
		}
	}
	/**************************************** 随访计划消息 ******************************************/
	/**
	 * 每日发送随访计划提醒消息
     */
	@Transactional
	public void sendMessage(String date)
	{
	    try{
			String start = date +" 00:00:00";
			String end = date +" 23:59:59";
			String sql = "select doctor_code,count(1) count from wlyy_followup where status not in ('0','1') and followup_plan_date>='"+start+"' and followup_plan_date<='"+end+"' group by doctor_code";
			//获取所有未执行随访计划
			List<Map<String,Object>> followupToday = jdbcTemplate.queryForList(sql);
			if(followupToday!=null)
			{
				List<Message> list = new ArrayList<>();
				for(Map<String,Object> map:followupToday)
				{
					String doctor = String.valueOf(map.get("doctor_code"));
					String count = String.valueOf(map.get("count"));
					// 添加签约消息
					String title = "随访计划提醒";
					String content = "您今日有" +count+"个随访计划待处理";
					Message message = new Message();
					message.setCode(getCode());
					message.setCzrq(new Date());
					message.setContent(content);
					message.setRead(1);//设置未读
					message.setReceiver(doctor);//设置接受医生的code
					message.setSender("system");//设置发送的用户
					message.setTitle(title);
					message.setType(4);//随访计划提醒
					message.setReadonly(1);//是否只读消息
					list.add(message);
					// 推送消息给医生
					PushMsgTask.getInstance().put(doctor,"4",title,content,"");
				}
				messageDao.save(list);
			}
		}
		catch (Exception e)
		{
		   e.printStackTrace();
		}
	}
}

+ 7 - 10
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java

@ -383,11 +383,12 @@ public class PatientHealthIndexService extends BaseService {
            // 餐后
            if (index % 2 == 0) {
                if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueBefore, minValueBefore)) {
                    msgContent += patient.getName() + "饭后血糖超标,血糖值" + value1 + ",参考范围:" + minValueAfter + " ~ " + maxValueAfter + ";\n";
                    msgContent += patient.getName() + "血糖异常("+value1+"mmol/L),请处理";
                }
            } else { //餐前
            }
            else { //餐前
                if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueAfter, minValueAfter)) {
                    msgContent += patient.getName() + "饭前血糖超标,血糖值" + value1 + ",参考范围:" + minValueBefore + " ~ " + maxValueBefore + ";\n";
                    msgContent += patient.getName() + "血糖异常("+value1+"mmol/L),请处理";
                }
            }
        }
@ -415,13 +416,9 @@ public class PatientHealthIndexService extends BaseService {
                    minValueSZY = standard.getMinValue2();
                }
            }
            // 收缩压校验
            if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueSSY, minValueSSY)) {
                msgContent += "血压超标,收缩压" + value1 + ",参考范围:" + minValueSSY + " ~ " + maxValueSSY + ";\n";
            }
            // 舒张压
            if (!checkHealthIndex(NumberUtils.toDouble(value2), maxValueSZY, minValueSZY)) {
                msgContent += "血压超标,舒张压" + value2 + ",参考范围:" + minValueSZY + " ~ " + maxValueSZY + ";\n";
            // 收缩压/舒张压校验
            if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueSSY, minValueSSY)||!checkHealthIndex(NumberUtils.toDouble(value2), maxValueSZY, minValueSZY)) {
                msgContent = patient.getName() +"血压异常(舒张压 "+value2+"mmHg、收缩压 "+value1+"mmHg),请处理";
            }
        }

+ 124 - 104
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -161,29 +161,29 @@ public class SignPatientLabelInfoService extends BaseService {
        }
        if (json.has("expensesStatus") && (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0"))) {
            String epTime = "";
            boolean epTime = false;
            try {
                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
            } catch (Exception e) {
                e.printStackTrace();
            }
            if (StringUtils.isEmpty(epTime)) {
            if (!epTime) {
                json.put("expensesRemindStatus", 0);
            } else {
                json.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                json.put("expensesRemindStatus", 1);
            }
        }
        String epTime = "";
        boolean epTime = false;
        try {
            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (StringUtils.isEmpty(epTime)) {
        if (!epTime) {
            json.put("wechatFocusRemind", 0);
        } else {
            json.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
            json.put("wechatFocusRemind", 1);
        }
        return json;
@ -303,28 +303,28 @@ public class SignPatientLabelInfoService extends BaseService {
                        // 缴费类型
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            String epTime = "";
                            boolean epTime = false;
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set",  p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            if (StringUtils.isEmpty(epTime)) {
                            if (!epTime) {
                                jsonP.put("expensesRemindStatus", 0);
                            } else {
                                jsonP.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                                jsonP.put("expensesRemindStatus", 1);
                            }
                        }
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            jsonP.put("wechatFocusRemind", 1);
                        }
                    }
@ -369,32 +369,32 @@ public class SignPatientLabelInfoService extends BaseService {
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            json.put("expensesRemindStatus", 1);
                        }
                    }
                } else {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                String epTime = "";
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (StringUtils.isEmpty(epTime)) {
                if (!epTime) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                    json.put("wechatFocusRemind", 1);
                }
                // 患者标签
                //json.put("labels", labels == null ? "" : labels);
@ -457,28 +457,28 @@ public class SignPatientLabelInfoService extends BaseService {
                        // 缴费类型
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            String epTime = "";
                            boolean epTime = false;
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            if (StringUtils.isEmpty(epTime)) {
                            if (!epTime) {
                                jsonP.put("expensesRemindStatus", 0);
                            } else {
                                jsonP.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                                jsonP.put("expensesRemindStatus", 1);
                            }
                        }
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            jsonP.put("wechatFocusRemind", 1);
                        }
                    }
                    continue;
@ -536,32 +536,32 @@ public class SignPatientLabelInfoService extends BaseService {
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            json.put("expensesRemindStatus", 1);
                        }
                    }
                } else {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                String epTime = "";
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (StringUtils.isEmpty(epTime)) {
                if (!epTime) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                    json.put("wechatFocusRemind", 1);
                }
                // 患者标签
                json.put("labels", labels == null ? "" : labels);
@ -700,6 +700,16 @@ public class SignPatientLabelInfoService extends BaseService {
                json.put("amount", amount);
                int focusAmount = 0;
                sql += labelType.equals("5") ? " AND LENGTH(TRIM(IFNULL(openid,''))) > 0 " : " AND LENGTH(TRIM(IFNULL(t1.openid,''))) > 0 ";
                List<Map<String, Object>> focusCount = jdbcTemplate.queryForList(sql, args);
                if (focusCount != null && focusCount.size() > 0 && focusCount.get(0).containsKey("count")) {
                    focusAmount = Integer.valueOf(String.valueOf(focusCount.get(0).get("count")));
                }
                json.put("focusAmount", focusAmount);
                if (label.getLabelCode().equals("0") && labelType.equals("1") && amount < 1) {
                    continue;
                }
@ -857,6 +867,16 @@ public class SignPatientLabelInfoService extends BaseService {
                json.put("amount", amount);
                int focusAmount = 0;
                sql += labelType.equals("5") ? " AND LENGTH(TRIM(IFNULL(openid,''))) > 0 " : " AND LENGTH(TRIM(IFNULL(t1.openid,''))) > 0 ";
                List<Map<String, Object>> focusCount = jdbcTemplate.queryForList(sql, args);
                if (focusCount != null && focusCount.size() > 0 && focusCount.get(0).containsKey("count")) {
                    focusAmount = Integer.valueOf(String.valueOf(focusCount.get(0).get("count")));
                }
                json.put("focusAmount", focusAmount);
                if (label.getLabelCode().equals("0") && labelType.equals("1") && amount < 1) {
                    continue;
                }
@ -1282,28 +1302,28 @@ public class SignPatientLabelInfoService extends BaseService {
                        // 缴费类型
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            String epTime = "";
                            boolean epTime = false;
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            if (StringUtils.isEmpty(epTime)) {
                            if (!epTime) {
                                jsonP.put("expensesRemindStatus", 0);
                            } else {
                                jsonP.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                                jsonP.put("expensesRemindStatus", 1);
                            }
                        }
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            jsonP.put("wechatFocusRemind", 1);
                        }
                    }
@ -1371,32 +1391,32 @@ public class SignPatientLabelInfoService extends BaseService {
//                    json.put("qyrq", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD) : "");
//                }
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            json.put("expensesRemindStatus", 1);
                        }
                    }
                } else {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                String epTime = "";
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (StringUtils.isEmpty(epTime)) {
                if (!epTime) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                    json.put("wechatFocusRemind", 1);
                }
                // 患者标签
                json.put("labels", labels == null ? "" : labels);
@ -1746,28 +1766,28 @@ public class SignPatientLabelInfoService extends BaseService {
                        // 缴费类型
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            String epTime = "";
                            boolean epTime = false;
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            if (StringUtils.isEmpty(epTime)) {
                            if (!epTime) {
                                jsonP.put("expensesRemindStatus", 0);
                            } else {
                                jsonP.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                                jsonP.put("expensesRemindStatus", 1);
                            }
                        }
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            jsonP.put("wechatFocusRemind", 1);
                        }
                    }
@ -1832,32 +1852,32 @@ public class SignPatientLabelInfoService extends BaseService {
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            json.put("expensesRemindStatus", 1);
                        }
                    }
                } else {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                String epTime = "";
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (StringUtils.isEmpty(epTime)) {
                if (!epTime) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                    json.put("wechatFocusRemind", 1);
                }
                // 患者标签
                json.put("labels", labels == null ? "" : labels);
@ -1924,29 +1944,29 @@ public class SignPatientLabelInfoService extends BaseService {
                        // 缴费类型
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            String epTime = "";
                            boolean epTime = false;
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            if (StringUtils.isEmpty(epTime)) {
                            if (!epTime) {
                                jsonP.put("expensesRemindStatus", 0);
                            } else {
                                jsonP.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                                jsonP.put("expensesRemindStatus", 1);
                            }
                        }
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            jsonP.put("wechatFocusRemind", 1);
                        }
                    }
@ -1997,32 +2017,32 @@ public class SignPatientLabelInfoService extends BaseService {
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            json.put("expensesRemindStatus", 1);
                        }
                    }
                } else {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                String epTime = "";
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (StringUtils.isEmpty(epTime)) {
                if (!epTime) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                    json.put("wechatFocusRemind", 1);
                }
                // 患者标签
                json.put("labels", labels == null ? "" : labels);
@ -2142,29 +2162,29 @@ public class SignPatientLabelInfoService extends BaseService {
                        // 缴费类型
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            String epTime = "";
                            boolean epTime = false;
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            if (StringUtils.isEmpty(epTime)) {
                            if (!epTime) {
                                jsonP.put("expensesRemindStatus", 0);
                            } else {
                                jsonP.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                                jsonP.put("expensesRemindStatus", 1);
                            }
                        }
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            jsonP.put("wechatFocusRemind", 1);
                        }
                    }
@ -2209,32 +2229,32 @@ public class SignPatientLabelInfoService extends BaseService {
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            json.put("expensesRemindStatus", 1);
                        }
                    }
                } else {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                String epTime = "";
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (StringUtils.isEmpty(epTime)) {
                if (!epTime) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                    json.put("wechatFocusRemind", 1);
                }
                // 患者标签
                //json.put("labels", labels == null ? "" : labels);

+ 129 - 36
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java

@ -7,9 +7,11 @@ import javax.transaction.Transactional;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SystemConf;
import io.swagger.models.auth.In;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
@ -17,6 +19,7 @@ import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.Specification;
@ -46,6 +49,17 @@ public class MessageService extends BaseService {
    private MessageDao messageDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PatientDao patientDao;
    /**
     * IM消息数量
     */
    private String getImMsgAmount(String doctor){
        String url = SystemConf.getInstance().getSystemProperties().getProperty("im_list_get")
                + "/api/v1/chats/msg/amount?user_id="+doctor;
        return HttpClientUtil.get(url, "UTF-8");
    }
    /**
     * 汇总查询医生的消息总数
@ -73,11 +87,8 @@ public class MessageService extends BaseService {
    /**
     * 查询医生未读消息和最后消息
     *
     * @param doctor
     * @return
     */
    public JSONObject findDoctorAllMessage(String doctor) {
    public JSONObject findDoctorAllMessage(String doctor) throws Exception {
        // 签约未读消息总数
        int sign = messageDao.amountUnreadByReceiver(doctor);
@ -90,54 +101,66 @@ public class MessageService extends BaseService {
            if (msgs != null && msgs.getSize() > 0) {
                for (Message msg : msgs) {
                    JSONObject msgJson = new JSONObject();
                    msgJson.put("title", msg.getTitle());
                    msgJson.put("type", msg.getType());
                    if (msg.getSignStatus().equals("4")) {
                        msgJson.put("msg", msg.getSenderName() + "申请与您解除家庭签约");
                    } else {
                        msgJson.put("msg", msg.getSenderName() + "申请与您签约家庭医生");
                    }
                    msgJson.put("msgTime", msg.getCzrq() != null ? DateUtil.dateToStr(msg.getCzrq(), DateUtil.YYYY_MM_DD) : "");
                    msgJson.put("msgTime", DateUtil.dateToStrLong(msg.getCzrq()));
                    signJson.put("lastMessage", msgJson);
                }
            }
        }
        // 体征指标未读消息总数
        int healthIndex = messageDao.amountUnreadHealthByReceiver(doctor);
        Integer healthIndex = messageDao.amountUnreadHealthByReceiver(doctor);
        JSONObject indexJson = new JSONObject();
        indexJson.put("amount", healthIndex);
        if (sign > 0) {
        if (healthIndex > 0) {
            PageRequest pageRequest = new PageRequest(0, 1);
            Page<Message> msgs = messageDao.amountUnreadHealthLastByReceiver(doctor, pageRequest);
            List<Message> msgs = messageDao.amountUnreadHealthLastByReceiver(doctor, pageRequest);
            if (msgs != null && msgs.getSize() > 0) {
                for (Message msg : msgs) {
                    JSONObject msgJson = new JSONObject();
                    msgJson.put("msg", msg.getContent());
                    msgJson.put("msgTime", msg.getCzrq() != null ? DateUtil.dateToStr(msg.getCzrq(), DateUtil.YYYY_MM_DD) : "");
                    indexJson.put("lastMessage", msgJson);
                }
            if (msgs != null && msgs.size() > 0) {
                JSONObject msgJson = new JSONObject();
                msgJson.put("title", msgs.get(0).getTitle());
                msgJson.put("type", msgs.get(0).getType());
                msgJson.put("msg",  msgs.get(0).getContent());
                msgJson.put("msgTime",  DateUtil.dateToStrLong(msgs.get(0).getCzrq()));
                indexJson.put("lastMessage", msgJson);
            }
        }
        //获取系统消息总数
        int count= messageDao.findMessageNum(doctor,3);
        //获取系统消息
        List<Message> systemMessage = messageDao.getSystemMessage(doctor);
        JSONObject systemJson = new JSONObject();
        systemJson.put("amount", count);
        JSONObject json = new JSONObject();
        getImMsgAmount(json,doctor);//IM消息数量
        if(systemMessage!=null && systemMessage.size()>0)
        {
            systemJson.put("amount", systemMessage.size());
            JSONObject msgJson = new JSONObject();
            msgJson.put("title", systemMessage.get(0).getTitle());
            msgJson.put("type", systemMessage.get(0).getType());
            msgJson.put("msg", systemMessage.get(0).getContent());
            msgJson.put("msgTime", DateUtil.dateToStrLong(systemMessage.get(0).getCzrq()));
            systemJson.put("lastMessage", msgJson);
        }
        else{
            systemJson.put("amount", 0);
        }
        JSONObject json = new JSONObject();
        json.put("imMsgCount",getImMsgAmount(doctor));//IM消息数量
        json.put("sign", signJson);//签约数
        json.put("healthIndex", indexJson);//健康指标
        json.put("system", systemJson);//系统消息
        return json;
    }
    private void  getImMsgAmount(JSONObject obj,String doctor){
        String url = SystemConf.getInstance().getSystemProperties().getProperty("im_list_get")
                + "/api/v1/chats/msg/amount?user_id="+doctor;
        String response = HttpClientUtil.get(url, "UTF-8");
        obj.put("imMsgCount",response);
    }
    /**
     * 查询健康咨询列表
     *
@ -203,14 +226,11 @@ public class MessageService extends BaseService {
    }
    /**
     * 根据参数查询指定的消息
     *
     * @return
     * 未读签约信息
     */
    public Message findMessage(String sender, String receiver, String signStatus) {
    public Message findUnreadSign(String sender, String receiver, String signStatus) {
        return messageDao.findByParams(sender, receiver, signStatus);
        return messageDao.findUnreadSign(sender, receiver, signStatus);
    }
    public Page<Message> find(String doctor, String type, long id, int pagesize) {
@ -252,8 +272,81 @@ public class MessageService extends BaseService {
        return jo;
    }
    public void changeMessageToRead(Long id) {
        Message message= messageDao.findOne(id);
        message.setRead(1);
    /**
     * 获取超标指标消息--根据患者分组
     */
    public List<Map<String,Object>> getHealthIndexMessage(String doctor)throws Exception{
        List<Map<String,Object>> re = new ArrayList<>();
        String sql = "select a.sender,a.tz_type,count(1) count,max(date_format(a.czrq,'%Y-%c-%d %h:%i:%s')) last_time from wlyy_Message a where a.receiver='"+doctor+"' and a.has_read='1' and a.type='2' group by a.sender,a.tz_type order by last_time desc";
        List<Map<String,Object>> list =jdbcTemplate.queryForList(sql);
        for(Map<String,Object> item:list)
        {
            Map<String,Object> obj = new HashMap<>();
            String patientCode = String.valueOf(item.get("sender"));
            //获取患者信息
            Patient patient =patientDao.findByCode(patientCode);
            if(patient!=null)
            {
                String type = String.valueOf(item.get("tz_type")); //1血糖,2血压,3体重,4腰
                obj.put("patient",patientCode);
                obj.put("type",type);
                obj.put("time",item.get("last_time"));
                obj.put("name",patient.getName());
                obj.put("sex",patient.getSex());
                obj.put("birthday",DateUtil.dateToStrShort(patient.getBirthday()));
                obj.put("sex",patient.getSex());
                obj.put("photo",patient.getPhoto());
                if("1".equals(type))
                {
                    obj.put("message","有"+item.get("count")+"条血糖异常未读消息") ;
                }
                else if("2".equals(type))
                {
                    obj.put("message","有"+item.get("count")+"条血压异常未读消息") ;
                }
                else{
                    break;
                }
                re.add(obj);
            }
            else{
                System.out.print("not exit patient!code:"+patientCode);
            }
        }
        return re;
    }
    /**
     * 获取患者超标指标消息
     */
    public List<Map<String,String>> getHealthIndexMessageByPatient(String doctor, String patient, String type, Integer page, Integer pagesize)throws Exception{
        List<Map<String,String>> re = new ArrayList<>();
        // 排序
        Sort sort = new Sort(Sort.Direction.DESC, "czrq");
        Pageable pageRequest = new PageRequest(page-1, pagesize, sort);
        List<Message> list= messageDao.getHealthIndexMessageByPatient(doctor,patient,type,pageRequest);
        if(list!=null && list.size()>0)
        {
            for(Message item:list)
            {
                Map<String,String> map = new HashMap<>();
                map.put("id",String.valueOf(item.getId()));
                map.put("sender",item.getSender());
                map.put("senderName",item.getSenderName());
                map.put("senderPhoto",item.getSenderPhoto());
                map.put("type",type);
                map.put("read",String.valueOf(item.getRead()));
                map.put("sex",String.valueOf(item.getSex()));
                map.put("value1",String.valueOf(item.getValue1()));
                map.put("value2",String.valueOf(item.getValue2()));
                map.put("czrq",DateUtil.dateToStrLong(item.getCzrq()));
                re.add(map);
            }
        }
        return re;
    }
}

+ 65 - 47
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/PatientRemindService.java

@ -25,10 +25,7 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
@ -76,7 +73,11 @@ public class PatientRemindService extends BaseService {
            }
            RemindAll(doc, hos);
            redisTemplate.opsForValue().set("expenses:remind:doctor:" + doctor, "0");
            redisTemplate.expire("expenses:remind:doctor:" + doctor, 10, TimeUnit.MINUTES);
        } catch (Exception e) {
            redisTemplate.opsForValue().set("expenses:remind:doctor:" + doctor, "0");
            redisTemplate.expire("expenses:remind:doctor:" + doctor, 10, TimeUnit.MINUTES);
            e.printStackTrace();
        }
    }
@ -87,8 +88,7 @@ public class PatientRemindService extends BaseService {
     * @param doc
     * @param hos
     */
    public void RemindAll(Doctor doc, Hospital hos) {
        try {
    public void RemindAll(Doctor doc, Hospital hos) throws Exception {
            boolean flag = true;
            int page = 0;
            int start = 0;
@ -103,14 +103,13 @@ public class PatientRemindService extends BaseService {
                    "     limit ?,3000";
            while (flag) {
                List<Patient> result = jdbcTemplate.query(sql,new Object[]{doc.getCode(), doc.getCode(), start}, new BeanPropertyRowMapper(Patient.class));
                List<Patient> result = jdbcTemplate.query(sql, new Object[]{doc.getCode(), doc.getCode(), start}, new BeanPropertyRowMapper(Patient.class));
                if (result != null && result.size() > 0) {
                    for (Patient p : result) {
                        if (p != null) {
                            String epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            if (StringUtils.isNotEmpty(epTime) &&
                                    new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime)) {
                            Boolean epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                            if (epTime) {
                                continue;
                            }
                            remindPatientExpenses(p, doc, hos, true);
@ -122,9 +121,6 @@ public class PatientRemindService extends BaseService {
                    flag = false;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
@ -172,6 +168,11 @@ public class PatientRemindService extends BaseService {
     */
    public JSONObject remindPatientExpenses(Patient p, Doctor doc, Hospital hos, boolean ignore) 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,59);
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            JSONObject reObj = new JSONObject();
            String mDesc = "";
@ -211,14 +212,14 @@ public class PatientRemindService extends BaseService {
            SendP2PUtil.sendP2Pmsg(doc.getCode(), p.getCode(), "1", doc.getName() + "医生提醒您:为完成家庭医生签约," +
                    "尽早为您提供家庭医生服务,请尽快到" + hos.getName() + "(地址:" + hos.getAddress() + ")缴费");
            if (ignore) {
                redisTemplate.opsForValue().set("expenses:remind:" + p.getCode(), df.format(new Date()));
                redisTemplate.expire("expenses:remind:" + p.getCode(), 1, TimeUnit.DAYS);
                redisTemplate.opsForSet().add("expenses:remind:set",p.getCode());
                redisTemplate.expireAt("expenses:remind:set", today.getTime());
            }
            if (wFlag || mFlag) {
                reObj.put("status", 200);
                redisTemplate.opsForValue().set("expenses:remind:" + p.getCode(), df.format(new Date()));
                redisTemplate.expire("expenses:remind:" + p.getCode(), 1, TimeUnit.DAYS);
                redisTemplate.opsForSet().add("expenses:remind:set",p.getCode());
                redisTemplate.expireAt("expenses:remind:set", today.getTime());
                if (wFlag && mFlag) {
                    reObj.put("msg", "提醒成功");
                } else if (mFlag && !wFlag) {
@ -294,36 +295,48 @@ public class PatientRemindService extends BaseService {
     */
    @Async
    public void remindPatientWechatFocusAll(String doctor) throws Exception {
        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";
        while (flag) {
            List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor, start});
            if (result != null && result.size() > 0) {
                for (Map<String, Object> map : result) {
                    remindWechatFocus(map, doc);
        try {
            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";
            while (flag) {
                List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor, start});
                if (result != null && result.size() > 0) {
                    for (Map<String, Object> map : result) {
                        boolean epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", map.get("code").toString());
                        if (epTime) {
                            continue;
                        }
                        remindWechatFocus(map, doc);
                    }
                    page = page + 1;
                    start = page * 3000;
                } else {
                    flag = false;
                }
                page = page + 1;
                start = page * 3000;
            } else {
                flag = false;
            }
        }
            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();
        }
    }
@ -335,14 +348,19 @@ public class PatientRemindService extends BaseService {
     * @return
     */
    public JSONObject remindWechatFocus(Map<String, Object> p, Doctor doctor) {
        Calendar today = Calendar.getInstance();
        today.set(Calendar.HOUR,23);
        today.set(Calendar.MINUTE,59);
        today.set(Calendar.SECOND,59);
        today.set(Calendar.MILLISECOND,59);
        JSONObject result = new JSONObject();
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        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);
            result.put("msg", "对不起,居民未绑定手机号,无法短信提醒");
            redisTemplate.opsForValue().set("wechat:focus:remind:" + p.get("code").toString(), df.format(new Date()));
            redisTemplate.expire("wechat:focus:remind:" + p.get("code").toString(), 1, TimeUnit.DAYS);
            return result;
        }
@ -352,7 +370,7 @@ public class PatientRemindService extends BaseService {
        JSONObject smsResult = smsService.sendMsg(p.get("mobile").toString(), msg);
        if (smsResult != null && smsResult.getInt("result") == 0) {
            result.put("status", 1);
            result.put("status", 200);
            result.put("msg", "提醒成功");
        } else {
            result.put("status", -1);

+ 74 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.service.app.sign;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
@ -10,6 +11,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -33,6 +35,8 @@ public class SignWebService extends BaseService {
    private SignFamilyDao signFamilyDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private StringRedisTemplate redisTemplate;
    /**
     * 根据医生代码及签约状态编码 获取该医生签约患者的信息列表
@ -62,6 +66,7 @@ public class SignWebService extends BaseService {
                "    ,a.reason " +
                "    ,b.street_name as streetName" +
                "    ,b.sex" +
                "    ,b.openid" +
                " from " +
                " ( select code,patient,doctor,status,id,apply_date,patient_apply_date,expenses_time,reason,begin from wlyy_sign_family where (doctor = ? or doctor_health = ?) and status = ? and type = 2" +
                (status == 3 ? " and expenses_status = '1'" : "") + " order by begin desc ) a " +
@ -86,6 +91,7 @@ public class SignWebService extends BaseService {
                "    ,a.reason " +
                "    ,b.street_name as streetName" +
                "    ,b.sex" +
                "    ,b.openid" +
                " from " +
                " ( select code,patient,doctor,status,id,apply_date,reason,begin,expenses_status,LENGTH(trim(ifnull(expenses_status,''))) len from wlyy_sign_family where (doctor = ? or doctor_health = ?) and status > ? and type = 2 order by begin desc ) a " +
                " ,wlyy_patient b " +
@ -109,6 +115,7 @@ public class SignWebService extends BaseService {
                "    ,a.reason " +
                "    ,b.street_name as streetName" +
                "    ,b.sex" +
                "    ,b.openid" +
                " from " +
                " ( select code,patient,doctor,status,id,apply_date,apply_unsign_date,reason,begin from wlyy_sign_family where (doctor = ? or doctor_health = ?) and ( status = ? or status = ? ) and type = 2 order by begin desc ) a " +
                " ,wlyy_patient b " +
@ -139,6 +146,73 @@ public class SignWebService extends BaseService {
        return patients;
    }
    /**
     * 查询家庭签约已缴费未关注人数
     *
     * @param doctor
     * @return
     */
    public int isRemindFocusAll(String doctor) {
        boolean isAll = true;
        // 查询语句
        String sql = "select distinct b.code" +
                " from " +
                "     wlyy_sign_family f" +
                "     ,wlyy_patient b " +
                " where " +
                "     f.patient = b.code " +
                "     and (f.doctor = ? or f.doctor_health = ?)" +
                "     and f.expenses_status = '1' " +
                "     and f.status > 0 " +
                "     and f.type = 2 " +
                "     and (b.openid is null or LENGTH(trim(ifnull(b.openid,''))) < 1)";
        List<String> result = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor},String.class);
        if (result != null && result.size() > 0) {
            Set<String> set = redisTemplate.opsForSet().members("wechat:focus:remind:set");
            if (set == null) {
                isAll = false;
            } else if(!set.containsAll(result)) {
                isAll = false;
            }
        }
        return isAll ? 1 : 0;
    }
    /**
     * 查询家庭签约已缴费未关注人数
     *
     * @param doctor
     * @return
     */
    public int isRemindExpensesAll(String doctor) {
        boolean isAll = true;
        // 查询语句
        String sql = "select distinct f.patient" +
                " from " +
                "     wlyy_sign_family f" +
                " where " +
                "     (f.doctor = ? or f.doctor_health = ?)" +
                "     and f.status > 0 " +
                "     and f.type = 2 " +
                "     and (f.expenses_status is null or LENGTH(trim(ifnull(f.expenses_status,''))) < 1)";
        List<String> result = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor},String.class);
        if (result != null && result.size() > 0) {
            Set<String> set = redisTemplate.opsForSet().members("expenses:remind:set");
            if (set == null) {
                isAll = false;
            } else if(!set.containsAll(result)) {
                isAll = false;
            }
        }
        return isAll ? 1 : 0;
    }
    /**
     * 根据代码查找签约信息明细
     *

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java

@ -83,7 +83,7 @@ public class StatisticsService extends BaseService {
     * @return
     */
    public boolean peopleNumToRedis() {
        Iterable<PopulationBase> peopleNums = peopleNumDao.findAll();
        List<PopulationBase> peopleNums = peopleNumDao.findByYear(Calendar.getInstance().get(Calendar.YEAR));
        for (PopulationBase peopleNum : peopleNums) {
            redisTemplate.opsForValue().set("people:num:" + peopleNum.getCode(), new JSONObject(peopleNum).toString());

+ 16 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java

@ -319,4 +319,20 @@ public class DoctorFollowUpController extends BaseController {
			return invalidUserException(e, -1, "复制上次随访失败!"+e.getMessage());
		}
	}
	/*************************************** 发送随访计划消息 ********************************************/
	@ApiOperation("发送随访计划消息")
	@RequestMapping(value = "/sendMessage", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String sendMessage(@ApiParam(name="date",value="日期",defaultValue = "2017-01-05")
								  @RequestParam(value="date",required = true) String date)
	{
		try {
			followUpService.sendMessage(date);
			return write(200, "发送随访计划消息成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "发送随访计划消息失败!"+e.getMessage());
		}
	}
}

+ 2 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthController.java

@ -300,4 +300,6 @@ public class DoctorHealthController extends BaseController {
		}
	}
}

+ 102 - 81
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/message/DoctorMessageController.java

@ -2,6 +2,8 @@ package com.yihu.wlyy.web.doctor.message;
import com.yihu.wlyy.entity.message.Message;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -19,6 +21,7 @@ import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping(value = "/doctor/message", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ -28,35 +31,29 @@ public class DoctorMessageController extends BaseController {
	@Autowired
	private MessageService messageService;
	/**
	 * 医生消息总数统计接口
	 * @return
	 */
	@RequestMapping(value = "amount")
	@RequestMapping(value = "messages")
	@ResponseBody
	public String amount() {
	@ApiOperation("查询医生未读消息和最后消息")
	public String messages() {
		try {
			JSONObject json = messageService.findDoctorAllMessageAmount(getUID());
			if (json == null) {
				return error(-1, "获取消息总数失败!");
			} else {
				return write(200, "获取消息总数成功!", "data", json);
			}
			JSONObject json = messageService.findDoctorAllMessage(getUID());
			return write(200, "获取消息总数成功!", "data", json);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取消息总数失败!");
			return error(-1, e.getMessage());
		}
	}
	/**
	 * 医生消息总数统计接口
	 * @return
	 */
	@RequestMapping(value = "messages")
	@RequestMapping(value = "amount")
	@ResponseBody
	public String messages() {
	public String amount() {
		try {
			JSONObject json = messageService.findDoctorAllMessage(getUID());
			JSONObject json = messageService.findDoctorAllMessageAmount(getUID());
			if (json == null) {
				return error(-1, "获取消息总数失败!");
			} else {
@ -111,53 +108,6 @@ public class DoctorMessageController extends BaseController {
		}
	}
	/**
	 * 体征指标消息查询接口
	 * @param id
	 * @param pagesize
	 * @param isRead 1未读,0已读
	 * @return
	 */
	@RequestMapping(value = "health")
	@ResponseBody
	public String health(long id, int pagesize, @RequestParam(required = false) String isRead) {
		try {
			JSONArray array = new JSONArray();
			Page<Message> list = messageService.findHealthListByDoctor(getUID(), id, pagesize, isRead);
			for (Message msg : list) {
				if (msg == null) {
					continue;
				}
				JSONObject json = new JSONObject();
				// 消息ID
				json.put("id", msg.getId());
				// 发送人标识
				json.put("sender", msg.getSender());
				// 发送人姓名
				json.put("senderName", msg.getSenderName());
				// 发送人头像
				json.put("senderPhoto", msg.getSenderPhoto());
				// 消息类型:1血糖,2血压
				json.put("type", msg.getTzType());
				// 是否已读:1未读,0已读
				json.put("read", msg.getRead());
				// 是否已读:
				json.put("sex", msg.getSex());
				// 当前值/收缩压,正数为高,负数为低
				json.put("value1", msg.getValue1());
				// 上次值/舒张压,正数为高,负数为低
				json.put("value2", msg.getValue2());
				// 发送时间
				json.put("czrq", DateUtil.dateToStrLong(msg.getCzrq()));
				array.put(json);
			}
			return write(200, "获取体征消息成功!", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取体征消息失败!");
		}
	}
	/**
	 * 更新体征消息为已读
	 * @param msgid
@ -165,6 +115,7 @@ public class DoctorMessageController extends BaseController {
	 */
	@RequestMapping(value = "read_health")
	@ResponseBody
	@ApiOperation("消息设置成已读")
	public String readHealth(long msgid) {
		try {
			messageService.readHealth(msgid);
@ -175,16 +126,16 @@ public class DoctorMessageController extends BaseController {
		}
	}
	/**
	 * 根据参数查询发送给我的消息
	 * @return
	 */
	@RequestMapping(value = "find")
	@ResponseBody
	public String find(String sender, String signStatus) {
	@ApiOperation("查询发送给我的消息")
	public String findMyMessage(String sender, String signStatus) {
		try {
			Message msg = messageService.findMessage(sender, getUID(), signStatus);
			Message msg = messageService.findUnreadSign(sender, getUID(), signStatus);
			JSONObject json = null;
			if (msg != null) {
				json = new JSONObject();
@ -203,11 +154,9 @@ public class DoctorMessageController extends BaseController {
			return error(-1, "获取消息失败!");
		}
	}
	/**
	 * @param type 消息类型  1.是家庭签约信息  2.体征消息  3分配健管师
	 * @param id  消息id
	 * @param pagesize  每頁顯示條數
	 * @return
	 * @param type 消息类型  1.是家庭签约信息  2.体征消息  3系统消息(分配健管师 + 随访计划消息 )
	 */
	@RequestMapping(value = "findMessage")
	@ResponseBody
@ -246,13 +195,57 @@ public class DoctorMessageController extends BaseController {
			return error(-1, "获取消息失败!");
		}
	}
	@RequestMapping(value = "getHealthIndexMessage",method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("获取超标指标消息--根据患者分组")
	public String getHealthIndexMessage()throws Exception{
		try {
			List<Map<String,Object>> list = messageService.getHealthIndexMessage(getUID());     //"D20161008003"
			return write(200, "获取超标指标消息成功", "data", list);
		} catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
	@RequestMapping(value = "getHealthIndexMessageByPatient",method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("获取患者超标指标消息")
	public String getHealthIndexMessageByPatient(@ApiParam(name="patient",value="患者代码",defaultValue = "P20161008001")
												 @RequestParam(value="patient",required = true) String patient,
												 @ApiParam(name="type",value="健康指标类型1血糖,2血压,3体重",defaultValue = "1")
												 @RequestParam(value="type",required = true) String type,
												 @ApiParam(name="page",value="第几页",defaultValue = "1")
												 @RequestParam(value="page",required = true) Integer page,
												 @ApiParam(name="pagesize",value="每页几行",defaultValue = "10")
												 @RequestParam(value="pagesize",required = true) Integer pagesize)throws Exception{
		try {
			List<Map<String,String>> list = messageService.getHealthIndexMessageByPatient(getUID(),patient,type,page,pagesize);
			return write(200, "获取超标指标消息成功", "data", list);
		} catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
	/**
	 * @param type 消息类型  1.是家庭签约信息  2.体征消息  3分配健管师
	 * @return
	 */
	@RequestMapping(value = "findMessageNum")
	@ResponseBody
	public String findMessageNum(Integer type) {
	@ApiOperation("获取未读消息数(1.2.8版本作废)")
	public String findMessageNum(@ApiParam(value="消息类型",defaultValue = "3")
								 @RequestParam Integer type) {
		try {
			JSONObject obj = messageService.findMessageNum(getUID(), type);
@ -263,21 +256,49 @@ public class DoctorMessageController extends BaseController {
			return error(-1, "获取消息失败!");
		}
	}
	/**
	 * @param id
	 * @return
	 * 体征指标消息查询接口
	 * @param isRead 1未读,0已读
	 */
	@RequestMapping(value = "changeMessageToRead")
	@RequestMapping(value = "health")
	@ResponseBody
	public String changeMessageToRead(Long id) {
	@ApiOperation("体征指标消息查询接口(1.2.8版本作废)")
	public String health(long id, int pagesize, @RequestParam(required = false) String isRead) {
		try {
			 messageService.changeMessageToRead(id);
			return write(200, "修改成功!");
			JSONArray array = new JSONArray();
			Page<Message> list = messageService.findHealthListByDoctor(getUID(), id, pagesize, isRead);
			for (Message msg : list) {
				if (msg == null) {
					continue;
				}
				JSONObject json = new JSONObject();
				// 消息ID
				json.put("id", msg.getId());
				// 发送人标识
				json.put("sender", msg.getSender());
				// 发送人姓名
				json.put("senderName", msg.getSenderName());
				// 发送人头像
				json.put("senderPhoto", msg.getSenderPhoto());
				// 消息类型:1血糖,2血压
				json.put("type", msg.getTzType());
				// 是否已读:1未读,0已读
				json.put("read", msg.getRead());
				// 是否已读:
				json.put("sex", msg.getSex());
				// 当前值/收缩压,正数为高,负数为低
				json.put("value1", msg.getValue1());
				// 上次值/舒张压,正数为高,负数为低
				json.put("value2", msg.getValue2());
				// 发送时间
				json.put("czrq", DateUtil.dateToStrLong(msg.getCzrq()));
				array.put(json);
			}
			return write(200, "获取体征消息成功!", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取消息失败!");
			return error(-1, "获取体征消息失败!");
		}
	}
}

+ 33 - 8
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java

@ -925,8 +925,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                return write(result.getInt("status"), result.getString("msg"));
            } else if (StringUtils.isNotEmpty(isAll) && isAll.equals("1")) {
                patientRemindService.remindPatientExpensesAll(getUID());
                redisTemplate.opsForValue().set("expenses:remind:doctor:" + getUID(), "0");
                redisTemplate.expire("expenses:remind:doctor:" + getUID(), 10, TimeUnit.MINUTES);
                return error(200, "提醒操作成功");
            } else {
                redisTemplate.opsForValue().set("expenses:remind:doctor:" + getUID(), "0");
@ -955,12 +953,12 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                return error(-1, "患者不能为空");
            }
            int result = 0;
            String epTime = redisTemplate.opsForValue().get("expenses:remind:" + patient);
            boolean epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", patient);
            if (StringUtils.isEmpty(epTime)) {
            if (!epTime) {
                result = 0;
            } else {
                result = new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0;
                result = 1;
            }
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
@ -1087,10 +1085,9 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                JSONObject json = patientRemindService.remindPatientFocusWechat(patient, getUID());
                result = json.getInt("status");
                msg = json.getString("msg");
                redisTemplate.opsForValue().set("wechat:focus:remind:doctor:" + getUID(), "0");
                redisTemplate.expire("wechat:focus:remind:doctor:" + getUID(), 10, TimeUnit.MINUTES);
            }
            redisTemplate.opsForValue().set("wechat:focus:remind:doctor:" + getUID(), "0");
            redisTemplate.expire("wechat:focus:remind:doctor:" + getUID(), 10, TimeUnit.MINUTES);
            return write(result, msg);
        } catch (Exception e) {
            redisTemplate.opsForValue().set("wechat:focus:remind:doctor:" + getUID(), "0");
@ -1099,4 +1096,32 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            return error(-1, "微信关注提醒失败");
        }
    }
    /**
     * 是否已提醒关注
     *
     * @param patient
     * @return
     */
    @RequestMapping(value = "/is_patient_remind_focus")
    @ResponseBody
    public String isPatientRemindFocusToday(String patient){
        try {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "患者不能为空");
            }
            int result = 0;
            boolean epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", patient);
            if (!epTime) {
                result = 0;
            } else {
                result = 1;
            }
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
}

+ 41 - 8
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java

@ -5,6 +5,7 @@ import java.util.*;
import com.yihu.wlyy.util.IdCardUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -233,6 +234,7 @@ public class DoctorSignController extends BaseController {
                    json.put("address", temp.get("address"));
                    json.put("photo", temp.get("photo"));
                    json.put("status", temp.get("status"));
                    json.put("openid", temp.get("openid"));
                    String statusName = "";
                    switch (Integer.parseInt(temp.get("status").toString())) {
                        case 0:
@ -256,29 +258,29 @@ public class DoctorSignController extends BaseController {
                    json.put("streetName", temp.get("streetName"));
                    json.put("sex", temp.get("sex"));
                    if (status == 5) {
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("expenses:remind:" + temp.get("patient"));
                            epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", temp.get("patient"));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", df.format(new Date()).equals(epTime) ? 1 : 0);
                            json.put("expensesRemindStatus", 1);
                        }
                    }
                    if (status == 3) {
                        String epTime = "";
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + temp.get("patient"));
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", temp.get("patient"));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                        if (!epTime) {
                            json.put("wechatFocusRemind", 0);
                        } else {
                            json.put("wechatFocusRemind", df.format(new Date()).equals(epTime) ? 1 : 0);
                            json.put("wechatFocusRemind", 1);
                        }
                    }
                    jsonArray.add(json);
@ -312,4 +314,35 @@ public class DoctorSignController extends BaseController {
        }
    }
    /**
     * 查询今天是否全部提醒关注
     *
     * @return
     */
    @RequestMapping(value = "/is_remind_focus_all")
    @ApiOperation(value = "今天是否已全部提醒关注")
    public String isRemindFocusAllToday(){
        try{
            return write(200,"查询成功","data",signWebService.isRemindFocusAll(getUID()));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    /**
     * 查询今天是否全部提醒关注
     *
     * @return
     */
    @RequestMapping(value = "/is_remind_expenses_all")
    @ApiOperation(value = "今天是否已全部提醒缴费")
    public String isRemindFExpensesAllToday(){
        try{
            return write(200,"查询成功","data",signWebService.isRemindExpensesAll(getUID()));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
}

+ 20 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/quota/JobController.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.web.quota;
import com.yihu.wlyy.job.FollowupPlanJob;
import com.yihu.wlyy.job.QuartzHelper;
import com.yihu.wlyy.job.consult.ConsultCleanerJob;
import com.yihu.wlyy.job.consult.FamousConsultTimesJob;
@ -322,4 +323,23 @@ public class JobController extends BaseController {
            return error(-1, e.getMessage());
        }
    }
    /******************************************** 随访计划任务 **********************************************************************/
    @RequestMapping(value = "/followup/planJob", method = RequestMethod.POST)
    @ApiOperation("随访计划消息发送任务")
    public String addFollowPlanJob() {
        try {
            String jobKey = "followup-plan";
            if (!quartzHelper.isExistJob(jobKey)) {
                quartzHelper.addJob(FollowupPlanJob.class, "0 0/5 0 * * ?", jobKey, new HashMap<String, Object>());
                return write(200, "启动成功");
            } else {
                return write(200, "任务已存在");
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "启动失败");
        }
    }
}

+ 2 - 0
patient-co-wlyy/src/main/resources/application.properties

@ -73,6 +73,7 @@ fv.jdbc.password=123456
#### redis
redis.host=172.19.103.47
redis.port=6379
redis.password=
#---------------------------------测试环境数据库配置---------------------------------------#
###### mysql database setting
@ -96,6 +97,7 @@ redis.port=6379
###### redis
#redis.host=172.19.103.88
#redis.port=6379
#redis.password=
#-----------------------------------通用配置--------------------------------------------#
##### redis