Jelajahi Sumber

Merge branch 'srdev' of yeshijie/patient-co-management into srdev

yeshijie 7 tahun lalu
induk
melakukan
fb984265e8

File diff ditekan karena terlalu besar
+ 2 - 2
common/common-entity/src/main/java/com/yihu/wlyy/entity/message/Message.java


+ 6 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java

@ -23,6 +23,12 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    @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 count(1) from Message a where a.type =14 and a.read= 1 and a.receiver=?1 ")
    Integer amountUnreadConcernByReceiver(String doctor);
    @Query("select a from Message a where a.type = 14 and a.read= 1 and a.receiver=?1 order by a.createTime desc")
    Page<Message> amountUnreadConcernLastByReceiver(String doctor, Pageable pageRequest);
    @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);

+ 3 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/concern/ConcernService.java

@ -117,6 +117,7 @@ public class ConcernService extends BaseService {
        message.setTitle("居民"+patient.getName()+"关注了您");
        message.setContent(content);
        message.setType(14);
        message.setSignStatus("1");
        message.setReadonly(1);//是否只读消息
        message.setDel("1");
        message.setRelationCode(patient.getCode());
@ -180,7 +181,8 @@ public class ConcernService extends BaseService {
        message.setSenderName("系统");
        message.setTitle("居民"+concern.getName()+"取消关注您");
        message.setContent(content);
        message.setType(15);
        message.setType(14);
        message.setSignStatus("-1");
        message.setReadonly(1);//是否只读消息
        message.setDel("1");
        message.setRelationCode(concern.getPatient());

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

@ -101,49 +101,43 @@ public class MessageService extends BaseService {
     * 查询医生未读消息和最后消息
     */
    public JSONObject findDoctorAllMessage(String doctor) throws Exception {
        // 签约未读消息总数
        int sign = messageDao.amountUnreadByReceiver(doctor);
        JSONObject signJson = new JSONObject();
        signJson.put("amount", sign);
        if (sign > 0) {
        // 关注未读消息总数
        int concern = messageDao.amountUnreadConcernByReceiver(doctor);
        JSONObject concernJson = new JSONObject();
        concernJson.put("amount", concern);
        if (concern > 0) {
            PageRequest pageRequest = new PageRequest(0, 1);
            Page<Message> msgs = messageDao.amountUnreadLastByReceiver(doctor, pageRequest);
            Page<Message> msgs = messageDao.amountUnreadConcernLastByReceiver(doctor, pageRequest);
            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 if(msg.getSignStatus().equals("8")){
                        msgJson.put("msg", msg.getSenderName() + "申请与您续签家庭医生");
                    }else{
                        msgJson.put("msg", msg.getSenderName() + "申请与您签约家庭医生");
                    }
                    msgJson.put("msgTime", DateUtil.dateToStrLong(msg.getCzrq()));
                    signJson.put("lastMessage", msgJson);
                    msgJson.put("msg",msg.getContent());
                    msgJson.put("msgTime", DateUtil.dateToStrLong(msg.getCreateTime()));
                    concernJson.put("lastMessage", msgJson);
                }
            }
        }
        // 体征指标未读消息总数
        Integer healthIndex = messageDao.amountUnreadHealthByReceiver(doctor);
        JSONObject indexJson = new JSONObject();
        indexJson.put("amount", healthIndex);
        if (healthIndex > 0) {
            PageRequest pageRequest = new PageRequest(0, 1);
            List<Message> msgs = messageDao.amountUnreadHealthLastByReceiver(doctor, pageRequest);
            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);
            }
        }
//        Integer healthIndex = messageDao.amountUnreadHealthByReceiver(doctor);
//        JSONObject indexJson = new JSONObject();
//        indexJson.put("amount", healthIndex);
//        if (healthIndex > 0) {
//            PageRequest pageRequest = new PageRequest(0, 1);
//            List<Message> msgs = messageDao.amountUnreadHealthLastByReceiver(doctor, pageRequest);
//
//            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);
//            }
//        }
        //获取未读系统消息
        List<Message> systemMessage = messageDao.getSystemMessageUnread(doctor);
@ -161,42 +155,27 @@ public class MessageService extends BaseService {
        }
        //获取续方消息
        List<Message> prescriptionMessage = messageDao.getSysTemMessageByPrescription(doctor,"0");
        JSONObject prescriptionJson = new JSONObject();
        if (prescriptionMessage != null && prescriptionMessage.size() > 0) {
            prescriptionJson.put("amount", prescriptionMessage.size());
            JSONObject msgJson = new JSONObject();
            msgJson.put("title", prescriptionMessage.get(0).getTitle());
            msgJson.put("type", prescriptionMessage.get(0).getType());
            msgJson.put("msg", prescriptionMessage.get(0).getContent());
            msgJson.put("msgTime", DateUtil.dateToStrLong(prescriptionMessage.get(0).getCreateTime()));
            prescriptionJson.put("lastMessage", msgJson);
        } else {
            prescriptionJson.put("amount", 0);
        }
//        List<Message> prescriptionMessage = messageDao.getSysTemMessageByPrescription(doctor,"0");
//        JSONObject prescriptionJson = new JSONObject();
//        if (prescriptionMessage != null && prescriptionMessage.size() > 0) {
//            prescriptionJson.put("amount", prescriptionMessage.size());
//            JSONObject msgJson = new JSONObject();
//            msgJson.put("title", prescriptionMessage.get(0).getTitle());
//            msgJson.put("type", prescriptionMessage.get(0).getType());
//            msgJson.put("msg", prescriptionMessage.get(0).getContent());
//            msgJson.put("msgTime", DateUtil.dateToStrLong(prescriptionMessage.get(0).getCreateTime()));
//            prescriptionJson.put("lastMessage", msgJson);
//        } else {
//            prescriptionJson.put("amount", 0);
//        }
        //协同服务
        List<Message> callServiceMes =  messageDao.findByReceiverCallService(doctor);
        JSONObject callServiceMesJson = new JSONObject();
        if (callServiceMes != null && callServiceMes.size() > 0) {
            callServiceMesJson.put("amount", callServiceMes.size());
            JSONObject callJson = new JSONObject();
            callJson.put("title", callServiceMes.get(0).getTitle());
            callJson.put("type", callServiceMes.get(0).getType());
            callJson.put("msg", callServiceMes.get(0).getContent());
            callJson.put("msgTime", DateUtil.dateToStrLong(callServiceMes.get(0).getCreateTime()));
            callServiceMesJson.put("lastMessage", callJson);
        } else {
            callServiceMesJson.put("amount", 0);
        }
        JSONObject json = new JSONObject();
        json.put("imMsgCount", getImMsgAmount(doctor));//IM消息数量
        json.put("sign", signJson);//签约数
        json.put("healthIndex", indexJson);//健康指标
        json.put("concern", concernJson);//关注数
//        json.put("healthIndex", indexJson);//健康指标
        json.put("system", systemJson);//系统消息
        json.put("prescription", prescriptionJson);//续方消息
        json.put("callService", callServiceMesJson);//协同服务消息
//        json.put("prescription", prescriptionJson);//续方消息
        return json;
    }