Przeglądaj źródła

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

liubing 3 lat temu
rodzic
commit
3240de1da7

+ 7 - 4
business/sms-service/src/main/java/com/yihu/jw/sms/service/TXYSmsService.java

@ -120,8 +120,8 @@ public class TXYSmsService {
    /**
     *
     * @param mobile
     * @param str {"templateCode":"VerificationCode","templateParamArr":["param1","param2","param3"]}
     * @return
     * @param str {"templateCode":"974603","templateParamArr":["param1","param2","param3"]}
     * @return   模板id暂时写死
     */
    public String sendMessageJson(String mobile,String str){
@ -135,7 +135,8 @@ public class TXYSmsService {
            }catch (Exception e){
                return "error";
            }
            String templateId = redisTemplate.opsForValue().get(key + ":"+jsonObj.getString("templateCode"));
//            String templateId = redisTemplate.opsForValue().get(key + ":"+jsonObj.getString("templateCode"));
            String templateId = jsonObj.getString("templateCode");
            JSONArray templateParamArr = jsonObj.getJSONArray("templateParamArr");
            String[] templateParamSet1 = templateParamArr.toArray(new String[0]);
@ -156,7 +157,9 @@ public class TXYSmsService {
            req.setSignName(signName);
            req.setTemplateId(templateId);
            req.setTemplateParamSet(templateParamSet1);
            if(templateParamSet1.length>0){
                req.setTemplateParamSet(templateParamSet1);
            }
            SendSmsResponse resp = client.SendSms(req);
            JSONObject json = JSON.parseObject(SendSmsResponse.toJsonString(resp));

+ 158 - 8
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/ConsultTeamService.java

@ -34,6 +34,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -72,7 +73,7 @@ public class ConsultTeamService {
    @Autowired
    private PatientDoorCoachOrderService patientDoorCoachOrderService;
    @Autowired
    private TXYSmsService txySmsService;
    private MessageUtil messageUtil;
    private Logger logger= LoggerFactory.getLogger(ConsultTeamService.class);
@ -318,15 +319,10 @@ public class ConsultTeamService {
            //发送短信给调度员 您有一条新的上门辅导申请,请进入调度平台处理。
            BaseDoctorDO doctorDO = doctorDao.findById(tmp.get("code").toString());
            if (doctorDO.getMobile()!=null){
                JSONObject sendObj = new JSONObject();
                sendObj.put("templateCode","VerificationCode");
                JSONArray paramArr = new JSONArray();
                paramArr.add("123123123123");
                sendObj.put("templateParamArr",paramArr);
                try {
                    txySmsService.sendMessageJson(doctorDO.getMobile(),sendObj.toJSONString());
                    messageUtil.sendTXYSJson("974603",doctorDO.getMobile());
                }catch (Exception e){
                    logger.info("发送腾讯短信给调度员报错:{"+doctorDO.getMobile()+"},"+sendObj.toJSONString());
                    logger.info("发送腾讯短信给调度员报错:{"+doctorDO.getMobile()+"}");
                }
            }
@ -511,5 +507,159 @@ public class ConsultTeamService {
        return true;
    }
    public int finishConsult(String consult, String endOperator, int endType) throws Exception {
        ConsultTeamDo consultTeam = consultTeamDao.findByConsult(consult);
        ConsultDo cons = consultDao.findOne(consult);
        if (consultTeam.getStatus() == 1) {
            return -1;
        }
//        //新增续方咨询结束判断 (续方未审核时不可由医生或居民关闭)
//        if (consultTeam.getType() == 8) {
//            Prescription prescription = prescriptionDao.findByCode(consultTeam.getRelationCode());
//            if (prescription.getStatus() == 0) {
//                return -2;
//            }
//        }
        String endName = "";
        String endId = "";
        //结束咨询才发送推送给IM文字消息
        if (endType == 1) {
            BasePatientDO p = patientDao.findById(endOperator);
            endName = p.getName();
            endId = p.getId();
        } else {
            if (endOperator.equals("admin")) {
                endId = "system";
                endName = "咨询超时未回复,系统自动";
            } else {
                BaseDoctorDO d = doctorDao.findOne(endOperator);
                endId = d.getId();
                endName = d.getName();
            }
        }
        JSONObject obj = imUtill.endTopics(consultTeam.getPatient(), endId, endName, consultTeam.getConsult());
        if (obj == null) {
            throw new RuntimeException("IM消息结束异常!");
        }
        if (obj.getInteger("status") == -1) {
            throw new RuntimeException(String.valueOf(obj.get("message")));
        }
        //结束咨询才发送推送给IM文字消息
//        if (endType == 1) {
//            BasePatientDO p = patientDao.findOne(endOperator);
//            endName = p.getName();
//            if (consultTeam.getType() == 2 || consultTeam.getType() == 8) {
//                String openId = p.getOpenid();
//
//                WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_survey", "zxpj");
//                String first = templateConfig.getFirst();
//                first = first.replace("key1", (endName == null ? "" : endName));
//                String keyword1 = templateConfig.getKeyword1();
//
//                org.json.JSONObject json = new org.json.JSONObject();
//                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//                json.put("keyword1", keyword1);
//                json.put("keyword2", sdf.format(new Date()));
//                json.put("toUser", p.getCode());
//                json.put("represented", p.getCode());//被代理人
//                json.put("remark", "");
//                json.put("consult", consult);
//                if (consultTeam.getType() == 8) {
//                    first = first.replace("key2", "续方");
//                } else {
//                    first = first.replace("key2", "");
//                }
//                json.put("first", first);
//                if (StringUtils.isNotBlank(p.getOpenid())) {
//                    pushMsgTask.putWxMsg(accessTokenUtils.getAccessToken(), 17, openId, p.getName(), json);
//                } else {
//                    //发送代理人
//                    org.json.JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(p.getCode(), p.getOpenid());
//                    if (jsonArray != null && jsonArray.length() > 0) {
//                        for (int i = 0; i < jsonArray.length(); i++) {
//                            org.json.JSONObject j = jsonArray.getJSONObject(i);
//                            Patient member = (Patient) j.get("member");
//                            org.json.JSONObject data = json;
//                            data.remove("toUser");
//                            data.put("toUser", member.getCode());
//                            data.remove("first");
//                            data.put("first", weiXinOpenIdUtils.getTitleMes(p, j.getInt("relation"), p.getName()) + first);
//                            pushMsgTask.putWxMsg(accessTokenUtils.getAccessToken(), 17, member.getOpenid(), p.getName(), data);
//                        }
//                    }
//                }
//            }
//        } else {
//            if (consultTeam.getType() == 2 || consultTeam.getType() == 8) {
//                Patient p = patientDao.findByCode(consultTeam.getPatient());
//                String name = p.getName();
//                String openId = p.getOpenid();
//
//                WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_survey", "zxpj");
//
//                if (endOperator.equals("admin")) {
//                    templateConfig = templateConfigDao.findByScene("template_doctor_survey", "zxcspj");
//                }
//                String first = templateConfig.getFirst();
//                first = first.replace("key1", (name == null ? "" : name));
//                String keyword1 = templateConfig.getKeyword1();
//
//                org.json.JSONObject json = new org.json.JSONObject();
//                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//                json.put("keyword1", keyword1);
//                json.put("keyword2", sdf.format(new Date()));
//                json.put("toUser", p.getCode());
//                json.put("represented", p.getCode());//被代理人
//                json.put("remark", "");
//                json.put("consult", consult);
//
//                if (consultTeam.getType() == 8) {
//                    first += "续方";
//                    first = first.replace("key2", "续方");
//                } else {
//                    first = first.replace("key2", "");
//                }
//                /*if (endOperator.equals("admin")) {
//                    first += "咨询超时未回复,系统自动关闭,请及时对咨询医生进行评价。";
//                }else {
//                    first += "咨询已结束,请及时对咨询医生进行评价。";
//                }*/
//                json.put("first", first);
//                if (StringUtils.isNotBlank(p.getOpenid())) {
//                    pushMsgTask.putWxMsg(accessTokenUtils.getAccessToken(), 17, openId, p.getName(), json);
//                } else {
//                    //发送代理人
//                    org.json.JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(p.getCode(), p.getOpenid());
//                    if (jsonArray != null && jsonArray.length() > 0) {
//                        for (int i = 0; i < jsonArray.length(); i++) {
//                            org.json.JSONObject j = jsonArray.getJSONObject(i);
//                            Patient member = (Patient) j.get("member");
//                            org.json.JSONObject data = json;
//                            data.remove("toUser");
//                            data.put("toUser", member.getCode());
//                            data.remove("first");
//                            data.put("first", weiXinOpenIdUtils.getTitleMes(p, j.getInt("relation"), p.getName()) + first);
//                            pushMsgTask.putWxMsg(accessTokenUtils.getAccessToken(), 17, member.getOpenid(), p.getName(), data);
//                        }
//                    }
//                }
//
//            }
//        }
        consultTeam.setEndMsgId(obj.getString("id"));
        cons.setEndTime(new Date());
        consultTeam.setEndTime(new Date());
        consultTeam.setStatus(1);
        consultDao.save(cons);
        consultTeamDao.save(consultTeam);
        return 1;
    }
}

+ 18 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MessageUtil.java

@ -1,5 +1,7 @@
package com.yihu.jw.care.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
@ -11,6 +13,7 @@ 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.sms.service.TXYSmsService;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.wechat.dao.WxAccessTokenDao;
@ -58,6 +61,8 @@ public class MessageUtil {
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private TXYSmsService txySmsService;
    //发送微信模板消息
    private  String sendMessageUrl = "http://172.16.100.37:8090/hospitalPortal-sms/sms/sendMessage";
@ -148,6 +153,19 @@ public class MessageUtil {
        }
    }
    public String sendTXYSJson(String templateCode,String mobile,String ...params)throws Exception{
        JSONObject sendObj = new JSONObject();
        sendObj.put("templateCode",templateCode);
        if (params.length>0){
            JSONArray paramArr =JSONArray.parseArray(JSON.toJSONString(params));
            sendObj.put("templateParamArr",paramArr);
        }else {
            JSONArray paramArr =new JSONArray();
            sendObj.put("templateParamArr",paramArr);
        }
        return txySmsService.sendMessageJson(mobile,sendObj.toJSONString());
    }
    public WxTemplateConfigDO setTemPlateUrl(WxTemplateConfigDO wxTemplateConfigDO,Integer type,String openid,JSONObject json){
        String url =  "taian-wx/html/";
        if (json==null){