Pārlūkot izejas kodu

Merge branch 'dev' of huangwenjie/wlyy2.0 into dev

huangwenjie 5 gadi atpakaļ
vecāks
revīzija
5e6c720d1b

+ 18 - 0
business/base-service/src/main/java/com/yihu/jw/wechat/dao/BasePatientWechatDao.java

@ -0,0 +1,18 @@
package com.yihu.jw.wechat.dao;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @author huangwenjie
 * @date 2020/3/10 14:43
 */
public interface BasePatientWechatDao extends
		PagingAndSortingRepository<BasePatientWechatDo, String>,
		JpaSpecificationExecutor<BasePatientWechatDo> {
	
	List<BasePatientWechatDo> findByWechatIdAndPatientId (String wechatid,String patientId);
}

+ 48 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WxTemplateService.java

@ -1,20 +1,24 @@
package com.yihu.jw.base.service.wx;
package com.yihu.jw.wechat.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.base.wx.WxTemplateDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import com.yihu.jw.wechat.dao.WxTemplateDao;
import com.yihu.jw.wechat.service.WxAccessTokenService;
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.stereotype.Service;
import java.util.ArrayList;
@ -39,7 +43,48 @@ public class WxTemplateService {
    @Autowired
    private WeixinMessagePushUtils weixinMessagePushUtils;
    
    @Value("${wechat.id}")
    private String wechatId;
    
    @Autowired
    private BasePatientDao basePatientDao;
    
    @Autowired
    private BasePatientWechatDao basePatientWechatDao;
    
    
    /**
     * 发送微信模版消息-小程序视频
     * @param sender_id 发送者ID
     * @param sender_name 发送者姓名
     * @param reciver_id 接收者ID
     * @param reciver_name 接收者姓名
     * @param session_id 会话ID
     */
    public String sendWeTempMesMiniProgram(String sender_id, String sender_name, String reciver_id, String reciver_name,String session_id)throws Exception {
        BasePatientDO basePatientDO = basePatientDao.findById(reciver_id);
        if(basePatientDO!=null){
            List<BasePatientWechatDo> ps = basePatientWechatDao.findByWechatIdAndPatientId(wechatId,reciver_id);
            if(ps.isEmpty()){
                logger.info("该用户"+sender_name+"没有openid,无法推送模版消息,用户ID:"+sender_id);
            }else{
                for (BasePatientWechatDo basePatientWechatDo:ps){
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId,"template_consult_notice","spthtx",1);
                    config.setFirst(config.getFirst().replace("key1",sender_name));
                    config.setPagepath(config.getPagepath()+""+reciver_id+"&doctorName="+sender_name+"&role=patient&roomID="+session_id+"&template=1v1&debugMode=false&cloudenv=PRO");
                    weixinMessagePushUtils.putWxMsg(wxAccessTokenService.getWxAccessTokenById(wechatId).getAccessToken(),basePatientWechatDo.getOpenid(),config);
                }
            }
        }else{
            throw new Exception("接收者ID错误,无法找到该账号");
        }
        return "success";
    }
    
    public String sendWeTempMesTest(String wechatId,String openid)throws Exception{
        WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId,"template_survey","test",1);
        config.setFirst(config.getFirst().replace("key1","小明"));
@ -93,4 +138,5 @@ public class WxTemplateService {
        }
        return rs;
    }
}

+ 15 - 13
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -170,7 +170,7 @@ public class ImService {
	 * @param status 状态
	 * @return
	 */
	public List<ConsultVO>  findConsultRecordByPatient(String patient, String id,Integer type, int page,int pagesize, String title,Integer status) {
	public List<ConsultVO>  findConsultRecordByPatient(String patient, String id,String type, int page,int pagesize, String title,Integer status) {
		if(page >=1){
			page --;
@ -197,7 +197,7 @@ public class ImService {
				"base_doctor d, " +
				"base_doctor_hospital h " +
				"WHERE a.id=b.consult and d.id = h.doctor_code " +
				"AND b.doctor=d.id AND a.patient='"+patient+"' AND a.type="+type;
				"AND b.doctor=d.id AND a.patient='"+patient+"' AND a.type in ("+type+")";
		List<ConsultVO> result = new ArrayList<>();
		
		if(!StringUtils.isEmpty(title)){
@ -234,7 +234,7 @@ public class ImService {
	 * @param title 标题关键字
	 * @return
	 */
	public Long countConsultRecordByPatient(String patient, String id,Integer type, String title) {
	public Long countConsultRecordByPatient(String patient, String id,String type, String title) {
		
		String  sql = "SELECT " +
				" COUNT(1) AS total " +
@ -242,7 +242,7 @@ public class ImService {
				"wlyy_consult_team b," +
				"base_doctor d " +
				"WHERE a.id=b.consult " +
				"AND b.doctor=d.id AND a.patient='"+patient+"' AND a.type="+type;
				"AND b.doctor=d.id AND a.patient='"+patient+"' AND a.type in ("+type+") ";
		List<ConsultVO> result = new ArrayList<>();
		
		if(!StringUtils.isEmpty(title)){
@ -1454,6 +1454,7 @@ public class ImService {
		patientinfoObj.put("sex",basePatientDO.getSex());
		patientinfoObj.put("mobile",basePatientDO.getMobile());
		patientinfoObj.put("address",basePatientDO.getAddress());
		patientinfoObj.put("photo",basePatientDO.getPhoto());
		Integer age = DateUtil.getAgeForIdcard(basePatientDO.getIdcard());
		patientinfoObj.put("age",age);
		result.put("patientInfo",patientinfoObj);
@ -1661,7 +1662,7 @@ public class ImService {
	 * @return
	 */
	public List<ConsultVO>  findConsultRecordByDoctor(String doctor, String id,
	                                                  Integer type, Integer status,
	                                                  String type, Integer status,
	                                                  int page,int pagesize,
	                                                  String title,String start_time,String end_time) {
		
@ -1674,7 +1675,8 @@ public class ImService {
		}
		
		String  sql = "";
		if(1 == type || 15 ==type){
		//专家咨询
		if("1".equals(type) || "15".equals(type) || type.contains(",")){
			sql = "SELECT " +
					"a.id AS id," +
					"a.type AS type," +
@ -1750,9 +1752,9 @@ public class ImService {
			
		}
		
		//咨询状态
		if(type != 0){
				sql +=" AND a.type="+type;
		//咨询类型
		if(!StringUtils.isEmpty(type)){
				sql +=" AND a.type in ("+type+")" ;
		}
		
		if (!StringUtils.isEmpty(id)) {
@ -1775,7 +1777,7 @@ public class ImService {
	 * @param end_time 结束时间
	 * @return
	 */
	public Long countConsultRecordByDoctor(String doctor, String id,Integer type, Integer status,String title,String start_time,String end_time) {
	public Long countConsultRecordByDoctor(String doctor, String id,String type, Integer status,String title,String start_time,String end_time) {
		
		String  sql = "SELECT " +
				" COUNT(1) AS total " +
@ -1812,9 +1814,9 @@ public class ImService {
		}
		
		
		//咨询状态
		if(type != 0){
			sql +=" AND a.type="+type;
		//咨询类型
		if(!StringUtils.isEmpty(type)){
			sql +=" AND a.type in ("+type+")";
		}
		
		if (!StringUtils.isEmpty(id)) {

+ 76 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/BasePatientWechatDo.java

@ -0,0 +1,76 @@
package com.yihu.jw.entity.base.wx;
import com.yihu.jw.entity.UuidIdentityEntity;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * @author huangwenjie
 * @date 2020/3/10 14:39
 */
@Entity
@Table(name = "base_patient_wechat")
public class BasePatientWechatDo extends UuidIdentityEntity {
	
	private String saasId;
	private String wechatId;
	private String patientId;
	private String openid;
	private String unionid;
	private String createTime;
	
	@Column(name = "saas_id")
	public String getSaasId() {
		return saasId;
	}
	
	public void setSaasId(String saasId) {
		this.saasId = saasId;
	}
	
	@Column(name = "wechat_id")
	public String getWechatId() {
		return wechatId;
	}
	
	public void setWechatId(String wechatId) {
		this.wechatId = wechatId;
	}
	
	@Column(name = "patient_id")
	public String getPatientId() {
		return patientId;
	}
	
	public void setPatientId(String patientId) {
		this.patientId = patientId;
	}
	
	public String getOpenid() {
		return openid;
	}
	
	public void setOpenid(String openid) {
		this.openid = openid;
	}
	
	public String getUnionid() {
		return unionid;
	}
	
	public void setUnionid(String unionid) {
		this.unionid = unionid;
	}
	
	@Column(name = "create_time")
	public String getCreateTime() {
		return createTime;
	}
	
	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}
}

+ 3 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -529,6 +529,9 @@ public class BaseHospitalRequestMapping {
    
        //医生端:查询会话视频邀请状态
        public static final String getVideoInviteStatus="getVideoInviteStatus";
    
        //医生端:发起/断开 会话小程序视频邀请
        public static final String videoInviteMiniProgram="videoInviteMiniProgram";
    }

+ 0 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/wx/WechatController.java

@ -3,7 +3,6 @@ package com.yihu.jw.base.endpoint.wx;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.base.service.wx.WechatService;
import com.yihu.jw.base.service.wx.WxTemplateService;
import com.yihu.jw.entity.base.wx.*;
import com.yihu.jw.restmodel.base.wx.*;
import com.yihu.jw.restmodel.web.Envelop;

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/wx/WxTemplateController.java

@ -1,9 +1,9 @@
package com.yihu.jw.base.endpoint.wx;
import com.yihu.jw.base.service.wx.WxTemplateService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.WechatRequestMapping;
import com.yihu.jw.wechat.service.WxTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;

+ 23 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java

@ -7,7 +7,6 @@ import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
@ -26,6 +25,7 @@ import com.yihu.jw.sms.service.ZhongShanSMSService;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.wechat.service.WxTemplateService;
import com.yihu.jw.wlyy.service.WlyyBusinessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -81,6 +81,8 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
	private HospitalSystemMessageService hospitalSystemMessageService;
	@Autowired
	public BasePatientDao basePatientDao;
	@Autowired
	private WxTemplateService wxTemplateService;
	
	
@ -350,7 +352,7 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
			@ApiParam(name = "id", value = "咨询ID")
			@RequestParam(value = "id",required = false) String id,
			@ApiParam(name = "type", value = "咨询类型")
			@RequestParam(value = "type",required = true) Integer type,
			@RequestParam(value = "type",required = true) String type,
			@ApiParam(name = "status", value = "咨询状态:0全部,1候诊中,2就诊中,3结束")
			@RequestParam(value = "status",required = true) Integer status,
			@ApiParam(name = "start_time", value = "开始时间 YYYY-MM-DD HH:MM:SS")
@ -748,4 +750,23 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
		
	}
	@PostMapping(value = BaseHospitalRequestMapping.DodtorIM.videoInviteMiniProgram)
	@ApiOperation(value = "医生端:发起/断开 会话小程序视频邀请", notes = "医生端:发起/断开 会话小程序视频邀请")
	public Envelop videoInviteMiniProgram(@ApiParam(name = "sender_id", value = "发起人")
	                                 @RequestParam(value = "sender_id",required = true) String sender_id,
	                                 @ApiParam(name = "sender_name", value = "发起人名字")
	                                 @RequestParam(value = "sender_name",required = true) String sender_name,
                                      @ApiParam(name = "reciver_id", value = "接收人")
                                      @RequestParam(value = "reciver_id",required = true) String reciver_id,
                                      @ApiParam(name = "reciver_name", value = "接收人")
                                      @RequestParam(value = "reciver_name",required = true) String reciver_name,
                                      @ApiParam(name = "reciver_type", value = "接收人类型1居民 2医生")
                                      @RequestParam(value = "reciver_name",required = true) String reciver_type,
                                      @ApiParam(name = "session_id", value = "会话ID")
                                      @RequestParam(value = "session_id",required = true) String session_id
	                                      )throws Exception  {
		wxTemplateService.sendWeTempMesMiniProgram(sender_id,sender_name,reciver_id,reciver_name,session_id);
		return success("操作成功");
	}
}

+ 5 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java

@ -92,6 +92,9 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
	@Value("${fastDFS.fastdfs_file_url}")
	private String fastdfs_file_url;
	
	@Value("${wlyy.url}")
	private String wlyyUrl;
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.records)
	@ApiOperation(value = "患者咨询记录查询")
	public Envelop records(
@ -102,7 +105,7 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
								@ApiParam(name = "id", value = "咨询ID")
								@RequestParam(value = "id",required = false) String id,
								@ApiParam(name = "type", value = "咨询类型")
								@RequestParam(value = "type",required = true) Integer type,
								@RequestParam(value = "type",required = true) String type,
								@ApiParam(name = "status", value = "咨询状态:0全部,1候诊中,2就诊中,3结束")
								@RequestParam(value = "status",required = false) Integer status,
								@ApiParam(name = "page", value = "第几页")
@ -416,7 +419,7 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
			}
			//发送厦门i健康智能推送
			try{
				String wxurl = "http://www.xmtyw.cn/wlyy/im/common/message/sendDoctorTemplateByDoctorIdcard?sessionId="+p.getId()+"_"+d.getId()+"_1&sessionType=1&from="+p.getId()+"&content="+URLEncoder.encode(symptoms)+"&businessType=1&doctor_idcard="+d.getIdcard()+"&patientName="+URLEncoder.encode(p.getName())+"&url=1";
				String wxurl = wlyyUrl+"/im/common/message/sendDoctorTemplateByDoctorIdcard?sessionId="+p.getId()+"_"+d.getId()+"_1&sessionType=1&from="+p.getId()+"&content="+URLEncoder.encode(symptoms)+"&businessType=1&doctor_idcard="+d.getIdcard()+"&patientName="+URLEncoder.encode(p.getName())+"&url=1";
				logger.info("发送厦门i健康智能推送url:"+wxurl);
				wlyyBusinessService.sendDoctorTemplateByDoctorIdcard(wxurl);
			}catch (Exception e){

+ 1 - 1
svr/svr-internet-hospital/src/main/resources/application.yml

@ -177,7 +177,7 @@ fastDFS:
fast-dfs:
  tracker-server: 172.26.0.110:22122 #服务器地址
wechat:
  id: 97ed8a0a-4f07-4b85-ab02-b716c611a464  # base库中,wx_wechat 的id字段
  id: xm_test_ihealth_wx  # base库中,wx_wechat 的id字段
# 短信验证码发送的客户端标识,居民端
sms:
  clientId: EwC0iRSrcP