Explorar el Código

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

# Conflicts:
#	common/common-entity/sql记录
yeshijie hace 3 años
padre
commit
c32870988e

+ 2 - 0
svr/svr-base/src/main/java/com/yihu/SvrBaseApplication.java

@ -7,6 +7,7 @@ import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync;
import javax.servlet.MultipartConfigElement;
@ -16,6 +17,7 @@ import javax.servlet.MultipartConfigElement;
 */
@SpringBootApplication
@EnableJpaAuditing
@EnableAsync
public class SvrBaseApplication extends SpringBootServletInitializer {
    public static void main(String[] args)  {

+ 4 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/course/RecruitStudentsRecordService.java

@ -3,6 +3,7 @@ package com.yihu.jw.base.service.course;
import com.yihu.jw.base.dao.course.PatientOrderRefundDao;
import com.yihu.jw.base.dao.course.RecruitStudentsDao;
import com.yihu.jw.base.dao.course.RecruitStudentsRecordDao;
import com.yihu.jw.base.util.WxMessageUtil;
import com.yihu.jw.entity.care.course.PatientOrderRefundDO;
import com.yihu.jw.entity.care.course.RecruitStudentsDO;
import com.yihu.jw.entity.care.course.RecruitStudentsRecordDO;
@ -31,6 +32,8 @@ public class RecruitStudentsRecordService extends BaseJpaService<RecruitStudents
    private RecruitStudentsRecordDao recruitStudentsRecordDao;
    @Autowired
    private RecruitStudentsDao recruitStudentsDao;
    @Autowired
    private WxMessageUtil wxMessageUtil;
    /**
     * 退费操作
@ -77,6 +80,7 @@ public class RecruitStudentsRecordService extends BaseJpaService<RecruitStudents
            }
        }
        recruitStudentsRecordDao.save(list);
        wxMessageUtil.sengdWxTemplates(list);
//        if(re.length()>0){
//            re = re.substring(0,re.length()-2);
//            return "("+ re +")人员状态不是待录取,无法录取,其他人员录取成功";

+ 238 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/util/WxMessageUtil.java

@ -0,0 +1,238 @@
package com.yihu.jw.base.util;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxAccessTokenDO;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.care.course.RecruitStudentsRecordDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WxAccessTokenDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.util.List;
/**
 * Created by liub on 2020/12/28.
 */
@Component
public class WxMessageUtil {
    private static Logger logger = LoggerFactory.getLogger(MessageUtil.class);
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private WeixinMessagePushUtils weixinMessagePushUtils;
    @Autowired
    private WxTemplateConfigDao wxTemplateConfigDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private SystemMessageDao systemMessageDao;
    @Autowired
    private WxAccessTokenDao wxAccessTokenDao;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private BasePatientDao basePatientDao;
    @Value("${wechat.id}")
    private String wechatId;
    @Value("${wechat.url}")
    private String serviceUrl;
    @Autowired
    private BasePatientWechatDao basePatientWechatDao;
    @Autowired
    private BaseOrgDao orgDao;
    /**
     * 批量异步发送微信模板消息
     */
    @Async
    public void sengdWxTemplates(List<RecruitStudentsRecordDO> list){
        String orgMobile = "";
        String orgId = "";
        for (RecruitStudentsRecordDO recordDO:list){
            if("".equals(orgId)){
                BaseOrgDO orgDO = orgDao.findByCode(recordDO.getOrgCode());
                orgMobile = orgDO.getMobile();
                orgId = orgDO.getId();
            }
            /**
             * 学生被录取的时候推送一个录取成功通知微信模板消息
             dc--ecFzT5vrnUFTNdVB6Sg4wXBnv14IX5sFP3jCFfk
             您好,恭喜您已被【机构名】成功录取
             姓名:【报名人姓名】
             手机号:【报名人手机号】
             请及时前往托育机构完成报名,如有疑问请联系招生热线【机构联系方式】
             (点击进入对应报名的机构详情页)
             */
            String first = "您好,恭喜您已被"+recordDO.getOrgName()+"成功录取";
            String remark = "请及时前往托育机构完成报名,如有疑问请联系招生热线"+orgMobile;
            String url = serviceUrl+"/medical-care-patient/onlineRegistration/nurseriesdetail?id="+orgId;
            List<BasePatientWechatDo> basePatientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId(wechatId,recordDO.getPatient());
            if(basePatientWechatDos.size()>0){
                String openId = basePatientWechatDos.get(0).getOpenid();
                putTemplateWxMessage(wechatId,"template_success_notice","cgrxtz",openId,first,url,remark,2,null,
                        recordDO.getPatientName(),recordDO.getMobile());
            }
        }
    }
    /**
     *
     * @param wechatId
     * @param templateName
     * @param scene
     * @param openId
     * @param first
     * @param url 跳转链接
     * @param remark
     * @param type  模板通知类型
     * @param json 用于对跳转连接的修改,
     * @param keywords
     */
    public void putTemplateWxMessage(String wechatId, String templateName, String scene, String openId, String first
            ,String url, String remark, Integer type,JSONObject json,String ...keywords) {
        try {
            System.out.println(wechatId);
            WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
            if (wxAccessTokenDO == null) {
                logger.info("wx_access_token表获取为空,wechatId" + wechatId);
                return;
            }
            WxTemplateConfigDO templateConfig = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, templateName, scene, 1);
            WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
            BeanUtils.copyProperties(templateConfig,newConfig);
            if (newConfig == null) {
                logger.info("微信模板不存在!请确认wechatId:" + wechatId + ",templateName:" + templateName + ",scene:" + scene);
                return;
            }
            logger.info("微信模板推送前");
            if (StringUtils.isNoneBlank(first)){
                newConfig.setFirst(first);
            }
            if (StringUtils.isNoneBlank(url)){
               newConfig.setUrl(url);
            }
            if (StringUtils.isNoneBlank(remark)){
                newConfig.setRemark(remark);
            }
            newConfig = setTemPlateUrl(newConfig,type,openId,json);
            int keyLength = keywords.length;
            if (keyLength >= 1) {
               if(StringUtils.isNoneBlank(keywords[0])){
                   newConfig.setKeyword1(keywords[0]);
                }
            }
            if (keyLength >= 2) {
                if(StringUtils.isNoneBlank(keywords[1])){
                    newConfig.setKeyword2(keywords[1]);
                }
            }
            if (keyLength >= 3) {
                if(StringUtils.isNoneBlank(keywords[2])){
                    newConfig.setKeyword3(keywords[2]);
                }
            }
            if (keyLength >= 4) {
                if(StringUtils.isNoneBlank(keywords[3])){
                    newConfig.setKeyword4(keywords[3]);
                }
            }
            if (keyLength >= 5) {
                if(StringUtils.isNoneBlank(keywords[4])){
                    newConfig.setKeyword5(keywords[4]);
                }
            }
            if (keyLength >= 6) {
                if(StringUtils.isNoneBlank(keywords[5])){
                    newConfig.setKeyword6(keywords[5]);
                }
            }
            if (keyLength >= 7) {
                if(StringUtils.isNoneBlank(keywords[6])){
                    newConfig.setKeyword7(keywords[6]);
                }
            }
            //发起微信消息模板推送
            weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(), openId, newConfig);
            logger.info("微信模板消息推送后");
        } catch (Exception e) {
            logger.info("微信模板推送异常");
            e.printStackTrace();
        }
    }
    public WxTemplateConfigDO setTemPlateUrl(WxTemplateConfigDO wxTemplateConfigDO,Integer type,String openid,JSONObject json){
        String url =  "/";
        if (json==null){
            return wxTemplateConfigDO;
        }
        switch (type){
            case 1:
                //咨询回复
                wxTemplateConfigDO.setUrl(wxTemplateConfigDO.getUrl() + "?sessionId=" + json.getString("sessionId")
                        +"&type="+json.getString("consultType"));
                break;
            case 19:
                String urlStr= wxTemplateConfigDO.getUrl();
                boolean status = urlStr.contains("openid=");
                if(!status){
                    urlStr=json.getString("url")+"?openid=" + openid;
                }
                wxTemplateConfigDO.setUrl(url + urlStr );
                break;
            case 30:
                //反馈通知 测试 TPbq9m0SAiVfRhXtXq17SDmYIfrJ8Whp2NpSrq9wlfI
                if(json.containsKey("consult")) {
                    wxTemplateConfigDO.setUrl(url + wxTemplateConfigDO.getUrl() + "?openid=" + openid + "&consult=" + json.getString("consult"));
                }else if (json.containsKey("id")){
                    wxTemplateConfigDO.setUrl(url + wxTemplateConfigDO.getUrl() + "?openid=" + openid + "&id=" + json.getString("id"));
                }else if(json.containsKey("relationCode")){
                    wxTemplateConfigDO.setUrl(url + wxTemplateConfigDO.getUrl() + "?openid=" + openid );
                }else if(json.containsKey("resultCode")){
                    wxTemplateConfigDO.setUrl(url + wxTemplateConfigDO.getUrl() + "?resultCode=" + json.getString("resultCode"));
                }
                break;
            case 31:
                //上门服务医生评分
                wxTemplateConfigDO.setUrl(url + wxTemplateConfigDO.getUrl()+"?openid=" + openid + "&id=" + json.getString("id")+ "&finish=" + json.getString("finish"));
                break;
            case 32:
                String url1 = "wx/common/";
                wxTemplateConfigDO.setUrl(url1 + wxTemplateConfigDO.getUrl()+"?openid=" + openid + "&consult=" + json.getString("consult") + "&status=" + json.getInteger("status"));
                break;
            case 34:
                wxTemplateConfigDO.setUrl(url + wxTemplateConfigDO.getUrl() + "?openid=" + openid + "&orderId=" + json.getString("orderId")+ "&authorizeImage=" + json.getString("authorizeImage"));
                break;
            case 35:
                wxTemplateConfigDO.setUrl(url + wxTemplateConfigDO.getUrl()+json.getString("orderId")+"&isMask=1");
                break;
        }
        return wxTemplateConfigDO;
    }
}

+ 6 - 3
svr/svr-base/src/main/resources/application.yml

@ -79,7 +79,8 @@ configDefault: # 默认配置
tencent:
  secretId: AKIDa1C6k7D2astd6JGvKRJvFJ6dsrZ1C5h2
  secretKey: 7xWpsd7KGC3f16vUq0ucARRAcnhKfjX4
wechat:
  url: 1
---
spring:
  profiles: jwdev
@ -170,7 +171,8 @@ hospital:
wlyy:
  url: http://ehr.yihu.com/wlyy/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040
  id: hz_yyyzh_wx
  url: http://hzijk.cityihealth.com/
  flag: false
pay:
  flag: false
@ -629,7 +631,8 @@ hospital:
wlyy:
  url: 1
wechat:
  id: 1
  id: hz_yyyzh_wx
  url: http://hzijk.cityihealth.com/
  flag: false
pay:
  flag: false

+ 5 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/WxPushService.java

@ -63,9 +63,10 @@ public class WxPushService {
        json.put("sessionId",sessionId);
        json.put("consultType",consultType);
        List<BasePatientWechatDo> basePatientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId(wxId,consult.getPatient());
        String openId = basePatientWechatDos.get(0).getOpenid();
        messageUtil.putTemplateWxMessage(wxId,"template_consult_reply","zxhf",openId,first,null,null,1,json,
                DateUtil.getStringDate(),content,"已回复");
        if(basePatientWechatDos.size()>0){
            String openId = basePatientWechatDos.get(0).getOpenid();
            messageUtil.putTemplateWxMessage(wxId,"template_consult_reply","zxhf",openId,first,null,null,1,json,
                    DateUtil.getStringDate(),content,"已回复");
        }
    }
}