Selaa lähdekoodia

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

liuwenbin 7 vuotta sitten
vanhempi
commit
51d169d48d
58 muutettua tiedostoa jossa 2756 lisäystä ja 1521 poistoa
  1. 39 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/message/MessageNoticeSetting.java
  2. 10 0
      patient-co-manage/wlyy-manage/pom.xml
  3. 177 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/MessageNoticeSetting.java
  4. 18 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/MessageNoticeSettingDao.java
  5. 33 10
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/account/CustomerService.java
  6. 8 2
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/consult/WlyyConsultRemindLogService.java
  7. 16 10
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/feedback/FeedbackService.java
  8. 133 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/message/MessageService.java
  9. 23 2
      patient-co-manage/wlyy-manage/src/main/resources/application.yml
  10. 15 0
      patient-co-service/wlyy_device/pom.xml
  11. 18 0
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/common/dao/MessageNoticeSettingDao.java
  12. 1 1
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/model/ConsultTeam.java
  13. 177 0
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/model/MessageNoticeSetting.java
  14. 12 8
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java
  15. 131 0
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/MessageService.java
  16. 24 1
      patient-co-service/wlyy_device/src/main/resources/application.yml
  17. 4 64
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  18. 39 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcMessageController.java
  19. 2 0
      patient-co/patient-co-doctor-assistant/src/main/resources/application-dev.yml
  20. 2 1
      patient-co/patient-co-doctor-assistant/src/main/resources/application-devtest.yml
  21. 2 1
      patient-co/patient-co-doctor-assistant/src/main/resources/application-local.yml
  22. 2 0
      patient-co/patient-co-doctor-assistant/src/main/resources/application-localtest.yml
  23. 2 0
      patient-co/patient-co-doctor-assistant/src/main/resources/application-prod.yml
  24. 2 0
      patient-co/patient-co-doctor-assistant/src/main/resources/application-test.yml
  25. 4 1
      patient-co/patient-co-statistics/pom.xml
  26. 18 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/MessageNoticeSettingDao.java
  27. 39 32
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/message/FollowupPlanJob.java
  28. 33 28
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/message/HealthMessageJob.java
  29. 178 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/signfamily/MessageNoticeSetting.java
  30. 130 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/service/MessageService.java
  31. 34 27
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/HealthMessageJob.java
  32. 18 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/message/MessageNoticeSettingDao.java
  33. 37 34
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java
  34. 14 144
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java
  35. 110 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  36. 6 51
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java
  37. 0 694
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  38. 4 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java
  39. 364 9
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java
  40. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java
  41. 32 28
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java
  42. 47 39
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java
  43. 65 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  44. 30 24
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java
  45. 26 20
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  46. 7 76
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java
  47. 102 90
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  48. 10 13
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/PatientRemindService.java
  49. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  50. 328 45
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  51. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java
  52. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwArchivesService.java
  53. 8 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/CommonUtil.java
  54. 13 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java
  55. 26 18
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionAdjustController.java
  56. 12 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java
  57. 55 39
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java
  58. 112 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.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;
    }

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

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

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

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

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

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

+ 33 - 10
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/account/CustomerService.java

@ -145,7 +145,7 @@ public class CustomerService extends BaseService{
	public Map<String, Object> sendMsg(Doctor doctor,String msg,String type) {
		Map<String, Object> resp = new HashMap<String, Object>();
		//发送微信消息啦
		//发送微信消息
		String openId = doctor.getOpenid();
		if(!StringUtils.isBlank(openId)&&!"1".equals(type)){
			List<NameValuePair> par = new ArrayList<NameValuePair>();
@ -189,6 +189,31 @@ public class CustomerService extends BaseService{
		return resp;
	}
	public Map<String,Object> sendCallServiceWXMes(String openid,String doctorName,String patientName,String typeName,String mobile,String remark){
		Map<String, Object> resp = new HashMap<String, Object>();
		List<NameValuePair> par = new ArrayList<NameValuePair>();
		par.add(new BasicNameValuePair("openIds", openid));
		par.add(new BasicNameValuePair("doctorName", doctorName));
		par.add(new BasicNameValuePair("patientName", patientName));
		par.add(new BasicNameValuePair("typeName", typeName));
		par.add(new BasicNameValuePair("mobile", mobile));
		par.add(new BasicNameValuePair("remark", remark));
		try {
			logger.info("====================================================================");
			String result = HttpClientUtil.post(messageApi+"/sendCallServerWechatMessage", par,"UTF-8");
			logger.info("微信发送消息返回结果:"+result);
			logger.info("====================================================================");
			JSONObject resultJson = new JSONObject(result);
			if(1!=resultJson.getInt("successNum")){
				resp.put("wechat","-1");//-1代表发送失败
			}
		}catch (Exception e){
			resp.put("wechat","-1");//-1代表发送失败
		}
		return resp;
	}
	public Map<String,Object> addCallRecord(String user,Integer type,String callerNumber,String recipientNumber,Integer status){
@ -440,7 +465,7 @@ public class CustomerService extends BaseService{
		//待处理发送消息给医生
		sendCallServiceMes(callService);
		//发送消息
		sendWxMes(callService,u);
		sendWxMes(callService);
		return "1";
	}
@ -468,20 +493,18 @@ public class CustomerService extends BaseService{
		//待处理发送消息给医生
		sendCallServiceMes(callService);
		//发送消息
		sendWxMes(callService,u);
		sendWxMes(callService);
		return "1";
	}
	public void sendWxMes(CallService callService,User u){
	public void sendWxMes(CallService callService){
		Doctor d = doctorDao.findByCode(callService.getDoctor());
		String mes = u.getName()+"(工号:"+u.getJobNo()+")代居民("+callService.getPatientName()+")发:" ;
		if(callService.getType()==1){
			mes += callService.getPatientName()+"需要预约挂号";
		CallRecord r = callRecordDao.findByCode(callService.getCallCode());
		if("0".equals(callService.getType())){
			sendCallServiceWXMes(d.getOpenid(),callService.getDoctorName(),callService.getPatientName(),"咨询",r.getCallerNumber(),callService.getServerContent());
		}else{
			mes += callService.getPatientName()+"发起咨询";
			sendCallServiceWXMes(d.getOpenid(),callService.getDoctorName(),callService.getPatientName(),"待预约",r.getCallerNumber(),callService.getServerContent());
		}
		mes +="\n请您登录i健康app,进入协同服务管理进行查看处理。";
		sendMsg(d,mes,"2");
	}
	public void sendCallServiceMes(CallService callService){

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -12,7 +12,16 @@ spring:
      properties:
        hibernate:
          dialect: org.hibernate.dialect.MySQL5Dialect
    # REDIS
  redis:
    database: 0 # Database index used by the connection factory.
    password: # Login password of the redis server.
    timeout: 120000 # 连接超时时间(毫秒) 60秒
    pool:
      max-active: 20 # 连接池最大连接数(使用负值表示没有限制)
      max-wait: -1  # 连接池最大阻塞等待时间(使用负值表示没有限制)
      max-idle: 20  # 连接池中的最大空闲连接
      min-idle: 5  # 连接池中的最小空闲连接
---
spring:
  profiles: dev
@ -23,6 +32,11 @@ spring:
    driverClassName: com.mysql.jdbc.Driver
    maxTotal: 500
    maxIdle: 30
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
#    血糖值默认时间段存到数据库 wlyy_patient_blood_sugger表
#bloodSugger:
#  fasting: 00:00-07:59
@ -57,6 +71,11 @@ spring:
    driverClassName: com.mysql.jdbc.Driver
    maxTotal: 500
    maxIdle: 30
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
bloodSugger:
  fasting: 00:00-07:59
  afterBreakfast: 08:00-09:59
@ -88,6 +107,10 @@ spring:
    driverClassName: com.mysql.jdbc.Driver
    maxTotal: 500
    maxIdle: 30
  redis:
     host: 27.155.101.77 # Redis server host.
     port: 6380 # Redis server port.
     password: jkzl_ehr
bloodSugger:
  fasting: 00:00-07:59
  afterBreakfast: 08:00-09:59

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

@ -1,19 +1,13 @@
package com.yihu.wlyy.service.app.sign;
import com.yihu.wlyy.entity.consult.Consult;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.doctor.OperatorLog;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.profile.DoctorService;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroupInfo;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.*;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.consult.ConsultDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.dict.SystemDictDao;
@ -27,13 +21,13 @@ import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.third.jkEduArticle.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;
    }
    /**
     * 查询患者的签约消息

+ 39 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcMessageController.java

@ -48,6 +48,8 @@ public class GcMessageController {
    private DoctorDao doctorDao;
    @Value("${wechat.message.template_consult_notice}")
    private String templateId;
    @Value("${wechat.message.template_callserver_remind}")
    private String callServerTemplateId;
    @Value("${server.server_url}")
    private String server_url;
@ -152,6 +154,43 @@ public class GcMessageController {
        }
    }
    @RequestMapping(value = "/sendCallServerWechatMessage", method = RequestMethod.POST)
    @ApiOperation("客服系统发送协同服务微信模板消息接口")
    public ResultBatchModel sendCallServerWechatMessage(
            @ApiParam(name = "openIds", value = "微信openid", required = true) @RequestParam(value = "openIds", required = true) String openIds,
            @ApiParam(name = "remark", value = "服务内容", required = true) @RequestParam(value = "remark", required = true)String remark,
            @ApiParam(name = "doctorName", value = "消息内容", required = true) @RequestParam(value = "doctorName", required = true)String doctorName,
            @ApiParam(name = "patientName", value = "居民姓名", required = true) @RequestParam(value = "patientName", required = true) String patientName,
            @ApiParam(name = "mobile", value = "居民手机", required = true) @RequestParam(value = "mobile", required = true)String mobile,
            @ApiParam(name = "typeName", value = "服务类型", required = true) @RequestParam(value = "typeName", required = true)String typeName) {
        Integer success = 0;
        Integer error = 0;
        List<String> errorLiust = new ArrayList<>();
        try {
            String url = server_url + "wx_doctor/html/home/html/jumpApp.html";
            String[] codeArr = openIds.split(",");
            for (String openId : codeArr) {
                try {
                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                    JSONObject sendJson = weiXinTempMsgSendUtils.packageTemplate("您好,您有一条协同服务待处理。", remark, doctorName, patientName,mobile,dateFormat.format(new Date()),typeName);
                    Boolean flag = weiXinTempMsgSendUtils.sendTemplateMessage(callServerTemplateId, openId, url, sendJson,null);
                    logger.info("send wechat message param : " + openId+" =======> "+remark);
                    logger.info("send wechat message retuen : " + openId+" =======> "+flag);
                    success++;
                } catch (Exception e) {
                    e.printStackTrace();
                    logger.error("openids " + openIds + " send Template error:" + e.getMessage());
                    error++;
                    errorLiust.add(openIds);
                }
            }
            return new ResultBatchModel(success, error, errorLiust);
        } catch (Exception e) {
            e.printStackTrace();
            return new ResultBatchModel(-1, "发送失败!", success, error, errorLiust);
        }
    }
    /**
     * 客服系统发送消息接口 居民没有有openID只发手机短信 有openID发微信模板消息、手机短信 没有IP次数限制
     *

+ 2 - 0
patient-co/patient-co-doctor-assistant/src/main/resources/application-dev.yml

@ -52,6 +52,8 @@ wechat:
   template_schedule_remind: z32DERzD6X4ShOl86sI3YCOWl-lkr5Z9sKh1w_YG8Bs
   #服务待处理提醒
   template_service_remind:  v2iqCHvqNLiU0PBBMIEPkB40xi8eUtdpsjwyxw-euo4
   #协同服务提醒
   template_callserver_remind: Fsnt5YUDBCNOREMKifZbr51XhNRyop6VAEV8mIuFYuc
yihu:
  yihu_OpenPlatform_url: http://ssotest.yihu.cn/OpenPlatform/cgiBin/1.0/

+ 2 - 1
patient-co/patient-co-doctor-assistant/src/main/resources/application-devtest.yml

@ -52,7 +52,8 @@ wechat:
   template_schedule_remind: z32DERzD6X4ShOl86sI3YCOWl-lkr5Z9sKh1w_YG8Bs
   #服务待处理提醒
   template_service_remind:  v2iqCHvqNLiU0PBBMIEPkB40xi8eUtdpsjwyxw-euo4
   #协同服务提醒
   template_callserver_remind: Fsnt5YUDBCNOREMKifZbr51XhNRyop6VAEV8mIuFYuc
yihu:
  yihu_OpenPlatform_url: http://ssotest.yihu.cn/OpenPlatform/cgiBin/1.0/

+ 2 - 1
patient-co/patient-co-doctor-assistant/src/main/resources/application-local.yml

@ -52,7 +52,8 @@ wechat:
   template_schedule_remind: z32DERzD6X4ShOl86sI3YCOWl-lkr5Z9sKh1w_YG8Bs
   #服务待处理提醒
   template_service_remind:  v2iqCHvqNLiU0PBBMIEPkB40xi8eUtdpsjwyxw-euo4
   #协同服务提醒
   template_callserver_remind: Fsnt5YUDBCNOREMKifZbr51XhNRyop6VAEV8mIuFYuc
yihu:
  yihu_OpenPlatform_url: http://ssotest.yihu.cn/OpenPlatform/cgiBin/1.0/

+ 2 - 0
patient-co/patient-co-doctor-assistant/src/main/resources/application-localtest.yml

@ -52,6 +52,8 @@ wechat:
   template_schedule_remind: z32DERzD6X4ShOl86sI3YCOWl-lkr5Z9sKh1w_YG8Bs
   #服务待处理提醒
   template_service_remind:  v2iqCHvqNLiU0PBBMIEPkB40xi8eUtdpsjwyxw-euo4
   #协同服务提醒
   template_callserver_remind: Fsnt5YUDBCNOREMKifZbr51XhNRyop6VAEV8mIuFYuc
yihu:

+ 2 - 0
patient-co/patient-co-doctor-assistant/src/main/resources/application-prod.yml

@ -51,6 +51,8 @@ wechat:
   template_schedule_remind:  9l1CBFlnJJaqWXW2UVQfgUidhtt5Fff_1L50RgXpIY8
   #服务待处理提醒
   template_service_remind:  v2iqCHvqNLiU0PBBMIEPkB40xi8eUtdpsjwyxw-euo4
   #协同服务提醒
   template_callserver_remind: Fsnt5YUDBCNOREMKifZbr51XhNRyop6VAEV8mIuFYuc
yihu:
  yihu_OpenPlatform_url: http://api.yihu.com.cn/OpenPlatform/cgiBin/1.0/

+ 2 - 0
patient-co/patient-co-doctor-assistant/src/main/resources/application-test.yml

@ -51,6 +51,8 @@ wechat:
   template_schedule_remind: z32DERzD6X4ShOl86sI3YCOWl-lkr5Z9sKh1w_YG8Bs
   #服务待处理提醒
   template_service_remind:  v2iqCHvqNLiU0PBBMIEPkB40xi8eUtdpsjwyxw-euo4
   #协同服务提醒
   template_callserver_remind: Fsnt5YUDBCNOREMKifZbr51XhNRyop6VAEV8mIuFYuc
yihu:
  yihu_OpenPlatform_url: http://ssotest.yihu.cn/OpenPlatform/cgiBin/1.0/

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -2,11 +2,13 @@ package com.yihu.wlyy.service.app.message;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.health.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.message.MessageNoticeSettingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
@ -21,6 +23,7 @@ import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
@ -52,6 +55,12 @@ public class MessageService extends BaseService {
    private DevicePatientHealthIndexDao devicePatientHealthIndexDao;
    @Autowired
    private HttpClientUtil HttpClientUtil;
    @Autowired
    private MessageNoticeSettingDao messageNoticeSettingDao;
    @Autowired
    private StringRedisTemplate redisTemplate;
    private final String MESSAGE_NOTICESETTING = "wlyy:message:setting:";
    @Value("${im.im_list_get}")
    private String im_list_get;
@ -458,4 +467,105 @@ public class MessageService extends BaseService {
            messageDao.setMessageReaded(doctor, type);
        }
    }
    /**
     * 获取消息提醒设置
     * @param user
     * @param type
     * @return
     */
    public com.alibaba.fastjson.JSONObject getMessageNoticSetting(String user, String type){
        com.alibaba.fastjson.JSONObject re = null;
        String key = MESSAGE_NOTICESETTING+user+":"+type;
        String response = redisTemplate.opsForValue().get(key);
        if(StringUtils.isBlank(response)){
            MessageNoticeSetting messageNoticeSetting = messageNoticeSettingDao.findByUserAndType(user,type);
            if(messageNoticeSetting == null){
                messageNoticeSetting = new MessageNoticeSetting();
                messageNoticeSetting.setCreateTime(new Date());
                messageNoticeSetting.setFamilyTopicSwitch(1);
                messageNoticeSetting.setCoordinationSwitch(1);
                messageNoticeSetting.setHealthSignSwitch(1);
                messageNoticeSetting.setImSwitch(1);
                messageNoticeSetting.setMasterSwitch(1);
                messageNoticeSetting.setPrescriptionSwitch(1);
                messageNoticeSetting.setSignSwitch(1);
                messageNoticeSetting.setSoundSwitch(1);
                messageNoticeSetting.setSystemSwitch(1);
                messageNoticeSetting.setType(type);
                messageNoticeSetting.setUser(user);
                messageNoticeSetting.setVibrationSwitch(1);
                messageNoticeSettingDao.save(messageNoticeSetting);
            }
            response = com.alibaba.fastjson.JSONObject.toJSONString(messageNoticeSetting);
            redisTemplate.opsForValue().set(key,response);
        }
        re = com.alibaba.fastjson.JSONObject.parseObject(response);
        return re;
    }
    /**
     * 获取消息提示开关
     * @param user
     * @param type
     * @param messageType
     * @return (1开,0关)
     */
    public Boolean getMessageNoticeSettingByMessageType(String user,String type,String messageType){
        Integer re = 0;
        com.alibaba.fastjson.JSONObject setting = getMessageNoticSetting(user,type);
        Integer masterSwitch = setting.getInteger("masterSwitch");
        if(masterSwitch==0){
            return false;
        }
        switch (messageType){
            case "masterSwitch":
                //总开关
                re = masterSwitch;
                break;
            case "imSwitch":
                //im消息开关
                re = setting.getInteger("imSwitch");
                break;
            case "familyTopicSwitch":
                //健管师邀请后推送开关
                Integer imSwitch = setting.getInteger("imSwitch");
                if(imSwitch==1){
                    re = setting.getInteger("familyTopicSwitch");
                }
                break;
            case "signSwitch":
                //签约消息开关
                re = setting.getInteger("signSwitch");
                break;
            case "healthSignSwitch":
                //体征消息开关
                re = setting.getInteger("healthSignSwitch");
                break;
            case "systemSwitch":
                //系统消息开关
                re = setting.getInteger("systemSwitch");
                break;
            case "prescriptionSwitch":
                //续方消息开关
                re = setting.getInteger("prescriptionSwitch");
                break;
            case "soundSwitch":
                //铃声提醒开关
                re = setting.getInteger("soundSwitch");
                break;
            case "vibrationSwitch":
                //振动提醒开关
                re = setting.getInteger("vibrationSwitch");
                break;
            case "coordinationSwitch":
                //协同消息开关
                re = setting.getInteger("coordinationSwitch");
                break;
            default:
                break;
        }
        return re==1;
    }
}

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

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

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

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

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

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

+ 364 - 9
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java

@ -53,7 +53,7 @@ import java.util.*;
/**
 * 患者基本信息类.
 *
 * @author George.
 * @author George
 */
@Component
@Transactional
@ -492,13 +492,321 @@ public class PatientInfoService extends BaseService {
            for(int i=0 ;i<phs.length ; i++){
                if("1".equals(phs[i])){
                    json.put("PAST_HYPERTENSION","1");//既往史--疾病--高血压【0不勾选 1勾选】
                    if(StringUtils.isNotBlank(dates[i])){
                    if(!"0".equals(dates[i])){
                        json.put("PAST_HYPERTENSION_DATE",dates[i]);//既往史--疾病--高血压日期
                    }
                }else if("2".equals(phs[i])){
                    json.put("PAST_DIABETES","1");//既往史--疾病--糖尿病【0不勾选 1勾选】
                    if(!"0".equals(dates[i])){
                        json.put("PAST_DIABETES_DATE",dates[i]);//既往史--疾病--糖尿病日期
                    }
                }
//                if("3".equals(phs[i])){
//                    json.put("SURGERY","1");//既往史--手术--【0 无 1 有】
//                    if(StringUtils.isNotBlank(dates[i])){
//                        json.put("PAST_HYPERTENSION_DATE",dates[i]);//既往史--疾病--高血压日期
//                    }
//                }
                else if("4".equals(phs[i])){
                    json.put("PAST_OTHER","1");//既往史--疾病--其它【0不勾选 1勾选】
                    if(!"0".equals(dates[i])){
                        json.put("PAST_OTHER_CONTENT_DATE",dates[i]);//既往史--疾病--高血压日期
                    }
                }
            }
        }else{
            json.put("PAST_NONE","1");//既往史
        }
        //遗传病史
        if(StringUtils.isNotBlank(archive.getGeneticFlag())){
            json.put("GENETIC","1");//遗传病史【0 无 1 有】
            json.put("GENETIC_DISEASENAME",archive.getGeneticContent());//疾病名称
        }else{
            json.put("GENETIC","0");//遗传病史【0 无 1 有】
        }
        //残疾
        if(StringUtils.isNotBlank(archive.getDisabilitys())){
            String ds[] = archive.getDisabilitys().split(",");
            for(String d :ds){
                if("1".equals(d)){
                    json.put("DISABILITY_WITHOUT","1");//有无残疾--无残疾【0不勾选 1勾选】
                }
                if("2".equals(d)){
                    json.put("DISABILITY_EYES","1");//有无残疾--视力残疾【0不勾选 1勾选】
                    json.put("DISABILITY_WITHOUT","0");//有无残疾--无残疾【0不勾选 1勾选】
                }
                if("3".equals(d)){
                    json.put("DISABILITY_EAR","1");//有无残疾--听力残疾【0不勾选 1勾选】
                    json.put("DISABILITY_WITHOUT","0");//有无残疾--无残疾【0不勾选 1勾选】
                }
                if("4".equals(d)){
                    json.put("DISABILITY_SPEECH","1");//有无残疾--言语残疾【0不勾选 1勾选】
                    json.put("DISABILITY_WITHOUT","0");//有无残疾--无残疾【0不勾选 1勾选】
                }
                if("5".equals(d)){
                    json.put("DISABILITY_LIMB","1");//有无残疾--肢体残疾【0不勾选 1勾选】
                    json.put("DISABILITY_WITHOUT","0");//有无残疾--无残疾【0不勾选 1勾选】
                }
                if("6".equals(d)){
                    json.put("DISABILITY_INTELLECTUAL","1");//有无残疾--智力残疾【0不勾选 1勾选】
                    json.put("DISABILITY_WITHOUT","0");//有无残疾--无残疾【0不勾选 1勾选】
                }
                if("7".equals(d)){
                    json.put("DISABILITY_OTHER","1");//有无残疾--其它残疾【0不勾选 1勾选】
                    json.put("DISABILITY_WITHOUT","0");//有无残疾--无残疾【0不勾选 1勾选】
                }
            }
        }else{
            json.put("DISABILITY_WITHOUT","1");//  "DISABILITY_WITHOUT":"有无残疾--无残疾【0不勾选 1勾选】(同一类别,新增时,默认勾选)",
        }
        //家族史
        if(StringUtils.isNotBlank(archive.getFamilyHistoryFlag())&&"1".equals(archive.getFamilyHistoryFlag())){
            //父亲
            if(StringUtils.isNotBlank(archive.getFamilyFatherHistorys())){
                json.put("FAMILY_FATHER_NONE","0");//家族史--父亲--无【0不勾选 1勾选】
                String fhs[] = archive.getFamilyFatherHistorys().split(",");
                for(String fh : fhs){
                    if("1".equals(fh)){
                        json.put("FAMILY_FATHER_HYPERTENSION","1");//家族史--父亲--高血压【0不勾选 1勾选】
                    } else if("2".equals(fh)){
                        json.put("FAMILY_FATHER_DIABETES","1");//家族史--父亲--糖尿病【0不勾选 1勾选】
                    } else if("3".equals(fh)){
                        json.put("FAMILY_FATHER_CORONARY","1");//家族史--父亲--冠心病【0不勾选 1勾选】
                    } else if("4".equals(fh)){
                        json.put("FAMILY_FATHER_ALLERGY","1");//家族史--父亲--慢性阻塞性肺疾病【0不勾选 1勾选】
                    } else if("5".equals(fh)){
                        json.put("FAMILY_FATHER_MALIGNANT","1");//家族史--父亲--恶性肿瘤【0不勾选 1勾选】
                    } else if("6".equals(fh)){
                        json.put("FAMILY_FATHER_STROKE","1");//家族史--父亲--脑卒中【0不勾选 1勾选】
                    } else if("7".equals(fh)){
                        json.put("FAMILY_FATHER_SCHIZOPHRENIA","1");//家族史--父亲--重性精神疾病【0不勾选 1勾选】
                    } else if("8".equals(fh)){
                        json.put("FAMILY_FATHER_TB","1");//家族史--父亲--结核病【0不勾选 1勾选】
                    } else if("9".equals(fh)){
                        json.put("FAMILY_FATHER_HEPATITIS","1");//家族史--父亲--肝炎【0不勾选 1勾选】
                    } else if("10".equals(fh)){
                        json.put("FAMILY_FATHER_CONGENITAL","1");//家族史--父亲--先天畸形【0不勾选 1勾选】
                    } else if("11".equals(fh)){
                        json.put("FAMILY_FATHER_OTHER","1");//家族史--父亲--其它【0不勾选 1勾选】
                    }
                }
                if("2".equals(phs[i])){
            }else{
                json.put("FAMILY_FATHER_NONE","1");//家族史--父亲--无【0不勾选 1勾选】
            }
            //母亲
            if(StringUtils.isNotBlank(archive.getFamilyMotherHistorys())){
                json.put("FAMILY_MOTHER_NONE","0");//家族史--母亲--无【0不勾选 1勾选】
                String mhs[] = archive.getFamilyMotherHistorys().split(",");
                for(String mh : mhs){
                    if("1".equals(mh)){
                        json.put("FAMILY_MOTHER_HYPERTENSION","1");//家族史--母亲--高血压【0不勾选 1勾选】
                    } else if("2".equals(mh)){
                        json.put("FAMILY_MOTHER_DIABETES","1");//家族史--母亲--糖尿病【0不勾选 1勾选】
                    } else if("3".equals(mh)){
                        json.put("FAMILY_MOTHER_CORONARY","1");//家族史--母亲--冠心病【0不勾选 1勾选】
                    } else if("4".equals(mh)){
                        json.put("FAMILY_MOTHER_ALLERGY","1");//家族史--母亲--慢性阻塞性肺疾病【0不勾选 1勾选】
                    } else if("5".equals(mh)){
                        json.put("FAMILY_MOTHER_MALIGNANT","1");//家族史--母亲--恶性肿瘤【0不勾选 1勾选】
                    } else if("6".equals(mh)){
                        json.put("FAMILY_MOTHER_STROKE","1");//家族史--母亲--脑卒中【0不勾选 1勾选】
                    } else if("7".equals(mh)){
                        json.put("FAMILY_MOTHER_SCHIZOPHRENIA","1");//家族史--母亲--重性精神疾病【0不勾选 1勾选】
                    } else if("8".equals(mh)){
                        json.put("FAMILY_MOTHER_TB","1");//家族史--母亲--结核病【0不勾选 1勾选】
                    } else if("9".equals(mh)){
                        json.put("FAMILY_MOTHER_HEPATITIS","1");//家族史--母亲--肝炎【0不勾选 1勾选】
                    } else if("10".equals(mh)){
                        json.put("FAMILY_MOTHER_CONGENITAL","1");//家族史--母亲--先天畸形【0不勾选 1勾选】
                    } else if("11".equals(mh)){
                        json.put("FAMILY_MOTHER_OTHER","1");//家族史--母亲--其它【0不勾选 1勾选】
                    }
                }
            }else{
                json.put("FAMILY_MOTHER_NONE","1");//家族史--母亲--无【0不勾选 1勾选】
            }
            //兄妹
            if(StringUtils.isNotBlank(archive.getFamilyBrotherHistorys())){
                json.put("FAMILY_BROTHERS_NONE","0");//家族史--兄弟姐妹--无【0不勾选 1勾选】
                String bhs[] = archive.getFamilyBrotherHistorys().split(",");
                for(String bh : bhs){
                    if("1".equals(bh)){
                        json.put("FAMILY_BROTHERS_HYPERTENSION","1");//家族史--兄弟姐妹--高血压【0不勾选 1勾选】
                    } else if("2".equals(bh)){
                        json.put("AMILY_BROTHERS_DIABETES","1");//家族史--兄弟姐妹--糖尿病【0不勾选 1勾选】
                    } else if("3".equals(bh)){
                        json.put("FAMILY_BROTHERS_CORONARY","1");//家族史--兄弟姐妹--冠心病【0不勾选 1勾选】
                    } else if("4".equals(bh)){
                        json.put("FAMILY_BROTHERS_ALLERGY","1");//家族史--兄弟姐妹--慢性阻塞性肺疾病【0不勾选 1勾选】
                    } else if("5".equals(bh)){
                        json.put("FAMILY_BROTHERS_MALIGNANT","1");//家族史--兄弟姐妹--恶性肿瘤【0不勾选 1勾选】
                    } else if("6".equals(bh)){
                        json.put("FAMILY_BROTHERS_STROKE","1");//家族史--兄弟姐妹--脑卒中【0不勾选 1勾选】
                    } else if("7".equals(bh)){
                        json.put("FAMILY_BROTHERS_SCHIZOPHRENIA","1");//家族史--兄弟姐妹--重性精神疾病【0不勾选 1勾选】
                    } else if("8".equals(bh)){
                        json.put("FAMILY_BROTHERS_TB","1");//家族史--兄弟姐妹--结核病【0不勾选 1勾选】
                    } else if("9".equals(bh)){
                        json.put("FAMILY_BROTHERS_HEPATITIS","1");//家族史--兄弟姐妹--肝炎【0不勾选 1勾选】
                    } else if("10".equals(bh)){
                        json.put("FAMILY_BROTHERS_CONGENITAL","1");//家族史--兄弟姐妹--先天畸形【0不勾选 1勾选】
                    } else if("11".equals(bh)){
                        json.put("FAMILY_BROTHERS_OTHER","1");//家族史--兄弟姐妹--其它【0不勾选 1勾选】
                    }
                }
            }else{
                json.put("FAMILY_BROTHERS_NONE","1");//家族史--兄弟姐妹--无【0不勾选 1勾选】
            }
            //子女
            if(StringUtils.isNotBlank(archive.getFamilyBrotherHistorys())){
                json.put("FAMILY_CHILDREN_NONE","0");//家族史--兄弟姐妹--无【0不勾选 1勾选】
                String bhs[] = archive.getFamilyBrotherHistorys().split(",");
                for(String bh : bhs){
                    if("1".equals(bh)){
                        json.put("FAMILY_CHILDREN_HYPERTENSION","1");//家族史--子女--高血压【0不勾选 1勾选】
                    } else if("2".equals(bh)){
                        json.put("FAMILY_CHILDREN_DIABETES","1");//家族史--子女--糖尿病【0不勾选 1勾选】
                    } else if("3".equals(bh)){
                        json.put("FAMILY_CHILDREN_CORONARY","1");//家族史--子女--冠心病【0不勾选 1勾选】
                    } else if("4".equals(bh)){
                        json.put("FAMILY_CHILDREN_ALLERGY","1");//家族史--子女--慢性阻塞性肺疾病【0不勾选 1勾选】
                    } else if("5".equals(bh)){
                        json.put("FAMILY_CHILDREN_MALIGNANT","1");//家族史--子女--恶性肿瘤【0不勾选 1勾选】
                    } else if("6".equals(bh)){
                        json.put("FAMILY_CHILDREN_STROKE","1");//家族史--子女--脑卒中【0不勾选 1勾选】
                    } else if("7".equals(bh)){
                        json.put("FAMILY_CHILDREN_SCHIZOPHRENIA","1");//家族史--子女--重性精神疾病【0不勾选 1勾选】
                    } else if("8".equals(bh)){
                        json.put("FAMILY_BROTHERS_TB","1");//家族史--子女--结核病【0不勾选 1勾选】
                    } else if("9".equals(bh)){
                        json.put("FAMILY_CHILDREN_HEPATITIS","1");//家族史--子女--肝炎【0不勾选 1勾选】
                    } else if("10".equals(bh)){
                        json.put("FAMILY_CHILDREN_CONGENITAL","1");//家族史--子女--先天畸形【0不勾选 1勾选】
                    } else if("11".equals(bh)){
                        json.put("FAMILY_CHILDREN_OTHER","1");//家族史--子女--其它【0不勾选 1勾选】
                    }
                }
            }else{
                json.put("FAMILY_CHILDREN_NONE","1");//家族史--子女--无【0不勾选 1勾选】
            }
        }else{
            json.put("FAMILY_FATHER_NONE","1");// "FAMILY_FATHER_NONE":"家族史--父亲--无【0不勾选 1勾选】(同一类别,新增时,默认勾选)",
            json.put("FAMILY_MOTHER_NONE","1");// "FAMILY_MOTHER_NONE":"家族史--母亲--无【0不勾选 1勾选】(同一类别,新增时,默认勾选)",
            json.put("FAMILY_BROTHERS_NONE","1");//  "FAMILY_BROTHERS_NONE":"家族史--兄弟姐妹--无【0不勾选 1勾选】(同一类别,新增时,默认勾选)",
            json.put("FAMILY_CHILDREN_NONE","1");//  "FAMILY_CHILDREN_NONE":"家族史--子女--无【0不勾选 1勾选】(同一类别,新增时,默认勾选)",
        }
        json.put("SURGERY","0");// "SURGERY":"既往史--手术--【0 无 1 有】(同一类别,新增时,默认选无)",
        String response = jwArchivesService.saveSickArchiveRecord(com.alibaba.fastjson.JSONObject.toJSONString(json, SerializerFeature.WriteMapNullValue),archive.getDoctorCode());
        if("0".equals(response)){
            return -1;
        }
        //保存建档记录
        SocialSecurityInfo info = new SocialSecurityInfo();
        info.setXming0(p.getName());
        info.setXbie00(p.getSex()+"");
        info.setSfzh18(p.getIdcard());
        info.setId0000(p.getIdcard());
        info.setCardno(p.getSsc());
        info.setCard16(p.getSsc());
        info.setCsrqi0(archive.getBrithday().replace("-",""));
        info.setGrsfen("8");
        info.setGzztai("01");
        socialSecurityInfoDao.save(info);
        return 1;
    }
    public int createProfile(PatientArchivesDto archive) throws Exception{
        Patient p = patientDao.findByCode(archive.getPatient());
        com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
        json.put("ARCHIVE_TIME", DateUtil.getStringDateShort());//建档时间
        json.put("ARCHIVE_STATUS","3");//档案状态【1.未管理 2.死亡 3.正常 4.高危】
        json.put("SICK_NAME",p.getName());//姓名
        json.put("SICK_SEX",archive.getSex());//性别【1.男 2.女 9 未知】
        json.put("BIRTHDAY",archive.getBrithday());//出生日期
        json.put("ZONE_CODE",archive.getJwCountryCode());//所属社区【ZONE_DICT】
        json.put("IDENTITY_TYPE","1");//证件类型【IDENTITY_TYPE_DICT】
        json.put("IDENTITY_CARD_NO",p.getIdcard());//身份证号
        json.put("HOME_PHONE",p.getMobile());//本人电话
        json.put("HOME_ADDRESS",archive.getAdress());//现住址
        json.put("ORG_ID","0");//新增默认传0
        json.put("RESIDENCE","1");//户籍【1.户籍 2.非户籍】
        json.put("NATIONAL",archive.getNation());//民族【NATION_DICT】
        json.put("ORIGO","350200");//户口所在地【ZONE_DICT】
        json.put("BLOOD",archive.getBlood());//血型【1.A型 2.3.O型4.AB型 5.不详】
        json.put("BLOOD_RH","1");//RH阴性【1.否 2.是 3.不详】
        json.put("MARRIAGE",archive.getMarry());//婚姻状况【10.未婚 20.已婚 30.丧偶 40.离婚 90.未说明的婚姻状况】
        //补充参数
        json.put("ALLERGIC_WITHOUT","1");//药物过敏史--无【0不勾选 1勾选】(同一类别,新增时,默认勾选)",
        json.put("TRAUMA","0");// "TRAUMA":"既往史--外伤--【0 无 1 有】(同一类别,新增时,默认选无)",
        json.put("TRANSFUSION","0");//   "TRANSFUSION":"既往史--输血--【0 无 1 有】(同一类别,新增时,默认选无)",
        json.put("EXPOSE_WITHOUT","1");//"EXPOSE_WITHOUT":"暴露史--无【0不勾选 1勾选】(同一类别,新增时,默认勾选)",
        //教育程度
        if(StringUtils.isNotBlank(archive.getEducation())){
            json.put("EDUCATION",archive.getEducation()+"");//文化程度
        }
        //职业
        if(StringUtils.isNotBlank(archive.getOccupation())){
            json.put("OCCUPATION",archive.getOccupation()+"");//职业
        }
        //支付方式
        if(StringUtils.isNotBlank(archive.getPayment())){
            json.put("MEDICAL_EXPENSES",archive.getPayment()+"");//支付方式
        }
        //药物过敏史
        if(StringUtils.isNotBlank(archive.getDrugAllergys())){
            json.put("ALLERGIC_WITHOUT","0");//药物过敏历史
            String as[] = archive.getDrugAllergys().split(",");
            for(String str : as){
                if("1".equals(str)){
                    json.put("ALLERGIC_PENICILLIN","1");//药物过敏史--青霉素
                }
                if("2".equals(str)){
                    json.put("ALLERGIC_SULFANILAMIDE","1");//药物过敏史--磺胺
                }
                if("3".equals(str)){
                    json.put("ALLERGIC_STREPTOMYCIN","1");//药物过敏史--链霉素
                }
                if("4".equals(str)){
                    json.put("ALLERGIC_OTHER","1");//药物过敏史--其它
                }
            }
        }else{
            json.put("ALLERGIC_WITHOUT","1");//药物过敏历史
        }
        //既往史
        if(StringUtils.isNotBlank(archive.getPastHistorys())){
            json.put("PAST_NONE","0");//既往史
            String phs[] = archive.getPastHistorys().split(",");
            String dates[] = archive.getPastHistoryDate().split(",");
            for(int i=0 ;i<phs.length ; i++){
                if("1".equals(phs[i])){
                    json.put("PAST_HYPERTENSION","1");//既往史--疾病--高血压【0不勾选 1勾选】
                    if(!"0".equals(dates[i])){
                        json.put("PAST_HYPERTENSION_DATE",dates[i]);//既往史--疾病--高血压日期
                    }
                }else if("2".equals(phs[i])){
                    json.put("PAST_DIABETES","1");//既往史--疾病--糖尿病【0不勾选 1勾选】
                    if(StringUtils.isNotBlank(dates[i])){
                    if(!"0".equals(dates[i])){
                        json.put("PAST_DIABETES_DATE",dates[i]);//既往史--疾病--糖尿病日期
                    }
                }
@ -508,9 +816,9 @@ public class PatientInfoService extends BaseService {
//                        json.put("PAST_HYPERTENSION_DATE",dates[i]);//既往史--疾病--高血压日期
//                    }
//                }
                if("4".equals(phs[i])){
                else if("4".equals(phs[i])){
                    json.put("PAST_OTHER","1");//既往史--疾病--其它【0不勾选 1勾选】
                    if(StringUtils.isNotBlank(dates[i])){
                    if(!"0".equals(dates[i])){
                        json.put("PAST_OTHER_CONTENT_DATE",dates[i]);//既往史--疾病--高血压日期
                    }
                }
@ -878,8 +1186,8 @@ public class PatientInfoService extends BaseService {
        password = MD5.GetMD5Code(password + salt);
        Patient p = patientService.registerAPPBydoctor(idcard,archive.getSsc(),archive.getName(),archive.getMobile(),password,salt,salt,3);
        createProfile(archiveJson);
        archive.setPatient(p.getCode());
        createProfile(archive);
        rs.put("code","1");
        rs.put("mes","操作成功!") ;
@ -914,7 +1222,7 @@ public class PatientInfoService extends BaseService {
        JSONObject rs = (JSONObject) jsonArray.get(0);
        String sql ="SELECT " +
                " TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age, " +
                " p.photo, " +
                " p.photo " +
                " FROM " +
                " wlyy_patient p " +
                " WHERE " +
@ -928,10 +1236,57 @@ public class PatientInfoService extends BaseService {
        return rs;
    }
    public Map<String,Object> getPatientInfo(String idcard){
        String sql ="SELECT " +
                " TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age, " +
                " p.photo," +
                " p.code," +
                " p.name" +
                " FROM " +
                " wlyy_patient p " +
                " WHERE " +
                " p.idcard = '"+idcard+"'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list!=null&&list.size()>0){
           return  list.get(0);
        }
        return null;
    }
    public  Map<String,Object> getPatientSignFamily(String idcard){
        SignFamily f = signFamilyDao.findByIdcard(idcard);
        Map<String,Object> rs = new HashedMap();
        rs.put("SignFamily",f);
        String sql ="SELECT " +
                " TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age, " +
                " p.photo," +
                " p.sex " +
                " FROM " +
                " wlyy_patient p " +
                " WHERE " +
                " p.idcard = '"+idcard+"'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list!=null&&list.size()>0){
            Map<String,Object>  s = list.get(0);
            rs.put("patient",s);
        }
        String sqlService = "SELECT * FROM wlyy_sign_family_server f WHERE f.sign_code = '"+f.getCode()+"' ";
        List<Map<String,Object>> services = jdbcTemplate.queryForList(sqlService);
        rs.put("servers",services);
        String sqlLabel = "SELECT  * " +
                " FROM " +
                " wlyy_sign_patient_label_info l " +
                " WHERE " +
                " l.patient = '"+f.getPatient()+"' " +
                " AND l.label_type = '2' " +
                " AND l.`status` = '1'";
        List<Map<String,Object>> lbs = jdbcTemplate.queryForList(sqlLabel);
        rs.put("labels",lbs);
        return rs;
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java

@ -1135,7 +1135,7 @@ public class FamilyMemberService extends BaseService {
        memberDao.save(fmt);
        //设置家人openid
        if(!"undefined".equals(m.getOpenid())&&StringUtils.isNotBlank(m.getOpenid())){
        if(!"undefined".equals(p.getOpenid())&&StringUtils.isNotBlank(p.getOpenid())){
            m.setOpenid(p.getOpenid());
            m.setOpenidTime(new Date());
            patientDao.save(m);

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

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

@ -9,6 +9,7 @@ import com.yihu.wlyy.entity.charge.PatientPopups;
import com.yihu.wlyy.entity.charge.WlyyCharge;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.patient.Patient;
@ -23,13 +24,14 @@ 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;
@ -94,7 +96,8 @@ public class PatientPrescriptionPayService extends BaseService {
    private HttpClientUtil httpClientUtil;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private MessageService messageService;
    //    引入实例
    @Autowired
    private PayConfiguraDao configuraDao;
@ -758,25 +761,28 @@ 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)) {
                                    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查看"));
                                    String keywords = "分配配送员" + "," + doctor.getHospitalName() + "," + doctor.getName();
                                    sendParams.add(new BasicNameValuePair("keywords", keywords));
                                    httpClientUtil.post(url, sendParams, "UTF-8");
                            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"));
                                        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查看"));
                                        String keywords = "分配配送员" + "," + doctor.getHospitalName() + "," +doctor.getName();
                                        sendParams.add(new BasicNameValuePair("keywords", keywords));
                                        httpClientUtil.post(url, sendParams, "UTF-8");
                                    }
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                        //支付成功生成二维码
@ -1604,7 +1610,7 @@ public class PatientPrescriptionPayService extends BaseService {
    }
    /**
     * 查询居民支付弹窗设置
     * 查询缴费居民手机绑定情况
     *
     * @param user 需要缴费的患者code(共济支付为被代理人)
     * @return

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

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

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

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

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

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

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

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

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

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

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

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

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

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

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwArchivesService.java

@ -876,7 +876,7 @@ public class JwArchivesService {
                        JSONArray jsonArray = data.getJSONArray("DATA");
                        // {"ARCHIVE_ID":"档案ID","SICK_NAME":"病人姓名","SICK_SEX":"性别","BIRTHDAY":"出生日期","IDENTITY_CARD_NO":"身份证号码","ZONE_CODE":"归属辖区","HOME_ADDRESS":"现住址","INSUR_CARD_NO":"医保卡号"}
                        jsonArray.forEach(one->{
                            JSONObject jsonObject = new JSONObject(one);
                            JSONObject jsonObject = (JSONObject)one;
                            JSONObject js = new JSONObject();
                            js.put("archiveId",jsonObject.get("ARCHIVE_ID"));
                            js.put("sickName",jsonObject.get("SICK_NAME"));

+ 8 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/CommonUtil.java

@ -476,7 +476,7 @@ public class CommonUtil {
                logger.info("result :" + returnStr.toString());
                if (returnStr != null) {
                    //1.3.7去掉前缀
                    fileUrls += returnStr;
                    fileUrls += returnStr+",";
                    f.delete();
                }
            } else {
@ -485,12 +485,13 @@ public class CommonUtil {
                logger.info("result :" + returnStr.toString());
                if (returnStr != null) {
                    //1.3.7去掉前缀
                    fileUrls += returnStr;
                    fileUrls += returnStr+",";
                }
            }
        }
        logger.info(" toNeiWang end files :" + fileUrls);
        return fileUrls;
        return fileUrls.substring(0,fileUrls.length()-1);
    }
    private String request(HttpServletRequest request, String path) {
@ -585,4 +586,8 @@ public class CommonUtil {
        return result;
    }
    public static void main(String[] args) {
        System.out.println("aaa,aaa,".substring(0,"aaa,aaa,".length()-2));
    }
}

+ 13 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java

@ -486,6 +486,19 @@ public class PatientInfoController extends BaseController {
        }
    }
    @RequestMapping(value = "getPatientInfo", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取居民信息")
    public String getPatientInfo(@ApiParam(value = "身份证号", name = "idcard") @RequestParam(required = true)String idcard){
        try {
            // 获取医生下的患者
            return write(200, "请求成功", "data",patientInfoService.getPatientInfo(idcard));
        } catch (Exception e) {
            error(e);
            return error( -1, "查询失败!");
        }
    }
    @RequestMapping(value = "getPatientSignFamily", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取居民签约信息")

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

+ 12 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java

@ -1001,5 +1001,16 @@ public class PatientController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "getArchiveComboList", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("获取居民建档详细信息下拉列表集合")
    public String getArchiveComboList(){
        try {
            // 获取医生下的患者
            return write(200, "请求成功", "data",patientInfoService.getArchiveComboList());
        } catch (Exception e) {
            error(e);
            return error( -1, "查询失败!");
        }
    }
}

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

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

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