Procházet zdrojové kódy

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

 Conflicts:
	svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/wechat/WechatMenuController.java
	svr/svr-cloud-care/src/main/resources/wechat/weixin_menu.txt
Shi Kejing před 3 roky
rodič
revize
cb393ea9ef

+ 1 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -733,7 +733,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
            //
            String result =  txySmsService.sendMessage(username,captcha);
            if ("ok".equals(result)) {
            if ("Ok".equals(result)) {
                Captcha _captcha = new Captcha();
                _captcha.setCode(captcha);
                _captcha.setExpiresIn(300);

+ 54 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/consult/WxPushEndpoint.java

@ -0,0 +1,54 @@
package com.yihu.jw.care.endpoint.consult;
import com.yihu.jw.care.service.consult.WxPushService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/27
 * @Description:
 */
@RestController
@RequestMapping(value = "wxpush")
@Api(value = "im推送微信模板", description = "im推送微信模板", tags = {"im推送微信模板"})
public class WxPushEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private WxPushService wxPushService;
    @PostMapping(value = "sendWXTemplate")
    @ApiOperation(value = "发送微信模板消息")
    public Envelop sendWXTemplate(
            @ApiParam(name = "userName", value = "推送人姓名")
            @RequestParam(value = "userName", required = true) String userName,
            @ApiParam(name = "idCard", value = "推送人身份证")
            @RequestParam(value = "idCard", required = false) String idCard,
            @ApiParam(name = "phone", value = "推送人手机号")
            @RequestParam(value = "phone", required = false) String phone,
            @ApiParam(name = "title", value = "推送标题")
            @RequestParam(value = "title", required = false) String title,
            @ApiParam(name = "url", value = "跳转链接")
            @RequestParam(value = "url", required = false) String url,
            @ApiParam(name = "content", value = "内容简介")
            @RequestParam(value = "content", required = true) String content,
            @ApiParam(name = "topidId", value = "咨询id")
            @RequestParam(value = "topidId", required = true) String topidId,
            @ApiParam(name = "sessionId", value = "会话id")
            @RequestParam(value = "sessionId", required = true) String sessionId,
            @ApiParam(name = "contentString", value = "内容明细串")
            @RequestParam(value = "contentString", required = false) String contentString) throws Exception {
        wxPushService.sendWXTemplate(userName, idCard, phone, title, url, content, topidId, sessionId, contentString);
        return success("success");
    }
}

+ 14 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientEndpoint.java

@ -8,10 +8,10 @@ import com.yihu.jw.care.aop.ServicesAuthAOP;
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
import com.yihu.jw.care.service.patient.CarePatientService;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
@ -40,6 +40,19 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
    ServicesAuthAOP servicesAuthAOP;
    public int num = 20;
    @GetMapping(value = "testException")
    @ApiOperation(value = "测试异常")
    public String testException(String type) throws Exception {
        if("1".equals(type)){
            throw new NullPointerException();
        }else if("2".equals(type)){
            throw new ApiException("111");
        }
        return "获取成功";
    }
    @RequestMapping(value = "testRedisLock")
    @RedisLock(key = "#patientDO.id")
    public Envelop testRedisLock(BasePatientDO patientDO) {

+ 2 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/wechat/WechatMenuController.java

@ -45,9 +45,8 @@ public class WechatMenuController extends EnvelopRestEndpoint {
    public String createMenuTest() {
        try {
            WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
            String filePath = "/usr/local/hospital/weixin_menu.txt";
//            String filePath = WechatCoreController.class.getResource("/").getPath() +
//                    File.separator + "wechat" + File.separator + "weixin_menu.txt";
            String filePath = WechatCoreController.class.getResource("/").getPath() +
                    File.separator + "wechat" + File.separator + "weixin_menu.txt";
            logger.info("filePath"+filePath);
            String url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + wxAccessTokenDO.getAccessToken();
            // 读取微信菜单配置文件

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

@ -0,0 +1,71 @@
package com.yihu.jw.care.service.consult;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/27
 * @Description:
 */
@Service
public class WxPushService {
    @Autowired
    private MessageUtil messageUtil;
    @Value("${wechat.id}")
    private String wxId;
    @Autowired
    private ConsultDao consultDao;
    @Autowired
    private BasePatientWechatDao basePatientWechatDao;
    /**
     * 发送微信模板
     */
    public void sendWXTemplate(String userName,String idCard, String phone,String title, String url,String content,
                               String topidId,String sessionId,String contentString){
        JSONObject json = new JSONObject();
        ConsultDo consult =  consultDao.findOne(topidId);
        if(consult == null) {
           return;
        }
        /**
         * 反馈处理结果通知
         【服务对象姓名】的上门辅导服务咨询有新的回复
         提交时间:【回复消息时间】
         提交内容:【IM消息内容】
         处理结果:已回复
         您可点击消息查看详情
         {{first.DATA}}
         提交时间:{{keyword1.DATA}}
         提交内容:{{keyword2.DATA}}
         处理结果:{{keyword3.DATA}}
         {{remark.DATA}}
         */
        String consultType = String.valueOf(consult.getType());
        String first = "key1,您好!您的咨询有新的回复";
        if(ImUtil.SESSION_TYPE_DOOR_COACH.equals(consultType)){
            first = userName +"的上门辅导服务咨询有新的回复";
        }
        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,"已回复");
    }
}

+ 9 - 8
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MessageUtil.java

@ -1,10 +1,8 @@
package com.yihu.jw.care.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
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.doorCoach.BaseDoorCoachOrderDO;
@ -13,10 +11,8 @@ import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringOrderDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.wechat.dao.WxAccessTokenDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import com.yihu.jw.wechat.service.WxAccessTokenService;
@ -27,7 +23,6 @@ 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.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
@ -77,10 +72,11 @@ public class MessageUtil {
     * @param url 跳转链接
     * @param remark
     * @param type  模板通知类型
     * @param josn 用于对跳转连接的修改,
     * @param json 用于对跳转连接的修改,
     * @param keywords
     */
    public void putTemplateWxMessage(String wechatId, String templateName, String scene, String openId, String first,String url, String remark, Integer type,JSONObject josn,String ...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);
@ -106,7 +102,7 @@ public class MessageUtil {
            if (StringUtils.isNoneBlank(remark)){
                newConfig.setRemark(remark);
            }
            newConfig = setTemPlateUrl(newConfig,type,openId,josn);
            newConfig = setTemPlateUrl(newConfig,type,openId,json);
            int keyLength = keywords.length;
            if (keyLength >= 1) {
               if(StringUtils.isNoneBlank(keywords[0])){
@ -158,6 +154,11 @@ public class MessageUtil {
            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=");

+ 1 - 1
svr/svr-cloud-care/src/main/resources/wechat/weixin_menu.txt

@ -3,7 +3,7 @@
   {
	  "name":"进入云照护",
	  "type":"view",
      "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx2c55f5b7b2f3cb56&redirect_uri=http%3A%2F%2Fhzijk.cityihealth.com%2Fmedical-care-patient%2Fhome%2Findex&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
      "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx2c55f5b7b2f3cb56&redirect_uri=https%3A%2F%2Fhzijk.cityihealth.com%2Fmedical-care-patient%2Fhome%2Findex&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
   }
]
}