Browse Source

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

trick9191 7 years ago
parent
commit
b11882cd74
51 changed files with 2520 additions and 1508 deletions
  1. 62 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/charge/PatientPopups.java
  2. 39 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/message/MessageNoticeSetting.java
  3. 10 0
      patient-co-manage/wlyy-manage/pom.xml
  4. 177 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/MessageNoticeSetting.java
  5. 18 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/MessageNoticeSettingDao.java
  6. 8 2
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/consult/WlyyConsultRemindLogService.java
  7. 16 10
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/feedback/FeedbackService.java
  8. 133 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/message/MessageService.java
  9. 23 2
      patient-co-manage/wlyy-manage/src/main/resources/application.yml
  10. 15 0
      patient-co-service/wlyy_device/pom.xml
  11. 18 0
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/common/dao/MessageNoticeSettingDao.java
  12. 1 1
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/model/ConsultTeam.java
  13. 177 0
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/model/MessageNoticeSetting.java
  14. 12 8
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java
  15. 131 0
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/MessageService.java
  16. 24 1
      patient-co-service/wlyy_device/src/main/resources/application.yml
  17. 4 64
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  18. 4 1
      patient-co/patient-co-statistics/pom.xml
  19. 18 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/MessageNoticeSettingDao.java
  20. 39 32
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/message/FollowupPlanJob.java
  21. 33 28
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/message/HealthMessageJob.java
  22. 178 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/signfamily/MessageNoticeSetting.java
  23. 130 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/service/MessageService.java
  24. 34 27
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/HealthMessageJob.java
  25. 18 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/message/MessageNoticeSettingDao.java
  26. 37 34
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java
  27. 14 144
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java
  28. 110 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  29. 1 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/physicalExamination/PatientPhysicalExaminationService.java
  30. 6 51
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java
  31. 0 694
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  32. 19 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/charge/PopupsDao.java
  33. 4 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java
  34. 32 28
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java
  35. 47 39
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java
  36. 65 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  37. 6 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/physicalExamination/PhysicalExaminationRemindService.java
  38. 94 18
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java
  39. 26 20
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  40. 7 76
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java
  41. 102 90
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  42. 10 13
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/PatientRemindService.java
  43. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  44. 328 45
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  45. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java
  46. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/service/OnePayService.java
  47. 6 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java
  48. 26 18
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionAdjustController.java
  49. 55 39
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java
  50. 88 11
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionPayController.java
  51. 112 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

+ 62 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/charge/PatientPopups.java

@ -0,0 +1,62 @@
package com.yihu.wlyy.entity.charge;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 居民支付弹窗设置
 * @author Reece 2017.11.29
 */
@Entity
@Table(name = "wlyy_patient_popups")
public class PatientPopups extends IdEntity {
    private String patient; //支付主体居民code
    private int type;  //弹窗类型(0签约支付 1续方支付)
    private String status;  //弹出状态(0不弹出 1弹出)
    private Date createTime;
    private Date czrq;
    public String getPatient() {
        return patient;
    }
    public int getType() {
        return type;
    }
    public void setType(int type) {
        this.type = type;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
}

+ 39 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/message/MessageNoticeSetting.java

@ -31,6 +31,45 @@ public class MessageNoticeSetting extends IdEntity{
    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;
    }

+ 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:

+ 15 - 0
patient-co-service/wlyy_device/pom.xml

@ -78,11 +78,26 @@
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-redis</artifactId>
            <version>1.7.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>2.8.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>

+ 18 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/common/dao/MessageNoticeSettingDao.java

@ -0,0 +1,18 @@
package com.yihu.hos.device.common.dao;
import com.yihu.hos.device.model.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);
}

+ 1 - 1
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/model/ConsultTeam.java

@ -13,7 +13,7 @@ import java.util.Date;
 * @author George
 */
@Entity
@Table(name = "wlyy_consult_team")
@Table(name = "wlyy_consult_team",schema="wlyy",catalog="wlyy")
public class ConsultTeam extends IdEntity {
	private static final long serialVersionUID = -7644448339473861513L;

+ 177 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/model/MessageNoticeSetting.java

@ -0,0 +1,177 @@
package com.yihu.hos.device.model;
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",schema="wlyy",catalog="wlyy")
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;
    }
}

+ 12 - 8
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java

@ -66,6 +66,8 @@ public class DeviceService {
    private ConsultTeamDao consultTeamDao;
    @Autowired
    private ImUtill ImUtill;
    @Autowired
    private MessageService messageService;
    private ObjectMapper objectMapper = new ObjectMapper();
    private Integer aStart;
@ -798,14 +800,16 @@ public class DeviceService {
            message.setTzType(String.valueOf(model.getType()));//体征类别 (1血糖,2血压,3体重,4腰围)
            messages.add(message);
            // 异常通知
            JSONObject json = new JSONObject();
            json.put("receiver", receiver);
            json.put("type", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.D_HI_01.name());
            json.put("title", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.体征指标.name());
            json.put("msg", content);
            json.put("data", "");
            array.add(json);
            if(messageService.getMessageNoticeSettingByMessageType(receiver,"1",MessageNoticeSetting.MessageTypeEnum.healthSignSwitch.getValue())){
                // 异常通知
                JSONObject json = new JSONObject();
                json.put("receiver", receiver);
                json.put("type", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.D_HI_01.name());
                json.put("title", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.体征指标.name());
                json.put("msg", content);
                json.put("data", "");
                array.add(json);
            }
        }
        // 批量保存消息
        messageDao.save(messages);

+ 131 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/MessageService.java

@ -0,0 +1,131 @@
package com.yihu.hos.device.service;
import com.yihu.hos.device.common.dao.MessageNoticeSettingDao;
import com.yihu.hos.device.model.MessageNoticeSetting;
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 {
    @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;
    }
}

+ 24 - 1
patient-co-service/wlyy_device/src/main/resources/application.yml

@ -12,7 +12,16 @@ spring:
      properties:
        hibernate:
          dialect: org.hibernate.dialect.MySQL5Dialect
    # 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
@ -23,6 +32,11 @@ spring:
    driverClassName: com.mysql.jdbc.Driver
    maxTotal: 500
    maxIdle: 30
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
#    血糖值默认时间段存到数据库 wlyy_patient_blood_sugger表
#bloodSugger:
#  fasting: 00:00-07:59
@ -57,6 +71,11 @@ spring:
    driverClassName: com.mysql.jdbc.Driver
    maxTotal: 500
    maxIdle: 30
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
bloodSugger:
  fasting: 00:00-07:59
  afterBreakfast: 08:00-09:59
@ -88,6 +107,10 @@ spring:
    driverClassName: com.mysql.jdbc.Driver
    maxTotal: 500
    maxIdle: 30
  redis:
     host: 27.155.101.77 # Redis server host.
     port: 6380 # Redis server port.
     password: jkzl_ehr
bloodSugger:
  fasting: 00:00-07:59
  afterBreakfast: 08:00-09:59

+ 4 - 64
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -1,19 +1,13 @@
package com.yihu.wlyy.service.app.sign;
import com.yihu.wlyy.entity.consult.Consult;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.doctor.OperatorLog;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.profile.DoctorService;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroupInfo;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.*;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.consult.ConsultDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.dict.SystemDictDao;
@ -27,13 +21,13 @@ import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.third.fzzb.HealthEducationArticleService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.task.SignUploadTask;
import com.yihu.wlyy.util.*;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.util.ImUtill;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
@ -53,7 +47,6 @@ import org.springside.modules.persistence.DynamicSpecifications;
import org.springside.modules.persistence.SearchFilter;
import org.springside.modules.persistence.SearchFilter.Operator;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -480,59 +473,6 @@ public class FamilyContractService extends BaseService {
        return 200;
    }
    /**
     * 申请解约
     *
     * @param patient 患者标识
     * @param doctor  医生标识
     * @param openid  微信openid
     * @param reason  解约理由
     * @return
     */
    public int surrender(String patient, String patientName, String userPhoto, String doctor, String doctorName, String openid, String reason, int sex) throws Exception {
        // 更新为待解约
        int res = signFamilyDao.surrender(patient, doctor);
        SignFamily signFamily = signFamilyDao.findByjiatingPatient(patient);
        signFamily.setPatientApplyUnsignDate(new Date());
        if (res == 0) {
            return 0;
        }
        // 添加签约消息
        Message message = new Message();
        // 消息时间
        message.setCzrq(new Date());
        message.setCreateTime(new Date());
        // 消息内容
        message.setContent("申请解除与您的签约关系");
        // 未读
        message.setRead(1);
        message.setReceiverName(doctorName);
        // 接收人
        message.setReceiver(doctor);
        message.setCode(getCode());
        // 发送人
        message.setSender(patient);
        message.setSenderName(patientName);
        message.setSenderPhoto(userPhoto);
        // 标题
        message.setTitle("解除家庭签约申请");
        message.setType(1);
        message.setSignStatus("4");
        message.setReadonly(1);
        message.setSex(sex);
        message.setOver("1");
        // 设置解约理由
        message.setReason(reason);
        message.setData(signFamily.getCode());
        messageDao.save(message);
        // 发送消息给医生
        JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
        if (jsonObject.getString("status").equals("1")) {
            //如果在工作时间内就推送
            pushMsgTask.put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_SIGN_WEB_RELIEVE.D_SW_02.name(), MessageType.MESSAGE_TYPE_DOCTOR_SIGN_WEB_RELIEVE.家庭签约.name(), patientName + " 申请解除与您的家庭签约!", patient);
        }
        return 1;
    }
    /**
     * 查询患者的签约消息

+ 4 - 1
patient-co/patient-co-statistics/pom.xml

@ -129,7 +129,10 @@
            <artifactId>commons-compress</artifactId>
            <version>${version.commons-compress}</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>
        <!--Hibernate framework-->
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>

+ 18 - 0
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/MessageNoticeSettingDao.java

@ -0,0 +1,18 @@
package com.yihu.wlyy.statistics.dao;
import com.yihu.wlyy.statistics.model.signfamily.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);
}

+ 39 - 32
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/message/FollowupPlanJob.java

@ -4,6 +4,8 @@ import com.yihu.wlyy.statistics.dao.DoctorDao;
import com.yihu.wlyy.statistics.dao.MessageDao;
import com.yihu.wlyy.statistics.model.doctor.Doctor;
import com.yihu.wlyy.statistics.model.signfamily.Message;
import com.yihu.wlyy.statistics.model.signfamily.MessageNoticeSetting;
import com.yihu.wlyy.statistics.service.MessageService;
import com.yihu.wlyy.statistics.task.PushMsgTask;
import com.yihu.wlyy.statistics.util.DateUtil;
import com.yihu.wlyy.statistics.util.HttpClientUtil;
@ -36,7 +38,8 @@ public class FollowupPlanJob implements Job {
    @Value("${systemConfig.msg_push_server}")
    private String url;
    @Autowired
    private MessageService messageService;
    @Autowired
    private MessageDao messageDao;
    @Value("${doctorAssistant.api}")
@ -97,40 +100,44 @@ public class FollowupPlanJob implements Job {
                    list.add(message);
                    // 推送消息给医生
                    PushMsgTask.url= url;
                    // 推送消息给医生
                    PushMsgTask.getInstance().put(doctor,"4",title,content,"");
                    try {
                        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        String hql = "SELECT a.patient_name patientName,a.patient_code patientCode,count(1) amount FROM wlyy_followup a WHERE a.doctor_code = ? " +
                                " AND a.followup_plan_date BETWEEN ? AND ? AND a. STATUS NOT IN ('0', '1') GROUP BY a.patient_code;";
                        //获取所有未执行随访计划
                        List<Map<String, Object>> followups = jdbcTemplate.queryForList(hql,doctor,format.parse(start),format.parse(end));
                        for (Map<String,Object> followup:followups) {
                            //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                            String patientName = String.valueOf(followup.get("patientName"));
                            String patientCount = String.valueOf(followup.get("amount"));
                            Doctor doctor1 = doctorDao.findByCode(doctor);
                            String doctorOpenID = doctor1.getOpenid();
                            if (StringUtils.isNotEmpty(doctorOpenID)) {
                                String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                                List<NameValuePair> params = new ArrayList<>();
                                params.add(new BasicNameValuePair("type", "6"));
                                params.add(new BasicNameValuePair("openId", doctorOpenID));
                                params.add(new BasicNameValuePair("url", targetUrl));
                                params.add(new BasicNameValuePair("first", "您今日有"+patientCount+"个随访计划待处理"));
                                params.add(new BasicNameValuePair("remark", ""));
                                SimpleDateFormat formatDate = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                                String newDate = formatDate.format(new Date());
                                String keywords = patientName+ "," + newDate + "," + "请进入手机APP查看";
                                params.add(new BasicNameValuePair("keywords", keywords));
                                HttpClientUtil.post(url, params, "UTF-8");
                    if(messageService.getMessageNoticeSettingByMessageType(doctor,"1", MessageNoticeSetting.MessageTypeEnum.systemSwitch.getValue())){
                        // 推送消息给医生
                        PushMsgTask.getInstance().put(doctor,"4",title,content,"");
                        try {
                            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                            String hql = "SELECT a.patient_name patientName,a.patient_code patientCode,count(1) amount FROM wlyy_followup a WHERE a.doctor_code = ? " +
                                    " AND a.followup_plan_date BETWEEN ? AND ? AND a. STATUS NOT IN ('0', '1') GROUP BY a.patient_code;";
                            //获取所有未执行随访计划
                            List<Map<String, Object>> followups = jdbcTemplate.queryForList(hql,doctor,format.parse(start),format.parse(end));
                            for (Map<String,Object> followup:followups) {
                                //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                                String patientName = String.valueOf(followup.get("patientName"));
                                String patientCount = String.valueOf(followup.get("amount"));
                                Doctor doctor1 = doctorDao.findByCode(doctor);
                                String doctorOpenID = doctor1.getOpenid();
                                if (StringUtils.isNotEmpty(doctorOpenID)) {
                                    String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                                    List<NameValuePair> params = new ArrayList<>();
                                    params.add(new BasicNameValuePair("type", "6"));
                                    params.add(new BasicNameValuePair("openId", doctorOpenID));
                                    params.add(new BasicNameValuePair("url", targetUrl));
                                    params.add(new BasicNameValuePair("first", "您今日有"+patientCount+"个随访计划待处理"));
                                    params.add(new BasicNameValuePair("remark", ""));
                                    SimpleDateFormat formatDate = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                                    String newDate = formatDate.format(new Date());
                                    String keywords = patientName+ "," + newDate + "," + "请进入手机APP查看";
                                    params.add(new BasicNameValuePair("keywords", keywords));
                                    HttpClientUtil.post(url, params, "UTF-8");
                                }
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                messageDao.save(list);

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

@ -7,7 +7,9 @@ import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.model.doctor.Doctor;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
import com.yihu.wlyy.statistics.model.signfamily.Message;
import com.yihu.wlyy.statistics.model.signfamily.MessageNoticeSetting;
import com.yihu.wlyy.statistics.model.signfamily.SignFamily;
import com.yihu.wlyy.statistics.service.MessageService;
import com.yihu.wlyy.statistics.task.PushMsgTask;
import com.yihu.wlyy.statistics.util.HttpClientUtil;
import net.sf.json.JSONArray;
@ -54,6 +56,8 @@ public class HealthMessageJob implements Job {
    private String targetUrl;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private MessageService messageService;
    @Transactional
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
@ -123,37 +127,38 @@ public class HealthMessageJob implements Job {
                message.setReceiver(teamLeader);
                messageDao.save(message);
                try {
                    //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                    Doctor doctor = doctorDao.findByCode(teamLeader);
                    String doctorOpenID = doctor.getOpenid();
                    if (!StringUtils.isEmpty(doctorOpenID)) {
                        String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                        List<NameValuePair> sendParams = new ArrayList<>();
                        sendParams.add(new BasicNameValuePair("type", "9"));
                        sendParams.add(new BasicNameValuePair("openId", doctorOpenID));
                        sendParams.add(new BasicNameValuePair("url", targetUrl));
                        sendParams.add(new BasicNameValuePair("first", doctor.getName()+"医生您好。" + content));
                        sendParams.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                        SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                        String keywords = "分配健管师" + "," +doctor.getHosptialName()+","+ doctor.getName()  ;
                        sendParams.add(new BasicNameValuePair("keywords", keywords));
                if(messageService.getMessageNoticeSettingByMessageType(teamLeader,"1", MessageNoticeSetting.MessageTypeEnum.systemSwitch.getValue())){
                    try {
                        //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                        Doctor doctor = doctorDao.findByCode(teamLeader);
                        String doctorOpenID = doctor.getOpenid();
                        if (!StringUtils.isEmpty(doctorOpenID)) {
                            String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                            List<NameValuePair> sendParams = new ArrayList<>();
                            sendParams.add(new BasicNameValuePair("type", "9"));
                            sendParams.add(new BasicNameValuePair("openId", doctorOpenID));
                            sendParams.add(new BasicNameValuePair("url", targetUrl));
                            sendParams.add(new BasicNameValuePair("first", doctor.getName()+"医生您好。" + content));
                            sendParams.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                            SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                            String keywords = "分配健管师" + "," +doctor.getHosptialName()+","+ doctor.getName()  ;
                            sendParams.add(new BasicNameValuePair("keywords", keywords));
                        HttpClientUtil.post(url, sendParams, "UTF-8");
                            HttpClientUtil.post(url, sendParams, "UTF-8");
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                // 异常通知
                JSONObject json = new JSONObject();
                json.put("receiver", teamLeader);
                json.put("type", "D_NH_01");
                json.put("title", title);
                json.put("msg", content);
                json.put("data", "");
                jsonArray.add(json);
                    // 异常通知
                    JSONObject json = new JSONObject();
                    json.put("receiver", teamLeader);
                    json.put("type", "D_NH_01");
                    json.put("title", title);
                    json.put("msg", content);
                    json.put("data", "");
                    jsonArray.add(json);
                }
            }
            quartzJobLog.setJobEndTime(new Date());
            quartzJobLog.setJobContent("生成"+yesterday+"的健康管理师消息成功");

+ 178 - 0
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/signfamily/MessageNoticeSetting.java

@ -0,0 +1,178 @@
package com.yihu.wlyy.statistics.model.signfamily;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.statistics.model.IdEntity;
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;
    }
}

+ 130 - 0
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/service/MessageService.java

@ -0,0 +1,130 @@
package com.yihu.wlyy.statistics.service;
import com.yihu.wlyy.statistics.dao.MessageNoticeSettingDao;
import com.yihu.wlyy.statistics.model.signfamily.MessageNoticeSetting;
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 ysj
 */
@Component
@Transactional(rollbackOn = Exception.class)
public class MessageService {
    @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;
    }
}

+ 34 - 27
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/HealthMessageJob.java

@ -3,10 +3,12 @@ package com.yihu.wlyy.job;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.job.QuartzJobLog;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.job.QuartzJobLogDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.task.NoticeJobPushMsgTask;
import com.yihu.wlyy.util.DBExtract;
import com.yihu.wlyy.util.HttpClientUtil;
@ -56,6 +58,8 @@ public class HealthMessageJob implements Job {
    private HttpClientUtil httpClientUtil;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private MessageService messageService;
    @Transactional
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
@ -125,36 +129,39 @@ public class HealthMessageJob implements Job {
                message.setReceiver(teamLeader);
                messageDao.save(message);
                quartzJobLogDao.save(quartzJobLog);
                try {
                    //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                    Doctor doctor = doctorDao.findByCode(teamLeader);
                    String doctorOpenID = doctor.getOpenid();
                    if (!StringUtils.isEmpty(doctorOpenID)) {
                        String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                        List<NameValuePair> sendParams = new ArrayList<>();
                        sendParams.add(new BasicNameValuePair("type", "9"));
                        sendParams.add(new BasicNameValuePair("openId", doctorOpenID));
                        sendParams.add(new BasicNameValuePair("url", targetUrl));
                        sendParams.add(new BasicNameValuePair("first", doctor.getName()+"医生您好。" + content));
                        sendParams.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                        SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                        String keywords = "分配健管师" + "," + doctor.getHospitalName()+ "," + doctor.getName();
                        sendParams.add(new BasicNameValuePair("keywords", keywords));
                        httpClientUtil.post(url, sendParams, "UTF-8");
                if(messageService.getMessageNoticeSettingByMessageType(teamLeader,"1", MessageNoticeSetting.MessageTypeEnum.systemSwitch.getValue())){
                    try {
                        //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                        Doctor doctor = doctorDao.findByCode(teamLeader);
                        String doctorOpenID = doctor.getOpenid();
                        if (!StringUtils.isEmpty(doctorOpenID)) {
                            String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                            List<NameValuePair> sendParams = new ArrayList<>();
                            sendParams.add(new BasicNameValuePair("type", "9"));
                            sendParams.add(new BasicNameValuePair("openId", doctorOpenID));
                            sendParams.add(new BasicNameValuePair("url", targetUrl));
                            sendParams.add(new BasicNameValuePair("first", doctor.getName()+"医生您好。" + content));
                            sendParams.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                            SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                            String keywords = "分配健管师" + "," + doctor.getHospitalName()+ "," + doctor.getName();
                            sendParams.add(new BasicNameValuePair("keywords", keywords));
                            httpClientUtil.post(url, sendParams, "UTF-8");
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                // 异常通知
                JSONObject json = new JSONObject();
                json.put("receiver", teamLeader);
                json.put("type", "D_NH_01");
                json.put("title", title);
                json.put("msg", content);
                json.put("data", "");
                jsonArray.add(json);
                    // 异常通知
                    JSONObject json = new JSONObject();
                    json.put("receiver", teamLeader);
                    json.put("type", "D_NH_01");
                    json.put("title", title);
                    json.put("msg", content);
                    json.put("data", "");
                    jsonArray.add(json);
                }
            }
            quartzJobLog.setJobEndTime(new Date());
            quartzJobLog.setJobContent("生成" + yesterday + "的健康管理师消息成功");

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

@ -0,0 +1,18 @@
package com.yihu.wlyy.repository.message;
import com.yihu.wlyy.entity.message.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);
}

+ 37 - 34
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java

@ -7,6 +7,7 @@ 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.message.MessageNoticeSetting;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.doctor.DoctorDao;
@ -16,6 +17,7 @@ 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.BaseService;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.app.team.DrHealthTeamService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.system.SystemDictService;
@ -82,7 +84,8 @@ public class FollowUpService extends BaseService {
    @Autowired
    SystemDictService dictService;
    @Autowired
    private MessageService messageService;
    @Autowired
    private PatientService patientService;
    @Autowired
@ -689,46 +692,46 @@ public class FollowUpService extends BaseService {
                    message.setType(4);//随访计划提醒
                    message.setReadonly(1);//是否只读消息
                    list.add(message);
                    // 推送消息给医生
                    pushMsgTask.put(doctor, "4", title, content, "");
                    try {
                        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        String hql = "SELECT a.patient_name patientName,a.patient_code patientCode,count(1) amount FROM wlyy_followup a WHERE a.doctor_code = ? " +
                                " AND a.followup_plan_date BETWEEN ? AND ? AND a. STATUS NOT IN ('0', '1') GROUP BY a.patient_code;";
                        //获取所有未执行随访计划
                        List<Map<String, Object>> followups = jdbcTemplate.queryForList(hql,doctor,format.parse(start),format.parse(end));
                        for (Map<String,Object> followup:followups) {
                            //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                            String patientName = String.valueOf(followup.get("patientName"));
                            String patientCount = String.valueOf(followup.get("amount"));
                            Doctor doctor1 = doctorDao.findByCode(doctor);
                            String doctorOpenID = doctor1.getOpenid();
                            if (StringUtils.isNotEmpty(doctorOpenID)) {
                                String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                                List<NameValuePair> params = new ArrayList<>();
                                params.add(new BasicNameValuePair("type", "6"));
                                params.add(new BasicNameValuePair("openId", doctorOpenID));
                                params.add(new BasicNameValuePair("url", targetUrl));
                                params.add(new BasicNameValuePair("first", "您今日有"+patientCount+"个随访计划待处理"));
                                params.add(new BasicNameValuePair("remark", ""));
                                SimpleDateFormat formatDate = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                                String newDate = formatDate.format(new Date());
                                String keywords = patientName+ "," + newDate + "," + "请进入手机APP查看";
                                params.add(new BasicNameValuePair("keywords", keywords));
                                httpClientUtil.post(url, params, "UTF-8");
                    if(messageService.getMessageNoticeSettingByMessageType(doctor,"1", MessageNoticeSetting.MessageTypeEnum.systemSwitch.getValue())){
                        // 推送消息给医生
                        pushMsgTask.put(doctor, "4", title, content, "");
                        try {
                            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                            String hql = "SELECT a.patient_name patientName,a.patient_code patientCode,count(1) amount FROM wlyy_followup a WHERE a.doctor_code = ? " +
                                    " AND a.followup_plan_date BETWEEN ? AND ? AND a. STATUS NOT IN ('0', '1') GROUP BY a.patient_code;";
                            //获取所有未执行随访计划
                            List<Map<String, Object>> followups = jdbcTemplate.queryForList(hql,doctor,format.parse(start),format.parse(end));
                            for (Map<String,Object> followup:followups) {
                                //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                                String patientName = String.valueOf(followup.get("patientName"));
                                String patientCount = String.valueOf(followup.get("amount"));
                                Doctor doctor1 = doctorDao.findByCode(doctor);
                                String doctorOpenID = doctor1.getOpenid();
                                if (StringUtils.isNotEmpty(doctorOpenID)) {
                                    String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                                    List<NameValuePair> params = new ArrayList<>();
                                    params.add(new BasicNameValuePair("type", "6"));
                                    params.add(new BasicNameValuePair("openId", doctorOpenID));
                                    params.add(new BasicNameValuePair("url", targetUrl));
                                    params.add(new BasicNameValuePair("first", "您今日有"+patientCount+"个随访计划待处理"));
                                    params.add(new BasicNameValuePair("remark", ""));
                                    SimpleDateFormat formatDate = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                                    String newDate = formatDate.format(new Date());
                                    String keywords = patientName+ "," + newDate + "," + "请进入手机APP查看";
                                    params.add(new BasicNameValuePair("keywords", keywords));
                                    httpClientUtil.post(url, params, "UTF-8");
                                }
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                messageDao.save(list);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

+ 14 - 144
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientHealthStandard;
import com.yihu.wlyy.entity.patient.SignFamily;
@ -15,6 +16,7 @@ import com.yihu.wlyy.repository.patient.PatientDeviceDao;
import com.yihu.wlyy.repository.patient.PatientHealthStandardDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.task.HealthIndexUploadTask;
import com.yihu.wlyy.task.PushMsgTask;
@ -75,7 +77,8 @@ public class PatientHealthIndexService extends BaseService {
    private CommonUtil CommonUtil;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private MessageService messageService;
    //更改接口(包括手动记录的修改和所有的删除)
@ -182,141 +185,6 @@ public class PatientHealthIndexService extends BaseService {
        return map;
    }
    /**
     * 保存患者健康指标  (旧)
     */
    public DevicePatientHealthIndex save(DevicePatientHealthIndex model, int index, double value, String patientCode) throws Exception {
        model.setCzrq(clock.getCurrentDate());
        model.setDel("1");
        PatientHealthStandard standard = null;
        // 当前值/收缩压,正数为高,负数为低
        double value1 = 0;
        // 上次值/舒张压,正数为高,负数为低
        double value2 = 0;
        if (model.getType() == 1) {
            // 血糖记录,查询患者血糖预警值
            standard = patientHealthStandardDao.findByPatientType(model.getUser(), 1);
            if (index % 2 == 0) {
                // 餐后
                value1 = CommonUtil.checkHealthIndex(value, standard != null && standard.getMaxValue2() > 0 ? standard.getMaxValue2() : SystemConf.HEALTH_STANDARD_ST_MAX_AFTER, standard != null && standard.getMinValue2() > 0 ? standard.getMinValue2() : SystemConf.HEALTH_STANDARD_ST_MIN_AFTER);
            } else {
                // 餐前
                value1 = CommonUtil.checkHealthIndex(value, standard != null && standard.getMaxValue1() > 0 ? standard.getMaxValue1() : SystemConf.HEALTH_STANDARD_ST_MAX_BEFORE, standard != null && standard.getMinValue1() > 0 ? standard.getMinValue1() : SystemConf.HEALTH_STANDARD_ST_MIN_BEFORE);
            }
            // 查询上一次的血糖值
            if (value1 != 0) {
                value2 = NumberUtils.toDouble(findPreValue(model.getUser(), model.getType(), index, model.getRecordDate()), 0);
            }
        } else if (model.getType() == 2) {
            // 血压记录,查询患者血压预警值
            standard = patientHealthStandardDao.findByPatientType(model.getUser(), 2);
            // 收缩压
            value1 = CommonUtil.checkHealthIndex(NumberUtils.toDouble(model.getValue1(), 0), standard != null && standard.getMaxValue1() > 0 ? standard.getMaxValue1() : SystemConf.HEALTH_STANDARD_SSY_MAX, standard != null && standard.getMinValue1() > 0 ? standard.getMinValue1() : SystemConf.HEALTH_STANDARD_SSY_MIN);
            // 舒张压
            value2 = CommonUtil.checkHealthIndex(NumberUtils.toDouble(model.getValue2(), 0), standard != null && standard.getMaxValue2() > 0 ? standard.getMaxValue2() : SystemConf.HEALTH_STANDARD_SZY_MAX, standard != null && standard.getMinValue2() > 0 ? standard.getMinValue2() : SystemConf.HEALTH_STANDARD_SZY_MIN);
            if (value1 > 0 || value2 > 0) {
                value1 = NumberUtils.toDouble(model.getValue1(), 0);
                value2 = NumberUtils.toDouble(model.getValue2(), 0);
            } else if (value1 < 0 || value2 < 0) {
                value1 = -NumberUtils.toDouble(model.getValue1(), 0);
                value2 = -NumberUtils.toDouble(model.getValue2(), 0);
            }
        }
        // 保存到数据库
        model = patientHealthIndexDao.save(model);
        if (value1 != 0) {
            // 消息接收者
            List<String> receivers = new ArrayList<String>();
            // 查询患者信息
            Patient p = patientDao.findByCode(model.getUser());
            // 查询病人家庭签约的健康管理师
            SignFamily signFamily = signFamilyDao.findByjiatingPatientYes(p.getCode());
            String healthDoctorFamily = "";
            if (signFamily != null) {
                healthDoctorFamily = signFamily.getDoctorHealth();
                if (StringUtils.isNotEmpty(healthDoctorFamily)) {
                    // 添加到消息接收人列表
                    receivers.add(healthDoctorFamily);
                }
            }
            // 查询病人三师签约中的健康管理师
            SignFamily signFamilySS = signFamilyDao.findBySanshiPatientYes(p.getCode());
            if (signFamilySS != null) {
                String healthDoctorTeam = signFamilySS.getDoctorHealth();
                // 判断是否是否是同一个健康管理师
                if (StringUtils.isNotEmpty(healthDoctorTeam) && !StringUtils.equals(healthDoctorFamily, healthDoctorTeam)) {
                    // 添加到消息接收人列表
                    receivers.add(healthDoctorTeam);
                }
            }
            List<Message> messages = new ArrayList<Message>();
            JSONArray array = new JSONArray();
            for (String receiver : receivers) {
                if (StringUtils.isEmpty(receiver)) {
                    continue;
                }
                Patient patient = patientDao.findByCode(patientCode);
                // 保存异常消息
                Message message = new Message();
                message.setCzrq(new Date());
                message.setCreateTime(new Date());
                message.setRead(1);
                message.setOver("1");
                message.setReceiver(receiver);
                message.setSender(p.getCode());
                message.setCode(getCode());
                message.setSex(patient.getSex());
                message.setSenderName(p.getName());
                message.setSenderPhoto(p.getPhoto());
                message.setTitle("预警值信息");
                String typeName = "";
                switch (model.getType()) {
                    case 1: {
                        typeName = "血糖";
                        break;
                    }
                    case 2: {
                        typeName = "血压";
                        break;
                    }
                    case 3: {
                        typeName = "体重";
                        break;
                    }
                    case 4: {
                        typeName = "腰围";
                        break;
                    }
                }
                message.setContent(patient.getName() + typeName + "超过预警值");
                message.setType(2);
                message.setValue1(value1);
                message.setValue2(value2);
                message.setTzCode(model.getId() + "");//消息关联的体征id
                message.setTzType(model.getType() + "");//体征类别 (1血糖,2血压,3体重,4腰围)
                messages.add(message);
                // 异常通知
                JSONObject json = new JSONObject();
                json.put("receiver", receiver);
                json.put("type", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.D_HI_01.name());
                json.put("title", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.体征指标.name());
                json.put("msg", p.getName() + "的体征指标出现异常,请及时处理!");
                json.put("data", "");
                JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(receiver);
                if (jsonObject.getString("status").equals("1")) {
                    //如果在工作时间内就推送
                    array.put(json);
                }
            }
            // 批量保存消息
            messageDao.save(messages);
            // 推送消息给医生
            pushMsgTask.put(array);
        }
        return model;
    }
    /**
     * 判断当前值是否在区间内
@ -386,14 +254,16 @@ public class PatientHealthIndexService extends BaseService {
            message.setTzType(String.valueOf(model.getType()));//体征类别 (1血糖,2血压,3体重,4腰围)
            messages.add(message);
            // 异常通知
            JSONObject json = new JSONObject();
            json.put("receiver", receiver);
            json.put("type", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.D_HI_01.name());
            json.put("title", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.体征指标.name());
            json.put("msg", content);
            json.put("data", "");
            array.put(json);
            if(messageService.getMessageNoticeSettingByMessageType(receiver,"1", MessageNoticeSetting.MessageTypeEnum.healthSignSwitch.getValue())){
                // 异常通知
                JSONObject json = new JSONObject();
                json.put("receiver", receiver);
                json.put("type", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.D_HI_01.name());
                json.put("title", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.体征指标.name());
                json.put("msg", content);
                json.put("data", "");
                array.put(json);
            }
        }
        // 批量保存消息
        messageDao.save(messages);

+ 110 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java

@ -2,11 +2,13 @@ package com.yihu.wlyy.service.app.message;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.health.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.message.MessageNoticeSettingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
@ -21,6 +23,7 @@ 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;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
@ -52,6 +55,12 @@ public class MessageService extends BaseService {
    private DevicePatientHealthIndexDao devicePatientHealthIndexDao;
    @Autowired
    private HttpClientUtil HttpClientUtil;
    @Autowired
    private MessageNoticeSettingDao messageNoticeSettingDao;
    @Autowired
    private StringRedisTemplate redisTemplate;
    private final String MESSAGE_NOTICESETTING = "wlyy:message:setting:";
    @Value("${im.im_list_get}")
    private String im_list_get;
@ -458,4 +467,105 @@ public class MessageService extends BaseService {
            messageDao.setMessageReaded(doctor, type);
        }
    }
    /**
     * 获取消息提醒设置
     * @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;
    }
}

+ 1 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/physicalExamination/PatientPhysicalExaminationService.java

@ -58,7 +58,7 @@ public class PatientPhysicalExaminationService extends BaseService {
        Date yesteryear = c.getTime();
        JSONObject json = new JSONObject();
        String first = "温馨提醒,您已经超过一年没有到社区进行健康体检啦,为了您和您的家庭医生了解您近期的健康状况,请及时到签约社区进行免费的健康体检哟~";
        String first = "温馨提醒,您已经超过一年没有到社区进行健康体检啦,为了您和您的家庭医生了解您近期的健康状况,请及时到签约社区进行65岁以上老年人的免费健康体检哟~(如今年已体检请忽略)";
        json.put("remark", "");
        json.put("keyword1", "健康体检");
        json.put("keyword2", format.format(new Date()));

+ 6 - 51
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java

@ -1,8 +1,7 @@
package com.yihu.wlyy.service.app.prescription;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
@ -16,6 +15,7 @@ import com.yihu.wlyy.repository.prescription.PrescriptionDiagnosisDao;
import com.yihu.wlyy.repository.prescription.PrescriptionExpressageDao;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.MessageType;
@ -29,7 +29,6 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -68,7 +67,8 @@ public class PrescriptionService extends BaseService {
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private JpaTransactionManager transactionManager;
    @Autowired
    private MessageService messageService;
    @Autowired
    private com.yihu.wlyy.util.CommonUtil commonUtil;
@ -153,7 +153,8 @@ public class PrescriptionService extends BaseService {
            }else if(prescription.getDispensaryType()==3){
                //健管师配送
                PrescriptionExpressage expressage = prescriptionExpressageDao.findByPrescriptionCode(code);
                if(StringUtils.isNotBlank(expressage.getExpressageCode())){
                if(StringUtils.isNotBlank(expressage.getExpressageCode())
                        &&messageService.getMessageNoticeSettingByMessageType(expressage.getExpressageCode(),"1", MessageNoticeSetting.MessageTypeEnum.prescriptionSwitch.getValue())){
                    String content = "您有一条新的续方订单待取药!";
                    pushMsgTask.put(expressage.getExpressageCode(), MessageType.MESSAGE_TYPE_PRESCRIPTION_WAIT_TAKE_DRUG.D_P_WRD.name(), MessageType.MESSAGE_TYPE_PRESCRIPTION_WAIT_TAKE_DRUG.续方消息.name(), content, prescription.getCode());
                }
@ -162,52 +163,6 @@ public class PrescriptionService extends BaseService {
        logger.info("配药完成,提示居民或健管师取药:"+code+",status="+prescription.getStatus());
    }
    /**
     * 提醒健管师待取药
     * @param code
     * @param healthDoctor
     */
    public void waitExpressageMessage(String code,String healthDoctor){
        try{
            Prescription prescription = prescriptionDao.findByCode(code);
            if(PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue()==prescription.getStatus()){
                //配药完成之后才分配健管师,分配健管师后,提示健管师待取药
                List<Message> list = messageDao.findByReceiverAndRelationCode(healthDoctor,code,7);
                if(list.size()==0){
                    PrescriptionExpressage expressage = prescriptionExpressageDao.findByPrescriptionCode(code);
                    if(StringUtils.isNotBlank(expressage.getExpressageCode())){
                        String content = "您有一条新的续方订单待取药!";
                        Message message = new Message();
                        message.setCzrq(new Date());
                        message.setCreateTime(new Date());
                        message.setRead(1);//设置未读
                        message.setOver("1");
                        message.setReceiver(expressage.getExpressageCode());
                        message.setSender("system");
                        message.setCode(getCode());
                        message.setSenderName("系统");
                        message.setTitle("居民"+prescription.getPatientName()+"的续方订单待取药");
                        message.setContent("您有一条新的续方订单待取药!");
                        message.setType(7);//续方订单待取药
                        message.setReadonly(1);//是否只读消息
                        message.setDel("1");
                        message.setRelationCode(prescription.getCode());
                        message.setPrescriptionStatus("0");//待取药
                        //获取居民团队code
                        DoctorTeam dt = doctorTeamDao.findByParientCode(prescription.getPatient());
                        message.setData(dt.getCode());
                        messageDao.save(message);
                        pushMsgTask.put(expressage.getExpressageCode(), MessageType.MESSAGE_TYPE_PRESCRIPTION_WAIT_TAKE_DRUG.D_P_WRD.name(), MessageType.MESSAGE_TYPE_PRESCRIPTION_WAIT_TAKE_DRUG.续方消息.name(), content, prescription.getCode());
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            logger.info("提醒健管师待取药,消息新增失败");
        }
    }
    /**
     *获取支付完成,院内结算失败的 处方CODE 集合

+ 0 - 694
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -33,7 +33,6 @@ import com.yihu.wlyy.util.*;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.sql.Select;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -403,253 +402,6 @@ public class FamilyContractService extends BaseService {
        return signFamilyDao.hasSingStatus(idcard);
    }
    /**
     * 发起签约申请
     *
     * @param province     省代码
     * @param provinceName 省名称
     * @param city         城市代码
     * @param cityName     城市名称
     * @param town         区县代码
     * @param townName     区县名称
     * @param address      详细地址
     * @param name         患者姓名
     * @param doctor       医生标识
     * @param openid       微信openid
     * @param patient      患者标识
     * @param idcard       患者身份证号
     * @param ssc          患者社保卡号
     * @param mobile       患者手机号
     * @param emerMobile   患者紧急联系人
     * @return
     */
    public JSONObject sign(String province,
                           String provinceName,
                           String city,
                           String cityName,
                           String town,
                           String townName,
                           String address,
                           String name,
                           String doctor,
                           String openid,
                           String patient,
                           String idcard,
                           String ssc,
                           String mobile,
                           String emerMobile) throws Exception {
        // 查询三师签约
        JSONObject json = new JSONObject();
        SignFamily sc = signFamilyDao.findByIdcard(idcard);
        //判断身份证号是否已经注册
        if (sc != null) {
            json.put("res", "-3");
            return json;
        }
        Doctor d = doctorDao.findByCode(doctor);
        SignFamily sf = new SignFamily();
        sf.setCode(getCode());
        // 设置两网编码
        sf.setLwCode(sc != null ? sc.getCode() : null);
        sf.setCzrq(new Date());
        sf.setPatientApplyDate(new Date());
        sf.setDoctor(doctor);
        //设置全科医生的行政团队
        sf.setAdminTeamId(doctorAdminTeamDao.findIdByLeaderCode(doctor));
        sf.setMobile(mobile);
        sf.setDoctorName(d.getName());
        sf.setEmerMobile(emerMobile);
        sf.setName(name);
        sf.setIdcard(idcard);
        sf.setOpenid(openid);
        sf.setPatient(patient);
        sf.setHospital(d.getHospital());
        sf.setHospitalName(d.getHospitalName());
        sf.setSsc(ssc);
        sf.setStatus(0);//0为初始状态
        sf.setType(2);// 设置为家庭签约
        sf.setSignType("1");//用户申请
        sf.setSignSource("2");//签约来源【1 社区签约 2 移动签约】
        //******************扣费接口**********************/
        sf.setExpensesStatus("0");   //扣费状态 【0未扣费 1已扣费 2已退费】
        // 判断用户表是否存在该身份证号
        Patient p = patientDao.findByIdcard(idcard);
        if (p == null) {
            // 插入患者基本信息
            IdcardInfoExtractor ie = new IdcardInfoExtractor(idcard);
            p = new Patient();
            p.setCode(getCode());
            p.setName(name);
            p.setProvince(province);
            p.setProvinceName(provinceName);
            p.setCity(city);
            p.setCityName(cityName);
            p.setTown(town);
            p.setTownName(townName);
            p.setAddress(address);
            p.setOpenid(openid);
            p.setOpenidTime(new Date());
            p.setIdcard(idcard);
            p.setMobile(mobile);
            p.setSsc(ssc);
            // 从身份证号中提取生日
            p.setBirthday(ie.getBirthday());
            // 从身份证号中提取性别
            p.setSex(ie.getGender());
            p.setCzrq(new Date());
            p.setStatus(1);
            // 保存新的用户信息
            p = patientDao.save(p);
        } else {
            if (StringUtils.isNotEmpty(patient) && !StringUtils.equals(p.getCode(), patient)) {
                // 身份证信息与登录信息不匹配
                json.put("res", -1);
                return json;
            }
            if (StringUtils.isNotEmpty(openid) && !StringUtils.equals(p.getOpenid(), openid)) {
                // 身份证信息与登录信息不匹配
                json.put("res", -1);
                return json;
            }
            if (StringUtils.isNotEmpty(idcard) && !StringUtils.equals(p.getIdcard(), idcard)) {
                // 身份证信息与登录信息不匹配
                json.put("res", -1);
                return json;
            }
        }
        // 更新签约用户信息
        patient = p.getCode();
        sf.setPatient(patient);
        SignFamily temp = signFamilyDao.save(sf);
        if (temp != null) {
            // 添加签约消息
            Message message = new Message();
            message.setCzrq(new Date());
            message.setCreateTime(new Date());
            message.setContent("您有一条新的家庭签约申请!");
            message.setRead(1);//设置未读
            message.setReceiver(doctor);//设置接受医生的code
            message.setSender(patient);//设置发送的用户
            message.setSenderName(p.getName());
            message.setCode(getCode());
            message.setSenderPhoto(p.getPhoto());
            message.setTitle("家庭签约申请");
            message.setType(1);//家庭签约信息
            message.setReadonly(1);//是否只读消息
            message.setSignStatus("1");//新的签约
            message.setSex(p.getSex());
            message.setOver("1");//未处理
            message.setData(temp.getCode());
            messageDao.save(message);
            // 发送消息给医生
            // 发送消息给医生
            JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
            if (jsonObject.getString("status").equals("1")) {
                //如果在工作时间内就推送
                pushMsgTask.put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.D_SW_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.家庭签约.name(), "您有一条新的家庭签约申请!", patient);
            }
        }
        json.put("id", p.getId());
        json.put("uid", p.getCode());
        json.put("res", 1);
        return json;
    }
    /**
     * 申请签约
     *
     * @param doctor  签约医生
     * @param patient 居民code
     * @return
     */
    public int sign(String doctor, String patient, String countryCode) throws Exception {
        Patient p = patientDao.findByCode(patient);
        if (p == null) {
            return -1;
        }
        SignFamily sc = signFamilyDao.findByIdcard(p.getIdcard());
        //判断身份证号是否已签约
        if (sc != null) {
            return -2;
        }
        Doctor d = doctorDao.findByCode(doctor);
        if (d == null) {
            return -3;
        }
        SignFamily sf = new SignFamily();
        sf.setCode(getCode());
        // 设置两网编码
        sf.setLwCode(sc != null ? sc.getCode() : null);
        sf.setCzrq(new Date());
        sf.setPatientApplyDate(new Date());
        if (d.getLevel() == 2) {
            sf.setDoctor(doctor);
            sf.setDoctorName(d.getName());
        } else {
            sf.setDoctorHealth(doctor);
            sf.setDoctorHealthName(d.getName());
        }
        sf.setMobile(p.getMobile());
        sf.setName(p.getName());
        sf.setIdcard(p.getIdcard());
        sf.setOpenid(p.getOpenid());
        sf.setPatient(patient);
        sf.setHospital(d.getHospital());
        sf.setHospitalName(d.getHospitalName());
        sf.setSsc(p.getSsc());
        sf.setStatus(0);//0为初始状态
        sf.setType(2);// 设置为家庭签约
        sf.setSignType("1");//用户申请
        sf.setSignSource("2");//签约来源【1 社区签约 2 移动签约】
        //******************扣费接口**********************/
        sf.setExpensesStatus("0");   //扣费状态 【0未扣费 1已扣费 2已退费】
        sf.setBegin(DateUtil.stringToDate(DateUtil.getSignYear() + "-07-01 00:00:00", "yyyy-MM-dd HH:mmm:ss"));
        sf.setEnd(DateUtil.stringToDate(DateUtil.getSignYear() + 1 + "-06-30 23:59:59", "yyyy-MM-dd HH:mmm:ss"));
        sf.setSignYear(DateUtil.getSignYear() + "");
        //1.3.5新增居委会字段
        signWebService.setPatientCountryFamily(countryCode, sf);
        SignFamily temp = signFamilyDao.save(sf);
        if (temp != null) {
            // 添加签约消息
            Message message = new Message();
            message.setCzrq(new Date());
            message.setCreateTime(new Date());
            message.setContent("您有一条新的家庭签约申请!");
            message.setRead(1);//设置未读
            message.setReceiver(doctor);//设置接受医生的code
            message.setSender(patient);//设置发送的用户
            message.setSenderName(p.getName());
            message.setCode(getCode());
            message.setSenderPhoto(p.getPhoto());
            message.setTitle("家庭签约申请");
            message.setType(1);//家庭签约信息
            message.setReadonly(1);//是否只读消息
            message.setSignStatus("1");//新的签约
            message.setSex(p.getSex());
            message.setOver("1");//未处理
            message.setData(temp.getCode());
            messageDao.save(message);
            // 发送消息给医生
            JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
            if (jsonObject.getString("status").equals("1")) {
                //如果在工作时间内就推送
                pushMsgTask.put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.D_SW_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.家庭签约.name(), "您有一条新的家庭签约申请!", patient);
            }
        }
        return 1;
    }
    /**
     * 取消签约申请
     *
@ -734,59 +486,6 @@ public class FamilyContractService extends BaseService {
        return 200;
    }
    /**
     * 申请解约
     *
     * @param patient 患者标识
     * @param doctor  医生标识
     * @param openid  微信openid
     * @param reason  解约理由
     * @return
     */
    public int surrender(String patient, String patientName, String userPhoto, String doctor, String doctorName, String openid, String reason, int sex) throws Exception {
        // 更新为待解约
        int res = signFamilyDao.surrender(patient, doctor);
        SignFamily signFamily = signFamilyDao.findByjiatingPatient(patient);
        signFamily.setPatientApplyUnsignDate(new Date());
        if (res == 0) {
            return 0;
        }
        // 添加签约消息
        Message message = new Message();
        // 消息时间
        message.setCzrq(new Date());
        message.setCreateTime(new Date());
        // 消息内容
        message.setContent("申请解除与您的签约关系");
        // 未读
        message.setRead(1);
        message.setReceiverName(doctorName);
        // 接收人
        message.setReceiver(doctor);
        message.setCode(getCode());
        // 发送人
        message.setSender(patient);
        message.setSenderName(patientName);
        message.setSenderPhoto(userPhoto);
        // 标题
        message.setTitle("解除家庭签约申请");
        message.setType(1);
        message.setSignStatus("4");
        message.setReadonly(1);
        message.setSex(sex);
        message.setOver("1");
        // 设置解约理由
        message.setReason(reason);
        message.setData(signFamily.getCode());
        messageDao.save(message);
        // 发送消息给医生
        JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
        if (jsonObject.getString("status").equals("1")) {
            //如果在工作时间内就推送
            pushMsgTask.put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_SIGN_WEB_RELIEVE.D_SW_02.name(), MessageType.MESSAGE_TYPE_DOCTOR_SIGN_WEB_RELIEVE.家庭签约.name(), patientName + " 申请解除与您的家庭签约!", patient);
        }
        return 1;
    }
    /**
     * 查询患者的签约消息
@ -3162,399 +2861,6 @@ public class FamilyContractService extends BaseService {
    }
    /**
     * 续签申请
     *
     * @param doctor  签约医生
     * @param patient 居民code
     * @return
     */
    @Transactional
    public int signRenew(String doctor, String healthDoctor, String patient, String reason) throws Exception {
        Patient p = patientDao.findByCode(patient);
        if (p == null) {
            return -1;
        }
//        List<SignFamilyRenew> sc = signFamilyRenewDao.findByIdcard(p.getIdcard());
//        //判断身份证号是否已签约
//        if (sc != null&&sc.size()>0) {
//            return -2;
//        }
        Doctor d = doctorDao.findByCode(doctor);
        Doctor hd = null;
        if (StringUtils.isNotBlank(healthDoctor)) {
            hd = doctorDao.findByCode(healthDoctor);
        }
        if (d == null) {
            return -3;
        }
        Calendar cal = Calendar.getInstance();
        int year = cal.get(Calendar.YEAR);
        int month = cal.get(Calendar.MONTH) + 1;
        List<SignFamilyRenew> res = signFamilyRenewDao.findByDoctorAndPatientHossPost(patient, DateUtil.getSignYear() + "");
        if (res != null && res.size() > 0) {
            return -2;
        }
        SignFamilyRenew sf = new SignFamilyRenew();
        String sql = "";
        //判断是否有生效记录SQL
        sql = "SELECT t.doctor,t.team_code teamCode,t.admin_team_code adminTeamCode,t.mobile FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status>=0 AND t.expenses_status='1' AND t.sign_year ='" + (DateUtil.getSignYear() - 1) + "'";
        List<Map<String, Object>> signs = jdbcTemplate.queryForList(sql);
        if (signs == null || signs.size() == 0) {
            return -4;
        }
        Map<String, Object> sign = signs.get(0);
        //判断续签医生是否一致
        if (doctor.equals(sign.get("doctor"))) {
            //如果一致保存团队信息
            sf.setTeamCode((String) sign.get("teamCode"));
            Integer c = (Integer) sign.get("adminTeamCode");
            sf.setRenewFlag("1");
            sf.setAdminTeamId(c.longValue());
        } else {
            //如果不一致 查看医生团队
            sf.setRenewFlag("2");
//            String tcSql = "SELECT t.id FROM wlyy_admin_team t WHERE t.leader_code ='"+doctor+"'";
//            List<Map<String ,Object>> ids = jdbcTemplate.queryForList(tcSql);
//            if(ids!=null&&ids.size()>0){
//                Integer id =  (Integer)ids.get(0).get("id");
//                Long lid = id.longValue();
//                sf.setAdminTeamId(lid);
//            }else{
//                //未找到团队信息
//                return -5;
//            }
            //新建咨询团队组逻辑
            DoctorTeam team = new DoctorTeam();
            String code = getCode();
            team.setCode(code);
            team.setCzrq(new Date());
            team.setDel("1");
            team.setSignType("2");
            //判断是否有健康管理师
            if (hd != null && StringUtils.isNotBlank(hd.getName())) {
                team.setName(d.getName() + "," + hd.getName() + "," + p.getName());
                //新建健康管理师
                DoctorTeamMember hdmb = new DoctorTeamMember();
                hdmb.setName(hd.getName());
                hdmb.setMemberCode(healthDoctor);
                hdmb.setCode(getCode());
                hdmb.setDel("1");
                hdmb.setCzrq(new Date());
                hdmb.setTeam(code);
                hdmb.setType(3);
                hdmb.setSignType("2");
                doctorTeamDoctor.save(hdmb);
            } else {
                team.setName(d.getName() + "," + p.getName());
            }
            //新建医生成员
            DoctorTeamMember dmb = new DoctorTeamMember();
            dmb.setName(d.getName());
            dmb.setMemberCode(doctor);
            dmb.setCode(getCode());
            dmb.setDel("1");
            dmb.setCzrq(new Date());
            dmb.setTeam(code);
            dmb.setType(d.getLevel());
            dmb.setSignType("2");
            //新建病人
            DoctorTeamMember pmb = new DoctorTeamMember();
            pmb.setName(p.getName());
            pmb.setMemberCode(patient);
            pmb.setCode(getCode());
            pmb.setDel("1");
            pmb.setCzrq(new Date());
            pmb.setTeam(code);
            pmb.setType(5);
            pmb.setSignType("2");
            doctorTeamDoctor.save(dmb);
            doctorTeamDoctor.save(pmb);
            doctorTeamDao.save(team);
            //关联新团队
            sf.setTeamCode(code);
        }
        sf.setCode(getCode());
        sf.setCzrq(new Date());
        sf.setPatientApplyDate(new Date());
        if (d != null) {
            sf.setDoctor(doctor);
            sf.setDoctorName(d.getName());
            sf.setSignDoctorCode(doctor);
            sf.setSignDoctorName(d.getName());
        }
        if (hd != null) {
            sf.setDoctorHealth(healthDoctor);
            sf.setDoctorHealthName(hd.getName());
        }
        sf.setMobile((String) sign.get("mobile"));
        sf.setName(p.getName());
        sf.setIdcard(p.getIdcard());
        sf.setOpenid(p.getOpenid());
        sf.setPatient(patient);
        sf.setHospital(d.getHospital());
        sf.setHospitalName(d.getHospitalName());
        sf.setSsc(p.getSsc());
        sf.setStatus(0);//0为初始状态
        sf.setType(2);// 设置为家庭签约
        sf.setSignType("1");//用户申请
        sf.setSignSource("2");//签约来源【1 社区签约 2 移动签约】
        //******************扣费接口**********************/
        sf.setExpensesStatus("0");   //扣费状态 【0未扣费 1已扣费 2已退费】
        sf.setSignYear(DateUtil.getSignYear() + "");
        sf.setIsValid(0);
        sf.setBegin(DateUtil.stringToDate(DateUtil.getSignYear() + "-07-01 00:00:00", "yyyy-MM-dd HH:mmm:ss"));
        sf.setEnd(DateUtil.stringToDate(DateUtil.getSignYear() + 1 + "-06-30 23:59:59", "yyyy-MM-dd HH:mmm:ss"));
        //设置转签原因
        if (StringUtils.isNotBlank(reason)) {
            sf.setRenewChangeReason(reason);
        }
        SignFamilyRenew temp = signFamilyRenewDao.save(sf);
        if (temp != null) {
            // 添加签约消息
            Message message = new Message();
            message.setCzrq(new Date());
            message.setCreateTime(new Date());
            message.setContent("您有一条新的家庭医生续签申请!");
            message.setRead(1);//设置未读
            message.setReceiver(doctor);//设置接受医生的code
            message.setSender(patient);//设置发送的用户
            message.setSenderName(p.getName());
            message.setCode(getCode());
            message.setSenderPhoto(p.getPhoto());
            message.setTitle("家庭续签申请");
            message.setType(1);//家庭签约信息
            message.setReadonly(1);//是否只读消息
            if ("1".equals(sf.getRenewFlag())) {
                message.setSignStatus("8");//续签
            } else {
                message.setSignStatus("9");//改签
            }
            message.setSex(p.getSex());
            message.setOver("1");//未处理
            message.setData(sf.getCode());
            messageDao.save(message);
            // 发送消息给医生
            JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
            if (jsonObject.getString("status").equals("1")) {
                //如果在工作时间内就推送
                pushMsgTask.put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.D_SW_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.家庭签约.name(), p.getName() + "申请与您续签家庭医生", patient);
            }
        }
        return 1;
    }
    /**
     * 续签申请(7月之后)
     *
     * @param doctor  签约医生
     * @param patient 居民code
     * @return
     */
    @Transactional
    public int signRenewOverdue(String doctor, String healthDoctor, String patient, String reason, String countryCode) throws Exception {
        Patient p = patientDao.findByCode(patient);
        if (p == null) {
            return -1;
        }
        Doctor d = doctorDao.findByCode(doctor);
        Doctor hd = null;
        if (StringUtils.isNotBlank(healthDoctor)) {
            hd = doctorDao.findByCode(healthDoctor);
        }
        if (d == null) {
            return -3;
        }
        List<SignFamily> res = signFamilyDao.findByDoctorAndPatientHossPost(patient, DateUtil.getSignYear() + "");
        if (res != null && res.size() > 0) {
            return -2;
        }
        SignFamily sf = new SignFamily();
        Calendar cal = Calendar.getInstance();
        int year = cal.get(Calendar.YEAR);
        int month = cal.get(Calendar.MONTH) + 1;
        String sql = "SELECT t.doctor,t.team_code teamCode,t.admin_team_code adminTeamCode,t.mobile FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status=-4 AND t.expenses_status='1' AND t.sign_year ='" + (year - 1) + "'";
        List<Map<String, Object>> signs = jdbcTemplate.queryForList(sql);
        if (signs == null || signs.size() == 0) {
            return -4;
        }
        Map<String, Object> sign = signs.get(0);
        //判断续签医生是否一致
        if (doctor.equals(sign.get("doctor"))) {
            //如果一致保存团队信息
            sf.setRenewFlag("1");
            sf.setTeamCode((String) sign.get("teamCode"));
            Integer c = (Integer) sign.get("adminTeamCode");
            sf.setAdminTeamId(c.longValue());
        } else {
            //如果不一致 查看医生团队
            sf.setRenewFlag("2");
//            String tcSql = "SELECT t.id FROM wlyy_admin_team t WHERE t.leader_code ='"+doctor+"'";
//            List<Map<String ,Object>> ids = jdbcTemplate.queryForList(tcSql);
//            if(ids!=null&&ids.size()>0){
//                Integer id =  (Integer)ids.get(0).get("id");
//                Long lid = id.longValue();
//                sf.setAdminTeamId(lid);
//            }else{
//                //未找到团队信息
//                return -5;
//            }
            //新建咨询团队组
            DoctorTeam team = new DoctorTeam();
            String code = getCode();
            team.setCode(code);
            team.setCzrq(new Date());
            team.setDel("1");
            team.setSignType("2");
            //判断是否有健康管理师
            if (hd != null && StringUtils.isNotBlank(hd.getName())) {
                team.setName(d.getName() + "," + hd.getName() + "," + p.getName());
                //新建健康管理师
                DoctorTeamMember hdmb = new DoctorTeamMember();
                hdmb.setName(hd.getName());
                hdmb.setMemberCode(healthDoctor);
                hdmb.setCode(getCode());
                hdmb.setDel("1");
                hdmb.setCzrq(new Date());
                hdmb.setTeam(code);
                hdmb.setType(3);
                hdmb.setSignType("2");
                doctorTeamDoctor.save(hdmb);
            } else {
                team.setName(d.getName() + "," + p.getName());
            }
            //新建医生成员
            DoctorTeamMember dmb = new DoctorTeamMember();
            dmb.setName(d.getName());
            dmb.setMemberCode(doctor);
            dmb.setCode(getCode());
            dmb.setDel("1");
            dmb.setCzrq(new Date());
            dmb.setTeam(code);
            dmb.setType(d.getLevel());
            dmb.setSignType("2");
            //新建病人
            DoctorTeamMember pmb = new DoctorTeamMember();
            pmb.setName(p.getName());
            pmb.setMemberCode(patient);
            pmb.setCode(getCode());
            pmb.setDel("1");
            pmb.setCzrq(new Date());
            pmb.setTeam(code);
            pmb.setType(5);
            pmb.setSignType("2");
            doctorTeamDoctor.save(dmb);
            doctorTeamDoctor.save(pmb);
            doctorTeamDao.save(team);
            //关联新团队
            sf.setTeamCode(code);
        }
        sf.setCode(getCode());
        sf.setCzrq(new Date());
        sf.setPatientApplyDate(new Date());
        if (d != null) {
            sf.setDoctor(doctor);
            sf.setDoctorName(d.getName());
            sf.setSignDoctorCode(doctor);
            sf.setSignDoctorName(d.getName());
        }
        if (hd != null) {
            sf.setDoctorHealth(healthDoctor);
            sf.setDoctorHealthName(hd.getName());
        }
        sf.setMobile((String) sign.get("mobile"));
        sf.setName(p.getName());
        sf.setIdcard(p.getIdcard());
        sf.setOpenid(p.getOpenid());
        sf.setPatient(patient);
        sf.setHospital(d.getHospital());
        sf.setHospitalName(d.getHospitalName());
        sf.setSsc(p.getSsc());
        sf.setStatus(0);//0为初始状态
        sf.setType(2);// 设置为家庭签约
        sf.setSignType("1");//用户申请
        sf.setSignSource("2");//签约来源【1 社区签约 2 移动签约】
        //******************扣费接口**********************/
        sf.setExpensesStatus("0");   //扣费状态 【0未扣费 1已扣费 2已退费】
        sf.setSignYear(year + "");
        sf.setBegin(DateUtil.stringToDate(DateUtil.getSignYear() + "-07-01 00:00:00", "yyyy-MM-dd HH:mmm:ss"));
        sf.setEnd(DateUtil.stringToDate(DateUtil.getSignYear() + 1 + "-06-30 23:59:59", "yyyy-MM-dd HH:mmm:ss"));
        if (StringUtils.isNotBlank(reason)) {
            sf.setRenewChangeReason(reason);
        }
        //1.3.5新增居委会字段
        signWebService.setPatientCountryFamily(countryCode, sf);
        SignFamily temp = signFamilyDao.save(sf);
        if (temp != null) {
            // 添加签约消息
            Message message = new Message();
            message.setCzrq(new Date());
            message.setCreateTime(new Date());
            message.setContent("您有一条新的家庭医生续签申请!");
            message.setRead(1);//设置未读
            message.setReceiver(doctor);//设置接受医生的code
            message.setSender(patient);//设置发送的用户
            message.setSenderName(p.getName());
            message.setCode(getCode());
            message.setSenderPhoto(p.getPhoto());
            message.setTitle("家庭续签申请");
            message.setType(1);//家庭签约信息
            message.setReadonly(1);//是否只读消息
            if ("1".equals(sf.getRenewFlag())) {
                message.setSignStatus("8");//续签
            } else {
                message.setSignStatus("9");//改签
            }
            //message.setSignStatus("1");//过期以后,变为1为签约
            message.setSex(p.getSex());
            message.setOver("1");//未处理
            message.setData(sf.getCode());
            messageDao.save(message);
            // 发送消息给医生
            JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
            if (jsonObject.getString("status").equals("1")) {
                //如果在工作时间内就推送
                pushMsgTask.put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.D_SW_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.家庭签约.name(), p.getName() + "申请与您续签家庭医生", patient);
            }
        }
        return 1;
    }
    /**
     * @param code

+ 19 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/charge/PopupsDao.java

@ -0,0 +1,19 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.charge;
import com.yihu.wlyy.entity.charge.PatientPopups;
import com.yihu.wlyy.entity.charge.WlyyCharge;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface PopupsDao extends PagingAndSortingRepository<PatientPopups, Long>, JpaSpecificationExecutor<PatientPopups> {
    //根据居民code和type查询弹窗设置
    @Query("select a from PatientPopups a where a.patient = ?1 and a.type = ?2 ")
    PatientPopups findByCodeAndType(String patient,int type);
}

+ 4 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java

@ -423,4 +423,8 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    // 查询团队已签约的总数
    @Query("select count(1) from SignFamily a where  a.adminTeamId = ?1 and (a.status = 1 or a.status = 2) and a.type = 2")
    int countAmountSignedByAdminTeam(Long id);
    // 查询已签约未缴费居民
    @Query("select a from SignFamily a where  a.patient = ?1 and a.type = 2 and a.expensesStatus = '0' and a.status >0")
    SignFamily findUnpay(String patient);
}

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

@ -12,6 +12,7 @@ import com.yihu.wlyy.entity.followup.FollowupContent;
import com.yihu.wlyy.entity.followup.FollowupDrugs;
import com.yihu.wlyy.entity.followup.FollowupMapping;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.doctor.DoctorDao;
@ -23,6 +24,7 @@ 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.BaseService;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.app.team.DrHealthTeamService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.system.SystemDictService;
@ -121,7 +123,8 @@ public class FollowUpService extends BaseService {
    private ElasticFactory elasticFactory;
    @Autowired
    private ElastricSearchSave elastricSearchSave;
    @Autowired
    private MessageService messageService;
    /**
     * 转译随访信息
@ -862,35 +865,36 @@ public class FollowUpService extends BaseService {
                    message.setType(4);//随访计划提醒
                    message.setReadonly(1);//是否只读消息
                    list.add(message);
                    // 推送消息给医生
                    pushMsgTask.put(doctor, "4", title, content, "");
                    try {
                        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        List<Followup> followups = followupDao.getByDoctorPlan(doctor,format.parse(start),format.parse(end));
                        for (Followup followup:followups) {
                            //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                            Doctor doctor1 = doctorDao.findByCode(doctor);
                            String doctorOpenID = doctor1.getOpenid();
                            if (StringUtils.isNotEmpty(doctorOpenID)) {
                                String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                                List<NameValuePair> params = new ArrayList<>();
                                params.add(new BasicNameValuePair("type", "6"));
                                params.add(new BasicNameValuePair("openId", doctorOpenID));
                                params.add(new BasicNameValuePair("url", targetUrl));
                                params.add(new BasicNameValuePair("first", "您今日有"+count+"个随访计划待处理"));
                                params.add(new BasicNameValuePair("remark", ""));
                                SimpleDateFormat formatDate = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                                String newDate = formatDate.format(new Date());
                                String keywords = followup.getPatientName() + newDate + "," + "请进入手机APP查看";
                                params.add(new BasicNameValuePair("keywords", keywords));
                                httpClientUtil.post(url, params, "UTF-8");
                    if(messageService.getMessageNoticeSettingByMessageType(doctor,"1", MessageNoticeSetting.MessageTypeEnum.systemSwitch.getValue())){
                        // 推送消息给医生
                        pushMsgTask.put(doctor, "4", title, content, "");
                        try {
                            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                            List<Followup> followups = followupDao.getByDoctorPlan(doctor,format.parse(start),format.parse(end));
                            for (Followup followup:followups) {
                                //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                                Doctor doctor1 = doctorDao.findByCode(doctor);
                                String doctorOpenID = doctor1.getOpenid();
                                if (StringUtils.isNotEmpty(doctorOpenID)) {
                                    String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                                    List<NameValuePair> params = new ArrayList<>();
                                    params.add(new BasicNameValuePair("type", "6"));
                                    params.add(new BasicNameValuePair("openId", doctorOpenID));
                                    params.add(new BasicNameValuePair("url", targetUrl));
                                    params.add(new BasicNameValuePair("first", "您今日有"+count+"个随访计划待处理"));
                                    params.add(new BasicNameValuePair("remark", ""));
                                    SimpleDateFormat formatDate = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                                    String newDate = formatDate.format(new Date());
                                    String keywords = followup.getPatientName() + newDate + "," + "请进入手机APP查看";
                                    params.add(new BasicNameValuePair("keywords", keywords));
                                    httpClientUtil.post(url, params, "UTF-8");
                                }
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }

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

@ -8,6 +8,7 @@ import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.doctor.health.DoctorHealthStandard;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientAimSports;
import com.yihu.wlyy.entity.patient.PatientHealthStandard;
@ -20,8 +21,8 @@ import com.yihu.wlyy.repository.doctor.health.DoctorHealthStandardDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.task.HealthIndexUploadTask;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.*;
import org.apache.commons.lang3.StringUtils;
@ -93,6 +94,8 @@ public class PatientHealthIndexService extends BaseService {
    private ImUtill ImUtill;
    @Autowired
    private ConsultTeamDao consultTeamDao;
    @Autowired
    private MessageService messageService;
    /**
     * 获取居民标准预警值
@ -378,17 +381,19 @@ public class PatientHealthIndexService extends BaseService {
                message.setTzType(model.getType() + "");//体征类别 (1血糖,2血压,3体重,4腰围)
                messages.add(message);
                // 异常通知
                JSONObject json = new JSONObject();
                json.put("receiver", receiver);
                json.put("type", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.D_HI_01.name());
                json.put("title", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.体征指标.name());
                json.put("msg", p.getName() + "的体征指标出现异常,请及时处理!");
                json.put("data", "");
                JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(receiver);
                if (jsonObject.getString("status").equals("1")) {
                    //如果在工作时间内就推送
                    array.put(json);
                if(messageService.getMessageNoticeSettingByMessageType(receiver,"1",MessageNoticeSetting.MessageTypeEnum.healthSignSwitch.getValue())){
                    // 异常通知
                    JSONObject json = new JSONObject();
                    json.put("receiver", receiver);
                    json.put("type", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.D_HI_01.name());
                    json.put("title", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.体征指标.name());
                    json.put("msg", p.getName() + "的体征指标出现异常,请及时处理!");
                    json.put("data", "");
                    JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(receiver);
                    if (jsonObject.getString("status").equals("1")) {
                        //如果在工作时间内就推送
                        array.put(json);
                    }
                }
            }
            // 批量保存消息
@ -477,14 +482,16 @@ public class PatientHealthIndexService extends BaseService {
            message.setTzType(String.valueOf(model.getType()));//体征类别 (1血糖,2血压,3体重,4腰围)
            messages.add(message);
            // 异常通知
            JSONObject json = new JSONObject();
            json.put("receiver", receiver);
            json.put("type", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.D_HI_01.name());
            json.put("title", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.体征指标.name());
            json.put("msg", content);
            json.put("data", "");
            array.put(json);
            if(messageService.getMessageNoticeSettingByMessageType(receiver,"1", MessageNoticeSetting.MessageTypeEnum.healthSignSwitch.getValue())){
                // 异常通知
                JSONObject json = new JSONObject();
                json.put("receiver", receiver);
                json.put("type", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.D_HI_01.name());
                json.put("title", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.体征指标.name());
                json.put("msg", content);
                json.put("data", "");
                array.put(json);
            }
        }
        // 批量保存消息
        messageDao.save(messages);
@ -492,26 +499,27 @@ public class PatientHealthIndexService extends BaseService {
            if (StringUtils.isEmpty(receiver)) {
                continue;
            }
            //            新增发送医生助手模板消息 v1.4.0 by wujunjie
            if (StringUtils.isNotEmpty(doctorOpenID)) {
                List<Message> messagesList = messageDao.findUnreadHealthIndex(patientCode, receiver);
                if (messagesList != null && messagesList.size()>0){
                    String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                    List<NameValuePair> params = new ArrayList<>();
                    params.add(new BasicNameValuePair("type", "3"));
                    params.add(new BasicNameValuePair("openId", doctorOpenID));
                    params.add(new BasicNameValuePair("url", targetUrl));
                    params.add(new BasicNameValuePair("first", doctorName + "医生,您的签约居民" + patientName +
                            "有" + messagesList.size() + "条未读的体征异常消息"));
                    params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                    SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                    String date = format.format(new Date());
                    String keywords = date + "," + patientName;
                    params.add(new BasicNameValuePair("keywords", keywords));
                    httpClientUtil.post(url, params, "UTF-8");
            if(messageService.getMessageNoticeSettingByMessageType(receiver,"1", MessageNoticeSetting.MessageTypeEnum.healthSignSwitch.getValue())){
                //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                if (StringUtils.isNotEmpty(doctorOpenID)) {
                    List<Message> messagesList = messageDao.findUnreadHealthIndex(patientCode, receiver);
                    if (messagesList != null && messagesList.size()>0){
                        String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                        List<NameValuePair> params = new ArrayList<>();
                        params.add(new BasicNameValuePair("type", "3"));
                        params.add(new BasicNameValuePair("openId", doctorOpenID));
                        params.add(new BasicNameValuePair("url", targetUrl));
                        params.add(new BasicNameValuePair("first", doctorName + "医生,您的签约居民" + patientName +
                                "有" + messagesList.size() + "条未读的体征异常消息"));
                        params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                        SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                        String date = format.format(new Date());
                        String keywords = date + "," + patientName;
                        params.add(new BasicNameValuePair("keywords", keywords));
                        httpClientUtil.post(url, params, "UTF-8");
                    }
                }
            }
        }
        // 推送消息给医生

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

@ -547,4 +547,69 @@ public class MessageService extends BaseService {
        String response = com.alibaba.fastjson.JSONObject.toJSONString(messageNoticeSetting);
        redisTemplate.opsForValue().set(key,response);
    }
    /**
     * 获取消息提示开关
     * @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;
    }
}

+ 6 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/physicalExamination/PhysicalExaminationRemindService.java

@ -336,13 +336,13 @@ public class PhysicalExaminationRemindService extends BaseService {
        Boolean flag = true;
        // 推送消息给微信端
        String url = "jkda/html/jiankangtijian.html?openid=" + patient.getOpenid() +"&toUser="+patient.getCode()+"&toName=" + patient.getName();
        String first = "您的家庭医生" + doctName + "提醒,您可以到签约社区进行免费的健康体检啦~";
        String first = "您的家庭医生" + doctName + "提醒,您可以到签约社区进行65岁以上老年人的免费健康体检啦~";
        JSONObject json = new org.json.JSONObject();
        json.put("first",first);
        json.put("url",url);
        json.put("keyword1", "健康体检");
        json.put("keyword2", format.format(new Date()));
        json.put("remark", "为了您和您的家庭医生了解您近期的健康状况,请及时到您签约的社区体检哟~");
        json.put("remark", "为了您和您的家庭医生了解您近期的健康状况,请及时到您签约的社区体检哟~(如已体检请忽略)");
        if (StringUtils.isNotBlank(patient.getOpenid())) {
            pushMsgTask.putWxMsg(accessToken, 11, patient.getOpenid(), patient.getName(), json);
            flag = false;
@ -372,7 +372,7 @@ public class PhysicalExaminationRemindService extends BaseService {
        }
//        微信发送失败发送短信
        if (flag && StringUtils.isNotEmpty(mobile)) {
            smsService.sendMsg(mobile, "厦门i健康家庭医生温馨提醒,您已经超过一年没有到社区进行健康体检啦,为了您和您的家庭医生了解您近期的健康状况,请及时到签约社区进行免费的健康体检");
            smsService.sendMsg(mobile, "厦门i健康家庭医生温馨提醒,您已经超过一年没有到社区进行健康体检啦,为了您和您的家庭医生了解您近期的健康状况,请及时到签约社区进行免费的健康体检(如已体检请忽略)");
        }
        //保存发送提醒
@ -401,7 +401,7 @@ public class PhysicalExaminationRemindService extends BaseService {
        JSONObject json = new org.json.JSONObject();
        json.put("keyword1", "健康体检");
        json.put("keyword2", format.format(new Date()));
        json.put("remark", "为了您和您的家庭医生了解您近期的健康状况,请及时到您签约的社区体检哟~");
        json.put("remark", "为了您和您的家庭医生了解您近期的健康状况,请及时到您签约的社区体检哟~(如已体检请忽略)");
        Calendar c = Calendar.getInstance();
        c.setTime(new Date());
@ -410,7 +410,7 @@ public class PhysicalExaminationRemindService extends BaseService {
        List<Patient> patients = patientDao.findExaminationRemind(teamId, yesteryear);
        for (Patient patient : patients) {
            String url = "jkda/html/jiankangtijian.html?openid=" + patient.getOpenid() +"&toUser="+patient.getCode()+"&toName=" + patient.getName();
            String first = "您的家庭医生" + doctName + "提醒,您可以到签约社区进行免费的健康体检啦~";
            String first = "您的家庭医生" + doctName + "提醒,您可以到签约社区进行65岁以上老年人的免费健康体检啦~";
            json.put("first",first);
            json.put("url",url);
            String mobile = patient.getMobile();
@ -447,7 +447,7 @@ public class PhysicalExaminationRemindService extends BaseService {
            }
            //        微信发送失败发送短信
            if (flag && StringUtils.isNotEmpty(mobile)) {
                smsService.sendMsg(mobile, "厦门i健康家庭医生温馨提醒,您已经超过一年没有到社区进行健康体检啦,为了您和您的家庭医生了解您近期的健康状况,请及时到签约社区进行免费的健康体检");
                smsService.sendMsg(mobile, "厦门i健康家庭医生温馨提醒,您已经超过一年没有到社区进行健康体检啦,为了您和您的家庭医生了解您近期的健康状况,请及时到签约社区进行免费的健康体检(如已体检请忽略)");
            }
            flag = true;
            //保存发送提醒

+ 94 - 18
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java

@ -5,9 +5,11 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.charge.PatientPopups;
import com.yihu.wlyy.entity.charge.WlyyCharge;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.patient.Patient;
@ -16,18 +18,20 @@ import com.yihu.wlyy.entity.patient.prescription.*;
import com.yihu.wlyy.entity.ylz.PayConfigura;
import com.yihu.wlyy.entity.zydict.ZyPushLog;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.charge.PopupsDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.prescription.*;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.prescription.PrescriptionExpressageDao;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.repository.prescription.PrescriptionPayDao;
import com.yihu.wlyy.repository.ylz.PayConfiguraDao;
import com.yihu.wlyy.repository.zydict.ZyPushLogDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.third.httplog.LogService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.third.ylz.PayLogService;
import com.yihu.wlyy.service.weixin.wxpay.model.BindCard;
import com.yihu.wlyy.service.weixin.wxpay.model.Charge;
@ -92,7 +96,8 @@ public class PatientPrescriptionPayService extends BaseService {
    private HttpClientUtil httpClientUtil;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private MessageService messageService;
    //    引入实例
    @Autowired
    private PayConfiguraDao configuraDao;
@ -130,6 +135,8 @@ public class PatientPrescriptionPayService extends BaseService {
    private PushMsgTask pushMsgTask;
    @Autowired
    private PrescriptionDispensaryCodeService codeService;
    @Autowired
    private PopupsDao popupsDao;
    /**
     * 长处方配送信息查询接口
@ -754,11 +761,13 @@ public class PatientPrescriptionPayService extends BaseService {
                            message.setState(1);//已发送
                            message.setCzrq(new Date());
                            messageDao.save(message);
                            try {
                                //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                                Doctor doctor = doctorDao.findByCode(receiver);
                                String doctorOpenID = doctor.getOpenid();
                                if (StringUtils.isNotEmpty(doctorOpenID)) {
                            if(messageService.getMessageNoticeSettingByMessageType(receiver,"1", MessageNoticeSetting.MessageTypeEnum.prescriptionSwitch.getValue())){
                                try {
                                    //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                                    Doctor doctor = doctorDao.findByCode(receiver);
                                    String doctorOpenID = doctor.getOpenid();
                                    if (StringUtils.isNotEmpty(doctorOpenID)) {
                                        String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                                        List<NameValuePair> sendParams = new ArrayList<>();
                                        sendParams.add(new BasicNameValuePair("type", "9"));
@ -770,9 +779,10 @@ public class PatientPrescriptionPayService extends BaseService {
                                        sendParams.add(new BasicNameValuePair("keywords", keywords));
                                        httpClientUtil.post(url, sendParams, "UTF-8");
                                    }
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                        //支付成功生成二维码
@ -1052,7 +1062,7 @@ public class PatientPrescriptionPayService extends BaseService {
            String resName = "";
            String resSsc = "";
            String resIdNo = "";
            if (!patient.equals(repUid)){
            if (!patient.equals(repUid)) {
                List<BindCard> bindCard = onePayService.bindCardList(openid);
                for (BindCard cards : bindCard) {
                    String attachCardNo = cards.getAttachCardNo();
@ -1067,7 +1077,7 @@ public class PatientPrescriptionPayService extends BaseService {
                    resultMap.put("status", "-1");
                    return resultMap;
                }
            }else {
            } else {
                logger.info("================================>" + "after get BindCard");
//            验证续方人与绑卡人(或代理人)是否一致
                if (!(payName.equals(name) && paySsc.equals(ssc) && payIdcard.equals(idNo))) {
@ -1121,14 +1131,14 @@ public class PatientPrescriptionPayService extends BaseService {
            String visitNo = prescription.getVisitNo();//续方挂号号
            String recipeNo = prescription.getRecipeNo();//基位处方code(开方成功后返回)
            JSONObject jsonParams = null;
            if (!patient.equals(repUid)){
            if (!patient.equals(repUid)) {
                logger.debug("======================> getPayInfo " + resSsc + visitNo);
                if (visitNo == null || resSsc == null || recipeNo == null) {
                    resultMap.put("status", "-2");
                    return resultMap;
                }
                jsonParams = prescriptionService.getPayInfo(resSsc, visitNo, recipeNo);
            }else{
            } else {
                logger.debug("======================> getPayInfo " + ssc + visitNo);
                if (visitNo == null || ssc == null || recipeNo == null) {
                    resultMap.put("status", "-2");
@ -1175,10 +1185,10 @@ public class PatientPrescriptionPayService extends BaseService {
                        principalCardNo = repSsc;
                    }
                }
                if (StringUtils.isNotEmpty(principalCardNo)){
                if (StringUtils.isNotEmpty(principalCardNo)) {
                    map.put("principalCardNo", principalCardNo); //实际签约卡号( 默认为绑卡主体卡号)
                    prescriptionPay.setPrincipalCardNo(principalCardNo);
                }else {
                } else {
                    resultMap.put("status", "-4");
                    return resultMap;
                }
@ -1553,5 +1563,71 @@ public class PatientPrescriptionPayService extends BaseService {
        return result;
    }
    /**
     * 保存及修改居民支付弹窗设置
     *
     * @param type    弹窗类型
     * @param patient 支付主体code
     * @param status  弹窗状态
     * @return
     * @throws Exception
     */
    public void savePopups(int type, String patient, String status) throws Exception {
        try {
            Date today = new Date();
            PatientPopups popups = popupsDao.findByCodeAndType(patient, type);
            if (popups == null) {
                popups = new PatientPopups();
                popups.setPatient(patient);
                popups.setType(type);
                popups.setCreateTime(today);
            }
            popups.setStatus(status);
            popups.setCzrq(today);
            popupsDao.save(popups);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 查询居民支付弹窗设置
     *
     * @param type    弹窗类型
     * @param patient 支付主体code
     * @return
     * @throws Exception
     */
    public PatientPopups getPopups(int type, String patient) throws Exception {
        PatientPopups popups = null;
        try {
            popups = popupsDao.findByCodeAndType(patient, type);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return popups;
    }
    /**
     * 查询缴费居民手机绑定情况
     *
     * @param user 需要缴费的患者code(共济支付为被代理人)
     * @return
     * @throws Exception
     */
    public String getPatientMobile(String user) throws Exception {
        String mobile = null;
        try {
            Patient patient = patientDao.findByCode(user);
            if (patient != null) {
                mobile = patient.getMobile();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return mobile;
    }
}

+ 26 - 20
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -5,6 +5,7 @@ import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.followup.Followup;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.prescription.*;
@ -17,6 +18,7 @@ import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.prescription.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.system.Icd10DictServcie;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.util.DateUtil;
@ -111,6 +113,8 @@ public class PrescriptionInfoService extends BaseService {
	private String targetUrl;
	@Autowired
	private HttpClientUtil httpClientUtil;
    @Autowired
    private MessageService messageService;
    private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
@ -691,27 +695,29 @@ public class PrescriptionInfoService extends BaseService {
                p.setPrescribeTime(new Date());
                prescriptionDao.save(p);
                try {
                    //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                    Doctor doctor = doctorDao.findByCode(p.getDoctor());
                    String doctorOpenID = doctor.getOpenid();
                    if (StringUtils.isNotEmpty(doctorOpenID)) {
                        String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                        List<NameValuePair> params = new ArrayList<>();
                        params.add(new BasicNameValuePair("type", "1"));
                        params.add(new BasicNameValuePair("openId", doctorOpenID));
                        params.add(new BasicNameValuePair("url", targetUrl));
                        params.add(new BasicNameValuePair("first", doctor.getName() + "医生您好。您有一个您有1个续方申请处方开立失败。"));
                        params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                        SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                        String date = format.format(new Date());
                        String keywords = doctor.getName() +","+ p.getPatientName() +"," + date;
                        params.add(new BasicNameValuePair("keywords", keywords));
                        httpClientUtil.post(url, params, "UTF-8");
                if(messageService.getMessageNoticeSettingByMessageType(p.getDoctor(),"1", MessageNoticeSetting.MessageTypeEnum.prescriptionSwitch.getValue())){
                    try {
                        //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                        Doctor doctor = doctorDao.findByCode(p.getDoctor());
                        String doctorOpenID = doctor.getOpenid();
                        if (StringUtils.isNotEmpty(doctorOpenID)) {
                            String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                            List<NameValuePair> params = new ArrayList<>();
                            params.add(new BasicNameValuePair("type", "1"));
                            params.add(new BasicNameValuePair("openId", doctorOpenID));
                            params.add(new BasicNameValuePair("url", targetUrl));
                            params.add(new BasicNameValuePair("first", doctor.getName() + "医生您好。您有一个您有1个续方申请处方开立失败。"));
                            params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                            SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                            String date = format.format(new Date());
                            String keywords = doctor.getName() +","+ p.getPatientName() +"," + date;
                            params.add(new BasicNameValuePair("keywords", keywords));
                            httpClientUtil.post(url, params, "UTF-8");
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return 0;
            }

+ 7 - 76
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java

@ -6,7 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
import com.yihu.wlyy.entity.followup.Followup;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionDiagnosis;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
@ -20,6 +20,7 @@ import com.yihu.wlyy.repository.prescription.PrescriptionDiagnosisDao;
import com.yihu.wlyy.repository.prescription.PrescriptionExpressageDao;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.CommonUtil;
@ -77,7 +78,8 @@ public class PrescriptionService extends BaseService {
    private JpaTransactionManager transactionManager;
    @Autowired
    private FollowUpDao followUpDao;
    @Autowired
    private MessageService messageService;
    /**
     *  获取处方信息
@ -88,79 +90,7 @@ public class PrescriptionService extends BaseService {
        return prescriptionDao.findByCode(prescriptionCode);
    }
    /**
     * redis 消息队列
     * @param message
     */
    public void redisMessage(String message){
        logger.info("redis_onMessage...:"+message);
        //this.unsubscribe();
        try{
            JSONObject json = JSONObject.parseObject(message);
            String title =  json.getString("title");
            if("dispensingComplete".equals(title)){//配药完成
                //药品配送完成,提醒取药
                String prescriptionCode = json.getString("prescription");
                dispensingComplete(prescriptionCode);
            }
        }catch (Exception e){
            logger.error("redis_error...",e);
        }
    }
    /**
     * 配药完成
     * @param code
     */
    public void dispensingComplete(String code){
        logger.info("配药完成,提示居民或健管师取药:"+code);
        Prescription prescription = prescriptionDao.findByCode(code);
        if(prescription.getStatus().equals(PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue())){//等待领药
            if(prescription.getDispensaryType()==1){
                //自取
                Patient patient = patientDao.findByCode(prescription.getPatient());
                try {
//                    String dispensaryCode = prescriptionDispensaryCodeDao.getCodeByPrescriptionCodeAndType(code,1);
                    StringBuffer url = new StringBuffer();
                    url.append("/wx/prescription/html/code-detail.html?prescriptionCode=").append(code);
                    url.append("&openid=").append(patient.getOpenid());
                    url.append("&toUser=").append(patient.getCode());
                    url.append("&toName=").append(patient.getName());
                    url.append("&represented=").append(patient.getCode());
                    prescriptionNoticesService.sendMessages(prescription.getPatient(), null, null, 2, 0, url.toString());
                }catch (Exception e){
                    logger.info("微信模板发送失败,续方code"+code);
                }
            }else if(prescription.getDispensaryType()==3){
                //健管师配送
                PrescriptionExpressage expressage = prescriptionExpressageDao.findByPrescriptionCode(code);
                if(StringUtils.isNotBlank(expressage.getExpressageCode())){
                    String content = "您有一条新的续方订单待取药!";
                    Message message = new Message();
                    message.setCzrq(new Date());
                    message.setCreateTime(new Date());
                    message.setRead(1);//设置未读
                    message.setOver("1");
                    message.setReceiver(expressage.getExpressageCode());
                    message.setSender("system");
                    message.setCode(getCode());
                    message.setSenderName("系统");
                    message.setTitle("居民"+prescription.getPatientName()+"的续方订单待取药");
                    message.setContent("您有一条新的续方订单待取药!");
                    message.setType(7);//续方订单待取药
                    message.setReadonly(1);//是否只读消息
                    message.setDel("1");
                    message.setRelationCode(prescription.getCode());
                    message.setPrescriptionStatus("0");//待取药
                    message.setData(prescription.getAdminTeamId()+"");
                    messageDao.save(message);
                    pushMsgTask.put(expressage.getExpressageCode(), MessageType.MESSAGE_TYPE_PRESCRIPTION_WAIT_TAKE_DRUG.D_P_WRD.name(), MessageType.MESSAGE_TYPE_PRESCRIPTION_WAIT_TAKE_DRUG.续方消息.name(), content, prescription.getCode());
                }
            }
        }
        logger.info("配药完成,提示居民或健管师取药:"+code+",status="+prescription.getStatus());
    }
    /**
     * 提醒健管师待取药
@ -197,8 +127,9 @@ public class PrescriptionService extends BaseService {
                        DoctorTeam dt = doctorTeamDao.findByParientCode(prescription.getPatient());
                        message.setData(dt.getCode());
                        messageDao.save(message);
                        pushMsgTask.put(expressage.getExpressageCode(), MessageType.MESSAGE_TYPE_PRESCRIPTION_WAIT_TAKE_DRUG.D_P_WRD.name(), MessageType.MESSAGE_TYPE_PRESCRIPTION_WAIT_TAKE_DRUG.续方消息.name(), content, prescription.getCode());
                        if(messageService.getMessageNoticeSettingByMessageType(expressage.getExpressageCode(),"1", MessageNoticeSetting.MessageTypeEnum.prescriptionSwitch.getValue())){
                            pushMsgTask.put(expressage.getExpressageCode(), MessageType.MESSAGE_TYPE_PRESCRIPTION_WAIT_TAKE_DRUG.D_P_WRD.name(), MessageType.MESSAGE_TYPE_PRESCRIPTION_WAIT_TAKE_DRUG.续方消息.name(), content, prescription.getCode());
                        }
                    }
                }
            }

+ 102 - 90
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -11,6 +11,7 @@ import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.*;
import com.yihu.wlyy.logs.BusinessLogs;
@ -625,26 +626,28 @@ public class FamilyContractService extends BaseService {
            messageDao.save(message);
            // 发送消息给医生
            // 发送消息给医生
            JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
            if (jsonObject.getString("status").equals("1")) {
                //如果在工作时间内就推送
                pushMsgTask.put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.D_SW_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.家庭签约.name(), "您有一条新的家庭签约申请!", patient);
            }
            if(messageService.getMessageNoticeSettingByMessageType(doctor,"1", MessageNoticeSetting.MessageTypeEnum.signSwitch.getValue())){
                JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
                if (jsonObject.getString("status").equals("1")) {
                    //如果在工作时间内就推送
                    pushMsgTask.put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.D_SW_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.家庭签约.name(), "您有一条新的家庭签约申请!", patient);
                }
//            新增发送医生助手模板消息 v1.4.0 by wujunjie
            if (StringUtils.isNotEmpty(d.getOpenid())){
                String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                List<NameValuePair> params = new ArrayList<>();
                params.add(new BasicNameValuePair("type", "5"));
                params.add(new BasicNameValuePair("openId", d.getOpenid()));
                params.add(new BasicNameValuePair("url", targetUrl));
                params.add(new BasicNameValuePair("first", d.getName() + "医生您好,你有一条新的签约申请待处理"));
                params.add(new BasicNameValuePair("remark", "请尽快使用厦门i健康APP处理居民的签约申请"));
                SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                String date = format.format(new Date());
                String keywords = date + "," + p.getName();
                params.add(new BasicNameValuePair("keywords", keywords));
                httpClientUtil.post(url, params, "UTF-8");
                if (StringUtils.isNotEmpty(d.getOpenid())){
                    String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                    List<NameValuePair> params = new ArrayList<>();
                    params.add(new BasicNameValuePair("type", "5"));
                    params.add(new BasicNameValuePair("openId", d.getOpenid()));
                    params.add(new BasicNameValuePair("url", targetUrl));
                    params.add(new BasicNameValuePair("first", d.getName() + "医生您好,你有一条新的签约申请待处理"));
                    params.add(new BasicNameValuePair("remark", "请尽快使用厦门i健康APP处理居民的签约申请"));
                    SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                    String date = format.format(new Date());
                    String keywords = date + "," + p.getName();
                    params.add(new BasicNameValuePair("keywords", keywords));
                    httpClientUtil.post(url, params, "UTF-8");
                }
            }
        }
        json.put("id", p.getId());
@ -740,32 +743,34 @@ public class FamilyContractService extends BaseService {
            message.setData(temp.getCode());
            messageDao.save(message);
            try {
                // 发送消息给医生
                JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
                if (jsonObject.getString("status").equals("1")) {
                    //如果在工作时间内就推送
                    pushMsgTask.put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.D_SW_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.家庭签约.name(), "您有一条新的家庭签约申请!", patient);
            if(messageService.getMessageNoticeSettingByMessageType(doctor,"1",MessageNoticeSetting.MessageTypeEnum.signSwitch.getValue())){
                try {
                    // 发送消息给医生
                    JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
                    if (jsonObject.getString("status").equals("1")) {
                        //如果在工作时间内就推送
                        pushMsgTask.put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.D_SW_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.家庭签约.name(), "您有一条新的家庭签约申请!", patient);
                    }
                }catch (Exception e){
                    logger.info("发送医生消息失败:"+e.getMessage());
                }
            }catch (Exception e){
                logger.info("发送医生消息失败:"+e.getMessage());
            }
            //            新增发送医生助手模板消息 v1.4.0 by wujunjie
            if (StringUtils.isNotEmpty(d.getOpenid())){
                String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                List<NameValuePair> params = new ArrayList<>();
                params.add(new BasicNameValuePair("type", "5"));
                params.add(new BasicNameValuePair("openId", d.getOpenid()));
                params.add(new BasicNameValuePair("url", targetUrl));
                params.add(new BasicNameValuePair("first", d.getName() + "医生您好,你有一条新的签约申请待处理"));
                params.add(new BasicNameValuePair("remark", "请尽快使用厦门i健康APP处理居民的签约申请"));
                SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                String date = format.format(new Date());
                String keywords = date + "," + p.getName();
                params.add(new BasicNameValuePair("keywords", keywords));
                httpClientUtil.post(url, params, "UTF-8");
                //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                if (StringUtils.isNotEmpty(d.getOpenid())){
                    String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                    List<NameValuePair> params = new ArrayList<>();
                    params.add(new BasicNameValuePair("type", "5"));
                    params.add(new BasicNameValuePair("openId", d.getOpenid()));
                    params.add(new BasicNameValuePair("url", targetUrl));
                    params.add(new BasicNameValuePair("first", d.getName() + "医生您好,你有一条新的签约申请待处理"));
                    params.add(new BasicNameValuePair("remark", "请尽快使用厦门i健康APP处理居民的签约申请"));
                    SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                    String date = format.format(new Date());
                    String keywords = date + "," + p.getName();
                    params.add(new BasicNameValuePair("keywords", keywords));
                    httpClientUtil.post(url, params, "UTF-8");
                }
            }
        }
@ -901,11 +906,13 @@ public class FamilyContractService extends BaseService {
        message.setReason(reason);
        message.setData(signFamily.getCode());
        messageDao.save(message);
        // 发送消息给医生
        JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
        if (jsonObject.getString("status").equals("1")) {
            //如果在工作时间内就推送
            pushMsgTask.put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_SIGN_WEB_RELIEVE.D_SW_02.name(), MessageType.MESSAGE_TYPE_DOCTOR_SIGN_WEB_RELIEVE.家庭签约.name(), patientName + " 申请解除与您的家庭签约!", patient);
        if(messageService.getMessageNoticeSettingByMessageType(doctor,"1",MessageNoticeSetting.MessageTypeEnum.signSwitch.getValue())){
            // 发送消息给医生
            JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
            if (jsonObject.getString("status").equals("1")) {
                //如果在工作时间内就推送
                pushMsgTask.put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_SIGN_WEB_RELIEVE.D_SW_02.name(), MessageType.MESSAGE_TYPE_DOCTOR_SIGN_WEB_RELIEVE.家庭签约.name(), patientName + " 申请解除与您的家庭签约!", patient);
            }
        }
        return 1;
    }
@ -3534,27 +3541,29 @@ public class FamilyContractService extends BaseService {
            message.setOver("1");//未处理
            message.setData(sf.getCode());
            messageDao.save(message);
            // 发送消息给医生
            JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
            if (jsonObject.getString("status").equals("1")) {
                //如果在工作时间内就推送
                pushMsgTask.put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.D_SW_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.家庭签约.name(), p.getName() + "申请与您续签家庭医生", patient);
            }
            //            新增发送医生助手模板消息 v1.4.0 by wujunjie
            if (StringUtils.isNotEmpty(d.getOpenid())){
                String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                List<NameValuePair> params = new ArrayList<>();
                params.add(new BasicNameValuePair("type", "5"));
                params.add(new BasicNameValuePair("openId", d.getOpenid()));
                params.add(new BasicNameValuePair("url", targetUrl));
                params.add(new BasicNameValuePair("first", d.getName() + "医生您好,你有一条新的签约申请待处理"));
                params.add(new BasicNameValuePair("remark", "请尽快使用厦门i健康APP处理居民的签约申请"));
                SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                String date = format.format(new Date());
                String keywords = date + "," + p.getName();
                params.add(new BasicNameValuePair("keywords", keywords));
                httpClientUtil.post(url, params, "UTF-8");
            if(messageService.getMessageNoticeSettingByMessageType(doctor,"1",MessageNoticeSetting.MessageTypeEnum.signSwitch.getValue())){
                // 发送消息给医生
                JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
                if (jsonObject.getString("status").equals("1")) {
                    //如果在工作时间内就推送
                    pushMsgTask.put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.D_SW_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.家庭签约.name(), p.getName() + "申请与您续签家庭医生", patient);
                }
                //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                if (StringUtils.isNotEmpty(d.getOpenid())){
                    String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                    List<NameValuePair> params = new ArrayList<>();
                    params.add(new BasicNameValuePair("type", "5"));
                    params.add(new BasicNameValuePair("openId", d.getOpenid()));
                    params.add(new BasicNameValuePair("url", targetUrl));
                    params.add(new BasicNameValuePair("first", d.getName() + "医生您好,你有一条新的签约申请待处理"));
                    params.add(new BasicNameValuePair("remark", "请尽快使用厦门i健康APP处理居民的签约申请"));
                    SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                    String date = format.format(new Date());
                    String keywords = date + "," + p.getName();
                    params.add(new BasicNameValuePair("keywords", keywords));
                    httpClientUtil.post(url, params, "UTF-8");
                }
            }
        }
@ -3746,27 +3755,30 @@ public class FamilyContractService extends BaseService {
            message.setOver("1");//未处理
            message.setData(sf.getCode());
            messageDao.save(message);
            // 发送消息给医生
            JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
            if (jsonObject.getString("status").equals("1")) {
                //如果在工作时间内就推送
                pushMsgTask.put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.D_SW_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.家庭签约.name(), p.getName() + "申请与您续签家庭医生", patient);
            }
            //            新增发送医生助手模板消息 v1.4.0 by wujunjie
            if (StringUtils.isNotEmpty(d.getOpenid())){
                String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                List<NameValuePair> params = new ArrayList<>();
                params.add(new BasicNameValuePair("type", "5"));
                params.add(new BasicNameValuePair("openId", d.getOpenid()));
                params.add(new BasicNameValuePair("url", targetUrl));
                params.add(new BasicNameValuePair("first", d.getName() + "医生您好,你有一条新的签约申请待处理"));
                params.add(new BasicNameValuePair("remark", "请尽快使用厦门i健康APP处理居民的签约申请"));
                SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                String date = format.format(new Date());
                String keywords = date + "," + p.getName();
                params.add(new BasicNameValuePair("keywords", keywords));
                httpClientUtil.post(url, params, "UTF-8");
            if(messageService.getMessageNoticeSettingByMessageType(doctor,"1",MessageNoticeSetting.MessageTypeEnum.signSwitch.getValue())){
                // 发送消息给医生
                JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
                if (jsonObject.getString("status").equals("1")) {
                    //如果在工作时间内就推送
                    pushMsgTask.put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.D_SW_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.家庭签约.name(), p.getName() + "申请与您续签家庭医生", patient);
                }
                //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                if (StringUtils.isNotEmpty(d.getOpenid())){
                    String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                    List<NameValuePair> params = new ArrayList<>();
                    params.add(new BasicNameValuePair("type", "5"));
                    params.add(new BasicNameValuePair("openId", d.getOpenid()));
                    params.add(new BasicNameValuePair("url", targetUrl));
                    params.add(new BasicNameValuePair("first", d.getName() + "医生您好,你有一条新的签约申请待处理"));
                    params.add(new BasicNameValuePair("remark", "请尽快使用厦门i健康APP处理居民的签约申请"));
                    SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                    String date = format.format(new Date());
                    String keywords = date + "," + p.getName();
                    params.add(new BasicNameValuePair("keywords", keywords));
                    httpClientUtil.post(url, params, "UTF-8");
                }
            }
        }

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

@ -3,6 +3,7 @@ package com.yihu.wlyy.service.app.sign;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.patient.PatientDao;
@ -202,6 +203,15 @@ public class PatientRemindService extends BaseService {
            boolean isMobileExist = false;
            boolean isOpenIdExist = false;
            //过滤只提醒已签约未扣费居民 by wujunjie 2017.11.29
            SignFamily signFamily = signFamilyDao.findUnpay(p.getCode());
            if (signFamily == null){
                JSONObject response = new JSONObject();
                response.put("status", -1);
                response.put("msg", "未找到该居民已签约未缴费信息!");
                return response;
            }
            if (StringUtils.isNotEmpty(p.getMobile())) {
                isMobileExist = true;
                JSONObject result = smsService.sendMsg(p.getMobile(), doc.getName() + "医生提醒您:为完成家庭医生签约," +
@ -213,7 +223,6 @@ public class PatientRemindService extends BaseService {
                    mDesc = result.getString("description");
                }
            }
//            if (StringUtils.isNotEmpty(p.getOpenid())) {
            // 微信提醒
            JSONObject json = new JSONObject();
@ -234,17 +243,6 @@ public class PatientRemindService extends BaseService {
                pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 8, p.getOpenid(), p.getName(), json);
                wFlag = true;
            }
//                else{
//                    JSONObject j  = weiXinOpenIdUtils.getFamilyOpenId(p.getCode());
//                    Patient member = (Patient) j.get("member");
//                    if(StringUtils.isNotBlank(member.getOpenid())){
//                        isOpenIdExist = true;
//                        String first = (String) json.get("doctorName");
//                        json.remove("doctorName");
//                        json.put("doctorName",weiXinOpenIdUtils.getTitleMes(p,j.getInt("relation"),member.getName())+"\n"+first);
//                        PushMsgTask.getInstance().putWxMsg(tokenUtils.getAccessToken(), 8, member.getOpenid(), member.getName(), json);
//                    }
//                }
            //发送代理人
            JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(p.getCode(),p.getOpenid());
            if(jsonArray!=null&&jsonArray.length()>0){
@ -264,7 +262,6 @@ public class PatientRemindService extends BaseService {
            }
//            }
            //发送IM
            consultService.sendMucMessageBySingnType(doc.getCode(), doc.getName(), p.getCode(), doc.getName() + "医生提醒您:为完成家庭医生签约," +
                    "尽早为您提供家庭医生服务,请尽快到" + hos.getName() + "(地址:" + hos.getAddress() + ")缴费", "1",p.getName());

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

@ -2625,7 +2625,7 @@ public class SignWebService extends BaseService {
    public JSONObject getSickFamilyDoctorSignLimit(String doctorCode){
        JSONObject re = new JSONObject();//0未达上线 1 已达上限
        Integer signTotal = 0;
        Integer limitTotal = 0;
        Integer limitTotal = 1500;
        List<AdminTeam> adminTeams = doctorAdminTeamMemberDao.findDoctorTeams(doctorCode);
        for(AdminTeam one:adminTeams){
            //获取团队签约数

+ 328 - 45
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java

@ -2711,10 +2711,10 @@ public class StatisticsESService {
        if (StringUtils.isEmpty(lowCode)) {
            //续签量
            renewSaveModels = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index, "2", "", low_level);
            renewSaveModels = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index, SaveModel.timeLevel_DDL, "", low_level);
        } else {
            //续签量
            renewSaveModels = elasticsearchUtil.findDateQuotaLevel1(timeKey,timeKey, area, level, index, "2", lowCode, "", low_level);
            renewSaveModels = elasticsearchUtil.findDateQuotaLevel1(timeKey,timeKey, area, level, index, SaveModel.timeLevel_DDL, lowCode, "", low_level);
        }
@ -2740,9 +2740,9 @@ public class StatisticsESService {
            //查询去年的签约转map
            List<SaveModel> yearsList = new ArrayList();
            if (StringUtils.isBlank(lowCode)) {
                yearsList = elasticsearchUtil.findDateQuotaLevel0(lastDate, lastDate, area, level, "1", "2", "", low_level);
                yearsList = elasticsearchUtil.findDateQuotaLevel0(lastDate, lastDate, area, level, "1", SaveModel.timeLevel_DDL, "", low_level);
            } else {
                yearsList = elasticsearchUtil.findDateQuotaLevel1(lastDate, lastDate, area, level, "17", "2", lowCode, "", low_level);
                yearsList = elasticsearchUtil.findDateQuotaLevel1(lastDate, lastDate, area, level, "17", SaveModel.timeLevel_DDL, lowCode, "", low_level);
            }
            Map<String, SaveModel> resultMap = new HashMap<>();
@ -4272,21 +4272,27 @@ public class StatisticsESService {
            totalModelList = (List<SaveModel>) elasticsearchUtil.findListDateQuotaLevel0(date, area, level, "1", SaveModel.timeLevel_DDL, low_level);
        }
        Map<String, Object> signOnlineMap = new HashMap<String, Object>();
        if (esModelList != null && esModelList.size() > 0) {
            for (SaveModel one : esModelList) {
                Map<String, Object> maps = new HashMap<String, Object>();
                maps.put("amount", one.getResult2().intValue());
                //signOnlineMap.put("amount", one.getResult2().intValue());
                /*if (low_level.equals("3") && one.getTown() != null) {
                    signOnlineMap.put("code", one.getTown());
                    signOnlineMap.put("name", one.getTownName());
                } else if (low_level.equals("4") && one.getHospital() != null) {
                    signOnlineMap.put("code", one.getHospital());
                    signOnlineMap.put("name", one.getHospitalName());
                } else if (low_level.equals("5") && one.getTeam() != null) {
                    signOnlineMap.put("code", one.getTeam());
                    signOnlineMap.put("name", one.getTeamName());
                }*/
                if (low_level.equals("3") && one.getTown() != null) {
                    maps.put("code", one.getTown());
                    maps.put("name", one.getTownName());
                    signOnlineMap.put(one.getTown(), one.getResult2().intValue());
                } else if (low_level.equals("4") && one.getHospital() != null) {
                    maps.put("code", one.getHospital());
                    maps.put("name", one.getHospitalName());
                    signOnlineMap.put(one.getHospital(), one.getResult2().intValue());
                } else if (low_level.equals("5") && one.getTeam() != null) {
                    maps.put("code", one.getTeam());
                    maps.put("name", one.getTeamName());
                    signOnlineMap.put(one.getTeam(), one.getResult2().intValue());
                }
                resultList.add(maps);
            }
        }
@ -4294,39 +4300,39 @@ public class StatisticsESService {
        if (resultList == null || resultList.size() < 1) {
            resultList = getLowLevelMapKey(level, low_level, area);
        }
        if (resultList != null) {
            DecimalFormat df = new DecimalFormat("0.0000");
            for (int i = 0; i < resultList.size(); i++) {
                Map<String, Object> map = resultList.get(i);
                long signOnline =Long.valueOf(String.valueOf(map.get("amount")));
                map.put("amount", map.get("amount") != null ? signOnline : 0L);
                for (SaveModel totalOne : totalModelList) {
                    if (low_level.equals("3") && String.valueOf(map.get("code")).equals(totalOne.getTown())) {
                        map.put("signAmount",totalOne.getResult2().longValue());
                        map.put("rate",df.format(signOnline*1.0/totalOne.getResult2().longValue()*1000));
                    } else if (low_level.equals("4") &&  String.valueOf(map.get("code")).equals(totalOne.getHospital())) {
                        map.put("signAmount",totalOne.getResult2().longValue());
                        map.put("rate",df.format(signOnline*1.0/totalOne.getResult2().longValue()*1000));
                    } else if (low_level.equals("5") && totalOne.getTeam() != null) {
                        map.put("signAmount",totalOne.getResult2().longValue());
                        map.put("rate",df.format(signOnline*1.0/totalOne.getResult2().longValue()*1000));
                    }
        if (resultList != null && resultList.size()>0) {
            //查询今年的线上续签转map
            Map<String, SaveModel> resultMap = new HashMap<>();
            totalModelList.stream().forEach(one->{
                if ("5".equals(low_level)) {
                    resultMap.put(one.getTeam(), one);
                } else if ("4".equals(low_level)) {
                    resultMap.put(one.getHospital(), one);
                } else if ("3".equals(low_level)) {
                    resultMap.put(one.getTown(), one);
                }
            });
                /*if (!low_level.equals("5")) {
                    String code = String.valueOf(map.get("code"));
                    PopulationBase peopleNum = getPopulationBase(code, year);
                    if (peopleNum != null) {
                        map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getNum() * 100));
                        map.put("taskRate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getTaskNum() * 100));
                        map.put("targetRate", df.format(peopleNum.getTaskNum() * 1.0000 / peopleNum.getNum() * 100));
                        map.put("rateString", map.get("amount") + "/" + peopleNum.getNum());
                        map.put("taskRateString", map.get("amount") + "/" + peopleNum.getTaskNum());
                        map.put("targetRateString", peopleNum.getTaskNum() + "/" + peopleNum.getNum());
                        map.put("num", peopleNum.getNum());
                        map.put("task", peopleNum.getTaskNum());
            for (Map<String, Object> reMap : resultList) {
                reMap.put("amount", reMap.get("amount") != null ? Long.valueOf(reMap.get("amount").toString()) : 0L);
                Integer signNun = 0;
                Integer signOnlineNum = 0;
                //获取签约量
                if (resultMap != null && resultMap.size() > 0) {
                    SaveModel one = resultMap.get(reMap.get("code").toString());
                    if (one != null) {
                        signNun = one.getResult2().intValue();
                    }
                }*/
                }
                if (signOnlineMap != null && signOnlineMap.size() > 0) {
                    signOnlineNum = (Integer) signOnlineMap.get(String.valueOf(reMap.get("code")));
                    if (signOnlineNum == null) {
                        signOnlineNum = 0;
                    }
                }
                reMap.put("signNun", signNun);
                reMap.put("signOnlineNum", signOnlineNum);
                reMap.put("rate", getRange(signOnlineNum, signNun, 2));//线上签约率是 线上签约量/签约量
            }
            if ((level == 2 && "5".equals(lowLevel)) || (level == 4) || (level == 3 && "5".equals(lowLevel))) {
@ -4335,8 +4341,8 @@ public class StatisticsESService {
            Collections.sort(resultList, new Comparator<Map<String, Object>>() {
                public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                    long map1value = (long) o1.get("amount");
                    long map2value = (long) o2.get("amount");
                    long map1value = (long) o1.get("signOnlineNum");
                    long map2value = (long) o2.get("signOnlineNum");
                    if (map1value - map2value > 0) {
                        return sort == 1 ? -1 : 1;
@ -4353,6 +4359,16 @@ public class StatisticsESService {
        }
    }
    /**
     * 线上续签率
     *
     * @param index
     * @param level
     * @param area
     * @param year
     * @param lowCode
     * @return
     */
    public JSONObject getRenewPercentOnline(String index, Integer level, String area, String year, String lowCode) {
        JSONObject jo = new JSONObject();
        String renewOnlineIndex = "";//线上续签index
@ -4441,4 +4457,271 @@ public class StatisticsESService {
        }
        return jo;
    }
    /**
     * 线上续签各等级地区的列表
     * @param area
     * @param level
     * @param index
     * @param sort
     * @param lowLevel
     * @param year
     * @param lowCode
     * @return
     * @throws Exception
     */
    public JSONArray getLevelTwoLowLevelTotalRenewOnline(String area, int level, String index, int sort, String lowLevel, String year, String lowCode) throws Exception {
        String timeKey = elasticsearchUtil.getQuotaTime();
        String low_level = String.valueOf(StringUtils.isEmpty(lowLevel) ? (level + 1) : lowLevel);
        String renewIndex = "";//续签指标
        if (level==3){//区
            if (StringUtils.isNotBlank(lowCode)){
                renewIndex="44";
            }else{
                renewIndex="54";
            }
        }
        if (level==4){//社区
            if (StringUtils.isNotBlank(lowCode)){
                renewIndex="43";
            }else{
                renewIndex="53";
            }
        }
        if (level==5){//团队
            if (StringUtils.isNotBlank(lowCode)){
                renewIndex="42";
            }else{
                renewIndex="52";
            }
        }
        List<Map<String, Object>> resultList = new ArrayList<>();//续签量
        Map<String, Integer> renewMap = new HashMap<>(); //续签的的列表转map
        List<SaveModel> renewSaveModels = new ArrayList<SaveModel>();
        List<SaveModel> renewOnlineList = new ArrayList<SaveModel>();
        if (StringUtils.isEmpty(lowCode)) {
            //续签量
            renewSaveModels = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, renewIndex, SaveModel.timeLevel_DDL, "", low_level);
            //线上续签量
            renewOnlineList = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index, SaveModel.timeLevel_DDL, "", low_level);
        } else {
            //续签量
            renewSaveModels = elasticsearchUtil.findDateQuotaLevel1(timeKey,timeKey, area, level, renewIndex, SaveModel.timeLevel_DDL, lowCode, "", low_level);
            //线上续签量
            renewOnlineList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index, SaveModel.timeLevel_DDL, lowCode, "", low_level);
        }
        if (renewSaveModels != null && renewSaveModels.size() > 0) {
            for (SaveModel saveModel : renewSaveModels) {
                if ("3".equals(low_level) && saveModel.getTown() != null) {
                    renewMap.put(saveModel.getTown(), saveModel.getResult2().intValue());
                } else if ("4".equals(low_level) && saveModel.getHospital() != null) {
                    renewMap.put(saveModel.getHospital(), saveModel.getResult2().intValue());
                } else if ("5".equals(low_level) && saveModel.getTeam() != null) {
                    renewMap.put(saveModel.getTeam(), saveModel.getResult2().intValue());
                } else {
                    continue;
                }
            }
        }
        //自建结果集
        resultList = getLowLevelMapKey(level, low_level, area);
        if (resultList != null && resultList.size() > 0) {
            //查询今年的线上续签转map
            Map<String, SaveModel> resultMap = new HashMap<>();
            renewOnlineList.stream().forEach(one -> {
                if ("5".equals(low_level)) {
                    resultMap.put(one.getTeam(), one);
                } else if ("4".equals(low_level)) {
                    resultMap.put(one.getHospital(), one);
                } else if ("3".equals(low_level)) {
                    resultMap.put(one.getTown(), one);
                }
            });
            for (Map<String, Object> reMap : resultList) {
                reMap.put("amount", reMap.get("amount") != null ? Long.valueOf(reMap.get("amount").toString()) : 0L);
                int renewOnlineNum = 0;
                Integer renewNum = 0;
                //获取线上续签数量
                if (resultMap != null && resultMap.size() > 0) {
                    SaveModel one = resultMap.get(reMap.get("code").toString());
                    if (one != null) {
                        renewOnlineNum = one.getResult2().intValue();
                    }
                }
                if (renewMap != null && renewMap.size() > 0) {
                    renewNum = renewMap.get(reMap.get("code").toString());
                    if (renewNum == null) {
                        renewNum = 0;
                    }
                }
                reMap.put("renewNum", renewNum);
                reMap.put("renewOnlineNum", renewOnlineNum);
                reMap.put("rate", getRange(renewOnlineNum, renewNum, 2));//线上续签率是 线上续签量/续签量
            }
            if ((level == 2 && "5".equals(lowLevel)) || (level == 4) || (level == 3 && "5".equals(lowLevel))) {
                translateTeamLeaderName(resultList);
            }
            //对结果进行排序
            Collections.sort(resultList, new Comparator<Map<String, Object>>() {
                public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                    int map1value = (int) o1.get("renewOnlineNum");
                    int map2value = (int) o2.get("renewOnlineNum");
                    if (map1value - map2value > 0) {
                        return sort == 1 ? -1 : 1;
                    } else if (map1value - map2value < 0) {
                        return sort == 1 ? 1 : -1;
                    } else {
                        return 0;
                    }
                }
            });
            return new JSONArray(resultList);
        } else {
            return new JSONArray();
        }
    }
    /**
     * 居民分析--线上和线下缴费
     * @param level
     * @param area
     * @param year
     * @return
     */
    public JSONObject getSignPayOnline(Integer level, String area, String year) {
        JSONObject jo = new JSONObject();
        String timeKey ="";
        try{
            if (StringUtils.isNotEmpty(year)) {
                if (Constant.getNowYear().equals(year)) {
                    timeKey = elasticsearchUtil.getQuotaTime();
                } else {
                    Integer coutYear = Integer.parseInt(year);
                    timeKey = coutYear + 1 + "-06-30";
                }
            }
            //获取已缴费的总人数
            SaveModel signSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(timeKey,area,level,"1",SaveModel.timeLevel_DDL);
            //获取线上缴费的人数
            SaveModel signPayOnlineSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(timeKey,area,level,"82",SaveModel.timeLevel_DDL);
            int signNum = signSaveModel.getResult2().intValue();
            int signPayOnlineNum = signPayOnlineSaveModel.getResult2().intValue();
            //线下缴费=已缴费的总人数-线上缴费
            int signPayUnderNum = signNum-signPayOnlineNum;
            jo.put("signPayOnlineNum", signPayOnlineNum);//线上缴费数量
            jo.put("signPayUnderNum", signPayUnderNum);//线下缴费数量
            jo.put("signPayOnlineRate", getRange(signPayOnlineNum, signNum, 2));//线上缴费率  50.00%
            jo.put("signPayUnderRate", getRange(signPayUnderNum, signNum, 2));//线下缴费率  50.00%
        } catch (Exception e) {
            e.getMessage();
            jo.put("status", "0");
            jo.put("error", "查询失败" + e.getMessage());
            return jo;
        }
        return jo;
    }
    public JSONArray getLowLevelSignPayOnline(String area, int level, String index, int sort, String lowLevel, String year) throws Exception {
        String timeKey = "";
        if (StringUtils.isNotEmpty(year)) {
            if (Constant.getNowYear().equals(year)) {
                timeKey = elasticsearchUtil.getQuotaTime();
            } else {
                Integer coutYear = Integer.parseInt(year);
                timeKey = coutYear + 1 + "-06-30";
            }
        }
        String low_level = String.valueOf(StringUtils.isEmpty(lowLevel) ? (level + 1) : lowLevel);
        List<Map<String, Object>> resultList = new ArrayList<>();
        Map<String, Integer> onlineMap = new HashMap<>();
        List<SaveModel> signList = new ArrayList<SaveModel>();
        List<SaveModel> signPayOnlineList = new ArrayList<SaveModel>();
        //总缴费人数
        signList = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, "1", SaveModel.timeLevel_DDL, "", low_level);
        //线上缴费人数
        signPayOnlineList = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index, SaveModel.timeLevel_DDL, "", low_level);
        if (signPayOnlineList != null && signPayOnlineList.size() > 0) {
            for (SaveModel saveModel : signPayOnlineList) {
                if ("3".equals(low_level) && saveModel.getTown() != null) {
                    onlineMap.put(saveModel.getTown(), saveModel.getResult2().intValue());
                } else if ("4".equals(low_level) && saveModel.getHospital() != null) {
                    onlineMap.put(saveModel.getHospital(), saveModel.getResult2().intValue());
                } else if ("5".equals(low_level) && saveModel.getTeam() != null) {
                    onlineMap.put(saveModel.getTeam(), saveModel.getResult2().intValue());
                } else {
                    continue;
                }
            }
        }
        //自建结果集
        resultList = getLowLevelMapKey(level, low_level, area);
        if (resultList != null && resultList.size() > 0) {
            //查询今年的线上续签转map
            Map<String, SaveModel> resultMap = new HashMap<>();
            signList.stream().forEach(one -> {
                if ("5".equals(low_level)) {
                    resultMap.put(one.getTeam(), one);
                } else if ("4".equals(low_level)) {
                    resultMap.put(one.getHospital(), one);
                } else if ("3".equals(low_level)) {
                    resultMap.put(one.getTown(), one);
                }
            });
            for (Map<String, Object> reMap : resultList) {
                //reMap.put("amount", reMap.get("amount") != null ? Long.valueOf(reMap.get("amount").toString()) : 0L);
                int signNum = 0;
                Integer signPayOnlineNum = 0;
                //获取总缴费人数
                if (resultMap != null && resultMap.size() > 0) {
                    SaveModel one = resultMap.get(String.valueOf(reMap.get("code")));
                    if (one != null) {
                        signNum = one.getResult2().intValue();
                    }
                }
                //获取线上缴费人数
                if (onlineMap != null && onlineMap.size() > 0) {
                    signPayOnlineNum = onlineMap.get(String.valueOf(reMap.get("code")));
                    if (signPayOnlineNum == null) {
                        signPayOnlineNum = 0;
                    }
                }
                reMap.put("signNum", signNum);
                reMap.put("signPayOnlineNum", signPayOnlineNum);
            }
            if ((level == 2 && "5".equals(lowLevel)) || (level == 4) || (level == 3 && "5".equals(lowLevel))) {
                translateTeamLeaderName(resultList);
            }
            //对结果进行排序
            Collections.sort(resultList, new Comparator<Map<String, Object>>() {
                public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                    int map1value = (int) o1.get("signPayOnlineNum");
                    int map2value = (int) o2.get("signPayOnlineNum");
                    if (map1value - map2value > 0) {
                        return sort == 1 ? -1 : 1;
                    } else if (map1value - map2value < 0) {
                        return sort == 1 ? 1 : -1;
                    } else {
                        return 0;
                    }
                }
            });
            return new JSONArray(resultList);
        } else {
            return new JSONArray();
        }
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java

@ -250,7 +250,7 @@ public class AdminTeamService extends BaseService {
            Integer signCount = signFamilyDao.findByAdminTeamIdAndStatus(one.getId(),0);
            //获取智业团队签约上线
            String jwCode = one.getMappingCode();//智业服务团队的code
            int sign_limit_number = 0;
            int sign_limit_number = 1500;
            try{
                String response = jwSignService.getSickFamilyDoctorSignLimit(jwCode);
                com.alibaba.fastjson.JSONObject json = com.alibaba.fastjson.JSONObject.parseObject(response);

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/service/OnePayService.java

@ -335,7 +335,7 @@ public class OnePayService {
                familyContent.put("moRegNo", moregNo);//医院签约号限长20  signFamily code
                familyContent.put("moRegName", signFamily.getName()); //签约人姓名
                familyContent.put("moRegAddr", user.getAddress()); //签约人地址
                familyContent.put("moRegTelephone", signFamily.getMobile());//签约人联系电话
                familyContent.put("moRegTelephone", user.getMobile());//签约人联系电话
                familyContent.put("moRegOrgNo", sbCode); //签约机构 限长4
                familyContent.put("moRegDocNo", doctor.getIdcard());//签约医生编号 限长18 身份证号
                familyContent.put("moRegDocName", signFamily.getSignDoctorName()); //签约医生姓名

+ 6 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java

@ -18,6 +18,8 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
@ -56,6 +58,8 @@ public class PatientInfoController extends BaseController {
    @Autowired
    private SendMessageService sendMessageService;
    private static Logger logger = LoggerFactory.getLogger(PatientInfoController.class);
    /**
     * 获取患者基本信息
     *
@ -443,7 +447,8 @@ public class PatientInfoController extends BaseController {
                Boolean mark = sendMessageService.sendTemplate(10,patient,url,first,remark,patientName,format.format(new Date()),keyword);
                if (!mark){
                    String msg = patientName+",您好!您的家庭医生已将您账号关联的手机号码变更:"+keyword+".您可以使用新手机号码登录i健康平台.";
                    sendMessageService.sendMessage(newMobile,msg);
                    String response = sendMessageService.sendMessage(newMobile,msg);
                    logger.info("message response : "+response);
                }
                return write(200, "手机号更新成功");
            } else {

+ 26 - 18
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionAdjustController.java

@ -3,9 +3,11 @@ package com.yihu.wlyy.web.doctor.prescription;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.app.prescription.PrescriptionAdjustService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.util.HttpClientUtil;
@ -18,11 +20,13 @@ import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
@ -47,6 +51,8 @@ public class PrescriptionAdjustController extends BaseController {
    private String targetUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private MessageService messageService;
    @RequestMapping(value = "adjustPrescription",method = RequestMethod.POST)
    @ObserverRequired
@ -65,23 +71,25 @@ public class PrescriptionAdjustController extends BaseController {
                return error(-1,json.getString("msg"));
            }
            try {
                //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                Prescription prescription = prescriptionDao.findByCode(code);
                Doctor doctor = doctorDao.findByCode(prescription.getDoctor());
                String doctorOpenID = doctor.getOpenid();
                if (StringUtils.isNotEmpty(doctorOpenID)) {
                    String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                    List<NameValuePair> params = new ArrayList<>();
                    params.add(new BasicNameValuePair("type", "9"));
                    params.add(new BasicNameValuePair("openId", doctorOpenID));
                    params.add(new BasicNameValuePair("url", targetUrl));
                    params.add(new BasicNameValuePair("first", doctor.getName() + "医生您好。您有1个续方申请已在线下调整完成,请尽快进行CA认证."));
                    params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                    SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                    String keywords = "续方审核CA认证" +"," + doctor.getHospitalName() + "," +doctor.getName();
                    params.add(new BasicNameValuePair("keywords", keywords));
                if(messageService.getMessageNoticeSettingByMessageType(getUID(),"1", MessageNoticeSetting.MessageTypeEnum.prescriptionSwitch.getValue())){
                    //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                    Prescription prescription = prescriptionDao.findByCode(code);
                    Doctor doctor = doctorDao.findByCode(prescription.getDoctor());
                    String doctorOpenID = doctor.getOpenid();
                    if (StringUtils.isNotEmpty(doctorOpenID)) {
                        String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                        List<NameValuePair> params = new ArrayList<>();
                        params.add(new BasicNameValuePair("type", "9"));
                        params.add(new BasicNameValuePair("openId", doctorOpenID));
                        params.add(new BasicNameValuePair("url", targetUrl));
                        params.add(new BasicNameValuePair("first", doctor.getName() + "医生您好。您有1个续方申请已在线下调整完成,请尽快进行CA认证."));
                        params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                        SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                        String keywords = "续方审核CA认证" +"," + doctor.getHospitalName() + "," +doctor.getName();
                        params.add(new BasicNameValuePair("keywords", keywords));
                    httpClientUtil.post(url, params, "UTF-8");
                        httpClientUtil.post(url, params, "UTF-8");
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();

+ 55 - 39
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

@ -5,6 +5,7 @@ import com.yihu.wlyy.entity.consult.Consult;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.consult.ConsultTeamLog;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.logs.BusinessLogs;
@ -16,12 +17,12 @@ import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.service.app.consult.ConsultTeamService;
import com.yihu.wlyy.service.app.consult.DoctorCommentService;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.app.prescription.PrescriptionDiagnosisService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.app.statistics.DoctorStatisticsService;
import com.yihu.wlyy.service.app.talk.TalkGroupService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.template.DoctorFeldsherTemplateService;
import com.yihu.wlyy.task.DoctorStatisticsTask;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.*;
@ -34,8 +35,6 @@ import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
@ -101,7 +100,8 @@ public class ConsultController extends WeixinBaseController {
    private String targetUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private MessageService messageService;
    /**
     * 患者咨询记录查询
@ -394,27 +394,9 @@ public class ConsultController extends WeixinBaseController {
            // 推送消息给医生
            if(dts==null||dts.length()==0){
                pushMsgTask.put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.D_CT_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.指定咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.您有新的指定咨询.name(), consult.getConsult());
                Doctor doctor = doctorDao.findByCode(consult.getDoctor());
                if (doctor!=null && StringUtils.isNotEmpty(doctor.getOpenid())){
                    String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                    List<NameValuePair> params = new ArrayList<>();
                    params.add(new BasicNameValuePair("type", "4"));
                    params.add(new BasicNameValuePair("openId", doctor.getOpenid()));
                    params.add(new BasicNameValuePair("url", targetUrl));
                    params.add(new BasicNameValuePair("first", doctor.getName() + "医生您好,有患者向您发起咨询"));
                    params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                    String sex = consult.getSex()==1? "男" : "女";
                    String keywords = consult.getName() + "," + sex;
                    params.add(new BasicNameValuePair("keywords", keywords));
                    httpClientUtil.post(url, params, "UTF-8");
                }
            }else {
                for (int i=0;i<dts.length();i++){
                    String doctorCode = dts.getString(i);
                    pushMsgTask.put(doctorCode, MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.D_CT_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.指定咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.您有新的指定咨询.name(), consult.getConsult());
                    Doctor doctor = doctorDao.findByCode(doctorCode);
                if(messageService.getMessageNoticeSettingByMessageType(consult.getDoctor(),"1", MessageNoticeSetting.MessageTypeEnum.imSwitch.getValue())){
                    pushMsgTask.put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.D_CT_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.指定咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.您有新的指定咨询.name(), consult.getConsult());
                    Doctor doctor = doctorDao.findByCode(consult.getDoctor());
                    if (doctor!=null && StringUtils.isNotEmpty(doctor.getOpenid())){
                        String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                        List<NameValuePair> params = new ArrayList<>();
@ -430,6 +412,36 @@ public class ConsultController extends WeixinBaseController {
                        httpClientUtil.post(url, params, "UTF-8");
                    }
                }
            }else {
                for (int i=0;i<dts.length();i++){
                    String doctorCode = dts.getString(i);
                    Boolean flag = true;
                    if(consult.getDoctor().equals(doctorCode)){
                        //健管
                        flag = messageService.getMessageNoticeSettingByMessageType(doctorCode,"1", MessageNoticeSetting.MessageTypeEnum.imSwitch.getValue());
                    }else {
                        //全科
                        flag = messageService.getMessageNoticeSettingByMessageType(doctorCode,"1", MessageNoticeSetting.MessageTypeEnum.familyTopicSwitch.getValue());
                    }
                    if(flag){
                        pushMsgTask.put(doctorCode, MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.D_CT_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.指定咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.您有新的指定咨询.name(), consult.getConsult());
                        Doctor doctor = doctorDao.findByCode(doctorCode);
                        if (doctor!=null && StringUtils.isNotEmpty(doctor.getOpenid())){
                            String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                            List<NameValuePair> params = new ArrayList<>();
                            params.add(new BasicNameValuePair("type", "4"));
                            params.add(new BasicNameValuePair("openId", doctor.getOpenid()));
                            params.add(new BasicNameValuePair("url", targetUrl));
                            params.add(new BasicNameValuePair("first", doctor.getName() + "医生您好,有患者向您发起咨询"));
                            params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                            String sex = consult.getSex()==1? "男" : "女";
                            String keywords = consult.getName() + "," + sex;
                            params.add(new BasicNameValuePair("keywords", keywords));
                            httpClientUtil.post(url, params, "UTF-8");
                        }
                    }
                }
            }
            BusinessLogs.info(BusinessLogs.BusinessType.consult, getRepUID(), getUID(), new JSONObject(consult));
@ -807,10 +819,11 @@ public class ConsultController extends WeixinBaseController {
                    }
                    failed.add(String.valueOf(resObj.get("data")));
                    try {
                        //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                        Doctor doctor = doctorDao.findByCode(consultModel.getDoctor());
                        String doctorOpenID = doctor.getOpenid();
                        if (StringUtils.isNotEmpty(doctorOpenID)) {
                        if(messageService.getMessageNoticeSettingByMessageType(consultModel.getDoctor(),"1",MessageNoticeSetting.MessageTypeEnum.imSwitch.getValue())){
                            //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                            Doctor doctor = doctorDao.findByCode(consultModel.getDoctor());
                            String doctorOpenID = doctor.getOpenid();
                            if (StringUtils.isNotEmpty(doctorOpenID)) {
                                String title = "";
                                Consult consultSingle = consultDao.findByCode(log.getConsult());
                                if (consultSingle!=null){
@ -834,6 +847,7 @@ public class ConsultController extends WeixinBaseController {
                                    httpClientUtil.post(url, params, "UTF-8");
                                }
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
@ -1101,14 +1115,15 @@ public class ConsultController extends WeixinBaseController {
//                DoctorStatisticsTask.getInstance(doctorStatisticsService).put(consult.getDoctor(), 1, 1, 0);
//            }
            // 推送消息给医生
            pushMsgTask.put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.D_CT_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_PRESCRIPTION.续方咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_PRESCRIPTION.您有新的续方咨询.name(), consult.getConsult());
            try {
                //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                Doctor doctor1 = doctorDao.findByCode(doctor);
                Patient patient = patientDao.findByCode(getRepUID());
                String doctorOpenID = doctor1.getOpenid();
                if (StringUtils.isNotEmpty(doctorOpenID)) {
            if(messageService.getMessageNoticeSettingByMessageType(doctor,"1",MessageNoticeSetting.MessageTypeEnum.prescriptionSwitch.getValue())){
                // 推送消息给医生
                pushMsgTask.put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.D_CT_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_PRESCRIPTION.续方咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_PRESCRIPTION.您有新的续方咨询.name(), consult.getConsult());
                try {
                    //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                    Doctor doctor1 = doctorDao.findByCode(doctor);
                    Patient patient = patientDao.findByCode(getRepUID());
                    String doctorOpenID = doctor1.getOpenid();
                    if (StringUtils.isNotEmpty(doctorOpenID)) {
                        String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                        List<NameValuePair> params = new ArrayList<>();
                        params.add(new BasicNameValuePair("type", "9"));
@ -1121,9 +1136,10 @@ public class ConsultController extends WeixinBaseController {
                        params.add(new BasicNameValuePair("keywords", keywords));
                        httpClientUtil.post(url, params, "UTF-8");
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            BusinessLogs.info(BusinessLogs.BusinessType.consult, getRepUID(), getUID(), new JSONObject(consult));
            return write(200, "提交成功", "data", consult);

+ 88 - 11
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionPayController.java

@ -1,5 +1,7 @@
package com.yihu.wlyy.web.patient.prescription;
import com.yihu.wlyy.entity.charge.PatientPopups;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.service.app.prescription.PatientPrescriptionPayService;
import com.yihu.wlyy.service.app.prescription.PrescriptionAdressService;
import com.yihu.wlyy.service.app.prescription.PrescriptionNoticesService;
@ -9,6 +11,7 @@ import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
@ -19,6 +22,8 @@ import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import static com.yihu.wlyy.interceptors.GateWayInterceptor.status;
/**
 * Created by Reece on 2017/7/28.
 */
@ -215,24 +220,26 @@ public class PatientPrescriptionPayController extends WeixinBaseController {
            return error(-1, "发送失败!");
        }
    }
//===========================v1.3.9======================================================================
    //===========================v1.3.9======================================================================
    @RequestMapping(value = "/getAddressList", method = RequestMethod.POST)
    @ApiOperation(value = "获取患者所有地址")
    public String getAdressList( @ApiParam(name = "patient", value = "居民code")
                                     @RequestParam(value = "patient", required = true)String patient){
    public String getAdressList(@ApiParam(name = "patient", value = "居民code")
                                @RequestParam(value = "patient", required = true) String patient) {
        try {
            return write(200, "获取成功!","data",prescriptionAdressService.getAdressList(patient));
            return write(200, "获取成功!", "data", prescriptionAdressService.getAdressList(patient));
        } catch (Exception e) {
            return error(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "/getDefAddress", method = RequestMethod.POST)
    @ApiOperation(value = "获取患者默认地址")
    public String getDefAdress(String patient){
    public String getDefAdress(String patient) {
        try {
            return write(200, "获取成功!","data",prescriptionAdressService.getDefAdress(patient));
            return write(200, "获取成功!", "data", prescriptionAdressService.getDefAdress(patient));
        } catch (Exception e) {
            error(e);
            return error(-1, "发送失败!");
@ -242,7 +249,7 @@ public class PatientPrescriptionPayController extends WeixinBaseController {
    @RequestMapping(value = "/saveAddress", method = RequestMethod.POST)
    @ApiOperation(value = "保存地址")
    public String saveAdress(@ApiParam(name = "addressJson", value = "实体json串")
                             @RequestParam(value = "addressJson", required = true)String addressJson){
                             @RequestParam(value = "addressJson", required = true) String addressJson) {
        try {
            return write(200, "获取成功!", "data", prescriptionAdressService.saveAdress(addressJson));
@ -251,10 +258,11 @@ public class PatientPrescriptionPayController extends WeixinBaseController {
            return error(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "/delAddress", method = RequestMethod.POST)
    @ApiOperation(value = "删除地址")
    public String delAdress(@ApiParam(name = "id", value = "主键")
                                @RequestParam(value = "id", required = true)Long id){
                            @RequestParam(value = "id", required = true) Long id) {
        try {
            return write(200, "获取成功!", "data", prescriptionAdressService.delAdress(id));
@ -266,7 +274,7 @@ public class PatientPrescriptionPayController extends WeixinBaseController {
    @RequestMapping(value = "/getProvince", method = RequestMethod.POST)
    @ApiOperation(value = "获取省会")
    public String getProvince(){
    public String getProvince() {
        try {
            return write(200, "获取成功!", "data", prescriptionAdressService.getProvince());
@ -279,7 +287,7 @@ public class PatientPrescriptionPayController extends WeixinBaseController {
    @RequestMapping(value = "/getCityByProvince", method = RequestMethod.POST)
    @ApiOperation(value = "根据省会获取城市")
    public String getCityByProvince(@ApiParam(name = "province", value = "省会code")
                                        @RequestParam(value = "province", required = true)String province){
                                    @RequestParam(value = "province", required = true) String province) {
        try {
            return write(200, "获取成功!", "data", prescriptionAdressService.getCityByProvince(province));
@ -292,7 +300,7 @@ public class PatientPrescriptionPayController extends WeixinBaseController {
    @RequestMapping(value = "/getTowmByCity", method = RequestMethod.POST)
    @ApiOperation(value = "根据城市获取区")
    public String getTowmByCity(@ApiParam(name = "city", value = "城市code")
                                    @RequestParam(value = "city", required = true)String city){
                                @RequestParam(value = "city", required = true) String city) {
        try {
            return write(200, "获取成功!", "data", prescriptionAdressService.getTowmByCity(city));
@ -301,4 +309,73 @@ public class PatientPrescriptionPayController extends WeixinBaseController {
            return error(-1, "获取失败!");
        }
    }
    /**
     * 保存居民支付弹窗设置
     *
     * @param type   弹窗类型(0:签约支付 1续方支付)
     * @param status 弹出状态(0不弹出 1弹出)
     * @return
     */
    @RequestMapping(value = "/savePopups", method = RequestMethod.POST)
    @ApiOperation(value = "保存居民支付弹窗设置")
    public String savePopups(@ApiParam(name = "type", value = "弹窗类型")
                             @RequestParam(value = "type", required = true) int type,
                             @ApiParam(name = "status", value = "弹窗状态")
                             @RequestParam(value = "status", required = true) String status) {
        try {
            payService.savePopups(type, getUID(), status);
            return write(200, "保存成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "保存失败!");
        }
    }
    /**
     * 查询居民支付弹窗设置
     *
     * @param type 弹窗类型(0:签约支付 1续方支付)
     * @return
     */
    @RequestMapping(value = "/getPopups", method = RequestMethod.GET)
    @ApiOperation(value = "查询居民支付弹窗设置")
    public String getPopups(@ApiParam(name = "type", value = "弹窗类型")
                            @RequestParam(value = "type", required = true) int type) {
        try {
            String status = "1";
            PatientPopups popups = payService.getPopups(type, getUID());
            if (popups != null) {
                status = popups.getStatus();
                return write(200, "查询成功!", "data", status);
            } else {
                return write(200, "该居民未设置弹窗!", "data", status);
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    /**
     * 查询缴费居民手机绑定情况
     *
     * @return
     */
    @RequestMapping(value = "/getPatientMobile", method = RequestMethod.GET)
    @ApiOperation(value = "查询缴费居民手机绑定情况")
    public String getPatientMobile() {
        try {
            String status = "1";
            String mobile = payService.getPatientMobile(getRepUID());
            if (StringUtils.isEmpty(mobile)){
                status = "0";
            }
            return write(200, "查询成功!", "data", status);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
}

+ 112 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

@ -1925,7 +1925,7 @@ public class EsStatisticsController extends BaseController {
    /**
     * 获取 线上续签率和续签率
     * 前端:线上续签
     * 前端:线上续签.
     *
     * @param index 29,43,44 (51,53,54 服务类型维度)
     * @param level 等级  4 市  3区  2社区 1团队
@ -1953,5 +1953,116 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 今年的线上续签量,续签量和线上续签率 列表
     *
     * @param index    75,76,77 (79,80,81 服务类型维度)
     * @param area     每个层级大的code  例如湖里区 350206  xx社区 3502060100
     * @param level    level1_type等级 1:团队 2社区机构 3区级 4市级
     * @param sort     0:升序 1:降序
     * @param lowLevel 只有可能是 1,2,3,不传默认是level-1;
     * @param year     不管根据当前时间找年度
     * @param lowCode  如果是服务类型维度code(老年人3,高血压1,糖尿病2)
     * @return
     */
    @RequestMapping("/lowlevel_all_sign_renew_online")
    @ResponseBody
    public String lowlevel_all_sign_renew_online(
            @RequestParam(required = true) String index,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) int sort,
            @RequestParam(required = false) String lowLevel,
            @RequestParam(required = false) String year,
            @RequestParam(required = false) String lowCode) {
        try {
            JSONObject result = new JSONObject();
            //如果年度是空,按当前时间计算是年度是属于那个年度
            if (org.springframework.util.StringUtils.isEmpty(year)) {
                year = Constant.getNowYear();
            }
            //lowLevel不传默认是 level-1
            if (org.springframework.util.StringUtils.isEmpty(lowLevel)) {
                lowLevel = level - 1 + "";
            }
            result.put("index_" + index, statisticsESService.getLevelTwoLowLevelTotalRenewOnline(area,elasticsearchUtil.changeLevel(level), index, sort, String.valueOf(elasticsearchUtil.changeLevel(Integer.valueOf(lowLevel))), year, lowCode));
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    /**
     *获取线上和线下缴费的比例
     * @author zhangdan 2017-11-29
     * @param area
     * @param level
     * @param year
     * @return
     */
    @ApiOperation("获取线上缴费和线下缴费的比例")
    @RequestMapping("/signPayOnline")
    @ResponseBody
    public String signPayOnline(
            @RequestParam(required = true)String area,
            @RequestParam(required = true)int level,
            @RequestParam(required = true)String year){
        try{
            JSONObject result = new JSONObject();
            //如果年度是空,按当前时间计算是年度是属于那个年度
            if (org.springframework.util.StringUtils.isEmpty(year)) {
                year = Constant.getNowYear();
            }
            result.put("data" , statisticsESService.getSignPayOnline(elasticsearchUtil.changeLevel(level),area,year));
            return write(200, "查询成功", "data", result);
        }catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取线上缴费的各个读取的列表
     * @author zhangdan 2017-11-29
     * @param index
     * @param area
     * @param level
     * @param sort
     * @param lowLevel
     * @param year
     * @return
     */
    @ApiOperation("获取线上缴费的各个地区的列表")
    @RequestMapping("/lowlevel_all_sign_pay_online")
    @ResponseBody
    public String lowlevel_all_sign_pay_online(
            @RequestParam(required = true) String index,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) int sort,
            @RequestParam(required = false) String lowLevel,
            @RequestParam(required = false) String year){
        try {
            JSONObject result = new JSONObject();
            //如果年度是空,按当前时间计算是年度是属于那个年度
            if (org.springframework.util.StringUtils.isEmpty(year)) {
                year = Constant.getNowYear();
            }
            //lowLevel不传默认是 level-1
            if (StringUtils.isEmpty(lowLevel)) {
                lowLevel = level - 1 + "";
            }
            result.put("index_" + index, statisticsESService.getLowLevelSignPayOnline(area,elasticsearchUtil.changeLevel(level), index, sort, String.valueOf(elasticsearchUtil.changeLevel(Integer.valueOf(lowLevel))), year));
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    /*==================================版本1.4.1统计优化结束 end=====================================*/
}