瀏覽代碼

消息提醒修改

yeshijie 7 年之前
父節點
當前提交
46b6366a29

+ 10 - 0
patient-co-manage/wlyy-manage/pom.xml

@ -118,6 +118,16 @@
            <version>20160212</version>
        </dependency>
        <!-- JSON end -->
        <!-- redis start  -->
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
        </dependency>
        <!-- redis end  -->
        <!-- SPRINGSIDE -->
        <dependency>
            <groupId>org.springside</groupId>

+ 177 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/MessageNoticeSetting.java

@ -0,0 +1,177 @@
package com.yihu.wlyy.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 消息提醒设置
 * @author yeshijie on 2017/11/27.
 *
 */
@Entity
@Table(name = "wlyy_message_notice_setting")
public class MessageNoticeSetting extends IdEntity{
    private String user;//'用户code'
    private String type;// '类型(1医生,2居民)'
    private Integer masterSwitch;// '总开关' (1开,0关)
    private Integer imSwitch;//'im消息开关'(1开,0关)
    private Integer familyTopicSwitch;// '健管师邀请后推送开关'(1开,0关)
    private Integer signSwitch;// '签约消息开关'(1开,0关)
    private Integer healthSignSwitch;// '体征消息开关'(1开,0关)
    private Integer systemSwitch;// '系统消息开关'(1开,0关)
    private Integer prescriptionSwitch;// '续方消息开关'(1开,0关)
    private Integer soundSwitch;// '铃声提醒开关'(1开,0关)
    private Integer vibrationSwitch;// '振动提醒开关'(1开,0关)
    private Integer coordinationSwitch;// '协同消息开关'(1开,0关)
    private Date createTime;// '创建时间'
    //状态枚举
    public enum MessageTypeEnum {
        masterSwitch("总开关","masterSwitch"),
        imSwitch("im消息开关","imSwitch"),
        familyTopicSwitch("健管师邀请后推送开关","familyTopicSwitch"),
        signSwitch("签约消息开关","signSwitch"),
        healthSignSwitch("体征消息开关","healthSignSwitch"),
        systemSwitch("系统消息开关","systemSwitch"),
        prescriptionSwitch("续方消息开关","prescriptionSwitch"),
        soundSwitch("铃声提醒开关","soundSwitch"),
        vibrationSwitch("振动提醒开关","vibrationSwitch"),
        coordinationSwitch("协同消息开关","coordinationSwitch");
        private String name;
        private String value;
        MessageTypeEnum(String name, String value) {
            this.name = name;
            this.value = value;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public String getValue() {
            return value;
        }
        public void setValue(String value) {
            this.value = value;
        }
    }
    public String getUser() {
        return user;
    }
    public void setUser(String user) {
        this.user = user;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public Integer getMasterSwitch() {
        return masterSwitch;
    }
    public void setMasterSwitch(Integer masterSwitch) {
        this.masterSwitch = masterSwitch;
    }
    public Integer getImSwitch() {
        return imSwitch;
    }
    public void setImSwitch(Integer imSwitch) {
        this.imSwitch = imSwitch;
    }
    public Integer getFamilyTopicSwitch() {
        return familyTopicSwitch;
    }
    public void setFamilyTopicSwitch(Integer familyTopicSwitch) {
        this.familyTopicSwitch = familyTopicSwitch;
    }
    public Integer getSignSwitch() {
        return signSwitch;
    }
    public void setSignSwitch(Integer signSwitch) {
        this.signSwitch = signSwitch;
    }
    public Integer getHealthSignSwitch() {
        return healthSignSwitch;
    }
    public void setHealthSignSwitch(Integer healthSignSwitch) {
        this.healthSignSwitch = healthSignSwitch;
    }
    public Integer getSystemSwitch() {
        return systemSwitch;
    }
    public void setSystemSwitch(Integer systemSwitch) {
        this.systemSwitch = systemSwitch;
    }
    public Integer getPrescriptionSwitch() {
        return prescriptionSwitch;
    }
    public void setPrescriptionSwitch(Integer prescriptionSwitch) {
        this.prescriptionSwitch = prescriptionSwitch;
    }
    public Integer getSoundSwitch() {
        return soundSwitch;
    }
    public void setSoundSwitch(Integer soundSwitch) {
        this.soundSwitch = soundSwitch;
    }
    public Integer getVibrationSwitch() {
        return vibrationSwitch;
    }
    public void setVibrationSwitch(Integer vibrationSwitch) {
        this.vibrationSwitch = vibrationSwitch;
    }
    public Integer getCoordinationSwitch() {
        return coordinationSwitch;
    }
    public void setCoordinationSwitch(Integer coordinationSwitch) {
        this.coordinationSwitch = coordinationSwitch;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name="create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 18 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/MessageNoticeSettingDao.java

@ -0,0 +1,18 @@
package com.yihu.wlyy.repository;
import com.yihu.wlyy.entity.MessageNoticeSetting;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2017/11/27.
 */
public interface MessageNoticeSettingDao extends PagingAndSortingRepository<MessageNoticeSetting, Long>, JpaSpecificationExecutor<MessageNoticeSetting> {
    @Query("from MessageNoticeSetting a where a.user = ?1 and a.type=?2")
    MessageNoticeSetting findByUserAndType(String user, String type);
    @Query("from MessageNoticeSetting a where a.id = ?1")
    MessageNoticeSetting findById(Long id);
}

+ 8 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/consult/WlyyConsultRemindLogService.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.service.manager.consult;
import com.yihu.wlyy.entity.Doctor;
import com.yihu.wlyy.entity.Message;
import com.yihu.wlyy.entity.MessageNoticeSetting;
import com.yihu.wlyy.entity.WlyyAdminTeamMember;
import com.yihu.wlyy.entity.consult.WlyyConsultRemindLog;
import com.yihu.wlyy.entity.consult.WlyyReplyConsult;
@ -9,6 +10,7 @@ import com.yihu.wlyy.repository.DoctorDao;
import com.yihu.wlyy.repository.MessageDao;
import com.yihu.wlyy.repository.consult.WlyyConsultRemindLogDao;
import com.yihu.wlyy.service.SMSService;
import com.yihu.wlyy.service.manager.message.MessageService;
import com.yihu.wlyy.service.manager.team.WlyyAdminTeamMemberService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.MessageType;
@ -49,6 +51,8 @@ public class WlyyConsultRemindLogService extends BaseJpaService<WlyyConsultRemin
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private MessageDao messageDao;
    @Autowired
    private MessageService messageService;
     public PageImpl<WlyyConsultRemindLog> list(String city, String town, String hospital, String teamCode, String doctorName,String doctor, Date beginDate, Date endDate,String remindType, int page, int pageSize){
@ -212,8 +216,10 @@ public class WlyyConsultRemindLogService extends BaseJpaService<WlyyConsultRemin
                }
            }
            messageDao.save(message);
            // 发送消息给医生
            PushMsgTask.getInstance().put(doctor, MessageType.MESSAGE_TYPE_CONSULT_REPLY.D_CR_01.name(),MessageType.MESSAGE_TYPE_CONSULT_REPLY.咨询未回复.name(), systemContent, "admin");
            if(messageService.getMessageNoticeSettingByMessageType(doctor,"1", MessageNoticeSetting.MessageTypeEnum.imSwitch.getValue())){
                // 发送消息给医生
                PushMsgTask.getInstance().put(doctor, MessageType.MESSAGE_TYPE_CONSULT_REPLY.D_CR_01.name(),MessageType.MESSAGE_TYPE_CONSULT_REPLY.咨询未回复.name(), systemContent, "admin");
            }
        }
    }

+ 16 - 10
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/feedback/FeedbackService.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.service.manager.feedback;
import com.yihu.wlyy.entity.Doctor;
import com.yihu.wlyy.entity.Message;
import com.yihu.wlyy.entity.MessageNoticeSetting;
import com.yihu.wlyy.entity.Patient;
import com.yihu.wlyy.entity.feedback.Feedback;
import com.yihu.wlyy.repository.DoctorDao;
@ -9,6 +10,7 @@ import com.yihu.wlyy.repository.MessageDao;
import com.yihu.wlyy.repository.PatientDao;
import com.yihu.wlyy.repository.feedback.FeedbackDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.manager.message.MessageService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
@ -46,6 +48,8 @@ public class FeedbackService extends BaseService {
    private String imgUrlDomain;
    @Autowired
    private MessageDao messageDao;
    @Autowired
    private MessageService messageService;
    /**
     * 分页查找问题
@ -250,17 +254,19 @@ public class FeedbackService extends BaseService {
                message.setReadonly(1);//是否只读消息
                message.setRelationCode(feedback.getCode());
                //wlyy给医生发送系统消息
                Doctor doctor = doctorDao.findByCode(creater);
                String doctorOpenID = doctor.getOpenid();
                String url = wlyyService + "/third/template/sendMessage";
                List<NameValuePair> params = new ArrayList<>();
                params.add(new BasicNameValuePair("receiver", creater));
                params.add(new BasicNameValuePair("title", title));
                params.add(new BasicNameValuePair("type", "10"));
                params.add(new BasicNameValuePair("content",content));
                if(messageService.getMessageNoticeSettingByMessageType(creater,"1", MessageNoticeSetting.MessageTypeEnum.systemSwitch.getValue())){
                    //wlyy给医生发送系统消息
                    Doctor doctor = doctorDao.findByCode(creater);
                    String doctorOpenID = doctor.getOpenid();
                    String url = wlyyService + "/third/template/sendMessage";
                    List<NameValuePair> params = new ArrayList<>();
                    params.add(new BasicNameValuePair("receiver", creater));
                    params.add(new BasicNameValuePair("title", title));
                    params.add(new BasicNameValuePair("type", "10"));
                    params.add(new BasicNameValuePair("content",content));
                HttpClientUtil.post(url, params, "UTF-8");
                    HttpClientUtil.post(url, params, "UTF-8");
                }
                messageDao.save(message);
            }
        }catch (Exception e){

+ 133 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/message/MessageService.java

@ -0,0 +1,133 @@
package com.yihu.wlyy.service.manager.message;
import com.yihu.wlyy.entity.MessageNoticeSetting;
import com.yihu.wlyy.repository.MessageNoticeSettingDao;
import com.yihu.wlyy.service.BaseService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import javax.transaction.Transactional;
import java.util.Date;
/**
 * 消息业务处理类
 *
 * @author George
 */
@Component
@Transactional(rollbackOn = Exception.class)
public class MessageService extends BaseService {
    @Autowired
    private MessageNoticeSettingDao messageNoticeSettingDao;
    @Autowired
    private StringRedisTemplate redisTemplate;
    private final String MESSAGE_NOTICESETTING = "wlyy:message:setting:";
    /**
     * 获取消息提醒设置
     * @param user
     * @param type
     * @return
     */
    public com.alibaba.fastjson.JSONObject getMessageNoticSetting(String user, String type){
        com.alibaba.fastjson.JSONObject re = null;
        String key = MESSAGE_NOTICESETTING+user+":"+type;
        String response = redisTemplate.opsForValue().get(key);
        if(StringUtils.isBlank(response)){
            MessageNoticeSetting messageNoticeSetting = messageNoticeSettingDao.findByUserAndType(user,type);
            if(messageNoticeSetting == null){
                messageNoticeSetting = new MessageNoticeSetting();
                messageNoticeSetting.setCreateTime(new Date());
                messageNoticeSetting.setFamilyTopicSwitch(1);
                messageNoticeSetting.setCoordinationSwitch(1);
                messageNoticeSetting.setHealthSignSwitch(1);
                messageNoticeSetting.setImSwitch(1);
                messageNoticeSetting.setMasterSwitch(1);
                messageNoticeSetting.setPrescriptionSwitch(1);
                messageNoticeSetting.setSignSwitch(1);
                messageNoticeSetting.setSoundSwitch(1);
                messageNoticeSetting.setSystemSwitch(1);
                messageNoticeSetting.setType(type);
                messageNoticeSetting.setUser(user);
                messageNoticeSetting.setVibrationSwitch(1);
                messageNoticeSettingDao.save(messageNoticeSetting);
            }
            response = com.alibaba.fastjson.JSONObject.toJSONString(messageNoticeSetting);
            redisTemplate.opsForValue().set(key,response);
        }
        re = com.alibaba.fastjson.JSONObject.parseObject(response);
        return re;
    }
    /**
     * 获取消息提示开关
     * @param user
     * @param type
     * @param messageType
     * @return (1开,0关)
     */
    public Boolean getMessageNoticeSettingByMessageType(String user,String type,String messageType){
        Integer re = 0;
        com.alibaba.fastjson.JSONObject setting = getMessageNoticSetting(user,type);
        Integer masterSwitch = setting.getInteger("masterSwitch");
        if(masterSwitch==0){
            return false;
        }
        switch (messageType){
            case "masterSwitch":
                //总开关
                re = masterSwitch;
                break;
            case "imSwitch":
                //im消息开关
                re = setting.getInteger("imSwitch");
                break;
            case "familyTopicSwitch":
                //健管师邀请后推送开关
                Integer imSwitch = setting.getInteger("imSwitch");
                if(imSwitch==1){
                    re = setting.getInteger("familyTopicSwitch");
                }
                break;
            case "signSwitch":
                //签约消息开关
                re = setting.getInteger("signSwitch");
                break;
            case "healthSignSwitch":
                //体征消息开关
                re = setting.getInteger("healthSignSwitch");
                break;
            case "systemSwitch":
                //系统消息开关
                re = setting.getInteger("systemSwitch");
                break;
            case "prescriptionSwitch":
                //续方消息开关
                re = setting.getInteger("prescriptionSwitch");
                break;
            case "soundSwitch":
                //铃声提醒开关
                re = setting.getInteger("soundSwitch");
                break;
            case "vibrationSwitch":
                //振动提醒开关
                re = setting.getInteger("vibrationSwitch");
                break;
            case "coordinationSwitch":
                //协同消息开关
                re = setting.getInteger("coordinationSwitch");
                break;
            default:
                break;
        }
        return re==1;
    }
}

+ 23 - 2
patient-co-manage/wlyy-manage/src/main/resources/application.yml

@ -45,7 +45,16 @@ spring:
    database-platform: org.hibernate.dialect.MySQL5Dialect
    hibernate.dialect: org.hibernate.dialect.MySQL5Dialect
    show-sql: true
    # REDIS
  redis:
    database: 0 # Database index used by the connection factory.
    password: # Login password of the redis server.
    timeout: 120000 # 连接超时时间(毫秒) 60秒
    pool:
      max-active: 20 # 连接池最大连接数(使用负值表示没有限制)
      max-wait: -1  # 连接池最大阻塞等待时间(使用负值表示没有限制)
      max-idle: 20  # 连接池中的最大空闲连接
      min-idle: 5  # 连接池中的最小空闲连接
---
spring:
  profiles: dev
@ -67,6 +76,11 @@ spring:
    yihu_sms_code: 229336
    yihu_sms_name: jkzldxjr
    yihu_sms_password: jkzldxjrpwd123
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
service-gateway:
  update-team-url: http://172.19.103.87:8011/wlyy_service/third/doctor/LoadTeamInfo
im-service:
@ -100,7 +114,10 @@ spring:
    yihu_sms_code: 229336
    yihu_sms_name: jkzldxjr
    yihu_sms_password: jkzldxjrpwd123
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
service-gateway:
  update-team-url: http://172.19.103.87:8011/wlyy_service/third/doctor/LoadTeamInfo
@ -135,6 +152,10 @@ spring:
    yihu_sms_code: 229336
    yihu_sms_name: jkzldxjr
    yihu_sms_password: jkzldxjrpwd123
  redis:
    host: 27.155.101.77 # Redis server host.
    port: 6380 # Redis server port.
    password: jkzl_ehr
service-gateway:
  update-team-url: http://59.61.92.90:8072/wlyy_service/third/doctor/LoadTeamInfo
im-service: