Bläddra i källkod

消息提醒修改

yeshijie 7 år sedan
förälder
incheckning
26c32bbf1b
19 ändrade filer med 825 tillägg och 460 borttagningar
  1. 39 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/message/MessageNoticeSetting.java
  2. 4 64
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  3. 4 1
      patient-co/patient-co-statistics/pom.xml
  4. 18 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/MessageNoticeSettingDao.java
  5. 39 32
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/message/FollowupPlanJob.java
  6. 33 28
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/message/HealthMessageJob.java
  7. 178 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/signfamily/MessageNoticeSetting.java
  8. 130 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/service/MessageService.java
  9. 32 28
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java
  10. 47 39
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java
  11. 65 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  12. 18 23
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java
  13. 26 20
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  14. 7 76
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java
  15. 102 90
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  16. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  17. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java
  18. 26 18
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionAdjustController.java
  19. 55 39
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

+ 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;
    }

+ 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;
    }
}

+ 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;
    }
}

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

@ -3,40 +3,33 @@ package com.yihu.wlyy.service.app.prescription;
import com.alibaba.fastjson.JSON;
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.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;
import com.yihu.wlyy.entity.patient.SignFamily;
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.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;
import com.yihu.wlyy.service.weixin.wxpay.service.OnePayService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.MessageType;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.web.wx.OnePayController;
import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.domain.RequestParams;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
@ -50,7 +43,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.security.access.method.P;
import org.springframework.stereotype.Service;
import org.springframework.util.StreamUtils;
@ -60,7 +52,6 @@ import javax.transaction.Transactional;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.*;
@ -92,7 +83,8 @@ public class PatientPrescriptionPayService extends BaseService {
    private HttpClientUtil httpClientUtil;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private MessageService messageService;
    //    引入实例
    @Autowired
    private PayConfiguraDao configuraDao;
@ -754,11 +746,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 +764,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();
                            }
                        }
                        //支付成功生成二维码

+ 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");
                }
            }
        }

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

@ -2624,7 +2624,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){
            //获取团队签约数

+ 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);

+ 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);